|
@@ -17,6 +17,7 @@ class GoodsService extends CrudService {
|
|
this.gjaModel = this.ctx.model.Shop.GoodsJoinAct;
|
|
this.gjaModel = this.ctx.model.Shop.GoodsJoinAct;
|
|
this.actTagsModel = this.ctx.model.System.ActTags;
|
|
this.actTagsModel = this.ctx.model.System.ActTags;
|
|
this.goodsConfigModel = this.ctx.model.Shop.GoodsConfig;
|
|
this.goodsConfigModel = this.ctx.model.Shop.GoodsConfig;
|
|
|
|
+ this.userModel = this.ctx.model.User.User;
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
*
|
|
*
|
|
@@ -159,23 +160,24 @@ class GoodsService extends CrudService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
data.act = _.uniqBy(data.act, '_id');
|
|
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') {
|
|
|
|
- if (is_leader === '0') {
|
|
|
|
- data.specs = data.specs.map(i => {
|
|
|
|
- const { sell_money, leader_price } = i;
|
|
|
|
- const sm = this.ctx.toNumber(sell_money);
|
|
|
|
- const obj = { o_sell_money: sm };
|
|
|
|
- if (leader_price) {
|
|
|
|
- const lp = this.ctx.toNumber(leader_price);
|
|
|
|
- obj.leader_price = lp;
|
|
|
|
- obj.sell_money = lp;
|
|
|
|
- }
|
|
|
|
- return { ...i, ...obj };
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
+ const user_id = _.get(this.ctx, 'user._id');
|
|
|
|
+ if (user_id) {
|
|
|
|
+ // 检查团长价格
|
|
|
|
+ const is_leader = await this.ctx.service.user.user.getUserIsLeader(user_id);
|
|
|
|
+ if (is_leader) {
|
|
|
|
+ data.specs = data.specs.map(i => {
|
|
|
|
+ const { sell_money, leader_price } = i;
|
|
|
|
+ const sm = this.ctx.toNumber(sell_money);
|
|
|
|
+ const obj = { o_sell_money: sm };
|
|
|
|
+ if (leader_price) {
|
|
|
|
+ const lp = this.ctx.toNumber(leader_price);
|
|
|
|
+ obj.leader_price = lp;
|
|
|
|
+ obj.sell_money = lp;
|
|
|
|
+ }
|
|
|
|
+ return { ...i, ...obj };
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ data.specs = data.specs.map(i => _.omit(i, [ 'leader_price' ]));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return data;
|
|
return data;
|
|
@@ -263,11 +265,19 @@ class GoodsService extends CrudService {
|
|
const platformActList = await this.platformActModel.find({ is_use: '0', type: [ '2', '3', '5', '6' ] });
|
|
const platformActList = await this.platformActModel.find({ is_use: '0', type: [ '2', '3', '5', '6' ] });
|
|
await this.getAboutAct(platformActList, list);
|
|
await this.getAboutAct(platformActList, list);
|
|
// 检查团长价格
|
|
// 检查团长价格
|
|
- const user = _.get(this.ctx, 'user');
|
|
|
|
- if (user) {
|
|
|
|
- const is_leader = _.get(user, 'is_leader', '1');
|
|
|
|
- if (is_leader === '1') {
|
|
|
|
- list = list.map(i => _.omit(i, [ 'leader_price' ]));
|
|
|
|
|
|
+ const user_id = _.get(this.ctx, 'user._id');
|
|
|
|
+ const is_leader = await this.ctx.service.user.user.getUserIsLeader(user_id);
|
|
|
|
+ if (!is_leader) {
|
|
|
|
+ list = list.map(i => _.omit(i, [ 'leader_price' ]));
|
|
|
|
+ } else {
|
|
|
|
+ for (const i of list) {
|
|
|
|
+ const { leader_price, _id: goods } = i;
|
|
|
|
+ if (leader_price) continue;
|
|
|
|
+ let specs = await this.goodsSpecModel.find({ goods, leader_price: { $gt: 0 } }, { leader_price: 1 }).lean();
|
|
|
|
+ specs = _.orderBy(specs, [ 'leader_price' ], [ 'asc' ]);
|
|
|
|
+ const head = _.head(specs);
|
|
|
|
+ i.leader_price = this.ctx.toNumber(_.get(head, 'leader_price', 0));
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
const tpipeline = _.cloneDeep(pipeline);
|
|
const tpipeline = _.cloneDeep(pipeline);
|