use of com.whoiszxl.entity.PurchaseSettlementOrder 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.PurchaseSettlementOrder in project shopzz by whoiszxl.
the class FinancePurchaseSettlementOrderController method submitOrderToApprove.
@PutMapping("/submit/approve/{id}")
@ApiOperation(value = "提交采购入库单的审核", notes = "提交采购入库单的审核", response = ResponseResult.class)
public ResponseResult submitOrderToApprove(@PathVariable("id") Long id) {
// 对采购入库单的订单状态进行校验
PurchaseSettlementOrder purchaseSettlementOrder = purchaseSettlementOrderService.getById(id);
if (purchaseSettlementOrder == null || !purchaseSettlementOrder.getStatus().equals(PurchaseSettlementOrderStatusConstants.EDITING)) {
return ResponseResult.buildError("采购结算单不存在或状态不为编辑中");
}
purchaseSettlementOrder.setStatus(PurchaseSettlementOrderStatusConstants.WAIT_FOR_APPROVE);
boolean updateFlag = purchaseSettlementOrderService.updateById(purchaseSettlementOrder);
return ResponseResult.buildByFlag(updateFlag);
}
use of com.whoiszxl.entity.PurchaseSettlementOrder in project shopzz by whoiszxl.
the class FinancePurchaseSettlementOrderController method approve.
@PutMapping("/approve/{id}/{status}")
@ApiOperation(value = "审核采购结算单", notes = "审核采购结算单", response = ResponseResult.class)
public ResponseResult approve(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
// 校验采购结算单状态
PurchaseSettlementOrder purchaseSettlementOrder = purchaseSettlementOrderService.getById(id);
if (purchaseSettlementOrder == null || !purchaseSettlementOrder.getStatus().equals(PurchaseSettlementOrderStatusConstants.WAIT_FOR_APPROVE)) {
return ResponseResult.buildError("采购结算单不存在或状态不为待审核中");
}
// 进行审核状态更改
purchaseSettlementOrderService.approve(id, status);
return ResponseResult.buildSuccess();
}
use of com.whoiszxl.entity.PurchaseSettlementOrder 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);
}
use of com.whoiszxl.entity.PurchaseSettlementOrder in project shopzz by whoiszxl.
the class PurchaseSettlementOrderServiceImpl method updateStatus.
@Override
public void updateStatus(Long id, Integer status) {
PurchaseSettlementOrder result = this.getById(id);
if (result == null) {
ExceptionCatcher.catchDatabaseFailEx();
}
result.setStatus(status);
this.updateById(result);
}
Aggregations