From 63f60bc92b615db113ef1f8c86916d4e49b07996 Mon Sep 17 00:00:00 2001 From: ctexthuang Date: Tue, 4 Mar 2025 18:01:07 +0800 Subject: [PATCH] feat : coupon --- app/Service/Api/Order/ConfirmationOrderService.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Service/Api/Order/ConfirmationOrderService.php b/app/Service/Api/Order/ConfirmationOrderService.php index 3046102..366b1fc 100644 --- a/app/Service/Api/Order/ConfirmationOrderService.php +++ b/app/Service/Api/Order/ConfirmationOrderService.php @@ -42,6 +42,9 @@ class ConfirmationOrderService extends BaseOrderService return $this->return->success('success',$this->orderRes); } + /** + * @return void + */ private function autoSelectCoupon(): void { if ($this->couponId != 0) return; @@ -56,7 +59,7 @@ class ConfirmationOrderService extends BaseOrderService $maxValidityEndTimeDate = max(array_column($noUseCoupon,'validity_end_time')); $filtered = array_filter($noUseCoupon, function($item) use($maxValidityEndTimeDate) { - return $item['validity_end_time'] === $maxValidityEndTimeDate; + return $item['validity_end_time'] == $maxValidityEndTimeDate; }); $selectMaxPrice = 0; @@ -64,7 +67,7 @@ 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 => $value['amount'] * $orderMaxPrice, + CouponCode::COUPON_TYPE_DISCOUNT => $value['ratio'] * $orderMaxPrice, default => 0 };