Browse Source

添加企业风险管理(app)查询接口:客户资料、套保计划、采购和销售

zou.yingbin 4 years ago
parent
commit
d6349a2a0c

+ 1 - 1
config/config.xml

@@ -42,4 +42,4 @@
     <Username value="quote_test132"/>
     <Password value="123456"/>
   </MySQLSetting>
-</Configuration>
+</Configuration>

+ 65 - 0
controllers/ermcp/qryErmcp.go

@@ -0,0 +1,65 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/1/6 10:12
+* @Modify  : 2021/1/6 10:12
+ */
+
+package ermcp
+
+import (
+	"github.com/gin-gonic/gin"
+	"mtp2_if/global/app"
+	"mtp2_if/global/e"
+	"mtp2_if/logger"
+	"mtp2_if/models"
+	"net/http"
+)
+
+// 查询合同请求结构
+type QryErmcpReq struct {
+	ContractType int32 `form:"contracttype" binding:"required"` // 合同类型
+	QueryType    int32 `form:"QueryType" binding:"required"`    // 查询类型 1-全部 2-待点价 3-履约结算
+}
+
+// 查询合同应答
+type QryErmcpRsp models.ErmcpModel
+
+// QueryContract  企业风险管理合同查询
+// @Summary 查询合同(采购和销售)
+// @Produce json
+// @Security ApiKeyAuth
+// @Param contracttype query int true "合同类型 1-采购, -1-销售"
+// @Param QueryType query int true "查询类型 1-全部 2-待点价 3-履约结算"
+// @Success 200 {array} QryErmcpRsp
+// @Failure 500 {object} app.Response
+// @Router /Ermcp/QueryContract [get]
+// @Tags 企业风险管理(app)
+func QueryContract(c *gin.Context) {
+	appG := app.Gin{C: c}
+	var req QryErmcpReq
+	if err := c.ShouldBind(&req); err != nil {
+		logger.GetLogger().Errorf("parse query req: %v", err)
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	// 参数检查
+	if req.ContractType != 1 && req.ContractType != -1 {
+		logger.GetLogger().Errorf("ContractType should in(1, -1)")
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	if req.QueryType != 0 && req.QueryType != 1 && req.QueryType != 2 {
+		logger.GetLogger().Errorf("QueryType should in(0, 1, 2)")
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	var m models.ErmcpModel
+	if d, err := m.GetData(req.ContractType, req.QueryType); err == nil {
+		appG.Response(http.StatusOK, e.SUCCESS, d)
+	} else {
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+	}
+}

+ 51 - 0
controllers/ermcp/qryHedgePlan.go

@@ -0,0 +1,51 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/1/7 17:58
+* @Modify  : 2021/1/7 17:58
+ */
+
+package ermcp
+
+import (
+	"github.com/gin-gonic/gin"
+	"mtp2_if/global/app"
+	"mtp2_if/global/e"
+	"mtp2_if/logger"
+	"mtp2_if/models"
+	"net/http"
+)
+
+// 查套保计划请求
+type QryHedgePlanReq struct {
+	HedgePlanStatus *int `form:"HedgePlanStatus" binding:"required"` // 套保计划状态
+}
+
+// 查套保计划应答
+type QryHedgePlanRsp models.ErmcpHedgePlan
+
+// QueryHedgePlan 查询套保计划
+// @Summary 查询套保计划
+// @Produce json
+// @Security ApiKeyAuth
+// @Param HedgePlanStatus query int true "套保计划状态 -  0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回"
+// @Success 200 {array} QryHedgePlanRsp
+// @Failure 500 {object} app.Response
+// @Router /Ermcp/QueryHedgePlan [get]
+// @Tags 企业风险管理(app)
+func QueryHedgePlan(c *gin.Context) {
+	appG := app.Gin{C: c}
+	req := QryHedgePlanReq{}
+	if err := c.ShouldBind(&req); err != nil {
+		logger.GetLogger().Errorf("query hedgeplanReq,%v", err)
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	var m models.ErmcpHedgePlan
+	if d, err := m.GetData(*req.HedgePlanStatus); err == nil {
+		appG.Response(http.StatusOK, e.SUCCESS, d)
+	} else {
+		logger.GetLogger().Errorf("query fail, %v", err)
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+	}
+}

+ 50 - 0
controllers/ermcp/qryUser.go

@@ -0,0 +1,50 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/1/7 10:54
+* @Modify  : 2021/1/7 10:54
+ */
+
+package ermcp
+
+import (
+	"github.com/gin-gonic/gin"
+	"mtp2_if/global/app"
+	"mtp2_if/global/e"
+	"mtp2_if/logger"
+	"mtp2_if/models"
+	"net/http"
+)
+
+// 查询客户资料请求
+type QryUserInfoReq struct {
+	AccountStatus string `form:"AccountStatus" binding:"required"` // 账户状态, 逗号隔开(1:待激活 2:待审核 3:待复审 4:正常 5:审核拒绝 6:注销)
+}
+
+// 查询客户资料应答
+type QryUserInfoRsp models.ErmcpUserModel
+
+// QueryUserInfo 查询客户资料
+// @Summary 查询客户资料
+// @Produce json
+// @Security ApiKeyAuth
+// @Param AccountStatus query string true "账户状态(可填多个, 逗号隔开) 1:待激活 2:待审核 3:待复审 4:正常 5:审核拒绝 6:注销"
+// @Success 200 {array} QryUserInfoRsp
+// @Failure 500 {object} app.Response
+// @Router /Ermcp/QueryUserInfo [get]
+// @Tags 企业风险管理(app)
+func QueryUserInfo(c *gin.Context) {
+	appG := app.Gin{C: c}
+	var req QryUserInfoReq
+	if err := c.ShouldBind(&req); err != nil {
+		logger.GetLogger().Errorf("parse query req: %v", err)
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	var m models.ErmcpUserModel
+	if d, err := m.GetData(req.AccountStatus); err == nil {
+		appG.Response(http.StatusOK, e.SUCCESS, d)
+	} else {
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+	}
+}

+ 394 - 30
docs/docs.go

@@ -20,6 +20,7 @@ var doc = `{
         "title": "{{.Title}}",
         "termsOfService": "http://muchinfo.cn",
         "contact": {},
+        "license": {},
         "version": "{{.Version}}"
     },
     "host": "{{.Host}}",
@@ -710,6 +711,139 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp/QueryContract": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询合同(采购和销售)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "合同类型 1-采购, -1-销售",
+                        "name": "contracttype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "查询类型 1-全部 2-待点价 3-履约结算",
+                        "name": "QueryType",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/ermcp.QryErmcpRsp"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp/QueryHedgePlan": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询套保计划",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "套保计划状态 -  0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回",
+                        "name": "HedgePlanStatus",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/ermcp.QryHedgePlanRsp"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp/QueryUserInfo": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询客户资料",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "账户状态(可填多个, 逗号隔开) 1:待激活 2:待审核 3:待复审 4:正常 5:审核拒绝 6:注销",
+                        "name": "AccountStatus",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/ermcp.QryUserInfoRsp"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Erms2/QueryArbitrageStrategy": {
             "get": {
                 "security": [
@@ -3931,6 +4065,7 @@ var doc = `{
                 },
                 "province": {
                     "description": "省",
+                    "type": "object",
                     "$ref": "#/definitions/models.Division"
                 }
             }
@@ -4934,6 +5069,15 @@ var doc = `{
                 }
             }
         },
+        "ermcp.QryErmcpRsp": {
+            "$ref": "#/definitions/models.ErmcpModel"
+        },
+        "ermcp.QryHedgePlanRsp": {
+            "$ref": "#/definitions/models.ErmcpHedgePlan"
+        },
+        "ermcp.QryUserInfoRsp": {
+            "$ref": "#/definitions/models.ErmcpUserModel"
+        },
         "erms2.QueryArbitrageStrategyRsp": {
             "type": "object",
             "required": [
@@ -6068,33 +6212,7 @@ var doc = `{
             }
         },
         "erms3.QryPendingBizRsp": {
-            "type": "object",
-            "properties": {
-                "accountid": {
-                    "description": "现货账户",
-                    "type": "string"
-                },
-                "areaname": {
-                    "description": "所属部门",
-                    "type": "string"
-                },
-                "bizid": {
-                    "description": "业务ID",
-                    "type": "string"
-                },
-                "bizname": {
-                    "description": "业务名称",
-                    "type": "string"
-                },
-                "status": {
-                    "description": "状态,0:待审核 1:审核通过 2:审核中 3:审核失败 4已撤销 5:审核拒绝",
-                    "type": "integer"
-                },
-                "type": {
-                    "description": "业务类型,1-期现套利,2-仓单回购,3-现货贸易",
-                    "type": "integer"
-                }
-            }
+            "$ref": "#/definitions/models.PendingAuditBizModel"
         },
         "erms3.QueryBusinessInfoRsp": {
             "type": "object",
@@ -6184,6 +6302,7 @@ var doc = `{
                 },
                 "ouruser": {
                     "description": "我方账号",
+                    "type": "object",
                     "$ref": "#/definitions/erms3.CustomerInfo"
                 },
                 "warehouseinfos": {
@@ -6519,6 +6638,7 @@ var doc = `{
                 },
                 "province": {
                     "description": "省",
+                    "type": "object",
                     "$ref": "#/definitions/models.Division"
                 }
             }
@@ -6631,6 +6751,221 @@ var doc = `{
                 }
             }
         },
+        "models.ErmcpHedgePlan": {
+            "type": "object",
+            "properties": {
+                "contracttype": {
+                    "description": "计划类型 - 1:采购 -1:销售",
+                    "type": "integer"
+                },
+                "convertfactor": {
+                    "description": "标仓系数",
+                    "type": "number"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
+                "hedgeplanid": {
+                    "description": "套保计划ID(601+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "hedgeplanno": {
+                    "description": "套保计划编号",
+                    "type": "string"
+                },
+                "hedgeplanstatus": {
+                    "description": "套保计划状态 -  0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回",
+                    "type": "integer"
+                },
+                "planqty": {
+                    "description": "计划数量",
+                    "type": "number"
+                },
+                "plantime": {
+                    "description": "计划时间",
+                    "type": "string"
+                },
+                "producttype": {
+                    "description": "产品类型 - 1:标准仓单 2:等标 3:非标",
+                    "type": "integer"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
+                "spotgoodsdesc": {
+                    "description": "商品型号",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "现货商品名称",
+                    "type": "string"
+                }
+            }
+        },
+        "models.ErmcpModel": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "账户ID",
+                    "type": "string"
+                },
+                "accountname": {
+                    "description": "账户名称",
+                    "type": "string"
+                },
+                "contracctstatus": {
+                    "description": "合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回",
+                    "type": "integer"
+                },
+                "convertfactor": {
+                    "description": "标仓系数",
+                    "type": "number"
+                },
+                "daikaiAmount": {
+                    "description": "待开票额",
+                    "type": "number"
+                },
+                "deliveryenddate": {
+                    "description": "交割结束日",
+                    "type": "string"
+                },
+                "deliverygoodscode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货商品名称",
+                    "type": "string"
+                },
+                "deliverystartdate": {
+                    "description": "交割开始日",
+                    "type": "string"
+                },
+                "enddate": {
+                    "description": "点价结束日",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
+                "goodscode": {
+                    "description": "点价商品代码",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "点价商品ID",
+                    "type": "integer"
+                },
+                "invoiceamount": {
+                    "description": "已开票额",
+                    "type": "number"
+                },
+                "payamount": {
+                    "description": "已收付额(收款或付款)",
+                    "type": "number"
+                },
+                "pricedqty": {
+                    "description": "已定价量",
+                    "type": "number"
+                },
+                "pricemove": {
+                    "description": "升贴水",
+                    "type": "number"
+                },
+                "pricetype": {
+                    "description": "定价类型 - 1:一口价 2:点价 3:暂定价",
+                    "type": "integer"
+                },
+                "producttype": {
+                    "description": "产品类型 - 1:标准仓单 2:等标 3:非标",
+                    "type": "integer"
+                },
+                "qty": {
+                    "description": "合同量",
+                    "type": "number"
+                },
+                "spotcontractid": {
+                    "description": "合同ID",
+                    "type": "integer"
+                },
+                "spotgoodsdesc": {
+                    "description": "商品型号(商品规格)",
+                    "type": "string"
+                },
+                "startdate": {
+                    "description": "点价开始日",
+                    "type": "string"
+                },
+                "unpayAmount": {
+                    "description": "待支收额(支付或收款)",
+                    "type": "number"
+                },
+                "unpricedqty": {
+                    "description": "未定价量",
+                    "type": "number"
+                },
+                "unsureqty": {
+                    "description": "未确定量",
+                    "type": "number"
+                }
+            }
+        },
+        "models.ErmcpUserModel": {
+            "type": "object",
+            "properties": {
+                "address": {
+                    "description": "通讯地址",
+                    "type": "string"
+                },
+                "cardnum": {
+                    "description": "证件号码",
+                    "type": "string"
+                },
+                "cardtype": {
+                    "description": "证件类型",
+                    "type": "string"
+                },
+                "customername": {
+                    "description": "企业名称",
+                    "type": "string"
+                },
+                "mobile": {
+                    "description": "手机号码",
+                    "type": "string"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
+                "status": {
+                    "description": "账户状态",
+                    "type": "string"
+                },
+                "telphone": {
+                    "description": "联系电话",
+                    "type": "string"
+                },
+                "userinfotype": {
+                    "description": "客户类型",
+                    "type": "string"
+                }
+            }
+        },
         "models.GoodsIDAndName": {
             "type": "object",
             "required": [
@@ -8197,7 +8532,7 @@ var doc = `{
                 },
                 "coupontypeid": {
                     "description": "优惠券类型ID",
-                    "type": "integer"
+                    "type": "string"
                 },
                 "couponvalue": {
                     "description": "面值[1:现金券 - 抵扣值 2:折扣券-折扣值]",
@@ -8277,7 +8612,7 @@ var doc = `{
                 },
                 "couponholdid": {
                     "description": "优惠券持仓ID(229+Unix秒时间戳(10位)+xxxxxx)",
-                    "type": "integer"
+                    "type": "string"
                 },
                 "couponname": {
                     "description": "优惠券名称",
@@ -8285,7 +8620,7 @@ var doc = `{
                 },
                 "coupontypeid": {
                     "description": "优惠券类型ID - SEQ_COUPONTYPE",
-                    "type": "integer"
+                    "type": "string"
                 },
                 "couponvalue": {
                     "description": "面值[1:现金券 - 抵扣值 2:折扣券-折扣值]",
@@ -8390,6 +8725,35 @@ var doc = `{
                 }
             }
         },
+        "models.PendingAuditBizModel": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "现货账户",
+                    "type": "string"
+                },
+                "areaname": {
+                    "description": "所属部门",
+                    "type": "string"
+                },
+                "bizid": {
+                    "description": "业务ID",
+                    "type": "string"
+                },
+                "bizname": {
+                    "description": "业务名称",
+                    "type": "string"
+                },
+                "status": {
+                    "description": "状态,0:待审核 1:审核通过 2:审核中 3:审核失败 4已撤销 5:审核拒绝",
+                    "type": "integer"
+                },
+                "type": {
+                    "description": "业务类型,1-期现套利,2-仓单回购,3-现货贸易",
+                    "type": "integer"
+                }
+            }
+        },
         "models.QuotePrimaryMenu": {
             "type": "object",
             "properties": {

+ 394 - 30
docs/swagger.json

@@ -5,6 +5,7 @@
         "title": "MTP2.0 查询服务 API",
         "termsOfService": "http://muchinfo.cn",
         "contact": {},
+        "license": {},
         "version": "1.0"
     },
     "basePath": "/api",
@@ -694,6 +695,139 @@
                 }
             }
         },
+        "/Ermcp/QueryContract": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询合同(采购和销售)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "合同类型 1-采购, -1-销售",
+                        "name": "contracttype",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "查询类型 1-全部 2-待点价 3-履约结算",
+                        "name": "QueryType",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/ermcp.QryErmcpRsp"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp/QueryHedgePlan": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询套保计划",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "套保计划状态 -  0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回",
+                        "name": "HedgePlanStatus",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/ermcp.QryHedgePlanRsp"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp/QueryUserInfo": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询客户资料",
+                "parameters": [
+                    {
+                        "type": "string",
+                        "description": "账户状态(可填多个, 逗号隔开) 1:待激活 2:待审核 3:待复审 4:正常 5:审核拒绝 6:注销",
+                        "name": "AccountStatus",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/ermcp.QryUserInfoRsp"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Erms2/QueryArbitrageStrategy": {
             "get": {
                 "security": [
@@ -3915,6 +4049,7 @@
                 },
                 "province": {
                     "description": "省",
+                    "type": "object",
                     "$ref": "#/definitions/models.Division"
                 }
             }
@@ -4918,6 +5053,15 @@
                 }
             }
         },
+        "ermcp.QryErmcpRsp": {
+            "$ref": "#/definitions/models.ErmcpModel"
+        },
+        "ermcp.QryHedgePlanRsp": {
+            "$ref": "#/definitions/models.ErmcpHedgePlan"
+        },
+        "ermcp.QryUserInfoRsp": {
+            "$ref": "#/definitions/models.ErmcpUserModel"
+        },
         "erms2.QueryArbitrageStrategyRsp": {
             "type": "object",
             "required": [
@@ -6052,33 +6196,7 @@
             }
         },
         "erms3.QryPendingBizRsp": {
-            "type": "object",
-            "properties": {
-                "accountid": {
-                    "description": "现货账户",
-                    "type": "string"
-                },
-                "areaname": {
-                    "description": "所属部门",
-                    "type": "string"
-                },
-                "bizid": {
-                    "description": "业务ID",
-                    "type": "string"
-                },
-                "bizname": {
-                    "description": "业务名称",
-                    "type": "string"
-                },
-                "status": {
-                    "description": "状态,0:待审核 1:审核通过 2:审核中 3:审核失败 4已撤销 5:审核拒绝",
-                    "type": "integer"
-                },
-                "type": {
-                    "description": "业务类型,1-期现套利,2-仓单回购,3-现货贸易",
-                    "type": "integer"
-                }
-            }
+            "$ref": "#/definitions/models.PendingAuditBizModel"
         },
         "erms3.QueryBusinessInfoRsp": {
             "type": "object",
@@ -6168,6 +6286,7 @@
                 },
                 "ouruser": {
                     "description": "我方账号",
+                    "type": "object",
                     "$ref": "#/definitions/erms3.CustomerInfo"
                 },
                 "warehouseinfos": {
@@ -6503,6 +6622,7 @@
                 },
                 "province": {
                     "description": "省",
+                    "type": "object",
                     "$ref": "#/definitions/models.Division"
                 }
             }
@@ -6615,6 +6735,221 @@
                 }
             }
         },
+        "models.ErmcpHedgePlan": {
+            "type": "object",
+            "properties": {
+                "contracttype": {
+                    "description": "计划类型 - 1:采购 -1:销售",
+                    "type": "integer"
+                },
+                "convertfactor": {
+                    "description": "标仓系数",
+                    "type": "number"
+                },
+                "deliverygoodsid": {
+                    "description": "现货品种ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货品种名称",
+                    "type": "string"
+                },
+                "hedgeplanid": {
+                    "description": "套保计划ID(601+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "hedgeplanno": {
+                    "description": "套保计划编号",
+                    "type": "string"
+                },
+                "hedgeplanstatus": {
+                    "description": "套保计划状态 -  0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回",
+                    "type": "integer"
+                },
+                "planqty": {
+                    "description": "计划数量",
+                    "type": "number"
+                },
+                "plantime": {
+                    "description": "计划时间",
+                    "type": "string"
+                },
+                "producttype": {
+                    "description": "产品类型 - 1:标准仓单 2:等标 3:非标",
+                    "type": "integer"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
+                "spotgoodsdesc": {
+                    "description": "商品型号",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "现货商品名称",
+                    "type": "string"
+                }
+            }
+        },
+        "models.ErmcpModel": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "账户ID",
+                    "type": "string"
+                },
+                "accountname": {
+                    "description": "账户名称",
+                    "type": "string"
+                },
+                "contracctstatus": {
+                    "description": "合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回",
+                    "type": "integer"
+                },
+                "convertfactor": {
+                    "description": "标仓系数",
+                    "type": "number"
+                },
+                "daikaiAmount": {
+                    "description": "待开票额",
+                    "type": "number"
+                },
+                "deliveryenddate": {
+                    "description": "交割结束日",
+                    "type": "string"
+                },
+                "deliverygoodscode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "现货商品名称",
+                    "type": "string"
+                },
+                "deliverystartdate": {
+                    "description": "交割开始日",
+                    "type": "string"
+                },
+                "enddate": {
+                    "description": "点价结束日",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
+                "goodscode": {
+                    "description": "点价商品代码",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "点价商品ID",
+                    "type": "integer"
+                },
+                "invoiceamount": {
+                    "description": "已开票额",
+                    "type": "number"
+                },
+                "payamount": {
+                    "description": "已收付额(收款或付款)",
+                    "type": "number"
+                },
+                "pricedqty": {
+                    "description": "已定价量",
+                    "type": "number"
+                },
+                "pricemove": {
+                    "description": "升贴水",
+                    "type": "number"
+                },
+                "pricetype": {
+                    "description": "定价类型 - 1:一口价 2:点价 3:暂定价",
+                    "type": "integer"
+                },
+                "producttype": {
+                    "description": "产品类型 - 1:标准仓单 2:等标 3:非标",
+                    "type": "integer"
+                },
+                "qty": {
+                    "description": "合同量",
+                    "type": "number"
+                },
+                "spotcontractid": {
+                    "description": "合同ID",
+                    "type": "integer"
+                },
+                "spotgoodsdesc": {
+                    "description": "商品型号(商品规格)",
+                    "type": "string"
+                },
+                "startdate": {
+                    "description": "点价开始日",
+                    "type": "string"
+                },
+                "unpayAmount": {
+                    "description": "待支收额(支付或收款)",
+                    "type": "number"
+                },
+                "unpricedqty": {
+                    "description": "未定价量",
+                    "type": "number"
+                },
+                "unsureqty": {
+                    "description": "未确定量",
+                    "type": "number"
+                }
+            }
+        },
+        "models.ErmcpUserModel": {
+            "type": "object",
+            "properties": {
+                "address": {
+                    "description": "通讯地址",
+                    "type": "string"
+                },
+                "cardnum": {
+                    "description": "证件号码",
+                    "type": "string"
+                },
+                "cardtype": {
+                    "description": "证件类型",
+                    "type": "string"
+                },
+                "customername": {
+                    "description": "企业名称",
+                    "type": "string"
+                },
+                "mobile": {
+                    "description": "手机号码",
+                    "type": "string"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
+                "status": {
+                    "description": "账户状态",
+                    "type": "string"
+                },
+                "telphone": {
+                    "description": "联系电话",
+                    "type": "string"
+                },
+                "userinfotype": {
+                    "description": "客户类型",
+                    "type": "string"
+                }
+            }
+        },
         "models.GoodsIDAndName": {
             "type": "object",
             "required": [
@@ -8181,7 +8516,7 @@
                 },
                 "coupontypeid": {
                     "description": "优惠券类型ID",
-                    "type": "integer"
+                    "type": "string"
                 },
                 "couponvalue": {
                     "description": "面值[1:现金券 - 抵扣值 2:折扣券-折扣值]",
@@ -8261,7 +8596,7 @@
                 },
                 "couponholdid": {
                     "description": "优惠券持仓ID(229+Unix秒时间戳(10位)+xxxxxx)",
-                    "type": "integer"
+                    "type": "string"
                 },
                 "couponname": {
                     "description": "优惠券名称",
@@ -8269,7 +8604,7 @@
                 },
                 "coupontypeid": {
                     "description": "优惠券类型ID - SEQ_COUPONTYPE",
-                    "type": "integer"
+                    "type": "string"
                 },
                 "couponvalue": {
                     "description": "面值[1:现金券 - 抵扣值 2:折扣券-折扣值]",
@@ -8374,6 +8709,35 @@
                 }
             }
         },
+        "models.PendingAuditBizModel": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "现货账户",
+                    "type": "string"
+                },
+                "areaname": {
+                    "description": "所属部门",
+                    "type": "string"
+                },
+                "bizid": {
+                    "description": "业务ID",
+                    "type": "string"
+                },
+                "bizname": {
+                    "description": "业务名称",
+                    "type": "string"
+                },
+                "status": {
+                    "description": "状态,0:待审核 1:审核通过 2:审核中 3:审核失败 4已撤销 5:审核拒绝",
+                    "type": "integer"
+                },
+                "type": {
+                    "description": "业务类型,1-期现套利,2-仓单回购,3-现货贸易",
+                    "type": "integer"
+                }
+            }
+        },
         "models.QuotePrimaryMenu": {
             "type": "object",
             "properties": {

+ 277 - 23
docs/swagger.yaml

@@ -87,6 +87,7 @@ definitions:
       province:
         $ref: '#/definitions/models.Division'
         description: 省
+        type: object
     type: object
   common.QueryTableDefineRsp:
     properties:
@@ -840,6 +841,12 @@ definitions:
     - mindeliveryqty
     - xdeliveryratio
     type: object
+  ermcp.QryErmcpRsp:
+    $ref: '#/definitions/models.ErmcpModel'
+  ermcp.QryHedgePlanRsp:
+    $ref: '#/definitions/models.ErmcpHedgePlan'
+  ermcp.QryUserInfoRsp:
+    $ref: '#/definitions/models.ErmcpUserModel'
   erms2.QueryArbitrageStrategyRsp:
     properties:
       applybasis:
@@ -1685,26 +1692,7 @@ definitions:
     - spotcontractid
     type: object
   erms3.QryPendingBizRsp:
-    properties:
-      accountid:
-        description: 现货账户
-        type: string
-      areaname:
-        description: 所属部门
-        type: string
-      bizid:
-        description: 业务ID
-        type: string
-      bizname:
-        description: 业务名称
-        type: string
-      status:
-        description: 状态,0:待审核 1:审核通过 2:审核中 3:审核失败 4已撤销 5:审核拒绝
-        type: integer
-      type:
-        description: 业务类型,1-期现套利,2-仓单回购,3-现货贸易
-        type: integer
-    type: object
+    $ref: '#/definitions/models.PendingAuditBizModel'
   erms3.QueryBusinessInfoRsp:
     properties:
       businessid:
@@ -1771,6 +1759,7 @@ definitions:
       ouruser:
         $ref: '#/definitions/erms3.CustomerInfo'
         description: 我方账号
+        type: object
       warehouseinfos:
         description: 仓库信息列表
         items:
@@ -2016,6 +2005,7 @@ definitions:
       province:
         $ref: '#/definitions/models.Division'
         description: 省
+        type: object
     type: object
   models.Division:
     properties:
@@ -2097,6 +2087,165 @@ definitions:
     - enumdicid
     - enumitemname
     type: object
+  models.ErmcpHedgePlan:
+    properties:
+      contracttype:
+        description: 计划类型 - 1:采购 -1:销售
+        type: integer
+      convertfactor:
+        description: 标仓系数
+        type: number
+      deliverygoodsid:
+        description: 现货品种ID
+        type: integer
+      deliverygoodsname:
+        description: 现货品种名称
+        type: string
+      hedgeplanid:
+        description: 套保计划ID(601+Unix秒时间戳(10位)+xxxxxx)
+        type: string
+      hedgeplanno:
+        description: 套保计划编号
+        type: string
+      hedgeplanstatus:
+        description: 套保计划状态 -  0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
+        type: integer
+      planqty:
+        description: 计划数量
+        type: number
+      plantime:
+        description: 计划时间
+        type: string
+      producttype:
+        description: 产品类型 - 1:标准仓单 2:等标 3:非标
+        type: integer
+      remark:
+        description: 备注
+        type: string
+      spotgoodsdesc:
+        description: 商品型号
+        type: string
+      wrstandardid:
+        description: 现货商品ID
+        type: integer
+      wrstandardname:
+        description: 现货商品名称
+        type: string
+    type: object
+  models.ErmcpModel:
+    properties:
+      accountid:
+        description: 账户ID
+        type: string
+      accountname:
+        description: 账户名称
+        type: string
+      contracctstatus:
+        description: 合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
+        type: integer
+      convertfactor:
+        description: 标仓系数
+        type: number
+      daikaiAmount:
+        description: 待开票额
+        type: number
+      deliveryenddate:
+        description: 交割结束日
+        type: string
+      deliverygoodscode:
+        description: 现货商品代码
+        type: string
+      deliverygoodsid:
+        description: 现货商品ID
+        type: integer
+      deliverygoodsname:
+        description: 现货商品名称
+        type: string
+      deliverystartdate:
+        description: 交割开始日
+        type: string
+      enddate:
+        description: 点价结束日
+        type: string
+      enumdicname:
+        description: 单位名称
+        type: string
+      goodscode:
+        description: 点价商品代码
+        type: string
+      goodsid:
+        description: 点价商品ID
+        type: integer
+      invoiceamount:
+        description: 已开票额
+        type: number
+      payamount:
+        description: 已收付额(收款或付款)
+        type: number
+      pricedqty:
+        description: 已定价量
+        type: number
+      pricemove:
+        description: 升贴水
+        type: number
+      pricetype:
+        description: 定价类型 - 1:一口价 2:点价 3:暂定价
+        type: integer
+      producttype:
+        description: 产品类型 - 1:标准仓单 2:等标 3:非标
+        type: integer
+      qty:
+        description: 合同量
+        type: number
+      spotcontractid:
+        description: 合同ID
+        type: integer
+      spotgoodsdesc:
+        description: 商品型号(商品规格)
+        type: string
+      startdate:
+        description: 点价开始日
+        type: string
+      unpayAmount:
+        description: 待支收额(支付或收款)
+        type: number
+      unpricedqty:
+        description: 未定价量
+        type: number
+      unsureqty:
+        description: 未确定量
+        type: number
+    type: object
+  models.ErmcpUserModel:
+    properties:
+      address:
+        description: 通讯地址
+        type: string
+      cardnum:
+        description: 证件号码
+        type: string
+      cardtype:
+        description: 证件类型
+        type: string
+      customername:
+        description: 企业名称
+        type: string
+      mobile:
+        description: 手机号码
+        type: string
+      remark:
+        description: 备注
+        type: string
+      status:
+        description: 账户状态
+        type: string
+      telphone:
+        description: 联系电话
+        type: string
+      userinfotype:
+        description: 客户类型
+        type: string
+    type: object
   models.GoodsIDAndName:
     properties:
       goodscode:
@@ -3296,7 +3445,7 @@ definitions:
         type: string
       coupontypeid:
         description: 优惠券类型ID
-        type: integer
+        type: string
       couponvalue:
         description: 面值[1:现金券 - 抵扣值 2:折扣券-折扣值]
         type: number
@@ -3356,13 +3505,13 @@ definitions:
         type: integer
       couponholdid:
         description: 优惠券持仓ID(229+Unix秒时间戳(10位)+xxxxxx)
-        type: integer
+        type: string
       couponname:
         description: 优惠券名称
         type: string
       coupontypeid:
         description: 优惠券类型ID - SEQ_COUPONTYPE
-        type: integer
+        type: string
       couponvalue:
         description: 面值[1:现金券 - 抵扣值 2:折扣券-折扣值]
         type: number
@@ -3439,6 +3588,27 @@ definitions:
         description: 菜单标题
         type: string
     type: object
+  models.PendingAuditBizModel:
+    properties:
+      accountid:
+        description: 现货账户
+        type: string
+      areaname:
+        description: 所属部门
+        type: string
+      bizid:
+        description: 业务ID
+        type: string
+      bizname:
+        description: 业务名称
+        type: string
+      status:
+        description: 状态,0:待审核 1:审核通过 2:审核中 3:审核失败 4已撤销 5:审核拒绝
+        type: integer
+      type:
+        description: 业务类型,1-期现套利,2-仓单回购,3-现货贸易
+        type: integer
+    type: object
   models.QuotePrimaryMenu:
     properties:
       Index:
@@ -5433,6 +5603,7 @@ definitions:
 info:
   contact: {}
   description: 新的查询服务,替代原通用查询服务。
+  license: {}
   termsOfService: http://muchinfo.cn
   title: MTP2.0 查询服务 API
   version: "1.0"
@@ -5868,6 +6039,89 @@ paths:
       summary: 查询商品交割关系表
       tags:
       - 交割服务
+  /Ermcp/QueryContract:
+    get:
+      parameters:
+      - description: 合同类型 1-采购, -1-销售
+        in: query
+        name: contracttype
+        required: true
+        type: integer
+      - description: 查询类型 1-全部 2-待点价 3-履约结算
+        in: query
+        name: QueryType
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/ermcp.QryErmcpRsp'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询合同(采购和销售)
+      tags:
+      - 企业风险管理(app)
+  /Ermcp/QueryHedgePlan:
+    get:
+      parameters:
+      - description: 套保计划状态 -  0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
+        in: query
+        name: HedgePlanStatus
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/ermcp.QryHedgePlanRsp'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询套保计划
+      tags:
+      - 企业风险管理(app)
+  /Ermcp/QueryUserInfo:
+    get:
+      parameters:
+      - description: 账户状态(可填多个, 逗号隔开) 1:待激活 2:待审核 3:待复审 4:正常 5:审核拒绝 6:注销
+        in: query
+        name: AccountStatus
+        required: true
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/ermcp.QryUserInfoRsp'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询客户资料
+      tags:
+      - 企业风险管理(app)
   /Erms2/QueryArbitrageStrategy:
     get:
       parameters:

+ 2 - 0
go.sum

@@ -211,9 +211,11 @@ github.com/mattn/go-sqlite3 v2.0.1+incompatible h1:xQ15muvnzGBHpIpdrNi1DA5x0+TcB
 github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
 github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
 github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
 github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
 github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
 github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
 github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=

+ 139 - 0
models/ermcp.go

@@ -0,0 +1,139 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/1/5 15:15
+* @Modify  : 2021/1/5 15:15
+ */
+
+// 企业风险管理
+package models
+
+import (
+	"fmt"
+	"mtp2_if/db"
+	"mtp2_if/logger"
+)
+
+// 风险管理合同
+type ErmcpModel struct {
+	SpotContractId    int64   `json:"spotcontractid"  xorm:"'SPOTCONTRACTID'"`       // 合同ID
+	AccountId         string  `json:"accountid"  xorm:"'ACCOUNTID'"`                 // 账户ID
+	AccountName       string  `json:"accountname"  xorm:"'ACCOUNTNAME'"`             // 账户名称
+	DeliveryGoodsId   int     `json:"deliverygoodsid"  xorm:"'DELIVERYGOODSID'"`     // 现货商品ID
+	DeliveryGoodsCode string  `json:"deliverygoodscode"  xorm:"'DELIVERYGOODSCODE'"` // 现货商品代码
+	DeliveryGoodsName string  `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"` // 现货商品名称
+	SpotGoodsdesc     string  `json:"spotgoodsdesc"  xorm:"'SPOTGOODSDESC'"`         // 商品型号(商品规格)
+	GoodsId           int     `json:"goodsid"  xorm:"'GOODSID'"`                     // 点价商品ID
+	Goodscode         string  `json:"goodscode"  xorm:"'GOODSCODE'"`                 // 点价商品代码
+	Pricemove         float64 `json:"pricemove"  xorm:"'PRICEMOVE'"`                 // 升贴水
+	Qty               float64 `json:"qty"  xorm:"'QTY'"`                             // 合同量
+	UnpricedQty       float64 `json:"unpricedqty"  xorm:"'UNPRICEDQTY'"`             // 未定价量
+	PricedQty         float64 `json:"pricedqty"  xorm:"'PRICEDQTY'"`                 // 已定价量
+	UnsureQty         float64 `json:"unsureqty"  xorm:"'UNSUREQTY'"`                 // 未确定量
+	PayAmount         float64 `json:"payamount"  xorm:"'PAYAMOUNT'"`                 // 已收付额(收款或付款)
+	UnpayAmount       float64 `json:"unpayAmount"  xorm:"'UNPAYAMOUNT'"`             // 待支收额(支付或收款)
+	InvoiceAmount     float64 `json:"invoiceamount"  xorm:"'INVOICEAMOUNT'"`         // 已开票额
+	DaikaiAmount      float64 `json:"daikaiAmount"  xorm:"'DAIKAIAMOUNT'"`           // 待开票额
+	StartDate         string  `json:"startdate"  xorm:"'STARTDATE'"`                 // 点价开始日
+	EndDate           string  `json:"enddate"  xorm:"'ENDDATE'"`                     // 点价结束日
+	DeliveryStartDate string  `json:"deliverystartdate"  xorm:"'DELIVERYSTARTDATE'"` // 交割开始日
+	DeliveryendDate   string  `json:"deliveryenddate"  xorm:"'DELIVERYENDDATE'"`     // 交割结束日
+	Convertfactor     float64 `json:"convertfactor"  xorm:"'CONVERTFACTOR'"`         // 标仓系数
+	EnumdicName       string  `json:"enumdicname"  xorm:"'ENUMDICNAME'"`             // 单位名称
+	Contracctstatus   uint    `json:"contracctstatus"  xorm:"'CONTRACCTSTATUS'"`     // 合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
+	PriceType         int     `json:"pricetype"  xorm:"'PRICETYPE'"`                 // 定价类型 - 1:一口价 2:点价 3:暂定价
+	ProductType       int     `json:"producttype"  xorm:"'PRODUCTTYPE'"`             // 产品类型 - 1:标准仓单 2:等标 3:非标
+}
+
+// 组装查询的sql
+func (r *ErmcpModel) buildSql(nContractType, nQueryType int32) string {
+	str := "select t.contractno," +
+		"       t.SpotContractId," +
+		"       t.deliverygoodsid," +
+		"       t.spotgoodsdesc," +
+		"       t.goodsid," +
+		"       t.pricemove," +
+		"       t.qty," +
+		"       t.qty - t.pricedqty unpricedqty," +
+		"       t.pricedqty," +
+		"       (case" +
+		"         when t.pricetype = 3 then" +
+		"          t.qty - t.RECKONREALQTY" +
+		"         else" +
+		"          t.qty - t.pricedqty" +
+		"       end) unsureqty," +
+		"       t.reckonedamount PayAmount," +
+		"       t.pricedamount + t.reckonadjustamount - t.RECKONEDAMOUNT unpayAmount," +
+		"       t.invoiceamount," +
+		"       (t.pricedamount + t.RECKONADJUSTAMOUNT + t.RECKONOTHERAMOUNT -" +
+		"       t.invoiceamount) as daikaiAmount," +
+		"       to_char(t.startdate, 'mmdd') startdate," +
+		"       to_char(t.enddate, 'mmdd') enddate," +
+		"       to_char(t.deliverystartdate, 'mmdd') deliverystartdate," +
+		"       to_char(t.deliveryenddate, 'mmdd') deliveryenddate," +
+		"       t.convertfactor," +
+		"       t.contracctstatus," +
+		"       t.pricetype," +
+		"       t.producttype," +
+		"       t.contracttype," +
+		"       to_char(ta.accountid) accountid," +
+		"       ta.accountname," +
+		"       g.deliverygoodscode," +
+		"       g.deliverygoodsname," +
+		"       g2.goodscode," +
+		"       e.enumdicname" +
+		"  from ermcp_spotcontract t" +
+		"  left join taaccount ta" +
+		"    on t.%v = ta.userid" +
+		"  left join deliverygoods g" +
+		"    on t.deliverygoodsid = g.deliverygoodsid" +
+		"  left join goods g2" +
+		"    on t.goodsid = g2.goodsid" +
+		"  left join wrstandard wr" +
+		"    on t.wrstandardid = wr.wrstandardid" +
+		"  left join enumdicitem e" +
+		"    on wr.unitid = e.enumitemname" +
+		"   and e.enumdiccode = 'goodsunit'" +
+		" where t.contracctstatus in (%v)" +
+		"   and t.contracttype in (%v)"
+
+	var status string
+	if 0 == nQueryType {
+		// 全部
+		status = "0,1,2,3,4,5,6"
+		str = str + " order by t.audittime desc"
+	} else if 1 == nQueryType {
+		// 待点价
+		status = "2"
+		str = str + "  and t.qty - t.pricedqty > 0 " +
+			"order by unpricedqty, t.audittime desc"
+	} else {
+		// 履约
+		status = "2"
+		str = str + " order by t.audittime desc"
+	}
+
+	var usrId string
+
+	switch nContractType {
+	case 1: // 采购
+		usrId = "buyuserid"
+	case -1: // 销售
+		usrId = "selluserid"
+	}
+
+	sqlId := fmt.Sprintf(str, usrId, status, nContractType)
+
+	return sqlId
+}
+
+// 从数据库中查询合同
+func (r *ErmcpModel) GetData(contractType, nQueryType int32) ([]ErmcpModel, error) {
+	sData := make([]ErmcpModel, 0)
+	e := db.GetEngine()
+	s := e.SQL(r.buildSql(contractType, nQueryType))
+	if err := s.Find(&sData); err != nil {
+		logger.GetLogger().Errorf("ermcp query fail:%v", err)
+		return sData, err
+	}
+	return sData, nil
+}

+ 68 - 0
models/ermcpHedgePlan.go

@@ -0,0 +1,68 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/1/7 17:58
+* @Modify  : 2021/1/7 17:58
+ */
+
+package models
+
+import (
+	"fmt"
+	"mtp2_if/db"
+	"mtp2_if/logger"
+)
+
+// 套保计划表结构
+type ErmcpHedgePlan struct {
+	Hedgeplanid       string  `json:"hedgeplanid"  xorm:"'Hedgeplanid'"`             //套保计划ID(601+Unix秒时间戳(10位)+xxxxxx)
+	Hedgeplanno       string  `json:"hedgeplanno"  xorm:"'Hedgeplanno'"`             //套保计划编号
+	Contracttype      int     `json:"contracttype"  xorm:"'Contracttype'"`           //计划类型 - 1:采购 -1:销售
+	Deliverygoodsid   int     `json:"deliverygoodsid"  xorm:"'Deliverygoodsid'"`     //现货品种ID
+	Deliverygoodsname string  `json:"deliverygoodsname"  xorm:"'Deliverygoodsname'"` //现货品种名称
+	Wrstandardid      int     `json:"wrstandardid"  xorm:"'Wrstandardid'"`           //现货商品ID
+	Wrstandardname    string  `json:"wrstandardname"  xorm:"'Wrstandardname'"`       // 现货商品名称
+	Producttype       int     `json:"producttype"  xorm:"'Producttype'"`             //产品类型 - 1:标准仓单 2:等标 3:非标
+	Spotgoodsdesc     string  `json:"spotgoodsdesc"  xorm:"'Spotgoodsdesc'"`         //商品型号
+	Planqty           float64 `json:"planqty"  xorm:"'Planqty'"`                     //计划数量
+	Convertfactor     float64 `json:"convertfactor"  xorm:"'Convertfactor'"`         //标仓系数
+	Plantime          string  `json:"plantime"  xorm:"'Plantime'"`                   //计划时间
+	Hedgeplanstatus   int     `json:"hedgeplanstatus"  xorm:"'Hedgeplanstatus'"`     //套保计划状态 -  0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
+	Remark            string  `json:"remark"  xorm:"'Remark'"`                       //备注
+}
+
+func (r *ErmcpHedgePlan) buildSql(status int) string {
+	str := "select to_char(t.Hedgeplanid) Hedgeplanid," +
+		"       t.Hedgeplanno," +
+		"       t.Contracttype," +
+		"       t.Deliverygoodsid," +
+		"       t.g.Deliverygoodsname," +
+		"       t.Wrstandardid," +
+		"       w.Wrstandardname," +
+		"       t.Producttype," +
+		"       t.Spotgoodsdesc," +
+		"       t.Planqty," +
+		"       t.Convertfactor," +
+		"       t.Plantime," +
+		"       t.Hedgeplanstatus," +
+		"       t.Remark" +
+		"  from ermcp_hedgeplan t" +
+		"  left join wrstandard w" +
+		"    on t.wrstandardid = w.wrstandardid" +
+		"  left join deliverygoods g" +
+		"    on t.deliverygoodsid = g.deliverygoodsid" +
+		" where t.hedgeplanstatus in (%v)"
+
+	return fmt.Sprintf(str, status)
+}
+
+// 从数据库中查询套保计划数据
+func (r *ErmcpHedgePlan) GetData(status int) ([]ErmcpHedgePlan, error) {
+	e := db.GetEngine()
+	sData := make([]ErmcpHedgePlan, 0)
+	if err := e.SQL(r.buildSql(status)).Find(&sData); err != nil {
+		logger.GetLogger().Errorf("query hedgeplan:%v", err)
+		return sData, err
+	}
+
+	return sData, nil
+}

+ 94 - 0
models/ermcpUser.go

@@ -0,0 +1,94 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/1/7 17:31
+* @Modify  : 2021/1/7 17:31
+ */
+
+package models
+
+import (
+	"crypto/aes"
+	"encoding/hex"
+	"fmt"
+	"mtp2_if/db"
+	"mtp2_if/logger"
+)
+
+// 客户资料结构
+type ErmcpUserModel struct {
+	USERINFOTYPE string `json:"userinfotype"  xorm:"'USERINFOTYPE'"` // 客户类型
+	CUSTOMERNAME string `json:"customername"  xorm:"'CUSTOMERNAME'"` // 企业名称
+	CARDTYPE     string `json:"cardtype"  xorm:"'CARDTYPE'"`         // 证件类型
+	CARDNUM      string `json:"cardnum"  xorm:"'CARDNUM'"`           // 证件号码
+	MOBILE       string `json:"mobile"  xorm:"'MOBILE'"`             // 手机号码
+	TELPHONE     string `json:"telphone"  xorm:"'TELPHONE'"`         // 联系电话
+	ADDRESS      string `json:"address"  xorm:"'ADDRESS'"`           // 通讯地址
+	REMARK       string `json:"remark"  xorm:"'REMARK'"`             // 备注
+	Status       string `json:"status"  xorm:"'STATUS'"`             // 账户状态
+}
+
+func (r *ErmcpUserModel) buildSql(accStatus string) string {
+	str := "select u.USERINFOTYPE," +
+		"       u.CUSTOMERNAME," +
+		"       u.CARDTYPEID," +
+		"       e.enumdicname CARDTYPE," +
+		"       u.CARDNUM," +
+		"       u.MOBILE," +
+		"       u.TELPHONE," +
+		"       u.ADDRESS," +
+		"       u.REMARK," +
+		"       t.accountstatus," +
+		"       decode(t.accountstatus,1,'待激活',2,'待审核',3,'待复审',4,'正常',5,'审核拒绝',6,'注销', '缺省') Status" +
+		"  from useraccount t" +
+		"  left join userinfo u" +
+		"    on t.userid = u.userid" +
+		"  left join enumdicitem e" +
+		"    on u.cardtypeid = e.enumitemname" +
+		"   and e.enumdiccode = 'certificatetype'" +
+		"  where t.accountstatus in (%v)"
+
+	return fmt.Sprintf(str, accStatus)
+}
+
+// 解密卡号和电话号码字段
+func (r *ErmcpUserModel) DecryptField() {
+	key := "0d299ce2d4105282f7471074cb0f9f9d"
+	key2, _ := hex.DecodeString(key)
+	b, _ := aes.NewCipher(key2)
+	fd := func(str string) string {
+		if str == "" {
+			return str
+		}
+
+		d, _ := hex.DecodeString(str)
+		b.Decrypt(d, d)
+		if len(d) >= 16 {
+			if cnt := d[len(d)-1]; int(cnt) < len(d) {
+				d = d[:len(d)-int(cnt)]
+			}
+			return string(d)
+		}
+		return str
+	}
+
+	r.CARDNUM = fd(r.CARDNUM)
+	r.MOBILE = fd(r.MOBILE)
+}
+
+// 查询客户资料
+func (r *ErmcpUserModel) GetData(accStatus string) ([]ErmcpUserModel, error) {
+	sData := make([]ErmcpUserModel, 0)
+	e := db.GetEngine()
+	s := e.SQL(r.buildSql(accStatus))
+	if err := s.Find(&sData); err != nil {
+		logger.GetLogger().Errorf("ermcp query fail:%v", err)
+		return sData, err
+	}
+
+	// 解密
+	for i := range sData {
+		sData[i].DecryptField()
+	}
+
+	return sData, nil
+}

+ 11 - 0
routers/router.go

@@ -6,6 +6,7 @@ import (
 	"mtp2_if/controllers/common"
 	"mtp2_if/controllers/cptrade"
 	"mtp2_if/controllers/delivery"
+	"mtp2_if/controllers/ermcp"
 	"mtp2_if/controllers/erms2"
 	"mtp2_if/controllers/erms3"
 	"mtp2_if/controllers/hsby"
@@ -290,6 +291,16 @@ func InitRouter() *gin.Engine {
 		hsbyR.GET("/QueryMyCouponHolds", hsby.QueryMyCouponHolds)
 	}
 
+	// ***************************** 企业风险管理(app)***************************
+	ermcpR := apiR.Group("Ermcp")
+	ermcpR.Use(token.Auth())
+	{
+		// 查询待点价、履约和全部合同
+		ermcpR.GET("/QueryUserInfo", ermcp.QueryUserInfo)
+		ermcpR.GET("/QueryContract", ermcp.QueryContract)
+		ermcpR.GET("/QueryHedgePlan", ermcp.QueryHedgePlan)
+	}
+
 	return r
 }