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 5.5 KiB

7 months ago
8 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
8 months ago
11 months ago
10 months ago
11 months ago
10 months ago
9 months ago
8 months ago
9 months ago
7 months ago
7 months ago
8 months ago
8 months ago
7 months ago
8 months ago
7 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. //jobs[consumeMd.ZhiosIntegralProxyRechargeFunName] = ZhiosIntegralProxyRecharge
  19. //jobs[consumeMd.ZhiosUserUpLvFunName] = ZhiosUserUpLv
  20. //jobs[consumeMd.CanalGuideOrderByUserUpLvConsume] = CanalGuideOrderByUserUpLvConsume
  21. //jobs[consumeMd.ZhiosOrderFreeFunName] = ZhiosOrderFree
  22. //jobs[consumeMd.ZhiosOrderTotalFunName] = ZhiosOrderTotal
  23. //jobs[consumeMd.ZhiosOrderTotalSecondFunName] = ZhiosOrderTotalSecond
  24. ////
  25. //jobs[consumeMd.ZhiosOrderSettleTotalFunName] = ZhiosSettleTotal
  26. //jobs[consumeMd.ZhiosOrderHjyFunName] = ZhiosOrderHjy
  27. //jobs[consumeMd.ZhiosOrderBuckleFunName] = ZhiosOrderBuckle
  28. ////
  29. //jobs[consumeMd.ZhiosSupplierAfterOrderFunName] = ZhiosSupplierAfterOrder
  30. //
  31. //jobs[consumeMd.ZhiosAppreciationFunName] = ZhiosAppreciation
  32. //jobs[consumeMd.ZhiosValidUserFunName] = ZhiosValidUser
  33. //
  34. //jobs[consumeMd.ZhiosAcquisitionConditionFunName] = ZhiosAcquisitionCondition
  35. //
  36. //jobs[consumeMd.DouShenUserRegisterConsumeForOfficialFunName] = DouShenUserRegisterConsumeForOfficial
  37. //jobs[consumeMd.DouShenUserRegisterConsumeForOperationCenterFunName] = DouShenUserRegisterConsumeForOperationCenter
  38. //jobs[consumeMd.DouShenUserRegisterConsumeForMyRecommenderFunName] = DouShenUserRegisterConsumeForMyRecommender
  39. //jobs[consumeMd.DouShenUserRegisterConsumeForMyFansFunName] = DouShenUserRegisterConsumeForMyFans
  40. //jobs[consumeMd.DouShenUserRegisterConsumeForUserRegisterUpLvFunName] = DouShenUserRegisterConsumeForUserRegisterUpLv
  41. //
  42. //jobs[consumeMd.ZhiosFastReturnOrderPayFunName] = ZhiosFastReturnOrderPay
  43. //jobs[consumeMd.ZhiosFastReturnOrderSuccessFunName] = ZhiosFastReturnOrderSuccess
  44. //jobs[consumeMd.ZhiosFastReturnOrderRefundFunName] = ZhiosFastReturnOrderRefund
  45. //jobs[consumeMd.ZhiosFastReturnOrderRefundSecondFunName] = ZhiosFastReturnOrderRefundSecond
  46. //
  47. //jobs[consumeMd.YoumishangExchangeStoreFunName] = YoumishangExchangeStore
  48. //
  49. //jobs[consumeMd.ZhiosRechargeOrderFailFunName] = ZhiosRechargeOrderFail
  50. //
  51. //jobs[consumeMd.CloudIssuanceAsyncMLoginFunName] = CloudIssuanceAsyncMLoginConsume
  52. //jobs[consumeMd.ZhiosTikTokUpdateFunName] = ZhiosTikTokUpdate
  53. //jobs[consumeMd.ZhiosTikTokAllUpdateFunName] = ZhiosTikTokAllUpdate
  54. //
  55. //jobs[consumeMd.ZhiosCapitalPoolOrderTotalFunName] = ZhiosCapitalPoolOrderTotal
  56. //jobs[consumeMd.ZhiosExpressOrderFail] = ZhiosExpressOrderFail
  57. //jobs[consumeMd.ZhiosWithdrawReward] = ZhiosWithdrawReward
  58. //
  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. //////////////////////////////////////// oneCircles /////////////////////////////////////////////////////
  71. //
  72. jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume
  73. jobs[consumeMd.OneCirclesStartLevelDividendFunName] = OneCirclesStartLevelDividendConsume
  74. jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyConsume
  75. jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume
  76. jobs[consumeMd.OneCirclesSettlementPublicGiveActivityCoinFunName] = OneCirclesSettlementPublicGiveActivityCoinConsume
  77. //jobs[consumeMd.OneCirclesSignInCopyGreenEnergyFunName] = OneCirclesSignInCopyGreenEnergyConsume
  78. //////////////////////////////////////// withdraw /////////////////////////////////////////////////////
  79. //jobs[consumeMd.WithdrawConsumeFunName] = WithdrawConsume
  80. //jobs[consumeMd.FlexibleEmploymentWithdrawForGongMaoConsumeFunName] = FlexibleEmploymentWithdrawForGongMaoConsume
  81. //jobs[consumeMd.FlexibleEmploymentWithdrawForPupiaoConsumeFunName] = FlexibleEmploymentWithdrawForPupiaoConsume
  82. //jobs[consumeMd.ZhiosMallGreenCoinConsumeFunName] = ZhiosMallGreenCoinConsume //绿色双链积分
  83. //jobs[consumeMd.ZhiosOneCirclesCoinConsumeFunName] = ZhiosOneCirclesCoinConsume //一个圈圈虚拟币变化
  84. }
  85. func Run() {
  86. for _, v := range consumeMd.RabbitMqQueueKeyList {
  87. if _, ok := jobs[v.ConsumeFunName]; ok {
  88. go doConsume(v.ConsumeFunName, *v)()
  89. }
  90. }
  91. }
  92. func doConsume(fnName string, queue consumeMd.MqQueue) func() {
  93. return func() {
  94. begin := time.Now().Local()
  95. jobs[fnName](queue)
  96. end := time.Now().Local()
  97. logx.Infof(
  98. "[%s] AutoConsume started at <%s>, ended at <%s> duration <%s>",
  99. fnName,
  100. begin.Format("2006-01-02 15:04:05.000"),
  101. end.Format("2006-01-02 15:04:05.000"),
  102. time.Duration(end.UnixNano()-begin.UnixNano()).String(),
  103. )
  104. }
  105. }