增加剧集周支付次数

This commit is contained in:
张松
2025-01-02 20:51:21 +08:00
parent eac53e57b0
commit 71ff32998e
6 changed files with 55 additions and 6 deletions

View File

@@ -23,4 +23,8 @@ public interface RedisService {
boolean isSetUserState(long userId);
int getCourseWeekViewCount(long courseId);
int getCourseWeekPayCount(long courseId);
}

View File

@@ -310,4 +310,23 @@ public class RedisServiceImpl implements RedisService {
redisUtils.set(key, i, -1);
return i;
}
@Override
public int getCourseWeekPayCount(long courseId) {
String key = "course:payCount:" + courseId;
String info = redisUtils.get(key);
if (StrUtil.isBlank(info)) {
// 获取当前时间
DateTime now = DateUtil.date();
// 获取下周一的日期
DateTime nextMonday = DateUtil.nextWeek();
// 计算距离下周一还有多少秒
long seconds = nextMonday.getTime() - now.getTime();
redisUtils.set(key, 1, seconds);
return 1;
}
int i = Integer.parseInt(info) + 1;
redisUtils.set(key, i, -1);
return i;
}
}