Преглед изворни кода

仓单贸易
1.增加 查询大厅报价接口
2.增加 查询买卖大厅列表接口

zou.yingbin пре 4 година
родитељ
комит
5430276c38
6 измењених фајлова са 1159 додато и 0 уклоњено
  1. 59 0
      controllers/wrTrade2/qryWrTrade.go
  2. 291 0
      docs/docs.go
  3. 291 0
      docs/swagger.json
  4. 200 0
      docs/swagger.yaml
  5. 310 0
      models/wrTrade2.go
  6. 8 0
      routers/router.go

+ 59 - 0
controllers/wrTrade2/qryWrTrade.go

@@ -0,0 +1,59 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/7/20 18:30
+* @Modify  : 2021/7/20 18:30
+ */
+
+package wrTrade2
+
+import (
+	"github.com/gin-gonic/gin"
+	"mtp2_if/global/app"
+	"mtp2_if/models"
+)
+
+// QueryOrderQuote
+// @Summary 查询大厅行情列表
+// @Produce json
+// @Security ApiKeyAuth
+// @Param page query int false "页码"
+// @Param pagesize query int false "每页条数"
+// @Param marketid query int false "仓单贸易市场id"
+// @Param wrpricetype query int true "价格方式 - 1:固定价 2-浮动价"
+// @Param haswr query int true "是否有仓单 0-没有 1-有(仓单贸易填1,产能预售填0)"
+// @Param wrstandardname query string false "商品名称(筛选条件)"
+// @Param brandname query string false "品牌名称(筛选条件)"
+// @Param warehouseid query int false "仓库id(筛选条件)"
+// @Success 200 {array} models.WrOrderQuote
+// @Failure 500 {object} app.Response
+// @Router /WrTrade2/QueryOrderQuote [get]
+// @Tags 仓单贸易v2
+func QueryOrderQuote(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.WrOrderQuote{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}
+
+// QueryOrderQuote
+// @Summary 查询买卖大厅
+// @Produce json
+// @Security ApiKeyAuth
+// @Param page query int false "页码"
+// @Param pagesize query int false "每页条数"
+// @Param marketid query int false "仓单贸易市场id"
+// @Param wrpricetype query int true "价格方式 - 1:固定价 2-浮动价"
+// @Param haswr query int true "是否有仓单 0-没有 1-有(仓单贸易填1,产能预售填0)"
+// @Param wrfactortypeid query int true "仓单要素id"
+// @Param goodsid query int true "期货商品id"
+// @Param buyorsell query int true "买卖方向 0-买 1-卖"
+// @Success 200 {array} models.WrOrderQuoteDetail
+// @Failure 500 {object} app.Response
+// @Router /WrTrade2/QueryOrderQuoteDetail [get]
+// @Tags 仓单贸易v2
+func QueryOrderQuoteDetail(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.WrOrderQuoteDetail{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}

+ 291 - 0
docs/docs.go

@@ -10890,6 +10890,179 @@ var doc = `{
                     }
                 }
             }
+        },
+        "/WrTrade2/QueryOrderQuote": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易v2"
+                ],
+                "summary": "查询大厅行情列表",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "仓单贸易市场id",
+                        "name": "marketid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "价格方式 - 1:固定价 2-浮动价",
+                        "name": "wrpricetype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "是否有仓单 0-没有 1-有(仓单贸易填1,产能预售填0)",
+                        "name": "haswr",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "商品名称(筛选条件)",
+                        "name": "wrstandardname",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "品牌名称(筛选条件)",
+                        "name": "brandname",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "仓库id(筛选条件)",
+                        "name": "warehouseid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.WrOrderQuote"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/WrTrade2/QueryOrderQuoteDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易v2"
+                ],
+                "summary": "查询买卖大厅",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "仓单贸易市场id",
+                        "name": "marketid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "价格方式 - 1:固定价 2-浮动价",
+                        "name": "wrpricetype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "是否有仓单 0-没有 1-有(仓单贸易填1,产能预售填0)",
+                        "name": "haswr",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "仓单要素id",
+                        "name": "wrfactortypeid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "期货商品id",
+                        "name": "goodsid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "买卖方向 0-买 1-卖",
+                        "name": "buyorsell",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.WrOrderQuoteDetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
         }
     },
     "definitions": {
@@ -28709,6 +28882,124 @@ var doc = `{
                 }
             }
         },
