Quellcode durchsuchen

1.增加查询仓单融资合同接口

zou.yingbin vor 4 Jahren
Ursprung
Commit
04d59d6fc1
6 geänderte Dateien mit 860 neuen und 9 gelöschten Zeilen
  1. 17 0
      controllers/wrTrade2/qryWrTrade.go
  2. 257 0
      docs/docs.go
  3. 257 0
      docs/swagger.json
  4. 187 0
      docs/swagger.yaml
  5. 141 9
      models/wrTrade2.go
  6. 1 0
      routers/router.go

+ 17 - 0
controllers/wrTrade2/qryWrTrade.go

@@ -344,3 +344,20 @@ func QueryWrFinanceBuyApply(c *gin.Context) {
 	a.DoBindReq(&m)
 	a.DoGetDataI(&m)
 }
+
+// QueryWrScfContract
+// @Summary 查询仓单贸易融资合同
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户id"
+// @Param scfcontractid query int false "融资合同id"
+// @Success 200 {array} models.WrScfContract
+// @Failure 500 {object} app.Response
+// @Router /WrTrade2/QueryWrScfContract [get]
+// @Tags 仓单贸易v2
+func QueryWrScfContract(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	m := models.WrScfContract{}
+	a.DoBindReq(&m)
+	a.DoGetDataI(&m)
+}

+ 257 - 0
docs/docs.go

@@ -11754,6 +11754,54 @@ var doc = `{
                 }
             }
         },
+        "/WrTrade2/QueryWrScfContract": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易v2"
+                ],
+                "summary": "查询仓单贸易融资合同",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户id",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "融资合同id",
+                        "name": "scfcontractid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.WrScfContract"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WrTrade2/QueryWrSpecialMatchOrder": {
             "get": {
                 "security": [
@@ -30075,6 +30123,10 @@ var doc = `{
                     "description": "金融产品ID",
                     "type": "integer"
                 },
