蛋蛋星球RabbitMq消费项目
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

85 líneas
4.5 KiB

  1. package consume
  2. import (
  3. "applet/app/utils/logx"
  4. consumeMd "applet/consume/md"
  5. "time"
  6. )
  7. var (
  8. jobs = map[string]func(consumeMd.MqQueue){}
  9. )
  10. func Init() {
  11. // 初始化任务列表
  12. initConsumes()
  13. }
  14. // 增加消费任务队列
  15. func initConsumes() {
  16. jobs[consumeMd.EggCanalUserDownConsume] = EggCanalUserDownConsume //监听 自动降级
  17. jobs[consumeMd.EggSlowAutoUpLvConsume] = EggSlowAutoUpLvConsume //缓慢 自动升级
  18. jobs[consumeMd.EggEnergyUserActivityConsume] = EggEnergyUserActivityConsume //监听 自动升级
  19. jobs[consumeMd.EggCanalUserConsume] = EggCanalUserConsume //监听 自动升级
  20. jobs[consumeMd.AliyunSmsRecordFunName] = AliyunSmsRecordConsume //阿里云短信
  21. jobs[consumeMd.JpushRecordFunName] = JpushRecordConsume //极光推送
  22. jobs[consumeMd.UserDeleteFunName] = UserDeleteConsume // 用户注销处理
  23. jobs[consumeMd.EggEnergyNewUserRegisterDataFunName] = EggEnergyNewUserRegisterDataConsume // 新用户注册
  24. jobs[consumeMd.IMEggEnergyBatchSendMessageDataFunName] = IMEggEnergyBatchSendMessageDataConsume // 批量发送信息
  25. jobs[consumeMd.IMEggEnergyDelFriendCircleDataFunName] = IMEggEnergyDelFriendCircleDataConsume // 删除朋友圈
  26. jobs[consumeMd.EggFinWithdrawApplyDataConsumeFunName] = EggFinWithdrawApplyDataConsume // 提现
  27. jobs[consumeMd.EggEnergyDealUserECPMFunName] = EggEnergyDealUserECPMConsume // 处理给用户Ecpm值
  28. //jobs[consumeMd.EggEnergyTemporaryDealUserECPMFunName] = TemporaryEggEnergyDealUserECPMConsume // 临时处理给用户Ecpm值
  29. jobs[consumeMd.EggCanalInviteUserNumsFunName] = EggCanalInviteUserNumsConsume // 处理拉新人数
  30. jobs[consumeMd.EggCanalViolateNumsFunName] = EggCanalViolateNumsConsume // 处理违规次数
  31. jobs[consumeMd.IMEggEnergySendRedPackageFunName] = IMEggEnergySendRedPackageConsume // 处理用户发送红包次数
  32. jobs[consumeMd.EggCanalPersonAddActivityValueFunName] = EggCanalPersonAddActivityValueConsume // 用户活跃积分变更时更新es
  33. jobs[consumeMd.EggRecordActiveDataFunName] = EggRecordActiveDataConsume // 用户签到后更新活跃数据
  34. jobs[consumeMd.EggEnergyAutoScoreDataFunName] = EggEnergyAutoScoreConsume // 自动打分
  35. jobs[consumeMd.EggSendFriendCircleDataFunName] = EggSendFriendCircleDataConsume // 用户发送朋友圈后更新es
  36. jobs[consumeMd.EggCommentDataFunName] = EggCommentDataConsume // 用户评论后更新es
  37. jobs[consumeMd.EggCanalEnergyExchangeAccountFunName] = EggCanalEnergyExchangeAccountConsume // 蛋蛋能量兑换为余额的时候更新es
  38. jobs[consumeMd.VideoRewardFunName] = VideoRewardConsume // 短视频奖励
  39. jobs[consumeMd.PlayletRewardFunName] = PlayletRewardConsume // 短剧奖励
  40. jobs[consumeMd.EggEnergyDealPlatformRevenueDataFunName] = EggEnergyDealPlatformRevenueDataConsume // 平台营收
  41. jobs[consumeMd.EggEnergyDealFundDataFunName] = EggEnergyDealFundDataConsume // 资金数据
  42. jobs[consumeMd.EggEnergyDealUserVirtualCoinDataFunName] = EggEnergyDealUserVirtualCoinDataConsume // 视频奖励给相应团队发放积分
  43. jobs[consumeMd.PublicPlatoonUserRelationCommissionConsumeFunName] = AddPublicPlatoonUserRelationCommissionConsume
  44. jobs[consumeMd.EggEnergyStartLevelDividendFunName] = EggEnergyStartLevelDividendConsume
  45. jobs[consumeMd.EggEnergySettlementPublicGiveActivityCoinFunName] = EggEnergySettlementPublicGiveActivityCoinConsume
  46. jobs[consumeMd.EggEnergyStartExchangeGreenEnergyFunName] = EggEnergyStartExchangeGreenEnergyConsume
  47. jobs[consumeMd.EggEnergyAutoExchangeGreenEnergyFunName] = EggEnergyAutoExchangeGreenEnergyConsume
  48. jobs[consumeMd.EggEnergyTeamAssistanceConsumeFunName] = EggEnergyTeamAssistanceConsume // 更新团队助力数据
  49. jobs[consumeMd.EggCanalUserVirtualCoinFlowAggregationConsumeFunName] = EggCanalUserVirtualCoinFlowAggregationConsume // 聚合流水数据
  50. }
  51. func Run() {
  52. for _, v := range consumeMd.RabbitMqQueueKeyList {
  53. if _, ok := jobs[v.ConsumeFunName]; ok {
  54. go doConsume(v.ConsumeFunName, *v)()
  55. }
  56. }
  57. }
  58. func doConsume(fnName string, queue consumeMd.MqQueue) func() {
  59. return func() {
  60. begin := time.Now().Local()
  61. jobs[fnName](queue)
  62. end := time.Now().Local()
  63. logx.Infof(
  64. "[%s] AutoConsume started at <%s>, ended at <%s> duration <%s>",
  65. fnName,
  66. begin.Format("2006-01-02 15:04:05.000"),
  67. end.Format("2006-01-02 15:04:05.000"),
  68. time.Duration(end.UnixNano()-begin.UnixNano()).String(),
  69. )
  70. }
  71. }