Prechádzať zdrojové kódy

1.增加查询合约交收可点选仓单接口
2.增加查询贸易圈挂牌大厅接口
3.联调问题修改

zou.yingbin 4 rokov pred
rodič
commit
76ee8da7f8
6 zmenil súbory, kde vykonal 560 pridanie a 4 odobranie
  1. 17 0
      controllers/wrTrade2/qryWrTrade.go
  2. 151 1
      docs/docs.go
  3. 151 1
      docs/swagger.json
  4. 107 1
      docs/swagger.yaml
  5. 133 1
      models/wrTrade2.go
  6. 1 0
      routers/router.go

+ 17 - 0
controllers/wrTrade2/qryWrTrade.go

@@ -506,3 +506,20 @@ func QueryWrAverageTradePrice(c *gin.Context) {
 	a.DoBindReq(&m)
 	a.DoGetDataByPage(&m)
 }
+
+// QueryWrDeliveryAvalidHoldLB
+// @Summary 查询合约交收可点选仓单
+// @Produce json
+// @Security ApiKeyAuth
+// @Param accountid query int true "资金账号"
+// @Param goodsid query int true "商品id"
+// @Success 200 {array} models.WrDeliveryAvalidHoldLB
+// @Failure 500 {object} app.Response
+// @Router /WrTrade2/QueryWrDeliveryAvalidHoldLB [get]
+// @Tags 仓单贸易v2
+func QueryWrDeliveryAvalidHoldLB(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.WrDeliveryAvalidHoldLB{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}

+ 151 - 1
docs/docs.go

@@ -11328,7 +11328,7 @@ var doc = `{
                 "tags": [
                     "仓单贸易v2"
                 ],
-                "summary": "查询贸易圈挂牌",
+                "summary": "查询贸易圈挂牌大厅",
                 "parameters": [
                     {
                         "type": "integer",
@@ -11576,6 +11576,55 @@ var doc = `{
                 }
             }
         },
