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

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

ページ間の遷移方法の改善(#783)

  • PC版のみ実装
  • 購入関連の処理を SC_Helper_Purchase へ移動
  • 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_PATH . "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_mainpage = 'shopping/confirm.tpl';
47        $this->tpl_column_num = 1;
48        $this->tpl_css = URL_DIR.'css/layout/shopping/confirm.css';
49        $this->tpl_title = "ご入力内容のご確認";
50        $masterData = new SC_DB_MasterData();
51        $this->arrPref = $masterData->getMasterData("mtb_pref", array("pref_id", "pref_name", "rank"));
52        $this->arrSex = $masterData->getMasterData("mtb_sex");
53        $this->arrMAILMAGATYPE = $masterData->getMasterData("mtb_mail_magazine_type");
54        $this->arrReminder = $masterData->getMasterData("mtb_reminder");
55        $this->httpCacheControl('nocache');
56    }
57
58    /**
59     * Page のプロセス.
60     *
61     * @return void
62     */
63    function process() {
64        global $objCampaignSess;
65
66        $objView = new SC_SiteView();
67        $objCartSess = new SC_CartSession();
68        $objSiteInfo = $objView->objSiteInfo;
69        $objSiteSess = new SC_SiteSession();
70        $objCampaignSess = new SC_CampaignSession();
71        $objCustomer = new SC_Customer();
72        $objQuery = new SC_Query();
73        $objDb = new SC_Helper_DB_Ex();
74
75        // 前のページで正しく登録手続きが行われた記録があるか判定
76        SC_Utils_Ex::sfIsPrePage($objSiteSess);
77
78        // ユーザユニークIDの取得と購入状態の正当性をチェック
79        $uniqid = SC_Utils_Ex::sfCheckNormalAccess($objSiteSess, $objCartSess);
80        $this->tpl_uniqid = $uniqid;
81
82        //ダウンロード商品判定
83        $this->cartdown = $objDb->chkCartDown($objCartSess);
84
85
86        $this->cartKey = $_SESSION['cartKey'];
87
88        // カート内商品のチェック
89        $this->tpl_message = $objCartSess->checkProducts($this->cartKey);
90        if (strlen($this->tpl_message) >= 1) {
91            SC_Utils_Ex::sfDispSiteError(SOLD_OUT, '', true);
92        }
93
94        // カートの商品を取得
95        $this->cartItems = $objCartSess->getCartList($this->cartKey);
96        // 合計金額
97        $this->tpl_total_pretax[$this->cartKey] = $objCartSess->getAllProductsTotal($this->cartKey);
98        // 税額
99        $this->tpl_total_tax[$this->cartKey] = $objCartSess->getAllProductsTax($this->cartKey);
100        // ポイント合計
101        $this->tpl_total_point[$this->cartKey] = $objCartSess->getAllProductsPoint($this->cartKey);
102
103        // TODO リファクタリング
104        // 一時受注テーブルの読込
105        $tmpData = $objDb->sfGetOrderTemp($uniqid);
106
107        // カート集計を元に最終計算
108        // FIXME 使用ポイント, 配送都道府県, 支払い方法, 手数料の扱い
109        $arrData = array_merge($tmpData, $objCartSess->calculate($this->cartKey, $objCustomer));
110
111        // 会員ログインチェック
112        if($objCustomer->isLoginSuccess()) {
113            $this->tpl_login = '1';
114            $this->tpl_user_point = $objCustomer->getValue('point');
115        }
116
117        // 決済区分を取得する
118        $payment_type = "";
119        if($objDb->sfColumnExists("dtb_payment", "memo01")){
120            // MEMO03に値が入っている場合には、モジュール追加されたものとみなす
121            $sql = "SELECT memo03 FROM dtb_payment WHERE payment_id = ?";
122            $arrPayment = $objQuery->getAll($sql, array($arrData['payment_id']));
123            $payment_type = $arrPayment[0]["memo03"];
124        }
125        $this->payment_type = $payment_type;
126
127        if (!isset($_POST['mode'])) $_POST['mode'] = "";
128
129        switch($_POST['mode']) {
130        // 前のページに戻る
131        case 'return':
132            // 正常な推移であることを記録しておく
133            $objSiteSess->setRegistFlag();
134            $this->sendRedirect($this->getLocation(URL_SHOP_PAYMENT));
135            exit;
136            break;
137        case 'confirm':
138            // この時点で注文番号を確保しておく(クレジット、コンビニ決済で必要なため)
139            $arrData["order_id"] = $objQuery->nextval("dtb_order_order_id");
140
141            // セッション情報を保持
142            $arrData['session'] = serialize($_SESSION);
143
144            // 集計結果を受注一時テーブルに反映
145            unset($arrData[0]); // FIXME
146            unset($arrData[1]);
147            $objDb->sfRegistTempOrder($uniqid, $arrData);
148            // 正常に登録されたことを記録しておく
149            $objSiteSess->setRegistFlag();
150
151            // 決済方法により画面切替
152            if($payment_type != "") {
153                // TODO 決済方法のモジュールは Plugin として実装したい
154                $_SESSION["payment_id"] = $arrData['payment_id'];
155                $this->sendRedirect($this->getLocation(URL_SHOP_MODULE));
156            }else{
157                // 受注を完了し, 購入完了ページへ
158                $objPurchase = new SC_Helper_Purchase_Ex();
159                $objPurchase->completeOrder();
160                $this->sendRedirect($this->getLocation(URL_SHOP_COMPLETE));
161            }
162            exit;
163            break;
164        default:
165            break;
166        }
167
168        $this->arrData = $arrData;
169        $this->arrInfo = $objSiteInfo->data;
170        $objView->assignobj($this);
171        // フレームを選択(キャンペーンページから遷移なら変更)
172        $objCampaignSess->pageView($objView);
173    }
174
175    /**
176     * モバイルページを初期化する.
177     *
178     * @return void
179     */
180    function mobileInit() {
181        $this->init();
182    }
183
184    /**
185     * Page のプロセス(モバイル).
186     *
187     * @return void
188     */
189    function mobileProcess() {
190        $objView = new SC_MobileView();
191        $objCartSess = new SC_CartSession();
192        $objSiteInfo = $objView->objSiteInfo;
193        $objSiteSess = new SC_SiteSession();
194        $objCustomer = new SC_Customer();
195        $objQuery = new SC_Query();
196        $objDb = new SC_Helper_DB_Ex();
197
198        // 前のページで正しく登録手続きが行われた記録があるか判定
199        SC_Utils_Ex::sfIsPrePage($objSiteSess);
200
201        // ユーザユニークIDの取得と購入状態の正当性をチェック
202        $uniqid = SC_Utils_Ex::sfCheckNormalAccess($objSiteSess, $objCartSess);
203        $this->tpl_uniqid = $uniqid;
204
205        //ダウンロード商品判定
206        $this->cartdown = $objDb->chkCartDown($objCartSess);
207
208        // カート集計処理
209        $objDb->sfTotalCart($this, $objCartSess);
210        if (strlen($this->tpl_message) >= 1) {
211            SC_Utils_Ex::sfDispSiteError(SOLD_OUT, '', true);
212        }
213        // 一時受注テーブルの読込
214        $arrData = $objDb->sfGetOrderTemp($uniqid);
215        // カート集計を元に最終計算
216        $arrData = $objDb->sfTotalConfirm($arrData, $this, $objCartSess, null, $objCustomer);
217
218        // 会員ログインチェック
219        if($objCustomer->isLoginSuccess(true)) {
220            $this->tpl_login = '1';
221            $this->tpl_user_point = $objCustomer->getValue('point');
222        }
223
224        // 決済区分を取得する
225        $payment_type = "";
226        if($objDb->sfColumnExists("dtb_payment", "memo01")){
227            // MEMO03に値が入っている場合には、モジュール追加されたものとみなす
228            $sql = "SELECT memo03 FROM dtb_payment WHERE payment_id = ?";
229            $arrPayment = $objQuery->getAll($sql, array($arrData['payment_id']));
230            $payment_type = $arrPayment[0]["memo03"];
231        }
232        $this->payment_type = $payment_type;
233
234        if (!isset($_POST['mode'])) $_POST['mode'] = "";
235
236        switch($_POST['mode']) {
237            // 前のページに戻る
238        case 'return':
239            // 正常な推移であることを記録しておく
240            $objSiteSess->setRegistFlag();
241            $this->sendRedirect($this->getLocation(MOBILE_URL_SHOP_PAYMENT), true);
242            exit;
243            break;
244        case 'confirm':
245            // この時点で注文番号を確保しておく(クレジット、コンビニ決済で必要なため)
246            $arrData["order_id"] = $objQuery->nextVal("dtb_order_order_id");
247
248            // セッション情報を保持
249            $arrData['session'] = serialize($_SESSION);
250
251            // 集計結果を受注一時テーブルに反映
252            $objDb->sfRegistTempOrder($uniqid, $arrData);
253            // 正常に登録されたことを記録しておく
254            $objSiteSess->setRegistFlag();
255
256            // 決済方法により画面切替
257            if($payment_type != "") {
258                $_SESSION["payment_id"] = $arrData['payment_id'];
259                $this->sendRedirect($this->getLocation(MOBILE_URL_SHOP_MODULE), true);
260            }else{
261                $this->sendRedirect($this->getLocation(MOBILE_URL_SHOP_COMPLETE), true);
262            }
263            exit;
264            break;
265        default:
266            break;
267        }
268        $this->arrData = $arrData;
269        $this->arrInfo = $objSiteInfo->data;
270        $objView->assignobj($this);
271        $objView->display(SITE_FRAME);
272    }
273
274    /**
275     * デストラクタ.
276     *
277     * @return void
278     */
279    function destroy() {
280        parent::destroy();
281    }
282}
283?>
Note: See TracBrowser for help on using the repository browser.