判断用户是否参与了抢购商品的活动

This commit is contained in:
wangxiaowei 2024-09-30 15:55:06 +08:00
parent e43561d28f
commit f9a3ecf946

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