85 lines
2.2 KiB
Go
85 lines
2.2 KiB
Go
package weektask
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) ActivityReceiveCheck(session comm.IUserSession, req *pb.WeekTaskActivityReceiveReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// /获取自己的排行榜信息
|
|
func (this *apiComp) ActivityReceive(session comm.IUserSession, req *pb.WeekTaskActivityReceiveReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
info *pb.DBWeektask
|
|
conf *cfg.GameActiveRewardData
|
|
award []*pb.UserAssets
|
|
ok bool
|
|
err error
|
|
)
|
|
if errdata = this.ActivityReceiveCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
|
|
if info, err = this.module.modelWeektask.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.getGameActiveRewardData(req.Id); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if info.Activity < conf.Active {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
Message: "Activity not enough!",
|
|
}
|
|
return
|
|
}
|
|
|
|
if _, ok = info.Acomplete[req.Id]; 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.Acomplete[req.Id] = true
|
|
this.module.modelWeektask.Change(session.GetUserId(), map[string]interface{}{
|
|
"acomplete": info.Acomplete,
|
|
})
|
|
session.SendMsg(string(this.module.GetType()), "activityreceive", &pb.WeekTaskActivityReceiveResp{Id: req.Id, Award: award})
|
|
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
|
this.module.WriteUserLog(session.GetUserId(), "WeekTaskActivityReceiveReq", conf.Reword)
|
|
})
|
|
return
|
|
}
|