From bdec92f4051c19c6d37fb087a9b6b285add82a1c Mon Sep 17 00:00:00 2001 From: lccsw <1127794702@qq.com> Date: Thu, 26 Aug 2021 19:15:07 +0800 Subject: [PATCH] edit-admin-clues-log --- admin/controllers/receiver/Clues.php | 87 ++++++--------- admin/controllers/receiver/Customer.php | 7 +- admin/views/receiver/clues/edit.php | 19 ++++ admin/views/receiver/clues/get_adviser.php | 104 +++++++++++++++++- admin/views/receiver/clues/lists.php | 82 ++++++++++---- admin/views/receiver/customer/lists.php | 4 +- api/controllers/wxapp/liche/Aptinfo.php | 6 +- .../libraries/receiver/Customers_entity.php | 13 ++- common/models/biz/Biz_model.php | 17 +++ 9 files changed, 252 insertions(+), 87 deletions(-) diff --git a/admin/controllers/receiver/Clues.php b/admin/controllers/receiver/Clues.php index 913b84c6..3777d52c 100644 --- a/admin/controllers/receiver/Clues.php +++ b/admin/controllers/receiver/Clues.php @@ -37,19 +37,6 @@ class Clues extends HD_Controller $this->data['city_id'] = $city_id = intval($params['city_id']); $this->data['county_id'] = $county_id = intval($params['county_id']); - //获取系统配置的城市 - $map_city = $this->city_ary(); - $rows_city = array(); - foreach($map_city as $k => $v){ - $rows_city[] = array( - 'city_id' => $k, - 'city_name' => $v - ); - } - $this->data['citys'] = $rows_city; - if($city_id){ - $this->data['countys'] = $this->area_model->select(array('city_id' => $city_id)); - } $page = $params['page'] = $params['page'] ? intval($params['page']) : 1; $size = $params['size'] = $params['size'] ? intval($params['size']) : 20; @@ -185,6 +172,18 @@ class Clues extends HD_Controller $autoList[4] = $this->mdAutoAttr->select(array('type' => 0, 's_id' => $re['s_id']), 'id desc', 0, 0, 'id,title as name'); } $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){ + $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'); + } + } + $info_show['cus_bizs'] = implode($biz_arr,','); $this->data['info'] = $dataInfo; $this->data['info_show'] = $info_show; $this->data['_title'] = '线索详情'; @@ -474,17 +473,27 @@ class Clues extends HD_Controller public function get_adviser() { $ids = $this->input->get('ids'); - $where = [ - 'status' => 1, - ]; - $bizList = $this->biz_model->select($where, '', '', '', 'id,biz_name'); - $this->data['bizList'] = $bizList; + if($this->input->method()=='post'){ + $city_id = $this->input->post('city_id'); + $county_id = $this->input->post('county_id'); + $where = [ + 'status' => 1, + ]; + $city_id && $where['city_id'] = $city_id; + $county_id && $where['county_id'] = $county_id; + $bizList = $this->biz_model->select($where, '', '', '', 'id,biz_name'); + $this->data['bizList'] = $bizList; + return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); + } $this->data['ids'] = $ids; return $this->show_view('receiver/clues/get_adviser'); } public function edit_adviser() { + $this->load->library('receiver/clues_entity'); + $this->load->library('receiver/customers_entity'); + $biz_id = $this->input->post('biz_id'); $ids = $this->input->post('ids'); $ids_arr = explode(',', $ids); @@ -526,10 +535,10 @@ class Clues extends HD_Controller $customers_id = $this->customers_model->add($add_data); if ($customers_id) { $this->clues_model->update(['status' => 1], ['id' => $val]); - $this->load->library('receiver/clues_entity'); - $this->clues_entity->add_log($val, $this->uid, $this->username, "分配给【{$biz['biz_name']}】商家"); - $this->load->library('receiver/customers_entity'); + //同步线索日志到客户日志 + $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']}】商家"); } } } @@ -744,37 +753,9 @@ class Clues extends HD_Controller return $this->show_json(SYS_CODE_SUCCESS); } - public function get_change(){ - $page = $this->input->get('page'); - $size = $this->input->get('size'); - !$page && $page = 1; - !$size && $size = 20; - - $where = [ - 'c_time<' => 1629907200, - ]; - $rows = $this->clues_model->select($where,'id desc',$page,$size,'id,jsondata'); - if($rows){ - $this->load->model('sys/sys_area_model'); - $up_ids = []; - foreach($rows as $key => $val){ - $jsondata = json_decode($val['jsondata'],true); - if($jsondata['info']['city_code']){ - $city_code = $jsondata['info']['city_code']; - $city = $this->sys_area_model->get(['county_id'=>$city_code],'city_id,county_id'); - if($city){ - $update = [ - 'city_id' => $city['city_id'], - 'county_id' => $city['county_id'] - ]; - $this->clues_model->update($update,['id'=>$val['id']]); - $up_ids[] = $val['id']; - } - } - } - echo "do up ids: ".implode(',',$up_ids); - }else{ - echo 'finish'; - } + public function get_city(){ + $citys = $this->city_ary(); + $this->data['citys'] = $citys; + return $this->show_json(SYS_CODE_SUCCESS); } } diff --git a/admin/controllers/receiver/Customer.php b/admin/controllers/receiver/Customer.php index 1f68c3e6..a9b40ba9 100644 --- a/admin/controllers/receiver/Customer.php +++ b/admin/controllers/receiver/Customer.php @@ -59,11 +59,14 @@ class Customer extends HD_Controller $count = $this->customers_model->count($where); $lists = []; if ($count) { - $fileds = 'id,name,mobile,cf_title,c_time,admin_id,status'; + $fileds = 'id,name,mobile,cf_title,c_time,admin_id,status,biz_id'; $rows = $this->customers_model->select($where, 'id desc', $page, $size, $fileds); //获取销售员 $admin_id_arr = array_unique(array_column($rows, 'admin_id')); $admin_id_arr && $admin_rows = $this->app_licheb_users_model->get_map_by_ids($admin_id_arr, 'id,uname'); + //获取门店 + $biz_id_arr = array_unique(array_column($rows, 'biz_id')); + $biz_id_arr && $biz_rows = $this->biz_model->get_map_by_ids($biz_id_arr, 'id,biz_name'); foreach ($rows as $key => $val) { $lists[] = array( 'id' => $val['id'], @@ -73,6 +76,7 @@ class Customer extends HD_Controller 'cf_title' => $val['cf_title'], 'status_name' => $status_arr[$val['status']], 'admin_name' => isset($admin_rows[$val['admin_id']]) ? $admin_rows[$val['admin_id']][0]['uname'] : '', + 'biz_name' => isset($biz_rows[$val['biz_id']]) ? $biz_rows[$val['biz_id']][0]['biz_name'] : '', 'c_time' => $val['c_time'] > 0 ? date('Y-m-d H:i:s', $val['c_time']) : '', ); } @@ -90,7 +94,6 @@ class Customer extends HD_Controller { $id = $this->input->get('id'); - $this->load->model("biz/biz_model"); $this->load->model('auto/auto_brand_model'); $this->load->model('auto/auto_series_model'); diff --git a/admin/views/receiver/clues/edit.php b/admin/views/receiver/clues/edit.php index 460654ea..590f2a97 100644 --- a/admin/views/receiver/clues/edit.php +++ b/admin/views/receiver/clues/edit.php @@ -88,6 +88,25 @@ + + +
+
分配商家:
+ + +
+ + + + + + + +
diff --git a/admin/views/receiver/clues/get_adviser.php b/admin/views/receiver/clues/get_adviser.php index 71092fc5..27ff5560 100755 --- a/admin/views/receiver/clues/get_adviser.php +++ b/admin/views/receiver/clues/get_adviser.php @@ -1,20 +1,114 @@
+ +
+ +
+
+
+ +
+
+ +
+
+
+
- - $value) { ?> - - +
- +
+ diff --git a/admin/views/receiver/clues/lists.php b/admin/views/receiver/clues/lists.php index 2449fc94..dc6cad78 100644 --- a/admin/views/receiver/clues/lists.php +++ b/admin/views/receiver/clues/lists.php @@ -17,7 +17,7 @@