From 274a61f398e1d7b4ae63208897b70b3a73b30805 Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期三, 18 六月 2025 09:14:24 +0800
Subject: [PATCH] 非空校验
---
src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java | 71 +++++++++++++++++++++++++++++++++--
1 files changed, 67 insertions(+), 4 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 624bc1a..9cab585 100644
--- a/src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java
+++ b/src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java
@@ -11,6 +11,7 @@
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.security.LoginUser;
+import com.ruoyi.purchase.dto.PaymentHistoryRecordVo;
import com.ruoyi.purchase.dto.PaymentLedgerDto;
import com.ruoyi.purchase.dto.PaymentRegistrationDto;
import com.ruoyi.purchase.mapper.*;
@@ -120,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());
@@ -201,6 +202,7 @@
for (SupplierManage supplierManage : supplierManages) {
Map<String, Object> res = new HashMap<>();
res.put("supplierName", supplierManage.getSupplierName());
+ res.put("supplierId", supplierManage.getId());
// 搴斾粯閲戦璁$畻
BigDecimal payableAmount = BigDecimal.ZERO;
@@ -212,7 +214,7 @@
.map(PurchaseLedger::getId)
.filter(Objects::nonNull)
.flatMap(id -> salesLedgerProductMapper.selectList(
- new QueryWrapper<SalesLedgerProduct>().eq("sales_ledger_id", id)
+ new QueryWrapper<SalesLedgerProduct>().eq("sales_ledger_id", id).eq("type",2)
).stream())
.collect(Collectors.toList());
payableAmount = salesLedgerProducts.stream()
@@ -266,7 +268,6 @@
new LambdaQueryWrapper<ProductRecord>().eq(ProductRecord::getTicketRegistrationId, ticketRegistration.getId())
).stream()
.map(ProductRecord::getTicketsNum)
- .map(BigDecimal::new)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
detail.put("voteCount", voteCount);
@@ -287,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);
@@ -354,6 +357,66 @@
return paymentRegistrationMapper.paymentHistoryList(paymentRegistrationDto);
}
+ /**
+ * 鏌ヨ渚涘簲鍟嗗線鏉ヨ褰�
+ * @param supplierId
+ * @return
+ */
+ @Override
+ public List<PaymentHistoryRecordVo> getPaymentRecordList(Long supplierId) {
+ List<PaymentHistoryRecordVo> paymentRecordList = paymentRegistrationMapper.getPaymentRecordList(supplierId);
+ 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 = amountTotal.add(currentDateTotal);
+ paymentHistoryRecordVo.setPayableAmount(amountTotal);
+ result.add(paymentHistoryRecordVo);
+ }
+
+ }
+ return result;
+ }
+
+ /**
+ * 鏌ヨ浠樻鐧昏鍒楄〃鍒嗛〉
+ *
+ * @param paymentRegistrationDto 浠樻鐧昏
+ * @return 浠樻鐧昏闆嗗悎
+ */
+ @Override
+ public IPage<PaymentRegistrationDto> paymentHistoryListPage(Page page, PaymentRegistrationDto paymentRegistrationDto) {
+ return paymentRegistrationMapper.paymentHistoryListPage(page, paymentRegistrationDto);
+ }
+
// 鎵归噺鏌ヨ閲囪喘鍙拌处锛堝綋鏈堬級
private Map<Long, List<PurchaseLedger>> batchQueryPurchaseLedgers(List<Long> supplierIds, LocalDate startDate, LocalDate endDate) {
LambdaQueryWrapper<PurchaseLedger> query = new LambdaQueryWrapper<>();
--
Gitblit v1.9.3