diff --git a/app/Models/UserCoupon.php b/app/Models/UserCoupon.php index 9ada496f..56c6c67a 100644 --- a/app/Models/UserCoupon.php +++ b/app/Models/UserCoupon.php @@ -176,13 +176,15 @@ class UserCoupon extends Model public function getDiscountAmount(int $total) { $couponDiscount = 0; - // 优惠券: 直接抵扣 - if ($this->coupon_type == Coupon::TYPE_AMOUNT) { - $couponDiscount = $this->coupon_amount; - } - // 优惠券: 折扣 - else if ($this->coupon_type == Coupon::TYPE_DISCOUNT) { - $couponDiscount = (int) bcmul($total, bcdiv(100 - $this->coupon_amount, 100, 2)); + if ($this->coupon_amount > 0) { + // 优惠券: 直接抵扣 + if ($this->coupon_type == Coupon::TYPE_AMOUNT) { + $couponDiscount = $this->coupon_amount; + } + // 优惠券: 折扣 + else if ($this->coupon_type == Coupon::TYPE_DISCOUNT) { + $couponDiscount = (int) bcmul($total, bcdiv(100 - $this->coupon_amount, 100, 2)); + } } return $couponDiscount;