source: branches/version-2_12-dev/data/class/pages/shopping/LC_Page_Shopping_Confirm.php @ 21864

Revision 21864, 7.3 KB checked in by h_yoshimoto, 12 years ago (diff)

#1831 Copyrightを更新

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2012 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
25require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
26
27/**
28 * 入力内容確認のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Shopping_Confirm extends LC_Page_Ex {
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->arrDeliv = SC_Helper_DB_Ex::sfGetIDValueList('dtb_deliv', 'deliv_id', 'service_name');
53        $this->httpCacheControl('nocache');
54    }
55
56    /**
57     * Page のプロセス.
58     *
59     * @return void
60     */
61    function process() {
62        parent::process();
63        $this->action();
64        $this->sendResponse();
65    }
66
67    /**
68     * Page のアクション.
69     *
70     * @return void
71     */
72    function action() {
73
74        $objCartSess = new SC_CartSession_Ex();
75        $objSiteSess = new SC_SiteSession_Ex();
76        $objCustomer = new SC_Customer_Ex();
77        $objQuery =& SC_Query_Ex::getSingletonInstance();
78        $objPurchase = new SC_Helper_Purchase_Ex();
79        $objHelperMail = new SC_Helper_Mail();
80        $objHelperMail->setPage($this);
81
82        $this->is_multiple = $objPurchase->isMultiple();
83
84        // 前のページで正しく登録手続きが行われた記録があるか判定
85        if (!$objSiteSess->isPrePage()) {
86            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, $objSiteSess);
87        }
88
89        // ユーザユニークIDの取得と購入状態の正当性をチェック
90        $this->tpl_uniqid = $objSiteSess->getUniqId();
91        $objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess);
92
93        $this->cartKey = $objCartSess->getKey();
94
95        // カート内商品のチェック
96        $this->tpl_message = $objCartSess->checkProducts($this->cartKey);
97        if (!SC_Utils_Ex::isBlank($this->tpl_message)) {
98
99            SC_Response_Ex::sendRedirect(CART_URLPATH);
100            SC_Response_Ex::actionExit();
101        }
102
103        // カートの商品を取得
104        $this->arrShipping = $objPurchase->getShippingTemp($this->is_multiple);
105        $this->arrCartItems = $objCartSess->getCartList($this->cartKey);
106        // 合計金額
107        $this->tpl_total_inctax[$this->cartKey] = $objCartSess->getAllProductsTotal($this->cartKey);
108        // 税額
109        $this->tpl_total_tax[$this->cartKey] = $objCartSess->getAllProductsTax($this->cartKey);
110        // ポイント合計
111        $this->tpl_total_point[$this->cartKey] = $objCartSess->getAllProductsPoint($this->cartKey);
112
113        // 一時受注テーブルの読込
114        $arrOrderTemp = $objPurchase->getOrderTemp($this->tpl_uniqid);
115
116        // カート集計を元に最終計算
117        $arrCalcResults = $objCartSess->calculate($this->cartKey, $objCustomer,
118                                                  $arrOrderTemp['use_point'],
119                                                  $objPurchase->getShippingPref($this->is_multiple),
120                                                  $arrOrderTemp['charge'],
121                                                  $arrOrderTemp['discount'],
122                                                  $arrOrderTemp['deliv_id']);
123        $this->arrForm = array_merge($arrOrderTemp, $arrCalcResults);
124
125        // 会員ログインチェック
126        if ($objCustomer->isLoginSuccess(true)) {
127            $this->tpl_login = '1';
128            $this->tpl_user_point = $objCustomer->getValue('point');
129        }
130
131        // 決済モジュールを使用するかどうか
132        $this->use_module = $this->useModule($this->arrForm['payment_id']);
133
134        switch ($this->getMode()) {
135            // 前のページに戻る
136            case 'return':
137                // 正常な推移であることを記録しておく
138                $objSiteSess->setRegistFlag();
139
140
141                SC_Response_Ex::sendRedirect(SHOPPING_PAYMENT_URLPATH);
142                SC_Response_Ex::actionExit();
143                break;
144            case 'confirm':
145                /*
146                 * 決済モジュールで必要なため, 受注番号を取得
147                 */
148                $this->arrForm['order_id'] = $objQuery->nextval('dtb_order_order_id');
149                $_SESSION['order_id'] = $this->arrForm['order_id'];
150
151                // 集計結果を受注一時テーブルに反映
152                $objPurchase->saveOrderTemp($this->tpl_uniqid, $this->arrForm,
153                                            $objCustomer);
154
155                // 正常に登録されたことを記録しておく
156                $objSiteSess->setRegistFlag();
157
158                // 決済モジュールを使用する場合
159                if ($this->use_module) {
160                    $objPurchase->completeOrder(ORDER_PENDING);
161
162
163                    SC_Response_Ex::sendRedirect(SHOPPING_MODULE_URLPATH);
164                }
165                // 購入完了ページ
166                else {
167                    $objPurchase->completeOrder(ORDER_NEW);
168                    $template_id = SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE ? 2 : 1;
169                    $objHelperMail->sfSendOrderMail(
170                            $this->arrForm['order_id'],
171                            $template_id);
172
173                    SC_Response_Ex::sendRedirect(SHOPPING_COMPLETE_URLPATH);
174                }
175                SC_Response_Ex::actionExit();
176                break;
177            default:
178                break;
179        }
180
181    }
182
183    /**
184     * デストラクタ.
185     *
186     * @return void
187     */
188    function destroy() {
189        parent::destroy();
190    }
191
192    /**
193     * 決済モジュールを使用するかどうか.
194     *
195     * dtb_payment.memo03 に値が入っている場合は決済モジュールと見なす.
196     *
197     * @param integer $payment_id 支払い方法ID
198     * @return boolean 決済モジュールを使用する支払い方法の場合 true
199     */
200    function useModule($payment_id) {
201        $objQuery =& SC_Query_Ex::getSingletonInstance();
202        $memo03 = $objQuery->get('memo03', 'dtb_payment', 'payment_id = ?', array($payment_id));
203        return !SC_Utils_Ex::isBlank($memo03);
204    }
205}
Note: See TracBrowser for help on using the repository browser.