Forráskód Böngészése

/Digital/QueryTaaccountDigitals:获取用户现货账户列表

deng.yinping 2 hónapja
szülő
commit
a35253f84b
6 módosított fájl, 548 hozzáadás és 0 törlés
  1. 27 0
      controllers/digital/queryDigital.go
  2. 157 0
      docs/docs.go
  3. 157 0
      docs/swagger.json
  4. 110 0
      docs/swagger.yaml
  5. 89 0
      models/taaccountdigital.go
  6. 8 0
      routers/router.go

+ 27 - 0
controllers/digital/queryDigital.go

@@ -0,0 +1,27 @@
+package digital
+
+import (
+	"mtp2_if/global/app"
+	"mtp2_if/models"
+
+	"github.com/gin-gonic/gin"
+)
+
+// QueryTaaccountDigitals
+// @Summary 获取用户现货账户列表
+// @Produce  json
+// @accept   application/json
+// @Security ApiKeyAuth
+// @Param   userid 				query    int true 	"用户ID"
+// @Param   currencyid 			query    int false 	"币种ID"
+// @Param   digitalaccountid 	query    string false 	"数字账户ID"
+// @Success 200    {array}  models.Taaccountdigital
+// @Failure 500    {object} app.Response
+// @Router  /Digital/QueryTaaccountDigitals [post]
+// @Tags    数字现货账户
+func QueryTaaccountDigitals(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.Taaccountdigital{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}

+ 157 - 0
docs/docs.go

@@ -2435,6 +2435,63 @@ const docTemplate = `{
                 }
             }
         },
+        "/Digital/QueryTaaccountDigitals": {
+            "post": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "consumes": [
+                    "application/json"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "数字现货账户"
+                ],
+                "summary": "获取用户现货账户列表",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "币种ID",
+                        "name": "currencyid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "数字账户ID",
+                        "name": "digitalaccountid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Taaccountdigital"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp/GetErmcpGoods": {
             "get": {
                 "security": [
@@ -56876,6 +56933,106 @@ const docTemplate = `{
                 }
             }
         },
+        "models.Taaccountdigital": {
+            "type": "object",
+            "required": [
+                "userid"
+            ],
+            "properties": {
+                "currencycode": {
+                    "description": "币种代码",
+                    "type": "string"
+                },
+                "currencydecimalplace": {
+                    "description": "币种小数位(param1)",
+                    "type": "integer"
+                },
+                "currencydisplayunit": {
+                    "description": "币种显示单位(param2)",
+                    "type": "string"
+                },
+                "currencyid": {
+                    "description": "货币ID - 枚举\"digitalcurrency\"",
+                    "type": "integer"
+                },
+                "currentbalance": {
+                    "description": "期末余额",
+                    "type": "number"
+                },
+                "digitalaccountid": {
+                    "description": "资金账户ID(userid + currencyid[3位,前面补0])",
+                    "type": "string"
+                },
+                "freezeinout": {
+                    "description": "充值提现冻结 - 正",
+                    "type": "number"
+                },
+                "freezemargin": {
+                    "description": "冻结保证金(交易) - 正",
+                    "type": "number"
+                },
+                "freezetradecharge": {
+                    "description": "交易手续费冻结 - 正",
+                    "type": "number"
+                },
+                "freezetransfer": {
+                    "description": "转入转出冻结 - 正",
+                    "type": "number"
+                },
+                "totalin": {
+                    "description": "累计充值(现货账户与外部钱包) - 正",
+                    "type": "number"
+                },
+                "totalinincharge": {
+                    "description": "累计充值手续费 - 负",
+                    "type": "number"
+                },
+                "totalinoutcharge": {
+                    "description": "累计提现手续费 - 负",
+                    "type": "number"
+                },
+                "totalout": {
+                    "description": "累计提现(现货账户与外部钱包) - 负",
+                    "type": "number"
+                },
+                "totaltradeadd": {
+                    "description": "累计交易增加 - 正",
+                    "type": "number"
+                },
+                "totaltradecharge": {
+                    "description": "累计交易手续费 - 负",
+                    "type": "number"
+                },
+                "totaltradereduce": {
+                    "description": "累计交易减少 - 负",
+                    "type": "number"
+                },
+                "totaltransferin": {
+                    "description": "累计转入(合约与现货账户) - 正",
+                    "type": "number"
+                },
+                "totaltransferincharge": {
+                    "description": "累计转入手续费 - 负 - 预留",
+                    "type": "number"
+                },
+                "totaltransferout": {
+                    "description": "累计转出(合约与现货账户) - 负",
+                    "type": "number"
+                },
+                "totaltransferoutcharge": {
+                    "description": "累计转出手续费 - 负 - 预留",
+                    "type": "number"
+                },
+                "usedmargin": {
+                    "description": "占用保证金(交易) - 正 - 预留",
+                    "type": "number"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                }
+            }
+        },
         "models.Tablecolumnconfig": {
             "type": "object",
             "required": [

+ 157 - 0
docs/swagger.json

@@ -2427,6 +2427,63 @@
                 }
             }
         },
