diff --git a/app/common/repositories/marketing/AgentRepository.php b/app/common/repositories/marketing/AgentRepository.php index 59ce1e6..dd955e3 100644 --- a/app/common/repositories/marketing/AgentRepository.php +++ b/app/common/repositories/marketing/AgentRepository.php @@ -126,13 +126,14 @@ class AgentRepository extends BaseRepository{ // 获取对应的角色身份列表 return $this->dao->searchList(['uid'=>$uid]) ->whereIn('agent_type', $agentType) - ->whereNotIn('agent_type', [4,7,8,10])// 忽略无管理菜单的角色 - ->field(['id','uid','agent_type','province_id','city_id','area_id','street_id','address','mer_id','contact_name']) + ->whereNotIn('agent_type', [7,8])// 忽略无管理菜单的角色 + ->field(['id','uid','agent_type','province_id','city_id','area_id','street_id','address','mer_id','contact_name','pid','province_corporate_name']) ->select() ->toArray(); } + /** * Common: 代理添加/编辑 * Author: wu-hui diff --git a/app/controller/api/Agent.php b/app/controller/api/Agent.php index 6cbd779..b9416a7 100644 --- a/app/controller/api/Agent.php +++ b/app/controller/api/Agent.php @@ -295,6 +295,25 @@ class Agent extends BaseController{ $headquartersList = (array)$this->repository->getIdentityList($uid); $provinceList = (array)$this->repository->getIdentityList($uid,'province'); $countyList = (array)$this->repository->getIdentityList($uid,'county'); + // 省公司信息:仅显示省公司信息,如果存在多个则只显示一个,如果是内勤或者外勤则查询省公司信息 + $newProvince = []; + foreach($provinceList as $k => $v){ + // 判断:是否为省公司发起人信息 是则直接使用,否则查询省公司发起人信息 + if($v['agent_type'] == 2) $currentUseInfo = $v; + else $currentUseInfo = $this->repository->getSearchModel(['id'=>$v['pid'],'agent_type'=>2])->findOrEmpty()->toArray(); + // 判断:当前省公司发起人信息是否已经存在,不存在添加 + if(!in_array($currentUseInfo['id'],array_column($newProvince,'id'))){ + $currentUseInfo['agent_type_list'][$v['agent_type']] = $v['agent_type_text']; + $newProvince[$currentUseInfo['id']] = $currentUseInfo; + }else{ + $newProvince[$currentUseInfo['id']]['agent_type_list'][$v['agent_type']] = $v['agent_type_text']; + } + } + $provinceList = array_values($newProvince); + + + + return app('json')->success([ 'headquarters_list' => $headquartersList,