From b5f919e8cc4301b71ff6b12de93f7aefc823ca6d Mon Sep 17 00:00:00 2001
From: yaowanxin <3588231647@qq.com>
Date: 星期二, 21 十月 2025 09:55:02 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java | 141 +++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 130 insertions(+), 11 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 ec355bd..30e838f 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.*;
@@ -46,8 +47,6 @@
private PaymentRegistrationMapper paymentRegistrationMapper;
private PurchaseLedgerMapper purchaseLedgerMapper;
-
- private InvoicePurchaseMapper invoicePurchaseMapper;
private SalesLedgerMapper salesLedgerMapper;
@@ -100,11 +99,12 @@
PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectById(paymentRegistration.getPurchaseLedgerId());
SalesLedger salesLedger = salesLedgerMapper.selectOne(new QueryWrapper<SalesLedger>().
eq("sales_contract_no", purchaseLedger.getSalesContractNo()));
- if (salesLedger == null) {
- throw new RuntimeException("鍏宠仈閿�鍞悎鍚屽彿涓嶅瓨鍦�");
+// if (salesLedger == null) {
+// throw new RuntimeException("鍏宠仈閿�鍞悎鍚屽彿涓嶅瓨鍦�");
+// }
+ if (salesLedger != null) {
+ paymentRegistration.setSaleLedgerId(salesLedger.getId());
}
-
- paymentRegistration.setSaleLedgerId(salesLedger.getId());
paymentRegistration.setSupplierId(purchaseLedger.getSupplierId());
TicketRegistration tr = ticketRegistrationMapper.selectOne(new LambdaQueryWrapper<TicketRegistration>().eq(TicketRegistration::getId, paymentRegistration.getTicketRegistrationId()));
@@ -122,8 +122,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());
@@ -138,7 +138,9 @@
*/
@Override
public int updatePaymentRegistration(PaymentRegistration paymentRegistration) {
- TicketRegistration ticketRegistration = ticketRegistrationMapper.selectById(paymentRegistration.getTicketRegistrationId());
+ PaymentRegistration paymentRegistration1 = paymentRegistrationMapper.selectById(paymentRegistration.getId());
+
+ TicketRegistration ticketRegistration = ticketRegistrationMapper.selectById(paymentRegistration.getTicketRegistrationId()==null?paymentRegistration1.getTicketRegistrationId():paymentRegistration.getTicketRegistrationId());
List<PaymentRegistration> paymentRegistrations = paymentRegistrationMapper.selectList(new QueryWrapper<PaymentRegistration>()
.eq("ticket_registration_id", paymentRegistration.getTicketRegistrationId()).ne("id", paymentRegistration.getId()));
@@ -203,6 +205,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;
@@ -214,7 +217,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()
@@ -268,7 +271,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);
@@ -289,6 +291,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);
@@ -345,6 +349,121 @@
return result;
}
+ /**
+ * 鏌ヨ浠樻鐧昏鍒楄〃
+ *
+ * @param paymentRegistrationDto 浠樻鐧昏
+ * @return 浠樻鐧昏闆嗗悎
+ */
+ @Override
+ public List<PaymentRegistrationDto> paymentHistoryList(PaymentRegistrationDto paymentRegistrationDto) {
+ 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<>();
+ List<PaymentHistoryRecordVo> newResult = 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);
+ }
+
+
+ for (int i = 0; i < result.size(); i++) {
+ PaymentHistoryRecordVo paymentHistoryRecordVo = result.get(i);
+ if (i == 0) {
+ paymentHistoryRecordVo.setPayableAmount(paymentHistoryRecordVo.getInvoiceAmount().subtract(paymentHistoryRecordVo.getCurrentPaymentAmount()));
+ }else {
+ PaymentHistoryRecordVo paymentHistoryRecordVo1 = result.get(i-1);
+ paymentHistoryRecordVo.setPayableAmount(paymentHistoryRecordVo1.getPayableAmount()
+ .add(paymentHistoryRecordVo.getInvoiceAmount()).subtract(paymentHistoryRecordVo.getCurrentPaymentAmount()));
+ }
+ newResult.add(paymentHistoryRecordVo);
+ }
+ }
+ return newResult;
+ }
+
+ /**
+ * 鏌ヨ浠樻鐧昏鍒楄〃鍒嗛〉
+ *
+ * @param paymentRegistrationDto 浠樻鐧昏
+ * @return 浠樻鐧昏闆嗗悎
+ */
+ @Override
+ public IPage<PaymentRegistrationDto> paymentHistoryListPage(Page page, PaymentRegistrationDto paymentRegistrationDto) {
+ return paymentRegistrationMapper.paymentHistoryListPage(page, paymentRegistrationDto);
+ }
+
+ @Override
+ public Boolean delete(Long[] ids) {
+ for (Long id : ids) {
+ List<ProductRecord> productRecords = productRecordMapper.selectList(new QueryWrapper<ProductRecord>().lambda().eq(ProductRecord::getTicketRegistrationId, id));
+ for (ProductRecord productRecord : productRecords) {
+ SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(productRecord.getSaleLedgerProjectId());
+ salesLedgerProduct.setTicketsNum(salesLedgerProduct.getTicketsNum().subtract(productRecord.getTicketsNum()));
+ salesLedgerProduct.setTicketsAmount(salesLedgerProduct.getTicketsAmount().subtract(productRecord.getTicketsAmount()));
+ salesLedgerProduct.setFutureTickets(salesLedgerProduct.getFutureTickets().add(productRecord.getTicketsNum()));
+ salesLedgerProduct.setFutureTicketsAmount(salesLedgerProduct.getFutureTicketsAmount().add(productRecord.getTicketsAmount()));
+ salesLedgerProductMapper.updateById(salesLedgerProduct);
+ }
+ ticketRegistrationMapper.delete(new QueryWrapper<TicketRegistration>().lambda().eq(TicketRegistration::getId, id));
+ productRecordMapper.delete(new QueryWrapper<ProductRecord>().lambda().eq(ProductRecord::getTicketRegistrationId, id));
+ }
+ return true;
+ }
+
+ @Override
+ public int delPaymentRegistration(Long id) {
+// PaymentRegistration paymentRegistration = paymentRegistrationMapper.selectById(id);
+// TicketRegistration ticketRegistration = ticketRegistrationMapper.selectById(paymentRegistration.getTicketRegistrationId());
+// if (ticketRegistration != null) {
+// ticketRegistration.setPaymentAmountTotal(ticketRegistration.getPaymentAmountTotal().subtract(paymentRegistration.getCurrentPaymentAmount()));
+// ticketRegistration.setUnPaymentAmountTotal(ticketRegistration.getUnPaymentAmountTotal().add(paymentRegistration.getCurrentPaymentAmount()));
+// ticketRegistrationMapper.updateById(ticketRegistration);
+// }
+
+ return paymentRegistrationMapper.deleteById(id);
+ }
+
// 鎵归噺鏌ヨ閲囪喘鍙拌处锛堝綋鏈堬級
private Map<Long, List<PurchaseLedger>> batchQueryPurchaseLedgers(List<Long> supplierIds, LocalDate startDate, LocalDate endDate) {
LambdaQueryWrapper<PurchaseLedger> query = new LambdaQueryWrapper<>();
--
Gitblit v1.9.3