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

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