Search in sources :

Example 6 with OrderItemDTO

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

the class WmsFeignClientImpl method notifyPayOrderSuccess.

@Override
public ResponseResult<Boolean> notifyPayOrderSuccess(OrderInfoDTO orderInfo) {
    // 更新WMS中心库存
    for (OrderItemDTO orderItemDTO : orderInfo.getOrderItemDTOList()) {
        WmsStockUpdater stockUpdater = wmsStockUpdaterFactory.create(WmsStockUpdateEventConstants.PAY_ORDER, null);
        stockUpdater.update();
    }
    // TODO 新增出库单,需要创建发货单,物流单,构建好出库单信息
    return ResponseResult.buildSuccess();
}
Also used : WmsStockUpdater(com.whoiszxl.stock.WmsStockUpdater) OrderItemDTO(com.whoiszxl.dto.OrderItemDTO)

Example 7 with OrderItemDTO

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

the class SubmitOrderConsumer method submitOrderSub.

@KafkaListener(topics = MQConstants.SUBMIT_ORDER_QUEUE, groupId = "default-group")
public void submitOrderSub(ConsumerRecord<String, String> record, @Header(KafkaHeaders.RECEIVED_TOPIC) String topic, Consumer consumer) {
    log.info("订阅到新的提交订单,开始处理, 主题为:{}, 消息值为:{}", topic, record.value());
    OrderCreateInfoDTO orderCreateInfoDTO = JsonUtil.fromJson(record.value(), OrderCreateInfoDTO.class);
    List<OrderItemDTO> orderItemList = orderCreateInfoDTO.getOrderItemList();
    for (OrderItemDTO orderItem : orderItemList) {
        // 7.1 通过商品的SKU ID查询到货位库存的明细条目,并进行遍历,一个SKU可能在多个货位上
        SaleDeliveryScheduleResult scheduleResult = saleDeliveryScheduler.schedule(orderItem);
        List<SaleDeliveryOrderPickingItem> pickingItems = scheduleResult.getPickingItems();
        // 7.2 创建出需要拣货的条目和发货的条目并进行批量入库
        saleDeliveryPickingItemService.saveBatch(pickingItems);
        // 7.3 更新wms中心的库存
        WmsStockUpdater stockUpdater = wmsStockUpdaterFactory.create(WmsStockUpdateEventConstants.SUBMIT_ORDER, scheduleResult);
        stockUpdater.update();
    }
}
Also used : WmsStockUpdater(com.whoiszxl.stock.WmsStockUpdater) OrderCreateInfoDTO(com.whoiszxl.dto.OrderCreateInfoDTO) OrderItemDTO(com.whoiszxl.dto.OrderItemDTO) SaleDeliveryOrderPickingItem(com.whoiszxl.entity.SaleDeliveryOrderPickingItem) SaleDeliveryScheduleResult(com.whoiszxl.entity.schedule.SaleDeliveryScheduleResult) KafkaListener(org.springframework.kafka.annotation.KafkaListener)

Example 8 with OrderItemDTO

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

the class PayOrderWmsStockUpdater method updateProductStock.

@Override
protected void updateProductStock() {
    OrderItemDTO orderItem = scheduleResult.getOrderItem();
    // 支付成功,减去锁定,加上出库
    warehouseProductStockService.subLockedStockAndAddDeliveriedStock(orderItem.getQuantity(), orderItem.getSkuId());
}
Also used : OrderItemDTO(com.whoiszxl.dto.OrderItemDTO)

Example 9 with OrderItemDTO

use of com.whoiszxl.dto.OrderItemDTO 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 10 with OrderItemDTO

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

the class ProductFeignClientImpl method paySuccessUpdateStock.

@Override
public ResponseResult paySuccessUpdateStock(OrderInfoDTO orderInfo) {
    List<OrderItemDTO> orderItemDTOList = orderInfo.getOrderItemDTOList();
    if (ObjectUtils.isNotEmpty(orderItemDTOList)) {
        for (OrderItemDTO orderItemDTO : orderItemDTOList) {
            Long skuId = orderItemDTO.getSkuId();
            Integer quantity = orderItemDTO.getQuantity();
            boolean updateFlag = productStockService.subLockStockAndAddSaledStockBySkuId(quantity, skuId);
            if (updateFlag) {
                return ResponseResult.buildError();
            }
        }
    }
    return ResponseResult.buildSuccess();
}
Also used : OrderItemDTO(com.whoiszxl.dto.OrderItemDTO)

Aggregations

OrderItemDTO (com.whoiszxl.dto.OrderItemDTO)10 OrderCreateInfoDTO (com.whoiszxl.dto.OrderCreateInfoDTO)3 WmsStockUpdater (com.whoiszxl.stock.WmsStockUpdater)3 OrderInfoDTO (com.whoiszxl.dto.OrderInfoDTO)2 SaleDeliveryScheduleResult (com.whoiszxl.entity.schedule.SaleDeliveryScheduleResult)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 SaleDeliveryOrderPickingItem (com.whoiszxl.entity.SaleDeliveryOrderPickingItem)1 KafkaListener (org.springframework.kafka.annotation.KafkaListener)1