排行榜:防报错

This commit is contained in:
luying
2022-09-09 20:39:17 +08:00
parent 7b8b110045
commit cb1384b24f
2 changed files with 8 additions and 1 deletions

View File

@@ -105,6 +105,7 @@ export function getDungeonBuyCountCost(num:number) {
}
export async function saveDungeonFirst(role: RoleType, warId: number, battleRecord: BattleRecordType) {
if(!role) return null;
let userInfo = new RankParam(role);
let lineup = battleRecord.record.lineup;
let dicWar = gameData.war.get(warId);

View File

@@ -485,11 +485,13 @@ export class Rank {
if (!hasCurUser) {
if (!guild) {
guild = await GuildModel.findByCode(guildCode, this.keyName.serverId, GUILD_SELECT.RANK);
if(!guild) return null
}
param = new GuildRankInfo(guild);
param.setInfo(0, { guildCode }, score, time);
} else {
const info = await redisClient().hgetAsync(this.infoKey, guildCode);
if(!info) return null
const guildInfo = JSON.parse(info);
param = new GuildRankInfo(guildInfo);
param.setInfo(0, { guildCode }, score, time);
@@ -510,12 +512,14 @@ export class Rank {
if (!hasCurUser) {
if (!guild) {
guild = await GuildModel.findByCode(guildCode, this.keyName.serverId, GUILD_SELECT.RANK);
if(!guild) return null
}
param = new GuildRankInfo(guild);
param.setInfo2(0, { guildCode }, score, time, active);
} else {
const info = await redisClient().hgetAsync(this.infoKey, guildCode);
const guildInfo = JSON.parse(info);
if(!guildInfo) return null
param = new GuildRankInfo(guildInfo);
param.setInfo2(0, { guildCode }, score, time, active);
}
@@ -745,7 +749,8 @@ export class Rank {
const info = await redisClient().hgetAsync(this.infoKey, this.composeFields(this.infoKey, myId));
const userInfo = JSON.parse(info);
if(!userInfo) return null;
let param: RoleRankInfo | GuildRankInfo;
if (this.infoKey == REDIS_KEY.USER_INFO) {
if (nowSeconds() - userInfo.updatedAt > 2 * 30 * 24 * 60 * 60) {
@@ -905,6 +910,7 @@ export class Rank {
private async getFirstUserInfo(myId: myIdInter) {
const info = await redisClient().hgetAsync(this.infoKey, this.composeFields(this.infoKey, myId));
if(!info) return null
const playerInfo = JSON.parse(info);
if (this.infoKey == REDIS_KEY.USER_INFO) {