# Conflicts:
#	modules/task/api_receive.go
This commit is contained in:
zhaocy 2022-08-01 15:23:56 +08:00
commit 7681be0aba
19 changed files with 92 additions and 61 deletions

View File

@ -67,7 +67,7 @@ type (
//获取用户expand //获取用户expand
GetUserExpand(uid string) (result *pb.DBUserExpand, err error) GetUserExpand(uid string) (result *pb.DBUserExpand, err error)
//更新用户expand //更新用户expand
ChanageUserExpand(uid string, value map[string]interface{}) error ChangeUserExpand(uid string, value map[string]interface{}) error
} }
//武器模块 //武器模块
IEquipment interface { IEquipment interface {

View File

@ -28,7 +28,7 @@ func (this *apiComp) ChanageChannel(session comm.IUserSession, req *pb.ChatChana
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }
this.module.ModuleUser.ChanageUserExpand(session.GetUserId(), map[string]interface{}{ this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{
"chatchannel": req.ChannelId, "chatchannel": req.ChannelId,
}) })
} }

View File

@ -23,7 +23,7 @@ func (this *apiComp) CrossChannel(session comm.IUserSession, req *pb.ChatCrossCh
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }
this.module.ModuleUser.ChanageUserExpand(session.GetUserId(), map[string]interface{}{ this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{
"chatchannel": channel, "chatchannel": channel,
}) })
session.SendMsg(string(this.module.GetType()), "crosschannel", &pb.ChatCrossChannelResp{ChannelId: channel}) session.SendMsg(string(this.module.GetType()), "crosschannel", &pb.ChatCrossChannelResp{ChannelId: channel})

View File

