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

Revision 18217, 10.3 KB checked in by Seasoft, 15 years ago (diff)

#454(非公開の商品を購入できる)を改修

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