From d14945e54649b06ed3034c4cae5054933339eca0 Mon Sep 17 00:00:00 2001 From: "HESU\\HESU" <1696136552@qq.com> Date: Mon, 24 Mar 2025 14:48:29 +0800 Subject: [PATCH 1/5] 1 --- app/controller/CustomerController.php | 73 +++++++++++++++++---------- 1 file changed, 45 insertions(+), 28 deletions(-) diff --git a/app/controller/CustomerController.php b/app/controller/CustomerController.php index 2ce3c6c..674752e 100644 --- a/app/controller/CustomerController.php +++ b/app/controller/CustomerController.php @@ -58,6 +58,24 @@ class CustomerController } + /** + * 待跟进客户列表 + * @param Request $request + * @return \support\Response + */ + public function waitFollow(Request $request) + { + $userId = $request->user['id']; + $where = [ + ['user_id', '=', $userId], +// ['follow_next', '<=', time() + 3600 * 24], + ['follow_next', '>', time()], + ['warn', '<', 1] + ]; + $customer = Customer::where($where)->orderBy('follow_next')->get(); + return Util::success($customer,trans('success')); + } + /** * 客户列表 * @param Request $request @@ -68,9 +86,9 @@ 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:近七天跟进客户 + $follow = $request->input('follow', ''); //跟进状态 + $keyword = $request->input('keyword', ''); //follow_last + $follow_last = $request->input('follow_last', ''); //最后跟进:1:当天跟进客户,2:近三天跟进客户,3:近七天跟进客户 $where = []; @@ -78,30 +96,29 @@ class CustomerController if (Util::isEmpty($userId)) { return Util::fail(['user_id' => $userId], trans('user_none')); } - $where[] =['user_id',$userId] ; + $where[] = ['user_id', $userId]; //验证权限 // if ($request->user['role'] != 1) { // $where[] =['user_id',$userId] ; // } $grade = []; if (!Util::isEmpty($follow) && $follow == 0) { - $where[] = ['grade','<=', 2]; + $where[] = ['grade', '<=', 2]; } elseif (!Util::isEmpty($follow) && $follow == 1) { - $grade = [3, 4]; + $grade = [3, 4]; } elseif (!Util::isEmpty($follow) && $follow == 2) { - $where[] = ['grade','=', 5]; + $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')]; + $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')]; } - // 执行分页查询 $query = Customer::where($where) ->orderBy('id', 'desc'); @@ -176,7 +193,7 @@ class CustomerController $email = Util::getParam($request, 'email'); $phone = Util::getParam($request, 'phone'); if (Util::isEmpty($contacts) && Util::isEmpty($email) && Util::isEmpty($phone)) { - return Util::fail([], trans('contacts_not_null')); + return Util::fail([], trans('contacts_not_null')); } $data = [ @@ -259,7 +276,7 @@ class CustomerController ]; $res = Customer::where('id', $id) - ->update($data); + ->update($data); if ($res) { return Util::success($res, trans('save_success')); @@ -298,19 +315,19 @@ class CustomerController } $userId = $request->user['id']; $created_at = $request->user['created_at']; - $day = ceil((time()-$created_at+1)/60/60/24); + $day = ceil((time() - $created_at + 1) / 60 / 60 / 24); $where[] = ['user_id', '=', $userId]; - $start = strtotime($created.'-01'); + $start = strtotime($created . '-01'); $year = date('Y', $start); - $month = date('n',$start); //获取月份 - $end = mktime(00, 00, 00, $month+1, 1, $year); + $month = date('n', $start); //获取月份 + $end = mktime(00, 00, 00, $month + 1, 1, $year); $where[] = ['created_at', '>=', $start]; $where[] = ['created_at', '<', $end]; $customer = Customer::where($where)->count(); //初步接触 $whereGrade = $where; - $whereGrade[] = ['grade','<=', 2]; + $whereGrade[] = ['grade', '<=', 2]; $customerInit = Customer::where($whereGrade)->count(); //跟进中 @@ -318,7 +335,7 @@ class CustomerController //已成交 $whereGrade = $where; - $whereGrade[] = ['grade','=', 5]; + $whereGrade[] = ['grade', '=', 5]; $customerDeal = Customer::where($whereGrade)->count(); //拜访数 @@ -332,13 +349,13 @@ class CustomerController $follow = Follow::where($whereVisit)->distinct('customer_id')->count(); $res = [ - 'customer'=>$customer, //客户数 - 'visit'=>$visit, //拜访 - 'follow'=>$follow, //跟进 - 'day'=>$day, //注册天数 - 'customer_init'=>$customerInit, //初步接触 - 'customero_fllow'=>$customeroFllow, //跟进中 - 'customer_deal'=>$customerDeal, //已成交 + 'customer' => $customer, //客户数 + 'visit' => $visit, //拜访 + 'follow' => $follow, //跟进 + 'day' => $day, //注册天数 + 'customer_init' => $customerInit, //初步接触 + 'customero_fllow' => $customeroFllow, //跟进中 + 'customer_deal' => $customerDeal, //已成交 ]; if ($res) { return Util::success($res, trans('success')); From 68eb23e3163f368db38f09ba18656612d1ba0d8c Mon Sep 17 00:00:00 2001 From: "HESU\\HESU" <1696136552@qq.com> Date: Tue, 25 Mar 2025 13:42:24 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=BE=85=E8=B7=9F=E8=BF=9B=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/CustomerController.php | 11 ++++++++--- app/controller/FollowController.php | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/controller/CustomerController.php b/app/controller/CustomerController.php index 674752e..bab9349 100644 --- a/app/controller/CustomerController.php +++ b/app/controller/CustomerController.php @@ -68,11 +68,16 @@ class CustomerController $userId = $request->user['id']; $where = [ ['user_id', '=', $userId], + ['follow_next', '<>', 0], // ['follow_next', '<=', time() + 3600 * 24], - ['follow_next', '>', time()], - ['warn', '<', 1] +// ['follow_next', '>', time()], +// ['warn', '<', 1] ]; - $customer = Customer::where($where)->orderBy('follow_next')->get(); + $customer = Customer::where($where)->whereNotNull('follow_next')->orderBy('follow_next')->get(); + + foreach ($customer as &$item) { + $item['follow_remaining'] = $item->follow_next-time(); + } return Util::success($customer,trans('success')); } diff --git a/app/controller/FollowController.php b/app/controller/FollowController.php index c4bd59a..c92e599 100644 --- a/app/controller/FollowController.php +++ b/app/controller/FollowController.php @@ -146,6 +146,8 @@ class FollowController $customer = Customer::find($customer_id); $customer->follow_last = strtotime($res->created_at); + $customer->follow_next = null; + $customer->warn = 0; $customer->save(); if ($res) { From d5c9d1a7a5b64b0f46e00f98727c88c45f652015 Mon Sep 17 00:00:00 2001 From: "HESU\\HESU" <1696136552@qq.com> Date: Tue, 25 Mar 2025 13:45:35 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/CustomerController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controller/CustomerController.php b/app/controller/CustomerController.php index bab9349..dbb1f31 100644 --- a/app/controller/CustomerController.php +++ b/app/controller/CustomerController.php @@ -278,6 +278,7 @@ class CustomerController $data = [ 'follow_next' => Util::getParam($request, 'follow_next', 0), 'follow_remark' => Util::getParam($request, 'follow_remark', 0), + 'warn' => 0, ]; $res = Customer::where('id', $id) From 23ffdab0f640612f4198e3986ea829a930b105d7 Mon Sep 17 00:00:00 2001 From: "HESU\\HESU" <1696136552@qq.com> Date: Tue, 25 Mar 2025 14:25:16 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=B8=8B=E6=AC=A1=E8=B7=9F=E8=BF=9B?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/CustomerController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controller/CustomerController.php b/app/controller/CustomerController.php index dbb1f31..b1c9e14 100644 --- a/app/controller/CustomerController.php +++ b/app/controller/CustomerController.php @@ -77,6 +77,7 @@ class CustomerController foreach ($customer as &$item) { $item['follow_remaining'] = $item->follow_next-time(); + $item['follow_next'] = date('Y-m-d H:i:s',$item->follow_next); } return Util::success($customer,trans('success')); } From 8cbf82fb2d95fa89ece30f81bb2fe5858cf1c86b Mon Sep 17 00:00:00 2001 From: "HESU\\HESU" <1696136552@qq.com> Date: Wed, 26 Mar 2025 09:50:10 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E7=AD=9B=E9=80=89=E8=B7=9F=E8=BF=9B?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/CustomerController.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/app/controller/CustomerController.php b/app/controller/CustomerController.php index b1c9e14..b19d9cb 100644 --- a/app/controller/CustomerController.php +++ b/app/controller/CustomerController.php @@ -66,20 +66,31 @@ class CustomerController public function waitFollow(Request $request) { $userId = $request->user['id']; + $filter = Util::getParam($request, 'filter'); + $page = $request->input('page', 1); + $perPage = $request->input('per_page', 10); $where = [ ['user_id', '=', $userId], ['follow_next', '<>', 0], -// ['follow_next', '<=', time() + 3600 * 24], -// ['follow_next', '>', time()], -// ['warn', '<', 1] ]; - $customer = Customer::where($where)->whereNotNull('follow_next')->orderBy('follow_next')->get(); + + if($filter == 0){ + $where[] = ['follow_next', '<=', time() + 3600 * 24]; + }elseif($filter == 1){ + $where[] = ['follow_next', '<=', time() + 3600 * 24*3]; + }elseif($filter == 2){ + $where[] = ['follow_next', '<=', time() + 3600 * 24*7]; + } + $customer = Customer::where($where) + ->whereNotNull('follow_next') + ->orderBy('follow_next') + ->paginate($perPage, ['*'], 'page', $page); foreach ($customer as &$item) { $item['follow_remaining'] = $item->follow_next-time(); $item['follow_next'] = date('Y-m-d H:i:s',$item->follow_next); } - return Util::success($customer,trans('success')); + return Util::page($customer); } /**