Browse Source

增加“期货成交单明细查询”接口

zhou.xiaoning 3 years ago
parent
commit
accff3935e
5 changed files with 555 additions and 0 deletions
  1. 16 0
      controllers/ermcp8/qryErmcp8.go
  2. 170 0
      docs/docs.go
  3. 170 0
      docs/swagger.json
  4. 122 0
      docs/swagger.yaml
  5. 77 0
      models/ermcp8.go

+ 16 - 0
controllers/ermcp8/qryErmcp8.go

@@ -73,3 +73,19 @@ func QueryERMCP2HedgedItemSpotDetail(c *gin.Context) {
 	a.DoBindReq(&m)
 	a.DoGetDataI(&m)
 }
+
+// QueryERMCPPatradeLinkDetail
+// @Summary 期货成交单明细查询
+// @Produce json
+// @Security ApiKeyAuth
+// @Param hedgeditemid query int true "套期项目ID"
+// @Success 200 {array} models.Ermcppatradelinkdetail
+// @Failure 500 {object} app.Response
+// @Router /Ermcp8/QueryERMCPPatradeLinkDetail [get]
+// @Tags 企业风险管理v8
+func QueryERMCPPatradeLinkDetail(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.Ermcppatradelinkdetail{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}

+ 170 - 0
docs/docs.go

@@ -5711,6 +5711,48 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp8/QueryERMCPPatradeLinkDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "期货成交单明细查询",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "套期项目ID",
+                        "name": "hedgeditemid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcppatradelinkdetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp8/QueryErmcp2HedgedItem": {
             "get": {
                 "security": [
@@ -26593,6 +26635,134 @@ var doc = `{
                 }
             }
         },
+        "models.Ermcppatradelinkdetail": {
+            "type": "object",
+            "required": [
+                "hedgeditemid"
+            ],
+            "properties": {
+                "agreeunit": {
+                    "description": "合约乘数",
+                    "type": "number"
+                },
+                "amount": {
+                    "description": "金额 = RelatedLot * TradePrice * AgreeUnit",
+                    "type": "number"
+                },
+                "areauserid": {
+                    "description": "所属机构",
+                    "type": "integer"
+                },
+                "bizsubjectid": {
+                    "description": "归属业务部门ID - SubjectID",
+                    "type": "integer"
+                },
+                "buyorsell": {
+                    "description": "方向 - 0:买 1:卖",
+                    "type": "integer"
+                },
+                "convertratio": {
+                    "description": "品种系数",
+                    "type": "number"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "creatorid": {
+                    "description": "创建人ID",
+                    "type": "integer"
+                },
+                "creatorsrc": {
+                    "description": "创建人来源 - 1:管理端 2:终端 3:交易",
+                    "type": "integer"
+                },
+                "goodsgroupid": {
+                    "description": "对冲品种ID[期货合约商品组ID]",
+                    "type": "integer"
+                },
+                "goodsid": {
+                    "description": "商品ID",
+                    "type": "integer"
+                },
+                "hedgeditemid": {
+                    "description": "现货ID[套期项目ID] [13 - 被套期项目ID] [4,10,11 - 现货合同ID]  [9 - 套保计划ID]",
+                    "type": "integer"
+                },
+                "hedgeflag": {
+                    "description": "投机套保标志 - 0:无 1:投机 2:套保 3:套利 4:套期保值(平安\\合同) 5:单边(平安) 6:移仓(平安) 7:错单处理(平安) 8:跨期套利(平安) 9:套期保值(计划) 10:套利(合同)  11:换月(合同)  12:交割(金瑞) 13:被套期项目",
+                    "type": "integer"
+                },
+                "linkdetailid": {
+                    "description": "期货明细ID(614+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "linkstatus": {
+                    "description": "关联状态 - 1:成功 2:失败 3:解绑",
+                    "type": "integer"
+                },
+                "middlegoodsid": {
+                    "description": "套保品种ID",
+                    "type": "integer"
+                },
+                "name": {
+                    "description": "账户名/子账户",
+                    "type": "string"
+                },
+                "optioncode": {
+                    "description": "[期货合约]期权代码 [期权]",
+                    "type": "string"
+                },
+                "ordertype": {
+                    "description": "单据类型[套期工具] - 1:期货单 2:看涨期权单 3:看跌期权单",
+                    "type": "integer"
+                },
+                "relatedlot": {
+                    "description": "[数量]关联手数",
+                    "type": "number"
+                },
+                "relatedmode": {
+                    "description": "关联方式 - 1:自动关联 2:手动关联 3:解绑关联",
+                    "type": "integer"
+                },
+                "relatedqty": {
+                    "description": "关联数量 = RelatedLot * AgreeUnit * ConvertRatio",
+                    "type": "number"
+                },
+                "retcode": {
+                    "description": "返回码",
+                    "type": "integer"
+                },
+                "saleuserid": {
+                    "description": "业务员ID",
+                    "type": "integer"
+                },
+                "tradedate": {
+                    "description": "关联交易日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "tradeid": {
+                    "description": "内部成交单ID",
+                    "type": "integer"
+                },
+                "tradelot": {
+                    "description": "成交手数",
+                    "type": "integer"
+                },
+                "tradeprice": {
+                    "description": "[价格]成交价格",
+                    "type": "number"
+                },
+                "tradetime": {
+                    "description": "日期时间",
+                    "type": "string"
+                },
+                "tradetradedate": {
+                    "description": "成交交易日(yyyyMMdd)",
+                    "type": "string"
+                }
+            }
+        },
         "models.Externalexchange": {
             "type": "object",
             "required": [

+ 170 - 0
docs/swagger.json

@@ -5695,6 +5695,48 @@
                 }
             }
         },
+        "/Ermcp8/QueryERMCPPatradeLinkDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理v8"
+                ],
+                "summary": "期货成交单明细查询",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "套期项目ID",
+                        "name": "hedgeditemid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Ermcppatradelinkdetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp8/QueryErmcp2HedgedItem": {
             "get": {
                 "security": [
@@ -26577,6 +26619,134 @@
                 }
             }
         },
+        "models.Ermcppatradelinkdetail": {
+            "type": "object",
+            "required": [
+                "hedgeditemid"
+            ],
+            "properties": {
+                "agreeunit": {
+                    "description": "合约乘数",
+                    "type": "number"
+                },
+                "amount": {
+                    "description": "金额 = RelatedLot * TradePrice * AgreeUnit",
+                    "type": "number"
+                },
+                "areauserid": {
+                    "description": "所属机构",
+                    "type": "integer"
+                },
+                "bizsubjectid": {
+                    "description": "归属业务部门ID - SubjectID",
+                    "type": "integer"
+                },
+                "buyorsell": {
+                    "description": "方向 - 0:买 1:卖",
+                    "type": "integer"
+                },
+                "convertratio": {
+                    "description": "品种系数",
+                    "type": "number"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "creatorid": {
+                    "description": "创建人ID",
+                    "type": "integer"
+                },
+                "creatorsrc": {
+                    "description": "创建人来源 - 1:管理端 2:终端 3:交易",
+                    "type": "integer"
+                },
+                "goodsgroupid": {
+                    "description": "对冲品种ID[期货合约商品组ID]",
+                    "type": "integer"
+                },
+                "goodsid": {
+                    "description": "商品ID",
+                    "type": "integer"
+                },
+                "hedgeditemid": {
+                    "description": "现货ID[套期项目ID] [13 - 被套期项目ID] [4,10,11 - 现货合同ID]  [9 - 套保计划ID]",
+                    "type": "integer"
+                },
+                "hedgeflag": {
+                    "description": "投机套保标志 - 0:无 1:投机 2:套保 3:套利 4:套期保值(平安\\合同) 5:单边(平安) 6:移仓(平安) 7:错单处理(平安) 8:跨期套利(平安) 9:套期保值(计划) 10:套利(合同)  11:换月(合同)  12:交割(金瑞) 13:被套期项目",
+                    "type": "integer"
+                },
+                "linkdetailid": {
+                    "description": "期货明细ID(614+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "linkstatus": {
+                    "description": "关联状态 - 1:成功 2:失败 3:解绑",
+                    "type": "integer"
+                },
+                "middlegoodsid": {
+                    "description": "套保品种ID",
+                    "type": "integer"
+                },
+                "name": {
+                    "description": "账户名/子账户",
+                    "type": "string"
+                },
+                "optioncode": {
+                    "description": "[期货合约]期权代码 [期权]",
+                    "type": "string"
+                },
+                "ordertype": {
+                    "description": "单据类型[套期工具] - 1:期货单 2:看涨期权单 3:看跌期权单",
+                    "type": "integer"
+                },
+                "relatedlot": {
+                    "description": "[数量]关联手数",
+                    "type": "number"
+                },
+                "relatedmode": {
+                    "description": "关联方式 - 1:自动关联 2:手动关联 3:解绑关联",
+                    "type": "integer"
+                },
+                "relatedqty": {
+                    "description": "关联数量 = RelatedLot * AgreeUnit * ConvertRatio",
+                    "type": "number"
+                },
+                "retcode": {
+                    "description": "返回码",
+                    "type": "integer"
+                },
+                "saleuserid": {
+                    "description": "业务员ID",
+                    "type": "integer"
+                },
+                "tradedate": {
+                    "description": "关联交易日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "tradeid": {
+                    "description": "内部成交单ID",
+                    "type": "integer"
+                },
+                "tradelot": {
+                    "description": "成交手数",
+                    "type": "integer"
+                },
+                "tradeprice": {
+                    "description": "[价格]成交价格",
+                    "type": "number"
+                },
+                "tradetime": {
+                    "description": "日期时间",
+                    "type": "string"
+                },
+                "tradetradedate": {
+                    "description": "成交交易日(yyyyMMdd)",
+                    "type": "string"
+                }
+            }
+        },
         "models.Externalexchange": {
             "type": "object",
             "required": [

+ 122 - 0
docs/swagger.yaml

@@ -8636,6 +8636,102 @@ definitions:
     required:
     - spotcontractid
     type: object
+  models.Ermcppatradelinkdetail:
+    properties:
+      agreeunit:
+        description: 合约乘数
+        type: number
+      amount:
+        description: 金额 = RelatedLot * TradePrice * AgreeUnit
+        type: number
+      areauserid:
+        description: 所属机构
+        type: integer
+      bizsubjectid:
+        description: 归属业务部门ID - SubjectID
+        type: integer
+      buyorsell:
+        description: 方向 - 0:买 1:卖
+        type: integer
+      convertratio:
+        description: 品种系数
+        type: number
+      createtime:
+        description: 创建时间
+        type: string
+      creatorid:
+        description: 创建人ID
+        type: integer
+      creatorsrc:
+        description: 创建人来源 - 1:管理端 2:终端 3:交易
+        type: integer
+      goodsgroupid:
+        description: 对冲品种ID[期货合约商品组ID]
+        type: integer
+      goodsid:
+        description: 商品ID
+        type: integer
+      hedgeditemid:
+        description: 现货ID[套期项目ID] [13 - 被套期项目ID] [4,10,11 - 现货合同ID]  [9 - 套保计划ID]
+        type: integer
+      hedgeflag:
+        description: 投机套保标志 - 0:无 1:投机 2:套保 3:套利 4:套期保值(平安\合同) 5:单边(平安) 6:移仓(平安) 7:错单处理(平安)
+          8:跨期套利(平安) 9:套期保值(计划) 10:套利(合同)  11:换月(合同)  12:交割(金瑞) 13:被套期项目
+        type: integer
+      linkdetailid:
+        description: 期货明细ID(614+Unix秒时间戳(10位)+xxxxxx)
+        type: string
+      linkstatus:
+        description: 关联状态 - 1:成功 2:失败 3:解绑
+        type: integer
+      middlegoodsid:
+        description: 套保品种ID
+        type: integer
+      name:
+        description: 账户名/子账户
+        type: string
+      optioncode:
+        description: '[期货合约]期权代码 [期权]'
+        type: string
+      ordertype:
+        description: 单据类型[套期工具] - 1:期货单 2:看涨期权单 3:看跌期权单
+        type: integer
+      relatedlot:
+        description: '[数量]关联手数'
+        type: number
+      relatedmode:
+        description: 关联方式 - 1:自动关联 2:手动关联 3:解绑关联
+        type: integer
+      relatedqty:
+        description: 关联数量 = RelatedLot * AgreeUnit * ConvertRatio
+        type: number
+      retcode:
+        description: 返回码
+        type: integer
+      saleuserid:
+        description: 业务员ID
+        type: integer
+      tradedate:
+        description: 关联交易日(yyyyMMdd)
+        type: string
+      tradeid:
+        description: 内部成交单ID
+        type: integer
+      tradelot:
+        description: 成交手数
+        type: integer
+      tradeprice:
+        description: '[价格]成交价格'
+        type: number
+      tradetime:
+        description: 日期时间
+        type: string
+      tradetradedate:
+        description: 成交交易日(yyyyMMdd)
+        type: string
+    required:
+    - hedgeditemid
+    type: object
   models.Externalexchange:
     properties:
       autoid:
@@ -24114,6 +24210,32 @@ paths:
       summary: 期货持仓明细查询
       tags:
       - 企业风险管理v8
+  /Ermcp8/QueryERMCPPatradeLinkDetail:
+    get:
+      parameters:
+      - description: 套期项目ID
+        in: query
+        name: hedgeditemid
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Ermcppatradelinkdetail'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 期货成交单明细查询
+      tags:
+      - 企业风险管理v8
   /Ermcp8/QueryErmcp2HedgedItem:
     get:
       description: 已完成项目查询 -> 项目状态 = 3:正常完结 or 5:异常完结

+ 77 - 0
models/ermcp8.go

@@ -475,3 +475,80 @@ func (r *Ermcp2hedgeditemspotDetail) GetDataEx() (interface{}, error) {
 	}
 	return sData, nil
 }
+
+// Ermcppatradelinkdetail 期货成交单关联明细表
+type Ermcppatradelinkdetail struct {
+	LINKDETAILID   string    `json:"linkdetailid"  xorm:"LINKDETAILID"`                                          // 期货明细ID(614+Unix秒时间戳(10位)+xxxxxx)
+	TRADEID        int64     `json:"tradeid"  xorm:"TRADEID"`                                                    // 内部成交单ID
+	BUYORSELL      int32     `json:"buyorsell"  xorm:"BUYORSELL"`                                                // 方向 - 0:买 1:卖
+	HEDGEFLAG      int32     `json:"hedgeflag"  xorm:"HEDGEFLAG"`                                                // 投机套保标志 - 0:无 1:投机 2:套保 3:套利 4:套期保值(平安\合同) 5:单边(平安) 6:移仓(平安) 7:错单处理(平安) 8:跨期套利(平安) 9:套期保值(计划) 10:套利(合同)  11:换月(合同)  12:交割(金瑞) 13:被套期项目
+	SPOTCONTRACTID int64     `json:"hedgeditemid"  xorm:"SPOTCONTRACTID" form:"hedgeditemid" binding:"required"` // 现货ID[套期项目ID] [13 - 被套期项目ID] [4,10,11 - 现货合同ID]  [9 - 套保计划ID]
+	RELATEDLOT     float64   `json:"relatedlot"  xorm:"RELATEDLOT"`                                              // [数量]关联手数
+	GOODSID        int32     `json:"goodsid"  xorm:"GOODSID"`                                                    // 商品ID
+	GOODSGROUPID   int32     `json:"goodsgroupid"  xorm:"GOODSGROUPID"`                                          // 对冲品种ID[期货合约商品组ID]
+	MIDDLEGOODSID  int64     `json:"middlegoodsid"  xorm:"MIDDLEGOODSID"`                                        // 套保品种ID
+	RELATEDQTY     float64   `json:"relatedqty"  xorm:"RELATEDQTY"`                                              // 关联数量 = RelatedLot * AgreeUnit * ConvertRatio
+	TRADEDATE      string    `json:"tradedate"  xorm:"TRADEDATE"`                                                // 关联交易日(yyyyMMdd)
+	RELATEDMODE    int32     `json:"relatedmode"  xorm:"RELATEDMODE"`                                            // 关联方式 - 1:自动关联 2:手动关联 3:解绑关联
+	TRADETRADEDATE string    `json:"tradetradedate"  xorm:"TRADETRADEDATE"`                                      // 成交交易日(yyyyMMdd)
+	TRADEPRICE     float64   `json:"tradeprice"  xorm:"TRADEPRICE"`                                              // [价格]成交价格
+	TRADELOT       int64     `json:"tradelot"  xorm:"TRADELOT"`                                                  // 成交手数
+	SALEUSERID     int64     `json:"saleuserid"  xorm:"SALEUSERID"`                                              // 业务员ID
+	BIZSUBJECTID   int64     `json:"bizsubjectid"  xorm:"BIZSUBJECTID"`                                          // 归属业务部门ID - SubjectID
+	AGREEUNIT      float64   `json:"agreeunit"  xorm:"AGREEUNIT"`                                                // 合约乘数
+	CONVERTRATIO   float64   `json:"convertratio"  xorm:"CONVERTRATIO"`                                          // 品种系数
+	AREAUSERID     int64     `json:"areauserid"  xorm:"AREAUSERID"`                                              // 所属机构
+	CREATORSRC     int32     `json:"creatorsrc"  xorm:"CREATORSRC"`                                              // 创建人来源 - 1:管理端 2:终端 3:交易
+	CREATORID      int64     `json:"creatorid"  xorm:"CREATORID"`                                                // 创建人ID
+	CREATETIME     time.Time `json:"createtime"  xorm:"CREATETIME"`                                              // 创建时间
+	LINKSTATUS     int32     `json:"linkstatus"  xorm:"LINKSTATUS"`                                              // 关联状态 - 1:成功 2:失败 3:解绑
+	RETCODE        int32     `json:"retcode"  xorm:"RETCODE"`                                                    // 返回码
+
+	TRADETIME  time.Time `json:"tradetime"  xorm:"TRADETIME"`   // 日期时间
+	ORDERTYPE  int32     `json:"ordertype"  xorm:"ORDERTYPE"`   // 单据类型[套期工具] - 1:期货单 2:看涨期权单 3:看跌期权单
+	OPTIONCODE string    `json:"optioncode"  xorm:"OPTIONCODE"` // [期货合约]期权代码 [期权]
+	AMOUNT     float64   `json:"amount"  xorm:"AMOUNT"`         // 金额 = RelatedLot * TradePrice * AgreeUnit
+	NAME       string    `json:"name" xorm:"NAME"`              // 账户名/子账户
+}
+
+func (r *Ermcppatradelinkdetail) calc() {
+
+}
+
+func (r *Ermcppatradelinkdetail) buildSql() string {
+	var sqlId utils.SQLVal = `
+	SELECT 
+		p.TRADETIME,
+		p.ORDERTYPE,
+		p.OPTIONCODE,
+		t.BUYORSELL,
+		t.TRADEPRICE,
+		t.RELATEDLOT,
+		(t.RelatedLot * t.TradePrice * t.AgreeUnit) AMOUNT,
+		t.TRADEID,
+		(u.ACCOUNTNAME || '/' || to_char(t.ACCOUNTID)) NAME
+	FROM ERMCP_PA_TradeLinkDetail t
+	LEFT JOIN ERMCP_PA_TradeLink p ON p.TradeID = t.TradeID AND p.BuyorSell = t.BuyorSell
+	LEFT JOIN TAACCOUNT ta ON ta.ACCOUNTID = t.ACCOUNTID
+	LEFT JOIN USERACCOUNT u on u.userid = ta.relateduserid
+	WHERE t.HedgeFlag = 13 AND t.SpotContractID = %v
+	ORDER BY p.TradeTime
+	`
+	sqlId.FormatParam(r.SPOTCONTRACTID)
+
+	return sqlId.String()
+}
+
+// GetDataEx 从数据库中查询数据
+func (r *Ermcppatradelinkdetail) GetDataEx() (interface{}, error) {
+	e := db.GetEngine()
+	s := e.SQL(r.buildSql())
+	sData := make([]Ermcppatradelinkdetail, 0)
+	if err := s.Find(&sData); err != nil {
+		return nil, err
+	}
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, nil
+}