房间排行榜

This commit is contained in:
2026-01-16 14:56:01 +08:00
parent 50a7226864
commit b8b935c8b2
3 changed files with 65 additions and 32 deletions

View File

@@ -141,6 +141,7 @@ class GiveGiftBases extends Model
$this->success('获取成功', $result);
}
/**
* 用户送礼统计
*/
@@ -382,4 +383,43 @@ class GiveGiftBases extends Model
return $result;
}
/**
* 获取房间内送礼排行
*/
public function getRoomGiftRanking($params,$type)
{
$where = [];
$options = [];
// 时间范围
if (!empty($params['start_time'])) {
$options['start_time'] = $params['start_time'];
}
if (!empty($params['end_time'])) {
$options['end_time'] = $params['end_time'];
}
// 构建查询条件
if (!empty($params['from_id'])) {
$where['from_id'] = $params['from_id'];
}
// 分页参数
$options['page'] = $params['page'] ?? 1;
$options['limit'] = min($params['limit'] ?? 20, 100); // 限制最大100条
if($type == 1){
$options['group_by'] = 'user_id';
}else{
$options['group_by'] = 'gift_user';
}
// 查询数据
$result = $this->giftModel->getGiftStatisticsRanking($where, $options);
return $result;
}
}