From a80e1c2035bdcb6557b1222216ba5abf67fe7f84 Mon Sep 17 00:00:00 2001 From: hujiebin Date: Fri, 10 Mar 2023 14:42:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E5=85=A8=E9=83=A8=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=AE=B6=E6=97=8F=E6=88=90=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- domain/model/groupPower_m/group_info.go | 9 +++++++++ domain/service/event_s/event_init.go | 19 ++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/domain/model/groupPower_m/group_info.go b/domain/model/groupPower_m/group_info.go index 2040ac8..e0feaba 100644 --- a/domain/model/groupPower_m/group_info.go +++ b/domain/model/groupPower_m/group_info.go @@ -46,3 +46,12 @@ func MGetGroupPowerUsers(model *domain.Model, groupPowerIds []mysql.ID) (map[mys } return res, nil } + +// 获取家族成员 +func GetGroupPowerUser(model *domain.Model, groupPowerId mysql.ID) ([]*GroupPowerUser, error) { + m, err := MGetGroupPowerUsers(model, []mysql.ID{groupPowerId}) + if err != nil { + return nil, err + } + return m[groupPowerId], nil +} diff --git a/domain/service/event_s/event_init.go b/domain/service/event_s/event_init.go index 2830a90..4936fc1 100644 --- a/domain/service/event_s/event_init.go +++ b/domain/service/event_s/event_init.go @@ -170,20 +170,25 @@ func GroupPowerEvents() { return nil } model.Log.Infof("msg AddGroupPowerUpgradeAsync GroupPowerId:%v", event.GroupPowerId) - //获取势力主 - mgrUserId, err := groupPower_m.GetGroupPowerMgr(model, event.GroupPowerId) + users, err := groupPower_m.GetGroupPowerUser(model, event.GroupPowerId) if err != nil { return err } - mgrUser, err := user_m.GetUser(model, mgrUserId) + var userIds []mysql.ID + for _, u := range users { + userIds = append(userIds, u.UserId) + } + userMaps, err := user_m.GetUserMapByIds(model, userIds) if err != nil { return err } - if err := msg_m.NewUserRecord(model, mgrUserId, msg_e.GroupPowerUpgrade, "", 0, "", "", "", "", "").Persistent(); err != nil { - model.Log.Errorf("msg AddGroupPowerLeaveAsync NewUserRecord err:%v", err) - return nil + for uid, u := range userMaps { + if err := msg_m.NewUserRecord(model, uid, msg_e.GroupPowerUpgrade, "", 0, "", "", "", "", "").Persistent(); err != nil { + model.Log.Errorf("msg AddGroupPowerLeaveAsync NewUserRecord err:%v", err) + return nil + } + msg_m.SendEmasMsgAssistant(model, u.ExternalId, u.DeviceType) } - msg_m.SendEmasMsgAssistant(model, mgrUser.ExternalId, mgrUser.DeviceType) return nil }) } -- 2.22.0