From 54320499e5b4aff3055dda5f20f459d2cd9a0383 Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 25 Jun 2021 10:17:58 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=B6=88=E6=81=AF=E5=AE=8C?= =?UTF-8?q?=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/controller/passport/MemberBuyerController.java | 6 +++--- .../src/main/java/cn/lili/common/enums/ResultCode.java | 3 ++- .../cn/lili/modules/order/cart/service/CartServiceImpl.java | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java index d909135c..a9981b3d 100644 --- a/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/passport/MemberBuyerController.java @@ -63,9 +63,9 @@ public class MemberBuyerController { public ResultMessage smsLogin(@NotNull(message = "手机号为空") @RequestParam String mobile, @NotNull(message = "验证码为空") @RequestParam String code, @RequestHeader String uuid) { - if(smsUtil.verifyCode(mobile,VerificationEnums.LOGIN,uuid,code)){ - return ResultUtil.data(memberService.mobilePhoneLogin(mobile)); - }else { + if (smsUtil.verifyCode(mobile, VerificationEnums.LOGIN, uuid, code)) { + return ResultUtil.data(memberService.mobilePhoneLogin(mobile)); + } else { throw new ServiceException("验证码错误"); } } diff --git a/framework/src/main/java/cn/lili/common/enums/ResultCode.java b/framework/src/main/java/cn/lili/common/enums/ResultCode.java index b23eb766..f0d99e42 100644 --- a/framework/src/main/java/cn/lili/common/enums/ResultCode.java +++ b/framework/src/main/java/cn/lili/common/enums/ResultCode.java @@ -51,7 +51,7 @@ public enum ResultCode { /** * 商品 */ - GOODS_ERROR(11010, "读取商品异常"), + GOODS_ERROR(11001, "商品异常,请稍后重试"), GOODS_NOT_EXIST(11001, "商品已下架"), GOODS_NAME_ERROR(11002, "商品名称不正确,名称应为2-50字符"), GOODS_UNDER_ERROR(11003, "商品下架失败"), @@ -63,6 +63,7 @@ public enum ResultCode { GOODS_SKU_COST_ERROR(11009, "商品SKU成本价不能小于等于0"), GOODS_SKU_WEIGHT_ERROR(11010, "商品重量不能为负数"), GOODS_SKU_QUANTITY_ERROR(11011, "商品库存数量不能为负数"), + GOODS_SKU_QUANTITY_NOT_ENOUGH(11011, "商品库存不足"), /** * 参数 diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index 4ccfd098..34b660de 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -360,17 +360,17 @@ public class CartServiceImpl implements CartService { private GoodsSku checkGoods(String skuId, Integer num) { GoodsSku dataSku = this.goodsSkuService.getGoodsSkuByIdFromCache(skuId); if (dataSku == null) { - throw new ServiceException("商品已失效,请重新选购!"); + throw new ServiceException(ResultCode.GOODS_NOT_EXIST); } if (!GoodsAuthEnum.PASS.name().equals(dataSku.getIsAuth()) || !GoodsStatusEnum.UPPER.name().equals(dataSku.getMarketEnable())) { - throw new ServiceException("商品已下架,请重新选购!"); + throw new ServiceException(ResultCode.GOODS_NOT_EXIST); } //读取sku的可用库存 Integer enableQuantity = goodsSkuService.getStock(skuId); //如果sku的可用库存小于等于0或者小于用户购买的数量,则不允许购买 if (enableQuantity <= 0 || enableQuantity < num) { - throw new ServiceException("商品库存已不足,请选购其他商品。"); + throw new ServiceException(ResultCode.GOODS_SKU_QUANTITY_NOT_ENOUGH); } return dataSku; }