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

Revision 19912, 9.7 KB checked in by nanasess, 13 years ago (diff)

#628(未使用処理・定義などの削除)

  • モジュール連携用のコードを削除

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

  • 受注編集画面を修正

#642(共通ロジックの機能向上)

  • SC_Utils::sfIsPrePage(), SC_Utils::sfCheckNormalAccess() を削除

#631(テーブル定義の改良)

  • データ型を大文字に統一
  • 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        if (!$objSiteSess->isPrePage()) {
83            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, $objSiteSess);
84        }
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(true)) {
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            SC_Response_Ex::sendRedirect(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                SC_Response_Ex::sendRedirect(SHOPPING_MODULE_URL_PATH);
159            }else{
160                // 受注を完了し, 購入完了ページへ
161                $objPurchase->completeOrder(ORDER_NEW);
162                $objPurchase->sendOrderMail($arrData["order_id"]);
163                SC_Response_Ex::sendRedirect(SHOPPING_COMPLETE_URL_PATH);
164            }
165            exit;
166            break;
167        default:
168            break;
169        }
170        $this->arrData = $arrData;
171    }
172
173    /**
174     * Page のアクション(モバイル).
175     *
176     * @return void
177     */
178    function mobileAction() {
179        $objView = new SC_MobileView();
180        $objCartSess = new SC_CartSession();
181        $objSiteInfo = $objView->objSiteInfo;
182        $objSiteSess = new SC_SiteSession();
183        $objCustomer = new SC_Customer();
184        $objQuery = new SC_Query();
185        $objDb = new SC_Helper_DB_Ex();
186
187        // 前のページで正しく登録手続きが行われた記録があるか判定
188        SC_Utils_Ex::sfIsPrePage($objSiteSess);
189
190        // ユーザユニークIDの取得と購入状態の正当性をチェック
191        $uniqid = SC_Utils_Ex::sfCheckNormalAccess($objSiteSess, $objCartSess);
192        $this->tpl_uniqid = $uniqid;
193
194        //ダウンロード商品判定
195        $this->cartdown = $objDb->chkCartDown($objCartSess);
196
197        // カート集計処理
198        $objDb->sfTotalCart($this, $objCartSess);
199        if (strlen($this->tpl_message) >= 1) {
200            SC_Utils_Ex::sfDispSiteError(SOLD_OUT, '', true);
201        }
202        // 一時受注テーブルの読込
203        $arrData = $objDb->sfGetOrderTemp($uniqid);
204        // カート集計を元に最終計算
205        $arrData = $objDb->sfTotalConfirm($arrData, $this, $objCartSess, null, $objCustomer);
206
207        // 会員ログインチェック
208        if($objCustomer->isLoginSuccess(true)) {
209            $this->tpl_login = '1';
210            $this->tpl_user_point = $objCustomer->getValue('point');
211        }
212
213        // 決済区分を取得する
214        $payment_type = "";
215        if($objDb->sfColumnExists("dtb_payment", "memo01")){
216            // MEMO03に値が入っている場合には、モジュール追加されたものとみなす
217            $sql = "SELECT memo03 FROM dtb_payment WHERE payment_id = ?";
218            $arrPayment = $objQuery->getAll($sql, array($arrData['payment_id']));
219            $payment_type = $arrPayment[0]["memo03"];
220        }
221        $this->payment_type = $payment_type;
222
223        if (!isset($_POST['mode'])) $_POST['mode'] = "";
224
225        switch($_POST['mode']) {
226            // 前のページに戻る
227        case 'return':
228            // 正常な推移であることを記録しておく
229            $objSiteSess->setRegistFlag();
230            SC_Response_Ex::sendRedirect(MOBILE_SHOPPING_PAYMENT_URL_PATH);
231            exit;
232            break;
233        case 'confirm':
234            // この時点で注文番号を確保しておく(クレジット、コンビニ決済で必要なため)
235            $arrData["order_id"] = $objQuery->nextVal("dtb_order_order_id");
236
237            // セッション情報を保持
238            $arrData['session'] = serialize($_SESSION);
239
240            // 集計結果を受注一時テーブルに反映
241            $objDb->sfRegistTempOrder($uniqid, $arrData);
242            // 正常に登録されたことを記録しておく
243            $objSiteSess->setRegistFlag();
244
245            // 決済方法により画面切替
246            if($payment_type != "") {
247                $_SESSION["payment_id"] = $arrData['payment_id'];
248                SC_Response_Ex::sendRedirect(MOBILE_SHOPPING_MODULE_URL_PATH);
249            }else{
250                SC_Response_Ex::sendRedirect(MOBILE_SHOPPING_COMPLETE_URL_PATH);
251            }
252            exit;
253            break;
254        default:
255            break;
256        }
257        $this->arrData = $arrData;
258        $this->arrInfo = $objSiteInfo->data;
259    }
260
261    /**
262     * デストラクタ.
263     *
264     * @return void
265     */
266    function destroy() {
267        parent::destroy();
268    }
269}
270?>
Note: See TracBrowser for help on using the repository browser.