🐞 fix(寻宝): 寻宝有时有问题

This commit is contained in:
luying
2022-11-03 15:55:00 +08:00
parent 76f35af7f8
commit 7f07a8bd0e
2 changed files with 8 additions and 11 deletions

View File

@@ -3,6 +3,7 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
import { EXTERIOR } from '../pubUtils/dicParam';
import { nowSeconds } from '../pubUtils/timeUtil';
import { RoleUpdate } from './Role';
import { COM_TEAM_STATUS } from '../consts';
export class ComRoleStatusHero {
@prop({ required: true })
@@ -241,6 +242,10 @@ export default class ComBattleTeam extends BaseModel {
return team;
}
public static async checkHasTeamByRoleId(roleId: string) {
return await ComBattleTeamModel.exists({ roleIds: { $in: [roleId] }, status: COM_TEAM_STATUS.FIGHTING });
}
public static async addRole(teamCode: string, roleStatus: RoleStatus, lean = true) {
const team: ComBattleTeamType = await ComBattleTeamModel.findOneAndUpdate({ teamCode, roleCnt: { $lte: 2 } }, {$push: {roleIds: roleStatus.roleId, roleStatus}, $inc: {roleCnt: 1}}, {new: true}).lean(lean);
return team;