|
@@ -15,6 +15,7 @@ class OrderDetailService extends CrudService {
|
|
|
this.userCouponModel = this.ctx.model.User.UserCoupon;
|
|
|
this.goodsRateModel = this.ctx.model.Shop.GoodsRate;
|
|
|
this.afterSaleModel = this.ctx.model.Trade.AfterSale;
|
|
|
+ this.platformActModel = this.ctx.model.System.PlatformAct;
|
|
|
this.tran = new Transaction();
|
|
|
}
|
|
|
async searchOrderTransport({ id, goods_id }) {
|
|
@@ -139,9 +140,28 @@ class OrderDetailService extends CrudService {
|
|
|
} else g.is_rate = false;
|
|
|
}
|
|
|
res.goods = goods;
|
|
|
+ // 整理total_detail为列表:让前端显示更方便
|
|
|
+ const total_detail = _.get(res, 'total_detail', {});
|
|
|
+ res.total_detail = await this.fetchResetTotalDetail(total_detail);
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ async fetchResetTotalDetail(total_detail) {
|
|
|
+ const tarr = [];
|
|
|
+ if (_.isNumber(_.get(total_detail, 'goods_total', 0))) tarr.push({ key: 'goods_total', zh: '商品总价', money: _.get(total_detail, 'goods_total', 0) });
|
|
|
+ if (_.isNumber(_.get(total_detail, 'freight_total', 0))) tarr.push({ key: 'freight_total', zh: '运费总价', money: _.get(total_detail, 'freight_total', 0) });
|
|
|
+ const act = _.get(total_detail, 'act', []);
|
|
|
+ for (const a of act) {
|
|
|
+ const { platform_act, platform_act_type, discount } = a;
|
|
|
+ const text = `满${platform_act_type === '6' ? '折' : '减'}活动`;
|
|
|
+ const actData = await this.platformActModel.findById(platform_act);
|
|
|
+ const title = _.get(actData, 'act_time.title', text);
|
|
|
+ const obj = { key: platform_act, zh: title, money: this.ctx.minus(0, discount) };
|
|
|
+ tarr.push(obj);
|
|
|
+ }
|
|
|
+ return tarr;
|
|
|
+ }
|
|
|
+
|
|
|
async query(filter, { skip = 0, limit, sort, desc, projection } = {}) {
|
|
|
// 处理排序
|
|
|
if (sort && _.isString(sort)) {
|