//获取过期队列key
String key = stringRedisTemplate.opsForValue().get(RedisCacheKey.ORDER_LOCK_TIMER_KEY + orderInfo.getOrderId());
//删除过期队列中的订单
stringRedisTemplate.opsForSet().remove(key, String.valueOf(orderInfo.getOrderId()));
//删除过期队列订单的key
stringRedisTemplate.expire(RedisCacheKey.ORDER_LOCK_TIMER_KEY + orderInfo.getOrderId() ,Constant.INT_VAL_0,TimeUnit.MINUTES);
String key = stringRedisTemplate.opsForValue().get(RedisCacheKey.COUPON_COUPON_INVENTORY_COUPON_ID + id);
stringRedisTemplate.opsForSet().remove(key, id);
stringRedisTemplate.expire(RedisCacheKey.COUPON_COUPON_INVENTORY_COUPON_ID + coupon.getCouponId() ,Constant.INT_VAL_0, TimeUnit.MINUTES);
LocalDate isActivityEnd = coupon.getIsActivityEnd();
LocalDate localDate = LocalDate.now();
boolean beforeFlag = localDate.isBefore(isActivityEnd);
System.out.println("判断localDate是否在isActivityEnd之前:"+beforeFlag);
boolean afterFlag = localDate.isAfter(isActivityEnd);
boolean isEqual = localDate.isAfter(isActivityEnd);
if(isEqual || beforeFlag){
LocalDateTime localDateTime = LocalDateTime.now();
LocalDateTime maxDateTime = LocalDateTime.of(coupon.getIsActivityEnd(), LocalTime.MAX);
long minutes = ChronoUnit.MINUTES.between(maxDateTime, localDateTime);
//设置过期时间 【单位:分钟】
stringRedisTemplate.expire(RedisCacheKey.COUPON_COUPON_INVENTORY_COUPON_ID + coupon.getCouponId() ,minutes, TimeUnit.MINUTES);
}else if(afterFlag){
//无效库存 暂不设置
}
String records2 = JSONUtil.toJsonStr(map.get("records"));
List<TouristCouponRecordRespVo> records = JSON.parseArray(records2, TouristCouponRecordRespVo.class);
List<TouristCouponRecordRespVo> records = JSON.parseArray(JSONUtil.toJsonStr(map.get("key")), TouristCouponRecordRespVo.class);
redis设置
最新推荐文章于 2024-05-21 17:21:03 发布