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,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;