zou.yingbin 4 rokov pred
rodič
commit
f834771785

+ 159 - 0
controllers/ermcp/qryAccMgr.go

@@ -0,0 +1,159 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/3/30 13:37
+* @Modify  : 2021/3/30 13:37
+* @Note    : 账户管理
+**/
+
+package ermcp
+
+import (
+	"github.com/gin-gonic/gin"
+	"mtp2_if/global/app"
+	"mtp2_if/models"
+)
+
+// QryLoginUserReq
+type QryLoginUserReq struct {
+	UserId int64 `form:"userid" binding:"required"` // 用户id
+}
+
+// QueryAccMgrLoginUser
+// @Summary 查询账户管理登录账号(账户管理/登录账号)
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
+// @Success 200 {array} models.ErmcpLoginUserEx
+// @Failure 500 {object} app.Response
+// @Router /Ermcp/QueryAccMgrLoginUser [get]
+// @Tags 企业风险管理(app)
+func QueryAccMgrLoginUser(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	req := QryLoginUserReq{}
+	a.DoBindReq(&req)
+	m := models.ErmcpLoginUser{MEMBERUSERID: req.UserId, USERID: req.UserId}
+	a.DoGetDataI(&m)
+}
+
+// QueryAccMgrTaaccount
+// @Summary 查询账户管理期货账号(账户管理/期货账号)
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
+// @Success 200 {array} models.ErmcpTaAccountEx
+// @Failure 500 {object} app.Response
+// @Router /Ermcp/QueryAccMgrTaaccount [get]
+// @Tags 企业风险管理(app)
+func QueryAccMgrTaaccount(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	req := QryLoginUserReq{}
+	a.DoBindReq(&req)
+	m := models.ErmcpTaAccount{RELATEDUSERID: req.UserId}
+	a.DoGetDataI(&m)
+}
+
+// QueryAccountReq 查主账号请求
+type QueryAccountReq struct {
+	UserId    int64  `form:"userid"`    // 用户id
+	AccountId string `form:"accountid"` // 主账号id
+}
+
+// QueryAccMgrMainAccountInfo
+// @Summary 查询账户管理主账号详情(账户管理/期货主账号详情)
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int false "用户ID"
+// @Param accountid query int false "主账号id"
+// @Success 200 {array} models.MainAccountInfo
+// @Failure 500 {object} app.Response
+// @Router /Ermcp/QueryAccMgrMainAccountInfo [get]
+// @Tags 企业风险管理(app)
+func QueryAccMgrMainAccountInfo(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	req := QueryAccountReq{}
+	a.DoBindReq(&req)
+	m := models.MainAccountInfo{RELATEDUSERID: req.UserId, ACCOUNTID: req.AccountId}
+	a.DoGetDataI(&m)
+}
+
+// QueryAccMgrRole
+// @Summary 查询账户管理角色设置(账户管理/角色设置)
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
+// @Success 200 {array} models.ErmcpRole
+// @Failure 500 {object} app.Response
+// @Router /Ermcp/QueryAccMgrRole [get]
+// @Tags 企业风险管理(app)
+func QueryAccMgrRole(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	req := QryLoginUserReq{}
+	a.DoBindReq(&req)
+	m := models.ErmcpRole{AREAUSERID: req.UserId}
+	a.DoGetDataI(&m)
+}
+
+// QryRoleMenuReq
+type QryRoleMenuReq struct {
+	UserId int64  `form:"userid" binding:"required"` // 用户id
+	RoleId string `form:"roleid"`                    // 角色id(可多个,逗号隔开)
+}
+
+// QueryAccMgrRoleMenu
+// @Summary 查询账户管理角色详情(账户管理/角色设置/角色详情)
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
+// @Param roleid query string false "角色id(可多个,逗号隔开)"
+// @Success 200 {array} models.ErmcpRoleMenuEx
+// @Failure 500 {object} app.Response
+// @Router /Ermcp/QueryAccMgrRoleMenu [get]
+// @Tags 企业风险管理(app)
+func QueryAccMgrRoleMenu(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	req := QryRoleMenuReq{}
+	a.DoBindReq(&req)
+	m := models.ErmcpRoleMenu{USERID: req.UserId, FilterRoleId: req.RoleId}
+	a.DoGetDataI(&m)
+}
+
+// QueryAccMgrBizGroupSet
+// @Summary 查询业务类型分组(账户管理/账户设置)
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
+// @Success 200 {array} models.ErmcpBizGroupEx
+// @Failure 500 {object} app.Response
+// @Router /Ermcp/QueryAccMgrBizGroupSet [get]
+// @Tags 企业风险管理(app)
+func QueryAccMgrBizGroupSet(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	req := QryLoginUserReq{}
+	a.DoBindReq(&req)
+	m := models.ErmcpBizGroupEx{AREAUSERID: req.UserId}
+	a.DoGetDataI(&m)
+}
+
+// QryTaAccountReq 查询资金账号
+type QryTaAccountReq struct {
+	UserId    int64 `form:"userid"`    // 用户id
+	AccountId int64 `form:"accountid"` // 账号id
+}
+
+// QueryAccMgrTaAccountInfo
+// @Summary 查询账户管理授信(账户管理/账户设置/授信)
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
+// @Param accountid query int false "账号id"
+// @Success 200 {array} models.ErmcpTaAccountInfo
+// @Failure 500 {object} app.Response
+// @Router /Ermcp/QueryAccMgrTaAccountInfo [get]
+// @Tags 企业风险管理(app)
+func QueryAccMgrTaAccountInfo(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	req := QryTaAccountReq{}
+	a.DoBindReq(&req)
+	m := models.ErmcpTaAccountInfo{RELATEDUSERID: req.UserId, ACCOUNTID: req.AccountId}
+	a.DoGetDataI(&m)
+}

+ 856 - 8
docs/docs.go

@@ -1403,6 +1403,317 @@ var doc = `{
                 }
             }
         },
+        "/Ermcp/QueryAccMgrBizGroupSet": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询业务类型分组(账户管理/账户设置)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpBizGroupEx"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp/QueryAccMgrLoginUser": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询账户管理登录账号(账户管理/登录账号)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpLoginUserEx"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp/QueryAccMgrMainAccountInfo": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询账户管理主账号详情(账户管理/期货主账号详情)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "主账号id",
+                        "name": "accountid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.MainAccountInfo"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp/QueryAccMgrRole": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询账户管理角色设置(账户管理/角色设置)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpRole"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp/QueryAccMgrRoleMenu": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询账户管理角色详情(账户管理/角色设置/角色详情)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "角色id(可多个,逗号隔开)",
+                        "name": "roleid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpRoleMenuEx"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp/QueryAccMgrTaAccountInfo": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询账户管理授信(账户管理/账户设置/授信)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "账号id",
+                        "name": "accountid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpTaAccountInfo"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp/QueryAccMgrTaaccount": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询账户管理期货账号(账户管理/期货账号)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpTaAccountEx"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp/QueryAreaStock": {
             "get": {
                 "security": [
@@ -11616,6 +11927,91 @@ var doc = `{
                 }
             }
         },
