diff --git a/_const/enum/msg_e/msg.go b/_const/enum/msg_e/msg.go index 3c0bbec54a2f854b87a988dc1d2599a6a8c538a7..02b9f5507940c48ef47a54704e07b0176bfe99e9 100644 --- a/_const/enum/msg_e/msg.go +++ b/_const/enum/msg_e/msg.go @@ -114,25 +114,25 @@ const ( //也门活动通知 ActivityTriggerYemen = 27 //月充值活动通知 - ActivityTriggerMonthPay = 28 - FruitTycoonAward = 29 // 水果大亨获奖 - LuckyboxRecycle = 30 //幸运盒子回收 - HlTemp1 = 31 //产品黄蕾,2022/06/29 临时要求发给某人的小助手消息 - HLTemp2 = 32 //问卷调查 - NewUserInviteAuditPassed = 33 // 新用户奖励活动审核通过 - NewUserInviteAuditFailed = 34 // 新用户奖励活动审核不通过 - NewUserInviterAward = 35 // 新用户奖励活动邀请成功数达标 - PowerSupportSalary = 36 // 势力扶持工资领取 提醒 - CountryStarOrdinaryAward = 37 // 国家之星瓜分奖提醒 - GroupActivityRewardMsg = 38 // 群组活动钻石奖励提醒 - TemplateActAwardMsg = 39 // 通用模板活动奖励提醒 - TemplateSmsCode = 40 // 通用模板活动奖励提醒 - NewUserRegisterPush1 = 44 // 首次充值免费获得永久充值勋章!累积充值$50可申请特殊ID:ABBABB! - NewUserRegisterPush2 = 45 // 邀请朋友来Hilo,最高获得100,000钻石奖励! - NewUserRegisterPush3 = 46 // 举办首个活动,领取10,000钻石和35%奖杯奖励! - ActFruitPutRankAward = 47 // 水果机投入排行榜提醒领奖 - ActGroupPowerUpgrade = 48 // 家族升级 - ActGroupPowerExpireNotice = 49 // 家族等级即将过期(每月20日) + ActivityTriggerMonthPay = 28 + FruitTycoonAward = 29 // 水果大亨获奖 + LuckyboxRecycle = 30 //幸运盒子回收 + HlTemp1 = 31 //产品黄蕾,2022/06/29 临时要求发给某人的小助手消息 + HLTemp2 = 32 //问卷调查 + NewUserInviteAuditPassed = 33 // 新用户奖励活动审核通过 + NewUserInviteAuditFailed = 34 // 新用户奖励活动审核不通过 + NewUserInviterAward = 35 // 新用户奖励活动邀请成功数达标 + PowerSupportSalary = 36 // 势力扶持工资领取 提醒 + CountryStarOrdinaryAward = 37 // 国家之星瓜分奖提醒 + GroupActivityRewardMsg = 38 // 群组活动钻石奖励提醒 + TemplateActAwardMsg = 39 // 通用模板活动奖励提醒 + TemplateSmsCode = 40 // 通用模板活动奖励提醒 + NewUserRegisterPush1 = 44 // 首次充值免费获得永久充值勋章!累积充值$50可申请特殊ID:ABBABB! + NewUserRegisterPush2 = 45 // 邀请朋友来Hilo,最高获得100,000钻石奖励! + NewUserRegisterPush3 = 46 // 举办首个活动,领取10,000钻石和35%奖杯奖励! + ActFruitPutRankAward = 47 // 水果机投入排行榜提醒领奖 + GroupPowerUpgrade = 48 // 家族升级 + GroupPowerExpireNotice = 49 // 家族等级即将过期(每月20日) ) type MsgSysUserType = mysql.Type diff --git a/domain/event/group_power_ev/groupPowerUpgrade.go b/domain/event/group_power_ev/groupPowerUpgrade.go new file mode 100644 index 0000000000000000000000000000000000000000..b60d1946cf78d75c5e50e33dc6bf3ee99b701e4b --- /dev/null +++ b/domain/event/group_power_ev/groupPowerUpgrade.go @@ -0,0 +1,28 @@ +package group_power_ev + +import ( + "git.hilo.cn/hilo-common/domain" + "git.hilo.cn/hilo-common/resource/mysql" +) + +//注册监听 +var groupPowerUpgradeListen = new(domain.EventBase) + +type GroupPowerUpgradeEvent struct { + GroupPowerId mysql.ID +} + +//添加领域事件,在每个领域模型中init中添加,因为这是静态业务,非动态的。 +func AddGroupPowerUpgradeSync(callback func(model *domain.Model, event interface{}) error) { + domain.AddEventSync(groupPowerUpgradeListen, callback) +} + +//加入到异步操作中 +func AddGroupPowerUpgradeAsync(callback func(model *domain.Model, event interface{}) error) { + domain.AddEventAsync(groupPowerUpgradeListen, callback) +} + +//领域事件发布 +func PublishGroupPowerUpgrade(model *domain.Model, event interface{}) error { + return domain.PublishEvent(groupPowerUpgradeListen, model, event) +} diff --git a/domain/model/groupPower_m/group_grade.go b/domain/model/groupPower_m/group_grade.go index ed2050ed0ad76122b939ef646d31138ff9df006b..3721a77493c6edb8d3490eddaef8f1fa81fa987a 100644 --- a/domain/model/groupPower_m/group_grade.go +++ b/domain/model/groupPower_m/group_grade.go @@ -8,8 +8,7 @@ import ( "gorm.io/gorm" "gorm.io/gorm/clause" "hilo-group/_const/enum/groupPower_e" - "hilo-group/_const/enum/msg_e" - "hilo-group/domain/model/msg_m" + "hilo-group/domain/event/group_power_ev" "time" ) @@ -125,16 +124,10 @@ func IncrGroupPowerExp(txModel *domain.Model, groupPowerId mysql.ID, exp mysql.N if err = txModel.DB().Model(GroupPowerGrade{}).Where("group_power_id = ?", latestGrade.GroupPowerId).UpdateColumns(updateAttrs).Error; err != nil { return err } - // 升级发消息 // todo 看看需要移出去外面,或者发一个事件? - record1 := msg_m.NewUserRecord(txModel, 4522, msg_e.ActGroupPowerUpgrade, "", 0, "", "", "", "", "") - _ = record1.Persistent() - return nil - // 不加离线推送 - //user, err := user_m.GetUser(model, event.UserId) - //if err != nil { - // return err - //} - //return SendEmasMsgAssistant(model, user.ExternalId, user.DeviceType) + // 升级发事件 + _ = group_power_ev.PublishGroupPowerUpgrade(txModel, &group_power_ev.GroupPowerUpgradeEvent{ + GroupPowerId: groupPowerId, + }) } break } diff --git a/domain/service/event_s/event_init.go b/domain/service/event_s/event_init.go index 5e5f13764f870fa8a6fef03729f73d31fd09bc1e..2830a9099915c11bac66ebf7dfd3d4692aab7bcf 100644 --- a/domain/service/event_s/event_init.go +++ b/domain/service/event_s/event_init.go @@ -106,7 +106,7 @@ func GroupSupportEvents() { } func GroupPowerEvents() { - //加入势力 + // 加入势力 group_power_ev.AddGroupPowerJoinAsync(func(model *domain.Model, e interface{}) error { event, ok := e.(*group_power_ev.GroupPowerJoinEvent) if !ok { @@ -134,7 +134,7 @@ func GroupPowerEvents() { msg_m.SendEmasMsgAssistant(model, mgrUser.ExternalId, mgrUser.DeviceType) return nil }) - //离开势力 + // 离开势力 group_power_ev.AddGroupPowerLeaveAsync(func(model *domain.Model, e interface{}) error { event, ok := e.(*group_power_ev.GroupPowerLeaveEvent) if !ok { @@ -162,6 +162,30 @@ func GroupPowerEvents() { msg_m.SendEmasMsgAssistant(model, mgrUser.ExternalId, mgrUser.DeviceType) return nil }) + // 势力升级 + group_power_ev.AddGroupPowerUpgradeAsync(func(model *domain.Model, e interface{}) error { + event, ok := e.(*group_power_ev.GroupPowerUpgradeEvent) + if !ok { + model.Log.Errorf("AddGroupPowerUpgradeAsync event type err") + return nil + } + model.Log.Infof("msg AddGroupPowerUpgradeAsync GroupPowerId:%v", event.GroupPowerId) + //获取势力主 + mgrUserId, err := groupPower_m.GetGroupPowerMgr(model, event.GroupPowerId) + if err != nil { + return err + } + mgrUser, err := user_m.GetUser(model, mgrUserId) + 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 + } + msg_m.SendEmasMsgAssistant(model, mgrUser.ExternalId, mgrUser.DeviceType) + return nil + }) } func GroupEvents() {