123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366 |
- <?php
- namespace app\admin\controller\send\message;
- use app\common\constants\Custom;
- use app\common\constants\Message;
- use app\common\constants\OfficialAccount;
- use app\common\controller\Backend;
- use app\main\constants\AdminConstants;
- use think\Controller;
- use think\Request;
- /**
- * 渠道商配置管理
- *
- * @icon fa fa-circle-o
- */
- class Subscriptionlist extends Backend
- {
-
- /**
- * AdminConfig模型对象
- */
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->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();
- }
- }
|