Browse Source

fix[litemall-wx-api]: 下单时存在传递不合适的优惠券的情况,此时后端自动选择合适的优惠券。

Junling Bu 6 years ago
parent
commit
b252cf2b5b

+ 6 - 3
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCartController.java

@@ -466,11 +466,14 @@ public class WxCartController {
         }
         else {
             LitemallCoupon coupon = couponVerifyService.checkCoupon(userId, couponId, checkedGoodsPrice);
-            // 用户选择的优惠券有问题
+            // 用户选择的优惠券有问题,则选择合适优惠券,否则使用用户选择的优惠券
             if(coupon == null){
-                return ResponseUtil.badArgumentValue();
+                couponPrice = tmpCouponPrice;
+                couponId = tmpCouponId;
+            }
+            else {
+                couponPrice = coupon.getDiscount();
             }
-            couponPrice = coupon.getDiscount();
         }
 
         // 根据订单商品总价计算运费,满88则免运费,否则8元;