From 4e7420877aa4c7e8d9b6ed3c6ca6a2739c929f66 Mon Sep 17 00:00:00 2001 From: "HDM58\\hdm58" Date: Tue, 6 Jun 2023 18:05:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AE=A2=E6=88=B7=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/customer/controller/Index.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/customer/controller/Index.php b/app/customer/controller/Index.php index fad7336..c1798d3 100644 --- a/app/customer/controller/Index.php +++ b/app/customer/controller/Index.php @@ -26,7 +26,7 @@ class Index extends BaseController $where = array(); $whereOr = array(); if (!empty($param['keywords'])) { - $where[] = ['a.id|a.name', 'like', '%' . $param['keywords'] . '%']; + $where[] = ['a.id|a.name|cc.name|cc.mobile', 'like', '%' . $param['keywords'] . '%']; } if (!empty($param['status'])) { $where[] = ['a.status', '=', $param['status']]; @@ -103,9 +103,9 @@ class Index extends BaseController } } } - - $ct_sql= Db::name('CustomerTrace')->order('id desc')->buildSql(); - $orderby = 'a.create_time desc'; + $cc_sql= Db::name('CustomerContact')->group('cid')->buildSql(); + $ct_sql= Db::name('CustomerTrace')->group('cid')->field('cid,MAX(follow_time) AS follow_time,MAX(next_time) AS next_time')->buildSql(); + $orderby = 'ct.next_time desc,a.create_time desc'; if(isset($param['orderby'])){ $orderby = 'ct.'.$param['orderby']; } @@ -121,8 +121,9 @@ class Index extends BaseController ->join('industry i', 'a.industry_id = i.id') ->join('department d', 'a.belong_did = d.id') ->join($ct_sql.' ct', 'ct.cid = a.id','left') + ->join($cc_sql.' cc', 'a.id = cc.cid','left') + ->distinct() ->order($orderby) - ->group('a.id') ->paginate($rows, false, ['query' => $param]) ->each(function ($item, $key) { $item->belong_name = Db::name('Admin')->where(['id' => $item->belong_uid])->value('name');