model = model('AdminConfig'); } /** * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个方法 * 因此在当前控制器中可不用编写增删改查的代码,如果需要自己控制这部分逻辑 * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 */ /** * 查看 */ public function index() { $hasIds = $this->request->request('not_in_ids'); //设置过滤方法 $this->request->filter(['strip_tags']); if ($this->request->isAjax()) { //如果发送的来源是Selectpage,则转发到Selectpage if ($this->request->request('pkey_name')) { return $this->selectpage(); } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $filter = $this->request->get("filter", ''); $filter = json_decode($filter, true); $where = []; $wherekey = ''; if ($filter) { foreach ($filter as $k => $v) { switch ($k) { case 'nickname': $where[$k] = $v; break; case 'username': $where[$k] = $v; break; case 'admin_id': $where[$k] = $v; break; case 'sub_nickname': $wherekey = $v; break; default: break; } } } //过滤ID $not_in_ids = $this->request->request('not_in_ids'); if(!empty($not_in_ids)){ $whereid['ac.admin_id'] = ['not in',$not_in_ids]; }else{ $whereid = []; } //搜索公众号昵称 if(!empty($wherekey)){ $wheresub['JSON_EXTRACT(json, "$.authorizer_info.nick_name")'] = ["like","%{$wherekey}%"]; }else{ $wheresub = []; } //公众号黑名单 $wheread = []; if( !$this->auth->checkGroupId(AdminConstants::ADMIN_GROUP_ID_VIP) && !$this->auth->checkGroupId(AdminConstants::ADMIN_GROUP_ID_VIP_OPERATOR) ){ $admin_black_ids = model('SendAdminBlack')->column('admin_id'); if(!empty($admin_black_ids)){ if(count($admin_black_ids) == 1){ $wheread['ac.admin_id'] = ['eq',$admin_black_ids[0]]; }else{ $wheread['ac.admin_id'] = ['not in',implode(',',$admin_black_ids)]; } } } //vip和vip管理用户组 if( $this->auth->checkGroupId(AdminConstants::ADMIN_GROUP_ID_VIP) || $this->auth->checkGroupId(AdminConstants::ADMIN_GROUP_ID_VIP_OPERATOR) ){ $wheretmp['flag'] = ['eq',1]; $wheretmp['admin_id_master'] = ['eq',$this->auth->id]; $vab_ids = model('vip_admin_bind')->where($wheretmp)->column('admin_id_slave'); if(count($vab_ids) == 1){ $wheregroup['ac.admin_id'] = ['eq',$vab_ids[0]]; }else{ $wheregroup['ac.admin_id'] = ['in',implode(',',$vab_ids)]; } }else{ $wheregroup =[]; } $total = $this->model->alias('ac') ->join('admin a','ac.admin_id= a.id','left') ->where($where) ->where($wheresub) ->where($wheread) ->where($wheregroup) ->where('json','neq','') ->where($whereid) ->count(); $list = $this->model->alias('ac') ->join('admin a','ac.admin_id= a.id','left') ->where($where) ->where($wheresub) ->where($wheread) ->where($wheregroup) ->where('json','neq','') ->where($whereid) ->field(['a.username,a.nickname,ac.admin_id']) ->field(['REPLACE (JSON_EXTRACT(JSON_EXTRACT( ac.json, "$.authorizer_info"),"$.nick_name"), "\"", "")' => 'sub_nickname']) ->order($sort, $order) ->limit($offset, $limit) ->select(); $result = array("total" => $total, "rows" => $list); return json($result); } $this->assignconfig('not_in_ids', $hasIds); return $this->view->fetch(); } /** * 查看 */ public function test_user() { $hasIds = $this->request->request('not_in_ids'); //设置过滤方法 $this->request->filter(['strip_tags']); if ($this->request->isAjax()) { //如果发送的来源是Selectpage,则转发到Selectpage if ($this->request->request('pkey_name')) { return $this->selectpage(); } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $filter = $this->request->get("filter", ''); $filter = json_decode($filter, true); $where = []; $wherekey = ''; if ($filter) { foreach ($filter as $k => $v) { switch ($k) { case 'nickname': $where[$k] = $v; break; case 'username': $where[$k] = $v; break; case 'admin_id': $where[$k] = $v; break; case 'sub_nickname': $wherekey = $v; break; default: break; } } } //过滤ID $not_in_ids = $this->request->request('not_in_ids'); if(!empty($not_in_ids)){ $whereid['id'] = ['not in',$not_in_ids]; }else{ $whereid = []; } //搜索公众号昵称 if(!empty($wherekey)){ $wheresub['JSON_EXTRACT(json, "$.authorizer_info.nick_name")'] = ["like","%{$wherekey}%"]; }else{ $wheresub = []; } //公众号黑名单 $admin_black_ids = model('SendAdminBlack')->column('admin_id'); if(!empty($admin_black_ids)){ $wheread['admin_id'] = ['not in',implode(',',$admin_black_ids)]; }else{ $wheread = []; } //vip和vip管理用户组 if( $this->auth->checkGroupId(AdminConstants::ADMIN_GROUP_ID_VIP) || $this->auth->checkGroupId(AdminConstants::ADMIN_GROUP_ID_VIP_OPERATOR) ){ $admin_binds = model('VipAdminBind')->where('admin_id_master','eq',$this->auth->id)->column('admin_id_slave'); if(empty($admin_binds)){ $wheregroup =[]; }else{ if(count($admin_binds)==1){ $wheregroup['admin_id'] = ['eq',$admin_binds[0]]; }else{ $wheregroup['admin_id'] = ['in',implode(',',$admin_binds)]; } } }else{ $wheregroup =[]; } $total = $this->model ->join('admin a','admin_id= a.id','left') ->where($where) ->where($wheresub) ->where($wheread) ->where($wheregroup) ->where('json','neq','') ->where($whereid) ->count(); $list = $this->model ->join('admin a','admin_id= a.id','left') ->where($where) ->where($wheresub) ->where($wheread) ->where($wheregroup) ->where('json','neq','') ->where($whereid) ->field(['a.username,a.nickname,admin_id']) ->field(['REPLACE (JSON_EXTRACT(JSON_EXTRACT( admin_config.json, "$.authorizer_info"),"$.nick_name"), "\"", "")' => 'sub_nickname']) ->order($sort, $order) ->limit($offset, $limit) ->select(); $result = array("total" => $total, "rows" => $list); return json($result); } $this->assignconfig('not_in_ids', $hasIds); return $this->view->fetch(); } /** * 查看公众号 */ public function subscriptions_list() { $in_ids = $this->request->request('in_ids'); //设置过滤方法 $this->request->filter(['strip_tags']); if ($this->request->isAjax()) { //如果发送的来源是Selectpage,则转发到Selectpage if ($this->request->request('pkey_name')) { return $this->selectpage(); } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $filter = $this->request->get("filter", ''); $filter = json_decode($filter, true); $where = []; $wherekey = ''; if ($filter) { foreach ($filter as $k => $v) { switch ($k) { case 'nickname': $where[$k] = $v; break; case 'username': $where[$k] = $v; break; case 'admin_id': $where[$k] = $v; break; case 'sub_nickname': $wherekey = $v; break; default: break; } } } $ids = $this->request->request('in_ids'); if(!empty($ids)){ if(count(explode(',',$ids)) == 1){ $whereid['admin_id'] = ['eq',$ids]; }else{ $whereid['admin_id'] = ['in',$ids]; } }else{ $whereid = []; } //搜索公众号昵称 if(!empty($wherekey)){ $wheresub['JSON_EXTRACT(json, "$.authorizer_info.nick_name")'] = ["like","%{$wherekey}%"]; }else{ $wheresub = []; } $total = $this->model ->join('admin a','admin_id= a.id','left') ->where($where) ->where($whereid) ->where($wheresub) ->where('json','neq','') ->order($sort, $order) ->count(); $list = $this->model ->join('admin a','admin_id= a.id','left') ->where($where) ->where($whereid) ->where($wheresub) ->where('json','neq','') ->field(['a.username,a.nickname,admin_id']) ->field(['REPLACE (JSON_EXTRACT(JSON_EXTRACT( admin_config.json, "$.authorizer_info"),"$.nick_name"), "\"", "")' => 'sub_nickname']) ->order($sort, $order) ->limit($offset, $limit) ->select(); $result = array("total" => $total, "rows" => $list); return json($result); } $this->assignconfig('in_ids',$in_ids); return $this->view->fetch(); } }