From fe4617515db96fffb6eeba4ffb6c89f6376d24b2 Mon Sep 17 00:00:00 2001 From: dengbw Date: Thu, 14 Jul 2022 14:12:01 +0800 Subject: [PATCH] customers_714 --- api/controllers/wxapp/licheb/Customers.php | 36 ++++++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/api/controllers/wxapp/licheb/Customers.php b/api/controllers/wxapp/licheb/Customers.php index 2bb197a6..638eeb89 100644 --- a/api/controllers/wxapp/licheb/Customers.php +++ b/api/controllers/wxapp/licheb/Customers.php @@ -26,6 +26,7 @@ class Customers extends Wxapp $this->load->model('receiver/receiver_customer_tagdata_model', 'mdCustomerTagdata'); $this->load->model('receiver/receiver_customers_visit_data_model', 'mdCustomerVisitData'); $this->load->model('receiver/order/receiver_orders_v2_model', 'mdOrders'); + $this->load->model('area_model', 'mdArea'); $this->load->model('auto/auto_series_model'); $this->load->model('auto/auto_brand_model'); $this->load->model('auto/auto_attr_model'); @@ -49,6 +50,10 @@ class Customers extends Wxapp $status_name = $this->customers_model->get_status(); $tip = $status_name[$row['status']] ? $status_name[$row['status']] : ''; $other_data = ['客户等级' => $row['level']]; + if ($row['county_id']) { + $re_area = $this->mdArea->get(['county_id' => $row['county_id']], 'city_name,county_name'); + $re_area && $other_data['所在地区'] = "{$re_area['city_name']}-{$re_area['county_name']}"; + } if ($this->get_biz('type') != 5) { $other_data['客户来源'] = $this->get_cfTitle($row); } @@ -633,21 +638,25 @@ class Customers extends Wxapp $lists = []; if ($count) { $fileds = 'id,name,admin_id,mobile,level,car_json,is_top,cf_title,brand_id,s_id,cont_time,c_time,if_defeat - ,of_id,of2_id,wxqy,status,biz_id,cs_biz_id'; + ,of_id,of2_id,wxqy,status,biz_id,cs_biz_id,county_id'; $rows = $this->customers_model->select($where, $orderby, $page, $size, $fileds); + $admins = $map_county = []; + //所在地区 + $str_county_ids = implode(',', array_unique(array_column($rows, 'county_id'))); + if ($str_county_ids) { + $map_county = $this->mdArea->map('county_id', 'city_name,county_name', ["county_id in({$str_county_ids})" => null]); + } //获取管理员 - $admin_arr = array_unique(array_column($rows, 'admin_id')); - $admin_ids = implode(',', $admin_arr); - $admins = []; + $admin_ids = implode(',', array_unique(array_column($rows, 'admin_id'))); if ($admin_ids) { - $where = [ - "id in ({$admin_ids})" => null - ]; - $admins = $this->app_user_model->map('id', '', $where, '', '', '', 'id,uname'); + $admins = $this->app_user_model->map('id', '', ["id in ({$admin_ids})" => null], '', '', '', 'id,uname'); } $allot = $this->get_allot(); $status_name = $this->customers_model->get_status(); foreach ($rows as $key => $val) { + if ($map_county[$val['county_id']]) { + $other_data['所在地区'] = "{$map_county[$val['county_id']]['city_name']}-{$map_county[$val['county_id']]['county_name']}"; + } if ($biz_type != 5) { $other_data['客户来源'] = $this->get_cfTitle($val); } @@ -861,17 +870,24 @@ class Customers extends Wxapp $lists = []; if ($count) { $fileds = 'a.id,a.name,a.admin_id,a.mobile,a.level,a.is_top,a.cont_time,a.c_time,a.if_defeat,a.cf_title - ,a.of_id,a.of2_id,a.status,a.biz_id'; + ,a.of_id,a.of2_id,a.status,a.biz_id,a.county_id'; $rows = $this->mdCustomerVisitData->select_visit($where, 'a.id desc', $page, $size, $fileds); + $admins = $map_county = []; + $str_county_ids = implode(',', array_unique(array_column($rows, 'county_id'))); + if ($str_county_ids) { + $map_county = $this->mdArea->map('county_id', 'city_name,county_name', ["county_id in({$str_county_ids})" => null]); + } //获取管理员 $admin_arr = array_unique(array_column($rows, 'admin_id')); - $admins = []; if ($admin_arr) { $admin_ids = implode(',', $admin_arr); $admins = $this->app_user_model->map('id', '', ["id in ({$admin_ids})" => null], '', '', '', 'id,uname'); } $status_name = $this->customers_model->get_status(); foreach ($rows as $key => $val) { + if ($map_county[$val['county_id']]) { + $other_data['所在地区'] = "{$map_county[$val['county_id']]['city_name']}-{$map_county[$val['county_id']]['county_name']}"; + } if ($biz_type != 5) { $other_data['客户来源'] = $this->get_cfTitle($val); }