🐞 fix(gvg): 批量保存数据后返回有时无法查询
This commit is contained in:
@@ -122,9 +122,6 @@ export default class GVGTeam extends BaseModel {
|
||||
@prop({ required: true, default: false })
|
||||
isBroken: boolean; // 机器人是否被击破,如果没有被击破,那么这个位置上就还是机器人,如果被击破了,这个位置就空出给玩家
|
||||
|
||||
@prop({ required: false })
|
||||
batchCode: string; // 批量编号
|
||||
|
||||
originPointId: number;
|
||||
curTeamBreak: boolean;
|
||||
|
||||
@@ -319,15 +316,14 @@ export default class GVGTeam extends BaseModel {
|
||||
|
||||
// 投石车伤害
|
||||
public static async attackByCatapult(teamCodes: string[], inc: number, rebirthAreaId: number) {
|
||||
let batchCode = genCode(8);
|
||||
await GVGTeamModel.updateMany({ teamCode: { $in: teamCodes } }, { $inc: { durability: -inc }, $set: { batchCode } });
|
||||
let brokenTeams: GVGTeamType[] = await GVGTeamModel.find({ batchCode, durability: { $lte: 0 } }).lean();
|
||||
await GVGTeamModel.updateMany({ teamCode: { $in: teamCodes } }, { $inc: { durability: -inc } });
|
||||
let brokenTeams: GVGTeamType[] = await GVGTeamModel.find({ teamCode: { $in: teamCodes }, durability: { $lte: 0 } }).lean();
|
||||
if(brokenTeams.length > 0) {
|
||||
await GVGTeamModel.bulkWrite(brokenTeams.map(({ teamCode, maxDurability }) => {
|
||||
return { updateOne: { filter: { teamCode }, update: { $set: { areaId: rebirthAreaId, pointId: 0, durability: maxDurability } }}}
|
||||
}));
|
||||
}
|
||||
let teams: GVGTeamType[] = await GVGTeamModel.find({ batchCode }).lean();
|
||||
let teams: GVGTeamType[] = await GVGTeamModel.find({ teamCode: { $in: teamCodes } }).lean();
|
||||
return teams.map(team => {
|
||||
let originTeam = brokenTeams.find(origin => origin.teamCode == team.teamCode);
|
||||
if(originTeam) {
|
||||
|
||||
Reference in New Issue
Block a user