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.

init.go 7.0 KiB

7 months ago
4 months ago
8 months ago
11 months ago
11 months ago
11 months ago
10 months ago
9 months ago
4 months ago
9 months ago
7 months ago
4 months ago
4 months ago
4 months ago
8 months ago
5 months ago
8 months ago
7 months ago
5 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. //jobs[consumeMd.ZhiosUserProfileInviteCode] = ZhiosUserProfileInviteCode
  50. //
  51. ////////////////////////////////////// V1 /////////////////////////////////////////////////////
  52. //jobs[consumeMd.CloudIssuanceMsgCallBackFunName] = CloudIssuanceMsgCallBackConsume
  53. //////////////////////////////////////// V2 /////////////////////////////////////////////////////
  54. //jobs[consumeMd.SupplyCloudChainFenxiaoNewChangeFunName] = SupplyCloudChainFenxiaoNewChangeConsume
  55. //////////////////////////////////////// V3 /////////////////////////////////////////////////////
  56. //jobs[consumeMd.MallAddSupplyGoodsFunName] = MallAddSupplyGoodsConsume
  57. //////////////////////////////////////// bigData /////////////////////////////////////////////////////
  58. //jobs[consumeMd.CanalOrderConsumeFunName] = CanalOrderConsume
  59. //jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume
  60. //jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume
  61. //jobs[consumeMd.CanalUserVirtualCcoinFlowFunName] = CanalUserVirtualCoinFlowConsume
  62. //jobs[consumeMd.CanalGuideOrderForNumericalStatementConsumeFunName] = CanalGuideOrderForNumericalStatementConsume
  63. //jobs[consumeMd.CanalMallOrderForNumericalStatementConsumeFunName] = CanalMallOrderForNumericalStatementConsume
  64. //jobs[consumeMd.CanalO2oOrderForNumericalStatementConsumeFunName] = CanalO2oOrderForNumericalStatementConsume
  65. //jobs[consumeMd.CanalO2oPayOrderForNumericalStatementConsumeFunName] = CanalO2oPayOrderForNumericalStatementConsume
  66. //jobs[consumeMd.CanalB2cOrderForNumericalStatementConsumeFunName] = CanalB2cOrderForNumericalStatementConsume
  67. //////////////////////////////////////// oneCircles /////////////////////////////////////////////////////
  68. //jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume
  69. //jobs[consumeMd.OneCirclesStartLevelDividendFunName] = OneCirclesStartLevelDividendConsume
  70. //jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyConsume
  71. //jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume
  72. //jobs[consumeMd.OneCirclesSettlementPublicGiveActivityCoinFunName] = OneCirclesSettlementPublicGiveActivityCoinConsume
  73. //jobs[consumeMd.OneCirclesAddPublicPlatoonUserRelationCommissionFunName] = OneCirclesAddPublicPlatoonUserRelationCommissionConsume
  74. //jobs[consumeMd.OneCirclesSignInCopyGreenEnergyFunName] = OneCirclesSignInCopyGreenEnergyConsume
  75. //////////////////////////////////////// withdraw /////////////////////////////////////////////////////
  76. //jobs[consumeMd.WithdrawConsumeFunName] = WithdrawConsume
  77. //jobs[consumeMd.FlexibleEmploymentWithdrawForGongMaoConsumeFunName] = FlexibleEmploymentWithdrawForGongMaoConsume
  78. //jobs[consumeMd.FlexibleEmploymentWithdrawForPupiaoConsumeFunName] = FlexibleEmploymentWithdrawForPupiaoConsume
  79. //jobs[consumeMd.ZhiosMallGreenCoinConsumeFunName] = ZhiosMallGreenCoinConsume //绿色双链积分
  80. //jobs[consumeMd.ZhiosOneCirclesCoinConsumeFunName] = ZhiosOneCirclesCoinConsume //一个圈圈虚拟币变化
  81. //////////////////////////////////////// autoRepaid /////////////////////////////////////////////////////
  82. //jobs[consumeMd.InstallmentPaymentAutoRepaidConsumeFunName] = InstallmentPaymentAutoRepaidConsume //分期付 - 自动扣款
  83. ////////////////////////////////////// SuperCloudIssuance /////////////////////////////////////////////////////
  84. //jobs[consumeMd.SuperCloudIssuanceMsgCallBackFunName] = SuperCloudIssuanceMsgCallBackConsume
  85. //jobs[consumeMd.SuperCloudIssuanceAsyncMLoginFunName] = SuperCloudIssuanceAsyncMLoginConsume
  86. ////////////////////////////////////// DMS /////////////////////////////////////////////////////
  87. //jobs[consumeMd.CanalGimMessageConsumeFunName] = CanalGimMessageConsume
  88. }
  89. func Run() {
  90. for _, v := range consumeMd.RabbitMqQueueKeyList {
  91. if _, ok := jobs[v.ConsumeFunName]; ok {
  92. go doConsume(v.ConsumeFunName, *v)()
  93. }
  94. }
  95. }
  96. func doConsume(fnName string, queue consumeMd.MqQueue) func() {
  97. return func() {
  98. begin := time.Now().Local()
  99. jobs[fnName](queue)
  100. end := time.Now().Local()
  101. logx.Infof(
  102. "[%s] AutoConsume started at <%s>, ended at <%s> duration <%s>",
  103. fnName,
  104. begin.Format("2006-01-02 15:04:05.000"),
  105. end.Format("2006-01-02 15:04:05.000"),
  106. time.Duration(end.UnixNano()-begin.UnixNano()).String(),
  107. )
  108. }
  109. }