Search in sources :

Example 1 with PurchaseOrderItemDTO

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

the class PurchaseInboundStockUpdater method updateStock.

@Override
protected boolean updateStock() {
    // 采购入库,只要新增销售库存就OK
    for (PurchaseOrderItemDTO purchaseOrderItemDTO : itemDTOMap.values()) {
        // 查询当前sku在库存中心是否存在,不存在则创建
        ProductStock productStock = productStockService.getProductStockBySkuId(purchaseOrderItemDTO.getProductSkuId());
        if (productStock == null) {
            productStock = new ProductStock();
            productStock.setProductSkuId(purchaseOrderItemDTO.getProductSkuId());
            productStock.setSaleStockQuantity(purchaseOrderItemDTO.getPurchaseQuantity());
            productStock.setLockedStockQuantity(0);
            productStock.setSaledStockQuantity(0);
            productStock.setStockStatus(StockStatus.IN_STOCK);
            productStockService.save(productStock);
        } else {
            productStockService.addSaleStock(purchaseOrderItemDTO.getPurchaseQuantity(), purchaseOrderItemDTO.getProductSkuId());
        }
    }
    return true;
}
Also used : PurchaseOrderItemDTO(com.whoiszxl.dto.PurchaseOrderItemDTO) ProductStock(com.whoiszxl.entity.ProductStock)

Example 2 with PurchaseOrderItemDTO

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

the class PurchaseStockUpdaterFactory method createCommand.

/**
 * 创建库存更新命令
 * @param parameter 参数
 * @return 库存更新命令
 */
@Override
public StockUpdater createCommand(T parameter) {
    PurchaseOrderDTO purchaseOrderDTO = (PurchaseOrderDTO) parameter;
    List<PurchaseOrderItemDTO> inboundOrderDTOItems = purchaseOrderDTO.getItems();
    Map<Long, PurchaseOrderItemDTO> itemDTOMap = new HashMap<>(100);
    if (ObjectUtils.isNotEmpty(inboundOrderDTOItems)) {
        for (PurchaseOrderItemDTO inboundOrderDTOItem : inboundOrderDTOItems) {
            itemDTOMap.put(inboundOrderDTOItem.getProductSkuId(), inboundOrderDTOItem);
        }
    }
    return new PurchaseInboundStockUpdater(productStockService, itemDTOMap);
}
Also used : PurchaseOrderItemDTO(com.whoiszxl.dto.PurchaseOrderItemDTO) HashMap(java.util.HashMap) PurchaseOrderDTO(com.whoiszxl.dto.PurchaseOrderDTO)

Example 3 with PurchaseOrderItemDTO

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

the class PurchaseSettlementOrderServiceImpl method createPurchaseSettlementOrder.

@Override
public boolean createPurchaseSettlementOrder(PurchaseOrderDTO purchaseOrderDTO) {
    // 1. 将采购入库单的数据填充到采购结算单中
    PurchaseSettlementOrderDTO settlementOrderDTO = purchaseOrderDTO.clone(PurchaseSettlementOrderDTO.class);
    settlementOrderDTO.setId(null);
    settlementOrderDTO.setStatus(null);
    settlementOrderDTO.setTotalSettlementAmount(BigDecimal.ZERO);
    settlementOrderDTO.setPurchaseOrderId(purchaseOrderDTO.getId());
    settlementOrderDTO.setComment("");
    // 2. 将采购入库条目信息填充到采购结算条目中
    List<PurchaseSettlementOrderItemDTO> items = new ArrayList<>();
    for (PurchaseOrderItemDTO purchaseOrderItemDTO : purchaseOrderDTO.getItems()) {
        PurchaseSettlementOrderItemDTO item = purchaseOrderItemDTO.clone(PurchaseSettlementOrderItemDTO.class);
        item.setId(null);
        items.add(item);
    }
    settlementOrderDTO.setItems(items);
    // 3. 将采购结算单与条目新增到数据库
    this.savePurchaseSettlementOrderAndItem(settlementOrderDTO);
    // 4. 更新采购单的状态为待结算
    PurchaseOrderDTO updateParams = purchaseOrderService.getPurchaseOrderById(settlementOrderDTO.getPurchaseOrderId());
    purchaseOrderService.updateStatus(updateParams.getId(), PurchaseOrderStatusConstants.WAIT_FOR_SETTLEMENT);
    return true;
}
Also used : PurchaseOrderItemDTO(com.whoiszxl.dto.PurchaseOrderItemDTO) ArrayList(java.util.ArrayList) PurchaseOrderDTO(com.whoiszxl.dto.PurchaseOrderDTO) PurchaseSettlementOrderItemDTO(com.whoiszxl.dto.PurchaseSettlementOrderItemDTO) PurchaseSettlementOrderDTO(com.whoiszxl.dto.PurchaseSettlementOrderDTO)

