|
@@ -38,7 +38,7 @@ class GoodsService extends CrudService {
|
|
|
|
|
|
async indexGoodsList(condition, { skip = 0, limit = 20 } = {}) {
|
|
|
condition = this.dealFilter(condition);
|
|
|
- const pipline = [{ $match: { status: { $ne: '0' } } }];
|
|
|
+ const pipline = [{ $sort: { 'meta.createdAt': -1 } }, { $match: { status: { $ne: '0' } } }];
|
|
|
const { view_num, sell_num, sell_money, name, shop } = condition;
|
|
|
const sort = {};
|
|
|
if (view_num) sort.view_num = view_num;
|
|
@@ -60,7 +60,7 @@ class GoodsService extends CrudService {
|
|
|
// 按照规格平铺数据
|
|
|
pipline.push({ $unwind: '$specs' });
|
|
|
// 格式化平铺后的数据
|
|
|
- pipline.push({ $project: { name: 1, view_num: 1, sell_num: 1, file: 1, sell_money: { $toDouble: '$specs.sell_money' } } });
|
|
|
+ pipline.push({ $project: { name: 1, view_num: 1, sell_num: 1, file: 1, sell_money: { $toDouble: '$specs.sell_money' }, meta: 1 } });
|
|
|
pipline.push({
|
|
|
$group: {
|
|
|
_id: '$_id',
|
|
@@ -106,7 +106,7 @@ class GoodsService extends CrudService {
|
|
|
}
|
|
|
|
|
|
async searchActTagsGoods(act_tags, limit = 2) {
|
|
|
- const pipline = [{ $match: { status: { $ne: '0' }, act_tags } }];
|
|
|
+ const pipline = [{ $sort: { 'meta.createdAt': -1 } }, { $match: { status: { $ne: '0' }, act_tags } }];
|
|
|
pipline.push({ $project: { name: 1, file: 1 } });
|
|
|
if (parseInt(limit)) pipline.push({ $limit: parseInt(limit) });
|
|
|
const list = await this.goodsModel.aggregate(pipline);
|