| 123456789101112131415161718192021222324252627 |
- <?php
- namespace Longyi\FreeGift\Services\Actions;
- /**
- * 满额送。
- *
- * 对应 Amasty 的 Rule\Action\Discount\Spent。
- *
- * 命中条件的商品金额合计每满 discount_step,送 discount_amount 个赠品。
- * 金额口径:base_total - base_discount_amount(不含税,且已扣掉原生促销折扣),
- * 与 Bagisto 原生 by_percent 规则的口径保持一致。
- */
- class SpentAction extends AbstractGiftAction
- {
- /**
- * 命中商品金额每满一个步长,送一份。
- */
- protected function calculate($rule, array $items, $cart): float
- {
- $step = $this->getStep($rule);
- $amount = $this->getAmount($rule);
- return floor($this->totalAmount($items) / $step) * $amount;
- }
- }
|