Search in sources :

Example 1 with PurchaseSettlementOrderItemDTO

use of com.whoiszxl.dto.PurchaseSettlementOrderItemDTO 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 PurchaseSettlementOrderItemDTO

use of com.whoiszxl.dto.PurchaseSettlementOrderItemDTO 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)

Example 3 with PurchaseSettlementOrderItemDTO

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

the class PurchaseSettlementOrderServiceImpl method savePurchaseSettlementOrderAndItem.

@Override
public void savePurchaseSettlementOrderAndItem(PurchaseSettlementOrderDTO settlementOrderDTO) {
    // 1. 新增采购结算单
    settlementOrderDTO.setStatus(PurchaseSettlementOrderStatusConstants.EDITING);
    BigDecimal totalSettlementAmount = BigDecimal.ZERO;
    for (PurchaseSettlementOrderItemDTO item : settlementOrderDTO.getItems()) {
        totalSettlementAmount = totalSettlementAmount.add(item.getPurchasePrice().multiply(new BigDecimal(item.getArrivalCount())));
    }
    settlementOrderDTO.setTotalSettlementAmount(totalSettlementAmount);
    PurchaseSettlementOrder purchaseSettlementOrder = settlementOrderDTO.clone(PurchaseSettlementOrder.class);
    this.save(purchaseSettlementOrder);
    // 2. 新增采购结算条目单
    List<PurchaseSettlementOrderItem> settlementOrderItemList = BeanCopierUtils.copyListProperties(settlementOrderDTO.getItems(), PurchaseSettlementOrderItem::new);
    settlementOrderItemList.forEach(item -> item.setPurchaseSettlementOrderId(purchaseSettlementOrder.getId()));
    purchaseSettlementOrderItemService.saveBatch(settlementOrderItemList);
}
Also used : PurchaseSettlementOrderItem(com.whoiszxl.entity.PurchaseSettlementOrderItem) PurchaseSettlementOrderItemDTO(com.whoiszxl.dto.PurchaseSettlementOrderItemDTO) BigDecimal(java.math.BigDecimal) PurchaseSettlementOrder(com.whoiszxl.entity.PurchaseSettlementOrder)

Aggregations

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