107 lines
2.8 KiB
Go
107 lines
2.8 KiB
Go
package sociaty
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/utils"
|
|
)
|
|
|
|
// 我的公会
|
|
|
|
func (this *apiComp) MineCheck(session comm.IUserSession, req *pb.SociatyMineReq) (errdata *pb.ErrorData) {
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (errdata *pb.ErrorData) {
|
|
|
|
uid := session.GetUserId()
|
|
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
|
|
}
|
|
|
|
rsp := &pb.SociatyMineResp{}
|
|
|
|
// 未加入公会
|
|
if userEx.SociatyId == "" {
|
|
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 {
|
|
this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid})
|
|
return
|
|
}
|
|
|
|
//判断公会是否解散(公会解散非立即执行)
|
|
if this.module.modelSociaty.isDismiss(sociaty) {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_SociatyDismissed,
|
|
Title: pb.ErrorCode_SociatyDismissed.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
// 初始玩家公会任务
|
|
sociatyTask := this.module.modelSociatyTask.getUserTask(uid, sociaty.Id)
|
|
if sociatyTask.SociatyId != "" {
|
|
// 今日首次进入公会
|
|
if utils.IsFirstTody(sociatyTask.LastUpdateTime) {
|
|
//更新昨日签到数
|
|
this.module.modelSociaty.clearSigned(sociaty)
|
|
// 删除任务
|
|
if err := this.module.modelSociatyTask.deleTask(sociaty.Id, uid); err == nil {
|
|
// 初始新的公会任务
|
|
if err = this.module.modelSociatyTask.initSociatyTask(uid, sociaty.Id); err != nil {
|
|
this.module.Error("初始化玩家公会任务",
|
|
log.Field{Key: "uid", Value: uid},
|
|
log.Field{Key: "sociatyId", Value: sociaty.Id},
|
|
log.Field{Key: "err", Value: err.Error()},
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 获取会长
|
|
master := this.module.modelSociaty.getMasterInfo(sociaty)
|
|
if master != nil {
|
|
// 会长弹劾判断
|
|
if err := this.module.modelSociaty.extendJob(master.Uid, sociaty); err == nil {
|
|
// 获取新的会长
|
|
master = this.module.modelSociaty.getMasterInfo(sociaty)
|
|
} else {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
|
|
this.module.Error("会长弹劾",
|
|
log.Field{Key: "uid", Value: uid},
|
|
log.Field{Key: "sociatyId", Value: sociaty.Id},
|
|
log.Field{Key: "master", Value: master.Uid},
|
|
log.Field{Key: "err", Value: err.Error()},
|
|
)
|
|
}
|
|
}
|
|
|
|
rsp.Sociaty = sociaty
|
|
rsp.Master = master
|
|
|
|
session.SendMsg(string(this.module.GetType()), SociatySubTypeMine, rsp)
|
|
return
|
|
}
|