Browse Source

增加 QueryRelatedTaAccount 接口

zhou.xiaoning 3 years ago
parent
commit
10f190136d
7 changed files with 218 additions and 37 deletions
  1. 2 2
      config/config.xml
  2. 16 0
      controllers/taaccount/taaccount.go
  3. 66 19
      docs/docs.go
  4. 61 8
      docs/swagger.json
  5. 41 8
      docs/swagger.yaml
  6. 30 0
      models/account.go
  7. 2 0
      routers/router.go

+ 2 - 2
config/config.xml

@@ -25,7 +25,7 @@
     <Pwd value=""/>
   </RedisSetting>
   <MqSetting>
-    <Url value="amqp://guest:guest@192.168.31.137:5020/test"/>
+    <Url value="amqp://guest:guest@192.168.31.203:5020/test"/>
     <Exchange value="entry"/>
   </MqSetting>
   <MongoDBSetting>
@@ -42,4 +42,4 @@
     <Username value="quote_test203"/>
     <Password value="123456"/>
   </MySQLSetting>
-</Configuration>
+</Configuration>

+ 16 - 0
controllers/taaccount/taaccount.go

@@ -312,3 +312,19 @@ func QueryHisAmountLog(c *gin.Context) {
 		appG.Response(http.StatusOK, e.SUCCESS, datas)
 	}
 }
+
+// QueryRelatedTaAccount
+// @Summary 查询关联资金账户信息
+// @Produce json
+// @Security ApiKeyAuth
+// @Param relateduserid query string true "关联UserID"
+// @Success 200 {array} models.RelatedTaAccount
+// @Failure 500 {object} app.Response
+// @Router /TaAccount/QueryRelatedTaAccount [get]
+// @Tags 资金账户
+func QueryRelatedTaAccount(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.RelatedTaAccount{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}

+ 66 - 19
docs/docs.go

@@ -1,13 +1,14 @@
-// Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
+// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
 // This file was generated by swaggo/swag
+
 package docs
 
 import (
 	"bytes"
 	"encoding/json"
 	"strings"
-	"text/template"
 
+	"github.com/alecthomas/template"
 	"github.com/swaggo/swag"
 )
 
@@ -15,7 +16,7 @@ var doc = `{
     "schemes": {{ marshal .Schemes }},
     "swagger": "2.0",
     "info": {
-        "description": "{{escape .Description}}",
+        "description": "{{.Description}}",
         "title": "{{.Title}}",
         "termsOfService": "http://www.muchinfo.cn",
         "contact": {},
@@ -11240,6 +11241,48 @@ var doc = `{
                 }
             }
         },
