source: branches/version-2_5-dev/data/class/pages/shopping/LC_Page_Shopping_Confirm.php @ 19868

Revision 19868, 10.3 KB checked in by nanasess, 13 years ago (diff)

#843(複数配送先の指定)

  • 購入確認画面を修正
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id Revision Date
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24// {{{ requires
25require_once(CLASS_REALDIR . "pages/LC_Page.php");
26
27/**
28 * 入力内容確認のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id:LC_Page_Shopping_Confirm.php 15532 2007-08-31 14:39:46Z nanasess $
33 */
34class LC_Page_Shopping_Confirm extends LC_Page {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $this->tpl_title = "ご入力内容のご確認";
47        $masterData = new SC_DB_MasterData();
48        $this->arrPref = $masterData->getMasterData('mtb_pref');
49        $this->arrSex = $masterData->getMasterData("mtb_sex");
50        $this->arrMAILMAGATYPE = $masterData->getMasterData("mtb_mail_magazine_type");
51        $this->arrReminder = $masterData->getMasterData("mtb_reminder");
52        $this->httpCacheControl('nocache');
53    }
54
55    /**
56     * Page のプロセス.
57     *
58     * @return void
59     */
60    function process() {
61        parent::process();
62        $this->action();
63        $this->sendResponse();
64    }
65
66    /**
67     * Page のアクション.
68     *
69     * @return void
70     */
71    function action() {
72        $objView = new SC_SiteView();
73        $objCartSess = new SC_CartSession();
74        $objSiteInfo = $objView->objSiteInfo;
75        $objSiteSess = new SC_SiteSession();
76        $objCustomer = new SC_Customer();
77        $objQuery = new SC_Query();
78        $objDb = new SC_Helper_DB_Ex();
79        $objPurchase = new SC_Helper_Purchase_Ex();
80
81        $this->isMultiple = $objPurchase->isMultiple();
82
83        // 前のページで正しく登録手続きが行われた記録があるか判定
84        SC_Utils_Ex::sfIsPrePage($objSiteSess);
85
86        // ユーザユニークIDの取得と購入状態の正当性をチェック
87        $uniqid = $objSiteSess->getUniqId();
88        $objPurchase->verifyChangeCart($uniqid, $objCartSess);
89        $this->tpl_uniqid = $uniqid;
90
91        $this->cartKey = $objCartSess->getKey();
92
93        // カート内商品のチェック
94        $this->tpl_message = $objCartSess->checkProducts($this->cartKey);
95        if (strlen($this->tpl_message) >= 1) {
96            SC_Utils_Ex::sfDispSiteError(SOLD_OUT, '', true);
97        }
98
99        // カートの商品を取得
100        $this->cartItems = $objCartSess->getCartList($this->cartKey);
101        // 合計金額
102        $this->tpl_total_inctax[$this->cartKey] = $objCartSess->getAllProductsTotal($this->cartKey);
103        // 税額
104        $this->tpl_total_tax[$this->cartKey] = $objCartSess->getAllProductsTax($this->cartKey);
105        // ポイント合計
106        $this->tpl_total_point[$this->cartKey] = $objCartSess->getAllProductsPoint($this->cartKey);
107
108        // TODO リファクタリング
109        // 一時受注テーブルの読込
110        $tmpData = $objPurchase->getOrderTemp($uniqid);
111
112        // カート集計を元に最終計算
113        // FIXME 使用ポイント, 配送都道府県, 支払い方法, 手数料の扱い
114        $arrData = array_merge($tmpData, $objCartSess->calculate($this->cartKey, $objCustomer, $tmpData['use_point'], $tmpData['deliv_pref'], $tmpData['payment_id'], $tmpData['charge'], $tmpData['discount']));
115        unset($arrData['deliv_fee']); // FIXME
116        // 会員ログインチェック
117        if($objCustomer->isLoginSuccess()) {
118            $this->tpl_login = '1';
119            $this->tpl_user_point = $objCustomer->getValue('point');
120        }
121
122        // 決済区分を取得する
123        $payment_type = "";
124        if($objDb->sfColumnExists("dtb_payment", "memo01")){
125            // MEMO03に値が入っている場合には、モジュール追加されたものとみなす
126            $sql = "SELECT memo03 FROM dtb_payment WHERE payment_id = ?";
127            $arrPayment = $objQuery->getAll($sql, array($arrData['payment_id']));
128            $payment_type = $arrPayment[0]["memo03"];
129        }
130        $this->payment_type = $payment_type;
131
132        $this->shipping = $objPurchase->getShippingTemp();
133
134        if (!isset($_POST['mode'])) $_POST['mode'] = "";
135
136        switch($_POST['mode']) {
137        // 前のページに戻る
138        case 'return':
139            // 正常な推移であることを記録しておく
140            $objSiteSess->setRegistFlag();
141            $this->objDisplay->redirect($this->getLocation(SHOPPING_PAYMENT_URL_PATH));
142            exit;
143            break;
144        case 'confirm':
145            // この時点で注文番号を確保しておく(クレジット、コンビニ決済で必要なため)
146            $arrData["order_id"] = $objQuery->nextval("dtb_order_order_id");
147
148            // 集計結果を受注一時テーブルに反映
149            $objPurchase->saveOrderTemp($uniqid, $arrData, $objCustomer);
150            // 正常に登録されたことを記録しておく
151            $objSiteSess->setRegistFlag();
152
153            // 決済方法により画面切替
154            if($payment_type != "") {
155                $_SESSION["payment_id"] = $arrData['payment_id'];
156
157                $objPurchase->completeOrder(ORDER_PENDING);
158                $this->objDisplay->redirect($this->getLocation(SHOPPING_MODULE_URL_PATH));
159            }else{
160                // 受注を完了し, 購入完了ページへ
161                $objPurchase->completeOrder(ORDER_NEW);
162                $objPurchase->sendOrderMail($arrData["order_id"]);
163                $this->objDisplay->redirect($this->getLocation(SHOPPING_COMPLETE_URL_PATH));
164            }
165            exit;
166            break;
167        default:
168            break;
169        }
170        $this->arrData = $arrData;
171    }
172
173    /**
174     * モバイルページを初期化する.
175     *
176     * @return void
177     */
178    function mobileInit() {
179        $this->init();
180    }
181
182    /**
183     * Page のプロセス(モバイル).
184     *
185     * @return void
186     */
187    function mobileProcess() {
188        parent::mobileProcess();
189        $this->mobileAction();
190        $this->sendResponse();
191    }
192
193    /**
194     * Page のアクション(モバイル).
195     *
196     * @return void
197     */
198    function mobileAction() {
199        $objView = new SC_MobileView();
200        $objCartSess = new SC_CartSession();
201        $objSiteInfo = $objView->objSiteInfo;
202        $objSiteSess = new SC_SiteSession();
203        $objCustomer = new SC_Customer();
204        $objQuery = new SC_Query();
205        $objDb = new SC_Helper_DB_Ex();
206
207        // 前のページで正しく登録手続きが行われた記録があるか判定
208        SC_Utils_Ex::sfIsPrePage($objSiteSess);
209
210        // ユーザユニークIDの取得と購入状態の正当性をチェック
211        $uniqid = SC_Utils_Ex::sfCheckNormalAccess($objSiteSess, $objCartSess);
212        $this->tpl_uniqid = $uniqid;
213
214        //ダウンロード商品判定
215        $this->cartdown = $objDb->chkCartDown($objCartSess);
216
217        // カート集計処理
218        $objDb->sfTotalCart($this, $objCartSess);
219        if (strlen($this->tpl_message) >= 1) {
220            SC_Utils_Ex::sfDispSiteError(SOLD_OUT, '', true);
221        }
222        // 一時受注テーブルの読込
223        $arrData = $objDb->sfGetOrderTemp($uniqid);
224        // カート集計を元に最終計算
225        $arrData = $objDb->sfTotalConfirm($arrData, $this, $objCartSess, null, $objCustomer);
226
227        // 会員ログインチェック
228        if($objCustomer->isLoginSuccess(true)) {
229            $this->tpl_login = '1';
230            $this->tpl_user_point = $objCustomer->getValue('point');
231        }
232
233        // 決済区分を取得する
234        $payment_type = "";
235        if($objDb->sfColumnExists("dtb_payment", "memo01")){
236            // MEMO03に値が入っている場合には、モジュール追加されたものとみなす
237            $sql = "SELECT memo03 FROM dtb_payment WHERE payment_id = ?";
238            $arrPayment = $objQuery->getAll($sql, array($arrData['payment_id']));
239            $payment_type = $arrPayment[0]["memo03"];
240        }
241        $this->payment_type = $payment_type;
242
243        if (!isset($_POST['mode'])) $_POST['mode'] = "";
244
245        switch($_POST['mode']) {
246            // 前のページに戻る
247        case 'return':
248            // 正常な推移であることを記録しておく
249            $objSiteSess->setRegistFlag();
250            $this->objDisplay->redirect($this->getLocation(MOBILE_SHOPPING_PAYMENT_URL_PATH));
251            exit;
252            break;
253        case 'confirm':
254            // この時点で注文番号を確保しておく(クレジット、コンビニ決済で必要なため)
255            $arrData["order_id"] = $objQuery->nextVal("dtb_order_order_id");
256
257            // セッション情報を保持
258            $arrData['session'] = serialize($_SESSION);
259
260            // 集計結果を受注一時テーブルに反映
261            $objDb->sfRegistTempOrder($uniqid, $arrData);
262            // 正常に登録されたことを記録しておく
263            $objSiteSess->setRegistFlag();
264
265            // 決済方法により画面切替
266            if($payment_type != "") {
267                $_SESSION["payment_id"] = $arrData['payment_id'];
268                $this->objDisplay->redirect($this->getLocation(MOBILE_SHOPPING_MODULE_URL_PATH));
269            }else{
270                $this->objDisplay->redirect($this->getLocation(MOBILE_SHOPPING_COMPLETE_URL_PATH));
271            }
272            exit;
273            break;
274        default:
275            break;
276        }
277        $this->arrData = $arrData;
278        $this->arrInfo = $objSiteInfo->data;
279    }
280
281    /**
282     * デストラクタ.
283     *
284     * @return void
285     */
286    function destroy() {
287        parent::destroy();
288    }
289}
290?>
Note: See TracBrowser for help on using the repository browser.