package sociaty import ( "go_dreamfactory/comm" "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" ) // 结束挑战 func (this *apiComp) ChallengefinishCheck(session comm.IUserSession, req *pb.SociatyBChallengeFinishReq) (errdata *pb.ErrorData) { return } func (this *apiComp) Challengefinish(session comm.IUserSession, req *pb.SociatyBChallengeFinishReq) (errdata *pb.ErrorData) { if errdata = this.ChallengefinishCheck(session, req); errdata != nil { return } data = &pb.ErrorData{} uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return } userEx, err := this.module.ModuleUser.GetUserExpand(uid) if err != nil { this.module.Error("GetRemoteUserExpand", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()}, ) code = pb.ErrorCode_UserSessionNobeing return } this.module.modelSociatyBoss.challengefinish(sociaty, uid, req.Report) //扣除挑战券 userEx.SociatyTicket -= 1 updateEx := map[string]interface{}{ "sociatyTicket": userEx.SociatyTicket, } if err := this.module.ModuleUser.ChangeUserExpand(uid, updateEx); err != nil { this.module.Error("更新扣除挑战券失败", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()}) } rsp := &pb.SociatyBChallengeFinishResp{ Integral: this.module.modelSociatyBoss.transIntegral(req.Report.Harm), } if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeChallengefinish, rsp); err != nil { code = pb.ErrorCode_SystemError } return }