mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2025-01-04 01:52:21 +08:00
refactor: 订单重构
This commit is contained in:
parent
9de82688d7
commit
054697e11a
@ -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();
|
||||||
@ -116,11 +116,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
|
|||||||
List<OrderItemDTO> items = cartItems.stream()
|
List<OrderItemDTO> items = cartItems.stream()
|
||||||
.filter(CartItemDTO::getChecked)
|
.filter(CartItemDTO::getChecked)
|
||||||
.map(cartItem -> {
|
.map(cartItem -> {
|
||||||
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());
|
||||||
|
Loading…
Reference in New Issue
Block a user