Skip to content

Commit

Permalink
Merge pull request #4932 from EC-CUBE/revert-4894-fix-charge
Browse files Browse the repository at this point in the history
Revert "利用条件の判定を、自身の手数料を考慮して計算するように修正"
  • Loading branch information
Kiyotaka Oku authored Feb 19, 2021
2 parents 6044efe + a711af2 commit 5d8c028
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 124 deletions.
13 changes: 4 additions & 9 deletions src/Eccube/Form/Type/Shopping/OrderType.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)

$Deliveries = $this->getDeliveries($Order);
$Payments = $this->getPayments($Deliveries);
// @see https://github.com/EC-CUBE/ec-cube/issues/4881
$charge = $Order->getPayment() ? $Order->getPayment()->getCharge() : 0;
$Payments = $this->filterPayments($Payments, $Order->getPaymentTotal() - $charge);
$Payments = $this->filterPayments($Payments, $Order->getPaymentTotal());

$form = $event->getForm();
$this->addPaymentForm($form, $Payments, $Order->getPayment());
Expand All @@ -161,9 +159,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}

$Payments = $this->getPayments($Deliveries);
// @see https://github.com/EC-CUBE/ec-cube/issues/4881
$charge = $Order->getPayment() ? $Order->getPayment()->getCharge() : 0;
$Payments = $this->filterPayments($Payments, $Order->getPaymentTotal() - $charge);
$Payments = $this->filterPayments($Payments, $Order->getPaymentTotal());

