增加产品排序 && 产品上架判断

This commit is contained in:
lcc
2025-10-15 10:13:45 +08:00
parent ad81194598
commit dbc9e8b204
4 changed files with 32 additions and 3 deletions
+28 -2
View File
@@ -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([], '保存成功');
}
}
+1 -1
View File
@@ -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 = [
@@ -21,6 +21,8 @@ class AutoProductEntity
public $createTime;
public $cpsMoney;
public $sort;
//扩展信息
public $guide_price; //指导价
public $discounts; //优惠信息
@@ -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 {