diff --git a/app/api/controller/Index.php b/app/api/controller/Index.php index 4ff19c9..42cbfdb 100755 --- a/app/api/controller/Index.php +++ b/app/api/controller/Index.php @@ -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() diff --git a/app/api/route/app.php b/app/api/route/app.php index 4991c9b..4668a08 100755 --- a/app/api/route/app.php +++ b/app/api/route/app.php @@ -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');