排行榜:修复数据错误
This commit is contained in:
@@ -245,7 +245,7 @@ export class Rank {
|
||||
if (!guild) {
|
||||
guild = await GuildModel.findByCode(guildCode, this.keyName.serverId, GUILD_SELECT.RANK)
|
||||
}
|
||||
let param = new GuildRankParam(guild);
|
||||
let param = new GuildRankParam(guild, true);
|
||||
await this.setUserInfo(infoKey, { guildCode }, param);
|
||||
} else if (infoKey == REDIS_KEY.TOP_LINEUP_INFO) {
|
||||
if (!role) {
|
||||
@@ -458,12 +458,12 @@ export class Rank {
|
||||
if (!guild) {
|
||||
guild = await GuildModel.findByCode(guildCode, this.keyName.serverId, GUILD_SELECT.RANK);
|
||||
}
|
||||
param = new GuildRankInfo(guild);
|
||||
param = new GuildRankInfo(guild, true);
|
||||
param.setInfo(0, { guildCode }, score, time);
|
||||
} else {
|
||||
const info = await redisClient().hgetAsync(this.infoKey, guildCode);
|
||||
const guildInfo = JSON.parse(info);
|
||||
param = new GuildRankInfo(guildInfo);
|
||||
param = new GuildRankInfo(guildInfo, false);
|
||||
param.setInfo(0, { guildCode }, score, time);
|
||||
}
|
||||
|
||||
@@ -483,12 +483,12 @@ export class Rank {
|
||||
if (!guild) {
|
||||
guild = await GuildModel.findByCode(guildCode, this.keyName.serverId, GUILD_SELECT.RANK);
|
||||
}
|
||||
param = new GuildRankInfo(guild);
|
||||
param = new GuildRankInfo(guild, true);
|
||||
param.setInfo2(0, { guildCode }, score, time, active);
|
||||
} else {
|
||||
const info = await redisClient().hgetAsync(this.infoKey, guildCode);
|
||||
const guildInfo = JSON.parse(info);
|
||||
param = new GuildRankInfo(guildInfo);
|
||||
param = new GuildRankInfo(guildInfo, false);
|
||||
param.setInfo2(0, { guildCode }, score, time, active);
|
||||
}
|
||||
|
||||
@@ -681,10 +681,10 @@ export class Rank {
|
||||
param.setInfo(Math.floor(ii / 2) + 1, myId, scores[0], scores[1]);
|
||||
} else if (this.infoKey == REDIS_KEY.GUILD_INFO) {
|
||||
if(this.key == REDIS_KEY.GUILD_LV_RANK) {
|
||||
param = new GuildRankInfo(userInfo);
|
||||
param = new GuildRankInfo(userInfo, false);
|
||||
param.setInfo2(Math.floor(ii / 2) + 1, myId, scores[0], scores[1], scores[2]);
|
||||
} else {
|
||||
param = new GuildRankInfo(userInfo);
|
||||
param = new GuildRankInfo(userInfo, false);
|
||||
param.setInfo(Math.floor(ii / 2) + 1, myId, scores[0], scores[1]);
|
||||
}
|
||||
}
|
||||
@@ -727,10 +727,10 @@ export class Rank {
|
||||
param.setInfo(Math.floor(ii / 2) + 1, myId, scores[0], scores[1]);
|
||||
} else if (this.infoKey == REDIS_KEY.GUILD_INFO) {
|
||||
if(this.key == REDIS_KEY.GUILD_LV_RANK) {
|
||||
param = new GuildRankInfo(userInfo);
|
||||
param = new GuildRankInfo(userInfo, false);
|
||||
param.setInfo2(Math.floor(ii / 2) + 1, myId, scores[0], scores[1], scores[2]);
|
||||
} else {
|
||||
param = new GuildRankInfo(userInfo);
|
||||
param = new GuildRankInfo(userInfo, false);
|
||||
param.setInfo(Math.floor(ii / 2) + 1, myId, scores[0], scores[1]);
|
||||
}
|
||||
}
|
||||
@@ -818,7 +818,7 @@ export class Rank {
|
||||
if(!reverse) {
|
||||
encodeResult += score * Math.pow(10, weight);
|
||||
} else {
|
||||
let pow = Math.pow(10, len + 1);
|
||||
let pow = Math.pow(10, len);
|
||||
encodeResult += pow - 1 - score;
|
||||
}
|
||||
})
|
||||
|
||||
@@ -72,6 +72,9 @@ export default class Guild extends BaseModel {
|
||||
|
||||
@prop({ required: true, default: 0, get: (val:number) => reduceCe(val), set: (val: number) => val })
|
||||
guildCe: number; // 总战力
|
||||
|
||||
@prop({ required: false, set: (val: boolean) => val, get: () => true })
|
||||
isReducedCe: boolean; // 如果战力没有缩过就会返回false,缩过了就会返回true
|
||||
|
||||
@prop({ required: true, type: String, default: [], select: false })
|
||||
members: string[]; // 军团成员的roleId,用于增加战力的时候加入总战力
|
||||
@@ -139,7 +142,7 @@ export default class Guild extends BaseModel {
|
||||
let sort = {}, condition = {};
|
||||
switch(type) {
|
||||
case REDIS_KEY.GUILD_LV_RANK:
|
||||
sort = { lv: -1, lvUpdateTime: 1 }; break;
|
||||
sort = { lv: -1, activeWeekly: -1, lvUpdateTime: 1 }; break;
|
||||
case REDIS_KEY.GUILD_ACTIVE_RANK:
|
||||
sort = { activeWeekly: -1, activeUpdateTime: 1 }; condition = { activeWeekly: { $gt: 0 } }; break;
|
||||
}
|
||||
|
||||
@@ -177,14 +177,27 @@ export class GuildRankParam {
|
||||
@prop({ required: true })
|
||||
guildCe: number;
|
||||
|
||||
constructor(guild: GuildUpdateParam) {
|
||||
constructor(guild: GuildUpdateParam, fromDb: boolean) {
|
||||
this.icon = guild.icon;
|
||||
this.name = guild.name;
|
||||
this.lv = guild.lv;
|
||||
let leader = <RoleType>guild.leader;
|
||||
let _leader = new GuildLeader(leader);
|
||||
this.leader = _leader;
|
||||
this.guildCe = guild.guildCe;
|
||||
console.log('*****', guild.isReducedCe, guild.guildCe, reduceCe(guild.guildCe))
|
||||
if(guild.isReducedCe) {
|
||||
this.guildCe = guild.guildCe;
|
||||
} else {
|
||||
this.guildCe = reduceCe(guild.guildCe);
|
||||
}
|
||||
|
||||
if(fromDb && !(<GuildUpdateParam>guild).isReducedCe) {
|
||||
this.guildCe = reduceCe(guild.guildCe);
|
||||
} else {
|
||||
this.guildCe = guild.guildCe;
|
||||
}
|
||||
|
||||
|
||||
this.memberCnt = guild.memberCnt;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user