source: branches/rel/html/mobile/shopping/complete.php @ 14898

Revision 14898, 16.1 KB checked in by kakinaka, 15 years ago (diff)

dtb_order_temp に セッション情報を保持するように修正

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