| 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
| 5 | * Copyright(c) 2000-2013 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 | require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php'; |
---|
| 25 | |
---|
| 26 | /** |
---|
| 27 | * 入力内容確認のページクラス. |
---|
| 28 | * |
---|
| 29 | * @package Page |
---|
| 30 | * @author LOCKON CO.,LTD. |
---|
| 31 | * @version $Id$ |
---|
| 32 | */ |
---|
| 33 | class LC_Page_Shopping_Confirm extends LC_Page_Ex |
---|
| 34 | { |
---|
| 35 | /** |
---|
| 36 | * Page を初期化する. |
---|
| 37 | * |
---|
| 38 | * @return void |
---|
| 39 | */ |
---|
| 40 | function init() |
---|
| 41 | { |
---|
| 42 | parent::init(); |
---|
| 43 | $this->tpl_title = '入力内容のご確認'; |
---|
| 44 | $masterData = new SC_DB_MasterData_Ex(); |
---|
| 45 | $this->arrPref = $masterData->getMasterData('mtb_pref'); |
---|
| 46 | $this->arrSex = $masterData->getMasterData('mtb_sex'); |
---|
| 47 | $this->arrJob = $masterData->getMasterData('mtb_job'); |
---|
| 48 | $this->arrMAILMAGATYPE = $masterData->getMasterData('mtb_mail_magazine_type'); |
---|
| 49 | $this->arrReminder = $masterData->getMasterData('mtb_reminder'); |
---|
| 50 | $this->arrDeliv = SC_Helper_Delivery_Ex::getIDValueList('service_name'); |
---|
| 51 | $this->httpCacheControl('nocache'); |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | /** |
---|
| 55 | * Page のプロセス. |
---|
| 56 | * |
---|
| 57 | * @return void |
---|
| 58 | */ |
---|
| 59 | function process() |
---|
| 60 | { |
---|
| 61 | parent::process(); |
---|
| 62 | $this->action(); |
---|
| 63 | $this->sendResponse(); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | /** |
---|
| 67 | * Page のアクション. |
---|
| 68 | * |
---|
| 69 | * @return void |
---|
| 70 | */ |
---|
| 71 | function action() |
---|
| 72 | { |
---|
| 73 | $objCartSess = new SC_CartSession_Ex(); |
---|
| 74 | $objSiteSess = new SC_SiteSession_Ex(); |
---|
| 75 | $objCustomer = new SC_Customer_Ex(); |
---|
| 76 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
| 77 | |
---|
| 78 | $this->is_multiple = $objPurchase->isMultiple(); |
---|
| 79 | |
---|
| 80 | // 前のページで正しく登録手続きが行われた記録があるか判定 |
---|
| 81 | if (!$objSiteSess->isPrePage()) { |
---|
| 82 | SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, $objSiteSess); |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | // ユーザユニークIDの取得と購入状態の正当性をチェック |
---|
| 86 | $this->tpl_uniqid = $objSiteSess->getUniqId(); |
---|
| 87 | $objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess); |
---|
| 88 | |
---|
| 89 | $this->cartKey = $objCartSess->getKey(); |
---|
| 90 | |
---|
| 91 | // カート内商品のチェック |
---|
| 92 | $this->tpl_message = $objCartSess->checkProducts($this->cartKey); |
---|
| 93 | if (!SC_Utils_Ex::isBlank($this->tpl_message)) { |
---|
| 94 | SC_Response_Ex::sendRedirect(CART_URLPATH); |
---|
| 95 | SC_Response_Ex::actionExit(); |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | // カートの商品を取得 |
---|
| 99 | $this->arrShipping = $objPurchase->getShippingTemp($this->is_multiple); |
---|
| 100 | $this->arrCartItems = $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 | // 一時受注テーブルの読込 |
---|
| 109 | $arrOrderTemp = $objPurchase->getOrderTemp($this->tpl_uniqid); |
---|
| 110 | |
---|
| 111 | // カート集計を元に最終計算 |
---|
| 112 | $arrCalcResults = $objCartSess->calculate($this->cartKey, $objCustomer, |
---|
| 113 | $arrOrderTemp['use_point'], |
---|
| 114 | $objPurchase->getShippingPref($this->is_multiple), |
---|
| 115 | $arrOrderTemp['charge'], |
---|
| 116 | $arrOrderTemp['discount'], |
---|
| 117 | $arrOrderTemp['deliv_id'], |
---|
| 118 | $arrOrderTemp['order_pref'], // 税金計算の為に追加 注文者基準 |
---|
| 119 | $arrOrderTemp['order_country_id'] // 税金計算の為に追加 注文者基準 |
---|
| 120 | ); |
---|
| 121 | |
---|
| 122 | $this->arrForm = array_merge($arrOrderTemp, $arrCalcResults); |
---|
| 123 | |
---|
| 124 | // 会員ログインチェック |
---|
| 125 | if ($objCustomer->isLoginSuccess(true)) { |
---|
| 126 | $this->tpl_login = '1'; |
---|
| 127 | $this->tpl_user_point = $objCustomer->getValue('point'); |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | // 決済モジュールを使用するかどうか |
---|
| 131 | $this->use_module = SC_Helper_Payment_Ex::useModule($this->arrForm['payment_id']); |
---|
| 132 | |
---|
| 133 | switch ($this->getMode()) { |
---|
| 134 | // 前のページに戻る |
---|
| 135 | case 'return': |
---|
| 136 | // 正常な推移であることを記録しておく |
---|
| 137 | $objSiteSess->setRegistFlag(); |
---|
| 138 | |
---|
| 139 | SC_Response_Ex::sendRedirect(SHOPPING_PAYMENT_URLPATH); |
---|
| 140 | SC_Response_Ex::actionExit(); |
---|
| 141 | break; |
---|
| 142 | case 'confirm': |
---|
| 143 | /* |
---|
| 144 | * 決済モジュールで必要なため, 受注番号を取得 |
---|
| 145 | */ |
---|
| 146 | $this->arrForm['order_id'] = $objPurchase->getNextOrderID(); |
---|
| 147 | $_SESSION['order_id'] = $this->arrForm['order_id']; |
---|
| 148 | |
---|
| 149 | // 集計結果を受注一時テーブルに反映 |
---|
| 150 | $objPurchase->saveOrderTemp($this->tpl_uniqid, $this->arrForm, |
---|
| 151 | $objCustomer); |
---|
| 152 | |
---|
| 153 | // 正常に登録されたことを記録しておく |
---|
| 154 | $objSiteSess->setRegistFlag(); |
---|
| 155 | |
---|
| 156 | // 決済モジュールを使用する場合 |
---|
| 157 | if ($this->use_module) { |
---|
| 158 | $objPurchase->completeOrder(ORDER_PENDING); |
---|
| 159 | |
---|
| 160 | SC_Response_Ex::sendRedirect(SHOPPING_MODULE_URLPATH); |
---|
| 161 | } |
---|
| 162 | // 購入完了ページ |
---|
| 163 | else { |
---|
| 164 | $objPurchase->completeOrder(ORDER_NEW); |
---|
| 165 | SC_Helper_Purchase_Ex::sendOrderMail($this->arrForm['order_id'], $this); |
---|
| 166 | |
---|
| 167 | SC_Response_Ex::sendRedirect(SHOPPING_COMPLETE_URLPATH); |
---|
| 168 | } |
---|
| 169 | SC_Response_Ex::actionExit(); |
---|
| 170 | break; |
---|
| 171 | default: |
---|
| 172 | break; |
---|
| 173 | } |
---|
| 174 | |
---|
| 175 | } |
---|
| 176 | } |
---|