|
|
@@ -123,17 +123,63 @@ class User extends BaseController
|
|
|
* 获取用户总邀请人数排行榜
|
|
|
* @param Request $request
|
|
|
*/
|
|
|
+// public function getInviterRanking(Request $request)
|
|
|
+// {
|
|
|
+// $time = $request->param('time');
|
|
|
+// $times = $request->param('times');
|
|
|
+// $users = (new UserModel())
|
|
|
+// ->where('parent_uid', '<>', 0)
|
|
|
+// ->where('regtime', '>=', $time)
|
|
|
+// ->where('regtime', '<=', $times)
|
|
|
+// ->field('parent_uid as uid, count(*) as invite_count')
|
|
|
+// ->group('parent_uid')
|
|
|
+// ->order('invite_count', 'desc')
|
|
|
+// ->select();
|
|
|
+// $rankList = [];
|
|
|
+// foreach ($users as $key => $value) {
|
|
|
+// $userInfo = (new UserModel)->where('uid', $value['uid'])->find();
|
|
|
+// $auth = (new InfoAudit)->where('uid', $value['uid'])->find();
|
|
|
+// $user_work_type_title = (new UserWorkType)->where('id', $auth['user_work_type_id'])->find();
|
|
|
+// $rankList[] = [
|
|
|
+// 'rank' => $key + 1,
|
|
|
+// 'uid' => $value['uid'],
|
|
|
+// 'nickname' => $userInfo['nickname'],
|
|
|
+// 'avatar' => $userInfo['avatar'],
|
|
|
+// 'invite_count' => $value['invite_count'],
|
|
|
+// 'is_type_audit' => $auth && $auth['status'] == 1 ? 1 : 0,
|
|
|
+// 'ancestral_place' => $auth ? $auth['ancestral_place'] : '',
|
|
|
+// 'auth_info' => $auth ? $auth->toArray() : [],
|
|
|
+// 'user_work_type_id' => $user_work_type_title['title'],
|
|
|
+// ];
|
|
|
+// }
|
|
|
+//
|
|
|
+// $rankList = array_values(array_filter($rankList, function ($item) {
|
|
|
+// return !empty($item['ancestral_place']);
|
|
|
+// }));
|
|
|
+//
|
|
|
+// $inviteCount = array_column($rankList, 'invite_count');
|
|
|
+// $uid = array_column($rankList, 'uid');
|
|
|
+// array_multisort($inviteCount, SORT_DESC, $uid, SORT_ASC, $rankList);
|
|
|
+//
|
|
|
+// $data['list'] = $rankList;
|
|
|
+//
|
|
|
+// return app('json')->success($data);
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
public function getInviterRanking(Request $request)
|
|
|
{
|
|
|
$time = $request->param('time');
|
|
|
$times = $request->param('times');
|
|
|
$users = (new UserModel())
|
|
|
- ->where('parent_uid', '<>', 0)
|
|
|
- ->where('regtime', '>=', $time)
|
|
|
- ->where('regtime', '<=', $times)
|
|
|
- ->field('parent_uid as uid, count(*) as invite_count')
|
|
|
- ->group('parent_uid')
|
|
|
+ ->leftJoin('user u', 'u.uid = user.parent_uid')
|
|
|
+ ->where('user.parent_uid', '<>', 0)
|
|
|
+ ->where('user.regtime', '>=', $time)
|
|
|
+ ->where('user.regtime', '<=', $times)
|
|
|
+ ->field('user.parent_uid as uid, IFNULL(count(u.uid), 0) as invite_count')
|
|
|
+ ->group('user.parent_uid')
|
|
|
->order('invite_count', 'desc')
|
|
|
+ ->order('user.parent_uid', 'asc')
|
|
|
->select();
|
|
|
$rankList = [];
|
|
|
foreach ($users as $key => $value) {
|
|
|
@@ -154,7 +200,7 @@ class User extends BaseController
|
|
|
}
|
|
|
|
|
|
$rankList = array_values(array_filter($rankList, function ($item) {
|
|
|
- return !empty($item['ancestral_place']);
|
|
|
+ return empty($item['auth_info']['service_area']);
|
|
|
}));
|
|
|
|
|
|
$inviteCount = array_column($rankList, 'invite_count');
|
|
|
@@ -167,47 +213,6 @@ class User extends BaseController
|
|
|
}
|
|
|
|
|
|
|
|
|
-// public function getInviterRanking(Request $request)
|
|
|
-// {
|
|
|
-// $time = $request->param('time');
|
|
|
-// $times = $request->param('times');
|
|
|
-// $users = (new UserModel())
|
|
|
-// ->leftJoin('user u', 'u.uid = user.parent_uid')
|
|
|
-// ->where('user.parent_uid', '<>', 0)
|
|
|
-// ->where('user.regtime', '>=', $time)
|
|
|
-// ->where('user.regtime', '<=', $times)
|
|
|
-// ->field('user.parent_uid as uid, count(u.uid) as invite_count')
|
|
|
-// ->group('user.parent_uid')
|
|
|
-// ->order('invite_count', 'desc')
|
|
|
-// ->select();
|
|
|
-// $rankList = [];
|
|
|
-// foreach ($users as $key => $value) {
|
|
|
-// $userInfo = (new UserModel)->where('uid', $value['uid'])->find();
|
|
|
-// $auth = (new InfoAudit)->where('uid', $value['uid'])->find();
|
|
|
-// $user_work_type_title = (new UserWorkType)->where('id', $auth['user_work_type_id'])->find();
|
|
|
-// $rankList[] = [
|
|
|
-// 'rank' => $key + 1,
|
|
|
-// 'uid' => $value['uid'],
|
|
|
-// 'nickname' => $userInfo['nickname'],
|
|
|
-// 'avatar' => $userInfo['avatar'],
|
|
|
-// 'invite_count' => $value['invite_count'],
|
|
|
-// 'is_type_audit' => $auth && $auth['status'] == 1 ? 1 : 0,
|
|
|
-// 'ancestral_place' => $auth ? $auth['ancestral_place'] : '',
|
|
|
-// 'auth_info' => $auth ? $auth->toArray() : [],
|
|
|
-// 'user_work_type_id' => $user_work_type_title['title'],
|
|
|
-// ];
|
|
|
-// }
|
|
|
-//
|
|
|
-// $inviteCount = array_column($rankList, 'invite_count');
|
|
|
-// $uid = array_column($rankList, 'uid');
|
|
|
-// array_multisort($inviteCount, SORT_DESC, $uid, SORT_ASC, $rankList);
|
|
|
-//
|
|
|
-// $data['list'] = $rankList;
|
|
|
-//
|
|
|
-// return app('json')->success($data);
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 设置用户信息
|
|
|
* @param Request $request
|