source: branches/beta/data/downloads/module/mdl_paygent/paygent_bank.php @ 16787

Revision 16787, 17.0 KB checked in by satou, 14 years ago (diff)

【ペイジェント決済モジュールの修正】
・ATM決済と銀行決済において、カナ文字に半長音が入るとエラーになる。
・銀行決済において、応答のない銀行があるため、購入完了できない。
上記2点を修正しました。

Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7require_once(MODULE_PATH . "mdl_paygent/mdl_paygent.inc");
8
9class LC_Page {
10    function LC_Page() {
11        /** ɬ¤º»ØÄꤹ¤ë **/
12        $this->tpl_mainpage = MODULE_PATH . 'mdl_paygent/paygent_bank.tpl';     // ¥á¥¤¥ó¥Æ¥ó¥×¥ì¡¼¥È
13        /*
14         session_start»þ¤Îno-cache¥Ø¥Ã¥À¡¼¤òÍÞÀ©¤¹¤ë¤³¤È¤Ç
15         ¡ÖÌá¤ë¡×¥Ü¥¿¥ó»ÈÍÑ»þ¤ÎÍ­¸ú´ü¸ÂÀÚ¤ìɽ¼¨¤òÍÞÀ©¤¹¤ë¡£
16         private-no-expire:¥¯¥é¥¤¥¢¥ó¥È¤Î¥­¥ã¥Ã¥·¥å¤òµö²Ä¤¹¤ë¡£
17        */
18        session_cache_limiter('private-no-expire');     
19    }
20}
21
22$objPage = new LC_Page();
23$objView = new SC_SiteView();
24$objCampaignSess = new SC_CampaignSession();
25$objCustomer = new SC_Customer();
26$objSiteInfo = $objView->objSiteInfo;
27$arrInfo = $objSiteInfo->data;
28
29if (GC_MobileUserAgent::isMobile()) {
30    sfDispSiteError(FREE_ERROR_MSG, "", false, "¶ä¹Ô¥Í¥Ã¥È·èºÑ¤Ï¡¢¤´»ÈÍѤε¡¼ï¤Ë¤ÏÂбþ¤·¤Æ¤ª¤ê¤Þ¤»¤ó¡£", true);
31    exit;
32}
33
34// ¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹
35$objFormParam = new SC_FormParam();
36
37// °ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤ÎÆɹþ
38$arrData = sfGetOrderTemp($uniqid);
39
40// ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
41lfInitParam($arrData);
42// POSTÃͤμèÆÀ
43$objFormParam->setParam($_POST);
44
45// ¥«¡¼¥È½¸·×½èÍý
46$objPage = sfTotalCart($objPage, $objCartSess, $arrInfo);
47
48// °ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤ÎÆɹþ
49$arrData = sfGetOrderTemp($uniqid);
50
51// ¥«¡¼¥È½¸·×¤ò¸µ¤ËºÇ½ª·×»»
52$arrData = sfTotalConfirm($arrData, $objPage, $objCartSess, $arrInfo);
53
54switch($_POST['mode']) {
55// Á°¤Î¥Ú¡¼¥¸¤ËÌá¤ë
56case 'return':
57    // Àµ¾ï¤Ê¿ä°Ü¤Ç¤¢¤ë¤³¤È¤òµ­Ï¿¤·¤Æ¤ª¤¯
58    $objSiteSess->setRegistFlag();
59    header("Location: " . URL_SHOP_CONFIRM);
60    exit;
61    break;
62// ¼¡¤Ø
63case 'next':
64    // ÆþÎÏÃͤÎÊÑ´¹
65    $objFormParam->convParam();
66    $objPage->arrErr = lfCheckError($arrRet);
67    // ÆþÎÏ¥¨¥é¡¼¤Ê¤·¤Î¾ì¹ç
68    if(count($objPage->arrErr) == 0) {
69         // ÆþÎϥǡ¼¥¿¤Î¼èÆÀ¤ò¹Ô¤¦
70        $arrInput = $objFormParam->getHashArray();
71        // ¥¯¥ì¥¸¥Ã¥ÈÅÅʸÁ÷¿®
72        $arrRet = sfSendPaygentBANK($arrData, $arrInput, $uniqid);     
73        // À®¸ù
74        if($arrRet['asp_url'] != "") {
75            // Àµ¾ï¤ËÅÐÏ¿¤µ¤ì¤¿¤³¤È¤òµ­Ï¿¤·¤Æ¤ª¤¯
76            $objSiteSess->setRegistFlag();
77            // ÅÐÏ¿½èÍý
78            $objQuery->begin();
79            $order_id = lfDoComplete($objQuery, $uniqid);
80            $objQuery->commit();
81            // ¥»¥Ã¥·¥ç¥ó¤ËÊݴɤµ¤ì¤Æ¤¤¤ë¾ðÊó¤ò¹¹¿·¤¹¤ë
82            $objCustomer->updateSession();
83            // ´°Î»¥á¡¼¥ëÁ÷¿®
84            if($order_id != "") {
85                $order_email = $objQuery->select("order_email", "dtb_order", "order_id = ?", array($order_id));
86                //ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¥á¡¼¥ë¥¢¥É¥ì¥¹¤¬·ÈÂÓ¤«PC¤«¤Ë±þ¤¸¤ÆÃíʸ´°Î»¥á¡¼¥ë¤Î¥Æ¥ó¥×¥ì¡¼¥È¤òÊѤ¨¤ë
87                if(ereg("(ezweb.ne.jp$|docomo.ne.jp$|softbank.ne.jp$|vodafone.ne.jp$)",$order_email[0]['order_email'])){
88                    // ¥â¥Ð¥¤¥ëÈÇ
89                    sfSendOrderMail($order_id, '2');
90                }else{
91                    // PCÈÇ
92                    sfSendOrderMail($order_id, '1');
93                }
94            }
95            // ¥Ú¥¤¥¸¥§¥ó¥È·èºÑ²èÌ̤ËÁ«°Ü
96            header("Location: " . $arrRet['asp_url']);
97        // ¼ºÇÔ
98        } else {
99            $objPage->tpl_error = "ǧ¾Ú¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£¤ª¼ê¿ô¤Ç¤¹¤¬ÆþÎÏÆâÍƤò¤´³Îǧ¤¯¤À¤µ¤¤¡£";
100        }
101    }
102    break;
103}
104
105$objDate = new SC_Date();
106$objDate->setStartYear(RELEASE_YEAR);
107$objDate->setEndYear(RELEASE_YEAR + CREDIT_ADD_YEAR);
108$objPage->arrYear = $objDate->getZeroYear();
109$objPage->arrMonth = $objDate->getZeroMonth();
110
111// ¶¦Ä̤Îɽ¼¨½àÈ÷
112$objPage = sfPaygentDisp($objPage, $payment_id);
113
114$objPage->arrNetBank = $arrNetBank;
115$objPage->arrForm = $objFormParam->getFormParamList();
116$objView->assignobj($objPage);
117// ¥Õ¥ì¡¼¥à¤òÁªÂò(¥­¥ã¥ó¥Ú¡¼¥ó¥Ú¡¼¥¸¤«¤éÁ«°Ü¤Ê¤éÊѹ¹)
118$objCampaignSess->pageView($objView);
119
120//-----------------------------------------------------------------------------------------------
121
122/* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */
123function lfInitParam($arrData) {
124    global $objFormParam;
125    $objFormParam->addParam("ÍøÍѼÔÀ«", "customer_family_name", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"), $arrData['order_name01']);
126    $objFormParam->addParam("ÍøÍѼÔ̾", "customer_name", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"), $arrData['order_name02']);
127    $objFormParam->addParam("ÍøÍѼÔÀ«¥«¥Ê", "customer_family_name_kana", STEXT_LEN, "CKVa", array("EXIST_CHECK", "KANA_CHECK", "MAX_LENGTH_CHECK"), $arrData['order_kana01']);
128    $objFormParam->addParam("ÍøÍѼÔ̾¥«¥Ê", "customer_name_kana", STEXT_LEN, "CKVa", array("EXIST_CHECK", "KANA_CHECK", "MAX_LENGTH_CHECK"), $arrData['order_kana02']);
129}
130
131/* ÆþÎÏÆâÍƤΥÁ¥§¥Ã¥¯ */
132function lfCheckError() {
133    global $objFormParam;
134    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
135    $arrRet =  $objFormParam->getHashArray();
136    $objErr = new SC_CheckError($arrRet);
137    $objErr->arrErr = $objFormParam->checkError();
138   
139    return $objErr->arrErr;
140}
141
142// ´°Î»½èÍý
143function lfDoComplete($objQuery, $uniqid) {
144    global $objCartSess;
145    global $objSiteSess;
146    global $objCampaignSess;
147    global $objCustomer;
148    global $arrInfo;
149   
150    // °ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤ÎÆɹþ
151    $arrData = sfGetOrderTemp($uniqid);
152
153    // ²ñ°÷¾ðÊóÅÐÏ¿½èÍý
154    if ($objCustomer->isLoginSuccess()) {
155        // ¿·¤ªÆϤ±Àè¤ÎÅÐÏ¿
156        lfSetNewAddr($uniqid, $objCustomer->getValue('customer_id'));
157        // ¹ØÆþ½¸·×¤ò¸ÜµÒ¥Æ¡¼¥Ö¥ë¤ËÈ¿±Ç
158        lfSetCustomerPurchase($objCustomer->getValue('customer_id'), $arrData, $objQuery);
159    } else {
160        //¹ØÆþ»þ¶¯À©²ñ°÷ÅÐÏ¿
161        switch(PURCHASE_CUSTOMER_REGIST) {
162        //̵¸ú
163        case '0':
164            // ¹ØÆþ»þ²ñ°÷ÅÐÏ¿
165            if($arrData['member_check'] == '1') {
166                // ²¾²ñ°÷ÅÐÏ¿
167                $customer_id = lfRegistPreCustomer($arrData, $arrInfo);
168                // ¹ØÆþ½¸·×¤ò¸ÜµÒ¥Æ¡¼¥Ö¥ë¤ËÈ¿±Ç
169                lfSetCustomerPurchase($customer_id, $arrData, $objQuery);
170            }
171            break;
172        //Í­¸ú
173        case '1':
174            // ²¾²ñ°÷ÅÐÏ¿
175            $customer_id = lfRegistPreCustomer($arrData, $arrInfo);
176            // ¹ØÆþ½¸·×¤ò¸ÜµÒ¥Æ¡¼¥Ö¥ë¤ËÈ¿±Ç
177            lfSetCustomerPurchase($customer_id, $arrData, $objQuery);
178            break;
179        }
180    }
181   
182    // °ì»þ¥Æ¡¼¥Ö¥ë¤ò¼õÃí¥Æ¡¼¥Ö¥ë¤Ë³ÊǼ¤¹¤ë
183    $order_id = lfRegistOrder($objQuery, $arrData, $objCampaignSess);
184    // ¥«¡¼¥È¾¦Éʤò¼õÃí¾ÜºÙ¥Æ¡¼¥Ö¥ë¤Ë³ÊǼ¤¹¤ë
185    lfRegistOrderDetail($objQuery, $order_id, $objCartSess);
186    // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Î¾ðÊó¤òºï½ü¤¹¤ë¡£
187    lfDeleteTempOrder($objQuery, $uniqid);
188    // ¥­¥ã¥ó¥Ú¡¼¥ó¤«¤é¤ÎÁ«°Ü¤Î¾ì¹çÅÐÏ¿¤¹¤ë¡£
189    if($objCampaignSess->getIsCampaign() and $objCartSess->chkCampaign($objCampaignSess->getCampaignId())) {
190        lfRegistCampaignOrder($objQuery, $objCampaignSess, $order_id);
191    }
192   
193    // ¥»¥Ã¥·¥ç¥ó¥«¡¼¥ÈÆâ¤Î¾¦Éʤòºï½ü¤¹¤ë¡£
194    $objCartSess->delAllProducts();
195    // Ãíʸ°ì»þID¤ò²ò½ü¤¹¤ë¡£
196    $objSiteSess->unsetUniqId();
197   
198    return $order_id;
199}
200
201// ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Î½»½ê¤¬ÅÐÏ¿ºÑ¤ß¥Æ¡¼¥Ö¥ë¤È°Û¤Ê¤ë¾ì¹ç¤Ï¡¢Ê̤ΤªÆϤ±Àè¤ËÄɲ乤ë
202function lfSetNewAddr($uniqid, $customer_id) {
203    $objQuery = new SC_Query();
204    $diff = false;
205    $find_same = false;
206   
207    $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";
208    $where = "order_temp_id = ?";
209    $arrRet = $objQuery->select($col, "dtb_order_temp", $where, array($uniqid));
210   
211    // Í×ÁÇ̾¤Îdeliv_¤òºï½ü¤¹¤ë¡£
212    foreach($arrRet[0] as $key => $val) {
213        $keyname = ereg_replace("^deliv_", "", $key);
214        $arrNew[$keyname] = $val;
215    }
216   
217    // ²ñ°÷¾ðÊó¥Æ¡¼¥Ö¥ë¤È¤ÎÈæ³Ó
218    $col = "name01,name02,kana01,kana02,tel01,tel02,tel03,zip01,zip02,pref,addr01,addr02";
219    $where = "customer_id = ?";
220    $arrCustomerAddr = $objQuery->select($col, "dtb_customer", $where, array($customer_id));
221   
222    // ²ñ°÷¾ðÊó¤Î½»½ê¤È°Û¤Ê¤ë¾ì¹ç
223    if($arrNew != $arrCustomerAddr[0]) {
224        // Ê̤ΤªÆϤ±Àè¥Æ¡¼¥Ö¥ë¤Î½»½ê¤ÈÈæ³Ó¤¹¤ë
225        $col = "name01,name02,kana01,kana02,tel01,tel02,tel03,zip01,zip02,pref,addr01,addr02";
226        $where = "customer_id = ?";
227        $arrOtherAddr = $objQuery->select($col, "dtb_other_deliv", $where, array($customer_id));
228
229        foreach($arrOtherAddr as $arrval) {
230            if($arrNew == $arrval) {
231                // ¤¹¤Ç¤ËƱ¤¸½»½ê¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë
232                $find_same = true;
233            }
234        }
235       
236        if(!$find_same) {
237            $diff = true;
238        }
239    }
240   
241    // ¿·¤·¤¤¤ªÆϤ±À褬ÅÐÏ¿ºÑ¤ß¤Î¤â¤Î¤È°Û¤Ê¤ë¾ì¹ç¤ÏÊ̤ΤªÆϤ±Àè¥Æ¡¼¥Ö¥ë¤ËÅÐÏ¿¤¹¤ë
242    if($diff) {
243        $sqlval = $arrNew;
244        $sqlval['customer_id'] = $customer_id;
245        $objQuery->insert("dtb_other_deliv", $sqlval);
246    }
247}
248
249/* ¹ØÆþ¾ðÊó¤ò²ñ°÷¥Æ¡¼¥Ö¥ë¤ËÅÐÏ¿¤¹¤ë */
250function lfSetCustomerPurchase($customer_id, $arrData, $objQuery) {
251    $col = "first_buy_date, last_buy_date, buy_times, buy_total, point";
252    $where = "customer_id = ?";
253    $arrRet = $objQuery->select($col, "dtb_customer", $where, array($customer_id));
254    $sqlval = $arrRet[0];
255   
256    if($sqlval['first_buy_date'] == "") {
257        $sqlval['first_buy_date'] = "Now()";
258    }
259    $sqlval['last_buy_date'] = "Now()";
260    $sqlval['buy_times']++;
261    $sqlval['buy_total']+= $arrData['total'];
262    $sqlval['point'] = ($sqlval['point'] + $arrData['add_point'] - $arrData['use_point']);
263   
264    // ¥Ý¥¤¥ó¥È¤¬ÉÔ­¤·¤Æ¤¤¤ë¾ì¹ç
265    if($sqlval['point'] < 0) {
266        $objQuery->rollback();
267        sfDispSiteError(LACK_POINT);
268    }
269   
270    $objQuery->update("dtb_customer", $sqlval, $where, array($customer_id));
271}
272
273// ²ñ°÷ÅÐÏ¿¡Ê²¾ÅÐÏ¿¡Ë
274function lfRegistPreCustomer($arrData, $arrInfo) {
275    // ¹ØÆþ»þ¤Î²ñ°÷ÅÐÏ¿
276    $sqlval['name01'] = $arrData['order_name01'];
277    $sqlval['name02'] = $arrData['order_name02'];
278    $sqlval['kana01'] = $arrData['order_kana01'];
279    $sqlval['kana02'] = $arrData['order_kana02'];
280    $sqlval['zip01'] = $arrData['order_zip01'];
281    $sqlval['zip02'] = $arrData['order_zip02'];
282    $sqlval['pref'] = $arrData['order_pref'];
283    $sqlval['addr01'] = $arrData['order_addr01'];
284    $sqlval['addr02'] = $arrData['order_addr02'];
285    $sqlval['email'] = $arrData['order_email'];
286    $sqlval['tel01'] = $arrData['order_tel01'];
287    $sqlval['tel02'] = $arrData['order_tel02'];
288    $sqlval['tel03'] = $arrData['order_tel03'];
289    $sqlval['fax01'] = $arrData['order_fax01'];
290    $sqlval['fax02'] = $arrData['order_fax02'];
291    $sqlval['fax03'] = $arrData['order_fax03'];
292    $sqlval['sex'] = $arrData['order_sex'];
293    $sqlval['password'] = $arrData['password'];
294    $sqlval['reminder'] = $arrData['reminder'];
295    $sqlval['reminder_answer'] = $arrData['reminder_answer'];
296   
297    // ¥á¥ë¥Þ¥¬ÇÛ¿®Íѥե饰¤ÎȽÄê
298    switch($arrData['mail_flag']) {
299    case '1':   // HTML¥á¡¼¥ë
300        $mail_flag = 4;
301        break;
302    case '2':   // TEXT¥á¡¼¥ë
303        $mail_flag = 5;
304        break;
305    case '3':   // ´õ˾¤Ê¤·
306        $mail_flag = 6;
307        break;
308    default:
309        $mail_flag = 6;
310        break;
311    }
312    // ¥á¥ë¥Þ¥¬¥Õ¥é¥°
313    $sqlval['mailmaga_flg'] = $mail_flag;
314       
315    // ²ñ°÷²¾ÅÐÏ¿
316    $sqlval['status'] = 1;
317    // URLȽÄêÍÑ¥­¡¼
318    $sqlval['secret_key'] = sfGetUniqRandomId("t");
319   
320    $objQuery = new SC_Query();
321    $sqlval['create_date'] = "now()";
322    $sqlval['update_date'] = "now()";
323    $objQuery->insert("dtb_customer", $sqlval);
324   
325    // ¸ÜµÒID¤Î¼èÆÀ
326    $arrRet = $objQuery->select("customer_id", "dtb_customer", "secret_key = ?", array($sqlval['secret_key']));
327    $customer_id = $arrRet[0]['customer_id'];
328   
329    //¡¡²¾ÅÐÏ¿´°Î»¥á¡¼¥ëÁ÷¿®
330    $objMailPage = new LC_Page();
331    $objMailPage->to_name01 = $arrData['order_name01'];
332    $objMailPage->to_name02 = $arrData['order_name02'];
333    $objMailPage->CONF = $arrInfo;
334    $objMailPage->uniqid = $sqlval['secret_key'];
335    $objMailView = new SC_SiteView();
336    $objMailView->assignobj($objMailPage);
337    $body = $objMailView->fetch("mail_templates/customer_mail.tpl");
338   
339    $objMail = new GC_SendMail();
340    $objMail->setItem(
341                        ''                                      //¡¡°¸Àè
342                        , sfMakeSubject("²ñ°÷ÅÐÏ¿¤Î¤´³Îǧ")     //¡¡¥µ¥Ö¥¸¥§¥¯¥È
343                        , $body                                 //¡¡ËÜʸ
344                        , $arrInfo['email03']                   //¡¡ÇÛÁ÷¸µ¥¢¥É¥ì¥¹
345                        , $arrInfo['shop_name']                 //¡¡ÇÛÁ÷¸µ¡¡Ì¾Á°
346                        , $arrInfo["email03"]                   //¡¡reply_to
347                        , $arrInfo["email04"]                   //¡¡return_path
348                        , $arrInfo["email04"]                   //  Errors_to
349                        , $arrInfo["email01"]                   //  Bcc
350                                                        );
351    // °¸Àè¤ÎÀßÄê
352    $name = $arrData['order_name01'] . $arrData['order_name02'] ." ÍÍ";
353    $objMail->setTo($arrData['order_email'], $name);           
354    $objMail->sendMail();
355   
356    return $customer_id;
357}
358
359// ¼õÃí¥Æ¡¼¥Ö¥ë¤ØÅÐÏ¿
360function lfRegistOrder($objQuery, $arrData, $objCampaignSess) {
361    $sqlval = $arrData;
362
363    // ¼õÃí¥Æ¡¼¥Ö¥ë¤Ë½ñ¤­¹þ¤Þ¤Ê¤¤Îó¤ò½üµî
364    unset($sqlval['mailmaga_flg']);     // ¥á¥ë¥Þ¥¬¥Á¥§¥Ã¥¯
365    unset($sqlval['deliv_check']);      // Ê̤ΤªÆϤ±Àè¥Á¥§¥Ã¥¯
366    unset($sqlval['point_check']);      // ¥Ý¥¤¥ó¥ÈÍøÍÑ¥Á¥§¥Ã¥¯
367    unset($sqlval['member_check']);     // ¹ØÆþ»þ²ñ°÷¥Á¥§¥Ã¥¯
368    unset($sqlval['password']);         // ¥í¥°¥¤¥ó¥Ñ¥¹¥ï¡¼¥É
369    unset($sqlval['reminder']);         // ¥ê¥Þ¥¤¥ó¥À¡¼¼ÁÌä
370    unset($sqlval['reminder_answer']);  // ¥ê¥Þ¥¤¥ó¥À¡¼Åú¤¨
371    unset($sqlval['mail_flag']);        // ¥á¡¼¥ë¥Õ¥é¥°
372    unset($sqlval['session']);          // ¥»¥Ã¥·¥ç¥ó¾ðÊó
373   
374    // Ãíʸ¥¹¥Æ¡¼¥¿¥¹:»ØÄ̵꤬¤±¤ì¤Ð¿·µ¬¼õÉÕ¤ËÀßÄê
375    if($sqlval["status"] == ""){
376        $sqlval['status'] = '1';           
377    }
378   
379    // Ê̤ΤªÆϤ±Àè¤ò»ØÄꤷ¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢ÇÛÁ÷Àè¤ËÅÐÏ¿½»½ê¤ò¥³¥Ô¡¼¤¹¤ë¡£
380    if($arrData["deliv_check"] == "-1") {
381        $sqlval['deliv_name01'] = $arrData['order_name01'];
382        $sqlval['deliv_name02'] = $arrData['order_name02'];
383        $sqlval['deliv_kana01'] = $arrData['order_kana01'];
384        $sqlval['deliv_kana02'] = $arrData['order_kana02'];
385        $sqlval['deliv_pref'] = $arrData['order_pref'];
386        $sqlval['deliv_zip01'] = $arrData['order_zip01'];
387        $sqlval['deliv_zip02'] = $arrData['order_zip02'];
388        $sqlval['deliv_addr01'] = $arrData['order_addr01'];
389        $sqlval['deliv_addr02'] = $arrData['order_addr02'];
390        $sqlval['deliv_tel01'] = $arrData['order_tel01'];
391        $sqlval['deliv_tel02'] = $arrData['order_tel02'];
392        $sqlval['deliv_tel03'] = $arrData['order_tel03'];
393    }
394   
395    $order_id = $arrData['order_id'];       // ¥ª¡¼¥À¡¼ID
396    $sqlval['create_date'] = 'now()';       // ¼õÃíÆü
397   
398    // ¥­¥ã¥ó¥Ú¡¼¥óID
399    if($objCampaignSess->getIsCampaign()) $sqlval['campaign_id'] = $objCampaignSess->getCampaignId();
400
401    // ¥²¥Ã¥È¤ÎÃͤò¥¤¥ó¥µ¡¼¥È
402    //$sqlval = lfGetInsParam($sqlval);
403   
404    // INSERT¤Î¼Â¹Ô
405    $objQuery->insert("dtb_order", $sqlval);
406   
407    return $order_id;
408}
409
410// ¼õÃí¾ÜºÙ¥Æ¡¼¥Ö¥ë¤ØÅÐÏ¿
411function lfRegistOrderDetail($objQuery, $order_id, $objCartSess) {
412    // ¥«¡¼¥ÈÆâ¾ðÊó¤Î¼èÆÀ
413    $arrCart = $objCartSess->getCartList();
414    $max = count($arrCart);
415   
416    // ´û¤Ë¸ºß¤¹¤ë¾ÜºÙ¥ì¥³¡¼¥É¤ò¾Ã¤·¤Æ¤ª¤¯¡£
417    $objQuery->delete("dtb_order_detail", "order_id = $order_id");
418
419    // µ¬³Ê̾°ìÍ÷
420    $arrClassName = sfGetIDValueList("dtb_class", "class_id", "name");
421    // µ¬³ÊʬÎà̾°ìÍ÷
422    $arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
423           
424    for ($i = 0; $i < $max; $i++) {
425        // ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ   
426        $arrData = sfGetProductsClass($arrCart[$i]['id']);
427       
428        // ¸ºß¤¹¤ë¾¦ÉʤΤßɽ¼¨¤¹¤ë¡£
429        if($arrData != "") {
430            $sqlval['order_id'] = $order_id;
431            $sqlval['product_id'] = $arrCart[$i]['id'][0];
432            $sqlval['classcategory_id1'] = $arrCart[$i]['id'][1];
433            $sqlval['classcategory_id2'] = $arrCart[$i]['id'][2];
434            $sqlval['product_name'] = $arrData['name'];
435            $sqlval['product_code'] = $arrData['product_code'];
436            $sqlval['classcategory_name1'] = $arrClassCatName[$arrData['classcategory_id1']];
437            $sqlval['classcategory_name2'] = $arrClassCatName[$arrData['classcategory_id2']];
438            $sqlval['point_rate'] = $arrCart[$i]['point_rate'];         
439            $sqlval['price'] = $arrCart[$i]['price'];
440            $sqlval['quantity'] = $arrCart[$i]['quantity'];
441            lfReduceStock($objQuery, $arrCart[$i]['id'], $arrCart[$i]['quantity']);
442            // INSERT¤Î¼Â¹Ô
443            $objQuery->insert("dtb_order_detail", $sqlval);
444        } else {
445            sfDispSiteError(CART_NOT_FOUND);
446        }
447    }
448}
449
450/* ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Îºï½ü */
451function lfDeleteTempOrder($objQuery, $uniqid) {
452    $where = "order_temp_id = ?";
453    $sqlval['del_flg'] = 1;
454    $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid));
455    // $objQuery->delete("dtb_order_temp", $where, array($uniqid));
456}
457
458// ¥­¥ã¥ó¥Ú¡¼¥ó¼õÃí¥Æ¡¼¥Ö¥ë¤ØÅÐÏ¿
459function lfRegistCampaignOrder($objQuery, $objCampaignSess, $order_id) {
460
461    // ¼õÃí¥Ç¡¼¥¿¤ò¼èÆÀ
462    $cols = "order_id, campaign_id, customer_id, message, order_name01, order_name02,".
463            "order_kana01, order_kana02, order_email, order_tel01, order_tel02, order_tel03,".
464            "order_fax01, order_fax02, order_fax03, order_zip01, order_zip02, order_pref, order_addr01,".
465            "order_addr02, order_sex, order_birth, order_job, deliv_name01, deliv_name02, deliv_kana01,".
466            "deliv_kana02, deliv_tel01, deliv_tel02, deliv_tel03, deliv_fax01, deliv_fax02, deliv_fax03,".
467            "deliv_zip01, deliv_zip02, deliv_pref, deliv_addr01, deliv_addr02, payment_total";
468
469    $arrOrder = $objQuery->select($cols, "dtb_order", "order_id = ?", array($order_id));
470           
471    $sqlval = $arrOrder[0];
472    $sqlval['create_date'] = 'now()';
473       
474    // INSERT¤Î¼Â¹Ô
475    $objQuery->insert("dtb_campaign_order", $sqlval);
476   
477    // ¿½¤·¹þ¤ß¿ô¤Î¹¹¿·
478    $total_count = $objQuery->get("dtb_campaign", "total_count", "campaign_id = ?", array($sqlval['campaign_id']));
479    $arrCampaign['total_count'] = $total_count += 1;
480    $objQuery->update("dtb_campaign", $arrCampaign, "campaign_id = ?", array($sqlval['campaign_id']));
481   
482}
483
484// ºß¸Ë¤ò¸º¤é¤¹½èÍý
485function lfReduceStock($objQuery, $arrID, $quantity) {
486    $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?";
487    $arrRet = $objQuery->select("stock, stock_unlimited", "dtb_products_class", $where, $arrID);
488   
489    // Çä¤êÀڤ쥨¥é¡¼
490    if(($arrRet[0]['stock_unlimited'] != '1' && $arrRet[0]['stock'] < $quantity) || $quantity == 0) {
491        $objQuery->rollback();
492        sfDispSiteError(SOLD_OUT, "", true);
493    // ̵À©¸Â¤Î¾ì¹ç¡¢ºß¸Ë¤ÏNULL
494    } elseif($arrRet[0]['stock_unlimited'] == '1') {
495        $sqlval['stock'] = null;
496        $objQuery->update("dtb_products_class", $sqlval, $where, $arrID);
497    // ºß¸Ë¤ò¸º¤é¤¹
498    } else {
499        $sqlval['stock'] = ($arrRet[0]['stock'] - $quantity);
500        if($sqlval['stock'] == "") {
501            $sqlval['stock'] = '0';
502        }       
503        $objQuery->update("dtb_products_class", $sqlval, $where, $arrID);
504    }
505}
506
507?>?>
Note: See TracBrowser for help on using the repository browser.