소스 검색

1.增加查品种筛选框接口
2.fix bug: #96827

zou.yingbin 4 년 전
부모
커밋
036c0380ec
7개의 변경된 파일320개의 추가작업 그리고 21개의 파일을 삭제
  1. 16 0
      controllers/wrTrade2/qryWrTrade.go
  2. 84 0
      docs/docs.go
  3. 84 0
      docs/swagger.json
  4. 56 0
      docs/swagger.yaml
  5. 5 3
      models/ermcp3.go
  6. 74 18
      models/wrTrade2.go
  7. 1 0
      routers/router.go

+ 16 - 0
controllers/wrTrade2/qryWrTrade.go

@@ -48,6 +48,7 @@ func QueryOrderQuote(c *gin.Context) {
 // @Param wrfactortypeid query int true "仓单要素id"
 // @Param goodsid query int false "期货商品id(浮动价方式时填)"
 // @Param buyorsell query int true "买卖方向 0-买 1-卖"
+// @Param deliverymonth query string false "交收月(yyyy-mm) 查仓单预售的买卖大厅时填写"
 // @Success 200 {array} models.WrOrderQuoteDetail
 // @Failure 500 {object} app.Response
 // @Router /WrTrade2/QueryOrderQuoteDetail [get]
@@ -259,3 +260,18 @@ func QueryWrMarketTradeConfig(c *gin.Context) {
 	a.DoBindReq(&m)
 	a.DoGetDataI(&m)
 }
+
+// QueryFtDeliveryGoods
+// @Summary 查询品种品类筛选框列表
+// @Produce json
+// @Security ApiKeyAuth
+// @Success 200 {array} models.WrFtDeliveryGoods
+// @Failure 500 {object} app.Response
+// @Router /WrTrade2/QueryFtDeliveryGoods [get]
+// @Tags 仓单贸易v2
+func QueryFtDeliveryGoods(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.WrFtDeliveryGoods{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}

+ 84 - 0
docs/docs.go

@@ -11018,6 +11018,39 @@ var doc = `{
                 }
             }
         },
+        "/WrTrade2/QueryFtDeliveryGoods": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易v2"
+                ],
+                "summary": "查询品种品类筛选框列表",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.WrFtDeliveryGoods"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WrTrade2/QueryHoldLB": {
             "get": {
                 "security": [
@@ -11236,6 +11269,12 @@ var doc = `{
                         "name": "buyorsell",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "交收月(yyyy-mm) 查仓单预售的买卖大厅时填写",
+                        "name": "deliverymonth",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -29685,6 +29724,47 @@ var doc = `{
                 }
             }
         },
+        "models.WrFtDeliveryGoods": {
+            "type": "object",
+            "properties": {
+                "deliverygoodscode": {
+                    "description": "品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "品种ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "品种名称",
+                    "type": "string"
+                },
+                "wdlst": {
+                    "description": "商品列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.WrFtWrstandard"
+                    }
+                }
+            }
+        },
+        "models.WrFtWrstandard": {
+            "type": "object",
+            "properties": {
+                "wrstandardcode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "商品名称",
+                    "type": "string"
+                }
+            }
+        },
         "models.WrGoodsInfo": {
             "type": "object",
             "properties": {
@@ -30268,6 +30348,10 @@ var doc = `{
                     "description": "买卖 - 0:买 1:卖",
                     "type": "integer"
                 },
+                "deliverymonth": {
+                    "description": "交收月",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "单位名称",
                     "type": "string"

+ 84 - 0
docs/swagger.json

@@ -11002,6 +11002,39 @@
                 }
             }
         },
+        "/WrTrade2/QueryFtDeliveryGoods": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易v2"
+                ],
+                "summary": "查询品种品类筛选框列表",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.WrFtDeliveryGoods"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WrTrade2/QueryHoldLB": {
             "get": {
                 "security": [
@@ -11220,6 +11253,12 @@
                         "name": "buyorsell",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "交收月(yyyy-mm) 查仓单预售的买卖大厅时填写",
+                        "name": "deliverymonth",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -29669,6 +29708,47 @@
                 }
             }
         },
