优化日志

This commit is contained in:
meixiongfeng 2023-12-14 10:32:14 +08:00
parent 46424d36ea
commit 35714bc422
17 changed files with 99 additions and 60 deletions

View File

@ -19,7 +19,8 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.AcademyReceiveRe
level *cfg.GameTeachingData level *cfg.GameTeachingData
info *pb.DBAcademy info *pb.DBAcademy
// group []*cfg.GameTeachingData // group []*cfg.GameTeachingData
err error err error
atno []*pb.UserAtno
) )
if errdata = this.ReceiveCheck(session, req); errdata != nil { if errdata = this.ReceiveCheck(session, req); errdata != nil {
return return
@ -65,11 +66,13 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.AcademyReceiveRe
return return
} }
this.module.DispenseRes(session, level.Award, true) if errdata, atno = this.module.DispenseAtno(session, level.Award, true); err != nil {
return
}
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.ModuleBuried.TriggerBuried(session, comm.GetBuriedParam(comm.Rtype151, 1)) this.module.ModuleBuried.TriggerBuried(session, comm.GetBuriedParam(comm.Rtype151, 1))
this.module.WriteUserLog(session.GetUserId(),req, comm.GMResAddType, "AcademyReceiveReq", level.Award) this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "AcademyReceiveReq", atno)
}) })
} }

View File

@ -20,6 +20,7 @@ func (this *apiComp) TeachingReceive(session comm.IUserSession, req *pb.AcademyT
level *cfg.GameHeroStrategyData level *cfg.GameHeroStrategyData
info *pb.DBAcademy info *pb.DBAcademy
err error err error
atno []*pb.UserAtno
) )
if errdata = this.TeachingReceiveCheck(session, req); errdata != nil { if errdata = this.TeachingReceiveCheck(session, req); errdata != nil {
return return
@ -64,10 +65,12 @@ func (this *apiComp) TeachingReceive(session comm.IUserSession, req *pb.AcademyT
} }
return return
} }
this.module.DispenseRes(session, level.Award, true) if errdata, atno = this.module.DispenseAtno(session, level.Award, true); err != nil {
return
}
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "AcademyTeachingReceiveReq", level.Award) this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "AcademyTeachingReceiveReq", atno)
}) })
} }
session.SendMsg(string(this.module.GetType()), "teachingreceive", &pb.AcademyTeachingReceiveResp{Issucc: true}) session.SendMsg(string(this.module.GetType()), "teachingreceive", &pb.AcademyTeachingReceiveResp{Issucc: true})

View File

@ -28,6 +28,7 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
buyValue int32 // 任务统计 贩卖货物价值 buyValue int32 // 任务统计 贩卖货物价值
sellSpValue int32 // 任务统计 向指定X城市贩卖货物贩卖货物价值 sellSpValue int32 // 任务统计 向指定X城市贩卖货物贩卖货物价值
profitValue int32 // 盈利 profitValue int32 // 盈利
atno []*pb.UserAtno
) )
update = make(map[string]interface{}) update = make(map[string]interface{})
if errdata = this.BuyOrSellCheck(session, req); errdata != nil { if errdata = this.BuyOrSellCheck(session, req); errdata != nil {
@ -112,11 +113,11 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
T: "profit", T: "profit",
N: profitValue, N: profitValue,
}) })
if errdata = this.module.DispenseRes(session, addRes, true); errdata != nil { if errdata, atno = this.module.DispenseAtno(session, addRes, true); errdata != nil {
this.module.Errorf("获得虚拟币失败:%v", errdata) this.module.Errorf("获得虚拟币失败:%v", errdata)
} }
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "troll sell", addRes) this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "troll sell", atno)
}) })
this.module.ArrayBag(caravan) this.module.ArrayBag(caravan)
@ -220,7 +221,7 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
} }
return return
} }
if errdata = this.module.DispenseRes(session, []*cfg.Gameatn{{ if errdata, atno = this.module.DispenseAtno(session, []*cfg.Gameatn{{
A: "attr", A: "attr",
T: "merchantmoney", T: "merchantmoney",
N: addScore, N: addScore,
@ -228,11 +229,7 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
this.module.Errorf("获得虚拟币失败:%v", errdata) this.module.Errorf("获得虚拟币失败:%v", errdata)
} }
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "troll buy", []*cfg.Gameatn{{ this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "troll buy", atno)
A: "attr",
T: "merchantmoney",
N: addScore,
}})
}) })
} }

