Browse Source

feat[litemall-wx-api, litemall-vue]: 优化下单逻辑

linlinjava 3 years ago
parent
commit
79a09d7af7

+ 1 - 1
litemall-vue/src/views/order/checkout.vue

@@ -107,7 +107,7 @@ export default {
     onSubmit() {     
     onSubmit() {     
       const {AddressId, CartId, CouponId, UserCouponId} = getLocalStorage('AddressId', 'CartId', 'CouponId', 'UserCouponId');
       const {AddressId, CartId, CouponId, UserCouponId} = getLocalStorage('AddressId', 'CartId', 'CouponId', 'UserCouponId');
 
 
-      if (AddressId === null) {
+      if (AddressId === null || AddressId === "0") {
         Toast.fail('请设置收货地址');
         Toast.fail('请设置收货地址');
         return;
         return;
       }
       }

+ 4 - 8
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCartController.java

@@ -413,7 +413,10 @@ public class WxCartController {
 
 
         // 收货地址
         // 收货地址
         LitemallAddress checkedAddress = null;
         LitemallAddress checkedAddress = null;
-        if (addressId == null || addressId.equals(0)) {
+        if (addressId != null && !addressId.equals(0)) {
+            checkedAddress = addressService.query(userId, addressId);
+        }
+        if (checkedAddress == null) {
             checkedAddress = addressService.findDefault(userId);
             checkedAddress = addressService.findDefault(userId);
             // 如果仍然没有地址,则是没有收货地址
             // 如果仍然没有地址,则是没有收货地址
             // 返回一个空的地址id=0,这样前端则会提醒添加地址
             // 返回一个空的地址id=0,这样前端则会提醒添加地址
@@ -424,13 +427,6 @@ public class WxCartController {
             } else {
             } else {
                 addressId = checkedAddress.getId();
                 addressId = checkedAddress.getId();
             }
             }
-
-        } else {
-            checkedAddress = addressService.query(userId, addressId);
-            // 如果null, 则报错
-            if (checkedAddress == null) {
-                return ResponseUtil.badArgumentValue();
-            }
         }
         }
 
 
         // 团购优惠
         // 团购优惠