Переглянути джерело

1.账户管理接口 拆分三个页签查询
2.套保计划 增加品类、交易用户、币种
3.现货市价详情 增加品牌、品类过滤
4.现货合同 增加交易用户、结算币种

zou.yingbin 4 роки тому
батько
коміт
6c1f7fb17b

+ 4 - 2
controllers/ermcp/qryAccMgr.go

@@ -15,7 +15,8 @@ import (
 
 // QryLoginUserReq
 type QryLoginUserReq struct {
-	UserId int64 `form:"userid" binding:"required"` // 用户id
+	UserId    int64 `form:"userid" binding:"required"`    // 用户id
+	QueryType int32 `form:"querytype" binding:"required"` // 查询类型 1-业务账户 2-交易账户 3-管理账户
 }
 
 // QueryAccMgrLoginUser
@@ -23,6 +24,7 @@ type QryLoginUserReq struct {
 // @Produce json
 // @Security ApiKeyAuth
 // @Param userid query int true "用户ID"
+// @Param querytype query int true "查询类型 1-业务账户 2-交易账户 3-管理账户"
 // @Success 200 {array} models.ErmcpLoginUserEx
 // @Failure 500 {object} app.Response
 // @Router /Ermcp/QueryAccMgrLoginUser [get]
@@ -31,7 +33,7 @@ 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}
+	m := models.ErmcpLoginUser{MEMBERUSERID: req.UserId, USERID: req.UserId, QueryType: req.QueryType}
 	a.DoGetDataI(&m)
 }
 

+ 6 - 1
controllers/ermcp3/qryErmcp3.go

