From 318547e9c86c30ddfd0a899c74d3278bbee7b21e Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Thu, 27 Aug 2020 13:10:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=A2=E5=8D=95=E6=8B=A6?= =?UTF-8?q?=E6=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/PaymentController.php | 2 +- app/Service/OrderService.php | 3 +-- app/Service/PurchaseLimitService.php | 7 +++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/Controller/PaymentController.php b/app/Controller/PaymentController.php index c691ed6..c6c9788 100644 --- a/app/Controller/PaymentController.php +++ b/app/Controller/PaymentController.php @@ -51,7 +51,7 @@ class PaymentController extends BaseController ->get(); //判断是否有购买多个特价商品 $result = $this->purchaseLimitService->PurchaseLimit($orderGoods); - if($result > 1){ + if(!$result){ Db::rollBack(); $this->log->event(LogLabel::ORDER_LOG, ['msg'=> '支付失败,同一订单不能存在多个特价商品','global_order_id' => $orderMain->global_order_id]); return $this->result(ErrorCode::PAY_FAILURE, $data,'同一订单不能存在多个特价商品'); diff --git a/app/Service/OrderService.php b/app/Service/OrderService.php index 38802eb..6bb990b 100644 --- a/app/Service/OrderService.php +++ b/app/Service/OrderService.php @@ -308,7 +308,7 @@ class OrderService implements OrderServiceInterface } //判断是否有购买多个特价商品 $result = $this->purchaseLimitService->PurchaseLimit($orderGoods); - if($result > 1){ + if(!$result){ Db::rollBack(); return '同一个订单不能购买多个特价商品'; } @@ -343,7 +343,6 @@ class OrderService implements OrderServiceInterface 'status' => 1, 'update_time' => 0, ]; - var_dump('$couponUse',$couponUse); $insertRes = CouponUserUse::query()->insert($couponUse); diff --git a/app/Service/PurchaseLimitService.php b/app/Service/PurchaseLimitService.php index 7c14fdd..a75b85e 100644 --- a/app/Service/PurchaseLimitService.php +++ b/app/Service/PurchaseLimitService.php @@ -80,13 +80,16 @@ class PurchaseLimitService implements PurchaseLimitServiceInterface public function PurchaseLimit($orderGoods) { + $sum = 0; foreach ($orderGoods as $goods){ - $sum = 0; if($goods['money'] == 0.01){ + if($sum > 0){ + return false; + } $sum++; } } - return $sum; + return true; } public function test($params)