package com.kiisoo.ic.store.service;

import com.kiisoo.ic.utils.DateUtils;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @author jinchaofan
 * @date 2019/4/28 15:20
 * @company kiisoo
 * @details 获取联系客户统计数据定时任务 job 0 0 1 * * ?
 */
@Service
@Slf4j
public class StorePromotionDataJob {

    /**
     * 客流定时任务 service
     */
    @Autowired
    private StorePromotionDataService storePromotionDataService;

    @Scheduled(cron = "0 0 1 * * ?")
    public void syncData(){
        try {
            log.info("<--获取联系客户统计数据定时任务执行-->");
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            List<Date> getdays = DateUtils.getdays(DateUtils.addDay(new Date(),-3), DateUtils.addDay(new Date(),-1));
            for (Date date:getdays){
                storePromotionDataService.syncCustomerBlackListByDate(date,date);
            }
            log.info("<--获取联系客户统计数据定时任务结束-->");
        } catch (Exception e) {
            log.error("获取联系客户统计数据任务出错", e);
        }
    }


}
