package com.reptileclient.jlifeapp.schedule;

import cn.hutool.core.date.DateUtil;
import com.reptileclient.jlifeapp.entity.jz.JzBookOrder;
import com.reptileclient.jlifeapp.service.JzBookOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author fuxubing
 */
@Async
@Component
public class JzBookOrderTask_bak {
    private static final Logger logger = LoggerFactory.getLogger(JzBookOrderTask_bak.class);
    @Resource
    private JzBookOrderService jzBookOrderService;

    /**
     * 每天1点执行一次
     */
    @Scheduled(cron = "0 0 1 * * ?")
    public void runTask() {
        logger.info("开始执行同步盒马服务单数据");
        JzBookOrder jzBookOrder = jzBookOrderService.selectNewOne(null);

        try {
           // int row = jzBookOrderService.addBookOrderList();
            //logger.info("执行完成盒马服务单总条数：{}", row);
            //数据去重
            //jzBookOrderService.deleteDistinctData(null != jzBookOrder ? DateUtil.lastMonth() : null);
            //同步数据到customer_client
            //jzBookOrderService.insertClientByBatch(null != jzBookOrder ? jzBookOrder.getCreateTime() : null);
            //更新customer_id
            //jzBookOrderService.updateCustomerIdIsNull();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /**
     * 每天8点执行一次
     */
    @Scheduled(cron = "0 0 8 * * ?")
    public void runUpdateTask() {
        logger.info("开始执行更新盒马服务单数据");
       /* JzBookOrder jzBookOrder = jzBookOrderService.selectNewOne(null);

        try {
            int row = jzBookOrderService.updateBookOrder();
            logger.info("执行完成盒马服务单总条数：{}", row);
            //数据去重
            jzBookOrderService.deleteDistinctData(null != jzBookOrder ? DateUtil.lastMonth() : null);
            //同步数据到customer_client
            jzBookOrderService.insertClientByBatch(null != jzBookOrder ? jzBookOrder.getCreateTime() : null);
            //更新customer_id
            jzBookOrderService.updateCustomerIdIsNull();
        } catch (Exception e) {
            e.printStackTrace();
        }*/
    }
}
