抽奖到账机制优化
This commit is contained in:
@@ -28,7 +28,8 @@ public class DataLimitUtil {
|
||||
|
||||
/**
|
||||
* 默认 当月5次
|
||||
* @param key 名称 sys:data:名称
|
||||
*
|
||||
* @param key 名称 sys:data:名称
|
||||
* @return
|
||||
*/
|
||||
public static boolean isAccessAllowed(String key) {
|
||||
@@ -51,8 +52,9 @@ public class DataLimitUtil {
|
||||
|
||||
/**
|
||||
* 默认月 month/月/自然月
|
||||
* @param key 名称 sys:data:名称
|
||||
* @param count 次数限制
|
||||
*
|
||||
* @param key 名称 sys:data:名称
|
||||
* @param count 次数限制
|
||||
* @return
|
||||
*/
|
||||
public static boolean isAccessAllowed(String key, Integer count) {
|
||||
@@ -74,8 +76,9 @@ public class DataLimitUtil {
|
||||
|
||||
/**
|
||||
* 默认 5次
|
||||
*
|
||||
* @param key 名称 sys:data:名称
|
||||
* @param timeFormat day/天/自然天 week/周/本周日 month/月/自然月 year/年/自然年
|
||||
* @param timeFormat day/天/自然天 week/周/本周日 month/月/自然月 year/年/自然年
|
||||
* @return
|
||||
*/
|
||||
public static boolean isAccessAllowed(String key, String timeFormat) {
|
||||
@@ -95,10 +98,19 @@ public class DataLimitUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isAllowed(String key, int seconds) {
|
||||
String redisKey = generateRedisKey(key);
|
||||
if (!redisUtils.hasKey(key)) {
|
||||
redisUtils.set(redisKey, 1, seconds);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key 名称 sys:data:名称
|
||||
* @param count 次数限制
|
||||
* @param timeFormat day/天/自然天 week/周/本周日 month/月/自然月 year/年/自然年
|
||||
* @param timeFormat day/天/自然天 week/周/本周日 month/月/自然月 year/年/自然年
|
||||
* @return
|
||||
*/
|
||||
public static boolean isAccessAllowed(String key, Integer count, String timeFormat) {
|
||||
@@ -127,7 +139,7 @@ public class DataLimitUtil {
|
||||
Date now = DateUtil.beginOfDay(DateUtil.date());
|
||||
Date expireDate = null;
|
||||
if ("day".equals(timePeriod)) {
|
||||
expireDate = DateUtil.endOfDay(now);
|
||||
expireDate = DateUtil.endOfDay(now);
|
||||
} else if ("week".equals(timePeriod)) {
|
||||
expireDate = DateUtil.endOfWeek(now);
|
||||
} else if ("month".equals(timePeriod)) {
|
||||
|
||||
Reference in New Issue
Block a user