source: branches/dev/html/shopping/complete.php @ 14871

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