feat: 1.uni-ad广告回调接入 2.广告奖励免费观看时长

This commit is contained in:
张松
2024-12-23 17:12:38 +08:00
parent b7e8047b4c
commit 81da6fa6a3

View File

@@ -1,5 +1,6 @@
package com.sqx.modules.redisService.impl; package com.sqx.modules.redisService.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
@@ -68,6 +69,7 @@ public class RedisServiceImpl implements RedisService {
} }
} }
@Override @Override
public Boolean getFreeWatchTimeIsExpire(Long userId) { public Boolean getFreeWatchTimeIsExpire(Long userId) {
String freeWatchKey = RedisKeys.getFreeWatchKey(userId, true); String freeWatchKey = RedisKeys.getFreeWatchKey(userId, true);
@@ -98,8 +100,12 @@ public class RedisServiceImpl implements RedisService {
Integer second = jsonObject.getInteger("second"); Integer second = jsonObject.getInteger("second");
if (expireTime == -1) { if (expireTime == -1) {
jsonObject.put("expireTime", DateUtil.offsetSecond(DateUtil.date(), second).getTime()); DateTime now = DateUtil.date();
redisUtils.set(watchKey, jsonObject.toJSONString(), -1); 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; return false;
}else { }else {
return DateUtil.current() > expireTime; return DateUtil.current() > expireTime;