Quellcode durchsuchen

1.查期货账号 主账号增加期货公司字段
2.查交易账户 增加电话、状态字段

zou.yingbin vor 4 Jahren
Ursprung
Commit
4dd0ac243b
6 geänderte Dateien mit 253 neuen und 100 gelöschten Zeilen
  1. 5 8
      controllers/ermcp/qryAccMgr.go
  2. 63 2
      docs/docs.go
  3. 63 2
      docs/swagger.json
  4. 47 2
      docs/swagger.yaml
  5. 63 86
      models/ermcpAccMgr.go
  6. 12 0
      mtpcache/useraccount.go

+ 5 - 8
controllers/ermcp/qryAccMgr.go

@@ -56,12 +56,6 @@ func QueryAccMgrTaaccount(c *gin.Context) {
 	a.DoGetDataI(&m)
 }
 
-// QueryAccountReq 查主账号请求
-type QueryAccountReq struct {
-	UserId    int64  `form:"userid"`    // 用户id
-	AccountId string `form:"accountid"` // 主账号id
-}
-
 // QueryAccMgrMainAccountInfo
 // @Summary 查询账户管理主账号详情(账户管理/期货主账号详情)
 // @Produce json
@@ -74,9 +68,12 @@ type QueryAccountReq struct {
 // @Tags 企业风险管理(app)
 func QueryAccMgrMainAccountInfo(c *gin.Context) {
 	a := app.GinUtils{Gin: app.Gin{C: c}}
-	req := QueryAccountReq{}
+	req := struct {
+		UserId    int64 `form:"userid"`    // 用户id
+		AccountId int64 `form:"accountid"` // 主账号id
+	}{}
 	a.DoBindReq(&req)
-	m := models.MainAccountInfo{RELATEDUSERID: req.UserId, ACCOUNTID: req.AccountId}
+	m := models.MainAccountInfo{USERID: req.UserId, ACCOUNTID: req.AccountId}
 	a.DoGetDataI(&m)
 }
 

+ 63 - 2
docs/docs.go

@@ -17144,6 +17144,14 @@ var doc = `{
         "models.ErmcpLoginUserEx": {
             "type": "object",
             "properties": {
+                "accountstatus": {
+                    "description": "账户的状态 - 1:待激活 2:待审核 3:待复审 4:正常 5:审核拒绝 6:停用(注销) 7:注销(删除)",
+                    "type": "integer"
+                },
+                "mobile": {
+                    "description": "手机号",
+                    "type": "string"
+                },
                 "querytype": {
                     "description": "查询类型 1-业务账户 2-交易账户 3-管理账户",
                     "type": "integer"
@@ -18826,7 +18834,7 @@ var doc = `{
                 "mainAcc": {
                     "description": "主账号",
                     "type": "object",
-                    "$ref": "#/definitions/models.ErmcpTaAccount"
+                    "$ref": "#/definitions/models.ErmcpTaAccountM"
                 },
                 "subacclist": {
                     "description": "子账号列表",
@@ -19014,6 +19022,55 @@ var doc = `{
                 }
             }
         },
+        "models.ErmcpTaAccountM": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "账户id",
+                    "type": "integer"
+                },
+                "accountname": {
+                    "description": "账户名称",
+                    "type": "string"
+                },
+                "currencyid": {
+                    "description": "币种id",
+                    "type": "integer"
+                },
+                "fcid": {
+                    "description": "期货公司id",
+                    "type": "integer"
+                },
+                "fcname": {
+                    "description": "期货公司代码",
+                    "type": "string"
+                },
+                "hedgeaccountcode": {
+                    "description": "主账号登录代码(仅当是主账号时有值,子账号没有登录账号)",
+                    "type": "string"
+                },
+                "ismain": {
+                    "description": "是否主账户 0-否 1-是",
+                    "type": "integer"
+                },
+                "parentaccountid": {
+                    "description": "父账户id",
+                    "type": "integer"
+                },
+                "relateduserid": {
+                    "description": "关联userid",
+                    "type": "integer"
+                },
+                "tradestatus": {
+                    "description": "交易状态 - 1:正常 2:受限 3:冻结 4:禁止建仓(人工受限) 5:禁止交易(人工冻结) 6:待激活 7:已注销",
+                    "type": "integer"
+                },
+                "userid": {
+                    "description": "用户id",
+                    "type": "integer"
+                }
+            }
+        },
         "models.ErmcpTradeConfigTMP": {
             "type": "object",
             "properties": {
@@ -21569,7 +21626,7 @@ var doc = `{
             "properties": {
                 "accountid": {
                     "description": "账号id",
-                    "type": "string"
+                    "type": "integer"
                 },
                 "accountname": {
                     "description": "账号名称(taaccount表中的名称)",
@@ -21610,6 +21667,10 @@ var doc = `{
                 "relateduserid": {
                     "description": "关联用户id",
                     "type": "integer"
+                },
+                "userid": {
+                    "description": "关联用户id",
+                    "type": "integer"
                 }
             }
         },

+ 63 - 2
docs/swagger.json

@@ -17128,6 +17128,14 @@
         "models.ErmcpLoginUserEx": {
             "type": "object",
             "properties": {
+                "accountstatus": {
+                    "description": "账户的状态 - 1:待激活 2:待审核 3:待复审 4:正常 5:审核拒绝 6:停用(注销) 7:注销(删除)",
+                    "type": "integer"
+                },
+                "mobile": {
+                    "description": "手机号",
+                    "type": "string"
+                },
                 "querytype": {
                     "description": "查询类型 1-业务账户 2-交易账户 3-管理账户",
                     "type": "integer"
@@ -18810,7 +18818,7 @@
                 "mainAcc": {
                     "description": "主账号",
                     "type": "object",
-                    "$ref": "#/definitions/models.ErmcpTaAccount"
+                    "$ref": "#/definitions/models.ErmcpTaAccountM"
                 },
                 "subacclist": {
                     "description": "子账号列表",
@@ -18998,6 +19006,55 @@
                 }
             }
         },
+        "models.ErmcpTaAccountM": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "账户id",
+                    "type": "integer"
+                },
+                "accountname": {
+                    "description": "账户名称",
+                    "type": "string"
+                },
+                "currencyid": {
+                    "description": "币种id",
+                    "type": "integer"
+                },
+                "fcid": {
+                    "description": "期货公司id",
+                    "type": "integer"
+                },
+                "fcname": {
+                    "description": "期货公司代码",
+                    "type": "string"
+                },
+                "hedgeaccountcode": {
+                    "description": "主账号登录代码(仅当是主账号时有值,子账号没有登录账号)",
+                    "type": "string"
+                },
+                "ismain": {
+                    "description": "是否主账户 0-否 1-是",
+                    "type": "integer"
+                },
+                "parentaccountid": {
+                    "description": "父账户id",
+                    "type": "integer"
+                },
+                "relateduserid": {
+                    "description": "关联userid",
+                    "type": "integer"
+                },
+                "tradestatus": {
+                    "description": "交易状态 - 1:正常 2:受限 3:冻结 4:禁止建仓(人工受限) 5:禁止交易(人工冻结) 6:待激活 7:已注销",
+                    "type": "integer"
+                },
+                "userid": {
+                    "description": "用户id",
+                    "type": "integer"
+                }
+            }
+        },
         "models.ErmcpTradeConfigTMP": {
             "type": "object",
             "properties": {
@@ -21553,7 +21610,7 @@
             "properties": {
                 "accountid": {
                     "description": "账号id",
-                    "type": "string"
+                    "type": "integer"
                 },
                 "accountname": {
                     "description": "账号名称(taaccount表中的名称)",
@@ -21594,6 +21651,10 @@
                 "relateduserid": {
                     "description": "关联用户id",
                     "type": "integer"
+                },
+                "userid": {
+                    "description": "关联用户id",
+                    "type": "integer"
                 }
             }
         },

+ 47 - 2
docs/swagger.yaml

@@ -5795,6 +5795,12 @@ definitions:
     type: object
   models.ErmcpLoginUserEx:
     properties:
+      accountstatus:
+        description: 账户的状态 - 1:待激活 2:待审核 3:待复审 4:正常 5:审核拒绝 6:停用(注销) 7:注销(删除)
+        type: integer
+      mobile:
+        description: 手机号
+        type: string
       querytype:
         description: 查询类型 1-业务账户 2-交易账户 3-管理账户
         type: integer
@@ -7038,7 +7044,7 @@ definitions:
   models.ErmcpTaAccountEx:
     properties:
       mainAcc:
-        $ref: '#/definitions/models.ErmcpTaAccount'
+        $ref: '#/definitions/models.ErmcpTaAccountM'
         description: 主账号
         type: object
       subacclist:
@@ -7179,6 +7185,42 @@ definitions:
         description: 用户ID
         type: integer
     type: object
+  models.ErmcpTaAccountM:
+    properties:
+      accountid:
+        description: 账户id
+        type: integer
+      accountname:
+        description: 账户名称
+        type: string
+      currencyid:
+        description: 币种id
+        type: integer
+      fcid:
+        description: 期货公司id
+        type: integer
+      fcname:
+        description: 期货公司代码
+        type: string
+      hedgeaccountcode:
+        description: 主账号登录代码(仅当是主账号时有值,子账号没有登录账号)
+        type: string
+      ismain:
+        description: 是否主账户 0-否 1-是
+        type: integer
+      parentaccountid:
+        description: 父账户id
+        type: integer
+      relateduserid:
+        description: 关联userid
+        type: integer
+      tradestatus:
+        description: 交易状态 - 1:正常 2:受限 3:冻结 4:禁止建仓(人工受限) 5:禁止交易(人工冻结) 6:待激活 7:已注销
+        type: integer
+      userid:
+        description: 用户id
+        type: integer
+    type: object
   models.ErmcpTradeConfigTMP:
     properties:
       areauserid:
@@ -9109,7 +9151,7 @@ definitions:
     properties:
       accountid:
         description: 账号id
-        type: string
+        type: integer
       accountname:
         description: 账号名称(taaccount表中的名称)
         type: string
@@ -9140,6 +9182,9 @@ definitions:
       relateduserid:
         description: 关联用户id
         type: integer
+      userid:
+        description: 关联用户id
+        type: integer
     type: object
   models.Market:
     properties:

+ 63 - 86
models/ermcpAccMgr.go

@@ -17,32 +17,36 @@ import (
 
 // ErmcpLoginUserEx 登录账号(按角色)
 type ErmcpLoginUserEx struct {
-	ROLENAME  string           `json:"rolename"`  // 角色名称(交易账户->用户名称)
-	USERTYPE  int32            `json:"usertype"`  // 用户类型 2-机构 7-企业成员(云平台)
-	UserList  []ErmcpLoginUser `json:"userlist"`  // 用户列表
-	RoleId    int64            `json:"roleid"`    // 角色id(交易账户->用户id)
-	QUERYTYPE int32            `json:"querytype"` // 查询类型 1-业务账户 2-交易账户 3-管理账户
+	ROLENAME      string           `json:"rolename"`                              // 角色名称(交易账户->用户名称)
+	USERTYPE      int32            `json:"usertype"`                              // 用户类型 2-机构 7-企业成员(云平台)
+	UserList      []ErmcpLoginUser `json:"userlist"`                              // 用户列表
+	RoleId        int64            `json:"roleid"`                                // 角色id(交易账户->用户id)
+	MOBILE        string           `json:"mobile"  xorm:"'MOBILE'"`               // 手机号
+	ACCOUNTSTATUS int32            `json:"accountstatus"  xorm:"'ACCOUNTSTATUS'"` // 账户的状态 - 1:待激活 2:待审核 3:待复审 4:正常 5:审核拒绝 6:停用(注销) 7:注销(删除)
+	QUERYTYPE     int32            `json:"querytype"`                             // 查询类型 1-业务账户 2-交易账户 3-管理账户
 }
 
 // ErmcpLoginUser 查询登录账户
 type ErmcpLoginUser struct {
-	USERID       int64                 `json:"userid"  xorm:"'USERID'"`             // 用户id
-	MEMBERUSERID int64                 `json:"memberuserid"  xorm:"'MEMBERUSERID'"` // 所属会员id
-	ACCOUNTNAME  string                `json:"accountname"  xorm:"'ACCOUNTNAME'"`   // 用户名称
-	USERTYPE     int32                 `json:"usertype"  xorm:"'USERTYPE'"`         // 用户类型 -  1:交易所 2:机构 3:会员子机构 4:经纪人 5:投资者 6:客户 7:企业成员(云平台)
-	LOGINSTATUS  int32                 `json:"loginstatus"  xorm:"'LOGINSTATUS'"`   // 登录账户状态 - 1:正常 2:冻结 3:无效
-	CREATETIME   string                `json:"createtime"  xorm:"'CREATETIME'"`     // 创建时间
-	MODIFYTIME   string                `json:"modifytime"  xorm:"'MODIFYTIME'"`     // 修改时间
-	ROLETYPE     string                `json:"roletype"  xorm:"'ROLETYPE'"`         // 角色类型(逗号隔开,如22,23), 22:业务员 23:跟单员 24:交易员
-	CLIENTROLEID int32                 `json:"clientroleid"  xorm:"'CLIENTROLEID'"` // 角色id(usertype=2)
-	ROLENAME     string                `json:"rolename"  xorm:"'ROLENAME'"`         // 角色名称
-	ROLESTATUS   int32                 `json:"rolestatus"  xorm:"'ROLESTATUS'"`     // 角色状态 1-启用 2-停用
-	LOGINCODE    string                `json:"logincode"  xorm:"'LOGINCODE'"`       // 登录代码
-	LOGINID      int64                 `json:"loginid"  xorm:"'LOGINID'"`           // 登录id(LOGINID)
-	PASSWORD     string                `json:"password"  xorm:"'PASSWORD'"`         // 密码(不可解密)
-	MOBILE       string                `json:"mobile"  xorm:"'MOBILE'"`             // 手机号
-	LOGINNAME    string                `json:"loginname"  xorm:"'LOGINNAME'"`       // 登录名称(loginaccount表中的accountname字段)
-	AccList      []ErmcpLoginTaAccount `json:"acclist"`                             // 关联资金账号
+	USERID        int64                 `json:"userid"  xorm:"'USERID'"`             // 用户id
+	MEMBERUSERID  int64                 `json:"memberuserid"  xorm:"'MEMBERUSERID'"` // 所属会员id
+	ACCOUNTNAME   string                `json:"accountname"  xorm:"'ACCOUNTNAME'"`   // 用户名称
+	USERTYPE      int32                 `json:"usertype"  xorm:"'USERTYPE'"`         // 用户类型 -  1:交易所 2:机构 3:会员子机构 4:经纪人 5:投资者 6:客户 7:企业成员(云平台)
+	ACCOUNTSTATUS int32                 `json:"-"  xorm:"'ACCOUNTSTATUS'"`           // 所属账户的状态 - 1:待激活 2:待审核 3:待复审 4:正常 5:审核拒绝 6:停用(注销) 7:注销(删除)
+	LOGINSTATUS   int32                 `json:"loginstatus"  xorm:"'LOGINSTATUS'"`   // 登录账户状态 - 1:正常 2:冻结 3:无效
+	CREATETIME    string                `json:"createtime"  xorm:"'CREATETIME'"`     // 创建时间
+	MODIFYTIME    string                `json:"modifytime"  xorm:"'MODIFYTIME'"`     // 修改时间
+	ROLETYPE      string                `json:"roletype"  xorm:"'ROLETYPE'"`         // 角色类型(逗号隔开,如22,23), 22:业务员 23:跟单员 24:交易员
+	CLIENTROLEID  int32                 `json:"clientroleid"  xorm:"'CLIENTROLEID'"` // 角色id(usertype=2)
+	ROLENAME      string                `json:"rolename"  xorm:"'ROLENAME'"`         // 角色名称
+	ROLESTATUS    int32                 `json:"rolestatus"  xorm:"'ROLESTATUS'"`     // 角色状态 1-启用 2-停用
+	LOGINCODE     string                `json:"logincode"  xorm:"'LOGINCODE'"`       // 登录代码
+	LOGINID       int64                 `json:"loginid"  xorm:"'LOGINID'"`           // 登录id(LOGINID)
+	PASSWORD      string                `json:"password"  xorm:"'PASSWORD'"`         // 密码(不可解密)
+	MOBILE        string                `json:"mobile"  xorm:"'MOBILE'"`             // 手机号
+	LOGINNAME     string                `json:"loginname"  xorm:"'LOGINNAME'"`       // 登录名称(loginaccount表中的accountname字段)
+	USERMOBILE    string                `json:"-"  xorm:"'usermobile'"`              // 所属用户手机号码
+	AccList       []ErmcpLoginTaAccount `json:"acclist"`                             // 关联资金账号
 
 	QueryType int32 `json:"-"` // 过滤条件 查询类型 1-业务账户 2-交易账户 3-管理账户
 }
@@ -57,6 +61,7 @@ func (r *ErmcpLoginUser) addAcc(accLst []ErmcpLoginTaAccount) {
 
 func (r *ErmcpLoginUser) calc() {
 	r.MOBILE = DecryptField(r.MOBILE)
+	r.USERMOBILE = DecryptField(r.USERMOBILE)
 }
 
 func (r *ErmcpLoginUser) buildSqlRoleAcc() string {
@@ -66,6 +71,8 @@ func (r *ErmcpLoginUser) buildSqlRoleAcc() string {
 		"       t.memberuserid," +
 		"       t.usertype," +
 		"       t.accountname," +
+		"       t.accountstatus," +
+		"       u.mobile usermobile," +
 		"       to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime," +
 		"       to_char(t.modifytime, 'yyyy-mm-dd hh24:mi:ss') modifytime," +
 		"       r.roletype," +
@@ -81,6 +88,7 @@ func (r *ErmcpLoginUser) buildSqlRoleAcc() string {
 		"  from useraccount t" +
 		"  left join loginaccount l" +
 		"    on t.userid = l.userid" +
+		"  left join userinfo u on t.userid=u.userid" +
 		"  left join tmp r" +
 		"    on t.userid = r.userid" +
 		" where 1 = 1" +
@@ -120,61 +128,6 @@ func (r *ErmcpLoginUser) buildSqlManageAcc() string {
 	return sqlId.String()
 }
 
-func (r *ErmcpLoginUser) buildSql() string {
-	var sqlId utils.SQLVal = "with tmp as" +
-		" (select userid, wm_concat(roletype) roletype from arearole group by userid)" +
-		"select t.userid," +
-		"       t.memberuserid," +
-		"       t.usertype," +
-		"       t.accountname," +
-		"       to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime," +
-		"       to_char(t.modifytime, 'yyyy-mm-dd hh24:mi:ss') modifytime," +
-		"       r.roletype," +
-		"       1 as rolestatus," +
-		"       l.logincode," +
-		"       l.loginid," +
-		"       l.clientroleid," +
-		"       '企业成员' rolename," +
-		"       l.loginstatus," +
-		"       l.password," +
-		"       l.mobile" +
-		"  from useraccount t" +
-		"  left join loginaccount l" +
-		"    on t.userid = l.userid" +
-		"  left join tmp r" +
-		"    on t.userid = r.userid" +
-		" where 1 = 1" +
-		"   and t.memberuserid = %v" +
-		"   and t.usertype = 7" +
-		" union all " +
-		"select t.userid," +
-		"       t.memberuserid," +
-		"       t.usertype," +
-		"       t.accountname," +
-		"       to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime," +
-		"       to_char(t.modifytime, 'yyyy-mm-dd hh24:mi:ss') modifytime," +
-		"       to_char(r.roletype) roletype," +
-		"       r.rolestatus," +
-		"       l.logincode," +
-		"       l.loginid," +
-		"       l.clientroleid," +
-		"       Nvl(r.rolename, l.clientroleid) rolename," +
-		"       l.loginstatus," +
-		"       l.password," +
-		"       l.mobile" +
-		"  from useraccount t" +
-		"  left join loginaccount l" +
-		"    on t.userid = l.userid" +
-		"  left join systemmanagerrole r" +
-		"    on l.clientroleid = r.autoid" +
-		"   and r.areauserid = l.userid" +
-		" where 1 = 1" +
-		"   and t.userid = %v" +
-		"   and t.usertype = 2"
-	sqlId.FormatParam(r.USERID, r.USERID)
-	return sqlId.String()
-}
-
 // hasRoletype 是否拥用某种角色
 func (r *ErmcpLoginUser) hasRoletype(nType int32) bool {
 	sType := strings.Split(r.ROLETYPE, ",")
@@ -268,6 +221,7 @@ func (r *ErmcpLoginUser) getTradeLoginAcc() ([]ErmcpLoginUserEx, error) {
 			}
 			if !bExist {
 				val := ErmcpLoginUserEx{RoleId: v.USERID, ROLENAME: v.ACCOUNTNAME, USERTYPE: 7,
+					MOBILE: v.USERMOBILE, ACCOUNTSTATUS: v.ACCOUNTSTATUS,
 					UserList: make([]ErmcpLoginUser, 0), QUERYTYPE: r.QueryType}
 				if v.LOGINID > 0 {
 					val.UserList = append(val.UserList, v)
@@ -341,10 +295,17 @@ func (r *ErmcpLoginUser) GetDataEx() (interface{}, error) {
 
 // ErmcpTaAccount 期货账户(分组)
 type ErmcpTaAccountEx struct {
-	MainAcc    ErmcpTaAccount   `json:"mainAcc"`    // 主账号
+	MainAcc    ErmcpTaAccountM  `json:"mainAcc"`    // 主账号
 	SubAccList []ErmcpTaAccount `json:"subacclist"` // 子账号列表
 }
 
+// 显示主账户额外信息
+type ErmcpTaAccountM struct {
+	ErmcpTaAccount
+	FCID   int32  `json:"fcid"  xorm:"'FCID'"`     // 期货公司id
+	FCNAME string `json:"fcname"  xorm:"'FCNAME'"` // 期货公司代码
+}
+
 // ErmcpTaAccount 期货账户
 type ErmcpTaAccount struct {
 	ACCOUNTID       int64  `json:"accountid"  xorm:"'ACCOUNTID'"`             // 账户id
@@ -390,10 +351,25 @@ func (r *ErmcpTaAccount) GetDataEx() (interface{}, error) {
 	// 主账号
 	for i := range sData {
 		if sData[i].ISMAIN == 1 {
-			val := ErmcpTaAccountEx{MainAcc: sData[i], SubAccList: make([]ErmcpTaAccount, 0)}
+			val := ErmcpTaAccountEx{MainAcc: ErmcpTaAccountM{ErmcpTaAccount: sData[i]},
+				SubAccList: make([]ErmcpTaAccount, 0)}
 			sDataEx = append(sDataEx, val)
 		}
 	}
+	// 获取主账号额外信息
+	m := MainAccountInfo{USERID: r.USERID}
+	if d, err := m.GetDataEx(); err == nil {
+		if acc, ok := d.([]MainAccountInfo); ok {
+			for _, v := range acc {
+				for i := range sDataEx {
+					if sDataEx[i].MainAcc.ACCOUNTID == v.ACCOUNTID {
+						sDataEx[i].MainAcc.FCID = v.FCID
+						sDataEx[i].MainAcc.FCNAME = v.FCNAME
+					}
+				}
+			}
+		}
+	}
 	// 子账号
 	for i := range sData {
 		if sData[i].ISMAIN == 0 {
@@ -410,7 +386,7 @@ func (r *ErmcpTaAccount) GetDataEx() (interface{}, error) {
 
 // MainAccountInfo 主账号详情
 type MainAccountInfo struct {
-	ACCOUNTID        string `json:"accountid"  xorm:"'ACCOUNTID'"`               // 账号id
+	ACCOUNTID        int64  `json:"accountid"  xorm:"'ACCOUNTID'"`               // 账号id
 	HEDGEACCOUNTCODE string `json:"hedgeaccountcode"  xorm:"'HEDGEACCOUNTCODE'"` // 外部账号代码(主账号登录代码)
 	HEDGEACCOUNTPWD  string `json:"hedgeaccountpwd"  xorm:"'HEDGEACCOUNTPWD'"`   // 密码
 	AUTHCODE         string `json:"authcode"  xorm:"'AUTHCODE'"`                 // 授权码
@@ -419,6 +395,7 @@ type MainAccountInfo struct {
 	FCID             int32  `json:"fcid"  xorm:"'FCID'"`                         // 期货公司id
 	FCNAME           string `json:"fcname"  xorm:"'FCNAME'"`                     // 期货公司代码
 	ISMAIN           int32  `json:"ismain"  xorm:"'ISMAIN'"`                     // 是否主账号
+	USERID           int64  `json:"userid"  xorm:"'USERID'"`                     // 关联用户id
 	RELATEDUSERID    int64  `json:"relateduserid"  xorm:"'RELATEDUSERID'"`       // 关联用户id
 	ACCOUNTNAME      string `json:"accountname"  xorm:"'ACCOUNTNAME'"`           // 账号名称(taaccount表中的名称)
 }
@@ -438,6 +415,7 @@ func (r *MainAccountInfo) buildSql() string {
 		"       f.fcname," +
 		"       ta.ismain," +
 		"       ta.relateduserid," +
+		"       ta.userid," +
 		"       ta.accountname" +
 		"  from hedge_outmainconfig c" +
 		"  left join ERMCP_FuturesCompany f" +
@@ -445,12 +423,11 @@ func (r *MainAccountInfo) buildSql() string {
 		"  left join taaccount ta" +
 		"    on c.accountid = ta.accountid" +
 		" where 1 = 1"
-	if r.RELATEDUSERID > 0 {
-		sqlId.And("ta.relateduserid", r.RELATEDUSERID)
-	}
-	if len(r.ACCOUNTID) > 0 {
-		sqlId.And("c.ACCOUNTID", r.ACCOUNTID)
-	}
+
+	sqlId.AndEx("ta.userid", r.USERID, r.USERID > 0)
+	sqlId.AndEx("ta.relateduserid", r.RELATEDUSERID, r.RELATEDUSERID > 0)
+	sqlId.AndInterEx("c.ACCOUNTID", r.ACCOUNTID, r.ACCOUNTID > 0)
+
 	return sqlId.String()
 }
 

+ 12 - 0
mtpcache/useraccount.go

@@ -78,6 +78,12 @@ func (r *userAccountMgr) get(userId int64) string {
 		return ""
 	}
 
+	now := time.Now()
+	// 用户名可能会修改, 间隔5分钟失效, 返回空, 需要重新加载
+	if d := now.Sub(r.last); d.Seconds() > 300 {
+		return ""
+	}
+
 	if v, ok := r.data[userId]; ok {
 		return v.ACCOUNTNAME
 	}
@@ -93,6 +99,12 @@ func (r *userAccountMgr) getEx(userId int64) (string, string) {
 		return "", ""
 	}
 
+	now := time.Now()
+	// 用户名可能会修改, 间隔5分钟失效, 返回空, 需要重新加载
+	if d := now.Sub(r.last); d.Seconds() > 300 {
+		return "", ""
+	}
+
 	if v, ok := r.data[userId]; ok {
 		return v.ACCOUNTNAME, v.NICKNAME
 	}