package com.gree.mall.manager.schedule;



import com.gree.mall.manager.logic.SyncOrderInfoLogic;
import com.gree.mall.manager.logic.policy.AgreementLogic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.mail.MessagingException;
import java.io.IOException;

/**
 * 定时购买保险
 */
@ConditionalOnProperty(name = "schedule.enable", havingValue = "true", matchIfMissing = true)
@Component
public class SyncSchedule {


    @Autowired
    private SyncOrderInfoLogic syncOrderInfoLogic;



    //每小时执行1次
    @Scheduled(fixedDelay =10* 1000)
    public void task() throws IOException {
        syncOrderInfoLogic.syncGuang();
    }


    //监测今天是否有回执邮件，如果有则表示今天买保险的回执成功
    @Scheduled(fixedDelay = 10* 1000)
    public void task2() throws IOException, MessagingException {
        syncOrderInfoLogic.syncDetail();
    }



}
