| @@ 110-120 (lines=11) @@ | ||
| 107 | /** |
|
| 108 | * {@inheritdoc} |
|
| 109 | */ |
|
| 110 | public function prepare(ItemHolderInterface $itemHolder, PurchaseContext $context) |
|
| 111 | { |
|
| 112 | if (!$itemHolder instanceof Order) { |
|
| 113 | return; |
|
| 114 | } |
|
| 115 | // ユーザの保有ポイントを減算 |
|
| 116 | $Customer = $itemHolder->getCustomer(); |
|
| 117 | if ($Customer) { |
|
| 118 | $Customer->setPoint($Customer->getPoint() - $itemHolder->getUsePoint()); |
|
| 119 | } |
|
| 120 | } |
|
| 121 | ||
| 122 | /** |
|
| 123 | * {@inheritdoc |
|
| @@ 133-141 (lines=9) @@ | ||
| 130 | /** |
|
| 131 | * {@inheritdoc |
|
| 132 | */ |
|
| 133 | public function rollback(ItemHolderInterface $itemHolder, PurchaseContext $context) |
|
| 134 | { |
|
| 135 | // 利用したポイントをユーザに戻す. |
|
| 136 | if (!$itemHolder instanceof Order) { |
|
| 137 | return; |
|
| 138 | } |
|
| 139 | $Customer = $itemHolder->getCustomer(); |
|
| 140 | $Customer->setPoint($Customer->getPoint() + $itemHolder->getUsePoint()); |
|
| 141 | } |
|
| 142 | ||
| 143 | /* |
|
| 144 | * Helper methods |
|