package com.gree.mall.miniapp.schedule;

import com.gree.mall.miniapp.logic.seckill.SecKillLogic;
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;

/**
 * 清除秒杀活动结束后的商品flag
 */
@ConditionalOnProperty(name = "schedule.enable", havingValue = "true", matchIfMissing = true)
@Component
public class SecGoodsSchedule {
    @Value("${spring.profiles.active}")
    private String env;
    @Autowired
    private SecKillLogic secKillLogic;
    @Scheduled(fixedDelay = 5*60*1000)
    public void task() throws ParseException {
        if(env.equals("dev")){
            return;
        }
        secKillLogic.goodsSecFlagUpdate();
    }
}
