From f9a3ecf9466284345b81f20b4e858a7795fb259d Mon Sep 17 00:00:00 2001 From: wangxiaowei Date: Mon, 30 Sep 2024 15:55:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A4=E6=96=AD=E7=94=A8=E6=88=B7=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E5=8F=82=E4=B8=8E=E4=BA=86=E6=8A=A2=E8=B4=AD=E5=95=86?= =?UTF-8?q?=E5=93=81=E7=9A=84=E6=B4=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/OrderLogic.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/api/logic/OrderLogic.php b/app/api/logic/OrderLogic.php index e6c56970..507220d8 100755 --- a/app/api/logic/OrderLogic.php +++ b/app/api/logic/OrderLogic.php @@ -112,8 +112,6 @@ class OrderLogic extends Logic } } - - foreach ($goods as &$good) { $good['delivery_type'] = !isset($good['delivery_type']) ? OrderEnum::DELIVERY_TYPE_EXPRESS : $good['delivery_type']; } @@ -121,15 +119,19 @@ class OrderLogic extends Logic Db::startTrans(); try { - if ($post['order_type'] == 4) { + $in_activity = Order::where('user_id', $post['user_id'])->where('order_status', '<', 4)->find(); + if ($in_activity) { + throw new Exception('每位用户只能限抢一件商品'); + } + foreach ($goods as $activ) { $isOrder = Db::name('order')->where([ 'activity_sn' => $activ['activity_sn'], 'user_id' => $post['user_id'] ]) - ->where('order_status', '<>', 4) - ->find(); + ->where('order_status', '<>', 4) + ->find(); if($isOrder){ throw new Exception('您已抢购过此商品'); }