package cn.com.ctop.job.kuaishou.handler;


import cn.com.ctop.common.module.utils.HttpUtils;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.jeecg.common.util.DateUtils;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * 达人补全定时
 */
@Component
public class KwaiJob {

    @XxlJob("queryAndInsertSkuNowDay")
    public void queryAndInsertSkuNowDay() throws Exception {
        String today = DateUtils.date2Str();
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("date", today);
        HttpUtils.httpGet("http://ruixuan.api.bjhcstszkj.cn/kwaixiaodian/jst/queryAndInsertSku", paramMap, null);
    }

    @XxlJob("queryAndInsertSkuYesterday")
    public void queryAndInsertSkuYesterday() throws Exception {
        String today = DateUtils.date2Str();
        //t-1 昨天
        String yesterday = DateUtils.getLastDay(today, 1);
        //t-2
        String beginDate = DateUtils.getLastDay(today, 2);

        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("date", yesterday);
        HttpUtils.httpGet("http://ruixuan.api.bjhcstszkj.cn/kwaixiaodian/jst/queryAndInsertSku", paramMap, null);

        paramMap.put("date", beginDate);
        HttpUtils.httpGet("http://ruixuan.api.bjhcstszkj.cn/kwaixiaodian/jst/queryAndInsertSku", paramMap, null);

    }

    @XxlJob("queryAndInsertPurchaseNowDay")
    public void queryAndInsertPurchaseNowDay() throws Exception {
        String today = DateUtils.date2Str();
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("date", today);
        HttpUtils.httpGet("http://ruixuan.api.bjhcstszkj.cn/kwaixiaodian/jst/queryAndInsertPurchase", paramMap, null);
    }

    @XxlJob("queryAndInsertPurchaseYesterday")
    public void queryAndInsertPurchaseYesterday() throws Exception {
        String today = DateUtils.date2Str();
        //t-1 昨天
        String yesterday = DateUtils.getLastDay(today, 1);
        //t-2
        String beginDate = DateUtils.getLastDay(today, 2);

        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("date", yesterday);
        HttpUtils.httpGet("http://ruixuan.api.bjhcstszkj.cn/kwaixiaodian/jst/queryAndInsertPurchase", paramMap, null);
        paramMap.put("date", beginDate);
        HttpUtils.httpGet("http://ruixuan.api.bjhcstszkj.cn/kwaixiaodian/jst/queryAndInsertPurchase", paramMap, null);
    }

}
