|
@@ -45,9 +45,35 @@ class OrderService extends CrudService {
|
|
const address = await this.addressModel.findOne({ customer, is_default: '1' });
|
|
const address = await this.addressModel.findOne({ customer, is_default: '1' });
|
|
pageData.address = address;
|
|
pageData.address = address;
|
|
// 商品总价,各店铺的价格明细
|
|
// 商品总价,各店铺的价格明细
|
|
|
|
+ specsData = this.computedShopTotal(specsData);
|
|
|
|
+ const shopTotalDetail = this.computedAllTotal(specsData);
|
|
pageData.goodsData = specsData;
|
|
pageData.goodsData = specsData;
|
|
|
|
+ pageData.orderTotal = shopTotalDetail;
|
|
return pageData;
|
|
return pageData;
|
|
}
|
|
}
|
|
|
|
+ /**
|
|
|
|
+ * 计算商店的结算
|
|
|
|
+ * @param {Array} list 按店铺分组的商品列表
|
|
|
|
+ */
|
|
|
|
+ computedShopTotal(list) {
|
|
|
|
+ for (const i of list) {
|
|
|
|
+ i.goods_total = i.goods.reduce((p, n) => p + (n.money || 0), 0);
|
|
|
|
+ i.freight_total = i.goods.reduce((p, n) => p + (n.freight || 0), 0);
|
|
|
|
+ }
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 计算订单的结算
|
|
|
|
+ * @param {Array} list 按店铺分组的商品列表
|
|
|
|
+ */
|
|
|
|
+ computedAllTotal(list) {
|
|
|
|
+ const obj = {
|
|
|
|
+ goods_total: list.reduce((p, n) => p + (n.goods_total || 0), 0),
|
|
|
|
+ freight_total: list.reduce((p, n) => p + (n.freight_total || 0), 0),
|
|
|
|
+ };
|
|
|
|
+ return obj;
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 单商品整理数据,需要商品与规格的快照,剩下的可以简略
|
|
* 单商品整理数据,需要商品与规格的快照,剩下的可以简略
|
|
@@ -70,7 +96,7 @@ class OrderService extends CrudService {
|
|
goods.money = _.get(i, 'sell_money');
|
|
goods.money = _.get(i, 'sell_money');
|
|
goods.num = num;
|
|
goods.num = num;
|
|
goods.file = _.get(i.goods, 'file');
|
|
goods.file = _.get(i.goods, 'file');
|
|
- obj.goods = goods;
|
|
|
|
|
|
+ obj.goods = [ goods ];
|
|
arr.push(obj);
|
|
arr.push(obj);
|
|
}
|
|
}
|
|
return arr;
|
|
return arr;
|