Przeglądaj źródła

1.定投计划增加登录代码、用户类型字段(pcweb)
2.增加融资信息查询接口(pcweb)

zou.yingbin 4 lat temu
rodzic
commit
5241b25d71
7 zmienionych plików z 701 dodań i 4 usunięć
  1. 34 0
      controllers/qhjPCWeb/qryQhjPCWeb.go
  2. 197 0
      docs/docs.go
  3. 197 0
      docs/swagger.json
  4. 140 0
      docs/swagger.yaml
  5. 17 4
      models/qhj.go
  6. 115 0
      models/qhjPCWeb.go
  7. 1 0
      routers/router.go

+ 34 - 0
controllers/qhjPCWeb/qryQhjPCWeb.go

@@ -254,3 +254,37 @@ func QueryTradePayOrder(c *gin.Context) {
 	m.FilterPayFlag = req.PAYFLAG
 	a.DoGetDataI(&m)
 }
+
+// QueryContract
+// @Summary 查询融资信息(合同)
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
+// @Param goodsid query int false "商品id"
+// @Param filtername query string false "名称(模糊搜索账户)"
+// @Param risklevel query string false "风险级别(逗号隔开) - 1:正常 2:追加货款 3:支付尾款"
+// @Param begindate query string false "开始交易日(yyyymmdd)"
+// @Param enddate query string false "结束交易日(yyyymmdd)"
+// @Success 200 {array} models.QhjMgrContract
+// @Failure 500 {object} app.Response
+// @Router /QhjMgr/QueryContract [get]
+// @Tags 大连千海金(PCWeb)
+func QueryContract(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"`
+		BEGINDATE    string `form:"begindate"`
+		ENDDATE      string `form:"enddate"`
+		RISKLEVEL    string `form:"risklevel"`
+	}{}
+	a.DoBindReq(&req)
+	m := models.QhjMgrContract{}
+	m.USERID, m.FilterName = req.USERID, req.FILTERNAME
+	m.USERINFOTYPE, m.GOODSID = req.USERINFOTYPE, req.GOODSID
+	m.BeginDate, m.EndDate = req.BEGINDATE, req.ENDDATE
+	m.FilterRiskLevel = req.RISKLEVEL
+	a.DoGetDataI(&m)
+}

+ 197 - 0
docs/docs.go

@@ -7997,6 +7997,78 @@ var doc = `{
                 }
             }
         },
+        "/QhjMgr/QueryContract": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "大连千海金(PCWeb)"
+                ],
+                "summary": "查询融资信息(合同)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商品id",
+                        "name": "goodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "名称(模糊搜索账户)",
+                        "name": "filtername",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "风险级别(逗号隔开) - 1:正常 2:追加货款 3:支付尾款",
+                        "name": "risklevel",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "开始交易日(yyyymmdd)",
+                        "name": "begindate",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "结束交易日(yyyymmdd)",
+                        "name": "enddate",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.QhjMgrContract"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/QhjMgr/QueryCustomerInfo": {
             "get": {
                 "security": [
@@ -22979,6 +23051,119 @@ var doc = `{
                 }
             }
         },
