From 1fe1ac0e09132e0147e48007986be235e4130aa1 Mon Sep 17 00:00:00 2001
From: zhangmei <645025773@qq.com>
Date: 星期五, 28 二月 2025 12:54:12 +0800
Subject: [PATCH] 分页查询更改

---
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java |   32 ++++++++++++++++++++------------
 1 files changed, 20 insertions(+), 12 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 88b06ed..d29baf1 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
@@ -9,6 +9,7 @@
 import com.ruoyi.common.utils.DateUtils;
 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.OfflinePayCheckDto;
 import com.ruoyi.system.dto.SmsByBillDto;
@@ -19,6 +20,7 @@
 import com.ruoyi.system.query.TBillQuery;
 import com.ruoyi.system.query.TInvoiceToBillQuery;
 import com.ruoyi.system.service.*;
+import com.ruoyi.system.vo.TBillVO;
 import com.taxi591.bankapi.dto.ChargeBillRequest;
 import com.tencentcloudapi.sms.v20190711.SmsClient;
 import com.tencentcloudapi.sms.v20190711.models.SendSmsRequest;
@@ -30,6 +32,7 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import javax.validation.constraints.NotEmpty;
 import java.util.*;
 import java.util.stream.Collectors;
 import java.math.BigDecimal;
@@ -79,6 +82,9 @@
 
     @Resource
     SmsUtil smsUtil;
+
+    @Resource
+    TencentMailUtil mailUtil;
 
     public PageInfo<TBillDto> queryPage(TBillQuery query){
         PageInfo<TBill> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
@@ -338,16 +344,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;
@@ -359,7 +367,7 @@
     public Integer sendSmsByBillIds(SmsByBillDto dto) {
         int failNum = 0;
         for (String billId : dto.getBillIds()) {
-            TBillDto bill = getTenentByBillId(billId);
+            TBillDto bill = getDetailByBillId(billId);
             if (bill.getSmsLastTime()!=null
                     && (System.currentTimeMillis()-bill.getSmsLastTime().getTime()<smsUtil.getPro().getBillSmsDelayPeriod()*60*1000L)){
                 throw new ServiceException("有账单最近一次发送的时间是:"+DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,bill.getSmsLastTime()));
@@ -388,9 +396,9 @@
     public Integer sendMailBatchByBillIds(SmsByBillDto dto) {
         int failNum = 0;
         for (String billId : dto.getBillIds()) {
-            TBillDto bill = getTenentByBillId(billId);
+            TBillDto bill = getDetailByBillId(billId);
             if (bill.getSmsLastTime()!=null
-                    && (System.currentTimeMillis()-bill.getSmsLastTime().getTime()<smsUtil.getPro().getBillMailDelayPeriod()*60*1000L)){
+                    && (System.currentTimeMillis()-bill.getSmsLastTime().getTime()<mailUtil.getPro().getBillMailDelayPeriod()*60*1000L)){
                 throw new ServiceException("有账单最近一次发送的时间是:"+DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,bill.getSmsLastTime()));
             }
             if (StringUtils.isEmpty(bill.getEmail())){
@@ -400,7 +408,7 @@
             TBill save = new TBill();
             save.setId(bill.getId());
             try {
-                //todo  发送邮件
+                mailUtil.send(bill.getEmail(),bill.getHouseName());
                 save.setMailStatus(1);
             }catch (ServiceException e){
                 failNum++;
@@ -413,8 +421,8 @@
         return failNum;
     }
 
-    private TBillDto getTenentByBillId(String billId) {
-        return getBaseMapper().selectTenentByBillId(billId);
+    public TBillDto getDetailByBillId(@NotEmpty String billId) {
+        return getBaseMapper().selectDetailByBillId(billId);
     }
 
 

--
Gitblit v1.7.1