View File

@ -216,13 +216,17 @@ func (this *Caravan) InitCaravanItemData(uid string, data *pb.DBCaravan) {
// 初始化门票和虚拟币 // 初始化门票和虚拟币
func (this *Caravan) InitCaravanTicket(session comm.IUserSession, conf *cfg.GameCaravanLvData) (errdata *pb.ErrorData) { func (this *Caravan) InitCaravanTicket(session comm.IUserSession, conf *cfg.GameCaravanLvData) (errdata *pb.ErrorData) {
var res []*cfg.Gameatn var (
res []*cfg.Gameatn
atno []*pb.UserAtno
)
res = append(res, conf.Tickettop) res = append(res, conf.Tickettop)
res = append(res, conf.Moneynumtop) res = append(res, conf.Moneynumtop)
errdata = this.DispenseRes(session, res, true) // 推送门票和虚拟币资源 if errdata, atno = this.DispenseAtno(session, res, true); errdata != nil { // 推送门票和虚拟币资源
return
}
go this.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { go this.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.WriteUserLog(session.GetUserId(), "", 0, "InitCaravanTicket", res) this.WriteUserLog(session.GetUserId(), "", 0, "InitCaravanTicket", atno)
}) })
return return
} }
@ -337,7 +341,6 @@ func (this *Caravan) CheckCaravanTask(session comm.IUserSession, data *pb.DBCara
A: "attr", A: "attr",
T: "merchantmoney", T: "merchantmoney",
N: -list.Unreword[1], // 扣除虚拟币 N: -list.Unreword[1], // 扣除虚拟币
O: "",
}) })
go this.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { go this.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.WriteUserLog(session.GetUserId(), "", comm.GMResDelType, "CheckCaravanTask", resp.Reward) // 消耗资源 this.WriteUserLog(session.GetUserId(), "", comm.GMResDelType, "CheckCaravanTask", resp.Reward) // 消耗资源
@ -379,15 +382,18 @@ func (this *Caravan) TaskComplete(session comm.IUserSession, taskid ...int32) {
resp = &pb.CaravanTaskCompletePush{} resp = &pb.CaravanTaskCompletePush{}
resp.Data = list resp.Data = list
resp.BSuccess = true resp.BSuccess = true
var (
if errdata, reward := this.ModuleBase.DispenseAtno(session, conf.Reword, true); errdata != nil { atno []*pb.UserAtno
errdata *pb.ErrorData
)
if errdata, atno = this.ModuleBase.DispenseAtno(session, conf.Reword, true); errdata != nil {
this.Errorf("Caravan DispenseRes err:%v", conf.Reword) this.Errorf("Caravan DispenseRes err:%v", conf.Reword)
} else { } else {
resp.Reward = reward resp.Reward = atno
} }
session.SendMsg(string(this.GetType()), "taskcomplete", resp) session.SendMsg(string(this.GetType()), "taskcomplete", resp)
go this.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { go this.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.WriteUserLog(session.GetUserId(), taskid, 0, "TaskComplete", conf.Reword) this.WriteUserLog(session.GetUserId(), taskid, comm.GMResAddType, "TaskComplete", atno)
}) })
} }
} }

View File

@ -23,6 +23,7 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC
atns []*pb.UserAssets atns []*pb.UserAssets
ok bool ok bool
err error err error
atno []*pb.UserAtno
) )
if errdata = this.ChallengeReceiveCheck(session, req); errdata != nil { if errdata = this.ChallengeReceiveCheck(session, req); errdata != nil {
@ -82,7 +83,9 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC
return return
} }
this.module.DispenseRes(session, manster.Award, true) if errdata, atno = this.module.DispenseAtno(session, manster.Award, true); errdata != nil {
return
}
atns = make([]*pb.UserAssets, len(manster.Award)) atns = make([]*pb.UserAssets, len(manster.Award))
for i, v := range manster.Award { for i, v := range manster.Award {
atns[i] = &pb.UserAssets{ atns[i] = &pb.UserAssets{
@ -101,7 +104,7 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC
} }
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "CombatChallengeReceiveReq", atns) this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "CombatChallengeReceiveReq", atno)
}) })
} }
session.SendMsg(string(this.module.GetType()), "challengereceive", &pb.CombatChallengeReceiveResp{Level: req.Level, Manster: req.Manster, Atns: atns}) session.SendMsg(string(this.module.GetType()), "challengereceive", &pb.CombatChallengeReceiveResp{Level: req.Level, Manster: req.Manster, Atns: atns})

