|
@@ -12,6 +12,7 @@ class GoodsService extends CrudService {
|
|
|
this.goodsModel = this.ctx.model.Shop.Goods;
|
|
|
this.goodsSpecModel = this.ctx.model.Shop.GoodsSpec;
|
|
|
this.gjaModel = this.ctx.model.Shop.GoodsJoinAct;
|
|
|
+ this.goodsTagsModel = this.ctx.model.System.GoodsTags;
|
|
|
}
|
|
|
/**
|
|
|
*
|
|
@@ -22,6 +23,16 @@ class GoodsService extends CrudService {
|
|
|
assert(id, '缺少商品信息');
|
|
|
const pipeline = [{ $match: { _id: ObjectId(id) } }];
|
|
|
const goodsProject = { file: 1, tags: 1, name: 1, shot_brief: 1, brief: 1, send_time: 1, shop: 1, view_num: 1, act_tags: 1 };
|
|
|
+ // 将 活动标签都进行数据替换
|
|
|
+ pipeline.push({
|
|
|
+ $lookup: {
|
|
|
+ from: 'actTags',
|
|
|
+ localField: 'act_tags',
|
|
|
+ foreignField: 'value',
|
|
|
+ pipeline: [{ $project: { label: 1 } }],
|
|
|
+ as: 'act_tags',
|
|
|
+ },
|
|
|
+ });
|
|
|
// 找店铺信息
|
|
|
pipeline.push({ $addFields: { shop_id: { $toObjectId: '$shop' } } });
|
|
|
pipeline.push({
|
|
@@ -119,6 +130,15 @@ class GoodsService extends CrudService {
|
|
|
const res = await this.goodsModel.aggregate(pipeline);
|
|
|
let data = _.head(res);
|
|
|
if (data) data = JSON.parse(JSON.stringify(data));
|
|
|
+ if (data.goods.tags.length > 0) {
|
|
|
+ const nt = [];
|
|
|
+ for (const t of data.goods.tags) {
|
|
|
+ const code = _.last(t);
|
|
|
+ const data = await this.goodsTagsModel.findOne({ code }, 'label');
|
|
|
+ nt.push(data);
|
|
|
+ }
|
|
|
+ data.goods.tags = nt;
|
|
|
+ }
|
|
|
for (const d of data.act) {
|
|
|
const { tag, text } = this.ctx.service.system.platformAct.getActText(d);
|
|
|
d.text = text;
|