From 4bc4fff673daadb96b1db63b398c1d056e1670fc Mon Sep 17 00:00:00 2001 From: lcc <805383944@qq.com> Date: Thu, 9 Oct 2025 20:15:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B94s=E5=93=81=E7=89=8C=E5=A4=9A?= =?UTF-8?q?=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/controllers/biz/store/Store.php | 45 ++++++++++++++++--- admin/views/biz/store/edit.php | 55 ++++++++++++++++++----- agent/admin/controllers/Common.php | 7 ++- agent/admin/controllers/api/Common.php | 7 ++- agent/admin/controllers/pingan/Common.php | 9 +++- common/models/biz/Biz_car_brand_model.php | 12 +++++ 6 files changed, 113 insertions(+), 22 deletions(-) create mode 100644 common/models/biz/Biz_car_brand_model.php diff --git a/admin/controllers/biz/store/Store.php b/admin/controllers/biz/store/Store.php index 2c8968cd..f135b12c 100644 --- a/admin/controllers/biz/store/Store.php +++ b/admin/controllers/biz/store/Store.php @@ -22,6 +22,7 @@ class Store extends HD_Controller $this->load->library('bizAccount'); $this->load->helper('db'); $this->load->model('auto/auto_brand_model'); + $this->load->model('biz/biz_car_brand_model'); } public function index() @@ -73,10 +74,10 @@ class Store extends HD_Controller $count = $this->biz_model->count($where); $bizlists = []; $account = new BizAccount(); - $brandAry = $this->auto_brand_model->select(['status>'=>0], 'initial asc', 0, 0, 'id,name'); - if($biz_lists){ + $brandAry = $this->auto_brand_model->select(['status>' => 0], 'initial asc', 0, 0, 'id,name'); + if ($biz_lists) { $map = []; - foreach($brandAry as $item) { + foreach ($brandAry as $item) { $map[$item['id']] = null !== $item['name'] ? $item['name'] : ''; } foreach ($biz_lists as $v) { @@ -118,6 +119,14 @@ class Store extends HD_Controller $biz['avatar'] = build_qiniu_image_url($biz['headimg'], 200, 200); $biz['car_brand_id'] = $biz['car_brand_id'] ? intval($biz['car_brand_id']) : ''; + $carBrands = $this->biz_car_brand_model->select(['biz_id' => $id], '', '', 'brand_id'); + $carBrandsIds = []; + if ($carBrands) { + foreach ($carBrands as $item) { + $carBrandsIds[] = intval($item['brand_id']); + } + } + $biz['car_brand_ids'] = $carBrandsIds; $this->data['biz'] = $biz; } else { $map_city = $this->city_ary(); @@ -145,7 +154,7 @@ class Store extends HD_Controller public function add() { - + $car_brand_ids = $this->input->post('car_brand_ids'); $biz['status'] = 1; $biz['biz_name'] = $this->input->post('biz_name', true); if (!$biz['biz_name']) { @@ -176,7 +185,17 @@ class Store extends HD_Controller if (!$id) { return $this->show_json(SYS_CODE_FAIL, '添加失败'); } - + if (is_array($car_brand_ids)) { + $carBrandData = []; + foreach ($car_brand_ids as $item) { + $carBrandData[] = [ + 'biz_id' => $id, + 'brand_id' => $item, + 'c_time' => time() + ]; + } + $carBrandData && $this->biz_car_brand_model->replace_batch($carBrandData); + } return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); } @@ -188,7 +207,7 @@ class Store extends HD_Controller $id = intval($this->input->post('id')); $company_id = intval($this->input->post('company_id', true)); $srv_company_id = intval($this->input->post('srv_company_id', true)); - + $car_brand_ids = $this->input->post('car_brand_ids'); $biz['biz_name'] = $this->input->post('biz_name', true); if (!$biz['biz_name']) { return $this->show_json(SYS_CODE_FAIL, '门店不能为空'); @@ -215,7 +234,19 @@ class Store extends HD_Controller if (!$res) { return $this->show_json(SYS_CODE_FAIL, '添加失败'); } - + if (is_array($car_brand_ids)) { + $carBrandData = []; + foreach ($car_brand_ids as $item) { + $carBrandData[] = [ + 'biz_id' => $id, + 'brand_id' => $item, + 'c_time' => time() + ]; + } + $carBrandData && $this->biz_car_brand_model->replace_batch($carBrandData); + } else { + $this->biz_car_brand_model->delete(['biz_id' => $id]); + } return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); } diff --git a/admin/views/biz/store/edit.php b/admin/views/biz/store/edit.php index a69dd215..d500138a 100644 --- a/admin/views/biz/store/edit.php +++ b/admin/views/biz/store/edit.php @@ -135,14 +135,15 @@