Kaynağa Gözat

1.增加查询外部成交单关联接口
2.增加查询期货子账户接口
3.fix:查询期现关联单失败

zou.yingbin 4 yıl önce
ebeveyn
işleme
7446431b34
6 değiştirilmiş dosya ile 691 ekleme ve 1 silme
  1. 37 0
      controllers/ermcp3/qryErmcp3.go
  2. 198 0
      docs/docs.go
  3. 198 0
      docs/swagger.json
  4. 134 0
      docs/swagger.yaml
  5. 122 1
      models/ermcp3.go
  6. 2 0
      routers/router.go

+ 37 - 0
controllers/ermcp3/qryErmcp3.go

@@ -592,3 +592,40 @@ func QueryPaTradeLinkDetail(c *gin.Context) {
 	a.DoBindReq(&m)
 	a.DoGetDataI(&m)
 }
+
+// QueryOutTradeLink
+// @Summary 查询外部成交单关联
+// @Description 页面 app 现货->期现关联->外部成交单关联
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID(填登录用户的userid)"
+// @Param outtradeid query string false "外部订单号(模糊匹配)"
+// @Param goodsname query string false "合约名称/代码(模糊匹配)"
+// @Param hasinnerorder query int false "关联状态 0-未关联 1-已关联"
+// @Success 200 {array} models.Ermcp3OutTradeLink
+// @Failure 500 {object} app.Response
+// @Router /Ermcp3/QueryOutTradeLink [get]
+// @Tags 企业风险管理v3(app)
+func QueryOutTradeLink(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.Ermcp3OutTradeLink{HASINNERORDER: -1}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}
+
+// QuerySubTaaccount
+// @Summary 查询期货子账户
+// @Produce json
+// @Security ApiKeyAuth
+// @Param parentaccountid query int false "母账号id"
+// @Param parentaccountcode query string false "母账号代码"
+// @Success 200 {array} models.Ermcp3SubTaaccount
+// @Failure 500 {object} app.Response
+// @Router /Ermcp3/QuerySubTaaccount [get]
+// @Tags 企业风险管理v3(app)
+func QuerySubTaaccount(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.Ermcp3SubTaaccount{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}

+ 198 - 0
docs/docs.go

@@ -4564,6 +4564,67 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp3/QueryOutTradeLink": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "description": "页面 app 现货-\u003e期现关联-\u003e外部成交单关联",
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询外部成交单关联",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID(填登录用户的userid)",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "外部订单号(模糊匹配)",
+                        "name": "outtradeid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "合约名称/代码(模糊匹配)",
+                        "name": "goodsname",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "关联状态 0-未关联 1-已关联",
+                        "name": "hasinnerorder",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3OutTradeLink"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp3/QueryPaAreaAuditCfg": {
             "get": {
                 "security": [
@@ -5125,6 +5186,53 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp3/QuerySubTaaccount": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询期货子账户",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "母账号id",
+                        "name": "parentaccountid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "母账号代码",
+                        "name": "parentaccountcode",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3SubTaaccount"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Erms2/QueryArbitrageStrategy": {
             "get": {
                 "security": [
@@ -20954,6 +21062,67 @@ var doc = `{
                 }
             }
         },
+        "models.Ermcp3OutTradeLink": {
+            "type": "object",
+            "properties": {
+                "buyorsell": {
+                    "description": "买卖方向 - 0:买 1:卖",
+                    "type": "integer"
+                },
+                "channelbuildtype": {
+                    "description": "开平标志- 0:无 1:建仓 2:平仓",
+                    "type": "integer"
+                },
+                "currencyname": {
+                    "description": "币种名称",
+                    "type": "string"
+                },
+                "exexchangecode": {
+                    "description": "交易所代码",
+                    "type": "string"
+                },
+                "exexchangename": {
+                    "description": "交易所名称",
+                    "type": "string"
+                },
+                "goodscode": {
+                    "description": "合约代码",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "合约id",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "合约名称",
+                    "type": "string"
+                },
+                "hasinnerorder": {
+                    "description": "是否有内部单关联 - 0:无 1:有",
+                    "type": "integer"
+                },
+                "hedgeaccountcode": {
+                    "description": "外部账号 | 对冲账号",
+                    "type": "string"
+                },
+                "outtradeid": {
+                    "description": "外部订单号 | 外部成交单ID(114+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)",
+                    "type": "string"
+                },
+                "tradeprice": {
+                    "description": "成交价格",
+                    "type": "number"
+                },
+                "tradeqty": {
+                    "description": "成交数量",
+                    "type": "integer"
+                },
+                "tradetime": {
+                    "description": "成交时间",
+                    "type": "string"
+                }
+            }
+        },
         "models.Ermcp3PaAreaAuditCfg": {
             "type": "object",
             "properties": {
@@ -22067,6 +22236,35 @@ var doc = `{
                 }
             }
         },
+        "models.Ermcp3SubTaaccount": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "资金账户ID",
+                    "type": "integer"
+                },
+                "parentaccountcode": {
+                    "description": "所属根账号代码(母账号代码)",
+                    "type": "string"
+                },
+                "parentaccountid": {
+                    "description": "所属根账号(母账号)",
+                    "type": "integer"
+                },
+                "taname": {
+                    "description": "资金账号名称",
+                    "type": "string"
+                },
+                "tradestatus": {
+                    "description": "交易状态 - 1:正常 2:受限 3:冻结(停用) 4:禁止建仓(人工受限) 5:禁止交易(人工冻结) 6:待激活 7:已删除(注销)",
+                    "type": "integer"
+                },
+                "username": {
+                    "description": "交易用户",
+                    "type": "string"
+                }
+            }
+        },
         "models.Ermcp3TaFutuReDataReport": {
             "type": "object",
             "properties": {

+ 198 - 0
docs/swagger.json

@@ -4548,6 +4548,67 @@
                 }
             }
         },
+        "/Ermcp3/QueryOutTradeLink": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "description": "页面 app 现货-\u003e期现关联-\u003e外部成交单关联",
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询外部成交单关联",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID(填登录用户的userid)",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "外部订单号(模糊匹配)",
+                        "name": "outtradeid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "合约名称/代码(模糊匹配)",
+                        "name": "goodsname",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "关联状态 0-未关联 1-已关联",
+                        "name": "hasinnerorder",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3OutTradeLink"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp3/QueryPaAreaAuditCfg": {
             "get": {
                 "security": [
@@ -5109,6 +5170,53 @@
                 }
             }
         },
+        "/Ermcp3/QuerySubTaaccount": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v3(app)"
+                ],
+                "summary": "查询期货子账户",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "母账号id",
+                        "name": "parentaccountid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "母账号代码",
+                        "name": "parentaccountcode",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcp3SubTaaccount"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Erms2/QueryArbitrageStrategy": {
             "get": {
                 "security": [
@@ -20938,6 +21046,67 @@
                 }
             }
         },
