公会errordata
This commit is contained in:
parent
6eb2a1b45e
commit
355c63a42e
@ -15,46 +15,52 @@ func (this *apiComp) Formation(session comm.IUserSession, req *pb.SociatyBFormat
|
||||
if errdata = this.FormationCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
data = &pb.ErrorData{}
|
||||
|
||||
uid := session.GetUserId()
|
||||
user := this.module.ModuleUser.GetUser(uid)
|
||||
if user == nil {
|
||||
this.module.Error("GetRemoteUser",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
)
|
||||
code = pb.ErrorCode_UserSessionNobeing
|
||||
return
|
||||
}
|
||||
|
||||
ggd := this.module.ModuleTools.GetGlobalConf()
|
||||
if ggd == nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
}
|
||||
data.Title = code.ToString()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//检验第二队或第三队是否达到解锁条件
|
||||
if _, ok := req.Teams[2]; ok {
|
||||
if user.Lv < ggd.GuildBossTroop2 {
|
||||
code = pb.ErrorCode_SociatyTeamUnlock
|
||||
data.Title = code.ToString()
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyTeamUnlock,
|
||||
Title: pb.ErrorCode_SociatyTeamUnlock.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
if _, ok := req.Teams[3]; ok {
|
||||
if user.Lv < ggd.GuildBossTroop3 {
|
||||
code = pb.ErrorCode_SociatyTeamUnlock
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyTeamUnlock,
|
||||
Title: pb.ErrorCode_SociatyTeamUnlock.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
||||
if sociaty == nil {
|
||||
code = pb.ErrorCode_SociatyNoFound
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoFound,
|
||||
Title: pb.ErrorCode_SociatyNoFound.ToString(),
|
||||
}
|
||||
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
|
||||
return
|
||||
}
|
||||
@ -73,8 +79,6 @@ func (this *apiComp) Formation(session comm.IUserSession, req *pb.SociatyBFormat
|
||||
SociatyId: sociaty.Id,
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeFormation, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeFormation, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -17,13 +17,15 @@ func (this *apiComp) Accuse(session comm.IUserSession, req *pb.SociatyAccuseReq)
|
||||
if errdata = this.AccuseCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
data = &pb.ErrorData{}
|
||||
|
||||
uid := session.GetUserId()
|
||||
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
||||
if sociaty == nil {
|
||||
code = pb.ErrorCode_SociatyNoFound
|
||||
data.Datastring = uid
|
||||
data.Message = SociatyNoFound
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoFound,
|
||||
Title: pb.ErrorCode_SociatyNoFound.ToString(),
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -32,14 +34,17 @@ func (this *apiComp) Accuse(session comm.IUserSession, req *pb.SociatyAccuseReq)
|
||||
pb.SociatyJob_VICEPRESIDENT,
|
||||
pb.SociatyJob_ADMIN,
|
||||
pb.SociatyJob_MEMBER) {
|
||||
code = pb.ErrorCode_SociatyNoRight
|
||||
data.Message = SociatyNoRight
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoRight,
|
||||
Title: pb.ErrorCode_SociatyNoRight.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 弹劾
|
||||
if err := this.module.modelSociaty.accuse(sociaty); err != nil {
|
||||
var customErr = new(comm.CustomError)
|
||||
var code pb.ErrorCode
|
||||
if errors.As(err, &customErr) {
|
||||
code = customErr.Code
|
||||
} else {
|
||||
@ -49,7 +54,12 @@ func (this *apiComp) Accuse(session comm.IUserSession, req *pb.SociatyAccuseReq)
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
data.Datastring = sociaty.Id
|
||||
|
||||
errdata = &pb.ErrorData{
|
||||
Code: code,
|
||||
Title: code.ToString(),
|
||||
Datastring: sociaty.Id,
|
||||
}
|
||||
this.module.Error("弹劾",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "sociatyId", Value: sociaty.Id},
|
||||
@ -62,8 +72,6 @@ func (this *apiComp) Accuse(session comm.IUserSession, req *pb.SociatyAccuseReq)
|
||||
SociatyId: sociaty.Id,
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeAccuse, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeAccuse, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -12,13 +12,14 @@ func (this *apiComp) ActivitylistCheck(session comm.IUserSession, req *pb.Sociat
|
||||
}
|
||||
|
||||
func (this *apiComp) Activitylist(session comm.IUserSession, req *pb.SociatyActivityListReq) (errdata *pb.ErrorData) {
|
||||
data = &pb.ErrorData{}
|
||||
|
||||
uid := session.GetUserId()
|
||||
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
||||
if sociaty == nil {
|
||||
code = pb.ErrorCode_SociatyNoFound
|
||||
data.Datastring = uid
|
||||
data.Message = SociatyNoFound
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoFound,
|
||||
Title: pb.ErrorCode_SociatyNoFound.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -37,9 +38,7 @@ func (this *apiComp) Activitylist(session comm.IUserSession, req *pb.SociatyActi
|
||||
rsp.List = activityList
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeActivityList, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeActivityList, rsp)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -23,12 +23,15 @@ func (this *apiComp) Activityreceive(session comm.IUserSession, req *pb.SociatyA
|
||||
if errdata = this.ActivityreceiveCheck(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})
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoFound,
|
||||
Title: pb.ErrorCode_SociatyNoFound.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -37,7 +40,10 @@ func (this *apiComp) Activityreceive(session comm.IUserSession, req *pb.SociatyA
|
||||
for _, v := range sociatyTask.ActivityList {
|
||||
if v.Id == req.Id {
|
||||
if v.Status == 1 {
|
||||
code = pb.ErrorCode_SociatyRewardReceived
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyRewardReceived,
|
||||
Title: pb.ErrorCode_SociatyRewardReceived.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
break
|
||||
@ -49,16 +55,17 @@ func (this *apiComp) Activityreceive(session comm.IUserSession, req *pb.SociatyA
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//是否满足领取条件
|
||||
if sociaty.Activity < conf.Activity {
|
||||
code = pb.ErrorCode_SociatyActivityNoEnough
|
||||
data.Datastring = uid
|
||||
data.Message = fmt.Sprintf("活跃度不足 实际:%d 期望:%d", sociaty.Activity, conf.Activity)
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyActivityNoEnough,
|
||||
Title: pb.ErrorCode_SociatyActivityNoEnough.ToString(),
|
||||
Message: fmt.Sprintf("活跃度不足 实际:%d 期望:%d", sociaty.Activity, conf.Activity),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -78,8 +85,6 @@ func (this *apiComp) Activityreceive(session comm.IUserSession, req *pb.SociatyA
|
||||
SociatyId: sociaty.Id,
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeActivityReceive, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeActivityReceive, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -24,14 +24,14 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) (
|
||||
if errdata = this.AgreeCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
data = &pb.ErrorData{}
|
||||
|
||||
uid := session.GetUserId()
|
||||
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
||||
if sociaty == nil {
|
||||
code = pb.ErrorCode_SociatyNoFound
|
||||
data.Title = code.ToString()
|
||||
data.Datastring = uid
|
||||
data.Message = SociatyNoFound
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoFound,
|
||||
Title: pb.ErrorCode_SociatyNoFound.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -40,14 +40,16 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) (
|
||||
pb.SociatyJob_PRESIDENT,
|
||||
pb.SociatyJob_VICEPRESIDENT,
|
||||
pb.SociatyJob_ADMIN) {
|
||||
code = pb.ErrorCode_SociatyNoRight
|
||||
data.Title = code.ToString()
|
||||
data.Message = SociatyNoRight
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoRight,
|
||||
Title: pb.ErrorCode_SociatyNoRight.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if err := this.module.modelSociaty.agree(req.Uid, sociaty); err != nil {
|
||||
var customError = new(comm.CustomError)
|
||||
var code pb.ErrorCode
|
||||
if errors.As(err, &customError) {
|
||||
code = customError.Code
|
||||
} else {
|
||||
@ -57,8 +59,11 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) (
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
data.Title = code.ToString()
|
||||
data.Message = err.Error()
|
||||
errdata = &pb.ErrorData{
|
||||
Code: code,
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
this.module.Error("公会审核-同意",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "申请人", Value: req.Uid},
|
||||
@ -84,10 +89,7 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) (
|
||||
SociatyId: sociaty.Id,
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeAgree, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeAgree, rsp)
|
||||
|
||||
//审核通过推送给申请人
|
||||
if err := this.module.SendMsgToUser(string(this.module.GetType()), "pagree", &pb.SociatyPAgreePush{
|
||||
|
@ -27,15 +27,14 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (
|
||||
return
|
||||
}
|
||||
|
||||
data = &pb.ErrorData{}
|
||||
uid := session.GetUserId()
|
||||
|
||||
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId)
|
||||
if sociaty == nil {
|
||||
code = pb.ErrorCode_SociatyNoFound
|
||||
data.Title = code.ToString()
|
||||
data.Datastring = req.SociatyId
|
||||
this.module.Error("公会未找到", log.Field{Key: "uid", Value: uid}, log.Field{Key: "sociatyId", Value: req.SociatyId})
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoFound,
|
||||
Title: pb.ErrorCode_SociatyNoFound.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -43,58 +42,69 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (
|
||||
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_UserNofound
|
||||
data.Title = code.ToString()
|
||||
data.Datastring = uid
|
||||
data.Message = err.Error()
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_UserNofound,
|
||||
Title: pb.ErrorCode_UserNofound.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if utils.IsInCDHour(userEx.SociatyCd) {
|
||||
code = pb.ErrorCode_SociatyCDLimit
|
||||
data.Title = code.ToString()
|
||||
data.Message = fmt.Sprintf("CD内[%v]不允许申请", userEx.SociatyCd)
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyCDLimit,
|
||||
Title: pb.ErrorCode_SociatyCDLimit.ToString(),
|
||||
Message: fmt.Sprintf("CD内[%v]不允许申请", userEx.SociatyCd),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 是否公会成员
|
||||
if this.module.modelSociaty.isMember(uid, sociaty) {
|
||||
code = pb.ErrorCode_SociatyBelongTo
|
||||
data.Title = code.ToString()
|
||||
data.Datastring = sociaty.Id
|
||||
data.Message = fmt.Sprintf("[%v]已经是公会[%v]成员", uid, sociaty.Name)
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyBelongTo,
|
||||
Title: pb.ErrorCode_SociatyBelongTo.ToString(),
|
||||
Message: fmt.Sprintf("[%v]已经是公会[%v]成员", uid, sociaty.Name),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
user := this.module.ModuleUser.GetUser(uid)
|
||||
if user == nil {
|
||||
code = pb.ErrorCode_UserNofound
|
||||
data.Title = code.ToString()
|
||||
data.Datastring = uid
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_UserNofound,
|
||||
Title: pb.ErrorCode_UserNofound.ToString(),
|
||||
Datastring: uid,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 是否达到入会等级
|
||||
if user.Lv < sociaty.ApplyLv {
|
||||
code = pb.ErrorCode_SociatyAppyLvNoEnough
|
||||
data.Title = code.ToString()
|
||||
data.Message = fmt.Sprintf("实际等级:%v 期望等级:%v", user.Lv, sociaty.ApplyLv)
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyAppyLvNoEnough,
|
||||
Title: pb.ErrorCode_SociatyAppyLvNoEnough.ToString(),
|
||||
Message: fmt.Sprintf("实际等级:%v 期望等级:%v", user.Lv, sociaty.ApplyLv),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 是否已申请
|
||||
if this.module.modelSociaty.isApplied(uid, sociaty) {
|
||||
code = pb.ErrorCode_SociatyApplied
|
||||
data.Title = code.ToString()
|
||||
data.Message = fmt.Sprintf("[%v]已申请", sociaty.Name)
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyApplied,
|
||||
Title: pb.ErrorCode_SociatyApplied.ToString(),
|
||||
Message: fmt.Sprintf("[%v]已申请", sociaty.Name),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//判断申请人数是否超出最大允许申请数
|
||||
if len(sociaty.ApplyRecord) >= int(this.module.globalConf.GuildAcceptApplyMax) {
|
||||
code = pb.ErrorCode_SociatyApplyMax
|
||||
data.Title = code.ToString()
|
||||
data.Message = fmt.Sprintf("实际人数:%d 期望人数:%d", len(sociaty.ApplyRecord), int(this.module.globalConf.GuildAcceptApplyMax))
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyApplyMax,
|
||||
Title: pb.ErrorCode_SociatyApplyMax.ToString(),
|
||||
Message: fmt.Sprintf("实际人数:%d 期望人数:%d", len(sociaty.ApplyRecord), int(this.module.globalConf.GuildAcceptApplyMax)),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -102,6 +112,7 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (
|
||||
isCheck, err := this.module.modelSociaty.apply(uid, sociaty)
|
||||
if err != nil {
|
||||
var customError = new(comm.CustomError)
|
||||
var code pb.ErrorCode
|
||||
if errors.As(err, &customError) {
|
||||
code = customError.Code
|
||||
} else {
|
||||
@ -111,8 +122,11 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
data.Title = code.ToString()
|
||||
data.Message = err.Error()
|
||||
errdata = &pb.ErrorData{
|
||||
Code: code,
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
this.module.Error("公会申请",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "sociatyId", Value: req.SociatyId},
|
||||
@ -130,8 +144,6 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (
|
||||
Uid: uid,
|
||||
ScoiatyId: req.SociatyId,
|
||||
}
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeApply, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeApply, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -23,14 +23,15 @@ func (this *apiComp) ApplyCancel(session comm.IUserSession, req *pb.SociatyApply
|
||||
if errdata = this.ApplyCancelCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
data = &pb.ErrorData{}
|
||||
|
||||
uid := session.GetUserId()
|
||||
|
||||
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId)
|
||||
if sociaty != nil && sociaty.Id == "" {
|
||||
code = pb.ErrorCode_SociatyNoFound
|
||||
data.Title = code.ToString()
|
||||
this.module.Error("公会未找到", log.Field{Key: "uid", Value: uid}, log.Field{Key: "sociatyId", Value: req.SociatyId})
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoFound,
|
||||
Title: pb.ErrorCode_SociatyNoFound.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -52,8 +53,6 @@ func (this *apiComp) ApplyCancel(session comm.IUserSession, req *pb.SociatyApply
|
||||
Uid: uid,
|
||||
ScoiatyId: req.SociatyId,
|
||||
}
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeApplyCanel, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeApplyCanel, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -23,15 +23,14 @@ func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.SociatyApplyLi
|
||||
if errdata = this.ApplyListCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
data = &pb.ErrorData{}
|
||||
|
||||
uid := session.GetUserId()
|
||||
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId)
|
||||
if sociaty == nil {
|
||||
code = pb.ErrorCode_SociatyNoFound
|
||||
this.module.Error("公会未找到",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "sociatyId", Value: req.SociatyId},
|
||||
)
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoFound,
|
||||
Title: pb.ErrorCode_SociatyNoFound.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -40,7 +39,10 @@ func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.SociatyApplyLi
|
||||
pb.SociatyJob_PRESIDENT,
|
||||
pb.SociatyJob_VICEPRESIDENT,
|
||||
pb.SociatyJob_ADMIN) {
|
||||
code = pb.ErrorCode_SociatyNoRight
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoRight,
|
||||
Title: pb.ErrorCode_SociatyNoRight.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -48,8 +50,6 @@ func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.SociatyApplyLi
|
||||
rsp := &pb.SociatyApplyListResp{
|
||||
List: list,
|
||||
}
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeApplyList, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeApplyList, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func (this *apiComp) Assign(session comm.IUserSession, req *pb.SociatyAssignReq)
|
||||
if errdata = this.AssignCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
data = &pb.ErrorData{}
|
||||
|
||||
uid := session.GetUserId()
|
||||
if uid == req.TargetId {
|
||||
errdata = &pb.ErrorData{
|
||||
@ -36,20 +36,28 @@ func (this *apiComp) Assign(session comm.IUserSession, req *pb.SociatyAssignReq)
|
||||
|
||||
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
||||
if sociaty == nil {
|
||||
code = pb.ErrorCode_SociatyNoFound
|
||||
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoFound,
|
||||
Title: pb.ErrorCode_SociatyNoFound.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 校验权限
|
||||
if !this.module.modelSociaty.isRight(uid, sociaty, pb.SociatyJob_PRESIDENT) {
|
||||
code = pb.ErrorCode_SociatyNoRight
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoRight,
|
||||
Title: pb.ErrorCode_SociatyNoRight.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 校验目标是否公会成员
|
||||
if !this.module.modelSociaty.isMember(req.TargetId, sociaty) {
|
||||
code = pb.ErrorCode_SociatyNoMember
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoMember,
|
||||
Title: pb.ErrorCode_SociatyNoMember.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -73,6 +81,7 @@ func (this *apiComp) Assign(session comm.IUserSession, req *pb.SociatyAssignReq)
|
||||
if err := this.module.modelSociatyLog.addLog(Log_Job, sociaty.Id,
|
||||
uid, req.TargetId, pb.SociatyJob_PRESIDENT.String()); err != nil {
|
||||
var customErr = new(comm.CustomError)
|
||||
var code pb.ErrorCode
|
||||
if errors.As(err, &customErr) {
|
||||
code = customErr.Code
|
||||
} else {
|
||||
@ -82,6 +91,11 @@ func (this *apiComp) Assign(session comm.IUserSession, req *pb.SociatyAssignReq)
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
errdata = &pb.ErrorData{
|
||||
Code: code,
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
this.module.Error("公会转让日志",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "sociatyId", Value: sociaty.Id},
|
||||
@ -96,8 +110,6 @@ func (this *apiComp) Assign(session comm.IUserSession, req *pb.SociatyAssignReq)
|
||||
SociatyId: sociaty.Id,
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeAssign, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeAssign, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -15,13 +15,12 @@ func (this *apiComp) BossmainCheck(session comm.IUserSession, req *pb.SociatyBMa
|
||||
|
||||
func (this *apiComp) Bossmain(session comm.IUserSession, req *pb.SociatyBMainReq) (errdata *pb.ErrorData) {
|
||||
uid := session.GetUserId()
|
||||
data = &pb.ErrorData{}
|
||||
|
||||
ggd := this.module.ModuleTools.GetGlobalConf()
|
||||
if ggd == nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -31,7 +30,10 @@ func (this *apiComp) Bossmain(session comm.IUserSession, req *pb.SociatyBMainReq
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "err", Value: err.Error()},
|
||||
)
|
||||
code = pb.ErrorCode_UserSessionNobeing
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_UserSessionNobeing,
|
||||
Title: pb.ErrorCode_UserSessionNobeing.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -58,8 +60,11 @@ func (this *apiComp) Bossmain(session comm.IUserSession, req *pb.SociatyBMainReq
|
||||
|
||||
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
||||
if sociaty == nil {
|
||||
code = pb.ErrorCode_SociatyNoFound
|
||||
data.Title = code.ToString()
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoFound,
|
||||
Title: pb.ErrorCode_SociatyNoFound.ToString(),
|
||||
}
|
||||
|
||||
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
|
||||
return
|
||||
}
|
||||
@ -67,7 +72,10 @@ func (this *apiComp) Bossmain(session comm.IUserSession, req *pb.SociatyBMainReq
|
||||
// 赛季信息
|
||||
dbs := this.module.modelSociatyBoss.getSociatyBossSports()
|
||||
if dbs == nil {
|
||||
code = pb.ErrorCode_SociatySportsNoinit
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatySportsNoinit,
|
||||
Title: pb.ErrorCode_SociatySportsNoinit.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
rsp.EndTime = dbs.EndTime
|
||||
@ -92,8 +100,6 @@ func (this *apiComp) Bossmain(session comm.IUserSession, req *pb.SociatyBMainReq
|
||||
rsp.Teams = sm.Teams
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeBossmain, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeBossmain, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -22,12 +22,15 @@ func (this *apiComp) Brank(session comm.IUserSession, req *pb.SociatyBRankReq) (
|
||||
if errdata = this.BrankCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
data = &pb.ErrorData{}
|
||||
|
||||
uid := session.GetUserId()
|
||||
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
||||
if sociaty == nil {
|
||||
code = pb.ErrorCode_SociatyNoFound
|
||||
data.Title = code.ToString()
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoFound,
|
||||
Title: pb.ErrorCode_SociatyNoFound.ToString(),
|
||||
}
|
||||
|
||||
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
|
||||
return
|
||||
}
|
||||
@ -38,8 +41,6 @@ func (this *apiComp) Brank(session comm.IUserSession, req *pb.SociatyBRankReq) (
|
||||
Rank: sri,
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeBrank, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeBrank, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -22,12 +22,14 @@ func (this *apiComp) Breceive(session comm.IUserSession, req *pb.SociatyBReceive
|
||||
if errdata = this.BreceiveCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
data = &pb.ErrorData{}
|
||||
|
||||
uid := session.GetUserId()
|
||||
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
||||
if sociaty == nil {
|
||||
code = pb.ErrorCode_SociatyNoFound
|
||||
data.Title = code.ToString()
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoFound,
|
||||
Title: pb.ErrorCode_SociatyNoFound.ToString(),
|
||||
}
|
||||
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
|
||||
return
|
||||
}
|
||||
@ -35,9 +37,8 @@ func (this *apiComp) Breceive(session comm.IUserSession, req *pb.SociatyBReceive
|
||||
taskConf := this.module.configure.getBossTask(req.TaskId)
|
||||
if taskConf == nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -48,10 +49,16 @@ func (this *apiComp) Breceive(session comm.IUserSession, req *pb.SociatyBReceive
|
||||
if task.TaskId == req.TaskId {
|
||||
taskId = task.TaskId
|
||||
if task.Status == 2 { //已领取
|
||||
code = pb.ErrorCode_SociatyTaskReceived
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyTaskReceived,
|
||||
Title: pb.ErrorCode_SociatyTaskReceived.ToString(),
|
||||
}
|
||||
return
|
||||
} else if taskId == 0 { //未完成
|
||||
code = pb.ErrorCode_SociatyTaskNoFinished
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyTaskNoFinished,
|
||||
Title: pb.ErrorCode_SociatyTaskNoFinished.ToString(),
|
||||
}
|
||||
return
|
||||
} else if taskId == 1 { //可领取
|
||||
task.Status = 2
|
||||
@ -74,7 +81,7 @@ func (this *apiComp) Breceive(session comm.IUserSession, req *pb.SociatyBReceive
|
||||
}
|
||||
|
||||
// 奖励
|
||||
if code := this.module.DispenseRes(session, taskConf.Reward, true); errdata != nil {
|
||||
if errdata := this.module.DispenseRes(session, taskConf.Reward, true); errdata != nil {
|
||||
this.module.Error("积分任务奖励领取",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "taskId", Value: taskId},
|
||||
@ -85,8 +92,6 @@ func (this *apiComp) Breceive(session comm.IUserSession, req *pb.SociatyBReceive
|
||||
SociatyId: sociaty.Id,
|
||||
TaskId: req.TaskId,
|
||||
}
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeBreceive, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeBreceive, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -21,21 +21,22 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.SociatyBuyReq) (errd
|
||||
if errdata = this.BuyCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
data = &pb.ErrorData{}
|
||||
|
||||
ggd := this.module.ModuleTools.GetGlobalConf()
|
||||
if ggd == nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
uid := session.GetUserId()
|
||||
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
||||
if sociaty == nil {
|
||||
code = pb.ErrorCode_SociatyNoFound
|
||||
data.Title = code.ToString()
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
}
|
||||
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
|
||||
return
|
||||
}
|
||||
@ -43,13 +44,16 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.SociatyBuyReq) (errd
|
||||
//校验钻石
|
||||
imodule, err := this.module.service.GetModule(comm.ModuleUser)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ExternalModule,
|
||||
Title: pb.ErrorCode_ExternalModule.ToString(),
|
||||
Message: comm.NewExternalModuleErr("user", "").Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
iuser, ok := imodule.(comm.IUser)
|
||||
if !ok {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
|
||||
@ -64,9 +68,11 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.SociatyBuyReq) (errd
|
||||
|
||||
ex, err := iuser.GetUserExpand(uid)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_UserSessionNobeing
|
||||
data.Title = code.ToString()
|
||||
data.Message = err.Error()
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_UserSessionNobeing,
|
||||
Title: pb.ErrorCode_UserSessionNobeing.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -84,7 +90,6 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.SociatyBuyReq) (errd
|
||||
|
||||
//扣除资源
|
||||
if errdata = this.module.DispenseRes(session, atn, true); errdata != nil {
|
||||
data.Title = code.ToString()
|
||||
return
|
||||
}
|
||||
|
||||
@ -92,8 +97,6 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.SociatyBuyReq) (errd
|
||||
Uid: uid,
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeBuy, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeBuy, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -15,11 +15,14 @@ func (this *apiComp) Challengefinish(session comm.IUserSession, req *pb.SociatyB
|
||||
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
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoFound,
|
||||
Title: pb.ErrorCode_SociatyNoFound.ToString(),
|
||||
}
|
||||
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
|
||||
return
|
||||
}
|
||||
@ -30,7 +33,7 @@ func (this *apiComp) Challengefinish(session comm.IUserSession, req *pb.SociatyB
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "err", Value: err.Error()},
|
||||
)
|
||||
code = pb.ErrorCode_UserSessionNobeing
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -51,8 +54,6 @@ func (this *apiComp) Challengefinish(session comm.IUserSession, req *pb.SociatyB
|
||||
Integral: this.module.modelSociatyBoss.transIntegral(req.Report.Harm),
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeChallengefinish, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeChallengefinish, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -16,11 +16,15 @@ func (this *apiComp) Challengestart(session comm.IUserSession, req *pb.SociatyBC
|
||||
if errdata = this.ChallengestartCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
data = &pb.ErrorData{}
|
||||
|
||||
uid := session.GetUserId()
|
||||
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
||||
if sociaty == nil {
|
||||
code = pb.ErrorCode_SociatyNoFound
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoFound,
|
||||
Title: pb.ErrorCode_SociatyNoFound.ToString(),
|
||||
}
|
||||
|
||||
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
|
||||
return
|
||||
}
|
||||
@ -31,19 +35,22 @@ func (this *apiComp) Challengestart(session comm.IUserSession, req *pb.SociatyBC
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "err", Value: err.Error()},
|
||||
)
|
||||
code = pb.ErrorCode_UserSessionNobeing
|
||||
data.Title = code.ToString()
|
||||
data.Message = err.Error()
|
||||
return
|
||||
}
|
||||
if userEx.SociatyTicket <= 0 {
|
||||
code = pb.ErrorCode_SociatyTicketsNoEnough
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyTicketsNoEnough,
|
||||
Title: pb.ErrorCode_SociatyTicketsNoEnough.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//校验赛季时间
|
||||
if this.module.modelSociatyBoss.sportsIsFinished() {
|
||||
code = pb.ErrorCode_SociatySportsEnd
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatySportsEnd,
|
||||
Title: pb.ErrorCode_SociatySportsEnd.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -51,10 +58,11 @@ func (this *apiComp) Challengestart(session comm.IUserSession, req *pb.SociatyBC
|
||||
if err := this.module.modelSociatyBoss.challengestart(session, sociaty); err != nil {
|
||||
var customErr = new(comm.CustomError)
|
||||
if errors.As(err, &customErr) {
|
||||
code = customErr.Code
|
||||
// if code == pb.ErrorCode_SociatyNoFormation {
|
||||
// return
|
||||
// }
|
||||
code := customErr.Code
|
||||
errdata = &pb.ErrorData{
|
||||
Code: code,
|
||||
Title: code.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -64,8 +72,6 @@ func (this *apiComp) Challengestart(session comm.IUserSession, req *pb.SociatyBC
|
||||
Uid: uid,
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeChallengestart, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeChallengestart, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -29,12 +29,11 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
|
||||
if errdata = this.CreateCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
data = &pb.ErrorData{}
|
||||
|
||||
uid := session.GetUserId()
|
||||
user := this.module.ModuleUser.GetUser(uid)
|
||||
if user == nil {
|
||||
this.module.Error("GetRmoteUser not found", log.Field{Key: "uid", Value: uid})
|
||||
code = pb.ErrorCode_UserSessionNobeing
|
||||
return
|
||||
}
|
||||
|
||||
@ -45,20 +44,25 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data.Title = code.ToString()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CD校验
|
||||
if utils.IsInCDHour(userExpand.SociatyCd) {
|
||||
code = pb.ErrorCode_SociatyCDLimit
|
||||
data.Title = code.ToString()
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyCDLimit,
|
||||
Title: pb.ErrorCode_SociatyCDLimit.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//检查是否已加入公会
|
||||
if userExpand.SociatyId != "" {
|
||||
code = pb.ErrorCode_SociatyAdded
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyAdded,
|
||||
Title: pb.ErrorCode_SociatyAdded.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -66,7 +70,12 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
|
||||
if err := this.module.modelSociaty.isNameExist(req.Name); err != nil {
|
||||
var customErr = new(comm.CustomError)
|
||||
if errors.As(err, &customErr) {
|
||||
code = customErr.Code
|
||||
code := customErr.Code
|
||||
errdata = &pb.ErrorData{
|
||||
Code: code,
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
errdata = &pb.ErrorData{
|
||||
@ -97,7 +106,11 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
|
||||
}
|
||||
|
||||
if req.ApplyLv > maxLv {
|
||||
code = pb.ErrorCode_SociatyApplyLvLimit
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyApplyLvLimit,
|
||||
Title: pb.ErrorCode_SociatyApplyLvLimit.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -119,17 +132,21 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
|
||||
})
|
||||
if err := this.module.modelSociaty.create(sociaty); err != nil {
|
||||
var customError = new(comm.CustomError)
|
||||
var code pb.ErrorCode
|
||||
if errors.As(err, &customError) {
|
||||
if customError.Code == pb.ErrorCode_SociatyNoFound {
|
||||
code = pb.ErrorCode_SociatyNoFound
|
||||
} else {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
code = customError.Code
|
||||
} else {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
errdata = &pb.ErrorData{
|
||||
Code: code,
|
||||
Title: code.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
this.module.Error("创建公会",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "params", Value: req.String()},
|
||||
@ -168,12 +185,9 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
|
||||
}
|
||||
}()
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeCreate, &pb.SociatyCreateResp{
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeCreate, &pb.SociatyCreateResp{
|
||||
Id: sociaty.Id,
|
||||
Uid: uid,
|
||||
}); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
@ -24,11 +24,14 @@ func (this *apiComp) Discharge(session comm.IUserSession, req *pb.SociatyDischar
|
||||
if errdata = this.DischargeCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
data = &pb.ErrorData{}
|
||||
|
||||
uid := session.GetUserId()
|
||||
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
||||
if sociaty == nil {
|
||||
code = pb.ErrorCode_SociatyNoFound
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoFound,
|
||||
Title: pb.ErrorCode_SociatyNoFound.ToString(),
|
||||
}
|
||||
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
|
||||
return
|
||||
}
|
||||
@ -37,13 +40,17 @@ func (this *apiComp) Discharge(session comm.IUserSession, req *pb.SociatyDischar
|
||||
if !this.module.modelSociaty.isRight(uid, sociaty,
|
||||
pb.SociatyJob_PRESIDENT,
|
||||
pb.SociatyJob_VICEPRESIDENT) {
|
||||
code = pb.ErrorCode_SociatyNoRight
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoRight,
|
||||
Title: pb.ErrorCode_SociatyNoRight.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 踢人
|
||||
if err := this.module.modelSociaty.discharge(req.TargetId, sociaty); err != nil {
|
||||
var customError = new(comm.CustomError)
|
||||
var code pb.ErrorCode
|
||||
if errors.As(err, &customError) {
|
||||
code = customError.Code
|
||||
} else {
|
||||
@ -53,8 +60,10 @@ func (this *apiComp) Discharge(session comm.IUserSession, req *pb.SociatyDischar
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
data.Title = code.ToString()
|
||||
data.Message = err.Error()
|
||||
errdata = &pb.ErrorData{
|
||||
Code: code,
|
||||
Title: code.ToString(),
|
||||
}
|
||||
this.module.Error("踢出公会",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "sociatyId", Value: sociaty.Id},
|
||||
@ -109,8 +118,6 @@ func (this *apiComp) Discharge(session comm.IUserSession, req *pb.SociatyDischar
|
||||
SociatyId: sociaty.Id,
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeDischarge, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeDischarge, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -25,11 +25,14 @@ func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissRe
|
||||
return
|
||||
}
|
||||
|
||||
data = &pb.ErrorData{}
|
||||
uid := session.GetUserId()
|
||||
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
||||
if sociaty == nil {
|
||||
code = pb.ErrorCode_SociatyNoFound
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoFound,
|
||||
Title: pb.ErrorCode_SociatyNoFound.ToString(),
|
||||
}
|
||||
|
||||
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
|
||||
return
|
||||
}
|
||||
@ -42,7 +45,10 @@ func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissRe
|
||||
// 校验权限
|
||||
if !this.module.modelSociaty.isRight(uid, sociaty,
|
||||
pb.SociatyJob_PRESIDENT) {
|
||||
code = pb.ErrorCode_SociatyNoRight
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoRight,
|
||||
Title: pb.ErrorCode_SociatyNoRight.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -53,7 +59,10 @@ func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissRe
|
||||
if sociaty.DismissTime == 0 {
|
||||
if sociaty.DismissCD != 0 {
|
||||
if utils.IsInCDHour(int64(sociaty.DismissCD)) {
|
||||
code = pb.ErrorCode_SociatyCDLimit
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyCDLimit,
|
||||
Title: pb.ErrorCode_SociatyCDLimit.ToString(),
|
||||
}
|
||||
return
|
||||
} else {
|
||||
update["dismissCD"] = 0
|
||||
@ -68,7 +77,10 @@ func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissRe
|
||||
update["dismissCD"] = utils.AddHour(int(globalCnf.GuildDissolutionCd)).Unix()
|
||||
} else {
|
||||
if utils.IsInCDHour(int64(sociaty.DismissCD)) {
|
||||
code = pb.ErrorCode_SociatyCDLimit
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyCDLimit,
|
||||
Title: pb.ErrorCode_SociatyCDLimit.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -89,8 +101,6 @@ func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissRe
|
||||
}
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeDismiss, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeDismiss, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -37,8 +37,6 @@ func (this *apiComp) List(session comm.IUserSession, req *pb.SociatyListReq) (er
|
||||
rsp.List = append(rsp.List, info)
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeList, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeList, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ func (this *apiComp) Log(session comm.IUserSession, req *pb.SociatyLogReq) (errd
|
||||
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
|
||||
}
|
||||
@ -31,8 +30,6 @@ func (this *apiComp) Log(session comm.IUserSession, req *pb.SociatyLogReq) (errd
|
||||
},
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeLog, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeLog, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ func (this *apiComp) Members(session comm.IUserSession, req *pb.SociatyMembersRe
|
||||
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
|
||||
}
|
||||
@ -27,8 +26,6 @@ func (this *apiComp) Members(session comm.IUserSession, req *pb.SociatyMembersRe
|
||||
List: members,
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeMembers, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeMembers, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ func (this *apiComp) MineCheck(session comm.IUserSession, req *pb.SociatyMineReq
|
||||
}
|
||||
|
||||
func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (errdata *pb.ErrorData) {
|
||||
data = &pb.ErrorData{}
|
||||
|
||||
uid := session.GetUserId()
|
||||
userEx, err := this.module.ModuleUser.GetUserExpand(uid)
|
||||
if err != nil {
|
||||
@ -22,7 +22,6 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (er
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "err", Value: err.Error()},
|
||||
)
|
||||
code = pb.ErrorCode_UserSessionNobeing
|
||||
return
|
||||
}
|
||||
|
||||
@ -30,22 +29,28 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (er
|
||||
|
||||
// 未加入公会
|
||||
if userEx.SociatyId == "" {
|
||||
code = pb.ErrorCode_SociatyNoAdded
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoAdded,
|
||||
Title: pb.ErrorCode_SociatyNoAdded.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 获取公会
|
||||
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
||||
if sociaty == nil {
|
||||
code = pb.ErrorCode_SociatyNoFound
|
||||
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
|
||||
return
|
||||
}
|
||||
|
||||
//判断公会是否解散(公会解散非立即执行)
|
||||
if this.module.modelSociaty.isDismiss(sociaty) {
|
||||
code = pb.ErrorCode_SociatyDismissed
|
||||
data.Title = code.ToString()
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyDismissed,
|
||||
Title: pb.ErrorCode_SociatyDismissed.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -83,8 +88,7 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (er
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data.Title = code.ToString()
|
||||
data.Message = err.Error()
|
||||
|
||||
this.module.Error("会长弹劾",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "sociatyId", Value: sociaty.Id},
|
||||
@ -97,8 +101,6 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (er
|
||||
rsp.Sociaty = sociaty
|
||||
rsp.Master = master
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeMine, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeMine, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -14,11 +14,10 @@ func (this *apiComp) QuitCheck(session comm.IUserSession, req *pb.SociatyQuitReq
|
||||
}
|
||||
|
||||
func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (errdata *pb.ErrorData) {
|
||||
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
|
||||
}
|
||||
@ -26,13 +25,19 @@ func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (er
|
||||
// 会长不允许退公会
|
||||
if this.module.modelSociaty.isRight(uid, sociaty,
|
||||
pb.SociatyJob_PRESIDENT) {
|
||||
code = pb.ErrorCode_SociatyQuitNoAllowed
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyQuitNoAllowed,
|
||||
Title: pb.ErrorCode_SociatyQuitNoAllowed.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 退出公会
|
||||
if err := this.module.modelSociaty.quit(uid, sociaty); err != nil {
|
||||
code = pb.ErrorCode_SociatyQuit
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyQuit,
|
||||
Title: pb.ErrorCode_SociatyQuit.ToString(),
|
||||
}
|
||||
this.module.Errorf("退出公会", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "err": err.Error()})
|
||||
return
|
||||
}
|
||||
@ -49,8 +54,7 @@ func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (er
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data.Title = code.ToString()
|
||||
data.Message = err.Error()
|
||||
|
||||
this.module.Error("退出公会,更新玩家公会ID",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "sociatyId", Value: sociaty.Id},
|
||||
@ -73,8 +77,6 @@ func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (er
|
||||
Uid: uid,
|
||||
SociatyId: sociaty.Id,
|
||||
}
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeQuit, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeQuit, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -18,8 +18,6 @@ func (this *apiComp) Rank(session comm.IUserSession, req *pb.SociatyRankReq) (er
|
||||
Rank: list,
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeRank, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeRank, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveRe
|
||||
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
|
||||
}
|
||||
@ -35,11 +34,17 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveRe
|
||||
for _, v := range sociatyTask.TaskList {
|
||||
if v.TaskId == req.TaskId {
|
||||
if v.Status != 1 {
|
||||
code = pb.ErrorCode_SociatyTaskValidation
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyTaskValidation,
|
||||
Title: pb.ErrorCode_SociatyTaskValidation.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if v.Received == 1 { //已领取
|
||||
code = pb.ErrorCode_SociatyRewardReceived
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyRewardReceived,
|
||||
Title: pb.ErrorCode_SociatyRewardReceived.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
break
|
||||
@ -48,7 +53,11 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveRe
|
||||
|
||||
// 奖励领取
|
||||
if err := this.module.modelSociatyTask.receive(req.TaskId, sociaty.Id, uid); err != nil {
|
||||
code = pb.ErrorCode_SociatyRewardReceive
|
||||
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyRewardReceived,
|
||||
Title: pb.ErrorCode_SociatyRewardReceived.ToString(),
|
||||
}
|
||||
this.module.Error("领取公会任务奖励",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "sociatyId", Value: sociaty.Id},
|
||||
@ -67,7 +76,6 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveRe
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "sociatyId", Value: sociaty.Id},
|
||||
log.Field{Key: "taskId", Value: req.TaskId},
|
||||
log.Field{Key: "code", Value: code},
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -99,8 +107,6 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveRe
|
||||
TaskId: req.TaskId,
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeReceive, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeReceive, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -23,8 +23,6 @@ func (this *apiComp) Recommend(session comm.IUserSession, req *pb.SociatyRecomme
|
||||
|
||||
rsp := &pb.SociatyRecommendResp{}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeRecommend, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeRecommend, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -24,11 +24,10 @@ func (this *apiComp) Refuse(session comm.IUserSession, req *pb.SociatyRefuseReq)
|
||||
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
|
||||
}
|
||||
@ -38,22 +37,28 @@ func (this *apiComp) Refuse(session comm.IUserSession, req *pb.SociatyRefuseReq)
|
||||
pb.SociatyJob_PRESIDENT,
|
||||
pb.SociatyJob_VICEPRESIDENT,
|
||||
pb.SociatyJob_ADMIN) {
|
||||
code = pb.ErrorCode_SociatyNoRight
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoRight,
|
||||
Title: pb.ErrorCode_SociatyNoRight.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 已是公会成员
|
||||
if this.module.modelSociaty.isMember(uid, sociaty) {
|
||||
code = pb.ErrorCode_SociatyAdded
|
||||
data.Title = code.ToString()
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyAdded,
|
||||
Title: pb.ErrorCode_SociatyAdded.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 拒绝公会申请
|
||||
if err := this.module.modelSociaty.refuse(req.Uid, sociaty); err != nil {
|
||||
code = pb.ErrorCode_SociatyRefuse
|
||||
data.Title = code.ToString()
|
||||
data.Message = err.Error()
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyRefuse,
|
||||
Title: pb.ErrorCode_SociatyRefuse.ToString(),
|
||||
}
|
||||
this.module.Error("申请拒绝",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "拒绝目标人", Value: req.Uid},
|
||||
@ -66,8 +71,6 @@ func (this *apiComp) Refuse(session comm.IUserSession, req *pb.SociatyRefuseReq)
|
||||
Uid: req.Uid,
|
||||
SociatyId: sociaty.Id,
|
||||
}
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeRefuse, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeRefuse, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -22,15 +22,13 @@ func (this *apiComp) Search(session comm.IUserSession, req *pb.SociatySearchReq)
|
||||
if errdata = this.SearchCheck(session, req); errdata != nil {
|
||||
return
|
||||
}
|
||||
data = &pb.ErrorData{}
|
||||
|
||||
rsp := &pb.SociatySearchResp{}
|
||||
sociaty := this.module.modelSociaty.findByName(req.Name)
|
||||
if sociaty != nil && sociaty.Id != "" {
|
||||
rsp.List = append(rsp.List, sociaty)
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeSearch, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeSearch, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -23,11 +23,10 @@ func (this *apiComp) Setting(session comm.IUserSession, req *pb.SociatySettingRe
|
||||
if errdata = this.SettingCheck(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
|
||||
}
|
||||
@ -35,7 +34,10 @@ func (this *apiComp) Setting(session comm.IUserSession, req *pb.SociatySettingRe
|
||||
// 校验权限
|
||||
if !this.module.modelSociaty.isRight(uid, sociaty,
|
||||
pb.SociatyJob_PRESIDENT, pb.SociatyJob_VICEPRESIDENT) {
|
||||
code = pb.ErrorCode_SociatyNoRight
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoRight,
|
||||
Title: pb.ErrorCode_SociatyNoRight.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -46,9 +48,10 @@ func (this *apiComp) Setting(session comm.IUserSession, req *pb.SociatySettingRe
|
||||
|
||||
// 更新设置
|
||||
if err := this.module.modelSociaty.setting(sociaty); err != nil {
|
||||
code = pb.ErrorCode_SociatySetting
|
||||
data.Title = code.ToString()
|
||||
data.Message = err.Error()
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatySetting,
|
||||
Title: pb.ErrorCode_SociatySetting.ToString(),
|
||||
}
|
||||
this.module.Error("公会修改",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "sociatyId", Value: sociaty.Id},
|
||||
@ -62,8 +65,6 @@ func (this *apiComp) Setting(session comm.IUserSession, req *pb.SociatySettingRe
|
||||
SociatyId: sociaty.Id,
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeSetting, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeSetting, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -22,11 +22,10 @@ func (this *apiComp) SettingJob(session comm.IUserSession, req *pb.SociatySettin
|
||||
if errdata = this.SettingJobCheck(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
|
||||
}
|
||||
@ -34,13 +33,19 @@ func (this *apiComp) SettingJob(session comm.IUserSession, req *pb.SociatySettin
|
||||
// 权限校验
|
||||
if !this.module.modelSociaty.isRight(uid, sociaty,
|
||||
pb.SociatyJob_PRESIDENT) {
|
||||
code = pb.ErrorCode_SociatyNoRight
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoRight,
|
||||
Title: pb.ErrorCode_SociatyNoRight.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 不能设置自己
|
||||
if uid == req.TargetId {
|
||||
code = pb.ErrorCode_SociatySelfSetting
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatySelfSetting,
|
||||
Title: pb.ErrorCode_SociatySelfSetting.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -49,13 +54,19 @@ func (this *apiComp) SettingJob(session comm.IUserSession, req *pb.SociatySettin
|
||||
jobCount := this.module.modelSociaty.getJobCount(req.Job, sociaty)
|
||||
if req.Job == pb.SociatyJob_VICEPRESIDENT && jobCount >= int(globalConf.GuildViceAllianceLeaderMaxNum) ||
|
||||
req.Job == pb.SociatyJob_ADMIN && jobCount >= int(globalConf.GuildAdministratorsMaxNum) {
|
||||
code = pb.ErrorCode_SociatyMemberCountLimit
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyMemberCountLimit,
|
||||
Title: pb.ErrorCode_SociatyMemberCountLimit.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 设置职位
|
||||
if err := this.module.modelSociaty.settingJob(req.TargetId, req.Job, sociaty); err != nil {
|
||||
code = pb.ErrorCode_SociatySettingJob
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatySettingJob,
|
||||
Title: pb.ErrorCode_SociatySettingJob.ToString(),
|
||||
}
|
||||
this.module.Errorf("设置公会职位", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "params": req, "err": err.Error()})
|
||||
return
|
||||
}
|
||||
@ -66,8 +77,6 @@ func (this *apiComp) SettingJob(session comm.IUserSession, req *pb.SociatySettin
|
||||
Job: req.Job,
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeSettingJob, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeSettingJob, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -16,31 +16,36 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.SociatySignReq) (er
|
||||
return
|
||||
}
|
||||
uid := session.GetUserId()
|
||||
data = &pb.ErrorData{}
|
||||
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
||||
if sociaty == nil {
|
||||
code = pb.ErrorCode_SociatyNoFound
|
||||
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
|
||||
return
|
||||
}
|
||||
|
||||
// 不是该公会成员
|
||||
if !this.module.modelSociaty.isMember(uid, sociaty) {
|
||||
code = pb.ErrorCode_SociatyNoAdded
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatyNoAdded,
|
||||
Title: pb.ErrorCode_SociatyNoAdded.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 判断是否已签到
|
||||
if this.module.modelSociaty.IsSign(uid, sociaty) {
|
||||
code = pb.ErrorCode_SociatySigned
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatySigned,
|
||||
Title: pb.ErrorCode_SociatySigned.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 签到
|
||||
if err := this.module.modelSociaty.sign(uid, sociaty); err != nil {
|
||||
code = pb.ErrorCode_SociatySign
|
||||
data.Title = code.ToString()
|
||||
data.Message = err.Error()
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SociatySign,
|
||||
Title: pb.ErrorCode_SociatySign.ToString(),
|
||||
}
|
||||
this.module.Error("签到失败", log.Field{Key: "uid", Value: uid}, log.Field{Key: "sociatyId", Value: sociaty.Id}, log.Field{Key: "err", Value: err.Error()})
|
||||
return
|
||||
}
|
||||
@ -51,13 +56,12 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.SociatySignReq) (er
|
||||
for _, v := range this.module.sociatySignConf.GetDataList() {
|
||||
if lastSignCount >= v.Down && lastSignCount <= v.Up {
|
||||
// 发放签到奖励
|
||||
if errdata = this.module.DispenseRes(session, v.Reward, true); code == pb.ErrorCode_Success {
|
||||
if errdata = this.module.DispenseRes(session, v.Reward, true); errdata == nil {
|
||||
signCfgId = v.Id
|
||||
} else {
|
||||
log.Error("发放签到奖励失败",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "sociatyId", Value: sociaty.Id},
|
||||
log.Field{Key: "code", Value: code},
|
||||
)
|
||||
}
|
||||
break
|
||||
@ -91,8 +95,6 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.SociatySignReq) (er
|
||||
SociatyId: sociaty.Id,
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeSign, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeSign, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -14,10 +14,10 @@ func (this *apiComp) TaskListCheck(session comm.IUserSession, req *pb.SociatyTas
|
||||
|
||||
func (this *apiComp) TaskList(session comm.IUserSession, req *pb.SociatyTaskListReq) (errdata *pb.ErrorData) {
|
||||
uid := session.GetUserId()
|
||||
data = &pb.ErrorData{}
|
||||
|
||||
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
||||
if sociaty == nil {
|
||||
code = pb.ErrorCode_SociatyNoFound
|
||||
|
||||
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
|
||||
return
|
||||
}
|
||||
@ -47,8 +47,7 @@ func (this *apiComp) TaskList(session comm.IUserSession, req *pb.SociatyTaskList
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
data.Title = code.ToString()
|
||||
data.Message = err.Error()
|
||||
|
||||
this.module.Error("更新公会任务列表失败",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "sociatyId", Value: sociaty.Id},
|
||||
@ -56,8 +55,6 @@ func (this *apiComp) TaskList(session comm.IUserSession, req *pb.SociatyTaskList
|
||||
}
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.module.GetType()), SociatySubTypeTasklist, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SociatySubTypeTasklist, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ func (s *ModelSociatyBoss) setFormation(sociaty *pb.DBSociaty, uid string, teams
|
||||
return s.moduleSociaty.modelSociaty.updateSociaty(sociaty.Id, update)
|
||||
}
|
||||
|
||||
//挑战开始
|
||||
// 挑战开始
|
||||
func (s *ModelSociatyBoss) challengestart(session comm.IUserSession, sociaty *pb.DBSociaty) error {
|
||||
//组装阵容数据
|
||||
var formations []*pb.BattleFormation
|
||||
@ -195,8 +195,8 @@ func (s *ModelSociatyBoss) challengestart(session comm.IUserSession, sociaty *pb
|
||||
Ptype: pb.PlayType_sociaty,
|
||||
Title: "公会BOSS",
|
||||
Format: formations,
|
||||
}); errdata != nil {
|
||||
return comm.NewCustomError(code)
|
||||
}); code != nil {
|
||||
return comm.NewCustomError(pb.ErrorCode_ExternalModule)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
@ -8,7 +8,10 @@ import (
|
||||
// 活跃度列表
|
||||
func (this *apiComp) ActiveListCheck(session comm.IUserSession, req *pb.TaskActiveListReq) (errdata *pb.ErrorData) {
|
||||
if req.TaskTag <= 0 || req.TaskTag > 2 {
|
||||
code = pb.ErrorCode_TaskTagEmpty
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -20,10 +23,7 @@ func (this *apiComp) ActiveList(session comm.IUserSession, req *pb.TaskActiveLis
|
||||
|
||||
resp := &pb.TaskActiveListResp{}
|
||||
defer func() {
|
||||
if err := session.SendMsg(string(this.module.GetType()), TaskSubTypeActiveList, resp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), TaskSubTypeActiveList, resp)
|
||||
}()
|
||||
|
||||
// 获取玩家活跃度
|
||||
|
@ -9,11 +9,17 @@ import (
|
||||
|
||||
// 活跃度领取
|
||||
func (this *apiComp) ActiveReceiveCheck(session comm.IUserSession, req *pb.TaskActiveReceiveReq) (errdata *pb.ErrorData) {
|
||||
var code pb.ErrorCode
|
||||
if req.Id == 0 {
|
||||
code = pb.ErrorCode_TaskIdEmpty
|
||||
} else if req.TaskTag <= 0 || req.TaskTag > 2 {
|
||||
code = pb.ErrorCode_TaskTagEmpty
|
||||
}
|
||||
errdata = &pb.ErrorData{
|
||||
Code: code,
|
||||
Title: code.ToString(),
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -34,7 +40,11 @@ func (this *apiComp) ActiveReceive(session comm.IUserSession, req *pb.TaskActive
|
||||
}
|
||||
|
||||
if ue == nil {
|
||||
code = pb.ErrorCode_UserExpandNull
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_UserExpandNull,
|
||||
Title: pb.ErrorCode_UserExpandNull.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
var rewards []*cfg.Gameatn
|
||||
@ -58,12 +68,21 @@ func (this *apiComp) ActiveReceive(session comm.IUserSession, req *pb.TaskActive
|
||||
|
||||
if req.TaskTag == int32(comm.TASK_DAILY) {
|
||||
if ue.Activeday < conf.Active {
|
||||
code = pb.ErrorCode_TaskActiveNoenough
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_TaskActiveNoenough,
|
||||
Title: pb.ErrorCode_TaskActiveNoenough.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
} else if req.TaskTag == int32(comm.TASK_WEEKLY) {
|
||||
if ue.Activeweek < conf.Active {
|
||||
code = pb.ErrorCode_TaskActiveNoenough
|
||||
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_TaskActiveNoenough,
|
||||
Title: pb.ErrorCode_TaskActiveNoenough.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -96,7 +115,6 @@ func (this *apiComp) ActiveReceive(session comm.IUserSession, req *pb.TaskActive
|
||||
this.module.Error("活跃度奖励",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "rewards", Value: rewards},
|
||||
log.Field{Key: "code", Value: code},
|
||||
)
|
||||
}
|
||||
go this.module.ModuleBuried.TriggerBuried(uid, comm.GetBuriedParam(comm.Rtype171, 1))
|
||||
@ -107,10 +125,7 @@ func (this *apiComp) ActiveReceive(session comm.IUserSession, req *pb.TaskActive
|
||||
Id: req.Id,
|
||||
}
|
||||
|
||||
err = session.SendMsg(string(this.module.GetType()), TaskSubTypeActiveReceive, resp)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), TaskSubTypeActiveReceive, resp)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -21,8 +21,6 @@ func (this *apiComp) Getrecord(session comm.IUserSession, req *pb.TaskGetrecordR
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := session.SendMsg(string(this.module.GetType()), TaskSubTypeGetrecord, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), TaskSubTypeGetrecord, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -9,7 +9,10 @@ import (
|
||||
|
||||
func (this *apiComp) ListCheck(session comm.IUserSession, req *pb.TaskListReq) (errdata *pb.ErrorData) {
|
||||
if req.TaskTag <= 0 || req.TaskTag > 3 {
|
||||
code = pb.ErrorCode_TaskTagEmpty
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -20,17 +23,12 @@ func (this *apiComp) List(session comm.IUserSession, req *pb.TaskListReq) (errda
|
||||
}
|
||||
rsp := &pb.TaskListResp{}
|
||||
|
||||
defer func() {
|
||||
err := session.SendMsg(string(this.module.GetType()), TaskSubTypeList, rsp)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
task := this.module.modelTask.getTaskListByTag(session.GetUserId(), comm.TaskTag(req.TaskTag))
|
||||
if task == nil {
|
||||
code = pb.ErrorCode_TaskNotFound
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_TaskNotFound,
|
||||
Title: pb.ErrorCode_TaskNotFound.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -42,5 +40,7 @@ func (this *apiComp) List(session comm.IUserSession, req *pb.TaskListReq) (errda
|
||||
case int32(comm.TASK_ACHIEVE):
|
||||
rsp.List = task.AchieveList
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), TaskSubTypeList, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -10,11 +10,16 @@ import (
|
||||
//任务奖励领取
|
||||
|
||||
func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.TaskReceiveReq) (errdata *pb.ErrorData) {
|
||||
var code pb.ErrorCode
|
||||
if req.Id == 0 {
|
||||
code = pb.ErrorCode_TaskIdEmpty
|
||||
} else if req.TaskTag == 0 {
|
||||
code = pb.ErrorCode_TaskTagEmpty
|
||||
}
|
||||
errdata = &pb.ErrorData{
|
||||
Code: code,
|
||||
Title: code.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -27,7 +32,10 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq)
|
||||
userTask := this.module.modelTask.getUserTask(uid, req.Id)
|
||||
|
||||
if userTask == nil {
|
||||
code = pb.ErrorCode_TaskNotFound
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_TaskNotFound,
|
||||
Title: pb.ErrorCode_TaskNotFound.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -52,12 +60,18 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq)
|
||||
|
||||
//判断是否完成
|
||||
if taskData.Status == 0 {
|
||||
code = pb.ErrorCode_TaskNoFinished
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_TaskNoFinished,
|
||||
Title: pb.ErrorCode_TaskNoFinished.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
//判断任务是否领取
|
||||
if taskData.Received == 1 {
|
||||
code = pb.ErrorCode_TaskReceived
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_TaskReceived,
|
||||
Title: pb.ErrorCode_TaskReceived.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -65,9 +79,8 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq)
|
||||
conf := this.module.configure.getTaskById(taskData.TaskId)
|
||||
if conf == nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -139,18 +152,14 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq)
|
||||
this.module.Error("活跃度奖励",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "rewards", Value: rewards},
|
||||
log.Field{Key: "code", Value: code},
|
||||
)
|
||||
}
|
||||
go this.module.ModuleBuried.TriggerBuried(uid, comm.GetBuriedParam(comm.Rtype171, 1))
|
||||
err := session.SendMsg(string(this.module.GetType()), "activereceive", &pb.TaskActiveReceivePush{
|
||||
session.SendMsg(string(this.module.GetType()), "activereceive", &pb.TaskActiveReceivePush{
|
||||
TaskTag: int32(comm.TASK_WEEKLY),
|
||||
Id: maxTaskId,
|
||||
})
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -172,7 +181,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq)
|
||||
this.module.Error("发送奖励",
|
||||
log.Field{Key: "uid", Value: uid},
|
||||
log.Field{Key: "rewards", Value: conf.Reword},
|
||||
log.Field{Key: "code", Value: code},
|
||||
log.Field{Key: "errdata", Value: errdata},
|
||||
)
|
||||
return
|
||||
}
|
||||
@ -204,11 +213,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.TaskReceiveReq)
|
||||
}
|
||||
resp.TaskId = taskData.TaskId
|
||||
|
||||
err := session.SendMsg(string(this.module.GetType()), TaskSubTypeReceive, resp)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), TaskSubTypeReceive, resp)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -26,8 +26,6 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.TaskSendReq) (errda
|
||||
rsp := &pb.TaskSendResp{
|
||||
IsSucc: true,
|
||||
}
|
||||
if err := session.SendMsg(string(this.module.GetType()), TaskSubTypeSend, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), TaskSubTypeSend, rsp)
|
||||
return
|
||||
}
|
||||
|
@ -488,7 +488,7 @@ func (this *ModelTask) doTaskHandle(event interface{}, next func(event interface
|
||||
update map[string]interface{}
|
||||
)
|
||||
|
||||
if code := this.moduleTask.ModuleRtask.CheckCondi(tl.Uid, conf.TypeId); code == pb.ErrorCode_Success {
|
||||
if code := this.moduleTask.ModuleRtask.CheckCondi(tl.Uid, conf.TypeId); code == nil {
|
||||
// update data
|
||||
if ret != nil && len(ret.Data) > 0 {
|
||||
progress = ret.Data[0]
|
||||
|
Loading…
Reference in New Issue
Block a user