From 6ed42390d7231b0d26700898ee2922732043effa Mon Sep 17 00:00:00 2001 From: liyong <18434998025@163.com> Date: 星期四, 19 六月 2025 16:20:34 +0800 Subject: [PATCH] 2025-06-19 增值税对比 + 问题修改 --- src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java | 64 +++++++++++++++++++++++++------ 1 files changed, 51 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java b/src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java index 38e0df3..cbc5b53 100644 --- a/src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java +++ b/src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java @@ -121,8 +121,8 @@ } LoginUser loginUser = SecurityUtils.getLoginUser(); - Integer tenantId = loginUser.getTenantId(); - paymentRegistration.setTenantId(tenantId.longValue()); + Long tenantId = loginUser.getTenantId(); + paymentRegistration.setTenantId(tenantId); paymentRegistration.setRegistrantId(loginUser.getUserId()); paymentRegistration.setCreateTime(DateUtils.getNowDate()); paymentRegistration.setUpdateTime(DateUtils.getNowDate()); @@ -288,6 +288,8 @@ detailPagination.put("pageSize", detailPageSize); detailPagination.put("pages", (int) Math.ceil((double) totalDetails / detailPageSize)); + // 搴斾粯閲戦閫昏緫涓嶉噰鐢ㄥ悎鍚岄噾棰濇敼鎴� 鍙戠エ閲戦鍑忎粯娆鹃噾棰� + payableAmount = invoiceAmount.subtract(paymentAmount); res.put("invoiceAmount", invoiceAmount); res.put("payableAmount", payableAmount); res.put("paymentAmount", paymentAmount); @@ -363,20 +365,56 @@ @Override public List<PaymentHistoryRecordVo> getPaymentRecordList(Long supplierId) { List<PaymentHistoryRecordVo> paymentRecordList = paymentRegistrationMapper.getPaymentRecordList(supplierId); - if(!CollectionUtils.isEmpty(paymentRecordList)) { - // 搴斾粯閲戦璁$畻 - BigDecimal amountTotal = BigDecimal.ZERO; - for (PaymentHistoryRecordVo paymentHistoryRecordVo : paymentRecordList) { - if(paymentHistoryRecordVo.getType() == 0){ - amountTotal = amountTotal.subtract(paymentHistoryRecordVo.getCurrentPaymentAmount()); - } - if(paymentHistoryRecordVo.getType() == 1){ - amountTotal = amountTotal.add(paymentHistoryRecordVo.getInvoiceAmount()); - } + List<PaymentHistoryRecordVo> result = new ArrayList<>(); + // 搴斾粯鎬婚噾棰濋噾棰濊绠� + BigDecimal amountTotal = BigDecimal.ZERO; + if(CollectionUtils.isNotEmpty(paymentRecordList)) { + Map<LocalDate, List<PaymentHistoryRecordVo>> dateListMap = paymentRecordList.stream().collect( + Collectors.groupingBy( + PaymentHistoryRecordVo::getHappenTime, + LinkedHashMap::new, + Collectors.toList() + ) + ); + for (LocalDate localDate : dateListMap.keySet()) { + BigDecimal currentPaymentAmount = BigDecimal.ZERO; + BigDecimal invoiceAmount = BigDecimal.ZERO; + BigDecimal currentDateTotal = BigDecimal.ZERO; + List<PaymentHistoryRecordVo> paymentHistoryRecordVos = dateListMap.get(localDate); + // 璁$畻褰撳ぉ姹囨鏁� + currentPaymentAmount = paymentHistoryRecordVos.stream() + .filter(item ->item.getType() == 0) + .map(PaymentHistoryRecordVo::getCurrentPaymentAmount) + .reduce(BigDecimal.ZERO,BigDecimal::add); + // 璁$畻浠婂ぉ鏉ョエ鏁� + invoiceAmount = paymentHistoryRecordVos.stream() + .filter(item ->item.getType() == 1) + .map(PaymentHistoryRecordVo::getInvoiceAmount) + .reduce(BigDecimal.ZERO,BigDecimal::add); + // 璁$畻褰撴棩姹囨�� + currentDateTotal = currentDateTotal.add(invoiceAmount).subtract(currentPaymentAmount); + PaymentHistoryRecordVo paymentHistoryRecordVo = new PaymentHistoryRecordVo(); + paymentHistoryRecordVo.setHappenTime(localDate); + paymentHistoryRecordVo.setCurrentPaymentAmount(currentPaymentAmount); + paymentHistoryRecordVo.setInvoiceAmount(invoiceAmount); + amountTotal = paymentHistoryRecordVo.getInvoiceAmount().subtract(paymentHistoryRecordVo.getCurrentPaymentAmount()); paymentHistoryRecordVo.setPayableAmount(amountTotal); + result.add(paymentHistoryRecordVo); } + } - return paymentRecordList; + return result; + } + + /** + * 鏌ヨ浠樻鐧昏鍒楄〃鍒嗛〉 + * + * @param paymentRegistrationDto 浠樻鐧昏 + * @return 浠樻鐧昏闆嗗悎 + */ + @Override + public IPage<PaymentRegistrationDto> paymentHistoryListPage(Page page, PaymentRegistrationDto paymentRegistrationDto) { + return paymentRegistrationMapper.paymentHistoryListPage(page, paymentRegistrationDto); } // 鎵归噺鏌ヨ閲囪喘鍙拌处锛堝綋鏈堬級 -- Gitblit v1.9.3