parent
fd1fe3ebf2
commit
2e22742a3d
|
|
@ -69,13 +69,14 @@ class AgentDao extends BaseDao{
|
|||
$query->field('agent_id,mer_name,mer_avatar');
|
||||
},
|
||||
'parent' => function($query){
|
||||
$query->field('id,uid,agent_type')
|
||||
$query->field('id,uid,agent_type,corporate_name')
|
||||
->with([
|
||||
'user' => function($query){
|
||||
$query->field('uid,nickname,avatar')
|
||||
->bind(['nickname','avatar']);
|
||||
}
|
||||
]);
|
||||
])
|
||||
->append(['agent_type_text']);
|
||||
},
|
||||
])
|
||||
->order('create_time DESC,id DESC')
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class AgentRepository extends BaseRepository{
|
|||
return $this->dao->searchList(['uid'=>$uid])
|
||||
->whereIn('agent_type', $agentType)
|
||||
->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'])
|
||||
->field(['id','uid','agent_type','province_id','city_id','area_id','street_id','address','mer_id','contact_name','pid','corporate_name'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
|
@ -175,7 +175,7 @@ class AgentRepository extends BaseRepository{
|
|||
"lat",
|
||||
"lng",
|
||||
"mer_id",
|
||||
'province_corporate_name'
|
||||
'corporate_name'
|
||||
]);
|
||||
$updateInfo = array_intersect_key($data, $keys);
|
||||
Agent::update($updateInfo,['id'=>$agentId]);
|
||||
|
|
@ -216,7 +216,7 @@ class AgentRepository extends BaseRepository{
|
|||
"lat",
|
||||
"lng",
|
||||
"mer_id",
|
||||
'province_corporate_name'
|
||||
'corporate_name'
|
||||
]);
|
||||
$eightUpdateIds = [];
|
||||
// 循环:区分对应的操作
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class Agent extends BaseController{
|
|||
'lng',
|
||||
['mer_id', 0],
|
||||
['mer_id_list', []],
|
||||
['province_corporate_name','']
|
||||
['corporate_name','']
|
||||
]);
|
||||
$agentId = (int)$this->request->param('id');
|
||||
$childrenList = $this->request->param('children_list');
|
||||
|
|
@ -87,7 +87,7 @@ class Agent extends BaseController{
|
|||
// if((float)$childrenItem['agent_stock'] <= 0) throw new ValidateException('发起人的股份必须大于0!');
|
||||
break;
|
||||
case 2:
|
||||
if(empty($childrenItem['province_corporate_name'])) throw new ValidateException('请输入省公司名称!');
|
||||
if(empty($childrenItem['corporate_name'])) throw new ValidateException('请输入省公司名称!');
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
|
|
@ -213,7 +213,7 @@ class Agent extends BaseController{
|
|||
// 判断:根据当前角色判断 数据
|
||||
switch((int)$data['agent_type']){
|
||||
case 2:
|
||||
if(empty($data['province_corporate_name'])) throw new ValidateException('请输入省公司名称!');
|
||||
if(empty($data['corporate_name'])) throw new ValidateException('请输入省公司名称!');
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
|
|
|
|||
|
|
@ -310,10 +310,30 @@ class Agent extends BaseController{
|
|||
}
|
||||
}
|
||||
$provinceList = array_values($newProvince);
|
||||
|
||||
|
||||
|
||||
|
||||
// 区县运营商:仅显示公司信息,如果存在多个则只显示一个,如果是内勤或者外勤则查询省公司信息
|
||||
$newCounty = [];
|
||||
foreach($countyList as $k => $v){
|
||||
// 判断:是否为餐厅,配送商 是则跳出处理
|
||||
if(in_array($v['agent_type'],[7,8])){
|
||||
$newCounty[$v['id']] = $v;
|
||||
continue;
|
||||
}
|
||||
// 判断:是否为区县运营商信息 是则直接使用,否则查询区县运营商信息
|
||||
if($v['agent_type'] == 5) $currentUseInfo = $v;
|
||||
else $currentUseInfo = $this->repository->getSearchModel(['id'=>$v['pid'],'agent_type'=>5])->findOrEmpty()->toArray();
|
||||
// 判断:当前省公司发起人信息是否已经存在,不存在添加
|
||||
if(!in_array($currentUseInfo['id'],array_column($newCounty,'id'))){
|
||||
$currentUseInfo['agent_type_list'][$v['agent_type']] = $v['agent_type_text'];
|
||||
$newCounty[$currentUseInfo['id']] = $currentUseInfo;
|
||||
}else{
|
||||
$newCounty[$currentUseInfo['id']]['agent_type_list'][$v['agent_type']] = $v['agent_type_text'];
|
||||
}
|
||||
}
|
||||
$countyList = array_values($newCounty);
|
||||
// 排序
|
||||
array_multisort(array_column($headquartersList,'id'), SORT_DESC, $headquartersList);
|
||||
array_multisort(array_column($provinceList,'id'), SORT_DESC, $provinceList);
|
||||
array_multisort(array_column($countyList,'id'), SORT_DESC, $countyList);
|
||||
|
||||
return app('json')->success([
|
||||
'headquarters_list' => $headquartersList,
|
||||
|
|
@ -321,6 +341,48 @@ class Agent extends BaseController{
|
|||
'county_list' => $countyList,
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* Common: 获取指定角色及相关角色的信息
|
||||
* Author: wu-hui
|
||||
* Time: 2024/02/26 9:53
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getRoleAndCorrelationRole(){
|
||||
// 参数获取
|
||||
$agentId = $this->request->param('agent_id');
|
||||
$uid = $this->request->uid();
|
||||
// 获取当前代理信息
|
||||
$agentInfo = $this->repository->getSingleInfo($agentId);
|
||||
if(!$agentInfo) throw new ValidateException('不存在该代理信息!');
|
||||
// 根据当前代理角色 获取全部相关角色信息(按照总部、省公司、区县划分)
|
||||
// 类型:1=总部发起人,2=省公司发起人,3=省合伙人(外勤),4=省合伙人(内勤),5=区县运营商,6=区县合伙人,7=餐厅,8=配送商,9=总部外勤,10=总部内勤
|
||||
if(in_array($agentInfo['agent_type'],[1,2,5])) {
|
||||
$pid = $agentInfo['id'];
|
||||
$corporateName = $agentInfo['corporate_name'];
|
||||
}
|
||||
else {
|
||||
$pid = $agentInfo['pid'];
|
||||
$corporateName = $this->repository->getSearchModel(['id'=>$pid])->value('corporate_name');
|
||||
}
|
||||
// 获取下级信息
|
||||
$children = $this->repository
|
||||
->getSearchModel([])
|
||||
->where('pid|id', $pid)
|
||||
->where('uid', $uid)
|
||||
->select()
|
||||
->toArray();
|
||||
// 判断:是否存在和传递ID一致的角色信息 不存在默认第一个
|
||||
if(!in_array($agentInfo['id'],array_column($children,'id'))) $agentInfo = $children[0];
|
||||
|
||||
return app('json')->success([
|
||||
'agent_info' => $agentInfo,
|
||||
'children' => $children,
|
||||
'corporate_name' => in_array($agentInfo['agent_type'],[1,9,10]) ? '万马奔腾总部' : $corporateName
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -395,8 +395,8 @@ Route::group('api/', function () {
|
|||
Route::post('apply_record', 'applyRecord');// 申请记录
|
||||
Route::get('apply_info', 'applyInfo');// 申请信息
|
||||
Route::get('commission_list', 'commissionList');// 佣金明细
|
||||
Route::get('identity_list', 'getIdentityList');// 某个身份是否有效
|
||||
|
||||
Route::get('identity_list', 'getIdentityList');// 获取用户身份信息列表
|
||||
Route::get('role_and_correlation_role', 'getRoleAndCorrelationRole');// 获取指定角色及相关角色的信息
|
||||
|
||||
|
||||
})->prefix('api.Agent/');
|
||||
|
|
|
|||
Loading…
Reference in New Issue