From ae17fedf4c852aa0a0f87e635231d90a5b88f48e Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期四, 06 三月 2025 16:49:25 +0800
Subject: [PATCH] 权限

---
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java |   63 ++++++++++++++++++++-----------
 1 files changed, 40 insertions(+), 23 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 6da60f4..e70e065 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
@@ -2,6 +2,7 @@
 
 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;
@@ -18,8 +19,6 @@
 import com.ruoyi.system.query.TInvoiceToBillQuery;
 import com.ruoyi.system.service.*;
 import com.taxi591.bankapi.dto.ChargeBillRequest;
-import com.tencentcloudapi.sms.v20190711.SmsClient;
-import com.tencentcloudapi.sms.v20190711.models.SendSmsRequest;
 import lombok.extern.slf4j.Slf4j;
 import org.jetbrains.annotations.NotNull;
 import org.springframework.beans.BeanUtils;
@@ -29,12 +28,15 @@
 
 import javax.annotation.Resource;
 import javax.validation.constraints.NotEmpty;
-import java.util.*;
-import java.util.stream.Collectors;
 import java.math.BigDecimal;
 import java.text.ParseException;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Date;
 import java.util.List;
 import java.util.function.Consumer;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -169,7 +171,7 @@
                             BigDecimal result = presist.getPayFeesMoney().add(tBill.getPayFeesMoney());
                             save.setPayFeesMoney(result);
                             //缴费后的欠费 =(应缴费+违约金)-已缴费金额
-                            BigDecimal outstand = save.getPayableFeesMoney()
+                            BigDecimal outstand = presist.getPayableFeesMoney()
                                     .add(presist.getPayableFeesPenalty())
                                     .subtract(save.getPayFeesMoney());
                             save.setOutstandingMoney(outstand);
