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