瀏覽代碼

查询接口增加所属机构用户ID字段、合同ID字段

zou.yingbin 4 年之前
父節點
當前提交
32fa101e54

+ 8 - 4
controllers/ermcp/qryErmcp.go

@@ -17,7 +17,8 @@ import (
 
 // 查询现货合同
 type QrySpotContractReq struct {
-	QueryType int32 `form:"QueryType" binding:"required"`    // 查询类型 1-未提交 2-待审核 3-履约中 4-已完成
+	UserId    int64 `form:"userId" binding:"required"`    //用户ID
+	QueryType int32 `form:"QueryType" binding:"required"` // 查询类型 1-未提交 2-待审核 3-履约中 4-已完成
 }
 
 // 查询现货合同应答
@@ -27,6 +28,7 @@ type QrySpotContractRsp models.ErmcpSpotContractModel
 // @Summary 查询现货合同(对应现货合同菜单)
 // @Produce json
 // @Security ApiKeyAuth
+// @Param userId query int true "用户ID"
 // @Param QueryType query int true "查询类型 1-未提交 2-待审核 3-履约中 4-已完成"
 // @Success 200 {array} QrySpotContractRsp
 // @Failure 500 {object} app.Response
@@ -41,7 +43,7 @@ func QuerySpotContract(c *gin.Context) {
 		return
 	}
 
-	var m models.ErmcpSpotContractModel
+	var m = models.ErmcpSpotContractModel{USERID: req.UserId}
 	if d, err := m.GetData(req.QueryType); err == nil {
 		appG.Response(http.StatusOK, e.SUCCESS, d)
 	} else {
@@ -51,6 +53,7 @@ func QuerySpotContract(c *gin.Context) {
 
 // 查询合同请求结构
 type QryErmcpReq struct {
+	UserId       int64 `form:"userId" binding:"required"`       //用户ID
 	ContractType int32 `form:"contracttype" binding:"required"` // 合同类型
 	QueryType    int32 `form:"querytype" binding:"required"`    // 查询类型 1-全部 2-待点价 3-履约结算
 }
@@ -62,8 +65,9 @@ type QryErmcpRsp models.ErmcpModel
 // @Summary 查询合同(采购和销售)
 // @Produce json
 // @Security ApiKeyAuth
+// @Param userId query int true "用户ID"
 // @Param contracttype query int true "合同类型 1-采购, -1-销售"
-// @Param QueryType query int true "查询类型 1-全部 2-待点价 3-履约结算"
+// @Param querytype query int true "查询类型 1-全部 2-待点价 3-履约结算"
 // @Success 200 {array} QryErmcpRsp
 // @Failure 500 {object} app.Response
 // @Router /Ermcp/QueryContract [get]
@@ -90,7 +94,7 @@ func QueryContract(c *gin.Context) {
 		return
 	}
 
-	var m models.ErmcpModel
+	var m = models.ErmcpModel{UserID: req.UserId}
 	if d, err := m.GetData(req.ContractType, req.QueryType); err == nil {
 		appG.Response(http.StatusOK, e.SUCCESS, d)
 	} else {

+ 3 - 1
controllers/ermcp/qryHedgePlan.go

@@ -17,6 +17,7 @@ import (
 
 // 查套保计划请求
 type QryHedgePlanReq struct {
+	UserId    int64   `form:"userId" binding:"required"`   //用户ID
 	HedgePlanStatus *int `form:"HedgePlanStatus" binding:"required"` // 套保计划状态
 }
 
@@ -27,6 +28,7 @@ type QryHedgePlanRsp models.ErmcpHedgePlan
 // @Summary 查询套保计划
 // @Produce json
 // @Security ApiKeyAuth
+// @Param userId query int true "用户ID"
 // @Param HedgePlanStatus query int true "套保计划状态 -  0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回"
 // @Success 200 {array} QryHedgePlanRsp
 // @Failure 500 {object} app.Response
@@ -41,7 +43,7 @@ func QueryHedgePlan(c *gin.Context) {
 		return
 	}
 
-	var m models.ErmcpHedgePlan
+	var m = models.ErmcpHedgePlan{Areauserid: req.UserId}
 	if d, err := m.GetData(*req.HedgePlanStatus); err == nil {
 		appG.Response(http.StatusOK, e.SUCCESS, d)
 	} else {

+ 34 - 5
controllers/ermcp/qryOPApply.go

@@ -19,6 +19,15 @@ import (
 type DjData struct {
 	PricedPrice *float64 `json:"pricedPrice,omitempty"` //点价价格(非必填)
 	PricedQty   *float64 `json:"pricedQty,omitempty"`   //点价数量(非必填)
+	Amount      *float64 `json:"amount,omitempty"`      //点价金额=(点价价格+升贴水)*点价数量
+}
+
+//计算点价金额
+func (r *DjData) calc(priceMove float64) {
+	if r.PricedPrice != nil && r.PricedQty != nil{
+		r.Amount = new(float64)
+		*r.Amount = (*r.PricedPrice + priceMove) * (*r.PricedQty)
+	}
 }
 
 //结点登记数据
@@ -44,6 +53,8 @@ type KpData struct {
 
 // 查询合同操作请求
 type QryOPApplyReq struct {
+	UserId    int64   `form:"userId" binding:"required"`   //用户ID
+	RelatedId string `form:"relatedid" binding:"required"` //现货合同ID, 不填则查所有
 }
 
 // 查询业务管理/点价应答
@@ -56,13 +67,17 @@ type QryBusinessDjRsp struct {
 // @Summary 查询业务管理(点价)(对应菜单:业务管理/点价)
 // @Produce json
 // @Security ApiKeyAuth
+// @Param UserId query int true "用户ID"
+// @Param relatedid query string false "现货合同ID, 不填则查所有"
 // @Success 200 {array} QryBusinessDjRsp
 // @Failure 500 {object} app.Response
 // @Router /Ermcp/QueryBusinessDj [get]
 // @Tags 企业风险管理(app)
 func QueryBusinessDj(c *gin.Context) {
 	appG := app.Gin{C: c}
-	var m models.ErmcpOPApplyModel
+	var req QryOPApplyReq
+	_=c.ShouldBind(&req)
+	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId, USERID: req.UserId}
 	if d, err := m.GetData(1); err == nil {
 		//构建应答数据
 		sData := make([]QryBusinessDjRsp, 0)
@@ -70,7 +85,9 @@ func QueryBusinessDj(c *gin.Context) {
 			var rsp QryBusinessDjRsp
 			rsp.ErmcpOPApplyModel = v
 			if len(rsp.DETAILJSON) > 0{
-				_ = json.Unmarshal([]byte(rsp.DETAILJSON), &rsp.DjData)
+				if err := json.Unmarshal([]byte(rsp.DETAILJSON), &rsp.DjData); err != nil{
+					rsp.DjData.calc(rsp.PRICEMOVE)
+				}
 			}
 			sData = append(sData, rsp)
 		}
@@ -90,13 +107,17 @@ type QryBussinessJsRsp struct {
 // @Summary 查询业务管理(结算)(对应菜单:业务管理/结算)
 // @Produce json
 // @Security ApiKeyAuth
+// @Param UserId query int true "用户ID"
+// @Param relatedid query string false "现货合同ID, 不填则查所有"
 // @Success 200 {array} QryBussinessJsRsp
 // @Failure 500 {object} app.Response
 // @Router /Ermcp/QueryBusinessJs [get]
 // @Tags 企业风险管理(app)
 func QueryBusinessJs(c *gin.Context) {
 	appG := app.Gin{C: c}
-	var m models.ErmcpOPApplyModel
+	var req QryOPApplyReq
+	_=c.ShouldBind(&req)
+	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId}
 	if d, err := m.GetData(2); err == nil {
 		//构建应答数据
 		sData := make([]QryBussinessJsRsp, 0)
@@ -124,13 +145,17 @@ type QryBussinessKxRsp struct {
 // @Summary 查询财务管理(款项)(对应菜单:财务管理/款项)
 // @Produce json
 // @Security ApiKeyAuth
+// @Param UserId query int true "用户ID"
+// @Param relatedid query string false "现货合同ID, 不填则查所有"
 // @Success 200 {array} QryBussinessKxRsp
 // @Failure 500 {object} app.Response
 // @Router /Ermcp/QueryBusinessKx [get]
 // @Tags 企业风险管理(app)
 func QueryBusinessKx(c *gin.Context) {
 	appG := app.Gin{C: c}
-	var m models.ErmcpOPApplyModel
+	var req QryOPApplyReq
+	_=c.ShouldBind(&req)
+	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId}
 	if d, err := m.GetData(3); err == nil {
 		//构建应答数据
 		sData := make([]QryBussinessKxRsp, 0)
@@ -158,13 +183,17 @@ type QryBussinessFpRsp struct {
 // @Summary 查询财务管理(发票)(对应菜单:财务管理/发票)
 // @Produce json
 // @Security ApiKeyAuth
+// @Param UserId query int true "用户ID"
+// @Param relatedid query string false "现货合同ID, 不填则查所有"
 // @Success 200 {array} QryBussinessFpRsp
 // @Failure 500 {object} app.Response
 // @Router /Ermcp/QueryBusinessFp [get]
 // @Tags 企业风险管理(app)
 func QueryBusinessFp(c *gin.Context) {
 	appG := app.Gin{C: c}
-	var m models.ErmcpOPApplyModel
+	var req QryOPApplyReq
+	_=c.ShouldBind(&req)
+	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId}
 	if d, err := m.GetData(4); err == nil {
 		//构建应答数据
 		sData := make([]QryBussinessFpRsp, 0)

+ 3 - 1
controllers/ermcp/qryUser.go

@@ -17,6 +17,7 @@ import (
 
 // 查询客户资料请求
 type QryUserInfoReq struct {
+	MemberUserID  int    `form:"MemberUserID" binding:"required"`  // 所属机构用户ID
 	AccountStatus string `form:"AccountStatus" binding:"required"` // 账户状态, 逗号隔开(1:待激活 2:待审核 3:待复审 4:正常 5:审核拒绝 6:注销)
 }
 
@@ -27,6 +28,7 @@ type QryUserInfoRsp models.ErmcpUserModel
 // @Summary 查询客户资料
 // @Produce json
 // @Security ApiKeyAuth
+// @Param MemberUserID query int true "所属机构用户ID"
 // @Param AccountStatus query string true "账户状态(可填多个, 逗号隔开) 1:待激活 2:待审核 3:待复审 4:正常 5:审核拒绝 6:注销"
 // @Success 200 {array} QryUserInfoRsp
 // @Failure 500 {object} app.Response
@@ -41,7 +43,7 @@ func QueryUserInfo(c *gin.Context) {
 		return
 	}
 
-	var m models.ErmcpUserModel
+	var m = models.ErmcpUserModel{MEMBERUSERID: req.MemberUserID}
 	if d, err := m.GetData(req.AccountStatus); err == nil {
 		appG.Response(http.StatusOK, e.SUCCESS, d)
 	} else {

+ 8 - 1
controllers/ermcp/qryWrstandard.go

@@ -17,6 +17,7 @@ import (
 
 //查询现货商品请求
 type QryWrStandardReq struct {
+	UserId int `form:"userid" binding:"required"` //用户ID
 }
 
 //查询现货商品响应
@@ -26,13 +27,19 @@ type QryWrStandardRsp models.ErmcpWrstandard
 // @Summary 查询现货商品
 // @Produce json
 // @Security ApiKeyAuth
+// @Param userid query int true  "所属机构ID"
 // @Success 200 {array} QryWrStandardRsp
 // @Failure 500 {object} app.Response
 // @Router /Ermcp/QueryWrStandard [get]
 // @Tags 企业风险管理(app)
 func QueryWrStandard(c *gin.Context)  {
 	appG := app.Gin{C: c}
-	var m models.ErmcpWrstandard
+	var req QryWrStandardReq
+	if err := c.ShouldBind(&req); err != nil{
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+	m := models.ErmcpWrstandard{AREAUSERID: req.UserId}
 	if d, err := m.GetData(); err == nil {
 		for i := range d {
 			d[i].EnumdicName = mtpcache.GetEnumDicitemName(d[i].UNITID)

文件差異過大導致無法顯示
+ 492 - 273
docs/docs.go


文件差異過大導致無法顯示
+ 492 - 273
docs/swagger.json


文件差異過大導致無法顯示
+ 620 - 596
docs/swagger.yaml


+ 9 - 5
models/ermcp.go

@@ -18,6 +18,7 @@ type ErmcpSpotContractModel struct {
 	SPOTCONTRACTID    string  `json:"spotcontractid"  xorm:"'SPOTCONTRACTID'"`       //现货合同ID(602+Unix秒时间戳(10位)+xxxxxx)
 	CONTRACTNO        string  `json:"contractno"  xorm:"'CONTRACTNO'"`               //现货合同编号
 	CONTRACTTYPE      int32   `json:"contracttype"  xorm:"'CONTRACTTYPE'"`           //现货合同类型 - 1:采购 -1:销售
+	USERID            int64   `json:"userid"  xorm:"'USERID'"`                       //机构ID
 	BUYUSERID         int64   `json:"buyuserid"  xorm:"'BUYUSERID'"`                 //采购方ID
 	BUYUSERName       string  `json:"buyusername"  xorm:"'BUYUSERName'"`             //采购方名称
 	SELLUSERID        int64   `json:"selluserid"  xorm:"'SELLUSERID'"`               //销售方ID
@@ -48,6 +49,7 @@ func (r *ErmcpSpotContractModel) buildSql(nQueryType int32) string {
 	str := "SELECT to_char(t.SPOTCONTRACTID) SPOTCONTRACTID," +
 		"       t.CONTRACTNO," +
 		"       t.CONTRACTTYPE," +
+		"       t.USERID," +
 		"       t.BUYUSERID," +
 		"       t.SELLUSERID," +
 		"       t.DELIVERYGOODSID," +
@@ -70,7 +72,7 @@ func (r *ErmcpSpotContractModel) buildSql(nQueryType int32) string {
 		"       u2.accountname      SellUserName," +
 		"       g.deliverygoodscode," +
 		"       g.deliverygoodsname," +
-		"       g2.goodscode" +
+		"       g2.goodscode," +
 		"       e.Enumdicname"+
 		"  FROM ERMCP_SPOTCONTRACT t" +
 		"  left join useraccount u1" +
@@ -82,7 +84,7 @@ func (r *ErmcpSpotContractModel) buildSql(nQueryType int32) string {
 		"  left join goods g2" +
 		"    on t.goodsid = g2.goodsid" +
 		"  left join enumdicitem e on g.goodsunitid = e.enumitemname and e.enumdiccode = 'goodsunit'" +
-		"  where t.contracctstatus in (%v)"
+		"  where t.contracctstatus in (%v) and t.userid=%v"
 
 	// 查询类型 1-未提交 2-待审核 3-履约中 4-已完成
 	// 合同状态 - 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
@@ -98,7 +100,7 @@ func (r *ErmcpSpotContractModel) buildSql(nQueryType int32) string {
 		status = "3,5,6"
 	}
 
-	return fmt.Sprintf(str, status)
+	return fmt.Sprintf(str, status, r.USERID)
 }
 
 // 从数据库中查询现货合同
@@ -115,6 +117,7 @@ func (r *ErmcpSpotContractModel) GetData(nQueryType int32) ([]ErmcpSpotContractM
 
 // 风险管理合同(对应采购和销售菜单)
 type ErmcpModel struct {
+	UserID            int64   `json:"userid"  xorm:"'UserID'"`                       // 用户ID
 	SpotContractId    string  `json:"spotcontractid"  xorm:"'SPOTCONTRACTID'"`       // 合同ID
 	AccountId         string  `json:"accountid"  xorm:"'ACCOUNTID'"`                 // 账户ID
 	AccountName       string  `json:"accountname"  xorm:"'ACCOUNTNAME'"`             // 账户名称
@@ -152,6 +155,7 @@ func (r *ErmcpModel) buildSql(nContractType, nQueryType int32) string {
 		"       t.spotgoodsdesc," +
 		"       t.goodsid," +
 		"       t.pricemove," +
+		"       t.userid," +
 		"       t.qty," +
 		"       t.qty - t.pricedqty unpricedqty," +
 		"       t.pricedqty," +
@@ -194,7 +198,7 @@ func (r *ErmcpModel) buildSql(nContractType, nQueryType int32) string {
 		"    on wr.unitid = e.enumitemname" +
 		"   and e.enumdiccode = 'goodsunit'" +
 		" where t.contracctstatus in (%v)" +
-		"   and t.contracttype in (%v)"
+		"   and t.contracttype in (%v) and t.userid=%v"
 
 	var status string
 	if 0 == nQueryType {
@@ -221,7 +225,7 @@ func (r *ErmcpModel) buildSql(nContractType, nQueryType int32) string {
 		usrId = "selluserid"
 	}
 
-	sqlId := fmt.Sprintf(str, usrId, status, nContractType)
+	sqlId := fmt.Sprintf(str, usrId, status, nContractType, r.UserID)
 
 	return sqlId
 }

+ 3 - 2
models/ermcpHedgePlan.go

@@ -14,6 +14,7 @@ import (
 
 // 套保计划表结构
 type ErmcpHedgePlan struct {
+	Areauserid        int64   `json:"areauserid"  xorm:"'Areauserid'"`               //用户ID
 	Hedgeplanid       string  `json:"hedgeplanid"  xorm:"'Hedgeplanid'"`             //套保计划ID(601+Unix秒时间戳(10位)+xxxxxx)
 	Hedgeplanno       string  `json:"hedgeplanno"  xorm:"'Hedgeplanno'"`             //套保计划编号
 	Contracttype      int     `json:"contracttype"  xorm:"'Contracttype'"`           //计划类型 - 1:采购 -1:销售
@@ -50,9 +51,9 @@ func (r *ErmcpHedgePlan) buildSql(status int) string {
 		"    on t.wrstandardid = w.wrstandardid" +
 		"  left join deliverygoods g" +
 		"    on t.deliverygoodsid = g.deliverygoodsid" +
-		" where t.hedgeplanstatus in (%v)"
+		" where t.hedgeplanstatus in (%v) and t.areauserid=%v"
 
-	return fmt.Sprintf(str, status)
+	return fmt.Sprintf(str, status, r.Areauserid)
 }
 
 // 从数据库中查询套保计划数据

+ 9 - 4
models/ermcpOPApply.go

@@ -14,6 +14,7 @@ import (
 
 //现货合同操作数据
 type ErmcpOPApplyModel struct {
+	USERID           int64  `json:"userid"  xorm:"'USERID'"`                     //用户ID
 	OPERATEAPPLYID   string `json:"operateapplyid"  xorm:"'OPERATEAPPLYID'"`     //操作申请ID(603+Unix秒时间戳(10位)+xxxxxx)
 	OPERATEAPPLYTYPE int32  `json:"operateapplytype"  xorm:"'OPERATEAPPLYTYPE'"` //操作申请类型 - 1:点价 2:结算登记 3:款项登记 4:发票登记
 	RELATEDID        string `json:"relatedid"  xorm:"'RELATEDID'"`               //现货合同ID
@@ -41,9 +42,9 @@ func (r *ErmcpOPApplyModel) buildSql(opType int32) string {
 		"       to_char(t.RELATEDID) RELATEDID," +
 		"       t.DETAILJSON," +
 		"       to_char(t.APPLYID) APPLYID," +
-		"       to_char(t.APPLYTIME,'yyyy-mm-dd hh:mi') APPLYTIME," +
+		"       to_char(t.APPLYTIME,'yyyy-mm-dd hh:mi:ss') APPLYTIME," +
 		"       t.APPLYSTATUS," +
-		"       to_char(t.AUDITTIME,'yyyy-mm-dd hh:mi') AUDITTIME," +
+		"       to_char(t.AUDITTIME,'yyyy-mm-dd hh:mi:ss') AUDITTIME," +
 		"       t.CONTRACTTYPE," +
 		"       s.CONTRACTNO," +
 		"       s.PRICETYPE," +
@@ -69,9 +70,13 @@ func (r *ErmcpOPApplyModel) buildSql(opType int32) string {
 		"  left join enumdicitem e" +
 		"    on e.enumitemname = g.goodunitid" +
 		"   and e.enumdiccode = 'goodsunit'" +
-		"  where t.operateapplytype = %v"
+		"  where t.operateapplytype = %v and s.userid=%v"
 
-	return fmt.Sprintf(sqlId, opType)
+	if len(r.RELATEDID) > 0{
+		sqlId = sqlId + " and t.relatedid=" + r.RELATEDID
+	}
+
+	return fmt.Sprintf(sqlId, opType, r.USERID)
 }
 
 // 从数据库中查询合同操作申请相关信息, opType 操作申请类型 - 1:点价 2:结算登记 3:款项登记 4:发票登记

+ 8 - 4
models/ermcpUser.go

@@ -16,6 +16,8 @@ import (
 
 // 客户资料结构
 type ErmcpUserModel struct {
+	USERID       int    `json:"userid"  xorm:"'USERID'"`             // 用户ID
+	MEMBERUSERID int    `json:"memberuserid"  xorm:"'MEMBERUSERID'"` //所属机构ID
 	USERINFOTYPE string `json:"userinfotype"  xorm:"'USERINFOTYPE'"` // 客户类型
 	CUSTOMERNAME string `json:"customername"  xorm:"'CUSTOMERNAME'"` // 企业名称
 	CARDTYPE     string `json:"cardtype"  xorm:"'CARDTYPE'"`         // 证件类型
@@ -28,7 +30,9 @@ type ErmcpUserModel struct {
 }
 
 func (r *ErmcpUserModel) buildSql(accStatus string) string {
-	str := "select u.USERINFOTYPE," +
+	str := "select t.userid," +
+		"       t.memberuserid," +
+		"       u.USERINFOTYPE," +
 		"       u.CUSTOMERNAME," +
 		"       u.CARDTYPEID," +
 		"       e.enumdicname CARDTYPE," +
@@ -38,16 +42,16 @@ func (r *ErmcpUserModel) buildSql(accStatus string) string {
 		"       u.ADDRESS," +
 		"       u.REMARK," +
 		"       t.accountstatus," +
-		"       decode(t.accountstatus,1,'待激活',2,'待审核',3,'待复审',4,'正常',5,'审核拒绝',6,'注销', '缺省') Status" +
+		"       decode(t.accountstatus,1,'待激活',2,'待审核',3,'待复审',4,'正常',5,'审核拒绝',6,'注销','缺省') Status" +
 		"  from useraccount t" +
 		"  left join userinfo u" +
 		"    on t.userid = u.userid" +
 		"  left join enumdicitem e" +
 		"    on u.cardtypeid = e.enumitemname" +
 		"   and e.enumdiccode = 'certificatetype'" +
-		"  where t.accountstatus in (%v)"
+		" where t.usertype=6 and t.accountstatus in (%v) and t.memberuserid=%v"
 
-	return fmt.Sprintf(str, accStatus)
+	return fmt.Sprintf(str, accStatus, r.MEMBERUSERID)
 }
 
 // 解密卡号和电话号码字段

+ 6 - 3
models/ermcpWrstandard.go

@@ -7,6 +7,7 @@
 package models
 
 import (
+	"fmt"
 	"mtp2_if/db"
 	"mtp2_if/logger"
 )
@@ -24,13 +25,13 @@ type ErmcpWrstandard struct {
 	CREATORID       int64  `json:"creatorid"  xorm:"'CREATORID'"`             //创建人
 	CREATETIME      string `json:"createtime"  xorm:"'CREATETIME'"`           //创建时间
 	WRSTANDARDNAME  string `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"`   //现货商品名称
-	AREAUSERID      int32  `json:"areauserid"  xorm:"'AREAUSERID'"`           //所属机构
+	AREAUSERID      int    `json:"areauserid"  xorm:"'AREAUSERID'"`           //所属机构
 	EnumdicName     string `json:"enumdicname"`                               //单位名称
 }
 
 // 查询现货商品
 func (r *ErmcpWrstandard) GetData() ([]ErmcpWrstandard, error) {
-	sqlId := "select WRSTANDARDID," +
+	str := "select WRSTANDARDID," +
 		"       WRSTANDARDCODE," +
 		"       DELIVERYGOODSID," +
 		"       UNITID," +
@@ -43,7 +44,9 @@ func (r *ErmcpWrstandard) GetData() ([]ErmcpWrstandard, error) {
 		"       WRSTANDARDNAME," +
 		"       AREAUSERID" +
 		"  from wrstandard t" +
-		" where t.isvalid = 1"
+		" where t.isvalid = 1 and t.AREAUSERID=%v"
+
+	sqlId := fmt.Sprintf(str, r.AREAUSERID)
 	sData := make([]ErmcpWrstandard, 0)
 	e := db.GetEngine()
 	if err := e.SQL(sqlId).Find(&sData); err != nil {

+ 85 - 0
mtpcache/useraccount.go

@@ -0,0 +1,85 @@
+/**
+* @Author: zou.yingbin
+* @Create  : 2021/1/13 14:07
+* @Modify  : 2021/1/13 14:07
+ */
+
+package mtpcache
+
+import (
+	"mtp2_if/db"
+	"mtp2_if/logger"
+	"sync"
+	"time"
+)
+
+var vUsrMgr userAccountMgr
+
+// 用户缓存
+type userAccountMgr struct {
+	mtx  sync.RWMutex     //锁
+	data map[int64]usrAccData //数据[userId]accountName
+	last time.Time
+}
+
+type usrAccData struct {
+	USERID       int64  `json:"userid"  xorm:"'USERID'"`             //用户ID
+	USERTYPE     int32  `json:"usertype"  xorm:"'USERTYPE'"`         //账户类型 -  1:交易所 2:机构 3:会员子机构 4:经纪人 5:投资者 6:客户
+	ACCOUNTNAME  string `json:"accountname"  xorm:"'ACCOUNTNAME'"`   //账户名称(机构名称)
+	PARENTUSERID int32  `json:"parentuserid"  xorm:"'PARENTUSERID'"` //所属机构ID
+	MEMBERUSERID int32  `json:"memberuserid"  xorm:"'MEMBERUSERID'"` //所属会员ID
+}
+
+// 加载数据
+func (r *userAccountMgr) load() {
+	now := time.Now()
+	// 间隔3秒以上才重新加载
+	if d := now.Sub(r.last); d.Seconds() < 3 {
+		return
+	}
+
+	r.mtx.Lock()
+	defer r.mtx.Unlock()
+	e := db.GetEngine()
+	if e == nil {
+		return
+	}
+
+	sqlId := "select USERID, USERTYPE, ACCOUNTNAME, PARENTUSERID, MEMBERUSERID from useraccount"
+	sData := make([]usrAccData, 0)
+	s := e.SQL(sqlId)
+	if err := s.Find(&sData); err != nil {
+		logger.GetLogger().Errorf("cache load useraccount, %v", err)
+	} else {
+		r.data = make(map[int64]usrAccData)
+		for i := range sData {
+			r.data[sData[i].USERID] = sData[i]
+		}
+		r.last = time.Now()
+	}
+}
+
+func (r *userAccountMgr) get(loginId int64) string {
+	r.mtx.RLock()
+	defer r.mtx.RUnlock()
+
+	if r.data == nil {
+		return ""
+	}
+
+	if v, ok := r.data[loginId]; ok {
+		return v.ACCOUNTNAME
+	}
+	return ""
+}
+
+//根据UserId获取名称
+func GetUserNameByUserId(userId int64) string {
+	if v := vUsrMgr.get(userId); v !=""{
+		return v
+	}else{
+		vUsrMgr.load()
+	}
+
+	return vUsrMgr.get(userId)
+}

+ 1 - 1
mtpcache/username.go

@@ -75,7 +75,7 @@ func (r *userName) get(loginId int64) string {
 }
 
 // 根据登录ID获取名称
-func GetUserName(loginId int64) string {
+func GetUserNameByLoginId(loginId int64) string {
 	if v := vUser.get(loginId); v !=""{
 		return v
 	}else{

部分文件因文件數量過多而無法顯示