排行榜: 获取排行榜

This commit is contained in:
luying
2021-04-12 09:47:15 +08:00
parent 34e02dea89
commit 5dca7b304d
32 changed files with 1077 additions and 290 deletions
@@ -6,7 +6,8 @@ import { updateUserInfo } from './redisService';
import { switchOnFunc } from './funcSwitchService';
import { FUNC_OPT_TYPE } from '../consts';
import { BackendSession } from 'pinus';
import { REDIS_KEY } from '../consts/consts';
import { REDIS_KEY } from '../consts';
import { Rank } from './rankService';
export async function roleLevelup(roleId: string, kingExp: number, session: BackendSession) {
let role = await RoleModel.findByRoleId(roleId);
@@ -24,7 +25,10 @@ export async function roleLevelup(roleId: string, kingExp: number, session: Back
role = await RoleModel.levelup(roleId, newLv, newExp);
if(newLv > lv) { // 升级
await switchOnFunc(roleId, FUNC_OPT_TYPE.LEVEL_UP, newLv, session);
await updateUserInfo(REDIS_KEY.USER_INFO, roleId, [{field: 'lv', value: newLv}])
await updateUserInfo(REDIS_KEY.USER_INFO, roleId, [{field: 'lv', value: newLv}]);
let r = new Rank(REDIS_KEY.USER_LV, { serverId: role.serverId });
await r.setRankWithRoleInfo(roleId, newLv, Date.now(), role);
}
let actordata = [];
for(let i = lv; i <= newLv; i++) {