This commit is contained in:
aozhiwei 2024-04-19 11:09:59 +08:00
parent bfce47f8cc
commit 63896afdb6
3 changed files with 26 additions and 8 deletions

View File

@ -88,7 +88,7 @@ type GuildMgr interface {
AsyncCreateGuild(string, string, int32, string, func(int32, string, string))
AsyncGetApplyList(int64, string, func(int32, string, int64, []string))
AsyncApplyJoin(string, string, func(int32, string))
AsyncApplyJoin(string, string, func(int32, string, Guild))
AsyncAcceptApply(string, string, func(int32, string, string, string))
AsyncRejectApply(string, string, func(int32, string))
AsyncGetGuildRank(int32, func(int32, string, []string))

View File

@ -321,14 +321,14 @@ func (this *guildMgr) AsyncGetApplyList(lastIdx int64, accountId string,
})
}
func (this *guildMgr) AsyncApplyJoin(accountId string, guildId string, cb func(int32, string)) {
func (this *guildMgr) AsyncApplyJoin(accountId string, guildId string, cb func(int32, string, common.Guild)) {
if this.internalGetGuildByAccountId(accountId) != nil {
cb(0, "")
cb(0, "", nil)
return
}
guild := this.internalGetGuildByGuildId(guildId)
if guild == nil {
cb(0, "")
cb(0, "", nil)
return
}
nowTime := f5.GetApp().GetNowSeconds()
@ -341,19 +341,19 @@ func (this *guildMgr) AsyncApplyJoin(accountId string, guildId string, cb func(i
model.GuildApply.SetStatus(guild.guildId, accountId, constant.GUILD_APPLY_STATUS_ACCEPT,
func (err error, lastInsertId int64, rowsAffected int64) {
GetDbLogMgr().GuildAccpetApply(guild.guildId, accountId, accountId)
cb(0, "")
return
})
cb(0, "", guild)
} else {
model.GuildApply.Force(
guildId,
accountId,
func (err error, lastInsertId int64, rowsAffected int64) {
if err != nil {
cb(500, "server internal error")
cb(500, "server internal error", nil)
return
}
cb(0, "")
cb(0, "", nil)
})
}
}

View File

@ -506,12 +506,30 @@ func (this *player) CMApplyToGuild(hdr *f5.MsgHdr, msg *cs.CMApplyToGuild) {
GetGuildMgr().AsyncApplyJoin(
this.GetAccountId(),
q5.ToString(msg.GetGuildId()),
func (errCode int32, errMsg string) {
func (errCode int32, errMsg string, okGuild common.Guild) {
if errCode != 0 {
this.SendMsg(rspMsg.Err(errCode, errMsg))
return
}
this.SendMsg(rspMsg)
if okGuild != nil {
pbGuilds := []*cs.MFGuildMember{}
GetCacheMgr().AsyncGetUsersAndFillMFGuildMember(
[]string{
this.GetAccountId(),
},
&pbGuilds,
func (errCode int32, errMsg string) {
if errCode == 0 && len(pbGuilds) > 0 {
notifyMsg := new(cs.SMApproveJoinGuildNotify)
notifyMsg.GuildId = proto.Int64(q5.ToInt64(okGuild.GetGuildId()))
notifyMsg.Name = proto.String(okGuild.GetGuildName())
notifyMsg.AccountId = proto.String(pbGuilds[0].GetAccountId())
notifyMsg.Username = proto.String(pbGuilds[0].GetUsername())
GetGuildMgr().NotifyGuildMsg(q5.ToString(msg.GetGuildId()), notifyMsg)
}
})
}
return
})
}