rabbitmq.go 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159
  1. package initialize
  2. import (
  3. "encoding/base64"
  4. "fmt"
  5. "mtp20access/client"
  6. "mtp20access/global"
  7. rsp "mtp20access/model/mq/response"
  8. "mtp20access/packet"
  9. "mtp20access/publish"
  10. "mtp20access/rabbitmq"
  11. "mtp20access/res/pb"
  12. accountSrv "mtp20access/service/account"
  13. "mtp20access/utils"
  14. "strconv"
  15. // "github.com/golang/protobuf/proto"
  16. "github.com/streadway/amqp"
  17. "go.uber.org/zap"
  18. "google.golang.org/protobuf/encoding/protojson"
  19. "google.golang.org/protobuf/proto"
  20. )
  21. func RabbitMQ() *global.RabbitMQ {
  22. url := global.M2A_CONFIG.Rabbitmq.Url
  23. connection, err := amqp.Dial(url)
  24. if err != nil {
  25. global.M2A_LOG.Error("rabbitmq connect failed, err:", zap.Error(err))
  26. return nil
  27. }
  28. channel, err := connection.Channel()
  29. if err != nil {
  30. global.M2A_LOG.Error("rabbitmq open channel failed, err:", zap.Error(err))
  31. return nil
  32. }
  33. global.M2A_LOG.Info("rabbitmq connect successed.")
  34. return &global.RabbitMQ{
  35. Connection: connection,
  36. Channel: channel,
  37. }
  38. }
  39. // MQProc 消息处理对象
  40. type MQProc struct{}
  41. // process 消息处理接口
  42. func (t *MQProc) Process(topic, queuename string, msg *[]byte) {
  43. info := fmt.Sprintf("rabbitmq receive message from: topic[%s] queue[%s] contentLen[%d]",
  44. topic,
  45. queuename,
  46. len(string(*msg)))
  47. global.M2A_LOG.Info(info)
  48. if funcode, sessionId, bytes, serialNumber, err := t.getRspProtobuf(msg); err == nil && bytes != nil {
  49. if sessionId == 0 || funcode == uint32(global.LogoutRsp) || funcode == uint32(global.LoginRsp) {
  50. // 通知类 或 特殊处理
  51. t.onNtf(funcode, sessionId, bytes)
  52. } else {
  53. // 请求回复
  54. // 尝试获取对应异步任务
  55. if c, exists := client.Clients[int(sessionId)]; exists {
  56. key := fmt.Sprintf("%v_%v_%v", sessionId, funcode, serialNumber)
  57. // 银行服务相关的回复流水号是错误的,所以需要特殊处理
  58. if int(funcode) == global.T2bBankSignRsp ||
  59. int(funcode) == global.T2bSMSVerificationCodeRsp ||
  60. int(funcode) == global.T2bBankCancelSignRsp ||
  61. int(funcode) == global.T2bBankWithdrawRsp ||
  62. int(funcode) == global.T2bBankDepositRsp {
  63. key = fmt.Sprintf("%v_%v", sessionId, funcode)
  64. }
  65. asyncTask := c.GetAsyncTask(key)
  66. if asyncTask != nil {
  67. rspData := string(*bytes)
  68. // 判断是否要加密
  69. if asyncTask.IsEncrypted {
  70. if b, err := packet.Encrypt(*bytes, packet.AESKey, true); err != nil {
  71. global.M2A_LOG.Error("总线回复数据加密失败", zap.Error(err))
  72. return
  73. } else {
  74. rspData = base64.StdEncoding.EncodeToString(b)
  75. }
  76. }
  77. // 给客户端回调
  78. global.M2A_LOG.Info("[S->C]", zap.Any("rsp", funcode), zap.Any("sessionId", sessionId), zap.Any("data", string(rspData)))
  79. r := rsp.MQBodyRsp{
  80. FunCode: funcode,
  81. IsEncrypted: asyncTask.IsEncrypted,
  82. Data: rspData,
  83. }
  84. asyncTask.Rsp <- r
  85. } else {
  86. global.M2A_LOG.Info("找不到对应KEY的异步任务", zap.Any("key", key), zap.Any("AsyncMap", c.GetAllAsyncTask()))
  87. global.M2A_LOG.Info("++++++++++++++ 当前的 Clients", zap.Any("client.Clients", client.Clients))
  88. global.M2A_LOG.Info("-------------- 当前的 AsyncTask", zap.Any("SessionId", c.SessionID), zap.Any("AsyncTask", c.GetAllAsyncTask()))
  89. }
  90. } else {
  91. global.M2A_LOG.Info("找不到对应的client", zap.Any("sessionId", sessionId))
  92. }
  93. }
  94. }
  95. }
  96. func (t *MQProc) onNtf(funcode uint32, sessionId uint32, bytes *[]byte) {
  97. var clients []*client.Client
  98. var err error
  99. var sendBytes *[]byte
  100. switch int(funcode) {
  101. case global.LoginRsp: // 用户登录应答 - 主要记录旧Token
  102. var p pb.LoginRsp
  103. if err = proto.Unmarshal(*bytes, &p); err != nil {
  104. global.M2A_LOG.Error("总线数据反序列化失败", zap.Error(err))
  105. return
  106. }
  107. // if bs, e := protojson.Marshal(&p); e != nil {
  108. // global.M2A_LOG.Error("总线数据反序列化失败", zap.Error(err))
  109. // return
  110. // } else {
  111. // sendBytes = &bs
  112. // }
  113. // 获取目标客户
  114. for i := range client.Clients {
  115. c := client.Clients[i]
  116. if strconv.Itoa(int(p.GetUserID())) == c.UserID &&
  117. strconv.Itoa(int(sessionId)) == c.SessionID {
  118. // 主要记录旧Token
  119. c.OldToken = p.GetToken()
  120. }
  121. }
  122. case global.LogoutRsp: // 用户登出应答 - 主要用于接收管理端踢上线
  123. var p pb.LogoutRsp
  124. if err = proto.Unmarshal(*bytes, &p); err != nil {
  125. global.M2A_LOG.Error("总线数据反序列化失败", zap.Error(err))
  126. return
  127. }
  128. if bs, e := protojson.Marshal(&p); e != nil {
  129. global.M2A_LOG.Error("总线数据序列化JSON失败", zap.Error(err))
  130. return
  131. } else {
  132. sendBytes = &bs
  133. }
  134. // 获取目标客户
  135. clients = make([]*client.Client, 0)
  136. for i := range client.Clients {
  137. c := client.Clients[i]
  138. if strconv.Itoa(int(p.GetHeader().GetUserID())) == c.UserID {
  139. clients = append(clients, c)
  140. }
  141. }
  142. case global.MoneyChangedNtf: // 资金变化通知
  143. var p pb.MoneyChangedNtf
  144. if err = proto.Unmarshal(*bytes, &p); err != nil {
  145. global.M2A_LOG.Error("总线数据反序列化失败", zap.Error(err))
  146. return
  147. }
  148. if bs, e := protojson.Marshal(&p); e != nil {
  149. global.M2A_LOG.Error("总线数据序列化JSON失败", zap.Error(err))
  150. return
  151. } else {
  152. sendBytes = &bs
  153. }
  154. // 获取目标客户
  155. clients, err = accountSrv.GetClientsByAccountID(*p.AccountID)
  156. if err != nil {
  157. return
  158. }
  159. case global.PosChangedNtf: // 头寸变化通知
  160. var p pb.PosChangedNtf
  161. if err = proto.Unmarshal(*bytes, &p); err != nil {
  162. global.M2A_LOG.Error("总线数据反序列化失败", zap.Error(err))
  163. return
  164. }
  165. if bs, e := protojson.Marshal(&p); e != nil {
  166. global.M2A_LOG.Error("总线数据序列化JSON失败", zap.Error(err))
  167. return
  168. } else {
  169. sendBytes = &bs
  170. }
  171. // global.M2A_LOG.Info("接收 PosChangedNtf", zap.Any("ntf", funcode), zap.Any("AccountID", *p.AccountID))
  172. // global.M2A_LOG.Info("当前的 Clients", zap.Any("ntf", funcode), zap.Any("client.Clients", client.Clients))
  173. // 获取目标客户
  174. clients, err = accountSrv.GetClientsByAccountID(*p.AccountID)
  175. global.M2A_LOG.Info("找到对应的clients", zap.Any("ntf", funcode), zap.Any("clients", clients))
  176. if err != nil {
  177. global.M2A_LOG.Info(fmt.Sprintf("接收头寸变化通知时获取不到对应Client,AccountID:%v", *p.AccountID))
  178. return
  179. }
  180. case global.OrderDealedNtf: // 委托单成交通知
  181. var p pb.OrderDealedNtf
  182. if err = proto.Unmarshal(*bytes, &p); err != nil {
  183. global.M2A_LOG.Error("总线数据反序列化失败", zap.Error(err))
  184. return
  185. }
  186. if bs, e := protojson.Marshal(&p); e != nil {
  187. global.M2A_LOG.Error("总线数据序列化JSON失败", zap.Error(err))
  188. return
  189. } else {
  190. sendBytes = &bs
  191. }
  192. // 获取目标客户
  193. clients, err = accountSrv.GetClientsByAccountID(*p.AccountID)
  194. if err != nil {
  195. return
  196. }
  197. case global.MarketStatusChangeNtf: // 市场状态变更通知
  198. var p pb.MarketStatusChangeNtf
  199. if err = proto.Unmarshal(*bytes, &p); err != nil {
  200. global.M2A_LOG.Error("总线数据反序列化失败", zap.Error(err))
  201. return
  202. }
  203. if bs, e := protojson.Marshal(&p); e != nil {
  204. global.M2A_LOG.Error("总线数据序列化JSON失败", zap.Error(err))
  205. return
  206. } else {
  207. sendBytes = &bs
  208. }
  209. // 获取目标客户
  210. clients = make([]*client.Client, 0)
  211. for i := range client.Clients {
  212. c := client.Clients[i]
  213. clients = append(clients, c)
  214. }
  215. case global.OrderCanceledNtf: // 委托单撤消通知
  216. var p pb.OrderCanceledNtf
  217. if err = proto.Unmarshal(*bytes, &p); err != nil {
  218. global.M2A_LOG.Error("总线数据反序列化失败", zap.Error(err))
  219. return
  220. }
  221. if bs, e := protojson.Marshal(&p); e != nil {
  222. global.M2A_LOG.Error("总线数据序列化JSON失败", zap.Error(err))
  223. return
  224. } else {
  225. sendBytes = &bs
  226. }
  227. // 获取目标客户
  228. clients = make([]*client.Client, 0)
  229. for i := range client.Clients {
  230. c := client.Clients[i]
  231. if strconv.Itoa(int(p.GetHeader().GetUserID())) == c.UserID {
  232. clients = append(clients, c)
  233. }
  234. }
  235. case global.ListingOrderChangeNtf: // 挂牌委托变更广播通知
  236. var p pb.ListingOrderChangeNtf
  237. if err = proto.Unmarshal(*bytes, &p); err != nil {
  238. global.M2A_LOG.Error("总线数据反序列化失败", zap.Error(err))
  239. return
  240. }
  241. if bs, e := protojson.Marshal(&p); e != nil {
  242. global.M2A_LOG.Error("总线数据序列化JSON失败", zap.Error(err))
  243. return
  244. } else {
  245. sendBytes = &bs
  246. }
  247. // 获取目标客户
  248. clients = make([]*client.Client, 0)
  249. for i := range client.Clients {
  250. c := client.Clients[i]
  251. clients = append(clients, c)
  252. }
  253. }
  254. if err == nil && len(clients) > 0 {
  255. // 组装待发送给客户端的5.0报文包
  256. b, err := packet.BuildPacket(funcode, 0, 0, *sendBytes, true)
  257. if err != nil {
  258. global.M2A_LOG.Error("组装5.0报文失败", zap.Error(err))
  259. return
  260. }
  261. // 发送信息
  262. for _, item := range clients {
  263. // c := clients[i]
  264. sessionId, _ := strconv.Atoi(item.SessionID)
  265. c := client.Clients[sessionId]
  266. // c.WriteTradeWsBuf(b)
  267. // 给客户端通知
  268. global.M2A_LOG.Info("[S->C]给客户端通知", zap.Any("ntf", funcode), zap.Any("clients", c.LoginID), zap.Any("SessionID", c.SessionID), zap.Any("len", len(b)))
  269. // 分发给订阅者
  270. m := make(map[string][]byte)
  271. m[item.SessionID] = b
  272. global.M2A_Publish.Publish(publish.Topic_Trading, m)
  273. }
  274. }
  275. }
  276. // getRspProtobuf 将总线回复的数据反序列化为Protobuf
  277. func (t *MQProc) getRspProtobuf(msg *[]byte) (funcode uint32, sessionId uint32, bytes *[]byte, serialNumber uint32, err error) {
  278. // 分解总线包信息
  279. funcode = utils.BytesToUint32((*msg)[0:4])
  280. sessionId = utils.BytesToUint32((*msg)[4:8])
  281. b := (*msg)[8:]
  282. global.M2A_LOG.Info("收到总线消息", zap.Any("funcode", funcode), zap.Any("sessionId", sessionId), zap.Any("len", len(b)))
  283. switch int(funcode) {
  284. case global.PosChangedNtf,
  285. global.MoneyChangedNtf,
  286. global.OrderDealedNtf,
  287. global.MarketStatusChangeNtf,
  288. global.OrderCanceledNtf,
  289. global.LoginRsp,
  290. global.LogoutRsp,
  291. global.ListingOrderChangeNtf: // 资金变化通知等
  292. // global.M2A_LOG.Info("进入通知逻辑----------", zap.Any("funcode", funcode), zap.Any("sessionId", sessionId))
  293. bytes = &b
  294. case global.ModifyPwdRsp: // 修改账户密码应答
  295. var p pb.ModifyPwdRsp
  296. if err = proto.Unmarshal(b, &p); err != nil {
  297. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  298. return
  299. }
  300. if bs, e := protojson.Marshal(&p); e != nil {
  301. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  302. return
  303. } else {
  304. bytes = &bs
  305. serialNumber = p.GetHeader().GetRequestID()
  306. }
  307. case global.UserReceiveInfoRsp: // 新增修改收货地址请求响应
  308. var p pb.UserReceiveInfoRsp
  309. if err = proto.Unmarshal(b, &p); err != nil {
  310. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  311. return
  312. }
  313. if bs, e := protojson.Marshal(&p); e != nil {
  314. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  315. return
  316. } else {
  317. bytes = &bs
  318. serialNumber = p.GetHeader().GetRequestID()
  319. }
  320. case global.DelUserReceiveInfoRsp: // 删除收货地址请求响应
  321. var p pb.DelUserReceiveInfoRsp
  322. if err = proto.Unmarshal(b, &p); err != nil {
  323. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  324. return
  325. }
  326. if bs, e := protojson.Marshal(&p); e != nil {
  327. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  328. return
  329. } else {
  330. bytes = &bs
  331. serialNumber = p.GetHeader().GetRequestID()
  332. }
  333. case global.UserReceiveIsDefaultRsp:
  334. var p pb.UserReceiveIsDefaultRsp
  335. if err = proto.Unmarshal(b, &p); err != nil {
  336. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  337. return
  338. }
  339. if bs, e := protojson.Marshal(&p); e != nil {
  340. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  341. return
  342. } else {
  343. bytes = &bs
  344. serialNumber = p.GetHeader().GetRequestID()
  345. }
  346. case global.UserReceiptInfoRsp: // 新增修改用户发票信息请求响应
  347. var p pb.UserReceiptInfoRsp
  348. if err = proto.Unmarshal(b, &p); err != nil {
  349. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  350. return
  351. }
  352. if bs, e := protojson.Marshal(&p); e != nil {
  353. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  354. return
  355. } else {
  356. bytes = &bs
  357. serialNumber = p.GetHeader().GetRequestID()
  358. }
  359. case global.DelUserReceiptInfoRsp: // 删除用户发票信息请求响应
  360. var p pb.DelUserReceiptInfoRsp
  361. if err = proto.Unmarshal(b, &p); err != nil {
  362. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  363. return
  364. }
  365. if bs, e := protojson.Marshal(&p); e != nil {
  366. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  367. return
  368. } else {
  369. bytes = &bs
  370. serialNumber = p.GetHeader().GetRequestID()
  371. }
  372. case global.T2bBankSignRsp: // 签约应答
  373. var p pb.T2BBankSignRsp
  374. if err = proto.Unmarshal(b, &p); err != nil {
  375. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  376. return
  377. }
  378. if bs, e := protojson.Marshal(&p); e != nil {
  379. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  380. return
  381. } else {
  382. bytes = &bs
  383. serialNumber = p.GetHeader().GetRequestID()
  384. }
  385. case global.T2bSMSVerificationCodeRsp:
  386. var p pb.T2BSMSVerificationCodeRsp
  387. if err = proto.Unmarshal(b, &p); err != nil {
  388. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  389. return
  390. }
  391. if bs, e := protojson.Marshal(&p); e != nil {
  392. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  393. return
  394. } else {
  395. bytes = &bs
  396. serialNumber = p.GetHeader().GetRequestID()
  397. }
  398. case global.T2bBankCancelSignRsp: // 解约应答
  399. var p pb.T2BBankCancelSignRsp
  400. if err = proto.Unmarshal(b, &p); err != nil {
  401. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  402. return
  403. }
  404. if bs, e := protojson.Marshal(&p); e != nil {
  405. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  406. return
  407. } else {
  408. bytes = &bs
  409. serialNumber = p.GetHeader().GetRequestID()
  410. }
  411. case global.T2bBankWithdrawRsp: // 出金应答
  412. var p pb.T2BBankWithdrawRsp
  413. if err = proto.Unmarshal(b, &p); err != nil {
  414. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  415. return
  416. }
  417. if bs, e := protojson.Marshal(&p); e != nil {
  418. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  419. return
  420. } else {
  421. bytes = &bs
  422. serialNumber = p.GetHeader().GetRequestID()
  423. }
  424. case global.T2bBankDepositRsp: // 入金应答
  425. var p pb.T2BBankDepositRsp
  426. if err = proto.Unmarshal(b, &p); err != nil {
  427. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  428. return
  429. }
  430. if bs, e := protojson.Marshal(&p); e != nil {
  431. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  432. return
  433. } else {
  434. bytes = &bs
  435. serialNumber = p.GetHeader().GetRequestID()
  436. }
  437. case global.WarehouseApplyRsp: // 仓库申请应答
  438. var p pb.WarehouseApplyRsp
  439. if err = proto.Unmarshal(b, &p); err != nil {
  440. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  441. return
  442. }
  443. if bs, e := protojson.Marshal(&p); e != nil {
  444. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  445. return
  446. } else {
  447. bytes = &bs
  448. serialNumber = p.GetHeader().GetRequestID()
  449. }
  450. case global.PerformanceContractedApplyRsp: // 违约申请应答
  451. var p pb.PerformanceContractedApplyRsp
  452. if err = proto.Unmarshal(b, &p); err != nil {
  453. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  454. return
  455. }
  456. if bs, e := protojson.Marshal(&p); e != nil {
  457. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  458. return
  459. } else {
  460. bytes = &bs
  461. serialNumber = p.GetHeader().GetRequestID()
  462. }
  463. case global.PerformanceDelayApplyRsp: // 延期申请应答
  464. var p pb.PerformanceDelayApplyRsp
  465. if err = proto.Unmarshal(b, &p); err != nil {
  466. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  467. return
  468. }
  469. if bs, e := protojson.Marshal(&p); e != nil {
  470. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  471. return
  472. } else {
  473. bytes = &bs
  474. serialNumber = p.GetHeader().GetRequestID()
  475. }
  476. case global.PerformanceManualConfirmRsp: // 履约手动确认应答
  477. var p pb.PerformanceManualConfirmRsp
  478. if err = proto.Unmarshal(b, &p); err != nil {
  479. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  480. return
  481. }
  482. if bs, e := protojson.Marshal(&p); e != nil {
  483. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  484. return
  485. } else {
  486. bytes = &bs
  487. serialNumber = p.GetHeader().GetRequestID()
  488. }
  489. case global.PerformanceModifyContactRsp: // 履约修改联络信息回应
  490. var p pb.PerformanceModifyContactRsp
  491. if err = proto.Unmarshal(b, &p); err != nil {
  492. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  493. return
  494. }
  495. if bs, e := protojson.Marshal(&p); e != nil {
  496. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  497. return
  498. } else {
  499. bytes = &bs
  500. serialNumber = p.GetHeader().GetRequestID()
  501. }
  502. case global.GoodsFavoriteOperateRsp: // 商品收藏操作接口应答
  503. var p pb.GoodsFavoriteOperateRsp
  504. if err = proto.Unmarshal(b, &p); err != nil {
  505. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  506. return
  507. }
  508. if bs, e := protojson.Marshal(&p); e != nil {
  509. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  510. return
  511. } else {
  512. bytes = &bs
  513. serialNumber = p.GetHeader().GetRequestID()
  514. }
  515. case global.ZSBuyOrderListingRsp: // 钻石买挂牌接口应答
  516. var p pb.ZSBuyOrderListingRsp
  517. if err = proto.Unmarshal(b, &p); err != nil {
  518. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  519. return
  520. }
  521. if bs, e := protojson.Marshal(&p); e != nil {
  522. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  523. return
  524. } else {
  525. bytes = &bs
  526. serialNumber = p.GetHeader().GetRequestID()
  527. }
  528. case global.ZSSellOrderListingRsp: // 钻石卖挂牌接口响应
  529. var p pb.ZSSellOrderListingRsp
  530. if err = proto.Unmarshal(b, &p); err != nil {
  531. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  532. return
  533. }
  534. if bs, e := protojson.Marshal(&p); e != nil {
  535. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  536. return
  537. } else {
  538. bytes = &bs
  539. serialNumber = p.GetHeader().GetRequestID()
  540. }
  541. case global.ZSBuyOrderDestingRsp: // 钻石卖摘牌申请接口响应
  542. var p pb.ZSBuyOrderDestingRsp
  543. if err = proto.Unmarshal(b, &p); err != nil {
  544. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  545. return
  546. }
  547. if bs, e := protojson.Marshal(&p); e != nil {
  548. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  549. return
  550. } else {
  551. bytes = &bs
  552. serialNumber = p.GetHeader().GetRequestID()
  553. }
  554. case global.ZSSellOrderDestingApplyOperateRsp: // 钻石卖摘牌申请操作接口应答
  555. var p pb.ZSSellOrderDestingApplyOperateRsp
  556. if err = proto.Unmarshal(b, &p); err != nil {
  557. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  558. return
  559. }
  560. if bs, e := protojson.Marshal(&p); e != nil {
  561. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  562. return
  563. } else {
  564. bytes = &bs
  565. serialNumber = p.GetHeader().GetRequestID()
  566. }
  567. case global.ZSBuyOrderDestingNegPriceRsp: // 买摘牌询价接口应答
  568. var p pb.ZSBuyOrderDestingNegPriceRsp
  569. if err = proto.Unmarshal(b, &p); err != nil {
  570. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  571. return
  572. }
  573. if bs, e := protojson.Marshal(&p); e != nil {
  574. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  575. return
  576. } else {
  577. bytes = &bs
  578. serialNumber = p.GetHeader().GetRequestID()
  579. }
  580. case global.ZSBuyOrderDestingNegPriceOperateRsp: // 买摘牌询价操作接口应答
  581. var p pb.ZSBuyOrderDestingNegPriceOperateRsp
  582. if err = proto.Unmarshal(b, &p); err != nil {
  583. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  584. return
  585. }
  586. if bs, e := protojson.Marshal(&p); e != nil {
  587. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  588. return
  589. } else {
  590. bytes = &bs
  591. serialNumber = p.GetHeader().GetRequestID()
  592. }
  593. case global.WRListingCancelOrderRsp: // 挂牌撤单应答
  594. var p pb.WRListingCancelOrderRsp
  595. if err = proto.Unmarshal(b, &p); err != nil {
  596. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  597. return
  598. }
  599. if bs, e := protojson.Marshal(&p); e != nil {
  600. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  601. return
  602. } else {
  603. bytes = &bs
  604. serialNumber = p.GetHeader().GetRequestID()
  605. }
  606. case global.HdWROrderRsp:
  607. var p pb.HdWROrderRsp
  608. if err = proto.Unmarshal(b, &p); err != nil {
  609. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  610. return
  611. }
  612. if bs, e := protojson.Marshal(&p); e != nil {
  613. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  614. return
  615. } else {
  616. bytes = &bs
  617. serialNumber = p.GetHeader().GetRequestID()
  618. }
  619. case global.WROutApplyRsp:
  620. var p pb.WROutApplyRsp
  621. if err = proto.Unmarshal(b, &p); err != nil {
  622. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  623. return
  624. }
  625. if bs, e := protojson.Marshal(&p); e != nil {
  626. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  627. return
  628. } else {
  629. bytes = &bs
  630. serialNumber = p.GetHeader().GetRequestID()
  631. }
  632. case global.ReceiptZSOutApplyRsp: // 钻石出库申请接口响应
  633. var p pb.ReceiptZSOutApplyRsp
  634. if err = proto.Unmarshal(b, &p); err != nil {
  635. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  636. return
  637. }
  638. if bs, e := protojson.Marshal(&p); e != nil {
  639. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  640. return
  641. } else {
  642. bytes = &bs
  643. serialNumber = p.GetHeader().GetRequestID()
  644. }
  645. case global.SpotPresaleListingOrderRsp: // 铁合金现货预售挂牌接口应答
  646. var p pb.SpotPresaleListingOrderRsp
  647. if err = proto.Unmarshal(b, &p); err != nil {
  648. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  649. return
  650. }
  651. if bs, e := protojson.Marshal(&p); e != nil {
  652. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  653. return
  654. } else {
  655. bytes = &bs
  656. serialNumber = p.GetHeader().GetRequestID()
  657. }
  658. case global.CJJCMemberOperateRsp: // 出境检测会员操作响应
  659. var p pb.CJJCMemberOperateRsp
  660. if err = proto.Unmarshal(b, &p); err != nil {
  661. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  662. return
  663. }
  664. if bs, e := protojson.Marshal(&p); e != nil {
  665. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  666. return
  667. } else {
  668. bytes = &bs
  669. serialNumber = p.GetHeader().GetRequestID()
  670. }
  671. case global.BSFWMemberOperateRsp: // 保税服务会员操作响应
  672. var p pb.BSFWMemberOperateRsp
  673. if err = proto.Unmarshal(b, &p); err != nil {
  674. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  675. return
  676. }
  677. if bs, e := protojson.Marshal(&p); e != nil {
  678. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  679. return
  680. } else {
  681. bytes = &bs
  682. serialNumber = p.GetHeader().GetRequestID()
  683. }
  684. case global.AccountFundInfoRsp: // 账户资金信息响应
  685. var p pb.AccountFundInfoRsp
  686. if err = proto.Unmarshal(b, &p); err != nil {
  687. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  688. return
  689. }
  690. if bs, e := protojson.Marshal(&p); e != nil {
  691. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  692. return
  693. } else {
  694. bytes = &bs
  695. serialNumber = p.GetHeader().GetRequestID()
  696. }
  697. case global.GZPresaleApplyRsp: // 广钻预售申请响应
  698. var p pb.GZPresaleApplyRsp
  699. if err = proto.Unmarshal(b, &p); err != nil {
  700. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  701. return
  702. }
  703. if bs, e := protojson.Marshal(&p); e != nil {
  704. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  705. return
  706. } else {
  707. bytes = &bs
  708. serialNumber = p.GetHeader().GetRequestID()
  709. }
  710. case global.GZPresaleOrderRsp: // 广钻预售认购下单响应
  711. var p pb.GZPresaleOrderRsp
  712. if err = proto.Unmarshal(b, &p); err != nil {
  713. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  714. return
  715. }
  716. if bs, e := protojson.Marshal(&p); e != nil {
  717. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  718. return
  719. } else {
  720. bytes = &bs
  721. serialNumber = p.GetHeader().GetRequestID()
  722. }
  723. case global.GZCenterPurchaseApplyRsp: // 广钻集采申请响应
  724. var p pb.GZCenterPurchaseApplyRsp
  725. if err = proto.Unmarshal(b, &p); err != nil {
  726. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  727. return
  728. }
  729. if bs, e := protojson.Marshal(&p); e != nil {
  730. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  731. return
  732. } else {
  733. bytes = &bs
  734. serialNumber = p.GetHeader().GetRequestID()
  735. }
  736. case global.GZCenterPurchaseOrderRsp: // 广钻集采认购下单响应
  737. var p pb.GZCenterPurchaseOrderRsp
  738. if err = proto.Unmarshal(b, &p); err != nil {
  739. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  740. return
  741. }
  742. if bs, e := protojson.Marshal(&p); e != nil {
  743. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  744. return
  745. } else {
  746. bytes = &bs
  747. serialNumber = p.GetHeader().GetRequestID()
  748. }
  749. case global.BSWMSReckonPayRsp: // WMS结算单支付接口响应
  750. var p pb.BSWMSReckonPayRsp
  751. if err = proto.Unmarshal(b, &p); err != nil {
  752. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  753. return
  754. }
  755. if bs, e := protojson.Marshal(&p); e != nil {
  756. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  757. return
  758. } else {
  759. bytes = &bs
  760. serialNumber = p.GetHeader().GetRequestID()
  761. }
  762. case global.OrderRsp:
  763. var p pb.OrderRsp
  764. if err = proto.Unmarshal(b, &p); err != nil {
  765. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  766. return
  767. }
  768. if bs, e := protojson.Marshal(&p); e != nil {
  769. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  770. return
  771. } else {
  772. bytes = &bs
  773. serialNumber = p.GetHeader().GetRequestID()
  774. }
  775. case global.OfflineDeliveryApplyCancelOrderRsp:
  776. var p pb.OfflineDeliveryApplyCancelOrderRsp
  777. if err = proto.Unmarshal(b, &p); err != nil {
  778. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  779. return
  780. }
  781. if bs, e := protojson.Marshal(&p); e != nil {
  782. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  783. return
  784. } else {
  785. bytes = &bs
  786. serialNumber = p.GetHeader().GetRequestID()
  787. }
  788. case global.CancelOrderRsp:
  789. var p pb.CancelOrderRsp
  790. if err = proto.Unmarshal(b, &p); err != nil {
  791. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  792. return
  793. }
  794. if bs, e := protojson.Marshal(&p); e != nil {
  795. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  796. return
  797. } else {
  798. bytes = &bs
  799. serialNumber = p.GetHeader().GetRequestID()
  800. }
  801. case global.HolderCloseRsp:
  802. var p pb.HolderCloseRsp
  803. if err = proto.Unmarshal(b, &p); err != nil {
  804. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  805. return
  806. }
  807. if bs, e := protojson.Marshal(&p); e != nil {
  808. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  809. return
  810. } else {
  811. bytes = &bs
  812. serialNumber = p.GetHeader().GetRequestID()
  813. }
  814. case global.DeliveryOrderRsp:
  815. var p pb.DeliveryOrderRsp
  816. if err = proto.Unmarshal(b, &p); err != nil {
  817. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  818. return
  819. }
  820. if bs, e := protojson.Marshal(&p); e != nil {
  821. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  822. return
  823. } else {
  824. bytes = &bs
  825. serialNumber = p.GetHeader().GetRequestID()
  826. }
  827. case global.MakeUpDepositRsp:
  828. var p pb.MakeUpDepositRsp
  829. if err = proto.Unmarshal(b, &p); err != nil {
  830. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  831. return
  832. }
  833. if bs, e := protojson.Marshal(&p); e != nil {
  834. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  835. return
  836. } else {
  837. bytes = &bs
  838. serialNumber = p.GetHeader().GetRequestID()
  839. }
  840. case global.HoldAppendDepositRsp:
  841. var p pb.HoldAppendDepositRsp
  842. if err = proto.Unmarshal(b, &p); err != nil {
  843. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  844. return
  845. }
  846. if bs, e := protojson.Marshal(&p); e != nil {
  847. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  848. return
  849. } else {
  850. bytes = &bs
  851. serialNumber = p.GetHeader().GetRequestID()
  852. }
  853. case global.OfflineDeliveryRsp:
  854. var p pb.OfflineDeliveryRsp
  855. if err = proto.Unmarshal(b, &p); err != nil {
  856. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  857. return
  858. }
  859. if bs, e := protojson.Marshal(&p); e != nil {
  860. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  861. return
  862. } else {
  863. bytes = &bs
  864. serialNumber = p.GetHeader().GetRequestID()
  865. }
  866. case global.HdWRDealOrderRsp:
  867. var p pb.HdWRDealOrderRsp
  868. if err = proto.Unmarshal(b, &p); err != nil {
  869. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  870. return
  871. }
  872. if bs, e := protojson.Marshal(&p); e != nil {
  873. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  874. return
  875. } else {
  876. bytes = &bs
  877. serialNumber = p.GetHeader().GetRequestID()
  878. }
  879. case global.SupplementDepositRsp:
  880. var p pb.SupplementDepositRsp
  881. if err = proto.Unmarshal(b, &p); err != nil {
  882. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  883. return
  884. }
  885. if bs, e := protojson.Marshal(&p); e != nil {
  886. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  887. return
  888. } else {
  889. bytes = &bs
  890. serialNumber = p.GetHeader().GetRequestID()
  891. }
  892. case global.RefundedDepositRsp:
  893. var p pb.RefundedDepositRsp
  894. if err = proto.Unmarshal(b, &p); err != nil {
  895. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  896. return
  897. }
  898. if bs, e := protojson.Marshal(&p); e != nil {
  899. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  900. return
  901. } else {
  902. bytes = &bs
  903. serialNumber = p.GetHeader().GetRequestID()
  904. }
  905. case global.MarketOrderDeliveryApplyRsp:
  906. var p pb.MarketOrderDeliveryApplyRsp
  907. if err = proto.Unmarshal(b, &p); err != nil {
  908. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  909. return
  910. }
  911. if bs, e := protojson.Marshal(&p); e != nil {
  912. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  913. return
  914. } else {
  915. bytes = &bs
  916. serialNumber = p.GetHeader().GetRequestID()
  917. }
  918. case global.DeliveryClientOperatorRsp:
  919. var p pb.DeliveryClientOperatorRsp
  920. if err = proto.Unmarshal(b, &p); err != nil {
  921. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  922. return
  923. }
  924. if bs, e := protojson.Marshal(&p); e != nil {
  925. global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
  926. return
  927. } else {
  928. bytes = &bs
  929. serialNumber = p.GetHeader().GetRequestID()
  930. }
  931. }
  932. return
  933. }
  934. // RabbitMQSubscribeTopic 订阅主题
  935. func RabbitMQSubscribeTopic() (err error) {
  936. // 订阅需要的总线响应主题
  937. if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_USER); err != nil {
  938. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  939. return
  940. }
  941. if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_NTF); err != nil {
  942. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  943. return
  944. }
  945. if err = rabbitmq.SubscribeTopic(global.TOPIC_NOTIFY); err != nil {
  946. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  947. return
  948. }
  949. if err = rabbitmq.SubscribeTopic(global.TOPIC_NTF_CONTROL); err != nil {
  950. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  951. return
  952. }
  953. if err = rabbitmq.SubscribeTopic(global.TOPIC_CLIENT_NTF); err != nil {
  954. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  955. return
  956. }
  957. if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_QKERNEL); err != nil {
  958. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  959. return
  960. }
  961. if err = rabbitmq.SubscribeTopic(global.TOPIC_MANAGE_RSP); err != nil {
  962. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  963. return
  964. }
  965. if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_BANK); err != nil {
  966. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  967. return
  968. }
  969. if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_MONEY); err != nil {
  970. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  971. return
  972. }
  973. if err = rabbitmq.SubscribeTopic(global.TOPIC_PERFORMANCE_RSP); err != nil {
  974. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  975. return
  976. }
  977. if err = rabbitmq.SubscribeTopic(global.TOPIC_WAREHOUSE_RECIEPT_RSP); err != nil {
  978. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  979. return
  980. }
  981. if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_WAREHOUSE_TRADE); err != nil {
  982. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  983. return
  984. }
  985. if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_WAREHOUSE_TRADE_GZ); err != nil {
  986. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  987. return
  988. }
  989. if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_CJBS_TRADE_GZ); err != nil {
  990. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  991. return
  992. }
  993. // 铁合金
  994. if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_WAREHOUSE_PRESALE_THJ); err != nil {
  995. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  996. return
  997. }
  998. if err = rabbitmq.SubscribeTopic(global.TOPIC_MANAGER_THJ_NTF); err != nil {
  999. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  1000. return
  1001. }
  1002. if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_WAREHOUSE_PRESALE_GZ); err != nil {
  1003. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  1004. return
  1005. }
  1006. if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_WAREHOUSE_CENTERPURCHASE_GZ); err != nil {
  1007. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  1008. return
  1009. }
  1010. if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_ORDER); err != nil {
  1011. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  1012. return
  1013. }
  1014. if err = rabbitmq.SubscribeTopic(global.TOPIC_RSP_DELIVERY_TRADE); err != nil {
  1015. global.M2A_LOG.Error("rabbitmq subscribe topic failed, err:", zap.Error(err))
  1016. return
  1017. }
  1018. global.M2A_LOG.Info("rabbitmq subscribe topic successed.")
  1019. return
  1020. }
  1021. // StartRabbitMQReceive 开始接收总线消息
  1022. func StartRabbitMQReceive() {
  1023. t := &MQProc{}
  1024. go func() {
  1025. for _, subinfo := range rabbitmq.SubInfos {
  1026. rabbitmq.Receive(subinfo.Topic, subinfo.QueueName, t)
  1027. }
  1028. }()
  1029. }
  1030. // InitFuncodeTopic 初始化功能码主题MAP
  1031. func InitFuncodeTopic() {
  1032. if global.M2A_FuncodeTopic == nil {
  1033. global.M2A_FuncodeTopic = make(map[string][]int)
  1034. }
  1035. global.M2A_FuncodeTopic[global.TOPIC_REQ_QKERNEL] = []int{
  1036. global.ModifyPwdReq,
  1037. }
  1038. global.M2A_FuncodeTopic[global.TOPIC_MANAGE_REQ] = []int{
  1039. global.UserReceiveInfoReq,
  1040. global.DelUserReceiveInfoReq,
  1041. global.UserReceiveIsDefaultReq,
  1042. global.UserReceiptInfoReq,
  1043. global.DelUserReceiptInfoReq,
  1044. global.WarehouseApplyReq,
  1045. global.WROutApplyReq,
  1046. }
  1047. global.M2A_FuncodeTopic[global.TOPIC_REQ_BANK] = []int{
  1048. global.T2bBankSignReq,
  1049. global.T2bBankCancelSignReq,
  1050. global.T2bBankWithdrawReq,
  1051. global.T2bBankDepositReq,
  1052. global.T2bSMSVerificationCodeReq,
  1053. }
  1054. global.M2A_FuncodeTopic[global.TOPIC_REQ_MONEY] = []int{
  1055. global.AccountFundInfoReq,
  1056. }
  1057. global.M2A_FuncodeTopic[global.TOPIC_PERFORMANCE_REQ] = []int{
  1058. global.PerformanceContractedApplyReq,
  1059. global.PerformanceDelayApplyReq,
  1060. global.PerformanceManualConfirmReq,
  1061. global.PerformanceModifyContactReq,
  1062. }
  1063. global.M2A_FuncodeTopic[global.TOPIC_WAREHOUSE_RECIEPT] = []int{
  1064. global.ReceiptZSOutApplyReq,
  1065. }
  1066. global.M2A_FuncodeTopic[global.TOPIC_REQ_WAREHOUSE_TRADE] = []int{
  1067. global.WRListingCancelOrderReq,
  1068. global.HdWROrderReq,
  1069. global.HdWRDealOrderReq,
  1070. }
  1071. global.M2A_FuncodeTopic[global.TOPIC_REQ_WAREHOUSE_TRADE_GZ] = []int{
  1072. global.GoodsFavoriteOperateReq,
  1073. global.ZSBuyOrderListingReq,
  1074. global.ZSSellOrderListingReq,
  1075. global.ZSBuyOrderDestingReq,
  1076. global.ZSSellOrderDestingApplyReq,
  1077. global.ZSSellOrderDestingApplyOperateReq,
  1078. global.ZSBuyOrderDestingNegPriceReq,
  1079. global.ZSBuyOrderDestingNegPriceOperateReq,
  1080. }
  1081. global.M2A_FuncodeTopic[global.TOPIC_REQ_CJBS_TRADE_GZ] = []int{
  1082. global.CJJCMemberOperateReq,
  1083. global.BSFWMemberOperateReq,
  1084. global.BSWMSReckonPayReq,
  1085. }
  1086. // 铁合金
  1087. global.M2A_FuncodeTopic[global.TOPIC_REQ_WAREHOUSE_PRESALE_THJ] = []int{
  1088. global.SpotPresaleListingOrderReq,
  1089. }
  1090. global.M2A_FuncodeTopic[global.TOPIC_REQ_WAREHOUSE_PRESALE_GZ] = []int{
  1091. global.GZPresaleApplyReq,
  1092. global.GZPresaleOrderReq,
  1093. }
  1094. global.M2A_FuncodeTopic[global.TOPIC_REQ_WAREHOUSE_CENTERPURCHASE_GZ] = []int{
  1095. global.GZCenterPurchaseApplyReq,
  1096. global.GZCenterPurchaseOrderReq,
  1097. }
  1098. global.M2A_FuncodeTopic[global.TOPIC_REQ_ORDER] = []int{
  1099. global.OrderReq,
  1100. global.CancelOrderReq,
  1101. global.HolderCloseReq,
  1102. global.MakeUpDepositReq,
  1103. global.HoldAppendDepositReq,
  1104. global.OfflineDeliveryReq,
  1105. global.SupplementDepositReq,
  1106. global.RefundedDepositReq,
  1107. global.MarketOrderDeliveryApplyReq,
  1108. global.DeliveryClientOperatorReq,
  1109. global.OfflineDeliveryApplyCancelOrderReq,
  1110. }
  1111. global.M2A_FuncodeTopic[global.TOPIC_REQ_DELIVERY_TRADE] = []int{
  1112. global.DeliveryOrderReq,
  1113. }
  1114. global.M2A_FuncodeTopic[global.TOPIC_REQ_USER] = []int{
  1115. global.LoginReq,
  1116. }
  1117. }