$form = $event->getForm();
$this->addPaymentForm($form, $Payments);
Expand Down Expand Up @@ -288,15 +284,14 @@ private function getPayments($Deliveries)
private function filterPayments(ArrayCollection $Payments, $total)
{
$PaymentArrays = $Payments->filter(function (Payment $Payment) use ($total) {
$charge = $Payment->getCharge();
$min = $Payment->getRuleMin();
$max = $Payment->getRuleMax();

if (null !== $min && ($total + $charge) < $min) {
if (null !== $min && $total < $min) {
return false;
}

if (null !== $max && ($total + $charge) > $max) {
if (null !== $max && $total > $max) {
return false;
}

Expand Down
1 change: 0 additions & 1 deletion src/Eccube/Resource/locale/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,6 @@ tooltip.setting.shop.shop.option_product_tax: If turned on, you can set the tax
tooltip.setting.shop.shop.option_point_enabled: If turned on, the point system is enabled.
tooltip.setting.shop.shop.option_point_rate: You can change the point return rate by purchase amount.
tooltip.setting.shop.shop.option_point_conversion_rate: Conversion rate per 1 point. E.g. If you set ''1'', the point becomes available to shoppers with the rate of 1 point = 1 yen.
tooltip.setting.shop.payment.rule: You can set the terms of use for the payment method. If the total payment amount (tax included) including your own fee matches the conditions, it will be displayed in the payment method options of the purchase flow.
tooltip.setting.shop.payment.logo_image: You can upload the payment option icons displayed in the payment methods during the checkout process. If not registered, the payment methods will be displayed w/o images.
tooltip.setting.shop.delivery.tracking_number_url: Enter the URL of the shipping tracker of the delivery company.
tooltip.setting.shop.delivery.sale_type: Specify the sales type(s) available for this delivery method.
Expand Down
1 change: 0 additions & 1 deletion src/Eccube/Resource/locale/messages.ja.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,6 @@ tooltip.setting.shop.shop.option_product_tax: オンにすると、商品別に
tooltip.setting.shop.shop.option_point_enabled: オンにすると、ポイント機能を有効化できます。
tooltip.setting.shop.shop.option_point_rate: 購入金額に対するポイント付与率を編集できます。
tooltip.setting.shop.shop.option_point_conversion_rate: 1ポイントあたりの換算レートです。例:「1」と設定すると1ポイント「1円」として利用可能になります。
tooltip.setting.shop.payment.rule: お支払い方法の利用条件を設定できます。自身の手数料を含む支払総額(税込)が条件に一致する場合、購入フローのお支払い方法の選択肢に表示されまます。
tooltip.setting.shop.payment.logo_image: 購入フローのお支払い方法に表示される画像を登録できます。登録がない場合は画像なしで表示されます。
tooltip.setting.shop.delivery.tracking_number_url: 配送業者のお問い合わせページURLを指定します。
tooltip.setting.shop.delivery.sale_type: この配送方法で取り扱える販売種別を指定します。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,7 @@ file that was distributed with this source code.
</div>
</div>
<div class="row">
<div class="col-3">
<div class="d-inline-block" data-tooltip="true" data-placement="top" title="{{ 'tooltip.setting.shop.payment.rule'|trans }}">
<span><span>{{ 'admin.setting.shop.payment.terms_of_use'|trans }}</span></span><i class="fa fa-question-circle fa-lg ml-1"></i>
</div>
</div>
<div class="col-3"><span>{{ 'admin.setting.shop.payment.terms_of_use'|trans }}</span></div>
<div class="col mb-2">
<div class="row justify-content-start">
<div class="col-4">
Expand Down
11 changes: 0 additions & 11 deletions src/Eccube/Service/OrderHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
use Eccube\Entity\Master\OrderStatus;
use Eccube\Entity\Order;
use Eccube\Entity\OrderItem;
use Eccube\Entity\Payment;
use Eccube\Entity\Shipping;
use Eccube\EventListener\SecurityListener;
use Eccube\Repository\DeliveryRepository;
Expand Down Expand Up @@ -467,16 +466,6 @@ protected function setDefaultPayment(Order $Order)

// 利用可能な支払い方法を抽出.
$Payments = $this->paymentRepository->findAllowedPayments($Deliveries, true);
// ここでは支払総額はまだ決まっていないため、利用条件が設定されているものは初期選択の支払い方法として除外する
$Payments = array_filter($Payments, function (Payment $Payment) {
$min = $Payment->getRuleMin();
$max = $Payment->getRuleMax();
if ($max === null && ($min === null || $min <= 1)) {
return true;
}

return false;
});

// 初期の支払い方法を設定.
$Payment = current($Payments);
Expand Down
66 changes: 0 additions & 66 deletions tests/Eccube/Tests/Form/Type/Shopping/OrderTypeTest.php

This file was deleted.

31 changes: 0 additions & 31 deletions tests/Eccube/Tests/Service/OrderHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@
namespace Eccube\Tests\Service;

use Eccube\Entity\Customer;
use Eccube\Entity\Delivery;
use Eccube\Entity\Order;
use Eccube\Entity\Payment;
use Eccube\Service\OrderHelper;
use Eccube\Tests\EccubeTestCase;
use Eccube\Util\ReflectionUtil;

class OrderHelperTest extends EccubeTestCase
{
Expand Down Expand Up @@ -72,32 +69,4 @@ public function testUpdateCustomerInfoNewCustomer()
self::assertNotNull($Order->getName01());
self::assertSame($Order->getName01(), $Customer->getName01());
}

/**
* @see https://github.com/EC-CUBE/ec-cube/issues/4881
*/
public function testSetDefaultPayment()
{
$paymentRepository = $this->entityManager->getRepository(Payment::class);
$Payments = $paymentRepository->findBy(['visible' => true], ['id' => 'asc']);
$Payments[0]->setRuleMax(100); // 除外
$Payments[1]->setRuleMax(null); $Payments[1]->setRuleMin(100); // 除外
$Payments[2]->setRuleMax(null); $Payments[2]->setRuleMin(0); // 対象
$Payments[3]->setRuleMax(null); $Payments[3]->setRuleMin(1); // 対象

$this->entityManager->flush();

$Customer = $this->createCustomer();
$Order = $this->createOrder($Customer);
$Order->setPayment(null);
$Order->setPaymentMethod(null);

$refObj = new \ReflectionObject($this->helper);
$refMethod = $refObj->getMethod('setDefaultPayment');
$refMethod->setAccessible(true);
$refMethod->invokeArgs($this->helper, [$Order]);

self::assertNotNull($Order->getPayment());
self::assertSame($Payments[2]->getId(), $Order->getPayment()->getId());
}
}

0 comments on commit 5d8c028

Please sign in to comment.