91 lines
2.5 KiB
Go
91 lines
2.5 KiB
Go
package weektask
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/sys/configure"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
"go_dreamfactory/utils"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.WeekTaskInfoReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// /获取自己的排行榜信息
|
|
func (this *apiComp) Info(session comm.IUserSession, req *pb.WeekTaskInfoReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
info *pb.DBWeektask
|
|
confs []*cfg.GameTaskRoundData
|
|
tasks []int32
|
|
progress []*pb.ConIProgress
|
|
opencmd map[string]int32
|
|
update map[string]interface{}
|
|
err error
|
|
)
|
|
if errdata = this.InfoCheck(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
|
|
}
|
|
update = make(map[string]interface{})
|
|
if !utils.IsSameWeek(info.Rtime) { //不是同一周 重置
|
|
info.Tcomplete = make(map[int32]bool)
|
|
info.Acomplete = make(map[int32]bool)
|
|
info.Activity = 0
|
|
info.Rtime = configure.Now().Unix()
|
|
if opencmd, errdata = this.module.sys.QueryOpenCondData(session.GetUserId()); errdata != nil {
|
|
return
|
|
} else {
|
|
if err = this.module.modelWeektask.inquireActivations(info, opencmd); err != nil {
|
|
return
|
|
}
|
|
}
|
|
update["activity"] = info.Activity
|
|
update["tasks"] = info.Tasks
|
|
update["tcomplete"] = info.Tcomplete
|
|
update["acomplete"] = info.Acomplete
|
|
update["rtime"] = info.Rtime
|
|
}
|
|
if confs, err = this.module.configure.getGameTaskRoundDatasByids(info.Tasks); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
}
|
|
tasks = make([]int32, 0, len(confs))
|
|
for _, v := range confs {
|
|
tasks = append(tasks, v.TypeId)
|
|
}
|
|
|
|
if progress, err = this.module.ModuleBuried.CheckCondition(session.GetUserId(), tasks...); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ExternalModule,
|
|
Title: pb.ErrorCode_ExternalModule.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if len(update) > 0 {
|
|
if err = this.module.modelWeektask.Change(session.GetUserId(), update); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_PbError,
|
|
Title: pb.ErrorCode_PbError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
}
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "info", &pb.WeekTaskInfoResp{Info: info, Progress: progress})
|
|
return
|
|
}
|