View File

@ -23,6 +23,7 @@ func (this *apiComp) Drop(session comm.IUserSession, req *pb.CombatDropReq) (err
user *pb.DBUser user *pb.DBUser
ok bool ok bool
err error err error
atno []*pb.UserAtno
) )
if errdata = this.DropCheck(session, req); errdata != nil { if errdata = this.DropCheck(session, req); errdata != nil {
return return
@ -92,7 +93,7 @@ func (this *apiComp) Drop(session comm.IUserSession, req *pb.CombatDropReq) (err
} }
return return
} }
if errdata = this.module.DispenseRes(session, reward, true); errdata != nil { if errdata, atno = this.module.DispenseAtno(session, reward, true); errdata != nil {
return return
} }
atns = make([]*pb.UserAssets, len(reward)) atns = make([]*pb.UserAssets, len(reward))
@ -114,7 +115,7 @@ func (this *apiComp) Drop(session comm.IUserSession, req *pb.CombatDropReq) (err
session.SendMsg(string(this.module.GetType()), "drop", &pb.CombatDropResp{Level: req.Level, Atns: atns}) session.SendMsg(string(this.module.GetType()), "drop", &pb.CombatDropResp{Level: req.Level, Atns: atns})
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "CombatDropReq", atns) this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "CombatDropReq", atno)
}) })
return return
} }

View File

@ -12,7 +12,11 @@ func (a *apiComp) AutoreceiveCheck(session comm.IUserSession, req *pb.DispatchAu
} }
func (a *apiComp) Autoreceive(session comm.IUserSession, req *pb.DispatchAutoReceiveReq) (errdata *pb.ErrorData) { func (a *apiComp) Autoreceive(session comm.IUserSession, req *pb.DispatchAutoReceiveReq) (errdata *pb.ErrorData) {
var res []*cfg.Gameatn var (
res []*cfg.Gameatn
rss []*pb.DispatchTaskRsp
atno []*pb.UserAtno
)
rsp := &pb.DispatchAutoReceiveResp{} rsp := &pb.DispatchAutoReceiveResp{}
d := a.module.modelDispatch.getDBDispatch(session.GetUserId()) d := a.module.modelDispatch.getDBDispatch(session.GetUserId())
if d == nil { if d == nil {
@ -32,11 +36,6 @@ func (a *apiComp) Autoreceive(session comm.IUserSession, req *pb.DispatchAutoRec
} }
} }
// if !flag {
// code = pb.ErrorCode_DispatchNoFinished
// return
// }
tasks, oldTasks := a.module.modelDispatch.replaceFinishedTask(session.GetUserId(), d) tasks, oldTasks := a.module.modelDispatch.replaceFinishedTask(session.GetUserId(), d)
//更新公告任务 //更新公告任务
@ -45,8 +44,6 @@ func (a *apiComp) Autoreceive(session comm.IUserSession, req *pb.DispatchAutoRec
return return
} }
var rss []*pb.DispatchTaskRsp
//奖励 //奖励
for _, t := range oldTasks { for _, t := range oldTasks {
gd, err := a.module.configure.getDispatchTaskConf(t.TaskId) gd, err := a.module.configure.getDispatchTaskConf(t.TaskId)
@ -65,13 +62,15 @@ func (a *apiComp) Autoreceive(session comm.IUserSession, req *pb.DispatchAutoRec
} }
rss = append(rss, rs) rss = append(rss, rs)
} }
a.module.DispenseRes(session, res, true) if errdata, atno = a.module.DispenseAtno(session, res, true); errdata != nil {
return
}
rsp.Task = rss rsp.Task = rss
session.SendMsg(string(a.module.GetType()), "autoreceive", rsp) session.SendMsg(string(a.module.GetType()), "autoreceive", rsp)
go a.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { go a.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
a.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "DispatchAutoReceiveReq", res) a.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "DispatchAutoReceiveReq", atno)
}) })
return return
} }

