Search in sources :

Example 1 with PurchaseSettlementOrderItem

use of com.whoiszxl.entity.PurchaseSettlementOrderItem 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 2 with PurchaseSettlementOrderItem

use of com.whoiszxl.entity.PurchaseSettlementOrderItem 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)2 PurchaseSettlementOrder (com.whoiszxl.entity.PurchaseSettlementOrder)2 PurchaseSettlementOrderItem (com.whoiszxl.entity.PurchaseSettlementOrderItem)2 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)1 PurchaseSettlementOrderDTO (com.whoiszxl.dto.PurchaseSettlementOrderDTO)1 BigDecimal (java.math.BigDecimal)1