diff --git a/comm/imodule.go b/comm/imodule.go index 10c2a8374..f2bda9d49 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -218,6 +218,8 @@ type ( // 体力转经验 PsConvertExp(ps int32) (res *cfg.Gameatn) + + CleanUserConsumeMoney(session IUserSession) (err error) } //武器模块 IEquipment interface { diff --git a/modules/entertainment/api_getlist.go b/modules/entertainment/api_getlist.go index cee72dc15..9aaed987a 100644 --- a/modules/entertainment/api_getlist.go +++ b/modules/entertainment/api_getlist.go @@ -48,7 +48,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.EntertainGetList if list.Etime > endSeasonTime { list.Etime = endSeasonTime update["etime"] = list.Etime - this.module.ModuleUser.CleanUserMerchantmoney(session) + this.module.ModuleUser.CleanUserConsumeMoney(session) curMonth := time.Now().Month() // 计算赛季 curYear := time.Now().Year() preMonth := this.module.service.GetOpentime().Month() @@ -56,6 +56,13 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.EntertainGetList tmp := int(curYear-preYear)*12 + int(curMonth-preMonth) list.Rounds = int32(tmp) update["rounds"] = list.Rounds + + // 低于一定的分数数据不清了 + score := this.module.configure.GetConsumeResetIntegral() + if list.Consumeexp > score { + list.Consumeexp = score + update["consumeexp"] = list.Consumeexp + } } this.module.model.modifyEntertainmList(session.GetUserId(), update) } diff --git a/modules/entertainment/configure.go b/modules/entertainment/configure.go index f6868fa1c..5db9cde93 100644 --- a/modules/entertainment/configure.go +++ b/modules/entertainment/configure.go @@ -26,10 +26,11 @@ const ( // /配置管理组件 type configureComp struct { modules.MCompConfigure - module *Entertainment - lock sync.RWMutex - block map[int32]*cfg.GameBlockData - order map[int32][]*cfg.GamePassCheckData //战令 + module *Entertainment + lock sync.RWMutex + block map[int32]*cfg.GameBlockData + order map[int32][]*cfg.GamePassCheckData //战令 + resetScore int32 // 重置积分 } const moduleName = "entertainment" @@ -48,6 +49,9 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp }) configure.RegisterConfigure(game_block, cfg.NewGameBlock, this.LoadGameBlock) configure.RegisterConfigure(game_passcheck, cfg.NewGamePassCheck, this.updatePassCheck) + configure.RegisterConfigure(game_consumeIntegral, cfg.NewGameConsumeIntegral, this.loadConsumeIntegral) + + this.GetConsumeResetIntegral() return } @@ -365,3 +369,28 @@ func (this *configureComp) GetGameConsumeReward() (conf []*cfg.GameIntegralData, err = comm.NewNotFoundConfErr(moduleName, game_integral, nil) return } +func (this *configureComp) loadConsumeIntegral() { + var ( + v interface{} + configure *cfg.GameConsumeIntegral + err error + ok bool + ) + if v, err = this.GetConfigure(game_consumeIntegral); err != nil { + this.module.Errorln(err) + return + } + if configure, ok = v.(*cfg.GameConsumeIntegral); ok { + for _, v := range configure.GetDataList() { + if v.Type == 2 { + this.resetScore = v.Key + break + } + } + } + return +} + +func (this *configureComp) GetConsumeResetIntegral() (score int32) { + return this.resetScore +} diff --git a/modules/user/model_user.go b/modules/user/model_user.go index 0bf47c749..ac9fd6c9f 100644 --- a/modules/user/model_user.go +++ b/modules/user/model_user.go @@ -310,31 +310,23 @@ func (this *ModelUser) changelv(session comm.IUserSession, lv int32, exp int64, } func (this *ModelUser) CleanUserMerchantmoney(session comm.IUserSession) (err error) { - // 只处理跨服 - if !db.IsCross() { - return - } - var ( - update map[string]interface{} - uid string - ) - uid = session.GetUserId() - user := &pb.DBUser{} - update = make(map[string]interface{}, 0) - update["profit"] = 0 - update["merchantmoney"] = 0 - if user.Caravanlv == 0 { // 默认1级 - user.Caravanlv = 1 - update["caravanlv"] = user.Caravanlv + // 获取本服的数据 + if m, e := this.module.GetDBModelByUid(session.GetUserId(), this.TableName); e == nil { + user := &pb.DBUser{} + if err := m.Get(session.GetUserId(), user); err == nil { + if user.Caravanlv == 0 { + user.Caravanlv = 1 + } + err = m.Change(session.GetUserId(), map[string]interface{}{ + "profit": 0, + "caravanlv": user.Caravanlv, + "merchantmoney": 0, + }) + } else { + this.module.Errorf("err:%v", err) + } } - - if err := this.Get(uid, user); err == nil { - err = this.Change(uid, update) - } else { - this.module.Errorf("err:%v", err) - } - return } @@ -407,3 +399,12 @@ func (this *ModelUser) ResAutoReplies(session comm.IUserSession, resreplies map[ } } } +func (this *ModelUser) CleanUserConsumeMoney(session comm.IUserSession) (err error) { + // 获取本服的数据 + if m, e := this.module.GetDBModelByUid(session.GetUserId(), this.TableName); e == nil { + err = m.Change(session.GetUserId(), map[string]interface{}{ + "consumemoney": 0, + }) + } + return +} diff --git a/modules/user/module.go b/modules/user/module.go index ab666645d..12b6a844f 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -1476,3 +1476,7 @@ func (this *User) PsConvertExp(ps int32) (res *cfg.Gameatn) { return } + +func (this *User) CleanUserConsumeMoney(session comm.IUserSession) (err error) { + return this.modelUser.CleanUserConsumeMoney(session) +}