60 lines
1.6 KiB
Go
60 lines
1.6 KiB
Go
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
|
|
}
|
|
|
|
uid := session.GetUserId()
|
|
sociaty := this.module.modelSociaty.getUserSociaty(uid)
|
|
if sociaty == nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_SociatyNoFound,
|
|
Title: pb.ErrorCode_SociatyNoFound.ToString(),
|
|
}
|
|
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()},
|
|
)
|
|
|
|
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),
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), SociatySubTypeChallengefinish, rsp)
|
|
return
|
|
}
|