Explorar el Código

1.增加查持仓明细接口
2.增加查掉期报价列表接口
3.增加查掉期买卖大厅接口
4.增加启动命令行参数, 支持按需初始化(oracle, redis, mongo, mysql)

zou.yingbin hace 4 años
padre
commit
f891d0dbfc
Se han modificado 10 ficheros con 1034 adiciones y 219 borrados
  1. 55 0
      controllers/tjmd/qryTjmd.go
  2. 2 2
      controllers/tradexx/qryTradexx.go
  3. 1 1
      controllers/wrTrade2/qryWrTrade.go
  4. 285 71
      docs/docs.go
  5. 285 71
      docs/swagger.json
  6. 190 45
      docs/swagger.yaml
  7. 62 27
      main.go
  8. 137 0
      models/tjmd.go
  9. 5 2
      models/wrTrade2.go
  10. 12 0
      routers/router.go

+ 55 - 0
controllers/tjmd/qryTjmd.go

@@ -0,0 +1,55 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/9/7 16:27
+* @Modify  : 2021/9/7 16:27
+ */
+
+package tjmd
+
+import (
+	"github.com/gin-gonic/gin"
+	"mtp2_if/global/app"
+	"mtp2_if/models"
+)
+
+// QueryQuoteGoodsList
+// @Summary 查询掉期报价列表
+// @Description 用户类型必传, 查掉期报价列表 marketids=掉期市场id
+// @Produce json
+// @Security ApiKeyAuth
+// @Param usertype query int true "用户类型"
+// @Param marketids query string false "市场id, 格式 1,2,3"
+// @Param goodsgroupid query int false "商品组id"
+// @Param goodsid query int false "商品id"
+// @Success 200 {array} models.TjmdQuoteGoods
+// @Failure 500 {object} app.Response
+// @Router /Tjmd/QueryQuoteGoodsList [get]
+// @Tags 天津麦顿
+func QueryQuoteGoodsList(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.TjmdQuoteGoods{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}
+
+// QueryTjmdTradeOrderDetail
+// @Summary 查询掉期买卖大厅
+// @Description 用户类型必传, 投资者只能看到自营会员的单, 反之亦然
+// @Produce json
+// @Security ApiKeyAuth
+// @Param page query int false "页码"
+// @Param pagesize query int false "每页条数"
+// @Param usertype query int true "用户类型"
+// @Param marketids query string false "市场id, 格式 1,2,3"
+// @Param goodsid query int true "商品id"
+// @Param buyorsell query int true "买卖方向 0-买 1-卖"
+// @Success 200 {array} models.TjmdTradeOrderDetail
+// @Failure 500 {object} app.Response
+// @Router /Tjmd/QueryTjmdTradeOrderDetail [get]
+// @Tags 天津麦顿
+func QueryTjmdTradeOrderDetail(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.WrTradeOrderDetail{}
+	a.DoBindReq(&m)
+	a.DoGetDataByPage(&m)
+}

+ 2 - 2
controllers/tradexx/qryTradexx.go

@@ -24,8 +24,8 @@ import (
 // @Param buyorsell query int false "买卖方向 0-买 1-卖"
 // @Success 200 {array} models.TradeHolderDetail
 // @Failure 500 {object} app.Response
-// @Router /WrTrade2/QueryTradeHolderDetail [get]
-// @Tags 仓单贸易v2
+// @Router /Order/QueryTradeHolderDetail [get]
+// @Tags 通用单据
 func QueryTradeHolderDetail(c *gin.Context) {
 	a := app.GinUtils{Gin: app.Gin{C: c}}
 	m := models.TradeHolderDetail{}

+ 1 - 1
controllers/wrTrade2/qryWrTrade.go

@@ -492,7 +492,7 @@ func QueryWrTradeOrderDetail(c *gin.Context) {
 	a := app.GinUtils{Gin: app.Gin{C: c}}
 	m := models.WrTradeOrderDetail{}
 	a.DoBindReq(&m)
-	a.DoGetDataI(&m)
+	a.DoGetDataByPage(&m)
 }
 
 // QueryWrAverageTradePrice

+ 285 - 71
docs/docs.go

@@ -7145,6 +7145,77 @@ var doc = `{
                 }
             }
         },
+        "/Order/QueryTradeHolderDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "通用单据"
+                ],
+                "summary": "查询持仓明细",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户id",
+                        "name": "userid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "资金账号, 格式 1,2,3",
+                        "name": "accids",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "交易模式, 格式 1,2,3",
+                        "name": "trademodes",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "市场id, 格式 1,2,3",
+                        "name": "marketids",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商品id",
+                        "name": "goodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "买卖方向 0-买 1-卖",
+                        "name": "buyorsell",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.TradeHolderDetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Order/QueryTradeOrderDetail": {
             "get": {
                 "security": [
@@ -10447,6 +10518,142 @@ var doc = `{
                 }
             }
         },
+        "/Tjmd/QueryQuoteGoodsList": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "description": "用户类型必传, 查掉期报价列表 marketids=掉期市场id",
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "天津麦顿"
+                ],
+                "summary": "查询掉期报价列表",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户类型",
+                        "name": "usertype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "市场id, 格式 1,2,3",
+                        "name": "marketids",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商品组id",
+                        "name": "goodsgroupid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商品id",
+                        "name": "goodsid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.TjmdQuoteGoods"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Tjmd/QueryTjmdTradeOrderDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "description": "用户类型必传, 投资者只能看到自营会员的单, 反之亦然",
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "天津麦顿"
+                ],
+                "summary": "查询掉期买卖大厅",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "用户类型",
+                        "name": "usertype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "市场id, 格式 1,2,3",
+                        "name": "marketids",
+                        "in": "query"
+                    },
+                    {
+                        "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.TjmdTradeOrderDetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Trade/QueryRecieptOrder": {
             "get": {
                 "security": [
@@ -11636,77 +11843,6 @@ var doc = `{
                 }
             }
         },
-        "/WrTrade2/QueryTradeHolderDetail": {
-            "get": {
-                "security": [
-                    {
-                        "ApiKeyAuth": []
-                    }
-                ],
-                "produces": [
-                    "application/json"
-                ],
-                "tags": [
-                    "仓单贸易v2"
-                ],
-                "summary": "查询持仓明细",
-                "parameters": [
-                    {
-                        "type": "integer",
-                        "description": "用户id",
-                        "name": "userid",
-                        "in": "query"
-                    },
-                    {
-                        "type": "string",
-                        "description": "资金账号, 格式 1,2,3",
-                        "name": "accids",
-                        "in": "query"
-                    },
-                    {
-                        "type": "string",
-                        "description": "交易模式, 格式 1,2,3",
-                        "name": "trademodes",
-                        "in": "query"
-                    },
-                    {
-                        "type": "string",
-                        "description": "市场id, 格式 1,2,3",
-                        "name": "marketids",
-                        "in": "query"
-                    },
-                    {
-                        "type": "integer",
-                        "description": "商品id",
-                        "name": "goodsid",
-                        "in": "query"
-                    },
-                    {
-                        "type": "integer",
-                        "description": "买卖方向 0-买 1-卖",
-                        "name": "buyorsell",
-                        "in": "query"
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "OK",
-                        "schema": {
-                            "type": "array",
-                            "items": {
-                                "$ref": "#/definitions/models.TradeHolderDetail"
-                            }
-                        }
-                    },
-                    "500": {
-                        "description": "Internal Server Error",
-                        "schema": {
-                            "$ref": "#/definitions/app.Response"
-                        }
-                    }
-                }
-            }
-        },
         "/WrTrade2/QueryWrAverageTradePrice": {
             "get": {
                 "security": [
@@ -30226,6 +30362,84 @@ var doc = `{
                 }
             }
         },
+        "models.TjmdQuoteGoods": {
+            "type": "object",
+            "properties": {
+                "buyqty": {
+                    "description": "买量(暂不做, 无值, 保留字段)",
+                    "type": "number"
+                },
+                "goodscode": {
+                    "description": "合约代码",
+                    "type": "string"
+                },
+                "goodsgroupid": {
+                    "description": "商品组ID(自增ID)",
+                    "type": "integer"
+                },
+                "goodsgroupname": {
+                    "description": "商品组名称",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "合约id",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "合约名称",
+                    "type": "string"
+                },
+                "refgoodscode": {
+                    "description": "标的合约代码",
+                    "type": "string"
+                },
+                "refgoodsid": {
+                    "description": "标的合约id",
+                    "type": "integer"
+                },
+                "refgoodsname": {
+                    "description": "标的合约名称",
+                    "type": "string"
+                },
+                "sellqty": {
+                    "description": "卖量(暂不做, 无值, 保留字段)",
+                    "type": "number"
+                }
+            }
+        },
+        "models.TjmdTradeOrderDetail": {
+            "type": "object",
+            "properties": {
+                "buyorsell": {
+                    "description": "买卖方向 0-买 1-卖",
+                    "type": "integer"
+                },
+                "goodsid": {
+                    "description": "商品id",
+                    "type": "integer"
+                },
+                "orderid": {
+                    "description": "委托单号",
+                    "type": "string"
+                },
+                "orderprice": {
+                    "description": "委托价格",
+                    "type": "number"
+                },
+                "orderqty": {
+                    "description": "委托数量",
+                    "type": "integer"
+                },
+                "userid": {
+                    "description": "用户id",
+                    "type": "integer"
+                },
+                "username": {
+                    "description": "用户名称(已脱敏)",
+                    "type": "string"
+                }
+            }
+        },
         "models.TradeHolderDetail": {
             "type": "object",
             "properties": {

+ 285 - 71
docs/swagger.json

@@ -7129,6 +7129,77 @@
                 }
             }
         },
+        "/Order/QueryTradeHolderDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "通用单据"
+                ],
+                "summary": "查询持仓明细",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户id",
+                        "name": "userid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "资金账号, 格式 1,2,3",
+                        "name": "accids",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "交易模式, 格式 1,2,3",
+                        "name": "trademodes",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "市场id, 格式 1,2,3",
+                        "name": "marketids",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商品id",
+                        "name": "goodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "买卖方向 0-买 1-卖",
+                        "name": "buyorsell",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.TradeHolderDetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Order/QueryTradeOrderDetail": {
             "get": {
                 "security": [
@@ -10431,6 +10502,142 @@
                 }
             }
         },
