Forráskód Böngészése

增加查询贸易圈挂牌大厅接口

zou.yingbin 4 éve
szülő
commit
0c13a7b362
6 módosított fájl, 595 hozzáadás és 4 törlés
  1. 22 1
      controllers/wrTrade2/qryWrTrade.go
  2. 164 0
      docs/docs.go
  3. 164 0
      docs/swagger.json
  4. 115 0
      docs/swagger.yaml
  5. 129 3
      models/wrTrade2.go
  6. 1 0
      routers/router.go

+ 22 - 1
controllers/wrTrade2/qryWrTrade.go

@@ -63,6 +63,27 @@ func QueryOrderQuoteDetail(c *gin.Context) {
 	a.DoGetDataByPage(&m)
 }
 
+// QueryOrderQuoteMyq
+// @Summary 查询贸易圈挂牌大厅
+// @Description
+// @Produce json
+// @Security ApiKeyAuth
+// @Param page query int false "页码"
+// @Param pagesize query int false "每页条数"
+// @Param marketid query int false "仓单贸易市场id"
+// @Param haswr query int true "0:仓单预售 1:仓单贸易"
+// @Param buyorsell query int true "买卖方向 0-买 1-卖"
+// @Success 200 {array} models.WrQuoteOrderMyq
+// @Failure 500 {object} app.Response
+// @Router /WrTrade2/QueryOrderQuoteMyq [get]
+// @Tags 仓单贸易v2
+func QueryOrderQuoteMyq(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.WrQuoteOrderMyq{}
+	a.DoBindReq(&m)
+	a.DoGetDataByPage(&m)
+}
+
 // QueryWrPosition
 // @Summary 查询现货(预售)仓单持仓
 // @Description 页面 现货仓单->现货汇总/库存汇总; 预售仓单->订单汇总
@@ -483,5 +504,5 @@ func QueryWrAverageTradePrice(c *gin.Context) {
 	a := app.GinUtils{Gin: app.Gin{C: c}}
 	m := models.WrAverageTradePrice{}
 	a.DoBindReq(&m)
-	a.DoGetDataI(&m)
+	a.DoGetDataByPage(&m)
 }

+ 164 - 0
docs/docs.go

@@ -11315,6 +11315,73 @@ var doc = `{
                 }
             }
         },
+        "/WrTrade2/QueryOrderQuoteMyq": {
+            "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": "0:仓单预售 1:仓单贸易",
+                        "name": "haswr",
+                        "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.WrQuoteOrderMyq"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WrTrade2/QueryPerformancePlan": {
             "get": {
                 "security": [
@@ -32067,6 +32134,103 @@ var doc = `{
                 }
             }
         },
