65 lines
1.7 KiB
Go
65 lines
1.7 KiB
Go
package dailytask
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.DailytaskReceiveReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// /获取自己的排行榜信息
|
|
func (this *apiComp) Receive(session comm.IUserSession, req *pb.DailytaskReceiveReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
dtask *pb.DBDailytask
|
|
conf *cfg.GameAnnulartaskAllData
|
|
atno []*pb.UserAtno
|
|
err error
|
|
)
|
|
if errdata = this.ReceiveCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
|
|
if dtask, err = this.module.modelDailytask.getUserDTasks(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if conf, err = this.module.configure.getAnnulartaskAllById(dtask.Key); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
for _, v := range dtask.Groups {
|
|
if !v.Complete {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
Message: "task no complete!",
|
|
}
|
|
return
|
|
}
|
|
}
|
|
if errdata, atno = this.module.DispenseAtno(session, conf.Reward, true); errdata != nil {
|
|
return
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "receive", &pb.DailytaskReceiveResp{Award: atno})
|
|
|
|
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
|
this.module.WriteUserLog(session.GetUserId(), "DailytaskReceiveReq", atno)
|
|
})
|
|
return
|
|
}
|