|
|
|
@ -4,9 +4,9 @@ import com.xhm.wjnft.domain.WjCollection;
|
|
|
|
|
import com.xhm.wjnft.domain.WjOrder; |
|
|
|
|
import com.xhm.wjnft.domain.WjPayInfo; |
|
|
|
|
import com.xhm.wjnft.mapper.WjCollectionMapper; |
|
|
|
|
import com.xhm.wjnft.mapper.WjMyCollectionMapper; |
|
|
|
|
import com.xhm.wjnft.mapper.WjOrderMapper; |
|
|
|
|
import com.xhm.wjnft.mapper.WjPayInfoMapper; |
|
|
|
|
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; |
|
|
|
@ -15,6 +15,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
|
|
@Slf4j |
|
|
|
|
@Component |
|
|
|
|
public class RedisKeyExpirationListener extends KeyExpirationEventMessageListener { |
|
|
|
|
public RedisKeyExpirationListener(RedisMessageListenerContainer container) { |
|
|
|
@ -35,12 +36,12 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void onMessage(Message message, byte[] pattern) { |
|
|
|
|
try { |
|
|
|
|
String key=message.toString();//失效的key
|
|
|
|
|
if (key!=null ){ |
|
|
|
|
//截取订单号,查询订单,如果是未支付状态则取消订单
|
|
|
|
|
WjOrder wjOrder = wjOrderMapper.selectWjOrderById(key); |
|
|
|
|
if (wjOrder !=null && wjOrder.getOrderState().equals(1)){ |
|
|
|
|
//
|
|
|
|
|
WjOrder order = new WjOrder(); |
|
|
|
|
order.setId(key); |
|
|
|
|
order.setOrderState(7); |
|
|
|
@ -59,8 +60,12 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
|
|
|
|
wjCollectionData.setNumberRemaining(wjCollection.getNumberRemaining()+1); |
|
|
|
|
wjCollectionMapper.updateWjCollection(wjCollectionData); |
|
|
|
|
} |
|
|
|
|
System.out.println("订单号为:"+key+"的订单超时未支付,取消订单"); |
|
|
|
|
log.info("订单号为:"+key+"的订单超时未支付,取消订单"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
log.error("【修改支付订单过期状态异常】:" + e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |