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

Revision 18187, 10.2 KB checked in by ramrun, 15 years ago (diff)

#261 設定見直し

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