source: branches/version-2_13-dev/data/class/pages/entry/LC_Page_Entry.php @ 23027

Revision 23027, 11.4 KB checked in by yomoro, 11 years ago (diff)

#1506 決済処理中でストップした際に在庫とポイントが差し引かれてしまう 対応。一旦こちらの形でコミットさせていただきます。

  • 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-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:LC_Page_Entry.php 15532 2007-08-31 14:39:46Z nanasess $
32 */
33class LC_Page_Entry extends LC_Page_Ex
34{
35    /**
36     * Page を初期化する.
37     * @return void
38     */
39    function init()
40    {
41        parent::init();
42        $masterData         = new SC_DB_MasterData_Ex();
43        $this->arrPref      = $masterData->getMasterData('mtb_pref');
44        $this->arrJob       = $masterData->getMasterData('mtb_job');
45        $this->arrReminder  = $masterData->getMasterData('mtb_reminder');
46        $this->arrCountry   = $masterData->getMasterData('mtb_country');
47
48        // 生年月日選択肢の取得
49        $objDate            = new SC_Date_Ex(BIRTH_YEAR, date('Y',strtotime('now')));
50        $this->arrYear      = $objDate->getYear('', START_BIRTH_YEAR, '');
51        $this->arrMonth     = $objDate->getMonth(true);
52        $this->arrDay       = $objDate->getDay(true);
53
54        $this->httpCacheControl('nocache');
55    }
56
57    /**
58     * Page のプロセス.
59     *
60     * @return void
61     */
62    function process()
63    {
64        parent::process();
65        $this->action();
66        $this->sendResponse();
67    }
68
69    /**
70     * Page のプロセス
71     * @return void
72     */
73    function action()
74    {
75        //決済処理中ステータスのロールバック
76        SC_Helper_Purchase_Ex::checkSessionPendingOrder();
77        SC_Helper_Purchase_Ex::checkDbMyPendignOrder();
78        SC_Helper_Purchase_Ex::checkDbAllPendingOrder();
79       
80        $objFormParam = new SC_FormParam_Ex();
81
82        // PC時は規約ページからの遷移でなければエラー画面へ遷移する
83        if ($this->lfCheckReferer($_POST, $_SERVER['HTTP_REFERER']) === false) {
84            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
85        }
86
87        SC_Helper_Customer_Ex::sfCustomerEntryParam($objFormParam);
88        $objFormParam->setParam($_POST);
89        $arrForm  = $objFormParam->getHashArray();
90
91        // mobile用(戻るボタンでの遷移かどうかを判定)
92        if (!empty($arrForm['return'])) {
93            $_POST['mode'] = 'return';
94        }
95
96        switch ($this->getMode()) {
97            case 'confirm':
98                if (isset($_POST['submit_address'])) {
99                    // 入力エラーチェック
100                    $this->arrErr = $this->lfCheckError($_POST);
101                    // 入力エラーの場合は終了
102                    if (count($this->arrErr) == 0) {
103                        // 郵便番号検索文作成
104                        $zipcode = $_POST['zip01'] . $_POST['zip02'];
105
106                        // 郵便番号検索
107                        $arrAdsList = SC_Utils_Ex::sfGetAddress($zipcode);
108
109                        // 郵便番号が発見された場合
110                        if (!empty($arrAdsList)) {
111                            $data['pref'] = $arrAdsList[0]['state'];
112                            $data['addr01'] = $arrAdsList[0]['city']. $arrAdsList[0]['town'];
113                            $objFormParam->setParam($data);
114
115                            // 該当無し
116                        } else {
117                            $this->arrErr['zip01'] = '※該当する住所が見つかりませんでした。<br>';
118                        }
119                    }
120                    $this->arrForm  = $objFormParam->getHashArray();
121                    break;
122                }
123
124                //-- 確認
125                $this->arrErr = SC_Helper_Customer_Ex::sfCustomerEntryErrorCheck($objFormParam);
126                $this->arrForm  = $objFormParam->getHashArray();
127                // 入力エラーなし
128                if (empty($this->arrErr)) {
129                    //パスワード表示
130                    $this->passlen      = SC_Utils_Ex::sfPassLen(strlen($this->arrForm['password']));
131
132                    $this->tpl_mainpage = 'entry/confirm.tpl';
133                    $this->tpl_title    = '会員登録(確認ページ)';
134                }
135                break;
136            case 'complete':
137                //-- 会員登録と完了画面
138                $this->arrErr = SC_Helper_Customer_Ex::sfCustomerEntryErrorCheck($objFormParam);
139                $this->arrForm  = $objFormParam->getHashArray();
140                if (empty($this->arrErr)) {
141                    $uniqid             = $this->lfRegistCustomerData($this->lfMakeSqlVal($objFormParam));
142
143                    $this->lfSendMail($uniqid, $this->arrForm);
144
145                    // 仮会員が無効の場合
146                    if (CUSTOMER_CONFIRM_MAIL == false) {
147                        // ログイン状態にする
148                        $objCustomer = new SC_Customer_Ex();
149                        $objCustomer->setLogin($this->arrForm['email']);
150                    }
151
152                    // 完了ページに移動させる。
153                    SC_Response_Ex::sendRedirect('complete.php', array('ci' => SC_Helper_Customer_Ex::sfGetCustomerId($uniqid)));
154                }
155                break;
156            case 'return':
157                $this->arrForm  = $objFormParam->getHashArray();
158                break;
159            default:
160                break;
161        }
162
163    }
164
165    /**
166     * 会員情報の登録
167     *
168     * @access private
169     * @return uniqid
170     */
171    function lfRegistCustomerData($sqlval)
172    {
173        SC_Helper_Customer_Ex::sfEditCustomerData($sqlval);
174
175        return $sqlval['secret_key'];
176    }
177
178    /**
179     * 会員登録に必要なSQLパラメーターの配列を生成する.
180     *
181     * フォームに入力された情報を元に, SQLパラメーターの配列を生成する.
182     * モバイル端末の場合は, email を email_mobile にコピーし,
183     * mobile_phone_id に携帯端末IDを格納する.
184     *
185     * @param mixed $objFormParam
186     * @access private
187     * @return $arrResults
188     */
189    function lfMakeSqlVal(&$objFormParam)
190    {
191        $arrForm                = $objFormParam->getHashArray();
192        $arrResults             = $objFormParam->getDbArray();
193
194        // 生年月日の作成
195        $arrResults['birth']    = SC_Utils_Ex::sfGetTimestamp($arrForm['year'], $arrForm['month'], $arrForm['day']);
196
197        // 仮会員 1 本会員 2
198        $arrResults['status']   = (CUSTOMER_CONFIRM_MAIL == true) ? '1' : '2';
199
200        /*
201         * secret_keyは、テーブルで重複許可されていない場合があるので、
202         * 本会員登録では利用されないがセットしておく。
203         */
204        $arrResults['secret_key'] = SC_Helper_Customer_Ex::sfGetUniqSecretKey();
205
206        // 入会時ポイント
207        $CONF = SC_Helper_DB_Ex::sfGetBasisData();
208        $arrResults['point'] = $CONF['welcome_point'];
209
210        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
211            // 携帯メールアドレス
212            $arrResults['email_mobile']     = $arrResults['email'];
213            // PHONE_IDを取り出す
214            $arrResults['mobile_phone_id']  =  SC_MobileUserAgent_Ex::getId();
215        }
216
217        return $arrResults;
218    }
219
220    /**
221     * 会員登録完了メール送信する
222     *
223     * @access private
224     * @return void
225     */
226    function lfSendMail($uniqid, $arrForm)
227    {
228        $CONF           = SC_Helper_DB_Ex::sfGetBasisData();
229
230        $objMailText    = new SC_SiteView_Ex();
231        $objMailText->setPage($this);
232        $objMailText->assign('CONF', $CONF);
233        $objMailText->assign('name01', $arrForm['name01']);
234        $objMailText->assign('name02', $arrForm['name02']);
235        $objMailText->assign('uniqid', $uniqid);
236        $objMailText->assignobj($this);
237
238        $objHelperMail  = new SC_Helper_Mail_Ex();
239        $objHelperMail->setPage($this);
240
241        // 仮会員が有効の場合
242        if (CUSTOMER_CONFIRM_MAIL == true) {
243            $subject        = $objHelperMail->sfMakeSubject('会員登録のご確認');
244            $toCustomerMail = $objMailText->fetch('mail_templates/customer_mail.tpl');
245        } else {
246            $subject        = $objHelperMail->sfMakeSubject('会員登録のご完了');
247            $toCustomerMail = $objMailText->fetch('mail_templates/customer_regist_mail.tpl');
248        }
249
250        $objMail = new SC_SendMail_Ex();
251        $objMail->setItem(
252            ''                    // 宛先
253            , $subject              // サブジェクト
254            , $toCustomerMail       // 本文
255            , $CONF['email03']      // 配送元アドレス
256            , $CONF['shop_name']    // 配送元 名前
257            , $CONF['email03']      // reply_to
258            , $CONF['email04']      // return_path
259            , $CONF['email04']      // Errors_to
260            , $CONF['email01']      // Bcc
261        );
262        // 宛先の設定
263        $objMail->setTo($arrForm['email'],
264                        $arrForm['name01'] . $arrForm['name02'] .' 様');
265
266        $objMail->sendMail();
267    }
268
269    /**
270     * kiyaku.php からの遷移の妥当性をチェックする
271     *
272     * 以下の内容をチェックし, 妥当であれば true を返す.
273     * 1. 規約ページからの遷移かどうか
274     * 2. PC及びスマートフォンかどうか
275     * 3. $post に何も含まれていないかどうか
276     *
277     * @access protected
278     * @param array $post $_POST のデータ
279     * @param string $referer $_SERVER['HTTP_REFERER'] のデータ
280     * @return boolean kiyaku.php からの妥当な遷移であれば true
281     */
282    function lfCheckReferer(&$post, $referer)
283    {
284        if (SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE
285            && empty($post)
286            && (preg_match('/kiyaku.php/', basename($referer)) === 0)) {
287            return false;
288            }
289
290        return true;
291    }
292
293    /**
294     * 入力エラーのチェック.
295     *
296     * @param array $arrRequest リクエスト値($_GET)
297     * @return array $arrErr エラーメッセージ配列
298     */
299    function lfCheckError($arrRequest)
300    {
301        // パラメーター管理クラス
302        $objFormParam = new SC_FormParam_Ex();
303        // パラメーター情報の初期化
304        $objFormParam->addParam('郵便番号1', 'zip01', ZIP01_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK'));
305        $objFormParam->addParam('郵便番号2', 'zip02', ZIP02_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK'));
306        // // リクエスト値をセット
307        $arrData['zip01'] = $arrRequest['zip01'];
308        $arrData['zip02'] = $arrRequest['zip02'];
309        $objFormParam->setParam($arrData);
310        // エラーチェック
311        $arrErr = $objFormParam->checkError();
312
313        return $arrErr;
314    }
315}
Note: See TracBrowser for help on using the repository browser.