adminExtendModel = model('AdminExtend'); } /** * 获取当前VIP所管辖的渠道商和配号代理商id * @param $vipId * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function getChannelAndAgentId($vipId) { $channelIds = $this->getChannelIds($vipId); $agentIds = $this->getAgentIds($channelIds); $adminIds = array_merge($channelIds, $agentIds); return $adminIds; } /** * 通过vipId获取隶属的渠道商id * @param $vipId * @param $channelId 渠道商id * @param $username 渠道商用户名 * @param $nickname 渠道商昵称 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function getChannelIds($vipId, $channelId = null, $username = null, $nickname = null) { #region 获取所有渠道商id $fetchObj = $this->join(['admin' => 'qds'], 'qds.id = vip_admin_bind.admin_id_slave') ->join('admin_config', 'qds.id = admin_config.admin_id') ->join(['auth_group_access' => 'aga_qds'], 'aga_qds.uid = qds.id and aga_qds.group_id=3') ->where(['vip_admin_bind.admin_id_master' => $vipId]) ->field('vip_admin_bind.admin_id_slave'); if (!empty($channelId)) { if (is_array($channelId)) { $fetchObj->whereIn('qds.id', $channelId); } else { $fetchObj->where('qds.id', $channelId); } } if (!empty($username)) { $username = trim($username); $fetchObj->where(['username' => $username]); } if (!empty($nickname)) { $nickname = trim($nickname); $fetchObj->where(['nickname' => ['like', "%$nickname%"]]); } $channelList = $fetchObj->select(); $channelIds = array_column($channelList, 'admin_id_slave'); #endregion return $channelIds; } /** * 通过渠道商id获取隶属的配号代理商id * @param $channelIds * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function getAgentIds($channelIds) { #region 获取所有配号代理商id $agentIds = []; if (!empty($channelIds)) { $agentList = $this->adminExtendModel->where(['distribute' => 1, 'create_by' => ['in', $channelIds]]) ->field('admin_id')->select(); $agentIds = array_column($agentList, 'admin_id'); } #endregion return $agentIds; } /** * 通过渠道商id获取隶属的所有代理商id * @param $channelIds * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function getAllAgentIds($channelIds) { #region 获取所有代理商id $agentIds = []; if (!empty($channelIds)) { $agentList = $this->adminExtendModel->where(['create_by' => ['in', $channelIds]]) ->field('admin_id')->select(); $agentIds = array_column($agentList, 'admin_id'); } #endregion return $agentIds; } public function getAdminIdsByVip($vipId){ return model("VipAdminBind") ->where("admin_id_master",$vipId) ->where("flag = 1") ->column("admin_id_slave"); } /** * 获取vip账号对应的服务号列表 * @param $iVipId * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function getSerListByAdminId($iVipId) { $admin_list = $this->alias("v") ->join('admin_config a', 'v.admin_id_slave=a.admin_id', 'RIGHT') ->where(['v.admin_id_master' => $iVipId]) ->whereNotNull('a.json') ->field('a.admin_id,a.json $.authorizer_info.nick_name') ->select(); $res = []; foreach ($admin_list as $v){ $res[] = ['sub_id' => $v['admin_id'], 'sub_name' => trim($v["json_extract(a.json , '$.authorizer_info.nick_name')"], '"') ?: '-']; } return $res; } }