diff --git a/comm/const.go b/comm/const.go index 0c7e81b08..aa9424281 100644 --- a/comm/const.go +++ b/comm/const.go @@ -1023,11 +1023,12 @@ const ( ) const ( - MaxRankList = 50 // 赛季塔 排行榜人数 - MaxMailCount = 50 // 当前邮件最大数量 - MaxRankNum = 3 - MinRankList = 10 // 排行榜人数 - AssistHeroCount = 12 // 助战英雄列表显示数量 + MaxRankList = 50 // 赛季塔 排行榜人数 + MaxMailCount = 50 // 当前邮件最大数量 + MaxRankNum = 3 + MinRankList = 10 // 排行榜人数 + AssistHeroCount = 12 // 助战英雄列表显示数量 + DrawRecordNumber = 100 // 抽卡列表数量 ) // /聊天消息公告类型 diff --git a/comm/imodule.go b/comm/imodule.go index 2ed95cc0b..237be4408 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -707,6 +707,7 @@ type ( } IMoonlv interface { IBuriedUpdateNotify + GMCreateMoonlv(session IUserSession, lv int32) } //捉虫子 ICatchBugs interface { diff --git a/modules/buried/module.go b/modules/buried/module.go index 54a4a4488..82ee0f474 100644 --- a/modules/buried/module.go +++ b/modules/buried/module.go @@ -548,7 +548,7 @@ func (this *Buried) TriggerBuried(session comm.IUserSession, burieds ...*pb.Buri this.Error("远程触发埋点错误!", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "err", Value: err.Error()}) return } - if _, err = this.service.AcrossClusterRpcGo( + if err = this.service.AcrossClusterRpcCall( context.Background(), stag, comm.Service_Worker, diff --git a/modules/dragon/api_train.go b/modules/dragon/api_train.go index 8c00f01c5..b649bc04d 100644 --- a/modules/dragon/api_train.go +++ b/modules/dragon/api_train.go @@ -136,7 +136,7 @@ func (this *apiComp) Train(session comm.IUserSession, req *pb.DragonTrainReq) (e rsp.Reward = atno } if curType != preType { // 坐骑升阶 增加属性 - if c, err := this.module.configure.GetDragonMount(dragon.Dragonid, curType); err != nil { + if c, err := this.module.configure.GetDragonMount(dragon.Dragonid, curType); err == nil { dragon.Property = make(map[string]int32) dragon.Property["stime"] = c.Stime dragon.Property["etime"] = c.Etime diff --git a/modules/entertainment/modelrecord.go b/modules/entertainment/modelrecord.go index 7b48f47ec..9fb40cd44 100644 --- a/modules/entertainment/modelrecord.go +++ b/modules/entertainment/modelrecord.go @@ -10,7 +10,6 @@ import ( "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - mgooptions "go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/x/bsonx" ) @@ -30,9 +29,6 @@ func (this *modelRecode) Init(service core.IService, module core.IModule, comp c { Keys: bsonx.Doc{{Key: "p1", Value: bsonx.Int32(1)}, {Key: "p2", Value: bsonx.Int32(1)}}, - }, { - Keys: bson.M{"createtime": -1}, - Options: mgooptions.Index().SetExpireAfterSeconds(7 * 24 * 3600), }, }); err != nil { return diff --git a/modules/gm/module.go b/modules/gm/module.go index e4d7f3563..c2c57ffd5 100644 --- a/modules/gm/module.go +++ b/modules/gm/module.go @@ -824,6 +824,20 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (errdata *pb.Er log.Field{Key: "0", Value: datas[0]}, ) + } else if len(datas) == 2 && (datas[0] == "moonlv") { // 等级 + module1, err := this.service.GetModule(comm.ModuleMoonlv) + if err != nil { + return + } + if lv, err := strconv.Atoi(datas[1]); err == nil { + module1.(comm.IMoonlv).GMCreateMoonlv(session, int32(lv)) + + this.Debug("使用bingo命令", + log.Field{Key: "uid", Value: session.GetUserId()}, + log.Field{Key: "0", Value: datas[1]}, + ) + } + } } } diff --git a/modules/hero/api.go b/modules/hero/api.go index 2baa93172..2e9ce281f 100644 --- a/modules/hero/api.go +++ b/modules/hero/api.go @@ -4,6 +4,7 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/modules" + "time" ) type apiComp struct { @@ -13,6 +14,14 @@ type apiComp struct { module *Hero chat comm.IChat } +type DBHeroDrawCardRecord struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID 主键id + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID + HeroId []string `protobuf:"bytes,3,rep,name=heroId,proto3" json:"heroId"` // 英雄ID + Drawtype int32 `protobuf:"varint,4,opt,name=drawtype,proto3" json:"drawtype"` // 卡池 + Ctime int64 `protobuf:"varint,5,opt,name=ctime,proto3" json:"ctime"` + ExpireAt time.Time `bson:"expireAt,omitempty"` +} const ( //消息回复的头名称 StrengthenUplv = "strengthenuplv" diff --git a/modules/hero/api_drawCard.go b/modules/hero/api_drawCard.go index e4e3569e2..dc028b441 100644 --- a/modules/hero/api_drawCard.go +++ b/modules/hero/api_drawCard.go @@ -325,13 +325,17 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq // 任务统计 go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { - this.module.modelDrawRecode.InstertDrawCardRecord(&pb.DBHeroDrawRecord{ + if _, err = this.module.modelDrawRecode.DBModel.DB.InsertOne("drawrecode", &DBHeroDrawCardRecord{ Id: primitive.NewObjectID().Hex(), Uid: session.GetUserId(), HeroId: szCards, - Drawtype: req.DrawType, + Drawtype: 1, Ctime: configure.Now().Unix(), - }) + ExpireAt: configure.Now(), + }); err != nil { + this.module.Errorln(err) + return + } var szHero []*pb.DBHero for _, hero := range add { // 奖励一次性发放 if user, err := this.module.ModuleUser.GetUser(session.GetUserId()); err == nil { // 广播 首次获得英雄 diff --git a/modules/hero/api_selectcard.go b/modules/hero/api_selectcard.go index b4d53de1d..8feae1a4f 100644 --- a/modules/hero/api_selectcard.go +++ b/modules/hero/api_selectcard.go @@ -124,14 +124,20 @@ func (this *apiComp) SelectCard(session comm.IUserSession, req *pb.HeroSelectCar Record: heroRecord, Atno: szAtno, }) + go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { - this.module.modelDrawRecode.InstertDrawCardRecord(&pb.DBHeroDrawRecord{ + + if _, err = this.module.modelDrawRecode.DBModel.DB.InsertOne("drawrecode", &DBHeroDrawCardRecord{ Id: primitive.NewObjectID().Hex(), Uid: session.GetUserId(), HeroId: curSzCard, Drawtype: 1, Ctime: configure.Now().Unix(), - }) + ExpireAt: configure.Now(), + }); err != nil { + this.module.Errorln(err) + return + } this.module.HeroLibrary(session, curSzCard, szHero) this.module.SendTaskMsg(session, szStar, 10, 1, curSzCard) }) diff --git a/modules/hero/model_drawrecord.go b/modules/hero/model_drawrecord.go index 3c7081a6f..63e291083 100644 --- a/modules/hero/model_drawrecord.go +++ b/modules/hero/model_drawrecord.go @@ -10,6 +10,7 @@ import ( "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" + mgooptions "go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/x/bsonx" ) @@ -25,10 +26,16 @@ func (this *modelDrawRecode) Init(service core.IService, module core.IModule, co this.module = module.(*Hero) // 通过uid创建索引 + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{}) + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, }) - + indexModel := mongo.IndexModel{ + Keys: bson.M{"expireAt": 1}, + Options: mgooptions.Index().SetExpireAfterSeconds(6 * 30 * 24 * 3600), + } + _, err = this.DB.CreateIndex(core.SqlTable(this.TableName), indexModel) //设置 验证码过期时间索引 return } @@ -46,7 +53,7 @@ func (this *modelDrawRecode) getDrawCardRecord(uid string) (results []*pb.DBHero ) results = make([]*pb.DBHeroDrawRecord, 0) if cursor, err = this.DBModel.DB.Find(comm.TableDrawRecode, bson.M{"uid": uid}, options.Find().SetSort(bson.M{"ctime": -1}), - options.Find().SetLimit(int64(comm.MaxRankList))); err != nil { + options.Find().SetLimit(int64(comm.DrawRecordNumber))); err != nil { this.module.Errorln(err) return } else { diff --git a/modules/moonlv/module.go b/modules/moonlv/module.go index c5a185fc5..3d8fbf264 100644 --- a/modules/moonlv/module.go +++ b/modules/moonlv/module.go @@ -113,3 +113,10 @@ func (this *Moonlv) BuriedsNotify(session comm.IUserSession, conds []*pb.ConIPro } } } + +func (this *Moonlv) GMCreateMoonlv(session comm.IUserSession, lv int32) { + if lv <= 0 { + return + } + this.modelMoonlv.modifyMoonlvList(session.GetUserId(), map[string]interface{}{"lv": lv}) +} diff --git a/pb/hero_db.pb.go b/pb/hero_db.pb.go index fe4ed13d5..4cf936882 100644 --- a/pb/hero_db.pb.go +++ b/pb/hero_db.pb.go @@ -659,7 +659,7 @@ type DBHeroDrawRecord struct { Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID HeroId []string `protobuf:"bytes,3,rep,name=heroId,proto3" json:"heroId"` // 英雄ID Drawtype int32 `protobuf:"varint,4,opt,name=drawtype,proto3" json:"drawtype"` // 卡池 - Ctime int64 `protobuf:"varint,5,opt,name=ctime,proto3" json:"ctime"` // 抽卡时间 + Ctime int64 `protobuf:"varint,5,opt,name=ctime,proto3" json:"ctime"` } func (x *DBHeroDrawRecord) Reset() {