123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <?php
- namespace app\admin\controller;
- use app\common\controller\Backend;
- use app\common\library\Redis;
- use app\common\model\Admin;
- use app\main\constants\AdminConstants;
- use app\main\constants\CacheConstants;
- use app\main\service\FufenService;
- /**
- * 管理员管理
- *
- * @icon fa fa-circle-o
- */
- class Channelfufen extends Backend
- {
- /**
- * @var Admin
- */
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = model('Admin');
- }
- public function index($ids = '')
- {
- $this->assignconfig('data', ['fufenid' => $ids]);
- if ($this->request->isAjax()) {
- list($where, $sort, $order, $offset, $limit) = $this->buildparams('', true);
- $channelIdList = FufenService::instance()->getFufenGroupModel()->column('channel_ids');
- $whereChannel = [];
- if ($channelIdList) {
- $channelIds = [];
- foreach ($channelIdList as $ids) {
- $channelIds = array_merge($channelIds, explode(',', $ids));
- }
- $whereChannel['admin.id'] = ['not in', array_unique($channelIds)];
- }
- $total = $this->model
- ->join('auth_group_access aga', 'aga.uid=admin.id')
- ->join('admin_extend ae', 'ae.admin_id=admin.id')
- ->where('aga.group_id', AdminConstants::ADMIN_GROUP_ID_CHANNEL)
- ->where($whereChannel)
- ->where($where)
- ->count();
- $list = $this->model
- ->join('auth_group_access aga', 'aga.uid=admin.id')
- ->join('admin_extend ae', 'ae.admin_id=admin.id')
- ->join('admin_config ac', 'ac.admin_id=admin.id')
- ->join('admin a', 'a.id=ae.create_by')
- ->where('aga.group_id', AdminConstants::ADMIN_GROUP_ID_CHANNEL)
- ->where($whereChannel)
- ->where($where)
- ->field('admin.id,admin.username,admin.nickname,ac.appid,a.nickname as c_nickname')
- ->limit($offset, $limit)
- ->order($sort, $order)
- ->select();
- return json(["total" => $total, "rows" => $list]);
- }
- return $this->view->fetch();
- }
- /**
- * 批量关联
- */
- public function batch_relation()
- {
- $channelids = $this->request->param('channel_ids');
- $fufenid = $this->request->param('fufen_id');
- $action = $this->request->param('action');
- $origin = FufenService::instance()->getFufenGroupModel()->where(['id' => $fufenid])->value('channel_ids');
- $origin_array = explode(',', $origin);
- $params = explode(',', $channelids);
- $all_ids = array_unique(array_merge($origin_array, $params));
- if ($action == 'add') {
- $update = $all_ids;
- } else {
- $update = array_unique(array_diff($origin_array, $params));
- }
- $update = array_filter($update, function($value){
- return $value;
- });
- foreach ($all_ids as $channel_id) {
- Redis::instance()->del(CacheConstants::getChannelWxpayIds($channel_id));
- }
- FufenService::instance()->getFufenGroupModel()->update(['channel_ids' => implode(',', $update)], ['id' => $fufenid]);
- $this->success();
- }
- public function show($ids = '')
- {
- $this->assignconfig('data', ['fufenid' => $ids]);
- if ($this->request->isAjax()) {
- $channelIds = FufenService::instance()->getFufenGroupModel()->where('id', $ids)->value('channel_ids');
- if ($channelIds) {
- list($where, $sort, $order, $offset, $limit) = $this->buildparams('', true);
- $whereChannel = [
- 'admin.id' => ['in', $channelIds],
- ];
- $total = $this->model
- ->join('auth_group_access aga', 'aga.uid=admin.id')
- ->join('admin_extend ae', 'ae.admin_id=admin.id')
- ->where('aga.group_id', AdminConstants::ADMIN_GROUP_ID_CHANNEL)
- ->where($whereChannel)
- ->where($where)
- ->count();
- $list = $this->model
- ->join('auth_group_access aga', 'aga.uid=admin.id')
- ->join('admin_extend ae', 'ae.admin_id=admin.id')
- ->join('admin_config ac', 'ac.admin_id=admin.id')
- ->join('admin a', 'a.id=ae.create_by')
- ->where('aga.group_id', AdminConstants::ADMIN_GROUP_ID_CHANNEL)
- ->where($whereChannel)
- ->where($where)
- ->field('admin.id,admin.username,admin.nickname,ac.appid,a.nickname as c_nickname')
- ->limit($offset, $limit)
- ->order($sort, $order)
- ->select();
- return json(["total" => $total, "rows" => $list]);
- } else {
- return json(["total" => 0, "rows" => []]);
- }
- }
- return $this->view->fetch();
- }
- }
|