[Svn-src-all:3642] [version-2_12-dev 22554] #2136 dtb_deliv の処理を SC_Helper_Delivery クラスに集める.
pineray
admin @ mail.ec-cube.net
2013年 2月 15日 (金) 21:45:14 JST
Subversion committed to /home/svn/open 22554
http://svn.ec-cube.net/open_trac/changeset/22554
┌────────────────────────────┐
│更新者 : pineray │
│更新日時: 2013-02-15 21:45:14 +0900 (金, 15 2月 2013)│
└────────────────────────────┘
Log:
--------------------------------------------------------
#2136 dtb_deliv の処理を SC_Helper_Delivery クラスに集める.
Changed: [U:修正,A:追加,D:削除]
--------------------------------------------------------
U branches/version-2_12-dev/data/class/SC_CartSession.php
U branches/version-2_12-dev/data/class/helper/SC_Helper_Delivery.php
U branches/version-2_12-dev/data/class/helper/SC_Helper_Purchase.php
U branches/version-2_12-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_DeliveryInput.php
U branches/version-2_12-dev/data/class/pages/admin/order/LC_Page_Admin_Order_Disp.php
U branches/version-2_12-dev/data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php
U branches/version-2_12-dev/data/class/pages/shopping/LC_Page_Shopping_Payment.php
D branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getDelivTimeTest.php
D branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getPaymentsTest.php
変更: branches/version-2_12-dev/data/class/SC_CartSession.php
===================================================================
--- branches/version-2_12-dev/data/class/SC_CartSession.php 2013-02-15 11:50:41 UTC (rev 22553)
+++ branches/version-2_12-dev/data/class/SC_CartSession.php 2013-02-15 12:45:14 UTC (rev 22554)
@@ -635,7 +635,7 @@
if (OPTION_DELIV_FEE == 1
&& !SC_Utils_Ex::isBlank($deliv_pref)
&& !SC_Utils_Ex::isBlank($deliv_id)) {
- $results['deliv_fee'] += $this->sfGetDelivFee($deliv_pref, $deliv_id);
+ $results['deliv_fee'] += SC_Helper_Delivery_Ex::getDelivFee($deliv_pref, $deliv_id);
}
// 送料無料チェック
@@ -732,33 +732,4 @@
function hasProductType($product_type_id) {
return in_array($product_type_id, $this->getKeys());
}
-
- /**
- * 都道府県から配送料金を取得する.
- *
- * @param integer|array $pref_id 都道府県ID 又は都道府県IDの配列
- * @param integer $deliv_id 配送業者ID
- * @return string 指定の都道府県, 配送業者の配送料金
- */
- function sfGetDelivFee($pref_id, $deliv_id = 0) {
- $objQuery =& SC_Query_Ex::getSingletonInstance();
- if (!is_array($pref_id)) {
- $pref_id = array($pref_id);
- }
- $sql = <<< __EOS__
- SELECT T1.fee AS fee
- FROM dtb_delivfee T1
- JOIN dtb_deliv T2
- ON T1.deliv_id = T2.deliv_id
- WHERE T1.pref = ?
- AND T1.deliv_id = ?
- AND T2.del_flg = 0
-__EOS__;
- $result = 0;
- foreach ($pref_id as $pref) {
- $result += $objQuery->getOne($sql, array($pref, $deliv_id));
- }
- return $result;
- }
-
}
変更: branches/version-2_12-dev/data/class/helper/SC_Helper_Delivery.php
===================================================================
--- branches/version-2_12-dev/data/class/helper/SC_Helper_Delivery.php 2013-02-15 11:50:41 UTC (rev 22553)
+++ branches/version-2_12-dev/data/class/helper/SC_Helper_Delivery.php 2013-02-15 12:45:14 UTC (rev 22554)
@@ -54,27 +54,13 @@
}
// お届け時間の取得
- $col = 'deliv_time';
- $where = 'deliv_id = ? ORDER BY time_id';
- $table = 'dtb_delivtime';
- $arrDeliv['deliv_time'] = $objQuery->select($col, $table, $where, array($deliv_id));
+ $arrDeliv['deliv_time'] = $this->getDelivTime($deliv_id);
// 配送料金の取得
- $col = 'fee';
- $where = 'deliv_id = ? ORDER BY pref';
- $table = 'dtb_delivfee';
- $arrDeliv['fee'] = $objQuery->select($col, $table, $where, array($deliv_id));
+ $arrDeliv['fee'] = $this->getDelivFeeList($deliv_id);
// 支払方法
- $col = 'payment_id';
- $where = 'deliv_id = ? ORDER BY rank';
- $table = 'dtb_payment_options';
- $arrRet = $objQuery->select($col, $table, $where, array($deliv_id));
- $arrPaymentIds = array();
- foreach ($arrRet as $val) {
- $arrPaymentIds[] = $val['payment_id'];
- }
- $arrDeliv['payment_ids'] = $arrPaymentIds;
+ $arrDeliv['payment_ids'] = $this->getPayments($deliv_id);
return $arrDeliv;
}
@@ -270,4 +256,81 @@
public static function getIDValueList($type = 'name') {
return SC_Helper_DB_Ex::sfGetIDValueList('dtb_deliv', 'deliv_id', $type);
}
+
+ /**
+ * 配送業者IDからお届け時間の配列を取得する.
+ *
+ * @param integer $deliv_id 配送業者ID
+ * @return array お届け時間の配列
+ */
+ public static function getDelivTime($deliv_id) {
+ $objQuery =& SC_Query_Ex::getSingletonInstance();
+ $objQuery->setOrder('time_id');
+ $results = $objQuery->select('time_id, deliv_time',
+ 'dtb_delivtime',
+ 'deliv_id = ?', array($deliv_id));
+ $arrDelivTime = array();
+ foreach ($results as $val) {
+ $arrDelivTime[$val['time_id']] = $val['deliv_time'];
+ }
+ return $arrDelivTime;
+ }
+
+ /**
+ * 配送業者ID から, 有効な支払方法IDを取得する.
+ *
+ * @param integer $deliv_id 配送業者ID
+ * @return array 有効な支払方法IDの配列
+ */
+ public static function getPayments($deliv_id) {
+ $objQuery =& SC_Query_Ex::getSingletonInstance();
+ $objQuery->setOrder('rank');
+ return $objQuery->getCol('payment_id', 'dtb_payment_options',
+ 'deliv_id = ?',
+ array($deliv_id), MDB2_FETCHMODE_ORDERED);
+ }
+
+ /**
+ * 都道府県から配送料金を取得する.
+ *
+ * @param integer|array $pref_id 都道府県ID 又は都道府県IDの配列
+ * @param integer $deliv_id 配送業者ID
+ * @return string 指定の都道府県, 配送業者の配送料金
+ */
+ public static function getDelivFee($pref_id, $deliv_id = 0) {
+ $objQuery =& SC_Query_Ex::getSingletonInstance();
+ if (!is_array($pref_id)) {
+ $pref_id = array($pref_id);
+ }
+ $sql = <<< __EOS__
+ SELECT T1.fee AS fee
+ FROM dtb_delivfee T1
+ JOIN dtb_deliv T2
+ ON T1.deliv_id = T2.deliv_id
+ WHERE T1.pref = ?
+ AND T1.deliv_id = ?
+ AND T2.del_flg = 0
+__EOS__;
+ $result = 0;
+ foreach ($pref_id as $pref) {
+ $result += $objQuery->getOne($sql, array($pref, $deliv_id));
+ }
+ return $result;
+ }
+
+ /**
+ * 配送業者ID から, 配送料金の一覧を取得する.
+ *
+ * @param integer $deliv_id 配送業者ID
+ * @return array 配送料金の配列
+ */
+ public static function getDelivFeeList($deliv_id) {
+ $objQuery =& SC_Query_Ex::getSingletonInstance();
+ $objQuery->setOrder('pref');
+ $col = 'fee';
+ $where = 'deliv_id = ?';
+ $table = 'dtb_delivfee';
+ return $objQuery->getCol($col, $table, $where, array($deliv_id),
+ MDB2_FETCHMODE_ORDERED);
+ }
}
変更: branches/version-2_12-dev/data/class/helper/SC_Helper_Purchase.php
===================================================================
--- branches/version-2_12-dev/data/class/helper/SC_Helper_Purchase.php 2013-02-15 11:50:41 UTC (rev 22553)
+++ branches/version-2_12-dev/data/class/helper/SC_Helper_Purchase.php 2013-02-15 12:45:14 UTC (rev 22554)
@@ -531,7 +531,7 @@
*/
function getPaymentsByPrice($total, $deliv_id) {
- $arrPaymentIds = $this->getPayments($deliv_id);
+ $arrPaymentIds = SC_Helper_Delivery_Ex::getPayments($deliv_id);
if (SC_Utils_Ex::isBlank($arrPaymentIds)) {
return array();
}
@@ -653,39 +653,6 @@
}
/**
- * 配送業者IDからお届け時間の配列を取得する.
- *
- * @param integer $deliv_id 配送業者ID
- * @return array お届け時間の配列
- */
- function getDelivTime($deliv_id) {
- $objQuery =& SC_Query_Ex::getSingletonInstance();
- $objQuery->setOrder('time_id');
- $results = $objQuery->select('time_id, deliv_time',
- 'dtb_delivtime',
- 'deliv_id = ?', array($deliv_id));
- $arrDelivTime = array();
- foreach ($results as $val) {
- $arrDelivTime[$val['time_id']] = $val['deliv_time'];
- }
- return $arrDelivTime;
- }
-
- /**
- * 配送業者ID から, 有効な支払方法IDを取得する.
- *
- * @param integer $deliv_id 配送業者ID
- * @return array 有効な支払方法IDの配列
- */
- function getPayments($deliv_id) {
- $objQuery =& SC_Query_Ex::getSingletonInstance();
- $objQuery->setOrder('rank');
- return $objQuery->getCol('payment_id', 'dtb_payment_options',
- 'deliv_id = ?',
- array($deliv_id), MDB2_FETCHMODE_ORDERED);
- }
-
- /**
* 配送情報の登録を行う.
*
* $arrParam のうち, dtb_shipping テーブルに存在するカラムのみを登録する.
変更: branches/version-2_12-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_DeliveryInput.php
===================================================================
--- branches/version-2_12-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_DeliveryInput.php 2013-02-15 11:50:41 UTC (rev 22553)
+++ branches/version-2_12-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_DeliveryInput.php 2013-02-15 12:45:14 UTC (rev 22554)
@@ -215,10 +215,18 @@
$arrDeliv = $objDelivery->get($deliv_id);
// お届け時間
- $objFormParam->setParamList($arrDeliv['deliv_time'], 'deliv_time');
+ $deliv_times = array();
+ foreach ($arrDeliv['deliv_time'] as $value) {
+ $deliv_times[]['deliv_time'] = $value;
+ }
+ $objFormParam->setParamList($deliv_times, 'deliv_time');
unset($arrDeliv['deliv_time']);
// 配送料金
- $objFormParam->setParamList($arrDeliv['fee'], 'fee');
+ $deliv_fee = array();
+ foreach ($arrDeliv['fee'] as $value) {
+ $deliv_fee[]['fee'] = $value;
+ }
+ $objFormParam->setParamList($deliv_fee, 'fee');
unset($arrDeliv['fee']);
// 支払方法
$objFormParam->setValue('payment_ids', $arrDeliv['payment_ids']);
変更: branches/version-2_12-dev/data/class/pages/admin/order/LC_Page_Admin_Order_Disp.php
===================================================================
--- branches/version-2_12-dev/data/class/pages/admin/order/LC_Page_Admin_Order_Disp.php 2013-02-15 11:50:41 UTC (rev 22553)
+++ branches/version-2_12-dev/data/class/pages/admin/order/LC_Page_Admin_Order_Disp.php 2013-02-15 12:45:14 UTC (rev 22554)
@@ -125,7 +125,7 @@
$this->arrForm = $objFormParam->getFormParamList();
$this->arrAllShipping = $objFormParam->getSwapArray(array_merge($this->arrShippingKeys, $this->arrShipmentItemKeys));
- $this->arrDelivTime = $objPurchase->getDelivTime($objFormParam->getValue('deliv_id'));
+ $this->arrDelivTime = SC_Helper_Delivery_Ex::getDelivTime($objFormParam->getValue('deliv_id'));
$this->arrInfo = SC_Helper_DB_Ex::sfGetBasisData();
$this->setTemplate($this->tpl_mainpage);
変更: branches/version-2_12-dev/data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php
===================================================================
--- branches/version-2_12-dev/data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php 2013-02-15 11:50:41 UTC (rev 22553)
+++ branches/version-2_12-dev/data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php 2013-02-15 12:45:14 UTC (rev 22554)
@@ -300,7 +300,7 @@
$this->arrForm = $objFormParam->getFormParamList();
$this->arrAllShipping = $objFormParam->getSwapArray(array_merge($this->arrShippingKeys, $this->arrShipmentItemKeys));
$this->top_shipping_id = array_shift((array_keys($this->arrAllShipping)));
- $this->arrDelivTime = $objPurchase->getDelivTime($objFormParam->getValue('deliv_id'));
+ $this->arrDelivTime = SC_Helper_Delivery_Ex::getDelivTime($objFormParam->getValue('deliv_id'));
$this->tpl_onload .= $this->getAnchorKey($objFormParam);
if ($arrValuesBefore['payment_id'])
$this->arrPayment[$arrValuesBefore['payment_id']] = $arrValuesBefore['payment_method'];
@@ -769,7 +769,7 @@
$arrAllShipping = $objFormParam->getSwapArray($this->arrShippingKeys);
$arrAllShipmentItem = $objFormParam->getSwapArray($this->arrShipmentItemKeys);
- $arrDelivTime = $objPurchase->getDelivTime($objFormParam->getValue('deliv_id'));
+ $arrDelivTime = SC_Helper_Delivery_Ex::getDelivTime($objFormParam->getValue('deliv_id'));
//商品単価を複数配送にも適応
$arrShippingValues = array();
$arrIsNotQuantityUp = array();
変更: branches/version-2_12-dev/data/class/pages/shopping/LC_Page_Shopping_Payment.php
===================================================================
--- branches/version-2_12-dev/data/class/pages/shopping/LC_Page_Shopping_Payment.php 2013-02-15 11:50:41 UTC (rev 22553)
+++ branches/version-2_12-dev/data/class/pages/shopping/LC_Page_Shopping_Payment.php 2013-02-15 12:45:14 UTC (rev 22554)
@@ -402,7 +402,7 @@
*/
function getSelectedDeliv(&$objPurchase, &$objCartSess, $deliv_id) {
$arrResults = array();
- $arrResults['arrDelivTime'] = $objPurchase->getDelivTime($deliv_id);
+ $arrResults['arrDelivTime'] = SC_Helper_Delivery_Ex::getDelivTime($deliv_id);
$total = $objCartSess->getAllProductsTotal($objCartSess->getKey());
$arrResults['arrPayment'] = $objPurchase->getPaymentsByPrice($total, $deliv_id);
$arrResults['img_show'] = $this->hasPaymentImage($arrResults['arrPayment']);
削除: branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getDelivTimeTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getDelivTimeTest.php 2013-02-15 11:50:41 UTC (rev 22553)
+++ branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getDelivTimeTest.php 2013-02-15 12:45:14 UTC (rev 22554)
@@ -1,74 +0,0 @@
-<?php
-
-$HOME = realpath(dirname(__FILE__)) . "/../../../..";
-require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php");
-/*
- * This file is part of EC-CUBE
- *
- * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
- *
- * http://www.lockon.co.jp/
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-/**
- * SC_Helper_Purchase::getDelivTime()のテストクラス.
- *
- *
- * @author Hiroko Tamagawa
- * @version $Id$
- */
-class SC_Helper_Purchase_getDelivTimeTest extends SC_Helper_Purchase_TestBase {
-
-
- protected function setUp() {
- parent::setUp();
- $this->setUpDelivTime();
- }
-
- protected function tearDown() {
- parent::tearDown();
- }
-
- /////////////////////////////////////////
- public function testGetDelivTime_存在しない配送業者IDを指定した場合_結果が空になる() {
- $deliv_id = '100'; // 存在しないID
-
- $this->expected = array();
- $helper = new SC_Helper_Purchase();
- $this->actual = $helper->getDelivTime($deliv_id);
-
- $this->verify('お届け時間');
- }
-
- public function testGetDelivTime_存在する配送業者IDを指定した場合_結果が正しい順序で取得できる() {
- $deliv_id = '1001';
-
- $this->expected = array(
- '1' => '午前',
- '2' => '午後'
- );
-
- $helper = new SC_Helper_Purchase();
- $this->actual = $helper->getDelivTime($deliv_id);
-
- $this->verify('お届け時間');
- }
-
- //////////////////////////////////////////
-
-}
-
削除: branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getPaymentsTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getPaymentsTest.php 2013-02-15 11:50:41 UTC (rev 22553)
+++ branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getPaymentsTest.php 2013-02-15 12:45:14 UTC (rev 22554)
@@ -1,71 +0,0 @@
-<?php
-
-$HOME = realpath(dirname(__FILE__)) . "/../../../..";
-require_once($HOME . "/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_TestBase.php");
-/*
- * This file is part of EC-CUBE
- *
- * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
- *
- * http://www.lockon.co.jp/
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-/**
- * SC_Helper_Purchase::getPayments()のテストクラス.
- *
- *
- * @author Hiroko Tamagawa
- * @version $Id$
- */
-class SC_Helper_Purchase_getPaymentsTest extends SC_Helper_Purchase_TestBase {
-
-
- protected function setUp() {
- parent::setUp();
- $this->setUpPaymentOptions();
- }
-
- protected function tearDown() {
- parent::tearDown();
- }
-
- /////////////////////////////////////////
- public function testGetPayments_存在しない配送業者IDを指定した場合_結果が空になる() {
- $deliv_id = '100'; // 存在しないID
-
- $this->expected = array();
- $helper = new SC_Helper_Purchase();
- $this->actual = $helper->getPayments($deliv_id);
-
- $this->verify('支払方法');
- }
-
- public function testGetPayments_存在する配送業者IDを指定した場合_結果が正しい順序で取得できる() {
- $deliv_id = '1001';
-
- $this->expected = array('1002', '1001');
-
- $helper = new SC_Helper_Purchase();
- $this->actual = $helper->getPayments($deliv_id);
-
- $this->verify('支払方法');
- }
-
- //////////////////////////////////////////
-
-}
-
Svn-src-all メーリングリストの案内