|
@@ -23,6 +23,7 @@ class OrderService extends CrudService {
|
|
|
this.orderUtil = this.ctx.service.util.order;
|
|
|
this.goodsConfigModel = this.ctx.model.Shop.GoodsConfig;
|
|
|
this.tran = new Transaction();
|
|
|
+ this.setModel = this.ctx.model.Shop.GoodsSet;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -250,6 +251,8 @@ class OrderService extends CrudService {
|
|
|
* @param {Array} actList 活动列表
|
|
|
*/
|
|
|
async dealAct(goodsList, actList) {
|
|
|
+ // 套装没活动,直接略过
|
|
|
+ if (actList.length <= 0) return;
|
|
|
// 活动根据类型有优先级设置,需要按优先级进行处理
|
|
|
// 特价(3)>满减(5)>满折(6)>加价购(4); 买赠(2)无所谓
|
|
|
const spActs = actList.filter(f => f.platform_act_type === '3');
|
|
@@ -281,7 +284,8 @@ class OrderService extends CrudService {
|
|
|
async getActList(data) {
|
|
|
const actList = [];
|
|
|
for (const i of data) {
|
|
|
- const { act = [], goodsSpec: spec } = i;
|
|
|
+ const { act = [], goodsSpec: spec, is_set = '1' } = i;
|
|
|
+ if (is_set !== '1') continue;
|
|
|
if (act.length <= 0) continue;
|
|
|
for (const a of act) {
|
|
|
let platformAct = await this.platformActModel.findById(a);
|
|
@@ -329,8 +333,6 @@ class OrderService extends CrudService {
|
|
|
const obj = { platform_act: platformAct._id, platform_act_type: type, discount };
|
|
|
const r = actList.find(f => _.isEqual(f, obj));
|
|
|
if (!r) actList.push(obj);
|
|
|
- } else if (type === '7') {
|
|
|
- // 套装先不考虑
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -394,8 +396,23 @@ class OrderService extends CrudService {
|
|
|
if (gs) gs = JSON.parse(JSON.stringify(gs));
|
|
|
if (cart_id) gs.cart_id = cart_id;
|
|
|
arr.push(gs);
|
|
|
+ } else {
|
|
|
+ // 套装信息
|
|
|
+ const setData = await this.setModel.findById(set_id).lean();
|
|
|
+ const { _id, set = [], sell_money, name } = setData;
|
|
|
+ const newSet = [];
|
|
|
+ const obj = { _id, name, sell_money, is_set: '0', num };
|
|
|
+ for (const s of set) {
|
|
|
+ const { goods, goods_name, spec, spec_name, set_num } = s;
|
|
|
+ const goodsData = await this.goodsModel.findById(goods, { file: 1 }).lean();
|
|
|
+ const specData = await this.goodsSpecModel.findById(spec, { file: 1 }).lean();
|
|
|
+ const file = [ ..._.get(specData, 'file', []), ..._.get(goodsData, 'file', []) ];
|
|
|
+ const newSetData = { goods_name, spec_name, file, set_num };
|
|
|
+ newSet.push(newSetData);
|
|
|
+ }
|
|
|
+ obj.set = newSet;
|
|
|
+ arr.push(obj);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
// 检测是否是团长,使用团长价格
|
|
|
const user = _.get(this.ctx, 'user');
|
|
@@ -403,6 +420,9 @@ class OrderService extends CrudService {
|
|
|
const is_leader = _.get(user, 'is_leader', '1');
|
|
|
if (is_leader === '0') {
|
|
|
for (const i of arr) {
|
|
|
+ const { is_set = '1' } = i;
|
|
|
+ // 套装不需要团长价格
|
|
|
+ if (is_set !== '1') continue;
|
|
|
if (i.leader_price) {
|
|
|
i.leader_price = this.ctx.toNumber(i.leader_price);
|
|
|
i.price = i.leader_price;
|