package cn.pluss.platform.job;

import cn.pluss.platform.officialActivity.OfficialActivityService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;

import java.util.Date;

@Configuration
@ConditionalOnProperty(prefix = "scheduling", name = "enabled", havingValue = "true")
public class merchantActivityJob {
    private Logger log = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private OfficialActivityService officialActivityService;

    @Scheduled(cron = "0 0 0 * * ? ")
//    @Scheduled(fixedDelay = 5 * 60 * 1000)
    public void merchantActivityQuery(){
        log.info("===============>检查官方活动是否到期定时任务开始<==================");
        Date dateTime = new Date();
        officialActivityService.updateActivicyStatus(dateTime);
        /*List<OfficialActivity> list = officialActivityService.list();
        for (OfficialActivity off: list) {
            if (dateTime.compareTo(off.getEndTime()) != -1){
                off.setStatus("3");
                officialActivityService.updateById(off);
            }
        }*/
        log.info("===============>检查官方活动是否到期定时任务结束<==================");
    }
}