+        "models.WrOrderQuote": {
+            "type": "object",
+            "properties": {
+                "buyprice": {
+                    "description": "买价",
+                    "type": "number"
+                },
+                "buypricemove": {
+                    "description": "买升贴水(基差)",
+                    "type": "number"
+                },
+                "buyqty": {
+                    "description": "买量",
+                    "type": "number"
+                },
+                "deliverygoodscode": {
+                    "description": "品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "品种id",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "品种名称",
+                    "type": "string"
+                },
+                "goodscode": {
+                    "description": "商品合约(浮动价列表才有)",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "商品id(浮动价列表才有)",
+                    "type": "integer"
+                },
+                "sellprice": {
+                    "description": "卖价",
+                    "type": "number"
+                },
+                "sellpricemove": {
+                    "description": "卖升贴水(基差)",
+                    "type": "number"
+                },
+                "sellqty": {
+                    "description": "卖量",
+                    "type": "number"
+                },
+                "warehousecode": {
+                    "description": "仓库代码",
+                    "type": "string"
+                },
+                "warehouseid": {
+                    "description": "仓库id",
+                    "type": "integer"
+                },
+                "warehousename": {
+                    "description": "仓库名称",
+                    "type": "string"
+                },
+                "wrfactortypeid": {
+                    "description": "仓单要素id",
+                    "type": "integer"
+                },
+                "wrfactortypename": {
+                    "description": "仓单要素类型名称(选择项要素的名称合并显示,逗号分隔)",
+                    "type": "string"
+                },
+                "wrgoodsname": {
+                    "description": "商品(商品名称+仓库要素名称 拼接)",
+                    "type": "string"
+                },
+                "wrstandardcode": {
+                    "description": "商品代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "商品id",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "商品名称",
+                    "type": "string"
+                }
+            }
+        },
+        "models.WrOrderQuoteDetail": {
+            "type": "object",
+            "properties": {
+                "buyorsell": {
+                    "description": "买卖 - 0:买 1:卖",
+                    "type": "integer"
+                },
+                "fixedprice": {
+                    "description": "买(卖)价",
+                    "type": "number"
+                },
+                "orderqty": {
+                    "description": "买(卖)量(=委托量-成交量)",
+                    "type": "number"
+                },
+                "pricemove": {
+                    "description": "买(卖)升贴水- 基差",
+                    "type": "number"
+                },
+                "userid": {
+                    "description": "购买方(销售方)用户ID",
+                    "type": "integer"
+                },
+                "username": {
+                    "description": "购买方(销售方)",
+                    "type": "string"
+                },
+                "wrtradeorderid": {
+                    "description": "仓单贸易委托单ID(320+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                }
+            }
+        },
         "order.QueryHisTradeDetailRsp": {
             "type": "object",
             "required": [

+ 291 - 0
docs/swagger.json

@@ -10874,6 +10874,179 @@
                     }
                 }
             }
+        },
+        "/WrTrade2/QueryOrderQuote": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易v2"
+                ],
+                "summary": "查询大厅行情列表",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "仓单贸易市场id",
+                        "name": "marketid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "价格方式 - 1:固定价 2-浮动价",
+                        "name": "wrpricetype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "是否有仓单 0-没有 1-有(仓单贸易填1,产能预售填0)",
+                        "name": "haswr",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "商品名称(筛选条件)",
+                        "name": "wrstandardname",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "品牌名称(筛选条件)",
+                        "name": "brandname",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "仓库id(筛选条件)",
+                        "name": "warehouseid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.WrOrderQuote"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/WrTrade2/QueryOrderQuoteDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易v2"
+                ],
+                "summary": "查询买卖大厅",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "仓单贸易市场id",
+                        "name": "marketid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "价格方式 - 1:固定价 2-浮动价",
+                        "name": "wrpricetype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "是否有仓单 0-没有 1-有(仓单贸易填1,产能预售填0)",
+                        "name": "haswr",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "仓单要素id",
+                        "name": "wrfactortypeid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "期货商品id",
+                        "name": "goodsid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "买卖方向 0-买 1-卖",
+                        "name": "buyorsell",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.WrOrderQuoteDetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
         }
     },
     "definitions": {
@@ -28693,6 +28866,124 @@
                 }
             }
         },
