From e03534469a49030e625f7f7c7bf86ffc878f9978 Mon Sep 17 00:00:00 2001 From: wangxiaowei Date: Fri, 29 Nov 2024 14:35:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E4=B8=8B=E5=8D=95=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4=E6=98=AF=E5=90=A6=E8=B4=AD=E4=B9=B0=E8=BF=87=E5=A5=BD?= =?UTF-8?q?=E7=89=A9=E7=9B=B4=E9=99=8D=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/OrderLogic.php | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/app/api/logic/OrderLogic.php b/app/api/logic/OrderLogic.php index 633c6486..91d6f08a 100755 --- a/app/api/logic/OrderLogic.php +++ b/app/api/logic/OrderLogic.php @@ -120,22 +120,31 @@ class OrderLogic extends Logic Db::startTrans(); try { - if ($post['order_type'] == 4) { - $in_activity = Order::where(['user_id' => $post['user_id'], 'order_type' => 4])->where('order_status', '<', 4)->find(); - if ($in_activity) { - throw new Exception('每位用户只能限抢一件商品'); - } + if ($post['order_type'] == OrderEnum::GROUP_BUY) { +// $in_activity = Order::where(['user_id' => $post['user_id'], 'order_type' => 4])->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(); - if($isOrder){ + foreach ($goods as $v) { + $in_activity = Order::alias('a') + ->join('order_goods og', 'a.id = og.order_id') + ->where(['a.user_id' => $post['user_id'], 'a.order_type' => 4, 'og.goods_id' => $v['goods_id']]) + ->where('a.order_status', '<', 4) + ->find(); + + if ($in_activity) { throw new Exception('您已抢购过此商品'); } +// $isOrder = Db::name('order')->where([ +// 'activity_sn' => $activ['activity_sn'], +// 'user_id' => $post['user_id'] +// ]) +// ->where('order_status', '<>', 4) +// ->find(); +// if($isOrder){ +// throw new Exception('您已抢购过此商品'); +// } } }