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.
 
 
 

114 lines
4.8 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. //
  18. ////
  19. //jobs[consumeMd.ZhiosIntegralProxyRechargeFunName] = ZhiosIntegralProxyRecharge
  20. //jobs[consumeMd.ZhiosUserUpLvFunName] = ZhiosUserUpLv
  21. //jobs[consumeMd.CanalGuideOrderByUserUpLvConsume] = CanalGuideOrderByUserUpLvConsume
  22. //jobs[consumeMd.ZhiosOrderFreeFunName] = ZhiosOrderFree
  23. //jobs[consumeMd.ZhiosOrderTotalFunName] = ZhiosOrderTotal
  24. //jobs[consumeMd.ZhiosOrderTotalSecondFunName] = ZhiosOrderTotalSecond
  25. ////
  26. //jobs[consumeMd.ZhiosOrderSettleTotalFunName] = ZhiosSettleTotal
  27. //jobs[consumeMd.ZhiosOrderHjyFunName] = ZhiosOrderHjy
  28. //jobs[consumeMd.ZhiosOrderBuckleFunName] = ZhiosOrderBuckle
  29. ////
  30. //jobs[consumeMd.ZhiosSupplierAfterOrderFunName] = ZhiosSupplierAfterOrder
  31. //
  32. //jobs[consumeMd.ZhiosAppreciationFunName] = ZhiosAppreciation
  33. //jobs[consumeMd.ZhiosValidUserFunName] = ZhiosValidUser
  34. //
  35. //jobs[consumeMd.ZhiosAcquisitionConditionFunName] = ZhiosAcquisitionCondition
  36. //
  37. //jobs[consumeMd.DouShenUserRegisterConsumeForOfficialFunName] = DouShenUserRegisterConsumeForOfficial
  38. //jobs[consumeMd.DouShenUserRegisterConsumeForOperationCenterFunName] = DouShenUserRegisterConsumeForOperationCenter
  39. //jobs[consumeMd.DouShenUserRegisterConsumeForMyRecommenderFunName] = DouShenUserRegisterConsumeForMyRecommender
  40. //jobs[consumeMd.DouShenUserRegisterConsumeForMyFansFunName] = DouShenUserRegisterConsumeForMyFans
  41. //jobs[consumeMd.DouShenUserRegisterConsumeForUserRegisterUpLvFunName] = DouShenUserRegisterConsumeForUserRegisterUpLv
  42. //
  43. //jobs[consumeMd.ZhiosFastReturnOrderPayFunName] = ZhiosFastReturnOrderPay
  44. //jobs[consumeMd.ZhiosFastReturnOrderSuccessFunName] = ZhiosFastReturnOrderSuccess
  45. //jobs[consumeMd.ZhiosFastReturnOrderRefundFunName] = ZhiosFastReturnOrderRefund
  46. //jobs[consumeMd.ZhiosFastReturnOrderRefundSecondFunName] = ZhiosFastReturnOrderRefundSecond
  47. //
  48. //jobs[consumeMd.YoumishangExchangeStoreFunName] = YoumishangExchangeStore
  49. //
  50. //jobs[consumeMd.ZhiosRechargeOrderFailFunName] = ZhiosRechargeOrderFail
  51. //
  52. //jobs[consumeMd.CloudIssuanceAsyncMLoginFunName] = CloudIssuanceAsyncMLoginConsume
  53. //jobs[consumeMd.ZhiosTikTokUpdateFunName] = ZhiosTikTokUpdate
  54. //jobs[consumeMd.ZhiosTikTokAllUpdateFunName] = ZhiosTikTokAllUpdate
  55. //
  56. //jobs[consumeMd.ZhiosCapitalPoolOrderTotalFunName] = ZhiosCapitalPoolOrderTotal
  57. //jobs[consumeMd.ZhiosExpressOrderFail] = ZhiosExpressOrderFail
  58. //jobs[consumeMd.ZhiosWithdrawReward] = ZhiosWithdrawReward
  59. //
  60. ////////////////////////////////////// V1 /////////////////////////////////////////////////////
  61. //jobs[consumeMd.CloudIssuanceMsgCallBackFunName] = CloudIssuanceMsgCallBackConsume
  62. //////////////////////////////////////// V2 /////////////////////////////////////////////////////
  63. //jobs[consumeMd.SupplyCloudChainFenxiaoNewChangeFunName] = SupplyCloudChainFenxiaoNewChangeConsume
  64. //////////////////////////////////////// V3 /////////////////////////////////////////////////////
  65. //jobs[consumeMd.MallAddSupplyGoodsFunName] = MallAddSupplyGoodsConsume
  66. //////////////////////////////////////// bigData /////////////////////////////////////////////////////
  67. //jobs[consumeMd.CanalOrderConsumeFunName] = CanalOrderConsume
  68. //jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume
  69. //jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume
  70. //jobs[consumeMd.CanalUserVirtualCcoinFlowFunName] = CanalUserVirtualCoinFlowConsume
  71. //////////////////////////////////////// oneCircles /////////////////////////////////////////////////////
  72. //jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume
  73. //jobs[consumeMd.OneCirclesStartLevelDividendFunName] = OneCirclesStartLevelDividendConsume
  74. //jobs[consumeMd.OneCirclesSignInCopyGreenEnergyFunName] = OneCirclesSignInCopyGreenEnergyConsume
  75. //////////////////////////////////////// withdraw /////////////////////////////////////////////////////
  76. //jobs[consumeMd.WithdrawConsumeFunName] = WithdrawConsume
  77. //jobs[consumeMd.ZhiosMallGreenCoinConsumeFunName] = ZhiosMallGreenCoinConsume //绿色双链积分
  78. }
  79. func Run() {
  80. for _, v := range consumeMd.RabbitMqQueueKeyList {
  81. if _, ok := jobs[v.ConsumeFunName]; ok {
  82. go doConsume(v.ConsumeFunName, *v)()
  83. }
  84. }
  85. }
  86. func doConsume(fnName string, queue consumeMd.MqQueue) func() {
  87. return func() {
  88. begin := time.Now().Local()
  89. jobs[fnName](queue)
  90. end := time.Now().Local()
  91. logx.Infof(
  92. "[%s] AutoConsume started at <%s>, ended at <%s> duration <%s>",
  93. fnName,
  94. begin.Format("2006-01-02 15:04:05.000"),
  95. end.Format("2006-01-02 15:04:05.000"),
  96. time.Duration(end.UnixNano()-begin.UnixNano()).String(),
  97. )
  98. }
  99. }