|
|
@@ -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()
|
|
|
}
|
|
|
|