From 263184b07832118da6283391683bdcebf15d2eec Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 03 四月 2026 17:36:01 +0800
Subject: [PATCH] yys 取绝对值

---
 src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java |   46 ++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 42 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 2bdf7d2..9af16c6 100644
--- a/src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java
+++ b/src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java
@@ -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()));
@@ -400,7 +402,7 @@
                 paymentHistoryRecordVo.setCurrentPaymentAmount(currentPaymentAmount);
                 paymentHistoryRecordVo.setInvoiceAmount(invoiceAmount);
                 amountTotal = paymentHistoryRecordVo.getInvoiceAmount().subtract(paymentHistoryRecordVo.getCurrentPaymentAmount());
-                paymentHistoryRecordVo.setPayableAmount(amountTotal);
+                paymentHistoryRecordVo.setPayableAmount(amountTotal.abs());
                 result.add(paymentHistoryRecordVo);
             }
 
@@ -408,11 +410,16 @@
             for (int i = 0; i < result.size(); i++) {
                 PaymentHistoryRecordVo paymentHistoryRecordVo = result.get(i);
                 if (i == 0) {
-                    paymentHistoryRecordVo.setPayableAmount(paymentHistoryRecordVo.getInvoiceAmount().subtract(paymentHistoryRecordVo.getCurrentPaymentAmount()));
+                    paymentHistoryRecordVo.setPayableAmount(paymentHistoryRecordVo
+                            .getInvoiceAmount()
+                            .subtract(paymentHistoryRecordVo.getCurrentPaymentAmount())
+                            .abs());
                 }else {
                     PaymentHistoryRecordVo paymentHistoryRecordVo1 = result.get(i-1);
                     paymentHistoryRecordVo.setPayableAmount(paymentHistoryRecordVo1.getPayableAmount()
-                            .add(paymentHistoryRecordVo.getInvoiceAmount()).subtract(paymentHistoryRecordVo.getCurrentPaymentAmount()));
+                            .add(paymentHistoryRecordVo.getInvoiceAmount())
+                            .subtract(paymentHistoryRecordVo.getCurrentPaymentAmount())
+                            .abs());
                 }
                 newResult.add(paymentHistoryRecordVo);
             }
@@ -431,6 +438,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