diff --git a/comm/imodule.go b/comm/imodule.go index c3c9c10e8..9b8a8f26a 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -211,6 +211,8 @@ type ( ChangeUserMoonLv(session IUserSession, lv int32) (errdata *pb.ErrorData) //GM创号 GMCreatePlayer(session IUserSession, req *pb.UserCreateReq) (errdata *pb.ErrorData) + // 清除玩家赛季积分 + CleanUserConsumeexp(session IUserSession) (err error) } //武器模块 IEquipment interface { diff --git a/modules/entertainment/api_getlist.go b/modules/entertainment/api_getlist.go index 8b8676c75..1c504e0a7 100644 --- a/modules/entertainment/api_getlist.go +++ b/modules/entertainment/api_getlist.go @@ -29,14 +29,20 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.EntertainGetList } if !utils.IsToday(list.Rtime) { + update := make(map[string]interface{}) list.Rtime = configure.Now().Unix() for _, v := range this.module.configure.GetGameConsumeIntegral() { list.Playtype = append(list.Playtype, v.Key) // 配置读取一个玩法 } - this.module.model.modifyEntertainmList(session.GetUserId(), map[string]interface{}{ - "rtime": list.Rtime, - "playtype": list.Playtype, - }) + update["rtime"] = list.Rtime + update["playtype"] = list.Playtype + _, endSeasonTime := utils.GetMonthStartEnd() + if list.Etime > endSeasonTime { + list.Etime = endSeasonTime + update["etime"] = list.Etime + this.module.ModuleUser.CleanUserMerchantmoney(session) + } + this.module.model.modifyEntertainmList(session.GetUserId(), update) } session.SendMsg(string(this.module.GetType()), "getlist", &pb.EntertainGetListResp{ Data: list, diff --git a/modules/entertainment/model.go b/modules/entertainment/model.go index f78b800f6..05c0d8f6f 100644 --- a/modules/entertainment/model.go +++ b/modules/entertainment/model.go @@ -3,7 +3,6 @@ package entertainment import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" - "go_dreamfactory/lego/sys/redis" "go_dreamfactory/modules" "go_dreamfactory/pb" "go_dreamfactory/sys/db" @@ -53,23 +52,27 @@ func (this *modelComp) getEntertainmList(uid string) (result *pb.DBXXLData, err } if err != nil { - if redis.RedisNil != err { // 没有数据直接创建新的数据 + if mongo.ErrNoDocuments == err { // 没有数据直接创建新的数据 result.Id = primitive.NewObjectID().Hex() result.Uid = uid result.Reward = make(map[int32]int32) result.Card = make(map[string]int32) - } - // 初始化默认获得类型为1的卡片 - for _, v := range this.module.configure.GetInitGameConsumeHero() { - result.Card[v] = 1 - } - if dbModel == nil { - err = this.Add(uid, result) - } else { - err = dbModel.Add(uid, result) + _, endSeasonTime := utils.GetMonthStartEnd() + result.Etime = endSeasonTime + + // 初始化默认获得类型为1的卡片 + for _, v := range this.module.configure.GetInitGameConsumeHero() { + result.Card[v] = 1 + } + if dbModel == nil { + err = this.Add(uid, result) + } else { + err = dbModel.Add(uid, result) + } + err = nil } } - err = nil + return result, err } diff --git a/modules/user/model_user.go b/modules/user/model_user.go index 131f43c73..4df4eaae5 100644 --- a/modules/user/model_user.go +++ b/modules/user/model_user.go @@ -373,3 +373,36 @@ type UserListen struct { Talent4 int32 Merchantmoney int32 } + +func (this *ModelUser) CleanUserConsumeexp(session comm.IUserSession) (err error) { + var ( + model *db.DBModel + update map[string]interface{} + uid string + ) + + uid = session.GetUserId() + user := &pb.DBUser{} + update = make(map[string]interface{}, 0) + update["consumeexp"] = 0 + + if db.IsCross() { + if model, err = this.module.GetDBModelByUid(uid, this.TableName); err == nil { + if err := this.Get(uid, user); err == nil { + err = model.Change(uid, update) + } else { + this.module.Errorf("err:%v", err) + } + } else { + this.module.Errorln(err) + } + } else { + if err := this.Get(uid, user); err == nil { + err = this.Change(uid, update) + } else { + this.module.Errorf("err:%v", err) + } + } + + return +} diff --git a/modules/user/module.go b/modules/user/module.go index 75fc70195..0fa792eeb 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -1441,3 +1441,6 @@ func (this *User) GMCreatePlayer(session comm.IUserSession, req *pb.UserCreateRe errdata = this.api.Create(session, req) return } +func (this *User) CleanUserConsumeexp(session comm.IUserSession) (err error) { + return this.modelUser.CleanUserConsumeexp(session) +} diff --git a/pb/entertain_db.pb.go b/pb/entertain_db.pb.go index c71331730..7676c65fe 100644 --- a/pb/entertain_db.pb.go +++ b/pb/entertain_db.pb.go @@ -393,6 +393,7 @@ type DBXXLData struct { Box []*BoxData `protobuf:"bytes,7,rep,name=box,proto3" json:"box"` Roomid string `protobuf:"bytes,8,opt,name=roomid,proto3" json:"roomid"` // 房间id 重连用 ServicePath string `protobuf:"bytes,9,opt,name=servicePath,proto3" json:"servicePath"` // 目标服务节点 重连RPC用 + Etime int64 `protobuf:"varint,10,opt,name=etime,proto3" json:"etime"` // 赛季结束时间 } func (x *DBXXLData) Reset() { @@ -490,6 +491,13 @@ func (x *DBXXLData) GetServicePath() string { return "" } +func (x *DBXXLData) GetEtime() int64 { + if x != nil { + return x.Etime + } + return 0 +} + var File_entertain_entertain_db_proto protoreflect.FileDescriptor var file_entertain_entertain_db_proto_rawDesc = []byte{ @@ -533,7 +541,7 @@ var file_entertain_entertain_db_proto_rawDesc = []byte{ 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x6f, 0x78, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x62, 0x6f, 0x78, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x6f, 0x70, 0x65, - 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x83, 0x03, 0x0a, 0x09, 0x44, 0x42, 0x58, 0x58, 0x4c, 0x44, + 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x99, 0x03, 0x0a, 0x09, 0x44, 0x42, 0x58, 0x58, 0x4c, 0x44, 0x61, 0x74, 0x61, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x2e, 0x0a, 0x06, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x18, @@ -550,15 +558,17 @@ var file_entertain_entertain_db_proto_rawDesc = []byte{ 0x06, 0x72, 0x6f, 0x6f, 0x6d, 0x69, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x6f, 0x6f, 0x6d, 0x69, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x61, 0x74, 0x68, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x50, 0x61, 0x74, 0x68, 0x1a, 0x39, 0x0a, 0x0b, 0x52, 0x65, 0x77, 0x61, 0x72, - 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, - 0x38, 0x01, 0x1a, 0x37, 0x0a, 0x09, 0x43, 0x61, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, - 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, - 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, - 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x69, 0x63, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x74, 0x69, 0x6d, 0x65, + 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x1a, 0x39, 0x0a, + 0x0b, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, + 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x37, 0x0a, 0x09, 0x43, 0x61, 0x72, 0x64, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, + 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var (