|
@@ -46,7 +46,6 @@ class OrderService extends CrudService {
|
|
|
i.goods_total = this.ctx.multiply(num, sell_money);
|
|
|
i.freight_total = this.ctx.multiply(num, freight);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
@@ -164,8 +163,16 @@ class OrderService extends CrudService {
|
|
|
** platform_act:活动金额
|
|
|
** }]
|
|
|
** at: 活动优惠总金额
|
|
|
+ ** },
|
|
|
+ ** 套装id:{
|
|
|
+ ** sm: 套装正常销售价格(sell_money),
|
|
|
+ ** f: 套装运费(freight),
|
|
|
+ ** bn: 购买数量(buy_num),
|
|
|
+ ** st: 套装正常销售总价(sell_total: sm * bn)
|
|
|
+ ** ft: 套装运费总价(freight_total: f * bn)
|
|
|
+ ** gt: 套装支付原价(goods_total: st + ft)
|
|
|
** }
|
|
|
- ** }
|
|
|
+ ** },
|
|
|
** }
|
|
|
*/
|
|
|
moneyDetail(data) {
|
|
@@ -174,32 +181,49 @@ class OrderService extends CrudService {
|
|
|
const ddt = _.get(data, 'total_detail.discount_detail', {});
|
|
|
// 店铺规格商品数据
|
|
|
const shopGoods = _.get(data, 'goods', []);
|
|
|
+ const groupShop = _.groupBy(shopGoods, 'shop');
|
|
|
const result = {};
|
|
|
- for (const s of shopGoods) {
|
|
|
- const { goods, shop } = s;
|
|
|
+ for (const shop_id in groupShop) {
|
|
|
+ const list = groupShop[shop_id];
|
|
|
const shopResult = {};
|
|
|
- for (const g of goods) {
|
|
|
- const { sell_money, freight: f, buy_num: bn, _id, act: ad = [] } = g;
|
|
|
- // 优先获取price字段,没有再取sell_money
|
|
|
- const sm = _.get(g, 'price', sell_money);
|
|
|
- const st = this.ctx.multiply(sm, bn);
|
|
|
- const ft = this.ctx.multiply(f, bn);
|
|
|
- const gt = this.ctx.plus(st, ft);
|
|
|
- // 优惠券部分
|
|
|
- const dd = {};
|
|
|
- for (const uc_id in ddt) {
|
|
|
- const detail = _.get(ddt, uc_id, {});
|
|
|
- const value = detail[_id];
|
|
|
- if (value) dd[uc_id] = value;
|
|
|
+ for (const s of list) {
|
|
|
+ const { is_set = '1' } = s;
|
|
|
+ if (is_set === '1') {
|
|
|
+ const { goods } = s;
|
|
|
+ for (const g of goods) {
|
|
|
+ const { sell_money, freight: f, buy_num: bn, _id, act: ad = [] } = g;
|
|
|
+ // 优先获取price字段,没有再取sell_money
|
|
|
+ const sm = _.get(g, 'price', sell_money);
|
|
|
+ const st = this.ctx.multiply(sm, bn);
|
|
|
+ const ft = this.ctx.multiply(f, bn);
|
|
|
+ const gt = this.ctx.plus(st, ft);
|
|
|
+ // 优惠券部分
|
|
|
+ const dd = {};
|
|
|
+ for (const uc_id in ddt) {
|
|
|
+ const detail = _.get(ddt, uc_id, {});
|
|
|
+ const value = detail[_id];
|
|
|
+ if (value) dd[uc_id] = value;
|
|
|
+ }
|
|
|
+ const dt = Object.values(dd).reduce((p, n) => this.ctx.plus(p, n), 0);
|
|
|
+ // 活动部分
|
|
|
+ const at = ad.reduce((p, n) => this.ctx.plus(p, n.discount), 0);
|
|
|
+ const grp = this.ctx.minus(this.ctx.minus(gt, dt), at);
|
|
|
+ const obj = { sm, f, bn, st, ft, gt, dd, dt, grp, ad, at };
|
|
|
+ shopResult[_id] = obj;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const { freight, sell_money, buy_num, set_id } = s;
|
|
|
+ const sm = sell_money,
|
|
|
+ f = freight,
|
|
|
+ bn = buy_num,
|
|
|
+ st = this.ctx.multiply(sm, bn),
|
|
|
+ ft = this.ctx.multiply(f, bn),
|
|
|
+ gt = this.ctx.plus(ft, st),
|
|
|
+ grp = gt;
|
|
|
+ shopResult[set_id] = { sm, f, bn, st, ft, gt, grp };
|
|
|
}
|
|
|
- const dt = Object.values(dd).reduce((p, n) => this.ctx.plus(p, n), 0);
|
|
|
- // 活动部分
|
|
|
- const at = ad.reduce((p, n) => this.ctx.plus(p, n.discount), 0);
|
|
|
- const grp = this.ctx.minus(this.ctx.minus(gt, dt), at);
|
|
|
- const obj = { sm, f, bn, st, ft, gt, dd, dt, grp, ad, at };
|
|
|
- shopResult[_id] = obj;
|
|
|
}
|
|
|
- result[shop] = shopResult;
|
|
|
+ result[shop_id] = shopResult;
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
@@ -256,7 +280,6 @@ class OrderService extends CrudService {
|
|
|
data.set_id = i.set_id;
|
|
|
goodsData.push(data);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
return { actList, goodsSpecs, goodsData };
|
|
|
}
|