package com.ssj.task;


import com.ssj.framework.core.util.SystemResourceLocator;
import com.ssj.service.conch.conch.service.IntegralDetailService;
import com.ssj.service.weixin.library.service.IBookDetailService;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@DisallowConcurrentExecution
@Component
public class BookOverTimeTask implements Job {

    private static Logger logger = LoggerFactory.getLogger(BookOverTimeTask.class);

    @Override
    public void execute(JobExecutionContext jobExecutionContext)  {

        //书籍将过期
        try {
            IBookDetailService detailService = SystemResourceLocator.getBean(IBookDetailService.class);
            logger.info("推送书籍将过期任务开始");
            detailService.sendBookOverMsg();
        } catch (Exception e) {
            logger.error("推送书籍将过期任务异常-->"+e.getMessage());
        }finally{
            logger.info("推送书籍将过期任务结束");
        }

        //服务过期60天,积分清0
        try {
            IntegralDetailService integralDetailService = SystemResourceLocator.getBean(IntegralDetailService.class);
            logger.info("服务过期60天积分清0任务开始");
            integralDetailService.clearTowMonthIntegral();
        } catch (Exception e) {
            logger.error("服务过期60天积分清0异常-->"+e.getMessage());
        }finally{
            logger.info("服务过期60天积分清0结束");
        }
    }

}
