| package cc.mrbird.febs.common.listener; | 
|   | 
| import cc.mrbird.febs.common.enumerates.OrderStatusEnum; | 
| import cc.mrbird.febs.common.utils.AppContants; | 
| import cc.mrbird.febs.mall.entity.MallOrderInfo; | 
| import cc.mrbird.febs.mall.mapper.MallOrderInfoMapper; | 
| import cn.hutool.core.util.StrUtil; | 
| import lombok.RequiredArgsConstructor; | 
| import lombok.extern.slf4j.Slf4j; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.data.redis.connection.Message; | 
| import org.springframework.data.redis.listener.KeyExpirationEventMessageListener; | 
| import org.springframework.data.redis.listener.RedisMessageListenerContainer; | 
| import org.springframework.stereotype.Component; | 
|   | 
| import java.util.List; | 
|   | 
| /** | 
|  * @author wzy | 
|  * @date 2021-04-16 | 
|  **/ | 
| @Slf4j | 
| @Component | 
| public class RedisKeyExpirationListener extends KeyExpirationEventMessageListener { | 
|   | 
|     public RedisKeyExpirationListener(RedisMessageListenerContainer listenerContainer) { | 
|         super(listenerContainer); | 
|     } | 
|   | 
|     @Autowired | 
|     private MallOrderInfoMapper mallOrderInfoMapper; | 
|   | 
|     @Override | 
|     public void onMessage(Message message, byte[] pattern) { | 
| //        String expireKey = message.toString(); | 
| //        if (expireKey.startsWith(AppContants.REDIS_ORDER_OVERTIME_PREFIX)) { | 
| //            List<String> split = StrUtil.split(expireKey, '_'); | 
| //            if (split.size() < 4) { | 
| //                log.error("自动取消订单失效:{}", expireKey); | 
| //                return; | 
| //            } | 
| //            Long memberId = Long.valueOf(split.get(2)); | 
| //            Long orderId = Long.valueOf(split.get(3)); | 
| // | 
| //            MallOrderInfo orderInfo = mallOrderInfoMapper.selectOrderByMemberIdAndId(memberId, orderId); | 
| //            if (orderInfo == null) { | 
| //                log.error("自动取消订单参数错误:{}", expireKey); | 
| //                return; | 
| //            } | 
| //            if (orderInfo.getStatus() == OrderStatusEnum.WAIT_PAY.getValue()) { | 
| //                log.info("自动取消订单:{},{}", memberId, orderId); | 
| //                orderInfo.setStatus(OrderStatusEnum.CANCEL.getValue()); | 
| //                orderInfo.setCancelType(MallOrderInfo.CANCEL_OVERTIME_NO_PAY); | 
| //                mallOrderInfoMapper.updateById(orderInfo); | 
| //            } | 
| //        } | 
|     } | 
| } |