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