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 |
---|
25 | require_once(CLASS_REALDIR . "pages/LC_Page.php"); |
---|
26 | |
---|
27 | /** |
---|
28 | * 入力内容確認のページクラス. |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class 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_title = "ご入力内容のご確認"; |
---|
47 | $masterData = new SC_DB_MasterData(); |
---|
48 | $this->arrPref = $masterData->getMasterData('mtb_pref'); |
---|
49 | $this->arrSex = $masterData->getMasterData("mtb_sex"); |
---|
50 | $this->arrMAILMAGATYPE = $masterData->getMasterData("mtb_mail_magazine_type"); |
---|
51 | $this->arrReminder = $masterData->getMasterData("mtb_reminder"); |
---|
52 | $this->arrDeliv = SC_Helper_DB_Ex::sfGetIDValueList("dtb_deliv", "deliv_id", "service_name"); |
---|
53 | $this->httpCacheControl('nocache'); |
---|
54 | } |
---|
55 | |
---|
56 | /** |
---|
57 | * Page のプロセス. |
---|
58 | * |
---|
59 | * @return void |
---|
60 | */ |
---|
61 | function process() { |
---|
62 | parent::process(); |
---|
63 | $this->action(); |
---|
64 | $this->sendResponse(); |
---|
65 | } |
---|
66 | |
---|
67 | /** |
---|
68 | * Page のアクション. |
---|
69 | * |
---|
70 | * @return void |
---|
71 | */ |
---|
72 | function action() { |
---|
73 | $objCartSess = new SC_CartSession(); |
---|
74 | $objSiteSess = new SC_SiteSession(); |
---|
75 | $objCustomer = new SC_Customer(); |
---|
76 | $objQuery = new SC_Query(); |
---|
77 | $objDb = new SC_Helper_DB_Ex(); |
---|
78 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
79 | |
---|
80 | $this->isMultiple = $objPurchase->isMultiple(); |
---|
81 | |
---|
82 | // 前のページで正しく登録手続きが行われた記録があるか判定 |
---|
83 | if (!$objSiteSess->isPrePage()) { |
---|
84 | SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, $objSiteSess); |
---|
85 | } |
---|
86 | |
---|
87 | // ユーザユニークIDの取得と購入状態の正当性をチェック |
---|
88 | $uniqid = $objSiteSess->getUniqId(); |
---|
89 | $objPurchase->verifyChangeCart($uniqid, $objCartSess); |
---|
90 | $this->tpl_uniqid = $uniqid; |
---|
91 | |
---|
92 | $this->cartKey = $objCartSess->getKey(); |
---|
93 | |
---|
94 | // カート内商品のチェック |
---|
95 | $this->tpl_message = $objCartSess->checkProducts($this->cartKey); |
---|
96 | if (strlen($this->tpl_message) >= 1) { |
---|
97 | SC_Response_Ex::sendRedirect(CART_URLPATH); |
---|
98 | exit; |
---|
99 | } |
---|
100 | |
---|
101 | // カートの商品を取得 |
---|
102 | $this->cartItems = $objCartSess->getCartList($this->cartKey); |
---|
103 | // 合計金額 |
---|
104 | $this->tpl_total_inctax[$this->cartKey] = $objCartSess->getAllProductsTotal($this->cartKey); |
---|
105 | // 税額 |
---|
106 | $this->tpl_total_tax[$this->cartKey] = $objCartSess->getAllProductsTax($this->cartKey); |
---|
107 | // ポイント合計 |
---|
108 | $this->tpl_total_point[$this->cartKey] = $objCartSess->getAllProductsPoint($this->cartKey); |
---|
109 | |
---|
110 | // TODO リファクタリング |
---|
111 | // 一時受注テーブルの読込 |
---|
112 | $tmpData = $objPurchase->getOrderTemp($uniqid); |
---|
113 | |
---|
114 | // カート集計を元に最終計算 |
---|
115 | // FIXME 使用ポイント, 手数料の扱い |
---|
116 | $arrData = array_merge($tmpData, $objCartSess->calculate($this->cartKey, $objCustomer, $tmpData['use_point'], $objPurchase->getShippingPref(), $tmpData['charge'], $tmpData['discount'])); |
---|
117 | |
---|
118 | // 会員ログインチェック |
---|
119 | if($objCustomer->isLoginSuccess(true)) { |
---|
120 | $this->tpl_login = '1'; |
---|
121 | $this->tpl_user_point = $objCustomer->getValue('point'); |
---|
122 | } |
---|
123 | |
---|
124 | // 決済区分を取得する |
---|
125 | $payment_type = ""; |
---|
126 | if($objDb->sfColumnExists("dtb_payment", "memo01")){ |
---|
127 | // MEMO03に値が入っている場合には、モジュール追加されたものとみなす |
---|
128 | $sql = "SELECT memo03 FROM dtb_payment WHERE payment_id = ?"; |
---|
129 | $arrPayment = $objQuery->getAll($sql, array($arrData['payment_id'])); |
---|
130 | $payment_type = $arrPayment[0]["memo03"]; |
---|
131 | } |
---|
132 | $this->payment_type = $payment_type; |
---|
133 | |
---|
134 | $this->shipping = $objPurchase->getShippingTemp(); |
---|
135 | |
---|
136 | switch($this->getMode()) { |
---|
137 | // 前のページに戻る |
---|
138 | case 'return': |
---|
139 | // 正常な推移であることを記録しておく |
---|
140 | $objSiteSess->setRegistFlag(); |
---|
141 | SC_Response_Ex::sendRedirect(SHOPPING_PAYMENT_URLPATH); |
---|
142 | exit; |
---|
143 | break; |
---|
144 | case 'confirm': |
---|
145 | // この時点で注文番号を確保しておく(クレジット、コンビニ決済で必要なため) |
---|
146 | $arrData["order_id"] = $objQuery->nextval("dtb_order_order_id"); |
---|
147 | |
---|
148 | // 集計結果を受注一時テーブルに反映 |
---|
149 | $objPurchase->saveOrderTemp($uniqid, $arrData, $objCustomer); |
---|
150 | // 正常に登録されたことを記録しておく |
---|
151 | $objSiteSess->setRegistFlag(); |
---|
152 | |
---|
153 | // 決済方法により画面切替 |
---|
154 | if($payment_type != "") { |
---|
155 | $_SESSION["payment_id"] = $arrData['payment_id']; |
---|
156 | |
---|
157 | $objPurchase->completeOrder(ORDER_PENDING); |
---|
158 | SC_Response_Ex::sendRedirect(SHOPPING_MODULE_URLPATH); |
---|
159 | }else{ |
---|
160 | // 受注を完了し, 購入完了ページへ |
---|
161 | $objPurchase->completeOrder(ORDER_NEW); |
---|
162 | $objPurchase->sendOrderMail($arrData["order_id"]); |
---|
163 | SC_Response_Ex::sendRedirect(SHOPPING_COMPLETE_URLPATH); |
---|
164 | } |
---|
165 | exit; |
---|
166 | break; |
---|
167 | default: |
---|
168 | break; |
---|
169 | } |
---|
170 | $this->arrData = $arrData; |
---|
171 | } |
---|
172 | |
---|
173 | /** |
---|
174 | * デストラクタ. |
---|
175 | * |
---|
176 | * @return void |
---|
177 | */ |
---|
178 | function destroy() { |
---|
179 | parent::destroy(); |
---|
180 | } |
---|
181 | } |
---|
182 | ?> |
---|