package com.lightinit.hsdataplatform.tasks;

import com.lightinit.hsdataplatform.service.task.IOrdersAndContractExpireTaskService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

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


/**
 * @Author: sunxiang
 * @Date: 2018/10/12 10:51
 * @Description: 定时任务：对已付款的三天后到期的订单和三天后讲到到期的合同进行提醒
 **/
@Component("ordersAndContractExpireTask")
public class OrdersAndContractExpireTask {

    private static final int PERIODDAY=3;//设置距离过期时间
    private static Logger logger=LoggerFactory.getLogger(OrdersAndContractExpireTask.class);
    @Autowired
    private IOrdersAndContractExpireTaskService ordersAndContractExpireTaskService;
    /*
    *@Description 三天后到期的订单提醒
    *@Param
    *@Date 2018/10/12
    *@return
    **/
    public void orderExpireWarningTask(){
        try {
            ordersAndContractExpireTaskService.getExpiringOrder(PERIODDAY);
        }catch(Exception e){
            e.printStackTrace();
            DateFormat instance = SimpleDateFormat.getInstance();
            logger.error(instance.format(new Date())+"------------------------订单提醒失败,请手动操作");
        }
    }

   /* public void contractExpireWarning(){

    }*/
}
