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

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