package com.gree.mall.manager.schedule;

import com.gree.mall.manager.logic.common.WxPubNoticeLogic;
import lombok.extern.slf4j.Slf4j;
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;

@ConditionalOnProperty(name = "schedule.enable", havingValue = "true", matchIfMissing = true)
@Slf4j
@Component
public class WxNoticeSchedule {

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

    /**
     * 发送模板通知
     */
    @Scheduled(fixedDelay = 10 *1000)
    public void task2(){
        if(env.equals("test") || env.equals("prd"))
            wxPubNoticeLogic.push();
    }

}
