排行榜

This commit is contained in:
2026-01-09 20:12:17 +08:00
parent be15b70885
commit 9a95595dd8
2 changed files with 71 additions and 63 deletions

View File

@@ -144,7 +144,7 @@ class GiveGiftBases extends Model
/**
* 用户送礼统计
*/
public function getUserStatistics($params)
public function getUserStatistics($params,$type)
{
$userId = $params['user_id'];
@@ -155,7 +155,12 @@ class GiveGiftBases extends Model
return ['code'=>0,'msg'=>'用户ID不能为空','data'=>null];
}
$where = ['user_id' => $userId];
if($type==1){
$where = ['user_id' => $userId];
}else{
$where = ['gift_user' => $userId];
}
$options = [
'start_time' => $startTime,
'end_time' => $endTime,
@@ -343,7 +348,7 @@ class GiveGiftBases extends Model
* 获取送礼排行
*/
public function getGiftRanking($params)
public function getGiftRanking($params,$type)
{
$where = [];
$options = [];
@@ -360,7 +365,12 @@ class GiveGiftBases extends Model
$options['page'] = $params['page'] ?? 1;
$options['limit'] = min($params['limit'] ?? 20, 100); // 限制最大100条
$options['group_by'] = 'user_id';
if($type == 1){
$options['group_by'] = 'user_id';
}else{
$options['group_by'] = 'gift_user';
}
// 查询数据
$result = $this->giftModel->getGiftStatisticsRanking($where, $options);