use of com.whoiszxl.bean.ResponseResult in project shopzz by whoiszxl.
the class OrderServiceImpl method getOrderConfirmData.
@Override
public OrderConfirmVO getOrderConfirmData() {
OrderConfirmVO result = new OrderConfirmVO();
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
CompletableFuture<Void> itemAndStockFuture = CompletableFuture.supplyAsync(() -> {
RequestContextHolder.setRequestAttributes(requestAttributes);
// 1. 获取购物车中所有的选中的sku商品
ResponseResult<List<CartDTO>> cartResult = cartFeignClient.getCheckedCartItem();
List<CartDTO> checkedCartList = cartResult.getData();
result.setCheckItem(checkedCartList);
return checkedCartList;
}, executor).thenAcceptAsync(checkedCartList -> {
RequestContextHolder.setRequestAttributes(requestAttributes);
// 2. 获取库存信息
List<Long> skuIds = checkedCartList.stream().map(CartDTO::getSkuId).collect(Collectors.toList());
ResponseResult<List<InventorySkuDTO>> stockResult = inventoryFeignClient.getSaleStockQuantity(skuIds);
List<InventorySkuDTO> stockSkuList = stockResult.getData();
Map<Long, Integer> stock = stockSkuList.stream().collect(Collectors.toMap(InventorySkuDTO::getSkuId, InventorySkuDTO::getQuantity));
result.setStocks(stock);
}, executor);
// 3. 获取所有收货地址
CompletableFuture<Void> addressFuture = CompletableFuture.runAsync(() -> {
RequestContextHolder.setRequestAttributes(requestAttributes);
List<MemberAddressDTO> addressList = memberFeignClient.listMemberAddress();
result.setMemberAddressDTOS(addressList);
}, executor);
// 4. 获取优惠券信息
CompletableFuture<Void> couponFuture = CompletableFuture.runAsync(() -> {
RequestContextHolder.setRequestAttributes(requestAttributes);
List<MemberCouponDTO> myCouponList = promotionFeignClient.getMyCoupon();
result.setMyCoupons(myCouponList);
}, executor);
// 8. 执行异步任务
try {
CompletableFuture.allOf(itemAndStockFuture, addressFuture, couponFuture).get();
} catch (Exception e) {
log.error("获取确认订单界面数据失败", e);
}
return result;
}
use of com.whoiszxl.bean.ResponseResult in project shopzz by whoiszxl.
the class OrderFeignClientImpl method notifyDcPaySuccess.
@Override
public ResponseResult<Boolean> notifyDcPaySuccess(List<Long> orderIds) {
// 1. 更新订单到发货状态
List<Order> orderList = orderIds.stream().map(orderId -> {
Order order = new Order();
order.setId(orderId);
order.setOrderStatus(OrderStatusConstants.WAIT_FOR_DELIVERY);
order.setUpdatedBy("admin");
return order;
}).collect(Collectors.toList());
boolean updateFlag = orderService.updateBatchById(orderList);
for (Long orderId : orderIds) {
OrderInfoDTO orderInfo = orderService.getOrderInfo(orderId);
// 2. 清空购物车
ResponseResult<Boolean> clearCartResult = cartFeignClient.clearCheckedCartByMemberId(orderInfo.getMemberId());
if (!clearCartResult.getData()) {
log.error("下单成功,但是清空购物车失败了");
}
// 3. 通知库存中心更新库存
inventoryFeignClient.notifyPayOrderEvent(orderInfo);
// 4. 通知WMS订单支付成功,更新WMS中心库存,WMS新增出库单
wmsFeignClient.notifyPayOrderSuccess(orderInfo);
// 5. 更新会员中心等级与积分
memberFeignClient.notifyPayOrderSuccess(orderInfo.getMemberId(), orderInfo.getTotalAmount());
}
return ResponseResult.buildByFlag(updateFlag);
}
Aggregations