Procházet zdrojové kódy

1.增加查协议单接口

zou.yingbin před 4 roky
rodič
revize
e112b2aab4
6 změnil soubory, kde provedl 365 přidání a 2 odebrání
  1. 19 1
      controllers/tjmd/qryTjmd.go
  2. 103 0
      docs/docs.go
  3. 103 0
      docs/swagger.json
  4. 70 0
      docs/swagger.yaml
  5. 69 1
      models/tjmd.go
  6. 1 0
      routers/router.go

+ 19 - 1
controllers/tjmd/qryTjmd.go

@@ -49,7 +49,25 @@ func QueryQuoteGoodsList(c *gin.Context) {
 // @Tags 天津麦顿
 func QueryTjmdTradeOrderDetail(c *gin.Context) {
 	a := app.GinUtils{Gin: app.Gin{C: c}}
-	m := models.WrTradeOrderDetail{}
+	m := models.TjmdTradeOrderDetail{}
 	a.DoBindReq(&m)
 	a.DoGetDataByPage(&m)
 }
+
+// QueryTjmdTransferApply
+// @Summary 查询掉期协议单
+// @Produce json
+// @Security ApiKeyAuth
+// @Param applytype query int true "类型  1-我的申请 2-对方申请"
+// @Param marketids query string false "市场id, 格式 1,2,3"
+// @Param accountids query string false "资金账号, 格式 25000000001,25000000003"
+// @Success 200 {array} models.TjmdTransferApply
+// @Failure 500 {object} app.Response
+// @Router /Tjmd/QueryTjmdTransferApply [get]
+// @Tags 天津麦顿
+func QueryTjmdTransferApply(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.TjmdTransferApply{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}

+ 103 - 0
docs/docs.go

@@ -10654,6 +10654,60 @@ var doc = `{
                 }
             }
         },
+        "/Tjmd/QueryTjmdTransferApply": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "天津麦顿"
+                ],
+                "summary": "查询掉期协议单",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "类型  1-我的申请 2-对方申请",
+                        "name": "applytype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "市场id, 格式 1,2,3",
+                        "name": "marketids",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "资金账号, 格式 25000000001,25000000003",
+                        "name": "accountids",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.TjmdTransferApply"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Trade/QueryRecieptOrder": {
             "get": {
                 "security": [
@@ -30440,6 +30494,55 @@ var doc = `{
                 }
             }
         },
+        "models.TjmdTransferApply": {
+            "type": "object",
+            "properties": {
+                "applystatus": {
+                    "description": "状态 - 0:未提交 1:待审核 2:审核中 3:审核通过 4:审核拒绝 5:审核失败 6:已撤销",
+                    "type": "integer"
+                },
+                "applytime": {
+                    "description": "申请时间(时间)",
+                    "type": "string"
+                },
+                "auditremark": {
+                    "description": "审核备注(拒绝原因?)",
+                    "type": "string"
+                },
+                "buyorsell": {
+                    "description": "买卖 - 0:买 1:卖",
+                    "type": "integer"
+                },
+                "goodscode": {
+                    "description": "商品代码",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "商品ID",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "商品名称",
+                    "type": "string"
+                },
+                "qty": {
+                    "description": "转让数量(数量)",
+                    "type": "number"
+                },
+                "tradeid": {
+                    "description": "成交单号(关联持仓)",
+                    "type": "string"
+                },
+                "transferamount": {
+                    "description": "转让总金额(金额)",
+                    "type": "number"
+                },
+                "transferprice": {
+                    "description": "转让价格(协议价格)",
+                    "type": "number"
+                }
+            }
+        },
         "models.TradeHolderDetail": {
             "type": "object",
             "properties": {

+ 103 - 0
docs/swagger.json

@@ -10638,6 +10638,60 @@
                 }
             }
         },
+        "/Tjmd/QueryTjmdTransferApply": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "天津麦顿"
+                ],
+                "summary": "查询掉期协议单",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "类型  1-我的申请 2-对方申请",
+                        "name": "applytype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "市场id, 格式 1,2,3",
+                        "name": "marketids",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "资金账号, 格式 25000000001,25000000003",
+                        "name": "accountids",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.TjmdTransferApply"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Trade/QueryRecieptOrder": {
             "get": {
                 "security": [
@@ -30424,6 +30478,55 @@
                 }
             }
         },
