房间用户列表
This commit is contained in:
@@ -1844,23 +1844,16 @@ class Room extends Model
|
||||
}
|
||||
unset($v); // 释放引用
|
||||
$lists['on_pit'] = $onPitUser;
|
||||
$onPitUserIds = array_column($lists['on_pit'], 'user_id');
|
||||
}
|
||||
}
|
||||
|
||||
// 计算麦上用户数量
|
||||
$onPitCount = count($lists['on_pit']);
|
||||
|
||||
// 获取麦下用户(非隐身用户)
|
||||
if ($page == 1) {
|
||||
// 第一页:需要的麦下用户数量 = limit - 麦上用户数量
|
||||
$needOffPitCount = $limit - $onPitCount;
|
||||
if ($needOffPitCount > 0) {
|
||||
$offPitUser = db::name('vs_room_visitor')->alias('a')
|
||||
->join('user b', 'a.user_id = b.id','left')
|
||||
->field('a.user_id,b.nickname,b.avatar,b.hide_status,a.is_onpit')
|
||||
->where(['a.room_id' => $room_id,'b.hide_status' => 0,'a.is_onpit' => 1,'a.user_id' => ['not in', empty($onPitUserIds) ? [0] : $onPitUserIds]]) // 非隐身且未上麦
|
||||
->limit(0, $needOffPitCount)
|
||||
->where(['a.room_id' => $room_id,'b.hide_status' => 0,'a.is_onpit' => 1]) // 非隐身且未上麦
|
||||
->page($page, $limit)
|
||||
->order('a.id', 'desc')
|
||||
->select();
|
||||
|
||||
@@ -1882,18 +1875,13 @@ class Room extends Model
|
||||
unset($v); // 释放引用
|
||||
$lists['off_pit'] = $offPitUser;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 第二页及以后:只显示麦下用户
|
||||
$offset = ($page - 1) * $limit;
|
||||
// 确保偏移量不会为负数
|
||||
$offset = max(0, $offset);
|
||||
|
||||
} else {
|
||||
$offPitUser = db::name('vs_room_visitor')->alias('a')
|
||||
->join('user b', 'a.user_id = b.id','left')
|
||||
->field('a.user_id,b.nickname,b.avatar,b.hide_status,a.is_onpit')
|
||||
->where(['a.room_id' => $room_id,'b.hide_status' => 0,'a.is_onpit' => 1,'a.user_id' => ['not in', empty($onPitUserIds) ? [0] : $onPitUserIds]]) // 非隐身且未上麦
|
||||
->limit($offset, $limit)
|
||||
->where(['a.room_id' => $room_id,'b.hide_status' => 0,'a.is_onpit' => 1]) // 非隐身且未上麦
|
||||
->page($page, $limit)
|
||||
->order('a.id', 'desc')
|
||||
->select();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user