+        "/WrTrade2/QueryWrDeliveryAvalidHoldLB": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易v2"
+                ],
+                "summary": "查询合约交收可点选仓单",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "资金账号",
+                        "name": "accountid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商品id",
+                        "name": "goodsid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.WrDeliveryAvalidHoldLB"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WrTrade2/QueryWrDeliveryDetail": {
             "get": {
                 "security": [
@@ -30348,6 +30397,107 @@ var doc = `{
                 }
             }
         },
+        "models.WrDeliveryAvalidHoldLB": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "资金账号",
+                    "type": "integer"
+                },
+                "avalidqty": {
+                    "description": "数量(可点选数量)",
+                    "type": "number"
+                },
+                "deliverygoodsid": {
+                    "description": "品种id",
+                    "type": "integer"
+                },
+                "goodsid": {
+                    "description": "x合约商品id",
+                    "type": "integer"
+                },
+                "ladingbillid": {
+                    "description": "提单id",
+                    "type": "string"
+                },
+                "pgoodscode": {
+                    "description": "p商品代码(点价合约)",
+                    "type": "string"
+                },
+                "pgoodsid": {
+                    "description": "p商品id(点价合约)",
+                    "type": "integer"
+                },
+                "pgoodsname": {
+                    "description": "p商品名称(点价合约)",
+                    "type": "string"
+                },
+                "pricemove": {
+                    "description": "升贴水",
+                    "type": "number"
+                },
+                "qty": {
+                    "description": "用户仓单数量",
+                    "type": "number"
+                },
+                "subnum": {
+                    "description": "提单子id",
+                    "type": "integer"
+                },
+                "uqty": {
+                    "description": "用户持有数量",
+                    "type": "number"
+                },
+                "userid": {
+                    "description": "用户id",
+                    "type": "integer"
+                },
+                "username": {
+                    "description": "仓单持有人",
+                    "type": "string"
+                },
+                "warehousecode": {
+                    "description": "仓库代码",
+                    "type": "string"
+                },
+                "warehouseid": {
+                    "description": "仓库id",
+                    "type": "integer"
+                },
+                "warehousename": {
+                    "description": "仓库名称",
+                    "type": "string"
+                },
+                "wrfactortypeid": {
+                    "description": "仓单要素id",
+                    "type": "string"
+                },
+                "wrfactortypename2": {
+                    "description": "仓单要素名称(不含仓库)",
+                    "type": "string"
+                },
+                "wrstandardcode": {
+                    "description": "品代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "品类d",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "品类名称",
+                    "type": "string"
+                },
+                "xgoodscode": {
+                    "description": "x合约代码",
+                    "type": "string"
+                },
+                "xgoodsname": {
+                    "description": "x合约名称",
+                    "type": "string"
+                }
+            }
+        },
         "models.WrDeliveryDetail": {
             "type": "object",
             "properties": {

+ 151 - 1
docs/swagger.json

@@ -11312,7 +11312,7 @@
                 "tags": [
                     "仓单贸易v2"
                 ],
-                "summary": "查询贸易圈挂牌",
+                "summary": "查询贸易圈挂牌大厅",
                 "parameters": [
                     {
                         "type": "integer",
@@ -11560,6 +11560,55 @@
                 }
             }
         },
+        "/WrTrade2/QueryWrDeliveryAvalidHoldLB": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易v2"
+                ],
+                "summary": "查询合约交收可点选仓单",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "资金账号",
+                        "name": "accountid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商品id",
+                        "name": "goodsid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.WrDeliveryAvalidHoldLB"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WrTrade2/QueryWrDeliveryDetail": {
             "get": {
                 "security": [
@@ -30332,6 +30381,107 @@
                 }
             }
         },
+        "models.WrDeliveryAvalidHoldLB": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "资金账号",
+                    "type": "integer"
+                },
+                "avalidqty": {
+                    "description": "数量(可点选数量)",
+                    "type": "number"
+                },
+                "deliverygoodsid": {
+                    "description": "品种id",
+                    "type": "integer"
+                },
+                "goodsid": {
+                    "description": "x合约商品id",
+                    "type": "integer"
+                },
+                "ladingbillid": {
+                    "description": "提单id",
+                    "type": "string"
+                },
+                "pgoodscode": {
+                    "description": "p商品代码(点价合约)",
+                    "type": "string"
+                },
+                "pgoodsid": {
+                    "description": "p商品id(点价合约)",
+                    "type": "integer"
+                },
+                "pgoodsname": {
+                    "description": "p商品名称(点价合约)",
+                    "type": "string"
+                },
+                "pricemove": {
+                    "description": "升贴水",
+                    "type": "number"
+                },
+                "qty": {
+                    "description": "用户仓单数量",
+                    "type": "number"
+                },
+                "subnum": {
+                    "description": "提单子id",
+                    "type": "integer"
+                },
+                "uqty": {
+                    "description": "用户持有数量",
+                    "type": "number"
+                },
+                "userid": {
+                    "description": "用户id",
+                    "type": "integer"
+                },
+                "username": {
+                    "description": "仓单持有人",
+                    "type": "string"
+                },
+                "warehousecode": {
+                    "description": "仓库代码",
+                    "type": "string"
+                },
+                "warehouseid": {
+                    "description": "仓库id",
+                    "type": "integer"
+                },
+                "warehousename": {
+                    "description": "仓库名称",
+                    "type": "string"
+                },
+                "wrfactortypeid": {
+                    "description": "仓单要素id",
+                    "type": "string"
+                },
+                "wrfactortypename2": {
+                    "description": "仓单要素名称(不含仓库)",
+                    "type": "string"
+                },
+                "wrstandardcode": {
+                    "description": "品代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "品类d",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "品类名称",
+                    "type": "string"
+                },
+                "xgoodscode": {
+                    "description": "x合约代码",
+                    "type": "string"
+                },
+                "xgoodsname": {
+                    "description": "x合约名称",
+                    "type": "string"
+                }
+            }
+        },
         "models.WrDeliveryDetail": {
             "type": "object",
             "properties": {

+ 107 - 1
docs/swagger.yaml

@@ -13365,6 +13365,81 @@ definitions:
         description: 交易日(yyyyMMdd)
         type: string
     type: object
+  models.WrDeliveryAvalidHoldLB:
+    properties:
+      accountid:
+        description: 资金账号
+        type: integer
+      avalidqty:
+        description: 数量(可点选数量)
+        type: number
+      deliverygoodsid:
+        description: 品种id
+        type: integer
+      goodsid:
+        description: x合约商品id
+        type: integer
+      ladingbillid:
+        description: 提单id
+        type: string
+      pgoodscode:
+        description: p商品代码(点价合约)
+        type: string
+      pgoodsid:
+        description: p商品id(点价合约)
+        type: integer
+      pgoodsname:
+        description: p商品名称(点价合约)
+        type: string
+      pricemove:
+        description: 升贴水
+        type: number
+      qty:
+        description: 用户仓单数量
+        type: number
+      subnum:
+        description: 提单子id
+        type: integer
+      uqty:
+        description: 用户持有数量
+        type: number
+      userid:
+        description: 用户id
+        type: integer
+      username:
+        description: 仓单持有人
+        type: string
+      warehousecode:
+        description: 仓库代码
+        type: string
+      warehouseid:
+        description: 仓库id
+        type: integer
+      warehousename:
+        description: 仓库名称
+        type: string
+      wrfactortypeid:
+        description: 仓单要素id
+        type: string
+      wrfactortypename2:
+        description: 仓单要素名称(不含仓库)
+        type: string
+      wrstandardcode:
+        description: 品代码
+        type: string
+      wrstandardid:
+        description: 品类d
+        type: integer
+      wrstandardname:
+        description: 品类名称
+        type: string
+      xgoodscode:
+        description: x合约代码
+        type: string
+      xgoodsname:
+        description: x合约名称
+        type: string
+    type: object
   models.WrDeliveryDetail:
     properties:
       accountid:
@@ -24369,7 +24444,7 @@ paths:
             $ref: '#/definitions/app.Response'
       security:
       - ApiKeyAuth: []
-      summary: 查询贸易圈挂牌
+      summary: 查询贸易圈挂牌大厅
       tags:
       - 仓单贸易v2
   /WrTrade2/QueryPerformancePlan:
@@ -24494,6 +24569,37 @@ paths:
       summary: 查询仓单回购明细
       tags:
       - 仓单贸易v2
+  /WrTrade2/QueryWrDeliveryAvalidHoldLB:
+    get:
+      parameters:
+      - description: 资金账号
+        in: query
+        name: accountid
+        required: true
+        type: integer
+      - description: 商品id
+        in: query
+        name: goodsid
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.WrDeliveryAvalidHoldLB'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询合约交收可点选仓单
+      tags:
+      - 仓单贸易v2
   /WrTrade2/QueryWrDeliveryDetail:
     get:
       parameters:

+ 133 - 1
models/wrTrade2.go

@@ -2527,7 +2527,7 @@ func (r *WrDeliveryDetail) buildSql() string {
 		"  left join useraccount u on ta.userid=u.userid" +
 		"  left join taaccount ta2 on t.accountid=ta2.accountid" +
 		"  left join useraccount u2 on ta2.userid=u2.userid" +
-		"where 1=1"
+		" where 1=1"
 	sqlId.AndEx("u.userid", r.USERID, r.USERID > 0)
 	sqlId.AndEx("t.accountid", r.ACCOUNTID, r.ACCOUNTID > 0)
 	return sqlId.String()
@@ -2820,3 +2820,135 @@ func (r *WrQuoteOrderMyq) GetDataByPage() (interface{}, error, int, int, int) {
 	}
 	return sData, err, r.Page, r.PageSize, total
 }
+
+// WrDeliveryAvalidHoldLB 合约交收可点选仓单
+type WrDeliveryAvalidHoldLB struct {
+	ACCOUNTID         int64   `json:"accountid"  xorm:"'ACCOUNTID'" form:"accountid"` // 资金账号
+	GOODSID           int32   `json:"goodsid"  xorm:"'GOODSID'" form:"goodsid"`       // x合约商品id
+	WRSTANDARDID      int32   `json:"wrstandardid"  xorm:"'WRSTANDARDID'"`            // 品类d
+	UQTY              float64 `json:"-"  xorm:"'UQTY'"`                               // 用户持有数量
+	QTY               float64 `json:"-"  xorm:"'QTY'"`                                // 用户仓单数量
+	WRFACTORTYPEID    string  `json:"wrfactortypeid"  xorm:"'WRFACTORTYPEID'"`        // 仓单要素id
+	LADINGBILLID      string  `json:"ladingbillid"  xorm:"'LADINGBILLID'"`            // 提单id
+	SUBNUM            int64   `json:"subnum"  xorm:"'SUBNUM'"`                        // 提单子id
+	DELIVERYGOODSID   int32   `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`      // 品种id
+	USERID            int64   `json:"userid"  xorm:"'USERID'"`                        // 用户id
+	WRFACTORTYPENAME2 string  `json:"-"  xorm:"'WRFACTORTYPENAME2'"`                  // 仓单要素名称(不含仓库)
+	WAREHOUSEID       int32   `json:"warehouseid"  xorm:"'WAREHOUSEID'"`              // 仓库id
+	AVALIDQTY         float64 `json:"avalidqty"  xorm:"'AVALIDQTY'"`                  // 数量(可点选数量)
+	WRSTANDARDNAME    string  `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"`        // 品类名称
+	WRSTANDARDCODE    string  `json:"wrstandardcode"  xorm:"'WRSTANDARDCODE'"`        // 品代码
+	WAREHOUSECODE     string  `json:"warehousecode"  xorm:"'WAREHOUSECODE'"`          // 仓库代码
+	WAREHOUSENAME     string  `json:"warehousename"  xorm:"'WAREHOUSENAME'"`          // 仓库名称
+	XGOODSCODE        string  `json:"xgoodscode"  xorm:"'XGOODSCODE'"`                // x合约代码
+	XGOODSNAME        string  `json:"xgoodsname"  xorm:"'XGOODSNAME'"`                // x合约名称
+	PGOODSID          int32   `json:"pgoodsid"  xorm:"'PGOODSID'"`                    // p商品id(点价合约)
+	PGOODSCODE        string  `json:"pgoodscode"  xorm:"'PGOODSCODE'"`                // p商品代码(点价合约)
+	PGOODSNAME        string  `json:"pgoodsname"  xorm:"'PGOODSNAME'"`                // p商品名称(点价合约)
+	USERNAME          string  `json:"username"  xorm:"'USERNAME'"`                    // 仓单持有人
+	PRICEMOVE         float64 `json:"pricemove"  xorm:"'PRICEMOVE'"`                  // 升贴水
+	WRTYPENAME        string  `json:"wrtypename"`                                     // 商品
+}
+
+func (r *WrDeliveryAvalidHoldLB) calc() {
+	r.USERNAME = EncryptByStar(r.USERNAME)
+	if r.WRTYPENAME == "" {
+		if len(r.WRFACTORTYPENAME2) > 0 {
+			r.WRTYPENAME = r.WRSTANDARDNAME + r.WRFACTORTYPENAME2
+		} else {
+			r.WRTYPENAME = r.WRSTANDARDNAME
+		}
+	}
+	r.WRTYPENAME = strings.ReplaceAll(r.WRTYPENAME, ",", "-")
+}
+
+func (r *WrDeliveryAvalidHoldLB) buildSql() string {
+	var sqlId utils.SQLVal = "with tmp as(" +
+		"select k.wrfactortypeid, k.goodsid, sum(k.pricemove) pricemove" +
+		"  from (select to_char(t.wrfactortypeid) wrfactortypeid," +
+		"               b.dgfactoryitemtypeid," +
+		"               b.itemtypename," +
+		"               c.dgfactoryitemvalue," +
+		"               t.optioncompare," +
+		"               t.warehouseid," +
+		"               t.wrstandardid," +
+		"               c.dgfactoryitemid," +
+		"               t.wrfactortypename," +
+		"               t.wrfactortypename2," +
+		"               r.goodsid," +
+		"               nvl(r.premiumvalue, 0) pricemove" +
+		"          from wrfactortype t" +
+		"         inner join wrfactortypeitem a" +
+		"            on t.wrfactortypeid = a.wrfactortypeid" +
+		"         inner join dgfactoryitemtype b" +
+		"            on t.deliverygoodsid = b.deliverygoodsid" +
+		"           and a.dgfactoryitemtypeid = b.dgfactoryitemtypeid" +
+		"          left join dgfactoryitem c" +
+		"            on a.dgfactoryitemid = c.dgfactoryitemid" +
+		"           and b.deliverygoodsid = c.deliverygoodsid" +
+		"          left join deliveryrelationdetail r" +
+		"            on c.dgfactoryitemid = r.dgfactoryitemid" +
+		"           and b.dgfactoryitemtypeid = r.dgfactoryitemtypeid" +
+		"         where 1 = 1) k" +
+		" group by k.wrfactortypeid, k.goodsid" +
+		" )" +
+		"select a.*," +
+		"       case" +
+		"         when a.uqty < a.qty then" +
+		"          a.uqty" +
+		"         else" +
+		"          a.qty" +
+		"       end as avalidqty," +
+		"       wd.wrstandardname," +
+		"       wd.wrstandardcode," +
+		"       h.warehousecode," +
+		"       h.warehousename," +
+		"       g1.goodscode xgoodscode," +
+		"       g1.goodsname xgoodsname," +
+		"       r.pgoodsid," +
+		"       g2.goodscode pgoodscode," +
+		"       g2.goodsname pgoodsname," +
+		"       u.accountname username," +
+		"       tmp.pricemove" +
+		"  from (select t.accountid," +
+		"               t.goodsid," +
+		"               t.wrstandardid," +
+		"               t.inqty - t.cancelqty - t.deliveryqty - t.curpresaleqty as uqty," +
+		"               hl.qty - hl.freezerqty qty," +
+		"               to_char(hl.wrfactortypeid) wrfactortypeid," +
+		"               to_char(hl.ladingbillid) ladingbillid," +
+		"               hl.subnum," +
+		"               hl.deliverygoodsid," +
+		"               hl.userid," +
+		"               w.wrfactortypename2," +
+		"               w.warehouseid" +
+		"          from cptrade_usergoodsdata t" +
+		"         inner join wrholdlb hl" +
+		"            on t.accountid = hl.accountid" +
+		"         inner join wrfactortype w" +
+		"            on t.wrstandardid = w.wrstandardid and hl.wrfactortypeid=w.wrfactortypeid) a" +
+		"  left join wrstandard wd" +
+		"    on a.wrstandardid = wd.wrstandardid" +
+		"  left join warehouseinfo h" +
+		"    on a.warehouseid = h.autoid" +
+		"  inner join deliveryrelation r on a.goodsid=r.goodsid and a.wrstandardid=r.wrstandardid" +
+		"  left join goods g1 on a.goodsid=g1.goodsid" +
+		"  left join goods g2 on r.pgoodsid=g2.goodsid" +
+		"  left join useraccount u on a.userid=u.userid" +
+		"  left join tmp on a.wrfactortypeid=tmp.wrfactortypeid and a.goodsid=tmp.goodsid" +
+		" where a.uqty > 0" +
+		"   and a.qty > 0"
+	sqlId.And("a.accountid", r.ACCOUNTID)
+	sqlId.And("a.goodsid", r.GOODSID)
+	return sqlId.String()
+}
+
+// GetDataEx 获取合约交收可点选仓单
+func (r *WrDeliveryAvalidHoldLB) GetDataEx() (interface{}, error) {
+	sData := make([]WrDeliveryAvalidHoldLB, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}

+ 1 - 0
routers/router.go

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