+        "models.TjmdTransferApply": {
+            "type": "object",
+            "properties": {
+                "applystatus": {
+                    "description": "状态 - 0:未提交 1:待审核 2:审核中 3:审核通过 4:审核拒绝 5:审核失败 6:已撤销",
+                    "type": "integer"
+                },
+                "applytime": {
+                    "description": "申请时间(时间)",
+                    "type": "string"
+                },
+                "auditremark": {
+                    "description": "审核备注(拒绝原因?)",
+                    "type": "string"
+                },
+                "buyorsell": {
+                    "description": "买卖 - 0:买 1:卖",
+                    "type": "integer"
+                },
+                "goodscode": {
+                    "description": "商品代码",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "商品ID",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "商品名称",
+                    "type": "string"
+                },
+                "qty": {
+                    "description": "转让数量(数量)",
+                    "type": "number"
+                },
+                "tradeid": {
+                    "description": "成交单号(关联持仓)",
+                    "type": "string"
+                },
+                "transferamount": {
+                    "description": "转让总金额(金额)",
+                    "type": "number"
+                },
+                "transferprice": {
+                    "description": "转让价格(协议价格)",
+                    "type": "number"
+                }
+            }
+        },
         "models.TradeHolderDetail": {
             "type": "object",
             "properties": {

+ 70 - 0
docs/swagger.yaml

@@ -12953,6 +12953,42 @@ definitions:
         description: 用户名称(已脱敏)
         type: string
     type: object
+  models.TjmdTransferApply:
+    properties:
+      applystatus:
+        description: 状态 - 0:未提交 1:待审核 2:审核中 3:审核通过 4:审核拒绝 5:审核失败 6:已撤销
+        type: integer
+      applytime:
+        description: 申请时间(时间)
+        type: string
+      auditremark:
+        description: 审核备注(拒绝原因?)
+        type: string
+      buyorsell:
+        description: 买卖 - 0:买 1:卖
+        type: integer
+      goodscode:
+        description: 商品代码
+        type: string
+      goodsid:
+        description: 商品ID
+        type: integer
+      goodsname:
+        description: 商品名称
+        type: string
+      qty:
+        description: 转让数量(数量)
+        type: number
+      tradeid:
+        description: 成交单号(关联持仓)
+        type: string
+      transferamount:
+        description: 转让总金额(金额)
+        type: number
+      transferprice:
+        description: 转让价格(协议价格)
+        type: number
+    type: object
   models.TradeHolderDetail:
     properties:
       accountid:
@@ -24590,6 +24626,40 @@ paths:
       summary: 查询掉期买卖大厅
       tags:
       - 天津麦顿
+  /Tjmd/QueryTjmdTransferApply:
+    get:
+      parameters:
+      - description: 类型  1-我的申请 2-对方申请
+        in: query
+        name: applytype
+        required: true
+        type: integer
+      - description: 市场id, 格式 1,2,3
+        in: query
+        name: marketids
+        type: string
+      - description: 资金账号, 格式 25000000001,25000000003
+        in: query
+        name: accountids
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.TjmdTransferApply'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询掉期协议单
+      tags:
+      - 天津麦顿
   /Trade/QueryRecieptOrder:
     get:
       description: 说明:pagesize参数赋值不为0时表示需要分页;page参数从0开始计算

+ 69 - 1
models/tjmd.go

@@ -112,7 +112,7 @@ select to_char(t.orderid) orderid,
 	sqlId.FormatParam(r.USERTYPE)
 	sqlId.And("t.GOODSID", r.GOODSID)
 	sqlId.And("t.BUYORSELL", r.BUYORSELL)
-	sqlId.AndEx("g.marketid", r.FtMarketIds, r.FtMarketIds != "")
+	sqlId.JoinEx(r.FtMarketIds != "", fmt.Sprintf(" and g.marketid in(%v)", r.FtMarketIds))
 	if r.BUYORSELL == 0 {
 		sqlId.Join(" order by t.orderprice desc, t.ordertime desc")
 	} else {
@@ -135,3 +135,71 @@ func (r *TjmdTradeOrderDetail) GetDataByPage() (interface{}, error, int, int, in
 	}
 	return sData, err, r.Page, r.PageSize, r.Total
 }
+
+// TjmdTransferApply 协议转让申请
+type TjmdTransferApply struct {
+	MARKETID        int32    `json:"-"  xorm:"MARKETID" form:"marketid"`         // 市场ID
+	INACCOUNTID     int64    `json:"-"  xorm:"INACCOUNTID" form:"inaccountid"`   // 转入方资金ID(确认方) --对方申请
+	OUTACCOUNTID    int64    `json:"-"  xorm:"OUTACCOUNTID" form:"outaccountid"` // 转出方资金ID(申请方) --我的申请
+	GOODSID         int32    `json:"goodsid"  xorm:"'GOODSID'"`                  // 商品ID
+	GOODSCODE       string   `json:"goodscode"  xorm:"'GOODSCODE'"`              // 商品代码
+	GOODSNAME       string   `json:"goodsname"  xorm:"'GOODSNAME'"`              // 商品名称
+	QTYDECIMALPLACE int      `json:"-"  xorm:"'QTYDECIMALPLACE'"`                // 成交量小数位
+	BUYORSELL       int32    `json:"buyorsell"  xorm:"'BUYORSELL'"`              // 买卖 - 0:买 1:卖
+	TRANSFERPRICE   float64  `json:"transferprice"  xorm:"'TRANSFERPRICE'"`      // 转让价格(协议价格)
+	QTY             SFLOAT64 `json:"qty"  xorm:"'QTY'"`                          // 转让数量(数量)
+	TRANSFERAMOUNT  float64  `json:"transferamount"  xorm:"'TRANSFERAMOUNT'"`    // 转让总金额(金额)
+	APPLYSTATUS     int32    `json:"applystatus"  xorm:"'APPLYSTATUS'"`          // 状态 - 0:未提交 1:待审核 2:审核中 3:审核通过 4:审核拒绝 5:审核失败 6:已撤销
+	TRADEID         string   `json:"tradeid"  xorm:"'TRADEID'"`                  // 成交单号(关联持仓)
+	APPLYTIME       string   `json:"applytime"  xorm:"'APPLYTIME'"`              // 申请时间(时间)
+	AUDITREMARK     string   `json:"auditremark"  xorm:"'AUDITREMARK'"`          // 审核备注(拒绝原因?)
+
+	ApplyType    int32  `json:"-" form:"applytype"`  // 类型  1-我的申请 2-对方申请
+	FtMarketIds  string `json:"-" form:"marketids"`  // 市场 格式 1,2,3
+	FtAccountIds string `json:"-" form:"accountids"` // 资金账号 格式 1,2,3
+}
+
+func (r *TjmdTransferApply) calc() {
+	if r.QTYDECIMALPLACE != 0 {
+		r.QTY.Power10(r.QTYDECIMALPLACE * -1)
+	}
+}
+
+func (r *TjmdTransferApply) buildSql() string {
+	var sqlId utils.SQLVal = `
+select t.goodsid,
+       g.goodscode,
+       g.goodsname,
+       g.qtydecimalplace,
+       t.buyorsell,
+       t.transferprice,
+       t.qty,
+       t.transferamount,
+       t.applystatus,
+       to_char(t.tradeid) tradeid,
+       to_char(t.applytime,'yyyy-mm-dd hh24:mi:ss') applytime,
+       t.auditremark
+  from trade_holdtransferapply t
+  left join goods g
+    on t.goodsid = g.goodsid
+  where 1=1
+`
+	sqlId.JoinEx(r.FtMarketIds != "", fmt.Sprintf(" and t.marketid in(%v)", r.FtMarketIds))
+	if r.ApplyType == 1 {
+		sqlId.JoinEx(r.FtAccountIds != "", fmt.Sprintf(" and t.outaccountid in(%v)", r.FtAccountIds))
+	} else if r.ApplyType == 2 {
+		sqlId.JoinEx(r.FtAccountIds != "", fmt.Sprintf(" and t.inaccountid in(%v)", r.FtAccountIds))
+	}
+
+	return sqlId.String()
+}
+
+// GetDataEx 获取协议转让申请
+func (r *TjmdTransferApply) GetDataEx() (interface{}, error) {
+	sData := make([]TjmdTransferApply, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}

+ 1 - 0
routers/router.go

@@ -565,6 +565,7 @@ func InitRouter() *gin.Engine {
 	{
 		tjmdR.GET("QueryQuoteGoodsList", tjmd.QueryQuoteGoodsList)
 		tjmdR.GET("QueryTjmdTradeOrderDetail", tjmd.QueryTjmdTradeOrderDetail)
+		tjmdR.GET("QueryTjmdTransferApply", tjmd.QueryTjmdTransferApply)
 	}
 
 	return r