|
|
@@ -114,28 +114,45 @@ func getQuoteMenu(loginID int) ([]QuotePrimaryMenu, error) {
|
|
|
engine := db.GetEngine()
|
|
|
rst := make([]QuotePrimaryMenu, 0)
|
|
|
|
|
|
- // ********************* 准备数据 *********************
|
|
|
- var taAccounts []string // 账户下所有资金账户
|
|
|
- var marketIDs []int // 资金账户下有权限的市场ID列表
|
|
|
- // 先要获取当前登录账户对应的资金账户
|
|
|
- if err := engine.SQL(fmt.Sprintf(`select to_char(AccountID) from LoginTAAccount where LoginID = %d`, loginID)).Find(&taAccounts); err != nil {
|
|
|
+ // 账户下有权限的市场ID列表
|
|
|
+ var marketIDs []int
|
|
|
+
|
|
|
+ // 获取账户类型 - 1:交易所 2:机构 3:会员子机构 4:经纪人 5:投资者 6:客户 (目前可能登录交易端的账号类型为 2 5)
|
|
|
+ userAccount := new(models.Useraccount)
|
|
|
+ has, err := engine.Join("INNER", "LOGINACCOUNT", "USERACCOUNT.UserID = LOGINACCOUNT.UserID").Where("LOGINACCOUNT.LoginID = ?", loginID).Get(userAccount)
|
|
|
+ if err != nil || !has {
|
|
|
return nil, err
|
|
|
}
|
|
|
- // 如果一条记录都没有则直接通过资金账户表获取
|
|
|
- if len(taAccounts) == 0 {
|
|
|
- sql := fmt.Sprintf(`select to_char(ta.accountid) from taaccount ta
|
|
|
- inner join loginaccount l on ta.userid = l.userid
|
|
|
- where l.loginid = %d`, loginID)
|
|
|
- if err := engine.SQL(sql).Find(&taAccounts); err != nil {
|
|
|
+ if userAccount.Usertype == 5 {
|
|
|
+ // 如果账户类型为5(投资者),则需要通过其所属经济会员来获取市场权限(表:AreaRoleMarket, 条件:对应市场状态为正常;角色类型:经济会员)
|
|
|
+ if err := engine.Table("AREAROLEMARKET").Cols("AREAROLEMARKET.MARKETID").Join("INNER", "MARKET", "MARKET.MARKETID = AREAROLEMARKET.MARKETID").Where("MARKET.MARKETSTATUS = 2 and AREAROLEMARKET.ROLETYPE = 7 and AREAROLEMARKET.AREAUSERID = ?", userAccount.Memberuserid).Find(&marketIDs); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- }
|
|
|
- // 获取资金账户对应的市场权限(有权限的市场ID)
|
|
|
- if len(taAccounts) > 0 {
|
|
|
- taAccountStr := strings.Join(taAccounts, ",")
|
|
|
- if err := engine.SQL(fmt.Sprintf(`select MarketID from TAAccountMarket where AccountID in (%s)`, taAccountStr)).Find(&marketIDs); err != nil {
|
|
|
+ } else {
|
|
|
+ // 非投资者账号直接通过资金账号获取市场权限(表:TAAccountMarket)
|
|
|
+ var taAccounts []string // 账户下所有资金账户
|
|
|
+
|
|
|
+ // 先要获取当前登录账户对应的资金账户
|
|
|
+ if err := engine.SQL(fmt.Sprintf(`select to_char(AccountID) from LoginTAAccount where LoginID = %d`, loginID)).Find(&taAccounts); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
+
|
|
|
+ // 如果一条记录都没有则直接通过资金账户表获取
|
|
|
+ if len(taAccounts) == 0 {
|
|
|
+ sql := fmt.Sprintf(`select to_char(ta.accountid) from taaccount ta
|
|
|
+ inner join loginaccount l on ta.userid = l.userid
|
|
|
+ where l.loginid = %d`, loginID)
|
|
|
+ if err := engine.SQL(sql).Find(&taAccounts); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 获取资金账户对应的市场权限(有权限的市场ID)
|
|
|
+ if len(taAccounts) > 0 {
|
|
|
+ taAccountStr := strings.Join(taAccounts, ",")
|
|
|
+ if err := engine.SQL(fmt.Sprintf(`select MarketID from TAAccountMarket where AccountID in (%s)`, taAccountStr)).Find(&marketIDs); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// ********************* 构建行情报价牌菜单 *********************
|