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('您已抢购过此商品'); +// } } }