@@ -468,6 +468,8 @@ func QuerySpotGoodsPrice(c *gin.Context) {
 // @Security ApiKeyAuth
 // @Param userid query int true "用户ID"
 // @Param deliverygoodsid query int true "现货商品ID"
+// @Param brandid query int false "品牌ID"
+// @Param wrstandardid query int false "品类ID"
 // @Success 200 {array} models.Ermcp3SpotGoodsPriceLog
 // @Failure 500 {object} app.Response
 // @Router /Ermcp3/QuerySpotGoodsPriceLog [get]
@@ -476,10 +478,13 @@ func QuerySpotGoodsPriceLog(c *gin.Context) {
 	req := struct {
 		UserId          int64 `form:"userid" binding:"required"`          // 用户id
 		DELIVERYGOODSID int32 `form:"deliverygoodsid" binding:"required"` // 现货商品id
+		WRSTANDARDID    int64 `form:"wrstandardid"`                       // 品类id
+		BRANDID         int32 `form:"brandid"`                            // 品牌id
 	}{}
 	a := app.GinUtils{Gin: app.Gin{C: c}}
 	a.DoBindReq(&req)
-	m := models.Ermcp3SpotGoodsPriceLog{AREAUSERID: req.UserId, DELIVERYGOODSID: req.DELIVERYGOODSID}
+	m := models.Ermcp3SpotGoodsPriceLog{AREAUSERID: req.UserId,
+		DELIVERYGOODSID: req.DELIVERYGOODSID, WRSTANDARDID: req.WRSTANDARDID, SPOTGOODSBRANDID: req.BRANDID}
 	a.DoGetDataI(&m)
 }
 

+ 67 - 4
docs/docs.go

@@ -1591,6 +1591,13 @@ var doc = `{
                         "name": "userid",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "查询类型 1-业务账户 2-交易账户 3-管理账户",
+                        "name": "querytype",
+                        "in": "query",
+                        "required": true
                     }
                 ],
                 "responses": {
@@ -5615,6 +5622,18 @@ var doc = `{
                         "name": "deliverygoodsid",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "品牌ID",
+                        "name": "brandid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "品类ID",
+                        "name": "wrstandardid",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -12149,6 +12168,10 @@ var doc = `{
                     "description": "审核时间",
                     "type": "string"
                 },
+                "auditsrc": {
+                    "description": "审核来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
                 "bankaccount": {
                     "description": "银行帐号 (加密存储)",
                     "type": "string"
@@ -12369,12 +12392,16 @@ var doc = `{
                     "description": "开户支行",
                     "type": "string"
                 },
+                "taxpayernum": {
+                    "description": "纳税人识别号",
+                    "type": "string"
+                },
                 "telphone": {
                     "description": "联系电话(加密存储)",
                     "type": "string"
                 },
                 "userid": {
-                    "description": "用户ID(自增ID)",
+                    "description": "用户ID(自增ID)SEQ_WSKH_USERINFO",
                     "type": "integer"
                 },
                 "userinfotype": {
@@ -12476,6 +12503,10 @@ var doc = `{
                     "description": "审核时间",
                     "type": "string"
                 },
+                "auditsrc": {
+                    "description": "审核来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
                 "bankaccount": {
                     "description": "银行帐号 (加密存储)",
                     "type": "string"
@@ -12696,12 +12727,16 @@ var doc = `{
                     "description": "开户支行",
                     "type": "string"
                 },
+                "taxpayernum": {
+                    "description": "纳税人识别号",
+                    "type": "string"
+                },
                 "telphone": {
                     "description": "联系电话(加密存储)",
                     "type": "string"
                 },
                 "userid": {
-                    "description": "用户ID(自增ID)",
+                    "description": "用户ID(自增ID)SEQ_WSKH_USERINFO",
                     "type": "integer"
                 },
                 "userinfotype": {
@@ -14038,6 +14073,14 @@ var doc = `{
                     "description": "创建时间",
                     "type": "string"
                 },
+                "currencyid": {
+                    "description": "币种id",
+                    "type": "integer"
+                },
+                "currencyname": {
+                    "description": "币种名称",
+                    "type": "string"
+                },
                 "deliveryenddate": {
                     "description": "交收期(结束)",
                     "type": "string"
@@ -14158,6 +14201,10 @@ var doc = `{
                     "description": "交易员登录代码",
                     "type": "string"
                 },
+                "tradeusername": {
+                    "description": "交易员名称",
+                    "type": "string"
+                },
                 "unitid": {
                     "description": "单位id(取品类上的单位id)",
                     "type": "integer"
@@ -14457,6 +14504,14 @@ var doc = `{
                     "description": "创建时间",
                     "type": "string"
                 },
+                "currencyid": {
+                    "description": "币种id",
+                    "type": "integer"
+                },
+                "currencyname": {
+                    "description": "币种名称",
+                    "type": "string"
+                },
                 "deliverygoodscode": {
                     "description": "现货品种代码",
                     "type": "string"
@@ -14509,6 +14564,14 @@ var doc = `{
                     "description": "资金账号名称",
                     "type": "string"
                 },
+                "tradeuserid": {
+                    "description": "交易用户id",
+                    "type": "integer"
+                },
+                "tradeusername": {
+                    "description": "交易用户名称",
+                    "type": "string"
+                },
                 "unitid": {
                     "description": "单位id",
                     "type": "integer"
@@ -17074,11 +17137,11 @@ var doc = `{
             "type": "object",
             "properties": {
                 "roleid": {
-                    "description": "角色id",
+                    "description": "角色id(交易账户-\u003e用户id)",
                     "type": "integer"
                 },
                 "rolename": {
-                    "description": "角色名称",
+                    "description": "角色名称(交易账户-\u003e用户名称)",
                     "type": "string"
                 },
                 "userlist": {

+ 67 - 4
docs/swagger.json

@@ -1575,6 +1575,13 @@
                         "name": "userid",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "查询类型 1-业务账户 2-交易账户 3-管理账户",
+                        "name": "querytype",
+                        "in": "query",
+                        "required": true
                     }
                 ],
                 "responses": {
@@ -5599,6 +5606,18 @@
                         "name": "deliverygoodsid",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "品牌ID",
+                        "name": "brandid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "品类ID",
+                        "name": "wrstandardid",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -12133,6 +12152,10 @@
                     "description": "审核时间",
                     "type": "string"
                 },
+                "auditsrc": {
+                    "description": "审核来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
                 "bankaccount": {
                     "description": "银行帐号 (加密存储)",
                     "type": "string"
@@ -12353,12 +12376,16 @@
                     "description": "开户支行",
                     "type": "string"
                 },
+                "taxpayernum": {
+                    "description": "纳税人识别号",
+                    "type": "string"
+                },
                 "telphone": {
                     "description": "联系电话(加密存储)",
                     "type": "string"
                 },
                 "userid": {
-                    "description": "用户ID(自增ID)",
+                    "description": "用户ID(自增ID)SEQ_WSKH_USERINFO",
                     "type": "integer"
                 },
                 "userinfotype": {
@@ -12460,6 +12487,10 @@
                     "description": "审核时间",
                     "type": "string"
                 },
+                "auditsrc": {
+                    "description": "审核来源 - 1:管理端 2:终端",
+                    "type": "integer"
+                },
                 "bankaccount": {
                     "description": "银行帐号 (加密存储)",
                     "type": "string"
@@ -12680,12 +12711,16 @@
                     "description": "开户支行",
                     "type": "string"
                 },
+                "taxpayernum": {
+                    "description": "纳税人识别号",
+                    "type": "string"
+                },
                 "telphone": {
                     "description": "联系电话(加密存储)",
                     "type": "string"
                 },
                 "userid": {
-                    "description": "用户ID(自增ID)",
+                    "description": "用户ID(自增ID)SEQ_WSKH_USERINFO",
                     "type": "integer"
                 },
                 "userinfotype": {
@@ -14022,6 +14057,14 @@
                     "description": "创建时间",
                     "type": "string"
                 },
+                "currencyid": {
+                    "description": "币种id",
+                    "type": "integer"
+                },
+                "currencyname": {
+                    "description": "币种名称",
+                    "type": "string"
+                },
                 "deliveryenddate": {
                     "description": "交收期(结束)",
                     "type": "string"
@@ -14142,6 +14185,10 @@
                     "description": "交易员登录代码",
                     "type": "string"
                 },
+                "tradeusername": {
+                    "description": "交易员名称",
+                    "type": "string"
+                },
                 "unitid": {
                     "description": "单位id(取品类上的单位id)",
                     "type": "integer"
@@ -14441,6 +14488,14 @@
                     "description": "创建时间",
                     "type": "string"
                 },
+                "currencyid": {
+                    "description": "币种id",
+                    "type": "integer"
+                },
+                "currencyname": {
+                    "description": "币种名称",
+                    "type": "string"
+                },
                 "deliverygoodscode": {
                     "description": "现货品种代码",
                     "type": "string"
@@ -14493,6 +14548,14 @@
                     "description": "资金账号名称",
                     "type": "string"
                 },
+                "tradeuserid": {
+                    "description": "交易用户id",
+                    "type": "integer"
+                },
+                "tradeusername": {
+                    "description": "交易用户名称",
+                    "type": "string"
+                },
                 "unitid": {
                     "description": "单位id",
                     "type": "integer"
@@ -17058,11 +17121,11 @@
             "type": "object",
             "properties": {
                 "roleid": {
-                    "description": "角色id",
+                    "description": "角色id(交易账户-\u003e用户id)",
                     "type": "integer"
                 },
                 "rolename": {
-                    "description": "角色名称",
+                    "description": "角色名称(交易账户-\u003e用户名称)",
                     "type": "string"
                 },
                 "userlist": {

+ 50 - 4
docs/swagger.yaml

@@ -2113,6 +2113,9 @@ definitions:
       auditime:
         description: 审核时间
         type: string
+      auditsrc:
+        description: 审核来源 - 1:管理端 2:终端
+        type: integer
       bankaccount:
         description: 银行帐号 (加密存储)
         type: string
@@ -2279,11 +2282,14 @@ definitions:
       subbranch:
         description: 开户支行
         type: string
+      taxpayernum:
+        description: 纳税人识别号
+        type: string
       telphone:
         description: 联系电话(加密存储)
         type: string
       userid:
-        description: 用户ID(自增ID)
+        description: 用户ID(自增ID)SEQ_WSKH_USERINFO
         type: integer
       userinfotype:
         description: 用户信息类型 - 1:个人  2:企业
@@ -2357,6 +2363,9 @@ definitions:
       auditime:
         description: 审核时间
         type: string
+      auditsrc:
+        description: 审核来源 - 1:管理端 2:终端
+        type: integer
       bankaccount:
         description: 银行帐号 (加密存储)
         type: string
@@ -2523,11 +2532,14 @@ definitions:
       subbranch:
         description: 开户支行
         type: string
+      taxpayernum:
+        description: 纳税人识别号
+        type: string
       telphone:
         description: 联系电话(加密存储)
         type: string
       userid:
-        description: 用户ID(自增ID)
+        description: 用户ID(自增ID)SEQ_WSKH_USERINFO
         type: integer
       userinfotype:
         description: 用户信息类型 - 1:个人  2:企业
@@ -3514,6 +3526,12 @@ definitions:
       createtime:
         description: 创建时间
         type: string
+      currencyid:
+        description: 币种id
+        type: integer
+      currencyname:
+        description: 币种名称
+        type: string
       deliveryenddate:
         description: 交收期(结束)
         type: string
@@ -3604,6 +3622,9 @@ definitions:
       tradeuserlogincode:
         description: 交易员登录代码
         type: string
+      tradeusername:
+        description: 交易员名称
+        type: string
       unitid:
         description: 单位id(取品类上的单位id)
         type: integer
@@ -3824,6 +3845,12 @@ definitions:
       createtime:
         description: 创建时间
         type: string
+      currencyid:
+        description: 币种id
+        type: integer
+      currencyname:
+        description: 币种名称
+        type: string
       deliverygoodscode:
         description: 现货品种代码
         type: string
@@ -3863,6 +3890,12 @@ definitions:
       taaccountname:
         description: 资金账号名称
         type: string
+      tradeuserid:
+        description: 交易用户id
+        type: integer
+      tradeusername:
+        description: 交易用户名称
+        type: string
       unitid:
         description: 单位id
         type: integer
@@ -5757,10 +5790,10 @@ definitions:
   models.ErmcpLoginUserEx:
     properties:
       roleid:
-        description: 角色id
+        description: 角色id(交易账户->用户id)
         type: integer
       rolename:
-        description: 角色名称
+        description: 角色名称(交易账户->用户名称)
         type: string
       userlist:
         description: 用户列表
@@ -13423,6 +13456,11 @@ paths:
         name: userid
         required: true
         type: integer
+      - description: 查询类型 1-业务账户 2-交易账户 3-管理账户
+        in: query
+        name: querytype
+        required: true
+        type: integer
       produces:
       - application/json
       responses:
@@ -15966,6 +16004,14 @@ paths:
         name: deliverygoodsid
         required: true
         type: integer
+      - description: 品牌ID
+        in: query
+        name: brandid
+        type: integer
+      - description: 品类ID
+        in: query
+        name: wrstandardid
+        type: integer
       produces:
       - application/json
       responses:

+ 16 - 0
models/ermcp3.go

@@ -643,12 +643,15 @@ type Ermcp3Contract struct {
 	MERUSERID         int64   `json:"meruserid"  xorm:"'MERUSERID'"`                 // 跟单员id
 	ACCOUNTID         string  `json:"accountid"  xorm:"'ACCOUNTID'"`                 // 期货账户id
 	BIZTYPE           int32   `json:"biztype"  xorm:"'BIZTYPE'"`                     // 业务类型 1-套保 2-套利
+	CURRENCYID        int32   `json:"currencyid"  xorm:"'CURRENCYID'"`               // 币种id
 
 	SELLNICKNAME       string `json:"sellnickname"`       // 采购方昵称
 	BUYNICKNAME        string `json:"buynickname"`        // 销售方昵称
 	TRADEUSERLOGINCODE string `json:"tradeuserlogincode"` // 交易员登录代码
 	SALEUSERLOGINCODE  string `json:"saleuserlogincode"`  // 业务员登录代码
 	MERUSERLOGINCODE   string `json:"meruserlogincode"`   // 跟单员登录代码
+	CURRENCYNAME       string `json:"currencyname"`       // 币种名称
+	TRADEUSERNAME      string `json:"tradeusername"`      // 交易员名称
 
 	// 筛选条件
 	QryType   int32 `json:"-"` // 查询类型 1-未提交 2-待审核 3-履约中 4-已完成
@@ -678,6 +681,8 @@ func (r *Ermcp3Contract) calc() {
 	r.TRADEUSERLOGINCODE = mtpcache.GetLoginCodeByUserId(r.TRADEUSERID)
 	r.SALEUSERLOGINCODE = mtpcache.GetLoginCodeByUserId(r.SALEUSERID)
 	r.MERUSERLOGINCODE = mtpcache.GetLoginCodeByUserId(r.MERUSERID)
+	r.TRADEUSERNAME = mtpcache.GetUserNameByUserId(r.TRADEUSERID)
+	r.CURRENCYNAME = mtpcache.GetCurrencyName(r.CURRENCYID)
 }
 
 func (r *Ermcp3Contract) buildSql() string {
@@ -1870,6 +1875,8 @@ func (r *Ermcp3SpotGoodsPriceLog) buildSql() string {
 		" WHERE 1 = 1"
 	sqlId.And("w.areauserid", r.AREAUSERID)
 	sqlId.And("t.deliverygoodsid", r.DELIVERYGOODSID)
+	sqlId.AndEx("t.SPOTGOODSBRANDID", r.SPOTGOODSBRANDID, r.SPOTGOODSBRANDID > 0)
+	sqlId.AndEx("t.wrstandardid", r.WRSTANDARDID, r.WRSTANDARDID > 0)
 	return sqlId.String()
 }
 
@@ -1911,10 +1918,17 @@ type Ermcp3HedgePlan struct {
 	WRSTANDARDNAME    string  `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"`       // 品类名称
 	ACCOUNTID         int64   `json:"accountid"  xorm:"'ACCOUNTID'"`                 // 资金账号
 	TAACCOUNTNAME     string  `json:"taaccountname"  xorm:"'TAACCOUNTNAME'"`         // 资金账号名称
+	TRADEUSERID       int64   `json:"tradeuserid"  xorm:"'TRADEUSERID'"`             // 交易用户id
+	CURRENCYID        int32   `json:"currencyid"  xorm:"'CURRENCYID'"`               // 币种id
+
+	TRADEUSERNAME string `json:"tradeusername"` // 交易用户名称
+	CURRENCYNAME  string `json:"currencyname"`  // 币种名称
 }
 
 func (r *Ermcp3HedgePlan) calc() {
 	r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.UNITID)
+	r.TRADEUSERNAME = mtpcache.GetUserNameByUserId(r.TRADEUSERID)
+	r.CURRENCYNAME = mtpcache.GetCurrencyName(r.CURRENCYID)
 }
 
 func (r *Ermcp3HedgePlan) buildSql(status string) string {
@@ -1939,6 +1953,8 @@ func (r *Ermcp3HedgePlan) buildSql(status string) string {
 		"       w.wrstandardcode," +
 		"       w.wrstandardname," +
 		"       t.accountid," +
+		"       t.tradeuserid," +
+		"       t.currencyid," +
 		"       ta.accountname taaccountname" +
 		"  from ermcp_hedgeplan t" +
 		"  left join deliverygoods g" +

+ 178 - 33
models/ermcpAccMgr.go

@@ -17,10 +17,10 @@ import (
 
 // ErmcpLoginUserEx 登录账号(按角色)
 type ErmcpLoginUserEx struct {
-	ROLENAME string           `json:"rolename"` // 角色名称
+	ROLENAME string           `json:"rolename"` // 角色名称(交易账户->用户名称)
 	USERTYPE int32            `json:"usertype"` // 用户类型 2-机构 7-企业成员(云平台)
 	UserList []ErmcpLoginUser `json:"userlist"` // 用户列表
-	RoleId   int32            `json:"roleid"`   // 角色id
+	RoleId   int64            `json:"roleid"`   // 角色id(交易账户->用户id)
 }
 
 // ErmcpLoginUser 查询登录账户
@@ -40,7 +40,10 @@ type ErmcpLoginUser struct {
 	LOGINID      int64                 `json:"loginid"  xorm:"'LOGINID'"`           // 登录id(LOGINID)
 	PASSWORD     string                `json:"password"  xorm:"'PASSWORD'"`         // 密码(不可解密)
 	MOBILE       string                `json:"mobile"  xorm:"'MOBILE'"`             // 手机号
+	LOGINNAME    string                `json:"loginname"  xorm:"'LOGINNAME'"`       // 登录名称(loginaccount表中的accountname字段)
 	AccList      []ErmcpLoginTaAccount `json:"acclist"`                             // 关联资金账号
+
+	QueryType int32 `json:"-"` // 过滤条件 查询类型 1-业务账户 2-交易账户 3-管理账户
 }
 
 func (r *ErmcpLoginUser) addAcc(accLst []ErmcpLoginTaAccount) {
@@ -55,6 +58,67 @@ func (r *ErmcpLoginUser) calc() {
 	r.MOBILE = DecryptField(r.MOBILE)
 }
 
+func (r *ErmcpLoginUser) buildSqlRoleAcc() 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," +
+		"       '企业成员' rolename," +
+		"       l.loginstatus," +
+		"       l.password," +
+		"       l.mobile," +
+		"       l.accountname loginname" +
+		"  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"
+	sqlId.FormatParam(r.USERID)
+	return sqlId.String()
+}
+
+func (r *ErmcpLoginUser) buildSqlManageAcc() string {
+	var sqlId utils.SQLVal = "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," +
+		"       l.password," +
+		"       l.mobile," +
+		"       l.accountname loginname" +
+		"  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)
+	return sqlId.String()
+}
+
 func (r *ErmcpLoginUser) buildSql() string {
 	var sqlId utils.SQLVal = "with tmp as" +
 		" (select userid, wm_concat(roletype) roletype from arearole group by userid)" +
@@ -122,8 +186,96 @@ func (r *ErmcpLoginUser) hasRoletype(nType int32) bool {
 	return false
 }
 
-// GetDataEx 查询登录用户
-func (r *ErmcpLoginUser) GetDataEx() (interface{}, error) {
+// getBizLoginAcc 获取业务账号(角色为22, 23)
+func (r *ErmcpLoginUser) getBizLoginAcc() ([]ErmcpLoginUserEx, error) {
+	sDataEx := make([]ErmcpLoginUserEx, 0)
+	sDataEx = append(sDataEx, ErmcpLoginUserEx{
+		ROLENAME: "业务员",
+		RoleId:   22,
+		UserList: make([]ErmcpLoginUser, 0),
+		USERTYPE: 7})
+	sDataEx = append(sDataEx, ErmcpLoginUserEx{
+		ROLENAME: "跟单员",
+		RoleId:   23,
+		UserList: make([]ErmcpLoginUser, 0),
+		USERTYPE: 7})
+	// 查询用户
+	sData := make([]ErmcpLoginUser, 0)
+	err := db.GetEngine().SQL(r.buildSqlRoleAcc()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+		sData[i].AccList = make([]ErmcpLoginTaAccount, 0)
+	}
+	// 查询登录账号关联的资金账号
+	if len(sData) > 0 {
+		m := ErmcpLoginTaAccount{}
+		if accLst, err := m.GetData(); err == nil {
+			for i := range sData {
+				sData[i].addAcc(accLst)
+			}
+		}
+	}
+	// 按角色分组
+	for _, v := range sData {
+		for i := range sDataEx {
+			// 企业成员usertype=7需根据roletype判断
+			if sDataEx[i].RoleId == 22 && v.hasRoletype(22) {
+				v.ROLENAME = sDataEx[i].ROLENAME
+				sDataEx[i].UserList = append(sDataEx[i].UserList, v)
+			}
+			if sDataEx[i].RoleId == 23 && v.hasRoletype(23) {
+				v.ROLENAME = sDataEx[i].ROLENAME
+				sDataEx[i].UserList = append(sDataEx[i].UserList, v)
+			}
+		}
+	}
+
+	return sDataEx, err
+}
+
+// getTradeLoginAcc 获取交易账号(角色id为24, 但是要按用户分组)
+func (r *ErmcpLoginUser) getTradeLoginAcc() ([]ErmcpLoginUserEx, error) {
+	sDataEx := make([]ErmcpLoginUserEx, 0)
+	// 查询用户
+	sData := make([]ErmcpLoginUser, 0)
+	err := db.GetEngine().SQL(r.buildSqlRoleAcc()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+		sData[i].AccList = make([]ErmcpLoginTaAccount, 0)
+	}
+	// 查询登录账号关联的资金账号
+	if len(sData) > 0 {
+		m := ErmcpLoginTaAccount{}
+		if accLst, err := m.GetData(); err == nil {
+			for i := range sData {
+				sData[i].addAcc(accLst)
+			}
+		}
+	}
+	// 按用户分组
+	for _, v := range sData {
+		if v.hasRoletype(24) {
+			bExist := false
+			for i := range sDataEx {
+				if sDataEx[i].RoleId == v.USERID {
+					sDataEx[i].UserList = append(sDataEx[i].UserList, v)
+					bExist = true
+					break
+				}
+			}
+			if !bExist {
+				val := ErmcpLoginUserEx{RoleId: v.USERID, ROLENAME: v.ACCOUNTNAME, USERTYPE: 7, UserList: make([]ErmcpLoginUser, 0)}
+				val.UserList = append(val.UserList, v)
+				sDataEx = append(sDataEx, val)
+			}
+		}
+	}
+
+	return sDataEx, err
+}
+
+// getMangeLoginAcc 获取管理账户(角色表中创建的角色)
+func (r *ErmcpLoginUser) getMangeLoginAcc() ([]ErmcpLoginUserEx, error) {
 	sDataEx := make([]ErmcpLoginUserEx, 0)
 	// 查询角色
 	m := ErmcpRole{AREAUSERID: r.USERID}
@@ -135,19 +287,14 @@ func (r *ErmcpLoginUser) GetDataEx() (interface{}, error) {
 	for _, val := range roles {
 		sDataEx = append(sDataEx, ErmcpLoginUserEx{
 			ROLENAME: val.ROLENAME,
-			RoleId:   val.AUTOID,
+			RoleId:   int64(val.AUTOID),
 			UserList: make([]ErmcpLoginUser, 0),
-			USERTYPE: func(roldId int32) int32 {
-				if roldId == 22 || roldId == 23 || roldId == 24 {
-					return 7
-				}
-				return 2
-			}(val.AUTOID),
+			USERTYPE: 2,
 		})
 	}
 	// 查询用户
 	sData := make([]ErmcpLoginUser, 0)
-	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	err := db.GetEngine().SQL(r.buildSqlManageAcc()).Find(&sData)
 	for i := range sData {
 		sData[i].calc()
 		sData[i].AccList = make([]ErmcpLoginTaAccount, 0)
@@ -161,28 +308,12 @@ func (r *ErmcpLoginUser) GetDataEx() (interface{}, error) {
 			}
 		}
 	}
-	// 用户分组
+	// 管理员用户分组(按角色)
 	for _, v := range sData {
 		for i := range sDataEx {
-			if v.USERTYPE == 2 {
-				// 企业管理角色直接使用CLIENTROLEID判断
-				if sDataEx[i].RoleId == v.CLIENTROLEID {
-					sDataEx[i].UserList = append(sDataEx[i].UserList, v)
-				}
-			} else {
-				// 企业成员usertype=7需根据roletype判断
-				if sDataEx[i].RoleId == 22 && v.hasRoletype(22) {
-					v.ROLENAME = sDataEx[i].ROLENAME
-					sDataEx[i].UserList = append(sDataEx[i].UserList, v)
-				}
-				if sDataEx[i].RoleId == 23 && v.hasRoletype(23) {
-					v.ROLENAME = sDataEx[i].ROLENAME
-					sDataEx[i].UserList = append(sDataEx[i].UserList, v)
-				}
-				if sDataEx[i].RoleId == 24 && v.hasRoletype(24) {
-					v.ROLENAME = sDataEx[i].ROLENAME
-					sDataEx[i].UserList = append(sDataEx[i].UserList, v)
-				}
+			// 企业管理角色直接使用CLIENTROLEID判断
+			if sDataEx[i].RoleId == int64(v.CLIENTROLEID) {
+				sDataEx[i].UserList = append(sDataEx[i].UserList, v)
 			}
 		}
 	}
@@ -190,6 +321,17 @@ func (r *ErmcpLoginUser) GetDataEx() (interface{}, error) {
 	return sDataEx, err
 }
 
+// GetDataEx 查询登录用户
+func (r *ErmcpLoginUser) GetDataEx() (interface{}, error) {
+	if r.QueryType == 1 {
+		return r.getBizLoginAcc()
+	} else if r.QueryType == 2 {
+		return r.getTradeLoginAcc()
+	} else {
+		return r.getMangeLoginAcc()
+	}
+}
+
 // ErmcpTaAccount 期货账户(分组)
 type ErmcpTaAccountEx struct {
 	MainAcc    ErmcpTaAccount   `json:"mainAcc"`    // 主账号
@@ -363,6 +505,7 @@ func (r *ErmcpRole) GetData() ([]ErmcpRole, error) {
 	for i := range sData {
 		sData[i].calc()
 	}
+	/* 后期改动 无须增加固定角色
 	sDataEx := make([]ErmcpRole, 0)
 	// 添加固定角色22,23,24
 	sDataEx = append(sDataEx, ErmcpRole{AREAUSERID: r.AREAUSERID, ROLENAME: "业务员", AUTOID: 22,
@@ -373,6 +516,8 @@ func (r *ErmcpRole) GetData() ([]ErmcpRole, error) {
 		ROLESTATUS: 1, ROLETYPE: 2, MODIFYTIME: "-", MODIFIERID: 1, MODIFIERNAME: "平台"})
 	sDataEx = append(sDataEx, sData...)
 	return sDataEx, err
+	*/
+	return sData, err
 }
 
 // GetDataEx 查询角色
@@ -570,7 +715,7 @@ func (r *ErmcpBizGroupEx) GetDataEx() (interface{}, error) {
 	mAcc := ErmcpBizGroupTaAccount{AREAUSERID: r.AREAUSERID}
 	if wrLst, err := mWr.GetDataEx(); err == nil {
 		for i := range wrLst {
-			var bFind bool = false
+			var bFind = false
 			for k := range sData {
 				if sData[k].BIZGROUPID == wrLst[i].BIZGROUPID &&
 					sData[k].BIZTYPE == wrLst[i].BIZTYPE {

+ 1 - 1
models/ermcpPendingAuditInfo.go

@@ -46,7 +46,7 @@ func (r *ErmcpPendingAudit) buildSql() string {
 		" union all " +
 		"select 7, count(1) BusinessFpQty from ermcp_contractoperateapply t where t.userid = %v and t.applystatus = 1 and t.operateapplytype=4" +
 		" union all " +
-		"select 8, count(1) AreaStockQty from ermcp_areainoutstockapply t where t.userid = %v and t.ApplyStatus = 1"
+		"select 8, count(1) AreaStockQty from ermcp_contractoperateapply t where t.userid = %v and t.operateapplytype in(5,6,7,8)"
 	sqlId = fmt.Sprintf(sqlId, r.UserId, r.UserId, r.UserId, r.UserId, r.UserId, r.UserId, r.UserId, r.UserId)
 	return sqlId
 }

+ 38 - 16
mtpcache/enumdicitem.go

@@ -9,17 +9,28 @@ package mtpcache
 import (
 	"mtp2_if/db"
 	"mtp2_if/logger"
+	"mtp2_if/utils"
 	"sync"
 	"time"
 )
 
-var vDic enumdicitem
+var (
+	vDicCurrency = enumdicitem{data: map[int32]string{}, nType: 2}
+	vDic         = enumdicitem{data: map[int32]string{}, nType: 1}
+)
+
+// IGetEnumdicName 获取字典名称接口
+type IGetEnumdicName interface {
+	get(int32) string
+	load()
+}
 
 // 商品单位名称缓存
 type enumdicitem struct {
-	mtx  sync.RWMutex     //锁
-	data map[int32]string //数据[enumitemname]enumdicname
-	last time.Time
+	mtx   sync.RWMutex     //锁
+	data  map[int32]string //数据[enumitemname]enumdicname
+	last  time.Time
+	nType int32 // 1-单位名称 2-币种名称
 }
 
 type enumData struct {
@@ -27,8 +38,13 @@ type enumData struct {
 	ENUMDICNAME  string `json:"enumdicname"  xorm:"'enumdicname'"`   //名称
 }
 
-func init() {
-	vDic.data = make(map[int32]string, 0)
+func (r *enumdicitem) buildSql() string {
+	var sqlId utils.SQLVal = "select t.enumitemname, t.enumdicname" +
+		"  from enumdicitem t" +
+		" where t.enumitemstatus = 1"
+	sqlId.AndEx("t.enumdiccode", "goodsunit", r.nType == 1)
+	sqlId.AndEx("t.enumdiccode", "currency", r.nType == 2)
+	return sqlId.String()
 }
 
 // 加载数据
@@ -46,12 +62,8 @@ func (r *enumdicitem) load() {
 		return
 	}
 
-	sqlId := "select t.enumitemname, t.enumdicname" +
-		"  from enumdicitem t" +
-		" where t.enumdiccode = 'goodsunit'" +
-		"   and t.enumitemstatus = 1"
 	sData := make([]enumData, 0)
-	s := e.SQL(sqlId)
+	s := e.SQL(r.buildSql())
 	if err := s.Find(&sData); err != nil {
 		logger.GetLogger().Errorf("cache load enumdicitem, %v", err)
 	} else {
@@ -77,16 +89,26 @@ func (r *enumdicitem) get(id int32) string {
 	return ""
 }
 
-// 获取商品单位枚举名称
-func GetEnumDicitemName(id int32) string {
+// getDicEnumName 获取字典名称
+func getDicEnumName(obj IGetEnumdicName, id int32) string {
 	if id <= 0 {
 		return ""
 	}
-	if v := vDic.get(id); v != "" {
+	if v := obj.get(id); v != "" {
 		return v
 	} else {
-		vDic.load()
+		obj.load()
 	}
 
-	return vDic.get(id)
+	return obj.get(id)
+}
+
+// GetEnumDicitemName 获取商品单位枚举名称
+func GetEnumDicitemName(id int32) string {
+	return getDicEnumName(&vDic, id)
+}
+
+// GetCurrencyName 获取币种名称
+func GetCurrencyName(id int32) string {
+	return getDicEnumName(&vDicCurrency, id)
 }