邀请排行榜
This commit is contained in:
parent
bc7319b21d
commit
62615d0a3b
|
|
@ -146,11 +146,31 @@ class Index extends Base
|
|||
{
|
||||
//select * from ( SELECT pid,count(1) n FROM xinglanmh_shequt_test.`user` where pid>0 group by pid ) t where n>1 order by n desc LIMIT 10
|
||||
$list = User::where('pid', '>', 0)
|
||||
->field('pid, COUNT(1) as n') // 选取 pid 和 计数字段
|
||||
->group('pid')
|
||||
->having('COUNT(*)', '>', 1)
|
||||
->order('COUNT(*) desc')
|
||||
->having('n', '>', 1) // `having` 需要使用 `as` 取别名
|
||||
->order('n desc')
|
||||
// ->limit(10) // 添加限制条数
|
||||
->select();
|
||||
return $this->renderSuccess('请求成功', $list);
|
||||
$data = array();
|
||||
$index = 1;
|
||||
foreach ($list as $item) {
|
||||
$pid = $item['pid'];
|
||||
// $count = $item['n'];
|
||||
// $item['user_id'] = $pid;
|
||||
$user_info = User::field('nickname,headimg,mobile')->where('id', '=', $pid)->find();
|
||||
if ($user_info != null) {
|
||||
$data[] = [
|
||||
'index' => $index,
|
||||
'user_id' => $pid,
|
||||
'invitenumber' => $item['n'],
|
||||
'nickname' => $user_info['nickname'],
|
||||
'headimg' => imageUrl($user_info['headimg'])
|
||||
];
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
return $this->renderSuccess('请求成功', $data);
|
||||
}
|
||||
|
||||
public function generate_urllink()
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ Route::any('picture1', 'Upload/picture1');
|
|||
Route::any('index', 'Index/index');
|
||||
Route::any('getAdvert', 'Index/getAdvert');
|
||||
Route::any('record', 'Index/record');
|
||||
Route::any('user_yaoqing', 'Index/get_user_yaoqing');
|
||||
|
||||
Route::any('yushourili', 'Index/yushourili');
|
||||
Route::any('danye', 'Index/danye');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user