+        "models.WrFtDeliveryGoods": {
+            "type": "object",
+            "properties": {
+                "deliverygoodscode": {
+                    "description": "品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "品种ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "品种名称",
+                    "type": "string"
+                },
+                "wdlst": {
+                    "description": "商品列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.WrFtWrstandard"
+                    }
+                }
+            }
+        },
+        "models.WrFtWrstandard": {
+            "type": "object",
+            "properties": {
+                "wrstandardcode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "商品名称",
+                    "type": "string"
+                }
+            }
+        },
         "models.WrGoodsInfo": {
             "type": "object",
             "properties": {
@@ -30252,6 +30332,10 @@
                     "description": "买卖 - 0:买 1:卖",
                     "type": "integer"
                 },
+                "deliverymonth": {
+                    "description": "交收月",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "单位名称",
                     "type": "string"

+ 56 - 0
docs/swagger.yaml

@@ -13400,6 +13400,35 @@ definitions:
         description: 类型 1-品种 2-品类(商品) 3-仓库
         type: integer
     type: object
+  models.WrFtDeliveryGoods:
+    properties:
+      deliverygoodscode:
+        description: 品种代码
+        type: string
+      deliverygoodsid:
+        description: 品种ID
+        type: integer
+      deliverygoodsname:
+        description: 品种名称
+        type: string
+      wdlst:
+        description: 商品列表
+        items:
+          $ref: '#/definitions/models.WrFtWrstandard'
+        type: array
+    type: object
+  models.WrFtWrstandard:
+    properties:
+      wrstandardcode:
+        description: 现货商品代码
+        type: string
+      wrstandardid:
+        description: 现货商品ID
+        type: integer
+      wrstandardname:
+        description: 商品名称
+        type: string
+    type: object
   models.WrGoodsInfo:
     properties:
       haswr:
@@ -13837,6 +13866,9 @@ definitions:
       buyorsell:
         description: 买卖 - 0:买 1:卖
         type: integer
+      deliverymonth:
+        description: 交收月
+        type: string
       enumdicname:
         description: 单位名称
         type: string
@@ -23237,6 +23269,26 @@ paths:
       summary: 查询筛选框列表
       tags:
       - 仓单贸易v2
+  /WrTrade2/QueryFtDeliveryGoods:
+    get:
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.WrFtDeliveryGoods'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询品种品类筛选框列表
+      tags:
+      - 仓单贸易v2
   /WrTrade2/QueryHoldLB:
     get:
       description: 页面 现货仓单->现货明细? ,  表名叫仓单持有记录, 有挂单特有维度,为防误解汇总也有相关维度, 新写接口,不跟汇总合在一起了。
@@ -23374,6 +23426,10 @@ paths:
         name: buyorsell
         required: true
         type: integer
+      - description: 交收月(yyyy-mm) 查仓单预售的买卖大厅时填写
+        in: query
+        name: deliverymonth
+        type: string
       produces:
       - application/json
       responses:

+ 5 - 3
models/ermcp3.go

@@ -1312,7 +1312,7 @@ func (r *Ermcp3Wrstandard) calc() {
 }
 
 func (r *Ermcp3Wrstandard) buildSql() string {
-	str := "select WRSTANDARDID," +
+	sqlId := "select WRSTANDARDID," +
 		"       WRSTANDARDCODE," +
 		"       DELIVERYGOODSID," +
 		"       UNITID," +
@@ -1329,8 +1329,10 @@ func (r *Ermcp3Wrstandard) buildSql() string {
 		"       CONVERTFACTOR," +
 		"       AREAUSERID" +
 		"  from wrstandard t" +
-		" where t.AREAUSERID=%v"
-	sqlId := fmt.Sprintf(str, r.AREAUSERID)
+		" where 1=1"
+	if r.AREAUSERID > 0 {
+		sqlId += fmt.Sprintf(" and t.AREAUSERID=%v", r.AREAUSERID)
+	}
 	if r.DELIVERYGOODSID > 0 {
 		sqlId = sqlId + fmt.Sprintf(" and DELIVERYGOODSID=%v", r.DELIVERYGOODSID)
 	}

+ 74 - 18
models/wrTrade2.go

@@ -54,41 +54,44 @@ func (r *WrOrderQuote) calc() {
 func (r *WrOrderQuote) buildSqlFixedPrice() string {
 	var sqlId utils.SQLVal = "with buyQuote as" +
 		" (" +
-		"  select to_char(a.wrfactortypeid) wrfactortypeid, a.fixedprice buyPrice, sum(a.orderqty) buyQty" +
+		"  select to_char(a.wrfactortypeid) wrfactortypeid, a.fixedprice buyPrice, sum(a.orderqty) buyQty, a.deliverymonth" +
 		"    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" +
+		"                  nvl(t.deliverymonth,'0') deliverymonth," +
+		"                  rank() over(partition by t.wrfactortypeid, nvl(t.deliverymonth,'0') 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)," +
+		"   group by a.wrfactortypeid, a.fixedprice, a.deliverymonth)," +
 		"sellQuote as" +
 		" (" +
-		"  select to_char(a.wrfactortypeid) wrfactortypeid, a.fixedprice sellPrice, sum(a.orderqty) sellQty" +
+		"  select to_char(a.wrfactortypeid) wrfactortypeid, a.fixedprice sellPrice, sum(a.orderqty) sellQty, a.deliverymonth" +
 		"    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" +
+		"                  nvl(t.deliverymonth,'0') deliverymonth," +
+		"                  rank() over(partition by t.wrfactortypeid, nvl(t.deliverymonth,'0') 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)," +
+		"   group by a.wrfactortypeid, a.fixedprice, a.deliverymonth)," +
 		"wrQuote as (" +
 		"  select nvl(k1.wrfactortypeid, k2.wrfactortypeid) wrfactortypeid," +
+		"         nvl(k1.deliverymonth, k2.deliverymonth) deliverymonth," +
 		"         k1.buyPrice," +
 		"         k1.buyQty," +
 		"         k2.sellPrice," +
 		"         k2.sellQty" +
 		"    from buyQuote k1" +
 		"    full join sellQuote k2" +
-		"      on k1.wrfactortypeid = k2.wrfactortypeid" +
+		"      on k1.wrfactortypeid = k2.wrfactortypeid and k1.deliverymonth = k2.deliverymonth" +
 		")" +
 		"select k.*," +
 		"       w.wrfactortypename," +
@@ -148,7 +151,7 @@ func (r *WrOrderQuote) buildSqlPriceMove() string {
 		"                 t.orderqty - t.tradeqty as orderqty," +
 		"                 t.pricemove," +
 		"                 t.wrtradeorderid," +
-		"                 t.deliverymonth," +
+		"                 nvl(t.deliverymonth,'0') deliverymonth," +
 		"                 c.goodsid," +
 		"                 c.goodscode," +
 		"                 rank() over(partition by t.wrfactortypeid, nvl(t.deliverymonth,'0'), c.goodsid order by t.pricemove desc) cnt" +
@@ -171,7 +174,7 @@ func (r *WrOrderQuote) buildSqlPriceMove() string {
 		"                 t.buyorsell," +
 		"                 t.orderqty - t.tradeqty as orderqty," +
 		"                 t.pricemove," +
-		"                 t.deliverymonth," +
+		"                 nvl(t.deliverymonth,'0') deliverymonth," +
 		"                 c.goodsid," +
 		"                 c.goodscode," +
 		"                 rank() over(partition by t.wrfactortypeid, nvl(t.deliverymonth,'0'), c.goodsid order by t.pricemove asc) cnt" +
@@ -258,15 +261,16 @@ func (r *WrOrderQuote) GetDataByPage() (interface{}, error, int, int, int) {
 
 // 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:"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'"`                // 现货商品最小变动值
+	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"` // 交收月
 	PageEx         `xorm:"extends"`
 
 	WRFACTORTYPEID int64 `json:"-" form:"wrfactortypeid"` // 仓单要素id
@@ -289,6 +293,7 @@ func (r *WrOrderQuoteDetail) buildSql() string {
 		"       t.pricemove," +
 		"       t.wrpricetype," +
 		"       t.buyorsell," +
+		"       t.deliverymonth," +
 		"       u.accountname as username," +
 		"       c.goodsid," +
 		"       c.goodscode," +
@@ -311,6 +316,7 @@ func (r *WrOrderQuoteDetail) buildSql() string {
 	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 {
@@ -1636,3 +1642,53 @@ func (r *WrMarketTradeConfig) GetDataEx() (interface{}, error) {
 	}
 	return sData, err
 }
+
+// WrFtWrstandard 品类筛选列表
+type WrFtWrstandard struct {
+	WRSTANDARDID   int64  `json:"wrstandardid"`   // 现货商品ID
+	WRSTANDARDCODE string `json:"wrstandardcode"` // 现货商品代码
+	WRSTANDARDNAME string `json:"wrstandardname"` // 商品名称
+}
+
+// WrFtDeliveryGoods 品种筛选列表
+type WrFtDeliveryGoods struct {
+	DELIVERYGOODSID   int32            `json:"deliverygoodsid"`   // 品种ID
+	DELIVERYGOODSCODE string           `json:"deliverygoodscode"` // 品种代码
+	DELIVERYGOODSNAME string           `json:"deliverygoodsname"` // 品种名称
+	WDLST             []WrFtWrstandard `json:"wdlst"`             // 商品列表
+}
+
+// GetDataEx 获取品种商品筛选列表
+func (r *WrFtDeliveryGoods) GetDataEx() (interface{}, error) {
+	sData := make([]WrFtDeliveryGoods, 0)
+	mg := ErmcpDeliveryGoods{}
+	sMgData, err := mg.GetData()
+	if err == nil {
+		mWd := Ermcp3Wrstandard{}
+		if d, er := mWd.GetDataEx(); er == nil {
+			if sMd, ok := d.([]Ermcp3Wrstandard); ok {
+				for _, v := range sMgData {
+					item := WrFtDeliveryGoods{
+						DELIVERYGOODSID:   v.DELIVERYGOODSID,
+						DELIVERYGOODSCODE: v.DELIVERYGOODSCODE,
+						DELIVERYGOODSNAME: v.DELIVERYGOODSNAME,
+						WDLST:             make([]WrFtWrstandard, 0),
+					}
+					for _, a := range sMd {
+						if a.DELIVERYGOODSID == item.DELIVERYGOODSID {
+							val := WrFtWrstandard{
+								WRSTANDARDID:   a.WRSTANDARDID,
+								WRSTANDARDNAME: a.WRSTANDARDNAME,
+								WRSTANDARDCODE: a.WRSTANDARDCODE,
+							}
+							item.WDLST = append(item.WDLST, val)
+						}
+					}
+					sData = append(sData, item)
+				}
+			}
+		}
+	}
+
+	return sData, err
+}

+ 1 - 0
routers/router.go

@@ -531,6 +531,7 @@ func InitRouter() *gin.Engine {
 		wrTrade2R.GET("QueryFaProductDetail", wrTrade2.QueryFaProductDetail)
 		wrTrade2R.GET("QueryWrFactorTypeInfo", wrTrade2.QueryWrFactorTypeInfo)
 		wrTrade2R.GET("QueryWrMarketTradeConfig", wrTrade2.QueryWrMarketTradeConfig)
+		wrTrade2R.GET("QueryFtDeliveryGoods", wrTrade2.QueryFtDeliveryGoods)
 	}
 
 	return r