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

Revision 18852, 10.7 KB checked in by nanasess, 14 years ago (diff)

商品種別によってカートを分ける(#823)

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