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

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