View File

@ -66,11 +66,13 @@ func (a *apiComp) Notice(session comm.IUserSession, req *pb.DispatchNoticeReq) (
if int32(left) < limit { if int32(left) < limit {
add := limit - int32(left) add := limit - int32(left)
atn := &cfg.Gameatn{A: "item", T: itemId, N: add} atn := &cfg.Gameatn{A: "item", T: itemId, N: add}
a.module.DispenseRes(session, []*cfg.Gameatn{atn}, true) if e, atno := a.module.DispenseAtno(session, []*cfg.Gameatn{atn}, true); e != nil {
return e
go a.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { } else {
a.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "恢复门票", atn) go a.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
}) a.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "恢复门票", atno)
})
}
} }
} }
//周任务重置 //周任务重置

View File

@ -57,10 +57,11 @@ func (a *apiComp) Weekrecive(session comm.IUserSession, req *pb.DispatchWeekReci
} }
} }
if len(res) > 0 { if len(res) > 0 {
a.module.DispenseRes(session, res, true) if errdata, atno := a.module.DispenseAtno(session, res, true); errdata != nil {
go a.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { go a.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
a.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "DispatchWeekReciveReq", res) a.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "DispatchWeekReciveReq", atno)
}) })
}
} }
session.SendMsg(string(a.module.GetType()), "weekrecive", rsp) session.SendMsg(string(a.module.GetType()), "weekrecive", rsp)
return return

View File

@ -25,6 +25,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.EnchantCha
bWin bool // 战斗是否胜利 bWin bool // 战斗是否胜利
score int32 // 通关获得分数 score int32 // 通关获得分数
res []*cfg.Gameatn res []*cfg.Gameatn
atno []*pb.UserAtno
) )
mapData = make(map[string]interface{}, 0) mapData = make(map[string]interface{}, 0)
// reward = make([]*cfg.Gameatn, 0) // reward = make([]*cfg.Gameatn, 0)
@ -102,11 +103,11 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.EnchantCha
} }
} }
if len(res) > 0 { if len(res) > 0 {
if errdata = this.module.DispenseRes(session, res, true); errdata != nil { if errdata, atno = this.module.DispenseAtno(session, res, true); errdata != nil {
return return
} }
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "EnchantChallengeOverReq", res) this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "EnchantChallengeOverReq", atno)
}) })
} }

View File

@ -26,7 +26,7 @@ func (this *apiComp) Sell(session comm.IUserSession, req *pb.EquipmentSellReq) (
confs []*cfg.GameEquipData confs []*cfg.GameEquipData
confUpsells []*cfg.GameEquipUpsellData confUpsells []*cfg.GameEquipUpsellData
sale [][]*cfg.Gameatn sale [][]*cfg.Gameatn
reward []*pb.UserAtno atno []*pb.UserAtno
) )
if errdata = this.SellCheck(session, req); errdata != nil { if errdata = this.SellCheck(session, req); errdata != nil {
return return
@ -102,15 +102,15 @@ func (this *apiComp) Sell(session comm.IUserSession, req *pb.EquipmentSellReq) (
for _, v := range sale { for _, v := range sale {
sales = append(sales, v...) sales = append(sales, v...)
} }
if errdata, reward = this.module.DispenseAtno(session, sales, true); errdata != nil { if errdata, atno = this.module.DispenseAtno(session, sales, true); errdata != nil {
return return
} }
if errdata = this.module.DelEquipments(session, req.EquipIds, true); errdata != nil { if errdata = this.module.DelEquipments(session, req.EquipIds, true); errdata != nil {
return return
} }
session.SendMsg(string(this.module.GetType()), "sell", &pb.EquipmentSellResp{IsSucc: true, Reward: reward}) session.SendMsg(string(this.module.GetType()), "sell", &pb.EquipmentSellResp{IsSucc: true, Reward: atno})
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "EquipmentSellReq", reward) this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "EquipmentSellReq", atno)
}) })
return return
} }

