From b93a0b2565a82984b4843fa31c2c764fcdd43aef Mon Sep 17 00:00:00 2001 From: yupeng <roc__yu@163.com> Date: 星期四, 27 二月 2025 11:45:48 +0800 Subject: [PATCH] feat: 完善后台批量发送邮件接口 --- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java | 17 +++++++++++------ 1 files changed, 11 insertions(+), 6 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..2d13e31 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; @@ -30,6 +31,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 +81,9 @@ @Resource SmsUtil smsUtil; + + @Resource + TencentMailUtil mailUtil; public PageInfo<TBillDto> queryPage(TBillQuery query){ PageInfo<TBill> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); @@ -359,7 +364,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 +393,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 +405,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 +418,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