@ -11,11 +11,9 @@ import (
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/lego/sys/mgo" "go_dreamfactory/lego/sys/mgo"
"go_dreamfactory/lego/sys/redis" "go_dreamfactory/lego/sys/redis"
"go_dreamfactory/pb"
"go_dreamfactory/sys/cache" "go_dreamfactory/sys/cache"
"go_dreamfactory/sys/db" "go_dreamfactory/sys/db"
"reflect" "reflect"
"time"
"unsafe" "unsafe"
"github.com/modern-go/reflect2" "github.com/modern-go/reflect2"
@ -671,31 +669,31 @@ func (this *MCompModel) logOpt(uid string, data interface{}, attrs ...*cache.Ope
} }
//获取用户通过扩展表 //获取用户通过扩展表
func (this *MCompModel) GetUserRecord(uid string) (result *pb.DBUserRecord, err error) { // func (this *MCompModel) GetUserRecord(uid string) (result *pb.DBUserRecord, err error) {
result = &pb.DBUserRecord{} // result = &pb.DBUserRecord{}
key := fmt.Sprintf("userrecord:%s{userrecord}", uid) // key := fmt.Sprintf("userrecord:%s{userrecord}", uid)
if err = this.Redis.HGetAll(key, result); err != nil && err != redis.RedisNil { // if err = this.Redis.HGetAll(key, result); err != nil && err != redis.RedisNil {
return // return
} // }
if err == redis.RedisNil { // if err == redis.RedisNil {
if err = this.DB.FindOne(core.SqlTable("userrecord"), bson.M{"uid": uid}).Decode(result); err != nil { // if err = this.DB.FindOne(core.SqlTable("userrecord"), bson.M{"uid": uid}).Decode(result); err != nil {
return // return
} // }
err = this.Redis.HMSet(key, result) // err = this.Redis.HMSet(key, result)
} // }
return // return
} // }
//修改用户扩展数据 // //修改用户扩展数据
func (this *MCompModel) ChangeUserRecord(uid string, value map[string]interface{}) (err error) { // func (this *MCompModel) ChangeUserRecord(uid string, value map[string]interface{}) (err error) {
value["mtime"] = time.Now().Unix() // 更新时间 // value["mtime"] = time.Now().Unix() // 更新时间
key := fmt.Sprintf("userrecord:%s{userrecord}", uid) // key := fmt.Sprintf("userrecord:%s{userrecord}", uid)
if err = this.Redis.HMSet(key, value); err != nil && err != redis.RedisNil { // if err = this.Redis.HMSet(key, value); err != nil && err != redis.RedisNil {
return // return
} // }
err = this.UpdateModelLogs("userrecord", uid, bson.M{"uid": uid}, value) // err = this.UpdateModelLogs("userrecord", uid, bson.M{"uid": uid}, value)
return // return
} // }
// 删除玩家缓存信息 // 删除玩家缓存信息
func (this *MCompModel) CleanUserRecord(uid string) (err error) { func (this *MCompModel) CleanUserRecord(uid string) (err error) {

View File

@ -53,27 +53,39 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
} }
} }
// =======活动数据记录完成 // =======活动数据记录完成
rst, _ := this.module.modelHero.GetUserRecord(session.GetUserId()) rst, _ := this.module.modelRecord.GetUserRecord(session.GetUserId())
if req.DrawType%2 == 0 { // 转成对应阵营信息 1~5 if req.DrawType%2 == 0 { // 转成对应阵营信息 1~5
race = int32((int(req.DrawType)) / 2) race = int32((int(req.DrawType)) / 2)
} else { } else {
race = int32(int(req.DrawType+1) / 2) race = int32(int(req.DrawType+1) / 2)
} }
if race == comm.RacePt { // 普通卡池 if race == comm.RacePt { // 普通卡池
curStar4Count = rst.Race0.H4 if rst.Race0 != nil {
curStar5Count = rst.Race0.H5 curStar4Count = rst.Race0.H4
curStar5Count = rst.Race0.H5
}
} else if race == comm.RaceZr { // 灼热 } else if race == comm.RaceZr { // 灼热
curStar4Count = rst.Race1.H4 if rst.Race1 != nil {
curStar5Count = rst.Race1.H5 curStar4Count = rst.Race1.H4
curStar5Count = rst.Race1.H5
}
} else if race == comm.RaceYd { // 涌动 } else if race == comm.RaceYd { // 涌动
curStar4Count = rst.Race2.H4 if rst.Race2 != nil {
curStar5Count = rst.Race2.H5 curStar4Count = rst.Race2.H4
curStar5Count = rst.Race2.H5
}
} else if race == comm.RaceHx { // 呼啸 } else if race == comm.RaceHx { // 呼啸
curStar4Count = rst.Race3.H4 if rst.Race3 != nil {
curStar5Count = rst.Race3.H5 curStar4Count = rst.Race3.H4
curStar5Count = rst.Race3.H5
}
} else if race == comm.RaceSy { // 闪耀 } else if race == comm.RaceSy { // 闪耀
curStar4Count = rst.Race4.H4 if rst.Race4 != nil {
curStar5Count = rst.Race4.H5 curStar4Count = rst.Race4.H4
curStar5Count = rst.Race4.H5
}
} }
// 获取配置文件的权重信息 // 获取配置文件的权重信息
_conf, err := this.module.configure.GetHeroDrawConfig(race) _conf, err := this.module.configure.GetHeroDrawConfig(race)
@ -185,7 +197,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
update := map[string]interface{}{} update := map[string]interface{}{}
update["race"+strconv.Itoa(int(race)-1)] = raceData update["race"+strconv.Itoa(int(race)-1)] = raceData
this.module.modelHero.ChangeUserRecord(session.GetUserId(), update) this.module.modelRecord.ChangeUserRecord(session.GetUserId(), update)
// 消耗道具 // 消耗道具
code = this.module.ConsumeRes(session, sz, true) code = this.module.ConsumeRes(session, sz, true)
if code != pb.ErrorCode_Success { if code != pb.ErrorCode_Success {

View File

@ -123,7 +123,7 @@ func (this *ModelHero) initHeroOverlying(uid string, heroCfgId string, count int
"tujian": sz, "tujian": sz,
} }
this.moduleHero.ModuleUser.ChanageUserExpand(uid, initUpdate) this.moduleHero.ModuleUser.ChangeUserExpand(uid, initUpdate)
} }
} }
hero.SameCount = count hero.SameCount = count

