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