爬塔奖励领取
This commit is contained in:
parent
8e44899d3c
commit
bb24e0943b
@ -3,6 +3,7 @@ package pagoda
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
)
|
||||
|
||||
//参数校验
|
||||
@ -19,57 +20,67 @@ func (this *apiComp) GetRewardCheck(session comm.IUserSession, req *pb.PagodaGet
|
||||
func (this *apiComp) GetReward(session comm.IUserSession, req *pb.PagodaGetRewardReq) (errdata *pb.ErrorData) {
|
||||
|
||||
var (
|
||||
atno []*pb.UserAtno
|
||||
atno []*pb.UserAtno
|
||||
pagoda *pb.DBPagoda
|
||||
err error
|
||||
_cfg *cfg.GamePagodaTaskRewardData
|
||||
)
|
||||
if errdata = this.GetRewardCheck(session, req); errdata != nil {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
|
||||
if pagoda, err := this.module.modelPagoda.getPagodaList(session.GetUserId()); err != nil {
|
||||
_cfg, err := this.module.configure.GetPagodaRewardconfig(req.Id)
|
||||
if err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
if pagoda, err = this.module.modelPagoda.getPagodaList(session.GetUserId()); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
// 校验是否能领取
|
||||
if _cfg.LayerNum > pagoda.PagodaId {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_PagodaConditionErr,
|
||||
Title: pb.ErrorCode_PagodaConditionErr.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if _, ok := pagoda.Reward[req.Id]; ok { // 校验是否重复领取
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_PagodaGetRewardErr,
|
||||
Title: pb.ErrorCode_PagodaGetRewardErr.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if pagoda.Reward == nil {
|
||||
pagoda.Reward = make(map[int32]bool, 0)
|
||||
}
|
||||
// 发奖励
|
||||
if errdata, atno = this.module.DispenseAtno(session, _cfg.Reward, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
pagoda.Reward[req.Id] = true
|
||||
mapData := make(map[string]interface{}, 0)
|
||||
mapData["reward"] = pagoda.Reward
|
||||
errdata = this.module.ModifyPagodaData(session.GetUserId(), mapData)
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), PagodaGetRewardResp, &pb.PagodaGetRewardResp{
|
||||
Data: pagoda,
|
||||
Atno: atno,
|
||||
})
|
||||
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
||||
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "PagodaGetRewardReq", atno)
|
||||
})
|
||||
return
|
||||
}
|
||||
_cfg, err = this.module.configure.GetPagodaRewardconfig(req.Id)
|
||||
if err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
// 校验是否能领取
|
||||
if _cfg.LayerNum > pagoda.PagodaId {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_PagodaConditionErr,
|
||||
Title: pb.ErrorCode_PagodaConditionErr.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if _, ok := pagoda.Reward[req.Id]; ok { // 校验是否重复领取
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_PagodaGetRewardErr,
|
||||
Title: pb.ErrorCode_PagodaGetRewardErr.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if pagoda.Reward == nil {
|
||||
pagoda.Reward = make(map[int32]bool, 0)
|
||||
}
|
||||
// 发奖励
|
||||
if errdata, atno = this.module.DispenseAtno(session, _cfg.Reward, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
pagoda.Reward[req.Id] = true
|
||||
mapData := make(map[string]interface{}, 0)
|
||||
mapData["reward"] = pagoda.Reward
|
||||
errdata = this.module.ModifyPagodaData(session.GetUserId(), mapData)
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), PagodaGetRewardResp, &pb.PagodaGetRewardResp{
|
||||
Data: pagoda,
|
||||
Atno: atno,
|
||||
})
|
||||
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
||||
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "PagodaGetRewardReq", atno)
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user