package com.ruoyi.cai.job;

import com.ruoyi.cai.service.DayIncomeStatisticsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDate;

@Component
@Slf4j
public class IncomeStatisticsJob {
    @Autowired
    private DayIncomeStatisticsService dayIncomeStatisticsService;
    @Scheduled(cron = "0 0/6 * * * ?")
    public void persistentDb() {
        try {
            dayIncomeStatisticsService.refreshByDate(LocalDate.now());
        }catch (Exception e){
            log.error("更新每日收益统计失败!",e);
        }

    }
}
