source: temp/branches/mobile/html/mobile/shopping/complete.php @ 11409

Revision 11409, 16.2 KB checked in by rebelt, 16 years ago (diff)

以下のモバイルサイト用ページ・機能を作成いたしました。

  • 会員登録
  • 注文
  • イプシロン決済
  • Property svn:eol-style set to native
Line 
1<?php
2/*
3 * Copyright(c) 2000-2006 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7
8require_once("../require.php");
9
10class LC_Page {
11    function LC_Page() {
12        $this->tpl_mainpage = 'shopping/complete.tpl';
13        $this->tpl_css = '/css/layout/shopping/complete.css';
14        $this->tpl_title = "¤´Ãíʸ´°Î»";
15        global $arrCONVENIENCE;
16        $this->arrCONVENIENCE = $arrCONVENIENCE;
17        global $arrCONVENIMESSAGE;
18        $this->arrCONVENIMESSAGE = $arrCONVENIMESSAGE;
19        global $arrCONVENIENCE;
20        global $arrCONVENIMESSAGE;
21        $objPage->arrCONVENIENCE = $arrCONVENIENCE;
22        $objPage->arrCONVENIMESSAGE = $arrCONVENIMESSAGE;
23        /*
24         session_start»þ¤Îno-cache¥Ø¥Ã¥À¡¼¤òÍÞÀ©¤¹¤ë¤³¤È¤Ç
25         ¡ÖÌá¤ë¡×¥Ü¥¿¥ó»ÈÍÑ»þ¤ÎÍ­¸ú´ü¸ÂÀÚ¤ìɽ¼¨¤òÍÞÀ©¤¹¤ë¡£
26         private-no-expire:¥¯¥é¥¤¥¢¥ó¥È¤Î¥­¥ã¥Ã¥·¥å¤òµö²Ä¤¹¤ë¡£
27        */
28        session_cache_limiter('private-no-expire');     
29
30    }
31}
32
33$conn = new SC_DBConn();
34$objPage = new LC_Page();
35$objView = new SC_SiteView();
36$objSiteSess = new SC_SiteSession();
37$objCartSess = new SC_CartSession();
38$objSiteInfo = $objView->objSiteInfo;
39$arrInfo = $objSiteInfo->data;
40$objCustomer = new SC_Customer();
41
42// Á°¤Î¥Ú¡¼¥¸¤ÇÀµ¤·¤¯ÅÐÏ¿¼ê³¤­¤¬¹Ô¤ï¤ì¤¿¤«È½Äê
43sfIsPrePage($objSiteSess);
44// ¥æ¡¼¥¶¥æ¥Ë¡¼¥¯ID¤Î¼èÆÀ¤È¹ØÆþ¾õÂÖ¤ÎÀµÅöÀ­¤ò¥Á¥§¥Ã¥¯
45$uniqid = sfCheckNormalAccess($objSiteSess, $objCartSess);
46if ($uniqid != "") {
47   
48    // ´°Î»½èÍý
49    $objQuery = new SC_Query();
50    $objQuery->begin();
51    $order_id = lfDoComplete($objQuery, $uniqid);
52    $objQuery->commit();
53   
54    // ¥»¥Ã¥·¥ç¥ó¤ËÊݴɤµ¤ì¤Æ¤¤¤ë¾ðÊó¤ò¹¹¿·¤¹¤ë
55    $objCustomer->updateSession();
56
57    // ´°Î»¥á¡¼¥ëÁ÷¿®
58    if($order_id != "") {
59        sfSendOrderMail($order_id, '1');
60    }
61
62    //¤½¤Î¾¾ðÊó¤Î¼èÆÀ
63    $other_data = $objQuery->get("dtb_order", "memo02", "order_id = ? ", array($order_id));
64    if($other_data != "") {
65        $arrOther = unserialize($other_data);
66       
67        // ¥Ç¡¼¥¿¤òÊÔ½¸
68        foreach($arrOther as $key => $val){
69            // URL¤Î¾ì¹ç¤Ë¤Ï¥ê¥ó¥¯¤Ä¤­¤Çɽ¼¨¤µ¤»¤ë
70            if (preg_match('/^(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/', $val["value"])) {
71                $arrOther[$key]["value"] = "<a href='#' onClick=\"window.open('". $val["value"] . "'); \" >" . $val["value"] ."</a>";
72            }
73        }
74               
75        $objPage->arrOther = $arrOther;
76       
77    }
78   
79    // ¥¢¥Õ¥£¥ê¥¨¥¤¥ÈÍÑ¥³¥ó¥Ð¡¼¥¸¥ç¥ó¥¿¥°¤ÎÀßÄê
80    $objPage->tpl_conv_page = AFF_SHOPPING_COMPLETE;
81    $objPage->tpl_aff_option = "order_id=$order_id";
82    //¹ç·×²Á³Ê¤Î¼èÆÀ
83    $total = $objQuery->get("dtb_order", "total", "order_id = ? ", array($order_id));
84    if($total != "") {
85        $objPage->tpl_aff_option.= "|total=$total";
86    }
87}
88
89$objPage->arrInfo = $arrInfo;
90
91$objView->assignobj($objPage);
92$objView->display(SITE_FRAME);
93//--------------------------------------------------------------------------------------------------------------------------
94// ¥¨¥Ó¥¹¥¿¥°°úÅϤ·Íѥǡ¼¥¿¤òÀ¸À®¤¹¤ë
95function lfGetEbisData($order_id) {
96    $objQuery = new SC_Query();
97    $col = "customer_id, total, order_sex, order_job, to_number(to_char(age(current_timestamp, order_birth), 'YYY'), 999) AS order_age";
98    $arrRet = $objQuery->select($col, "dtb_order", "order_id = ?", array($order_id));
99   
100    if($arrRet[0]['customer_id'] > 0) {
101        // ²ñ°÷ÈÖ¹æ
102        $arrEbis['m1id'] = $arrRet[0]['customer_id'];
103        // Èó²ñ°÷or²ñ°÷
104        $arrEbis['o5id'] = '1';
105    } else {
106        // ²ñ°÷ÈÖ¹æ
107        $arrEbis['m1id'] = '';
108        // Èó²ñ°÷or²ñ°÷
109        $arrEbis['o5id'] = '2';
110    }
111   
112    // ¹ØÆþ¶â³Û
113    $arrEbis['a1id'] = $arrRet[0]['total'];
114    // À­ÊÌ
115    $arrEbis['o2id'] = $arrRet[0]['order_sex'];
116    // ǯÎð
117    $arrEbis['o3id'] = $arrRet[0]['order_age'];
118    // ¿¦¶È
119    $arrEbis['o4id'] = $arrRet[0]['order_job'];
120       
121    $objQuery->setgroupby("product_id");
122    $arrRet = $objQuery->select("product_id", "dtb_order_detail", "order_id = ?", array($order_id));
123    $arrProducts = sfSwapArray($arrRet);
124   
125    $line = "";
126    // ¾¦ÉÊID¤ò¥¢¥ó¥À¡¼¥Ð¡¼¤ÇÀܳ¤¹¤ë¡£
127    foreach($arrProducts['product_id'] as $val) {
128        if($line != "") {
129            $line .= "_$val";       
130        } else {
131            $line .= "$val";
132        }
133    }
134   
135    // ¾¦ÉÊID   
136    $arrEbis['o1id'] = $line;
137   
138    return $arrEbis;
139}
140
141// ´°Î»½èÍý
142function lfDoComplete($objQuery, $uniqid) {
143    global $objCartSess;
144    global $objSiteSess;
145    global $objCustomer;
146    global $arrInfo;
147   
148    // °ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤ÎÆɹþ
149    $arrData = sfGetOrderTemp($uniqid);
150   
151    // ²ñ°÷¾ðÊóÅÐÏ¿½èÍý
152    if ($objCustomer->isLoginSuccess()) {
153        // ¿·¤ªÆϤ±Àè¤ÎÅÐÏ¿
154        lfSetNewAddr($uniqid, $objCustomer->getValue('customer_id'));
155        // ¹ØÆþ½¸·×¤ò¸ÜµÒ¥Æ¡¼¥Ö¥ë¤ËÈ¿±Ç
156        lfSetCustomerPurchase($objCustomer->getValue('customer_id'), $arrData, $objQuery);
157    } else {
158        //¹ØÆþ»þ¶¯À©²ñ°÷ÅÐÏ¿
159        switch(PURCHASE_CUSTOMER_REGIST) {
160        //̵¸ú
161        case '0':
162            // ¹ØÆþ»þ²ñ°÷ÅÐÏ¿
163            if($arrData['member_check'] == '1') {
164                // ²¾²ñ°÷ÅÐÏ¿
165                $customer_id = lfRegistPreCustomer($arrData, $arrInfo);
166                // ¹ØÆþ½¸·×¤ò¸ÜµÒ¥Æ¡¼¥Ö¥ë¤ËÈ¿±Ç
167                lfSetCustomerPurchase($customer_id, $arrData, $objQuery);
168            }
169            break;
170        //Í­¸ú
171        case '1':
172            // ²¾²ñ°÷ÅÐÏ¿
173            $customer_id = lfRegistPreCustomer($arrData, $arrInfo);
174            // ¹ØÆþ½¸·×¤ò¸ÜµÒ¥Æ¡¼¥Ö¥ë¤ËÈ¿±Ç
175            lfSetCustomerPurchase($customer_id, $arrData, $objQuery);
176            break;
177        }
178       
179    }
180    // °ì»þ¥Æ¡¼¥Ö¥ë¤ò¼õÃí¥Æ¡¼¥Ö¥ë¤Ë³ÊǼ¤¹¤ë
181    $order_id = lfRegistOrder($objQuery, $arrData);
182    // ¥«¡¼¥È¾¦Éʤò¼õÃí¾ÜºÙ¥Æ¡¼¥Ö¥ë¤Ë³ÊǼ¤¹¤ë
183    lfRegistOrderDetail($objQuery, $order_id, $objCartSess);
184    // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Î¾ðÊó¤òºï½ü¤¹¤ë¡£
185    lfDeleteTempOrder($objQuery, $uniqid);
186   
187    // ¥»¥Ã¥·¥ç¥ó¥«¡¼¥ÈÆâ¤Î¾¦Éʤòºï½ü¤¹¤ë¡£
188    $objCartSess->delAllProducts();
189    // Ãíʸ°ì»þID¤ò²ò½ü¤¹¤ë¡£
190    $objSiteSess->unsetUniqId();
191   
192    return $order_id;
193}
194
195// ²ñ°÷ÅÐÏ¿¡Ê²¾ÅÐÏ¿¡Ë
196function lfRegistPreCustomer($arrData, $arrInfo) {
197    // ¹ØÆþ»þ¤Î²ñ°÷ÅÐÏ¿
198    $sqlval['name01'] = $arrData['order_name01'];
199    $sqlval['name02'] = $arrData['order_name02'];
200    $sqlval['kana01'] = $arrData['order_kana01'];
201    $sqlval['kana02'] = $arrData['order_kana02'];
202    $sqlval['zip01'] = $arrData['order_zip01'];
203    $sqlval['zip02'] = $arrData['order_zip02'];
204    $sqlval['pref'] = $arrData['order_pref'];
205    $sqlval['addr01'] = $arrData['order_addr01'];
206    $sqlval['addr02'] = $arrData['order_addr02'];
207    $sqlval['email'] = $arrData['order_email'];
208    $sqlval['tel01'] = $arrData['order_tel01'];
209    $sqlval['tel02'] = $arrData['order_tel02'];
210    $sqlval['tel03'] = $arrData['order_tel03'];
211    $sqlval['fax01'] = $arrData['order_fax01'];
212    $sqlval['fax02'] = $arrData['order_fax02'];
213    $sqlval['fax03'] = $arrData['order_fax03'];
214    $sqlval['sex'] = $arrData['order_sex'];
215    $sqlval['password'] = $arrData['password'];
216    $sqlval['reminder'] = $arrData['reminder'];
217    $sqlval['reminder_answer'] = $arrData['reminder_answer'];
218    // ²ñ°÷²¾ÅÐÏ¿
219    $sqlval['status'] = 1;
220    // URLȽÄêÍÑ¥­¡¼
221    $sqlval['secret_key'] = sfGetUniqRandomId("t");
222   
223    $objQuery = new SC_Query();
224    $sqlval['create_date'] = "now()";
225    $sqlval['update_date'] = "now()";
226    $objQuery->insert("dtb_customer", $sqlval);
227   
228    // ¸ÜµÒID¤Î¼èÆÀ
229    $arrRet = $objQuery->select("customer_id", "dtb_customer", "secret_key = ?", array($sqlval['secret_key']));
230    $customer_id = $arrRet[0]['customer_id'];
231   
232    // ¥á¥ë¥Þ¥¬ÇÛ¿®Íѥե饰¤ÎȽÄê
233    switch($arrData['mail_flag']) {
234    case '1':   // HTML¥á¡¼¥ë
235        $mail_flag = 4;
236        break;
237    case '2':   // TEXT¥á¡¼¥ë
238        $mail_flag = 5;
239        break;
240    case '3':   // ´õ˾¤Ê¤·
241        $mail_flag = 6;
242        break;
243    default:
244        $mail_flag = 6;
245        break;
246    }
247
248    $objQuery = new SC_Query();
249    $objQuery->begin();
250    // ¥á¥ë¥Þ¥¬ÇÛ¿®Íѥơ¼¥Ö¥ëÅÐÏ¿
251    lfRegistNonCustomer($arrData['order_email'], $mail_flag, $objQuery);
252    $objQuery->commit();
253
254    //¡¡²¾ÅÐÏ¿´°Î»¥á¡¼¥ëÁ÷¿®
255    $objMailPage = new LC_Page();
256    $objMailPage->to_name01 = $arrData['order_name01'];
257    $objMailPage->to_name02 = $arrData['order_name02'];
258    $objMailPage->CONF = $arrInfo;
259    $objMailPage->uniqid = $sqlval['secret_key'];
260    $objMailView = new SC_SiteView();
261    $objMailView->assignobj($objMailPage);
262    $body = $objMailView->fetch("mail_templates/customer_mail.tpl");
263   
264    $objMail = new GC_SendMail();
265    $objMail->setItem(
266                        ''                                      //¡¡°¸Àè
267                        , sfMakeSubject("²ñ°÷ÅÐÏ¿¤Î¤´³Îǧ")     //¡¡¥µ¥Ö¥¸¥§¥¯¥È
268                        , $body                                 //¡¡ËÜʸ
269                        , $arrInfo['email03']                   //¡¡ÇÛÁ÷¸µ¥¢¥É¥ì¥¹
270                        , $arrInfo['shop_name']                 //¡¡ÇÛÁ÷¸µ¡¡Ì¾Á°
271                        , $arrInfo["email03"]                   //¡¡reply_to
272                        , $arrInfo["email04"]                   //¡¡return_path
273                        , $arrInfo["email04"]                   //  Errors_to
274                        , $arrInfo["email01"]                   //  Bcc
275                                                        );
276    // °¸Àè¤ÎÀßÄê
277    $name = $arrData['order_name01'] . $arrData['order_name02'] ." ÍÍ";
278    $objMail->setTo($arrData['order_email'], $name);           
279    $objMail->sendMail();
280   
281    return $customer_id;
282}
283
284// ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Î¤ªÆϤ±Àè¤ò¥³¥Ô¡¼¤¹¤ë
285function lfCopyDeliv($uniqid, $arrData) {
286    $objQuery = new SC_Query();
287   
288    // Ê̤ΤªÆϤ±Àè¤ò»ØÄꤷ¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢ÇÛÁ÷Àè¤ËÅÐÏ¿½»½ê¤ò¥³¥Ô¡¼¤¹¤ë¡£
289    if($arrData["deliv_check"] != "1") {
290        $sqlval['deliv_name01'] = $arrData['order_name01'];
291        $sqlval['deliv_name02'] = $arrData['order_name02'];
292        $sqlval['deliv_kana01'] = $arrData['order_kana01'];
293        $sqlval['deliv_kana02'] = $arrData['order_kana02'];
294        $sqlval['deliv_pref'] = $arrData['order_pref'];
295        $sqlval['deliv_zip01'] = $arrData['order_zip01'];
296        $sqlval['deliv_zip02'] = $arrData['order_zip02'];
297        $sqlval['deliv_addr01'] = $arrData['order_addr01'];
298        $sqlval['deliv_addr02'] = $arrData['order_addr02'];
299        $sqlval['deliv_tel01'] = $arrData['order_tel01'];
300        $sqlval['deliv_tel02'] = $arrData['order_tel02'];
301        $sqlval['deliv_tel03'] = $arrData['order_tel03'];
302        $where = "order_temp_id = ?";
303        $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid));
304    }
305}
306
307// ¼õÃí¥Æ¡¼¥Ö¥ë¤ØÅÐÏ¿
308function lfRegistOrder($objQuery, $arrData) {
309    $sqlval = $arrData;
310
311    // ¼õÃí¥Æ¡¼¥Ö¥ë¤Ë½ñ¤­¹þ¤Þ¤Ê¤¤Îó¤ò½üµî
312    unset($sqlval['mail_flag']);        // ¥á¥ë¥Þ¥¬¥Á¥§¥Ã¥¯
313    unset($sqlval['deliv_check']);      // Ê̤ΤªÆϤ±Àè¥Á¥§¥Ã¥¯
314    unset($sqlval['point_check']);      // ¥Ý¥¤¥ó¥ÈÍøÍÑ¥Á¥§¥Ã¥¯
315    unset($sqlval['member_check']);     // ¹ØÆþ»þ²ñ°÷¥Á¥§¥Ã¥¯
316    unset($sqlval['password']);         // ¥í¥°¥¤¥ó¥Ñ¥¹¥ï¡¼¥É
317    unset($sqlval['reminder']);         // ¥ê¥Þ¥¤¥ó¥À¡¼¼ÁÌä
318    unset($sqlval['reminder_answer']);  // ¥ê¥Þ¥¤¥ó¥À¡¼Åú¤¨
319
320    // Ãíʸ¥¹¥Æ¡¼¥¿¥¹:»ØÄ̵꤬¤±¤ì¤Ð¿·µ¬¼õÉÕ¤ËÀßÄê
321    if($sqlval["status"] == ""){
322        $sqlval['status'] = '1';           
323    }
324   
325    // Ê̤ΤªÆϤ±Àè¤ò»ØÄꤷ¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢ÇÛÁ÷Àè¤ËÅÐÏ¿½»½ê¤ò¥³¥Ô¡¼¤¹¤ë¡£
326    if($arrData["deliv_check"] != "1") {
327        $sqlval['deliv_name01'] = $arrData['order_name01'];
328        $sqlval['deliv_name02'] = $arrData['order_name02'];
329        $sqlval['deliv_kana01'] = $arrData['order_kana01'];
330        $sqlval['deliv_kana02'] = $arrData['order_kana02'];
331        $sqlval['deliv_pref'] = $arrData['order_pref'];
332        $sqlval['deliv_zip01'] = $arrData['order_zip01'];
333        $sqlval['deliv_zip02'] = $arrData['order_zip02'];
334        $sqlval['deliv_addr01'] = $arrData['order_addr01'];
335        $sqlval['deliv_addr02'] = $arrData['order_addr02'];
336        $sqlval['deliv_tel01'] = $arrData['order_tel01'];
337        $sqlval['deliv_tel02'] = $arrData['order_tel02'];
338        $sqlval['deliv_tel03'] = $arrData['order_tel03'];
339    }
340   
341    $order_id = $arrData['order_id'];       // ¥ª¡¼¥À¡¼ID
342    $sqlval['create_date'] = 'now()';       // ¼õÃíÆü
343   
344    // ¥²¥Ã¥È¤ÎÃͤò¥¤¥ó¥µ¡¼¥È
345    //$sqlval = lfGetInsParam($sqlval);
346   
347    // INSERT¤Î¼Â¹Ô
348    $objQuery->insert("dtb_order", $sqlval);
349   
350    // ¥á¥ë¥Þ¥¬ÇÛ¿®´õ˾¾ðÊó¤ÎÅÐÏ¿
351    lfRegistNonCustomer($arrData['order_email'], $arrData['mail_flag'], $objQuery);
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);
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 lfRegistNonCustomer($email, $mail_flag, $objQuery) {
478    // ²ñ°÷¤Î¥á¡¼¥ë¥¢¥É¥ì¥¹¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç
479    if(!sfCheckCustomerMailMaga($email)) {
480        $where = "email = ?";
481        $objQuery->delete("dtb_customer_mail", $where, array($email));
482        $sqlval['email'] = $email;
483        $sqlval['mail_flag'] = $mail_flag;
484        $sqlval['create_date'] = "now()";
485        $sqlval['update_date'] = "now()";
486        $objQuery->insert("dtb_customer_mail", $sqlval);
487    }
488}
489
490// ºß¸Ë¤ò¸º¤é¤¹½èÍý
491function lfReduceStock($objQuery, $arrID, $quantity) {
492    $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?";
493    $arrRet = $objQuery->select("stock, stock_unlimited", "dtb_products_class", $where, $arrID);
494   
495    // Çä¤êÀڤ쥨¥é¡¼
496    if(($arrRet[0]['stock_unlimited'] != '1' && $arrRet[0]['stock'] < $quantity) || $quantity == 0) {
497        $objQuery->rollback();
498        sfDispSiteError(SOLD_OUT, "", true);
499    // ̵À©¸Â¤Î¾ì¹ç¡¢ºß¸Ë¤ÏNULL
500    } elseif($arrRet[0]['stock_unlimited'] == '1') {
501        $sqlval['stock'] = null;
502        $objQuery->update("dtb_products_class", $sqlval, $where, $arrID);
503    // ºß¸Ë¤ò¸º¤é¤¹
504    } else {
505        $sqlval['stock'] = ($arrRet[0]['stock'] - $quantity);
506        if($sqlval['stock'] == "") {
507            $sqlval['stock'] = '0';
508        }       
509        $objQuery->update("dtb_products_class", $sqlval, $where, $arrID);
510    }
511}
512
513// GET¤ÎÃͤò¥¤¥ó¥µ¡¼¥ÈÍѤËÀ°¤¨¤ë
514function lfGetInsParam($sqlVal){
515   
516    foreach($_GET as $key => $val){
517        // ¥«¥é¥à¤Î¸ºß¥Á¥§¥Ã¥¯
518        if(sfColumnExists("dtb_order", $key)) $sqlVal[$key] = $val;
519    }
520   
521    return $sqlVal;
522}
523
524?>
Note: See TracBrowser for help on using the repository browser.