KKSU
2024-11-26 c245fd8c67c75ebec392d52b29af7d532282a737
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package cc.mrbird.febs.common.listener;
 
import cc.mrbird.febs.mall.mapper.MallOrderInfoMapper;
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;
 
/**
 * @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);
//            }
//        }
    }
}