source: branches/feature-module-paygent/data/downloads/module/mdl_zero/recv.php @ 15761

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