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

This commit is contained in:
wangxiaowei 2024-09-30 16:08:52 +08:00
parent f9a3ecf946
commit 3867fd19fb
2 changed files with 2 additions and 2 deletions

@ -1115,7 +1115,7 @@ class GoodsLogic extends Logic
}
// 如果当前用户参与了抢购的活动(则不允许再次抢购)
$in_activity = Order::where('user_id', $userId)->where('order_status', '<', 4)->find();
$in_activity = Order::where(['user_id' => $userId, 'order_type' => 4])->where('order_status', '<', 4)->find();
$goods['activity'] = [
'type' => 4,

@ -120,7 +120,7 @@ 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();
$in_activity = Order::where(['user_id' => $userId, 'order_type' => 4])->where('order_status', '<', 4)->find();
if ($in_activity) {
throw new Exception('每位用户只能限抢一件商品');
}