lrf 2 年之前
父節點
當前提交
4b1d46a70f
共有 1 個文件被更改,包括 12 次插入0 次删除
  1. 12 0
      app/service/trade/orderDetail.js

+ 12 - 0
app/service/trade/orderDetail.js

@@ -159,6 +159,18 @@ class OrderDetailService extends CrudService {
       const obj = { key: platform_act, zh: title, money: this.ctx.minus(0, discount) };
       tarr.push(obj);
     }
+    const discount_detail = _.get(total_detail, 'discount_detail', {});
+    const userCoupons = Object.keys(discount_detail);
+    if (userCoupons.length > 0) {
+      let dm = 0;
+      for (const uc_id of userCoupons) {
+        const detail = _.get(discount_detail, uc_id, {});
+        const values = Object.values(detail);
+        dm = values.reduce((p, n) => this.ctx.minus(p, n), dm);
+      }
+      tarr.push({ key: 'coupons', zh: '优惠券优惠', money: dm });
+    }
+
     return tarr;
   }