6
0
Fork 0

OfflineOrderItem.coupon_discount_amount

base
panliang 2026-06-28 22:31:48 +08:00
parent c4c098c385
commit 1a1f88cbdf
1 changed files with 9 additions and 7 deletions

View File

@ -176,6 +176,7 @@ class UserCoupon extends Model
public function getDiscountAmount(int $total) public function getDiscountAmount(int $total)
{ {
$couponDiscount = 0; $couponDiscount = 0;
if ($this->coupon_amount > 0) {
// 优惠券: 直接抵扣 // 优惠券: 直接抵扣
if ($this->coupon_type == Coupon::TYPE_AMOUNT) { if ($this->coupon_type == Coupon::TYPE_AMOUNT) {
$couponDiscount = $this->coupon_amount; $couponDiscount = $this->coupon_amount;
@ -184,6 +185,7 @@ class UserCoupon extends Model
else if ($this->coupon_type == Coupon::TYPE_DISCOUNT) { else if ($this->coupon_type == Coupon::TYPE_DISCOUNT) {
$couponDiscount = (int) bcmul($total, bcdiv(100 - $this->coupon_amount, 100, 2)); $couponDiscount = (int) bcmul($total, bcdiv(100 - $this->coupon_amount, 100, 2));
} }
}
return $couponDiscount; return $couponDiscount;
} }