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

Revision 19897, 9.8 KB checked in by kotani, 13 years ago (diff)

#880(mobile/sphoneディレクトリを削除)に対応。まずmobileのみ意図通りの動作になるように一部コミット(shopping/入力内容確認ページ)

  • 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$
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        $objCartSess = new SC_CartSession();
73        $objSiteSess = new SC_SiteSession();
74        $objCustomer = new SC_Customer();
75        $objQuery = new SC_Query();
76        $objDb = new SC_Helper_DB_Ex();
77        $objPurchase = new SC_Helper_Purchase_Ex();
78
79        $this->isMultiple = $objPurchase->isMultiple();
80
81        // 前のページで正しく登録手続きが行われた記録があるか判定
82        SC_Utils_Ex::sfIsPrePage($objSiteSess);
83
84        // ユーザユニークIDの取得と購入状態の正当性をチェック
85        $uniqid = $objSiteSess->getUniqId();
86        $objPurchase->verifyChangeCart($uniqid, $objCartSess);
87        $this->tpl_uniqid = $uniqid;
88
89        $this->cartKey = $objCartSess->getKey();
90
91        // カート内商品のチェック
92        $this->tpl_message = $objCartSess->checkProducts($this->cartKey);
93        if (strlen($this->tpl_message) >= 1) {
94            SC_Utils_Ex::sfDispSiteError(SOLD_OUT, '', true);
95        }
96
97        // カートの商品を取得
98        $this->cartItems = $objCartSess->getCartList($this->cartKey);
99        // 合計金額
100        $this->tpl_total_inctax[$this->cartKey] = $objCartSess->getAllProductsTotal($this->cartKey);
101        // 税額
102        $this->tpl_total_tax[$this->cartKey] = $objCartSess->getAllProductsTax($this->cartKey);
103        // ポイント合計
104        $this->tpl_total_point[$this->cartKey] = $objCartSess->getAllProductsPoint($this->cartKey);
105
106        // TODO リファクタリング
107        // 一時受注テーブルの読込
108        $tmpData = $objPurchase->getOrderTemp($uniqid);
109
110        // カート集計を元に最終計算
111        // FIXME 使用ポイント, 配送都道府県, 支払い方法, 手数料の扱い
112        $arrData = array_merge($tmpData, $objCartSess->calculate($this->cartKey, $objCustomer, $tmpData['use_point'], $tmpData['deliv_pref'], $tmpData['payment_id'], $tmpData['charge'], $tmpData['discount']));
113        unset($arrData['deliv_fee']); // FIXME
114        // 会員ログインチェック
115        if($objCustomer->isLoginSuccess(true)) {
116            $this->tpl_login = '1';
117            $this->tpl_user_point = $objCustomer->getValue('point');
118        }
119
120        // 決済区分を取得する
121        $payment_type = "";
122        if($objDb->sfColumnExists("dtb_payment", "memo01")){
123            // MEMO03に値が入っている場合には、モジュール追加されたものとみなす
124            $sql = "SELECT memo03 FROM dtb_payment WHERE payment_id = ?";
125            $arrPayment = $objQuery->getAll($sql, array($arrData['payment_id']));
126            $payment_type = $arrPayment[0]["memo03"];
127        }
128        $this->payment_type = $payment_type;
129
130        $this->shipping = $objPurchase->getShippingTemp();
131
132        if (!isset($_POST['mode'])) $_POST['mode'] = "";
133
134        switch($_POST['mode']) {
135        // 前のページに戻る
136        case 'return':
137            // 正常な推移であることを記録しておく
138            $objSiteSess->setRegistFlag();
139            $this->objDisplay->redirect($this->getLocation(SHOPPING_PAYMENT_URL_PATH));
140            exit;
141            break;
142        case 'confirm':
143            // この時点で注文番号を確保しておく(クレジット、コンビニ決済で必要なため)
144            $arrData["order_id"] = $objQuery->nextval("dtb_order_order_id");
145
146            // 集計結果を受注一時テーブルに反映
147            $objPurchase->saveOrderTemp($uniqid, $arrData, $objCustomer);
148            // 正常に登録されたことを記録しておく
149            $objSiteSess->setRegistFlag();
150
151            // 決済方法により画面切替
152            if($payment_type != "") {
153                $_SESSION["payment_id"] = $arrData['payment_id'];
154
155                $objPurchase->completeOrder(ORDER_PENDING);
156                $this->objDisplay->redirect($this->getLocation(SHOPPING_MODULE_URL_PATH));
157            }else{
158                // 受注を完了し, 購入完了ページへ
159                $objPurchase->completeOrder(ORDER_NEW);
160                $objPurchase->sendOrderMail($arrData["order_id"]);
161                $this->objDisplay->redirect($this->getLocation(SHOPPING_COMPLETE_URL_PATH));
162            }
163            exit;
164            break;
165        default:
166            break;
167        }
168        $this->arrData = $arrData;
169    }
170
171    /**
172     * Page のアクション(モバイル).
173     *
174     * @return void
175     */
176    function mobileAction() {
177        $objView = new SC_MobileView();
178        $objCartSess = new SC_CartSession();
179        $objSiteInfo = $objView->objSiteInfo;
180        $objSiteSess = new SC_SiteSession();
181        $objCustomer = new SC_Customer();
182        $objQuery = new SC_Query();
183        $objDb = new SC_Helper_DB_Ex();
184
185        // 前のページで正しく登録手続きが行われた記録があるか判定
186        SC_Utils_Ex::sfIsPrePage($objSiteSess);
187
188        // ユーザユニークIDの取得と購入状態の正当性をチェック
189        $uniqid = SC_Utils_Ex::sfCheckNormalAccess($objSiteSess, $objCartSess);
190        $this->tpl_uniqid = $uniqid;
191
192        //ダウンロード商品判定
193        $this->cartdown = $objDb->chkCartDown($objCartSess);
194
195        // カート集計処理
196        $objDb->sfTotalCart($this, $objCartSess);
197        if (strlen($this->tpl_message) >= 1) {
198            SC_Utils_Ex::sfDispSiteError(SOLD_OUT, '', true);
199        }
200        // 一時受注テーブルの読込
201        $arrData = $objDb->sfGetOrderTemp($uniqid);
202        // カート集計を元に最終計算
203        $arrData = $objDb->sfTotalConfirm($arrData, $this, $objCartSess, null, $objCustomer);
204
205        // 会員ログインチェック
206        if($objCustomer->isLoginSuccess(true)) {
207            $this->tpl_login = '1';
208            $this->tpl_user_point = $objCustomer->getValue('point');
209        }
210
211        // 決済区分を取得する
212        $payment_type = "";
213        if($objDb->sfColumnExists("dtb_payment", "memo01")){
214            // MEMO03に値が入っている場合には、モジュール追加されたものとみなす
215            $sql = "SELECT memo03 FROM dtb_payment WHERE payment_id = ?";
216            $arrPayment = $objQuery->getAll($sql, array($arrData['payment_id']));
217            $payment_type = $arrPayment[0]["memo03"];
218        }
219        $this->payment_type = $payment_type;
220
221        if (!isset($_POST['mode'])) $_POST['mode'] = "";
222
223        switch($_POST['mode']) {
224            // 前のページに戻る
225        case 'return':
226            // 正常な推移であることを記録しておく
227            $objSiteSess->setRegistFlag();
228            $this->objDisplay->redirect($this->getLocation(MOBILE_SHOPPING_PAYMENT_URL_PATH));
229            exit;
230            break;
231        case 'confirm':
232            // この時点で注文番号を確保しておく(クレジット、コンビニ決済で必要なため)
233            $arrData["order_id"] = $objQuery->nextVal("dtb_order_order_id");
234
235            // セッション情報を保持
236            $arrData['session'] = serialize($_SESSION);
237
238            // 集計結果を受注一時テーブルに反映
239            $objDb->sfRegistTempOrder($uniqid, $arrData);
240            // 正常に登録されたことを記録しておく
241            $objSiteSess->setRegistFlag();
242
243            // 決済方法により画面切替
244            if($payment_type != "") {
245                $_SESSION["payment_id"] = $arrData['payment_id'];
246                $this->objDisplay->redirect($this->getLocation(MOBILE_SHOPPING_MODULE_URL_PATH));
247            }else{
248                $this->objDisplay->redirect($this->getLocation(MOBILE_SHOPPING_COMPLETE_URL_PATH));
249            }
250            exit;
251            break;
252        default:
253            break;
254        }
255        $this->arrData = $arrData;
256        $this->arrInfo = $objSiteInfo->data;
257    }
258
259    /**
260     * デストラクタ.
261     *
262     * @return void
263     */
264    function destroy() {
265        parent::destroy();
266    }
267}
268?>
Note: See TracBrowser for help on using the repository browser.