排行榜:修复排行榜奖励错误

This commit is contained in:
luying
2022-01-05 16:17:30 +08:00
parent 8681ca1e54
commit 639049ddbe
2 changed files with 9 additions and 7 deletions

View File

@@ -7,7 +7,7 @@ import { HeroModel, HeroType, HeroUpdate } from "../db/Hero";
import { PVPConfigModel } from "../db/SystemConfig";
import { PvpDefenseModel } from "../db/PvpDefense";
import { gameData } from "../pubUtils/data";
import { nowSeconds } from "../pubUtils/timeUtil";
import { getSeconds, nowSeconds } from "../pubUtils/timeUtil";
import { getWorldChannelSid } from "./chatChannelService";
import { pinus } from "pinus";
import { RankFirstModel, RankFirstType, RankFirstUpdateParam } from "../db/RankFirst";
@@ -176,7 +176,7 @@ export class Rank {
* @param hero 武将数据库
* @param isInc 得分是累加上的还是直接设置的
*/
public async setRankWithHeroInfo(roleId: string, hid: number, score: number, timestamp: number, hero?: HeroType, isInc = true) {
public async setRankWithHeroInfo(roleId: string, hid: number, score: number, timestamp: number, hero?: HeroType, isInc = false) {
// 如果没有信息,更新玩家信息
for (let infoKey of [this.infoKey, ...this.extraKeys]) {
await this.generParamAndSet(infoKey, { roleId, hid }, { hero });
@@ -882,11 +882,13 @@ export class Rank {
// console.log(rankId, dicRank.id, oldScore, condition, newScore);
if(dicRank.id == rankId && oldScore < condition && newScore >= condition) {
let rankFirstRec = await RankFirstModel.createRankFirst(serverId, id, rankId, { userInfo, guildInfo });
let roleServers = pinus.app.getServersByType('role');
for(let server of roleServers) {
pinus.app.rpc.role.roleRemote.setRankFirst.toServer(server.id, rankFirstRec);
if(rankFirstRec && getSeconds(rankFirstRec.createdAt) == getSeconds(rankFirstRec.updatedAt)) {
let roleServers = pinus.app.getServersByType('role');
for(let server of roleServers) {
pinus.app.rpc.role.roleRemote.setRankFirst.toServer(server.id, rankFirstRec);
}
rankFirstRecs.push({ ... rankFirstRec, status: 1});
}
rankFirstRecs.push({ ... rankFirstRec, status: 1});
}
}
}

View File

@@ -23,7 +23,7 @@
guildInfo: GuildRankParam; // 军团信息
public static async createRankFirst(serverId: number, id: number, type: number, update: RankFirstUpdateParam) {
const rec: RankFirstType = await RankFirstModel.findOneAndUpdate({ serverId, id, type}, { $setOnInsert: update }, { new: true, upsert: true }).lean();
const rec: RankFirstType = await RankFirstModel.findOneAndUpdate({ serverId, id, type, }, { $setOnInsert: update }, { new: true, upsert: true }).lean();
return rec;
}