| | |
| | | @GetMapping("/listPage") |
| | | public IPage<SalesLedgerVo> listPage(Page page, SalesLedgerDto salesLedgerDto) { |
| | | IPage<SalesLedgerVo> iPage = salesLedgerService.selectSalesLedgerListPage(page, salesLedgerDto); |
| | | |
| | | // 查询结果为空,直接返回 |
| | | if (CollectionUtils.isEmpty(iPage.getRecords())) { |
| | | return iPage; |
| | | } |
| | | |
| | | // 获取当前页所有台账记录的 ID 集合 |
| | | List<Long> salesLedgerIds = iPage.getRecords().stream().map(SalesLedger::getId).collect(Collectors.toList()); |
| | | |
| | | |
| | | |
| | | |
| | | // 转换回款数据, key 为台账ID, value 为该台账的总回款金额 |
| | | Map<Long, BigDecimal> receiptTotals = new HashMap<>(); |
| | | |
| | | |
| | | for (SalesLedgerVo salesLedgerVo : iPage.getRecords()) { |
| | | Long ledgerId = salesLedgerVo.getId(); |
| | | // 合同总金额 |
| | | BigDecimal contractAmount = salesLedgerVo.getContractAmount() == null ? BigDecimal.ZERO : salesLedgerVo.getContractAmount(); |
| | | // 开票总额和回款总额 |
| | | BigDecimal receiptPaymentAmountTotal = receiptTotals.getOrDefault(ledgerId, BigDecimal.ZERO); |
| | | |
| | | // 如果已经有过开票或回款操作,则不允许编辑 |
| | | boolean hasReceiptOperation = receiptPaymentAmountTotal.compareTo(BigDecimal.ZERO) > 0; |
| | | salesLedgerVo.setIsEdit(hasReceiptOperation); |
| | | |
| | | salesLedgerVo.setStorageBlobVOs(fileUtil.getStorageBlobVOsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum.FILE, RecordTypeEnum.SALES_LEDGER, ledgerId)); |
| | | salesLedgerVo.setStorageBlobVOs(fileUtil.getStorageBlobVOsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum.FILE, RecordTypeEnum.SALES_LEDGER, salesLedgerVo.getId())); |
| | | } |
| | | |
| | | if (ObjectUtils.isNotEmpty(salesLedgerDto.getStatus())) { |
| | | if (salesLedgerDto.getStatus()) { |
| | | iPage.setTotal(iPage.getRecords().size()); |
| | | } |
| | | } |
| | | |
| | | return iPage; |
| | | } |
| | | |