+                "productname": {
+                    "description": "产品名称",
+                    "type": "string"
+                },
                 "remark": {
                     "description": "备注",
                     "type": "string"
@@ -31333,6 +31385,211 @@ var doc = `{
                 }
             }
         },
+        "models.WrScfContract": {
+            "type": "object",
+            "properties": {
+                "borroweruserid": {
+                    "description": "借款用户ID",
+                    "type": "integer"
+                },
+                "buybackwrpositionqty": {
+                    "description": "已回购仓单头寸数量 - [仓单回购\\仓单质押] -\u003e 已回购数量",
+                    "type": "number"
+                },
+                "closeinterest": {
+                    "description": "已结利息 -\u003e 已结费用",
+                    "type": "number"
+                },
+                "currisklevel": {
+                    "description": "风险级别 - 1:正常 2:追加货款 3:支付尾款",
+                    "type": "integer"
+                },
+                "deadline": {
+                    "description": "截止日期(yyyyMMdd) -\u003e 借款到期时间",
+                    "type": "string"
+                },
+                "deliverygoodscode": {
+                    "description": "品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "品种ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "品种名称",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
+                "financingdays": {
+                    "description": "天数(天)",
+                    "type": "integer"
+                },
+                "initmargin": {
+                    "description": "保证金 - [仓单回购]",
+                    "type": "number"
+                },
+                "interestamount": {
+                    "description": "计息金额=合同剩余金额 - 初始保证金 - 追缴保证金 \\  合同剩余金额",
+                    "type": "number"
+                },
+                "interestdebt": {
+                    "description": "利息欠款(记录负数) -\u003e 费用欠款",
+                    "type": "number"
+                },
+                "interestminlen": {
+                    "description": "最小起息天数",
+                    "type": "integer"
+                },
+                "interestrate": {
+                    "description": "利率",
+                    "type": "number"
+                },
+                "interestratemode": {
+                    "description": "利率方式 - 1:年利率 2:日利率 3:日固定值",
+                    "type": "integer"
+                },
+                "interestsettlemode": {
+                    "description": "结息方式 - 1:按日结息  3:按月结息",
+                    "type": "integer"
+                },
+                "interestsettlevalue": {
+                    "description": "结息方式值",
+                    "type": "integer"
+                },
+                "isautoloan": {
+                    "description": "是否自动放款 - 0:手动 1:自动 - [仓单质押]",
+                    "type": "integer"
+                },
+                "lastcloseinterestday": {
+                    "description": "最近结息日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "lenderamount": {
+                    "description": "贷款金额 -\u003e 借款金额",
+                    "type": "number"
+                },
+                "lenderuserid": {
+                    "description": "贷款方用户ID -\u003e 融出方用户ID",
+                    "type": "integer"
+                },
+                "lenderusername": {
+                    "description": "融出方",
+                    "type": "string"
+                },
+                "marginratio": {
+                    "description": "保证金比率质押率 - [仓单质押]",
+                    "type": "number"
+                },
+                "marketid": {
+                    "description": "市场ID - 拆成三个独立模式后,根据市场ID处理",
+                    "type": "integer"
+                },
+                "minivalue": {
+                    "description": "现货商品最小变动值",
+                    "type": "integer"
+                },
+                "optioncompare": {
+                    "description": "选择项比较串【{选择项ID}+{冒号}+选择项值 } ,逗号分隔,头尾加逗号】-- 所有选择项拼接,用于比较",
+                    "type": "string"
+                },
+                "pricemove": {
+                    "description": "估值升贴水值",
+                    "type": "number"
+                },
+                "productdetailid": {
+                    "description": "产品组合ID",
+                    "type": "integer"
+                },
+                "productid": {
+                    "description": "金融产品ID",
+                    "type": "integer"
+                },
+                "productname": {
+                    "description": "产品名称",
+                    "type": "string"
+                },
+                "remainamount": {
+                    "description": "合同剩余金额 -\u003e 剩余金额",
+                    "type": "number"
+                },
+                "remainwrpositionqty": {
+                    "description": "剩余仓单头寸数量 - [仓单回购\\仓单质押] -\u003e 剩余数量",
+                    "type": "number"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
+                "scfcontractid": {
+                    "description": "SCF合同ID(310+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "scfcontractstatus": {
+                    "description": "合同状态 - 1:待确认 2:已确认 3:确认拒绝 4:已支付保证金 5:已激活 6:已违约 7:到期结束 8:延期结束 9:违约结束 10:已注销 11:已关闭 99:未提交",
+                    "type": "integer"
+                },
+                "scfcontracttype": {
+                    "description": "合同类型 - 1:仓单回购 2:仓单质押 3:合作套保 4:资金贷款 5:融资单 6:融资回购",
+                    "type": "integer"
+                },
+                "startinterestday": {
+                    "description": "计息开始日(yyyyMMdd)  -\u003e 开始计费日期",
+                    "type": "string"
+                },
+                "totalinterest": {
+                    "description": "已计利息 -\u003e 已计费用",
+                    "type": "number"
+                },
+                "unpaidinterest": {
+                    "description": "未结费用",
+                    "type": "number"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "warehouseid": {
+                    "description": "仓库ID",
+                    "type": "integer"
+                },
+                "warehousename": {
+                    "description": "仓库名称",
+                    "type": "string"
+                },
+                "wrfactortypeid": {
+                    "description": "仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "wrfactortypename": {
+                    "description": "仓单要素类型名称(选择项要素的名称合并显示,逗号分隔)",
+                    "type": "string"
+                },
+                "wrqty": {
+                    "description": "仓单数量 - [仓单回购\\仓单质押] -\u003e 数量",
+                    "type": "number"
+                },
+                "wrstandardcode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "商品名称",
+                    "type": "string"
+                },
+                "wrtypename": {
+                    "description": "商品",
+                    "type": "string"
+                }
+            }
+        },
         "models.WrSpecialMatchOrder": {
             "type": "object",
             "properties": {

+ 257 - 0
docs/swagger.json

@@ -11738,6 +11738,54 @@
                 }
             }
         },
+        "/WrTrade2/QueryWrScfContract": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "仓单贸易v2"
+                ],
+                "summary": "查询仓单贸易融资合同",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户id",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "融资合同id",
+                        "name": "scfcontractid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.WrScfContract"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WrTrade2/QueryWrSpecialMatchOrder": {
             "get": {
                 "security": [
@@ -30059,6 +30107,10 @@
                     "description": "金融产品ID",
                     "type": "integer"
                 },
+                "productname": {
+                    "description": "产品名称",
+                    "type": "string"
+                },
                 "remark": {
                     "description": "备注",
                     "type": "string"
@@ -31317,6 +31369,211 @@
                 }
             }
         },
+        "models.WrScfContract": {
+            "type": "object",
+            "properties": {
+                "borroweruserid": {
+                    "description": "借款用户ID",
+                    "type": "integer"
+                },
+                "buybackwrpositionqty": {
+                    "description": "已回购仓单头寸数量 - [仓单回购\\仓单质押] -\u003e 已回购数量",
+                    "type": "number"
+                },
+                "closeinterest": {
+                    "description": "已结利息 -\u003e 已结费用",
+                    "type": "number"
+                },
+                "currisklevel": {
+                    "description": "风险级别 - 1:正常 2:追加货款 3:支付尾款",
+                    "type": "integer"
+                },
+                "deadline": {
+                    "description": "截止日期(yyyyMMdd) -\u003e 借款到期时间",
+                    "type": "string"
+                },
+                "deliverygoodscode": {
+                    "description": "品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "品种ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "品种名称",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
+                "financingdays": {
+                    "description": "天数(天)",
+                    "type": "integer"
+                },
+                "initmargin": {
+                    "description": "保证金 - [仓单回购]",
+                    "type": "number"
+                },
+                "interestamount": {
+                    "description": "计息金额=合同剩余金额 - 初始保证金 - 追缴保证金 \\  合同剩余金额",
+                    "type": "number"
+                },
+                "interestdebt": {
+                    "description": "利息欠款(记录负数) -\u003e 费用欠款",
+                    "type": "number"
+                },
+                "interestminlen": {
+                    "description": "最小起息天数",
+                    "type": "integer"
+                },
+                "interestrate": {
+                    "description": "利率",
+                    "type": "number"
+                },
+                "interestratemode": {
+                    "description": "利率方式 - 1:年利率 2:日利率 3:日固定值",
+                    "type": "integer"
+                },
+                "interestsettlemode": {
+                    "description": "结息方式 - 1:按日结息  3:按月结息",
+                    "type": "integer"
+                },
+                "interestsettlevalue": {
+                    "description": "结息方式值",
+                    "type": "integer"
+                },
+                "isautoloan": {
+                    "description": "是否自动放款 - 0:手动 1:自动 - [仓单质押]",
+                    "type": "integer"
+                },
+                "lastcloseinterestday": {
+                    "description": "最近结息日(yyyyMMdd)",
+                    "type": "string"
+                },
+                "lenderamount": {
+                    "description": "贷款金额 -\u003e 借款金额",
+                    "type": "number"
+                },
+                "lenderuserid": {
+                    "description": "贷款方用户ID -\u003e 融出方用户ID",
+                    "type": "integer"
+                },
+                "lenderusername": {
+                    "description": "融出方",
+                    "type": "string"
+                },
+                "marginratio": {
+                    "description": "保证金比率质押率 - [仓单质押]",
+                    "type": "number"
+                },
+                "marketid": {
+                    "description": "市场ID - 拆成三个独立模式后,根据市场ID处理",
+                    "type": "integer"
+                },
+                "minivalue": {
+                    "description": "现货商品最小变动值",
+                    "type": "integer"
+                },
+                "optioncompare": {
+                    "description": "选择项比较串【{选择项ID}+{冒号}+选择项值 } ,逗号分隔,头尾加逗号】-- 所有选择项拼接,用于比较",
+                    "type": "string"
+                },
+                "pricemove": {
+                    "description": "估值升贴水值",
+                    "type": "number"
+                },
+                "productdetailid": {
+                    "description": "产品组合ID",
+                    "type": "integer"
+                },
+                "productid": {
+                    "description": "金融产品ID",
+                    "type": "integer"
+                },
+                "productname": {
+                    "description": "产品名称",
+                    "type": "string"
+                },
+                "remainamount": {
+                    "description": "合同剩余金额 -\u003e 剩余金额",
+                    "type": "number"
+                },
+                "remainwrpositionqty": {
+                    "description": "剩余仓单头寸数量 - [仓单回购\\仓单质押] -\u003e 剩余数量",
+                    "type": "number"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
+                "scfcontractid": {
+                    "description": "SCF合同ID(310+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "scfcontractstatus": {
+                    "description": "合同状态 - 1:待确认 2:已确认 3:确认拒绝 4:已支付保证金 5:已激活 6:已违约 7:到期结束 8:延期结束 9:违约结束 10:已注销 11:已关闭 99:未提交",
+                    "type": "integer"
+                },
+                "scfcontracttype": {
+                    "description": "合同类型 - 1:仓单回购 2:仓单质押 3:合作套保 4:资金贷款 5:融资单 6:融资回购",
+                    "type": "integer"
+                },
+                "startinterestday": {
+                    "description": "计息开始日(yyyyMMdd)  -\u003e 开始计费日期",
+                    "type": "string"
+                },
+                "totalinterest": {
+                    "description": "已计利息 -\u003e 已计费用",
+                    "type": "number"
+                },
+                "unpaidinterest": {
+                    "description": "未结费用",
+                    "type": "number"
+                },
+                "updatetime": {
+                    "description": "更新时间",
+                    "type": "string"
+                },
+                "warehouseid": {
+                    "description": "仓库ID",
+                    "type": "integer"
+                },
+                "warehousename": {
+                    "description": "仓库名称",
+                    "type": "string"
+                },
+                "wrfactortypeid": {
+                    "description": "仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "wrfactortypename": {
+                    "description": "仓单要素类型名称(选择项要素的名称合并显示,逗号分隔)",
+                    "type": "string"
+                },
+                "wrqty": {
+                    "description": "仓单数量 - [仓单回购\\仓单质押] -\u003e 数量",
+                    "type": "number"
+                },
+                "wrstandardcode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "商品名称",
+                    "type": "string"
+                },
+                "wrtypename": {
+                    "description": "商品",
+                    "type": "string"
+                }
+            }
+        },
         "models.WrSpecialMatchOrder": {
             "type": "object",
             "properties": {

+ 187 - 0
docs/swagger.yaml

@@ -13522,6 +13522,9 @@ definitions:
       productid:
         description: 金融产品ID
         type: integer
+      productname:
+        description: 产品名称
+        type: string
       remark:
         description: 备注
         type: string
@@ -14466,6 +14469,160 @@ definitions:
         description: 持有人ID
         type: integer
     type: object
+  models.WrScfContract:
+    properties:
+      borroweruserid:
+        description: 借款用户ID
+        type: integer
+      buybackwrpositionqty:
+        description: 已回购仓单头寸数量 - [仓单回购\仓单质押] -> 已回购数量
+        type: number
+      closeinterest:
+        description: 已结利息 -> 已结费用
+        type: number
+      currisklevel:
+        description: 风险级别 - 1:正常 2:追加货款 3:支付尾款
+        type: integer
+      deadline:
+        description: 截止日期(yyyyMMdd) -> 借款到期时间
+        type: string
+      deliverygoodscode:
+        description: 品种代码
+        type: string
+      deliverygoodsid:
+        description: 品种ID
+        type: integer
+      deliverygoodsname:
+        description: 品种名称
+        type: string
+      enumdicname:
+        description: 单位名称
+        type: string
+      financingdays:
+        description: 天数(天)
+        type: integer
+      initmargin:
+        description: 保证金 - [仓单回购]
+        type: number
+      interestamount:
+        description: 计息金额=合同剩余金额 - 初始保证金 - 追缴保证金 \  合同剩余金额
+        type: number
+      interestdebt:
+        description: 利息欠款(记录负数) -> 费用欠款
+        type: number
+      interestminlen:
+        description: 最小起息天数
+        type: integer
+      interestrate:
+        description: 利率
+        type: number
+      interestratemode:
+        description: 利率方式 - 1:年利率 2:日利率 3:日固定值
+        type: integer
+      interestsettlemode:
+        description: 结息方式 - 1:按日结息  3:按月结息
+        type: integer
+      interestsettlevalue:
+        description: 结息方式值
+        type: integer
+      isautoloan:
+        description: 是否自动放款 - 0:手动 1:自动 - [仓单质押]
+        type: integer
+      lastcloseinterestday:
+        description: 最近结息日(yyyyMMdd)
+        type: string
+      lenderamount:
+        description: 贷款金额 -> 借款金额
+        type: number
+      lenderuserid:
+        description: 贷款方用户ID -> 融出方用户ID
+        type: integer
+      lenderusername:
+        description: 融出方
+        type: string
+      marginratio:
+        description: 保证金比率质押率 - [仓单质押]
+        type: number
+      marketid:
+        description: 市场ID - 拆成三个独立模式后,根据市场ID处理
+        type: integer
+      minivalue:
+        description: 现货商品最小变动值
+        type: integer
+      optioncompare:
+        description: 选择项比较串【{选择项ID}+{冒号}+选择项值 } ,逗号分隔,头尾加逗号】-- 所有选择项拼接,用于比较
+        type: string
+      pricemove:
+        description: 估值升贴水值
+        type: number
+      productdetailid:
+        description: 产品组合ID
+        type: integer
+      productid:
+        description: 金融产品ID
+        type: integer
+      productname:
+        description: 产品名称
+        type: string
+      remainamount:
+        description: 合同剩余金额 -> 剩余金额
+        type: number
+      remainwrpositionqty:
+        description: 剩余仓单头寸数量 - [仓单回购\仓单质押] -> 剩余数量
+        type: number
+      remark:
+        description: 备注
+        type: string
+      scfcontractid:
+        description: SCF合同ID(310+Unix秒时间戳(10位)+xxxxxx)
+        type: string
+      scfcontractstatus:
+        description: 合同状态 - 1:待确认 2:已确认 3:确认拒绝 4:已支付保证金 5:已激活 6:已违约 7:到期结束 8:延期结束
+          9:违约结束 10:已注销 11:已关闭 99:未提交
+        type: integer
+      scfcontracttype:
+        description: 合同类型 - 1:仓单回购 2:仓单质押 3:合作套保 4:资金贷款 5:融资单 6:融资回购
+        type: integer
+      startinterestday:
+        description: 计息开始日(yyyyMMdd)  -> 开始计费日期
+        type: string
+      totalinterest:
+        description: 已计利息 -> 已计费用
+        type: number
+      unpaidinterest:
+        description: 未结费用
+        type: number
+      updatetime:
+        description: 更新时间
+        type: string
+      warehouseid:
+        description: 仓库ID
+        type: integer
+      warehousename:
+        description: 仓库名称
+        type: string
+      wrfactortypeid:
+        description: 仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)
+        type: string
+      wrfactortypename:
+        description: 仓单要素类型名称(选择项要素的名称合并显示,逗号分隔)
+        type: string
+      wrqty:
+        description: 仓单数量 - [仓单回购\仓单质押] -> 数量
+        type: number
+      wrstandardcode:
+        description: 现货商品代码
+        type: string
+      wrstandardid:
+        description: 现货商品ID
+        type: integer
+      wrstandardname:
+        description: 商品名称
+        type: string
+      wrtypename:
+        description: 商品
+        type: string
+    type: object
   models.WrSpecialMatchOrder:
     properties:
       amount:
@@ -24078,6 +24235,36 @@ paths:
       summary: 查询现货(预售)仓单持仓
       tags:
       - 仓单贸易v2
+  /WrTrade2/QueryWrScfContract:
+    get:
+      parameters:
+      - description: 用户id
+        in: query
+        name: userid
+        required: true
+        type: integer
+      - description: 融资合同id
+        in: query
+        name: scfcontractid
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.WrScfContract'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询仓单贸易融资合同
+      tags:
+      - 仓单贸易v2
   /WrTrade2/QueryWrSpecialMatchOrder:
     get:
       description: 页面 现货仓单 | 预售仓单 -> 指定成交

+ 141 - 9
models/wrTrade2.go

@@ -9,6 +9,7 @@ package models
 import (
 	"fmt"
 	"mtp2_if/db"
+	"mtp2_if/mtpcache"
 	"mtp2_if/utils"
 	"strings"
 )
@@ -1981,7 +1982,6 @@ type WrFinanceBuyApply struct {
 	ORDERQTY           float64 `json:"orderqty"  xorm:"ORDERQTY" form:"orderqty"`                               // 委托数量(商品数量)
 	SELLUSERID         int64   `json:"selluserid"  xorm:"SELLUSERID" form:"selluserid"`                         // 卖方用户ID
 	SELLACCOUNTID      int64   `json:"sellaccountid"  xorm:"SELLACCOUNTID" form:"sellaccountid"`                // 卖方资金账号
-	PRODUCTDETAILID    int64   `json:"productdetailid"  xorm:"PRODUCTDETAILID" form:"productdetailid"`          // 产品组合ID
 	FINANCEACCOUNTID   int64   `json:"financeaccountid"  xorm:"FINANCEACCOUNTID" form:"financeaccountid"`       // 融资方资金帐户ID
 	FINANCEAREAUSERID  string  `json:"financeareauserid"  xorm:"FINANCEAREAUSERID" form:"financeareauserid"`    // 融资方用户ID
 	ISAUTOLOAN         int32   `json:"isautoloan"  xorm:"ISAUTOLOAN" form:"isautoloan"`                         // 是否自动放款 - 0:手动 1:自动
@@ -2005,14 +2005,16 @@ type WrFinanceBuyApply struct {
 	FINANCENAME        string  `json:"financename"  xorm:"'FINANCENAME'"`                                       // 融出方名称
 	FINANCETYPE        int32   `json:"financetype"  xorm:"'FINANCETYPE'"`                                       // 融资类型  1-融资回购
 
-	PRODUCTID           int64   `json:"productid"  xorm:"PRODUCTID"`                     // 金融产品ID
-	FINANCINGDAYS       int32   `json:"financingdays"  xorm:"FINANCINGDAYS"`             // 天数(天)
-	MARGINRATIO         float64 `json:"marginratio"  xorm:"MARGINRATIO"`                 // 保证金比率质押率 - [仓单质押]
-	INTERESTRATEMODE    int32   `json:"interestratemode"  xorm:"INTERESTRATEMODE"`       // 利率方式 - 1:年利率 2:日利率 3:日固定值
-	INTERESTRATE        float64 `json:"interestrate"  xorm:"INTERESTRATE"`               // 利率
-	INTERESTMINLEN      int32   `json:"interestminlen"  xorm:"INTERESTMINLEN"`           // 最小起息天数
-	INTERESTSETTLEMODE  int32   `json:"interestsettlemode"  xorm:"INTERESTSETTLEMODE"`   // 结息方式 - 1:按日结息  3:按月结息
-	INTERESTSETTLEVALUE int32   `json:"interestsettlevalue"  xorm:"INTERESTSETTLEVALUE"` // 结息方式值
+	PRODUCTDETAILID     int64   `json:"productdetailid"  xorm:"PRODUCTDETAILID" form:"productdetailid"` // 产品组合ID
+	PRODUCTID           int64   `json:"productid"  xorm:"PRODUCTID"`                                    // 金融产品ID
+	PRODUCTNAME         string  `json:"productname"  xorm:"'PRODUCTNAME'"`                              // 产品名称
+	FINANCINGDAYS       int32   `json:"financingdays"  xorm:"FINANCINGDAYS"`                            // 天数(天)
+	MARGINRATIO         float64 `json:"marginratio"  xorm:"MARGINRATIO"`                                // 保证金比率质押率 - [仓单质押]
+	INTERESTRATEMODE    int32   `json:"interestratemode"  xorm:"INTERESTRATEMODE"`                      // 利率方式 - 1:年利率 2:日利率 3:日固定值
+	INTERESTRATE        float64 `json:"interestrate"  xorm:"INTERESTRATE"`                              // 利率
+	INTERESTMINLEN      int32   `json:"interestminlen"  xorm:"INTERESTMINLEN"`                          // 最小起息天数
+	INTERESTSETTLEMODE  int32   `json:"interestsettlemode"  xorm:"INTERESTSETTLEMODE"`                  // 结息方式 - 1:按日结息  3:按月结息
+	INTERESTSETTLEVALUE int32   `json:"interestsettlevalue"  xorm:"INTERESTSETTLEVALUE"`                // 结息方式值
 
 	Wr2FactorType `xorm:"extends"`
 }
@@ -2076,6 +2078,7 @@ func (r *WrFinanceBuyApply) buildSql() string {
 		"       t.TRADEPRICE," +
 		"       t.TRADEAMOUNT," +
 		"       t.DELIVERYMONTH," +
+		"       f.PRODUCTNAME," +
 		"       p.FINANCINGDAYS," +
 		"       p.MARGINRATIO," +
 		"       p.INTERESTRATEMODE," +
@@ -2088,6 +2091,7 @@ func (r *WrFinanceBuyApply) buildSql() string {
 		"       tmp.*" +
 		"  FROM WRTRADE_FINANCEBUYAPPLY t" +
 		"  LEFT JOIN FINANCEAREAPRODUCTDETAIL p on t.productdetailid = p.productdetailid" +
+		"  LEFT JOIN FinanceAreaProduct f on p.productid = f.productid" +
 		"  LEFT JOIN tmp on t.wrfactortypeid=tmp.wrfactortypeid" +
 		"  LEFT JOIN USERACCOUNT u1 on t.BUYUSERID = u1.userid" +
 		"  LEFT JOIN USERACCOUNT u2 on t.FINANCEAREAUSERID = u2.userid" +
@@ -2106,3 +2110,131 @@ func (r *WrFinanceBuyApply) GetDataEx() (interface{}, error) {
 	}
 	return sData, err
 }
+
+// WrScfContract 仓单贸易融资合同
+type WrScfContract struct {
+	DEADLINE             string  `json:"deadline"  xorm:"DEADLINE"`                                      // 截止日期(yyyyMMdd) -> 借款到期时间
+	MARKETID             int64   `json:"marketid"  xorm:"MARKETID" form:"marketid"`                      // 市场ID - 拆成三个独立模式后,根据市场ID处理
+	SCFCONTRACTID        string  `json:"scfcontractid"  xorm:"SCFCONTRACTID" form:"scfcontractid"`       // SCF合同ID(310+Unix秒时间戳(10位)+xxxxxx)
+	SCFCONTRACTTYPE      int32   `json:"scfcontracttype"  xorm:"SCFCONTRACTTYPE" form:"scfcontracttype"` // 合同类型 - 1:仓单回购 2:仓单质押 3:合作套保 4:资金贷款 5:融资单 6:融资回购
+	LENDERUSERID         int64   `json:"lenderuserid"  xorm:"LENDERUSERID" form:"lenderuserid"`          // 贷款方用户ID -> 融出方用户ID
+	BORROWERUSERID       int64   `json:"borroweruserid"  xorm:"BORROWERUSERID" form:"userid"`            // 借款用户ID
+	LENDERAMOUNT         float64 `json:"lenderamount"  xorm:"LENDERAMOUNT"`                              // 贷款金额 -> 借款金额
+	WRFACTORTYPEID       int64   `json:"wrfactortypeid"  xorm:"WRFACTORTYPEID" form:"wrfactortypeid"`    // 仓单要素类型ID -   [仓单回购\仓单质押]
+	WRQTY                float64 `json:"wrqty"  xorm:"WRQTY"`                                            // 仓单数量 - [仓单回购\仓单质押] -> 数量
+	ISAUTOLOAN           int32   `json:"isautoloan"  xorm:"ISAUTOLOAN"`                                  // 是否自动放款 - 0:手动 1:自动 - [仓单质押]
+	REMAINAMOUNT         float64 `json:"remainamount"  xorm:"REMAINAMOUNT"`                              // 合同剩余金额 -> 剩余金额
+	INITMARGIN           float64 `json:"initmargin"  xorm:"INITMARGIN"`                                  // 保证金 - [仓单回购]
+	REMAINWRPOSITIONQTY  float64 `json:"remainwrpositionqty"  xorm:"REMAINWRPOSITIONQTY"`                // 剩余仓单头寸数量 - [仓单回购\仓单质押] -> 剩余数量
+	BUYBACKWRPOSITIONQTY float64 `json:"buybackwrpositionqty"  xorm:"BUYBACKWRPOSITIONQTY"`              // 已回购仓单头寸数量 - [仓单回购\仓单质押] -> 已回购数量
+	INTERESTAMOUNT       float64 `json:"interestamount"  xorm:"INTERESTAMOUNT"`                          // 计息金额=合同剩余金额 - 初始保证金 - 追缴保证金 \  合同剩余金额
+	TOTALINTEREST        float64 `json:"totalinterest"  xorm:"TOTALINTEREST"`                            // 已计利息 -> 已计费用
+	CLOSEINTEREST        float64 `json:"closeinterest"  xorm:"CLOSEINTEREST"`                            // 已结利息 -> 已结费用
+	INTERESTDEBT         float64 `json:"interestdebt"  xorm:"INTERESTDEBT"`                              // 利息欠款(记录负数) -> 费用欠款
+	STARTINTERESTDAY     string  `json:"startinterestday"  xorm:"STARTINTERESTDAY"`                      // 计息开始日(yyyyMMdd)  -> 开始计费日期
+	LASTCLOSEINTERESTDAY string  `json:"lastcloseinterestday"  xorm:"LASTCLOSEINTERESTDAY"`              // 最近结息日(yyyyMMdd)
+	SCFCONTRACTSTATUS    int32   `json:"scfcontractstatus"  xorm:"SCFCONTRACTSTATUS"`                    // 合同状态 - 1:待确认 2:已确认 3:确认拒绝 4:已支付保证金 5:已激活 6:已违约 7:到期结束 8:延期结束 9:违约结束 10:已注销 11:已关闭 99:未提交
+	UPDATETIME           string  `json:"updatetime"  xorm:"UPDATETIME"`                                  // 更新时间
+	REMARK               string  `json:"remark"  xorm:"REMARK"`                                          // 备注
+	PRICEMOVE            float64 `json:"pricemove"  xorm:"PRICEMOVE"`                                    // 估值升贴水值
+	CURRISKLEVEL         int32   `json:"currisklevel"  xorm:"CURRISKLEVEL"`                              // 风险级别 - 1:正常 2:追加货款 3:支付尾款
+
+	PRODUCTDETAILID     int64   `json:"productdetailid"  xorm:"PRODUCTDETAILID" form:"productdetailid"` // 产品组合ID
+	PRODUCTID           int64   `json:"productid"  xorm:"PRODUCTID"`                                    // 金融产品ID
+	PRODUCTNAME         string  `json:"productname"  xorm:"'PRODUCTNAME'"`                              // 产品名称
+	FINANCINGDAYS       int32   `json:"financingdays"  xorm:"FINANCINGDAYS"`                            // 天数(天)
+	MARGINRATIO         float64 `json:"marginratio"  xorm:"MARGINRATIO"`                                // 保证金比率质押率 - [仓单质押]
+	INTERESTRATEMODE    int32   `json:"interestratemode"  xorm:"INTERESTRATEMODE"`                      // 利率方式 - 1:年利率 2:日利率 3:日固定值
+	INTERESTRATE        float64 `json:"interestrate"  xorm:"INTERESTRATE"`                              // 利率
+	INTERESTMINLEN      int32   `json:"interestminlen"  xorm:"INTERESTMINLEN"`                          // 最小起息天数
+	INTERESTSETTLEMODE  int32   `json:"interestsettlemode"  xorm:"INTERESTSETTLEMODE"`                  // 结息方式 - 1:按日结息  3:按月结息
+	INTERESTSETTLEVALUE int32   `json:"interestsettlevalue"  xorm:"INTERESTSETTLEVALUE"`                // 结息方式值
+
+	Wr2FactorType `xorm:"extends"`
+
+	UNPAIDINTEREST SFLOAT64 `json:"unpaidinterest"` // 未结费用
+	LENDERUSERNAME string   `json:"lenderusername"` // 融出方
+}
+
+func (r *WrScfContract) calc() {
+	r.LENDERUSERNAME = mtpcache.GetUserNameByUserId(r.LENDERUSERID)
+	r.UNPAIDINTEREST.Set(r.TOTALINTEREST - r.CLOSEINTEREST)
+	r.UNPAIDINTEREST.Round(2)
+}
+
+func (r *WrScfContract) buildSql() string {
+	var sqlId utils.SQLVal = "with tmp as" +
+		" (select to_char(t.wrfactortypeid) wrfactortypeid," +
+		"         t.wrfactortypename," +
+		"         t.wrstandardid," +
+		"         t.deliverygoodsid," +
+		"         g.deliverygoodscode," +
+		"         g.deliverygoodsname," +
+		"         w.wrstandardcode," +
+		"         w.wrstandardname," +
+		"         h.warehousecode," +
+		"         h.warehousename," +
+		"         e.enumdicname," +
+		"         w.wrstandardname || t.wrfactortypename2 as wrtypename" +
+		"    from wrfactortype t" +
+		"    left join deliverygoods g" +
+		"      on t.deliverygoodsid = g.deliverygoodsid" +
+		"    left join wrstandard w" +
+		"      on t.wrstandardid = w.wrstandardid" +
+		"    left join warehouseinfo h" +
+		"      on t.warehouseid = h.autoid" +
+		"    left join enumdicitem e" +
+		"      on w.unitid = e.enumitemname" +
+		"     and e.enumdiccode = 'goodsunit')" +
+		"select to_char(t.scfcontractid) scfcontractid," +
+		"       t.scfcontracttype," +
+		"       t.lenderuserid," +
+		"       t.lenderamount," +
+		"       s.remainamount," +
+		"       s.initmargin," +
+		"       t.wrqty," +
+		"       s.buybackwrpositionqty," +
+		"       s.remainwrpositionqty," +
+		"       s.closeinterest," +
+		"       s.interestdebt," +
+		"       s.startinterestday," +
+		"       s.lastcloseinterestday," +
+		"       t.deadline," +
+		"       s.scfcontractstatus," +
+		"       p.productdetailid," +
+		"       p.productid," +
+		"       f.productname," +
+		"       p.FINANCINGDAYS," +
+		"       p.MARGINRATIO," +
+		"       p.INTERESTRATEMODE," +
+		"       p.INTERESTRATE," +
+		"       p.INTERESTMINLEN," +
+		"       p.INTERESTSETTLEMODE," +
+		"       p.INTERESTSETTLEVALUE," +
+		"       tmp.*" +
+		"  from scf_contract t" +
+		"  left join scf_contractinfo s" +
+		"    on t.scfcontractid = t.scfcontractid" +
+		"  left join WRTrade_FinanceBuyApply a" +
+		"    on t.scfcontractid = a.scfcontractid" +
+		"  left join FINANCEAREAPRODUCTDETAIL p" +
+		"    on a.productdetailid = p.productdetailid" +
+		"  left join FINANCEAREAPRODUCT f" +
+		"    on p.productid = f.productid" +
+		"  left join tmp" +
+		"    on t.wrfactortypeid = tmp.wrfactortypeid" +
+		" where 1 = 1"
+	sqlId.And("t.borroweruserid", r.BORROWERUSERID)
+	sqlId.AndEx("t.scfcontractid", r.SCFCONTRACTID, r.SCFCONTRACTID != "")
+	return sqlId.String()
+}
+
+// GetDataEx 获取仓单贸易融资合同
+func (r *WrScfContract) GetDataEx() (interface{}, error) {
+	sData := make([]WrScfContract, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}

+ 1 - 0
routers/router.go

@@ -536,6 +536,7 @@ func InitRouter() *gin.Engine {
 		wrTrade2R.GET("QueryWrStandardFactoryItem", wrTrade2.QueryWrStandardFactoryItem)
 		wrTrade2R.GET("QueryWrPerformancePlanStep", wrTrade2.QueryWrPerformancePlanStep)
 		wrTrade2R.GET("QueryWrFinanceBuyApply", wrTrade2.QueryWrFinanceBuyApply)
+		wrTrade2R.GET("QueryWrScfContract", wrTrade2.QueryWrScfContract)
 	}
 
 	return r