Skip to content

Commit

Permalink
feat[litemall-wx-api, litemall-vue]: 优化下单逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
linlinjava committed Mar 30, 2022
1 parent ac81599 commit 79a09d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion litemall-vue/src/views/order/checkout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default {
onSubmit() {
const {AddressId, CartId, CouponId, UserCouponId} = getLocalStorage('AddressId', 'CartId', 'CouponId', 'UserCouponId');
if (AddressId === null) {
if (AddressId === null || AddressId === "0") {
Toast.fail('请设置收货地址');
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,10 @@ public Object checkout(@LoginUser Integer userId, Integer cartId, Integer addres

// 收货地址
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);
// 如果仍然没有地址,则是没有收货地址
// 返回一个空的地址id=0,这样前端则会提醒添加地址
Expand All @@ -424,13 +427,6 @@ public Object checkout(@LoginUser Integer userId, Integer cartId, Integer addres
} else {
addressId = checkedAddress.getId();
}

} else {
checkedAddress = addressService.query(userId, addressId);
// 如果null, 则报错
if (checkedAddress == null) {
return ResponseUtil.badArgumentValue();
}
}

// 团购优惠
Expand Down

0 comments on commit 79a09d7

Please sign in to comment.