|
@@ -2,7 +2,9 @@ package com.gree.mall.manager.schedule;
|
|
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.gree.mall.manager.logic.policy.AgreementLogic;
|
|
|
+import org.apache.http.client.utils.DateUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
@@ -10,6 +12,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.mail.MessagingException;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.Date;
|
|
|
|
|
|
/**
|
|
|
* 定时购买保险
|
|
@@ -25,8 +28,17 @@ public class InsureEmailSchedule {
|
|
|
|
|
|
|
|
|
//每小时执行1次
|
|
|
- @Scheduled(cron = "0 0/5 8,20 * * ?")
|
|
|
+ @Scheduled(fixedDelay = 600* 1000)
|
|
|
public void task() throws IOException {
|
|
|
+
|
|
|
+ Date startTime = DateUtil.parseDateTime(DateUtils.formatDate(new Date(),"yyyy-MM-dd") +" "+"08:00:00");
|
|
|
+ Date endTime = DateUtil.parseDateTime(DateUtils.formatDate(new Date(),"yyyy-MM-dd") +" "+"20:00:00");
|
|
|
+
|
|
|
+ if (new Date().before(startTime))
|
|
|
+ return;
|
|
|
+ if (new Date().after(endTime))
|
|
|
+ return;
|
|
|
+
|
|
|
agreementLogic.sendEmailSche();
|
|
|
agreementLogic.sendEmailScheEM();
|
|
|
agreementLogic.sendEmailScheIN();
|