source: branches/comu-ver2/data/class/pages/shopping/LC_Page_Shopping_Confirm.php @ 18052

Revision 18052, 10.2 KB checked in by Seasoft, 15 years ago (diff)

・店舗基本情報の取得処理にランタイムのキャッシュ機構を設け、店舗基本情報を深く渡し回す実装を改めた。
・SC_Utils 冒頭のコメントに従い、インスタンスを生成していた処理を、Helper クラスへ移す。計算処理のみ SC_Utils に残す。

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