package cn.pluss.platform.job;

import cn.pluss.platform.user.UserProfitService;
import cn.pluss.platform.userRewardFlow.UserRewardFlowService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.Resource;

/**
 *
 * 统计前一天用户交易分润
 *@author: bzg
 *@time: 2022/1/14 14:07
 */
@Slf4j
@Configuration
@ConditionalOnProperty(prefix = "scheduling", name = "enabled", havingValue = "true")
public class CalcUserProfitJob {


    @Resource
    private UserProfitService userProfitService;

    @Resource
    private UserRewardFlowService userRewardFlowService;

    /**
     * 每天24点10分统计上一个交易日所产生的分润
     * @date: 2022/1/14 14:14
     */
    @Scheduled(cron = "0 10 0 * * ?")
    public void calcProftTask(){
        log.info("~~~~~~~~统计所有用户前一天的流水以及分润定时任务开始~~~~~~~~~~~~~");
        userProfitService.createProfitV2(null);
        log.info("~~~~~~~~统计所有用户前一天的流水以及分润定时任务结束~~~~~~~~~~~~");
    }

    /**
     * 统计用户管理奖收益
     */
    @Scheduled(cron = "30 0 0 * * ?")
    public void calcManageProftTask(){
        log.info("统计用户管理奖定时任务开始");
        userRewardFlowService.countManageProfit();
        log.info("统计用户管理奖定时任务结束");
    }
}