+        "models.Ermcp3OutTradeLink": {
+            "type": "object",
+            "properties": {
+                "buyorsell": {
+                    "description": "买卖方向 - 0:买 1:卖",
+                    "type": "integer"
+                },
+                "channelbuildtype": {
+                    "description": "开平标志- 0:无 1:建仓 2:平仓",
+                    "type": "integer"
+                },
+                "currencyname": {
+                    "description": "币种名称",
+                    "type": "string"
+                },
+                "exexchangecode": {
+                    "description": "交易所代码",
+                    "type": "string"
+                },
+                "exexchangename": {
+                    "description": "交易所名称",
+                    "type": "string"
+                },
+                "goodscode": {
+                    "description": "合约代码",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "合约id",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "合约名称",
+                    "type": "string"
+                },
+                "hasinnerorder": {
+                    "description": "是否有内部单关联 - 0:无 1:有",
+                    "type": "integer"
+                },
+                "hedgeaccountcode": {
+                    "description": "外部账号 | 对冲账号",
+                    "type": "string"
+                },
+                "outtradeid": {
+                    "description": "外部订单号 | 外部成交单ID(114+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)",
+                    "type": "string"
+                },
+                "tradeprice": {
+                    "description": "成交价格",
+                    "type": "number"
+                },
+                "tradeqty": {
+                    "description": "成交数量",
+                    "type": "integer"
+                },
+                "tradetime": {
+                    "description": "成交时间",
+                    "type": "string"
+                }
+            }
+        },
         "models.Ermcp3PaAreaAuditCfg": {
             "type": "object",
             "properties": {
@@ -22051,6 +22220,35 @@
                 }
             }
         },
