[Svn-src-all:3656] [version-2_12-dev 22568] #2134 支払い方法に関する処理を SC_Helper_Payment へ集約.

pineray admin @ mail.ec-cube.net
2013年 2月 18日 (月) 19:43:16 JST


Subversion committed to /home/svn/open 22568
http://svn.ec-cube.net/open_trac/changeset/22568
┌────────────────────────────┐
│更新者 :  pineray                                      │
│更新日時:  2013-02-18 19:43:15 +0900 (月, 18  2月 2013)│
└────────────────────────────┘

Log:
--------------------------------------------------------
#2134 支払い方法に関する処理を SC_Helper_Payment へ集約.

Changed:                      [U:修正,A:追加,D:削除]
--------------------------------------------------------
U   branches/version-2_12-dev/data/class/helper/SC_Helper_Payment.php
U   branches/version-2_12-dev/data/class/helper/SC_Helper_Purchase.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_getPaymentsByPriceTest.php

変更: branches/version-2_12-dev/data/class/helper/SC_Helper_Payment.php
===================================================================
--- branches/version-2_12-dev/data/class/helper/SC_Helper_Payment.php	2013-02-18 10:09:54 UTC (rev 22567)
+++ branches/version-2_12-dev/data/class/helper/SC_Helper_Payment.php	2013-02-18 10:43:15 UTC (rev 22568)
@@ -57,7 +57,7 @@
     public function getList($has_deleted = false)
     {
         $objQuery =& SC_Query_Ex::getSingletonInstance();
-        $col = 'payment_id, payment_method, charge, rule_max, upper_rule, note, fix, charge_flg';
+        $col = 'payment_id, payment_method, payment_image, charge, rule_max, upper_rule, note, fix, charge_flg';
         $where = '';
         if (!$has_deleted) {
             $where .= 'del_flg = 0';
@@ -69,6 +69,44 @@
     }
 
     /**
+     * 購入金額に応じた支払方法を取得する.
+     *
+     * @param integer $total 購入金額
+     * @return array 購入金額に応じた支払方法の配列
+     */
+    function getByPrice($total)
+    {
+        // 削除されていない支払方法を取得
+        $payments = $this->getList();
+        $arrPayment = array();
+        foreach ($payments as $data) {
+            // 下限と上限が設定されている
+            if (strlen($data['rule_max']) != 0 && strlen($data['upper_rule']) != 0) {
+                if ($data['rule_max'] <= $total && $data['upper_rule'] >= $total) {
+                    $arrPayment[] = $data;
+                }
+            }
+            // 下限のみ設定されている
+            elseif (strlen($data['rule_max']) != 0) {
+                if ($data['rule_max'] <= $total) {
+                    $arrPayment[] = $data;
+                }
+            }
+            // 上限のみ設定されている
+            elseif (strlen($data['upper_rule']) != 0) {
+                if ($data['upper_rule'] >= $total) {
+                    $arrPayment[] = $data;
+                }
+            }
+            // いずれも設定なし
+            else {
+                $arrPayment[] = $data;
+            }
+        }
+        return $arrPayment;
+    }
+
+    /**
      * 支払方法の登録.
      * 
      * @param array $sqlval

変更: 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-18 10:09:54 UTC (rev 22567)
+++ branches/version-2_12-dev/data/class/helper/SC_Helper_Purchase.php	2013-02-18 10:43:15 UTC (rev 22568)
@@ -542,55 +542,6 @@
     }
 
     /**
-     * 購入金額に応じた支払方法を取得する.
-     *
-     * @param integer $total 購入金額
-     * @param integer $deliv_id 配送業者ID
-     * @return array 購入金額に応じた支払方法の配列
-     */
-    function getPaymentsByPrice($total, $deliv_id)
-    {
-
-        $arrPaymentIds = SC_Helper_Delivery_Ex::getPayments($deliv_id);
-        if (SC_Utils_Ex::isBlank($arrPaymentIds)) {
-            return array();
-        }
-
-        $objQuery =& SC_Query_Ex::getSingletonInstance();
-
-        // 削除されていない支払方法を取得
-        $where = 'del_flg = 0 AND payment_id IN (' . SC_Utils_Ex::repeatStrWithSeparator('?', count($arrPaymentIds)) . ')';
-        $objQuery->setOrder('rank DESC');
-        $payments = $objQuery->select('payment_id, payment_method, rule_max, upper_rule, note, payment_image, charge', 'dtb_payment', $where, $arrPaymentIds);
-        $arrPayment = array();
-        foreach ($payments as $data) {
-            // 下限と上限が設定されている
-            if (strlen($data['rule_max']) != 0 && strlen($data['upper_rule']) != 0) {
-                if ($data['rule_max'] <= $total && $data['upper_rule'] >= $total) {
-                    $arrPayment[] = $data;
-                }
-            }
-            // 下限のみ設定されている
-            elseif (strlen($data['rule_max']) != 0) {
-                if ($data['rule_max'] <= $total) {
-                    $arrPayment[] = $data;
-                }
-            }
-            // 上限のみ設定されている
-            elseif (strlen($data['upper_rule']) != 0) {
-                if ($data['upper_rule'] >= $total) {
-                    $arrPayment[] = $data;
-                }
-            }
-            // いずれも設定なし
-            else {
-                $arrPayment[] = $data;
-            }
-        }
-        return $arrPayment;
-    }
-
-    /**
      * お届け日一覧を取得する.
      */
     function getDelivDate(&$objCartSess, $productTypeId)

変更: 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-18 10:09:54 UTC (rev 22567)
+++ branches/version-2_12-dev/data/class/pages/shopping/LC_Page_Shopping_Payment.php	2013-02-18 10:43:15 UTC (rev 22568)
@@ -415,7 +415,16 @@
         $arrResults = array();
         $arrResults['arrDelivTime'] = SC_Helper_Delivery_Ex::getDelivTime($deliv_id);
         $total = $objCartSess->getAllProductsTotal($objCartSess->getKey());
-        $arrResults['arrPayment'] = $objPurchase->getPaymentsByPrice($total, $deliv_id);
+        $payments_deliv = SC_Helper_Delivery_Ex::getPayments($deliv_id);
+        $objPayment = new SC_Helper_Payment_Ex();
+        $payments_total = $objPayment->getByPrice($total);
+        $arrPayment = array();
+        foreach ($payments_total as $payment) {
+            if (in_array($payment['payment_id'], $payments_deliv)) {
+                $arrPayment[] = $payment;
+            }
+        }
+        $arrResults['arrPayment'] = $arrPayment;
         $arrResults['img_show'] = $this->hasPaymentImage($arrResults['arrPayment']);
         return $arrResults;
     }