+        "/TaAccount/QueryRelatedTaAccount": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "资金账户"
+                ],
+                "summary": "查询关联资金账户信息",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "关联UserID",
+                        "name": "relateduserid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.RelatedTaAccount"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Tjmd/QueryQuoteGoodsList": {
             "get": {
                 "security": [
@@ -14658,7 +14701,9 @@ var doc = `{
                 "code": {
                     "type": "integer"
                 },
-                "data": {},
+                "data": {
+                    "type": "object"
+                },
                 "msg": {
                     "type": "string"
                 },
@@ -17746,31 +17791,31 @@ var doc = `{
                     "type": "number"
                 },
                 "diffArbitrageQty": {
-                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
+                    "description": "套利变动量",
                     "type": "number"
                 },
                 "diffExposoureQty": {
-                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
+                    "description": "变动量(套保敞口)",
                     "type": "number"
                 },
                 "diffFutuQty": {
-                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
+                    "description": "变动量(期货总量) 平安:保值净持仓量今日变动",
                     "type": "number"
                 },
                 "diffHedgeQty": {
-                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
+                    "description": "套保变动量",
                     "type": "number"
                 },
                 "diffQty": {
-                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
+                    "description": "变动量(总敞口) 平安:净敞口今日变动",
                     "type": "number"
                 },
                 "diffSpotHedgeQty": {
-                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
+                    "description": "变动量(现货应套保总量) 平安:应套保量今日变动",
                     "type": "number"
                 },
                 "diffSpotQty": {
-                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
+                    "description": "变动量(现货总量) = 现货数量 - 期初现货数量 平安:采销定价净值今日变动",
                     "type": "number"
                 },
                 "enumdicname": {
@@ -32552,6 +32597,15 @@ var doc = `{
                 }
             }
         },
+        "models.RelatedTaAccount": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "资金账户ID",
+                    "type": "integer"
+                }
+            }
+        },
         "models.RoleMenu": {
             "type": "object",
             "properties": {
@@ -41403,13 +41457,6 @@ func (s *s) ReadDoc() string {
 			a, _ := json.Marshal(v)
 			return string(a)
 		},
-		"escape": func(v interface{}) string {
-			// escape tabs
-			str := strings.Replace(v.(string), "\t", "\\t", -1)
-			// replace " with \", and if that results in \\", replace that with \\\"
-			str = strings.Replace(str, "\"", "\\\"", -1)
-			return strings.Replace(str, "\\\\\"", "\\\\\\\"", -1)
-		},
 	}).Parse(doc)
 	if err != nil {
 		return doc
@@ -41424,5 +41471,5 @@ func (s *s) ReadDoc() string {
 }
 
 func init() {
-	swag.Register("swagger", &s{})
+	swag.Register(swag.Name, &s{})
 }

+ 61 - 8
docs/swagger.json

@@ -11225,6 +11225,48 @@
                 }
             }
         },
+        "/TaAccount/QueryRelatedTaAccount": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "资金账户"
+                ],
+                "summary": "查询关联资金账户信息",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "关联UserID",
+                        "name": "relateduserid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.RelatedTaAccount"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Tjmd/QueryQuoteGoodsList": {
             "get": {
                 "security": [
@@ -14643,7 +14685,9 @@
                 "code": {
                     "type": "integer"
                 },
-                "data": {},
+                "data": {
+                    "type": "object"
+                },
                 "msg": {
                     "type": "string"
                 },
@@ -17731,31 +17775,31 @@
                     "type": "number"
                 },
                 "diffArbitrageQty": {
-                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
+                    "description": "套利变动量",
                     "type": "number"
                 },
                 "diffExposoureQty": {
-                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
+                    "description": "变动量(套保敞口)",
                     "type": "number"
                 },
                 "diffFutuQty": {
-                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
+                    "description": "变动量(期货总量) 平安:保值净持仓量今日变动",
                     "type": "number"
                 },
                 "diffHedgeQty": {
-                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
+                    "description": "套保变动量",
                     "type": "number"
                 },
                 "diffQty": {
-                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
+                    "description": "变动量(总敞口) 平安:净敞口今日变动",
                     "type": "number"
                 },
                 "diffSpotHedgeQty": {
-                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
+                    "description": "变动量(现货应套保总量) 平安:应套保量今日变动",
                     "type": "number"
                 },
                 "diffSpotQty": {
-                    "description": "期现数量差 = 套保计划量 - 今日期货关联成交量",
+                    "description": "变动量(现货总量) = 现货数量 - 期初现货数量 平安:采销定价净值今日变动",
                     "type": "number"
                 },
                 "enumdicname": {
@@ -32537,6 +32581,15 @@
                 }
             }
         },
+        "models.RelatedTaAccount": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "资金账户ID",
+                    "type": "integer"
+                }
+            }
+        },
         "models.RoleMenu": {
             "type": "object",
             "properties": {

+ 41 - 8
docs/swagger.yaml

@@ -4,7 +4,8 @@ definitions:
     properties:
       code:
         type: integer
-      data: {}
+      data:
+        type: object
       msg:
         type: string
       page:
@@ -2301,25 +2302,25 @@ definitions:
         description: 套利量
         type: number
       diffArbitrageQty:
-        description: 期现数量差 = 套保计划量 - 今日期货关联成交
+        description: 套利变动
         type: number
       diffExposoureQty:
-        description: 期现数量差 = 套保计划量 - 今日期货关联成交量
+        description: 变动量(套保敞口)
         type: number
       diffFutuQty:
-        description: 期现数量差 = 套保计划量 - 今日期货关联成交量
+        description: 变动量(期货总量) 平安:保值净持仓量今日变动
         type: number
       diffHedgeQty:
-        description: 期现数量差 = 套保计划量 - 今日期货关联成交
+        description: 套保变动
         type: number
       diffQty:
-        description: 期现数量差 = 套保计划量 - 今日期货关联成交量
+        description: 变动量(总敞口) 平安:净敞口今日变动
         type: number
       diffSpotHedgeQty:
-        description: 期现数量差 = 套保计划量 - 今日期货关联成交量
+        description: 变动量(现货应套保总量) 平安:应套保量今日变动
         type: number
       diffSpotQty:
-        description: 期现数量差 = 套保计划量 - 今日期货关联成交量
+        description: 变动量(现货总量) = 现货数量 - 期初现货数量 平安:采销定价净值今日变动
         type: number
       enumdicname:
         description: 单位名称
@@ -13348,6 +13349,12 @@ definitions:
         description: 交易模式
         type: integer
     type: object
+  models.RelatedTaAccount:
+    properties:
+      accountid:
+        description: 资金账户ID
+        type: integer
+    type: object
   models.RoleMenu:
     properties:
       hasright:
@@ -27059,6 +27066,32 @@ paths:
       summary: 资金流水查询(历史)
       tags:
       - 资金账户
+  /TaAccount/QueryRelatedTaAccount:
+    get:
+      parameters:
+      - description: 关联UserID
+        in: query
+        name: relateduserid
+        required: true
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.RelatedTaAccount'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询关联资金账户信息
+      tags:
+      - 资金账户
   /Tjmd/QueryQuoteGoodsList:
     get:
       description: 用户类型必传, 查掉期报价列表 marketids=掉期市场id

+ 30 - 0
models/account.go

@@ -1156,3 +1156,33 @@ func GetHedgeOutTaAccount(accountID int) (*Hedgeouttaaccount, error) {
 
 	return &rst, nil
 }
+
+type RelatedTaAccount struct {
+	Accountid int64 `json:"accountid"  xorm:"'ACCOUNTID'"` // 资金账户ID
+
+	Relateduserid int64 `json:"-"  xorm:"'RELATEDUSERID'" form:"relateduserid"` // 关联用户
+}
+
+func (r *RelatedTaAccount) calc() {
+
+}
+
+func (r *RelatedTaAccount) buildSql() string {
+	var sqlId utils.SQLVal = `
+select t.accountid
+  from taaccount t
+ where t.RELATEDUSERID = %v
+`
+	sqlId.FormatParam(r.Relateduserid)
+	return sqlId.String()
+}
+
+// GetDataEx
+func (r *RelatedTaAccount) GetDataEx() (interface{}, error) {
+	sData := make([]RelatedTaAccount, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}

+ 2 - 0
routers/router.go

@@ -104,6 +104,8 @@ func InitRouter() *gin.Engine {
 		taAccountR.GET("/QueryAmountLog", taaccount.QueryAmountLog)
 		// 资金流水查询(历史)
 		taAccountR.GET("/QueryHisAmountLog", taaccount.QueryHisAmountLog)
+		// 获取关联资金账户信息
+		taAccountR.GET("/QueryRelatedTaAccount", taaccount.QueryRelatedTaAccount)
 	}
 	// ************************ 通用服务 ************************
 	commonR := apiR.Group("Common")