rabbitmq.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. package initialize
  2. import (
  3. "encoding/base64"
  4. "fmt"
  5. "mtp20access/global"
  6. rsp "mtp20access/model/mq/response"
  7. "mtp20access/packet"
  8. "mtp20access/res/pb"
  9. "mtp20access/utils"
  10. "github.com/golang/protobuf/proto"
  11. "github.com/streadway/amqp"
  12. "go.uber.org/zap"
  13. "google.golang.org/protobuf/encoding/protojson"
  14. )
  15. func RabbitMQ() *global.RabbitMQ {
  16. url := global.M2A_CONFIG.Rabbitmq.Url
  17. connection, err := amqp.Dial(url)
  18. if err != nil {
  19. global.M2A_LOG.Error("rabbitmq connect failed, err:", zap.Error(err))
  20. return nil
  21. }
  22. channel, err := connection.Channel()
  23. if err != nil {
  24. global.M2A_LOG.Error("rabbitmq open channel failed, err:", zap.Error(err))
  25. return nil
  26. }
  27. global.M2A_LOG.Info("rabbitmq connect successed.")
  28. return &global.RabbitMQ{
  29. Connection: connection,
  30. Channel: channel,
  31. }
  32. }
  33. // MQProc 消息处理对象
  34. type MQProc struct{}
  35. // process 消息处理接口
  36. func (t *MQProc) Process(topic, queuename string, msg *[]byte) {
  37. // info := fmt.Sprintf("rabbitmq receive message from: topic[%s] queue[%s] contentLen[%d]",
  38. // topic,
  39. // queuename,
  40. // len(string(*msg)))
  41. // global.M2A_LOG.Info(info)
  42. if funcode, sessionId, bytes, serialNumber, err := t.getRspProtobuf(msg); err == nil && bytes != nil {
  43. // 尝试获取对应异步任务
  44. if client, exists := global.M2A_Clients[int(sessionId)]; exists {
  45. key := fmt.Sprintf("%v_%v_%v", sessionId, funcode, serialNumber)
  46. // 银行服务相关的回复流水号是错误的,所以需要特殊处理
  47. if int(funcode) == global.T2bBankSignRsp ||
  48. int(funcode) == global.T2bBankCancelSignRsp ||
  49. int(funcode) == global.T2bBankWithdrawRsp ||
  50. int(funcode) == global.T2bBankDepositRsp {
  51. key = fmt.Sprintf("%v_%v", sessionId, funcode)
  52. }
  53. asyncTask := client.GetAsyncTask(key)
  54. if asyncTask != nil {
  55. rspData := string(*bytes)
  56. // 判断是否要加密
  57. if asyncTask.IsEncrypted {
  58. if b, err := packet.Encrypt(*bytes, packet.AESKey, true); err != nil {
  59. global.M2A_LOG.Error("总线回复数据加密失败", zap.Error(err))
  60. return
  61. } else {
  62. rspData = base64.StdEncoding.EncodeToString(b)
  63. }
  64. }
  65. // 给客户端回调
  66. global.M2A_LOG.Info("[S->C]", zap.Any("rsp", funcode), zap.Any("data", string(rspData)))
  67. r := rsp.MQBodyRsp{
  68. FunCode: funcode,
  69. IsEncrypted: asyncTask.IsEncrypted,
  70. Data: rspData,
  71. }
  72. asyncTask.Rsp <- r
  73. } else {
  74. global.M2A_LOG.Info("找不到对应KEY的异步任务", zap.Any("key", key), zap.Any("AsyncMap", client.GetAllAsyncTask()))
  75. }
  76. }
  77. }
  78. }
  79. // getRspProtobuf 将总线回复的数据反序列化为Protobuf
  80. func (t *MQProc) getRspProtobuf(msg *[]byte) (funcode uint32, sessionId uint32, bytes *[]byte, serialNumber uint32, err error) {
  81. // 分解总线包信息
  82. funcode = utils.BytesToUint32((*msg)[0:4])
  83. sessionId = utils.BytesToUint32((*msg)[4:8])
  84. b := (*msg)[8:]
  85. global.M2A_LOG.Info("收到总线订阅消息", zap.Any("funcode", funcode), zap.Any("sessionId", sessionId), zap.Any("len", len(b)))
  86. switch int(funcode) {
  87. case global.ModifyPwdRsp: // 修改账户密码应答
  88. var p pb.ModifyPwdRsp
  89. if err = proto.Unmarshal(b, &p); err != nil {
  90. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  91. return
  92. }
  93. if bs, e := protojson.Marshal(&p); e != nil {
  94. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  95. return
  96. } else {
  97. bytes = &bs
  98. serialNumber = p.GetHeader().GetRequestID()
  99. }
  100. case global.UserReceiveInfoRsp: // 新增修改收货地址请求响应
  101. var p pb.UserReceiveInfoRsp
  102. if err = proto.Unmarshal(b, &p); err != nil {
  103. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  104. return
  105. }
  106. if bs, e := protojson.Marshal(&p); e != nil {
  107. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  108. return
  109. } else {
  110. bytes = &bs
  111. serialNumber = p.GetHeader().GetRequestID()
  112. }
  113. case global.DelUserReceiveInfoRsp: // 删除收货地址请求响应
  114. var p pb.DelUserReceiveInfoRsp
  115. if err = proto.Unmarshal(b, &p); err != nil {
  116. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  117. return
  118. }
  119. if bs, e := protojson.Marshal(&p); e != nil {
  120. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  121. return
  122. } else {
  123. bytes = &bs
  124. serialNumber = p.GetHeader().GetRequestID()
  125. }
  126. case global.UserReceiptInfoRsp: // 新增修改用户发票信息请求响应
  127. var p pb.UserReceiptInfoRsp
  128. if err = proto.Unmarshal(b, &p); err != nil {
  129. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  130. return
  131. }
  132. if bs, e := protojson.Marshal(&p); e != nil {
  133. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  134. return
  135. } else {
  136. bytes = &bs
  137. serialNumber = p.GetHeader().GetRequestID()
  138. }
  139. case global.DelUserReceiptInfoRsp: // 删除用户发票信息请求响应
  140. var p pb.DelUserReceiptInfoRsp
  141. if err = proto.Unmarshal(b, &p); err != nil {
  142. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  143. return
  144. }
  145. if bs, e := protojson.Marshal(&p); e != nil {
  146. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  147. return
  148. } else {
  149. bytes = &bs
  150. serialNumber = p.GetHeader().GetRequestID()
  151. }
  152. case global.T2bBankSignRsp: // 签约应答
  153. var p pb.T2BBankSignRsp
  154. if err = proto.Unmarshal(b, &p); err != nil {
  155. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  156. return
  157. }
  158. if bs, e := protojson.Marshal(&p); e != nil {
  159. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  160. return
  161. } else {
  162. bytes = &bs
  163. serialNumber = p.GetHeader().GetRequestID()
  164. }
  165. case global.T2bBankCancelSignRsp: // 解约应答
  166. var p pb.T2BBankCancelSignRsp
  167. if err = proto.Unmarshal(b, &p); err != nil {
  168. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  169. return
  170. }
  171. if bs, e := protojson.Marshal(&p); e != nil {
  172. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  173. return
  174. } else {
  175. bytes = &bs
  176. serialNumber = p.GetHeader().GetRequestID()
  177. }
  178. case global.T2bBankWithdrawRsp: // 出金应答
  179. var p pb.T2BBankWithdrawRsp
  180. if err = proto.Unmarshal(b, &p); err != nil {
  181. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  182. return
  183. }
  184. if bs, e := protojson.Marshal(&p); e != nil {
  185. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  186. return
  187. } else {
  188. bytes = &bs
  189. serialNumber = p.GetHeader().GetRequestID()
  190. }
  191. case global.T2bBankDepositRsp: // 入金应答
  192. var p pb.T2BBankDepositRsp
  193. if err = proto.Unmarshal(b, &p); err != nil {
  194. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  195. return
  196. }
  197. if bs, e := protojson.Marshal(&p); e != nil {
  198. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  199. return
  200. } else {
  201. bytes = &bs
  202. serialNumber = p.GetHeader().GetRequestID()
  203. }
  204. case global.WarehouseApplyRsp: // 仓库申请应答
  205. var p pb.WarehouseApplyRsp
  206. if err = proto.Unmarshal(b, &p); err != nil {
  207. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  208. return
  209. }
  210. if bs, e := protojson.Marshal(&p); e != nil {
  211. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  212. return
  213. } else {
  214. bytes = &bs
  215. serialNumber = p.GetHeader().GetRequestID()
  216. }
  217. case global.PerformanceContractedApplyRsp: // 违约申请应答
  218. var p pb.PerformanceContractedApplyRsp
  219. if err = proto.Unmarshal(b, &p); err != nil {
  220. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  221. return
  222. }
  223. if bs, e := protojson.Marshal(&p); e != nil {
  224. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  225. return
  226. } else {
  227. bytes = &bs
  228. serialNumber = p.GetHeader().GetRequestID()
  229. }
  230. case global.PerformanceDelayApplyRsp: // 延期申请应答
  231. var p pb.PerformanceDelayApplyRsp
  232. if err = proto.Unmarshal(b, &p); err != nil {
  233. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  234. return
  235. }
  236. if bs, e := protojson.Marshal(&p); e != nil {
  237. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  238. return
  239. } else {
  240. bytes = &bs
  241. serialNumber = p.GetHeader().GetRequestID()
  242. }
  243. case global.PerformanceManualConfirmRsp: // 履约手动确认应答
  244. var p pb.PerformanceManualConfirmRsp
  245. if err = proto.Unmarshal(b, &p); err != nil {
  246. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  247. return
  248. }
  249. if bs, e := protojson.Marshal(&p); e != nil {
  250. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  251. return
  252. } else {
  253. bytes = &bs
  254. serialNumber = p.GetHeader().GetRequestID()
  255. }
  256. case global.PerformanceModifyContactRsp: // 履约修改联络信息回应
  257. var p pb.PerformanceModifyContactRsp
  258. if err = proto.Unmarshal(b, &p); err != nil {
  259. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  260. return
  261. }
  262. if bs, e := protojson.Marshal(&p); e != nil {
  263. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  264. return
  265. } else {
  266. bytes = &bs
  267. serialNumber = p.GetHeader().GetRequestID()
  268. }
  269. case global.GoodsFavoriteOperateRsp: // 商品收藏操作接口应答
  270. var p pb.GoodsFavoriteOperateRsp
  271. if err = proto.Unmarshal(b, &p); err != nil {
  272. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  273. return
  274. }
  275. if bs, e := protojson.Marshal(&p); e != nil {
  276. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  277. return
  278. } else {
  279. bytes = &bs
  280. serialNumber = p.GetHeader().GetRequestID()
  281. }
  282. case global.ZSBuyOrderListingRsp: // 钻石买挂牌接口应答
  283. var p pb.ZSBuyOrderListingRsp
  284. if err = proto.Unmarshal(b, &p); err != nil {
  285. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  286. return
  287. }
  288. if bs, e := protojson.Marshal(&p); e != nil {
  289. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  290. return
  291. } else {
  292. bytes = &bs
  293. serialNumber = p.GetHeader().GetRequestID()
  294. }
  295. case global.ZSSellOrderListingRsp: // 钻石卖挂牌接口响应
  296. var p pb.ZSSellOrderListingRsp
  297. if err = proto.Unmarshal(b, &p); err != nil {
  298. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  299. return
  300. }
  301. if bs, e := protojson.Marshal(&p); e != nil {
  302. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  303. return
  304. } else {
  305. bytes = &bs
  306. serialNumber = p.GetHeader().GetRequestID()
  307. }
  308. case global.ZSBuyOrderDestingRsp: // 钻石卖摘牌申请接口响应
  309. var p pb.ZSBuyOrderDestingRsp
  310. if err = proto.Unmarshal(b, &p); err != nil {
  311. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  312. return
  313. }
  314. if bs, e := protojson.Marshal(&p); e != nil {
  315. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  316. return
  317. } else {
  318. bytes = &bs
  319. serialNumber = p.GetHeader().GetRequestID()
  320. }
  321. case global.ZSSellOrderDestingApplyOperateRsp: // 钻石卖摘牌申请操作接口应答
  322. var p pb.ZSSellOrderDestingApplyOperateRsp
  323. if err = proto.Unmarshal(b, &p); err != nil {
  324. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  325. return
  326. }
  327. if bs, e := protojson.Marshal(&p); e != nil {
  328. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  329. return
  330. } else {
  331. bytes = &bs
  332. serialNumber = p.GetHeader().GetRequestID()
  333. }
  334. case global.ZSBuyOrderDestingNegPriceRsp: // 买摘牌询价接口应答
  335. var p pb.ZSBuyOrderDestingNegPriceRsp
  336. if err = proto.Unmarshal(b, &p); err != nil {
  337. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  338. return
  339. }
  340. if bs, e := protojson.Marshal(&p); e != nil {
  341. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  342. return
  343. } else {
  344. bytes = &bs
  345. serialNumber = p.GetHeader().GetRequestID()
  346. }
  347. case global.ZSBuyOrderDestingNegPriceOperateRsp: // 买摘牌询价操作接口应答
  348. var p pb.ZSBuyOrderDestingNegPriceOperateRsp
  349. if err = proto.Unmarshal(b, &p); err != nil {
  350. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  351. return
  352. }
  353. if bs, e := protojson.Marshal(&p); e != nil {
  354. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  355. return
  356. } else {
  357. bytes = &bs
  358. serialNumber = p.GetHeader().GetRequestID()
  359. }
  360. case global.WRListingCancelOrderRsp: // 挂牌撤单应答
  361. var p pb.WRListingCancelOrderRsp
  362. if err = proto.Unmarshal(b, &p); err != nil {
  363. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  364. return
  365. }
  366. if bs, e := protojson.Marshal(&p); e != nil {
  367. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  368. return
  369. } else {
  370. bytes = &bs
  371. serialNumber = p.GetHeader().GetRequestID()
  372. }
  373. case global.ReceiptZSOutApplyRsp: // 钻石出库申请接口响应
  374. var p pb.ReceiptZSOutApplyRsp
  375. if err = proto.Unmarshal(b, &p); err != nil {
  376. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  377. return
  378. }
  379. if bs, e := protojson.Marshal(&p); e != nil {
  380. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  381. return
  382. } else {
  383. bytes = &bs
  384. serialNumber = p.GetHeader().GetRequestID()
  385. }
  386. case global.SpotPresaleListingOrderRsp: // 铁合金现货预售挂牌接口应答
  387. var p pb.SpotPresaleListingOrderRsp
  388. if err = proto.Unmarshal(b, &p); err != nil {
  389. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  390. return
  391. }
  392. if bs, e := protojson.Marshal(&p); e != nil {
  393. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  394. return
  395. } else {
  396. bytes = &bs
  397. serialNumber = p.GetHeader().GetRequestID()
  398. }
  399. case global.CJJCMemberOperateRsp: // 出境检测会员操作响应
  400. var p pb.CJJCMemberOperateRsp
  401. if err = proto.Unmarshal(b, &p); err != nil {
  402. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  403. return
  404. }
  405. if bs, e := protojson.Marshal(&p); e != nil {
  406. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  407. return
  408. } else {
  409. bytes = &bs
  410. serialNumber = p.GetHeader().GetRequestID()
  411. }
  412. case global.BSFWMemberOperateRsp: // 保税服务会员操作响应
  413. var p pb.BSFWMemberOperateRsp
  414. if err = proto.Unmarshal(b, &p); err != nil {
  415. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  416. return
  417. }
  418. if bs, e := protojson.Marshal(&p); e != nil {
  419. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  420. return
  421. } else {
  422. bytes = &bs
  423. serialNumber = p.GetHeader().GetRequestID()
  424. }
  425. case global.AccountFundInfoRsp: // 账户资金信息响应
  426. var p pb.AccountFundInfoRsp
  427. if err = proto.Unmarshal(b, &p); err != nil {
  428. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  429. return
  430. }
  431. if bs, e := protojson.Marshal(&p); e != nil {
  432. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  433. return
  434. } else {
  435. bytes = &bs
  436. serialNumber = p.GetHeader().GetRequestID()
  437. }
  438. }
  439. return
  440. }
  441. // RabbitMQSubscribeTopic 订阅主题
  442. func RabbitMQSubscribeTopic() (err error) {
  443. // 订阅需要的总线响应主题
  444. if err = global.SubscribeTopic(global.TOPIC_RSP_QKERNEL); err != nil {
  445. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  446. return
  447. }
  448. if err = global.SubscribeTopic(global.TOPIC_MANAGE_RSP); err != nil {
  449. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  450. return
  451. }
  452. if err = global.SubscribeTopic(global.TOPIC_RSP_BANK); err != nil {
  453. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  454. return
  455. }
  456. if err = global.SubscribeTopic(global.TOPIC_RSP_MONEY); err != nil {
  457. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  458. return
  459. }
  460. if err = global.SubscribeTopic(global.TOPIC_PERFORMANCE_RSP); err != nil {
  461. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  462. return
  463. }
  464. if err = global.SubscribeTopic(global.TOPIC_WAREHOUSE_RECIEPT_RSP); err != nil {
  465. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  466. return
  467. }
  468. if err = global.SubscribeTopic(global.TOPIC_RSP_WAREHOUSE_TRADE); err != nil {
  469. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  470. return
  471. }
  472. if err = global.SubscribeTopic(global.TOPIC_RSP_WAREHOUSE_TRADE_GZ); err != nil {
  473. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  474. return
  475. }
  476. if err = global.SubscribeTopic(global.TOPIC_RSP_CJBS_TRADE_GZ); err != nil {
  477. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  478. return
  479. }
  480. // 铁合金
  481. if err = global.SubscribeTopic(global.TOPIC_RSP_WAREHOUSE_PRESALE_THJ); err != nil {
  482. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  483. return
  484. }
  485. if err = global.SubscribeTopic(global.TOPIC_MANAGER_THJ_NTF); err != nil {
  486. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  487. return
  488. }
  489. global.M2A_LOG.Info("rabbitmq subscribe topic successed.")
  490. return
  491. }
  492. // StartRabbitMQReceive 开始接收总线消息
  493. func StartRabbitMQReceive() {
  494. t := &MQProc{}
  495. go func() {
  496. for _, subinfo := range global.SubInfos {
  497. global.Receive(subinfo.Topic, subinfo.QueueName, t)
  498. }
  499. }()
  500. }
  501. // InitFuncodeTopic 初始化功能码主题MAP
  502. func InitFuncodeTopic() {
  503. if global.M2A_FuncodeTopic == nil {
  504. global.M2A_FuncodeTopic = make(map[string][]int)
  505. }
  506. global.M2A_FuncodeTopic[global.TOPIC_REQ_QKERNEL] = []int{
  507. global.ModifyPwdReq,
  508. }
  509. global.M2A_FuncodeTopic[global.TOPIC_MANAGE_REQ] = []int{
  510. global.UserReceiveInfoReq,
  511. global.DelUserReceiveInfoReq,
  512. global.UserReceiveIsDefaultReq,
  513. global.UserReceiptInfoReq,
  514. global.DelUserReceiptInfoReq,
  515. global.WarehouseApplyReq,
  516. }
  517. global.M2A_FuncodeTopic[global.TOPIC_REQ_BANK] = []int{
  518. global.T2bBankSignReq,
  519. global.T2bBankCancelSignReq,
  520. global.T2bBankWithdrawReq,
  521. global.T2bBankDepositReq,
  522. }
  523. global.M2A_FuncodeTopic[global.TOPIC_REQ_MONEY] = []int{
  524. global.AccountFundInfoReq,
  525. }
  526. global.M2A_FuncodeTopic[global.TOPIC_PERFORMANCE_REQ] = []int{
  527. global.PerformanceContractedApplyReq,
  528. global.PerformanceDelayApplyReq,
  529. global.PerformanceManualConfirmReq,
  530. global.PerformanceModifyContactReq,
  531. }
  532. global.M2A_FuncodeTopic[global.TOPIC_WAREHOUSE_RECIEPT] = []int{
  533. global.ReceiptZSOutApplyReq,
  534. }
  535. global.M2A_FuncodeTopic[global.TOPIC_REQ_WAREHOUSE_TRADE] = []int{
  536. global.WRListingCancelOrderReq,
  537. }
  538. global.M2A_FuncodeTopic[global.TOPIC_REQ_WAREHOUSE_TRADE_GZ] = []int{
  539. global.GoodsFavoriteOperateReq,
  540. global.ZSBuyOrderListingReq,
  541. global.ZSSellOrderListingReq,
  542. global.ZSBuyOrderDestingReq,
  543. global.ZSSellOrderDestingApplyReq,
  544. global.ZSSellOrderDestingApplyOperateReq,
  545. global.ZSBuyOrderDestingNegPriceReq,
  546. global.ZSBuyOrderDestingNegPriceOperateReq,
  547. }
  548. global.M2A_FuncodeTopic[global.TOPIC_REQ_CJBS_TRADE_GZ] = []int{
  549. global.CJJCMemberOperateReq,
  550. global.BSFWMemberOperateReq,
  551. }
  552. // 铁合金
  553. global.M2A_FuncodeTopic[global.TOPIC_REQ_WAREHOUSE_PRESALE_THJ] = []int{
  554. global.SpotPresaleListingOrderReq,
  555. }
  556. }