Browse Source

增加“查询仓单贸易成交行情”接口

zhou.xiaoning 3 years ago
parent
commit
d2bcb187ea
6 changed files with 441 additions and 0 deletions
  1. 19 0
      controllers/wrTrade2/qryWrTrade.go
  2. 131 0
      docs/docs.go
  3. 131 0
      docs/swagger.json
  4. 91 0
      docs/swagger.yaml
  5. 68 0
      models/wrTrade2.go
  6. 1 0
      routers/router.go

+ 19 - 0
controllers/wrTrade2/qryWrTrade.go

@@ -867,3 +867,22 @@ func InsertXhcpSellBackApply(c *gin.Context) {
 		a.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil)
 	}
 }
+
+// QueryWrTradeQuote
+// @Summary 查询仓单贸易成交行情
+// @Produce json
+// @Security ApiKeyAuth
+// @param wrstandardid query int true "现货商品id"
+// @Param begindate query string true "开始日期(yyyymmdd)"
+// @Param enddate query string true "结束日期(yyyymmdd)"
+// @param marketid query int false "市场id"
+// @Success 200 {array} models.Wrtradetradequote
+// @Failure 500 {object} app.Response
+// @Router /WrTrade2/QueryWrTradeQuote [get]
+// @Tags 仓单贸易v2
+func QueryWrTradeQuote(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.Wrtradetradequote{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}

+ 131 - 0
docs/docs.go

@@ -15433,6 +15433,68 @@ var doc = `{
                 }
             }
         },
+        "/WrTrade2/QueryWrTradeQuote": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易v2"
+                ],
+                "summary": "查询仓单贸易成交行情",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "现货商品id",
+                        "name": "wrstandardid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "开始日期(yyyymmdd)",
+                        "name": "begindate",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "结束日期(yyyymmdd)",
+                        "name": "enddate",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "市场id",
+                        "name": "marketid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Wrtradetradequote"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WrTrade2/QueryWrUserFriend": {
             "get": {
                 "security": [
@@ -41719,6 +41781,75 @@ var doc = `{
                 }
             }
         },
+        "models.Wrtradetradequote": {
+            "type": "object",
+            "properties": {
+                "begindate": {
+                    "description": "开始日期(结果含开始日期) yyyymmdd",
+                    "type": "string"
+                },
+                "buyaccountid": {
+                    "description": "买方账号ID",
+                    "type": "integer"
+                },
+                "buyuserid": {
+                    "description": "买方用户ID",
+                    "type": "integer"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "enddate": {
+                    "description": "结束日期(结果含结束日期) yyyymmdd",
+                    "type": "string"
+                },
+                "marketid": {
+                    "description": "市场ID",
+                    "type": "integer"
+                },
+                "sellaccountid": {
+                    "description": "卖方账号ID",
+                    "type": "integer"
+                },
+                "selluserid": {
+                    "description": "卖方用户ID",
+                    "type": "integer"
+                },
+                "tradeamount": {
+                    "description": "成交金额",
+                    "type": "number"
+                },
+                "tradedate": {
+                    "description": "交易日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "tradeprice": {
+                    "description": "成交价格",
+                    "type": "number"
+                },
+                "tradeqty": {
+                    "description": "成交数量",
+                    "type": "integer"
+                },
+                "tradetime": {
+                    "description": "成交时间",
+                    "type": "string"
+                },
+                "wrfactortypeid": {
+                    "description": "仓单要素类型ID",
+                    "type": "integer"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrtradedetailid": {
+                    "description": "仓单贸易成交单ID(321+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                }
+            }
+        },
         "models.XHBRAND": {
             "type": "object",
             "properties": {

+ 131 - 0
docs/swagger.json

@@ -15417,6 +15417,68 @@
                 }
             }
         },
+        "/WrTrade2/QueryWrTradeQuote": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易v2"
+                ],
+                "summary": "查询仓单贸易成交行情",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "现货商品id",
+                        "name": "wrstandardid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "开始日期(yyyymmdd)",
+                        "name": "begindate",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "结束日期(yyyymmdd)",
+                        "name": "enddate",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "市场id",
+                        "name": "marketid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Wrtradetradequote"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WrTrade2/QueryWrUserFriend": {
             "get": {
                 "security": [
@@ -41703,6 +41765,75 @@
                 }
             }
         },