+        "models.WrQuoteOrderMyq": {
+            "type": "object",
+            "properties": {
+                "buyorsell": {
+                    "description": "买卖 - 0:买 1:卖",
+                    "type": "integer"
+                },
+                "canbargain": {
+                    "description": "是否可议价 - 0:不可 1:可",
+                    "type": "integer"
+                },
+                "canpart": {
+                    "description": "是否允许部份摘牌 - 0:不允许 1:允许",
+                    "type": "integer"
+                },
+                "delistminqty": {
+                    "description": "起摘数量",
+                    "type": "number"
+                },
+                "deliverymonth": {
+                    "description": "交收月",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
+                "fixedprice": {
+                    "description": "买(卖)价",
+                    "type": "number"
+                },
+                "goodscode": {
+                    "description": "商品合约代码",
+                    "type": "string"
+                },
+                "marginflag": {
+                    "description": "挂牌是否指定保证金 - 0:未指定 1:指定",
+                    "type": "integer"
+                },
+                "marginvalue": {
+                    "description": "保证金设置值",
+                    "type": "number"
+                },
+                "minivalue": {
+                    "description": "现货商品最小变动值",
+                    "type": "integer"
+                },
+                "orderqty": {
+                    "description": "买(卖)量(=委托量-成交量)",
+                    "type": "number"
+                },
+                "ordertime": {
+                    "description": "委托时间",
+                    "type": "string"
+                },
+                "performancetemplateid": {
+                    "description": "履约模板id",
+                    "type": "integer"
+                },
+                "pricemove": {
+                    "description": "买(卖)升贴水- 基差",
+                    "type": "number"
+                },
+                "templatename": {
+                    "description": "履约模板名称",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "购买方(销售方)用户ID",
+                    "type": "integer"
+                },
+                "username": {
+                    "description": "购买方(销售方)",
+                    "type": "string"
+                },
+                "validtime": {
+                    "description": "有效期限",
+                    "type": "string"
+                },
+                "validtype": {
+                    "description": "有效类型 - 1当日有效 2本周有效 3指定日期有效 4一直有效",
+                    "type": "integer"
+                },
+                "warehousename": {
+                    "description": "仓库名称",
+                    "type": "string"
+                },
+                "wrtradeorderid": {
+                    "description": "仓单贸易委托单ID(320+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "wrtypename": {
+                    "description": "商品",
+                    "type": "string"
+                }
+            }
+        },
         "models.WrScfContract": {
             "type": "object",
             "properties": {

+ 164 - 0
docs/swagger.json

@@ -11299,6 +11299,73 @@
                 }
             }
         },
+        "/WrTrade2/QueryOrderQuoteMyq": {
+            "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": "0:仓单预售 1:仓单贸易",
+                        "name": "haswr",
+                        "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.WrQuoteOrderMyq"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WrTrade2/QueryPerformancePlan": {
             "get": {
                 "security": [
@@ -32051,6 +32118,103 @@
                 }
             }
         },
