feat : config

This commit is contained in:
2025-03-20 15:50:49 +08:00
parent 0dc49e5c3c
commit 7be642f104

View File

@@ -353,16 +353,16 @@ trait OrderTrait
{ {
if ($this->couponId <= 0 || empty($this->orderRes['coupon']) || $this->orderRes['coupon_id'] <= 0) return; if ($this->couponId <= 0 || empty($this->orderRes['coupon']) || $this->orderRes['coupon_id'] <= 0) return;
if ($this->orderRes['coupon_info']['amount'] <= 0 && $this->orderRes['coupon_info']['coupon_type'] != CouponCode::COUPON_TYPE_INSTANT_REDUCTION) { if ($this->orderRes['coupon']['amount'] <= 0 && $this->orderRes['coupon']['coupon_type'] != CouponCode::COUPON_TYPE_INSTANT_REDUCTION) {
$orderMaxPrice = max(array_column($this->orderRes['good'],'price')); $orderMaxPrice = max(array_column($this->orderRes['good'],'price'));
$this->orderRes['coupon_info']['amount'] = match ($this->orderRes['coupon_info']['coupon_type']) { $this->orderRes['coupon']['amount'] = match ($this->orderRes['coupon']['coupon_type']) {
CouponCode::COUPON_TYPE_INSTANT_REDUCTION => $this->orderRes['coupon_info']['amount'], CouponCode::COUPON_TYPE_INSTANT_REDUCTION => $this->orderRes['coupon']['amount'],
CouponCode::COUPON_TYPE_DISCOUNT => bcmul(bcdiv("100", bcsub("100",$this->orderRes['coupon_info']['ratio'],2),2),$orderMaxPrice,2), CouponCode::COUPON_TYPE_DISCOUNT => bcmul(bcdiv("100", bcsub("100",$this->orderRes['coupon']['ratio'],2),2),$orderMaxPrice,2),
default => 0 default => 0
}; };
} }
$this->orderRes['favorable_good_price'] = $this->orderRes['coupon_info']['amount']; $this->orderRes['favorable_good_price'] = $this->orderRes['coupon']['amount'];
$this->orderRes['good_after_discount_price'] = bcsub($this->orderRes['good_after_discount_price'],$this->orderRes['favorable_good_price'],2); $this->orderRes['good_after_discount_price'] = bcsub($this->orderRes['good_after_discount_price'],$this->orderRes['favorable_good_price'],2);
$this->orderRes['actual_price'] = bcsub($this->orderRes['actual_price'],$this->orderRes['favorable_good_price'],2); $this->orderRes['actual_price'] = bcsub($this->orderRes['actual_price'],$this->orderRes['favorable_good_price'],2);
} }