View File

@ -12,6 +12,9 @@ func (this *apiComp) GetrewardCheck(session comm.IUserSession, req *pb.FriendGet
} }
func (this *apiComp) Getreward(session comm.IUserSession, req *pb.FriendGetrewardReq) (errdata *pb.ErrorData) { func (this *apiComp) Getreward(session comm.IUserSession, req *pb.FriendGetrewardReq) (errdata *pb.ErrorData) {
var (
atno []*pb.UserAtno
)
uid := session.GetUserId() uid := session.GetUserId()
//获取玩家自己好友数据 //获取玩家自己好友数据
self, err := this.module.modelFriend.GetFriend(uid) self, err := this.module.modelFriend.GetFriend(uid)
@ -48,7 +51,7 @@ func (this *apiComp) Getreward(session comm.IUserSession, req *pb.FriendGetrewar
} }
globalConf := this.module.ModuleTools.GetGlobalConf() globalConf := this.module.ModuleTools.GetGlobalConf()
if errdata = this.module.DispenseRes(session, globalConf.FriendPeize, true); errdata != nil { if errdata, atno = this.module.DispenseAtno(session, globalConf.FriendPeize, true); errdata != nil {
this.module.Error("好友领奖励", this.module.Error("好友领奖励",
log.Field{Key: "uid", Value: uid}, log.Field{Key: "uid", Value: uid},
log.Field{Key: "reward", Value: globalConf.FriendPeize}, log.Field{Key: "reward", Value: globalConf.FriendPeize},
@ -61,7 +64,7 @@ func (this *apiComp) Getreward(session comm.IUserSession, req *pb.FriendGetrewar
session.SendMsg(string(this.module.GetType()), "getreward", rsp) session.SendMsg(string(this.module.GetType()), "getreward", rsp)
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "FriendGetrewardReq", globalConf.FriendPeize) this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "FriendGetrewardReq", atno)
}) })
return return
} }

View File

@ -29,6 +29,7 @@ func (this *apiComp) Zan(session comm.IUserSession, req *pb.FriendZanReq) (errda
target *pb.DBFriend target *pb.DBFriend
err error err error
selfId string selfId string
atno []*pb.UserAtno
) )
uid := session.GetUserId() uid := session.GetUserId()
@ -126,14 +127,16 @@ func (this *apiComp) Zan(session comm.IUserSession, req *pb.FriendZanReq) (errda
T: "friendPoint", T: "friendPoint",
N: 1, N: 1,
} }
this.module.DispenseRes(s, []*cfg.Gameatn{res}, true) if errdata, atno = this.module.DispenseAtno(s, []*cfg.Gameatn{res}, true); errdata != nil {
return
}
session.SendMsg(string(this.module.GetType()), FriendSubTypeZan, rsp) session.SendMsg(string(this.module.GetType()), FriendSubTypeZan, rsp)
// 赠送X次友情点 // 赠送X次友情点
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.ModuleBuried.TriggerBuried(session, comm.GetBuriedParam(comm.Rtype11, 1)) this.module.ModuleBuried.TriggerBuried(session, comm.GetBuriedParam(comm.Rtype11, 1))
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "FriendGetrewardReq", res) this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "FriendGetrewardReq", atno)
}) })
return return
} }

View File

