package worldtask import ( "go_dreamfactory/comm" "go_dreamfactory/pb" ) func (this *apiComp) ChapterrewardCheck(session comm.IUserSession, req *pb.WorldtaskChapterrewardReq) (code pb.ErrorCode) { if req.GroupId <= 0 { code = pb.ErrorCode_ReqParameterError } return } func (this *apiComp) Chapterreward(session comm.IUserSession, req *pb.WorldtaskChapterrewardReq) (code pb.ErrorCode, data *pb.ErrorData) { if code = this.ChapterrewardCheck(session, req); code != pb.ErrorCode_Success { return } uid := session.GetUserId() rsp := &pb.WorldtaskChapterrewardResp{} myWorldtask, err := this.module.modelWorldtask.getWorldtask(uid) if err != nil { code = pb.ErrorCode_DBError data.Title = code.String() return } if stats, ok := myWorldtask.Chapters[req.GroupId]; !ok { code = pb.ErrorCode_WorldtaskChapterUnFinished data.Title = code.String() return } else { if stats == 2 { code = pb.ErrorCode_WorldtaskChapterReceived data.Title = code.String() return } } gwa, err := this.module.configure.getWorldAllCfg() if err != nil || gwa == nil { code = pb.ErrorCode_ConfigNoFound data.Title = code.String() data.Message = err.Error() return } rewardCnf := gwa.GetDataMap()[req.GroupId] if rewardCnf == nil { code = pb.ErrorCode_ConfigNoFound data.Title = code.String() return } this.module.DispenseRes(session, rewardCnf.Reword, true) this.sendMsg(session, WorldtaskChapterReward, rsp) return }