🐞 fix(gvg): 激战期推送相关修改

This commit is contained in:
luying
2023-02-23 22:04:54 +08:00
parent 5a85d6e86c
commit 724b0ee485
11 changed files with 75 additions and 55 deletions
+3 -2
View File
@@ -49,7 +49,8 @@ export default class GVGCity extends BaseModel {
// 添加人数
public static async increasePlayer(configId: number, groupKey: string, cityId: number, roleId: string, leagueCode: string, teamCnt: number) {
const city: GVGCityType = await GVGCityModel.findOneAndUpdate({ configId, groupKey, cityId, userCnt: { $lt: 200 } }, { $inc: { userCnt: 1 }, $push: { players: { roleId, leagueCode, teamCnt } }}, { new: true, upsert: true }).lean();
await GVGCityModel.findOneAndUpdate({ configId, groupKey, cityId }, { $setOnInsert: { userCnt: 0, players: [] } }, { upsert: true }).lean()
const city: GVGCityType = await GVGCityModel.findOneAndUpdate({ configId, groupKey, cityId, userCnt: { $lt: 200 } }, { $inc: { userCnt: 1 }, $push: { players: { roleId, leagueCode, teamCnt } }}, { new: true }).lean();
return city;
}
@@ -98,7 +99,7 @@ export default class GVGCity extends BaseModel {
public static async guardCity(configId: number, groupKey: string, cityId: number, league: LeagueRankInfo) {
const city: GVGCityType = await GVGCityModel.findOneAndUpdate({ configId: configId + 1, cityId, groupKey }, { $set: {
hasGuard: true, guardLeague: league.code, guardLeagueName: league.name, guardLeagueIcon: league.icon
} }, { upsert: true, new: true }).lean();
}, $setOnInsert: { userCnt: 0, players: [] } }, { upsert: true, new: true }).lean();
return city;
}