lrf 2 年之前
父節點
當前提交
ea3bc3cb60
共有 1 個文件被更改,包括 3 次插入8 次删除
  1. 3 8
      app/service/user/userCoupon.js

+ 3 - 8
app/service/user/userCoupon.js

@@ -148,6 +148,7 @@ class UserCouponService extends CrudService {
       }
       uc.canUse = true;
     }
+    couponList = couponList.filter(f => f.canUse);
     if (couponList.length <= 0) return [];
     couponList = await this.makeShowData(couponList);
     return couponList;
@@ -229,14 +230,8 @@ class UserCouponService extends CrudService {
     const { discount_config = {} } = coupon;
     const limit = _.get(discount_config, 'limit');
     if (limit === 'nolimit') return true;
-    const goods_total = shopGoods.reduce((p, n) =>
-      this.ctx.plus(
-        p,
-        n.goods.reduce((gp, gn) =>
-          this.ctx.plus(gp, this.ctx.multiply(gn.sell_money, gn.buy_num)), 0)
-      )
-    , 0);
-    if (this.ctx.minus(goods_total, limit) > 0) return true;
+    const goods_total = shopGoods.reduce((p, n) => this.ctx.plus(this.ctx.plus(p, n.goods_total), n.freight_total), 0);
+    if (this.ctx.minus(goods_total, limit) >= 0) return true;
     return false;
 
   }