From 1a1f88cbdf261dace802e1131b9661a87cf49c69 Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Sun, 28 Jun 2026 22:31:48 +0800 Subject: [PATCH] OfflineOrderItem.coupon_discount_amount --- app/Models/UserCoupon.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) 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;