房间用户列表

This commit is contained in:
2025-12-09 19:55:56 +08:00
parent b29b9bbcd9
commit 9fbc544a85

View File

@@ -1883,28 +1883,10 @@ class Room extends Model
}
} else {
// 第二页及以后:只显示麦下用户
// 偏移量计算:对于第二页及以后,我们需要考虑第一页已经展示的麦下用户数量
// 第一页展示的麦下用户数量是 min(limit - onPitCount, totalOffPitCount)
// 所以从第二页开始的偏移量应该是 (page-2) * limit + (limit - onPitCount)
// 先查询所有符合条件的麦下用户总数
$totalOffPitCount = db::name('vs_room_visitor')->alias('a')
->join('user b', 'a.user_id = b.id')
->where(['a.room_id' => $room_id,'b.hide_status' => 0,'a.is_onpit' => 1])
->count();
// 计算偏移量
if ($page == 2) {
// 第二页的偏移量就是第一页展示的麦下用户数量
$offset = min($limit - $onPitCount, $totalOffPitCount);
} else {
// 第三页及以后需要考虑前面所有页已经展示的麦下用户
// 前面已经展示的麦下用户 = 第一页展示的 + (page-2) * limit
$firstPageOffPitCount = min($limit - $onPitCount, $totalOffPitCount);
$offset = $firstPageOffPitCount + ($page - 2) * $limit;
}
// 修复:确保偏移量不会为负数
// 计算偏移量:总偏移量 = (页码-1) * 每页数量 - 麦上用户数量
// 因为第一页包含了麦上用户,所以从第二页开始只需要麦下用户
$offset = ($page - 1) * $limit - $onPitCount;
// 确保偏移量不会为负数
$offset = max(0, $offset);
$offPitUser = db::name('vs_room_visitor')->alias('a')