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

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

sfConnectMovilinkURL()の未定義回避

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