Search in sources :

Example 1 with OrderInfoDTO

use of com.whoiszxl.dto.OrderInfoDTO in project shopzz by whoiszxl.

the class PayOrderStockUpdaterFactory method createCommand.

@Override
protected StockUpdater createCommand(T parameter) {
    OrderInfoDTO orderInfoDTO = (OrderInfoDTO) parameter;
    Map<Long, OrderItemDTO> orderItemDTOMap = new HashMap<>(100);
    for (OrderItemDTO orderItemDTO : orderInfoDTO.getOrderItemDTOList()) {
        orderItemDTOMap.put(orderItemDTO.getSkuId(), orderItemDTO);
    }
    return new PayOrderStockUpdater(productStockService, orderItemDTOMap);
}
Also used : OrderItemDTO(com.whoiszxl.dto.OrderItemDTO) HashMap(java.util.HashMap) OrderInfoDTO(com.whoiszxl.dto.OrderInfoDTO)

Example 2 with OrderInfoDTO

use of com.whoiszxl.dto.OrderInfoDTO 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("system");
        return order;
    }).collect(Collectors.toList());
    boolean updateFlag = orderService.updateBatchById(orderList);
    for (Long orderId : orderIds) {
        OrderInfoDTO orderInfo = orderService.getOrderInfo(orderId);
        // 通知商品中心更新库存
        ResponseResult result = productFeignClient.paySuccessUpdateStock(orderInfo);
        if (!result.isOk()) {
            log.info("库存更新失败");
        }
    // TODO 通知WMS订单支付成功,更新WMS中心库存,WMS新增出库单
    // TODO 更新会员中心等级与积分
    }
    return ResponseResult.buildByFlag(updateFlag);
}
Also used : Order(com.whoiszxl.entity.Order) ResponseResult(com.whoiszxl.bean.ResponseResult) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) Autowired(org.springframework.beans.factory.annotation.Autowired) OrderInfoDTO(com.whoiszxl.dto.OrderInfoDTO) Order(com.whoiszxl.entity.Order) OrderService(com.whoiszxl.service.OrderService) OrderStatusConstants(com.whoiszxl.constants.OrderStatusConstants) RestController(org.springframework.web.bind.annotation.RestController) Collectors(java.util.stream.Collectors) ResponseResult(com.whoiszxl.bean.ResponseResult) OrderInfoDTO(com.whoiszxl.dto.OrderInfoDTO)

Example 3 with OrderInfoDTO

use of com.whoiszxl.dto.OrderInfoDTO in project shopzz by whoiszxl.

the class PayOrderStockUpdaterFactory method getProductSkuIds.

@Override
protected List<Long> getProductSkuIds(T parameter) {
    OrderInfoDTO orderInfoDTO = (OrderInfoDTO) parameter;
    List<Long> productSkuIds = new ArrayList<>();
    for (OrderItemDTO orderItemDTO : orderInfoDTO.getOrderItemDTOList()) {
        productSkuIds.add(orderItemDTO.getSkuId());
    }
    return productSkuIds;
}
Also used : OrderItemDTO(com.whoiszxl.dto.OrderItemDTO) ArrayList(java.util.ArrayList) OrderInfoDTO(com.whoiszxl.dto.OrderInfoDTO)

Example 4 with OrderInfoDTO

use of com.whoiszxl.dto.OrderInfoDTO 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);
}
Also used : Order(com.whoiszxl.entity.Order) com.whoiszxl.feign(com.whoiszxl.feign) ResponseResult(com.whoiszxl.bean.ResponseResult) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) Autowired(org.springframework.beans.factory.annotation.Autowired) OrderInfoDTO(com.whoiszxl.dto.OrderInfoDTO) Order(com.whoiszxl.entity.Order) OrderService(com.whoiszxl.service.OrderService) OrderStatusConstants(com.whoiszxl.constants.OrderStatusConstants) RestController(org.springframework.web.bind.annotation.RestController) Collectors(java.util.stream.Collectors) OrderInfoDTO(com.whoiszxl.dto.OrderInfoDTO)

Aggregations

OrderInfoDTO (com.whoiszxl.dto.OrderInfoDTO)4 ResponseResult (com.whoiszxl.bean.ResponseResult)2 OrderStatusConstants (com.whoiszxl.constants.OrderStatusConstants)2 OrderItemDTO (com.whoiszxl.dto.OrderItemDTO)2 Order (com.whoiszxl.entity.Order)2 OrderService (com.whoiszxl.service.OrderService)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Slf4j (lombok.extern.slf4j.Slf4j)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 RestController (org.springframework.web.bind.annotation.RestController)2 com.whoiszxl.feign (com.whoiszxl.feign)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1