优化:身份信息列表 - 同一个省公司存在多个身份时仅输出一个省公司信息,不在全部显示

This commit is contained in:
wuhui_zzw 2024-02-22 18:11:51 +08:00
parent 81c2e9dea7
commit fd1fe3ebf2
2 changed files with 22 additions and 2 deletions

View File

@ -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

View File

@ -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,