Переглянути джерело

pcweb 增加查持仓汇总接口

zou.yingbin 4 роки тому
батько
коміт
c6d8687482
8 змінених файлів з 587 додано та 11 видалено
  1. 31 1
      controllers/qhjPCWeb/qryQhjPCWeb.go
  2. 149 3
      docs/docs.go
  3. 149 3
      docs/swagger.json
  4. 103 2
      docs/swagger.yaml
  5. 12 0
      models/ermcpCommon.go
  6. 2 2
      models/qhj.go
  7. 140 0
      models/qhjPCWeb.go
  8. 1 0
      routers/router.go

+ 31 - 1
controllers/qhjPCWeb/qryQhjPCWeb.go

@@ -66,7 +66,7 @@ func QueryCustomerInfo(c *gin.Context) {
 // @Produce json
 // @Security ApiKeyAuth
 // @Param querytype query int true "查询类型 1-提现(出金) 2-充值(出金)"
-// @Param applystatus query int true "状态 1-待审核 2-审核通过 3-审核拒绝"
+// @Param applystatus query int false "状态 1-待审核 2-审核通过 3-审核拒绝"
 // @Param begindate query string false "申请起始日期(格式yyyymmdd)"
 // @Param enddate query string false "申请截止日期(格式yyyymmdd)"
 // @Param likename query string false "模糊搜索名称"
@@ -107,3 +107,33 @@ func QueryAccountInOutApply(c *gin.Context) {
 		QUERYTYPE: req.QUERYTYPE, STATUS: req.APPLYSTATUS}
 	a.DoGetDataI(&m)
 }
+
+// QueryTradePosition
+// @Summary 查询持仓汇总
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
+// @Param userinfotype query int false "用户类型 1-个人 2-企业"
+// @Param goodsid query int false "商品id"
+// @Param filtername query string false "名称(模糊搜索账户)"
+// @Param includesub query int false "是否包含子级 1-包含"
+// @Success 200 {array} models.QhjMgrPosition
+// @Failure 500 {object} app.Response
+// @Router /QhjMgr/QueryTradePosition [get]
+// @Tags 大连千海金(PCWeb)
+func QueryTradePosition(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	req := struct {
+		USERID       int64  `form:"userid" binding:"required"` // 用户id
+		USERINFOTYPE int32  `form:"userinfotype"`
+		FILTERNAME   string `form:"filtername"`
+		GOODSID      int32  `form:"goodsid"`
+		INCLUDESUB   int32  `form:"includesub"`
+	}{}
+	a.DoBindReq(&req)
+	m := models.QhjMgrTradePosition{}
+	m.USERID, m.FilterName = req.USERID, req.FILTERNAME
+	m.USERINFOTYPE, m.GOODSID = req.USERINFOTYPE, req.GOODSID
+	m.IncludeSub = req.INCLUDESUB
+	a.DoGetDataI(&m)
+}

+ 149 - 3
docs/docs.go

@@ -7950,8 +7950,7 @@ var doc = `{
                         "type": "integer",
                         "description": "状态 1-待审核 2-审核通过 3-审核拒绝",
                         "name": "applystatus",
-                        "in": "query",
-                        "required": true
+                        "in": "query"
                     },
                     {
                         "type": "string",
@@ -8106,6 +8105,72 @@ var doc = `{
                 }
             }
         },
