package com.yiqi.task;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import com.yiqi.common.core.redis.RedisUtils;
import com.yiqi.common.utils.DateUtils;
import com.yiqi.delay.DelayMessage;
import com.yiqi.delay.DelayQueueCache;
import com.yiqi.delay.impl.DelayTaskRunService;
import com.yiqi.lock.RedisLockUtil;
import com.yiqi.order.domain.OrderCloth;
import com.yiqi.order.service.IOrderClothService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;
import java.util.Set;
import java.util.concurrent.ExecutorService;

/**
 * @author douya
 * @description 订单状态变更逻辑
 * @date 2022/5/19
 */
@Component
@Slf4j
public class ClothOrderStatusChangeTask {

    protected final Logger logger = LoggerFactory.getLogger(ClothOrderStatusChangeTask.class);

    @Resource
    private DelayQueueCache delayQueueCache;

    @Resource
    private RedisUtils redisUtils;

    @Resource
    private IOrderClothService orderClothService;

    /**
     * 订单状态变更逻辑，每5分钟执行一次，扫描任务，如果到期则执行任务
     * 所有衣服 入厂 -> 变成清洗中
     */
    public void run() {
        log.info("*****订单状态变更逻辑开始执行*****");
        orderClothService.checkAllOrderStatus(null, null);
    }
}
