From 512ee16a51fcfff6237c3d845066b53005362ea9 Mon Sep 17 00:00:00 2001 From: dengbw Date: Tue, 14 Sep 2021 10:32:52 +0800 Subject: [PATCH] admin_customers_914 --- admin/controllers/receiver/Clues.php | 83 ++++++++++++---------- admin/controllers/receiver/Customer.php | 6 +- api/controllers/wxapp/licheb/Customers.php | 2 +- 3 files changed, 48 insertions(+), 43 deletions(-) diff --git a/admin/controllers/receiver/Clues.php b/admin/controllers/receiver/Clues.php index e0e791c2..0a07e483 100644 --- a/admin/controllers/receiver/Clues.php +++ b/admin/controllers/receiver/Clues.php @@ -71,14 +71,14 @@ class Clues extends HD_Controller strlen($params['status']) && $where["status"] = $params['status']; $city_id && $where['city_id'] = $city_id; $county_id && $where['county_id'] = $county_id; - if($params['cfrom_id']||$params['cfrom_id2']){ - if($params['cfrom_id2']){ + if ($params['cfrom_id'] || $params['cfrom_id2']) { + if ($params['cfrom_id2']) { $where['cf_id'] = $params['cfrom_id2']; - }else{ - $cf_rows = $this->clues_cfrom_model->select(['pid'=>$params['cfrom_id']],'','','','id'); - $cf_ids = array_column($cf_rows,'id'); + } else { + $cf_rows = $this->clues_cfrom_model->select(['pid' => $params['cfrom_id']], '', '', '', 'id'); + $cf_ids = array_column($cf_rows, 'id'); $cf_ids[] = $params['cfrom_id']; - $cf_str_ids = implode(',',array_filter($cf_ids)); + $cf_str_ids = implode(',', array_filter($cf_ids)); $cf_str_ids && $where["cf_id in ({$cf_str_ids})"] = null; } } @@ -86,14 +86,14 @@ class Clues extends HD_Controller $lists = []; if ($count) { $fileds = 'id,name,mobile,cf_id,status_id,c_time,admin_id,status,en_time'; - $rows = $this->clues_model->select($where, 'en_time desc', $page, $size, $fileds); + $rows = $this->clues_model->select($where, 'en_time desc,id desc', $page, $size, $fileds); //获取来源 $cf_id_arr = array_unique(array_column($rows, 'cf_id')); $cf_rows = $this->clues_cfrom_model->get_map_by_ids($cf_id_arr, 'id,title'); //获取管理员 $this->load->model('sys/sys_admin_model', 'admin_model'); $admin_id_arr = array_unique(array_column($rows, 'admin_id')); - if($admin_id_arr){ + if ($admin_id_arr) { $str_ids = implode(',', $admin_id_arr); $where = array("id in ({$str_ids})" => null); $map_admin = $this->admin_model->map('id', 'username', $where); @@ -186,22 +186,22 @@ class Clues extends HD_Controller } $info_show['autoList'] = $autoList; //获取已分配店铺 - $cus = $this->customers_model->select(['rid'=>$re['id']],'','','','biz_id'); - $biz_arr = []; - if($cus){ - $biz_ids = implode(array_column($cus,'biz_id'),','); - if($biz_ids){ + $cus = $this->customers_model->select(['rid' => $re['id']], '', '', '', 'biz_id'); + $biz_arr = []; + if ($cus) { + $biz_ids = implode(array_column($cus, 'biz_id'), ','); + if ($biz_ids) { $where_biz["id in ($biz_ids)"] = null; - $cus_biz = $this->biz_model->select($where_biz,'','','','biz_name'); - $biz_arr = array_column($cus_biz,'biz_name'); + $cus_biz = $this->biz_model->select($where_biz, '', '', '', 'biz_name'); + $biz_arr = array_column($cus_biz, 'biz_name'); } } - $info_show['cus_bizs'] = implode($biz_arr,','); + $info_show['cus_bizs'] = implode($biz_arr, ','); //附近门店 - if($re['lat']&&$re['lng']){ - $info_show['near_bizs'] = $this->biz_model->nearby($re['lat'],$re['lng'],1,3,'id,biz_name'); - }else{ - $info_show['near_bizs'] = $this->biz_model->select(['city_id'=>$re['city_id'],'county_id'=>$re['county_id'],'status'=>1],'id desc',1,3,'id,biz_name'); + if ($re['lat'] && $re['lng']) { + $info_show['near_bizs'] = $this->biz_model->nearby($re['lat'], $re['lng'], 1, 3, 'id,biz_name'); + } else { + $info_show['near_bizs'] = $this->biz_model->select(['city_id' => $re['city_id'], 'county_id' => $re['county_id'], 'status' => 1], 'id desc', 1, 3, 'id,biz_name'); } $this->data['info'] = $dataInfo; $this->data['info_show'] = $info_show; @@ -225,9 +225,9 @@ class Clues extends HD_Controller $cf_id1 = ''; $cf_id2 = ''; - if($row['cf_id']){ + if ($row['cf_id']) { $row_cfrom = $this->clues_cfrom_model->get(array('id' => $row['cf_id'])); - if($row_cfrom['pid']){ + if ($row_cfrom['pid']) { $cf_id1 = $row_cfrom['pid']; $cf_id2 = $row['cf_id']; } else { @@ -280,9 +280,9 @@ class Clues extends HD_Controller } $cf_id = 0; - if($info['cf_id2']){ + if ($info['cf_id2']) { $cf_id = $info['cf_id2']; - } else if($info['cf_id1']) { + } else if ($info['cf_id1']) { $cf_id = $info['cf_id1']; } @@ -414,7 +414,7 @@ class Clues extends HD_Controller 's_id' => $info['s_id'], 'city_id' => $info['city_id'], 'county_id' => $info['county_id'], - 'jsondata' => json_encode($jsondata,JSON_UNESCAPED_UNICODE) + 'jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE) ]; $ret = $this->clues_model->update($up_data, array('id' => $info['id'])); if (!$ret) { @@ -490,7 +490,7 @@ class Clues extends HD_Controller public function get_adviser() { $ids = $this->input->get('ids'); - if($this->input->method()=='post'){ + if ($this->input->method() == 'post') { $city_id = $this->input->post('city_id'); $county_id = $this->input->post('county_id'); $where = [ @@ -555,7 +555,7 @@ class Clues extends HD_Controller if ($customers_id) { $this->clues_model->update(['status' => 1], ['id' => $val]); //同步线索日志到客户日志 - $this->customers_entity->syn_clues($customers_id,$val); + $this->customers_entity->syn_clues($customers_id, $val); $this->customers_entity->add_log($customers_id, $this->uid, $this->username, "平台分配", 0, 'admin'); $this->clues_entity->add_log($val, $this->uid, $this->username, "分配给【{$biz['biz_name']}】商家"); } @@ -670,16 +670,17 @@ class Clues extends HD_Controller * 返回map select数据 * @return bool */ - function json_map_cfrom(){ + function json_map_cfrom() + { $pid = $this->input->post('pid'); $status = $this->input->post('status'); $where = array(); - if(strlen($pid) > 0){ + if (strlen($pid) > 0) { $where['pid'] = $pid; } - if(strlen($status) > 0){ + if (strlen($status) > 0) { $where['status'] = $status; } else { $where["status>-1"] = null; @@ -687,11 +688,11 @@ class Clues extends HD_Controller $total = $this->clues_cfrom_model->count($where); $map = array(); - if($total){ + if ($total) { $orderby = 'id desc'; - $select= 'id, title'; + $select = 'id, title'; $rows = $this->clues_cfrom_model->select($where, $orderby, 0, 0, $select); - foreach($rows as $v){ + foreach ($rows as $v) { $map[$v['id']] = $v['title']; } } @@ -699,6 +700,7 @@ class Clues extends HD_Controller $this->data = $map; return $this->show_json(SYS_CODE_SUCCESS); } + private function upload() { $config['upload_path'] = $_SERVER['DOCUMENT_ROOT'] . '/temp/'; @@ -759,23 +761,26 @@ class Clues extends HD_Controller return $done; } + //获取线索来源 - public function get_cfroms(){ + public function get_cfroms() + { $id = $this->input->get('id'); $where = [ 'status' => 1, 'pid' => 0 ]; $id && $where['pid'] = $id; - $rows = $this->clues_cfrom_model->select($where,'id desc','','','id,title'); + $rows = $this->clues_cfrom_model->select($where, 'id desc', '', '', 'id,title'); $this->data['data'] = $rows; return $this->show_json(SYS_CODE_SUCCESS); } - - public function get_bizInfo(){ + + public function get_bizInfo() + { $id = $this->input->get('id'); - $info = $this->biz_model->get(['id'=>$id],'city_id,county_id,address'); - $city = $this->area_model->get(['county_id'=>$info['county_id']]); + $info = $this->biz_model->get(['id' => $id], 'city_id,county_id,address'); + $city = $this->area_model->get(['county_id' => $info['county_id']]); $bizinfo['city_name'] = $city['city_name']; $bizinfo['county_name'] = $city['county_name']; $bizinfo['address'] = $info['address']; diff --git a/admin/controllers/receiver/Customer.php b/admin/controllers/receiver/Customer.php index 704e04f4..8d4323b0 100644 --- a/admin/controllers/receiver/Customer.php +++ b/admin/controllers/receiver/Customer.php @@ -11,7 +11,7 @@ class Customer extends HD_Controller { private $searchTpAry = array('mobile' => '客户手机号', 'name' => '客户姓名'); private $searchTimeAry = array('c_time' => '创建时间', 'p_time' => '分配时间', 'cont_time' => '最后联系时间', 'u_time' => '最后操作时间' - , 'dt_time' => '最后到店时间'); + , 'dt_time' => '首次到店时间'); protected $log_dir; @@ -170,7 +170,7 @@ class Customer extends HD_Controller array( array('title' => '分配时间', 'value' => $row['p_time'] != '0000-00-00 00:00:00' ? $row['p_time'] : ''), array('title' => '最后联系时间', 'value' => $row['cont_time'] != '0000-00-00 00:00:00' ? $row['cont_time'] : ''), - array('title' => '最后到店时间', 'value' => $row['dt_time'] != '0000-00-00 00:00:00' ? $row['dt_time'] : ''), + array('title' => '首次到店时间', 'value' => $row['dt_time'] != '0000-00-00 00:00:00' ? $row['dt_time'] : ''), array('title' => '预计购买时间', 'value' => "{$row['buy_time']} 天内"), ), array( @@ -274,7 +274,7 @@ class Customer extends HD_Controller $status_name_up = $statuAry[$info['status']]; $log = '更新状态(' . $status_name . ')为(' . $status_name_up . ')'; $up_data['status'] = $info['status']; - if ($info['status'] == 1) {//修改最后到店时间 + if ($info['status'] == 1 && $row['dt_time'] == '0000-00-00 00:00:00') {//修改首次到店时间 $up_data['dt_time'] = date('Y-m-d H:i:s'); } $ret = $this->customers_model->update($up_data, array('id' => $info['id'])); diff --git a/api/controllers/wxapp/licheb/Customers.php b/api/controllers/wxapp/licheb/Customers.php index c827d7ec..3e8193a7 100644 --- a/api/controllers/wxapp/licheb/Customers.php +++ b/api/controllers/wxapp/licheb/Customers.php @@ -267,7 +267,7 @@ class Customers extends Wxapp{ $result = true; if($up_data){ $status==1 && $up_data['cont_time'] = date('Y-m-d H:i:s'); //修改到店状态修改最后联系时间 - if($status==1 || $a_num){//修改最后到店时间 + if($status==1 && $row['dt_time'] == '0000-00-00 00:00:00'){//首次到店时间 $up_data['dt_time'] = date('Y-m-d H:i:s'); } $result = $this->customers_model->update($up_data,['id'=>$id]);