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(); } }