source: branches/dev/html/mobile/nonmember/complete.php @ 12263

Revision 12263, 16.0 KB checked in by nakanishi, 15 years ago (diff)
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
317    // Ãíʸ¥¹¥Æ¡¼¥¿¥¹:»ØÄ̵꤬¤±¤ì¤Ð¿·µ¬¼õÉÕ¤ËÀßÄê
318    if($sqlval["status"] == ""){
319        $sqlval['status'] = '1';           
320    }
321   
322    // Ê̤ΤªÆϤ±Àè¤ò»ØÄꤷ¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢ÇÛÁ÷Àè¤ËÅÐÏ¿½»½ê¤ò¥³¥Ô¡¼¤¹¤ë¡£
323    if($arrData["deliv_check"] != "1") {
324        $sqlval['deliv_name01'] = $arrData['order_name01'];
325        $sqlval['deliv_name02'] = $arrData['order_name02'];
326        $sqlval['deliv_kana01'] = $arrData['order_kana01'];
327        $sqlval['deliv_kana02'] = $arrData['order_kana02'];
328        $sqlval['deliv_pref'] = $arrData['order_pref'];
329        $sqlval['deliv_zip01'] = $arrData['order_zip01'];
330        $sqlval['deliv_zip02'] = $arrData['order_zip02'];
331        $sqlval['deliv_addr01'] = $arrData['order_addr01'];
332        $sqlval['deliv_addr02'] = $arrData['order_addr02'];
333        $sqlval['deliv_tel01'] = $arrData['order_tel01'];
334        $sqlval['deliv_tel02'] = $arrData['order_tel02'];
335        $sqlval['deliv_tel03'] = $arrData['order_tel03'];
336    }
337   
338    $order_id = $arrData['order_id'];       // ¥ª¡¼¥À¡¼ID
339    $sqlval['create_date'] = 'now()';       // ¼õÃíÆü
340   
341    // ¥²¥Ã¥È¤ÎÃͤò¥¤¥ó¥µ¡¼¥È
342    //$sqlval = lfGetInsParam($sqlval);
343   
344    // INSERT¤Î¼Â¹Ô
345    $objQuery->insert("dtb_order", $sqlval);
346
347    return $order_id;
348}
349
350// ¼õÃí¾ÜºÙ¥Æ¡¼¥Ö¥ë¤ØÅÐÏ¿
351function lfRegistOrderDetail($objQuery, $order_id, $objCartSess) {
352    // ¥«¡¼¥ÈÆâ¾ðÊó¤Î¼èÆÀ
353    $arrCart = $objCartSess->getCartList();
354    $max = count($arrCart);
355   
356    // ´û¤Ë¸ºß¤¹¤ë¾ÜºÙ¥ì¥³¡¼¥É¤ò¾Ã¤·¤Æ¤ª¤¯¡£
357    $objQuery->delete("dtb_order_detail", "order_id = $order_id");
358
359    // µ¬³Ê̾°ìÍ÷
360    $arrClassName = sfGetIDValueList("dtb_class", "class_id", "name");
361    // µ¬³ÊʬÎà̾°ìÍ÷
362    $arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
363           
364    for ($i = 0; $i < $max; $i++) {
365        // ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ   
366        $arrData = sfGetProductsClass($arrCart[$i]['id']);
367       
368        // ¸ºß¤¹¤ë¾¦ÉʤΤßɽ¼¨¤¹¤ë¡£
369        if($arrData != "") {
370            $sqlval['order_id'] = $order_id;
371            $sqlval['product_id'] = $arrCart[$i]['id'][0];
372            $sqlval['classcategory_id1'] = $arrCart[$i]['id'][1];
373            $sqlval['classcategory_id2'] = $arrCart[$i]['id'][2];
374            $sqlval['product_name'] = $arrData['name'];
375            $sqlval['product_code'] = $arrData['product_code'];
376            $sqlval['classcategory_name1'] = $arrClassCatName[$arrData['classcategory_id1']];
377            $sqlval['classcategory_name2'] = $arrClassCatName[$arrData['classcategory_id2']];
378            $sqlval['point_rate'] = $arrCart[$i]['point_rate'];         
379            $sqlval['price'] = $arrCart[$i]['price'];
380            $sqlval['quantity'] = $arrCart[$i]['quantity'];
381            lfReduceStock($objQuery, $arrCart[$i]['id'], $arrCart[$i]['quantity']);
382            // INSERT¤Î¼Â¹Ô
383            $objQuery->insert("dtb_order_detail", $sqlval);
384        } else {
385            sfDispSiteError(CART_NOT_FOUND, "", false, "", true);
386        }
387    }
388}
389
390/* ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Îºï½ü */
391function lfDeleteTempOrder($objQuery, $uniqid) {
392    $where = "order_temp_id = ?";
393    $sqlval['del_flg'] = 1;
394    $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid));
395    // $objQuery->delete("dtb_order_temp", $where, array($uniqid));
396}
397
398// ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Î½»½ê¤¬ÅÐÏ¿ºÑ¤ß¥Æ¡¼¥Ö¥ë¤È°Û¤Ê¤ë¾ì¹ç¤Ï¡¢Ê̤ΤªÆϤ±Àè¤ËÄɲ乤ë
399function lfSetNewAddr($uniqid, $customer_id) {
400    $objQuery = new SC_Query();
401    $diff = false;
402    $find_same = false;
403   
404    $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";
405    $where = "order_temp_id = ?";
406    $arrRet = $objQuery->select($col, "dtb_order_temp", $where, array($uniqid));
407   
408    // Í×ÁÇ̾¤Îdeliv_¤òºï½ü¤¹¤ë¡£
409    foreach($arrRet[0] as $key => $val) {
410        $keyname = ereg_replace("^deliv_", "", $key);
411        $arrNew[$keyname] = $val;
412    }
413   
414    // ²ñ°÷¾ðÊó¥Æ¡¼¥Ö¥ë¤È¤ÎÈæ³Ó
415    $col = "name01,name02,kana01,kana02,tel01,tel02,tel03,zip01,zip02,pref,addr01,addr02";
416    $where = "customer_id = ?";
417    $arrCustomerAddr = $objQuery->select($col, "dtb_customer", $where, array($customer_id));
418   
419    // ²ñ°÷¾ðÊó¤Î½»½ê¤È°Û¤Ê¤ë¾ì¹ç
420    if($arrNew != $arrCustomerAddr[0]) {
421        // Ê̤ΤªÆϤ±Àè¥Æ¡¼¥Ö¥ë¤Î½»½ê¤ÈÈæ³Ó¤¹¤ë
422        $col = "name01,name02,kana01,kana02,tel01,tel02,tel03,zip01,zip02,pref,addr01,addr02";
423        $where = "customer_id = ?";
424        $arrOtherAddr = $objQuery->select($col, "dtb_other_deliv", $where, array($customer_id));
425
426        foreach($arrOtherAddr as $arrval) {
427            if($arrNew == $arrval) {
428                // ¤¹¤Ç¤ËƱ¤¸½»½ê¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë
429                $find_same = true;
430            }
431        }
432       
433        if(!$find_same) {
434            $diff = true;
435        }
436    }
437   
438    // ¿·¤·¤¤¤ªÆϤ±À褬ÅÐÏ¿ºÑ¤ß¤Î¤â¤Î¤È°Û¤Ê¤ë¾ì¹ç¤ÏÊ̤ΤªÆϤ±Àè¥Æ¡¼¥Ö¥ë¤ËÅÐÏ¿¤¹¤ë
439    if($diff) {
440        $sqlval = $arrNew;
441        $sqlval['customer_id'] = $customer_id;
442        $objQuery->insert("dtb_other_deliv", $sqlval);
443    }
444}
445
446/* ¹ØÆþ¾ðÊó¤ò²ñ°÷¥Æ¡¼¥Ö¥ë¤ËÅÐÏ¿¤¹¤ë */
447function lfSetCustomerPurchase($customer_id, $arrData, $objQuery) {
448    $col = "first_buy_date, last_buy_date, buy_times, buy_total, point";
449    $where = "customer_id = ?";
450    $arrRet = $objQuery->select($col, "dtb_customer", $where, array($customer_id));
451    $sqlval = $arrRet[0];
452   
453    if($sqlval['first_buy_date'] == "") {
454        $sqlval['first_buy_date'] = "Now()";
455    }
456    $sqlval['last_buy_date'] = "Now()";
457    $sqlval['buy_times']++;
458    $sqlval['buy_total']+= $arrData['total'];
459    $sqlval['point'] = ($sqlval['point'] + $arrData['add_point'] - $arrData['use_point']);
460   
461    // ¥Ý¥¤¥ó¥È¤¬ÉÔ­¤·¤Æ¤¤¤ë¾ì¹ç
462    if($sqlval['point'] < 0) {
463        $objQuery->rollback();
464        sfDispSiteError(LACK_POINT);
465    }
466   
467    $objQuery->update("dtb_customer", $sqlval, $where, array($customer_id));
468}
469
470// ºß¸Ë¤ò¸º¤é¤¹½èÍý
471function lfReduceStock($objQuery, $arrID, $quantity) {
472    $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?";
473    $arrRet = $objQuery->select("stock, stock_unlimited", "dtb_products_class", $where, $arrID);
474   
475    // Çä¤êÀڤ쥨¥é¡¼
476    if(($arrRet[0]['stock_unlimited'] != '1' && $arrRet[0]['stock'] < $quantity) || $quantity == 0) {
477        $objQuery->rollback();
478        sfDispSiteError(SOLD_OUT, "", true);
479    // ̵À©¸Â¤Î¾ì¹ç¡¢ºß¸Ë¤ÏNULL
480    } elseif($arrRet[0]['stock_unlimited'] == '1') {
481        $sqlval['stock'] = null;
482        $objQuery->update("dtb_products_class", $sqlval, $where, $arrID);
483    // ºß¸Ë¤ò¸º¤é¤¹
484    } else {
485        $sqlval['stock'] = ($arrRet[0]['stock'] - $quantity);
486        if($sqlval['stock'] == "") {
487            $sqlval['stock'] = '0';
488        }       
489        $objQuery->update("dtb_products_class", $sqlval, $where, $arrID);
490    }
491}
492
493// GET¤ÎÃͤò¥¤¥ó¥µ¡¼¥ÈÍѤËÀ°¤¨¤ë
494function lfGetInsParam($sqlVal){
495   
496    foreach($_GET as $key => $val){
497        // ¥«¥é¥à¤Î¸ºß¥Á¥§¥Ã¥¯
498        if(sfColumnExists("dtb_order", $key)) $sqlVal[$key] = $val;
499    }
500   
501    return $sqlVal;
502}
503
504?>
Note: See TracBrowser for help on using the repository browser.