Subscriptionlist.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <?php
  2. namespace app\admin\controller\send\message;
  3. use app\common\constants\Custom;
  4. use app\common\constants\Message;
  5. use app\common\constants\OfficialAccount;
  6. use app\common\controller\Backend;
  7. use app\main\constants\AdminConstants;
  8. use think\Controller;
  9. use think\Request;
  10. /**
  11. * 渠道商配置管理
  12. *
  13. * @icon fa fa-circle-o
  14. */
  15. class Subscriptionlist extends Backend
  16. {
  17. /**
  18. * AdminConfig模型对象
  19. */
  20. protected $model = null;
  21. public function _initialize()
  22. {
  23. parent::_initialize();
  24. $this->model = model('AdminConfig');
  25. }
  26. /**
  27. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个方法
  28. * 因此在当前控制器中可不用编写增删改查的代码,如果需要自己控制这部分逻辑
  29. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  30. */
  31. /**
  32. * 查看
  33. */
  34. public function index()
  35. {
  36. $hasIds = $this->request->request('not_in_ids');
  37. //设置过滤方法
  38. $this->request->filter(['strip_tags']);
  39. if ($this->request->isAjax())
  40. {
  41. //如果发送的来源是Selectpage,则转发到Selectpage
  42. if ($this->request->request('pkey_name'))
  43. {
  44. return $this->selectpage();
  45. }
  46. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  47. $filter = $this->request->get("filter", '');
  48. $filter = json_decode($filter, true);
  49. $where = [];
  50. $wherekey = '';
  51. if ($filter) {
  52. foreach ($filter as $k => $v) {
  53. switch ($k) {
  54. case 'nickname':
  55. $where[$k] = $v;
  56. break;
  57. case 'username':
  58. $where[$k] = $v;
  59. break;
  60. case 'admin_id':
  61. $where[$k] = $v;
  62. break;
  63. case 'sub_nickname':
  64. $wherekey = $v;
  65. break;
  66. default:
  67. break;
  68. }
  69. }
  70. }
  71. //过滤ID
  72. $not_in_ids = $this->request->request('not_in_ids');
  73. if(!empty($not_in_ids)){
  74. $whereid['ac.admin_id'] = ['not in',$not_in_ids];
  75. }else{
  76. $whereid = [];
  77. }
  78. //搜索公众号昵称
  79. if(!empty($wherekey)){
  80. $wheresub['JSON_EXTRACT(json, "$.authorizer_info.nick_name")'] = ["like","%{$wherekey}%"];
  81. }else{
  82. $wheresub = [];
  83. }
  84. //公众号黑名单
  85. $wheread = [];
  86. if(
  87. !$this->auth->checkGroupId(AdminConstants::ADMIN_GROUP_ID_VIP) &&
  88. !$this->auth->checkGroupId(AdminConstants::ADMIN_GROUP_ID_VIP_OPERATOR)
  89. ){
  90. $admin_black_ids = model('SendAdminBlack')->column('admin_id');
  91. if(!empty($admin_black_ids)){
  92. if(count($admin_black_ids) == 1){
  93. $wheread['ac.admin_id'] = ['eq',$admin_black_ids[0]];
  94. }else{
  95. $wheread['ac.admin_id'] = ['not in',implode(',',$admin_black_ids)];
  96. }
  97. }
  98. }
  99. //vip和vip管理用户组
  100. if(
  101. $this->auth->checkGroupId(AdminConstants::ADMIN_GROUP_ID_VIP) ||
  102. $this->auth->checkGroupId(AdminConstants::ADMIN_GROUP_ID_VIP_OPERATOR)
  103. ){
  104. $wheretmp['flag'] = ['eq',1];
  105. $wheretmp['admin_id_master'] = ['eq',$this->auth->id];
  106. $vab_ids = model('vip_admin_bind')->where($wheretmp)->column('admin_id_slave');
  107. if(count($vab_ids) == 1){
  108. $wheregroup['ac.admin_id'] = ['eq',$vab_ids[0]];
  109. }else{
  110. $wheregroup['ac.admin_id'] = ['in',implode(',',$vab_ids)];
  111. }
  112. }else{
  113. $wheregroup =[];
  114. }
  115. $total = $this->model->alias('ac')
  116. ->join('admin a','ac.admin_id= a.id','left')
  117. ->where($where)
  118. ->where($wheresub)
  119. ->where($wheread)
  120. ->where($wheregroup)
  121. ->where('json','neq','')
  122. ->where($whereid)
  123. ->count();
  124. $list = $this->model->alias('ac')
  125. ->join('admin a','ac.admin_id= a.id','left')
  126. ->where($where)
  127. ->where($wheresub)
  128. ->where($wheread)
  129. ->where($wheregroup)
  130. ->where('json','neq','')
  131. ->where($whereid)
  132. ->field(['a.username,a.nickname,ac.admin_id'])
  133. ->field(['REPLACE (JSON_EXTRACT(JSON_EXTRACT( ac.json, "$.authorizer_info"),"$.nick_name"), "\"", "")' => 'sub_nickname'])
  134. ->order($sort, $order)
  135. ->limit($offset, $limit)
  136. ->select();
  137. $result = array("total" => $total, "rows" => $list);
  138. return json($result);
  139. }
  140. $this->assignconfig('not_in_ids', $hasIds);
  141. return $this->view->fetch();
  142. }
  143. /**
  144. * 查看
  145. */
  146. public function test_user()
  147. {
  148. $hasIds = $this->request->request('not_in_ids');
  149. //设置过滤方法
  150. $this->request->filter(['strip_tags']);
  151. if ($this->request->isAjax())
  152. {
  153. //如果发送的来源是Selectpage,则转发到Selectpage
  154. if ($this->request->request('pkey_name'))
  155. {
  156. return $this->selectpage();
  157. }
  158. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  159. $filter = $this->request->get("filter", '');
  160. $filter = json_decode($filter, true);
  161. $where = [];
  162. $wherekey = '';
  163. if ($filter) {
  164. foreach ($filter as $k => $v) {
  165. switch ($k) {
  166. case 'nickname':
  167. $where[$k] = $v;
  168. break;
  169. case 'username':
  170. $where[$k] = $v;
  171. break;
  172. case 'admin_id':
  173. $where[$k] = $v;
  174. break;
  175. case 'sub_nickname':
  176. $wherekey = $v;
  177. break;
  178. default:
  179. break;
  180. }
  181. }
  182. }
  183. //过滤ID
  184. $not_in_ids = $this->request->request('not_in_ids');
  185. if(!empty($not_in_ids)){
  186. $whereid['id'] = ['not in',$not_in_ids];
  187. }else{
  188. $whereid = [];
  189. }
  190. //搜索公众号昵称
  191. if(!empty($wherekey)){
  192. $wheresub['JSON_EXTRACT(json, "$.authorizer_info.nick_name")'] = ["like","%{$wherekey}%"];
  193. }else{
  194. $wheresub = [];
  195. }
  196. //公众号黑名单
  197. $admin_black_ids = model('SendAdminBlack')->column('admin_id');
  198. if(!empty($admin_black_ids)){
  199. $wheread['admin_id'] = ['not in',implode(',',$admin_black_ids)];
  200. }else{
  201. $wheread = [];
  202. }
  203. //vip和vip管理用户组
  204. if(
  205. $this->auth->checkGroupId(AdminConstants::ADMIN_GROUP_ID_VIP) ||
  206. $this->auth->checkGroupId(AdminConstants::ADMIN_GROUP_ID_VIP_OPERATOR)
  207. ){
  208. $admin_binds = model('VipAdminBind')->where('admin_id_master','eq',$this->auth->id)->column('admin_id_slave');
  209. if(empty($admin_binds)){
  210. $wheregroup =[];
  211. }else{
  212. if(count($admin_binds)==1){
  213. $wheregroup['admin_id'] = ['eq',$admin_binds[0]];
  214. }else{
  215. $wheregroup['admin_id'] = ['in',implode(',',$admin_binds)];
  216. }
  217. }
  218. }else{
  219. $wheregroup =[];
  220. }
  221. $total = $this->model
  222. ->join('admin a','admin_id= a.id','left')
  223. ->where($where)
  224. ->where($wheresub)
  225. ->where($wheread)
  226. ->where($wheregroup)
  227. ->where('json','neq','')
  228. ->where($whereid)
  229. ->count();
  230. $list = $this->model
  231. ->join('admin a','admin_id= a.id','left')
  232. ->where($where)
  233. ->where($wheresub)
  234. ->where($wheread)
  235. ->where($wheregroup)
  236. ->where('json','neq','')
  237. ->where($whereid)
  238. ->field(['a.username,a.nickname,admin_id'])
  239. ->field(['REPLACE (JSON_EXTRACT(JSON_EXTRACT( admin_config.json, "$.authorizer_info"),"$.nick_name"), "\"", "")' => 'sub_nickname'])
  240. ->order($sort, $order)
  241. ->limit($offset, $limit)
  242. ->select();
  243. $result = array("total" => $total, "rows" => $list);
  244. return json($result);
  245. }
  246. $this->assignconfig('not_in_ids', $hasIds);
  247. return $this->view->fetch();
  248. }
  249. /**
  250. * 查看公众号
  251. */
  252. public function subscriptions_list()
  253. {
  254. $in_ids = $this->request->request('in_ids');
  255. //设置过滤方法
  256. $this->request->filter(['strip_tags']);
  257. if ($this->request->isAjax())
  258. {
  259. //如果发送的来源是Selectpage,则转发到Selectpage
  260. if ($this->request->request('pkey_name'))
  261. {
  262. return $this->selectpage();
  263. }
  264. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  265. $filter = $this->request->get("filter", '');
  266. $filter = json_decode($filter, true);
  267. $where = [];
  268. $wherekey = '';
  269. if ($filter) {
  270. foreach ($filter as $k => $v) {
  271. switch ($k) {
  272. case 'nickname':
  273. $where[$k] = $v;
  274. break;
  275. case 'username':
  276. $where[$k] = $v;
  277. break;
  278. case 'admin_id':
  279. $where[$k] = $v;
  280. break;
  281. case 'sub_nickname':
  282. $wherekey = $v;
  283. break;
  284. default:
  285. break;
  286. }
  287. }
  288. }
  289. $ids = $this->request->request('in_ids');
  290. if(!empty($ids)){
  291. if(count(explode(',',$ids)) == 1){
  292. $whereid['admin_id'] = ['eq',$ids];
  293. }else{
  294. $whereid['admin_id'] = ['in',$ids];
  295. }
  296. }else{
  297. $whereid = [];
  298. }
  299. //搜索公众号昵称
  300. if(!empty($wherekey)){
  301. $wheresub['JSON_EXTRACT(json, "$.authorizer_info.nick_name")'] = ["like","%{$wherekey}%"];
  302. }else{
  303. $wheresub = [];
  304. }
  305. $total = $this->model
  306. ->join('admin a','admin_id= a.id','left')
  307. ->where($where)
  308. ->where($whereid)
  309. ->where($wheresub)
  310. ->where('json','neq','')
  311. ->order($sort, $order)
  312. ->count();
  313. $list = $this->model
  314. ->join('admin a','admin_id= a.id','left')
  315. ->where($where)
  316. ->where($whereid)
  317. ->where($wheresub)
  318. ->where('json','neq','')
  319. ->field(['a.username,a.nickname,admin_id'])
  320. ->field(['REPLACE (JSON_EXTRACT(JSON_EXTRACT( admin_config.json, "$.authorizer_info"),"$.nick_name"), "\"", "")' => 'sub_nickname'])
  321. ->order($sort, $order)
  322. ->limit($offset, $limit)
  323. ->select();
  324. $result = array("total" => $total, "rows" => $list);
  325. return json($result);
  326. }
  327. $this->assignconfig('in_ids',$in_ids);
  328. return $this->view->fetch();
  329. }
  330. }