source: branches/feature-module-paygent/data/downloads/module/mdl_zero/zero_recv.php @ 15883

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