+        "models.Ermcp3SubTaaccount": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "资金账户ID",
+                    "type": "integer"
+                },
+                "parentaccountcode": {
+                    "description": "所属根账号代码(母账号代码)",
+                    "type": "string"
+                },
+                "parentaccountid": {
+                    "description": "所属根账号(母账号)",
+                    "type": "integer"
+                },
+                "taname": {
+                    "description": "资金账号名称",
+                    "type": "string"
+                },
+                "tradestatus": {
+                    "description": "交易状态 - 1:正常 2:受限 3:冻结(停用) 4:禁止建仓(人工受限) 5:禁止交易(人工冻结) 6:待激活 7:已删除(注销)",
+                    "type": "integer"
+                },
+                "username": {
+                    "description": "交易用户",
+                    "type": "string"
+                }
+            }
+        },
         "models.Ermcp3TaFutuReDataReport": {
             "type": "object",
             "properties": {

+ 134 - 0
docs/swagger.yaml

@@ -5532,6 +5532,51 @@ definitions:
         description: 品类单位名称
         type: string
     type: object
+  models.Ermcp3OutTradeLink:
+    properties:
+      buyorsell:
+        description: 买卖方向 - 0:买 1:卖
+        type: integer
+      channelbuildtype:
+        description: 开平标志- 0:无 1:建仓 2:平仓
+        type: integer
+      currencyname:
+        description: 币种名称
+        type: string
+      exexchangecode:
+        description: 交易所代码
+        type: string
+      exexchangename:
+        description: 交易所名称
+        type: string
+      goodscode:
+        description: 合约代码
+        type: string
+      goodsid:
+        description: 合约id
+        type: integer
+      goodsname:
+        description: 合约名称
+        type: string
+      hasinnerorder:
+        description: 是否有内部单关联 - 0:无 1:有
+        type: integer
+      hedgeaccountcode:
+        description: 外部账号 | 对冲账号
+        type: string
+      outtradeid:
+        description: 外部订单号 | 外部成交单ID(114+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
+        type: string
+      tradeprice:
+        description: 成交价格
+        type: number
+      tradeqty:
+        description: 成交数量
+        type: integer
+      tradetime:
+        description: 成交时间
+        type: string
+    type: object
   models.Ermcp3PaAreaAuditCfg:
     properties:
       areauserid:
@@ -6360,6 +6405,27 @@ definitions:
         description: 品类名称
         type: string
     type: object
+  models.Ermcp3SubTaaccount:
+    properties:
+      accountid:
+        description: 资金账户ID
+        type: integer
+      parentaccountcode:
+        description: 所属根账号代码(母账号代码)
+        type: string
+      parentaccountid:
+        description: 所属根账号(母账号)
+        type: integer
+      taname:
+        description: 资金账号名称
+        type: string
+      tradestatus:
+        description: 交易状态 - 1:正常 2:受限 3:冻结(停用) 4:禁止建仓(人工受限) 5:禁止交易(人工冻结) 6:待激活 7:已删除(注销)
+        type: integer
+      username:
+        description: 交易用户
+        type: string
+    type: object
   models.Ermcp3TaFutuReDataReport:
     properties:
       accountid:
@@ -21295,6 +21361,45 @@ paths:
       summary: 查询套保品种详情(套保品种/商品详情)
       tags:
       - 企业风险管理v3(app)
+  /Ermcp3/QueryOutTradeLink:
+    get:
+      description: 页面 app 现货->期现关联->外部成交单关联
+      parameters:
+      - description: 用户ID(填登录用户的userid)
+        in: query
+        name: userid
+        required: true
+        type: integer
+      - description: 外部订单号(模糊匹配)
+        in: query
+        name: outtradeid
+        type: string
+      - description: 合约名称/代码(模糊匹配)
+        in: query
+        name: goodsname
+        type: string
+      - description: 关联状态 0-未关联 1-已关联
+        in: query
+        name: hasinnerorder
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Ermcp3OutTradeLink'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询外部成交单关联
+      tags:
+      - 企业风险管理v3(app)
   /Ermcp3/QueryPaAreaAuditCfg:
     get:
       parameters:
@@ -21654,6 +21759,35 @@ paths:
       summary: 查询现货市价详情(现货市价/详情)
       tags:
       - 企业风险管理v3(app)
+  /Ermcp3/QuerySubTaaccount:
+    get:
+      parameters:
+      - description: 母账号id
+        in: query
+        name: parentaccountid
+        type: integer
+      - description: 母账号代码
+        in: query
+        name: parentaccountcode
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Ermcp3SubTaaccount'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询期货子账户
+      tags:
+      - 企业风险管理v3(app)
   /Erms2/QueryArbitrageStrategy:
     get:
       parameters:

+ 122 - 1
models/ermcp3.go

@@ -2898,7 +2898,7 @@ type Ermcp3PaTradeLink struct {
 	MIDDLEGOODSQTY    float64 `json:"middlegoodsqty"  xorm:"MIDDLEGOODSQTY"`        // 套保品种数量 = TradeQty * AgreeUnit * ConvertRatio
 	RELATEDQTY        float64 `json:"relatedqty"  xorm:"RELATEDQTY"`                // 关联数量
 	RELATEDLOT        float64 `json:"relatedlot"  xorm:"RELATEDLOT"`                // 已关联数量(已关联数量手) | db:关联手数
-	AREAUSERID        string  `json:"userid"  xorm:"AREAUSERID" form:"areauserid"`  // 所属机构 - 所属母账户的UserID
+	AREAUSERID        string  `json:"userid"  xorm:"AREAUSERID" form:"userid"`      // 所属机构 - 所属母账户的UserID
 
 	GOODSCODE     string `json:"goodscode"  xorm:"'GOODSCODE'"`         // 合约代码
 	GOODSNAME     string `json:"goodsname"  xorm:"'GOODSNAME'"`         // 合约名称
@@ -3194,3 +3194,124 @@ func (r *Ermcp3TradeLinkDetail) GetDataEx() (interface{}, error) {
 	}
 	return sData, err
 }
+
+// Ermcp3OutTradeLink 外部成交单关联
+type Ermcp3OutTradeLink struct {
+	GOODSID          int32   `json:"goodsid"  xorm:"'GOODSID'"`                                  // 合约id
+	GOODSCODE        string  `json:"goodscode"  xorm:"'GOODSCODE'" form:"goodscode"`             // 合约代码
+	GOODSNAME        string  `json:"goodsname"  xorm:"'GOODSNAME'" form:"goodsname"`             // 合约名称
+	TRADETIME        string  `json:"tradetime"  xorm:"'TRADETIME'"`                              // 成交时间
+	HEDGEACCOUNTCODE string  `json:"hedgeaccountcode"  xorm:"'HEDGEACCOUNTCODE'"`                // 外部账号 | 对冲账号
+	BUYORSELL        int32   `json:"buyorsell"  xorm:"'BUYORSELL'"`                              // 买卖方向 - 0:买 1:卖
+	TRADEQTY         int64   `json:"tradeqty"  xorm:"'TRADEQTY'"`                                // 成交数量
+	TRADEPRICE       float64 `json:"tradeprice"  xorm:"'TRADEPRICE'"`                            // 成交价格
+	HASINNERORDER    int32   `json:"hasinnerorder"  xorm:"'HASINNERORDER'" form:"hasinnerorder"` // 是否有内部单关联 - 0:无 1:有
+	CHANNELBUILDTYPE int32   `json:"channelbuildtype"  xorm:"'CHANNELBUILDTYPE'"`                // 开平标志- 0:无 1:建仓 2:平仓
+	OUTTRADEID       string  `json:"outtradeid"  xorm:"'OUTTRADEID'" form:"outtradeid"`          // 外部订单号 | 外部成交单ID(114+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
+	EXEXCHANGECODE   string  `json:"exexchangecode"  xorm:"'EXEXCHANGECODE'"`                    // 交易所代码
+	EXEXCHANGENAME   string  `json:"exexchangename"  xorm:"'EXEXCHANGENAME'"`                    // 交易所名称
+	CURRENCYID       int32   `json:"-"  xorm:"'CURRENCYID'"`                                     // 币种id
+	CURRENCYNAME     string  `json:"currencyname"  xorm:"'CURRENCYNAME'"`                        // 币种名称
+
+	USERID int64 `json:"-" form:"userid"` // 用户id, 用于过滤
+}
+
+func (r *Ermcp3OutTradeLink) calc() {
+
+}
+
+func (r *Ermcp3OutTradeLink) buildSql() string {
+	var sqlId utils.SQLVal = `
+select g.goodsid,
+       g.goodscode,
+       g.goodsname,
+       to_char(t.tradetime, 'yyyy-mm-dd hh24:mi:ss') tradetime,
+       c.hedgeaccountcode,
+       t.buyorsell,
+       t.tradeqty,
+       t.tradeprice,
+       t.hasinnerorder,
+       t.channelbuildtype,
+       to_char(t.outtradeid) outtradeid,
+       ex.exexchangecode,
+       ex.exexchangename,
+       ta.currencyid,
+       e.enumdicname currencyname
+  from hedge_outtradedetail t
+ inner join goods g
+    on t.hedgegoodsid = g.goodsid
+  left join goodsgroup gp
+    on g.goodsgroupid = gp.goodsgroupid
+  left join externalexchange ex
+    on gp.exexchangeid = ex.autoid
+  left join hedge_outmainconfig c
+    on t.accountid = c.accountid
+  left join taaccount ta
+    on t.accountid = ta.accountid
+  left join enumdicitem e
+    on ta.currencyid = e.enumitemname
+   and e.enumdiccode = 'currency'
+ where 1 = 1
+   and %v in (ta.userid, ta.relateduserid)
+`
+	sqlId.FormatParam(r.USERID)
+	sqlId.AndEx("t.hasinnerorder", r.HASINNERORDER, r.HASINNERORDER != -1)
+	sqlId.AndLike("t.outtradeid", r.OUTTRADEID)
+	sqlId.AndLike("g.goodscode||g.goodsname", r.GOODSNAME)
+	sqlId.Join(" order by t.tradetime desc")
+	return sqlId.String()
+}
+
+// GetDataEx 获取外部成交单关联
+func (r *Ermcp3OutTradeLink) GetDataEx() (interface{}, error) {
+	sData := make([]Ermcp3OutTradeLink, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}
+
+// Ermcp3SubTaaccount 期货子账户
+type Ermcp3SubTaaccount struct {
+	ACCOUNTID         int64  `json:"accountid"  xorm:"'ACCOUNTID'"`                                          // 资金账户ID
+	TANAME            string `json:"taname"  xorm:"'TANAME'"`                                                // 资金账号名称
+	TRADESTATUS       int32  `json:"tradestatus"  xorm:"'TRADESTATUS'"`                                      // 交易状态 - 1:正常 2:受限 3:冻结(停用) 4:禁止建仓(人工受限) 5:禁止交易(人工冻结) 6:待激活 7:已删除(注销)
+	PARENTACCOUNTID   int64  `json:"parentaccountid"  xorm:"'PARENTACCOUNTID'" form:"parentaccountid"`       // 所属根账号(母账号)
+	PARENTACCOUNTCODE string `json:"parentaccountcode"  xorm:"'PARENTACCOUNTCODE'" form:"parentaccountcode"` // 所属根账号代码(母账号代码)
+	USERNAME          string `json:"username"  xorm:"'USERNAME'"`                                            // 交易用户
+}
+
+func (r *Ermcp3SubTaaccount) calc() {
+
+}
+
+func (r *Ermcp3SubTaaccount) buildSql() string {
+	var sqlId utils.SQLVal = `
+select t.accountid,
+       t.accountname      taname,
+       t.tradestatus,
+       t.parentaccountid,
+       c.hedgeaccountcode parentaccountcode,
+       u.accountname      username
+  from taaccount t
+ inner join hedge_outmainconfig c
+    on t.parentaccountid = c.accountid
+  left join useraccount u
+    on t.relateduserid = u.userid
+ where 1 = 1 and t.ismain=0
+`
+	sqlId.AndEx("t.parentaccountid", r.PARENTACCOUNTID, r.PARENTACCOUNTID > 0)
+	sqlId.AndEx("c.hedgeaccountcode", r.PARENTACCOUNTCODE, r.PARENTACCOUNTCODE != "")
+	return sqlId.String()
+}
+
+// GetDataEx 获取期货子账户
+func (r *Ermcp3SubTaaccount) GetDataEx() (interface{}, error) {
+	sData := make([]Ermcp3SubTaaccount, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}

+ 2 - 0
routers/router.go

@@ -444,6 +444,8 @@ func InitRouter() *gin.Engine {
 		ermcp3R.GET("/QueryPaTradeLink", ermcp3.QueryPaTradeLink)
 		ermcp3R.GET("/QuerySCMiddleGoods", ermcp3.QuerySCMiddleGoods)
 		ermcp3R.GET("/QueryPaTradeLinkDetail", ermcp3.QueryPaTradeLinkDetail)
+		ermcp3R.GET("/QueryOutTradeLink", ermcp3.QueryOutTradeLink)
+		ermcp3R.GET("/QuerySubTaaccount", ermcp3.QuerySubTaaccount)
 
 		// 报表
 		ermcp3R.GET("/QryReportDaySpotDetail", ermcp3.QryReportDaySpotDetail)