From 1dc2b79ced9efa284ba835300fa02cdaa0792889 Mon Sep 17 00:00:00 2001 From: "HESU\\HESU" <1696136552@qq.com> Date: Tue, 18 Mar 2025 17:23:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/CustomerController.php | 47 ++++++++++++++++++++------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/app/controller/CustomerController.php b/app/controller/CustomerController.php index 160eb25..688f593 100644 --- a/app/controller/CustomerController.php +++ b/app/controller/CustomerController.php @@ -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); @@ -137,7 +161,7 @@ class CustomerController if (Util::isEmpty($channel_id)) { 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)) { // return Util::fail([],'country_id'.trans('not_null')); } @@ -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)) {