Warning: Can't use blame annotator:
svn blame failed on branches/version-2_13-dev/data/class/pages/shopping/LC_Page_Shopping.php: バイナリファイル 'file:///home/svn/open/branches/version-2_13-dev/data/class/pages/shopping/LC_Page_Shopping.php' に対しては blame で各行の最終変更者を計算できません 195004

source: branches/version-2_13-dev/data/class/pages/shopping/LC_Page_Shopping.php @ 23026

Revision 23026, 19.7 KB checked in by AMUAMU, 11 years ago (diff)

#2323 (税率対応)
#2235 (越境ECを想定した機能の追加)
#2234 (非会員お客様情報入力テンプレートと機能の共通化)
#2324 (会員登録、注文フォームに「会社名」フィールドを足す)
#2233 (購入手続きのログイン画面でログイン出来ないユーザーがいる)
などの修正

  • 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
RevLine 
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
24require_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 */
33class LC_Page_Shopping 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->arrCountry = $masterData->getMasterData('mtb_country');
47        $this->arrSex = $masterData->getMasterData('mtb_sex');
48        $this->arrJob = $masterData->getMasterData('mtb_job');
49        $this->tpl_onload = 'fnCheckInputDeliv();';
50
51        $objDate = new SC_Date_Ex(BIRTH_YEAR, date('Y',strtotime('now')));
52        $this->arrYear = $objDate->getYear('', START_BIRTH_YEAR, '');
53        $this->arrMonth = $objDate->getMonth(true);
54        $this->arrDay = $objDate->getDay(true);
55
56        $this->httpCacheControl('nocache');
57    }
58
59    /**
60     * Page のプロセス.
61     *
62     * @return void
63     */
64    function process()
65    {
66        parent::process();
67        $this->action();
68        $this->sendResponse();
69    }
70
71    /**
72     * Page のプロセス.
73     *
74     * @return void
75     */
76    function action()
77    {
78        $objSiteSess = new SC_SiteSession_Ex();
79        $objCartSess = new SC_CartSession_Ex();
80        $objCustomer = new SC_Customer_Ex();
81        $objCookie = new SC_Cookie_Ex();
82        $objPurchase = new SC_Helper_Purchase_Ex();
83        $objFormParam = new SC_FormParam_Ex();
84
85        $nonmember_mainpage = 'shopping/nonmember_input.tpl';
86        $nonmember_title = 'お客様情報入力';
87
88        $this->tpl_uniqid = $objSiteSess->getUniqId();
89        $objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess);
90
91        $this->cartKey = $objCartSess->getKey();
92
93        // ログイン済みの場合は次画面に遷移
94        if ($objCustomer->isLoginSuccess(true)) {
95            SC_Response_Ex::sendRedirect(
96                    $this->getNextlocation($this->cartKey, $this->tpl_uniqid,
97                                           $objCustomer, $objPurchase,
98                                           $objSiteSess));
99            SC_Response_Ex::actionExit();
100        }
101        // 非会員かつ, ダウンロード商品の場合はエラー表示
102        else {
103            if ($this->cartKey == PRODUCT_TYPE_DOWNLOAD) {
104                $msg = 'ダウンロード商品を含むお買い物は、会員登録が必要です。<br/>'
105                     . 'お手数ですが、会員登録をお願いします。';
106                SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, $objSiteSess, false, $msg);
107                SC_Response_Ex::actionExit();
108            }
109        }
110
111        switch ($this->getMode()) {
112            // ログイン実行
113            case 'login':
114                $this->lfInitLoginFormParam($objFormParam);
115                $objFormParam->setParam($_POST);
116                $objFormParam->trimParam();
117                $objFormParam->convParam();
118                $objFormParam->toLower('login_email');
119                $this->arrErr = $objFormParam->checkError();
120
121                // ログイン判定
122                if (SC_Utils_Ex::isBlank($this->arrErr)
123                    && $objCustomer->doLogin($objFormParam->getValue('login_email'),
124                                             $objFormParam->getValue('login_pass'))) {
125                    // モバイルサイトで携帯アドレスの登録が無い場合、携帯アドレス登録ページへ遷移
126                    if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
127                        if (!$objCustomer->hasValue('email_mobile')) {
128                            SC_Response_Ex::sendRedirectFromUrlPath('entry/email_mobile.php');
129                            SC_Response_Ex::actionExit();
130                        }
131                    }
132                    // スマートフォンの場合はログイン成功を返す
133                    elseif (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) {
134                        echo SC_Utils_Ex::jsonEncode(array('success' =>
135                                                     $this->getNextLocation($this->cartKey, $this->tpl_uniqid,
136                                                                            $objCustomer, $objPurchase,
137                                                                            $objSiteSess)));
138                        SC_Response_Ex::actionExit();
139                    }
140
141                    // クッキー保存判定
142                    if ($objFormParam->getValue('login_memory') == '1' && $objFormParam->getValue('login_email') != '') {
143                        $objCookie->setCookie('login_email', $objFormParam->getValue('login_email'));
144                    } else {
145                        $objCookie->setCookie('login_email', '');
146                    }
147
148                    SC_Response_Ex::sendRedirect(
149                            $this->getNextLocation($this->cartKey, $this->tpl_uniqid,
150                                                   $objCustomer, $objPurchase,
151                                                   $objSiteSess));
152                    SC_Response_Ex::actionExit();
153                }
154                // ログインに失敗した場合
155                else {
156                    // 仮登録の場合
157                    if (SC_Helper_Customer_Ex::checkTempCustomer($objFormParam->getValue('login_email'))) {
158                        if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) {
159                            echo $this->lfGetErrorMessage(TEMP_LOGIN_ERROR);
160                            SC_Response_Ex::actionExit();
161                        } else {
162                            SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR);
163                            SC_Response_Ex::actionExit();
164                        }
165                    } else {
166                        if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) {
167                            echo $this->lfGetErrorMessage(SITE_LOGIN_ERROR);
168                            SC_Response_Ex::actionExit();
169                        } else {
170                            SC_Utils_Ex::sfDispSiteError(SITE_LOGIN_ERROR);
171                            SC_Response_Ex::actionExit();
172                        }
173                    }
174                }
175                break;
176            // お客様情報登録
177            case 'nonmember_confirm':
178                $this->tpl_mainpage = $nonmember_mainpage;
179                $this->tpl_title = $nonmember_title;
180                $this->lfInitParam($objFormParam);
181                $objFormParam->setParam($_POST);
182                $this->arrErr = $this->lfCheckError($objFormParam);
183
184                if (SC_Utils_Ex::isBlank($this->arrErr)) {
185                    $this->lfRegistData($this->tpl_uniqid, $objPurchase, $objCustomer, $objFormParam);
186
187                    $arrParams = $objFormParam->getHashArray();
188                    $shipping_id = $arrParams['deliv_check'] == '1' ? 1 : 0;
189                    $objPurchase->setShipmentItemTempForSole($objCartSess, $shipping_id);
190
191                    $objSiteSess->setRegistFlag();
192
193                    SC_Response_Ex::sendRedirect(SHOPPING_PAYMENT_URLPATH);
194                    SC_Response_Ex::actionExit();
195                }
196                break;
197
198            // 前のページに戻る
199            case 'return':
200                SC_Response_Ex::sendRedirect(CART_URLPATH);
201                SC_Response_Ex::actionExit();
202                break;
203
204            // 複数配送ページへ遷移
205            case 'multiple':
206                // 複数配送先指定が無効な場合はエラー
207                if (USE_MULTIPLE_SHIPPING === false) {
208                    SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
209                    SC_Response_Ex::actionExit();
210                }
211
212                $this->lfInitParam($objFormParam);
213                $objFormParam->setParam($_POST);
214                $this->arrErr = $this->lfCheckError($objFormParam);
215
216                if (SC_Utils_Ex::isBlank($this->arrErr)) {
217                    $this->lfRegistData($this->tpl_uniqid, $objPurchase, $objCustomer, $objFormParam, true);
218
219                    $objSiteSess->setRegistFlag();
220
221                    SC_Response_Ex::sendRedirect(MULTIPLE_URLPATH);
222                    SC_Response_Ex::actionExit();
223                }
224                $this->tpl_mainpage = $nonmember_mainpage;
225                $this->tpl_title = $nonmember_title;
226                break;
227
228            // お客様情報入力ページの表示
229            case 'nonmember':
230                $this->tpl_mainpage = $nonmember_mainpage;
231                $this->tpl_title = $nonmember_title;
232                $this->lfInitParam($objFormParam);
233                // ※breakなし
234
235            default:
236                // 前のページから戻ってきた場合は, お客様情報入力ページ
237                if (isset($_GET['from']) && $_GET['from'] == 'nonmember') {
238                    $this->tpl_mainpage = $nonmember_mainpage;
239                    $this->tpl_title = $nonmember_title;
240                    $this->lfInitParam($objFormParam);
241                } else {
242                    // 通常はログインページ
243                    $this->lfInitLoginFormParam($objFormParam);
244                }
245
246                $this->setFormParams($objFormParam, $objPurchase, $this->tpl_uniqid);
247                break;
248        }
249
250        // 入力値の取得
251        // TODO: getFormParamListに統一したいが顧客登録系がgetHashArrayなので現在は切替方式
252        if ($this->tpl_mainpage == $nonmember_mainpage) {
253            $this->arrForm = $objFormParam->getHashArray();
254        } else {
255            $this->arrForm = $objFormParam->getFormParamList();
256        }
257
258        // 記憶したメールアドレスを取得
259        $this->tpl_login_email = $objCookie->getCookie('login_email');
260        if (!SC_Utils_Ex::isBlank($this->tpl_login_email)) {
261            $this->tpl_login_memory = '1';
262        }
263
264        // 携帯端末IDが一致する会員が存在するかどうかをチェックする。
265        if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_MOBILE) {
266            $this->tpl_valid_phone_id = $objCustomer->checkMobilePhoneId();
267        }
268
269    }
270
271    /**
272     * お客様情報入力時のパラメーター情報の初期化を行う.
273     *
274     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
275     * @return void
276     */
277    function lfInitParam(&$objFormParam)
278    {
279        SC_Helper_Customer_Ex::sfCustomerCommonParam($objFormParam, 'order_');
280        SC_Helper_Customer_Ex::sfCustomerRegisterParam($objFormParam, false, false, 'order_');
281
282        // 不要なパラメーターの削除
283        // XXX: 共通化したことをうまく使えば、以前あった購入同時会員登録も復活出来そうですが
284        $objFormParam->removeParam('order_password');
285        $objFormParam->removeParam('order_password02');
286        $objFormParam->removeParam('order_reminder');
287        $objFormParam->removeParam('order_reminder_answer');
288        $objFormParam->removeParam('order_mailmaga_flg');
289
290        $objFormParam->addParam('別のお届け先', 'deliv_check', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
291
292        SC_Helper_Customer_Ex::sfCustomerCommonParam($objFormParam, 'shipping_');
293    }
294
295    /**
296     * ログイン時のパラメーター情報の初期化を行う.
297     *
298     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
299     * @return void
300     */
301    function lfInitLoginFormParam(&$objFormParam)
302    {
303        $objFormParam->addParam('記憶する', 'login_memory', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
304        $objFormParam->addParam('メールアドレス', 'login_email', '' , 'a', array('EXIST_CHECK', 'EMAIL_CHECK', 'SPTAB_CHECK' ,'EMAIL_CHAR_CHECK'));
305        $objFormParam->addParam('パスワード', 'login_pass', PASSWORD_MAX_LEN, '', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'SPTAB_CHECK'));
306    }
307
308    /**
309     * ログイン済みの場合の遷移先を取得する.
310     *
311     * 商品種別IDが, ダウンロード商品の場合は, 会員情報を受注一時情報に保存し,
312     * 支払方法選択画面のパスを返す.
313     * それ以外は, お届け先選択画面のパスを返す.
314     *
315     * @param integer $product_type_id 商品種別ID
316     * @param string $uniqid 受注一時テーブルのユニークID
317     * @param SC_Customer $objCustomer SC_Customer インスタンス
318     * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス
319     * @param SC_SiteSession $objSiteSess SC_SiteSession インスタンス
320     * @return string 遷移先のパス
321     */
322    function getNextLocation($product_type_id, $uniqid, &$objCustomer, &$objPurchase, &$objSiteSess)
323    {
324        switch ($product_type_id) {
325            case PRODUCT_TYPE_DOWNLOAD:
326                $objPurchase->unsetAllShippingTemp(true);
327                $objPurchase->saveOrderTemp($uniqid, array(), $objCustomer);
328                $objSiteSess->setRegistFlag();
329                return 'payment.php';
330
331            case PRODUCT_TYPE_NORMAL:
332            default:
333                return 'deliv.php';
334        }
335    }
336
337    /**
338     * データの一時登録を行う.
339     *
340     * 非会員向けの処理
341     * @param integer $uniqid 受注一時テーブルのユニークID
342     * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス
343     * @param SC_Customer $objCustomer SC_Customer インスタンス
344     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
345     * @param boolean $isMultiple 複数配送の場合 true
346     */
347    function lfRegistData($uniqid, &$objPurchase, &$objCustomer, &$objFormParam, $isMultiple = false)
348    {
349        $arrParams = $objFormParam->getHashArray();
350
351        // 注文者をお届け先とする配列を取得
352        $arrShippingOwn = array();
353        $objPurchase->copyFromOrder($arrShippingOwn, $arrParams);
354
355        // 都度入力されたお届け先
356        $arrShipping = $objPurchase->extractShipping($arrParams);
357
358        if ($isMultiple) {
359            $objPurchase->unsetOneShippingTemp(0);
360            $objPurchase->unsetOneShippingTemp(1);
361            $objPurchase->saveShippingTemp($arrShippingOwn, 0);
362            if ($arrParams['deliv_check'] == '1') {
363                $objPurchase->saveShippingTemp($arrShipping, 1);
364            }
365        } else {
366            $objPurchase->unsetAllShippingTemp(true);
367            if ($arrParams['deliv_check'] == '1') {
368                $objPurchase->saveShippingTemp($arrShipping, 1);
369            } else {
370                $objPurchase->saveShippingTemp($arrShippingOwn, 0);
371            }
372        }
373
374        $arrValues = $objFormParam->getDbArray();
375
376        // 登録データの作成
377        $arrValues['order_birth'] = SC_Utils_Ex::sfGetTimestamp($arrParams['year'], $arrParams['month'], $arrParams['day']);
378        $arrValues['update_date'] = 'CURRENT_TIMESTAMP';
379        $arrValues['customer_id'] = '0';
380        $objPurchase->saveOrderTemp($uniqid, $arrValues, $objCustomer);
381    }
382
383    /**
384     * 入力内容のチェックを行う.
385     *
386     * 追加の必須チェック, 相関チェックを行うため, SC_CheckError を使用する.
387     *
388     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
389     * @return array エラー情報の配
390     */
391    function lfCheckError(&$objFormParam)
392    {
393        $objErr = SC_Helper_Customer_Ex::sfCustomerCommonErrorCheck($objFormParam, 'order_');
394
395        // 別のお届け先チェック
396        if (isset($arrParams['deliv_check']) && $arrParams['deliv_check'] == '1') {
397            $objErr2 = SC_Helper_Customer_Ex::sfCustomerCommonErrorCheck($objFormParam, 'shipping_');
398            $objErr->arrErr = array_merge((array)$objErr->arrErr, (array)$objErr2->arrErr);
399        } else {
400            // shipping系のエラーは無視
401            foreach ($objErr->arrErr as $key => $val) {
402                if (substr($key, 0, strlen('shipping_')) == 'shipping_') {
403                    unset($objErr->arrErr[$key]);
404                }
405            }
406        }
407
408        // 複数項目チェック
409        $objErr->doFunc(array('生年月日', 'year', 'month', 'day'), array('CHECK_BIRTHDAY'));
410        $objErr->doFunc(array('メールアドレス', 'メールアドレス(確認)', 'order_email', 'order_email02'), array('EQUAL_CHECK'));
411
412        return $objErr->arrErr;
413    }
414
415    /**
416     * 入力済みの購入情報をフォームに設定する.
417     *
418     * 受注一時テーブル, セッションの配送情報から入力済みの購入情報を取得し,
419     * フォームに設定する.
420     *
421     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
422     * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス
423     * @param integer $uniqid 購入一時情報のユニークID
424     * @return void
425     */
426    function setFormParams(&$objFormParam, &$objPurchase, $uniqid)
427    {
428        $arrOrderTemp = $objPurchase->getOrderTemp($uniqid);
429        if (SC_Utils_Ex::isBlank($arrOrderTemp)) {
430            $arrOrderTemp = array(
431                'order_email' => '',
432                'order_birth' => '',
433            );
434        }
435        $arrShippingTemp = $objPurchase->getShippingTemp();
436
437        $objFormParam->setParam($arrOrderTemp);
438        /*
439         * count($arrShippingTemp) > 1 は複数配送であり,
440         * $arrShippingTemp[0] は注文者が格納されている
441         */
442        if (count($arrShippingTemp) > 1) {
443            $objFormParam->setParam($arrShippingTemp[1]);
444        } else {
445            if ($arrOrderTemp['deliv_check'] == 1) {
446                $objFormParam->setParam($arrShippingTemp[1]);
447            } else {
448                $objFormParam->setParam($arrShippingTemp[0]);
449            }
450        }
451        $objFormParam->setValue('order_email02', $arrOrderTemp['order_email']);
452        $objFormParam->setDBDate($arrOrderTemp['order_birth']);
453    }
454
455    /**
456     * エラーメッセージを JSON 形式で返す.
457     *
458     * TODO リファクタリング
459     * この関数は主にスマートフォンで使用します.
460     *
461     * @param integer エラーコード
462     * @return string JSON 形式のエラーメッセージ
463     * @see LC_PageError
464     */
465    function lfGetErrorMessage($error)
466    {
467        switch ($error) {
468            case TEMP_LOGIN_ERROR:
469                $msg = "メールアドレスもしくはパスワードが正しくありません。\n本登録がお済みでない場合は、仮登録メールに記載されているURLより本登録を行ってください。";
470                break;
471            case SITE_LOGIN_ERROR:
472            default:
473                $msg = 'メールアドレスもしくはパスワードが正しくありません。';
474        }
475
476        return SC_Utils_Ex::jsonEncode(array('login_error' => $msg));
477    }
478}
Note: See TracBrowser for help on using the repository browser.