BillApply类中有一个名为billAmount的字段,但是billApply.getBillAmount()得不到总金额把
时间: 2023-08-19 09:54:38 浏览: 44
非常抱歉,我之前的回答有误。在您提供的代码中,并没有直接获取到BillApply类中的billAmount字段的总金额。请检查您的代码,确认是否有其他方法用于计算总金额。
如果您的需求是要获取billApply对象的总金额,那么您可以将计算总金额的逻辑放在saveReport方法之前进行处理,然后将计算得到的总金额传递给saveReport方法。例如:
```java
public boolean saveReport(ApplyReportDto dto, BigDecimal totalAmount) {
BillApply billApply = billApplyMapper.selectById(dto.getBillApplyId());
ValidationUtils.checkNotNull(billApply, "未查询到开票申请");
ValidationUtils.checkMustTrue(ApplyStatusEnum.isInvoicing(billApply.getStatus()), "非开票中,无法操作开票");
// 验证总金额与申请记录中的billAmount总金额是否相等
if (totalAmount.compareTo(billApply.getBillAmount()) != 0) {
throw new RuntimeException("列表中的billAmount总金额与申请记录中的billAmount总金额不相等");
}
// 对象转化
List<BillApplyReport> map = MapperUtils.mapObjs(dto.getReportDetails(), BillApplyReport.class, (source, destination) -> {
destination.setBillApplyId(billApply.getId());
destination.setCreateUser(AdminUtil.getCurrentAdminName());
});
return this.saveBatch(map, 200);
}
```
在调用saveReport方法之前,您可以先计算billApply对象的总金额,并将其作为参数传入saveReport方法中。这样就可以在saveReport方法中进行总金额的验证了。