Coupon.php 671 B

123456789101112131415161718192021
  1. <?php
  2. namespace app\frontend\modules\orderGoods\discount;
  3. class Coupon extends BaseDiscount
  4. {
  5. protected $code = 'coupon';
  6. protected $name = '优惠券优惠';
  7. protected function _getAmount()
  8. {
  9. // todo 订单优惠券计算需要参照抵扣的结构重构, 这里先调用一次订单的抵扣金额,来保证先绑定订单商品优惠券的模型,后通过模型获取订单商品优惠券总金额
  10. $this->orderGoods->order->getPriceAfter('coupon');
  11. return max($this->orderGoods->getCouponAmount(), 0);
  12. //return max($this->orderGoods->getPriceBefore($this->code) - $this->orderGoods->getCouponAmount(), 0);
  13. }
  14. }