|
@@ -343,13 +343,15 @@ class EmployeeService extends Service
|
|
$role2[$value->employee_id][] = $value->id;
|
|
$role2[$value->employee_id][] = $value->id;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ $map = $this->getTopDepartSon();
|
|
|
|
+
|
|
$res = DB::table('employee_depart_permission as a')
|
|
$res = DB::table('employee_depart_permission as a')
|
|
->select('a.employee_id','b.title','b.id')
|
|
->select('a.employee_id','b.title','b.id')
|
|
->join('depart as b','a.depart_id','=','b.id')
|
|
->join('depart as b','a.depart_id','=','b.id')
|
|
->whereIn("a.employee_id",array_column($data['data'],'id'))
|
|
->whereIn("a.employee_id",array_column($data['data'],'id'))
|
|
->orderBy('b.id')
|
|
->orderBy('b.id')
|
|
->get()->toArray();
|
|
->get()->toArray();
|
|
- $depart_title = $depart_id = [];
|
|
|
|
|
|
+ $depart_title = $depart_id = $man_top_depart = [];
|
|
foreach ($res as $value){
|
|
foreach ($res as $value){
|
|
if(isset($depart_title[$value->employee_id])){
|
|
if(isset($depart_title[$value->employee_id])){
|
|
$depart_title[$value->employee_id] .= ',' . $value->title;
|
|
$depart_title[$value->employee_id] .= ',' . $value->title;
|
|
@@ -357,6 +359,17 @@ class EmployeeService extends Service
|
|
$depart_title[$value->employee_id] = $value->title;
|
|
$depart_title[$value->employee_id] = $value->title;
|
|
}
|
|
}
|
|
$depart_id[$value->employee_id][] = $value->id;
|
|
$depart_id[$value->employee_id][] = $value->id;
|
|
|
|
+
|
|
|
|
+ $tmp = $map[$value->id] ?? [];
|
|
|
|
+ if(empty($tmp)) continue;
|
|
|
|
+ $key = $tmp['id'] . $tmp['title'];
|
|
|
|
+ if(! isset($man_top_depart[$value->employee_id][$key])) {
|
|
|
|
+ $man_top_depart[$value->employee_id][$key] = $map[$value->id];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ foreach ($man_top_depart as $key => $value){
|
|
|
|
+ $man_top_depart[$key] = array_values($value);
|
|
}
|
|
}
|
|
|
|
|
|
$wx = WxEmployeeOfficial::where('appid',WeixinService::APPID)
|
|
$wx = WxEmployeeOfficial::where('appid',WeixinService::APPID)
|
|
@@ -372,11 +385,34 @@ class EmployeeService extends Service
|
|
$is_wx = "未绑定微信公众号";
|
|
$is_wx = "未绑定微信公众号";
|
|
if(in_array($value['id'], $wx)) $is_wx = "已绑定微信公众号";
|
|
if(in_array($value['id'], $wx)) $is_wx = "已绑定微信公众号";
|
|
$data['data'][$key]['is_wx'] = $is_wx;
|
|
$data['data'][$key]['is_wx'] = $is_wx;
|
|
|
|
+ $data['data'][$key]['my_top'] = $man_top_depart[$value['id']] ?? [];
|
|
}
|
|
}
|
|
|
|
|
|
return $data;
|
|
return $data;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //门店下所有子集
|
|
|
|
+ public function getTopDepartSon(){
|
|
|
|
+ $departList = Depart::where('del_time',0)
|
|
|
|
+ ->select('id','parent_id','title')
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+
|
|
|
|
+ $map = [];
|
|
|
|
+ foreach ($departList as $value){
|
|
|
|
+ if($value['parent_id'] == 0){
|
|
|
|
+ $result = array_merge($this->getAllDescendants($departList,$value['id']),[$value['id']]);
|
|
|
|
+ foreach ($result as $val){
|
|
|
|
+ $map[$val] = [
|
|
|
|
+ 'id' => $value['id'],
|
|
|
|
+ 'title' => $value['title'],
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $map;
|
|
|
|
+ }
|
|
|
|
+
|
|
//获取当前顶级部门下人员id
|
|
//获取当前顶级部门下人员id
|
|
public function getEmployee($user){
|
|
public function getEmployee($user){
|
|
$top_depart_id = $user['depart_top'][0] ?? [];
|
|
$top_depart_id = $user['depart_top'][0] ?? [];
|