Commit ff14d728 by 朱继来

调整

parent e55d5ca5
Showing with 9 additions and 18 deletions
......@@ -402,15 +402,15 @@
$this->getSubDepartmentId($department_id, $department_ids);
$data = DB::table('user_info')->whereIn('department_id', $department_ids)
->where(function($query) use($status) {
->where(function($query) use($status, $filter) {
if ($status !== '') {
$query->where('status', '=', $status);
}
})
->where(function($query) use($filter) {
if ($filter) {
$query->whereRaw($filter);
}
})
->select('userId', 'name', 'status')
->get();
......@@ -470,29 +470,20 @@
array_unshift($sale_ids, $userId); // 将当前用户添加到数组
$department_id = DB::table('user_info')->where('userId', $userId)->value('department_id'); // 用户信息
$user_info = DB::table('user_info')->where('userId', $userId)->select('department_id')->first(); // 用户信息
if (!$department_id) return $sale_ids;
if (!$user_info->department_id) return $sale_ids;
// 获取当前用户下级部门
$department = DB::table('user_department')
->where('parent_id', $user_info->department_id)
->select('department_id', 'department_name')
->get();
$department_ids = [];
if (!$department) {
$tmp = DB::table('user_info')->where('department_id', $user_info->department_id)->lists('userId');
$this->getSubDepartmentId($department_id, $department_ids); // 获取下级部门ID
$sale_ids = array_merge($sale_ids, $tmp);
} else {
// 获取下级部门的人员
foreach ($department as $v) {
$tmp = DB::table('user_info')->where('department_id', $v->department_id)->lists('userId');
foreach ($department_ids as $v) {
$tmp = DB::table('user_info')->where('department_id', $v)->lists('userId');
$sale_ids = array_merge($sale_ids, $tmp);
}
}
return array_unique($sale_ids); // 去重返回
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment