|
1
|
|
|
<?php |
|
2
|
|
|
namespace Eccube\Service\Calculator\Strategy; |
|
3
|
|
|
|
|
4
|
|
|
use Eccube\Application; |
|
5
|
|
|
use Eccube\Entity\Master\OrderItemType; |
|
6
|
|
|
use Eccube\Entity\Master\TaxType; |
|
7
|
|
|
use Eccube\Entity\Master\TaxDisplayType; |
|
8
|
|
|
use Eccube\Entity\Order; |
|
9
|
|
|
use Eccube\Entity\PurchaseInterface; |
|
10
|
|
|
use Eccube\Entity\ShipmentItem; |
|
11
|
|
|
use Eccube\Entity\Shipping; |
|
12
|
|
|
use Eccube\Repository\Master\OrderItemTypeRepository; |
|
13
|
|
|
use Eccube\Service\Calculator\ShipmentItemCollection; |
|
14
|
|
|
|
|
15
|
|
|
class ChargeStrategy implements CalculateStrategyInterface |
|
|
|
|
|
|
16
|
|
|
{ |
|
17
|
|
|
/* @var Application $app */ |
|
18
|
|
|
protected $app; |
|
19
|
|
|
|
|
20
|
|
|
/* @var Order $Order */ |
|
21
|
|
|
protected $Order; |
|
22
|
|
|
|
|
23
|
|
|
/** @var OrderItemTypeRepository */ |
|
24
|
|
|
protected $OrderItemTypeRepository; |
|
25
|
|
|
|
|
26
|
|
|
public function execute(ShipmentItemCollection $ShipmentItems) |
|
|
|
|
|
|
27
|
|
|
{ |
|
28
|
|
|
// 手数料の受注明細区分 |
|
29
|
|
|
$ChargeType = $this->app['eccube.repository.master.order_item_type']->find(OrderItemType::CHARGE); |
|
30
|
|
|
// TODO |
|
31
|
|
|
$TaxInclude = $this->app['orm.em']->getRepository(TaxDisplayType::class)->find(TaxDisplayType::INCLUDED); |
|
32
|
|
|
$Taxion = $this->app['orm.em']->getRepository(TaxType::class)->find(TaxType::TAXATION); |
|
33
|
|
|
|
|
34
|
|
View Code Duplication |
if (!$ShipmentItems->hasItemByOrderItemType($ChargeType)) { |
|
35
|
|
|
$Payment = $this->Order->getPayment(); |
|
36
|
|
|
if (is_object($Payment) && $Payment->getCharge() > 0) { |
|
37
|
|
|
$ShipmentItem = new ShipmentItem(); |
|
38
|
|
|
$ShipmentItem->setProductName("手数料") |
|
39
|
|
|
->setPrice($Payment->getCharge()) |
|
40
|
|
|
->setPriceIncTax($Payment->getCharge()) |
|
41
|
|
|
->setTaxRate(8) |
|
42
|
|
|
->setQuantity(1) |
|
43
|
|
|
->setOrderItemType($ChargeType) |
|
44
|
|
|
->setTaxDisplayType($TaxInclude) |
|
45
|
|
|
->setTaxType($Taxion); |
|
46
|
|
|
$ShipmentItems->add($ShipmentItem); |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function setApplication(Application $app) |
|
|
|
|
|
|
52
|
|
|
{ |
|
53
|
|
|
$this->app = $app; |
|
54
|
|
|
return $this; |
|
|
|
|
|
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function setOrder(PurchaseInterface $Order) |
|
|
|
|
|
|
58
|
|
|
{ |
|
59
|
|
|
$this->Order = $Order; |
|
|
|
|
|
|
60
|
|
|
return $this; |
|
|
|
|
|
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function getTargetTypes() |
|
|
|
|
|
|
64
|
|
|
{ |
|
65
|
|
|
return [Order::class]; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|