source: branches/version-2_13-dev/data/class/pages/mypage/LC_Page_Mypage_History.php @ 23605

Revision 23605, 9.0 KB checked in by kimoto, 10 years ago (diff)

#2448 typo修正・ソース整形・ソースコメントの改善 for 2.13.3

Scrutinizer Auto-Fixes

This patch was automatically generated as part of the following inspection:
 https://scrutinizer-ci.com/g/nobuhiko/EC-CUBE/inspections/d8722894-69a6-4b1b-898d-43618035c60d

Enabled analysis tools:

  • PHP Analyzer
  • PHP PDepend
  • PHP Similarity Analyzer
  • PHP Change Tracking Analyzer
  • 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-2014 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/mypage/LC_Page_AbstractMypage_Ex.php';
25
26/**
27 * 購入履歴 のページクラス.
28 *
29 * @package Page
30 * @author LOCKON CO.,LTD.
31 * @version $Id$
32 */
33class LC_Page_Mypage_History extends LC_Page_AbstractMypage_Ex
34{
35    /**
36     * Page を初期化する.
37     *
38     * @return void
39     */
40    public function init()
41    {
42        parent::init();
43        $this->tpl_mypageno     = 'index';
44        $this->tpl_subtitle     = '購入履歴詳細';
45        $this->httpCacheControl('nocache');
46
47        $masterData             = new SC_DB_MasterData_Ex();
48        $this->arrMAILTEMPLATE  = $masterData->getMasterData('mtb_mail_template');
49        $this->arrPref          = $masterData->getMasterData('mtb_pref');
50        $this->arrCountry       = $masterData->getMasterData('mtb_country');
51        $this->arrWDAY          = $masterData->getMasterData('mtb_wday');
52        $this->arrProductType   = $masterData->getMasterData('mtb_product_type');
53        $this->arrCustomerOrderStatus = $masterData->getMasterData('mtb_customer_order_status');
54    }
55
56    /**
57     * Page のプロセス.
58     *
59     * @return void
60     */
61    public function process()
62    {
63        parent::process();
64    }
65
66    /**
67     * Page のAction.
68     *
69     * @return void
70     */
71    public function action()
72    {
73        //決済処理中ステータスのロールバック
74        $objPurchase = new SC_Helper_Purchase_Ex();
75        $objPurchase->cancelPendingOrder(PENDING_ORDER_CANCEL_FLAG);
76
77        $objCustomer    = new SC_Customer_Ex();
78        $objProduct  = new SC_Product();
79
80        if (!SC_Utils_Ex::sfIsInt($_GET['order_id'])) {
81            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
82        }
83
84        $order_id               = $_GET['order_id'];
85        $this->is_price_change  = false;
86
87        //受注データの取得
88        $this->tpl_arrOrderData = $objPurchase->getOrder($order_id, $objCustomer->getValue('customer_id'));
89
90        if (empty($this->tpl_arrOrderData)) {
91            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
92        }
93
94        $this->arrShipping      = $this->lfGetShippingDate($objPurchase, $order_id, $this->arrWDAY);
95
96        $this->isMultiple       = count($this->arrShipping) > 1;
97        // 支払い方法の取得
98        $this->arrPayment       = SC_Helper_Payment_Ex::getIDValueList();
99        // 受注商品明細の取得
100        $this->tpl_arrOrderDetail = $objPurchase->getOrderDetail($order_id);
101        foreach ($this->tpl_arrOrderDetail as $product_index => $arrOrderProductDetail) {
102            //必要なのは商品の販売金額のみなので、遅い場合は、別途SQL作成した方が良い
103            $arrTempProductDetail = $objProduct->getProductsClass($arrOrderProductDetail['product_class_id']);
104            // 税計算
105            $this->tpl_arrOrderDetail[$product_index]['price_inctax'] = $this->tpl_arrOrderDetail[$product_index]['price']  +
106                SC_Helper_TaxRule_Ex::calcTax(
107                    $this->tpl_arrOrderDetail[$product_index]['price'],
108                    $this->tpl_arrOrderDetail[$product_index]['tax_rate'],
109                    $this->tpl_arrOrderDetail[$product_index]['tax_rule']
110                    );
111            $arrTempProductDetail['price02_inctax'] = SC_Helper_TaxRule_Ex::sfCalcIncTax(
112                    $arrTempProductDetail['price02'],
113                    $arrTempProductDetail['product_id'],
114                    $arrTempProductDetail['product_class_id']
115                    );
116            if ($this->tpl_arrOrderDetail[$product_index]['price_inctax'] != $arrTempProductDetail['price02_inctax']) {
117                $this->is_price_change = true;
118            }
119            $this->tpl_arrOrderDetail[$product_index]['product_price_inctax'] = ($arrTempProductDetail['price02_inctax']) ? $arrTempProductDetail['price02_inctax'] : 0 ;
120        }
121
122        $this->tpl_arrOrderDetail = $this->setMainListImage($this->tpl_arrOrderDetail);
123        $objPurchase->setDownloadableFlgTo($this->tpl_arrOrderDetail);
124        // モバイルダウンロード対応処理
125        $this->lfSetAU($this->tpl_arrOrderDetail);
126        // 受注メール送信履歴の取得
127        $this->tpl_arrMailHistory = $this->lfGetMailHistory($order_id);
128    }
129
130    /**
131     * 受注メール送信履歴の取得
132     *
133     * @param  integer $order_id 注文番号
134     * @return array   受注メール送信履歴の内容
135     */
136    public function lfGetMailHistory($order_id)
137    {
138        $objQuery   =& SC_Query_Ex::getSingletonInstance();
139        $col        = 'send_date, subject, template_id, send_id';
140        $where      = 'order_id = ?';
141        $objQuery->setOrder('send_date DESC');
142
143        return $objQuery->select($col, 'dtb_mail_history', $where, array($order_id));
144    }
145
146    /**
147     * 受注お届け先情報の取得
148     *
149     * @param SC_Helper_Purchase_Ex $objPurchase object SC_Helper_Purchaseクラス
150     * @param $order_id integer 注文番号
151     * @param $arrWDAY array 曜日データの配列
152     * @return array お届け先情報
153     */
154    public function lfGetShippingDate(&$objPurchase, $order_id, $arrWDAY)
155    {
156        $arrShipping = $objPurchase->getShippings($order_id);
157
158        foreach ($arrShipping as $shipping_index => $shippingData) {
159            foreach ($shippingData as $key => $val) {
160                if ($key == 'shipping_date' && SC_Utils_Ex::isBlank($val) == false) {
161                    // お届け日を整形
162                    list($y, $m, $d, $w) = explode(' ', date('Y m d w', strtotime($val)));
163                    $arrShipping[$shipping_index]['shipping_date'] = sprintf('%04d/%02d/%02d(%s)', $y, $m, $d, $arrWDAY[$w]);
164                }
165            }
166        }
167
168        return $arrShipping;
169    }
170
171    /**
172     * 購入履歴商品に画像をセット
173     *
174     * @param $arrOrderDetail 購入履歴の配列
175     * @return array 画像をセットした購入履歴の配列
176     */
177    public function setMainListImage($arrOrderDetails)
178    {
179        $i = 0;
180        foreach ($arrOrderDetails as $arrOrderDetail) {
181            $objQuery =& SC_Query_Ex::getSingletonInstance();
182            $arrProduct = $objQuery->select('main_list_image', 'dtb_products', 'product_id = ?', array($arrOrderDetail['product_id']));
183            $arrOrderDetails[$i]['main_list_image'] = $arrProduct[0]['main_list_image'];
184            $i++;
185        }
186
187        return $arrOrderDetails;
188    }
189
190    /**
191     * 購入履歴商品にMIMETYPE、ファイル名をセット
192     *
193     * @param $arrOrderDetail 購入履歴の配列
194     * @return array MIMETYPE、ファイル名をセットした購入履歴の配列
195     */
196    public function lfSetMimetype($arrOrderDetails)
197    {
198        $objHelperMobile = new SC_Helper_Mobile_Ex();
199        $i = 0;
200        foreach ($arrOrderDetails as $arrOrderDetail) {
201            $objQuery =& SC_Query_Ex::getSingletonInstance();
202            $arrProduct = $objQuery->select('down_realfilename,down_filename', 'dtb_products_class', 'product_id = ? AND product_class_id = ?', array($arrOrderDetail['product_id'],$arrOrderDetail['product_class_id']));
203            $arrOrderDetails[$i]['mime_type'] = $objHelperMobile->getMimeType($arrProduct[0]['down_realfilename']);
204            $arrOrderDetails[$i]['down_filename'] = $arrProduct[0]['down_filename'];
205            $i++;
206        }
207
208        return $arrOrderDetails;
209    }
210
211    /**
212     * 特定キャリア(AU)モバイルダウンロード処理
213     * キャリアがAUのモバイル端末からダウンロードする場合は単純に
214     * Aタグでダウンロードできないケースがある為、対応する。
215     *
216     * @param $arrOrderDetail 購入履歴の配列
217     */
218    public function lfSetAU($arrOrderDetails)
219    {
220        $this->isAU = false;
221        // モバイル端末かつ、キャリアがAUの場合に処理を行う
222        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE && SC_MobileUserAgent::getCarrier() == 'ezweb') {
223            // MIMETYPE、ファイル名のセット
224            $this->tpl_arrOrderDetail = $this->lfSetMimetype($arrOrderDetails);
225
226            // @deprecated 2.12.0 PHP 定数 SID を使うこと
227            $this->phpsessid = $_GET['PHPSESSID'];
228
229            $this->isAU = true;
230        }
231    }
232}
Note: See TracBrowser for help on using the repository browser.