From d64dc4439064ff1da583f01547ab662c247dc293 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 29 Jan 2024 18:46:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=9B=E5=AD=A3=E7=BB=93=E6=9D=9F=E5=88=B7?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/plunder/api_getlist.go | 30 +++++++++++++++++++++++++++++- modules/plunder/model_land.go | 11 +++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/modules/plunder/api_getlist.go b/modules/plunder/api_getlist.go index 2d55a7358..eace775df 100644 --- a/modules/plunder/api_getlist.go +++ b/modules/plunder/api_getlist.go @@ -1,10 +1,14 @@ package plunder import ( + "fmt" "go_dreamfactory/comm" + "go_dreamfactory/lego/core" "go_dreamfactory/pb" "go_dreamfactory/sys/configure" "go_dreamfactory/utils" + + "go.mongodb.org/mongo-driver/bson" ) func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.PlunderGetListReq) (errdata *pb.ErrorData) { @@ -42,10 +46,34 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PlunderGetListRe list.Landid = land.Id update["landid"] = land.Id } else { + var uids []string + etime := this.module.modelLand.GetEndTime() + // 清理岛数据 + if land.Etime > configure.Now().Unix() { + land.Etime = etime + for _, v := range land.Uinfo { // 重置成员信息 + uids = append(uids, v.Uid) + } + if _, err = this.module.modelPlunder.DB.UpdateMany(core.SqlTable(comm.TablePlunder), bson.M{"uid": bson.M{"$in": uids}}, bson.M{"$set": bson.M{"landid": land.Id}}); err != nil { + fmt.Printf("err:%v", err) + return + } + } // 校验是否过期 if list.Etime > configure.Now().Unix() { - + if land, err = this.module.modelLand.createPlunderLandData(list); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Message: err.Error(), + } + return + } + list.Landid = land.Id + update["landid"] = land.Id + list.Etime = etime + update["etime"] = land.Etime } + if land, err = this.module.modelLand.getPlunderLandData(list.Landid); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, diff --git a/modules/plunder/model_land.go b/modules/plunder/model_land.go index cbec30f6b..dfdd8a215 100644 --- a/modules/plunder/model_land.go +++ b/modules/plunder/model_land.go @@ -60,6 +60,7 @@ func (this *modelLand) createPlunderLandData(user *pb.DBPlunder) (land *pb.DBPlu Score: make(map[string]int32, 0), Etime: utils.GetTodayZeroTime(configure.Now().Unix()) + 48*3600, // 临时处理 后面走配置 } + socre = user.Score - 100 if socre < 0 { socre = 0 @@ -101,3 +102,13 @@ func (this *modelLand) createPlunderLandData(user *pb.DBPlunder) (land *pb.DBPlu func (this *modelLand) landMutexLock(oid string) (result *redis.RedisMutex, err error) { return this.module.modelLand.NewRedisMutex(fmt.Sprintf("%s-%s_lock", this.TableName, oid), 5) } + +// 获取结束时间 +func (this *modelLand) GetEndTime() (newTime int64) { + + opentime := this.module.service.GetOpentime().Unix() // 开服时间 + subTime := (configure.Now().Unix() - opentime) % int64(this.module.ModuleTools.GetGlobalConf().PlunderPvpSeasontime) + st := 24 - this.module.ModuleTools.GetGlobalConf().PlunderPvpEndtime + newTime = utils.GetZeroTime(configure.Now().Unix()) + subTime*24*3600 - int64(st*3600) + return +}