golang 的 rabbitmq 消费项目
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

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