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

Revision 15120, 17.3 KB checked in by adati, 13 years ago (diff)

1.4.2betaのマージ

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