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

Revision 21629, 9.1 KB checked in by Seasoft, 12 years ago (diff)

#1439 (「お届け先の指定」に戻った際に、選択した状態を引き継いでいない)

  • 実装誤りの修正

#1672 (非会員購入時「お届け先の複数指定」から戻るボタンで遷移すると追加したお届け先が削除される)

  • 実装誤りの修正

#1675 (「お届け先の複数指定」画面での入力内容が復元されない)
#1315 (複数のお届け先関連のキー情報が怪しい)

  • 根本的な解決ではありませんが、とりあえず会員に関しては other_deliv_id を使うようにした。

#1613 (typo修正・ソース整形・ソースコメントの改善)

  • 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-2011 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_Deliv extends LC_Page_Ex {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $masterData = new SC_DB_MasterData();
47        $this->arrPref = $masterData->getMasterData('mtb_pref');
48        $this->tpl_title = 'お届け先の指定';
49        $this->httpCacheControl('nocache');
50    }
51
52    /**
53     * Page のプロセス.
54     *
55     * @return void
56     */
57    function process() {
58        parent::process();
59        $this->action();
60        $this->sendResponse();
61    }
62
63    /**
64     * Page のプロセス.
65     *
66     * @return void
67     */
68    function action() {
69        // フックポイント.
70        $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
71        $objPlugin->doAction('lc_page_shopping_deliv_action_start', array($this));
72
73        $objSiteSess = new SC_SiteSession_Ex();
74        $objCartSess = new SC_CartSession_Ex();
75        $objCustomer = new SC_Customer_Ex();
76        $objPurchase = new SC_Helper_Purchase_Ex();
77        $objFormParam = new SC_FormParam_Ex();
78
79        $this->tpl_uniqid = $objSiteSess->getUniqId();
80        $objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess);
81
82        $this->cartKey = $objCartSess->getKey();
83
84        // ログインチェック
85        if (!$objCustomer->isLoginSuccess(true)) {
86            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
87        }
88
89        // ダウンロード商品の場合は、支払方法画面に転送
90        if ($this->cartKey == PRODUCT_TYPE_DOWNLOAD) {
91            $objPurchase->copyFromCustomer($sqlval, $objCustomer, 'shipping');
92            $objPurchase->saveShippingTemp($sqlval);
93            $objPurchase->saveOrderTemp($this->tpl_uniqid, $sqlval, $objCustomer);
94            $objSiteSess->setRegistFlag();
95            // フックポイント.
96            $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
97            $objPlugin->doAction('lc_page_shopping_deliv_action_download', array($this));
98
99            SC_Response_Ex::sendRedirect('payment.php');
100            exit;
101        }
102
103        $this->lfInitParam($objFormParam);
104        $objFormParam->setParam($_POST);
105        $objFormParam->convParam();
106        $arrErr = $objFormParam->checkError();
107        if (!SC_Utils_Ex::isBlank($arrErr)) {
108            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
109            exit;
110        }
111
112        $arrForm = $objFormParam->getHashArray();
113
114        switch ($this->getMode()) {
115            // 削除
116            case 'delete':
117                $this->doDelete($arrForm['other_deliv_id']);
118                break;
119
120            // 会員登録住所に送る
121            case 'customer_addr':
122                $objPurchase->unsetShippingTemp();
123
124                $shipping_id = $arrForm['deliv_check'] == -1 ? 0 : $arrForm['deliv_check'];
125                $success = $this->registerDeliv($shipping_id, $this->tpl_uniqid, $objPurchase, $objCustomer);
126                if (!$success) {
127                    SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
128                }
129
130                $objPurchase->setShipmentItemTempForSole($objCartSess, $shipping_id);
131                $objSiteSess->setRegistFlag();
132                SC_Response_Ex::sendRedirect(SHOPPING_PAYMENT_URLPATH);
133                exit;
134                break;
135
136            // 前のページに戻る
137            case 'return':
138                // フックポイント.
139                $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
140                $objPlugin->doAction('lc_page_shopping_deliv_action_return', array($this));
141
142                // 確認ページへ移動
143                SC_Response_Ex::sendRedirect(CART_URLPATH);
144                exit;
145                break;
146
147            // お届け先複数指定
148            case 'multiple':
149                // 複数配送先指定が無効な場合はエラー
150                if (USE_MULTIPLE_SHIPPING === false) {
151                    SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
152                    exit;
153                }
154                // フックポイント.
155                $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
156                $objPlugin->doAction('lc_page_shopping_deliv_action_multiple', array($this));
157
158                SC_Response_Ex::sendRedirect('multiple.php');
159                exit;
160                break;
161
162            default:
163                // 配送IDの取得
164                $shippingData = $objPurchase->getShippingTemp();
165                $arrShippingId = array_keys($shippingData);
166                if (isset($arrShippingId[0])) {
167                    $this->arrForm['deliv_check']['value'] = $arrShippingId[0] == 0 ? -1 : $arrShippingId[0];
168                }
169                break;
170        }
171
172        // 登録済み住所を取得
173        $this->arrAddr = $objCustomer->getCustomerAddress($objCustomer->getValue('customer_id'));
174        $this->tpl_addrmax = count($this->arrAddr);
175
176        // フックポイント.
177        $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
178        $objPlugin->doAction('lc_page_shopping_deliv_action_end', array($this));
179    }
180
181    /**
182     * デストラクタ.
183     *
184     * @return void
185     */
186    function destroy() {
187        parent::destroy();
188    }
189
190    /**
191     * パラメーター情報の初期化を行う.
192     *
193     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
194     * @return void
195     */
196    function lfInitParam(&$objFormParam) {
197        $objFormParam->addParam('その他のお届け先ID', 'other_deliv_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
198        $objFormParam->addParam('お届け先チェック', 'deliv_check', INT_LEN, 'n', array('MAX_LENGTH_CHECK'));
199    }
200
201    /**
202     * その他のお届け先情報を削除する.
203     *
204     * @param integer $other_deliv_id その他のお届け先ID
205     * @return void
206     */
207    function doDelete($other_deliv_id) {
208        $objQuery =& SC_Query_Ex::getSingletonInstance();
209        $where = 'other_deliv_id = ?';
210        $objQuery->delete('dtb_other_deliv', $where, array($other_deliv_id));
211    }
212
213    /**
214     * お届け先チェックの値に応じて, お届け先情報を保存する.
215     *
216     * 会員住所がチェックされている場合は, 会員情報からお届け先を取得する.
217     * その他のお届け先がチェックされている場合は, その他のお届け先からお届け先を取得する.
218     * お届け先チェックの値が不正な場合は false を返す.
219     *
220     * @param integer $other_deliv_id
221     * @param string $uniqid 受注一時テーブルのユニークID
222     * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス
223     * @param SC_Customer $objCustomer SC_Customer インスタンス
224     * @return boolean お届け先チェックの値が妥当な場合 true
225     */
226    function registerDeliv($other_deliv_id, $uniqid, &$objPurchase, &$objCustomer) {
227        GC_Utils_Ex::gfDebugLog('register deliv. deliv_check=' . $deliv_check);
228        $arrValues = array();
229        // 会員登録住所がチェックされている場合
230        if ($other_deliv_id == 0) {
231            $objPurchase->copyFromCustomer($arrValues, $objCustomer, 'shipping');
232        }
233        // 別のお届け先がチェックされている場合
234        else {
235            $objQuery =& SC_Query_Ex::getSingletonInstance();
236            $arrOtherDeliv = $objQuery->getRow('*', 'dtb_other_deliv',
237                                               'customer_id = ? AND other_deliv_id = ?',
238                                               array($objCustomer->getValue('customer_id'), $other_deliv_id));
239            if (empty($arrOtherDeliv)) {
240                return false;
241            }
242
243            $objPurchase->copyFromOrder($arrValues, $arrOtherDeliv, 'shipping', '');
244        }
245        $objPurchase->saveShippingTemp($arrValues, $other_deliv_id);
246        $objPurchase->saveOrderTemp($uniqid, $arrValues, $objCustomer);
247        return true;
248    }
249}
Note: See TracBrowser for help on using the repository browser.