Просмотр исходного кода

#7271 【Go查询】接口”api/Order/QueryTradeHolderDetail“:返回字段添加止盈止损设置(trade_holdertpslorder表)

deng.yinping 3 недель назад
Родитель
Сommit
1f6a41e4a5
5 измененных файлов с 144 добавлено и 9 удалено
  1. 2 1
      controllers/tradexx/qryTradexx.go
  2. 43 1
      docs/docs.go
  3. 43 1
      docs/swagger.json
  4. 31 0
      docs/swagger.yaml
  5. 25 6
      models/tradexx.go

+ 2 - 1
controllers/tradexx/qryTradexx.go

@@ -17,11 +17,12 @@ import (
 // @Summary  查询持仓明细
 // @Produce  json
 // @Security ApiKeyAuth
-// @Param    userid          query    int    false "用户id"
+// @Param    userid          query    int    true "用户id"
 // @Param    accids          query    string false "资金账号, 格式 1,2,3"
 // @Param    trademodes      query    string false "交易模式, 格式 1,2,3"
 // @Param    marketids       query    string false "市场id, 格式 1,2,3"
 // @Param    goodsid         query    int    false "商品id"
+// @Param    tradeid		 query    string false "成交单号"
 // @Param    buyorsell       query    int    false "买卖方向 0-买 1-卖"
 // @Param    riskcontrolmode query    int    false "风控方式(52模式) 1:按单风控 2:按账户风控"
 // @Success  200             {array}  models.TradeHolderDetail

+ 43 - 1
docs/docs.go

@@ -15602,7 +15602,8 @@ const docTemplate = `{
                         "type": "integer",
                         "description": "用户id",
                         "name": "userid",
-                        "in": "query"
+                        "in": "query",
+                        "required": true
                     },
                     {
                         "type": "string",
@@ -15629,6 +15630,12 @@ const docTemplate = `{
                         "in": "query"
                     },
                     {
+                        "type": "string",
+                        "description": "成交单号",
+                        "name": "tradeid",
+                        "in": "query"
+                    },
+                    {
                         "type": "integer",
                         "description": "买卖方向 0-买 1-卖",
                         "name": "buyorsell",
@@ -59650,6 +59657,9 @@ const docTemplate = `{
         },
         "models.TradeHolderDetail": {
             "type": "object",
+            "required": [
+                "userid"
+            ],
             "properties": {
                 "accountid": {
                     "description": "账号ID",
@@ -59799,6 +59809,38 @@ const docTemplate = `{
                     "description": "资金账号名称",
                     "type": "string"
                 },
+                "tpsl_executeprice": {
+                    "description": "执行价格(10按账户风控)",
+                    "type": "string"
+                },
+                "tpsl_executeretcode": {
+                    "description": "执行错误代码(10按账户风控)",
+                    "type": "integer"
+                },
+                "tpsl_executetime": {
+                    "description": "执行时间(10按账户风控)",
+                    "type": "string"
+                },
+                "tpsl_orderstatus": {
+                    "description": "止盈止损单状态 - 1:待执行 2:执行中 3:已执行 4:已失效 5:执行失败(10按账户风控)",
+                    "type": "integer"
+                },
+                "tpsl_slflag": {
+                    "description": "止损标识 - 0:未设置 1:已设置(10按账户风控)",
+                    "type": "integer"
+                },
+                "tpsl_slprice": {
+                    "description": "止损价格(10按账户风控)",
+                    "type": "string"
+                },
+                "tpsl_tpflag": {
+                    "description": "止盈标识 - 0:未设置 1:已设置(10按账户风控)",
+                    "type": "integer"
+                },
+                "tpsl_tpprice": {
+                    "description": "止盈价格(10按账户风控)",
+                    "type": "string"
+                },
                 "tradeamount": {
                     "description": "成交金额",
                     "type": "number"

+ 43 - 1
docs/swagger.json

@@ -15594,7 +15594,8 @@
                         "type": "integer",
                         "description": "用户id",
                         "name": "userid",
-                        "in": "query"
+                        "in": "query",
+                        "required": true
                     },
                     {
                         "type": "string",
@@ -15621,6 +15622,12 @@
                         "in": "query"
                     },
                     {
+                        "type": "string",
+                        "description": "成交单号",
+                        "name": "tradeid",
+                        "in": "query"
+                    },
+                    {
                         "type": "integer",
                         "description": "买卖方向 0-买 1-卖",
                         "name": "buyorsell",
@@ -59642,6 +59649,9 @@
         },
         "models.TradeHolderDetail": {
             "type": "object",
+            "required": [
+                "userid"
+            ],
             "properties": {
                 "accountid": {
                     "description": "账号ID",
@@ -59791,6 +59801,38 @@
                     "description": "资金账号名称",
                     "type": "string"
                 },
+                "tpsl_executeprice": {
+                    "description": "执行价格(10按账户风控)",
+                    "type": "string"
+                },
+                "tpsl_executeretcode": {
+                    "description": "执行错误代码(10按账户风控)",
+                    "type": "integer"
+                },
+                "tpsl_executetime": {
+                    "description": "执行时间(10按账户风控)",
+                    "type": "string"
+                },
+                "tpsl_orderstatus": {
+                    "description": "止盈止损单状态 - 1:待执行 2:执行中 3:已执行 4:已失效 5:执行失败(10按账户风控)",
+                    "type": "integer"
+                },
+                "tpsl_slflag": {
+                    "description": "止损标识 - 0:未设置 1:已设置(10按账户风控)",
+                    "type": "integer"
+                },
+                "tpsl_slprice": {
+                    "description": "止损价格(10按账户风控)",
+                    "type": "string"
+                },
+                "tpsl_tpflag": {
+                    "description": "止盈标识 - 0:未设置 1:已设置(10按账户风控)",
+                    "type": "integer"
+                },
+                "tpsl_tpprice": {
+                    "description": "止盈价格(10按账户风控)",
+                    "type": "string"
+                },
                 "tradeamount": {
                     "description": "成交金额",
                     "type": "number"

+ 31 - 0
docs/swagger.yaml

@@ -25997,6 +25997,30 @@ definitions:
       taname:
         description: 资金账号名称
         type: string
+      tpsl_executeprice:
+        description: 执行价格(10按账户风控)
+        type: string
+      tpsl_executeretcode:
+        description: 执行错误代码(10按账户风控)
+        type: integer
+      tpsl_executetime:
+        description: 执行时间(10按账户风控)
+        type: string
+      tpsl_orderstatus:
+        description: 止盈止损单状态 - 1:待执行 2:执行中 3:已执行 4:已失效 5:执行失败(10按账户风控)
+        type: integer
+      tpsl_slflag:
+        description: 止损标识 - 0:未设置 1:已设置(10按账户风控)
+        type: integer
+      tpsl_slprice:
+        description: 止损价格(10按账户风控)
+        type: string
+      tpsl_tpflag:
+        description: 止盈标识 - 0:未设置 1:已设置(10按账户风控)
+        type: integer
+      tpsl_tpprice:
+        description: 止盈价格(10按账户风控)
+        type: string
       tradeamount:
         description: 成交金额
         type: number
@@ -26022,6 +26046,8 @@ definitions:
       username:
         description: 用户名称
         type: string
+    required:
+    - userid
     type: object
   models.TradeHolderDetailEx:
     properties:
@@ -42720,6 +42746,7 @@ paths:
       - description: 用户id
         in: query
         name: userid
+        required: true
         type: integer
       - description: 资金账号, 格式 1,2,3
         in: query
@@ -42737,6 +42764,10 @@ paths:
         in: query
         name: goodsid
         type: integer
+      - description: 成交单号
+        in: query
+        name: tradeid
+        type: string
       - description: 买卖方向 0-买 1-卖
         in: query
         name: buyorsell

+ 25 - 6
models/tradexx.go

@@ -33,10 +33,10 @@ type TradeGoodsEx struct {
 
 // TradeAccountEx 交易账户相关字段
 type TradeAccountEx struct {
-	TANAME       string `json:"taname"  xorm:"'TANAME'"`               // 资金账号名称
-	USERID       int64  `json:"userid"  xorm:"'USERID'" form:"userid"` // 用户id
-	USERNAME     string `json:"username"  xorm:"'USERNAME'"`           // 用户名称
-	TaCurrencyid int64  `json:"tacurrencyid"  xorm:"'TACURRENCYID'"`   // 报价货币ID - taaccount
+	TANAME       string `json:"taname"  xorm:"'TANAME'"`                                  // 资金账号名称
+	USERID       int64  `json:"userid"  xorm:"'USERID'" form:"userid" binding:"required"` // 用户id
+	USERNAME     string `json:"username"  xorm:"'USERNAME'"`                              // 用户名称
+	TaCurrencyid int64  `json:"tacurrencyid"  xorm:"'TACURRENCYID'"`                      // 报价货币ID - taaccount
 }
 
 // TradePosition 持仓汇总
@@ -217,6 +217,15 @@ type TradeHolderDetail struct {
 	FtTradeMode     string `json:"-" form:"trademodes"`                                           // 交易模式筛选, 逗号隔开
 	FtMarketIDs     string `json:"-" form:"marketids"`                                            // 市场id, 逗号隔开
 	RISKCONTROLMODE int32  `json:"riskcontrolmode" form:"riskcontrolmode" xorm:"RISKCONTROLMODE"` // 风控方式(52模式) 1:按单风控 2:按账户风控
+
+	TPSL_TPFLAG         int32  `json:"tpsl_tpflag" xorm:"TPFLAG"`                 // 止盈标识 - 0:未设置 1:已设置(10按账户风控)
+	TPSL_TPPRICE        string `json:"tpsl_tpprice" xorm:"TPPRICE"`               // 止盈价格(10按账户风控)
+	TPSL_SLFLAG         int32  `json:"tpsl_slflag" xorm:"SLFLAG"`                 // 止损标识 - 0:未设置 1:已设置(10按账户风控)
+	TPSL_SLPRICE        string `json:"tpsl_slprice" xorm:"SLPRICE"`               // 止损价格(10按账户风控)
+	TPSL_ORDERSTATUS    int32  `json:"tpsl_orderstatus" xorm:"TPSL_ORDERSTATUS"`  // 止盈止损单状态 - 1:待执行 2:执行中 3:已执行 4:已失效 5:执行失败(10按账户风控)
+	TPSL_EXECUTETIME    string `json:"tpsl_executetime" xorm:"EXECUTETIME"`       // 执行时间(10按账户风控)
+	TPSL_EXECUTEPRICE   string `json:"tpsl_executeprice" xorm:"EXECUTEPRICE"`     // 执行价格(10按账户风控)
+	TPSL_EXECUTERETCODE int32  `json:"tpsl_executeretcode" xorm:"EXECUTERETCODE"` // 执行错误代码(10按账户风控)
 }
 
 func (r *TradeHolderDetail) calc() {
@@ -293,17 +302,27 @@ SELECT to_char(t.TRADEID) TRADEID,
        t.HOLDERCREDIT,
        t.RELEASEHOLDERCREDIT,
        gtmp.*,
-       utmp.*
+       utmp.*,
+	   tpsl.TPFLAG,
+	   tpsl.TPPRICE,
+	   tpsl.SLFLAG,
+	   tpsl.SLPRICE,
+	   tpsl.ORDERSTATUS TPSL_ORDERSTATUS,
+	   TO_CHAR(tpsl.EXECUTETIME, 'YYYY-MM-DD HH24:MI:SS') EXECUTETIME,
+	   tpsl.EXECUTEPRICE, 
+	   tpsl.EXECUTERETCODE
   FROM TRADE_HOLDERDETAIL t
   INNER JOIN gtmp on t.goodsid=gtmp.goodsid
   LEFT JOIN utmp on t.accountid=utmp.accountid
- WHERE 1 = 1 and t.HOLDERQTY > 0
+  LEFT JOIN trade_holdertpslorder tpsl on t.tradeid = tpsl.tradeid and t.buyorsell = tpsl.buyorsell
+  WHERE 1 = 1 and t.HOLDERQTY > 0
 `
 
 	sqlId.AndEx("gtmp.riskcontrolmode", r.RISKCONTROLMODE, r.RISKCONTROLMODE > 0)
 	sqlId.AndEx("utmp.userid", r.USERID, r.USERID > 0)
 	sqlId.AndEx("t.goodsid", r.GOODSID, r.GOODSID > 0)
 	sqlId.AndEx("t.BUYORSELL", r.BUYORSELL, r.BUYORSELL != -1)
+	sqlId.AndEx("t.tradeid", r.TRADEID, r.TRADEID != "")
 	sqlId.JoinEx(r.FtTradeMode != "", fmt.Sprintf(" and gtmp.trademode in(%v)", r.FtTradeMode))
 	sqlId.JoinEx(r.FtMarketIDs != "", fmt.Sprintf(" and gtmp.marketid in(%v)", r.FtMarketIDs))
 	sqlId.JoinEx(r.FtAccountIDs != "", fmt.Sprintf(" and t.accountid in(%v)", r.FtAccountIDs))