削除: branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getPaymentsByPriceTest.php
===================================================================
--- branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getPaymentsByPriceTest.php	2013-02-18 10:09:54 UTC (rev 22567)
+++ branches/version-2_12-dev/tests/class/helper/SC_Helper_Purchase/SC_Helper_Purchase_getPaymentsByPriceTest.php	2013-02-18 10:43:15 UTC (rev 22568)
@@ -1,123 +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::getPaymentsByPrice()のテストクラス.
- *
- *
- * @author Hiroko Tamagawa
- * @version $Id$
- */
-class SC_Helper_Purchase_getPaymentsByPriceTest extends SC_Helper_Purchase_TestBase
-{
-
-
-  protected function setUp()
-  {
-    parent::setUp();
-    $this->setUpPayment();
-    $this->setUpPaymentOptions();
-  }
-
-  protected function tearDown()
-  {
-    parent::tearDown();
-  }
-
-  /////////////////////////////////////////
-  public function testGetPaymentsByPrice_購入金額がすべての上限を上回る場合_上限の設定がないものだけ取得できる()
-  {
-    $deliv_id = '1003';
-    $total = 21001;
-    $helper = new SC_Helper_Purchase();
-
-    $this->expected['count'] = 2;
-    $this->expected['first'] = array(
-      'payment_id' => '3002',
-      'payment_method' => '支払方法3002',
-      'rule_max' => null,
-      'upper_rule' => null,
-      'note' => null,
-      'payment_image' => null,
-      'charge' => null
-    );
-    $this->expected['second_id'] = '3003';
-
-    $result = $helper->getPaymentsByPrice($total, $deliv_id);
-    $this->actual['count'] = count($result);
-    $this->actual['first'] = $result[0];
-    $this->actual['second_id'] = $result[1]['payment_id'];
-
-    $this->verify();
-  }
-
-  public function testGetPaymentsByPrice_購入金額が一部の上限を上回る場合_上限に引っかからないものだけ取得できる()
-  {
-    $deliv_id = '1003';
-    $total = 20500;
-    $helper = new SC_Helper_Purchase();
-
-    $this->expected = array('3002', '3003', '3005');
-
-    $result = $helper->getPaymentsByPrice($total, $deliv_id);
-    $this->actual = Test_Utils::mapCols($result, 'payment_id');
-
-    $this->verify();
-  }
-
-  public function testGetPaymentsByPrice_購入金額が一部の下限を下回る場合_下限に引っかからないものだけ取得できる()
-  {
-    $deliv_id = '1003';
-    $total = 11000;
-    $helper = new SC_Helper_Purchase();
-
-    $this->expected = array('3002', '3003', '3004');
-
-    $result = $helper->getPaymentsByPrice($total, $deliv_id);
-    $this->actual = Test_Utils::mapCols($result, 'payment_id');
-
-    $this->verify();
-  }
-
-  public function testGetPaymentsByPrice_購入金額がすべての下限を下回る場合_下限の設定がないものだけ取得できる()
-  {
-    $deliv_id = '1003';
-    $total = 9999;
-    $helper = new SC_Helper_Purchase();
-
-    $this->expected = array('3002', '3004');
-
-    $result = $helper->getPaymentsByPrice($total, $deliv_id);
-    $this->actual = Test_Utils::mapCols($result, 'payment_id');
-
-    $this->verify();
-  }
-
-
-  //////////////////////////////////////////
-
-}
-




Svn-src-all メーリングリストの案内