+        "models.WrOrderQuote": {
+            "type": "object",
+            "properties": {
+                "buyprice": {
+                    "description": "买价",
+                    "type": "number"
+                },
+                "buypricemove": {
+                    "description": "买升贴水(基差)",
+                    "type": "number"
+                },
+                "buyqty": {
+                    "description": "买量",
+                    "type": "number"
+                },
+                "deliverygoodscode": {
+                    "description": "品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "品种id",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "品种名称",
+                    "type": "string"
+                },
+                "goodscode": {
+                    "description": "商品合约(浮动价列表才有)",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "商品id(浮动价列表才有)",
+                    "type": "integer"
+                },
+                "sellprice": {
+                    "description": "卖价",
+                    "type": "number"
+                },
+                "sellpricemove": {
+                    "description": "卖升贴水(基差)",
+                    "type": "number"
+                },
+                "sellqty": {
+                    "description": "卖量",
+                    "type": "number"
+                },
+                "warehousecode": {
+                    "description": "仓库代码",
+                    "type": "string"
+                },
+                "warehouseid": {
+                    "description": "仓库id",
+                    "type": "integer"
+                },
+                "warehousename": {
+                    "description": "仓库名称",
+                    "type": "string"
+                },
+                "wrfactortypeid": {
+                    "description": "仓单要素id",
+                    "type": "integer"
+                },
+                "wrfactortypename": {
+                    "description": "仓单要素类型名称(选择项要素的名称合并显示,逗号分隔)",
+                    "type": "string"
+                },
+                "wrgoodsname": {
+                    "description": "商品(商品名称+仓库要素名称 拼接)",
+                    "type": "string"
+                },
+                "wrstandardcode": {
+                    "description": "商品代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "商品id",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "商品名称",
+                    "type": "string"
+                }
+            }
+        },
+        "models.WrOrderQuoteDetail": {
+            "type": "object",
+            "properties": {
+                "buyorsell": {
+                    "description": "买卖 - 0:买 1:卖",
+                    "type": "integer"
+                },
+                "fixedprice": {
+                    "description": "买(卖)价",
+                    "type": "number"
+                },
+                "orderqty": {
+                    "description": "买(卖)量(=委托量-成交量)",
+                    "type": "number"
+                },
+                "pricemove": {
+                    "description": "买(卖)升贴水- 基差",
+                    "type": "number"
+                },
+                "userid": {
+                    "description": "购买方(销售方)用户ID",
+                    "type": "integer"
+                },
+                "username": {
+                    "description": "购买方(销售方)",
+                    "type": "string"
+                },
+                "wrtradeorderid": {
+                    "description": "仓单贸易委托单ID(320+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                }
+            }
+        },
         "order.QueryHisTradeDetailRsp": {
             "type": "object",
             "required": [

+ 200 - 0
docs/swagger.yaml

@@ -13280,6 +13280,93 @@ definitions:
     - autoid
     - warehousecode
     type: object
+  models.WrOrderQuote:
+    properties:
+      buyprice:
+        description: 买价
+        type: number
+      buypricemove:
+        description: 买升贴水(基差)
+        type: number
+      buyqty:
+        description: 买量
+        type: number
+      deliverygoodscode:
+        description: 品种代码
+        type: string
+      deliverygoodsid:
+        description: 品种id
+        type: integer
+      deliverygoodsname:
+        description: 品种名称
+        type: string
+      goodscode:
+        description: 商品合约(浮动价列表才有)
+        type: string
+      goodsid:
+        description: 商品id(浮动价列表才有)
+        type: integer
+      sellprice:
+        description: 卖价
+        type: number
+      sellpricemove:
+        description: 卖升贴水(基差)
+        type: number
+      sellqty:
+        description: 卖量
+        type: number
+      warehousecode:
+        description: 仓库代码
+        type: string
+      warehouseid:
+        description: 仓库id
+        type: integer
+      warehousename:
+        description: 仓库名称
+        type: string
+      wrfactortypeid:
+        description: 仓单要素id
+        type: integer
+      wrfactortypename:
+        description: 仓单要素类型名称(选择项要素的名称合并显示,逗号分隔)
+        type: string
+      wrgoodsname:
+        description: 商品(商品名称+仓库要素名称 拼接)
+        type: string
+      wrstandardcode:
+        description: 商品代码
+        type: string
+      wrstandardid:
+        description: 商品id
+        type: integer
+      wrstandardname:
+        description: 商品名称
+        type: string
+    type: object
+  models.WrOrderQuoteDetail:
+    properties:
+      buyorsell:
+        description: 买卖 - 0:买 1:卖
+        type: integer
+      fixedprice:
+        description: 买(卖)价
+        type: number
+      orderqty:
+        description: 买(卖)量(=委托量-成交量)
+        type: number
+      pricemove:
+        description: 买(卖)升贴水- 基差
+        type: number
+      userid:
+        description: 购买方(销售方)用户ID
+        type: integer
+      username:
+        description: 购买方(销售方)
+        type: string
+      wrtradeorderid:
+        description: 仓单贸易委托单ID(320+Unix秒时间戳(10位)+xxxxxx)
+        type: string
+    type: object
   order.QueryHisTradeDetailRsp:
     properties:
       accountid:
@@ -22115,6 +22202,119 @@ paths:
       tags:
       - 仓单贸易
       - 仓单贸易
+  /WrTrade2/QueryOrderQuote:
+    get:
+      parameters:
+      - description: 页码
+        in: query
+        name: page
+        type: integer
+      - description: 每页条数
+        in: query
+        name: pagesize
+        type: integer
+      - description: 仓单贸易市场id
+        in: query
+        name: marketid
+        type: integer
+      - description: 价格方式 - 1:固定价 2-浮动价
+        in: query
+        name: wrpricetype
+        required: true
+        type: integer
+      - description: 是否有仓单 0-没有 1-有(仓单贸易填1,产能预售填0)
+        in: query
+        name: haswr
+        required: true
+        type: integer
+      - description: 商品名称(筛选条件)
+        in: query
+        name: wrstandardname
+        type: string
+      - description: 品牌名称(筛选条件)
+        in: query
+        name: brandname
+        type: string
+      - description: 仓库id(筛选条件)
+        in: query
+        name: warehouseid
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.WrOrderQuote'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询大厅行情列表
+      tags:
+      - 仓单贸易v2
+  /WrTrade2/QueryOrderQuoteDetail:
+    get:
+      parameters:
+      - description: 页码
+        in: query
+        name: page
+        type: integer
+      - description: 每页条数
+        in: query
+        name: pagesize
+        type: integer
+      - description: 仓单贸易市场id
+        in: query
+        name: marketid
+        type: integer
+      - description: 价格方式 - 1:固定价 2-浮动价
+        in: query
+        name: wrpricetype
+        required: true
+        type: integer
+      - description: 是否有仓单 0-没有 1-有(仓单贸易填1,产能预售填0)
+        in: query
+        name: haswr
+        required: true
+        type: integer
+      - description: 仓单要素id
+        in: query
+        name: wrfactortypeid
+        required: true
+        type: integer
+      - description: 期货商品id
+        in: query
+        name: goodsid
+        required: true
+        type: integer
+      - description: 买卖方向 0-买 1-卖
+        in: query
+        name: buyorsell
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.WrOrderQuoteDetail'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询买卖大厅
+      tags:
+      - 仓单贸易v2
 securityDefinitions:
   ApiKeyAuth:
     in: header

+ 310 - 0
models/wrTrade2.go

@@ -0,0 +1,310 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/7/20 18:31
+* @Modify  : 2021/7/20 18:31
+ */
+
+package models
+
+import (
+	"mtp2_if/db"
+	"mtp2_if/utils"
+)
+
+// WrOrderQuote 买卖大厅行情
+type WrOrderQuote struct {
+	WRFACTORTYPEID    int64            `json:"wrfactortypeid"  xorm:"'WRFACTORTYPEID'" form:"wrfactortypeid"` // 仓单要素id
+	BUYPRICE          float64          `json:"buyprice"  xorm:"'BUYPRICE'"`                                   // 买价
+	BUYQTY            float64          `json:"buyqty"  xorm:"'BUYQTY'"`                                       // 买量
+	SELLPRICE         float64          `json:"sellprice"  xorm:"'SELLPRICE'"`                                 // 卖价
+	SELLQTY           float64          `json:"sellqty"  xorm:"'SELLQTY'"`                                     // 卖量
+	WRFACTORTYPENAME  string           `json:"wrfactortypename"  xorm:"'WRFACTORTYPENAME'"`                   // 仓单要素类型名称(选择项要素的名称合并显示,逗号分隔)
+	DELIVERYGOODSID   int32            `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`                     // 品种id
+	WRSTANDARDID      int32            `json:"wrstandardid"  xorm:"'WRSTANDARDID'"`                           // 商品id
+	WAREHOUSEID       int32            `json:"warehouseid"  xorm:"'WAREHOUSEID'" form:"warehouseid"`          // 仓库id
+	DELIVERYGOODSNAME string           `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"`                 // 品种名称
+	DELIVERYGOODSCODE string           `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"`                 // 品种代码
+	WAREHOUSENAME     string           `json:"warehousename"  xorm:"'WAREHOUSENAME'"`                         // 仓库名称
+	WAREHOUSECODE     string           `json:"warehousecode"  xorm:"'WAREHOUSECODE'"`                         // 仓库代码
+	WRSTANDARDNAME    string           `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'" form:"wrstandardname"` // 商品名称
+	WRSTANDARDCODE    string           `json:"wrstandardcode"  xorm:"'WRSTANDARDCODE'"`                       // 商品代码
+	WRGOODSNAME       string           `json:"wrgoodsname"  xorm:"'WRGOODSNAME'"`                             // 商品(商品名称+仓库要素名称 拼接)
+	BUYPRICEMOVE      float64          `json:"buypricemove"  xorm:"'BUYPRICEMOVE'"`                           // 买升贴水(基差)
+	SELLPRICEMOVE     float64          `json:"sellpricemove"  xorm:"'SELLPRICEMOVE'"`                         // 卖升贴水(基差)
+	GOODSID           int32            `json:"goodsid"  xorm:"'GOODSID'"`                                     // 商品id(浮动价列表才有)
+	GOODSCODE         string           `json:"goodscode"  xorm:"'GOODSCODE'"`                                 // 商品合约(浮动价列表才有)
+	PageEx            `xorm:"extends"` // 页码信息
+
+	HasWr       int32  `json:"-" form:"haswr"`       // 是否有仓单 0-没有 1-有
+	WrPriceType int32  `json:"-" form:"wrpricetype"` // 价格方式 - 1:固定价 2-浮动价  -   [挂牌]
+	MarketId    int32  `json:"-" form:"marketid"`    // 市场id
+	BRANDNAME   string `json:"-" form:"brandname"`   // 品牌名称
+}
+
+func (r *WrOrderQuote) calc() {
+
+}
+
+// buildSqlFixedPrice 一口价
+func (r *WrOrderQuote) buildSqlFixedPrice() string {
+	var sqlId utils.SQLVal = "with buyQuote as" +
+		" (" +
+		"  select a.wrfactortypeid, a.fixedprice buyPrice, sum(a.orderqty) buyQty" +
+		"    from (select t.wrfactortypeid," +
+		"                  t.marketid," +
+		"                  t.buyorsell," +
+		"                  t.orderqty - t.tradeqty as orderqty," +
+		"                  t.fixedprice," +
+		"                  rank() over(partition by t.wrfactortypeid order by t.fixedprice desc) cnt" +
+		"             from wrtrade_orderdetail t" +
+		"            where t.wrtradetype = 1 and t.buyorsell = 0 and t.wrtradeorderstatus in(3,10) %v" +
+		"          ) a" +
+		"   where a.cnt = 1" +
+		"   group by a.wrfactortypeid, a.fixedprice)," +
+		"sellQuote as" +
+		" (" +
+		"  select a.wrfactortypeid, a.fixedprice sellPrice, sum(a.orderqty) sellQty" +
+		"    from (select t.wrfactortypeid," +
+		"                  t.marketid," +
+		"                  t.buyorsell," +
+		"                  t.orderqty - t.tradeqty as orderqty," +
+		"                  t.fixedprice," +
+		"                  rank() over(partition by t.wrfactortypeid order by t.fixedprice asc) cnt" +
+		"             from wrtrade_orderdetail t" +
+		"            where t.wrtradetype = 1 and t.buyorsell = 1 and t.wrtradeorderstatus in(3,10) %v " +
+		"          ) a" +
+		"   where a.cnt = 1" +
+		"   group by a.wrfactortypeid, a.fixedprice)," +
+		"wrQuote as (" +
+		"  select nvl(k1.wrfactortypeid, k2.wrfactortypeid) wrfactortypeid," +
+		"         k1.buyPrice," +
+		"         k1.buyQty," +
+		"         k2.sellPrice," +
+		"         k2.sellQty" +
+		"    from buyQuote k1" +
+		"    full join sellQuote k2" +
+		"      on k1.wrfactortypeid = k2.wrfactortypeid" +
+		")" +
+		"select k.*," +
+		"       w.wrfactortypename," +
+		"       w.deliverygoodsid," +
+		"       w.wrstandardid," +
+		"       w.warehouseid," +
+		"       dg.deliverygoodsname," +
+		"       dg.deliverygoodscode," +
+		"       h.warehousename," +
+		"       h.warehousecode," +
+		"       wg.wrstandardname," +
+		"       wg.wrstandardcode," +
+		"       wg.wrstandardname || w.wrfactortypename as wrgoodsname" +
+		"  from wrQuote k" +
+		"  left join WRFactorType w" +
+		"    on k.wrfactortypeid = w.wrfactortypeid" +
+		"  left join deliverygoods dg" +
+		"    on w.deliverygoodsid = dg.deliverygoodsid" +
+		"  left join wrstandard wg" +
+		"    on w.wrstandardid = wg.wrstandardid" +
+		"  left join warehouseinfo h" +
+		"    on w.warehouseid = h.autoid" +
+		"  where 1=1 %v " +
+		"order by deliverygoodsname"
+	var param, param2 utils.SQLVal
+	param.And("t.haswr", r.HasWr)
+	param.And("t.wrpricetype", r.WrPriceType)
+	param.AndEx("t.marketid", r.MarketId, r.MarketId > 0)
+
+	param2.AndLike("w.wrfactortypename", r.WRSTANDARDNAME)
+	param2.AndLike("w.wrfactortypename", r.BRANDNAME)
+	param2.AndEx("w.warehouseid", r.WAREHOUSEID, r.WAREHOUSEID > 0)
+	sqlId.FormatParam(param.String(), param.String(), param2.String())
+
+	sqlId.Page(r.Page, r.PageSize)
+	return sqlId.String()
+}
+
+// buildSqlPriceMove 浮动价
+func (r *WrOrderQuote) buildSqlPriceMove() string {
+	var sqlId utils.SQLVal = "with buyQuote as" +
+		" (select a.wrfactortypeid," +
+		"         a.pricemove buypricemove," +
+		"         sum(a.orderqty) buyQty," +
+		"         a.goodsid," +
+		"         a.goodscode" +
+		"    from (select t.wrfactortypeid," +
+		"                 t.marketid," +
+		"                 t.buyorsell," +
+		"                 t.orderqty - t.tradeqty as orderqty," +
+		"                 t.pricemove," +
+		"                 t.wrtradeorderid," +
+		"                 c.goodsid," +
+		"                 c.goodscode," +
+		"                 rank() over(partition by t.wrfactortypeid, c.goodsid order by t.pricemove desc) cnt" +
+		"            from wrtrade_orderdetail t" +
+		"            left join WRTrade_GoodsConfig c" +
+		"              on t.wrtradeorderid = c.wrtradeorderid" +
+		"           where t.wrtradetype = 1 and t.wrtradeorderstatus in(3,10)" +
+		"             and t.buyorsell = 0 %v) a" +
+		"   where a.cnt = 1" +
+		"   group by a.wrfactortypeid, a.pricemove, a.goodsid, a.goodscode)," +
+		"sellQuote as" +
+		" (select a.wrfactortypeid," +
+		"         a.pricemove sellpricemove," +
+		"         a.goodsid," +
+		"         a.goodscode," +
+		"         sum(a.orderqty) sellQty" +
+		"    from (select t.wrfactortypeid," +
+		"                 t.marketid," +
+		"                 t.buyorsell," +
+		"                 t.orderqty - t.tradeqty as orderqty," +
+		"                 t.pricemove," +
+		"                 c.goodsid," +
+		"                 c.goodscode," +
+		"                 rank() over(partition by t.wrfactortypeid order by t.pricemove asc) cnt" +
+		"            from wrtrade_orderdetail t" +
+		"            left join WRTrade_GoodsConfig c" +
+		"              on t.wrtradeorderid = c.wrtradeorderid" +
+		"           where t.wrtradetype = 1 and t.wrtradeorderstatus in(3,10)" +
+		"             and t.buyorsell = 1 %v) a" +
+		"   where a.cnt = 1" +
+		"   group by a.wrfactortypeid, a.pricemove, a.goodsid, a.goodscode)," +
+		"wrQuote as" +
+		" (select nvl(k1.wrfactortypeid, k2.wrfactortypeid) wrfactortypeid," +
+		"         nvl(k1.goodsid, k2.goodsid) goodsid," +
+		"         nvl(k1.goodscode, k2.goodscode) goodscode," +
+		"         k1.buypricemove," +
+		"         k1.buyQty," +
+		"         k2.sellpricemove," +
+		"         k2.sellQty" +
+		"    from buyQuote k1" +
+		"    full join sellQuote k2" +
+		"      on k1.wrfactortypeid = k2.wrfactortypeid)" +
+		"select k.*," +
+		"       w.wrfactortypename," +
+		"       w.deliverygoodsid," +
+		"       w.wrstandardid," +
+		"       w.warehouseid," +
+		"       dg.deliverygoodsname," +
+		"       dg.deliverygoodscode," +
+		"       h.warehousename," +
+		"       h.warehousecode," +
+		"       wg.wrstandardname," +
+		"       wg.wrstandardcode," +
+		"       wg.wrstandardname || w.wrfactortypename as wrgoodsname" +
+		"  from wrQuote k" +
+		"  left join WRFactorType w" +
+		"    on k.wrfactortypeid = w.wrfactortypeid" +
+		"  left join deliverygoods dg" +
+		"    on w.deliverygoodsid = dg.deliverygoodsid" +
+		"  left join wrstandard wg" +
+		"    on w.wrstandardid = wg.wrstandardid" +
+		"  left join warehouseinfo h" +
+		"    on w.warehouseid = h.autoid" +
+		" where 1 = 1 %v" +
+		" order by deliverygoodsname"
+	var param, param2 utils.SQLVal
+	param.And("t.haswr", r.HasWr)
+	param.And("t.wrpricetype", r.WrPriceType)
+	param.AndEx("t.marketid", r.MarketId, r.MarketId > 0)
+
+	param2.AndLike("w.wrfactortypename", r.WRSTANDARDNAME)
+	param2.AndLike("w.wrfactortypename", r.BRANDNAME)
+	param2.AndEx("w.warehouseid", r.WAREHOUSEID, r.WAREHOUSEID > 0)
+	sqlId.FormatParam(param.String(), param.String(), param2.String())
+
+	sqlId.Page(r.Page, r.PageSize)
+	return sqlId.String()
+}
+
+func (r *WrOrderQuote) buildSql() string {
+	if r.WrPriceType == 1 {
+		return r.buildSqlFixedPrice()
+	} else {
+		return r.buildSqlPriceMove()
+	}
+}
+
+// GetDataEx 获取买卖大厅行情
+func (r *WrOrderQuote) GetDataEx() (interface{}, error) {
+	sData := make([]WrOrderQuote, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}
+
+// WrOrderQuoteDetail 行情大厅明细(买卖大厅)
+type WrOrderQuoteDetail struct {
+	WRTRADEORDERID string  `json:"wrtradeorderid"  xorm:"WRTRADEORDERID"`        // 仓单贸易委托单ID(320+Unix秒时间戳(10位)+xxxxxx)
+	BUYORSELL      int32   `json:"buyorsell"  xorm:"BUYORSELL" form:"buyorsell"` // 买卖 - 0:买 1:卖
+	USERID         int64   `json:"userid"  xorm:"USERID" form:"userid"`          // 购买方(销售方)用户ID
+	QTY            float64 `json:"orderqty"  xorm:"ORDERQTY"`                    // 买(卖)量(=委托量-成交量)
+	PRICE          float64 `json:"fixedprice"  xorm:"FIXEDPRICE"`                // 买(卖)价
+	PRICEMOVE      float64 `json:"pricemove"  xorm:"PRICEMOVE"`                  // 买(卖)升贴水- 基差
+	USERNAME       string  `json:"username"  xorm:"'USERNAME'"`                  // 购买方(销售方)
+	PageEx         `xorm:"extends"`
+
+	WRFACTORTYPEID int64 `json:"-" form:"wrfactortypeid"` // 仓单要素id
+	HasWr          int32 `json:"-" form:"haswr"`          // 是否有仓单 0-没有 1-有
+	WrPriceType    int32 `json:"-" form:"wrpricetype"`    // 价格方式 - 1:固定价 2-浮动价 - [挂牌]
+	MarketId       int32 `json:"-" form:"marketid"`       // 市场id
+	GOODSID        int32 `json:"-" form:"goodsid"`        // 商品id
+}
+
+func (r *WrOrderQuoteDetail) calc() {
+
+}
+
+func (r *WrOrderQuoteDetail) buildSql() string {
+	var sqlId utils.SQLVal = "select t.wrtradeorderid," +
+		"       t.wrfactortypeid," +
+		"       t.userid," +
+		"       t.orderqty - t.tradeqty as qty," +
+		"       t.fixedprice as price," +
+		"       t.pricemove," +
+		"       t.wrpricetype," +
+		"       t.buyorsell," +
+		"       u.accountname as username," +
+		"       c.goodsid," +
+		"       c.goodscode" +
+		"  from WRTRADE_ORDERDETAIL t" +
+		"  left join WRTRADE_GOODSCONFIG c" +
+		"    on t.wrtradeorderid = c.wrtradeorderid" +
+		"  left join Useraccount u" +
+		"    on t.userid = u.Accountname" +
+		" where 1 = 1" +
+		"   and t.wrtradetype = 1" +
+		"   and t.wrtradeorderstatus in (3, 10)"
+	sqlId.And("t.haswr", r.HasWr)
+	sqlId.And("t.wrpricetype", r.WrPriceType)
+	sqlId.And("t.wrfactortypeid", r.WRFACTORTYPEID)
+	sqlId.And("c.goodsid", r.GOODSID)
+	sqlId.And("t.buyorsell", r.BUYORSELL)
+	sqlId.AndEx("t.marketid", r.MarketId, r.MarketId > 0)
+
+	if r.BUYORSELL == 0 {
+		if r.WrPriceType == 1 {
+			sqlId.Join(" order by t.fixedprice desc")
+		} else {
+			sqlId.Join(" order by t.pricemove desc")
+		}
+	} else {
+		if r.WrPriceType == 1 {
+			sqlId.Join(" order by t.fixedprice asc")
+		} else {
+			sqlId.Join(" order by t.pricemove asc")
+		}
+	}
+	sqlId.Page(r.Page, r.PageSize)
+	return sqlId.String()
+}
+
+// GetDataEx 获取行情大厅明细(买卖大厅)
+func (r *WrOrderQuoteDetail) GetDataEx() (interface{}, error) {
+	sData := make([]WrOrderQuoteDetail, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}

+ 8 - 0
routers/router.go

@@ -21,6 +21,7 @@ import (
 	"mtp2_if/controllers/taaccount"
 	"mtp2_if/controllers/trade"
 	"mtp2_if/controllers/user"
+	"mtp2_if/controllers/wrTrade2"
 	"mtp2_if/controllers/wrtrade"
 	"mtp2_if/logger"
 	"mtp2_if/token"
@@ -511,6 +512,13 @@ func InitRouter() *gin.Engine {
 		qhjAgreementR.GET("QueryUserNodeCfgAndStatus", qhj.QueryUserNodeCfgAndStatus)
 	}
 
+	// **************************仓单贸易v2(仓单优化)********************
+	wrTrade2R := apiR.Group("WrTrade2")
+	{
+		wrTrade2R.GET("QueryOrderQuote", wrTrade2.QueryOrderQuote)
+		wrTrade2R.GET("QueryOrderQuoteDetail", wrTrade2.QueryOrderQuoteDetail)
+	}
+
 	return r
 }