+        "models.ErmcpBizGroupEx": {
+            "type": "object",
+            "properties": {
+                "acclist": {
+                    "description": "账号列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.ErmcpBizGroupTaAccount"
+                    }
+                },
+                "bizgroupid": {
+                    "description": "业务分组id",
+                    "type": "integer"
+                },
+                "biztype": {
+                    "description": "业务类型 1-套保 2-套利",
+                    "type": "integer"
+                },
+                "wrlist": {
+                    "description": "现货商品表表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.ErmcpBizGroupSpotGoods"
+                    }
+                }
+            }
+        },
+        "models.ErmcpBizGroupSpotGoods": {
+            "type": "object",
+            "properties": {
+                "areauserid": {
+                    "description": "所属机构id",
+                    "type": "integer"
+                },
+                "bizgroupid": {
+                    "description": "分组id",
+                    "type": "integer"
+                },
+                "biztype": {
+                    "description": "业务类型 1-套保 2-套利",
+                    "type": "integer"
+                },
+                "unitid": {
+                    "description": "现货商品单位id",
+                    "type": "integer"
+                },
+                "wrstandardcode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品id",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "现货商品名称",
+                    "type": "string"
+                }
+            }
+        },
+        "models.ErmcpBizGroupTaAccount": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "账号id",
+                    "type": "string"
+                },
+                "accountname": {
+                    "description": "账号名称",
+                    "type": "string"
+                },
+                "areauserid": {
+                    "description": "所属机构id",
+                    "type": "integer"
+                },
+                "bizgroupid": {
+                    "description": "业务分组id",
+                    "type": "integer"
+                },
+                "ismain": {
+                    "description": "是否主账号 1-是 0-否",
+                    "type": "integer"
+                }
+            }
+        },
         "models.ErmcpExposureDetailModel": {
             "type": "object",
             "properties": {
@@ -12173,6 +12569,75 @@ var doc = `{
                 }
             }
         },
+        "models.ErmcpLoginUser": {
+            "type": "object",
+            "properties": {
+                "accountname": {
+                    "description": "用户名称",
+                    "type": "string"
+                },
+                "clientroleid": {
+                    "description": "角色id(usertype=2)",
+                    "type": "integer"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "loginstatus": {
+                    "description": "登录账户状态 - 1:正常 2:冻结 3:无效",
+                    "type": "integer"
+                },
+                "memberuserid": {
+                    "description": "所属会员id",
+                    "type": "integer"
+                },
+                "modifytime": {
+                    "description": "修改时间",
+                    "type": "string"
+                },
+                "rolename": {
+                    "description": "角色名称",
+                    "type": "string"
+                },
+                "rolestatus": {
+                    "description": "角色状态 1-启用 2-停用",
+                    "type": "integer"
+                },
+                "roletype": {
+                    "description": "角色类型(逗号隔开,如22,23), 22:业务员 23:跟单员 24:交易员",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "用户id",
+                    "type": "integer"
+                },
+                "usertype": {
+                    "description": "用户类型 -  1:交易所 2:机构 3:会员子机构 4:经纪人 5:投资者 6:客户 7:企业成员(云平台)",
+                    "type": "integer"
+                }
+            }
+        },
+        "models.ErmcpLoginUserEx": {
+            "type": "object",
+            "properties": {
+                "rolename": {
+                    "description": "角色名称",
+                    "type": "string"
+                },
+                "userlist": {
+                    "description": "用户列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.ErmcpLoginUser"
+                    }
+                },
+                "usertype": {
+                    "description": "用户类型 2-机构 7-企业成员(云平台)",
+                    "type": "integer"
+                }
+            }
+        },
         "models.ErmcpMiddleGoodsChangeLog": {
             "type": "object",
             "properties": {
@@ -12363,7 +12828,7 @@ var doc = `{
                     "type": "string"
                 },
                 "daikaiamount": {
-                    "description": "待开票额",
+                    "description": "应收(开)票额",
                     "type": "number"
                 },
                 "deliveryenddate": {
@@ -12426,6 +12891,14 @@ var doc = `{
                     "description": "已收付额(收款或付款)",
                     "type": "number"
                 },
+                "preinvoiceamount": {
+                    "description": "预收(开)票额",
+                    "type": "number"
+                },
+                "prepayamount": {
+                    "description": "预收付额",
+                    "type": "number"
+                },
                 "price": {
                     "description": "价格",
                     "type": "number"
@@ -12463,7 +12936,7 @@ var doc = `{
                     "type": "number"
                 },
                 "reckonedamount": {
-                    "description": "已收付额(已确定额)",
+                    "description": "实际已收付额(已确定额,已收付总额-已退款总额)",
                     "type": "number"
                 },
                 "reckonotheramount": {
@@ -12503,7 +12976,7 @@ var doc = `{
                     "type": "number"
                 },
                 "unpayamount": {
-                    "description": "待支收额(支付或收款)",
+                    "description": "应收付款额(应支付或应收款)",
                     "type": "number"
                 },
                 "unpricedqty": {
@@ -13158,13 +13631,116 @@ var doc = `{
                     "description": "现货商品代码",
                     "type": "string"
                 },
-                "wrstandardid": {
-                    "description": "现货商品ID",
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "现货商品名称",
+                    "type": "string"
+                }
+            }
+        },
+        "models.ErmcpRole": {
+            "type": "object",
+            "properties": {
+                "areauserid": {
+                    "description": "所属机构",
+                    "type": "integer"
+                },
+                "autoid": {
+                    "description": "角色ID(自增ID)",
+                    "type": "integer"
+                },
+                "modifierid": {
+                    "description": "修改人(创建人)",
+                    "type": "integer"
+                },
+                "modifiername": {
+                    "description": "修改人名称",
+                    "type": "string"
+                },
+                "modifytime": {
+                    "description": "修改时间(创建时间)",
+                    "type": "string"
+                },
+                "rolename": {
+                    "description": "角色名称",
+                    "type": "string"
+                },
+                "rolestatus": {
+                    "description": "角色状态 - 1:启用  2:停用",
+                    "type": "integer"
+                },
+                "roletype": {
+                    "description": "角色类型 - 1- 管理端   2-  交易端",
+                    "type": "integer"
+                }
+            }
+        },
+        "models.ErmcpRoleMenu": {
+            "type": "object",
+            "properties": {
+                "iconame": {
+                    "description": "菜单图标",
+                    "type": "string"
+                },
+                "menutype": {
+                    "description": "菜单类型 1:管理端 2:交易端 3:终端(企业云平台)",
+                    "type": "integer"
+                },
+                "parentcode": {
+                    "description": "上级资源代码",
+                    "type": "string"
+                },
+                "remark": {
+                    "description": "菜单备注",
+                    "type": "string"
+                },
+                "resourcecode": {
+                    "description": "菜单代码",
+                    "type": "string"
+                },
+                "resourcelevel": {
+                    "description": "级别",
+                    "type": "integer"
+                },
+                "resourcename": {
+                    "description": "菜单名称",
+                    "type": "string"
+                },
+                "roleid": {
+                    "description": "角色id",
+                    "type": "integer"
+                },
+                "sort": {
+                    "description": "排序",
+                    "type": "integer"
+                },
+                "url": {
+                    "description": "URL",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "用户id",
                     "type": "integer"
+                }
+            }
+        },
+        "models.ErmcpRoleMenuEx": {
+            "type": "object",
+            "properties": {
+                "menu": {
+                    "description": "父级菜单",
+                    "type": "object",
+                    "$ref": "#/definitions/models.ErmcpRoleMenu"
                 },
-                "wrstandardname": {
-                    "description": "现货商品名称",
-                    "type": "string"
+                "subMenu": {
+                    "description": "子级菜单",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.ErmcpRoleMenu"
+                    }
                 }
             }
         },
@@ -13345,6 +13921,233 @@ var doc = `{
                 }
             }
         },
+        "models.ErmcpTaAccount": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "账户id",
+                    "type": "integer"
+                },
+                "accountname": {
+                    "description": "账户名称",
+                    "type": "string"
+                },
+                "currencyid": {
+                    "description": "币种id",
+                    "type": "integer"
+                },
+                "ismain": {
+                    "description": "是否主账户 0-否 1-是",
+                    "type": "integer"
+                },
+                "parentaccountid": {
+                    "description": "父账户id",
+                    "type": "integer"
+                },
+                "relateduserid": {
+                    "description": "关联userid",
+                    "type": "integer"
+                },
+                "tradestatus": {
+                    "description": "交易状态 - 1:正常 2:受限 3:冻结 4:禁止建仓(人工受限) 5:禁止交易(人工冻结) 6:待激活 7:已注销",
+                    "type": "integer"
+                }
+            }
+        },
+        "models.ErmcpTaAccountEx": {
+            "type": "object",
+            "properties": {
+                "mainAcc": {
+                    "description": "主账号",
+                    "type": "object",
+                    "$ref": "#/definitions/models.ErmcpTaAccount"
+                },
+                "subacclist": {
+                    "description": "子账号列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.ErmcpTaAccount"
+                    }
+                }
+            }
+        },
+        "models.ErmcpTaAccountInfo": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "资金账户ID",
+                    "type": "integer"
+                },
+                "accountname": {
+                    "description": "账户名称",
+                    "type": "string"
+                },
+                "balance": {
+                    "description": "期初余额",
+                    "type": "number"
+                },
+                "capitalbalance": {
+                    "description": "本金余额[外部子账户实际出入金余额]",
+                    "type": "number"
+                },
+                "closepl": {
+                    "description": "今日平仓盈亏",
+                    "type": "number"
+                },
+                "creditdecrease": {
+                    "description": "今日授信减少",
+                    "type": "number"
+                },
+                "creditincrease": {
+                    "description": "今日授信增加",
+                    "type": "number"
+                },
+                "curdebt": {
+                    "description": "期末欠款",
+                    "type": "number"
+                },
+                "currencyid": {
+                    "description": "货币ID",
+                    "type": "integer"
+                },
+                "currentbalance": {
+                    "description": "期末余额",
+                    "type": "number"
+                },
+                "freezecharge": {
+                    "description": "手续费冻结",
+                    "type": "number"
+                },
+                "freezemargin": {
+                    "description": "冻结保证金",
+                    "type": "number"
+                },
+                "fromaccountid": {
+                    "description": "所属上级账户",
+                    "type": "integer"
+                },
+                "inamount": {
+                    "description": "今日入金金额(包括三方入金)",
+                    "type": "number"
+                },
+                "ismain": {
+                    "description": "是否母账号 0:不是母账户 1:是母账户",
+                    "type": "integer"
+                },
+                "mortgagecredit": {
+                    "description": "授信金额",
+                    "type": "number"
+                },
+                "oridebt": {
+                    "description": "期初欠款",
+                    "type": "number"
+                },
+                "orifreezecharge": {
+                    "description": "期初手续费冻结",
+                    "type": "number"
+                },
+                "orifreezemargin": {
+                    "description": "期初冻结保证金",
+                    "type": "number"
+                },
+                "orimortgagecredit": {
+                    "description": "期初授信金额",
+                    "type": "number"
+                },
+                "oriothercredit": {
+                    "description": "期初其它授信金额",
+                    "type": "number"
+                },
+                "oriotherfreezemargin": {
+                    "description": "期初其他冻结保证金(出金冻结资金 交割买方冻结 申购冻结 全款买入 商城买入)",
+                    "type": "number"
+                },
+                "orioutamountfreeze": {
+                    "description": "期初出金冻结",
+                    "type": "number"
+                },
+                "oriusedmargin": {
+                    "description": "期初占用保证金",
+                    "type": "number"
+                },
+                "othercredit": {
+                    "description": "其它授信金额",
+                    "type": "number"
+                },
+                "othercreditdecrease": {
+                    "description": "今日其它授信减少",
+                    "type": "number"
+                },
+                "othercreditincrease": {
+                    "description": "今日其它授信增加",
+                    "type": "number"
+                },
+                "otherfreezemargin": {
+                    "description": "其他冻结保证金(交割买方冻结 申购冻结 全款买入 商城买入)",
+                    "type": "number"
+                },
+                "outamount": {
+                    "description": "今日出金金额(包括三方出金)",
+                    "type": "number"
+                },
+                "outamountfreeze": {
+                    "description": "出金冻结",
+                    "type": "number"
+                },
+                "outthreshold": {
+                    "description": "出金阈值",
+                    "type": "number"
+                },
+                "parentaccountid": {
+                    "description": "所属根账号",
+                    "type": "integer"
+                },
+                "paycharge": {
+                    "description": "今日手续费支出",
+                    "type": "number"
+                },
+                "relateduserid": {
+                    "description": "关联用户",
+                    "type": "integer"
+                },
+                "signstatus": {
+                    "description": "签约状态 - 1:未签约 2:签约待审核 3:签约中 4:已签约 5:解约待审核 6:解约中 7:已解约 8:已解绑 9:绑卡中",
+                    "type": "integer"
+                },
+                "sublevelpath": {
+                    "description": "账号层级路径(逗号分隔,首尾加逗号)",
+                    "type": "string"
+                },
+                "taaccounttype": {
+                    "description": "账号类型 - 1:外部账号 2:内部账号 3:内部做市自营账号 4:内部做市接单账号",
+                    "type": "integer"
+                },
+                "thirdinamount": {
+                    "description": "今日三方入金",
+                    "type": "number"
+                },
+                "thirdoutamount": {
+                    "description": "今日三方出金",
+                    "type": "number"
+                },
+                "tradestatus": {
+                    "description": "交易状态 - 1:正常 2:受限 3:冻结 4:禁止建仓(人工受限) 5:禁止交易(人工冻结) 6:待激活 7:已注销",
+                    "type": "integer"
+                },
+                "transferamount": {
+                    "description": "今日划转金额(母子账号资金划转,从划入账号为正,从账号划出为负)",
+                    "type": "number"
+                },
+                "usedmargin": {
+                    "description": "占用保证金",
+                    "type": "number"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                }
+            }
+        },
         "models.ErmcpUserModel": {
             "type": "object",
             "properties": {
@@ -15794,6 +16597,51 @@ var doc = `{
                 }
             }
         },
+        "models.MainAccountInfo": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "账号id",
+                    "type": "string"
+                },
+                "appid": {
+                    "description": "AppID",
+                    "type": "string"
+                },
+                "authcode": {
+                    "description": "授权码",
+                    "type": "string"
+                },
+                "brokerid": {
+                    "description": "经纪商id",
+                    "type": "string"
+                },
+                "fcid": {
+                    "description": "期货公司id",
+                    "type": "integer"
+                },
+                "fcname": {
+                    "description": "期货公司代码",
+                    "type": "string"
+                },
+                "hedgeaccountcode": {
+                    "description": "外部账号代码",
+                    "type": "string"
+                },
+                "hedgeaccountpwd": {
+                    "description": "密码",
+                    "type": "string"
+                },
+                "ismain": {
+                    "description": "是否主账号",
+                    "type": "integer"
+                },
+                "relateduserid": {
+                    "description": "关联用户id",
+                    "type": "integer"
+                }
+            }
+        },
         "models.Market": {
             "type": "object",
             "required": [

+ 856 - 8
docs/swagger.json

@@ -1387,6 +1387,317 @@
                 }
             }
         },
+        "/Ermcp/QueryAccMgrBizGroupSet": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询业务类型分组(账户管理/账户设置)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpBizGroupEx"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp/QueryAccMgrLoginUser": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询账户管理登录账号(账户管理/登录账号)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpLoginUserEx"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp/QueryAccMgrMainAccountInfo": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询账户管理主账号详情(账户管理/期货主账号详情)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "主账号id",
+                        "name": "accountid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.MainAccountInfo"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp/QueryAccMgrRole": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询账户管理角色设置(账户管理/角色设置)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpRole"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp/QueryAccMgrRoleMenu": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询账户管理角色详情(账户管理/角色设置/角色详情)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "角色id(可多个,逗号隔开)",
+                        "name": "roleid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpRoleMenuEx"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp/QueryAccMgrTaAccountInfo": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询账户管理授信(账户管理/账户设置/授信)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "账号id",
+                        "name": "accountid",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpTaAccountInfo"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/Ermcp/QueryAccMgrTaaccount": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "企业风险管理(app)"
+                ],
+                "summary": "查询账户管理期货账号(账户管理/期货账号)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.ErmcpTaAccountEx"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Ermcp/QueryAreaStock": {
             "get": {
                 "security": [
@@ -11600,6 +11911,91 @@
                 }
             }
         },
