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

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