source: branches/beta/html/mobile/shopping/complete.php @ 16665

Revision 16665, 16.1 KB checked in by naka, 15 years ago (diff)

sfConnectMovilinkURL()の未定義回避

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