73 lines
1.8 KiB
Go
73 lines
1.8 KiB
Go
package entertainment
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) RewardCheck(session comm.IUserSession, req *pb.EntertainRewardReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// 赛季奖励 req.key = 0 表示一键领取所有的奖励
|
|
func (this *apiComp) Reward(session comm.IUserSession, req *pb.EntertainRewardReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
list *pb.DBXXLData
|
|
err error
|
|
atno []*pb.UserAtno
|
|
conf []*cfg.GameIntegralData
|
|
res []*cfg.Gameatn
|
|
)
|
|
list, err = this.module.model.getEntertainmList(session.GetUserId())
|
|
if err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if conf, err = this.module.configure.GetGameConsumeReward(); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if list.Reward >= list.Consumeexp {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_UserRepeadReward,
|
|
Title: pb.ErrorCode_UserRepeadReward.ToString(),
|
|
}
|
|
return
|
|
}
|
|
for _, v := range conf {
|
|
if v.Key > list.Reward && v.Key <= list.Consumeexp {
|
|
res = append(res, v.Onereward...)
|
|
list.Reward = v.Key
|
|
}
|
|
}
|
|
if len(res) > 0 {
|
|
if errdata, atno = this.module.DispenseAtno(session, res, true); errdata != nil {
|
|
return
|
|
}
|
|
this.module.model.modifyEntertainmList(session.GetUserId(), map[string]interface{}{
|
|
"reward": list.Reward,
|
|
})
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), "reward", &pb.EntertainRewardResp{
|
|
Data: list,
|
|
Reward: atno,
|
|
})
|
|
|
|
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
|
this.module.WriteUserLog(session.GetUserId(), req, 0, "EntertainRewardReq", atno)
|
|
})
|
|
return
|
|
}
|