From ea08aa94a6e5082a01433ed049b41e064cbf5f5b Mon Sep 17 00:00:00 2001 From: ctexthuang Date: Wed, 6 Aug 2025 21:37:30 +0800 Subject: [PATCH] fix : auto coupon --- .../Api/Order/ConfirmationOrderService.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/Service/Api/Order/ConfirmationOrderService.php b/app/Service/Api/Order/ConfirmationOrderService.php index f6670b7..e68e245 100644 --- a/app/Service/Api/Order/ConfirmationOrderService.php +++ b/app/Service/Api/Order/ConfirmationOrderService.php @@ -72,7 +72,20 @@ class ConfirmationOrderService extends BaseOrderService foreach ($filtered as &$value) { $value['amount'] = match ($value['coupon_type']) { CouponCode::COUPON_TYPE_INSTANT_REDUCTION => $value['amount'], - CouponCode::COUPON_TYPE_DISCOUNT => bcmul(bcsub("1", (string)$value['ratio'],2),(string)$orderMaxPrice,2), +// CouponCode::COUPON_TYPE_DISCOUNT => bcmul(bcsub("100", (string)$value['ratio'],2),(string)$orderMaxPrice,2), + CouponCode::COUPON_TYPE_DISCOUNT => bcmul( + bcdiv( + bcsub( + "100", + (string)$value['ratio'], + 2 + ), + "100", + 2 + ), + bcadd((string)max(array_column($this->orderRes['good'],'price')),(string)$this->orderRes['sundry_price'],2), + 2 + ), default => 0 };