Browse Source

1、分类查询置顶排序;

Lawsun_M 1 year ago
parent
commit
1b14aff07a
1 changed files with 2 additions and 2 deletions
  1. 2 2
      app/controller/home/productCategory.js

+ 2 - 2
app/controller/home/productCategory.js

@@ -78,7 +78,7 @@ module.exports = class ProductCategoryController extends shopController {
         ],
         attributes: [ 'category_id', [ 'category_name', 'text' ]],
         // 2023/9/15 关联查询排序
-        order: [[ 'category_sort', 'asc' ], [ 'category_id', 'asc' ], [ 'products', 'is_hot', 'desc' ], [ 'products', 'is_new', 'desc' ], [ 'products', 'sale_count', 'desc' ]],
+        order: [[ 'category_sort', 'asc' ], [ 'category_id', 'asc' ], [ 'products', 'is_top', 'desc' ], [ 'products', 'is_hot', 'desc' ], [ 'products', 'is_new', 'desc' ], [ 'products', 'sale_count', 'desc' ]],
       };
       const selectBean = await that.app.comoBean.instance({}, opt);
       const result = await that.service.manager.select(selectBean, that.useModel, '商品列表查看失败,请重试', false, true);
@@ -100,7 +100,7 @@ module.exports = class ProductCategoryController extends shopController {
       const data = await that.ctx.validate(that.categoryValidate, await that.ctx.getParse());
       const options = {
         where: { category_id: data.category_id, is_sale: 1 },
-        order: [[ 'is_hot', 'desc' ], [ 'is_new', 'desc' ], [ 'sale_count', 'desc' ]], // , [ 'product_stock', 'desc' ]
+        order: [[ 'is_top', 'desc' ], [ 'is_hot', 'desc' ], [ 'is_new', 'desc' ], [ 'sale_count', 'desc' ]], // , [ 'product_stock', 'desc' ]
         // offset: (data.page - 1) * data.limit, limit: data.limit,
         attributes: [ 'product_id', 'category_id', 'product_name', 'product_image', 'shop_price', 'market_price', 'is_new', 'is_hot' ],
       };