防沉迷:redis key 写反
This commit is contained in:
@@ -356,12 +356,16 @@ export async function getAllOnlineRoles() {
|
||||
export async function incOnlineTime(userCode: string, isToday: boolean, incTime: number) {
|
||||
moment.locale('zh-cn');
|
||||
let today = moment().format('YYYYMMDD');
|
||||
let key = isToday? REDIS_KEY.ONLINE_TIME: `${REDIS_KEY.ONLINE_TIME}:${today}`;
|
||||
let key = isToday? `${REDIS_KEY.ONLINE_TIME}:${today}`: REDIS_KEY.ONLINE_TIME;
|
||||
if(isToday) {
|
||||
let tomorrow = moment().add(1, 'days').hours(0).minutes(0).seconds(0).format('x');
|
||||
await redisClient().expireatAsync(key, parseInt(tomorrow));
|
||||
let tomorrow = moment().add(1, 'days').hours(0).minutes(0).seconds(0).unix();
|
||||
let result = await redisClient().hincrbyAsync(key, userCode, incTime);
|
||||
let result2 = await redisClient().expireatAsync(key, tomorrow);
|
||||
console.log(result2)
|
||||
return result;
|
||||
} else {
|
||||
return await redisClient().hincrbyAsync(key, userCode, incTime);
|
||||
}
|
||||
return await redisClient().hincrbyAsync(key, userCode, incTime);
|
||||
}
|
||||
|
||||
export async function setOnlineTime(userCode: string, isToday: boolean, setTime: number) {
|
||||
|
||||
Reference in New Issue
Block a user