From 69bd7bd4a7434eb7b92ced34183fe5c548a2bedf Mon Sep 17 00:00:00 2001 From: "HESU\\HESU" <1696136552@qq.com> Date: Wed, 19 Mar 2025 12:44:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E6=AC=A1=E8=B7=9F=E8=BF=9B=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=8F=8A=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/CustomerController.php | 62 +++++++++++++++++++++++++++ app/controller/FollowController.php | 3 +- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/app/controller/CustomerController.php b/app/controller/CustomerController.php index 688f593..e345b77 100644 --- a/app/controller/CustomerController.php +++ b/app/controller/CustomerController.php @@ -4,6 +4,7 @@ namespace app\controller; use app\model\Channel; use app\model\Customer; +use app\model\Follow; use app\util\Util; use config\constants\Constants; use support\Log; @@ -210,6 +211,32 @@ class CustomerController } } + /** + * 更新下次跟进时间 + * @param Request $request + * @return \support\Response + */ + public function follow_next(Request $request) + { + $id = Util::getParam($request, 'id'); + if (Util::isEmpty($id)) { + return Util::fail([], 'id' . trans('not_null')); + } + $data = [ + 'follow_next' => Util::getParam($request, 'follow_next', 0), + 'follow_remark' => Util::getParam($request, 'follow_remark', 0), + ]; + + $res = Customer::where('id', $id) + ->update($data); + + if ($res) { + return Util::success($res, trans('save_success')); + } else { + return Util::fail($res, trans('save_fail')); + } + } + /** * 删除客户 * @param Request $request @@ -227,4 +254,39 @@ class CustomerController } } + /** + * 统计客户 + * @param Request $request + * @return \support\Response + */ + public function statistics(Request $request) + { + $created = Util::getParam($request, 'created'); + if (Util::isEmpty($created)) { + return Util::fail([], 'created' . trans('not_null')); + } + $userId = $request->user['id']; + $id = Util::getParam($request, 'id'); + $where = ['user_id', '=', $userId]; + $where[] = ['created_at', '>', strtotime($created.'-01')]; + $customer = Customer::where($where)->count(); + $whereVisit = $where; + $whereVisit[] = ['type', '=', 0]; + $visit = Follow::where($whereVisit)->distinct('customer_id')->count(); + $whereVisit = $where; + $whereVisit[] = ['type', '=', 1]; + $follow = Follow::where($whereVisit)->distinct('customer_id')->count(); + + $res = [ + 'customer'=>$customer, + 'visit'=>$visit, + 'follow'=>$follow, + ]; + if ($res) { + return Util::success($res, trans('success')); + } else { + return Util::fail($res, trans('fail')); + } + } + } \ No newline at end of file diff --git a/app/controller/FollowController.php b/app/controller/FollowController.php index c8d7161..19455fb 100644 --- a/app/controller/FollowController.php +++ b/app/controller/FollowController.php @@ -138,7 +138,8 @@ class FollowController 'audio_text'=>Util::getParam($request,'audio',''), 'lat'=>Util::getParam($request,'lat',0), 'lng'=>Util::getParam($request,'lng',0), - 'address1'=>Util::getParam($request,'address'), + 'address'=>Util::getParam($request,'address'), + 'follow_time'=>Util::getParam($request,'firstFollowtime',0), ]; $res = Follow::create($data);