Example 4 with PurchaseOrderItemDTO

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

the class PurchaseInboundWmsStockUpdater method updateProductAllocationStock.

/**
 * 更新商品货位库存
 */
@Override
protected void updateProductAllocationStock() {
    // 1. 拿到采购入库单条目并进行遍历
    for (PurchaseOrderItemDTO item : purchaseOrder.getItems()) {
        // 2. 再从入库单条目中拿到上架条目
        for (PurchaseInboundOnItemDTO onItemDTO : item.getOnItems()) {
            // 3. 获取商品货位库存,如果货位不存在则新建一个
            ProductAllocationStock productAllocationStock = productAllocationStockService.getOrSave(onItemDTO.getProductAllocationId(), onItemDTO.getProductSkuId());
            // 4. 累加可用库存数量并更新
            productAllocationStock.setAvailableStockQuantity(productAllocationStock.getAvailableStockQuantity() + onItemDTO.getPutOnShelvesCount());
            productAllocationStockService.updateById(productAllocationStock);
        }
    }
}
Also used : PurchaseOrderItemDTO(com.whoiszxl.dto.PurchaseOrderItemDTO) PurchaseInboundOnItemDTO(com.whoiszxl.dto.PurchaseInboundOnItemDTO) ProductAllocationStock(com.whoiszxl.entity.ProductAllocationStock)

Example 5 with PurchaseOrderItemDTO

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

the class PurchaseStockUpdaterFactory method getProductSkuIds.

/**
 * 获取商品skuid集合
 * @param parameter 参数
 * @return 商品sku id集合
 */
@Override
protected List<Long> getProductSkuIds(T parameter) {
    PurchaseOrderDTO purchaseOrderDTO = (PurchaseOrderDTO) parameter;
    List<PurchaseOrderItemDTO> inboundOrderDTOItems = purchaseOrderDTO.getItems();
    if (ObjectUtils.isEmpty(inboundOrderDTOItems)) {
        return new ArrayList<>();
    }
    List<Long> productSkuIds = new ArrayList<>(inboundOrderDTOItems.size());
    for (PurchaseOrderItemDTO inboundOrderDTOItem : inboundOrderDTOItems) {
        productSkuIds.add(inboundOrderDTOItem.getProductSkuId());
    }
    return productSkuIds;
}
Also used : PurchaseOrderItemDTO(com.whoiszxl.dto.PurchaseOrderItemDTO) ArrayList(java.util.ArrayList) PurchaseOrderDTO(com.whoiszxl.dto.PurchaseOrderDTO)

Aggregations

PurchaseOrderItemDTO (com.whoiszxl.dto.PurchaseOrderItemDTO)5 PurchaseOrderDTO (com.whoiszxl.dto.PurchaseOrderDTO)3 ArrayList (java.util.ArrayList)2 PurchaseInboundOnItemDTO (com.whoiszxl.dto.PurchaseInboundOnItemDTO)1 PurchaseSettlementOrderDTO (com.whoiszxl.dto.PurchaseSettlementOrderDTO)1 PurchaseSettlementOrderItemDTO (com.whoiszxl.dto.PurchaseSettlementOrderItemDTO)1 ProductAllocationStock (com.whoiszxl.entity.ProductAllocationStock)1 ProductStock (com.whoiszxl.entity.ProductStock)1 HashMap (java.util.HashMap)1