From dbc9e8b2044caed96dcea135ad6ec0b1e77b6342 Mon Sep 17 00:00:00 2001 From: lcc <805383944@qq.com> Date: Wed, 15 Oct 2025 10:13:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=A7=E5=93=81=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=20&&=20=E4=BA=A7=E5=93=81=E4=B8=8A=E6=9E=B6=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agent/admin/controllers/api/car/Product.php | 30 +++++++++++++++++-- agent/admin/controllers/auto/car/Product.php | 2 +- common/libraries/entity/AutoProductEntity.php | 2 ++ common/models/agent/Auto_product_model.php | 1 + 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/agent/admin/controllers/api/car/Product.php b/agent/admin/controllers/api/car/Product.php index c541fdbf..5f9daeed 100644 --- a/agent/admin/controllers/api/car/Product.php +++ b/agent/admin/controllers/api/car/Product.php @@ -44,7 +44,7 @@ class Product extends BaseController $params['priceRange'] && $labelIdArray = array_merge($labelIdArray, $params['priceRange']); $params['carProductLabel'] && $labelIdArray = array_merge($labelIdArray, $params['carProductLabel']); $params['productLevel'] && $labelIdArray = array_merge($labelIdArray, $params['productLevel']); - if($labelIdArray){ + if ($labelIdArray) { $countLabelIds = count($labelIdArray); $labelIdString = implode(',', $labelIdArray); $where["lc_auto_product.id in (SELECT product_id @@ -123,9 +123,17 @@ class Product extends BaseController { $id = $this->input_param('id'); $status = $this->input_param('status'); - if (!$this->autoProduct->get(['id' => $id])) { + /** @var AutoProductEntity $row */ + $row = $this->autoProduct->get(['id' => $id], 'AutoProductEntity'); + if (!$row) { $this->return_json('参数错误'); } + if (!$row->banner) { + $this->return_json('产品缩略图未上传'); + } + if (!$row->imgs) { + $this->return_json('产品轮播图未上传'); + } $update = [ 'status' => $status, ]; @@ -168,6 +176,7 @@ class Product extends BaseController $this->autoProduct->update($update, ['id' => $params['id']]); $this->return_response(); } + /** * 修改CPS金额 */ @@ -183,4 +192,21 @@ class Product extends BaseController $this->autoProduct->update($update, ['id' => $params['id']]); $this->return_response(); } + + /** + * 修改状态 + */ + public function sort_put() + { + $id = $this->input_param('id'); + $sort = $this->input_param('sort'); + if (!$this->autoProduct->get(['id' => $id])) { + $this->return_json('参数错误'); + } + $update = [ + 'sort' => intval($sort), + ]; + $this->autoProduct->update($update, ['id' => $id]); + $this->return_response([], '保存成功'); + } } diff --git a/agent/admin/controllers/auto/car/Product.php b/agent/admin/controllers/auto/car/Product.php index bd611d14..edf077f8 100644 --- a/agent/admin/controllers/auto/car/Product.php +++ b/agent/admin/controllers/auto/car/Product.php @@ -50,7 +50,7 @@ class Product extends BaseController } $count = $this->autoProduct->selectProductCount($where); if ($count) { - $res = $this->autoProduct->selectProduct($where, 'id desc', $page, $limit, '', 'AutoProductEntity'); + $res = $this->autoProduct->selectProduct($where, 'sort desc,id desc', $page, $limit, '', 'AutoProductEntity'); /** @var AutoProductEntity[] $res */ foreach ($res as $v) { $temp = [ diff --git a/common/libraries/entity/AutoProductEntity.php b/common/libraries/entity/AutoProductEntity.php index 31717962..145db61d 100644 --- a/common/libraries/entity/AutoProductEntity.php +++ b/common/libraries/entity/AutoProductEntity.php @@ -21,6 +21,8 @@ class AutoProductEntity public $createTime; public $cpsMoney; + public $sort; + //扩展信息 public $guide_price; //指导价 public $discounts; //优惠信息 diff --git a/common/models/agent/Auto_product_model.php b/common/models/agent/Auto_product_model.php index 12db0acd..fef87d38 100644 --- a/common/models/agent/Auto_product_model.php +++ b/common/models/agent/Auto_product_model.php @@ -61,6 +61,7 @@ class Auto_product_model extends HD_Model ]; $addData['brandId'] = $params['selectedCar']['brandId'] ?: 0; $addData['seriesId'] = $params['selectedCar']['seriesId'] ?: 0; + $addData['sort'] = $params['sort'] ?: 0; if ($params['id']) { $result = $this->update($addData, ['id' => $params['id']]); } else {