package com.kxs.daemon.quartz.task;

import com.kxs.common.core.constant.SecurityConstants;
import com.kxs.daemon.quartz.constants.SkyQuartzEnum;
import com.kxs.system.api.feign.RemoteSysService;
import com.kxs.system.api.feign.RemoteUserService;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * 训练营-百城千团定时任务
 */
@Slf4j
@Component("campBcqtBeanTask")
@RequiredArgsConstructor
public class CampBcqtBeanTask {
    private final RemoteSysService remoteSysService;
    /**
     *  关闭活动结束的team和用户状态
     */
    @SneakyThrows
    public String setUserActiviteStatus(String para) {
        log.info("百城千团定时扫描关闭活动结束的team和用户状态:{}，输入参数{}", LocalDateTime.now(), para);
        try {
            remoteSysService.setUserActiviteStatus(SecurityConstants.FROM_IN);
            return SkyQuartzEnum.JOB_LOG_STATUS_SUCCESS.getType();

        }catch (Exception e){
            log.error(e.getLocalizedMessage());
        }
        return SkyQuartzEnum.JOB_LOG_STATUS_FAIL.getType();

    }

    @SneakyThrows
    public String setUserActivityTimeStat(String para) {
        log.info("百城千团定时统计活动期间人员激活:{}，输入参数{}", LocalDateTime.now(), para);
        try {
            remoteSysService.setUserActivityTimeStat(SecurityConstants.FROM_IN);
            return SkyQuartzEnum.JOB_LOG_STATUS_SUCCESS.getType();

        }catch (Exception e){
            log.error(e.getLocalizedMessage());
        }
        return SkyQuartzEnum.JOB_LOG_STATUS_FAIL.getType();

    }
}
