diff --git a/app/Service/ServiceTrait/Api/OrderTrait.php b/app/Service/ServiceTrait/Api/OrderTrait.php index aa2db58..dca651e 100644 --- a/app/Service/ServiceTrait/Api/OrderTrait.php +++ b/app/Service/ServiceTrait/Api/OrderTrait.php @@ -353,16 +353,16 @@ trait OrderTrait { 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')); - $this->orderRes['coupon_info']['amount'] = match ($this->orderRes['coupon_info']['coupon_type']) { - CouponCode::COUPON_TYPE_INSTANT_REDUCTION => $this->orderRes['coupon_info']['amount'], - CouponCode::COUPON_TYPE_DISCOUNT => bcmul(bcdiv("100", bcsub("100",$this->orderRes['coupon_info']['ratio'],2),2),$orderMaxPrice,2), + $this->orderRes['coupon']['amount'] = match ($this->orderRes['coupon']['coupon_type']) { + CouponCode::COUPON_TYPE_INSTANT_REDUCTION => $this->orderRes['coupon']['amount'], + CouponCode::COUPON_TYPE_DISCOUNT => bcmul(bcdiv("100", bcsub("100",$this->orderRes['coupon']['ratio'],2),2),$orderMaxPrice,2), 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['actual_price'] = bcsub($this->orderRes['actual_price'],$this->orderRes['favorable_good_price'],2); }