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