@@ -107,6 +107,16 @@ class OrderService extends CrudService {
}
+ async afterQuery(filter, data) {
+ data = JSON.parse(JSON.stringify(data));
+ for (const i of data) {
+ const { goods } = i;
+ const buy_num_total = goods.reduce((p, n) => this.ctx.plus(p, n.goods.reduce((np, ng) => this.ctx.plus(np, ng.buy_num), 0)), 0);
+ i.buy_num_total = buy_num_total;
+ }
+ return data;
+
/**
* 取消订单(支付前)
* @param {Object} body 参数体
@@ -89,6 +89,16 @@ class OrderDetailService extends CrudService {
res = await this.afterFetch(filter, res);
return res;
+ const buy_num_total = goods.reduce((p, n) => this.ctx.plus(p, n.buy_num), 0);
module.exports = OrderDetailService;