feat: 用户累计充值可得免费播放全集权限

This commit is contained in:
张松
2024-12-18 17:07:13 +08:00
parent 4184193ee6
commit 5a10f03a4a
7 changed files with 114 additions and 1 deletions

View File

@@ -1,11 +1,15 @@
package com.sqx.common.utils;
import cn.hutool.core.date.DateUtil;
/**
* Redis所有Keys
*
*/
public class RedisKeys {
public static final String PAY_FREE_WATCH_KEY = "pay:free:watch:";
public static String getSysConfigKey(String key){
return "sys:config:" + key;
}
@@ -13,4 +17,12 @@ public class RedisKeys {
public static String getDateKey(String key){
return "date:" + key;
}
public static String getPayFreeWatchKey(Long userId) {
return PAY_FREE_WATCH_KEY + DateUtil.today() + ":" + userId;
}
public static void main(String[] args) {
System.out.println(DateUtil.today());
}
}

View File

@@ -98,6 +98,20 @@ public class RedisUtils {
if(expire != NOT_EXPIRE){
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
}
}
public boolean setIfAbsent(String key, Object value, long expire){
Boolean absent = valueOperations.setIfAbsent(key, toJson(value));
if (Boolean.FALSE.equals(absent)) {
return false;
}
if(expire != NOT_EXPIRE){
redisTemplate.expire(key, expire, TimeUnit.SECONDS);
}
return true;
}
public void set(String key, Object value){