diff --git a/app/controller/AdminTeam.php b/app/controller/AdminTeam.php index 460e75f..012e089 100644 --- a/app/controller/AdminTeam.php +++ b/app/controller/AdminTeam.php @@ -4,9 +4,10 @@ declare (strict_types = 1); namespace app\controller; use app\BaseController; +use app\model\AgentUser; +use app\model\User as UserModel; use think\exception\ValidateException; use think\facade\Request; -use app\model\User as UserModel; use app\validate\User as UserValidate; class AdminTeam extends BaseController @@ -46,7 +47,7 @@ class AdminTeam extends BaseController } # 查询用户列表 - $field = 'id,aid,phone,avatar,balance,withdrawal_balance'; + $field = 'id,aid,phone,avatar,balance,withdrawal_balance,status'; $userRes = $UserModel->field($field)->where($where)->order('id desc')->paginate($limit); $list = $userRes->items(); @@ -56,6 +57,7 @@ class AdminTeam extends BaseController $item['phone'] = format_phone_number($item['phone']); $item['avatar'] = get_image_url($item['avatar']); + $item['status'] = $item['status'] == 1 ? '正常' : '停用'; } return $this->renderSuccess('数据返回成功', ['list' => $list, 'total' => $total]); @@ -82,4 +84,54 @@ class AdminTeam extends BaseController return $this->renderError($validateException->getMessage()); } } + + /** + * 代理列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function agentList() + { + $request = Request::param(); + + $limit = $request['limit'] ?? 10; + + $where = []; + + $UserModel = new AgentUser(); + + # 用户id / 手机号码查询 + if (isset($request['title']) && !empty($request['title'])) { + $queryUser = $UserModel + ->whereOr(['phone' => $request['title'], 'id' => $request['title']]) + ->field('id') + ->select() + ->toArray(); + if ($queryUser) { + foreach ($queryUser as $queryUserRow) { + $where['id'][] = $queryUserRow['id']; + } + } else { + $where['id'] = 0; + } + } + + # 查询用户列表 + $field = 'id,phone,avatar,balance,withdrawal_balance'; + $userRes = $UserModel->field($field)->where($where)->order('id desc')->paginate($limit); + + $list = $userRes->items(); + $total = $userRes->total(); + + foreach ($list as &$item) { + + $item['phone'] = format_phone_number($item['phone']); + $item['avatar'] = get_image_url($item['avatar']); + $item['status'] = $item['status'] == 1 ? '正常' : '停用'; + } + + return $this->renderSuccess('数据返回成功', ['list' => $list, 'total' => $total]); + } } diff --git a/app/controller/AgentTeam.php b/app/controller/AgentTeam.php index e919b6c..18e70ba 100644 --- a/app/controller/AgentTeam.php +++ b/app/controller/AgentTeam.php @@ -32,9 +32,9 @@ class AgentTeam extends BaseController $limit = $request['limit'] ?? 10; - # 代理id查询 + # 代理id查询 启用用户 $agentData = Session::get('login_agent_user_data'); - $where = ['aid' => $agentData['id']]; + $where = ['aid' => $agentData['id'], 'status' => 1]; $UserModel = new UserModel(); diff --git a/route/app.php b/route/app.php index 7dc70ca..072dad0 100644 --- a/route/app.php +++ b/route/app.php @@ -58,6 +58,7 @@ Route::group('agentTeam',function(){ Route::group('adminTeam',function() { Route::post('userList','adminTeam/userList')->middleware(CheckAdmin::class)->allowCrossDomain(); Route::post('editUser','adminTeam/editUser')->middleware(CheckAdmin::class)->allowCrossDomain(); + Route::post('agentList','adminTeam/agentList')->middleware(CheckAdmin::class)->allowCrossDomain(); }); # 支付(待开发)