+        "/Digital/QueryTaaccountDigitals": {
+            "post": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "consumes": [
+                    "application/json"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "数字现货账户"
+                ],
+                "summary": "获取用户现货账户列表",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "币种ID",
+                        "name": "currencyid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "数字账户ID",
+                        "name": "digitalaccountid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.Taaccountdigital"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp/GetErmcpGoods": {
             "get": {
                 "security": [
@@ -56868,6 +56925,106 @@
                 }
             }
         },
+        "models.Taaccountdigital": {
+            "type": "object",
+            "required": [
+                "userid"
+            ],
+            "properties": {
+                "currencycode": {
+                    "description": "币种代码",
+                    "type": "string"
+                },
+                "currencydecimalplace": {
+                    "description": "币种小数位(param1)",
+                    "type": "integer"
+                },
+                "currencydisplayunit": {
+                    "description": "币种显示单位(param2)",
+                    "type": "string"
+                },
+                "currencyid": {
+                    "description": "货币ID - 枚举\"digitalcurrency\"",
+                    "type": "integer"
+                },
+                "currentbalance": {
+                    "description": "期末余额",
+                    "type": "number"
+                },
+                "digitalaccountid": {
+                    "description": "资金账户ID(userid + currencyid[3位,前面补0])",
+                    "type": "string"
+                },
+                "freezeinout": {
+                    "description": "充值提现冻结 - 正",
+                    "type": "number"
+                },
+                "freezemargin": {
+                    "description": "冻结保证金(交易) - 正",
+                    "type": "number"
+                },
+                "freezetradecharge": {
+                    "description": "交易手续费冻结 - 正",
+                    "type": "number"
+                },
+                "freezetransfer": {
+                    "description": "转入转出冻结 - 正",
+                    "type": "number"
+                },
+                "totalin": {
+                    "description": "累计充值(现货账户与外部钱包) - 正",
+                    "type": "number"
+                },
+                "totalinincharge": {
+                    "description": "累计充值手续费 - 负",
+                    "type": "number"
+                },
+                "totalinoutcharge": {
+                    "description": "累计提现手续费 - 负",
+                    "type": "number"
+                },
+                "totalout": {
+                    "description": "累计提现(现货账户与外部钱包) - 负",
+                    "type": "number"
+                },
+                "totaltradeadd": {
+                    "description": "累计交易增加 - 正",
+                    "type": "number"
+                },
+                "totaltradecharge": {
+                    "description": "累计交易手续费 - 负",
+                    "type": "number"
+                },
+                "totaltradereduce": {
+                    "description": "累计交易减少 - 负",
+                    "type": "number"
+                },
+                "totaltransferin": {
+                    "description": "累计转入(合约与现货账户) - 正",
+                    "type": "number"
+                },
+                "totaltransferincharge": {
+                    "description": "累计转入手续费 - 负 - 预留",
+                    "type": "number"
+                },
+                "totaltransferout": {
+                    "description": "累计转出(合约与现货账户) - 负",
+                    "type": "number"
+                },
+                "totaltransferoutcharge": {
+                    "description": "累计转出手续费 - 负 - 预留",
+                    "type": "number"
+                },
+                "usedmargin": {
+                    "description": "占用保证金(交易) - 正 - 预留",
+                    "type": "number"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                }
+            }
+        },
         "models.Tablecolumnconfig": {
             "type": "object",
             "required": [

+ 110 - 0
docs/swagger.yaml

@@ -24165,6 +24165,80 @@ definitions:
     - accountid
     - userid
     type: object
+  models.Taaccountdigital:
+    properties:
+      currencycode:
+        description: 币种代码
+        type: string
+      currencydecimalplace:
+        description: 币种小数位(param1)
+        type: integer
+      currencydisplayunit:
+        description: 币种显示单位(param2)
+        type: string
+      currencyid:
+        description: 货币ID - 枚举"digitalcurrency"
+        type: integer
+      currentbalance:
+        description: 期末余额
+        type: number
+      digitalaccountid:
+        description: 资金账户ID(userid + currencyid[3位,前面补0])
+        type: string
+      freezeinout:
+        description: 充值提现冻结 - 正
+        type: number
+      freezemargin:
+        description: 冻结保证金(交易) - 正
+        type: number
+      freezetradecharge:
+        description: 交易手续费冻结 - 正
+        type: number
+      freezetransfer:
+        description: 转入转出冻结 - 正
+        type: number
+      totalin:
+        description: 累计充值(现货账户与外部钱包) - 正
+        type: number
+      totalinincharge:
+        description: 累计充值手续费 - 负
+        type: number
+      totalinoutcharge:
+        description: 累计提现手续费 - 负
+        type: number
+      totalout:
+        description: 累计提现(现货账户与外部钱包) - 负
+        type: number
+      totaltradeadd:
+        description: 累计交易增加 - 正
+        type: number
+      totaltradecharge:
+        description: 累计交易手续费 - 负
+        type: number
+      totaltradereduce:
+        description: 累计交易减少 - 负
+        type: number
+      totaltransferin:
+        description: 累计转入(合约与现货账户) - 正
+        type: number
+      totaltransferincharge:
+        description: 累计转入手续费 - 负 - 预留
+        type: number
+      totaltransferout:
+        description: 累计转出(合约与现货账户) - 负
+        type: number
+      totaltransferoutcharge:
+        description: 累计转出手续费 - 负 - 预留
+        type: number
+      usedmargin:
+        description: 占用保证金(交易) - 正 - 预留
+        type: number
+      userid:
+        description: 用户ID
+        type: integer
+    required:
+    - userid
+    type: object
   models.Tablecolumnconfig:
     properties:
       aligntype:
@@ -33991,6 +34065,42 @@ paths:
       summary: 查询商品交割关系表
       tags:
       - 交割服务
+  /Digital/QueryTaaccountDigitals:
+    post:
+      consumes:
+      - application/json
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      - description: 币种ID
+        in: query
+        name: currencyid
+        type: integer
+      - description: 数字账户ID
+        in: query
+        name: digitalaccountid
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.Taaccountdigital'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 获取用户现货账户列表
+      tags:
+      - 数字现货账户
   /Ermcp/GetErmcpGoods:
     get:
       parameters:

+ 89 - 0
models/taaccountdigital.go

@@ -0,0 +1,89 @@
+package models
+
+import (
+	"mtp2_if/db"
+	"mtp2_if/utils"
+	"strings"
+)
+
+// Taaccountdigital  数字账户表
+type Taaccountdigital struct {
+	DIGITALACCOUNTID       string  `json:"digitalaccountid" xorm:"DIGITALACCOUNTID" form:"digitalaccountid"` // 资金账户ID(userid + currencyid[3位,前面补0])
+	CURRENCYID             uint32  `json:"currencyid" xorm:"CURRENCYID" form:"currencyid"`                   // 货币ID - 枚举"digitalcurrency"
+	USERID                 uint64  `json:"userid" xorm:"USERID" form:"userid" binding:"required"`            // 用户ID
+	CURRENTBALANCE         float64 `json:"currentbalance" xorm:"CURRENTBALANCE"`                             // 期末余额
+	USEDMARGIN             float64 `json:"usedmargin" xorm:"USEDMARGIN"`                                     // 占用保证金(交易) - 正 - 预留
+	FREEZEMARGIN           float64 `json:"freezemargin" xorm:"FREEZEMARGIN"`                                 // 冻结保证金(交易) - 正
+	FREEZETRADECHARGE      float64 `json:"freezetradecharge" xorm:"FREEZETRADECHARGE"`                       // 交易手续费冻结 - 正
+	FREEZETRANSFER         float64 `json:"freezetransfer" xorm:"FREEZETRANSFER"`                             // 转入转出冻结 - 正
+	FREEZEINOUT            float64 `json:"freezeinout" xorm:"FREEZEINOUT"`                                   // 充值提现冻结 - 正
+	TOTALTRADEADD          float64 `json:"totaltradeadd" xorm:"TOTALTRADEADD"`                               // 累计交易增加 - 正
+	TOTALTRADEREDUCE       float64 `json:"totaltradereduce" xorm:"TOTALTRADEREDUCE"`                         // 累计交易减少 - 负
+	TOTALTRADECHARGE       float64 `json:"totaltradecharge" xorm:"TOTALTRADECHARGE"`                         // 累计交易手续费 - 负
+	TOTALTRANSFERIN        float64 `json:"totaltransferin" xorm:"TOTALTRANSFERIN"`                           // 累计转入(合约与现货账户) - 正
+	TOTALTRANSFEROUT       float64 `json:"totaltransferout" xorm:"TOTALTRANSFEROUT"`                         // 累计转出(合约与现货账户) - 负
+	TOTALTRANSFERINCHARGE  float64 `json:"totaltransferincharge" xorm:"TOTALTRANSFERINCHARGE"`               // 累计转入手续费 - 负 - 预留
+	TOTALTRANSFEROUTCHARGE float64 `json:"totaltransferoutcharge" xorm:"TOTALTRANSFEROUTCHARGE"`             // 累计转出手续费 - 负 - 预留
+	TOTALIN                float64 `json:"totalin" xorm:"TOTALIN"`                                           // 累计充值(现货账户与外部钱包) - 正
+	TOTALOUT               float64 `json:"totalout" xorm:"TOTALOUT"`                                         // 累计提现(现货账户与外部钱包) - 负
+	TOTALININCHARGE        float64 `json:"totalinincharge" xorm:"TOTALININCHARGE"`                           // 累计充值手续费 - 负
+	TOTALINOUTCHARGE       float64 `json:"totalinoutcharge" xorm:"TOTALINOUTCHARGE"`                         // 累计提现手续费 - 负
+
+	CURRENCYCODE         string `json:"currencycode" xorm:"CURRENCYCODE"`                 // 币种代码
+	CURRENCYDECIMALPLACE uint32 `json:"currencydecimalplace" xorm:"CURRENCYDECIMALPLACE"` // 币种小数位(param1)
+	CURRENCYDISPLAYUNIT  string `json:"currencydisplayunit" xorm:"CURRENCYDISPLAYUNIT"`   // 币种显示单位(param2)
+}
+
+func (r *Taaccountdigital) calc() {
+
+}
+
+func (r *Taaccountdigital) buildSql() string {
+	var sqlId utils.SQLVal = `
+	   SELECT A.ENUMITEMVALUE CURRENCYCODE, A.PARAM1 CURRENCYDECIMALPLACE, A.PARAM2 CURRENCYDISPLAYUNIT, 
+       TO_CHAR(NVL(TA.DIGITALACCOUNTID, '')) DIGITALACCOUNTID,
+       CASE 
+         WHEN TA.CURRENCYID IS NULL THEN A.ENUMITEMNAME
+           ELSE TA.CURRENCYID
+             END CURRENCYID,
+       CASE 
+         WHEN TA.USERID IS NULL THEN %v
+           ELSE TA.USERID
+             END USERID,
+       NVL(TA.CURRENTBALANCE, 0) CURRENTBALANCE,
+       NVL(TA.USEDMARGIN, 0) USEDMARGIN,
+       NVL(TA.FREEZEMARGIN, 0) FREEZEMARGIN,
+       NVL(TA.FREEZETRADECHARGE, 0) FREEZETRADECHARGE,
+       NVL(TA.FREEZETRANSFER, 0) FREEZETRANSFER,
+       NVL(TA.FREEZEINOUT, 0) FREEZEINOUT,
+       NVL(TA.TOTALTRADEADD, 0) TOTALTRADEADD,
+       NVL(TA.TOTALTRADEREDUCE, 0) TOTALTRADEREDUCE,
+       NVL(TA.TOTALTRADECHARGE, 0) TOTALTRADECHARGE,
+       NVL(TA.TOTALTRANSFERIN, 0) TOTALTRANSFERIN,
+       NVL(TA.TOTALTRANSFEROUT, 0) TOTALTRANSFEROUT,
+       NVL(TA.TOTALTRANSFERINCHARGE, 0) TOTALTRANSFERINCHARGE,
+       NVL(TA.TOTALTRANSFEROUTCHARGE, 0) TOTALTRANSFEROUTCHARGE,
+       NVL(TA.TOTALIN, 0) TOTALIN,
+       NVL(TA.TOTALOUT, 0) TOTALOUT,
+       NVL(TA.TOTALININCHARGE, 0) TOTALININCHARGE,
+       NVL(TA.TOTALINOUTCHARGE, 0) TOTALINOUTCHARGE
+	   FROM (SELECT E.* FROM ENUMDICITEM E WHERE E.ENUMDICCODE = 'digitalcurrency') A
+	   LEFT JOIN (SELECT T.* FROM TAACCOUNTDIGITAL T WHERE T.USERID = %v) TA ON A.ENUMITEMNAME = TA.CURRENCYID
+	   where 1=1
+		`
+	sqlId.AndEx("A.ENUMITEMNAME", r.CURRENCYID, r.CURRENCYID > 0)
+	sqlId.AndEx("TA.DIGITALACCOUNTID", r.DIGITALACCOUNTID, strings.TrimSpace(r.DIGITALACCOUNTID) != "")
+	sqlId.FormatParam(r.USERID, r.USERID)
+	sqlId.Join(" ORDER BY NVL(TA.CURRENTBALANCE, 0) DESC, A.ENUMITEMNAME")
+	return sqlId.String()
+}
+
+// GetDataEx 从数据库中查询数据
+func (r *Taaccountdigital) GetDataEx() (interface{}, error) {
+	sData := make([]Taaccountdigital, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}

+ 8 - 0
routers/router.go

@@ -8,6 +8,7 @@ import (
 	"mtp2_if/controllers/common"
 	"mtp2_if/controllers/cptrade"
 	"mtp2_if/controllers/delivery"
+	"mtp2_if/controllers/digital"
 	"mtp2_if/controllers/ermcp"
 	"mtp2_if/controllers/ermcp3"
 	"mtp2_if/controllers/ermcp8"
@@ -929,6 +930,13 @@ func InitRouter() *gin.Engine {
 		asignR.Use(token.Auth()).POST("WillFace", asign.WillFace)
 	}
 
+	// ************************* 数字现货账户 *************************
+	digitalR := apiR.Group("Digital")
+	digitalR.Use()
+	{
+		digitalR.Use(token.Auth()).POST("QueryTaaccountDigitals", digital.QueryTaaccountDigitals)
+	}
+
 	return r
 }