63 lines
1.6 KiB
Go
63 lines
1.6 KiB
Go
package entertainment
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) TaskRewardCheck(session comm.IUserSession, req *pb.EntertainTaskRewardReq) (errdata *pb.ErrorData) {
|
|
if req.Score == 0 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// 限时任务
|
|
func (this *apiComp) TaskReward(session comm.IUserSession, req *pb.EntertainTaskRewardReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
list *pb.DBXXLData
|
|
err error
|
|
atno []*pb.UserAtno
|
|
awards []*cfg.Gameatn
|
|
confs []*cfg.GameConsumeTaskData
|
|
)
|
|
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
|
|
}
|
|
|
|
confs = this.module.configure.GetConsumeTaskData()
|
|
|
|
awards = make([]*cfg.Gameatn, 0)
|
|
for _, v := range confs {
|
|
if v.TaskIntegral <= req.Score {
|
|
if list.Taskprogess < v.TaskIntegral {
|
|
awards = append(awards, v.Reward...)
|
|
}
|
|
}
|
|
}
|
|
list.Taskprogess = req.Score
|
|
this.module.model.Change(session.GetUserId(), map[string]interface{}{
|
|
"taskprogess": list.Taskprogess,
|
|
})
|
|
session.SendMsg(string(this.module.GetType()), "taskreward", &pb.EntertainTaskRewardResp{
|
|
Taskprogess: req.Score,
|
|
Award: atno,
|
|
})
|
|
|
|
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
|
this.module.WriteUserLog(session.GetUserId(), req, 0, "EntertainTaskRewardReq", atno)
|
|
})
|
|
return
|
|
}
|