refactor(OrderServiceImpl.java): 商品锁库存响应判断优化

This commit is contained in:
有来技术 2021-08-17 00:47:11 +08:00
parent 2a1c6e1b94
commit ca80bf71ed

View File

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
@ -21,6 +22,7 @@ import com.github.binarywang.wxpay.service.WxPayService;
import com.youlai.common.enums.BusinessTypeEnum; import com.youlai.common.enums.BusinessTypeEnum;
import com.youlai.common.redis.component.BusinessNoGenerator; import com.youlai.common.redis.component.BusinessNoGenerator;
import com.youlai.common.result.Result; import com.youlai.common.result.Result;
import com.youlai.common.result.ResultCode;
import com.youlai.common.web.exception.BizException; import com.youlai.common.web.exception.BizException;
import com.youlai.common.web.util.JwtUtils; import com.youlai.common.web.util.JwtUtils;
import com.youlai.mall.oms.config.WxPayProperties; import com.youlai.mall.oms.config.WxPayProperties;
@ -188,8 +190,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
Result<SkuDTO> goodsResult = goodsFeignClient.getSkuById(1l); Result<SkuDTO> goodsResult = goodsFeignClient.getSkuById(1l);
System.out.println(goodsResult); System.out.println(goodsResult);
// 锁定库存
Result<Boolean> lockResult = stockFeignClient.lockStock(skuLockList); Result<Boolean> lockResult = stockFeignClient.lockStock(skuLockList);
Assert.isTrue(Result.success().getCode().equals(lockResult.getCode()), "锁定商品库存失败:{}", lockResult.getMsg()); Assert.isTrue(Result.isSuccess(lockResult), "锁定商品库存失败:{}", lockResult.getMsg());
// 创建订单(状态待支付) // 创建订单(状态待支付)
OmsOrder order = new OmsOrder(); OmsOrder order = new OmsOrder();