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

Revision 19661, 10.5 KB checked in by nanasess, 13 years ago (diff)

source:branches/camp/camp-2_5-E のマージ

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