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

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