|
@@ -16,6 +16,7 @@ class GoodsService extends CrudService {
|
|
|
this.platformActModel = this.ctx.model.System.PlatformAct;
|
|
|
this.gjaModel = this.ctx.model.Shop.GoodsJoinAct;
|
|
|
this.actTagsModel = this.ctx.model.System.ActTags;
|
|
|
+ this.goodsConfigModel = this.ctx.model.Shop.GoodsConfig;
|
|
|
}
|
|
|
/**
|
|
|
*
|
|
@@ -157,6 +158,22 @@ class GoodsService extends CrudService {
|
|
|
}
|
|
|
}
|
|
|
data.act = _.uniqBy(data.act, '_id');
|
|
|
+ const user = _.get(this.ctx, 'user');
|
|
|
+ if (user) {
|
|
|
+ const is_leader = _.get(user, 'is_leader', '1');
|
|
|
+ if (is_leader === '0') {
|
|
|
+ const list = await this.goodsConfigModel.find({ goods: id }).lean();
|
|
|
+ for (const i of list) {
|
|
|
+ const { spec, leader_price } = i;
|
|
|
+ const r = data.specs.find(f => f._id === spec);
|
|
|
+ if (r) {
|
|
|
+ r.o_sell_money = JSON.parse(r.sell_money);
|
|
|
+ r.leader_price = leader_price;
|
|
|
+ r.sell_money = leader_price;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return data;
|
|
|
}
|
|
|
|
|
@@ -238,9 +255,18 @@ class GoodsService extends CrudService {
|
|
|
// 只找: 买赠;特价;满减/折; 特价需要修改价格; 剩下的打标签
|
|
|
const platformActList = await this.platformActModel.find({ is_use: '0', type: [ '2', '3', '5', '6' ] });
|
|
|
await this.getAboutAct(platformActList, list);
|
|
|
+ // 检查团长价格
|
|
|
+ const user = _.get(this.ctx, 'user');
|
|
|
+ if (user) {
|
|
|
+ const is_leader = _.get(user, 'is_leader', '1');
|
|
|
+ if (is_leader === '0') {
|
|
|
+ list = await this.searchLeaderPrice(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
const tpipeline = _.cloneDeep(pipeline);
|
|
|
tpipeline.push({ $count: 'total' });
|
|
|
const total = await this.goodsModel.aggregate(tpipeline);
|
|
|
+
|
|
|
return { list, total: _.get(_.head(total), 'total', 0) };
|
|
|
}
|
|
|
|
|
@@ -325,6 +351,16 @@ class GoodsService extends CrudService {
|
|
|
const list = await this.goodsModel.aggregate(pipeline);
|
|
|
return list;
|
|
|
}
|
|
|
+
|
|
|
+ async searchLeaderPrice(list) {
|
|
|
+ for (const i of list) {
|
|
|
+ const { _id: goods } = i;
|
|
|
+ let gcl = await this.goodsConfigModel.find({ goods }).lean();
|
|
|
+ gcl = _.orderBy(gcl, [ 'leader_price' ], [ 'asc' ]);
|
|
|
+ i.leader_price = _.get(_.head(gcl), 'leader_price');
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
module.exports = GoodsService;
|