|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of EC-CUBE |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright(c) LOCKON CO.,LTD. All Rights Reserved. |
|
7
|
|
|
* |
|
8
|
|
|
* http://www.lockon.co.jp/ |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Eccube\Service\PurchaseFlow\Processor; |
|
15
|
|
|
|
|
16
|
|
|
use Eccube\Entity\ItemInterface; |
|
17
|
|
|
use Eccube\Entity\OrderItem; |
|
18
|
|
|
use Eccube\Service\PurchaseFlow\ItemValidator; |
|
19
|
|
|
use Eccube\Service\PurchaseFlow\PurchaseContext; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* 販売価格の変更検知. |
|
23
|
|
|
*/ |
|
24
|
|
|
class PriceChangeValidator extends ItemValidator |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* @param ItemInterface $item |
|
|
|
|
|
|
28
|
|
|
* @param PurchaseContext $context |
|
29
|
|
|
* |
|
30
|
|
|
* @throws \Eccube\Service\PurchaseFlow\InvalidItemException |
|
31
|
|
|
*/ |
|
32
|
80 |
|
public function validate(ItemInterface $item, PurchaseContext $context) |
|
33
|
|
|
{ |
|
34
|
80 |
|
if (!$item->isProduct()) { |
|
35
|
51 |
|
return; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
80 |
|
if ($item instanceof OrderItem) { |
|
39
|
51 |
|
$price = $item->getPriceIncTax(); |
|
40
|
|
|
} else { |
|
41
|
|
|
// CartItem::priceは税込金額. |
|
42
|
80 |
|
$price = $item->getPrice(); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
80 |
|
$realPrice = $item->getProductClass()->getPrice02IncTax(); |
|
46
|
80 |
|
if ($price != $realPrice) { |
|
47
|
1 |
|
if ($item instanceof OrderItem) { |
|
48
|
|
|
$item->setPrice($item->getProductClass()->getPrice02()); |
|
49
|
|
|
|
|
50
|
|
|
$this->throwInvalidItemException('cart.product.price.change', $item->getProductClass()); |
|
51
|
|
|
} else { |
|
52
|
|
|
// CartItem::priceは税込金額. |
|
53
|
1 |
|
$item->setPrice($realPrice); |
|
54
|
1 |
|
$this->throwInvalidItemException('cart.product.price.change', $item->getProductClass()); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|