|
@@ -9,6 +9,7 @@ import (
|
|
|
"mtp20access/packet"
|
|
"mtp20access/packet"
|
|
|
"mtp20access/rabbitmq"
|
|
"mtp20access/rabbitmq"
|
|
|
"mtp20access/res/pb"
|
|
"mtp20access/res/pb"
|
|
|
|
|
+ accountSrv "mtp20access/service/account"
|
|
|
"mtp20access/utils"
|
|
"mtp20access/utils"
|
|
|
|
|
|
|
|
// "github.com/golang/protobuf/proto"
|
|
// "github.com/golang/protobuf/proto"
|
|
@@ -52,10 +53,9 @@ func (t *MQProc) Process(topic, queuename string, msg *[]byte) {
|
|
|
if funcode, sessionId, bytes, serialNumber, err := t.getRspProtobuf(msg); err == nil && bytes != nil {
|
|
if funcode, sessionId, bytes, serialNumber, err := t.getRspProtobuf(msg); err == nil && bytes != nil {
|
|
|
if sessionId == 0 {
|
|
if sessionId == 0 {
|
|
|
// 通知类
|
|
// 通知类
|
|
|
-
|
|
|
|
|
|
|
+ t.onNtf(funcode, bytes)
|
|
|
} else {
|
|
} else {
|
|
|
- // 请求回复
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // 请求回复W
|
|
|
// 尝试获取对应异步任务
|
|
// 尝试获取对应异步任务
|
|
|
if client, exists := client.Clients[int(sessionId)]; exists {
|
|
if client, exists := client.Clients[int(sessionId)]; exists {
|
|
|
key := fmt.Sprintf("%v_%v_%v", sessionId, funcode, serialNumber)
|
|
key := fmt.Sprintf("%v_%v_%v", sessionId, funcode, serialNumber)
|
|
@@ -96,6 +96,36 @@ func (t *MQProc) Process(topic, queuename string, msg *[]byte) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func (t *MQProc) onNtf(funcode uint32, bytes *[]byte) {
|
|
|
|
|
+ switch int(funcode) {
|
|
|
|
|
+ case global.MoneyChangedNtf: // 资金变化通知
|
|
|
|
|
+ var p pb.MoneyChangedNtf
|
|
|
|
|
+ if err := proto.Unmarshal(*bytes, &p); err != nil {
|
|
|
|
|
+ global.M2A_LOG.Error("总线回复数据反序列化失败", zap.Error(err))
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 组装待发送给客户端的5.0报文包
|
|
|
|
|
+ b, err := packet.BuildPacket(funcode, 0, 0, *bytes, true)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ global.M2A_LOG.Error("组装5.0报文失败", zap.Error(err))
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 获取目标客户
|
|
|
|
|
+ clients, err := accountSrv.GetClientsByAccountID(*p.AccountID)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 发送信息
|
|
|
|
|
+ for i := range clients {
|
|
|
|
|
+ c := clients[i]
|
|
|
|
|
+ c.WriteTradeWsBuf(b)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// getRspProtobuf 将总线回复的数据反序列化为Protobuf
|
|
// getRspProtobuf 将总线回复的数据反序列化为Protobuf
|
|
|
func (t *MQProc) getRspProtobuf(msg *[]byte) (funcode uint32, sessionId uint32, bytes *[]byte, serialNumber uint32, err error) {
|
|
func (t *MQProc) getRspProtobuf(msg *[]byte) (funcode uint32, sessionId uint32, bytes *[]byte, serialNumber uint32, err error) {
|
|
|
// 分解总线包信息
|
|
// 分解总线包信息
|
|
@@ -107,18 +137,7 @@ func (t *MQProc) getRspProtobuf(msg *[]byte) (funcode uint32, sessionId uint32,
|
|
|
|
|
|
|
|
switch int(funcode) {
|
|
switch int(funcode) {
|
|
|
case global.MoneyChangedNtf: // 资金变化通知
|
|
case global.MoneyChangedNtf: // 资金变化通知
|
|
|
- var p pb.MoneyChangedNtf
|
|
|
|
|
- if err = proto.Unmarshal(b, &p); err != nil {
|
|
|
|
|
- global.M2A_LOG.Error("总线通知数据反序列化失败", zap.Error(err))
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- if bs, e := protojson.Marshal(&p); e != nil {
|
|
|
|
|
- global.M2A_LOG.Error("总线通知数据反序列化失败", zap.Error(err))
|
|
|
|
|
- return
|
|
|
|
|
- } else {
|
|
|
|
|
- bytes = &bs
|
|
|
|
|
- serialNumber = p.GetHeader().GetRequestID()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ bytes = &b
|
|
|
case global.ModifyPwdRsp: // 修改账户密码应答
|
|
case global.ModifyPwdRsp: // 修改账户密码应答
|
|
|
var p pb.ModifyPwdRsp
|
|
var p pb.ModifyPwdRsp
|
|
|
if err = proto.Unmarshal(b, &p); err != nil {
|
|
if err = proto.Unmarshal(b, &p); err != nil {
|