package com.gree.mall.miniapp.schedule;

import com.gree.mall.miniapp.logic.order.OrderLogic;
import com.gree.mall.miniapp.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.ParseException;
import java.util.Date;


/**
 * 订单超时取消
 */
@ConditionalOnProperty(name = "schedule.enable", havingValue = "true", matchIfMissing = true)
@Component
public class OrderTimeOutSchedule {

    @Value("${spring.profiles.active}")
    private String env;
    @Autowired
    OrderLogic orderLogic;

    @Scheduled(fixedDelay = 2000)
    public void task() throws ParseException {
        if(env.equals("dev")){
            return;
        }
        orderLogic.timeoutOrder();
    }

}
