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

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