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:LC_Page_Shopping_Confirm.php 15532 2007-08-31 14:39:46Z nanasess $ |
---|
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->httpCacheControl('nocache'); |
---|
53 | } |
---|
54 | |
---|
55 | /** |
---|
56 | * Page のプロセス. |
---|
57 | * |
---|
58 | * @return void |
---|
59 | */ |
---|
60 | function process() { |
---|
61 | parent::process(); |
---|
62 | $this->action(); |
---|
63 | $this->sendResponse(); |
---|
64 | } |
---|
65 | |
---|
66 | /** |
---|
67 | * Page のアクション. |
---|
68 | * |
---|
69 | * @return void |
---|
70 | */ |
---|
71 | function action() { |
---|
72 | $objView = new SC_SiteView(); |
---|
73 | $objCartSess = new SC_CartSession(); |
---|
74 | $objSiteInfo = $objView->objSiteInfo; |
---|
75 | $objSiteSess = new SC_SiteSession(); |
---|
76 | $objCustomer = new SC_Customer(); |
---|
77 | $objQuery = new SC_Query(); |
---|
78 | $objDb = new SC_Helper_DB_Ex(); |
---|
79 | |
---|
80 | // 前のページで正しく登録手続きが行われた記録があるか判定 |
---|
81 | SC_Utils_Ex::sfIsPrePage($objSiteSess); |
---|
82 | |
---|
83 | // ユーザユニークIDの取得と購入状態の正当性をチェック |
---|
84 | $uniqid = SC_Utils_Ex::sfCheckNormalAccess($objSiteSess, $objCartSess); |
---|
85 | $this->tpl_uniqid = $uniqid; |
---|
86 | |
---|
87 | //ダウンロード商品判定 |
---|
88 | $this->cartdown = $objDb->chkCartDown($objCartSess); |
---|
89 | |
---|
90 | |
---|
91 | $this->cartKey = $_SESSION['cartKey']; |
---|
92 | |
---|
93 | // カート内商品のチェック |
---|
94 | $this->tpl_message = $objCartSess->checkProducts($this->cartKey); |
---|
95 | if (strlen($this->tpl_message) >= 1) { |
---|
96 | SC_Utils_Ex::sfDispSiteError(SOLD_OUT, '', true); |
---|
97 | } |
---|
98 | |
---|
99 | // カートの商品を取得 |
---|
100 | $this->cartItems = $objCartSess->getCartList($this->cartKey); |
---|
101 | // 合計金額 |
---|
102 | $this->tpl_total_inctax[$this->cartKey] = $objCartSess->getAllProductsTotal($this->cartKey); |
---|
103 | // 税額 |
---|
104 | $this->tpl_total_tax[$this->cartKey] = $objCartSess->getAllProductsTax($this->cartKey); |
---|
105 | // ポイント合計 |
---|
106 | $this->tpl_total_point[$this->cartKey] = $objCartSess->getAllProductsPoint($this->cartKey); |
---|
107 | |
---|
108 | // TODO リファクタリング |
---|
109 | // 一時受注テーブルの読込 |
---|
110 | $tmpData = $objDb->sfGetOrderTemp($uniqid); |
---|
111 | |
---|
112 | // カート集計を元に最終計算 |
---|
113 | // FIXME 使用ポイント, 配送都道府県, 支払い方法, 手数料の扱い |
---|
114 | $arrData = array_merge($tmpData, $objCartSess->calculate($this->cartKey, $objCustomer, $tmpData['use_point'], $tmpData['deliv_pref'], $tmpData['payment_id'], $tmpData['charge'], $tmpData['discount'])); |
---|
115 | |
---|
116 | // 会員ログインチェック |
---|
117 | if($objCustomer->isLoginSuccess()) { |
---|
118 | $this->tpl_login = '1'; |
---|
119 | $this->tpl_user_point = $objCustomer->getValue('point'); |
---|
120 | } |
---|
121 | |
---|
122 | // 決済区分を取得する |
---|
123 | $payment_type = ""; |
---|
124 | if($objDb->sfColumnExists("dtb_payment", "memo01")){ |
---|
125 | // MEMO03に値が入っている場合には、モジュール追加されたものとみなす |
---|
126 | $sql = "SELECT memo03 FROM dtb_payment WHERE payment_id = ?"; |
---|
127 | $arrPayment = $objQuery->getAll($sql, array($arrData['payment_id'])); |
---|
128 | $payment_type = $arrPayment[0]["memo03"]; |
---|
129 | } |
---|
130 | $this->payment_type = $payment_type; |
---|
131 | |
---|
132 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
133 | |
---|
134 | switch($_POST['mode']) { |
---|
135 | // 前のページに戻る |
---|
136 | case 'return': |
---|
137 | // 正常な推移であることを記録しておく |
---|
138 | $objSiteSess->setRegistFlag(); |
---|
139 | $this->objDisplay->redirect($this->getLocation(SHOPPING_PAYMENT_URL_PATH)); |
---|
140 | exit; |
---|
141 | break; |
---|
142 | case 'confirm': |
---|
143 | // この時点で注文番号を確保しておく(クレジット、コンビニ決済で必要なため) |
---|
144 | $arrData["order_id"] = $objQuery->nextval("dtb_order_order_id"); |
---|
145 | |
---|
146 | // セッション情報を保持 |
---|
147 | $arrData['session'] = serialize($_SESSION); |
---|
148 | |
---|
149 | // 集計結果を受注一時テーブルに反映 |
---|
150 | unset($arrData[0]); // FIXME |
---|
151 | unset($arrData[1]); |
---|
152 | $objDb->sfRegistTempOrder($uniqid, $arrData); |
---|
153 | // 正常に登録されたことを記録しておく |
---|
154 | $objSiteSess->setRegistFlag(); |
---|
155 | |
---|
156 | // 決済方法により画面切替 |
---|
157 | if($payment_type != "") { |
---|
158 | $_SESSION["payment_id"] = $arrData['payment_id']; |
---|
159 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
160 | $objPurchase->completeOrder(ORDER_PENDING); |
---|
161 | $this->objDisplay->redirect($this->getLocation(SHOPPING_MODULE_URL_PATH)); |
---|
162 | }else{ |
---|
163 | // 受注を完了し, 購入完了ページへ |
---|
164 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
165 | $objPurchase->completeOrder(ORDER_NEW); |
---|
166 | $objPurchase->sendOrderMail($arrData["order_id"]); |
---|
167 | $this->objDisplay->redirect($this->getLocation(SHOPPING_COMPLETE_URL_PATH)); |
---|
168 | } |
---|
169 | exit; |
---|
170 | break; |
---|
171 | default: |
---|
172 | break; |
---|
173 | } |
---|
174 | $this->arrData = $arrData; |
---|
175 | } |
---|
176 | |
---|
177 | /** |
---|
178 | * モバイルページを初期化する. |
---|
179 | * |
---|
180 | * @return void |
---|
181 | */ |
---|
182 | function mobileInit() { |
---|
183 | $this->init(); |
---|
184 | } |
---|
185 | |
---|
186 | /** |
---|
187 | * Page のプロセス(モバイル). |
---|
188 | * |
---|
189 | * @return void |
---|
190 | */ |
---|
191 | function mobileProcess() { |
---|
192 | parent::mobileProcess(); |
---|
193 | $this->mobileAction(); |
---|
194 | $this->sendResponse(); |
---|
195 | } |
---|
196 | |
---|
197 | /** |
---|
198 | * Page のアクション(モバイル). |
---|
199 | * |
---|
200 | * @return void |
---|
201 | */ |
---|
202 | function mobileAction() { |
---|
203 | $objView = new SC_MobileView(); |
---|
204 | $objCartSess = new SC_CartSession(); |
---|
205 | $objSiteInfo = $objView->objSiteInfo; |
---|
206 | $objSiteSess = new SC_SiteSession(); |
---|
207 | $objCustomer = new SC_Customer(); |
---|
208 | $objQuery = new SC_Query(); |
---|
209 | $objDb = new SC_Helper_DB_Ex(); |
---|
210 | |
---|
211 | // 前のページで正しく登録手続きが行われた記録があるか判定 |
---|
212 | SC_Utils_Ex::sfIsPrePage($objSiteSess); |
---|
213 | |
---|
214 | // ユーザユニークIDの取得と購入状態の正当性をチェック |
---|
215 | $uniqid = SC_Utils_Ex::sfCheckNormalAccess($objSiteSess, $objCartSess); |
---|
216 | $this->tpl_uniqid = $uniqid; |
---|
217 | |
---|
218 | //ダウンロード商品判定 |
---|
219 | $this->cartdown = $objDb->chkCartDown($objCartSess); |
---|
220 | |
---|
221 | // カート集計処理 |
---|
222 | $objDb->sfTotalCart($this, $objCartSess); |
---|
223 | if (strlen($this->tpl_message) >= 1) { |
---|
224 | SC_Utils_Ex::sfDispSiteError(SOLD_OUT, '', true); |
---|
225 | } |
---|
226 | // 一時受注テーブルの読込 |
---|
227 | $arrData = $objDb->sfGetOrderTemp($uniqid); |
---|
228 | // カート集計を元に最終計算 |
---|
229 | $arrData = $objDb->sfTotalConfirm($arrData, $this, $objCartSess, null, $objCustomer); |
---|
230 | |
---|
231 | // 会員ログインチェック |
---|
232 | if($objCustomer->isLoginSuccess(true)) { |
---|
233 | $this->tpl_login = '1'; |
---|
234 | $this->tpl_user_point = $objCustomer->getValue('point'); |
---|
235 | } |
---|
236 | |
---|
237 | // 決済区分を取得する |
---|
238 | $payment_type = ""; |
---|
239 | if($objDb->sfColumnExists("dtb_payment", "memo01")){ |
---|
240 | // MEMO03に値が入っている場合には、モジュール追加されたものとみなす |
---|
241 | $sql = "SELECT memo03 FROM dtb_payment WHERE payment_id = ?"; |
---|
242 | $arrPayment = $objQuery->getAll($sql, array($arrData['payment_id'])); |
---|
243 | $payment_type = $arrPayment[0]["memo03"]; |
---|
244 | } |
---|
245 | $this->payment_type = $payment_type; |
---|
246 | |
---|
247 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
248 | |
---|
249 | switch($_POST['mode']) { |
---|
250 | // 前のページに戻る |
---|
251 | case 'return': |
---|
252 | // 正常な推移であることを記録しておく |
---|
253 | $objSiteSess->setRegistFlag(); |
---|
254 | $this->objDisplay->redirect($this->getLocation(MOBILE_SHOPPING_PAYMENT_URL_PATH)); |
---|
255 | exit; |
---|
256 | break; |
---|
257 | case 'confirm': |
---|
258 | // この時点で注文番号を確保しておく(クレジット、コンビニ決済で必要なため) |
---|
259 | $arrData["order_id"] = $objQuery->nextVal("dtb_order_order_id"); |
---|
260 | |
---|
261 | // セッション情報を保持 |
---|
262 | $arrData['session'] = serialize($_SESSION); |
---|
263 | |
---|
264 | // 集計結果を受注一時テーブルに反映 |
---|
265 | $objDb->sfRegistTempOrder($uniqid, $arrData); |
---|
266 | // 正常に登録されたことを記録しておく |
---|
267 | $objSiteSess->setRegistFlag(); |
---|
268 | |
---|
269 | // 決済方法により画面切替 |
---|
270 | if($payment_type != "") { |
---|
271 | $_SESSION["payment_id"] = $arrData['payment_id']; |
---|
272 | $this->objDisplay->redirect($this->getLocation(MOBILE_SHOPPING_MODULE_URL_PATH)); |
---|
273 | }else{ |
---|
274 | $this->objDisplay->redirect($this->getLocation(MOBILE_SHOPPING_COMPLETE_URL_PATH)); |
---|
275 | } |
---|
276 | exit; |
---|
277 | break; |
---|
278 | default: |
---|
279 | break; |
---|
280 | } |
---|
281 | $this->arrData = $arrData; |
---|
282 | $this->arrInfo = $objSiteInfo->data; |
---|
283 | } |
---|
284 | |
---|
285 | /** |
---|
286 | * デストラクタ. |
---|
287 | * |
---|
288 | * @return void |
---|
289 | */ |
---|
290 | function destroy() { |
---|
291 | parent::destroy(); |
---|
292 | } |
---|
293 | } |
---|
294 | ?> |
---|