From 8e14fa84f6f2dfdda8a739400fca80ac73dca874 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期四, 25 十二月 2025 11:06:21 +0800
Subject: [PATCH] yys 修改项目利润,供应商往来
---
src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java | 74 ++++++++++++++++++++++++++++++++-----
1 files changed, 64 insertions(+), 10 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 cbc5b53..0d2e349 100644
--- a/src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java
+++ b/src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java
@@ -99,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()));
@@ -137,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()));
@@ -217,10 +220,10 @@
new QueryWrapper<SalesLedgerProduct>().eq("sales_ledger_id", id).eq("type",2)
).stream())
.collect(Collectors.toList());
- payableAmount = salesLedgerProducts.stream()
- .map(SalesLedgerProduct::getTaxInclusiveTotalPrice)
- .filter(Objects::nonNull)
- .reduce(BigDecimal.ZERO, BigDecimal::add);
+// payableAmount = salesLedgerProducts.stream()
+// .map(SalesLedgerProduct::getTaxInclusiveTotalPrice)
+// .filter(Objects::nonNull)
+// .reduce(BigDecimal.ZERO, BigDecimal::add);
// 鏉ョエ閲戦璁$畻
List<TicketRegistration> ticketRegistrations = purchaseLedgers.stream()
@@ -244,6 +247,11 @@
.map(PaymentRegistration::getCurrentPaymentAmount)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
+
+ // 鏍稿績杩囨护閫昏緫锛氬綋paymentAmount鍜宨nvoiceAmount鍚屾椂涓�0鏃讹紝璺宠繃璇ヨ褰�
+ if (BigDecimal.ZERO.compareTo(paymentAmount) == 0 && BigDecimal.ZERO.compareTo(invoiceAmount) == 0) {
+ continue; // 璺宠繃褰撳墠渚涘簲鍟嗭紝涓嶅姞鍏ョ粨鏋滈泦
+ }
// 璇︽儏鍒嗛〉澶勭悊
detailPageNum = detailPageNum != null ? detailPageNum : 1;
@@ -298,6 +306,8 @@
result.add(res);
}
+ // 淇鎬绘潯鏁帮細杩囨护鍚庨渶瑕侀噸鏂拌绠楁�绘潯鏁�
+ resultPage.setTotal(result.size());
resultPage.setRecords(result);
return resultPage;
}
@@ -366,6 +376,7 @@
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)) {
@@ -402,8 +413,20 @@
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 result;
+ return newResult;
}
/**
@@ -417,6 +440,37 @@
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