From 7685af4ed67c693d197393f56f392d7b12434853 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期四, 27 二月 2025 16:43:42 +0800
Subject: [PATCH] Merge branch 'master' of https://gitee.com/xiaochen991015/xizang

---
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 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..fd4ec65 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;
@@ -9,6 +10,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;
@@ -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());
@@ -359,9 +365,9 @@
     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)){
+                    && (System.currentTimeMillis()-bill.getSmsLastTime().getTime()<mailUtil.getPro().getBillSmsDelayPeriod()*60*1000L)){
                 throw new ServiceException("有账单最近一次发送的时间是:"+DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,bill.getSmsLastTime()));
             }
             if (StringUtils.isEmpty(bill.getPhone())){
@@ -388,9 +394,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 +406,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 +419,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