BUGFIX: 试用订单邮件发送,区分环境

This commit is contained in:
2025-09-17 11:33:25 +08:00
parent b9c24386b9
commit 3c1d180ed6

View File

@@ -22,6 +22,8 @@ import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.security.core.parameters.P;
@@ -157,6 +159,8 @@ public class MyTaskScheduler {
private PortfolioMapper portfolioMapper;
@Resource
private CollectionSortService collectionSortService;
@Autowired
private Environment environment;
// 定时任务,每十五天执行一次
// @Scheduled(cron = "0 0 0 ? * MON")
@@ -188,7 +192,9 @@ public class MyTaskScheduler {
long thirtyDaysInMillis = 30L * 24 * 60 * 60 * 1000;
boolean within30Days = timeDifference <= thirtyDaysInMillis;
if (within30Days) {
String[] activeProfiles = environment.getActiveProfiles();
boolean env = activeProfiles.length == 1 && Objects.equals(activeProfiles[0], "prod");
if (within30Days && env) {
// 发邮件
SendEmailUtil.sendWillBeExpiredEmail(account, null);
}
@@ -204,7 +210,9 @@ public class MyTaskScheduler {
qw.lambda().between(TrialOrder::getCreateTime, yesterday.atStartOfDay(), yesterday.atTime(23, 59, 59));
List<TrialOrder> trialOrders = trialOrderMapper.selectList(qw);
if (!trialOrders.isEmpty()) {
String[] activeProfiles = environment.getActiveProfiles();
boolean env = activeProfiles.length == 1 && Objects.equals(activeProfiles[0], "prod");
if (!trialOrders.isEmpty() && env) {
// 创建Excel工作簿
try (Workbook workbook = new XSSFWorkbook()) {
// 创建工作表