@ -18,7 +18,9 @@ func (this *apiComp) ActivateAtlasCheck(session comm.IUserSession, req *pb.Gourm
} }
func (this *apiComp) ActivateAtlas(session comm.IUserSession, req *pb.GourmetActivateAtlasReq) (errdata *pb.ErrorData) { func (this *apiComp) ActivateAtlas(session comm.IUserSession, req *pb.GourmetActivateAtlasReq) (errdata *pb.ErrorData) {
var (
atno []*pb.UserAtno
)
errdata = this.ActivateAtlasCheck(session, req) errdata = this.ActivateAtlasCheck(session, req)
if errdata != nil { if errdata != nil {
return // 参数校验失败直接返回 return // 参数校验失败直接返回
@ -56,13 +58,15 @@ func (this *apiComp) ActivateAtlas(session comm.IUserSession, req *pb.GourmetAct
} }
// 发送首次获得奖励 // 发送首次获得奖励
this.module.DispenseRes(session, []*cfg.Gameatn{conf.Unlockreward}, true) if errdata, atno = this.module.DispenseAtno(session, []*cfg.Gameatn{conf.Unlockreward}, true); errdata != nil {
return
}
session.SendMsg(string(this.module.GetType()), "activateatlas", &pb.GourmetActivateAtlasResp{ session.SendMsg(string(this.module.GetType()), "activateatlas", &pb.GourmetActivateAtlasResp{
Atlas: _gourmet.Atlas, Atlas: _gourmet.Atlas,
}) })
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "GourmetActivateAtlasReq", conf.Unlockreward) this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "GourmetActivateAtlasReq", atno)
}) })
return return
} }

View File

@ -24,6 +24,7 @@ func (this *apiComp) CreateFood(session comm.IUserSession, req *pb.GourmetCreate
res []*cfg.Gameatn res []*cfg.Gameatn
curFood string // 做出来的食物ID curFood string // 做出来的食物ID
bFirst bool // 是否首次获得 bFirst bool // 是否首次获得
atno []*pb.UserAtno
) )
errdata = this.CreateFoodCheck(session, req) errdata = this.CreateFoodCheck(session, req)
if errdata != nil { if errdata != nil {
@ -78,7 +79,9 @@ func (this *apiComp) CreateFood(session comm.IUserSession, req *pb.GourmetCreate
T: curFood, T: curFood,
N: 1, N: 1,
} }
this.module.DispenseRes(session, []*cfg.Gameatn{atn}, true) if errdata, atno = this.module.DispenseAtno(session, []*cfg.Gameatn{atn}, true); errdata != nil {
return
}
rst, _ := this.module.modelAtlas.getGourmetAtlasList(session.GetUserId()) // 校验是否首次获得 rst, _ := this.module.modelAtlas.getGourmetAtlasList(session.GetUserId()) // 校验是否首次获得
if _, ok := rst.Atlas[curFood]; !ok { if _, ok := rst.Atlas[curFood]; !ok {
@ -100,7 +103,7 @@ func (this *apiComp) CreateFood(session comm.IUserSession, req *pb.GourmetCreate
}) })
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.ModuleBuried.TriggerBuried(session, comm.GetBuriedParam(comm.Rtype150, 1)) this.module.ModuleBuried.TriggerBuried(session, comm.GetBuriedParam(comm.Rtype150, 1))
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "GourmetCreateFoodReq", atn) this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "GourmetCreateFoodReq", atno)
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResDelType, "GourmetCreateFoodReq", res) this.module.WriteUserLog(session.GetUserId(), req, comm.GMResDelType, "GourmetCreateFoodReq", res)
}) })
return return

View File

@ -164,7 +164,13 @@ func (t t20190107) A(a int) int {
return t.v + a return t.v + a
} }
func Test_Main(t *testing.T) { func Test_Main(t *testing.T) {
var (
szByte []byte
)
szByte = make([]byte, 0)
//szByte = append(szByte, 8)
fmt.Printf("%v,%s", szByte, string(szByte))
i := t20190107{678} i := t20190107{678}
t1 := reflect.TypeOf(i) t1 := reflect.TypeOf(i)
for it := 0; it < t1.NumMethod(); it++ { for it := 0; it < t1.NumMethod(); it++ {

View File

@ -58,10 +58,14 @@ func (this *modelUserLog) AddUserLog(uid string, req interface{}, itype int32, t
if len(jsonStr) == 0 { if len(jsonStr) == 0 {
return return
} }
if jsonReq, err = json.Marshal(req); err != nil { if jsonReq, err = json.Marshal(req); err != nil {
log.Errorln(err) log.Errorln(err)
return return
} }
if len(jsonReq) > 128 {
jsonReq = make([]byte, 0)
}
if itype == 0 { if itype == 0 {
logType = "add" // 新增资源类型 logType = "add" // 新增资源类型
} else if itype == 1 { } else if itype == 1 {