+        "/QhjMgr/QueryTradePosition": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "大连千海金(PCWeb)"
+                ],
+                "summary": "查询持仓汇总",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "用户类型 1-个人 2-企业",
+                        "name": "userinfotype",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商品id",
+                        "name": "goodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "名称(模糊搜索账户)",
+                        "name": "filtername",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "是否包含子级 1-包含",
+                        "name": "includesub",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.QhjMgrPosition"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Quote/QueryHistoryDatas": {
             "get": {
                 "security": [
@@ -22643,6 +22708,87 @@ var doc = `{
                 }
             }
         },
+        "models.QhjMgrPosition": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "账号Id",
+                    "type": "integer"
+                },
+                "accountname": {
+                    "description": "用户名称",
+                    "type": "string"
+                },
+                "agreeunit": {
+                    "description": "合约乘数",
+                    "type": "number"
+                },
+                "averageprice": {
+                    "description": "均价",
+                    "type": "number"
+                },
+                "avialqty": {
+                    "description": "可用数量",
+                    "type": "number"
+                },
+                "decimalplace": {
+                    "description": "报价小数位",
+                    "type": "integer"
+                },
+                "enumdicname": {
+                    "description": "单位名称(商品)",
+                    "type": "string"
+                },
+                "frozenqty": {
+                    "description": "冻结数量",
+                    "type": "number"
+                },
+                "goodscode": {
+                    "description": "商品代码(内部)",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "商品Id",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "商品名称",
+                    "type": "string"
+                },
+                "goodunitid": {
+                    "description": "报价单位ID",
+                    "type": "integer"
+                },
+                "holderamount": {
+                    "description": "金额",
+                    "type": "number"
+                },
+                "holderqty": {
+                    "description": "持有数量",
+                    "type": "number"
+                },
+                "holdertype": {
+                    "description": "持仓类别 - 1:单边持仓 2:双边持仓",
+                    "type": "integer"
+                },
+                "logincode": {
+                    "description": "登录代码(账户)",
+                    "type": "string"
+                },
+                "qtydecimalplace": {
+                    "description": "成交量小数位",
+                    "type": "integer"
+                },
+                "userid": {
+                    "description": "用户id",
+                    "type": "integer"
+                },
+                "userinfotype": {
+                    "description": "账户类型 1-个人 2-企业",
+                    "type": "integer"
+                }
+            }
+        },
         "models.QhjMgrSubArea": {
             "type": "object",
             "properties": {
@@ -23509,7 +23655,7 @@ var doc = `{
                 },
                 "takeorderid": {
                     "description": "提货单号(905+Unix秒时间戳(10位)+xxxxxx)",
-                    "type": "integer"
+                    "type": "string"
                 },
                 "takeorderstatus": {
                     "description": "提货状态 -  1:备货中 2:待取货(自提) 3:已取货(自提) 4:待收货(邮寄) 5:已收货(邮寄) 6:自动收货(邮寄) 7:已拒绝 8:已撤销",

+ 149 - 3
docs/swagger.json

@@ -7934,8 +7934,7 @@
                         "type": "integer",
                         "description": "状态 1-待审核 2-审核通过 3-审核拒绝",
                         "name": "applystatus",
-                        "in": "query",
-                        "required": true
+                        "in": "query"
                     },
                     {
                         "type": "string",
@@ -8090,6 +8089,72 @@
                 }
             }
         },
+        "/QhjMgr/QueryTradePosition": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "大连千海金(PCWeb)"
+                ],
+                "summary": "查询持仓汇总",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "用户类型 1-个人 2-企业",
+                        "name": "userinfotype",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商品id",
+                        "name": "goodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "名称(模糊搜索账户)",
+                        "name": "filtername",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "是否包含子级 1-包含",
+                        "name": "includesub",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.QhjMgrPosition"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Quote/QueryHistoryDatas": {
             "get": {
                 "security": [
@@ -22627,6 +22692,87 @@
                 }
             }
         },
