package cn.iocoder.yudao.module.crm.job.salesperformance;

import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
import cn.iocoder.yudao.module.crm.service.salesperformancesettlement.SalesPerformanceSettlementService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Slf4j
public class GenerateSalesPerformanceJob {

    // TODO: 2024/11/04  - 每个月最后一天晚上11点半 执行一次
    @Resource
    private SalesPerformanceSettlementService salesPerformanceSettlementService;

    @XxlJob("generateSalesPerformanceJob")
    @TenantJob // --- ⚠️ 这个注解 会将租户列表拉出来 完了后逐个租户执行 定时任务需要注意
    public ReturnT<String> execute() {
        log.info("开始 生产下一个月的销售业绩");
        salesPerformanceSettlementService.generateSalesPerformanceJob();
        log.info("结束 生产下一个月的销售业绩");
        return ReturnT.SUCCESS;
    }
}
