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.
 
 
 

128 lines
6.0 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. jobs[consumeMd.ZhiosAppreciationFunName] = ZhiosAppreciation
  30. jobs[consumeMd.ZhiosValidUserFunName] = ZhiosValidUser
  31. jobs[consumeMd.ZhiosAcquisitionConditionFunName] = ZhiosAcquisitionCondition
  32. jobs[consumeMd.DouShenUserRegisterConsumeForOfficialFunName] = DouShenUserRegisterConsumeForOfficial
  33. jobs[consumeMd.DouShenUserRegisterConsumeForOperationCenterFunName] = DouShenUserRegisterConsumeForOperationCenter
  34. jobs[consumeMd.DouShenUserRegisterConsumeForMyRecommenderFunName] = DouShenUserRegisterConsumeForMyRecommender
  35. jobs[consumeMd.DouShenUserRegisterConsumeForMyFansFunName] = DouShenUserRegisterConsumeForMyFans
  36. jobs[consumeMd.DouShenUserRegisterConsumeForUserRegisterUpLvFunName] = DouShenUserRegisterConsumeForUserRegisterUpLv
  37. jobs[consumeMd.ZhiosFastReturnOrderPayFunName] = ZhiosFastReturnOrderPay
  38. jobs[consumeMd.ZhiosFastReturnOrderSuccessFunName] = ZhiosFastReturnOrderSuccess
  39. jobs[consumeMd.ZhiosFastReturnOrderRefundFunName] = ZhiosFastReturnOrderRefund
  40. jobs[consumeMd.ZhiosFastReturnOrderRefundSecondFunName] = ZhiosFastReturnOrderRefundSecond
  41. jobs[consumeMd.YoumishangExchangeStoreFunName] = YoumishangExchangeStore
  42. jobs[consumeMd.ZhiosRechargeOrderFailFunName] = ZhiosRechargeOrderFail
  43. jobs[consumeMd.CloudIssuanceAsyncMLoginFunName] = CloudIssuanceAsyncMLoginConsume
  44. jobs[consumeMd.ZhiosTikTokUpdateFunName] = ZhiosTikTokUpdate
  45. jobs[consumeMd.ZhiosTikTokAllUpdateFunName] = ZhiosTikTokAllUpdate
  46. jobs[consumeMd.ZhiosCapitalPoolOrderTotalFunName] = ZhiosCapitalPoolOrderTotal
  47. jobs[consumeMd.ZhiosExpressOrderFail] = ZhiosExpressOrderFail
  48. jobs[consumeMd.ZhiosWithdrawReward] = ZhiosWithdrawReward
  49. jobs[consumeMd.ZhiosTaskTotal] = ZhiosTaskTotal
  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. //////////////////////////////////////// oneCircles /////////////////////////////////////////////////////
  63. //jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume
  64. //jobs[consumeMd.OneCirclesStartLevelDividendFunName] = OneCirclesStartLevelDividendConsume
  65. //jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyConsume
  66. //jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume
  67. //jobs[consumeMd.OneCirclesSettlementPublicGiveActivityCoinFunName] = OneCirclesSettlementPublicGiveActivityCoinConsume
  68. ////jobs[consumeMd.OneCirclesSignInCopyGreenEnergyFunName] = OneCirclesSignInCopyGreenEnergyConsume
  69. //////////////////////////////////////// withdraw /////////////////////////////////////////////////////
  70. //jobs[consumeMd.WithdrawConsumeFunName] = WithdrawConsume
  71. //jobs[consumeMd.FlexibleEmploymentWithdrawForGongMaoConsumeFunName] = FlexibleEmploymentWithdrawForGongMaoConsume
  72. //jobs[consumeMd.FlexibleEmploymentWithdrawForPupiaoConsumeFunName] = FlexibleEmploymentWithdrawForPupiaoConsume
  73. //jobs[consumeMd.ZhiosMallGreenCoinConsumeFunName] = ZhiosMallGreenCoinConsume //绿色双链积分
  74. //jobs[consumeMd.ZhiosOneCirclesCoinConsumeFunName] = ZhiosOneCirclesCoinConsume //一个圈圈虚拟币变化
  75. //////////////////////////////////////// autoRepaid /////////////////////////////////////////////////////
  76. //jobs[consumeMd.InstallmentPaymentAutoRepaidConsumeFunName] = InstallmentPaymentAutoRepaidConsume //分期付 - 自动扣款
  77. ////////////////////////////////////// SuperCloudIssuance /////////////////////////////////////////////////////
  78. //jobs[consumeMd.SuperCloudIssuanceMsgCallBackFunName] = SuperCloudIssuanceMsgCallBackConsume
  79. //jobs[consumeMd.SuperCloudIssuanceAsyncMLoginFunName] = SuperCloudIssuanceAsyncMLoginConsume
  80. }
  81. func Run() {
  82. for _, v := range consumeMd.RabbitMqQueueKeyList {
  83. if _, ok := jobs[v.ConsumeFunName]; ok {
  84. go doConsume(v.ConsumeFunName, *v)()
  85. }
  86. }
  87. }
  88. func doConsume(fnName string, queue consumeMd.MqQueue) func() {
  89. return func() {
  90. begin := time.Now().Local()
  91. jobs[fnName](queue)
  92. end := time.Now().Local()
  93. logx.Infof(
  94. "[%s] AutoConsume started at <%s>, ended at <%s> duration <%s>",
  95. fnName,
  96. begin.Format("2006-01-02 15:04:05.000"),
  97. end.Format("2006-01-02 15:04:05.000"),
  98. time.Duration(end.UnixNano()-begin.UnixNano()).String(),
  99. )
  100. }
  101. }