+        "models.ErmcpBizGroupEx": {
+            "type": "object",
+            "properties": {
+                "acclist": {
+                    "description": "账号列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.ErmcpBizGroupTaAccount"
+                    }
+                },
+                "bizgroupid": {
+                    "description": "业务分组id",
+                    "type": "integer"
+                },
+                "biztype": {
+                    "description": "业务类型 1-套保 2-套利",
+                    "type": "integer"
+                },
+                "wrlist": {
+                    "description": "现货商品表表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.ErmcpBizGroupSpotGoods"
+                    }
+                }
+            }
+        },
+        "models.ErmcpBizGroupSpotGoods": {
+            "type": "object",
+            "properties": {
+                "areauserid": {
+                    "description": "所属机构id",
+                    "type": "integer"
+                },
+                "bizgroupid": {
+                    "description": "分组id",
+                    "type": "integer"
+                },
+                "biztype": {
+                    "description": "业务类型 1-套保 2-套利",
+                    "type": "integer"
+                },
+                "unitid": {
+                    "description": "现货商品单位id",
+                    "type": "integer"
+                },
+                "wrstandardcode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品id",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "现货商品名称",
+                    "type": "string"
+                }
+            }
+        },
+        "models.ErmcpBizGroupTaAccount": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "账号id",
+                    "type": "string"
+                },
+                "accountname": {
+                    "description": "账号名称",
+                    "type": "string"
+                },
+                "areauserid": {
+                    "description": "所属机构id",
+                    "type": "integer"
+                },
+                "bizgroupid": {
+                    "description": "业务分组id",
+                    "type": "integer"
+                },
+                "ismain": {
+                    "description": "是否主账号 1-是 0-否",
+                    "type": "integer"
+                }
+            }
+        },
         "models.ErmcpExposureDetailModel": {
             "type": "object",
             "properties": {
@@ -12157,6 +12553,75 @@
                 }
             }
         },
+        "models.ErmcpLoginUser": {
+            "type": "object",
+            "properties": {
+                "accountname": {
+                    "description": "用户名称",
+                    "type": "string"
+                },
+                "clientroleid": {
+                    "description": "角色id(usertype=2)",
+                    "type": "integer"
+                },
+                "createtime": {
+                    "description": "创建时间",
+                    "type": "string"
+                },
+                "loginstatus": {
+                    "description": "登录账户状态 - 1:正常 2:冻结 3:无效",
+                    "type": "integer"
+                },
+                "memberuserid": {
+                    "description": "所属会员id",
+                    "type": "integer"
+                },
+                "modifytime": {
+                    "description": "修改时间",
+                    "type": "string"
+                },
+                "rolename": {
+                    "description": "角色名称",
+                    "type": "string"
+                },
+                "rolestatus": {
+                    "description": "角色状态 1-启用 2-停用",
+                    "type": "integer"
+                },
+                "roletype": {
+                    "description": "角色类型(逗号隔开,如22,23), 22:业务员 23:跟单员 24:交易员",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "用户id",
+                    "type": "integer"
+                },
+                "usertype": {
+                    "description": "用户类型 -  1:交易所 2:机构 3:会员子机构 4:经纪人 5:投资者 6:客户 7:企业成员(云平台)",
+                    "type": "integer"
+                }
+            }
+        },
+        "models.ErmcpLoginUserEx": {
+            "type": "object",
+            "properties": {
+                "rolename": {
+                    "description": "角色名称",
+                    "type": "string"
+                },
+                "userlist": {
+                    "description": "用户列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.ErmcpLoginUser"
+                    }
+                },
+                "usertype": {
+                    "description": "用户类型 2-机构 7-企业成员(云平台)",
+                    "type": "integer"
+                }
+            }
+        },
         "models.ErmcpMiddleGoodsChangeLog": {
             "type": "object",
             "properties": {
@@ -12347,7 +12812,7 @@
                     "type": "string"
                 },
                 "daikaiamount": {
-                    "description": "待开票额",
+                    "description": "应收(开)票额",
                     "type": "number"
                 },
                 "deliveryenddate": {
@@ -12410,6 +12875,14 @@
                     "description": "已收付额(收款或付款)",
                     "type": "number"
                 },
+                "preinvoiceamount": {
+                    "description": "预收(开)票额",
+                    "type": "number"
+                },
+                "prepayamount": {
+                    "description": "预收付额",
+                    "type": "number"
+                },
                 "price": {
                     "description": "价格",
                     "type": "number"
@@ -12447,7 +12920,7 @@
                     "type": "number"
                 },
                 "reckonedamount": {
-                    "description": "已收付额(已确定额)",
+                    "description": "实际已收付额(已确定额,已收付总额-已退款总额)",
                     "type": "number"
                 },
                 "reckonotheramount": {
@@ -12487,7 +12960,7 @@
                     "type": "number"
                 },
                 "unpayamount": {
-                    "description": "待支收额(支付或收款)",
+                    "description": "应收付款额(应支付或应收款)",
                     "type": "number"
                 },
                 "unpricedqty": {
@@ -13142,13 +13615,116 @@
                     "description": "现货商品代码",
                     "type": "string"
                 },
-                "wrstandardid": {
-                    "description": "现货商品ID",
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "现货商品名称",
+                    "type": "string"
+                }
+            }
+        },
+        "models.ErmcpRole": {
+            "type": "object",
+            "properties": {
+                "areauserid": {
+                    "description": "所属机构",
+                    "type": "integer"
+                },
+                "autoid": {
+                    "description": "角色ID(自增ID)",
+                    "type": "integer"
+                },
+                "modifierid": {
+                    "description": "修改人(创建人)",
+                    "type": "integer"
+                },
+                "modifiername": {
+                    "description": "修改人名称",
+                    "type": "string"
+                },
+                "modifytime": {
+                    "description": "修改时间(创建时间)",
+                    "type": "string"
+                },
+                "rolename": {
+                    "description": "角色名称",
+                    "type": "string"
+                },
+                "rolestatus": {
+                    "description": "角色状态 - 1:启用  2:停用",
+                    "type": "integer"
+                },
+                "roletype": {
+                    "description": "角色类型 - 1- 管理端   2-  交易端",
+                    "type": "integer"
+                }
+            }
+        },
+        "models.ErmcpRoleMenu": {
+            "type": "object",
+            "properties": {
+                "iconame": {
+                    "description": "菜单图标",
+                    "type": "string"
+                },
+                "menutype": {
+                    "description": "菜单类型 1:管理端 2:交易端 3:终端(企业云平台)",
+                    "type": "integer"
+                },
+                "parentcode": {
+                    "description": "上级资源代码",
+                    "type": "string"
+                },
+                "remark": {
+                    "description": "菜单备注",
+                    "type": "string"
+                },
+                "resourcecode": {
+                    "description": "菜单代码",
+                    "type": "string"
+                },
+                "resourcelevel": {
+                    "description": "级别",
+                    "type": "integer"
+                },
+                "resourcename": {
+                    "description": "菜单名称",
+                    "type": "string"
+                },
+                "roleid": {
+                    "description": "角色id",
+                    "type": "integer"
+                },
+                "sort": {
+                    "description": "排序",
+                    "type": "integer"
+                },
+                "url": {
+                    "description": "URL",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "用户id",
                     "type": "integer"
+                }
+            }
+        },
+        "models.ErmcpRoleMenuEx": {
+            "type": "object",
+            "properties": {
+                "menu": {
+                    "description": "父级菜单",
+                    "type": "object",
+                    "$ref": "#/definitions/models.ErmcpRoleMenu"
                 },
-                "wrstandardname": {
-                    "description": "现货商品名称",
-                    "type": "string"
+                "subMenu": {
+                    "description": "子级菜单",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.ErmcpRoleMenu"
+                    }
                 }
             }
         },
@@ -13329,6 +13905,233 @@
                 }
             }
         },
+        "models.ErmcpTaAccount": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "账户id",
+                    "type": "integer"
+                },
+                "accountname": {
+                    "description": "账户名称",
+                    "type": "string"
+                },
+                "currencyid": {
+                    "description": "币种id",
+                    "type": "integer"
+                },
+                "ismain": {
+                    "description": "是否主账户 0-否 1-是",
+                    "type": "integer"
+                },
+                "parentaccountid": {
+                    "description": "父账户id",
+                    "type": "integer"
+                },
+                "relateduserid": {
+                    "description": "关联userid",
+                    "type": "integer"
+                },
+                "tradestatus": {
+                    "description": "交易状态 - 1:正常 2:受限 3:冻结 4:禁止建仓(人工受限) 5:禁止交易(人工冻结) 6:待激活 7:已注销",
+                    "type": "integer"
+                }
+            }
+        },
+        "models.ErmcpTaAccountEx": {
+            "type": "object",
+            "properties": {
+                "mainAcc": {
+                    "description": "主账号",
+                    "type": "object",
+                    "$ref": "#/definitions/models.ErmcpTaAccount"
+                },
+                "subacclist": {
+                    "description": "子账号列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.ErmcpTaAccount"
+                    }
+                }
+            }
+        },
+        "models.ErmcpTaAccountInfo": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "资金账户ID",
+                    "type": "integer"
+                },
+                "accountname": {
+                    "description": "账户名称",
+                    "type": "string"
+                },
+                "balance": {
+                    "description": "期初余额",
+                    "type": "number"
+                },
+                "capitalbalance": {
+                    "description": "本金余额[外部子账户实际出入金余额]",
+                    "type": "number"
+                },
+                "closepl": {
+                    "description": "今日平仓盈亏",
+                    "type": "number"
+                },
+                "creditdecrease": {
+                    "description": "今日授信减少",
+                    "type": "number"
+                },
+                "creditincrease": {
+                    "description": "今日授信增加",
+                    "type": "number"
+                },
+                "curdebt": {
+                    "description": "期末欠款",
+                    "type": "number"
+                },
+                "currencyid": {
+                    "description": "货币ID",
+                    "type": "integer"
+                },
+                "currentbalance": {
+                    "description": "期末余额",
+                    "type": "number"
+                },
+                "freezecharge": {
+                    "description": "手续费冻结",
+                    "type": "number"
+                },
+                "freezemargin": {
+                    "description": "冻结保证金",
+                    "type": "number"
+                },
+                "fromaccountid": {
+                    "description": "所属上级账户",
+                    "type": "integer"
+                },
+                "inamount": {
+                    "description": "今日入金金额(包括三方入金)",
+                    "type": "number"
+                },
+                "ismain": {
+                    "description": "是否母账号 0:不是母账户 1:是母账户",
+                    "type": "integer"
+                },
+                "mortgagecredit": {
+                    "description": "授信金额",
+                    "type": "number"
+                },
+                "oridebt": {
+                    "description": "期初欠款",
+                    "type": "number"
+                },
+                "orifreezecharge": {
+                    "description": "期初手续费冻结",
+                    "type": "number"
+                },
+                "orifreezemargin": {
+                    "description": "期初冻结保证金",
+                    "type": "number"
+                },
+                "orimortgagecredit": {
+                    "description": "期初授信金额",
+                    "type": "number"
+                },
+                "oriothercredit": {
+                    "description": "期初其它授信金额",
+                    "type": "number"
+                },
+                "oriotherfreezemargin": {
+                    "description": "期初其他冻结保证金(出金冻结资金 交割买方冻结 申购冻结 全款买入 商城买入)",
+                    "type": "number"
+                },
+                "orioutamountfreeze": {
+                    "description": "期初出金冻结",
+                    "type": "number"
+                },
+                "oriusedmargin": {
+                    "description": "期初占用保证金",
+                    "type": "number"
+                },
+                "othercredit": {
+                    "description": "其它授信金额",
+                    "type": "number"
+                },
+                "othercreditdecrease": {
+                    "description": "今日其它授信减少",
+                    "type": "number"
+                },
+                "othercreditincrease": {
+                    "description": "今日其它授信增加",
+                    "type": "number"
+                },
+                "otherfreezemargin": {
+                    "description": "其他冻结保证金(交割买方冻结 申购冻结 全款买入 商城买入)",
+                    "type": "number"
+                },
+                "outamount": {
+                    "description": "今日出金金额(包括三方出金)",
+                    "type": "number"
+                },
+                "outamountfreeze": {
+                    "description": "出金冻结",
+                    "type": "number"
+                },
+                "outthreshold": {
+                    "description": "出金阈值",
+                    "type": "number"
+                },
+                "parentaccountid": {
+                    "description": "所属根账号",
+                    "type": "integer"
+                },
+                "paycharge": {
+                    "description": "今日手续费支出",
+                    "type": "number"
+                },
+                "relateduserid": {
+                    "description": "关联用户",
+                    "type": "integer"
+                },
+                "signstatus": {
+                    "description": "签约状态 - 1:未签约 2:签约待审核 3:签约中 4:已签约 5:解约待审核 6:解约中 7:已解约 8:已解绑 9:绑卡中",
+                    "type": "integer"
+                },
+                "sublevelpath": {
+                    "description": "账号层级路径(逗号分隔,首尾加逗号)",
+                    "type": "string"
+                },
+                "taaccounttype": {
+                    "description": "账号类型 - 1:外部账号 2:内部账号 3:内部做市自营账号 4:内部做市接单账号",
+                    "type": "integer"
+                },
+                "thirdinamount": {
+                    "description": "今日三方入金",
+                    "type": "number"
+                },
+                "thirdoutamount": {
+                    "description": "今日三方出金",
+                    "type": "number"
+                },
+                "tradestatus": {
+                    "description": "交易状态 - 1:正常 2:受限 3:冻结 4:禁止建仓(人工受限) 5:禁止交易(人工冻结) 6:待激活 7:已注销",
+                    "type": "integer"
+                },
+                "transferamount": {
+                    "description": "今日划转金额(母子账号资金划转,从划入账号为正,从账号划出为负)",
+                    "type": "number"
+                },
+                "usedmargin": {
+                    "description": "占用保证金",
+                    "type": "number"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                }
+            }
+        },
         "models.ErmcpUserModel": {
             "type": "object",
             "properties": {
@@ -15778,6 +16581,51 @@
                 }
             }
         },
