quanwei
18 hours ago c441dea81bd86bdfb12dff35821fed51f4cc91c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
 
namespace app\operations\service\statistics;
 
use app\operations\model\user\User as UserModel;
 
/**
 * 数据统计-用户排行
 */
class UserRankingService
{
    /**
     * 用户消费榜
     */
    public function getUserRanking($type)
    {
        $model = new UserModel();
        $model = $model->field(['user_id', 'nickName', 'avatarUrl', 'expend_money', 'total_points', 'total_invite'])
            ->where('is_delete', '=', 0);
        if($type == 'pay'){
            $model = $model->order(['expend_money' => 'DESC']);
        } else if($type == 'points'){
            $model = $model->order(['total_points' => 'DESC']);
        } else if($type == 'invite'){
            $model = $model->order(['total_invite' => 'DESC']);
        }
        return $model->limit(10)->select();
    }
 
}