refactor: 订单重构

This commit is contained in:
郝先瑞 2022-02-06 23:17:06 +08:00
parent 9de82688d7
commit 054697e11a

View File

@ -104,7 +104,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
CompletableFuture<Void> orderItemsCompletableFuture = CompletableFuture.runAsync(() -> { CompletableFuture<Void> orderItemsCompletableFuture = CompletableFuture.runAsync(() -> {
List<OrderItemDTO> orderItems = new ArrayList<>(); List<OrderItemDTO> orderItems = new ArrayList<>();
Long skuId = orderConfirmDTO.getSkuId(); Long skuId = orderConfirmDTO.getSkuId();
if (skuId != null) { // 直接购买商品结算 if (skuId != null) { // 直接购买商品
Result<SkuInfoDTO> getSkuInfoResult = skuFeignClient.getSkuInfo(orderConfirmDTO.getSkuId()); Result<SkuInfoDTO> getSkuInfoResult = skuFeignClient.getSkuInfo(orderConfirmDTO.getSkuId());
Assert.isTrue(Result.isSuccess(getSkuInfoResult), "获取商品信息失败"); Assert.isTrue(Result.isSuccess(getSkuInfoResult), "获取商品信息失败");
SkuInfoDTO skuInfoDTO = getSkuInfoResult.getData(); SkuInfoDTO skuInfoDTO = getSkuInfoResult.getData();
@ -119,8 +119,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
OrderItemDTO orderItemDTO = new OrderItemDTO(); OrderItemDTO orderItemDTO = new OrderItemDTO();
BeanUtil.copyProperties(cartItem, orderItemDTO); BeanUtil.copyProperties(cartItem, orderItemDTO);
return orderItemDTO; return orderItemDTO;
} })
)
.collect(Collectors.toList()); .collect(Collectors.toList());
orderItems.addAll(items); orderItems.addAll(items);
} }
@ -163,7 +162,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
// 订单验价 // 订单验价
Long currentTotalPrice = orderItems.stream().map(item -> { Long currentTotalPrice = orderItems.stream().map(item -> {
AppSkuDetailVO sku = goodsFeignClient.getSkuById(item.getSkuId()).getData(); SkuInfoDTO sku = skuFeignClient.getSkuInfo(item.getSkuId()).getData();
if (sku != null) { if (sku != null) {
return sku.getPrice() * item.getCount(); return sku.getPrice() * item.getCount();
} }
@ -180,9 +179,6 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
.build()) .build())
.collect(Collectors.toList()); .collect(Collectors.toList());
Result<AppSkuDetailVO> goodsResult = goodsFeignClient.getSkuById(1l);
System.out.println(goodsResult);
// 锁定库存 // 锁定库存
Result lockResult = skuFeignClient.lockStock(skuLockList); Result lockResult = skuFeignClient.lockStock(skuLockList);
Assert.isTrue(Result.isSuccess(lockResult), "锁定商品库存失败:{}", lockResult.getMsg()); Assert.isTrue(Result.isSuccess(lockResult), "锁定商品库存失败:{}", lockResult.getMsg());