97 lines
2.5 KiB
Go
97 lines
2.5 KiB
Go
package weektask
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.WeekTaskReceiveReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// /获取自己的排行榜信息
|
|
func (this *apiComp) Receive(session comm.IUserSession, req *pb.WeekTaskReceiveReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
info *pb.DBWeektask
|
|
conf *cfg.GameTaskRoundData
|
|
award []*pb.UserAssets
|
|
ok bool
|
|
opencmd map[string]int32
|
|
err error
|
|
)
|
|
if errdata = this.ReceiveCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
|
|
if info, err = this.module.modelWeektask.getUserDTasks(session); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if conf, err = this.module.configure.getGameTaskRoundData(req.Tid); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if _, ok = info.Tcomplete[req.Tid]; ok {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
Message: "task no complete!",
|
|
}
|
|
return
|
|
}
|
|
|
|
award = make([]*pb.UserAssets, 0)
|
|
for _, v := range conf.Reword {
|
|
award = append(award, &pb.UserAssets{
|
|
A: v.A,
|
|
T: v.T,
|
|
N: v.N,
|
|
})
|
|
}
|
|
if errdata = this.module.DispenseRes(session, conf.Reword, true); errdata != nil {
|
|
return
|
|
}
|
|
info.Activity += conf.Active
|
|
info.Tcomplete[req.Tid] = true
|
|
|
|
if opencmd, errdata = this.module.sys.QueryOpenCondData(session); errdata != nil {
|
|
return
|
|
} else {
|
|
if err = this.module.modelWeektask.inquireActivations(info, opencmd); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
if ok, _, _ = this.module.ModuleBuried.CheckCondition(session, conf.TypeId); !ok {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Message: "task is unfish!",
|
|
}
|
|
return
|
|
}
|
|
|
|
this.module.modelWeektask.Change(session.GetUserId(), map[string]interface{}{
|
|
"activity": info.Activity,
|
|
"tasks": info.Tasks,
|
|
"tcomplete": info.Tcomplete,
|
|
})
|
|
session.SendMsg(string(this.module.GetType()), "receive", &pb.WeekTaskReceiveResp{Tid: req.Tid, Activity: info.Activity, Tasks: info.Tasks, Award: award})
|
|
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
|
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "WeekTaskReceiveReq", award)
|
|
})
|
|
return
|
|
}
|