package com.ruoyi.job;

import com.ruoyi.model.service.IAppletOrderService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class OrderTimeoutNoticeJob {

    private static final Logger log = LoggerFactory.getLogger(OrderTimeoutNoticeJob.class);

    @Autowired
    private IAppletOrderService appletOrderService;

    /**
     * 每5分钟检查订单是否未接单超时
     */

    @Async
    @Scheduled(cron = "0 */5 * * * ?")
    // @Scheduled(cron = "0 * * * * ?")
    public void check(){
        log.info("定时任务[订单未接单超时检查]开始执行");
        //系统订单超过3小时未接单，通知管理员
        appletOrderService.systemOrderTimeoutNotice();
        //个人订单超过3小时未接单转成系统派单
        appletOrderService.personalSystemTransferOrder();
        log.info("定时任务[订单未接单超时检查]执行结束");
    }

}