+        "models.QhjMgrPosition": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "账号Id",
+                    "type": "integer"
+                },
+                "accountname": {
+                    "description": "用户名称",
+                    "type": "string"
+                },
+                "agreeunit": {
+                    "description": "合约乘数",
+                    "type": "number"
+                },
+                "averageprice": {
+                    "description": "均价",
+                    "type": "number"
+                },
+                "avialqty": {
+                    "description": "可用数量",
+                    "type": "number"
+                },
+                "decimalplace": {
+                    "description": "报价小数位",
+                    "type": "integer"
+                },
+                "enumdicname": {
+                    "description": "单位名称(商品)",
+                    "type": "string"
+                },
+                "frozenqty": {
+                    "description": "冻结数量",
+                    "type": "number"
+                },
+                "goodscode": {
+                    "description": "商品代码(内部)",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "商品Id",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "商品名称",
+                    "type": "string"
+                },
+                "goodunitid": {
+                    "description": "报价单位ID",
+                    "type": "integer"
+                },
+                "holderamount": {
+                    "description": "金额",
+                    "type": "number"
+                },
+                "holderqty": {
+                    "description": "持有数量",
+                    "type": "number"
+                },
+                "holdertype": {
+                    "description": "持仓类别 - 1:单边持仓 2:双边持仓",
+                    "type": "integer"
+                },
+                "logincode": {
+                    "description": "登录代码(账户)",
+                    "type": "string"
+                },
+                "qtydecimalplace": {
+                    "description": "成交量小数位",
+                    "type": "integer"
+                },
+                "userid": {
+                    "description": "用户id",
+                    "type": "integer"
+                },
+                "userinfotype": {
+                    "description": "账户类型 1-个人 2-企业",
+                    "type": "integer"
+                }
+            }
+        },
         "models.QhjMgrSubArea": {
             "type": "object",
             "properties": {
@@ -23493,7 +23639,7 @@
                 },
                 "takeorderid": {
                     "description": "提货单号(905+Unix秒时间戳(10位)+xxxxxx)",
-                    "type": "integer"
+                    "type": "string"
                 },
                 "takeorderstatus": {
                     "description": "提货状态 -  1:备货中 2:待取货(自提) 3:已取货(自提) 4:待收货(邮寄) 5:已收货(邮寄) 6:自动收货(邮寄) 7:已拒绝 8:已撤销",

+ 103 - 2
docs/swagger.yaml

@@ -9853,6 +9853,66 @@ definitions:
         description: 用户名称
         type: string
     type: object
+  models.QhjMgrPosition:
+    properties:
+      accountid:
+        description: 账号Id
+        type: integer
+      accountname:
+        description: 用户名称
+        type: string
+      agreeunit:
+        description: 合约乘数
+        type: number
+      averageprice:
+        description: 均价
+        type: number
+      avialqty:
+        description: 可用数量
+        type: number
+      decimalplace:
+        description: 报价小数位
+        type: integer
+      enumdicname:
+        description: 单位名称(商品)
+        type: string
+      frozenqty:
+        description: 冻结数量
+        type: number
+      goodscode:
+        description: 商品代码(内部)
+        type: string
+      goodsid:
+        description: 商品Id
+        type: integer
+      goodsname:
+        description: 商品名称
+        type: string
+      goodunitid:
+        description: 报价单位ID
+        type: integer
+      holderamount:
+        description: 金额
+        type: number
+      holderqty:
+        description: 持有数量
+        type: number
+      holdertype:
+        description: 持仓类别 - 1:单边持仓 2:双边持仓
+        type: integer
+      logincode:
+        description: 登录代码(账户)
+        type: string
+      qtydecimalplace:
+        description: 成交量小数位
+        type: integer
+      userid:
+        description: 用户id
+        type: integer
+      userinfotype:
+        description: 账户类型 1-个人 2-企业
+        type: integer
+    type: object
   models.QhjMgrSubArea:
     properties:
       accountname:
@@ -10496,7 +10556,7 @@ definitions:
         type: integer
       takeorderid:
         description: 提货单号(905+Unix秒时间戳(10位)+xxxxxx)
-        type: integer
+        type: string
       takeorderstatus:
         description: 提货状态 -  1:备货中 2:待取货(自提) 3:已取货(自提) 4:待收货(邮寄) 5:已收货(邮寄) 6:自动收货(邮寄)
           7:已拒绝 8:已撤销
@@ -18576,7 +18636,6 @@ paths:
       - description: 状态 1-待审核 2-审核通过 3-审核拒绝
         in: query
         name: applystatus
-        required: true
         type: integer
       - description: 申请起始日期(格式yyyymmdd)
         in: query
@@ -18681,6 +18740,48 @@ paths:
       summary: 查询子机构列表
       tags:
       - 大连千海金(PCWeb)
+  /QhjMgr/QueryTradePosition:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      - description: 用户类型 1-个人 2-企业
+        in: query
+        name: userinfotype
+        type: integer
+      - description: 商品id
+        in: query
+        name: goodsid
+        type: integer
+      - description: 名称(模糊搜索账户)
+        in: query
+        name: filtername
+        type: string
+      - description: 是否包含子级 1-包含
+        in: query
+        name: includesub
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.QhjMgrPosition'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询持仓汇总
+      tags:
+      - 大连千海金(PCWeb)
   /Quote/QueryHistoryDatas:
     get:
       parameters:

+ 12 - 0
models/ermcpCommon.go

@@ -10,6 +10,7 @@ package models
 import (
 	"encoding/hex"
 	"fmt"
+	"math"
 	"mtp2_if/utils"
 )
 
@@ -62,3 +63,14 @@ func InStr(param ...interface{}) string {
 	}
 	return str
 }
+
+type ZOOMFUN func(vList ...*float64)
+
+// NewZoomFun 创建缩放函数
+func NewZoomFun(decimalplace int) ZOOMFUN {
+	return func(vList ...*float64) {
+		for i := range vList {
+			*vList[i] = *vList[i] / math.Pow10(decimalplace)
+		}
+	}
+}

+ 2 - 2
models/qhj.go

@@ -473,7 +473,7 @@ type QhjTradeGoodsPickup struct {
 	UPDATETIME           string  `json:"updatetime"  xorm:"UPDATETIME"`                     // 更新时间
 	AUDITTRADEDATE       string  `json:"audittradedate"  xorm:"AUDITTRADEDATE"`             // 审核交易日(yyyyMMdd)
 	EXPRESSNUM           string  `json:"expressnum"  xorm:"EXPRESSNUM"`                     // 物流单号
-	TAKEORDERID          int64   `json:"takeorderid"  xorm:"TAKEORDERID"`                   // 提货单号(905+Unix秒时间戳(10位)+xxxxxx)
+	TAKEORDERID          string  `json:"takeorderid"  xorm:"TAKEORDERID"`                   // 提货单号(905+Unix秒时间戳(10位)+xxxxxx)
 	ACCOUNTID            int64   `json:"accountid"  xorm:"ACCOUNTID"`                       // 账户ID
 	GOODSID              int64   `json:"goodsid"  xorm:"GOODSID"`                           // 商品ID
 	USERID               int64   `json:"userid"  xorm:"USERID"`                             // 用户ID
@@ -539,7 +539,7 @@ func (r *QhjTradeGoodsPickup) buildSql() string {
 		"       to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME," +
 		"       t.AUDITTRADEDATE," +
 		"       t.EXPRESSNUM," +
-		"       t.TAKEORDERID," +
+		"       to_char(t.TAKEORDERID) TAKEORDERID," +
 		"       t.ACCOUNTID," +
 		"       t.GOODSID," +
 		"       t.USERID," +

+ 140 - 0
models/qhjPCWeb.go

@@ -393,3 +393,143 @@ func (r *QhjMgrAccountOutInApply) GetDataEx() (interface{}, error) {
 	}
 	return sData, err
 }
+
+// QhjTradeEx 额外的用户和商品信息
+type QhjTradeEx struct {
+	LOGINCODE       string  `json:"logincode"  xorm:"'LOGINCODE'"`           // 登录代码(账户)
+	USERID          int64   `json:"userid"  xorm:"'USERID'"`                 // 用户id
+	ACCOUNTNAME     string  `json:"accountname"  xorm:"'ACCOUNTNAME'"`       // 用户名称
+	ENUMDICNAME     string  `json:"enumdicname"  xorm:"'ENUMDICNAME'"`       // 单位名称(商品)
+	GOODSCODE       string  `json:"goodscode"  xorm:"GOODSCODE"`             // 商品代码(内部)
+	GOODSNAME       string  `json:"goodsname"  xorm:"GOODSNAME"`             // 商品名称
+	GOODUNITID      int32   `json:"goodunitid"  xorm:"GOODUNITID"`           // 报价单位ID
+	AGREEUNIT       float64 `json:"agreeunit"  xorm:"AGREEUNIT"`             // 合约乘数
+	DECIMALPLACE    int32   `json:"decimalplace"  xorm:"DECIMALPLACE"`       // 报价小数位
+	QTYDECIMALPLACE int32   `json:"qtydecimalplace"  xorm:"QTYDECIMALPLACE"` // 成交量小数位
+	USERINFOTYPE    int32   `json:"userinfotype"  xorm:"'USERINFOTYPE'"`     // 账户类型 1-个人 2-企业
+}
+
+// QhjMgrPosition 持仓汇总
+type QhjMgrPosition struct {
+	QhjTradeEx   `xorm:"extends"`
+	ACCOUNTID    int64   `json:"accountid"`    // 账号Id
+	GOODSID      int32   `json:"goodsid"`      // 商品Id
+	HOLDERTYPE   int32   `json:"holdertype"`   // 持仓类别 - 1:单边持仓 2:双边持仓
+	HOLDERQTY    float64 `json:"holderqty"`    // 持有数量
+	FROZENQTY    float64 `json:"frozenqty"`    // 冻结数量
+	AVIALQTY     float64 `json:"avialqty"`     // 可用数量
+	HOLDERAMOUNT float64 `json:"holderamount"` // 金额
+	AVERAGEPRICE float64 `json:"averageprice"` // 均价
+}
+
+// QhjMgrTradePosition 持仓汇总
+type QhjMgrTradePosition struct {
+	ACCOUNTID           int64   `json:"accountid"  xorm:"ACCOUNTID"`                     // 账号Id
+	GOODSID             int32   `json:"goodsid"  xorm:"GOODSID"`                         // 商品Id
+	HOLDERTYPE          int32   `json:"holdertype"  xorm:"HOLDERTYPE"`                   // 持仓类别 - 1:单边持仓 2:双边持仓
+	BUYPOSITIONQTY      float64 `json:"buypositionqty"  xorm:"BUYPOSITIONQTY"`           // 买期初持仓数量
+	BUYHOLDERAMOUNT     float64 `json:"buyholderamount"  xorm:"BUYHOLDERAMOUNT"`         // 买期初持仓总金额[商品币种]
+	BUYCURPOSITIONQTY   float64 `json:"buycurpositionqty"  xorm:"BUYCURPOSITIONQTY"`     // 买当前持仓总数量
+	BUYCURHOLDERAMOUNT  float64 `json:"buycurholderamount"  xorm:"BUYCURHOLDERAMOUNT"`   // 买当前持仓总金额[商品币种]
+	BUYFROZENQTY        float64 `json:"buyfrozenqty"  xorm:"BUYFROZENQTY"`               // 买持仓冻结数量
+	BUYOTHERFROZENQTY   float64 `json:"buyotherfrozenqty"  xorm:"BUYOTHERFROZENQTY"`     // 买持仓其他冻结数量(交割冻结)
+	BUYOPENREQQTY       float64 `json:"buyopenreqqty"  xorm:"BUYOPENREQQTY"`             // 买开仓申请数量(用于比较最大持仓数量)
+	BUYOPENTOTALQTY     float64 `json:"buyopentotalqty"  xorm:"BUYOPENTOTALQTY"`         // 今日买开仓总数量
+	BUYCLOSETOTALQTY    float64 `json:"buyclosetotalqty"  xorm:"BUYCLOSETOTALQTY"`       // 今日买平仓总数量
+	SELLPOSITIONQTY     float64 `json:"sellpositionqty"  xorm:"SELLPOSITIONQTY"`         // 卖期初持仓数量
+	SELLHOLDERAMOUNT    float64 `json:"sellholderamount"  xorm:"SELLHOLDERAMOUNT"`       // 卖期初持仓总金额[商品币种]
+	SELLCURPOSITIONQTY  float64 `json:"sellcurpositionqty"  xorm:"SELLCURPOSITIONQTY"`   // 卖当前持仓数量
+	SELLCURHOLDERAMOUNT float64 `json:"sellcurholderamount"  xorm:"SELLCURHOLDERAMOUNT"` // 卖当前持仓总金额[商品币种]
+	SELLFROZENQTY       float64 `json:"sellfrozenqty"  xorm:"SELLFROZENQTY"`             // 卖持仓冻结
+	SELLOTHERFROZENQTY  float64 `json:"sellotherfrozenqty"  xorm:"SELLOTHERFROZENQTY"`   // 卖持仓其他冻结(交割冻结)
+	SELLOPENREQQTY      float64 `json:"sellopenreqqty"  xorm:"SELLOPENREQQTY"`           // 卖开仓申请数量(用于比较最大持仓数量)
+	SELLOPENTOTALQTY    float64 `json:"sellopentotalqty"  xorm:"SELLOPENTOTALQTY"`       // 今日卖开仓总数量
+	SELLCLOSETOTALQTY   float64 `json:"sellclosetotalqty"  xorm:"SELLCLOSETOTALQTY"`     // 今日卖平仓总数量
+	USEDMARGIN          float64 `json:"usedmargin"  xorm:"USEDMARGIN"`                   // 占用保证金[商品币种]
+	TRADEPROPERTY       int32   `json:"tradeproperty"  xorm:"TRADEPROPERTY"`             // 交易属性
+	BUYTNQTY            float64 `json:"buytnqty"  xorm:"BUYTNQTY"`                       // 买T+N冻结总量
+	BUYTNUSEDQTY        float64 `json:"buytnusedqty"  xorm:"BUYTNUSEDQTY"`               // 买T+N使用量(可以使用T+N的冻结数量)
+	SELLTNQTY           float64 `json:"selltnqty"  xorm:"SELLTNQTY"`                     // 卖T+N冻结总量
+	SELLTNUSEDQTY       float64 `json:"selltnusedqty"  xorm:"SELLTNUSEDQTY"`             // 卖T+N使用量(可以使用T+N的冻结数量)
+	BUYCURTDPOSITION    float64 `json:"buycurtdposition"  xorm:"BUYCURTDPOSITION"`       // 买期末今日头寸
+	BUYFRETDPOSITION    float64 `json:"buyfretdposition"  xorm:"BUYFRETDPOSITION"`       // 买冻结今日头寸
+	SELLCURTDPOSITION   float64 `json:"sellcurtdposition"  xorm:"SELLCURTDPOSITION"`     // 卖期末今日头寸
+	SELLFRETDPOSITION   float64 `json:"sellfretdposition"  xorm:"SELLFRETDPOSITION"`     // 卖冻结今日头寸
+	QhjTradeEx          `xorm:"extends"`
+
+	IncludeSub int32  `json:"-"` // 是否包含子级 1-包含
+	FilterName string `json:"-"` // 模糊搜索
+}
+
+func (r *QhjMgrTradePosition) calc() {
+
+}
+
+func (r *QhjMgrTradePosition) buildSql() string {
+	var sqlId utils.SQLVal = "with k as" +
+		" (select t.userid, wm_concat(t.logincode) logincode" +
+		"    from loginaccount t" +
+		"   group by t.userid)" +
+		"select u.userid," +
+		"       u.accountname," +
+		"       k.logincode," +
+		"       u.subarealevelpath," +
+		"       ui.userinfotype," +
+		"       g.goodsname," +
+		"       g.goodscode," +
+		"       g.goodunitid," +
+		"       g.qtydecimalplace," +
+		"       g.decimalplace," +
+		"       e.enumdicname," +
+		"       t.*" +
+		"  from tradeposition t" +
+		" inner join taaccount ta" +
+		"    on t.accountid = ta.accountid" +
+		" inner join useraccount u" +
+		"    on ta.relateduserid = u.userid" +
+		" inner join userinfo ui" +
+		"    on u.userid = ui.userid" +
+		"  left join k" +
+		"    on u.userid = k.userid" +
+		"  left join goods g" +
+		"    on t.goodsid = g.goodsid" +
+		"  left join enumdicitem e" +
+		"    on e.enumitemname = g.goodunitid" +
+		"   and e.enumdiccode = 'goodsunit'" +
+		" where 1 = 1"
+	if r.IncludeSub == 1 {
+		sqlId.JoinFormat(" and u.subarealevelpath like '%%,%v,%%'", r.USERID)
+	} else {
+		sqlId.And("u.parentuserid", r.USERID)
+	}
+	sqlId.AndEx("ui.USERINFOTYPE", r.USERINFOTYPE, r.USERINFOTYPE > 0)
+	sqlId.AndEx("t.goodsid", r.GOODSID, r.GOODSID > 0)
+	if len(r.FilterName) > 0 {
+		sqlId.JoinFormat(" and (k.logincode like '%%%v%%' or u.accountname like '%%%v%%')", r.FilterName, r.FilterName)
+	}
+	return sqlId.String()
+}
+
+// GetDataEx 获取持仓汇总
+func (r *QhjMgrTradePosition) GetDataEx() (interface{}, error) {
+	sData := make([]QhjMgrTradePosition, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	sData2 := make([]QhjMgrPosition, 0)
+	for i := range sData {
+		sData[i].calc()
+		v := QhjMgrPosition{QhjTradeEx: sData[i].QhjTradeEx}
+		v.GOODSID = sData[i].GOODSID
+		v.ACCOUNTID, v.HOLDERTYPE = sData[i].ACCOUNTID, sData[i].HOLDERTYPE
+		v.HOLDERAMOUNT = sData[i].BUYCURHOLDERAMOUNT
+		v.HOLDERQTY = sData[i].BUYCURPOSITIONQTY
+		v.FROZENQTY = sData[i].BUYFROZENQTY
+		v.AVIALQTY = v.HOLDERQTY - v.FROZENQTY
+		zoomFun := NewZoomFun(int(v.QTYDECIMALPLACE))
+		zoomFun(&v.HOLDERQTY, &v.FROZENQTY, &v.AVIALQTY)
+		if v.HOLDERQTY > 1e-10 {
+			v.AVERAGEPRICE = v.HOLDERAMOUNT / v.HOLDERQTY
+		}
+		sData2 = append(sData2, v)
+	}
+	return sData2, err
+}

+ 1 - 0
routers/router.go

@@ -482,6 +482,7 @@ func InitRouter() *gin.Engine {
 		qhjPCWebR.GET("QuerySubArea", qhjPCWeb.QuerySubArea)
 		qhjPCWebR.GET("QueryCustomerInfo", qhjPCWeb.QueryCustomerInfo)
 		qhjPCWebR.GET("QueryAccountInOutApply", qhjPCWeb.QueryAccountInOutApply)
+		qhjPCWebR.GET("QueryTradePosition", qhjPCWeb.QueryTradePosition)
 	}
 
 	return r