package com.kxs.daemon.quartz.task;

import cn.hutool.core.util.NumberUtil;
import com.kxs.common.core.constant.SecurityConstants;
import com.kxs.daemon.quartz.constants.SkyQuartzEnum;
import com.kxs.stat.api.feign.RemoteKxsStatService;
import com.kxs.user.api.feign.RemoteKxsUserService;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * 用户模块 Bean 任务
 *
 * @author 没秃顶的码农
 * @date 2024-03-21
 */
@Slf4j
@Component("statjob")
@RequiredArgsConstructor
public class StatBeanTask {


    private final RemoteKxsStatService remoteKxsStatService;

    /**
     * 股东大盘分红积分计算任务
     */
    @SneakyThrows
    public String dividendPointsCalculationTask(String para) {
        try {
            if (!NumberUtil.isNumber(para)) {
                para = "";
            }
            remoteKxsStatService.shdUserTradeTotalList(para, SecurityConstants.FROM_IN);
            log.info("股东大盘分红积分计算任务:{}，输入参数{}", LocalDateTime.now(), para);
            return SkyQuartzEnum.JOB_LOG_STATUS_SUCCESS.getType();
        } catch (Exception e) {
            log.error("股东大盘分红积分计算任务执行失败，输入参数{}：", para);
        }
        return SkyQuartzEnum.JOB_LOG_STATUS_FAIL.getType();
    }
}
