Kaynağa Gözat

1. #95138 业务员登录查不到点价等数据
2. #95136 履约交收字段名更改

zou.yingbin 4 yıl önce
ebeveyn
işleme
407c8b267b
3 değiştirilmiş dosya ile 46 ekleme ve 11 silme
  1. 14 6
      controllers/ermcp/qryOPApply.go
  2. 14 2
      models/ermcp3.go
  3. 18 3
      models/ermcpOPApply.go

+ 14 - 6
controllers/ermcp/qryOPApply.go

@@ -69,6 +69,7 @@ type QryOPApplyReq struct {
 	RelatedId      string `form:"relatedid" binding:"required"` //现货合同ID, 不填则查所有
 	OperateapplyId string `form:"operateapplyid"`               //操作申请id
 	Applystatus    string `form:"applystatus"`                  // 申请状态 1:待审核 2:审核通过 3:审核拒绝 4:处理失败 5:已撤回
+	USERTYPE       int32  `form:"usertype"`                     // 用户类型 2-机构 7-企业成员
 }
 
 // 查询业务管理/点价应答
@@ -82,6 +83,7 @@ type QryBusinessDjRsp struct {
 // @Produce json
 // @Security ApiKeyAuth
 // @Param UserId query int true "用户ID"
+// @Param usertype query int false "用户类型 2-机构 7-企业成员"
 // @Param relatedid query string false "现货合同ID, 不填则查所有"
 // @Param applystatus query string false "申请状态(逗号隔开) 1:待审核 2:审核通过 3:审核拒绝 4:处理失败 5:已撤回"
 // @Success 200 {array} QryBusinessDjRsp
@@ -92,7 +94,7 @@ func QueryBusinessDj(c *gin.Context) {
 	appG := app.Gin{C: c}
 	var req QryOPApplyReq
 	_ = c.ShouldBind(&req)
-	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId, USERID: req.UserId, FilterAppStatus: req.Applystatus}
+	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId, USERID: req.UserId, FilterAppStatus: req.Applystatus, UserType: req.USERTYPE}
 	if d, err := m.GetData(1); err == nil {
 		//构建应答数据
 		sData := make([]QryBusinessDjRsp, 0)
@@ -123,6 +125,7 @@ type QryBussinessJsRsp struct {
 // @Produce json
 // @Security ApiKeyAuth
 // @Param UserId query int true "用户ID"
+// @Param usertype query int false "用户类型 2-机构 7-企业成员"
 // @Param relatedid query string false "现货合同ID, 不填则查所有"
 // @Param operateapplyid query string false "操作申请id"
 // @Param applystatus query string false "申请状态(逗号隔开) 1:待审核 2:审核通过 3:审核拒绝 4:处理失败 5:已撤回"
@@ -134,7 +137,8 @@ func QueryBusinessJs(c *gin.Context) {
 	appG := app.Gin{C: c}
 	var req QryOPApplyReq
 	_ = c.ShouldBind(&req)
-	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId, USERID: req.UserId, OPERATEAPPLYID: req.OperateapplyId, FilterAppStatus: req.Applystatus}
+	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId, USERID: req.UserId,
+		OPERATEAPPLYID: req.OperateapplyId, FilterAppStatus: req.Applystatus, UserType: req.USERTYPE}
 	if d, err := m.GetData(2); err == nil {
 		//构建应答数据
 		sData := make([]QryBussinessJsRsp, 0)
@@ -159,10 +163,12 @@ type QryBussinessJsExRsp struct {
 	ReckonValue float64 `json:"reckonvalue"` // 值
 }
 
+// QueryBusinessJsEx
 // @Summary 查询业务管理(结算)(对应菜单:业务管理/结算[拆分记录])
 // @Produce json
 // @Security ApiKeyAuth
 // @Param UserId query int true "用户ID"
+// @Param usertype query int false "用户类型 2-机构 7-企业成员"
 // @Param relatedid query string false "现货合同ID, 不填则查所有"
 // @Param applystatus query string false "申请状态(逗号隔开) 1:待审核 2:审核通过 3:审核拒绝 4:处理失败 5:已撤回"
 // @Success 200 {array} QryBussinessJsExRsp
@@ -173,7 +179,7 @@ func QueryBusinessJsEx(c *gin.Context) {
 	appG := app.Gin{C: c}
 	var req QryOPApplyReq
 	_ = c.ShouldBind(&req)
-	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId, USERID: req.UserId, FilterAppStatus: req.Applystatus}
+	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId, USERID: req.UserId, FilterAppStatus: req.Applystatus, UserType: req.USERTYPE}
 	if d, err := m.GetData(2); err == nil {
 		//构建应答数据
 		sData := make([]QryBussinessJsExRsp, 0)
@@ -184,7 +190,7 @@ func QueryBusinessJsEx(c *gin.Context) {
 			if len(rsp.DETAILJSON) > 0 {
 				if err := json.Unmarshal([]byte(rsp.DETAILJSON), &rd); err == nil {
 					if rd.ReckonRealQty != nil {
-						rsp.ReckonType = "确定量"
+						rsp.ReckonType = "交收量"
 						rsp.ReckonValue = *rd.ReckonRealQty
 						sData = append(sData, rsp)
 					}
@@ -233,6 +239,7 @@ type QryBussinessKxRsp struct {
 // @Produce json
 // @Security ApiKeyAuth
 // @Param UserId query int true "用户ID"
+// @Param usertype query int false "用户类型 2-机构 7-企业成员"
 // @Param relatedid query string false "现货合同ID, 不填则查所有"
 // @Param applystatus query string false "申请状态(逗号隔开) 1:待审核 2:审核通过 3:审核拒绝 4:处理失败 5:已撤回"
 // @Success 200 {array} QryBussinessKxRsp
@@ -243,7 +250,7 @@ func QueryBusinessKx(c *gin.Context) {
 	appG := app.Gin{C: c}
 	var req QryOPApplyReq
 	_ = c.ShouldBind(&req)
-	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId, USERID: req.UserId, FilterAppStatus: req.Applystatus}
+	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId, USERID: req.UserId, FilterAppStatus: req.Applystatus, UserType: req.USERTYPE}
 	if d, err := m.GetData(3); err == nil {
 		//构建应答数据
 		sData := make([]QryBussinessKxRsp, 0)
@@ -274,6 +281,7 @@ type QryBussinessFpRsp struct {
 // @Produce json
 // @Security ApiKeyAuth
 // @Param UserId query int true "用户ID"
+// @Param usertype query int false "用户类型 2-机构 7-企业成员"
 // @Param relatedid query string false "现货合同ID, 不填则查所有"
 // @Param applystatus query string false "申请状态(逗号隔开) 1:待审核 2:审核通过 3:审核拒绝 4:处理失败 5:已撤回"
 // @Success 200 {array} QryBussinessFpRsp
@@ -284,7 +292,7 @@ func QueryBusinessFp(c *gin.Context) {
 	appG := app.Gin{C: c}
 	var req QryOPApplyReq
 	_ = c.ShouldBind(&req)
-	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId, USERID: req.UserId, FilterAppStatus: req.Applystatus}
+	m := models.ErmcpOPApplyModel{RELATEDID: req.RelatedId, USERID: req.UserId, FilterAppStatus: req.Applystatus, UserType: req.USERTYPE}
 	if d, err := m.GetData(4); err == nil {
 		//构建应答数据
 		sData := make([]QryBussinessFpRsp, 0)

+ 14 - 2
models/ermcp3.go

@@ -1382,6 +1382,7 @@ type Ermcp3AreaStockApply struct {
 	FilterType   string `json:"-"` // 查询条件, 出入库类型, 逗号隔开
 	BeginDate    string `json:"-"` // 开始日期
 	EndDate      string `json:"-"` // 结束日期
+	UserType     int32  `json:"-"` // 用户类型
 }
 
 func (r *Ermcp3AreaStockApply) calc() {
@@ -1462,8 +1463,19 @@ func (r *Ermcp3AreaStockApply) buildSql() string {
 		"  left join ermcp_spotcontract s" +
 		"    on t.relatedid = s.spotcontractid" +
 		" WHERE t.operateapplytype in(5,6,7,8)"
-	// 用户id(必要条件)
-	sqlId.And("t.USERID", r.USERID)
+
+	areaUserId := mtpcache.GetAreaUserId(r.USERID, r.UserType)
+	if areaUserId == r.USERID {
+		// 机构用户
+		sqlId.And("t.USERID", r.USERID)
+	} else {
+		if r.INOUTTYPE == 7 || r.INOUTTYPE == 8 {
+			// 生产出入库, 没有相关合同
+			sqlId.And("t.USERID", r.USERID)
+		} else {
+			sqlId.Join(fmt.Sprintf(" and %v in(s.saleuserid, s.tradeuserid, s.meruserid)", r.USERID))
+		}
+	}
 	// 合同id
 	sqlId.AndInterEx("t.RELATEDID", r.SPOTCONTRACTID, len(r.SPOTCONTRACTID) > 0)
 

+ 18 - 3
models/ermcpOPApply.go

@@ -47,6 +47,7 @@ type ErmcpOPApplyModel struct {
 	DELIVERYGOODSNAME string  `json:"deliverygoodsname"  xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称
 
 	FilterAppStatus string `json:"-"` // 状态过滤条件
+	UserType        int32  `json:"-"`
 }
 
 func (r *ErmcpOPApplyModel) calc() {
@@ -114,8 +115,7 @@ func (r *ErmcpOPApplyModel) buildSql(opType int32) string {
 		"  left join enumdicitem e" +
 		"    on e.enumitemname = w.unitid" +
 		"   and e.enumdiccode = 'goodsunit'" +
-		" where t.operateapplytype = %v" +
-		"   and s.userid = %v"
+		" where t.operateapplytype = %v"
 
 	if len(r.RELATEDID) > 0 {
 		sqlId = sqlId + " and t.relatedid=" + r.RELATEDID
@@ -128,8 +128,23 @@ func (r *ErmcpOPApplyModel) buildSql(opType int32) string {
 	if len(r.FilterAppStatus) > 0 {
 		sqlId += fmt.Sprintf(" and t.applystatus in(%v)", r.FilterAppStatus)
 	}
+	// 终端没传用户类型过来
+	if r.UserType == 0 {
+		areaUserId := mtpcache.GetAreaUserId(r.USERID, r.UserType)
+		if areaUserId == r.USERID {
+			// 所属机构=自己, 则为机构用户类型
+			r.UserType = 2
+		} else {
+			r.UserType = 7
+		}
+	}
+	if r.UserType == 7 {
+		sqlId += fmt.Sprintf(" and %v in(s.saleuserid, s.tradeuserid, s.meruserid)", r.USERID)
+	} else {
+		sqlId += fmt.Sprintf(" and s.userid = %v", r.USERID)
+	}
 
-	return fmt.Sprintf(sqlId, opType, r.USERID)
+	return fmt.Sprintf(sqlId, opType)
 }
 
 // GetData 从数据库中查询合同操作申请相关信息, opType 操作申请类型 - 1:点价 2:结算登记 3:款项登记 4:发票登记