+        "models.WrQuoteOrderMyq": {
+            "type": "object",
+            "properties": {
+                "buyorsell": {
+                    "description": "买卖 - 0:买 1:卖",
+                    "type": "integer"
+                },
+                "canbargain": {
+                    "description": "是否可议价 - 0:不可 1:可",
+                    "type": "integer"
+                },
+                "canpart": {
+                    "description": "是否允许部份摘牌 - 0:不允许 1:允许",
+                    "type": "integer"
+                },
+                "delistminqty": {
+                    "description": "起摘数量",
+                    "type": "number"
+                },
+                "deliverymonth": {
+                    "description": "交收月",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
+                "fixedprice": {
+                    "description": "买(卖)价",
+                    "type": "number"
+                },
+                "goodscode": {
+                    "description": "商品合约代码",
+                    "type": "string"
+                },
+                "marginflag": {
+                    "description": "挂牌是否指定保证金 - 0:未指定 1:指定",
+                    "type": "integer"
+                },
+                "marginvalue": {
+                    "description": "保证金设置值",
+                    "type": "number"
+                },
+                "minivalue": {
+                    "description": "现货商品最小变动值",
+                    "type": "integer"
+                },
+                "orderqty": {
+                    "description": "买(卖)量(=委托量-成交量)",
+                    "type": "number"
+                },
+                "ordertime": {
+                    "description": "委托时间",
+                    "type": "string"
+                },
+                "performancetemplateid": {
+                    "description": "履约模板id",
+                    "type": "integer"
+                },
+                "pricemove": {
+                    "description": "买(卖)升贴水- 基差",
+                    "type": "number"
+                },
+                "templatename": {
+                    "description": "履约模板名称",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "购买方(销售方)用户ID",
+                    "type": "integer"
+                },
+                "username": {
+                    "description": "购买方(销售方)",
+                    "type": "string"
+                },
+                "validtime": {
+                    "description": "有效期限",
+                    "type": "string"
+                },
+                "validtype": {
+                    "description": "有效类型 - 1当日有效 2本周有效 3指定日期有效 4一直有效",
+                    "type": "integer"
+                },
+                "warehousename": {
+                    "description": "仓库名称",
+                    "type": "string"
+                },
+                "wrtradeorderid": {
+                    "description": "仓单贸易委托单ID(320+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "wrtypename": {
+                    "description": "商品",
+                    "type": "string"
+                }
+            }
+        },
         "models.WrScfContract": {
             "type": "object",
             "properties": {

+ 115 - 0
docs/swagger.yaml

@@ -14702,6 +14702,78 @@ definitions:
         description: 持有人ID
         type: integer
     type: object
+  models.WrQuoteOrderMyq:
+    properties:
+      buyorsell:
+        description: 买卖 - 0:买 1:卖
+        type: integer
+      canbargain:
+        description: 是否可议价 - 0:不可 1:可
+        type: integer
+      canpart:
+        description: 是否允许部份摘牌 - 0:不允许 1:允许
+        type: integer
+      delistminqty:
+        description: 起摘数量
+        type: number
+      deliverymonth:
+        description: 交收月
+        type: string
+      enumdicname:
+        description: 单位名称
+        type: string
+      fixedprice:
+        description: 买(卖)价
+        type: number
+      goodscode:
+        description: 商品合约代码
+        type: string
+      marginflag:
+        description: 挂牌是否指定保证金 - 0:未指定 1:指定
+        type: integer
+      marginvalue:
+        description: 保证金设置值
+        type: number
+      minivalue:
+        description: 现货商品最小变动值
+        type: integer
+      orderqty:
+        description: 买(卖)量(=委托量-成交量)
+        type: number
+      ordertime:
+        description: 委托时间
+        type: string
+      performancetemplateid:
+        description: 履约模板id
+        type: integer
+      pricemove:
+        description: 买(卖)升贴水- 基差
+        type: number
+      templatename:
+        description: 履约模板名称
+        type: string
+      userid:
+        description: 购买方(销售方)用户ID
+        type: integer
+      username:
+        description: 购买方(销售方)
+        type: string
+      validtime:
+        description: 有效期限
+        type: string
+      validtype:
+        description: 有效类型 - 1当日有效 2本周有效 3指定日期有效 4一直有效
+        type: integer
+      warehousename:
+        description: 仓库名称
+        type: string
+      wrtradeorderid:
+        description: 仓单贸易委托单ID(320+Unix秒时间戳(10位)+xxxxxx)
+        type: string
+      wrtypename:
+        description: 商品
+        type: string
+    type: object
   models.WrScfContract:
     properties:
       borroweruserid:
@@ -24257,6 +24329,49 @@ paths:
       summary: 查询买卖大厅
       tags:
       - 仓单贸易v2
+  /WrTrade2/QueryOrderQuoteMyq:
+    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: 0:仓单预售 1:仓单贸易
+        in: query
+        name: haswr
+        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.WrQuoteOrderMyq'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询贸易圈挂牌
+      tags:
+      - 仓单贸易v2
   /WrTrade2/QueryPerformancePlan:
     get:
       parameters:

+ 129 - 3
models/wrTrade2.go

@@ -1043,7 +1043,7 @@ type WrGoodsPerformanceStep struct {
 
 func (r *WrGoodsPerformanceStep) calc() {
 	switch r.STEPTYPEID {
-	case 1, 2:
+	case 1, 2, 98:
 		r.STEPINFO = fmt.Sprintf("%v %v%%", r.STEPTYPENAME, r.STEPVALUE*100)
 	default:
 		if r.STEPVALUE == 0 {
@@ -2677,7 +2677,7 @@ func (r *WrAverageTradePrice) buildSql() string {
 }
 
 // GetDataEx 获取成交均价(历史走势)
-func (r *WrAverageTradePrice) GetDataEx() (interface{}, error) {
+func (r *WrAverageTradePrice) GetDataByPage() (interface{}, error, int, int, int) {
 	sData := make([]WrAverageTradePrice, 0)
 	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
 	for i := range sData {
@@ -2692,5 +2692,131 @@ func (r *WrAverageTradePrice) GetDataEx() (interface{}, error) {
 			j--
 		}
 	}
-	return sData, err
+	if len(sData) > 0 {
+		r.Total = sData[0].Total
+	}
+	return sData, err, r.Page, r.PageSize, r.Total
+}
+
+// WrQuoteOrderMyq 贸易圈大厅
+type WrQuoteOrderMyq 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:"qty"`                                       // 买(卖)量(=委托量-成交量)
+	PRICE          float64  `json:"fixedprice"  xorm:"price"`                                   // 买(卖)价
+	PRICEMOVE      float64  `json:"pricemove"  xorm:"PRICEMOVE"`                                // 买(卖)升贴水- 基差
+	USERNAME       string   `json:"username"  xorm:"'USERNAME'"`                                // 购买方(销售方)
+	ENUMDICNAME    string   `json:"enumdicname" xorm:"'enumdicname'"`                           // 单位名称
+	MINIVALUE      int32    `json:"minivalue"  xorm:"'MINIVALUE'"`                              // 现货商品最小变动值
+	DELIVERYMONTH  string   `json:"deliverymonth"  xorm:"'DELIVERYMONTH'" form:"deliverymonth"` // 交收月
+	ORDERTIME      string   `json:"ordertime"  xorm:"'ORDERTIME'"`                              // 委托时间
+	DELISTMINQTY   SFLOAT64 `json:"delistminqty"  xorm:"'DELISTMINQTY'"`                        // 起摘数量
+
+	CANBARGAIN            int32   `json:"canbargain"  xorm:"'CANBARGAIN'"`                       // 是否可议价 - 0:不可 1:可
+	CANPART               int32   `json:"canpart"  xorm:"'CANPART'"`                             // 是否允许部份摘牌 - 0:不允许 1:允许
+	MARGINFLAG            int32   `json:"marginflag"  xorm:"'MARGINFLAG'"`                       // 挂牌是否指定保证金 - 0:未指定 1:指定
+	MARGINVALUE           float64 `json:"marginvalue"  xorm:"'MARGINVALUE'"`                     // 保证金设置值
+	VALIDTYPE             int32   `json:"validtype"  xorm:"'VALIDTYPE'"`                         // 有效类型 - 1当日有效 2本周有效 3指定日期有效 4一直有效
+	VALIDTIME             string  `json:"validtime"  xorm:"'VALIDTIME'"`                         // 有效期限
+	PERFORMANCETEMPLATEID int64   `json:"performancetemplateid"  xorm:"'PERFORMANCETEMPLATEID'"` // 履约模板id
+	GOODSCODE             string  `json:"goodscode"  xorm:"'GOODSCODE'"`                         // 商品合约代码
+	TEMPLATENAME          string  `json:"templatename"  xorm:"'TEMPLATENAME'"`                   // 履约模板名称
+	WAREHOUSENAME         string  `json:"warehousename"  xorm:"'WAREHOUSENAME'"`                 // 仓库名称
+	WRTYPENAME            string  `json:"wrtypename" xorm:"'WRTYPENAME'"`                        // 商品
+	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 *WrQuoteOrderMyq) calc() {
+	r.WRTYPENAME = strings.ReplaceAll(r.WRTYPENAME, ",", "-")
+	r.USERNAME = EncryptByStar(r.USERNAME)
+}
+
+func (r *WrQuoteOrderMyq) buildSql() string {
+	var sqlId utils.SQLVal = "select to_char(t.wrtradeorderid) wrtradeorderid," +
+		"       to_char(t.wrfactortypeid) wrfactortypeid," +
+		"       t.userid," +
+		"       t.orderqty - t.tradeqty as qty," +
+		"       t.fixedprice as price," +
+		"       t.pricemove," +
+		"       t.wrpricetype," +
+		"       t.buyorsell," +
+		"       t.deliverymonth," +
+		"       t.delistminqty," +
+		"       t.haswr," +
+		"       t.canbargain," +
+		"       t.canpart," +
+		"       t.marginflag," +
+		"       t.marginvalue," +
+		"       t.validtype," +
+		"       to_char(t.validtime, 'yyyy-mm-dd hh24:mi:ss') validtime," +
+		"       t.performancetemplateid," +
+		"       to_char(t.ordertime, 'yyyy-mm-dd hh24:mi:ss') ordertime," +
+		"       u.accountname as username," +
+		"       c.goodsid," +
+		"       c.goodscode," +
+		"       wd.minivalue," +
+		"       e.enumdicname," +
+		"       wd.wrstandardname || w.wrfactortypename2 WRTYPENAME," +
+		"       s.templatename," +
+		"       h.warehousename" +
+		"  from WRTRADE_ORDERDETAIL t" +
+		"  left join WRTRADE_GOODSCONFIG c" +
+		"    on t.wrtradeorderid = c.wrtradeorderid" +
+		"  left join Useraccount u" +
+		"    on t.userid = u.userid" +
+		"  left join wrfactortype w" +
+		"    on t.wrfactortypeid = w.wrfactortypeid" +
+		"  left join wrstandard wd" +
+		"    on w.wrstandardid = wd.wrstandardid" +
+		"  left join performanceplantemplate s on t.performancetemplateid=s.autoid" +
+		"  left join warehouseinfo h on w.warehouseid=h.autoid" +
+		"  left join enumdicitem e" +
+		"    on wd.unitid = e.enumitemname" +
+		"   and e.enumdiccode = 'goodsunit'" +
+		" where 1 = 1" +
+		"   and t.wrtradetype = 1" +
+		"   and t.wrtradeorderstatus in (3, 10)"
+	sqlId.And("t.haswr", r.HasWr)
+	r.WrPriceType = 1 // 查固定价
+	sqlId.And("t.wrpricetype", r.WrPriceType)
+	sqlId.AndEx("t.wrfactortypeid", r.WRFACTORTYPEID, r.WRFACTORTYPEID > 0)
+	sqlId.AndEx("c.goodsid", r.GOODSID, r.GOODSID > 0)
+	sqlId.And("t.buyorsell", r.BUYORSELL)
+	sqlId.AndEx("t.marketid", r.MarketId, r.MarketId > 0)
+	sqlId.AndEx("t.deliverymonth", r.DELIVERYMONTH, len(r.DELIVERYMONTH) > 0)
+
+	if r.BUYORSELL == 0 {
+		if r.WrPriceType == 1 {
+			sqlId.Join(" order by t.fixedprice desc, t.ordertime")
+		} else {
+			sqlId.Join(" order by t.pricemove desc, t.ordertime")
+		}
+	} else {
+		if r.WrPriceType == 1 {
+			sqlId.Join(" order by t.fixedprice asc, t.ordertime")
+		} else {
+			sqlId.Join(" order by t.pricemove asc, t.ordertime")
+		}
+	}
+	sqlId.Page(r.Page, r.PageSize)
+	return sqlId.String()
+}
+
+// GetDataByPage 获取贸易圈大厅
+func (r *WrQuoteOrderMyq) GetDataByPage() (interface{}, error, int, int, int) {
+	sData := make([]WrQuoteOrderMyq, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	total := 0
+	for i := range sData {
+		sData[i].calc()
+		total = sData[i].Total
+	}
+	return sData, err, r.Page, r.PageSize, total
 }

+ 1 - 0
routers/router.go

@@ -544,6 +544,7 @@ func InitRouter() *gin.Engine {
 		wrTrade2R.GET("QueryWrBsGoodsInfo", wrTrade2.QueryWrBsGoodsInfo)
 		wrTrade2R.GET("QueryWrTradeOrderDetail", wrTrade2.QueryWrTradeOrderDetail)
 		wrTrade2R.GET("QueryWrAverageTradePrice", wrTrade2.QueryWrAverageTradePrice)
+		wrTrade2R.GET("QueryOrderQuoteMyq", wrTrade2.QueryOrderQuoteMyq)
 	}
 
 	return r