From fd1fe3ebf26eb8bc0aa9c62e7a49f6f1f8073242 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Thu, 22 Feb 2024 18:11:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E8=BA=AB=E4=BB=BD?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=88=97=E8=A1=A8=20-=20=E5=90=8C=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E7=9C=81=E5=85=AC=E5=8F=B8=E5=AD=98=E5=9C=A8=E5=A4=9A?= =?UTF-8?q?=E4=B8=AA=E8=BA=AB=E4=BB=BD=E6=97=B6=E4=BB=85=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E7=9C=81=E5=85=AC=E5=8F=B8=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E5=9C=A8=E5=85=A8=E9=83=A8=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../marketing/AgentRepository.php | 5 +++-- app/controller/api/Agent.php | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) 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,