From e9573dc619e9a1e17d511c5ea4ab461919955be2 Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期一, 24 三月 2025 15:17:03 +0800
Subject: [PATCH] 合同终止时间修改

---
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java |  125 +++++++++++++++++++++++++++++++----------
 1 files changed, 93 insertions(+), 32 deletions(-)

diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java
index 6fab5c1..05bbd56 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java
@@ -1,21 +1,42 @@
 package com.ruoyi.system.service.impl;
 
-import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.basic.PageInfo;
-import com.ruoyi.common.config.SmsProperties;
 import com.ruoyi.common.constant.AmountConstant;
 import com.ruoyi.common.constant.CacheConstants;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.exception.ServiceException;
-import com.ruoyi.common.utils.*;
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.OrderNos;
+import com.ruoyi.common.utils.SmsUtil;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.TencentMailUtil;
 import com.ruoyi.common.utils.uuid.UUID;
-import com.ruoyi.system.dto.*;
+import com.ruoyi.system.dto.BillStatisticsDto;
+import com.ruoyi.system.dto.CachPayDto;
+import com.ruoyi.system.dto.OfflinePayCheckDto;
+import com.ruoyi.system.dto.SmsByBillDto;
+import com.ruoyi.system.dto.TBillDto;
+import com.ruoyi.system.dto.TbillSaveDto;
 import com.ruoyi.system.mapper.TBillMapper;
-import com.ruoyi.system.model.*;
+import com.ruoyi.system.model.TBankFlow;
+import com.ruoyi.system.model.TBill;
+import com.ruoyi.system.model.TBillDetail;
+import com.ruoyi.system.model.TFlowManagement;
+import com.ruoyi.system.model.TInvoiceToBill;
+import com.ruoyi.system.model.TOrderBill;
+import com.ruoyi.system.model.TPayOrder;
 import com.ruoyi.system.query.TBillQuery;
 import com.ruoyi.system.query.TInvoiceToBillQuery;
-import com.ruoyi.system.service.*;
+import com.ruoyi.system.service.TBankFlowService;
+import com.ruoyi.system.service.TBillConfirmService;
+import com.ruoyi.system.service.TBillDetailService;
+import com.ruoyi.system.service.TBillService;
+import com.ruoyi.system.service.TFlowManagementService;
+import com.ruoyi.system.service.TInvoiceToBillService;
+import com.ruoyi.system.service.TOrderBillService;
+import com.ruoyi.system.service.TPayOrderService;
+import com.ruoyi.system.vo.ScreenRentRankVO;
 import com.taxi591.bankapi.dto.ChargeBillRequest;
 import lombok.extern.slf4j.Slf4j;
 import org.jetbrains.annotations.NotNull;
@@ -28,7 +49,6 @@
 import javax.validation.constraints.NotEmpty;
 import java.math.BigDecimal;
 import java.text.ParseException;
