diff --git a/rule/egg_energy/activity_coin_auto_exchange_egg_energy.go b/rule/egg_energy/activity_coin_auto_exchange_egg_energy.go index 61bba98..dc3a940 100644 --- a/rule/egg_energy/activity_coin_auto_exchange_egg_energy.go +++ b/rule/egg_energy/activity_coin_auto_exchange_egg_energy.go @@ -8,6 +8,7 @@ import ( "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md" egg_system_rules "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils" zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/logx" + "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" "fmt" "github.com/shopspring/decimal" "math/rand" @@ -88,5 +89,22 @@ func ActivityCoinAutoExchangeEggPersonEnergy(engine *xorm.Engine, req md.EggEner return err } - return session.Commit() + err = session.Commit() + if err != nil { + session.Rollback() + return err + } + + // 推入队列中异步处理 + ch, err1 := rabbit.Cfg.Pool.GetChannel() + if err1 != nil { + return err1 + } + defer ch.Release() + ch.Publish(md.EggEnergyExchange, egg_system_rules.SerializeStr(md.EggStructForRecordActiveData{ + Uid: req.Uid, + TotalPersonEggPoints: sign.TotalPersonEggPoints, + }), md.EggRoutKeyForRecordActive) + + return nil } diff --git a/rule/egg_energy/md/mq_egg_app.go b/rule/egg_energy/md/mq_egg_app.go index 1c812ec..8b81524 100644 --- a/rule/egg_energy/md/mq_egg_app.go +++ b/rule/egg_energy/md/mq_egg_app.go @@ -3,9 +3,10 @@ package md const EggAppExchange = "egg.app" const ( - EggNewUserRegister = "egg_new_user_register" // 新用户注册 - EggFinWithdrawApply = "egg_fin_withdraw_apply" // 提现申请 - EggFinWithdrawApplyError = "egg_fin_deposit_apply_error" + EggNewUserRegister = "egg_new_user_register" // 新用户注册 + EggFinWithdrawApply = "egg_fin_withdraw_apply" // 提现申请 + EggFinWithdrawApplyError = "egg_fin_deposit_apply_error" // 提现申请异常队列 + EggRoutKeyForRecordActive = "egg_record_active" // 更新活跃记录 ) type EggNewUserRegisterData struct { @@ -37,3 +38,8 @@ type EggFinWithdrawApplyErrorData struct { ErrorInfo string `json:"error_info"` // 错误信息 Ext []byte `json:"ext"` // 如果尝试解析失败,则将整个结构体放入 } + +type EggStructForRecordActiveData struct { + Uid int64 `json:"uid"` + TotalPersonEggPoints string `json:"total_person_egg_points"` // 个人活跃积分 +}