source: branches/dev/data/downloads/module/mdl_zero/recv.php @ 14826

Revision 14826, 15.2 KB checked in by kakinaka, 15 years ago (diff)
Line 
1<?php
2
3$objSiteSess = new SC_SiteSession();
4$objCartSess = new SC_CartSession();
5$objCampaignSess = new SC_CampaignSession();
6$objCustomer = new SC_Customer();
7
8$objSiteInfo = $objView->objSiteInfo;
9$arrInfo = $objSiteInfo->data;
10
11$log_path = DATA_PATH . "logs/zero.log";
12gfPrintLog("** zero start **", $log_path);
13
14$arrResult = $_GET;
15// GET¤ÎÆâÍƤòÁ´¤Æ¥í¥°Êݸ
16foreach($arrResult as $key => $val){
17    gfPrintLog( "\t" . $key . " => " . $val, $log_path);
18}
19
20$objQuery->begin();
21$order_id = lfDoComplete($objQuery, $arrResult);
22$objQuery->commit();
23
24// ´°Î»¥á¡¼¥ëÁ÷¿®
25if(sfIsInt($order_id)) {
26    sfSendOrderMail($order_id, '1');
27    print("OK");
28}else{
29    // ¥¨¥é¡¼¤Î¾ì¹ç¼õ¿®¥Ç¡¼¥¿¤òÁ÷¿®
30    gfPrintLog(" zero error " . $order_id, $log_path);
31    gfPrintLog($order_id, $log_path);
32   
33    ob_start();
34    print($order_id . "\n");
35    print_r($arrResult);
36   
37    $msg = ob_get_contents();
38    ob_end_clean();
39    mb_send_mail("kakinaka@lockon.co.jp", "¥¼¥í¥¯¥ì¥¸¥Ã¥È¥¨¥é¡¼:" . $arrResult['sendid'], $msg . "\n");
40    print("NG");
41}
42gfPrintLog("** zero end **", $log_path);
43//---------------------------------------------------------------------------------------------------------------------------------
44// ´°Î»½èÍý
45function lfDoComplete($objQuery, $arrResult) {
46    global $objCartSess;
47    global $objSiteSess;
48    $objCampaignSess = new SC_CampaignSession();
49    $objCustomer = new SC_Customer();
50    global $arrInfo;
51   
52    gfprintlog($objCustomer->isLoginSuccess(),DATA_PATH . "logs/zero.log");
53   
54    // sendid ¤ÎÃͤò¶èÀÚ¤ë
55    $arrSendid = preg_split("/\\".SEND_PARAM_DELIMITER."/", $arrResult["sendid"]);
56   
57    $uniqid = $arrSendid[0];          // order_temp_id
58    $money =  $arrResult["money"];    // payment_total
59
60    $arrCrilentIP = $objQuery->select("memo02, memo04", "dtb_payment", "payment_id = ? and del_flg = 0", array($arrSendid[1]));
61    //$client_id = $objQuery->getAll("SELECT memo04 FROM dtb_payment WHERE payment_id = ? and del_flg = 0", array($arrSendid[1]));
62   
63    // ²ÃÌÁŹ¥³¡¼¥É¤¬°ã¤¦¾ì¹ç¤Ë¤Ï¥¨¥é¡¼
64    if(count($arrResult)){
65        if(in_array($arrResult["clientip"], $arrCrilentIP)) return "111²ÃÌÁŹ¥³¡¼¥É¤¬°ã¤¤¤Þ¤¹¡£";
66    }else{
67        return "222²ÃÌÁŹ¥³¡¼¥É¤¬°ã¤¤¤Þ¤¹¡£";
68    }
69   
70    // °ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤ÎÆɹþ
71    $arrData = sfGetOrderTemp($uniqid);
72   
73    // °ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤«¤é¥Ç¡¼¥¿¤¬¼èÆÀ¤Ç¤­¤Ê¤±¤ì¤Ð¡¢¥¨¥é¡¼
74    if(count($arrData) <= 0) return "333¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Ë»ØÄꤷ¤¿ID¤Î¥Ç¡¼¥¿¤¬¤¢¤ê¤Þ¤»¤ó¡£";
75   
76    // ·èºÑ´°Î»ºÑ¤ß¤Ç¤¢¤ì¤Ð¥¨¥é¡¼
77    if($arrData["del_flg"] == 1) return "444»ØÄꤷ¤¿ID¤Î¥Ç¡¼¥¿¤Ï·èºÑ´°Î»ºÑ¤ß¤Ç¤¹¡£";
78   
79    // °ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤Î¤ª»Ùʧ¤¤¹ç·×¤È¡¢¥¼¥í¤«¤éÊ֤äƤ­¤¿¶â³Û¤È¤¬°ã¤¦¾ì¹ç¤Ï¥¨¥é¡¼
80    if($arrData["payment_total"] != $money) return "555¤ª»Ùʧ¤¤¶â³Û¤¬°ã¤¤¤Þ¤¹¡£";
81   
82    // ¥»¥Ã¥·¥ç¥ó¾ðÊó¤ÎÉüµ¢
83    $_SESSION = unserialize($arrData["session"]);
84
85    // ²ñ°÷¾ðÊóÅÐÏ¿½èÍý
86    if ($objCustomer->isLoginSuccess()) {
87        // ¿·¤ªÆϤ±Àè¤ÎÅÐÏ¿
88        lfSetNewAddr($uniqid, $objCustomer->getValue('customer_id'));
89        // ¹ØÆþ½¸·×¤ò¸ÜµÒ¥Æ¡¼¥Ö¥ë¤ËÈ¿±Ç
90        lfSetCustomerPurchase($objCustomer->getValue('customer_id'), $arrData, $objQuery);
91    } else {
92        //¹ØÆþ»þ¶¯À©²ñ°÷ÅÐÏ¿
93        switch(PURCHASE_CUSTOMER_REGIST) {
94        //̵¸ú
95        case '0':
96            // ¹ØÆþ»þ²ñ°÷ÅÐÏ¿
97            if($arrData['member_check'] == '1') {
98                // ²¾²ñ°÷ÅÐÏ¿
99                $customer_id = lfRegistPreCustomer($arrData, $arrInfo);
100                // ¹ØÆþ½¸·×¤ò¸ÜµÒ¥Æ¡¼¥Ö¥ë¤ËÈ¿±Ç
101                lfSetCustomerPurchase($customer_id, $arrData, $objQuery);
102            }
103            break;
104        //Í­¸ú
105        case '1':
106            // ²¾²ñ°÷ÅÐÏ¿
107            $customer_id = lfRegistPreCustomer($arrData, $arrInfo);
108            // ¹ØÆþ½¸·×¤ò¸ÜµÒ¥Æ¡¼¥Ö¥ë¤ËÈ¿±Ç
109            lfSetCustomerPurchase($customer_id, $arrData, $objQuery);
110            break;
111        }
112    }
113
114    // °ì»þ¥Æ¡¼¥Ö¥ë¤ò¼õÃí¥Æ¡¼¥Ö¥ë¤Ë³ÊǼ¤¹¤ë
115    $order_id = lfRegistOrder($objQuery, $arrData);
116    // ¥«¡¼¥È¾¦Éʤò¼õÃí¾ÜºÙ¥Æ¡¼¥Ö¥ë¤Ë³ÊǼ¤¹¤ë
117    lfRegistOrderDetail($objQuery, $order_id, $objCartSess);
118    // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Î¾ðÊó¤òºï½ü¤¹¤ë¡£
119    lfDeleteTempOrder($objQuery, $uniqid);
120    // ¥­¥ã¥ó¥Ú¡¼¥ó¤«¤é¤ÎÁ«°Ü¤Î¾ì¹çÅÐÏ¿¤¹¤ë¡£
121    if($objCampaignSess->getIsCampaign()) {
122        lfRegistCampaignOrder($objQuery, $objCampaignSess, $order_id);
123    }
124   
125    return $order_id;
126}
127
128// ²ñ°÷ÅÐÏ¿¡Ê²¾ÅÐÏ¿¡Ë
129function lfRegistPreCustomer($arrData, $arrInfo) {
130    // ¹ØÆþ»þ¤Î²ñ°÷ÅÐÏ¿
131    $sqlval['name01'] = $arrData['order_name01'];
132    $sqlval['name02'] = $arrData['order_name02'];
133    $sqlval['kana01'] = $arrData['order_kana01'];
134    $sqlval['kana02'] = $arrData['order_kana02'];
135    $sqlval['zip01'] = $arrData['order_zip01'];
136    $sqlval['zip02'] = $arrData['order_zip02'];
137    $sqlval['pref'] = $arrData['order_pref'];
138    $sqlval['addr01'] = $arrData['order_addr01'];
139    $sqlval['addr02'] = $arrData['order_addr02'];
140    $sqlval['email'] = $arrData['order_email'];
141    $sqlval['tel01'] = $arrData['order_tel01'];
142    $sqlval['tel02'] = $arrData['order_tel02'];
143    $sqlval['tel03'] = $arrData['order_tel03'];
144    $sqlval['fax01'] = $arrData['order_fax01'];
145    $sqlval['fax02'] = $arrData['order_fax02'];
146    $sqlval['fax03'] = $arrData['order_fax03'];
147    $sqlval['sex'] = $arrData['order_sex'];
148    $sqlval['password'] = $arrData['password'];
149    $sqlval['reminder'] = $arrData['reminder'];
150    $sqlval['reminder_answer'] = $arrData['reminder_answer'];
151   
152    // ¥á¥ë¥Þ¥¬ÇÛ¿®Íѥե饰¤ÎȽÄê
153    switch($arrData['mail_flag']) {
154    case '1':   // HTML¥á¡¼¥ë
155        $mail_flag = 4;
156        break;
157    case '2':   // TEXT¥á¡¼¥ë
158        $mail_flag = 5;
159        break;
160    case '3':   // ´õ˾¤Ê¤·
161        $mail_flag = 6;
162        break;
163    default:
164        $mail_flag = 6;
165        break;
166    }
167    // ¥á¥ë¥Þ¥¬¥Õ¥é¥°
168    $sqlval['mailmaga_flg'] = $mail_flag;
169       
170    // ²ñ°÷²¾ÅÐÏ¿
171    $sqlval['status'] = 1;
172    // URLȽÄêÍÑ¥­¡¼
173    $sqlval['secret_key'] = sfGetUniqRandomId("t");
174   
175    $objQuery = new SC_Query();
176    $sqlval['create_date'] = "now()";
177    $sqlval['update_date'] = "now()";
178    $objQuery->insert("dtb_customer", $sqlval);
179   
180    // ¸ÜµÒID¤Î¼èÆÀ
181    $arrRet = $objQuery->select("customer_id", "dtb_customer", "secret_key = ?", array($sqlval['secret_key']));
182    $customer_id = $arrRet[0]['customer_id'];
183   
184    //¡¡²¾ÅÐÏ¿´°Î»¥á¡¼¥ëÁ÷¿®
185    $objMailPage = new LC_Page();
186    $objMailPage->to_name01 = $arrData['order_name01'];
187    $objMailPage->to_name02 = $arrData['order_name02'];
188    $objMailPage->CONF = $arrInfo;
189    $objMailPage->uniqid = $sqlval['secret_key'];
190    $objMailView = new SC_SiteView();
191    $objMailView->assignobj($objMailPage);
192    $body = $objMailView->fetch("mail_templates/customer_mail.tpl");
193   
194    $objMail = new GC_SendMail();
195    $objMail->setItem(
196                        ''                                      //¡¡°¸Àè
197                        , sfMakeSubject("²ñ°÷ÅÐÏ¿¤Î¤´³Îǧ")     //¡¡¥µ¥Ö¥¸¥§¥¯¥È
198                        , $body                                 //¡¡ËÜʸ
199                        , $arrInfo['email03']                   //¡¡ÇÛÁ÷¸µ¥¢¥É¥ì¥¹
200                        , $arrInfo['shop_name']                 //¡¡ÇÛÁ÷¸µ¡¡Ì¾Á°
201                        , $arrInfo["email03"]                   //¡¡reply_to
202                        , $arrInfo["email04"]                   //¡¡return_path
203                        , $arrInfo["email04"]                   //  Errors_to
204                        , $arrInfo["email01"]                   //  Bcc
205                                                        );
206    // °¸Àè¤ÎÀßÄê
207    $name = $arrData['order_name01'] . $arrData['order_name02'] ." ÍÍ";
208    $objMail->setTo($arrData['order_email'], $name);           
209    $objMail->sendMail();
210   
211    return $customer_id;
212}
213
214// ¼õÃí¥Æ¡¼¥Ö¥ë¤ØÅÐÏ¿
215function lfRegistOrder($objQuery, $arrData) {
216    $objCampaignSess = new SC_CampaignSession();
217    $sqlval = $arrData;
218
219    // ¼õÃí¥Æ¡¼¥Ö¥ë¤Ë½ñ¤­¹þ¤Þ¤Ê¤¤Îó¤ò½üµî
220    unset($sqlval['mailmaga_flg']);     // ¥á¥ë¥Þ¥¬¥Á¥§¥Ã¥¯
221    unset($sqlval['deliv_check']);      // Ê̤ΤªÆϤ±Àè¥Á¥§¥Ã¥¯
222    unset($sqlval['point_check']);      // ¥Ý¥¤¥ó¥ÈÍøÍÑ¥Á¥§¥Ã¥¯
223    unset($sqlval['member_check']);     // ¹ØÆþ»þ²ñ°÷¥Á¥§¥Ã¥¯
224    unset($sqlval['password']);         // ¥í¥°¥¤¥ó¥Ñ¥¹¥ï¡¼¥É
225    unset($sqlval['reminder']);         // ¥ê¥Þ¥¤¥ó¥À¡¼¼ÁÌä
226    unset($sqlval['reminder_answer']);  // ¥ê¥Þ¥¤¥ó¥À¡¼Åú¤¨
227    unset($sqlval['mail_flag']);        // ¥á¡¼¥ë¥Õ¥é¥°
228    unset($sqlval['session']);          // ¥»¥Ã¥·¥ç¥ó¾ðÊó
229   
230    // Ãíʸ¥¹¥Æ¡¼¥¿¥¹:»ØÄ̵꤬¤±¤ì¤Ð¿·µ¬¼õÉÕ¤ËÀßÄê
231    if($sqlval["status"] == ""){
232        $sqlval['status'] = '1';           
233    }
234   
235    // Ê̤ΤªÆϤ±Àè¤ò»ØÄꤷ¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢ÇÛÁ÷Àè¤ËÅÐÏ¿½»½ê¤ò¥³¥Ô¡¼¤¹¤ë¡£
236    if($arrData["deliv_check"] == "-1") {
237        $sqlval['deliv_name01'] = $arrData['order_name01'];
238        $sqlval['deliv_name02'] = $arrData['order_name02'];
239        $sqlval['deliv_kana01'] = $arrData['order_kana01'];
240        $sqlval['deliv_kana02'] = $arrData['order_kana02'];
241        $sqlval['deliv_pref'] = $arrData['order_pref'];
242        $sqlval['deliv_zip01'] = $arrData['order_zip01'];
243        $sqlval['deliv_zip02'] = $arrData['order_zip02'];
244        $sqlval['deliv_addr01'] = $arrData['order_addr01'];
245        $sqlval['deliv_addr02'] = $arrData['order_addr02'];
246        $sqlval['deliv_tel01'] = $arrData['order_tel01'];
247        $sqlval['deliv_tel02'] = $arrData['order_tel02'];
248        $sqlval['deliv_tel03'] = $arrData['order_tel03'];
249    }
250   
251    $order_id = $arrData['order_id'];       // ¥ª¡¼¥À¡¼ID
252    $sqlval['create_date'] = 'now()';       // ¼õÃíÆü
253   
254    // ¥­¥ã¥ó¥Ú¡¼¥óID
255    if($objCampaignSess->getIsCampaign()) $sqlval['campaign_id'] = $objCampaignSess->getCampaignId();
256
257    // ¥²¥Ã¥È¤ÎÃͤò¥¤¥ó¥µ¡¼¥È
258    //$sqlval = lfGetInsParam($sqlval);
259   
260    // INSERT¤Î¼Â¹Ô
261    $objQuery->insert("dtb_order", $sqlval);
262   
263    return $order_id;
264}
265
266// ¼õÃí¾ÜºÙ¥Æ¡¼¥Ö¥ë¤ØÅÐÏ¿
267function lfRegistOrderDetail($objQuery, $order_id) {
268    $objCartSess = new SC_CartSession();
269   
270    // ¥«¡¼¥ÈÆâ¾ðÊó¤Î¼èÆÀ
271    $arrCart = $objCartSess->getCartList();
272    $max = count($arrCart);
273   
274    // ´û¤Ë¸ºß¤¹¤ë¾ÜºÙ¥ì¥³¡¼¥É¤ò¾Ã¤·¤Æ¤ª¤¯¡£
275    $objQuery->delete("dtb_order_detail", "order_id = $order_id");
276
277    // µ¬³Ê̾°ìÍ÷
278    $arrClassName = sfGetIDValueList("dtb_class", "class_id", "name");
279    // µ¬³ÊʬÎà̾°ìÍ÷
280    $arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
281           
282    for ($i = 0; $i < $max; $i++) {
283        // ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ   
284        $arrData = sfGetProductsClass($arrCart[$i]['id']);
285       
286        // ¸ºß¤¹¤ë¾¦ÉʤΤßɽ¼¨¤¹¤ë¡£
287        if($arrData != "") {
288            $sqlval['order_id'] = $order_id;
289            $sqlval['product_id'] = $arrCart[$i]['id'][0];
290            $sqlval['classcategory_id1'] = $arrCart[$i]['id'][1];
291            $sqlval['classcategory_id2'] = $arrCart[$i]['id'][2];
292            $sqlval['product_name'] = $arrData['name'];
293            $sqlval['product_code'] = $arrData['product_code'];
294            $sqlval['classcategory_name1'] = $arrClassCatName[$arrData['classcategory_id1']];
295            $sqlval['classcategory_name2'] = $arrClassCatName[$arrData['classcategory_id2']];
296            $sqlval['point_rate'] = $arrCart[$i]['point_rate'];         
297            $sqlval['price'] = $arrCart[$i]['price'];
298            $sqlval['quantity'] = $arrCart[$i]['quantity'];
299            lfReduceStock($objQuery, $arrCart[$i]['id'], $arrCart[$i]['quantity']);
300            // INSERT¤Î¼Â¹Ô
301            $objQuery->insert("dtb_order_detail", $sqlval);
302        } else {
303            sfDispSiteError(CART_NOT_FOUND);
304        }
305    }
306}
307
308// ¥­¥ã¥ó¥Ú¡¼¥ó¼õÃí¥Æ¡¼¥Ö¥ë¤ØÅÐÏ¿
309function lfRegistCampaignOrder($objQuery, $objCampaignSess, $order_id) {
310
311    // ¼õÃí¥Ç¡¼¥¿¤ò¼èÆÀ
312    $cols = "order_id, campaign_id, customer_id, message, order_name01, order_name02,".
313            "order_kana01, order_kana02, order_email, order_tel01, order_tel02, order_tel03,".
314            "order_fax01, order_fax02, order_fax03, order_zip01, order_zip02, order_pref, order_addr01,".
315            "order_addr02, order_sex, order_birth, order_job, deliv_name01, deliv_name02, deliv_kana01,".
316            "deliv_kana02, deliv_tel01, deliv_tel02, deliv_tel03, deliv_fax01, deliv_fax02, deliv_fax03,".
317            "deliv_zip01, deliv_zip02, deliv_pref, deliv_addr01, deliv_addr02, payment_total";
318
319    $arrOrder = $objQuery->select($cols, "dtb_order", "order_id = ?", array($order_id));
320           
321    $sqlval = $arrOrder[0];
322    $sqlval['create_date'] = 'now()';
323       
324    // INSERT¤Î¼Â¹Ô
325    $objQuery->insert("dtb_campaign_order", $sqlval);
326   
327    // ¿½¤·¹þ¤ß¿ô¤Î¹¹¿·
328    $total_count = $objQuery->get("dtb_campaign", "total_count", "campaign_id = ?", array($sqlval['campaign_id']));
329    $arrCampaign['total_count'] = $total_count += 1;
330    $objQuery->update("dtb_campaign", $arrCampaign, "campaign_id = ?", array($sqlval['campaign_id']));
331   
332}
333
334/* ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Îºï½ü */
335function lfDeleteTempOrder($objQuery, $uniqid) {
336    $where = "order_temp_id = ?";
337    $sqlval['del_flg'] = 1;
338    $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid));
339    // $objQuery->delete("dtb_order_temp", $where, array($uniqid));
340}
341
342// ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Î½»½ê¤¬ÅÐÏ¿ºÑ¤ß¥Æ¡¼¥Ö¥ë¤È°Û¤Ê¤ë¾ì¹ç¤Ï¡¢Ê̤ΤªÆϤ±Àè¤ËÄɲ乤ë
343function lfSetNewAddr($uniqid, $customer_id) {
344    $objQuery = new SC_Query();
345    $diff = false;
346    $find_same = false;
347   
348    $col = "deliv_name01,deliv_name02,deliv_kana01,deliv_kana02,deliv_tel01,deliv_tel02,deliv_tel03,deliv_zip01,deliv_zip02,deliv_pref,deliv_addr01,deliv_addr02";
349    $where = "order_temp_id = ?";
350    $arrRet = $objQuery->select($col, "dtb_order_temp", $where, array($uniqid));
351   
352    // Í×ÁÇ̾¤Îdeliv_¤òºï½ü¤¹¤ë¡£
353    foreach($arrRet[0] as $key => $val) {
354        $keyname = ereg_replace("^deliv_", "", $key);
355        $arrNew[$keyname] = $val;
356    }
357   
358    // ²ñ°÷¾ðÊó¥Æ¡¼¥Ö¥ë¤È¤ÎÈæ³Ó
359    $col = "name01,name02,kana01,kana02,tel01,tel02,tel03,zip01,zip02,pref,addr01,addr02";
360    $where = "customer_id = ?";
361    $arrCustomerAddr = $objQuery->select($col, "dtb_customer", $where, array($customer_id));
362   
363    // ²ñ°÷¾ðÊó¤Î½»½ê¤È°Û¤Ê¤ë¾ì¹ç
364    if($arrNew != $arrCustomerAddr[0]) {
365        // Ê̤ΤªÆϤ±Àè¥Æ¡¼¥Ö¥ë¤Î½»½ê¤ÈÈæ³Ó¤¹¤ë
366        $col = "name01,name02,kana01,kana02,tel01,tel02,tel03,zip01,zip02,pref,addr01,addr02";
367        $where = "customer_id = ?";
368        $arrOtherAddr = $objQuery->select($col, "dtb_other_deliv", $where, array($customer_id));
369
370        foreach($arrOtherAddr as $arrval) {
371            if($arrNew == $arrval) {
372                // ¤¹¤Ç¤ËƱ¤¸½»½ê¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë
373                $find_same = true;
374            }
375        }
376       
377        if(!$find_same) {
378            $diff = true;
379        }
380    }
381   
382    // ¿·¤·¤¤¤ªÆϤ±À褬ÅÐÏ¿ºÑ¤ß¤Î¤â¤Î¤È°Û¤Ê¤ë¾ì¹ç¤ÏÊ̤ΤªÆϤ±Àè¥Æ¡¼¥Ö¥ë¤ËÅÐÏ¿¤¹¤ë
383    if($diff) {
384        $sqlval = $arrNew;
385        $sqlval['customer_id'] = $customer_id;
386        $objQuery->insert("dtb_other_deliv", $sqlval);
387    }
388}
389
390/* ¹ØÆþ¾ðÊó¤ò²ñ°÷¥Æ¡¼¥Ö¥ë¤ËÅÐÏ¿¤¹¤ë */
391function lfSetCustomerPurchase($customer_id, $arrData, $objQuery) {
392    $col = "first_buy_date, last_buy_date, buy_times, buy_total, point";
393    $where = "customer_id = ?";
394    $arrRet = $objQuery->select($col, "dtb_customer", $where, array($customer_id));
395    $sqlval = $arrRet[0];
396   
397    if($sqlval['first_buy_date'] == "") {
398        $sqlval['first_buy_date'] = "Now()";
399    }
400    $sqlval['last_buy_date'] = "Now()";
401    $sqlval['buy_times']++;
402    $sqlval['buy_total']+= $arrData['total'];
403    $sqlval['point'] = ($sqlval['point'] + $arrData['add_point'] - $arrData['use_point']);
404   
405    // ¥Ý¥¤¥ó¥È¤¬ÉÔ­¤·¤Æ¤¤¤ë¾ì¹ç
406    if($sqlval['point'] < 0) {
407        $objQuery->rollback();
408        sfDispSiteError(LACK_POINT);
409    }
410   
411    $objQuery->update("dtb_customer", $sqlval, $where, array($customer_id));
412}
413
414// ºß¸Ë¤ò¸º¤é¤¹½èÍý
415function lfReduceStock($objQuery, $arrID, $quantity) {
416    $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?";
417    $arrRet = $objQuery->select("stock, stock_unlimited", "dtb_products_class", $where, $arrID);
418   
419    // Çä¤êÀڤ쥨¥é¡¼
420    if(($arrRet[0]['stock_unlimited'] != '1' && $arrRet[0]['stock'] < $quantity) || $quantity == 0) {
421        $objQuery->rollback();
422        sfDispSiteError(SOLD_OUT, "", true);
423    // ̵À©¸Â¤Î¾ì¹ç¡¢ºß¸Ë¤ÏNULL
424    } elseif($arrRet[0]['stock_unlimited'] == '1') {
425        $sqlval['stock'] = null;
426        $objQuery->update("dtb_products_class", $sqlval, $where, $arrID);
427    // ºß¸Ë¤ò¸º¤é¤¹
428    } else {
429        $sqlval['stock'] = ($arrRet[0]['stock'] - $quantity);
430        if($sqlval['stock'] == "") {
431            $sqlval['stock'] = '0';
432        }       
433        $objQuery->update("dtb_products_class", $sqlval, $where, $arrID);
434    }
435}
436
437// GET¤ÎÃͤò¥¤¥ó¥µ¡¼¥ÈÍѤËÀ°¤¨¤ë
438function lfGetInsParam($sqlVal){
439   
440    foreach($_GET as $key => $val){
441        // ¥«¥é¥à¤Î¸ºß¥Á¥§¥Ã¥¯
442        if(sfColumnExists("dtb_order", $key)) $sqlVal[$key] = $val;
443    }
444   
445    return $sqlVal;
446}
447?>
Note: See TracBrowser for help on using the repository browser.