package org.dromara.main.task;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.main.service.ICsOrderCardService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@RequiredArgsConstructor
@Component
public class OrderCardExpireTask {

    private final ICsOrderCardService orderCardService;

    /**
     * 每5秒检查一次过期结算单
     * 检查状态为pending且已超过过期时间的结算单，将其状态更新为expired
     */
    @Scheduled(fixedRate = 5000)
    public void checkExpiredOrderCards() {
        try {
            orderCardService.checkExpiredOrderCards();
        } catch (Exception e) {
            log.error("检查过期结算单失败", e);
        }
    }
}
