From e3237532fe3c4bb9fd7d7e0f76d45c944b5a6ad3 Mon Sep 17 00:00:00 2001 From: xiaoyu Date: Sat, 8 Mar 2025 16:37:23 +0800 Subject: [PATCH] area --- admin/controllers/autohome/Customer.php | 27 +++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/admin/controllers/autohome/Customer.php b/admin/controllers/autohome/Customer.php index fd44574c..cb891fba 100644 --- a/admin/controllers/autohome/Customer.php +++ b/admin/controllers/autohome/Customer.php @@ -280,12 +280,6 @@ class Customer extends HD_Controller $cfrom_f = array_flip($this->cfrom); $cfrom2_f = array_flip($this->cfrom2); $map_biz = $this->biz_model->map('biz_name', 'id', ['status' => 1, 'province_id' => 350000], '', 0, 0, 'id,biz_name'); - $province_strings = implode("','", array_unique(array_column($lists, 'province_name'))); - if ($province_strings) $where = ["province_name in ('{$province_strings}')" => null]; - $province_strings && $map_province = $this->area_model->map('province_name', 'province_id', $where, '', 0, 0, 'DISTINCT(province_id),province_name'); - $city_strings = implode("','", array_unique(array_column($lists, 'city_name'))); - if ($city_strings) $where = ["city_name in ('{$city_strings}')" => null]; - $city_strings && $map_city = $this->area_model->map('city_name', 'city_id', $where, '', 0, 0, 'DISTINCT(city_id),city_name'); $fails = array(); foreach ($lists as $k => $v) { @@ -309,6 +303,23 @@ class Customer extends HD_Controller $cf2_id = $map_biz[$v['cfrom2']]; } + $province_name = $v['province_name']; + $city_name = $v['city_name']; + if($city_name){ + $city = $this->area_model->get(["city_name like '%$city_name'" => null]); + if(!$city){ + $city = $this->area_model->get(["county_name like '%$city_name'" => null]); + } + + $city_id = $city['city_id']; + $province_id = $city['province_id']; + } + + if(!$province_id){ + $province = $this->area_model->get(["province_name like '%$province_name'" => null]); + $province_id = $province['province_id']; + } + $temp = array( 'sid' => create_customer_no(), 'name' => $v['name'], @@ -318,8 +329,8 @@ class Customer extends HD_Controller 'channel' => $v['channel'] ? $v['channel'] : '', 'brand_id' => $v['brand_id'] ? $v['brand_id'] : '', 'series_id' => $v['series_id'] ? $v['series_id'] : '', - 'province_id' => $map_province[$v['province_name']] ? $map_province[$v['province_name']] : 0, - 'city_id' => $map_city[$v['city_name']] ? $map_city[$v['city_name']] : 0, + 'province_id' => $province_id, + 'city_id' => $city_id ? $city_id : 0, 'c_time' => date('Y-m-d H:i:s'), );