diff --git a/modules/plunder/model_land.go b/modules/plunder/model_land.go index 326f79e82..c98ea5b52 100644 --- a/modules/plunder/model_land.go +++ b/modules/plunder/model_land.go @@ -51,6 +51,8 @@ func (this *modelLand) createPlunderLandData(uid string) (land *pb.DBPlunderLand uids []string users []*pb.DBUser info []*pb.DBPlunder + join map[string]struct{} + curUids []string // 过滤后的玩家 ) land = &pb.DBPlunderLand{ Id: primitive.NewObjectID().Hex(), @@ -75,14 +77,21 @@ func (this *modelLand) createPlunderLandData(uid string) (land *pb.DBPlunderLand } } } - // 批量查 + join = make(map[string]struct{}) + // 批量查 是否有加入海岛的 info, _ = this.module.modelPlunder.getPlunderDataByUids(uids) - for i, v := range info { + for _, v := range info { if v.Landid != "" { // 过滤 - uids = append(uids[:i], uids[i+1:]...) + join[v.Uid] = struct{}{} } } - if users, err = this.module.ModuleUser.GetCrossUsers(uids); err != nil { + + for _, v := range uids { // 过滤已经加入海岛的玩家 + if _, ok := join[v]; !ok { + curUids = append(curUids, v) + } + } + if users, err = this.module.ModuleUser.GetCrossUsers(curUids); err != nil { for _, v := range users { land.Uinfo[v.Uid] = comm.GetUserBaseInfo(v) if len(land.Uinfo) > 20 {