Bladeren bron

登录增加LoginReq总线消息

zhou.xiaoning 2 jaren geleden
bovenliggende
commit
f0c53d4a7b
13 gewijzigde bestanden met toevoegingen van 563 en 28 verwijderingen
  1. 1 1
      api/v1/account/login.go
  2. 1 1
      api/v1/mq/ntf.go
  3. 4 4
      config.yaml
  4. 2 0
      global/funcode.go
  5. 3 0
      global/topic.go
  6. 1 0
      go.mod
  7. 1 0
      go.sum
  8. 4 0
      initialize/rabbitmq.go
  9. 449 8
      res/pb/mtp2.pb.go
  10. 39 0
      res/pb/mtp2.proto
  11. 43 10
      service/account/login.go
  12. 2 4
      service/mq/ntf.go
  13. 13 0
      utils/var.go

+ 1 - 1
api/v1/account/login.go

@@ -27,7 +27,7 @@ func Login(c *gin.Context) {
 	r := request.LoginReq{}
 	g.BindJsonReq(&r)
 
-	if loginaccount, token, expiresAt, err := accountService.Login(r, g.C.ClientIP()); err == nil {
+	if loginaccount, token, _, expiresAt, err := accountService.Login(r, g.C.ClientIP()); err == nil {
 		response.OkWithDetailed(accountRsp.LoginRsp{
 			LoginID:   int(loginaccount.LOGINID),
 			UserID:    int(loginaccount.USERID),

+ 1 - 1
api/v1/mq/ntf.go

@@ -27,7 +27,7 @@ func SendNtfToMQ(c *gin.Context) {
 		global.M2A_LOG.Info("[C->S]", zap.Any("req", req.FunCode), zap.Any("data", req.Data))
 	}
 
-	if err := mq.SendNtfMQ(c, &req); err != nil {
+	if err := mq.SendNtfMQ(&req, 0); err != nil {
 		response.FailWithMessage(err.Error(), c)
 		return
 	}

+ 4 - 4
config.yaml

@@ -20,7 +20,7 @@ jwt:
 # redis configuration
 redis:
   db: 0
-  addr: '192.168.31.204:5007'
+  addr: '192.168.31.171:5007'
   password: ''
 
 # system configuration
@@ -28,7 +28,7 @@ system:
   env: 'develop'  # "develop" & "public", Change to "develop" to skip authentication for development mode
   addr: 8888
   need-quote-publish: true # 是否需要连接行情发布服务
-  quote-publish-addr: '192.168.31.204:5004' # 行情发布服务地址
+  quote-publish-addr: '192.168.31.171:5004' # 行情发布服务地址
 
 # local configuration
 local:
@@ -41,14 +41,14 @@ oracle:
   address: '192.168.31.88'
   name: 'orcl'
   port: '1521'
-  user: 'mtp2_test204'
+  user: 'mtp2_test171'
   pwd: 'muchinfo'
   max-idle-conns: 10
   max-open-conns: 100
 
 # rabbitmq configuration
 rabbitmq:
-  url: 'amqp://guest:guest@192.168.31.204:5020/test'
+  url: 'amqp://guest:guest@192.168.31.171:5020/test'
   exchange: 'entry'
 
 # 跨域配置

+ 2 - 0
global/funcode.go

@@ -117,6 +117,8 @@ var (
 	MarketOrderDeliveryApplyRsp = 196740 // 按单做市交收申请接口响应
 	DeliveryClientOperatorReq   = 196743 // 交收终端操作接口请求
 	DeliveryClientOperatorRsp   = 196744 // 交收终端操作接口响应
+
+	LoginReq = 65537 // 用户登录请求
 )
 
 // 通过请求功能码获取对应主题的方法

+ 3 - 0
global/topic.go

@@ -46,4 +46,7 @@ var (
 
 	TOPIC_REQ_DELIVERY_TRADE = "delivery_trade_req" // 交割交易请求
 	TOPIC_RSP_DELIVERY_TRADE = "delivery_trade_rsp" // 交割交易响应
+
+	TOPIC_REQ_USER = "user_req" // 用户相关请求,比如登陆
+	TOPIC_RSP_USER = "user_rsp" // 用户相关回应
 )

+ 1 - 0
go.mod

@@ -6,6 +6,7 @@ require (
 	github.com/fsnotify/fsnotify v1.5.4
 	github.com/gin-gonic/gin v1.8.1
 	github.com/go-redis/redis/v8 v8.11.5
+	github.com/gofrs/uuid v4.0.0+incompatible
 	github.com/golang-jwt/jwt/v4 v4.4.2
 	github.com/golang/protobuf v1.5.2
 	github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c

+ 1 - 0
go.sum

@@ -177,6 +177,7 @@ github.com/goccy/go-json v0.8.1/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGF
 github.com/goccy/go-json v0.9.7 h1:IcB+Aqpx/iMHu5Yooh7jEzJk1JZ7Pjtmys2ukPr7EeM=
 github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
 github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
+github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
 github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
 github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
 github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=

+ 4 - 0
initialize/rabbitmq.go

@@ -965,4 +965,8 @@ func InitFuncodeTopic() {
 	global.M2A_FuncodeTopic[global.TOPIC_REQ_DELIVERY_TRADE] = []int{
 		global.DeliveryOrderReq,
 	}
+
+	global.M2A_FuncodeTopic[global.TOPIC_REQ_USER] = []int{
+		global.LoginReq,
+	}
 }

+ 449 - 8
res/pb/mtp2.pb.go

@@ -13641,6 +13641,350 @@ func (x *DeliveryClientOperatorRsp) GetClientSerialNo() string {
 	return ""
 }
 
+// 用户登录请求
+type LoginReq struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Header           *MessageHead `protobuf:"bytes,1,opt,name=Header" json:"Header,omitempty"`
+	LoginID          *uint64      `protobuf:"varint,2,opt,name=LoginID" json:"LoginID,omitempty"`                   // 登录ID
+	LoginPWD         *string      `protobuf:"bytes,3,opt,name=LoginPWD" json:"LoginPWD,omitempty"`                  // 登录密码
+	LoginType        *uint32      `protobuf:"varint,4,opt,name=LoginType" json:"LoginType,omitempty"`               // 登陆类型
+	ClientType       *uint32      `protobuf:"varint,5,opt,name=ClientType" json:"ClientType,omitempty"`             // 终端软件类型
+	Version          *string      `protobuf:"bytes,6,opt,name=Version" json:"Version,omitempty"`                    // 终端软件版本号
+	MobilePhone      *string      `protobuf:"bytes,7,opt,name=MobilePhone" json:"MobilePhone,omitempty"`            // 移动电话
+	GUID             *string      `protobuf:"bytes,8,opt,name=GUID" json:"GUID,omitempty"`                          // 唯一标识码
+	LoginIp          *string      `protobuf:"bytes,9,opt,name=LoginIp" json:"LoginIp,omitempty"`                    // 登录IP地址
+	LoginPort        *uint32      `protobuf:"varint,10,opt,name=LoginPort" json:"LoginPort,omitempty"`              // 登陆通信端口
+	DeviceID         *string      `protobuf:"bytes,11,opt,name=DeviceID" json:"DeviceID,omitempty"`                 // 设备标识
+	EnvironmentInfo  *string      `protobuf:"bytes,12,opt,name=EnvironmentInfo" json:"EnvironmentInfo,omitempty"`   // 软件环境信息
+	LoginCode        *string      `protobuf:"bytes,13,opt,name=LoginCode" json:"LoginCode,omitempty"`               // 登陆码
+	ClientSystemInfo []byte       `protobuf:"bytes,14,opt,name=ClientSystemInfo" json:"ClientSystemInfo,omitempty"` // 终端系统信息
+	ClientAppID      *string      `protobuf:"bytes,15,opt,name=ClientAppID" json:"ClientAppID,omitempty"`           // 终端AppID
+}
+
+func (x *LoginReq) Reset() {
+	*x = LoginReq{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_mtp2_proto_msgTypes[118]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *LoginReq) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*LoginReq) ProtoMessage() {}
+
+func (x *LoginReq) ProtoReflect() protoreflect.Message {
+	mi := &file_mtp2_proto_msgTypes[118]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use LoginReq.ProtoReflect.Descriptor instead.
+func (*LoginReq) Descriptor() ([]byte, []int) {
+	return file_mtp2_proto_rawDescGZIP(), []int{118}
+}
+
+func (x *LoginReq) GetHeader() *MessageHead {
+	if x != nil {
+		return x.Header
+	}
+	return nil
+}
+
+func (x *LoginReq) GetLoginID() uint64 {
+	if x != nil && x.LoginID != nil {
+		return *x.LoginID
+	}
+	return 0
+}
+
+func (x *LoginReq) GetLoginPWD() string {
+	if x != nil && x.LoginPWD != nil {
+		return *x.LoginPWD
+	}
+	return ""
+}
+
+func (x *LoginReq) GetLoginType() uint32 {
+	if x != nil && x.LoginType != nil {
+		return *x.LoginType
+	}
+	return 0
+}
+
+func (x *LoginReq) GetClientType() uint32 {
+	if x != nil && x.ClientType != nil {
+		return *x.ClientType
+	}
+	return 0
+}
+
+func (x *LoginReq) GetVersion() string {
+	if x != nil && x.Version != nil {
+		return *x.Version
+	}
+	return ""
+}
+
+func (x *LoginReq) GetMobilePhone() string {
+	if x != nil && x.MobilePhone != nil {
+		return *x.MobilePhone
+	}
+	return ""
+}
+
+func (x *LoginReq) GetGUID() string {
+	if x != nil && x.GUID != nil {
+		return *x.GUID
+	}
+	return ""
+}
+
+func (x *LoginReq) GetLoginIp() string {
+	if x != nil && x.LoginIp != nil {
+		return *x.LoginIp
+	}
+	return ""
+}
+
+func (x *LoginReq) GetLoginPort() uint32 {
+	if x != nil && x.LoginPort != nil {
+		return *x.LoginPort
+	}
+	return 0
+}
+
+func (x *LoginReq) GetDeviceID() string {
+	if x != nil && x.DeviceID != nil {
+		return *x.DeviceID
+	}
+	return ""
+}
+
+func (x *LoginReq) GetEnvironmentInfo() string {
+	if x != nil && x.EnvironmentInfo != nil {
+		return *x.EnvironmentInfo
+	}
+	return ""
+}
+
+func (x *LoginReq) GetLoginCode() string {
+	if x != nil && x.LoginCode != nil {
+		return *x.LoginCode
+	}
+	return ""
+}
+
+func (x *LoginReq) GetClientSystemInfo() []byte {
+	if x != nil {
+		return x.ClientSystemInfo
+	}
+	return nil
+}
+
+func (x *LoginReq) GetClientAppID() string {
+	if x != nil && x.ClientAppID != nil {
+		return *x.ClientAppID
+	}
+	return ""
+}
+
+// 用户登录应答
+type LoginRsp struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Header           *MessageHead `protobuf:"bytes,1,opt,name=Header" json:"Header,omitempty"`                       // 消息头
+	RetCode          *int32       `protobuf:"varint,2,opt,name=RetCode" json:"RetCode,omitempty"`                    // 返回码
+	RetDesc          *string      `protobuf:"bytes,3,opt,name=RetDesc" json:"RetDesc,omitempty"`                     // 描述信息
+	LoginID          *uint64      `protobuf:"varint,4,opt,name=LoginID" json:"LoginID,omitempty"`                    // 登录ID
+	LoginUserType    *uint32      `protobuf:"varint,5,opt,name=LoginUserType" json:"LoginUserType,omitempty"`        // 登陆用户类型
+	AccountStatus    *uint32      `protobuf:"varint,6,opt,name=AccountStatus" json:"AccountStatus,omitempty"`        // 用户状态
+	UserID           *uint32      `protobuf:"varint,7,opt,name=UserID" json:"UserID,omitempty"`                      // 用户ID
+	MemberUserID     *uint32      `protobuf:"varint,8,opt,name=MemberUserID" json:"MemberUserID,omitempty"`          // 用户所属会员用户ID
+	AccountIDs       []uint64     `protobuf:"varint,9,rep,name=AccountIDs" json:"AccountIDs,omitempty"`              // 账户ID列表(有权限的)
+	Token            *string      `protobuf:"bytes,10,opt,name=Token" json:"Token,omitempty"`                        // 用户令牌
+	SystemTime       *uint64      `protobuf:"varint,11,opt,name=SystemTime" json:"SystemTime,omitempty"`             // 系统时间
+	HasUpdatedPwd    *uint32      `protobuf:"varint,12,opt,name=HasUpdatedPwd" json:"HasUpdatedPwd,omitempty"`       // 是否已更改密码
+	PwdWrongCnt      *uint32      `protobuf:"varint,13,opt,name=PwdWrongCnt" json:"PwdWrongCnt,omitempty"`           // 当前密码输入错误次数
+	PwdWrongLockCnt  *uint32      `protobuf:"varint,14,opt,name=PwdWrongLockCnt" json:"PwdWrongLockCnt,omitempty"`   // 登陆账号锁定密码输入错误次数
+	LoginLockHourNum *uint32      `protobuf:"varint,15,opt,name=LoginLockHourNum" json:"LoginLockHourNum,omitempty"` // 登陆账号锁定时长(小时)
+	LoginCode        *string      `protobuf:"bytes,16,opt,name=LoginCode" json:"LoginCode,omitempty"`                // 登陆码
+	ClientSystemInfo []byte       `protobuf:"bytes,17,opt,name=ClientSystemInfo" json:"ClientSystemInfo,omitempty"`  // 终端系统信息
+	ClientID         *uint64      `protobuf:"varint,18,opt,name=ClientID" json:"ClientID,omitempty"`                 // 终端ID(登陆服务分配,用于通道交易关联链路)
+}
+
+func (x *LoginRsp) Reset() {
+	*x = LoginRsp{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_mtp2_proto_msgTypes[119]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *LoginRsp) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*LoginRsp) ProtoMessage() {}
+
+func (x *LoginRsp) ProtoReflect() protoreflect.Message {
+	mi := &file_mtp2_proto_msgTypes[119]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use LoginRsp.ProtoReflect.Descriptor instead.
+func (*LoginRsp) Descriptor() ([]byte, []int) {
+	return file_mtp2_proto_rawDescGZIP(), []int{119}
+}
+
+func (x *LoginRsp) GetHeader() *MessageHead {
+	if x != nil {
+		return x.Header
+	}
+	return nil
+}
+
+func (x *LoginRsp) GetRetCode() int32 {
+	if x != nil && x.RetCode != nil {
+		return *x.RetCode
+	}
+	return 0
+}
+
+func (x *LoginRsp) GetRetDesc() string {
+	if x != nil && x.RetDesc != nil {
+		return *x.RetDesc
+	}
+	return ""
+}
+
+func (x *LoginRsp) GetLoginID() uint64 {
+	if x != nil && x.LoginID != nil {
+		return *x.LoginID
+	}
+	return 0
+}
+
+func (x *LoginRsp) GetLoginUserType() uint32 {
+	if x != nil && x.LoginUserType != nil {
+		return *x.LoginUserType
+	}
+	return 0
+}
+
+func (x *LoginRsp) GetAccountStatus() uint32 {
+	if x != nil && x.AccountStatus != nil {
+		return *x.AccountStatus
+	}
+	return 0
+}
+
+func (x *LoginRsp) GetUserID() uint32 {
+	if x != nil && x.UserID != nil {
+		return *x.UserID
+	}
+	return 0
+}
+
+func (x *LoginRsp) GetMemberUserID() uint32 {
+	if x != nil && x.MemberUserID != nil {
+		return *x.MemberUserID
+	}
+	return 0
+}
+
+func (x *LoginRsp) GetAccountIDs() []uint64 {
+	if x != nil {
+		return x.AccountIDs
+	}
+	return nil
+}
+
+func (x *LoginRsp) GetToken() string {
+	if x != nil && x.Token != nil {
+		return *x.Token
+	}
+	return ""
+}
+
+func (x *LoginRsp) GetSystemTime() uint64 {
+	if x != nil && x.SystemTime != nil {
+		return *x.SystemTime
+	}
+	return 0
+}
+
+func (x *LoginRsp) GetHasUpdatedPwd() uint32 {
+	if x != nil && x.HasUpdatedPwd != nil {
+		return *x.HasUpdatedPwd
+	}
+	return 0
+}
+
+func (x *LoginRsp) GetPwdWrongCnt() uint32 {
+	if x != nil && x.PwdWrongCnt != nil {
+		return *x.PwdWrongCnt
+	}
+	return 0
+}
+
+func (x *LoginRsp) GetPwdWrongLockCnt() uint32 {
+	if x != nil && x.PwdWrongLockCnt != nil {
+		return *x.PwdWrongLockCnt
+	}
+	return 0
+}
+
+func (x *LoginRsp) GetLoginLockHourNum() uint32 {
+	if x != nil && x.LoginLockHourNum != nil {
+		return *x.LoginLockHourNum
+	}
+	return 0
+}
+
+func (x *LoginRsp) GetLoginCode() string {
+	if x != nil && x.LoginCode != nil {
+		return *x.LoginCode
+	}
+	return ""
+}
+
+func (x *LoginRsp) GetClientSystemInfo() []byte {
+	if x != nil {
+		return x.ClientSystemInfo
+	}
+	return nil
+}
+
+func (x *LoginRsp) GetClientID() uint64 {
+	if x != nil && x.ClientID != nil {
+		return *x.ClientID
+	}
+	return 0
+}
+
 var File_mtp2_proto protoreflect.FileDescriptor
 
 var file_mtp2_proto_rawDesc = []byte{
@@ -16159,7 +16503,76 @@ var file_mtp2_proto_rawDesc = []byte{
 	0x75, 0x6e, 0x74, 0x49, 0x44, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x41, 0x63, 0x63,
 	0x6f, 0x75, 0x6e, 0x74, 0x49, 0x44, 0x12, 0x26, 0x0a, 0x0e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74,
 	0x53, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x4e, 0x6f, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e,
-	0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x4e, 0x6f,
+	0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x4e, 0x6f, 0x22, 0xe1,
+	0x03, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x27, 0x0a, 0x06, 0x48,
+	0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x62,
+	0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x65, 0x61, 0x64, 0x52, 0x06, 0x48, 0x65,
+	0x61, 0x64, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x49, 0x44, 0x18,
+	0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x49, 0x44, 0x12, 0x1a,
+	0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x50, 0x57, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09,
+	0x52, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x50, 0x57, 0x44, 0x12, 0x1c, 0x0a, 0x09, 0x4c, 0x6f,
+	0x67, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x4c,
+	0x6f, 0x67, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x43, 0x6c, 0x69, 0x65,
+	0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x43, 0x6c,
+	0x69, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73,
+	0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69,
+	0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x4d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x50, 0x68, 0x6f, 0x6e,
+	0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x4d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x50,
+	0x68, 0x6f, 0x6e, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x47, 0x55, 0x49, 0x44, 0x18, 0x08, 0x20, 0x01,
+	0x28, 0x09, 0x52, 0x04, 0x47, 0x55, 0x49, 0x44, 0x12, 0x18, 0x0a, 0x07, 0x4c, 0x6f, 0x67, 0x69,
+	0x6e, 0x49, 0x70, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x4c, 0x6f, 0x67, 0x69, 0x6e,
+	0x49, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x50, 0x6f, 0x72, 0x74, 0x18,
+	0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x50, 0x6f, 0x72, 0x74,
+	0x12, 0x1a, 0x0a, 0x08, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x44, 0x18, 0x0b, 0x20, 0x01,
+	0x28, 0x09, 0x52, 0x08, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x44, 0x12, 0x28, 0x0a, 0x0f,
+	0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x18,
+	0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65,
+	0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1c, 0x0a, 0x09, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x43,
+	0x6f, 0x64, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x4c, 0x6f, 0x67, 0x69, 0x6e,
+	0x43, 0x6f, 0x64, 0x65, 0x12, 0x2a, 0x0a, 0x10, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x79,
+	0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x10,
+	0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f,
+	0x12, 0x20, 0x0a, 0x0b, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x41, 0x70, 0x70, 0x49, 0x44, 0x18,
+	0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x41, 0x70, 0x70,
+	0x49, 0x44, 0x22, 0xe3, 0x04, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x73, 0x70, 0x12,
+	0x27, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
+	0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x65, 0x61, 0x64,
+	0x52, 0x06, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x52, 0x65, 0x74, 0x43,
+	0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x52, 0x65, 0x74, 0x43, 0x6f,
+	0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x52, 0x65, 0x74, 0x44, 0x65, 0x73, 0x63, 0x18, 0x03, 0x20,
+	0x01, 0x28, 0x09, 0x52, 0x07, 0x52, 0x65, 0x74, 0x44, 0x65, 0x73, 0x63, 0x12, 0x18, 0x0a, 0x07,
+	0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x49, 0x44, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x4c,
+	0x6f, 0x67, 0x69, 0x6e, 0x49, 0x44, 0x12, 0x24, 0x0a, 0x0d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x55,
+	0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x4c,
+	0x6f, 0x67, 0x69, 0x6e, 0x55, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x24, 0x0a, 0x0d,
+	0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x06, 0x20,
+	0x01, 0x28, 0x0d, 0x52, 0x0d, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74,
+	0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x07, 0x20, 0x01,
+	0x28, 0x0d, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x12, 0x22, 0x0a, 0x0c, 0x4d, 0x65,
+	0x6d, 0x62, 0x65, 0x72, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0d,
+	0x52, 0x0c, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x12, 0x1e,
+	0x0a, 0x0a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x44, 0x73, 0x18, 0x09, 0x20, 0x03,
+	0x28, 0x04, 0x52, 0x0a, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x44, 0x73, 0x12, 0x14,
+	0x0a, 0x05, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x54,
+	0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x54, 0x69,
+	0x6d, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d,
+	0x54, 0x69, 0x6d, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x48, 0x61, 0x73, 0x55, 0x70, 0x64, 0x61, 0x74,
+	0x65, 0x64, 0x50, 0x77, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x48, 0x61, 0x73,
+	0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x50, 0x77, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x50, 0x77,
+	0x64, 0x57, 0x72, 0x6f, 0x6e, 0x67, 0x43, 0x6e, 0x74, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0d, 0x52,
+	0x0b, 0x50, 0x77, 0x64, 0x57, 0x72, 0x6f, 0x6e, 0x67, 0x43, 0x6e, 0x74, 0x12, 0x28, 0x0a, 0x0f,
+	0x50, 0x77, 0x64, 0x57, 0x72, 0x6f, 0x6e, 0x67, 0x4c, 0x6f, 0x63, 0x6b, 0x43, 0x6e, 0x74, 0x18,
+	0x0e, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0f, 0x50, 0x77, 0x64, 0x57, 0x72, 0x6f, 0x6e, 0x67, 0x4c,
+	0x6f, 0x63, 0x6b, 0x43, 0x6e, 0x74, 0x12, 0x2a, 0x0a, 0x10, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x4c,
+	0x6f, 0x63, 0x6b, 0x48, 0x6f, 0x75, 0x72, 0x4e, 0x75, 0x6d, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0d,
+	0x52, 0x10, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x4c, 0x6f, 0x63, 0x6b, 0x48, 0x6f, 0x75, 0x72, 0x4e,
+	0x75, 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x18,
+	0x10, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x43, 0x6f, 0x64, 0x65,
+	0x12, 0x2a, 0x0a, 0x10, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d,
+	0x49, 0x6e, 0x66, 0x6f, 0x18, 0x11, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x10, 0x43, 0x6c, 0x69, 0x65,
+	0x6e, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1a, 0x0a, 0x08,
+	0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x44, 0x18, 0x12, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08,
+	0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x44,
 }
 
 var (
@@ -16174,7 +16587,7 @@ func file_mtp2_proto_rawDescGZIP() []byte {
 	return file_mtp2_proto_rawDescData
 }
 
-var file_mtp2_proto_msgTypes = make([]protoimpl.MessageInfo, 118)
+var file_mtp2_proto_msgTypes = make([]protoimpl.MessageInfo, 120)
 var file_mtp2_proto_goTypes = []interface{}{
 	(*MessageHead)(nil),                         // 0: pb.MessageHead
 	(*NotifyHead)(nil),                          // 1: pb.NotifyHead
@@ -16294,6 +16707,8 @@ var file_mtp2_proto_goTypes = []interface{}{
 	(*MarketOrderDeliveryApplyRsp)(nil),         // 115: pb.MarketOrderDeliveryApplyRsp
 	(*DeliveryClientOperatorReq)(nil),           // 116: pb.DeliveryClientOperatorReq
 	(*DeliveryClientOperatorRsp)(nil),           // 117: pb.DeliveryClientOperatorRsp
+	(*LoginReq)(nil),                            // 118: pb.LoginReq
+	(*LoginRsp)(nil),                            // 119: pb.LoginRsp
 }
 var file_mtp2_proto_depIdxs = []int32{
 	0,   // 0: pb.MoneyChangedNtf.Header:type_name -> pb.MessageHead
@@ -16419,11 +16834,13 @@ var file_mtp2_proto_depIdxs = []int32{
 	0,   // 120: pb.DeliveryClientOperatorReq.Header:type_name -> pb.MessageHead
 	113, // 121: pb.DeliveryClientOperatorReq.PayAttr:type_name -> pb.PayAttrs
 	0,   // 122: pb.DeliveryClientOperatorRsp.Header:type_name -> pb.MessageHead
-	123, // [123:123] is the sub-list for method output_type
-	123, // [123:123] is the sub-list for method input_type
-	123, // [123:123] is the sub-list for extension type_name
-	123, // [123:123] is the sub-list for extension extendee
-	0,   // [0:123] is the sub-list for field type_name
+	0,   // 123: pb.LoginReq.Header:type_name -> pb.MessageHead
+	0,   // 124: pb.LoginRsp.Header:type_name -> pb.MessageHead
+	125, // [125:125] is the sub-list for method output_type
+	125, // [125:125] is the sub-list for method input_type
+	125, // [125:125] is the sub-list for extension type_name
+	125, // [125:125] is the sub-list for extension extendee
+	0,   // [0:125] is the sub-list for field type_name
 }
 
 func init() { file_mtp2_proto_init() }
@@ -17848,6 +18265,30 @@ func file_mtp2_proto_init() {
 				return nil
 			}
 		}
+		file_mtp2_proto_msgTypes[118].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*LoginReq); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_mtp2_proto_msgTypes[119].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*LoginRsp); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
 	}
 	type x struct{}
 	out := protoimpl.TypeBuilder{
@@ -17855,7 +18296,7 @@ func file_mtp2_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_mtp2_proto_rawDesc,
 			NumEnums:      0,
-			NumMessages:   118,
+			NumMessages:   120,
 			NumExtensions: 0,
 			NumServices:   0,
 		},

+ 39 - 0
res/pb/mtp2.proto

@@ -1557,4 +1557,43 @@ message DeliveryClientOperatorRsp {
 		optional uint32 UserID = 5; // 用户ID,必填
 		optional uint64 AccountID = 6; // 交易账号,必填
 		optional string ClientSerialNo = 7; // 客户端流水号
+}
+// 用户登录请求
+message LoginReq {
+	optional MessageHead Header = 1;
+		optional uint64 LoginID = 2; // 登录ID
+		optional string LoginPWD = 3; // 登录密码
+		optional uint32 LoginType = 4; // 登陆类型
+		optional uint32 ClientType = 5; // 终端软件类型
+		optional string Version = 6; // 终端软件版本号
+		optional string MobilePhone = 7; // 移动电话
+		optional string GUID = 8; // 唯一标识码
+		optional string LoginIp = 9; // 登录IP地址
+		optional uint32 LoginPort = 10; // 登陆通信端口
+		optional string DeviceID = 11; // 设备标识
+		optional string EnvironmentInfo = 12; // 软件环境信息
+		optional string LoginCode = 13; // 登陆码
+		optional bytes ClientSystemInfo = 14; // 终端系统信息
+		optional string ClientAppID = 15; // 终端AppID
+}
+// 用户登录应答
+message LoginRsp {
+	optional MessageHead Header = 1; // 消息头
+	optional int32 RetCode = 2; // 返回码
+	optional string RetDesc = 3; // 描述信息
+		optional uint64 LoginID = 4; // 登录ID
+		optional uint32 LoginUserType = 5; // 登陆用户类型
+		optional uint32 AccountStatus = 6; // 用户状态
+		optional uint32 UserID = 7; // 用户ID
+		optional uint32 MemberUserID = 8; // 用户所属会员用户ID
+		repeated uint64 AccountIDs = 9; // 账户ID列表(有权限的)
+		optional string Token = 10; // 用户令牌
+		optional uint64 SystemTime = 11; // 系统时间
+		optional uint32 HasUpdatedPwd = 12; // 是否已更改密码
+		optional uint32 PwdWrongCnt = 13; // 当前密码输入错误次数
+		optional uint32 PwdWrongLockCnt = 14; // 登陆账号锁定密码输入错误次数
+		optional uint32 LoginLockHourNum = 15; // 登陆账号锁定时长(小时)
+		optional string LoginCode = 16; // 登陆码
+		optional bytes ClientSystemInfo = 17; // 终端系统信息
+		optional uint64 ClientID = 18; // 终端ID(登陆服务分配,用于通道交易关联链路)
 }

+ 43 - 10
service/account/login.go

@@ -11,11 +11,15 @@ import (
 	"mtp20access/model/account/request"
 	jwtRequest "mtp20access/model/common/request"
 	"mtp20access/packet"
+	"mtp20access/rabbitmq"
+	"mtp20access/res/pb"
 	"sync"
 
 	"mtp20access/utils"
 	"strconv"
 
+	"github.com/gofrs/uuid"
+	"github.com/golang/protobuf/proto"
 	"go.uber.org/zap"
 )
 
@@ -25,9 +29,9 @@ var (
 )
 
 // Login 用户登录
-func Login(req request.LoginReq, addr string) (loginaccount *accountModel.Loginaccount, token string, expiresAt int64, err error) {
+func Login(req request.LoginReq, addr string) (loginaccount *accountModel.Loginaccount, token string, sessionID int, expiresAt int64, err error) {
 	// 分别尝试用LoginID、LoginCode和手机号码进行登录
-	loginaccount, err = getLoginAccount(req.UserName, req.Password)
+	loginaccount, _, err = getLoginAccount(req.UserName, req.Password)
 	if err != nil {
 		return
 	}
@@ -43,15 +47,44 @@ func Login(req request.LoginReq, addr string) (loginaccount *accountModel.Logina
 	}
 
 	// 生成Token,并写入Redis
-	if token, expiresAt, err = buildRedisLoginInfo(*loginaccount, addr, req.ClientType); err != nil {
+	token, expiresAt, sessionID, err = buildRedisLoginInfo(*loginaccount, addr, req.ClientType)
+	if err != nil {
 		return
 	}
 
+	// 发送登录报文给总线
+	loginReq := pb.LoginReq{}
+	loginReq.LoginID = utils.SetPointValue(uint64(loginaccount.LOGINID))
+	// loginReq.LoginPWD = utils.SetPointValue(strings.ToLower(utils.EncoderSha256(fmt.Sprintf("%v%s", loginReq.LoginID, oriPwd))))
+	loginReq.LoginPWD = utils.SetPointValue(loginaccount.PASSWORD)
+	loginReq.LoginIp = utils.SetPointValue(addr)
+	loginReq.LoginType = utils.SetPointValue[uint32](0)
+	loginReq.ClientType = utils.SetPointValue(uint32(req.ClientType))
+	uid, _ := uuid.NewV4()
+	loginReq.GUID = utils.SetPointValue(uid.String())
+	loginReq.Version = utils.SetPointValue("10.0.0.1")
+	uid, _ = uuid.NewV4()
+	loginReq.DeviceID = utils.SetPointValue(uid.String())
+	loginReq.ClientAppID = utils.SetPointValue("MTP20_GO_ACCESS")
+	header := pb.MessageHead{}
+	header.FunCode = utils.SetPointValue(uint32(global.LoginReq))
+	uid, _ = uuid.NewV4()
+	header.UUID = utils.SetPointValue(uid.String())
+	loginReq.Header = &header
+	if b, e := proto.Marshal(&loginReq); e == nil {
+		packet := &client.MQPacket{
+			FunCode:   uint32(global.LoginReq),
+			SessionId: uint32(sessionID),
+			Data:      &b,
+		}
+		go rabbitmq.Publish(global.TOPIC_REQ_USER, packet)
+	}
+
 	return
 }
 
 // getLoginAccount 分别尝试用LoginID、LoginCode和手机号码进行登录
-func getLoginAccount(userName string, password string) (loginaccount *accountModel.Loginaccount, err error) {
+func getLoginAccount(userName string, password string) (loginaccount *accountModel.Loginaccount, oriPwd string, err error) {
 	// 密码解密(5.0报文解密)
 	d, err := base64.StdEncoding.DecodeString(password)
 	if err != nil {
@@ -62,13 +95,13 @@ func getLoginAccount(userName string, password string) (loginaccount *accountMod
 	if err != nil {
 		return
 	}
-	pwd := string(p)
+	oriPwd = string(p)
 
 	// 通过LoginID查询
 	if loginID, _ := strconv.Atoi(userName); loginID != 0 {
 		loginaccount = &accountModel.Loginaccount{
 			LOGINID:  int64(loginID),
-			PASSWORD: utils.EncoderSha256(fmt.Sprintf("%s%s", userName, pwd)), // 构建数据库存储的密码
+			PASSWORD: utils.EncoderSha256(fmt.Sprintf("%s%s", userName, oriPwd)), // 构建数据库存储的密码
 		}
 		if has, _ := global.M2A_DB.Get(loginaccount); has {
 			return
@@ -81,7 +114,7 @@ func getLoginAccount(userName string, password string) (loginaccount *accountMod
 	}
 	if has, _ := global.M2A_DB.Get(loginaccount); has {
 		// 构建数据库存储的密码
-		if loginaccount.PASSWORD == utils.EncoderSha256(fmt.Sprintf("%d%s", loginaccount.LOGINID, pwd)) {
+		if loginaccount.PASSWORD == utils.EncoderSha256(fmt.Sprintf("%d%s", loginaccount.LOGINID, oriPwd)) {
 			return
 		}
 	}
@@ -97,7 +130,7 @@ func getLoginAccount(userName string, password string) (loginaccount *accountMod
 		if has, _ := global.M2A_DB.Get(userauthinfo); has {
 			loginaccount = &accountModel.Loginaccount{
 				LOGINID:  userauthinfo.LOGINID,
-				PASSWORD: utils.EncoderSha256(fmt.Sprintf("%v%s", userauthinfo.LOGINID, pwd)), // 构建数据库存储的密码
+				PASSWORD: utils.EncoderSha256(fmt.Sprintf("%v%s", userauthinfo.LOGINID, oriPwd)), // 构建数据库存储的密码
 			}
 			if has, _ := global.M2A_DB.Get(loginaccount); has {
 				return
@@ -129,9 +162,9 @@ func newSessionID() int {
 }
 
 // buildRedisLoginInfo 生成Token,并写入Redis
-func buildRedisLoginInfo(loginaccount accountModel.Loginaccount, addr string, group int) (token string, expiresAt int64, err error) {
+func buildRedisLoginInfo(loginaccount accountModel.Loginaccount, addr string, group int) (token string, expiresAt int64, sessionID int, err error) {
 	// 生成SessionID
-	sessionID := newSessionID()
+	sessionID = newSessionID()
 
 	// 生成本服务Token
 	j := &utils.JWT{SigningKey: []byte(global.M2A_CONFIG.JWT.SigningKey)} // 唯一签名

+ 2 - 4
service/mq/ntf.go

@@ -5,12 +5,10 @@ import (
 	"mtp20access/client"
 	"mtp20access/model/mq/request"
 	"mtp20access/rabbitmq"
-
-	"github.com/gin-gonic/gin"
 )
 
 // SendNtfMQ 向总线发送通知类信息
-func SendNtfMQ(c *gin.Context, req *request.MQNtfReq) (err error) {
+func SendNtfMQ(req *request.MQNtfReq, sessionID int) (err error) {
 	// 将请求的数据转换成总线使用的Protobuf
 	bytes, err := req.GetProtoBytes()
 	if err != nil {
@@ -24,7 +22,7 @@ func SendNtfMQ(c *gin.Context, req *request.MQNtfReq) (err error) {
 	// 向总线发送业务信息
 	packet := &client.MQPacket{
 		FunCode:   req.FunCode,
-		SessionId: 0,
+		SessionId: uint32(sessionID),
 		Data:      bytes,
 	}
 	go rabbitmq.Publish(req.Topic, packet)

+ 13 - 0
utils/var.go

@@ -0,0 +1,13 @@
+package utils
+
+type PointValue interface {
+	int | bool | float64 | uint | uint32 | uint64 | string
+}
+
+// SetPointValue 给Struct的指针类型成员赋值
+func SetPointValue[T PointValue](value T) (field *T) {
+	field = new(T)
+	*field = value
+
+	return
+}