golang 的 rabbitmq 消费项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

143 lines
7.6 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.ZhiosGuideStoreOrderFunName] = ZhiosGuideStoreOrder
  17. jobs[consumeMd.ZhiosIntegralProxyRechargeFunName] = ZhiosIntegralProxyRecharge
  18. jobs[consumeMd.ZhiosUserUpLvFunName] = ZhiosUserUpLv
  19. jobs[consumeMd.CanalGuideOrderByUserUpLvConsume] = CanalGuideOrderByUserUpLvConsume
  20. jobs[consumeMd.ZhiosOrderFreeFunName] = ZhiosOrderFree
  21. jobs[consumeMd.ZhiosOrderTotalFunName] = ZhiosOrderTotal
  22. jobs[consumeMd.ZhiosOrderTotalSecondFunName] = ZhiosOrderTotalSecond
  23. jobs[consumeMd.ZhiosOrderSettleTotalFunName] = ZhiosSettleTotal
  24. jobs[consumeMd.ZhiosOrderHjyFunName] = ZhiosOrderHjy
  25. jobs[consumeMd.ZhiosOrderBuckleFunName] = ZhiosOrderBuckle
  26. jobs[consumeMd.ZhiosSupplierAfterOrderFunName] = ZhiosSupplierAfterOrder
  27. jobs[consumeMd.ZhiosAppreciationFunName] = ZhiosAppreciation
  28. jobs[consumeMd.ZhiosValidUserFunName] = ZhiosValidUser
  29. jobs[consumeMd.ZhiosAcquisitionConditionFunName] = ZhiosAcquisitionCondition
  30. jobs[consumeMd.DouShenUserRegisterConsumeForOfficialFunName] = DouShenUserRegisterConsumeForOfficial
  31. jobs[consumeMd.DouShenUserRegisterConsumeForOperationCenterFunName] = DouShenUserRegisterConsumeForOperationCenter
  32. jobs[consumeMd.DouShenUserRegisterConsumeForMyRecommenderFunName] = DouShenUserRegisterConsumeForMyRecommender
  33. jobs[consumeMd.DouShenUserRegisterConsumeForMyFansFunName] = DouShenUserRegisterConsumeForMyFans
  34. jobs[consumeMd.DouShenUserRegisterConsumeForUserRegisterUpLvFunName] = DouShenUserRegisterConsumeForUserRegisterUpLv
  35. jobs[consumeMd.ZhiosFastReturnOrderPayFunName] = ZhiosFastReturnOrderPay
  36. jobs[consumeMd.ZhiosFastReturnOrderSuccessFunName] = ZhiosFastReturnOrderSuccess
  37. jobs[consumeMd.ZhiosFastReturnOrderRefundFunName] = ZhiosFastReturnOrderRefund
  38. jobs[consumeMd.ZhiosFastReturnOrderRefundSecondFunName] = ZhiosFastReturnOrderRefundSecond
  39. jobs[consumeMd.YoumishangExchangeStoreFunName] = YoumishangExchangeStore
  40. jobs[consumeMd.ZhiosRechargeOrderFailFunName] = ZhiosRechargeOrderFail
  41. jobs[consumeMd.CloudIssuanceAsyncMLoginFunName] = CloudIssuanceAsyncMLoginConsume
  42. jobs[consumeMd.ZhiosTikTokUpdateFunName] = ZhiosTikTokUpdate
  43. jobs[consumeMd.ZhiosTikTokAllUpdateFunName] = ZhiosTikTokAllUpdate
  44. jobs[consumeMd.ZhiosCapitalPoolOrderTotalFunName] = ZhiosCapitalPoolOrderTotal
  45. jobs[consumeMd.ZhiosExpressOrderFail] = ZhiosExpressOrderFail
  46. jobs[consumeMd.ZhiosWithdrawReward] = ZhiosWithdrawReward
  47. jobs[consumeMd.ZhiosTaskTotal] = ZhiosTaskTotal
  48. jobs[consumeMd.ZhiosAutoUnFreeze] = ZhiosAutoUnFreeze
  49. ////////////////////////////////////// V1 /////////////////////////////////////////////////////
  50. //jobs[consumeMd.CloudIssuanceMsgCallBackFunName] = CloudIssuanceMsgCallBackConsume
  51. //////////////////////////////////////// V2 /////////////////////////////////////////////////////
  52. //jobs[consumeMd.SupplyCloudChainFenxiaoNewChangeFunName] = SupplyCloudChainFenxiaoNewChangeConsume
  53. //////////////////////////////////////// V3 /////////////////////////////////////////////////////
  54. //jobs[consumeMd.MallAddSupplyGoodsFunName] = MallAddSupplyGoodsConsume
  55. //////////////////////////////////////// bigData /////////////////////////////////////////////////////
  56. //jobs[consumeMd.CanalOrderConsumeFunName] = CanalOrderConsume
  57. //jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume
  58. //jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume
  59. //jobs[consumeMd.CanalUserVirtualCcoinFlowFunName] = CanalUserVirtualCoinFlowConsume
  60. //jobs[consumeMd.CanalGuideOrderForNumericalStatementConsumeFunName] = CanalGuideOrderForNumericalStatementConsume
  61. //jobs[consumeMd.CanalMallOrderForNumericalStatementConsumeFunName] = CanalMallOrderForNumericalStatementConsume
  62. //jobs[consumeMd.CanalO2oOrderForNumericalStatementConsumeFunName] = CanalO2oOrderForNumericalStatementConsume
  63. //jobs[consumeMd.CanalO2oPayOrderForNumericalStatementConsumeFunName] = CanalO2oPayOrderForNumericalStatementConsume
  64. //jobs[consumeMd.CanalB2cOrderForNumericalStatementConsumeFunName] = CanalB2cOrderForNumericalStatementConsume
  65. //////////////////////////////////////// oneCircles-v1 /////////////////////////////////////////////////////
  66. //jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume
  67. //jobs[consumeMd.OneCirclesStartLevelDividendFunName] = OneCirclesStartLevelDividendConsume
  68. //jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyConsume
  69. //jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume
  70. //jobs[consumeMd.OneCirclesSettlementPublicGiveActivityCoinFunName] = OneCirclesSettlementPublicGiveActivityCoinConsume
  71. //jobs[consumeMd.OneCirclesAddPublicPlatoonUserRelationCommissionFunName] = OneCirclesAddPublicPlatoonUserRelationCommissionConsume
  72. //////////////////////////////////////// oneCircles-v2 /////////////////////////////////////////////////////
  73. //jobs[consumeMd.OneCirclesDealUserCoinConsumeFunName] = OneCirclesDealUserCoinConsume
  74. //////////////////////////////////////// withdraw /////////////////////////////////////////////////////
  75. //jobs[consumeMd.WithdrawConsumeFunName] = WithdrawConsume
  76. //jobs[consumeMd.FlexibleEmploymentWithdrawForGongMaoConsumeFunName] = FlexibleEmploymentWithdrawForGongMaoConsume
  77. //jobs[consumeMd.FlexibleEmploymentWithdrawForPupiaoConsumeFunName] = FlexibleEmploymentWithdrawForPupiaoConsume
  78. //jobs[consumeMd.NewFlexibleEmploymentWithdrawForPupiaoConsumeFunName] = NewFlexibleEmploymentWithdrawForPupiaoConsume
  79. //jobs[consumeMd.ServiceAwardDividendRelationConsumeFunName] = ServiceAwardDividendRelationConsume
  80. //jobs[consumeMd.CanalServiceAwardDividendRelationConsumeFunName] = CanalServiceAwardDividendRelationConsume //服务奖消费
  81. //jobs[consumeMd.DividendRewardConsumeFunName] = DividendRewardConsume //蜂蜜分红
  82. //jobs[consumeMd.ContributionExchangeConsumeFunName] = ContributionExchangeConsume //蜂蜜分红-兑换贡献值
  83. //jobs[consumeMd.ZhiosMallGreenCoinConsumeFunName] = ZhiosMallGreenCoinConsume //绿色双链积分
  84. //jobs[consumeMd.ZhiosOneCirclesCoinConsumeFunName] = ZhiosOneCirclesCoinConsume //一个圈圈虚拟币变化
  85. //////////////////////////////////////// autoRepaid /////////////////////////////////////////////////////
  86. //jobs[consumeMd.InstallmentPaymentAutoRepaidConsumeFunName] = InstallmentPaymentAutoRepaidConsume //分期付 - 自动扣款
  87. ////////////////////////////////////// SuperCloudIssuance /////////////////////////////////////////////////////
  88. //jobs[consumeMd.SuperCloudIssuanceMsgCallBackFunName] = SuperCloudIssuanceMsgCallBackConsume
  89. //jobs[consumeMd.SuperCloudIssuanceAsyncMLoginFunName] = SuperCloudIssuanceAsyncMLoginConsume
  90. ////////////////////////////////////// DMS /////////////////////////////////////////////////////
  91. //jobs[consumeMd.CanalGimMessageConsumeFunName] = CanalGimMessageConsume
  92. }
  93. func Run() {
  94. for _, v := range consumeMd.RabbitMqQueueKeyList {
  95. if _, ok := jobs[v.ConsumeFunName]; ok {
  96. go doConsume(v.ConsumeFunName, *v)()
  97. }
  98. }
  99. }
  100. func doConsume(fnName string, queue consumeMd.MqQueue) func() {
  101. return func() {
  102. begin := time.Now().Local()
  103. jobs[fnName](queue)
  104. end := time.Now().Local()
  105. logx.Infof(
  106. "[%s] AutoConsume started at <%s>, ended at <%s> duration <%s>",
  107. fnName,
  108. begin.Format("2006-01-02 15:04:05.000"),
  109. end.Format("2006-01-02 15:04:05.000"),
  110. time.Duration(end.UnixNano()-begin.UnixNano()).String(),
  111. )
  112. }
  113. }