//package org.springblade.modules.finance.listener;
//
//import lombok.extern.slf4j.Slf4j;
//import org.springblade.common.constant.CacheBizConstant;
//import org.springblade.modules.finance.service.IOrderService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.connection.Message;
//import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
//import org.springframework.data.redis.listener.RedisMessageListenerContainer;
//
///**
// * Author pangqijun
// * Date 2023/6/7
// * Description 通过监听redis的过期时间来实现订单超时处理
// */
//@Configuration
//@Slf4j
//public class OrderTimeoutListener extends KeyExpirationEventMessageListener {
//
//    @Autowired
//    private IOrderService orderService;
//
//
//    public OrderTimeoutListener(RedisMessageListenerContainer listenerContainer) {
//        super(listenerContainer);
//    }
//
//    @Override
//    public void onMessage(Message message, byte[] pattern) {
//        String expiredKey = message.toString();
//        log.info("过期key[{}]", expiredKey);
//        if (expiredKey.startsWith(CacheBizConstant.ORDER_TIMEOUT_PREFIX)) {
//            String[] split = expiredKey.split(":");
//            Long orderId = Long.parseLong(split[2]);
//            log.info("处理超时订单,orderId[{}]", orderId);
//            orderService.orderTimeout(orderId, null);
//        }
//    }
//}