+        "/Tjmd/QueryQuoteGoodsList": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "description": "用户类型必传, 查掉期报价列表 marketids=掉期市场id",
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "天津麦顿"
+                ],
+                "summary": "查询掉期报价列表",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户类型",
+                        "name": "usertype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "市场id, 格式 1,2,3",
+                        "name": "marketids",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商品组id",
+                        "name": "goodsgroupid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商品id",
+                        "name": "goodsid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.TjmdQuoteGoods"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Tjmd/QueryTjmdTradeOrderDetail": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "description": "用户类型必传, 投资者只能看到自营会员的单, 反之亦然",
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "天津麦顿"
+                ],
+                "summary": "查询掉期买卖大厅",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "用户类型",
+                        "name": "usertype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "市场id, 格式 1,2,3",
+                        "name": "marketids",
+                        "in": "query"
+                    },
+                    {
+                        "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.TjmdTradeOrderDetail"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Trade/QueryRecieptOrder": {
             "get": {
                 "security": [
@@ -11620,77 +11827,6 @@
                 }
             }
         },
-        "/WrTrade2/QueryTradeHolderDetail": {
-            "get": {
-                "security": [
-                    {
-                        "ApiKeyAuth": []
-                    }
-                ],
-                "produces": [
-                    "application/json"
-                ],
-                "tags": [
-                    "仓单贸易v2"
-                ],
-                "summary": "查询持仓明细",
-                "parameters": [
-                    {
-                        "type": "integer",
-                        "description": "用户id",
-                        "name": "userid",
-                        "in": "query"
-                    },
-                    {
-                        "type": "string",
-                        "description": "资金账号, 格式 1,2,3",
-                        "name": "accids",
-                        "in": "query"
-                    },
-                    {
-                        "type": "string",
-                        "description": "交易模式, 格式 1,2,3",
-                        "name": "trademodes",
-                        "in": "query"
-                    },
-                    {
-                        "type": "string",
-                        "description": "市场id, 格式 1,2,3",
-                        "name": "marketids",
-                        "in": "query"
-                    },
-                    {
-                        "type": "integer",
-                        "description": "商品id",
-                        "name": "goodsid",
-                        "in": "query"
-                    },
-                    {
-                        "type": "integer",
-                        "description": "买卖方向 0-买 1-卖",
-                        "name": "buyorsell",
-                        "in": "query"
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "OK",
-                        "schema": {
-                            "type": "array",
-                            "items": {
-                                "$ref": "#/definitions/models.TradeHolderDetail"
-                            }
-                        }
-                    },
-                    "500": {
-                        "description": "Internal Server Error",
-                        "schema": {
-                            "$ref": "#/definitions/app.Response"
-                        }
-                    }
-                }
-            }
-        },
         "/WrTrade2/QueryWrAverageTradePrice": {
             "get": {
                 "security": [
@@ -30210,6 +30346,84 @@
                 }
             }
         },