View File

@ -1,4 +1,4 @@
package user package hero
import ( import (
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
@ -27,3 +27,21 @@ func (this *ModelRecord) getUserSession(uid string) (cuser *pb.CacheUser) {
} }
return return
} }
//获取用户通过扩展表
func (this *ModelRecord) GetUserRecord(uid string) (result *pb.DBUserRecord, err error) {
result = &pb.DBUserRecord{}
if err = this.Get(uid, result); err != nil {
return
}
return result, err
}
//修改用户扩展数据
func (this *ModelRecord) ChangeUserRecord(uid string, value map[string]interface{}) (err error) {
if len(value) == 0 {
return nil
}
return this.Change(uid, value)
}

View File

@ -16,9 +16,10 @@ func NewModule() core.IModule {
type Hero struct { type Hero struct {
modules.ModuleBase modules.ModuleBase
api *apiComp api *apiComp
configure *configureComp configure *configureComp
modelHero *ModelHero modelHero *ModelHero
modelRecord *ModelRecord
} }
//模块名 //模块名
@ -37,6 +38,7 @@ func (this *Hero) OnInstallComp() {
this.ModuleBase.OnInstallComp() this.ModuleBase.OnInstallComp()
this.api = this.RegisterComp(new(apiComp)).(*apiComp) this.api = this.RegisterComp(new(apiComp)).(*apiComp)
this.modelHero = this.RegisterComp(new(ModelHero)).(*ModelHero) this.modelHero = this.RegisterComp(new(ModelHero)).(*ModelHero)
this.modelRecord = this.RegisterComp(new(ModelRecord)).(*ModelRecord)
this.configure = this.RegisterComp(new(configureComp)).(*configureComp) this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
} }

View File

@ -21,9 +21,7 @@ func (this *apiComp) ReadMail(session comm.IUserSession, req *pb.MailReadMailReq
err error err error
mail *pb.DBMailData mail *pb.DBMailData
) )
defer func() {
session.SendMsg(string(this.module.GetType()), "readmail", &pb.MailReadMailResp{Mail: mail})
}()
code = this.ReadMailCheck(session, req) // check code = this.ReadMailCheck(session, req) // check
if code != pb.ErrorCode_Success { if code != pb.ErrorCode_Success {
return return
@ -31,7 +29,9 @@ func (this *apiComp) ReadMail(session comm.IUserSession, req *pb.MailReadMailReq
mail, err = this.module.modelMail.Mail_ReadOneMail(req.ObjID) mail, err = this.module.modelMail.Mail_ReadOneMail(req.ObjID)
if err != nil { if err != nil {
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
return
} }
mail.Check = true
session.SendMsg(string(this.module.GetType()), "readmail", &pb.MailReadMailResp{Mail: mail})
return return
} }

View File

@ -34,7 +34,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.NotifyGetListReq
userexpand = &pb.DBUserExpand{} userexpand = &pb.DBUserExpand{}
} }
//修改最后公告读取时间 //修改最后公告读取时间
this.module.ModuleUser.ChanageUserExpand(session.GetUserId(), map[string]interface{}{ this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{
"lastreadnotiftime": time.Now().Unix(), "lastreadnotiftime": time.Now().Unix(),
}) })
session.SendMsg(string(this.module.GetType()), "getlist", &pb.NotifyGetListResp{LastReadTime: userexpand.Lastreadnotiftime, SysNotify: notify}) session.SendMsg(string(this.module.GetType()), "getlist", &pb.NotifyGetListResp{LastReadTime: userexpand.Lastreadnotiftime, SysNotify: notify})

View File

@ -69,7 +69,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq)
} }
} }
if len(update) > 0 { if len(update) > 0 {
if err = this.moduleTask.ModuleUser.ChanageUserExpand(session.GetUserId(), update); err != nil { if err = this.moduleTask.ModuleUser.ChangeUserExpand(session.GetUserId(), update); err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }

View File

@ -72,7 +72,7 @@ func (this *ModuleTask) resetActive(uid string, taskTag comm.TaskTag) {
update["activeweek"] = 0 update["activeweek"] = 0
} }
if len(update) > 0 { if len(update) > 0 {
this.ModuleUser.ChanageUserExpand(uid, update) this.ModuleUser.ChangeUserExpand(uid, update)
} }
} }

