|
@@ -27,15 +27,36 @@ class PlatformActService extends CrudService {
|
|
|
rs = await this.afterQuery(filter, rs);
|
|
|
return rs;
|
|
|
}
|
|
|
-
|
|
|
- getActText(data) {
|
|
|
+ /**
|
|
|
+ * 获取设置
|
|
|
+ * @param {PlatformAct} data 活动数据
|
|
|
+ * @param {Goods} goods 商品数据
|
|
|
+ */
|
|
|
+ async getActText(data, goods) {
|
|
|
const { type } = data;
|
|
|
let tag = '';
|
|
|
let text = '';
|
|
|
+ const aboutList = [];
|
|
|
if (type === '2') {
|
|
|
tag = '赠品';
|
|
|
+ // 寻找赠品信息
|
|
|
+ const list = await this.gjaModel.find({ platform_act: data._id, 'goods._id': goods._id });
|
|
|
+ for (const i of list) {
|
|
|
+ const gift = _.get(i, 'config.gift', []);
|
|
|
+ const goods = _.get(i, 'goods._id');
|
|
|
+ const spec = _.get(i, 'spec._id');
|
|
|
+ aboutList.push({ goods, spec, gift });
|
|
|
+ }
|
|
|
} else if (type === '3') {
|
|
|
tag = '特价';
|
|
|
+ // 寻找商品的特价
|
|
|
+ const list = await this.gjaModel.find({ platform_act: data._id, 'goods._id': goods._id });
|
|
|
+ for (const i of list) {
|
|
|
+ const goods = _.get(i, 'goods._id');
|
|
|
+ const spec = _.get(i, 'spec._id');
|
|
|
+ const price = _.get(i, 'config.sp_price');
|
|
|
+ aboutList.push({ goods, spec, price });
|
|
|
+ }
|
|
|
} else if (type === '4') {
|
|
|
tag = '加价购';
|
|
|
} else if (type === '5') {
|
|
@@ -57,7 +78,7 @@ class PlatformActService extends CrudService {
|
|
|
} else if (type === '7') {
|
|
|
tag = '套装';
|
|
|
}
|
|
|
- return { tag, text };
|
|
|
+ return { tag, text, aboutList };
|
|
|
}
|
|
|
|
|
|
async beforeUpdate(filter, update) {
|