客户筛选
This commit is contained in:
@@ -68,6 +68,8 @@ class CustomerController
|
||||
$page = $request->input('page', 1);
|
||||
$perPage = $request->input('per_page', 10);
|
||||
$follow = $request->input('follow'); //跟进状态
|
||||
$keyword = $request->input('keyword'); //follow_last
|
||||
$follow_last = $request->input('follow_last'); //最后跟进:1:当天跟进客户,2:近三天跟进客户,3:近七天跟进客户
|
||||
|
||||
$where = [];
|
||||
|
||||
@@ -76,21 +78,43 @@ class CustomerController
|
||||
return Util::fail(['user_id' => $userId], trans('user_none'));
|
||||
}
|
||||
if ($request->user['role'] != 1) {
|
||||
$where['user_id'] = $userId;
|
||||
$where[] =['user_id',$userId] ;
|
||||
}
|
||||
$grade = [];
|
||||
if (!Util::isEmpty($follow) && $follow == 0) {
|
||||
$where[] = ['grade','<=', 2];
|
||||
} elseif (!Util::isEmpty($follow) && $follow == 1) {
|
||||
$grade = [3, 4];
|
||||
} elseif (!Util::isEmpty($follow) && $follow == 2) {
|
||||
$where[] = ['grade','=', 5];
|
||||
}
|
||||
|
||||
if (!Util::isEmpty($follow) && $follow == 0) {
|
||||
$where['grade'] = ['<=', 2];
|
||||
} elseif (!Util::isEmpty($follow) && $follow == 1) {
|
||||
$where['grade'] = ['in', [3, 4, 5]];
|
||||
} elseif (!Util::isEmpty($follow) && $follow == 2) {
|
||||
$where['grade'] = ['>', 5];
|
||||
if (!Util::isEmpty($follow_last) && $follow_last == 0) {
|
||||
$where[] = ['follow_last','>', strtotime('-1 day')];
|
||||
}elseif (!Util::isEmpty($follow_last) && $follow_last == 1) {
|
||||
$where[] = ['follow_last','>', strtotime('-3 day')];
|
||||
}elseif (!Util::isEmpty($follow_last) && $follow_last == 2) {
|
||||
$where[] = ['follow_last','>', strtotime('-7 day')];
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 执行分页查询
|
||||
$data = Customer::where($where)
|
||||
->orderBy('id', 'desc')
|
||||
->paginate($perPage, ['*'], 'page', $page);
|
||||
$query = Customer::where($where)
|
||||
->orderBy('id', 'desc');
|
||||
if (!Util::isEmpty($keyword)) {
|
||||
$query->where(function ($query) use ($keyword) {
|
||||
$query->where('contacts', 'like', "%{$keyword}%")
|
||||
->orWhere('phone', 'like', "%{$keyword}%");
|
||||
});
|
||||
|
||||
}
|
||||
if (!Util::isEmpty($grade)) {
|
||||
$query->whereIn('grade', $grade);
|
||||
|
||||
}
|
||||
// return Util::success($query->toSql().serialize($where),$follow);
|
||||
$data = $query->paginate($perPage, ['*'], 'page', $page);
|
||||
|
||||
foreach ($data->items() as &$value) {
|
||||
$value = Customer::getCustomer($value);
|
||||
@@ -167,6 +191,7 @@ class CustomerController
|
||||
'lat' => Util::getParam($request, 'lat', 0),
|
||||
'lng' => Util::getParam($request, 'lng', 0),
|
||||
'address' => Util::getParam($request, 'address', ''),
|
||||
'sex' => Util::getParam($request, 'sex', 0),
|
||||
];
|
||||
|
||||
if (Util::isEmpty($id)) {
|
||||
|
||||
Reference in New Issue
Block a user