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;
}
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);
}
Aggregations