package cn.com.ty.lift.ud.task;

import cn.com.ty.lift.ud.userInfo.service.IUserInfoService;
import cn.com.ty.lift.ud.userInfo.service.impl.UserInfoServiceImpl;
import cn.com.ty.lift.ud.utils.ApplicationContextUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 定时取消会员
 * 
 * @author sKing
 *
 */

@Component
public class VipPeriodTask {

    private static final Logger logger = LoggerFactory.getLogger(VipPeriodTask.class);

    @Resource(type = UserInfoServiceImpl.class)
    private IUserInfoService iUserInfoService;
    /**
     * 每天晚上12点，定时取消会员
     * 线上必须用public ，本地用private也可以
     */
    @Scheduled(cron = "0 0 1 * * ?  ")
    public void cancelVip() {
        //@Autowired 注解不能导入
//         IUserInfoService iUserInfoService = ApplicationContextUtil.getBean(UserInfoServiceImpl.class);
       logger.info("开始调用取消会员方法");
        iUserInfoService.cancelOverTimeVip();
       logger.info("调用取消会员方法完成");

    }

}