-import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.Date;
@@ -241,42 +261,72 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean checkOfflinePay(OfflinePayCheckDto dto) {
-        TBankFlow bankflow = tBankFlowService.getById(dto.getFlowId());
         TBillDto bill = getDetailByBillId(dto.getBillId());
-        if (bankflow.getRemainingMoney().compareTo(BigDecimal.ZERO)<=0){
-            throw new ServiceException("该流水已无可抵扣剩余金额");
-        }
-        if (bankflow.getRemainingMoney().compareTo(dto.getAmount())<0){
-            throw new ServiceException("实付金额不能高于于流水可抵扣剩余金额");
-        }
-        //如果实付金额大于欠费金额
-        if (dto.getAmount().compareTo(bill.getOutstandingMoney())>0){
-            throw new ServiceException("实付金额不能高于该账单欠费金额");
-        }
+        if (dto.getPayType()==1){ //银行
+            if (StringUtils.isEmpty(dto.getFlowId())){
+                throw new ServiceException("银行流水ID不能为空");
+            }
+            TBankFlow bankflow = tBankFlowService.getById(dto.getFlowId());
+            if (bankflow.getRemainingMoney().compareTo(BigDecimal.ZERO)<=0){
+                throw new ServiceException("该流水已无可抵扣剩余金额");
+            }
+            if (bankflow.getRemainingMoney().compareTo(dto.getAmount())<0){
+                throw new ServiceException("实付金额不能高于于流水可抵扣剩余金额");
+            }
+            //如果实付金额大于欠费金额
+            if (dto.getAmount().compareTo(bill.getOutstandingMoney())>0){
+                throw new ServiceException("实付金额不能高于该账单欠费金额");
+            }
+            TBill billSave = new TBill();
+            billSave.setId(bill.getId());
+            billSave.setPayFeesMoney(dto.getAmount());
+            billSave.setBankSerialNumber(bankflow.getBankSerialNumber());
+            billSave.setPayFeesTime(bankflow.getPayTime());
+            billSave.setVoucher(dto.getVoucher());
+            billSave.setPayFeesType(2);
+            TBill back = lockAndUpdateInfo(billSave, 2);
+            TBankFlow saveBankFlow = new TBankFlow();
+            saveBankFlow.setId(bankflow.getId());
+            saveBankFlow.setDeductionMoney(bankflow.getDeductionMoney().add(dto.getAmount()));
+            BigDecimal subtract = bankflow.getRemainingMoney().subtract(dto.getAmount());
+            saveBankFlow.setRemainingMoney(subtract);
+            if (BigDecimal.ZERO.compareTo(subtract) == 0){
+                saveBankFlow.setFlowStatus(1);
+            }
+            tBankFlowService.updateById(saveBankFlow);
+            //更新银行流水的已抵扣金额和剩余可抵扣金额
 
+            //存流水
+            TFlowManagement save = new TFlowManagement();
+            save.setPayType(3);
+            save.setPayer(dto.getPayer());
+            save.setPayTime(bankflow.getPayTime());
+            save.setSysSerialNumber(OrderNos.getDid(30));
+            save.setBankSerialNumber(bankflow.getBankSerialNumber());
+            save.setFlowType(2);
+            save.setPaymentBillId(back.getId());
+            save.setDeductionMoney(back.getDeductionMoney());
+            save.setFlowMoney(dto.getAmount());
+            save.setRemainingMoney(back.getOutstandingMoney());
+            save.setPreOutstand(back.getPreOutstand());
+            tFlowManagementService.save(save);
+            return true;
+        }
+        //现金支付
         TBill billSave = new TBill();
         billSave.setId(bill.getId());
         billSave.setPayFeesMoney(dto.getAmount());
-        billSave.setBankSerialNumber(bankflow.getBankSerialNumber());
-        billSave.setPayFeesTime(bankflow.getPayTime());
+        billSave.setPayFeesTime(dto.getPayTime()!=null?dto.getPayTime():DateUtils.dateToLocalDateTime(new Date()));
         billSave.setVoucher(dto.getVoucher());
         billSave.setPayFeesType(2);
         TBill back = lockAndUpdateInfo(billSave, 2);
 
-        //更新银行流水的已抵扣金额和剩余可抵扣金额
-        TBankFlow saveBankFlow = new TBankFlow();
-        saveBankFlow.setId(bankflow.getId());
-        saveBankFlow.setDeductionMoney(bankflow.getDeductionMoney().add(dto.getAmount()));
-        saveBankFlow.setRemainingMoney(bankflow.getRemainingMoney().subtract(dto.getAmount()));
-        tBankFlowService.updateById(saveBankFlow);
-        //存流水
         TFlowManagement save = new TFlowManagement();
         save.setPayType(3);
         save.setPayer(dto.getPayer());
-        save.setPayTime(bankflow.getPayTime());
+        save.setPayTime(billSave.getPayFeesTime());
         save.setSysSerialNumber(OrderNos.getDid(30));
-        save.setBankSerialNumber(bankflow.getBankSerialNumber());
-        save.setFlowType(2);
+        save.setFlowType(1);
         save.setPaymentBillId(back.getId());
         save.setDeductionMoney(back.getDeductionMoney());
         save.setFlowMoney(dto.getAmount());
@@ -483,7 +533,11 @@
             TBankFlow saveBankFlow = new TBankFlow();
             saveBankFlow.setId(bankflow.getId());
             saveBankFlow.setDeductionMoney(bankflow.getDeductionMoney().add(dto.getAmount()));
-            saveBankFlow.setRemainingMoney(bankflow.getRemainingMoney().subtract(dto.getAmount()));
+            BigDecimal subtract = bankflow.getRemainingMoney().subtract(dto.getAmount());
+            saveBankFlow.setRemainingMoney(subtract);
+            if (BigDecimal.ZERO.compareTo(subtract) == 0){
+                saveBankFlow.setFlowStatus(1);
+            }
             tBankFlowService.updateById(saveBankFlow);
         }
         //存流水
@@ -518,5 +572,12 @@
         return this.baseMapper.batchBillCount(userId,billIds);
     }
 
-
+    /**
+     * 街道租金排行
+     * @return
+     */
+    @Override
+    public List<ScreenRentRankVO> getStreetRentRank() {
+        return baseMapper.getStreetRentRank();
+    }
 }

--
Gitblit v1.7.1