@@ -241,7 +243,7 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean checkOfflinePay(OfflinePayCheckDto dto) {
-        TBankFlow bankflow = tBankFlowService.getById(dto.getTBankFlow().getId());
+        TBankFlow bankflow = tBankFlowService.getById(dto.getFlowId());
         TBillDto bill = getDetailByBillId(dto.getBillId());
         if (bankflow.getRemainingMoney().compareTo(BigDecimal.ZERO)<=0){
             throw new ServiceException("该流水已无可抵扣剩余金额");
@@ -257,8 +259,8 @@
         TBill billSave = new TBill();
         billSave.setId(bill.getId());
         billSave.setPayFeesMoney(dto.getAmount());
-        billSave.setBankSerialNumber(dto.getTBankFlow().getBankSerialNumber());
-        billSave.setPayFeesTime(dto.getTBankFlow().getPayTime());
+        billSave.setBankSerialNumber(bankflow.getBankSerialNumber());
+        billSave.setPayFeesTime(bankflow.getPayTime());
         billSave.setVoucher(dto.getVoucher());
         billSave.setPayFeesType(2);
         TBill back = lockAndUpdateInfo(billSave, 2);
@@ -273,8 +275,8 @@
         TFlowManagement save = new TFlowManagement();
         save.setPayType(3);
         save.setPayer(dto.getPayer());
-        save.setPayTime(dto.getTBankFlow().getPayTime());
-        save.setBankSerialNumber(dto.getTBankFlow().getBankSerialNumber());
+        save.setPayTime(bankflow.getPayTime());
+        save.setBankSerialNumber(bankflow.getBankSerialNumber());
         save.setFlowType(2);
         save.setPaymentBillId(back.getId());
         save.setDeductionMoney(back.getDeductionMoney());
@@ -358,16 +360,18 @@
      * @return
      */
     @Override
-    public PageInfo<TBill> getBillByInvoiceId(String invoiceId){
-        invoiceId = "1889552849671061505";
-        PageInfo<TBill> pageInfo = new PageInfo<>();
-        ArrayList<TBill> bills = new ArrayList<>();
+    public PageInfo<TBillDto> getBillByInvoiceId(String invoiceId){
+        PageInfo<TBillDto> pageInfo = new PageInfo<>();
+        ArrayList<TBillDto> bills = new ArrayList<>();
         TInvoiceToBillQuery query = new TInvoiceToBillQuery();
         query.setInvoiceId(invoiceId);
         List<TInvoiceToBill> tInvoiceToBills = tInvoiceToBillService.makeQuery(query);
         for (TInvoiceToBill tInvoiceToBill : tInvoiceToBills) {
-            TBill byId = getById(tInvoiceToBill.getBillId());
-            bills.add(byId);
+            TBill bill = getById(tInvoiceToBill.getBillId());
+            if (bill != null && bill.getId() != null){
+                TBillDto detailByBillId = getDetailByBillId(bill.getId());
+                bills.add(detailByBillId);
+            }
         }
         pageInfo.setRecords(bills);
         return pageInfo;
@@ -380,7 +384,7 @@
         int failNum = 0;
         for (String billId : dto.getBillIds()) {
             TBillDto bill = getDetailByBillId(billId);
-            if (bill.getSmsLastTime()!=null
+            if (bill.getSmsLastTime()!=null && bill.getSmsStatus()==1
                     && (System.currentTimeMillis()-bill.getSmsLastTime().getTime()<smsUtil.getPro().getBillSmsDelayPeriod()*60*1000L)){
                 throw new ServiceException("有账单最近一次发送的时间是:"+DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,bill.getSmsLastTime()));
             }
@@ -409,7 +413,7 @@
         int failNum = 0;
         for (String billId : dto.getBillIds()) {
             TBillDto bill = getDetailByBillId(billId);
-            if (bill.getMailLastTime()!=null
+            if (bill.getMailLastTime()!=null && bill.getMailStatus()==1
                     && (System.currentTimeMillis()-bill.getMailLastTime().getTime()<mailUtil.getPro().getBillMailDelayPeriod()*60*1000L)){
                 throw new ServiceException("有账单最近一次发送的时间是:"+DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,bill.getMailLastTime()));
             }
@@ -448,7 +452,10 @@
         TBill back = null;
         TBankFlow bankflow = null;
         if (dto.getPayType()==1){
-            bankflow = tBankFlowService.getById(dto.getTBankFlow().getId());
+            if (StringUtils.isEmpty(dto.getFlowId())){
+                throw new ServiceException("银行流水不能为空");
+            }
+            bankflow = tBankFlowService.getById(dto.getFlowId());
             TBillDto bill = getDetailByBillId(dto.getBillId());
             if (bankflow.getRemainingMoney().compareTo(BigDecimal.ZERO)<=0){
                 throw new ServiceException("该流水已无可抵扣剩余金额");
@@ -465,8 +472,8 @@
         TBill billSave = new TBill();
         billSave.setId(bill.getId());
         billSave.setPayFeesMoney(dto.getAmount());
-        billSave.setBankSerialNumber(dto.getTBankFlow().getBankSerialNumber());
-        billSave.setPayFeesTime(dto.getTBankFlow().getPayTime());
+        billSave.setBankSerialNumber(bankflow!=null?bankflow.getBankSerialNumber():null);
+        billSave.setPayFeesTime(bankflow!=null?bankflow.getPayTime():DateUtils.dateToLocalDateTime(new Date()));
         billSave.setVoucher(dto.getVoucher());
         billSave.setPayFeesType(2);
         back = lockAndUpdateInfo(billSave, 2);
@@ -482,8 +489,8 @@
         TFlowManagement save = new TFlowManagement();
         save.setPayType(3);
         save.setPayer(dto.getPayer());
-        save.setPayTime(dto.getTBankFlow().getPayTime());
-        save.setBankSerialNumber(dto.getTBankFlow().getBankSerialNumber());
+        save.setPayTime(bankflow!=null?bankflow.getPayTime():DateUtils.dateToLocalDateTime(new Date()));
+        save.setBankSerialNumber(bankflow!=null?bankflow.getBankSerialNumber():null);
         save.setFlowType(dto.getPayType()==1?2:1);
         save.setPaymentBillId(back.getId());
         save.setDeductionMoney(back.getDeductionMoney());
@@ -494,5 +501,15 @@
         return true;
     }
 
+    @Override
+    public BillStatisticsDto statistics() {
+        BillStatisticsDto dto = new BillStatisticsDto();
+        dto.setRent(getBaseMapper().statisticsAllRent());
+        dto.setNopay(getBaseMapper().statisticsNoPay());
+        dto.setPayed(getBaseMapper().statisticsPayed());
+        dto.setOverdue(getBaseMapper().statisticsOverdue());
+        return dto;
+    }
+
 
 }

--
Gitblit v1.7.1