From 99a22b26d1dc635785e3a95b74a2b6b6227c8e65 Mon Sep 17 00:00:00 2001 From: ctexthuang Date: Fri, 21 Mar 2025 09:22:13 +0800 Subject: [PATCH] feat : coupon --- app/Service/Api/Pay/PlacePayService.php | 2 +- app/Service/ServiceTrait/Api/OrderTrait.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Service/Api/Pay/PlacePayService.php b/app/Service/Api/Pay/PlacePayService.php index 7d31e8c..a99af9e 100644 --- a/app/Service/Api/Pay/PlacePayService.php +++ b/app/Service/Api/Pay/PlacePayService.php @@ -274,7 +274,7 @@ class PlacePayService extends BaseService private function checkPayOrder(): void { $this->payInfo = $this->payOrderModel->getInfoByOrderIdAndTypeAndRType($this->orderId,$this->orderType,$this->payType); - if (!empty($this->payInfo)) return; + if (empty($this->payInfo)) return; if ($this->payInfo->status == PayCode::FINISH_PAY) throw new ErrException('该订单已支付,请确认后重试'); if ($this->payInfo->recharge_type != $this->payType) throw new ErrException('该订单调起支付失败'); if ($this->payInfo->order_type != $this->orderType) throw new ErrException('传值错误'); diff --git a/app/Service/ServiceTrait/Api/OrderTrait.php b/app/Service/ServiceTrait/Api/OrderTrait.php index 622656a..5371c94 100644 --- a/app/Service/ServiceTrait/Api/OrderTrait.php +++ b/app/Service/ServiceTrait/Api/OrderTrait.php @@ -362,7 +362,7 @@ trait OrderTrait $orderMaxPrice = max(array_column($this->orderRes['good'],'price')); $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((string)$this->orderRes['coupon']['ratio'],"100",2),(string)$orderMaxPrice,2), + CouponCode::COUPON_TYPE_DISCOUNT => bcmul(bcdiv(bcsub("100",(string)$this->orderRes['coupon']['ratio'],2),"100",2),$orderMaxPrice,2), default => 0 }; }