+        "models.MainAccountInfo": {
+            "type": "object",
+            "properties": {
+                "accountid": {
+                    "description": "账号id",
+                    "type": "string"
+                },
+                "appid": {
+                    "description": "AppID",
+                    "type": "string"
+                },
+                "authcode": {
+                    "description": "授权码",
+                    "type": "string"
+                },
+                "brokerid": {
+                    "description": "经纪商id",
+                    "type": "string"
+                },
+                "fcid": {
+                    "description": "期货公司id",
+                    "type": "integer"
+                },
+                "fcname": {
+                    "description": "期货公司代码",
+                    "type": "string"
+                },
+                "hedgeaccountcode": {
+                    "description": "外部账号代码",
+                    "type": "string"
+                },
+                "hedgeaccountpwd": {
+                    "description": "密码",
+                    "type": "string"
+                },
+                "ismain": {
+                    "description": "是否主账号",
+                    "type": "integer"
+                },
+                "relateduserid": {
+                    "description": "关联用户id",
+                    "type": "integer"
+                }
+            }
+        },
         "models.Market": {
             "type": "object",
             "required": [

+ 589 - 3
docs/swagger.yaml

@@ -3343,6 +3343,67 @@ definitions:
         description: 期货品种代码
         type: string
     type: object
+  models.ErmcpBizGroupEx:
+    properties:
+      acclist:
+        description: 账号列表
+        items:
+          $ref: '#/definitions/models.ErmcpBizGroupTaAccount'
+        type: array
+      bizgroupid:
+        description: 业务分组id
+        type: integer
+      biztype:
+        description: 业务类型 1-套保 2-套利
+        type: integer
+      wrlist:
+        description: 现货商品表表
+        items:
+          $ref: '#/definitions/models.ErmcpBizGroupSpotGoods'
+        type: array
+    type: object
+  models.ErmcpBizGroupSpotGoods:
+    properties:
+      areauserid:
+        description: 所属机构id
+        type: integer
+      bizgroupid:
+        description: 分组id
+        type: integer
+      biztype:
+        description: 业务类型 1-套保 2-套利
+        type: integer
+      unitid:
+        description: 现货商品单位id
+        type: integer
+      wrstandardcode:
+        description: 现货商品代码
+        type: string
+      wrstandardid:
+        description: 现货商品id
+        type: integer
+      wrstandardname:
+        description: 现货商品名称
+        type: string
+    type: object
+  models.ErmcpBizGroupTaAccount:
+    properties:
+      accountid:
+        description: 账号id
+        type: string
+      accountname:
+        description: 账号名称
+        type: string
+      areauserid:
+        description: 所属机构id
+        type: integer
+      bizgroupid:
+        description: 业务分组id
+        type: integer
+      ismain:
+        description: 是否主账号 1-是 0-否
+        type: integer
+    type: object
   models.ErmcpExposureDetailModel:
     properties:
       areauserid:
@@ -3753,6 +3814,56 @@ definitions:
         description: 套保品种名称
         type: string
     type: object
+  models.ErmcpLoginUser:
+    properties:
+      accountname:
+        description: 用户名称
+        type: string
+      clientroleid:
+        description: 角色id(usertype=2)
+        type: integer
+      createtime:
+        description: 创建时间
+        type: string
+      loginstatus:
+        description: 登录账户状态 - 1:正常 2:冻结 3:无效
+        type: integer
+      memberuserid:
+        description: 所属会员id
+        type: integer
+      modifytime:
+        description: 修改时间
+        type: string
+      rolename:
+        description: 角色名称
+        type: string
+      rolestatus:
+        description: 角色状态 1-启用 2-停用
+        type: integer
+      roletype:
+        description: 角色类型(逗号隔开,如22,23), 22:业务员 23:跟单员 24:交易员
+        type: string
+      userid:
+        description: 用户id
+        type: integer
+      usertype:
+        description: 用户类型 -  1:交易所 2:机构 3:会员子机构 4:经纪人 5:投资者 6:客户 7:企业成员(云平台)
+        type: integer
+    type: object
+  models.ErmcpLoginUserEx:
+    properties:
+      rolename:
+        description: 角色名称
+        type: string
+      userlist:
+        description: 用户列表
+        items:
+          $ref: '#/definitions/models.ErmcpLoginUser'
+        type: array
+      usertype:
+        description: 用户类型 2-机构 7-企业成员(云平台)
+        type: integer
+    type: object
   models.ErmcpMiddleGoodsChangeLog:
     properties:
       aftervalue:
@@ -3893,7 +4004,7 @@ definitions:
         description: 创建时间
         type: string
       daikaiamount:
-        description: 待开票额
+        description: 应收(开)票额
         type: number
       deliveryenddate:
         description: 交割结束日
@@ -3940,6 +4051,12 @@ definitions:
       payamount:
         description: 已收付额(收款或付款)
         type: number
+      preinvoiceamount:
+        description: 预收(开)票额
+        type: number
+      prepayamount:
+        description: 预收付额
+        type: number
       price:
         description: 价格
         type: number
@@ -3968,7 +4085,7 @@ definitions:
         description: 调整金额
         type: number
       reckonedamount:
-        description: 已收付额(已确定额)
+        description: 实际已收付额(已确定额,已收付总额-已退款总额)
         type: number
       reckonotheramount:
         description: 其它费用
@@ -3998,7 +4115,7 @@ definitions:
         description: 合计总额
         type: number
       unpayamount:
-        description: 待支收额(支付或收款)
+        description: 应收付款额(应支付或应收款)
         type: number
       unpricedqty:
         description: 未定价量
@@ -4489,6 +4606,81 @@ definitions:
         description: 现货商品名称
         type: string
     type: object
+  models.ErmcpRole:
+    properties:
+      areauserid:
+        description: 所属机构
+        type: integer
+      autoid:
+        description: 角色ID(自增ID)
+        type: integer
+      modifierid:
+        description: 修改人(创建人)
+        type: integer
+      modifiername:
+        description: 修改人名称
+        type: string
+      modifytime:
+        description: 修改时间(创建时间)
+        type: string
+      rolename:
+        description: 角色名称
+        type: string
+      rolestatus:
+        description: 角色状态 - 1:启用  2:停用
+        type: integer
+      roletype:
+        description: 角色类型 - 1- 管理端   2-  交易端
+        type: integer
+    type: object
+  models.ErmcpRoleMenu:
+    properties:
+      iconame:
+        description: 菜单图标
+        type: string
+      menutype:
+        description: 菜单类型 1:管理端 2:交易端 3:终端(企业云平台)
+        type: integer
+      parentcode:
+        description: 上级资源代码
+        type: string
+      remark:
+        description: 菜单备注
+        type: string
+      resourcecode:
+        description: 菜单代码
+        type: string
+      resourcelevel:
+        description: 级别
+        type: integer
+      resourcename:
+        description: 菜单名称
+        type: string
+      roleid:
+        description: 角色id
+        type: integer
+      sort:
+        description: 排序
+        type: integer
+      url:
+        description: URL
+        type: string
+      userid:
+        description: 用户id
+        type: integer
+    type: object
+  models.ErmcpRoleMenuEx:
+    properties:
+      menu:
+        $ref: '#/definitions/models.ErmcpRoleMenu'
+        description: 父级菜单
+        type: object
+      subMenu:
+        description: 子级菜单
+        items:
+          $ref: '#/definitions/models.ErmcpRoleMenu'
+        type: array
+    type: object
   models.ErmcpSpotContractModel:
     properties:
       amount:
@@ -4621,6 +4813,174 @@ definitions:
         description: 现货商品名称
         type: string
     type: object
+  models.ErmcpTaAccount:
+    properties:
+      accountid:
+        description: 账户id
+        type: integer
+      accountname:
+        description: 账户名称
+        type: string
+      currencyid:
+        description: 币种id
+        type: integer
+      ismain:
+        description: 是否主账户 0-否 1-是
+        type: integer
+      parentaccountid:
+        description: 父账户id
+        type: integer
+      relateduserid:
+        description: 关联userid
+        type: integer
+      tradestatus:
+        description: 交易状态 - 1:正常 2:受限 3:冻结 4:禁止建仓(人工受限) 5:禁止交易(人工冻结) 6:待激活 7:已注销
+        type: integer
+    type: object
+  models.ErmcpTaAccountEx:
+    properties:
+      mainAcc:
+        $ref: '#/definitions/models.ErmcpTaAccount'
+        description: 主账号
+        type: object
+      subacclist:
+        description: 子账号列表
+        items:
+          $ref: '#/definitions/models.ErmcpTaAccount'
+        type: array
+    type: object
+  models.ErmcpTaAccountInfo:
+    properties:
+      accountid:
+        description: 资金账户ID
+        type: integer
+      accountname:
+        description: 账户名称
+        type: string
+      balance:
+        description: 期初余额
+        type: number
+      capitalbalance:
+        description: 本金余额[外部子账户实际出入金余额]
+        type: number
+      closepl:
+        description: 今日平仓盈亏
+        type: number
+      creditdecrease:
+        description: 今日授信减少
+        type: number
+      creditincrease:
+        description: 今日授信增加
+        type: number
+      curdebt:
+        description: 期末欠款
+        type: number
+      currencyid:
+        description: 货币ID
+        type: integer
+      currentbalance:
+        description: 期末余额
+        type: number
+      freezecharge:
+        description: 手续费冻结
+        type: number
+      freezemargin:
+        description: 冻结保证金
+        type: number
+      fromaccountid:
+        description: 所属上级账户
+        type: integer
+      inamount:
+        description: 今日入金金额(包括三方入金)
+        type: number
+      ismain:
+        description: 是否母账号 0:不是母账户 1:是母账户
+        type: integer
+      mortgagecredit:
+        description: 授信金额
+        type: number
+      oridebt:
+        description: 期初欠款
+        type: number
+      orifreezecharge:
+        description: 期初手续费冻结
+        type: number
+      orifreezemargin:
+        description: 期初冻结保证金
+        type: number
+      orimortgagecredit:
+        description: 期初授信金额
+        type: number
+      oriothercredit:
+        description: 期初其它授信金额
+        type: number
+      oriotherfreezemargin:
+        description: 期初其他冻结保证金(出金冻结资金 交割买方冻结 申购冻结 全款买入 商城买入)
+        type: number
+      orioutamountfreeze:
+        description: 期初出金冻结
+        type: number
+      oriusedmargin:
+        description: 期初占用保证金
+        type: number
+      othercredit:
+        description: 其它授信金额
+        type: number
+      othercreditdecrease:
+        description: 今日其它授信减少
+        type: number
+      othercreditincrease:
+        description: 今日其它授信增加
+        type: number
+      otherfreezemargin:
+        description: 其他冻结保证金(交割买方冻结 申购冻结 全款买入 商城买入)
+        type: number
+      outamount:
+        description: 今日出金金额(包括三方出金)
+        type: number
+      outamountfreeze:
+        description: 出金冻结
+        type: number
+      outthreshold:
+        description: 出金阈值
+        type: number
+      parentaccountid:
+        description: 所属根账号
+        type: integer
+      paycharge:
+        description: 今日手续费支出
+        type: number
+      relateduserid:
+        description: 关联用户
+        type: integer
+      signstatus:
+        description: 签约状态 - 1:未签约 2:签约待审核 3:签约中 4:已签约 5:解约待审核 6:解约中 7:已解约 8:已解绑 9:绑卡中
+        type: integer
+      sublevelpath:
+        description: 账号层级路径(逗号分隔,首尾加逗号)
+        type: string
+      taaccounttype:
+        description: 账号类型 - 1:外部账号 2:内部账号 3:内部做市自营账号 4:内部做市接单账号
+        type: integer
+      thirdinamount:
+        description: 今日三方入金
+        type: number
+      thirdoutamount:
+        description: 今日三方出金
+        type: number
+      tradestatus:
+        description: 交易状态 - 1:正常 2:受限 3:冻结 4:禁止建仓(人工受限) 5:禁止交易(人工冻结) 6:待激活 7:已注销
+        type: integer
+      transferamount:
+        description: 今日划转金额(母子账号资金划转,从划入账号为正,从账号划出为负)
+        type: number
+      usedmargin:
+        description: 占用保证金
+        type: number
+      userid:
+        description: 用户ID
+        type: integer
+    type: object
   models.ErmcpUserModel:
     properties:
       address:
@@ -6473,6 +6833,39 @@ definitions:
     required:
     - loginid
     type: object
+  models.MainAccountInfo:
+    properties:
+      accountid:
+        description: 账号id
+        type: string
+      appid:
+        description: AppID
+        type: string
+      authcode:
+        description: 授权码
+        type: string
+      brokerid:
+        description: 经纪商id
+        type: string
+      fcid:
+        description: 期货公司id
+        type: integer
+      fcname:
+        description: 期货公司代码
+        type: string
+      hedgeaccountcode:
+        description: 外部账号代码
+        type: string
+      hedgeaccountpwd:
+        description: 密码
+        type: string
+      ismain:
+        description: 是否主账号
+        type: integer
+      relateduserid:
+        description: 关联用户id
+        type: integer
+    type: object
   models.Market:
     properties:
       auctionwrtype:
@@ -10700,6 +11093,199 @@ paths:
       summary: 查询现货月报表详情(菜单:报表查询/现货月报表/现货月报表详情)
       tags:
       - 企业风险管理(app)
+  /Ermcp/QueryAccMgrBizGroupSet:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.ErmcpBizGroupEx'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询业务类型分组(账户管理/账户设置)
+      tags:
+      - 企业风险管理(app)
+  /Ermcp/QueryAccMgrLoginUser:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.ErmcpLoginUserEx'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询账户管理登录账号(账户管理/登录账号)
+      tags:
+      - 企业风险管理(app)
+  /Ermcp/QueryAccMgrMainAccountInfo:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        type: integer
+      - description: 主账号id
+        in: query
+        name: accountid
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.MainAccountInfo'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询账户管理主账号详情(账户管理/期货主账号详情)
+      tags:
+      - 企业风险管理(app)
+  /Ermcp/QueryAccMgrRole:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.ErmcpRole'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询账户管理角色设置(账户管理/角色设置)
+      tags:
+      - 企业风险管理(app)
+  /Ermcp/QueryAccMgrRoleMenu:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      - description: 角色id(可多个,逗号隔开)
+        in: query
+        name: roleid
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.ErmcpRoleMenuEx'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询账户管理角色详情(账户管理/角色设置/角色详情)
+      tags:
+      - 企业风险管理(app)
+  /Ermcp/QueryAccMgrTaAccountInfo:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      - description: 账号id
+        in: query
+        name: accountid
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.ErmcpTaAccountInfo'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询账户管理授信(账户管理/账户设置/授信)
+      tags:
+      - 企业风险管理(app)
+  /Ermcp/QueryAccMgrTaaccount:
+    get:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userid
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.ErmcpTaAccountEx'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询账户管理期货账号(账户管理/期货账号)
+      tags:
+      - 企业风险管理(app)
   /Ermcp/QueryAreaStock:
     get:
       parameters:

+ 25 - 8
global/app/ginUtils.go

@@ -13,35 +13,36 @@ import (
 	"net/http"
 )
 
-// 获取数据接口
+// GetData 获取数据接口
 type IGetData interface {
 	GetData() ([]interface{}, error)
 }
 
-// 获取数据接口
+// IGetDataEx 获取数据接口
 type IGetDataEx interface {
 	GetDataEx() (interface{}, error)
 }
 
-// 数据处理接口
+// ICalc 数据处理接口
 type ICalc interface {
 	Calc()
 }
 
-// 封装绑定和数据获取处理
+// GinUtils 封装绑定和数据获取处理
 type GinUtils struct {
 	Gin
 	err error
 }
 
-// 处理参数绑定
+// DoBindReq 处理参数绑定
 func (r *GinUtils) DoBindReq(req interface{}) {
 	if r.err = r.C.ShouldBind(req); r.err != nil {
 		r.Gin.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
 	}
 }
 
-// 处理数据获取, 参数obj为models结构体
+// DoGetData 处理数据获取, 参数obj为models结构体
+// Deprecated
 func (r *GinUtils) DoGetData(obj interface{}) {
 	// 如果在参数绑定阶段有错误, 则不执行数据获取
 	if r.err != nil {
@@ -65,7 +66,8 @@ func (r *GinUtils) DoGetData(obj interface{}) {
 	}
 }
 
-// 处理数据获取, 参数obj为models结构体
+// DoGetDataEx 处理数据获取, 参数obj为models结构体
+// Deprecated
 func (r *GinUtils) DoGetDataEx(modelObj interface{}) {
 	// 如果在参数绑定阶段有错误, 则不执行数据获取
 	if r.err != nil {
@@ -81,7 +83,22 @@ func (r *GinUtils) DoGetDataEx(modelObj interface{}) {
 	}
 }
 
-// 生成处理GinUtils实例
+// DoGetDataI 获取数据
+func (r *GinUtils) DoGetDataI(iObj IGetDataEx) {
+	// 如果在参数绑定阶段有错误, 则不执行数据获取
+	if r.err != nil {
+		return
+	}
+
+	if d, err := iObj.GetDataEx(); err == nil {
+		r.Gin.Response(http.StatusOK, e.SUCCESS, d)
+	} else {
+		logger.GetLogger().Errorf("query fail, %v", err)
+		r.Gin.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+	}
+}
+
+// NewGinUtils 生成处理GinUtils实例
 func NewGinUtils(c *gin.Context) *GinUtils {
 	return &GinUtils{Gin: Gin{C: c}}
 }

+ 7 - 4
models/ermcp.go

@@ -175,9 +175,11 @@ type ErmcpModel struct {
 	PricedQty          float64 `json:"pricedqty"  xorm:"'PRICEDQTY'"`                   // 已定价量
 	UnsureQty          float64 `json:"unsureqty"  xorm:"'UNSUREQTY'"`                   // 未确定量
 	PayAmount          float64 `json:"payamount"  xorm:"'PAYAMOUNT'"`                   // 已收付额(收款或付款)
-	UnpayAmount        float64 `json:"unpayamount"`                                     // 待支收额(支付或收款)
+	UnpayAmount        float64 `json:"unpayamount"`                                     // 应收付款额(应支付或应收款)
+	PrePayAmount       float64 `json:"prepayamount"`                                    // 预收付额
 	InvoiceAmount      float64 `json:"invoiceamount"  xorm:"'INVOICEAMOUNT'"`           // 已开票额
-	DaikaiAmount       float64 `json:"daikaiamount"  xorm:"'DAIKAIAMOUNT'"`             // 待开票额
+	DaikaiAmount       float64 `json:"daikaiamount"  xorm:"'DAIKAIAMOUNT'"`             // 应收(开)票额
+	PreInvoiceAmount   float64 `json:"preinvoiceamount"`                                // 预收(开)票额
 	StartDate          string  `json:"startdate"  xorm:"'STARTDATE'"`                   // 点价开始日
 	EndDate            string  `json:"enddate"  xorm:"'ENDDATE'"`                       // 点价结束日
 	DeliveryStartDate  string  `json:"deliverystartdate"  xorm:"'DELIVERYSTARTDATE'"`   // 交割开始日
@@ -201,7 +203,7 @@ type ErmcpModel struct {
 	LoanAmount         float64 `json:"loanamount"  xorm:"'LoanAmount'"`                 // 贷款总额=已定价额+调整金额
 	Contractno         string  `json:"contractno"  xorm:"'Contractno'"`                 // 合同编号
 	TotalAmount        float64 `json:"totalamount"  xorm:"'-'"`                         // 合计总额
-	ReckonedAmount     float64 `json:"reckonedamount"  xorm:"'ReckonedAmount'"`         // 已收付额(已确定额)
+	ReckonedAmount     float64 `json:"reckonedamount"  xorm:"'ReckonedAmount'"`         // 实际已收付额(已确定额,已收付总额-已退款总额)
 	BUYUSERID          int64   `json:"-"  xorm:"'BUYUSERID'"`                           // 采购方ID
 	SELLUSERID         int64   `json:"-"  xorm:"'SELLUSERID'"`                          // 销售方ID
 	AUDITTIME          string  `json:"audittime"  xorm:"'AUDITTIME'"`                   // 审核时间
@@ -219,7 +221,8 @@ func (r *ErmcpModel) calc() {
 	// #94293 公式调整:合计总额不再加保证金
 	r.TotalAmount = r.LoanAmount + r.ReckonOtherAmount
 	r.UnpayAmount = r.TotalAmount - r.ReckonedAmount
-
+	r.PrePayAmount = r.ReckonedAmount - r.TotalAmount
+	r.PreInvoiceAmount = r.InvoiceAmount - r.TotalAmount
 	if r.Contracttype == 1 {
 		//采购合同, 取销售方名称
 		r.AccountName = mtpcache.GetUserNameByUserId(r.SELLUSERID)

+ 626 - 0
models/ermcpAccMgr.go

@@ -0,0 +1,626 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/3/30 13:38
+* @Modify  : 2021/3/30 13:38
+* @note    : 账户管理
+**/
+
+package models
+
+import (
+	"fmt"
+	"mtp2_if/db"
+	"mtp2_if/mtpcache"
+	"mtp2_if/utils"
+	"strings"
+)
+
+// ErmcpLoginUserEx 登录账号(按角色)
+type ErmcpLoginUserEx struct {
+	ROLENAME string           `json:"rolename"` // 角色名称
+	USERTYPE int32            `json:"usertype"` // 用户类型 2-机构 7-企业成员(云平台)
+	UserList []ErmcpLoginUser `json:"userlist"` // 用户列表
+	RoleId   int32            `json:"-"`        // 角色id
+}
+
+// ErmcpLoginUser 查询登录账户
+type ErmcpLoginUser struct {
+	USERID       int64  `json:"userid"  xorm:"'USERID'"`             // 用户id
+	MEMBERUSERID int64  `json:"memberuserid"  xorm:"'MEMBERUSERID'"` // 所属会员id
+	ACCOUNTNAME  string `json:"accountname"  xorm:"'ACCOUNTNAME'"`   // 用户名称
+	USERTYPE     int32  `json:"usertype"  xorm:"'USERTYPE'"`         // 用户类型 -  1:交易所 2:机构 3:会员子机构 4:经纪人 5:投资者 6:客户 7:企业成员(云平台)
+	LOGINSTATUS  int32  `json:"loginstatus"  xorm:"'LOGINSTATUS'"`   // 登录账户状态 - 1:正常 2:冻结 3:无效
+	CREATETIME   string `json:"createtime"  xorm:"'CREATETIME'"`     // 创建时间
+	MODIFYTIME   string `json:"modifytime"  xorm:"'MODIFYTIME'"`     // 修改时间
+	ROLETYPE     string `json:"roletype"  xorm:"'ROLETYPE'"`         // 角色类型(逗号隔开,如22,23), 22:业务员 23:跟单员 24:交易员
+	CLIENTROLEID int32  `json:"clientroleid"  xorm:"'CLIENTROLEID'"` // 角色id(usertype=2)
+	ROLENAME     string `json:"rolename"  xorm:"'ROLENAME'"`         // 角色名称
+	ROLESTATUS   int32  `json:"rolestatus"  xorm:"'ROLESTATUS'"`     // 角色状态 1-启用 2-停用
+}
+
+func (r *ErmcpLoginUser) calc() {
+
+}
+
+func (r *ErmcpLoginUser) buildSql() string {
+	var sqlId utils.SQLVal = "with tmp as" +
+		" (select userid, wm_concat(roletype) roletype from arearole group by userid)" +
+		"select t.userid," +
+		"       t.memberuserid," +
+		"       t.usertype," +
+		"       t.accountname," +
+		"       to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime," +
+		"       to_char(t.modifytime, 'yyyy-mm-dd hh24:mi:ss') modifytime," +
+		"       r.roletype," +
+		"       1 as rolestatus," +
+		"       l.logincode," +
+		"       l.loginid," +
+		"       l.clientroleid," +
+		"       'name(22,23,24)' rolename," +
+		"       l.loginstatus" +
+		"  from useraccount t" +
+		"  left join loginaccount l" +
+		"    on t.userid = l.userid" +
+		"  left join tmp r" +
+		"    on t.userid = r.userid" +
+		" where 1=1" +
+		"   and t.memberuserid = %v" +
+		"   and t.usertype = 7" +
+		" union all " +
+		"select t.userid," +
+		"       t.memberuserid," +
+		"       t.usertype," +
+		"       t.accountname," +
+		"       to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime," +
+		"       to_char(t.modifytime, 'yyyy-mm-dd hh24:mi:ss') modifytime," +
+		"       to_char(r.roletype) roletype," +
+		"       r.rolestatus," +
+		"       l.logincode," +
+		"       l.loginid," +
+		"       l.clientroleid," +
+		"       Nvl(r.rolename, l.clientroleid) rolename," +
+		"       l.loginstatus" +
+		"  from useraccount t" +
+		"  left join loginaccount l" +
+		"    on t.userid = l.userid" +
+		"  left join systemmanagerrole r on l.clientroleid=r.autoid and r.areauserid=l.userid" +
+		" where 1=1" +
+		"   and t.userid = %v" +
+		"   and t.usertype = 2"
+	sqlId.FormatParam(r.USERID, r.USERID)
+	return sqlId.String()
+}
+
+// hasRoletype 是否拥用某种角色
+func (r *ErmcpLoginUser) hasRoletype(nType int32) bool {
+	sType := strings.Split(r.ROLETYPE, ",")
+	strType := fmt.Sprintf("%v", nType)
+	for i := range sType {
+		if sType[i] == strType {
+			return true
+		}
+	}
+	return false
+}
+
+// GetDataEx 查询登录用户
+func (r *ErmcpLoginUser) GetDataEx() (interface{}, error) {
+	sData := make([]ErmcpLoginUser, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	sDataEx := make([]ErmcpLoginUserEx, 0)
+	// 初始化固定三种企业成员角色
+	sDataEx = append(sDataEx, ErmcpLoginUserEx{ROLENAME: "业务员", USERTYPE: 7, RoleId: 22, UserList: make([]ErmcpLoginUser, 0)})
+	sDataEx = append(sDataEx, ErmcpLoginUserEx{ROLENAME: "跟单员", USERTYPE: 7, RoleId: 23, UserList: make([]ErmcpLoginUser, 0)})
+	sDataEx = append(sDataEx, ErmcpLoginUserEx{ROLENAME: "交易员", USERTYPE: 7, RoleId: 24, UserList: make([]ErmcpLoginUser, 0)})
+	for _, v := range sData {
+		if v.USERTYPE == 7 {
+			if len(sDataEx) >= 3 {
+				if v.hasRoletype(22) {
+					sDataEx[0].UserList = append(sDataEx[0].UserList, v)
+				} else if v.hasRoletype(23) {
+					sDataEx[1].UserList = append(sDataEx[1].UserList, v)
+				} else if v.hasRoletype(24) {
+					sDataEx[2].UserList = append(sDataEx[2].UserList, v)
+				}
+			}
+		} else if v.USERTYPE == 2 {
+			var bAdd bool = false
+			for i := range sDataEx {
+				if sDataEx[i].USERTYPE == 2 && sDataEx[i].RoleId == v.CLIENTROLEID {
+					sDataEx[i].UserList = append(sDataEx[i].UserList, v)
+					bAdd = true
+					break
+				}
+			}
+			// 不存在的新类别
+			if !bAdd {
+				val := ErmcpLoginUserEx{ROLENAME: v.ROLENAME, USERTYPE: 2, RoleId: v.CLIENTROLEID, UserList: make([]ErmcpLoginUser, 0)}
+				val.UserList = append(val.UserList, v)
+				sDataEx = append(sDataEx, val)
+			}
+		}
+	}
+
+	return sDataEx, err
+}
+
+// ErmcpTaAccount 期货账户(分组)
+type ErmcpTaAccountEx struct {
+	MainAcc    ErmcpTaAccount   `json:"mainAcc"`    // 主账号
+	SubAccList []ErmcpTaAccount `json:"subacclist"` // 子账号列表
+}
+
+// ErmcpTaAccount 期货账户
+type ErmcpTaAccount struct {
+	ACCOUNTID       int64  `json:"accountid"  xorm:"'ACCOUNTID'"`             // 账户id
+	CURRENCYID      int32  `json:"currencyid"  xorm:"'CURRENCYID'"`           // 币种id
+	TRADESTATUS     int32  `json:"tradestatus"  xorm:"'TRADESTATUS'"`         // 交易状态 - 1:正常 2:受限 3:冻结 4:禁止建仓(人工受限) 5:禁止交易(人工冻结) 6:待激活 7:已注销
+	ISMAIN          int32  `json:"ismain"  xorm:"'ISMAIN'"`                   // 是否主账户 0-否 1-是
+	RELATEDUSERID   int64  `json:"relateduserid"  xorm:"'RELATEDUSERID'"`     // 关联userid
+	ACCOUNTNAME     string `json:"accountname"  xorm:"'ACCOUNTNAME'"`         // 账户名称
+	PARENTACCOUNTID int64  `json:"parentaccountid"  xorm:"'PARENTACCOUNTID'"` // 父账户id
+}
+
+func (r *ErmcpTaAccount) calc() {
+
+}
+
+func (r *ErmcpTaAccount) buildSql() string {
+	var sqlId utils.SQLVal = "select t.accountid," +
+		"       t.currencyid," +
+		"       t.tradestatus," +
+		"       t.ismain," +
+		"       t.relateduserid," +
+		"       t.accountname," +
+		"       t.parentaccountid" +
+		"  from taaccount t" +
+		" where 1 = 1"
+	sqlId.And("t.relateduserid", r.RELATEDUSERID)
+	return sqlId.String()
+}
+
+// GetDataEx 查询企业期货账户
+func (r *ErmcpTaAccount) GetDataEx() (interface{}, error) {
+	sData := make([]ErmcpTaAccount, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	sDataEx := make([]ErmcpTaAccountEx, 0)
+	// 主账号
+	for i := range sData {
+		if sData[i].ISMAIN == 1 {
+			val := ErmcpTaAccountEx{MainAcc: sData[i], SubAccList: make([]ErmcpTaAccount, 0)}
+			sDataEx = append(sDataEx, val)
+		}
+	}
+	// 子账号
+	for i := range sData {
+		if sData[i].ISMAIN == 0 {
+			for k := range sDataEx {
+				if sDataEx[k].MainAcc.ACCOUNTID == sData[i].PARENTACCOUNTID {
+					sDataEx[k].SubAccList = append(sDataEx[k].SubAccList, sData[i])
+				}
+			}
+		}
+	}
+
+	return sDataEx, err
+}
+
+// MainAccountInfo 主账号详情
+type MainAccountInfo struct {
+	ACCOUNTID        string `json:"accountid"  xorm:"'ACCOUNTID'"`               // 账号id
+	HEDGEACCOUNTCODE string `json:"hedgeaccountcode"  xorm:"'HEDGEACCOUNTCODE'"` // 外部账号代码
+	HEDGEACCOUNTPWD  string `json:"hedgeaccountpwd"  xorm:"'HEDGEACCOUNTPWD'"`   // 密码
+	AUTHCODE         string `json:"authcode"  xorm:"'AUTHCODE'"`                 // 授权码
+	APPID            string `json:"appid"  xorm:"'APPID'"`                       // AppID
+	BROKERID         string `json:"brokerid"  xorm:"'BROKERID'"`                 // 经纪商id
+	FCID             int32  `json:"fcid"  xorm:"'FCID'"`                         // 期货公司id
+	FCNAME           string `json:"fcname"  xorm:"'FCNAME'"`                     // 期货公司代码
+	ISMAIN           int32  `json:"ismain"  xorm:"'ISMAIN'"`                     // 是否主账号
+	RELATEDUSERID    int64  `json:"relateduserid"  xorm:"'RELATEDUSERID'"`       // 关联用户id
+}
+
+func (r *MainAccountInfo) calc() {
+	r.HEDGEACCOUNTPWD = DecryptField(r.HEDGEACCOUNTPWD)
+}
+
+func (r *MainAccountInfo) buildSql() string {
+	var sqlId utils.SQLVal = "select t.accountid," +
+		"       t.hedgeaccountcode," +
+		"       c.hedgeaccountpwd," +
+		"       c.authcode," +
+		"       c.appid," +
+		"       c.brokerid," +
+		"       c.fcid," +
+		"       f.fcname," +
+		"       ta.ismain," +
+		"       ta.relateduserid" +
+		"  from hedge_outtaaccount t" +
+		"  left join hedge_outmainconfig c" +
+		"    on t.accountid = c.accountid" +
+		"  left join ERMCP_FuturesCompany f" +
+		"    on c.fcid = f.fcid" +
+		"  left join taaccount ta on t.accountid=ta.accountid" +
+		" where 1 = 1"
+	if r.RELATEDUSERID > 0 {
+		sqlId.And("ta.relateduserid", r.RELATEDUSERID)
+	}
+	if len(r.ACCOUNTID) > 0 {
+		sqlId.And("t.ACCOUNTID", r.ACCOUNTID)
+	}
+	return sqlId.String()
+}
+
+// GetDataEx 查询主账号信息
+func (r *MainAccountInfo) GetDataEx() (interface{}, error) {
+	sData := make([]MainAccountInfo, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}
+
+// ErmcpRole 角色
+type ErmcpRole struct {
+	AUTOID     int32  `json:"autoid"  xorm:"'AUTOID'"`         // 角色ID(自增ID)
+	ROLENAME   string `json:"rolename"  xorm:"'ROLENAME'"`     // 角色名称
+	AREAUSERID int64  `json:"areauserid"  xorm:"'AREAUSERID'"` // 所属机构
+	ROLESTATUS int32  `json:"rolestatus"  xorm:"'ROLESTATUS'"` // 角色状态 - 1:启用  2:停用
+	ROLETYPE   int32  `json:"roletype"  xorm:"'ROLETYPE'"`     // 角色类型 - 1- 管理端   2-  交易端
+	MODIFYTIME string `json:"modifytime"  xorm:"'MODIFYTIME'"` // 修改时间(创建时间)
+	MODIFIERID int64  `json:"modifierid"  xorm:"'MODIFIERID'"` // 修改人(创建人)
+
+	MODIFIERNAME string `json:"modifiername"` // 修改人名称
+}
+
+func (r *ErmcpRole) calc() {
+	if r.MODIFIERID > 0 {
+		r.MODIFIERNAME = mtpcache.GetSystemmangerLoginCode(r.MODIFIERID)
+		// 目前看表里修改人id存的是管理员id,为防止以后终端操作存的是登录id,多做一层判断
+		// 如果按管理员id找不到,则按登录id试试
+		if r.MODIFIERID > 1e8 && len(r.MODIFIERNAME) == 0 {
+			r.MODIFIERNAME = mtpcache.GetLoginCodeByLoginId(r.MODIFIERID)
+		}
+	}
+}
+
+func (r *ErmcpRole) buildSql() string {
+	var sqlId utils.SQLVal = "SELECT t.AUTOID," +
+		"       t.ROLENAME," +
+		"       t.AREAUSERID," +
+		"       t.ROLESTATUS," +
+		"       t.ROLETYPE," +
+		"       t.SENSITIVEFIELDS," +
+		"       to_char(t.MODIFYTIME, 'yyyy-mm-dd hh24:mi:ss') MODIFYTIME," +
+		"       to_char(t.MODIFIERID) MODIFIERID" +
+		"  FROM SYSTEMMANAGERROLE t" +
+		" WHERE 1 = 1"
+	if r.AREAUSERID > 0 {
+		sqlId.And("t.AREAUSERID", r.AREAUSERID)
+	}
+	return sqlId.String()
+}
+
+// GetDataEx 查询角色
+func (r *ErmcpRole) GetDataEx() (interface{}, error) {
+	sData := make([]ErmcpRole, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	sDataEx := make([]ErmcpRole, 0)
+	// 添加固定角色22,23,24
+	sDataEx = append(sDataEx, ErmcpRole{AREAUSERID: r.AREAUSERID, ROLENAME: "业务员", AUTOID: 22,
+		ROLESTATUS: 1, ROLETYPE: 2, MODIFYTIME: "-", MODIFIERID: 1, MODIFIERNAME: "平台"})
+	sDataEx = append(sDataEx, ErmcpRole{AREAUSERID: r.AREAUSERID, ROLENAME: "跟单员", AUTOID: 23,
+		ROLESTATUS: 1, ROLETYPE: 2, MODIFYTIME: "-", MODIFIERID: 1, MODIFIERNAME: "平台"})
+	sDataEx = append(sDataEx, ErmcpRole{AREAUSERID: r.AREAUSERID, ROLENAME: "交易员", AUTOID: 24,
+		ROLESTATUS: 1, ROLETYPE: 2, MODIFYTIME: "-", MODIFIERID: 1, MODIFIERNAME: "平台"})
+	sDataEx = append(sDataEx, sData...)
+	return sDataEx, err
+}
+
+// ErmcpRoleMenuEx 角色菜单(分层级)
+type ErmcpRoleMenuEx struct {
+	Menu    ErmcpRoleMenu   // 父级菜单
+	SubMenu []ErmcpRoleMenu // 子级菜单
+}
+
+// add 添加子级菜单
+func (r *ErmcpRoleMenuEx) add(menu ErmcpRoleMenu) {
+	if menu.PARENTCODE == r.Menu.RESOURCECODE {
+		r.SubMenu = append(r.SubMenu, menu)
+	}
+}
+
+// ErmcpRoleMenu 角色菜单
+type ErmcpRoleMenu struct {
+	USERID        int64  `json:"userid"  xorm:"'USERID'"`               // 用户id
+	ROLEID        int32  `json:"roleid"  xorm:"'ROLEID'"`               // 角色id
+	RESOURCECODE  string `json:"resourcecode"  xorm:"'RESOURCECODE'"`   // 菜单代码
+	RESOURCENAME  string `json:"resourcename"  xorm:"'RESOURCENAME'"`   // 菜单名称
+	RESOURCELEVEL int32  `json:"resourcelevel"  xorm:"'RESOURCELEVEL'"` // 级别
+	MENUTYPE      int32  `json:"menutype"  xorm:"'MENUTYPE'"`           // 菜单类型 1:管理端 2:交易端 3:终端(企业云平台)
+	PARENTCODE    string `json:"parentcode"  xorm:"'PARENTCODE'"`       // 上级资源代码
+	URL           string `json:"url"  xorm:"'URL'"`                     // URL
+	SORT          int32  `json:"sort"  xorm:"'SORT'"`                   // 排序
+	ICONAME       string `json:"iconame"  xorm:"'ICONAME'"`             // 菜单图标
+	REMARK        string `json:"remark"  xorm:"'REMARK'"`               // 菜单备注
+
+	FilterRoleId string `json:"-"` // 查询过滤条件, 角色 - 逗号隔开
+}
+
+func (r *ErmcpRoleMenu) calc() {
+}
+
+func (r *ErmcpRoleMenu) buildSql() string {
+	var sqlId utils.SQLVal = "select distinct t.userid," +
+		"       t.roleid," +
+		"       t.resourcecode," +
+		"       f.resourcename," +
+		"       f.resourcelevel," +
+		"       f.menutype," +
+		"       f.parentcode," +
+		"       f.url," +
+		"       f.sort," +
+		"       f.iconame," +
+		"       f.remark" +
+		"  from ermcp_memberfuncmenu t" +
+		" inner join funcmenulist f" +
+		"    on t.resourcecode = f.resourcecode" +
+		" where t.isvalid = 1"
+	if r.USERID > 0 {
+		sqlId.And("t.userid", r.USERID)
+	}
+	if len(r.FilterRoleId) > 0 {
+		sqlId.Join(fmt.Sprintf(" and t.roleid in(%v)", r.FilterRoleId))
+	}
+	sqlId.Join(" order by f.resourcelevel, f.sort")
+	return sqlId.String()
+}
+
+// GetDataEx 查询角色菜单
+func (r *ErmcpRoleMenu) GetDataEx() (interface{}, error) {
+	sData := make([]ErmcpRoleMenu, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	// 构建层级树
+	sDataEx := make([]ErmcpRoleMenuEx, 0)
+	// 最多构建4层
+	for level := int32(1); level <= 4; level++ {
+		for _, v := range sData {
+			if v.RESOURCELEVEL == level {
+				val := ErmcpRoleMenuEx{Menu: v, SubMenu: make([]ErmcpRoleMenu, 0)}
+				for _, v2 := range sData {
+					// 获取子菜单
+					if v2.ROLEID == v.ROLEID && v2.PARENTCODE == v.RESOURCECODE {
+						val.SubMenu = append(val.SubMenu, v2)
+					}
+				}
+				// 第一层固定要, 不管有没有子菜单
+				if val.Menu.RESOURCELEVEL == 1 {
+					sDataEx = append(sDataEx, val)
+				} else if val.Menu.RESOURCELEVEL > 1 && len(val.SubMenu) > 0 {
+					// 第二层开始,有子菜单内容的才要
+					sDataEx = append(sDataEx, val)
+				}
+			}
+		}
+	}
+	return sDataEx, err
+}
+
+// ErmcpBizGroupSpotGoods 业务类型分组商品表
+type ErmcpBizGroupSpotGoods struct {
+	BIZTYPE        int32  `json:"biztype"  xorm:"'BIZTYPE'"`               // 业务类型 1-套保 2-套利
+	BIZGROUPID     int64  `json:"bizgroupid"  xorm:"'BIZGROUPID'"`         // 分组id
+	WRSTANDARDID   int32  `json:"wrstandardid"  xorm:"'WRSTANDARDID'"`     // 现货商品id
+	WRSTANDARDCODE string `json:"wrstandardcode"  xorm:"'WRSTANDARDCODE'"` // 现货商品代码
+	WRSTANDARDNAME string `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"` // 现货商品名称
+	UNITID         int32  `json:"unitid"  xorm:"'UNITID'"`                 // 现货商品单位id
+	AREAUSERID     int64  `json:"areauserid"  xorm:"'AREAUSERID'"`         // 所属机构id
+}
+
+func (r *ErmcpBizGroupSpotGoods) calc() {
+}
+
+func (r *ErmcpBizGroupSpotGoods) buildSql() string {
+	var sqlId utils.SQLVal = "select t.biztype," +
+		"       t.bizgroupid," +
+		"       t.wrstandardid," +
+		"       w.wrstandardcode," +
+		"       w.wrstandardname," +
+		"       w.unitid," +
+		"       w.areauserid" +
+		"  from ermcp_bizgroupspotgoods t" +
+		"  left join wrstandard w" +
+		"    on t.wrstandardid = w.wrstandardid" +
+		" where 1 = 1"
+	if r.AREAUSERID > 0 {
+		sqlId.And("w.AREAUSERID", r.AREAUSERID)
+	}
+	return sqlId.String()
+}
+
+// GetDataEx 获取业务类型分组商品
+func (r *ErmcpBizGroupSpotGoods) GetDataEx() ([]ErmcpBizGroupSpotGoods, error) {
+	sData := make([]ErmcpBizGroupSpotGoods, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}
+
+// ErcmpBizGroupTaaccount 业务分组账号
+type ErmcpBizGroupTaAccount struct {
+	BIZGROUPID  int64  `json:"bizgroupid"  xorm:"'BIZGROUPID'"`   // 业务分组id
+	ACCOUNTID   string `json:"accountid"  xorm:"'ACCOUNTID'"`     // 账号id
+	AREAUSERID  int64  `json:"areauserid"  xorm:"'AREAUSERID'"`   // 所属机构id
+	ACCOUNTNAME string `json:"accountname"  xorm:"'ACCOUNTNAME'"` // 账号名称
+	ISMAIN      int32  `json:"ismain"  xorm:"'ISMAIN'"`           // 是否主账号 1-是 0-否
+}
+
+func (r *ErmcpBizGroupTaAccount) calc() {
+}
+
+func (r *ErmcpBizGroupTaAccount) buildSql() string {
+	var sqlId utils.SQLVal = "select t.bizgroupid," +
+		"       t.accountid," +
+		"       ta.relateduserid areauserid," +
+		"       ta.accountname," +
+		"       ta.ismain" +
+		"  from ermcp_bizgrouptaaccount t" +
+		"  left join taaccount ta" +
+		"    on t.accountid = ta.accountid" +
+		" where 1 = 1"
+	if r.AREAUSERID > 0 {
+		sqlId.And("ta.relateduserid", r.AREAUSERID)
+	}
+	return sqlId.String()
+}
+
+// GetDataEx 获取业务分组账号
+func (r *ErmcpBizGroupTaAccount) GetDataEx() ([]ErmcpBizGroupTaAccount, error) {
+	sData := make([]ErmcpBizGroupTaAccount, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}
+
+// 账户设置分组信息
+type ErmcpBizGroupEx struct {
+	BIZTYPE    int32 `json:"biztype"  xorm:"'BIZTYPE'"`       // 业务类型 1-套保 2-套利
+	BIZGROUPID int64 `json:"bizgroupid"  xorm:"'BIZGROUPID'"` // 业务分组id
+
+	AccList []ErmcpBizGroupTaAccount `json:"acclist"` // 账号列表
+	WrList  []ErmcpBizGroupSpotGoods `json:"wrlist"`  // 现货商品表表
+
+	AREAUSERID int64 `json:"-"` // 所属机构
+}
+
+// GetDataEx 获取账户设置分组信息
+func (r *ErmcpBizGroupEx) GetDataEx() (interface{}, error) {
+	sData := make([]ErmcpBizGroupEx, 0)
+	mWr := ErmcpBizGroupSpotGoods{AREAUSERID: r.AREAUSERID}
+	mAcc := ErmcpBizGroupTaAccount{AREAUSERID: r.AREAUSERID}
+	if wrLst, err := mWr.GetDataEx(); err == nil {
+		for i := range wrLst {
+			var bFind bool = false
+			for k := range sData {
+				if sData[k].BIZGROUPID == wrLst[i].BIZGROUPID &&
+					sData[k].BIZTYPE == wrLst[i].BIZTYPE {
+					sData[k].WrList = append(sData[k].WrList, wrLst[i])
+					bFind = true
+				}
+			}
+
+			if !bFind {
+				var d = ErmcpBizGroupEx{BIZGROUPID: wrLst[i].BIZGROUPID,
+					BIZTYPE: wrLst[i].BIZTYPE,
+					AccList: make([]ErmcpBizGroupTaAccount, 0),
+					WrList:  make([]ErmcpBizGroupSpotGoods, 0)}
+				d.WrList = append(d.WrList, wrLst[i])
+				sData = append(sData, d)
+			}
+		}
+	}
+
+	if accLst, err := mAcc.GetDataEx(); err == nil {
+		for i := range accLst {
+			for k := range sData {
+				if sData[k].BIZGROUPID == accLst[i].BIZGROUPID {
+					sData[k].AccList = append(sData[k].AccList, accLst[i])
+				}
+			}
+		}
+	}
+
+	return sData, nil
+}
+
+// 资金账号信息
+type ErmcpTaAccountInfo struct {
+	CREDITDECREASE        float64 `json:"creditdecrease"  xorm:"'CREDITDECREASE'"`             // 今日授信减少
+	OTHERCREDITINCREASE   float64 `json:"othercreditincrease"  xorm:"'OTHERCREDITINCREASE'"`   // 今日其它授信增加
+	OTHERCREDITDECREASE   float64 `json:"othercreditdecrease"  xorm:"'OTHERCREDITDECREASE'"`   // 今日其它授信减少
+	TRANSFERAMOUNT        float64 `json:"transferamount"  xorm:"'TRANSFERAMOUNT'"`             // 今日划转金额(母子账号资金划转,从划入账号为正,从账号划出为负)
+	OTHERPAY              float64 `json:"-"  xorm:"'OTHERPAY'"`                                // 其他支出(交割付款 申购付款 全款买入 商城买入 卖家退货)
+	OTHERINCOME           float64 `json:"-"  xorm:"'OTHERINCOME'"`                             // 其他收入(交割收款 申购收款 全款卖出 商城卖出 买家退货 会员手续费收入)
+	OUTTHRESHOLD          float64 `json:"outthreshold"  xorm:"'OUTTHRESHOLD'"`                 // 出金阈值
+	TRADESTATUSCHANGETIME string  `json:"-"  xorm:"'TRADESTATUSCHANGETIME'"`                   // 激活时间
+	CHANGETIME            string  `json:"-"  xorm:"'CHANGETIME'"`                              // 账户状态变更时间
+	THIRDINAMOUNT         float64 `json:"thirdinamount"  xorm:"'THIRDINAMOUNT'"`               // 今日三方入金
+	THIRDOUTAMOUNT        float64 `json:"thirdoutamount"  xorm:"'THIRDOUTAMOUNT'"`             // 今日三方出金
+	CAPITALBALANCE        float64 `json:"capitalbalance"  xorm:"'CAPITALBALANCE'"`             // 本金余额[外部子账户实际出入金余额]
+	FROMACCOUNTID         int64   `json:"fromaccountid"  xorm:"'FROMACCOUNTID'"`               // 所属上级账户
+	SUBLEVELPATH          string  `json:"sublevelpath"  xorm:"'SUBLEVELPATH'"`                 // 账号层级路径(逗号分隔,首尾加逗号)
+	SERIVCEGROUP          int64   `json:"-"  xorm:"'SERIVCEGROUP'"`                            // 服务分组
+	ACCOUNTNAME           string  `json:"accountname"  xorm:"'ACCOUNTNAME'"`                   // 账户名称
+	ACCOUNTFLAG           int32   `json:"-"  xorm:"'ACCOUNTFLAG'"`                             // 账户标识 - 0\1 (默认为0, 当上级账户与本账户的关联用户均为自己时更新为1)
+	ORIDEBT               float64 `json:"oridebt"  xorm:"'ORIDEBT'"`                           // 期初欠款
+	CURDEBT               float64 `json:"curdebt"  xorm:"'CURDEBT'"`                           // 期末欠款
+	ACCOUNTID             int64   `json:"accountid"  xorm:"'ACCOUNTID'"`                       // 资金账户ID
+	USERID                int64   `json:"userid"  xorm:"'USERID'"`                             // 用户ID
+	CURRENCYID            int64   `json:"currencyid"  xorm:"'CURRENCYID'"`                     // 货币ID
+	CHANGEFLAG            int32   `json:"-"  xorm:"'CHANGEFLAG'"`                              // 变动标志(当前账户资金有任何变动更新为1系统结算时更新0;供清算时使用) 0:无变动 1:有变动
+	PASSWORD              string  `json:"-"  xorm:"'PASSWORD'"`                                // 资金密码
+	TRADESTATUS           int32   `json:"tradestatus"  xorm:"'TRADESTATUS'"`                   // 交易状态 - 1:正常 2:受限 3:冻结 4:禁止建仓(人工受限) 5:禁止交易(人工冻结) 6:待激活 7:已注销
+	SIGNSTATUS            int32   `json:"signstatus"  xorm:"'SIGNSTATUS'"`                     // 签约状态 - 1:未签约 2:签约待审核 3:签约中 4:已签约 5:解约待审核 6:解约中 7:已解约 8:已解绑 9:绑卡中
+	ISMAIN                int32   `json:"ismain"  xorm:"'ISMAIN'"`                             // 是否母账号 0:不是母账户 1:是母账户
+	PARENTACCOUNTID       int64   `json:"parentaccountid"  xorm:"'PARENTACCOUNTID'"`           // 所属根账号
+	RELATEDUSERID         int64   `json:"relateduserid"  xorm:"'RELATEDUSERID'"`               // 关联用户
+	RELATEDACCOUNTSTATUS  int32   `json:"-"  xorm:"'RELATEDACCOUNTSTATUS'"`                    // 关联用户交易权限状态 - 1:正常(可交易) 2:受限(可平仓,不可建仓) 3:冻结(不可交易)
+	TAACCOUNTTYPE         int32   `json:"taaccounttype"  xorm:"'TAACCOUNTTYPE'"`               // 账号类型 - 1:外部账号 2:内部账号 3:内部做市自营账号 4:内部做市接单账号
+	ISRECKONACCOUNT       int32   `json:"-"  xorm:"'ISRECKONACCOUNT'"`                         // 是否机构分润账号 0:不是 1:是
+	ISMARKETACCOUNT       int32   `json:"-"  xorm:"'ISMARKETACCOUNT'"`                         // 是否机构接单账号 0:不是 1:是
+	BALANCE               float64 `json:"balance"  xorm:"'BALANCE'"`                           // 期初余额
+	ORIFREEZEMARGIN       float64 `json:"orifreezemargin"  xorm:"'ORIFREEZEMARGIN'"`           // 期初冻结保证金
+	ORIUSEDMARGIN         float64 `json:"oriusedmargin"  xorm:"'ORIUSEDMARGIN'"`               // 期初占用保证金
+	ORIOTHERFREEZEMARGIN  float64 `json:"oriotherfreezemargin"  xorm:"'ORIOTHERFREEZEMARGIN'"` // 期初其他冻结保证金(出金冻结资金 交割买方冻结 申购冻结 全款买入 商城买入)
+	ORIFREEZECHARGE       float64 `json:"orifreezecharge"  xorm:"'ORIFREEZECHARGE'"`           // 期初手续费冻结
+	ORIMORTGAGECREDIT     float64 `json:"orimortgagecredit"  xorm:"'ORIMORTGAGECREDIT'"`       // 期初授信金额
+	ORIOTHERCREDIT        float64 `json:"oriothercredit"  xorm:"'ORIOTHERCREDIT'"`             // 期初其它授信金额
+	ORIOUTAMOUNTFREEZE    float64 `json:"orioutamountfreeze"  xorm:"'ORIOUTAMOUNTFREEZE'"`     // 期初出金冻结
+	FREEZEMARGIN          float64 `json:"freezemargin"  xorm:"'FREEZEMARGIN'"`                 // 冻结保证金
+	USEDMARGIN            float64 `json:"usedmargin"  xorm:"'USEDMARGIN'"`                     // 占用保证金
+	OTHERFREEZEMARGIN     float64 `json:"otherfreezemargin"  xorm:"'OTHERFREEZEMARGIN'"`       // 其他冻结保证金(交割买方冻结 申购冻结 全款买入 商城买入)
+	FREEZECHARGE          float64 `json:"freezecharge"  xorm:"'FREEZECHARGE'"`                 // 手续费冻结
+	MORTGAGECREDIT        float64 `json:"mortgagecredit"  xorm:"'MORTGAGECREDIT'"`             // 授信金额
+	OTHERCREDIT           float64 `json:"othercredit"  xorm:"'OTHERCREDIT'"`                   // 其它授信金额
+	OUTAMOUNTFREEZE       float64 `json:"outamountfreeze"  xorm:"'OUTAMOUNTFREEZE'"`           // 出金冻结
+	INAMOUNT              float64 `json:"inamount"  xorm:"'INAMOUNT'"`                         // 今日入金金额(包括三方入金)
+	CURRENTBALANCE        float64 `json:"currentbalance"  xorm:"'CURRENTBALANCE'"`             // 期末余额
+	OUTAMOUNT             float64 `json:"outamount"  xorm:"'OUTAMOUNT'"`                       // 今日出金金额(包括三方出金)
+	PAYCHARGE             float64 `json:"paycharge"  xorm:"'PAYCHARGE'"`                       // 今日手续费支出
+	CLOSEPL               float64 `json:"closepl"  xorm:"'CLOSEPL'"`                           // 今日平仓盈亏
+	CREDITINCREASE        float64 `json:"creditincrease"  xorm:"'CREDITINCREASE'"`             // 今日授信增加
+}
+
+func (r *ErmcpTaAccountInfo) calc() {
+}
+
+func (r *ErmcpTaAccountInfo) buildSql() string {
+	var sqlId utils.SQLVal = "select * from taaccount t where 1 = 1"
+	if r.USERID > 0 {
+		sqlId.And("t.RELATEDUSERID", r.RELATEDUSERID)
+	}
+	if r.ACCOUNTID > 0 {
+		sqlId.And("t.accountid", r.ACCOUNTID)
+	}
+	return sqlId.String()
+}
+
+// 获取资金账号信息
+func (r *ErmcpTaAccountInfo) GetDataEx() (interface{}, error) {
+	sData := make([]ErmcpTaAccountInfo, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}

+ 36 - 0
models/ermcpCommon.go

@@ -0,0 +1,36 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/3/30 14:51
+* @Modify  : 2021/3/30 14:51
+* @Note    : Ermcp定义一些公共的方法或变量
+ */
+
+package models
+
+import (
+	"encoding/hex"
+	"mtp2_if/utils"
+)
+
+// IErmcp 通用接口
+type IErmcp interface {
+	calc()                           // 相关计算和数据处理
+	buildSql() string                // 生成sql语句
+	GetDataEx() (interface{}, error) // 获取数据接口
+}
+
+// DecryptField 解密字段
+func DecryptField(oriStr string) string {
+	key := "0d299ce2d4105282f7471074cb0f9f9d"
+	key2, _ := hex.DecodeString(key)
+	if oriStr == "" {
+		return oriStr
+	}
+
+	d, _ := hex.DecodeString(oriStr)
+	if dst, err := utils.AESDecrypt(d, key2); err == nil {
+		return string(dst)
+	}
+
+	return oriStr
+}

+ 7 - 0
routers/router.go

@@ -371,6 +371,13 @@ func InitRouter() *gin.Engine {
 		ermcpR.GET("/QueryAreaStockReportDetail", ermcp.QueryAreaStockReportDetail)
 		ermcpR.GET("/QueryGoodsBrand", ermcp.QueryGoodsBrand)
 		ermcpR.GET("/QueryGoodsModel", ermcp.QueryGoodsModel)
+		ermcpR.GET("/QueryAccMgrLoginUser", ermcp.QueryAccMgrLoginUser)
+		ermcpR.GET("/QueryAccMgrTaaccount", ermcp.QueryAccMgrTaaccount)
+		ermcpR.GET("/QueryAccMgrMainAccountInfo", ermcp.QueryAccMgrMainAccountInfo)
+		ermcpR.GET("/QueryAccMgrRole", ermcp.QueryAccMgrRole)
+		ermcpR.GET("/QueryAccMgrRoleMenu", ermcp.QueryAccMgrRoleMenu)
+		ermcpR.GET("/QueryAccMgrBizGroupSet", ermcp.QueryAccMgrBizGroupSet)
+		ermcpR.GET("/QueryAccMgrTaAccountInfo", ermcp.QueryAccMgrTaAccountInfo)
 
 		// 期货相关
 		// 查询企业风管期货商品信息