source: temp/branches/mobile/html/mobile/shopping/payment.php @ 11409

Revision 11409, 9.5 KB checked in by rebelt, 15 years ago (diff)

以下のモバイルサイト用ページ・機能を作成いたしました。

  • 会員登録
  • 注文
  • イプシロン決済
  • Property svn:eol-style set to native
Line 
1<?php
2/*
3 * Copyright(c) 2000-2006 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7
8require_once("../require.php");
9
10class LC_Page {
11    var $arrSession;
12    var $tpl_mode;
13    function LC_Page() {
14        $this->tpl_css = '/css/layout/shopping/pay.css';
15        $this->tpl_mainpage = 'shopping/payment.tpl';
16        $this->tpl_onload = 'fnCheckInputPoint();';
17        $this->tpl_title = "¤ª»ÙʧÊýË¡¡¦¤ªÆϤ±»þ´ÖÅù¤Î»ØÄê";
18        /*
19         session_start»þ¤Îno-cache¥Ø¥Ã¥À¡¼¤òÍÞÀ©¤¹¤ë¤³¤È¤Ç
20         ¡ÖÌá¤ë¡×¥Ü¥¿¥ó»ÈÍÑ»þ¤ÎÍ­¸ú´ü¸ÂÀÚ¤ìɽ¼¨¤òÍÞÀ©¤¹¤ë¡£
21         private-no-expire:¥¯¥é¥¤¥¢¥ó¥È¤Î¥­¥ã¥Ã¥·¥å¤òµö²Ä¤¹¤ë¡£
22        */
23        session_cache_limiter('private-no-expire');     
24    }
25}
26
27$objPage = new LC_Page();
28$objView = new SC_SiteView();
29$objSiteSess = new SC_SiteSession();
30$objCartSess = new SC_CartSession();
31$objCustomer = new SC_Customer();
32$objSiteInfo = $objView->objSiteInfo;
33$arrInfo = $objSiteInfo->data;
34
35// ¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹
36$objFormParam = new SC_FormParam();
37// ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
38lfInitParam();
39// POSTÃͤμèÆÀ
40$objFormParam->setParam($_POST);
41
42// ¥æ¡¼¥¶¥æ¥Ë¡¼¥¯ID¤Î¼èÆÀ¤È¹ØÆþ¾õÂÖ¤ÎÀµÅöÀ­¤ò¥Á¥§¥Ã¥¯
43$uniqid = sfCheckNormalAccess($objSiteSess, $objCartSess);
44// ¥æ¥Ë¡¼¥¯ID¤ò°ú¤­·Ñ¤°
45$objPage->tpl_uniqid = $uniqid;
46
47// ²ñ°÷¥í¥°¥¤¥ó¥Á¥§¥Ã¥¯
48if($objCustomer->isLoginSuccess()) {
49    $objPage->tpl_login = '1';
50    $objPage->tpl_user_point = $objCustomer->getValue('point');
51}
52
53// ¶â³Û¤Î¼èÆÀ (¹ØÆþÅÓÃæ¤ÇÇä¤êÀڤ줿¾ì¹ç¤Ë¤Ï¤³¤Î´Ø¿ôÆâ¤Ë¤Æ¤½¤Î¾¦ÉʤθĿô¤¬£°¤Ë¤Ê¤ë)
54$objPage = sfTotalCart($objPage, $objCartSess, $arrInfo);
55$objPage->arrData = sfTotalConfirm($arrData, $objPage, $objCartSess, $arrInfo);
56
57// ¥«¡¼ÅÔÆâ¤Î¾¦ÉʤÎÇä¤êÀÚ¤ì¥Á¥§¥Ã¥¯
58$objCartSess->chkSoldOut($objCartSess->getCartList());
59
60switch($_POST['mode']) {
61case 'confirm':
62    // ÆþÎÏÃͤÎÊÑ´¹
63    $objFormParam->convParam();
64    $objPage->arrErr = lfCheckError($objPage->arrData );
65    // ÆþÎÏ¥¨¥é¡¼¤Ê¤·
66    if(count($objPage->arrErr) == 0) {
67        // DB¤Ø¤Î¥Ç¡¼¥¿ÅÐÏ¿
68        lfRegistData($uniqid);
69        // Àµ¾ï¤ËÅÐÏ¿¤µ¤ì¤¿¤³¤È¤òµ­Ï¿¤·¤Æ¤ª¤¯
70        $objSiteSess->setRegistFlag();
71        // ³Îǧ¥Ú¡¼¥¸¤Ø°ÜÆ°
72        header("Location: " . gfAddSessionId(URL_SHOP_CONFIRM));
73        exit;
74    }else{
75        // ¥æ¡¼¥¶¥æ¥Ë¡¼¥¯ID¤Î¼èÆÀ
76        $uniqid = $objSiteSess->getUniqId();
77        // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤«¤é¤Î¾ðÊó¤ò³ÊǼ
78        lfSetOrderTempData($uniqid);
79    }
80    break;
81// Á°¤Î¥Ú¡¼¥¸¤ËÌá¤ë
82case 'return':
83    // Èó²ñ°÷¤Î¾ì¹ç
84    // Àµ¾ï¤Ê¿ä°Ü¤Ç¤¢¤ë¤³¤È¤òµ­Ï¿¤·¤Æ¤ª¤¯
85    $objSiteSess->setRegistFlag();
86    header("Location: " . gfAddSessionId(URL_SHOP_TOP));
87    exit;
88    break;
89// »Ùʧ¤¤ÊýË¡¤¬Êѹ¹¤µ¤ì¤¿¾ì¹ç
90case 'payment':
91    // ¤³¤³¤Îbreak¤Ï¡¢°ÕÌ£¤¬¤¢¤ë¤Î¤Ç³°¤µ¤Ê¤¤¤Ç²¼¤µ¤¤¡£
92    break;
93default:
94    // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤«¤é¤Î¾ðÊó¤ò³ÊǼ
95    lfSetOrderTempData($uniqid);
96    break;
97}
98
99// ŹÊÞ¾ðÊó¤Î¼èÆÀ
100$arrInfo = $objSiteInfo->data;
101// ¹ØÆþ¶â³Û¤Î¼èÆÀÆÀ
102$total_pretax = $objCartSess->getAllProductsTotal($arrInfo);
103// »Ùʧ¤¤ÊýË¡¤Î¼èÆÀ
104$objPage->arrPayment = lfGetPayment($total_pretax);
105// ÇÛÁ÷»þ´Ö¤Î¼èÆÀ
106$arrRet = sfGetDelivTime($objFormParam->getValue('payment_id'));
107$objPage->arrDelivTime = sfArrKeyValue($arrRet, 'time_id', 'deliv_time');
108$objPage->objCustomer = $objCustomer;
109//¡¡ÇÛÁ÷Æü°ìÍ÷¤Î¼èÆÀ
110$objPage->arrDelivDate = lfGetDelivDate();
111
112$objPage->arrForm = $objFormParam->getFormParamList();
113
114$objView->assignobj($objPage);
115$objView->display(SITE_FRAME);
116//--------------------------------------------------------------------------------------------------------------------------
117/* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */
118function lfInitParam() {
119    global $objFormParam;
120    $objFormParam->addParam("¤ª»Ùʧ¤¤ÊýË¡", "payment_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
121    $objFormParam->addParam("¥Ý¥¤¥ó¥È", "use_point", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK", "ZERO_START"));
122    $objFormParam->addParam("ÇÛã»þ´Ö", "deliv_time_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
123    $objFormParam->addParam("¤´¼ÁÌä", "message", LTEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK"));
124    $objFormParam->addParam("¥Ý¥¤¥ó¥È¤ò»ÈÍѤ¹¤ë", "point_check", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), '2');
125    $objFormParam->addParam("ÇÛãÆü", "deliv_date", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
126}
127
128function lfGetPayment($total_pretax) {
129    $objQuery = new SC_Query();
130    $objQuery->setorder("rank DESC");
131    //ºï½ü¤µ¤ì¤Æ¤¤¤Ê¤¤»ÙʧÊýË¡¤ò¼èÆÀ
132    $arrRet = $objQuery->select("payment_id, payment_method, rule, upper_rule, note, payment_image", "dtb_payment", "del_flg = 0 AND deliv_id IN (SELECT deliv_id FROM dtb_deliv WHERE del_flg = 0) ");
133    //ÍøÍѾò·ï¤«¤é»Ùʧ²ÄǽÊýË¡¤òȽÄê
134    foreach($arrRet as $data) {
135        //²¼¸Â¤È¾å¸Â¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë
136        if($data['rule'] > 0 && $data['upper_rule'] > 0) {
137            if($data['rule'] <= $total_pretax && $data['upper_rule'] >= $total_pretax) {
138                $arrPayment[] = $data;
139            }
140        //²¼¸Â¤Î¤ßÀßÄꤵ¤ì¤Æ¤¤¤ë
141        } elseif($data['rule'] > 0) {   
142            if($data['rule'] <= $total_pretax) {
143                $arrPayment[] = $data;
144            }
145        //¾å¸Â¤Î¤ßÀßÄꤵ¤ì¤Æ¤¤¤ë
146        } elseif($data['upper_rule'] > 0) {
147            if($data['upper_rule'] >= $total_pretax) {
148                $arrPayment[] = $data;
149            }
150        //ÀßÄê¤Ê¤·
151        } else {
152            $arrPayment[] = $data;
153        }   
154    }
155    return $arrPayment;
156}
157
158/* ÆþÎÏÆâÍƤΥÁ¥§¥Ã¥¯ */
159function lfCheckError($arrData) {
160    global $objFormParam;
161    global $objCustomer;
162    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
163    $arrRet =  $objFormParam->getHashArray();
164    $objErr = new SC_CheckError($arrRet);
165    $objErr->arrErr = $objFormParam->checkError();
166   
167    if($_POST['point_check'] == '1') {
168        $objErr->doFunc(array("¥Ý¥¤¥ó¥È¤ò»ÈÍѤ¹¤ë", "point_check"), array("EXIST_CHECK"));
169        $objErr->doFunc(array("¥Ý¥¤¥ó¥È", "use_point"), array("EXIST_CHECK"));
170        $max_point = $objCustomer->getValue('point');
171        if($max_point == "") {
172            $max_point = 0;
173        }
174        if($arrRet['use_point'] > $max_point) {
175            $objErr->arrErr['use_point'] = "¢¨ ¤´ÍøÍѥݥ¤¥ó¥È¤¬½ê»ý¥Ý¥¤¥ó¥È¤òĶ¤¨¤Æ¤¤¤Þ¤¹¡£<br>";
176        }
177        if(($arrRet['use_point'] * POINT_VALUE) > $arrData['subtotal']) {
178            $objErr->arrErr['use_point'] = "¢¨ ¤´ÍøÍѥݥ¤¥ó¥È¤¬¤´¹ØÆþ¶â³Û¤òĶ¤¨¤Æ¤¤¤Þ¤¹¡£<br>";
179        }
180    }
181    return $objErr->arrErr;
182}
183
184/* »Ùʧ¤¤Êýˡʸ»úÎó¤Î¼èÆÀ */
185function lfGetPaymentInfo($payment_id) {
186    $objQuery = new SC_Query();
187    $where = "payment_id = ?";
188    $arrRet = $objQuery->select("payment_method, charge", "dtb_payment", $where, array($payment_id));
189    return (array($arrRet[0]['payment_method'], $arrRet[0]['charge']));
190}
191
192/* ÇÛÁ÷»þ´Öʸ»úÎó¤Î¼èÆÀ */
193function lfGetDelivTimeInfo($time_id) {
194    $objQuery = new SC_Query();
195    $where = "time_id = ?";
196    $arrRet = $objQuery->select("deliv_id, deliv_time", "dtb_delivtime", $where, array($time_id));
197    return (array($arrRet[0]['deliv_id'], $arrRet[0]['deliv_time']));
198}
199
200/* DB¤Ø¥Ç¡¼¥¿¤ÎÅÐÏ¿ */
201function lfRegistData($uniqid) {
202    global $objFormParam;
203    $arrRet = $objFormParam->getHashArray();
204    $sqlval = $objFormParam->getDbArray();
205    // ÅÐÏ¿¥Ç¡¼¥¿¤ÎºîÀ®
206    $sqlval['order_temp_id'] = $uniqid;
207    $sqlval['update_date'] = 'Now()';
208   
209    if($sqlval['payment_id'] != "") {
210        list($sqlval['payment_method'], $sqlval['charge']) = lfGetPaymentInfo($sqlval['payment_id']);
211    } else {
212        $sqlval['payment_id'] = '0';
213        $sqlval['payment_method'] = "";
214    }
215   
216    if($sqlval['deliv_time_id'] != "") {
217        list($sqlval['deliv_id'], $sqlval['deliv_time']) = lfGetDelivTimeInfo($sqlval['deliv_time_id']);
218    } else {
219        $sqlval['deliv_time_id'] = '0';
220        $sqlval['deliv_id'] = '0';
221        $sqlval['deliv_time'] = "";
222    }
223   
224    // »ÈÍѥݥ¤¥ó¥È¤ÎÀßÄê
225    if($sqlval['point_check'] != '1') {
226        $sqlval['use_point'] = 0;
227    }
228   
229    sfRegistTempOrder($uniqid, $sqlval);
230}
231
232/* ÇÛãÆü°ìÍ÷¤ò¼èÆÀ¤¹¤ë */
233function lfGetDelivDate() {
234    $objCartSess = new SC_CartSession();
235    $objQuery = new SC_Query();
236    // ¾¦ÉÊID¤Î¼èÆÀ
237    $max = $objCartSess->getMax();
238    for($i = 1; $i <= $max; $i++) {
239        if($_SESSION[$objCartSess->key][$i]['id'][0] != "") {
240            $arrID['product_id'][$i] = $_SESSION[$objCartSess->key][$i]['id'][0];
241        }
242    }
243    if(count($arrID['product_id']) > 0) {
244        $id = implode(",", $arrID['product_id']);
245        //¾¦Éʤ«¤éȯÁ÷Ìܰ¤μèÆÀ
246        $deliv_date = $objQuery->get("dtb_products", "MAX(deliv_date_id)", "product_id IN (".$id.")");
247        //ȯÁ÷ÌÜ°Â
248        switch($deliv_date) {
249        //¨ÆüȯÁ÷
250        case '1':
251            $start_day = 1;
252            break;
253        //1-2Æü¸å
254        case '2':
255            $start_day = 3;
256            break;
257        //3-4Æü¸å
258        case '3':
259            $start_day = 5;
260            break;
261        //1½µ´Ö°ÊÆâ
262        case '4':
263            $start_day = 8;
264            break;
265        //2½µ´Ö°ÊÆâ
266        case '5':
267            $start_day = 15;
268            break;
269        //3½µ´Ö°ÊÆâ
270        case '6':
271            $start_day = 22;
272            break;
273        //1¥ö·î°ÊÆâ
274        case '7':
275            $start_day = 32;
276            break;
277        //2¥ö·î°Ê¹ß
278        case '8':
279            $start_day = 62;           
280            break;
281        //¤ª¼è¤ê´ó¤»(¾¦ÉÊÆþ²Ù¸å)
282        case '9':
283            $start_day = "";
284            break;
285        default:
286            //¤ªÆϤ±Æü¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç
287            $start_day = "";
288            break;
289        }
290        //ÇÛã²ÄǽÆü¤Î¥¹¥¿¡¼¥ÈÃͤ«¤é¡¢ÇÛãÆü¤ÎÇÛÎó¤ò¼èÆÀ¤¹¤ë
291        $arrDelivDate = lfGetDateArray($start_day, DELIV_DATE_END_MAX);
292    }
293    return $arrDelivDate;
294}
295
296//ÇÛã²ÄǽÆü¤Î¥¹¥¿¡¼¥ÈÃͤ«¤é¡¢ÇÛãÆü¤ÎÇÛÎó¤ò¼èÆÀ¤¹¤ë
297function lfGetDateArray($start_day, $end_day) {
298    global $arrWDAY;
299    //ÇÛã²ÄǽÆü¤Î¥¹¥¿¡¼¥ÈÃͤ¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤ì¤Ð
300    if($start_day >= 1) {
301        $now_time = time();
302        $max_day = $start_day + $end_day;
303        // ½¸·×
304        for ($i = $start_day; $i < $max_day; $i++) {
305            // ´ðËÜ»þ´Ö¤«¤éÆü¿ô¤òÄɲ䷤Ƥ¤¤¯
306            $tmp_time = $now_time + ($i * 24 * 3600);
307            list($y, $m, $d, $w) = split(" ", date("y m d w", $tmp_time)); 
308            $val = sprintf("%02d/%02d/%02d(%s)", $y, $m, $d, $arrWDAY[$w]);
309            $arrDate[$val] = $val;
310        }
311    } else {
312        $arrDate = false;
313    }
314    return $arrDate;
315}
316
317//°ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤«¤é¤Î¾ðÊó¤ò³ÊǼ¤¹¤ë
318function lfSetOrderTempData($uniqid) {
319    global $objQuery;
320    global $objFormParam;
321   
322    $objQuery = new SC_Query();
323    $col = "payment_id, use_point, deliv_time_id, message, point_check, deliv_date";
324    $from = "dtb_order_temp";
325    $where = "order_temp_id = ?";
326    $arrRet = $objQuery->select($col, $from, $where, array($uniqid));
327    // DBÃͤμèÆÀ
328    $objFormParam->setParam($arrRet[0]);
329    return $objFormParam;
330}
331
332
333?>
Note: See TracBrowser for help on using the repository browser.