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)