+        "models.QhjMgrContract": {
+            "type": "object",
+            "properties": {
+                "contractconfirmtime": {
+                    "description": "合同确认时间(时间)",
+                    "type": "string"
+                },
+                "currisklevel": {
+                    "description": "风险级别 - 1:正常 2:追加货款 3:支付尾款",
+                    "type": "integer"
+                },
+                "decimalplace": {
+                    "description": "商品报价小数位",
+                    "type": "integer"
+                },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
+                "goodscode": {
+                    "description": "商品代码",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "商品ID [5:融资单]",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "商品名称",
+                    "type": "string"
+                },
+                "goodunitid": {
+                    "description": "商品单位id",
+                    "type": "integer"
+                },
+                "initmargin": {
+                    "description": "初始保证金(首付款)",
+                    "type": "number"
+                },
+                "lenderamount": {
+                    "description": "贷款金额(总额|订单总额)",
+                    "type": "number"
+                },
+                "logincode": {
+                    "description": "账号(登录代码)",
+                    "type": "string"
+                },
+                "marginratio": {
+                    "description": "保证金比率(首付比例)",
+                    "type": "number"
+                },
+                "mobile": {
+                    "description": "电话号码(用户资料里的电话)",
+                    "type": "string"
+                },
+                "payamount": {
+                    "description": "已付(已付货款)",
+                    "type": "number"
+                },
+                "reckonrecovermargin": {
+                    "description": "结算应追缴保底金(结算时到过风险率时临时存储) - [仓单回购\\仓单质押]",
+                    "type": "number"
+                },
+                "recoveredmargin": {
+                    "description": "已追缴保证金",
+                    "type": "number"
+                },
+                "remainamount": {
+                    "description": "合同剩余金额(融资额)",
+                    "type": "number"
+                },
+                "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:融资单",
+                    "type": "integer"
+                },
+                "totalinterest": {
+                    "description": "已计总利息(利息)",
+                    "type": "number"
+                },
+                "tradedate": {
+                    "description": "交易日",
+                    "type": "string"
+                },
+                "tradeprice": {
+                    "description": "成交价格(成本价格)",
+                    "type": "number"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                },
+                "userinfotype": {
+                    "description": "用户类型 1-个人 2-企业",
+                    "type": "integer"
+                },
+                "username": {
+                    "description": "用户名称",
+                    "type": "string"
+                },
+                "wrqty": {
+                    "description": "仓单数量(数量)",
+                    "type": "number"
+                }
+            }
+        },
         "models.QhjMgrPositionRsp": {
             "type": "object",
             "properties": {
@@ -23852,6 +24037,10 @@ var doc = `{
                     "description": "最新触发交易日",
                     "type": "string"
                 },
+                "logincode": {
+                    "description": "账号(登录代码)",
+                    "type": "string"
+                },
                 "nexttriggeramount": {
                     "description": "下次触发金额",
                     "type": "number"
@@ -23928,6 +24117,10 @@ var doc = `{
                     "description": "所属用户ID",
                     "type": "integer"
                 },
+                "userinfotype": {
+                    "description": "用户类型 1-个人 2-企业",
+                    "type": "integer"
+                },
                 "username": {
                     "description": "用户名称(userid对应的名称)",
                     "type": "string"
@@ -24255,6 +24448,10 @@ var doc = `{
                     "description": "交易商品总手数(交易商品 - 69模式按成交量放大) - 明细表的交易商品手数汇总",
                     "type": "number"
                 },
+                "qtydecimalplace": {
+                    "description": "商品数量小数位",
+                    "type": "integer"
+                },
                 "recivername": {
                     "description": "提货人姓名",
                     "type": "string"

+ 197 - 0
docs/swagger.json

@@ -7981,6 +7981,78 @@
                 }
             }
         },
+        "/QhjMgr/QueryContract": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "大连千海金(PCWeb)"
+                ],
+                "summary": "查询融资信息(合同)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "商品id",
+                        "name": "goodsid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "名称(模糊搜索账户)",
+                        "name": "filtername",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "风险级别(逗号隔开) - 1:正常 2:追加货款 3:支付尾款",
+                        "name": "risklevel",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "开始交易日(yyyymmdd)",
+                        "name": "begindate",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "结束交易日(yyyymmdd)",
+                        "name": "enddate",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.QhjMgrContract"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/QhjMgr/QueryCustomerInfo": {
             "get": {
                 "security": [
@@ -22963,6 +23035,119 @@
                 }
             }
         },
+        "models.QhjMgrContract": {
+            "type": "object",
+            "properties": {
+                "contractconfirmtime": {
+                    "description": "合同确认时间(时间)",
+                    "type": "string"
+                },
+                "currisklevel": {
+                    "description": "风险级别 - 1:正常 2:追加货款 3:支付尾款",
+                    "type": "integer"
+                },
+                "decimalplace": {
+                    "description": "商品报价小数位",
+                    "type": "integer"
+                },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
+                "goodscode": {
+                    "description": "商品代码",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "商品ID [5:融资单]",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "商品名称",
+                    "type": "string"
+                },
+                "goodunitid": {
+                    "description": "商品单位id",
+                    "type": "integer"
+                },
+                "initmargin": {
+                    "description": "初始保证金(首付款)",
+                    "type": "number"
+                },
+                "lenderamount": {
+                    "description": "贷款金额(总额|订单总额)",
+                    "type": "number"
+                },
+                "logincode": {
+                    "description": "账号(登录代码)",
+                    "type": "string"
+                },
+                "marginratio": {
+                    "description": "保证金比率(首付比例)",
+                    "type": "number"
+                },
+                "mobile": {
+                    "description": "电话号码(用户资料里的电话)",
+                    "type": "string"
+                },
+                "payamount": {
+                    "description": "已付(已付货款)",
+                    "type": "number"
+                },
+                "reckonrecovermargin": {
+                    "description": "结算应追缴保底金(结算时到过风险率时临时存储) - [仓单回购\\仓单质押]",
+                    "type": "number"
+                },
+                "recoveredmargin": {
+                    "description": "已追缴保证金",
+                    "type": "number"
+                },
+                "remainamount": {
+                    "description": "合同剩余金额(融资额)",
+                    "type": "number"
+                },
+                "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:融资单",
+                    "type": "integer"
+                },
+                "totalinterest": {
+                    "description": "已计总利息(利息)",
+                    "type": "number"
+                },
+                "tradedate": {
+                    "description": "交易日",
+                    "type": "string"
+                },
+                "tradeprice": {
+                    "description": "成交价格(成本价格)",
+                    "type": "number"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                },
+                "userinfotype": {
+                    "description": "用户类型 1-个人 2-企业",
+                    "type": "integer"
+                },
+                "username": {
+                    "description": "用户名称",
+                    "type": "string"
+                },
+                "wrqty": {
+                    "description": "仓单数量(数量)",
+                    "type": "number"
+                }
+            }
+        },
         "models.QhjMgrPositionRsp": {
             "type": "object",
             "properties": {
@@ -23836,6 +24021,10 @@
                     "description": "最新触发交易日",
                     "type": "string"
                 },
+                "logincode": {
+                    "description": "账号(登录代码)",
+                    "type": "string"
+                },
                 "nexttriggeramount": {
                     "description": "下次触发金额",
                     "type": "number"
@@ -23912,6 +24101,10 @@
                     "description": "所属用户ID",
                     "type": "integer"
                 },
+                "userinfotype": {
+                    "description": "用户类型 1-个人 2-企业",
+                    "type": "integer"
+                },
                 "username": {
                     "description": "用户名称(userid对应的名称)",
                     "type": "string"
@@ -24239,6 +24432,10 @@
                     "description": "交易商品总手数(交易商品 - 69模式按成交量放大) - 明细表的交易商品手数汇总",
                     "type": "number"
                 },
+                "qtydecimalplace": {
+                    "description": "商品数量小数位",
+                    "type": "integer"
+                },
                 "recivername": {
                     "description": "提货人姓名",
                     "type": "string"

+ 140 - 0
docs/swagger.yaml

@@ -9853,6 +9853,91 @@ definitions:
         description: 用户名称
         type: string
     type: object
+  models.QhjMgrContract:
+    properties:
+      contractconfirmtime:
+        description: 合同确认时间(时间)
+        type: string
+      currisklevel:
+        description: 风险级别 - 1:正常 2:追加货款 3:支付尾款
+        type: integer
+      decimalplace:
+        description: 商品报价小数位
+        type: integer
+      enumdicname:
+        description: 单位名称
+        type: string
+      goodscode:
+        description: 商品代码
+        type: string
+      goodsid:
+        description: 商品ID [5:融资单]
+        type: integer
+      goodsname:
+        description: 商品名称
+        type: string
+      goodunitid:
+        description: 商品单位id
+        type: integer
+      initmargin:
+        description: 初始保证金(首付款)
+        type: number
+      lenderamount:
+        description: 贷款金额(总额|订单总额)
+        type: number
+      logincode:
+        description: 账号(登录代码)
+        type: string
+      marginratio:
+        description: 保证金比率(首付比例)
+        type: number
+      mobile:
+        description: 电话号码(用户资料里的电话)
+        type: string
+      payamount:
+        description: 已付(已付货款)
+        type: number
+      reckonrecovermargin:
+        description: 结算应追缴保底金(结算时到过风险率时临时存储) - [仓单回购\仓单质押]
+        type: number
+      recoveredmargin:
+        description: 已追缴保证金
+        type: number
+      remainamount:
+        description: 合同剩余金额(融资额)
+        type: number
+      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:融资单
+        type: integer
+      totalinterest:
+        description: 已计总利息(利息)
+        type: number
+      tradedate:
+        description: 交易日
+        type: string
+      tradeprice:
+        description: 成交价格(成本价格)
+        type: number
+      userid:
+        description: 用户ID
+        type: integer
+      userinfotype:
+        description: 用户类型 1-个人 2-企业
+        type: integer
+      username:
+        description: 用户名称
+        type: string
+      wrqty:
+        description: 仓单数量(数量)
+        type: number
+    type: object
   models.QhjMgrPositionRsp:
     properties:
       accountid:
@@ -10500,6 +10585,9 @@ definitions:
       lasttriggertradedate:
         description: 最新触发交易日
         type: string
+      logincode:
+        description: 账号(登录代码)
+        type: string
       nexttriggeramount:
         description: 下次触发金额
         type: number
@@ -10557,6 +10645,9 @@ definitions:
       userid:
         description: 所属用户ID
         type: integer
+      userinfotype:
+        description: 用户类型 1-个人 2-企业
+        type: integer
       username:
         description: 用户名称(userid对应的名称)
         type: string
@@ -10800,6 +10891,9 @@ definitions:
       qty:
         description: 交易商品总手数(交易商品 - 69模式按成交量放大) - 明细表的交易商品手数汇总
         type: number
+      qtydecimalplace:
+        description: 商品数量小数位
+        type: integer
       recivername:
         description: 提货人姓名
         type: string
@@ -18960,6 +19054,52 @@ paths:
       summary: 查询充值提现
       tags:
       - 大连千海金(PCWeb)
+  /QhjMgr/QueryContract:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      - description: 商品id
+        in: query
+        name: goodsid
+        type: integer
+      - description: 名称(模糊搜索账户)
+        in: query
+        name: filtername
+        type: string
+      - description: 风险级别(逗号隔开) - 1:正常 2:追加货款 3:支付尾款
+        in: query
+        name: risklevel
+        type: string
+      - description: 开始交易日(yyyymmdd)
+        in: query
+        name: begindate
+        type: string
+      - description: 结束交易日(yyyymmdd)
+        in: query
+        name: enddate
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.QhjMgrContract'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询融资信息(合同)
+      tags:
+      - 大连千海金(PCWeb)
   /QhjMgr/QueryCustomerInfo:
     get:
       parameters:

+ 17 - 4
models/qhj.go

@@ -211,6 +211,9 @@ type QhjRStrategy struct {
 	CURRENCYID              int32   `json:"currencyid"  xorm:"'CURRENCYID'"`                         // 币种id
 	DECIMALPLACE            int32   `json:"decimalplace"  xorm:"'DECIMALPLACE'"`                     // 商品报价小数位
 	QTYDECIMALPLACE         int     `json:"qtydecimalplace"  xorm:"'QTYDECIMALPLACE'"`               // 成交量小数位
+	LOGINCODE               string  `json:"logincode"  xorm:"'LOGINCODE'"`                           // 账号(登录代码)
+	USERINFOTYPE            int32   `json:"userinfotype"  xorm:"'USERINFOTYPE'"`                     // 用户类型 1-个人 2-企业
+	MOBILE                  string  `json:"-"  xorm:"'MOBILE'"`                                      // 电话号码(用户资料里的电话)
 
 	USERNAME     string `json:"username"`     // 用户名称(userid对应的名称)
 	ACCOUNTNAME  string `json:"accountname"`  // 账号名称(ACCOUNTID对应的名称)
@@ -228,10 +231,14 @@ func (r *QhjRStrategy) calc() {
 	if r.REGULARLYMODE == 1 {
 		ZoomByDecimal(r.QTYDECIMALPLACE, &r.REGULARLYMODEVALUE)
 	}
+	if r.LOGINCODE == "" {
+		r.LOGINCODE = DecryptField(r.MOBILE)
+	}
 }
 
 func (r *QhjRStrategy) buildSql() string {
-	var sqlId utils.SQLVal = "SELECT t.REGULARLYCYCLE," +
+	var sqlId utils.SQLVal = "with k as (select t.userid, wm_concat(t.logincode) logincode from loginaccount t group by t.userid)" +
+		"SELECT t.REGULARLYCYCLE," +
 		"       t.REGULARLYCYCLEVALUE," +
 		"       t.REGULARLYMODE," +
 		"       t.REGULARLYMODEVALUE," +
@@ -259,10 +266,16 @@ func (r *QhjRStrategy) buildSql() string {
 		"       g.decimalplace," +
 		"       g.qtydecimalplace," +
 		"       g.goodunitid," +
-		"       ta.accountname" +
+		"       ta.accountname," +
+		"       k.logincode," +
+		"       ui.userinfotype" +
 		"  FROM QHJ_REGULARLYSTRATEGY t" +
-		"  LEFT JOIN GOODS g on t.goodsid=g.goodsid" +
-		"  LEFT JOIN TAACCOUNT ta on t.accountid=ta.accountid" +
+		"  LEFT JOIN GOODS g" +
+		"    on t.goodsid = g.goodsid" +
+		"  LEFT JOIN TAACCOUNT ta" +
+		"    on t.accountid = ta.accountid" +
+		"  LEFT JOIN USERINFO ui on t.userid=ui.userid" +
+		"  LEFT JOIN k on t.userid=k.userid" +
 		" WHERE 1 = 1"
 	sqlId.AndEx("t.USERID", r.USERID, r.USERID > 0)
 	sqlId.JoinEx(len(r.FilterStatus) > 0, fmt.Sprintf(" and t.REGULARLYSTRATEGYSTATUS in(%v)", r.FilterStatus))

+ 115 - 0
models/qhjPCWeb.go

@@ -996,3 +996,118 @@ func (r *QhjMgrTradePayOrder) GetDataEx() (interface{}, error) {
 	}
 	return sData, err
 }
+
+// QhjMgrContract 千海金融资明细(合同)
+type QhjMgrContract struct {
+	USERID              int64   `json:"userid"  xorm:"USERID"`                             // 用户ID
+	SCFCONTRACTID       string  `json:"scfcontractid"  xorm:"SCFCONTRACTID"`               // SCF合同ID(310+Unix秒时间戳(10位)+xxxxxx)
+	SCFCONTRACTTYPE     int32   `json:"scfcontracttype"  xorm:"SCFCONTRACTTYPE"`           // 合同类型 - 1:仓单回购 2:仓单质押 3:合作套保 4:资金贷款 5:融资单
+	GOODSID             int32   `json:"goodsid"  xorm:"GOODSID"`                           // 商品ID [5:融资单]
+	CONTRACTCONFIRMTIME string  `json:"contractconfirmtime"  xorm:"CONTRACTCONFIRMTIME"`   // 合同确认时间(时间)
+	WRQTY               float64 `json:"wrqty"  xorm:"WRQTY"`                               // 仓单数量(数量)
+	TRADEPRICE          float64 `json:"tradeprice"  xorm:"TRADEPRICE"`                     // 成交价格(成本价格)
+	LENDERAMOUNT        float64 `json:"lenderamount"  xorm:"LENDERAMOUNT"`                 // 贷款金额(总额|订单总额)
+	MARGINRATIO         float64 `json:"marginratio"  xorm:"MARGINRATIO"`                   // 保证金比率(首付比例)
+	INITMARGIN          float64 `json:"initmargin"  xorm:"'INITMARGIN'"`                   // 初始保证金(首付款)
+	RECOVEREDMARGIN     float64 `json:"recoveredmargin"  xorm:"'RECOVEREDMARGIN'"`         // 已追缴保证金
+	REMAINAMOUNT        float64 `json:"remainamount"  xorm:"'REMAINAMOUNT'"`               // 合同剩余金额(融资额)
+	TOTALINTEREST       float64 `json:"totalinterest"  xorm:"'TOTALINTEREST'"`             // 已计总利息(利息)
+	GOODSCODE           string  `json:"goodscode"  xorm:"'GOODSCODE'"`                     // 商品代码
+	GOODSNAME           string  `json:"goodsname"  xorm:"'GOODSNAME'"`                     // 商品名称
+	GOODUNITID          int32   `json:"goodunitid"  xorm:"'GOODUNITID'"`                   // 商品单位id
+	CURRISKLEVEL        int32   `json:"currisklevel"  xorm:"'CURRISKLEVEL'"`               // 风险级别 - 1:正常 2:追加货款 3:支付尾款
+	RECKONRECOVERMARGIN float64 `json:"reckonrecovermargin"  xorm:"'RECKONRECOVERMARGIN'"` // 结算应追缴保底金(结算时到过风险率时临时存储) - [仓单回购\仓单质押]
+	DECIMALPLACE        int32   `json:"decimalplace"  xorm:"'DECIMALPLACE'"`               // 商品报价小数位
+	SCFCONTRACTSTATUS   int32   `json:"scfcontractstatus"  xorm:"'SCFCONTRACTSTATUS'"`     // 合同状态 - 1:待确认 2:已确认 3:确认拒绝 4:已支付保证金 5:已激活 6:已违约 7:到期结束 8:延期结束 9:违约结束 10:已注销 11:已关闭 99:未提交
+	LOGINCODE           string  `json:"logincode"  xorm:"'LOGINCODE'"`                     // 账号(登录代码)
+	USERINFOTYPE        int32   `json:"userinfotype"  xorm:"'USERINFOTYPE'"`               // 用户类型 1-个人 2-企业
+	MOBILE              string  `json:"mobile"  xorm:"'MOBILE'"`                           // 电话号码(用户资料里的电话)
+	TRADEDATE           string  `json:"tradedate"  xorm:"'TRADEDATE'"`                     // 交易日
+
+	PAYAMOUNT   float64 `json:"payamount"  xorm:"'PAYAMOUNT'"` // 已付(已付货款)
+	USERNAME    string  `json:"username"  xorm:"'USERNAME'"`   // 用户名称
+	ENUMDICNAME string  `json:"enumdicname"`                   // 单位名称
+
+	BeginDate       string `json:"-"` // 开始交易日
+	EndDate         string `json:"-"` // 结束交易日
+	FilterName      string `json:"-"` // 模糊搜索
+	FilterRiskLevel string `json:"-"` // 风险级别
+}
+
+func (r *QhjMgrContract) calc() {
+	r.USERNAME = mtpcache.GetUserNameByUserId(r.USERID)
+	r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.GOODUNITID)
+	// 已付(已付货款) = 已追缴保证金  + 初始保证金
+	r.PAYAMOUNT = r.RECOVEREDMARGIN + r.INITMARGIN
+	if r.SCFCONTRACTSTATUS == 10 || r.SCFCONTRACTSTATUS == 11 {
+		// 当合同关闭时, 利息重置为0
+		r.TOTALINTEREST = 0
+	}
+	if r.LOGINCODE == "" {
+		r.LOGINCODE = DecryptField(r.MOBILE)
+	}
+}
+
+func (r *QhjMgrContract) 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 t.borroweruserid userid," +
+		"       to_char(t.scfcontractid) scfcontractid," +
+		"       t.scfcontracttype," +
+		"       t.goodsid," +
+		"       to_char(t.contractconfirmtime, 'yyyy-mm-dd hh24:mi:ss') contractconfirmtime," +
+		"       t.wrqty," +
+		"       t.tradeprice," +
+		"       t.lenderamount," +
+		"       t.marginratio," +
+		"       s.initmargin," +
+		"       s.recoveredmargin," +
+		"       s.remainamount," +
+		"       s.totalinterest," +
+		"       s.currisklevel," +
+		"       s.reckonrecovermargin," +
+		"       s.scfcontractstatus," +
+		"       s.tradedate," +
+		"       g.goodscode," +
+		"       g.goodsname," +
+		"       g.decimalplace," +
+		"       g.goodunitid," +
+		"       ui.userinfotype," +
+		"       ui.mobile," +
+		"       u.accountname," +
+		"       k.logincode" +
+		"  from scf_contract t" +
+		"  left join scf_contractinfo s" +
+		"    on t.scfcontractid = s.scfcontractid" +
+		"  left join goods g" +
+		"    on t.goodsid = g.goodsid" +
+		"  left join userinfo ui on t.borroweruserid=ui.userid" +
+		"  left join k on ui.userid=k.userid" +
+		"  left join useraccount u on t.borroweruserid=u.userid" +
+		" where 1 = 1"
+	sqlId.AndEx("t.borroweruserid", r.USERID, r.USERID > 0)
+	sqlId.AndEx("ui.USERINFOTYPE", r.USERINFOTYPE, r.USERINFOTYPE > 0)
+	sqlId.AndEx("t.goodsid", r.GOODSID, r.GOODSID > 0)
+	if len(r.FilterRiskLevel) > 0 {
+		sqlId.JoinFormat(" and s.currisklevel in(%v)", r.FilterRiskLevel)
+	}
+	if len(r.BeginDate) > 0 {
+		sqlId.JoinFormat(" and s.TRADEDATE >=%v", r.BeginDate)
+	}
+	if len(r.EndDate) > 0 {
+		sqlId.JoinFormat(" and s.TRADEDATE <=%v", r.EndDate)
+	}
+	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 *QhjMgrContract) GetDataEx() (interface{}, error) {
+	sData := make([]QhjMgrContract, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}

+ 1 - 0
routers/router.go

@@ -486,6 +486,7 @@ func InitRouter() *gin.Engine {
 		qhjPCWebR.GET("QueryTradeDetail", qhjPCWeb.QueryTradeDetail)
 		qhjPCWebR.GET("QueryTradeOrderDetail", qhjPCWeb.QueryTradeOrderDetail)
 		qhjPCWebR.GET("QueryTradePayOrder", qhjPCWeb.QueryTradePayOrder)
+		qhjPCWebR.GET("QueryContract", qhjPCWeb.QueryContract)
 	}
 
 	return r