fix: 到期提醒提前天数;开发环境邮件发送关闭
This commit is contained in:
@@ -38,7 +38,7 @@ public interface LicenseMapper extends BaseMapperX<LicenseDO> {
|
|||||||
default List<LicenseDO> selectListByExpiryDate() {
|
default List<LicenseDO> selectListByExpiryDate() {
|
||||||
return selectList(new LambdaQueryWrapperX<LicenseDO>()
|
return selectList(new LambdaQueryWrapperX<LicenseDO>()
|
||||||
.gt(LicenseDO::getExpiryDate, LocalDateTime.now())
|
.gt(LicenseDO::getExpiryDate, LocalDateTime.now())
|
||||||
.le(LicenseDO::getExpiryDate, LocalDateTime.now().plusDays(8))
|
.le(LicenseDO::getExpiryDate, LocalDateTime.now().plusDays(7))
|
||||||
.eq(LicenseDO::getStatus, LicenseStatusEnum.COMPLETED.getCode())
|
.eq(LicenseDO::getStatus, LicenseStatusEnum.COMPLETED.getCode())
|
||||||
.orderByAsc(LicenseDO::getExpiryDate));
|
.orderByAsc(LicenseDO::getExpiryDate));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class LicenseTask {
|
|||||||
@Resource
|
@Resource
|
||||||
private NotifyMessageSendApi notifySendApi;
|
private NotifyMessageSendApi notifySendApi;
|
||||||
|
|
||||||
@Scheduled(cron = "*/6 * * * * ?")
|
@Scheduled(cron = "*/5 * * * * ?")
|
||||||
public void task() {
|
public void task() {
|
||||||
licenseService.genLicenseTask();
|
licenseService.genLicenseTask();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
package org.agt.module.system.service.mail;
|
package org.agt.module.system.service.mail;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.agt.framework.common.enums.CommonStatusEnum;
|
import org.agt.framework.common.enums.CommonStatusEnum;
|
||||||
import org.agt.framework.common.enums.UserTypeEnum;
|
import org.agt.framework.common.enums.UserTypeEnum;
|
||||||
import org.agt.module.system.dal.dataobject.mail.MailAccountDO;
|
import org.agt.module.system.dal.dataobject.mail.MailAccountDO;
|
||||||
@@ -10,17 +14,19 @@ import org.agt.module.system.mq.message.mail.MailSendMessage;
|
|||||||
import org.agt.module.system.mq.producer.mail.MailProducer;
|
import org.agt.module.system.mq.producer.mail.MailProducer;
|
||||||
import org.agt.module.system.service.member.MemberService;
|
import org.agt.module.system.service.member.MemberService;
|
||||||
import org.agt.module.system.service.user.AdminUserService;
|
import org.agt.module.system.service.user.AdminUserService;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import org.dromara.hutool.extra.mail.MailAccount;
|
||||||
import jakarta.annotation.Resource;
|
import org.dromara.hutool.extra.mail.MailUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.dromara.hutool.extra.mail.*;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.agt.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static org.agt.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static org.agt.module.system.enums.ErrorCodeConstants.*;
|
import static org.agt.module.system.enums.ErrorCodeConstants.MAIL_ACCOUNT_NOT_EXISTS;
|
||||||
|
import static org.agt.module.system.enums.ErrorCodeConstants.MAIL_SEND_MAIL_NOT_EXISTS;
|
||||||
|
import static org.agt.module.system.enums.ErrorCodeConstants.MAIL_SEND_TEMPLATE_PARAM_MISS;
|
||||||
|
import static org.agt.module.system.enums.ErrorCodeConstants.MAIL_TEMPLATE_NOT_EXISTS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 邮箱发送 Service 实现类
|
* 邮箱发送 Service 实现类
|
||||||
@@ -48,6 +54,13 @@ public class MailSendServiceImpl implements MailSendService {
|
|||||||
@Resource
|
@Resource
|
||||||
private MailProducer mailProducer;
|
private MailProducer mailProducer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮件的开关,默认为 true
|
||||||
|
*/
|
||||||
|
@Value("${agt.mail.enable:true}")
|
||||||
|
@Setter // 为了开发环境关闭邮件发送
|
||||||
|
private Boolean mailEnable;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long sendSingleMailToAdmin(String mail, Long userId,
|
public Long sendSingleMailToAdmin(String mail, Long userId,
|
||||||
String templateCode, Map<String, Object> templateParams) {
|
String templateCode, Map<String, Object> templateParams) {
|
||||||
@@ -92,7 +105,7 @@ public class MailSendServiceImpl implements MailSendService {
|
|||||||
Long sendLogId = mailLogService.createMailLog(userId, userType, mail,
|
Long sendLogId = mailLogService.createMailLog(userId, userType, mail,
|
||||||
account, template, content, templateParams, isSend);
|
account, template, content, templateParams, isSend);
|
||||||
// 发送 MQ 消息,异步执行发送短信
|
// 发送 MQ 消息,异步执行发送短信
|
||||||
if (isSend) {
|
if (isSend && mailEnable) {
|
||||||
mailProducer.sendMailSendMessage(sendLogId, mail, account.getId(),
|
mailProducer.sendMailSendMessage(sendLogId, mail, account.getId(),
|
||||||
template.getNickname(), title, content);
|
template.getNickname(), title, content);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,6 +203,8 @@ wx:
|
|||||||
agt:
|
agt:
|
||||||
captcha:
|
captcha:
|
||||||
enable: false # 本地环境,暂时关闭图片验证码,方便登录等接口的测试;
|
enable: false # 本地环境,暂时关闭图片验证码,方便登录等接口的测试;
|
||||||
|
mail:
|
||||||
|
enable: false # 本地环境,暂时关闭邮件发送;
|
||||||
security:
|
security:
|
||||||
mock-enable: true
|
mock-enable: true
|
||||||
pay:
|
pay:
|
||||||
|
|||||||
Reference in New Issue
Block a user