FixedAmount.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: shenyang
  5. * Date: 2017/10/13
  6. * Time: 下午5:07
  7. */
  8. namespace app\frontend\modules\deduction\orderGoods\amount;
  9. /**
  10. * 固定金额抵扣
  11. * Class FixedAmount
  12. * @package app\frontend\modules\deduction\orderGoods\amount
  13. */
  14. class FixedAmount extends OrderGoodsDeductionAmount
  15. {
  16. /**
  17. * @return float|mixed
  18. * @throws \app\common\exceptions\ShopException
  19. */
  20. public function getMaxAmount()
  21. {
  22. $result = $this->getGoodsDeduction()->getMaxFixedAmount() * $this->getOrderGoods()->total;
  23. //todo blank 两种抵扣同时使用问题,订单商品金额已小于抵扣金额则获取最低金额 2022/3/3
  24. $amount = min($result, $this->orderGoods->getPriceBefore($this->getGoodsDeduction()->getCode() . 'Deduction'));
  25. return max($amount, 0);
  26. }
  27. /**
  28. * @return float|mixed
  29. * @throws \app\common\exceptions\ShopException
  30. */
  31. public function getMinAmount()
  32. {
  33. $result = $this->getGoodsDeduction()->getMinFixedAmount() * $this->getOrderGoods()->total;
  34. //$result = min($result,$this->getOrderGoods()->getPriceBeforeWeight($this->getGoodsDeduction()->getCode().'Deduction'));
  35. return max($result, 0);
  36. }
  37. public function hasMinAmount(){
  38. return $this->getGoodsDeduction()->getMinFixedAmount() > 0;
  39. }
  40. }