80 lines
1.9 KiB
Go
80 lines
1.9 KiB
Go
package worldtask
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
func (this *apiComp) ChapterrewardCheck(session comm.IUserSession, req *pb.WorldtaskChapterrewardReq) (errdata *pb.ErrorData) {
|
|
if req.GroupId <= 0 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Chapterreward(session comm.IUserSession, req *pb.WorldtaskChapterrewardReq) (errdata *pb.ErrorData) {
|
|
if errdata = this.ChapterrewardCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
|
|
uid := session.GetUserId()
|
|
rsp := &pb.WorldtaskChapterrewardResp{}
|
|
myWorldtask, err := this.module.modelWorldtask.getWorldtask(uid)
|
|
if err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if stats, ok := myWorldtask.Chapters[req.GroupId]; !ok {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_WorldtaskChapterUnFinished,
|
|
Title: pb.ErrorCode_WorldtaskChapterUnFinished.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
} else {
|
|
if stats == 2 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_WorldtaskChapterReceived,
|
|
Title: pb.ErrorCode_WorldtaskChapterReceived.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
}
|
|
|
|
gwa, err := this.module.configure.getWorldAllCfg()
|
|
if err != nil || gwa == nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
rewardCnf := gwa.GetDataMap()[req.GroupId]
|
|
if rewardCnf == nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: fmt.Sprintf("未找到组%v配置", req.GroupId),
|
|
}
|
|
return
|
|
}
|
|
|
|
this.module.DispenseRes(session, rewardCnf.Reword, true)
|
|
|
|
this.sendMsg(session, WorldtaskChapterReward, rsp)
|
|
|
|
return
|
|
}
|