Skip to content

Commit

Permalink
🐝 购物项数量验证逻辑修改
Browse files Browse the repository at this point in the history
  • Loading branch information
newbee-mall committed Feb 12, 2020
1 parent 04e230c commit 83a8086
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ public String saveNewBeeMallCartItem(NewBeeMallShoppingCartItem newBeeMallShoppi
if (newBeeMallGoods == null) {
return ServiceResultEnum.GOODS_NOT_EXIST.getResult();
}
int totalItem = newBeeMallShoppingCartItemMapper.selectCountByUserId(newBeeMallShoppingCartItem.getUserId());
//超出最大数量
if (totalItem > Constants.SHOPPING_CART_ITEM_LIMIT_NUMBER) {
int totalItem = newBeeMallShoppingCartItemMapper.selectCountByUserId(newBeeMallShoppingCartItem.getUserId()) + 1;
//超出单个商品的最大数量
if (newBeeMallShoppingCartItem.getGoodsCount() > Constants.SHOPPING_CART_ITEM_LIMIT_NUMBER) {
return ServiceResultEnum.SHOPPING_CART_ITEM_LIMIT_NUMBER_ERROR.getResult();
}
//超出最大数量
if (totalItem > Constants.SHOPPING_CART_ITEM_TOTAL_NUMBER) {
return ServiceResultEnum.SHOPPING_CART_ITEM_TOTAL_NUMBER_ERROR.getResult();
}
//保存记录
if (newBeeMallShoppingCartItemMapper.insertSelective(newBeeMallShoppingCartItem) > 0) {
return ServiceResultEnum.SUCCESS.getResult();
Expand All @@ -60,7 +64,7 @@ public String updateNewBeeMallCartItem(NewBeeMallShoppingCartItem newBeeMallShop
if (newBeeMallShoppingCartItemUpdate == null) {
return ServiceResultEnum.DATA_NOT_EXIST.getResult();
}
//超出最大数量
//超出单个商品的最大数量
if (newBeeMallShoppingCartItem.getGoodsCount() > Constants.SHOPPING_CART_ITEM_LIMIT_NUMBER) {
return ServiceResultEnum.SHOPPING_CART_ITEM_LIMIT_NUMBER_ERROR.getResult();
}
Expand Down

0 comments on commit 83a8086

Please sign in to comment.