浏览代码

增加接口:
/Ferroalloy/QueryTHJinvesotrdeposit
定金比例个性化查询

zhou.xiaoning 2 年之前
父节点
当前提交
04abcfd316

+ 20 - 1
controllers/ferroalloy/trade.go

@@ -70,7 +70,7 @@ func QueryTHJPurchaseTransferOrder(c *gin.Context) {
 // @Security ApiKeyAuth
 // @Param    transferid query    string true "转让单号"
 // @Success  200        {array}  models.ThjpurchasetransferDetail
-// @Failure  500      {object} app.Response
+// @Failure  500          {object} app.Response
 // @Router   /Ferroalloy/QueryTHJPurchaseTransferOrderDetail [get]
 // @Tags     铁合金
 func QueryTHJPurchaseTransferOrderDetail(c *gin.Context) {
@@ -117,3 +117,22 @@ func QueryTHJPromotionIncomeDetail(c *gin.Context) {
 	a.DoBindReq(&m)
 	a.DoGetDataByPage(&m)
 }
+
+// QueryTHJinvesotrdeposit
+// @Summary  定金比例个性化查询
+// @Produce  json
+// @Security ApiKeyAuth
+// @Param    userid       query    int true  "用户ID"
+// @Param    wrstandardid query    int true  "现货商品ID"
+// @Param    page         query    int false "页码"
+// @Param    pagesize     query    int false "每页条数"
+// @Success  200          {array}  models.GThjinvesotrdeposit
+// @Failure  500      {object} app.Response
+// @Router   /Ferroalloy/QueryTHJinvesotrdeposit [get]
+// @Tags     铁合金
+func QueryTHJinvesotrdeposit(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.GThjinvesotrdeposit{}
+	a.DoBindReq(&m)
+	a.DoGetDataByPage(&m)
+}

+ 4 - 4
controllers/guangzuan/tradeService.go

@@ -18,8 +18,8 @@ import (
 // @Security Group
 // @Param    userid   query    int    true  "用户ID"
 // @Param    executestatus query    int false "执行状态 - 1:未生效 2:进行中 3:已结束"
-// @Param    page     query    int    false "页码"
-// @Param    pagesize query    int    false "每页条数"
+// @Param    page          query    int false "页码"
+// @Param    pagesize      query    int false "每页条数"
 // @Success  200           {array}  models.GzcjjcorderM
 // @Failure  500     {object} app.Response
 // @Router   /Guangzuan/QueryGZCJJCOrder [get]
@@ -39,8 +39,8 @@ func QueryGZCJJCOrder(c *gin.Context) {
 // @Security Group
 // @Param    userid        query    int true  "用户ID"
 // @Param    orderid  query    string false "单据ID"
-// @Param    page          query    int false "页码"
-// @Param    pagesize      query    int false "每页条数"
+// @Param    page     query    int    false "页码"
+// @Param    pagesize query    int    false "每页条数"
 // @Success  200      {array}  models.GzcjjcorderdetailM
 // @Failure  500           {object} app.Response
 // @Router   /Guangzuan/QueryGZCJJCOrderDetail [get]

+ 2 - 2
controllers/wrTrade2/qryWrTrade.go

@@ -319,7 +319,7 @@ func QueryWrFactorTypeInfoEx(c *gin.Context) {
 // @Security ApiKeyAuth
 // @Param    marketid query    int false "市场id"
 // @Success  200      {array}  models.WrMarketTradeConfig
-// @Failure 500      {object} app.Response
+// @Failure 500        {object} app.Response
 // @Router   /WrTrade2/QueryWrMarketTradeConfig [get]
 // @Tags     仓单贸易v2
 func QueryWrMarketTradeConfig(c *gin.Context) {
@@ -671,7 +671,7 @@ func QueryWrUserReceiptInfo(c *gin.Context) {
 // @Param   pagesize query    int false "每页条数"
 // @Param   columnid query    int false "所属栏目id"
 // @Success 200      {array}  models.WrSiteColumnDetail
-// @Failure 500        {object} app.Response
+// @Failure 500      {object} app.Response
 // @Router  /WrTrade2/QuerySiteColumnDetail [get]
 // @Tags     仓单贸易v2
 func QuerySiteColumnDetail(c *gin.Context) {

+ 81 - 0
docs/docs.go

@@ -8649,6 +8649,67 @@ const docTemplate = `{
                 }
             }
         },
+        "/Ferroalloy/QueryTHJinvesotrdeposit": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "铁合金"
+                ],
+                "summary": "定金比例个性化查询",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货商品ID",
+                        "name": "wrstandardid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.GThjinvesotrdeposit"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ferroalloy/QueryThjSpotQuoteConfig": {
             "get": {
                 "produces": [
@@ -32674,6 +32735,26 @@ const docTemplate = `{
                 }
             }
         },
+        "models.GThjinvesotrdeposit": {
+            "type": "object",
+            "required": [
+                "userid"
+            ],
+            "properties": {
+                "depositrate": {
+                    "description": "定金比例",
+                    "type": "number"
+                },
+                "qty": {
+                    "description": "可用量",
+                    "type": "integer"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                }
+            }
+        },
         "models.GThjuserscorelog": {
             "type": "object",
             "properties": {

+ 81 - 0
docs/swagger.json

@@ -8640,6 +8640,67 @@
                 }
             }
         },
+        "/Ferroalloy/QueryTHJinvesotrdeposit": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "铁合金"
+                ],
+                "summary": "定金比例个性化查询",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "现货商品ID",
+                        "name": "wrstandardid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.GThjinvesotrdeposit"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ferroalloy/QueryThjSpotQuoteConfig": {
             "get": {
                 "produces": [
@@ -32665,6 +32726,26 @@
                 }
             }
         },
+        "models.GThjinvesotrdeposit": {
+            "type": "object",
+            "required": [
+                "userid"
+            ],
+            "properties": {
+                "depositrate": {
+                    "description": "定金比例",
+                    "type": "number"
+                },
+                "qty": {
+                    "description": "可用量",
+                    "type": "integer"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                }
+            }
+        },
         "models.GThjuserscorelog": {
             "type": "object",
             "properties": {

+ 53 - 0
docs/swagger.yaml

@@ -9834,6 +9834,20 @@ definitions:
         description: 昨价
         type: number
     type: object
+  models.GThjinvesotrdeposit:
+    properties:
+      depositrate:
+        description: 定金比例
+        type: number
+      qty:
+        description: 可用量
+        type: integer
+      userid:
+        description: 用户ID
+        type: integer
+    required:
+    - userid
+    type: object
   models.GThjuserscorelog:
     properties:
       createtime:
@@ -31527,6 +31541,45 @@ paths:
       summary: 查询采购详情
       tags:
       - 铁合金
+  /Ferroalloy/QueryTHJinvesotrdeposit:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      - description: 现货商品ID
+        in: query
+        name: wrstandardid
+        required: true
+        type: integer
+      - description: 页码
+        in: query
+        name: page
+        type: integer
+      - description: 每页条数
+        in: query
+        name: pagesize
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.GThjinvesotrdeposit'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 定金比例个性化查询
+      tags:
+      - 铁合金
   /Ferroalloy/QueryThjSpotQuoteConfig:
     get:
       produces:

+ 48 - 0
models/ferroalloy.go

@@ -2034,3 +2034,51 @@ func (r *THJProfit) GetDataByPage() (interface{}, error, int, int, int) {
 	}
 	return sData, err, r.Page, r.PageSize, total
 }
+
+// 定金比例个性化查询
+type GThjinvesotrdeposit struct {
+	USERID      int64   `json:"userid" xorm:"USERID" form:"userid" binding:"required"` // 用户ID
+	DEPOSITRATE float64 `json:"depositrate" xorm:"DEPOSITRATE"`                        // 定金比例
+	DEPOSITQTY  int64   `json:"-" xorm:"DEPOSITQTY"`                                   // 可用量
+
+	QTY int64 `json:"qty" xorm:"QTY"` // 可用量
+
+	WRSTANDARDID int64 `json:"-" xorm:"-" form:"wrstandardid" binding:"required"` // 现货商品ID
+
+	PageEx `xorm:"extends"` // 页码信息
+}
+
+func (r *GThjinvesotrdeposit) calc() {
+
+}
+
+func (r *GThjinvesotrdeposit) buildSql() string {
+	var sqlId utils.SQLVal = `
+		select 
+			t.DEPOSITRATE, 
+			sum(t.depositqty) QTY 
+		from THJ_InvesotrDeposit t
+		where (
+			t.userid = %v or 
+			t.userid in (select t.refereeuserid from useraccount t where t.userid=%v))
+			AND t.depositrate not in (select distinct t.depositrate from THJ_PresaleApplyDeposit t where t.wrstandardid = %v
+		)
+		group by t.depositrate
+		order by t.depositrate
+	`
+	sqlId.FormatParam(r.USERID, r.USERID, r.WRSTANDARDID)
+
+	sqlId.Page(r.Page, r.PageSize)
+	return sqlId.String()
+}
+
+func (r *GThjinvesotrdeposit) GetDataByPage() (interface{}, error, int, int, int) {
+	sData := make([]GThjinvesotrdeposit, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	total := 0
+	for i := range sData {
+		sData[i].calc()
+		total = sData[i].Total
+	}
+	return sData, err, r.Page, r.PageSize, total
+}

+ 12 - 0
models/ori.go

@@ -313,3 +313,15 @@ type Thjinvestorcheckday struct {
 func (r *Thjinvestorcheckday) TableName() string {
 	return "THJ_INVESTORCHECKDAY"
 }
+
+// Thjinvesotrdeposit 交易商定金比例设置表
+type Thjinvesotrdeposit struct {
+	USERID      int64   `json:"userid" xorm:"USERID"`           // 用户ID
+	DEPOSITRATE float64 `json:"depositrate" xorm:"DEPOSITRATE"` // 定金比例
+	DEPOSITQTY  int64   `json:"depositqty" xorm:"DEPOSITQTY"`   // 可用量
+}
+
+// TableName is THJ_INVESOTRDEPOSIT
+func (r *Thjinvesotrdeposit) TableName() string {
+	return "THJ_INVESOTRDEPOSIT"
+}

+ 1 - 0
routers/router.go

@@ -719,6 +719,7 @@ func InitRouter() *gin.Engine {
 		ferroalloyR.Use(token.Auth()).GET("QueryInvestorLevelGroup", ferroalloy.QueryInvestorLevelGroup)
 		ferroalloyR.Use(token.Auth()).GET("QueryTHJFriends", ferroalloy.QueryTHJFriends)
 		ferroalloyR.Use(token.Auth()).GET("QueryTHJProfits", ferroalloy.QueryTHJProfits)
+		ferroalloyR.Use(token.Auth()).GET("QueryTHJinvesotrdeposit", ferroalloy.QueryTHJinvesotrdeposit)
 	}
 
 	return r