field[$name])) { switch ($name) { case 'channel_id': $this->field[$name] = (int)$this->getChannelId(); break; case 'channel_user_id': $this->field[$name] = (int)$this->getChannelUserId(); break; case 'channel_name': $this->field[$name] = $this->getChannelName(); break; case 'channel_domain': $this->field[$name] = $this->getChannelDomain(); break; case 'company_id': $this->field[$name] = (int)$this->getCompanyId(); break; case 'company_channel_ids': $this->field[$name] = $this->getALLChannelIDByCompanyID(); break; case 'user_channel_ids': $this->field[$name] = $this->getAllChannelIdByChannelUserId(); break; case 'is_inner': $this->field[$name] = $this->isInnerRole(); break; case 'phone': $this->field[$name] = $this->getLogPhone(); break; } } return $this->field[$name]; } function getShenjiStatus() { return redisEnv('SHENJI_SWITCH') ? 1 : 0; } //获取分销渠道ID function getChannelId() { if (empty(session('ydychannel'))) { if (env('APP_ENV') == 'local') return 1; } $distribution_channel = unserialize(session('ydychannel')); if ($distribution_channel) { return $distribution_channel->id; } else { return 0; } } //获取分销渠道名称 function getChannelName() { if (empty(session('ydychannel'))) { if (env('APP_ENV') == 'local') return '测试'; } $distribution_channel = unserialize(session('ydychannel')); return $distribution_channel->distribution_channel_name; } //获取分销渠道域名 function getChannelDomain() { if (empty(session('ydychannel'))) { if (env('APP_ENV') == 'local') return 'site1.aizhuishu.com'; } $distribution_channel = unserialize(session('ydychannel')); return "site{$distribution_channel->id}.leyuee.com"; } //获取登陆用户ID function getChannelUserId() { return session('ydyauth'); } //获取登陆号码 function getLogPhone() { return session('ydylogphone'); } function getCompanyId() { $channel_info = ChannelUser::find($this->channel_user_id); if ($channel_info) { return $channel_info->company_id ? $channel_info->company_id : 0; } return 0; } function getALLChannelIDByCompanyID() { return Channel::select('distribution_channels.id') ->join('channel_users', 'channel_users.id', '=', 'distribution_channels.channel_user_id') ->join('companies', 'companies.id', '=', 'channel_users.company_id') ->where('companies.id', $this->company_id) ->get()->pluck('id') ->all(); } //判断是否为内部站点 function isInnerRole() { $lists = ChannelUsersInner::where('is_enable', 1)->get(); $inner_phones = []; foreach ($lists as $item) { $inner_phones[] = $item->phone . '2'; } return in_array($this->phone, $inner_phones); } public function getAllChannelIdByChannelUserId() { return Channel::where('channel_user_id', $this->channel_user_id)->get()->pluck('id')->all(); } }