source: branches/dev/data/downloads/module/mdl_zero/recv.php @ 14778

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