diff --git a/modules/arena/modelarena.go b/modules/arena/modelarena.go index 343353e13..c0d8beab2 100644 --- a/modules/arena/modelarena.go +++ b/modules/arena/modelarena.go @@ -155,6 +155,9 @@ func (this *modelArena) updateArenaUserInfo(info *pb.DBArenaUser) (err error) { var ( dan int32 ) + if info.Integral < 0 { + info.Integral = 0 + } if dan, err = this.computedan(info.Integral); err != nil { return } diff --git a/modules/plunder/api_getlist.go b/modules/plunder/api_getlist.go index 2d1f53d81..54579c2b9 100644 --- a/modules/plunder/api_getlist.go +++ b/modules/plunder/api_getlist.go @@ -31,7 +31,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PlunderGetListRe } if list.Landid == "" { - if land, err = this.module.modelLand.createPlunderLandData(session.GetUserId()); err != nil { + if land, err = this.module.modelLand.createPlunderLandData(session.GetUserId(), list.Score); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, Message: err.Error(), diff --git a/modules/plunder/model_land.go b/modules/plunder/model_land.go index 069baee84..db1d250be 100644 --- a/modules/plunder/model_land.go +++ b/modules/plunder/model_land.go @@ -46,13 +46,11 @@ func (this *modelLand) changePlunderLandData(id string, update map[string]interf return } -func (this *modelLand) createPlunderLandData(uid string) (land *pb.DBPlunderLand, err error) { +func (this *modelLand) createPlunderLandData(uid string, socre int32) (land *pb.DBPlunderLand, err error) { var ( - user *pb.DBUser - limtSocre int32 - uids []string - users []*pb.DBUser - uInfos []*pb.BaseUserInfo + uids []string + users []*pb.DBUser + uInfos []*pb.BaseUserInfo ) land = &pb.DBPlunderLand{ Id: primitive.NewObjectID().Hex(), @@ -61,22 +59,16 @@ func (this *modelLand) createPlunderLandData(uid string) (land *pb.DBPlunderLand Score: make(map[string]int32, 0), Etime: utils.GetTodayZeroTime(configure.Now().Unix()) + 48*3600, // 临时处理 后面走配置 } - if user, err = this.module.ModuleUser.GetUser(uid); err != nil { - return - } - limtSocre = user.Plunder - 100 - if limtSocre < 0 { - limtSocre = 0 + socre = socre - 100 + if socre < 0 { + socre = 0 } uids = append(uids, uid) // 优先加入自己 - uInfos = append(uInfos, comm.GetUserBaseInfo(user)) - cur, err := this.DB.Find(core.SqlTable(comm.TablePlunder), bson.M{"score": bson.M{"$gte": limtSocre}, "landid": bson.M{"$ne": ""}}, options.Find().SetSkip(int64(0)).SetLimit(int64(20))) + cur, err := this.DB.Find(core.SqlTable(comm.TablePlunder), bson.M{"score": bson.M{"$gte": socre}, "uid": bson.M{"$ne": uid}, "landid": bson.M{"$ne": ""}}, options.Find().SetSkip(int64(0)).SetLimit(int64(20))) for cur.Next(context.TODO()) { tmp := &pb.DBPlunder{} if err = cur.Decode(tmp); err == nil { - if uid != tmp.Uid { - uids = append(uids, tmp.Uid) - } + uids = append(uids, tmp.Uid) } } @@ -96,9 +88,7 @@ func (this *modelLand) createPlunderLandData(uid string) (land *pb.DBPlunderLand if _, err = this.module.modelRecord.getPlunderRecordData(land.Id); err != nil { return } - if _, err = this.DB.UpdateMany(core.SqlTable(comm.TablePlunder), bson.M{"uid": bson.M{"$in": uids}}, bson.M{"$set": bson.M{"landid": land.Id}}); err != nil { - return - } + return } diff --git a/modules/plunder/module.go b/modules/plunder/module.go index 733debe34..43acb55f0 100644 --- a/modules/plunder/module.go +++ b/modules/plunder/module.go @@ -4,7 +4,6 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/modules" - "go_dreamfactory/pb" ) func NewModule() core.IModule { @@ -67,10 +66,6 @@ func (this *Plunder) OnInstallComp() { this.modelRecord = this.RegisterComp(new(modelRecord)).(*modelRecord) } -func (this *Plunder) CreatePlunderLand(uid string) (land *pb.DBPlunderLand, err error) { - return this.modelLand.createPlunderLandData(uid) -} - //初始化用户掠夺信息 func (this *Plunder) InitPlunderByUser(session comm.IUserSession) { var (