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