diff --git a/app/Controller/PurchaseLimitController.php b/app/Controller/PurchaseLimitController.php index 32fca1f..4e9e3fe 100644 --- a/app/Controller/PurchaseLimitController.php +++ b/app/Controller/PurchaseLimitController.php @@ -36,7 +36,7 @@ class PurchaseLimitController extends BaseController public function test() { - $res = $this->purchaseLimitService->test($this->request->all()); + $res = $this->purchaseLimitService->PurchaseLimit($this->request->input('global_order_id')); return $this->success($res); } diff --git a/app/Service/OrderService.php b/app/Service/OrderService.php index 3b0e76a..a02634e 100644 --- a/app/Service/OrderService.php +++ b/app/Service/OrderService.php @@ -300,6 +300,12 @@ class OrderService implements OrderServiceInterface Db::rollBack(); return '订单商品异常'; } + //判断是否有购买多个特价商品 + $result = $this->purchaseLimitService->PurchaseLimit($orderGoods); + if(!$result){ + Db::rollBack(); + return '同一个订单不能购买多个特价商品'; + } //判断是否有购买特价商品 $this->purchaseLimitService->ssdbPurchaseRecord($orderGoods,$data['user_id'],$dataMain['global_order_id']); diff --git a/app/Service/PurchaseLimitService.php b/app/Service/PurchaseLimitService.php index 3c10a5a..cfb41ef 100644 --- a/app/Service/PurchaseLimitService.php +++ b/app/Service/PurchaseLimitService.php @@ -78,6 +78,20 @@ class PurchaseLimitService implements PurchaseLimitServiceInterface return true; } + public function PurchaseLimit($orderGoods) + { + foreach ($orderGoods as $goods){ + $sum = 0; + if($goods['money'] == 0.01){ + if($sum > 0){ + return false; + } + $sum++; + } + } + return true; + } + public function test($params) { $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); diff --git a/app/Service/PurchaseLimitServiceInterface.php b/app/Service/PurchaseLimitServiceInterface.php index f5e415b..da0f536 100644 --- a/app/Service/PurchaseLimitServiceInterface.php +++ b/app/Service/PurchaseLimitServiceInterface.php @@ -12,5 +12,7 @@ interface PurchaseLimitServiceInterface public function delSsdbPurchaseRecord($global_order_id); + public function PurchaseLimit($orderGoods); + public function test($params); } \ No newline at end of file