+        "models.TjmdQuoteGoods": {
+            "type": "object",
+            "properties": {
+                "buyqty": {
+                    "description": "买量(暂不做, 无值, 保留字段)",
+                    "type": "number"
+                },
+                "goodscode": {
+                    "description": "合约代码",
+                    "type": "string"
+                },
+                "goodsgroupid": {
+                    "description": "商品组ID(自增ID)",
+                    "type": "integer"
+                },
+                "goodsgroupname": {
+                    "description": "商品组名称",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "合约id",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "合约名称",
+                    "type": "string"
+                },
+                "refgoodscode": {
+                    "description": "标的合约代码",
+                    "type": "string"
+                },
+                "refgoodsid": {
+                    "description": "标的合约id",
+                    "type": "integer"
+                },
+                "refgoodsname": {
+                    "description": "标的合约名称",
+                    "type": "string"
+                },
+                "sellqty": {
+                    "description": "卖量(暂不做, 无值, 保留字段)",
+                    "type": "number"
+                }
+            }
+        },
+        "models.TjmdTradeOrderDetail": {
+            "type": "object",
+            "properties": {
+                "buyorsell": {
+                    "description": "买卖方向 0-买 1-卖",
+                    "type": "integer"
+                },
+                "goodsid": {
+                    "description": "商品id",
+                    "type": "integer"
+                },
+                "orderid": {
+                    "description": "委托单号",
+                    "type": "string"
+                },
+                "orderprice": {
+                    "description": "委托价格",
+                    "type": "number"
+                },
+                "orderqty": {
+                    "description": "委托数量",
+                    "type": "integer"
+                },
+                "userid": {
+                    "description": "用户id",
+                    "type": "integer"
+                },
+                "username": {
+                    "description": "用户名称(已脱敏)",
+                    "type": "string"
+                }
+            }
+        },
         "models.TradeHolderDetail": {
             "type": "object",
             "properties": {

+ 190 - 45
docs/swagger.yaml

@@ -12896,6 +12896,63 @@ definitions:
     required:
     - autoid
     type: object
+  models.TjmdQuoteGoods:
+    properties:
+      buyqty:
+        description: 买量(暂不做, 无值, 保留字段)
+        type: number
+      goodscode:
+        description: 合约代码
+        type: string
+      goodsgroupid:
+        description: 商品组ID(自增ID)
+        type: integer
+      goodsgroupname:
+        description: 商品组名称
+        type: string
+      goodsid:
+        description: 合约id
+        type: integer
+      goodsname:
+        description: 合约名称
+        type: string
+      refgoodscode:
+        description: 标的合约代码
+        type: string
+      refgoodsid:
+        description: 标的合约id
+        type: integer
+      refgoodsname:
+        description: 标的合约名称
+        type: string
+      sellqty:
+        description: 卖量(暂不做, 无值, 保留字段)
+        type: number
+    type: object
+  models.TjmdTradeOrderDetail:
+    properties:
+      buyorsell:
+        description: 买卖方向 0-买 1-卖
+        type: integer
+      goodsid:
+        description: 商品id
+        type: integer
+      orderid:
+        description: 委托单号
+        type: string
+      orderprice:
+        description: 委托价格
+        type: number
+      orderqty:
+        description: 委托数量
+        type: integer
+      userid:
+        description: 用户id
+        type: integer
+      username:
+        description: 用户名称(已脱敏)
+        type: string
+    type: object
   models.TradeHolderDetail:
     properties:
       accountid:
@@ -22315,6 +22372,51 @@ paths:
       summary: 成交单查询(合约市场)
       tags:
       - 通用单据
+  /Order/QueryTradeHolderDetail:
+    get:
+      parameters:
+      - description: 用户id
+        in: query
+        name: userid
+        type: integer
+      - description: 资金账号, 格式 1,2,3
+        in: query
+        name: accids
+        type: string
+      - description: 交易模式, 格式 1,2,3
+        in: query
+        name: trademodes
+        type: string
+      - description: 市场id, 格式 1,2,3
+        in: query
+        name: marketids
+        type: string
+      - description: 商品id
+        in: query
+        name: goodsid
+        type: integer
+      - description: 买卖方向 0-买 1-卖
+        in: query
+        name: buyorsell
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.TradeHolderDetail'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询持仓明细
+      tags:
+      - 通用单据
   /Order/QueryTradeOrderDetail:
     get:
       parameters:
@@ -24400,6 +24502,94 @@ paths:
       summary: 资金流水查询(历史)
       tags:
       - 资金账户
+  /Tjmd/QueryQuoteGoodsList:
+    get:
+      description: 用户类型必传, 查掉期报价列表 marketids=掉期市场id
+      parameters:
+      - description: 用户类型
+        in: query
+        name: usertype
+        required: true
+        type: integer
+      - description: 市场id, 格式 1,2,3
+        in: query
+        name: marketids
+        type: string
+      - description: 商品组id
+        in: query
+        name: goodsgroupid
+        type: integer
+      - description: 商品id
+        in: query
+        name: goodsid
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.TjmdQuoteGoods'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询掉期报价列表
+      tags:
+      - 天津麦顿
+  /Tjmd/QueryTjmdTradeOrderDetail:
+    get:
+      description: 用户类型必传, 投资者只能看到自营会员的单, 反之亦然
+      parameters:
+      - description: 页码
+        in: query
+        name: page
+        type: integer
+      - description: 每页条数
+        in: query
+        name: pagesize
+        type: integer
+      - description: 用户类型
+        in: query
+        name: usertype
+        required: true
+        type: integer
+      - description: 市场id, 格式 1,2,3
+        in: query
+        name: marketids
+        type: string
+      - 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.TjmdTradeOrderDetail'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询掉期买卖大厅
+      tags:
+      - 天津麦顿
   /Trade/QueryRecieptOrder:
     get:
       description: 说明:pagesize参数赋值不为0时表示需要分页;page参数从0开始计算
@@ -25157,51 +25347,6 @@ paths:
       summary: 查询履约模板
       tags:
       - 仓单贸易v2
-  /WrTrade2/QueryTradeHolderDetail:
-    get:
-      parameters:
-      - description: 用户id
-        in: query
-        name: userid
-        type: integer
-      - description: 资金账号, 格式 1,2,3
-        in: query
-        name: accids
-        type: string
-      - description: 交易模式, 格式 1,2,3
-        in: query
-        name: trademodes
-        type: string
-      - description: 市场id, 格式 1,2,3
-        in: query
-        name: marketids
-        type: string
-      - description: 商品id
-        in: query
-        name: goodsid
-        type: integer
-      - description: 买卖方向 0-买 1-卖
-        in: query
-        name: buyorsell
-        type: integer
-      produces:
-      - application/json
-      responses:
-        "200":
-          description: OK
-          schema:
-            items:
-              $ref: '#/definitions/models.TradeHolderDetail'
-            type: array
-        "500":
-          description: Internal Server Error
-          schema:
-            $ref: '#/definitions/app.Response'
-      security:
-      - ApiKeyAuth: []
-      summary: 查询持仓明细
-      tags:
-      - 仓单贸易v2
   /WrTrade2/QueryWrAverageTradePrice:
     get:
       parameters:

+ 62 - 27
main.go

@@ -30,7 +30,34 @@ import (
 // @name Authorization
 //
 // @BasePath /api
+
+// cmdLine 命令行参数
+type cmdLine struct {
+	StrCmd []string
+}
+
+// IsInit 是否初始化某项, 如 IsInit("redis")
+func (r *cmdLine) IsInit(item string) bool {
+	if len(r.StrCmd) <= 1 {
+		return true
+	}
+	if len(r.StrCmd) >= 2 {
+		if r.StrCmd[1] == "init" {
+			for i := 2; i < len(r.StrCmd); i++ {
+				if r.StrCmd[i] == item {
+					logger.GetLogger().Info("cmdline init", item)
+					return true
+				}
+			}
+		} else {
+			return true
+		}
+	}
+	return true
+}
+
 func main() {
+	cmd := cmdLine{StrCmd: os.Args}
 	// 初始化配置
 	err := config.SerCfg.Init("config/config.xml")
 	if err != nil {
@@ -45,40 +72,48 @@ func main() {
 		return
 	}
 
-	// 初始化数据库引擎
-	err = db.InitDbEngine()
-	if err != nil {
-		logger.GetLogger().Errorf("init db engine failed:", err.Error())
-		return
+	if cmd.IsInit("oracle") {
+		// 初始化数据库引擎
+		err = db.InitDbEngine()
+		if err != nil {
+			logger.GetLogger().Errorf("init db engine failed:", err.Error())
+			return
+		}
+		go db.StartCheckConnection(0)
+		defer db.Close()
 	}
-	go db.StartCheckConnection(0)
-	defer db.Close()
 
-	// 初始化MongoDB引擎
-	err = db.InitMongoDB()
-	if err != nil {
-		logger.GetLogger().Errorf("init mongodb engine failed:", err.Error())
-		return
+	if cmd.IsInit("mongodb") {
+		// 初始化MongoDB引擎
+		err = db.InitMongoDB()
+		if err != nil {
+			logger.GetLogger().Errorf("init mongodb engine failed:", err.Error())
+			return
+		}
+		go db.StartCheckConnection(2)
+		defer db.CloseMongoDB()
 	}
-	go db.StartCheckConnection(2)
-	defer db.CloseMongoDB()
 
-	// 初始化MySQL引擎
-	err = db.InitMySQLDbEngine()
-	if err != nil {
-		logger.GetLogger().Errorf("init mysql engine failed:", err.Error())
-		return
+	if cmd.IsInit("mysql") {
+		// 初始化MySQL引擎
+		err = db.InitMySQLDbEngine()
+		if err != nil {
+			logger.GetLogger().Errorf("init mysql engine failed:", err.Error())
+			return
+		}
+		go db.StartCheckConnection(1)
+		defer db.CloseMySQL()
 	}
-	go db.StartCheckConnection(1)
-	defer db.CloseMySQL()
 
-	// 初始化Redis客户端
-	err = rediscli.InitRedisCli()
-	if err != nil {
-		logger.GetLogger().Errorf("init redis client failed:", err.Error())
-		return
+	if cmd.IsInit("redis") {
+		// 初始化Redis客户端
+		err = rediscli.InitRedisCli()
+		if err != nil {
+			logger.GetLogger().Errorf("init redis client failed:", err.Error())
+			return
+		}
+		defer rediscli.CloseReidsClient()
 	}
-	defer rediscli.CloseReidsClient()
 
 	if config.SerCfg.GetDebugMode() {
 		gin.SetMode(gin.DebugMode)

+ 137 - 0
models/tjmd.go

@@ -0,0 +1,137 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/9/7 16:01
+* @Modify  : 2021/9/7 16:01
+* @note    : 天津麦顿
+ */
+
+package models
+
+import (
+	"fmt"
+	"mtp2_if/db"
+	"mtp2_if/utils"
+)
+
+// TjmdQuoteGoods 掉期报价列表
+type TjmdQuoteGoods struct {
+	GOODSID        int64   `json:"goodsid"  xorm:"'GOODSID'" form:"goodsid"`                // 合约id
+	GOODSCODE      string  `json:"goodscode"  xorm:"'GOODSCODE'"`                           // 合约代码
+	GOODSNAME      string  `json:"goodsname"  xorm:"'GOODSNAME'"`                           // 合约名称
+	REFGOODSID     int64   `json:"refgoodsid"  xorm:"'REFGOODSID'"`                         // 标的合约id
+	REFGOODSCODE   string  `json:"refgoodscode"  xorm:"'REFGOODSCODE'"`                     // 标的合约代码
+	REFGOODSNAME   string  `json:"refgoodsname"  xorm:"'REFGOODSNAME'"`                     // 标的合约名称
+	SELLQTY        float64 `json:"sellqty"  xorm:"'SELLQTY'"`                               // 卖量(暂不做, 无值, 保留字段)
+	BUYQTY         float64 `json:"buyqty"  xorm:"'BUYQTY'"`                                 // 买量(暂不做, 无值, 保留字段)
+	GOODSGROUPID   int64   `json:"goodsgroupid"  xorm:"'GOODSGROUPID'" form:"goodsgroupid"` // 商品组ID(自增ID)
+	GOODSGROUPNAME string  `json:"goodsgroupname"  xorm:"'GOODSGROUPNAME'"`                 // 商品组名称
+
+	UserType    int32  `json:"-" form:"usertype"`  // 用户类型
+	FtMarketIds string `json:"-" form:"marketids"` // 市场id, 格式 1,2,3
+}
+
+func (r *TjmdQuoteGoods) calc() {
+
+}
+
+func (r *TjmdQuoteGoods) buildSql() string {
+	var sqlId utils.SQLVal = `
+select g1.goodsid,
+       g1.goodscode,
+       g1.goodsname,
+       g2.goodsid        refgoodsid,
+       g2.goodscode      refgoodscode,
+       g2.goodsname      refgoodsname,
+       gp.goodsgroupid,
+       gp.goodsgroupname,
+       gp.outergroupcode goodsgroupcode,
+       gp.marketid
+  from goods g1
+  left join goods g2
+    on g1.refgoodsid = g2.goodsid
+  left join goodsgroup gp
+    on g1.goodsgroupid = gp.goodsgroupid
+  where 1=1
+`
+	sqlId.JoinEx(r.FtMarketIds != "", fmt.Sprintf(" and gp.marketid in(%v)", r.FtMarketIds))
+
+	return sqlId.String()
+}
+
+// GetDataEx 获取掉期报价列表
+func (r *TjmdQuoteGoods) GetDataEx() (interface{}, error) {
+	sData := make([]TjmdQuoteGoods, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}
+
+// TjmdTradeOrderDetail 买卖大厅
+type TjmdTradeOrderDetail struct {
+	ORDERID    string   `json:"orderid"  xorm:"'ORDERID'"`                      // 委托单号
+	GOODSID    int32    `json:"goodsid"  xorm:"'GOODSID'" form:"goodsid"`       // 商品id
+	BUYORSELL  int32    `json:"buyorsell"  xorm:"'BUYORSELL'" form:"buyorsell"` // 买卖方向 0-买 1-卖
+	ORDERPRICE SFLOAT64 `json:"orderprice"  xorm:"'ORDERPRICE'"`                // 委托价格
+	ORDERQTY   int64    `json:"orderqty"  xorm:"'ORDERQTY'"`                    // 委托数量
+	USERID     int64    `json:"userid"  xorm:"'USERID'"`                        // 用户id
+	USERNAME   string   `json:"username"  xorm:"'USERNAME'"`                    // 用户名称(已脱敏)
+	PageEx     `xorm:"extends"`
+
+	USERTYPE    int32  `json:"-" form:"usertype"`  // 用户类型
+	FtMarketIds string `json:"-" form:"marketids"` // 市场id, 格式 1,2,3
+}
+
+func (r *TjmdTradeOrderDetail) calc() {
+	r.USERNAME = EncryptByStar(r.USERNAME)
+}
+
+func (r *TjmdTradeOrderDetail) buildSql() string {
+	var sqlId utils.SQLVal = `
+select to_char(t.orderid) orderid,
+       t.buyorsell,
+       t.goodsid,
+       t.orderprice,
+       t.orderqty - t.tradeqty orderqty,
+       u.userid,
+       u.accountname username,
+       t.orderstatus,
+       g.marketid
+  from trade_orderdetail t
+  left join taaccount ta
+    on t.accountid = ta.accountid
+  left join useraccount u
+    on ta.relateduserid = u.userid
+  left join goods g on t.goodsid=g.goodsid
+ where 1 = 1
+   and t.orderstatus in (3, 7)
+   and u.usertype = decode(%v,2,5,-1)
+`
+	// 投资者只能看到会员的单, 会员只能看到投资者的单, decode(%v,2,5,-1)
+	sqlId.FormatParam(r.USERTYPE)
+	sqlId.And("t.GOODSID", r.GOODSID)
+	sqlId.And("t.BUYORSELL", r.BUYORSELL)
+	sqlId.AndEx("g.marketid", r.FtMarketIds, r.FtMarketIds != "")
+	if r.BUYORSELL == 0 {
+		sqlId.Join(" order by t.orderprice desc, t.ordertime desc")
+	} else {
+		sqlId.Join(" order by t.orderprice, t.ordertime desc")
+	}
+	sqlId.Page(r.Page, r.PageSize)
+
+	return sqlId.String()
+}
+
+// GetDataByPage 获取买卖大厅
+func (r *TjmdTradeOrderDetail) GetDataByPage() (interface{}, error, int, int, int) {
+	sData := make([]TjmdTradeOrderDetail, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	if len(sData) > 0 {
+		r.Total = sData[0].Total
+	}
+	return sData, err, r.Page, r.PageSize, r.Total
+}

+ 5 - 2
models/wrTrade2.go

@@ -2789,13 +2789,16 @@ func (r *WrTradeOrderDetail) buildSql() string {
 }
 
 // GetDataEx 获取合约交易买卖大厅
-func (r *WrTradeOrderDetail) GetDataEx() (interface{}, error) {
+func (r *WrTradeOrderDetail) GetDataByPage() (interface{}, error, int, int, int) {
 	sData := make([]WrTradeOrderDetail, 0)
 	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
 	for i := range sData {
 		sData[i].calc()
 	}
-	return sData, err
+	if len(sData) > 0 {
+		r.Total = sData[0].Total
+	}
+	return sData, err, r.Page, r.PageSize, r.Total
 }
 
 // WrAverageTradePrice 成交均价(历史走势)

+ 12 - 0
routers/router.go

@@ -19,7 +19,9 @@ import (
 	"mtp2_if/controllers/search"
 	"mtp2_if/controllers/szdz"
 	"mtp2_if/controllers/taaccount"
+	"mtp2_if/controllers/tjmd"
 	"mtp2_if/controllers/trade"
+	"mtp2_if/controllers/tradexx"
 	"mtp2_if/controllers/user"
 	"mtp2_if/controllers/wrTrade2"
 	"mtp2_if/controllers/wrtrade"
@@ -150,6 +152,8 @@ func InitRouter() *gin.Engine {
 		orderR.GET("/QueryTradeDetail", order.QueryTradeDetail)
 		// 历史成交单查询(合约市场)
 		orderR.GET("/QueryHisTradeDetail", order.QueryHisTradeDetail)
+
+		orderR.GET("/QueryTradeHolderDetail", tradexx.QueryTradeHolderDetail)
 	}
 	// ************************ 通用交易 ************************
 	tradeR := apiR.Group("Trade")
@@ -555,6 +559,14 @@ func InitRouter() *gin.Engine {
 		wrTrade2R.GET("QueryWrPerformanceStepType", wrTrade2.QueryWrPerformanceStepType)
 	}
 
+	// **************************天津麦顿*************************
+	tjmdR := apiR.Group("Tjmd")
+	tjmdR.Use(token.Auth())
+	{
+		tjmdR.GET("QueryQuoteGoodsList", tjmd.QueryQuoteGoodsList)
+		tjmdR.GET("QueryTjmdTradeOrderDetail", tjmd.QueryTjmdTradeOrderDetail)
+	}
+
 	return r
 }