View File

@ -62,7 +62,7 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c
initUpdate := map[string]interface{}{ initUpdate := map[string]interface{}{
"modifynameCount": 1, //修改名称1次 "modifynameCount": 1, //修改名称1次
} }
if err := this.module.modelExpand.ChanageUserExpand(session.GetUserId(), initUpdate); err != nil { if err := this.module.modelExpand.ChangeUserExpand(session.GetUserId(), initUpdate); err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }

View File

@ -82,7 +82,7 @@ func (this *apiComp) Figure(session comm.IUserSession, req *pb.UserFigureReq) (c
update = utils.StructToMap(curFigure) update = utils.StructToMap(curFigure)
this.module.modelExpand.ChanageUserExpand(session.GetUserId(), update) this.module.modelExpand.ChangeUserExpand(session.GetUserId(), update)
} }
if err := session.SendMsg(string(this.module.GetType()), UserSubTypeFigure, rsp); err != nil { if err := session.SendMsg(string(this.module.GetType()), UserSubTypeFigure, rsp); err != nil {

View File

@ -56,7 +56,7 @@ func (this *apiComp) Modifyname(session comm.IUserSession, req *pb.UserModifynam
mc := map[string]interface{}{ mc := map[string]interface{}{
"modifynameCount": left, "modifynameCount": left,
} }
if err := this.module.modelExpand.ChanageUserExpand(session.GetUserId(), mc); err != nil { if err := this.module.modelExpand.ChangeUserExpand(session.GetUserId(), mc); err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
} }

View File

@ -31,7 +31,7 @@ func (this *apiComp) Modifysign(session comm.IUserSession, req *pb.UserModifysig
update := map[string]interface{}{ update := map[string]interface{}{
"sign": req.Sign, "sign": req.Sign,
} }
this.module.ChanageUserExpand(session.GetUserId(), update) this.module.ChangeUserExpand(session.GetUserId(), update)
} }
if err = session.SendMsg(string(this.module.GetType()), UserSubTypeModifySign, &pb.UserModifysignResp{ if err = session.SendMsg(string(this.module.GetType()), UserSubTypeModifySign, &pb.UserModifysignResp{

View File

@ -36,11 +36,12 @@ func (this *ModelExpand) GetUserExpand(uid string) (result *pb.DBUserExpand, err
if err = this.moduleUser.modelExpand.Get(uid, result); err != nil { if err = this.moduleUser.modelExpand.Get(uid, result); err != nil {
return return
} }
return result, err return result, err
} }
//修改用户扩展数据 //修改用户扩展数据
func (this *ModelExpand) ChanageUserExpand(uid string, value map[string]interface{}) (err error) { func (this *ModelExpand) ChangeUserExpand(uid string, value map[string]interface{}) (err error) {
if len(value) == 0 { if len(value) == 0 {
return nil return nil
} }

View File

@ -152,7 +152,7 @@ func (this *ModelUser) InitFigure(uid string) {
update := map[string]interface{}{ update := map[string]interface{}{
"preinstall": figureMap, "preinstall": figureMap,
} }
this.moduleUser.modelExpand.ChanageUserExpand(uid, update) this.moduleUser.modelExpand.ChangeUserExpand(uid, update)
} }
// change exp // change exp

View File

@ -177,6 +177,6 @@ func (this *User) GetUserExpand(uid string) (result *pb.DBUserExpand, err error)
return this.modelExpand.GetUserExpand(uid) return this.modelExpand.GetUserExpand(uid)
} }
func (this *User) ChanageUserExpand(uid string, value map[string]interface{}) error { func (this *User) ChangeUserExpand(uid string, value map[string]interface{}) error {
return this.modelExpand.ChanageUserExpand(uid, value) return this.modelExpand.ChangeUserExpand(uid, value)
} }