+        "models.Wrtradetradequote": {
+            "type": "object",
+            "properties": {
+                "begindate": {
+                    "description": "开始日期(结果含开始日期) yyyymmdd",
+                    "type": "string"
+                },
+                "buyaccountid": {
+                    "description": "买方账号ID",
+                    "type": "integer"
+                },
+                "buyuserid": {
+                    "description": "买方用户ID",
+                    "type": "integer"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "enddate": {
+                    "description": "结束日期(结果含结束日期) yyyymmdd",
+                    "type": "string"
+                },
+                "marketid": {
+                    "description": "市场ID",
+                    "type": "integer"
+                },
+                "sellaccountid": {
+                    "description": "卖方账号ID",
+                    "type": "integer"
+                },
+                "selluserid": {
+                    "description": "卖方用户ID",
+                    "type": "integer"
+                },
+                "tradeamount": {
+                    "description": "成交金额",
+                    "type": "number"
+                },
+                "tradedate": {
+                    "description": "交易日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "tradeprice": {
+                    "description": "成交价格",
+                    "type": "number"
+                },
+                "tradeqty": {
+                    "description": "成交数量",
+                    "type": "integer"
+                },
+                "tradetime": {
+                    "description": "成交时间",
+                    "type": "string"
+                },
+                "wrfactortypeid": {
+                    "description": "仓单要素类型ID",
+                    "type": "integer"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrtradedetailid": {
+                    "description": "仓单贸易成交单ID(321+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                }
+            }
+        },
         "models.XHBRAND": {
             "type": "object",
             "properties": {

+ 91 - 0
docs/swagger.yaml

@@ -19449,6 +19449,57 @@ definitions:
         description: 户名(个人姓名或企业名称)
         type: string
     type: object
+  models.Wrtradetradequote:
+    properties:
+      begindate:
+        description: 开始日期(结果含开始日期) yyyymmdd
+        type: string
+      buyaccountid:
+        description: 买方账号ID
+        type: integer
+      buyuserid:
+        description: 买方用户ID
+        type: integer
+      deliverygoodsid:
+        description: 现货品种ID
+        type: integer
+      enddate:
+        description: 结束日期(结果含结束日期) yyyymmdd
+        type: string
+      marketid:
+        description: 市场ID
+        type: integer
+      sellaccountid:
+        description: 卖方账号ID
+        type: integer
+      selluserid:
+        description: 卖方用户ID
+        type: integer
+      tradeamount:
+        description: 成交金额
+        type: number
+      tradedate:
+        description: 交易日(yyyyMMdd)
+        type: string
+      tradeprice:
+        description: 成交价格
+        type: number
+      tradeqty:
+        description: 成交数量
+        type: integer
+      tradetime:
+        description: 成交时间
+        type: string
+      wrfactortypeid:
+        description: 仓单要素类型ID
+        type: integer
+      wrstandardid:
+        description: 现货商品ID
+        type: integer
+      wrtradedetailid:
+        description: 仓单贸易成交单ID(321+Unix秒时间戳(10位)+xxxxxx)
+        type: string
+    type: object
   models.XHBRAND:
     properties:
       brandid:
@@ -31430,6 +31481,46 @@ paths:
       summary: 查询合约交易买卖大厅
       tags:
       - 仓单贸易v2
+  /WrTrade2/QueryWrTradeQuote:
+    get:
+      parameters:
+      - description: 现货商品id
+        in: query
+        name: wrstandardid
+        required: true
+        type: integer
+      - description: 开始日期(yyyymmdd)
+        in: query
+        name: begindate
+        required: true
+        type: string
+      - description: 结束日期(yyyymmdd)
+        in: query
+        name: enddate
+        required: true
+        type: string
+      - description: 市场id
+        in: query
+        name: marketid
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Wrtradetradequote'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询仓单贸易成交行情
+      tags:
+      - 仓单贸易v2
   /WrTrade2/QueryWrUserFriend:
     get:
       parameters:

+ 68 - 0
models/wrTrade2.go

@@ -5123,3 +5123,71 @@ func (r *XhcpSellBackApplyEx) Insert() error {
 	// add Commit() after all actions
 	return session.Commit()
 }
+
+// Wrtradetradequote 仓单贸易成交行情表
+type Wrtradetradequote struct {
+	WRTRADEDETAILID string    `json:"wrtradedetailid"  xorm:"WRTRADEDETAILID"`               // 仓单贸易成交单ID(321+Unix秒时间戳(10位)+xxxxxx)
+	TRADEDATE       string    `json:"tradedate"  xorm:"TRADEDATE"`                           // 交易日(yyyyMMdd)
+	MARKETID        int32     `json:"marketid"  xorm:"MARKETID"  form:"marketid"`            // 市场ID
+	WRFACTORTYPEID  int64     `json:"wrfactortypeid"  xorm:"WRFACTORTYPEID"`                 // 仓单要素类型ID
+	DELIVERYGOODSID int32     `json:"deliverygoodsid"  xorm:"DELIVERYGOODSID"`               // 现货品种ID
+	WRSTANDARDID    int32     `json:"wrstandardid"  xorm:"WRSTANDARDID" form:"wrstandardid"` // 现货商品ID
+	BUYUSERID       int64     `json:"buyuserid"  xorm:"BUYUSERID"`                           // 买方用户ID
+	BUYACCOUNTID    int64     `json:"buyaccountid"  xorm:"BUYACCOUNTID"`                     // 买方账号ID
+	SELLUSERID      int64     `json:"selluserid"  xorm:"SELLUSERID"`                         // 卖方用户ID
+	SELLACCOUNTID   int64     `json:"sellaccountid"  xorm:"SELLACCOUNTID"`                   // 卖方账号ID
+	TRADETIME       time.Time `json:"tradetime"  xorm:"TRADETIME"`                           // 成交时间
+	TRADEPRICE      float64   `json:"tradeprice"  xorm:"TRADEPRICE"`                         // 成交价格
+	TRADEQTY        int64     `json:"tradeqty"  xorm:"TRADEQTY"`                             // 成交数量
+	TRADEAMOUNT     float64   `json:"tradeamount"  xorm:"TRADEAMOUNT"`                       // 成交金额
+
+	BEGINDATE string `json:"begindate" form:"begindate"` // 开始日期(结果含开始日期) yyyymmdd
+	ENDDATE   string `json:"enddate" form:"enddate"`     // 结束日期(结果含结束日期) yyyymmdd
+}
+
+// TableName is WRTRADE_TRADEQUOTE
+func (r *Wrtradetradequote) TableName() string {
+	return "WRTRADE_TRADEQUOTE"
+}
+
+func (r *Wrtradetradequote) calc() {
+
+}
+
+func (r *Wrtradetradequote) buildSql() string {
+	var sqlId utils.SQLVal = `
+	SELECT 
+		to_char(t.WRTRADEDETAILID) WRTRADEDETAILID,
+		t.TRADEDATE,
+		t.MARKETID,
+		t.WRFACTORTYPEID,
+		t.DELIVERYGOODSID,
+		t.WRSTANDARDID,
+		t.BUYUSERID,
+		t.BUYACCOUNTID,
+		t.SELLUSERID,
+		t.SELLACCOUNTID,
+		t.TRADETIME,
+		t.TRADEPRICE,
+		t.TRADEQTY,
+		t.TRADEAMOUNT
+	FROM WRTRADE_TRADEQUOTE t
+	WHERE 
+		t.WRSTANDARDID = %v
+	AND
+		t.TRADETIME BETWEEN TO_DATE('%v' || ' 000000', 'yyyymmdd hh24:mi:ss') and TO_DATE('%v' || ' 235959', 'yyyymmdd hh24:mi:ss')
+	`
+	sqlId.FormatParam(r.WRSTANDARDID, r.BEGINDATE, r.ENDDATE)
+	sqlId.AndEx("t.MARKETID", r.MARKETID, r.MARKETID > 0)
+
+	return sqlId.String()
+}
+
+func (r *Wrtradetradequote) GetDataEx() (interface{}, error) {
+	sData := make([]Wrtradetradequote, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}

+ 1 - 0
routers/router.go

@@ -615,6 +615,7 @@ func InitRouter() *gin.Engine {
 		wrTrade2R.GET("QueryWrClientAdSpaceConfig", wrTrade2.QueryWrClientAdSpaceConfig)
 		wrTrade2R.GET("QueryXhcpSellBackApply", wrTrade2.QueryXhcpSellBackApply)
 		wrTrade2R.POST("InsertXhcpSellBackApply", wrTrade2.InsertXhcpSellBackApply)
+		wrTrade2R.GET("QueryWrTradeQuote", wrTrade2.QueryWrTradeQuote)
 	}
 
 	// **************************天津麦顿*************************