Search in sources :

Example 1 with PurchaseSettlementOrderDTO

use of com.whoiszxl.dto.PurchaseSettlementOrderDTO 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 2 with PurchaseSettlementOrderDTO

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

the class PurchaseSettlementOrderServiceImpl method getPurchaseSettlementOrderById.

@Override
public PurchaseSettlementOrderDTO getPurchaseSettlementOrderById(Long id) {
    // 1. 查询采购结算单
    PurchaseSettlementOrder purchaseSettlementOrder = this.getById(id);
    PurchaseSettlementOrderDTO purchaseSettlementOrderDTO = purchaseSettlementOrder.clone(PurchaseSettlementOrderDTO.class);
    // 2. 查询采购结算单条目
    QueryWrapper queryWrapper = new QueryWrapper<PurchaseSettlementOrderItem>();
    queryWrapper.eq("purchase_settlement_order_id", id);
    List<PurchaseSettlementOrderItem> itemList = purchaseSettlementOrderItemService.list(queryWrapper);
    List<PurchaseSettlementOrderItemDTO> purchaseSettlementOrderItemDTOS = BeanCopierUtils.copyListProperties(itemList, PurchaseSettlementOrderItemDTO::new);
    purchaseSettlementOrderDTO.setItems(purchaseSettlementOrderItemDTOS);
    return purchaseSettlementOrderDTO;
}
Also used : PurchaseSettlementOrderItem(com.whoiszxl.entity.PurchaseSettlementOrderItem) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) PurchaseSettlementOrderItemDTO(com.whoiszxl.dto.PurchaseSettlementOrderItemDTO) PurchaseSettlementOrder(com.whoiszxl.entity.PurchaseSettlementOrder) PurchaseSettlementOrderDTO(com.whoiszxl.dto.PurchaseSettlementOrderDTO)

Aggregations

PurchaseSettlementOrderDTO (com.whoiszxl.dto.PurchaseSettlementOrderDTO)2 PurchaseSettlementOrderItemDTO (com.whoiszxl.dto.PurchaseSettlementOrderItemDTO)2 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)1 PurchaseOrderDTO (com.whoiszxl.dto.PurchaseOrderDTO)1 PurchaseOrderItemDTO (com.whoiszxl.dto.PurchaseOrderItemDTO)1 PurchaseSettlementOrder (com.whoiszxl.entity.PurchaseSettlementOrder)1 PurchaseSettlementOrderItem (com.whoiszxl.entity.PurchaseSettlementOrderItem)1 ArrayList (java.util.ArrayList)1