From e6176f6bbd7bf0c54b1cc0a31426f8cf66d06ab0 Mon Sep 17 00:00:00 2001 From: ctexthuang Date: Mon, 31 Mar 2025 17:52:14 +0800 Subject: [PATCH] fix : coupon --- app/Service/Api/Order/BaseOrderService.php | 1 + app/Service/ServiceTrait/Api/OrderTrait.php | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/Service/Api/Order/BaseOrderService.php b/app/Service/Api/Order/BaseOrderService.php index abbad59..d400232 100644 --- a/app/Service/Api/Order/BaseOrderService.php +++ b/app/Service/Api/Order/BaseOrderService.php @@ -151,6 +151,7 @@ abstract class BaseOrderService extends BaseService 'sundry_num' => 0, //服务费数量 'favorable_sundry_price' => '0.00', //服务费优惠价格 'sundry_after_discount_price' => '0.00', //服务费优惠后价格 + 'discount_price' => '0.00', // 优惠金额 'actual_price' => '0.00', //实际支付价格 'coupon_id' => 0, 'coupon' => [], diff --git a/app/Service/ServiceTrait/Api/OrderTrait.php b/app/Service/ServiceTrait/Api/OrderTrait.php index e5659b1..868d432 100644 --- a/app/Service/ServiceTrait/Api/OrderTrait.php +++ b/app/Service/ServiceTrait/Api/OrderTrait.php @@ -408,18 +408,19 @@ trait OrderTrait "100", 2 ), - max(array_column($this->orderRes['good'],'price')), + bcadd((string)max(array_column($this->orderRes['good'],'price')),(string)$this->orderRes['sundry_price'],2), 2 ), default => 0 }; } - $this->orderRes['favorable_good_price'] = $this->orderRes['coupon']['coupon_type'] == CouponCode::COUPON_TYPE_INSTANT_REDUCTION ? - min($this->orderRes['coupon']['amount'], $this->orderRes['good_after_discount_price']) : - $this->orderRes['coupon']['amount']; - $this->orderRes['good_after_discount_price'] = bcsub((string)$this->orderRes['good_after_discount_price'],(string)$this->orderRes['favorable_good_price'],2); - $this->orderRes['actual_price'] = bcsub((string)$this->orderRes['actual_price'],(string)$this->orderRes['favorable_good_price'],2); +// $this->orderRes['favorable_good_price'] = $this->orderRes['coupon']['coupon_type'] == CouponCode::COUPON_TYPE_INSTANT_REDUCTION ? +// min($this->orderRes['coupon']['amount'], $this->orderRes['good_after_discount_price']) : +// $this->orderRes['coupon']['amount']; +// $this->orderRes['good_after_discount_price'] = bcsub((string)$this->orderRes['good_after_discount_price'],(string)$this->orderRes['favorable_good_price'],2); + $this->orderRes['discount_price'] = min($this->orderRes['coupon']['amount'],$this->orderRes['coupon']['actual_price']); + $this->orderRes['actual_price'] = bcsub((string)$this->orderRes['actual_price'],(string)$this->orderRes['discount_price'],2); } /**