From 81da6fa6a39a2c0edb0d0368e1f7599b05f88497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Mon, 23 Dec 2024 17:12:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=201.uni-ad=E5=B9=BF=E5=91=8A=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E6=8E=A5=E5=85=A5=202.=E5=B9=BF=E5=91=8A=E5=A5=96?= =?UTF-8?q?=E5=8A=B1=E5=85=8D=E8=B4=B9=E8=A7=82=E7=9C=8B=E6=97=B6=E9=95=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/redisService/impl/RedisServiceImpl.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sqx/modules/redisService/impl/RedisServiceImpl.java b/src/main/java/com/sqx/modules/redisService/impl/RedisServiceImpl.java index 1a9b3ef2..33a9f5d3 100644 --- a/src/main/java/com/sqx/modules/redisService/impl/RedisServiceImpl.java +++ b/src/main/java/com/sqx/modules/redisService/impl/RedisServiceImpl.java @@ -1,5 +1,6 @@ package com.sqx.modules.redisService.impl; +import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; @@ -68,6 +69,7 @@ public class RedisServiceImpl implements RedisService { } } + @Override public Boolean getFreeWatchTimeIsExpire(Long userId) { String freeWatchKey = RedisKeys.getFreeWatchKey(userId, true); @@ -98,8 +100,12 @@ public class RedisServiceImpl implements RedisService { Integer second = jsonObject.getInteger("second"); if (expireTime == -1) { - jsonObject.put("expireTime", DateUtil.offsetSecond(DateUtil.date(), second).getTime()); - redisUtils.set(watchKey, jsonObject.toJSONString(), -1); + DateTime now = DateUtil.date(); + jsonObject.put("expireTime", DateUtil.offsetSecond(now, second).getTime()); + Date tomorrow = DateUtil.beginOfDay(DateUtil.offsetDay(now, 1)); + long expire = DateUtil.between(now, tomorrow, DateUnit.SECOND); + + redisUtils.set(watchKey, jsonObject.toJSONString(), expire); return false; }else { return DateUtil.current() > expireTime;