package com.cf.imes.module.system.job.pay;

import cn.hutool.core.text.CharSequenceUtil;
import com.cf.imes.module.system.service.pay.PayOrderService;
import com.xxl.job.core.handler.annotation.XxlJob;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 支付订单的过期 Job
 *
 * 支付超过过期时间时，支付渠道是不会通知进行过期，所以需要定时进行过期关闭。
 *
 * @author
 */
@Component
@Slf4j
public class PayOrderExpireJob {

    @Resource
    private PayOrderService payOrderService;

    @XxlJob("payOrderExpireJob")
    public String execute() {
        int count = payOrderService.expirePayOrder();
        if (count > 0) {
            log.info("[execute][支付过期 ({}) 个]", count);
        }
        return CharSequenceUtil.format("支付过期 ({}) 个", count);
    }

}
