Ver Fonte

no message

xingzai há 11 meses atrás
pai
commit
5dd36147e3
3 ficheiros alterados com 63 adições e 0 exclusões
  1. 9 0
      controllers/article.go
  2. 6 0
      services/company_permission.go
  3. 48 0
      services/user_permission.go

+ 9 - 0
controllers/article.go

@@ -198,6 +198,15 @@ func (this *ArticleController) Detail() {
 
 	}
 
+	if hasPermission != 1 {
+		hasPermission, err = services.GetUserPermissionCode(user.UserId, user.CompanyId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取用户状态信息失败,Err:" + err.Error()
+			return
+		}
+	}
+
 	if detail.ArticleTypeId == 14 {
 		detail.IsApplyAppointmentExpert = true //判断文章类型是否属于专家访谈  查研观向11.0
 	}

+ 6 - 0
services/company_permission.go

@@ -218,6 +218,12 @@ func GetUserHasPermissionActivity(user *models.WxUserItem, activityInfo *models.
 	} else {
 		hasPermission = 5
 	}
+
+	hasPermission, e = GetUserPermissionCode(user.UserId, user.CompanyId)
+	if e != nil {
+		err = errors.New("GetUserDetailPermissionCode, Err: " + e.Error())
+		return
+	}
 	return
 }
 

+ 48 - 0
services/user_permission.go

@@ -146,6 +146,54 @@ func GetUserApplyRecordCountByCompanyIdPay(companyIdPay int) (isCompanyApply boo
 	return
 }
 
+// 获取用户权限状态  https://hzstatic.hzinsights.com/static/images/202402/20240205/LpE6dspJCLzfQoCoE8SFMDiLuxXk.png(状态码说明)
+func GetUserPermissionCode(userId, companyId int) (permission int, err error) {
+	// 用户申请记录
+	applyCount, e := models.GetApplyRecordCount(userId)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("获取用户申请信息失败, Err: " + e.Error())
+		return
+	}
+
+	if companyId == 1 {
+		// 潜在用户
+		if applyCount > 0 {
+			permission = 6
+		} else {
+			permission = 7
+		}
+	} else {
+		//权益客户
+		raiCount, e := models.GetCompanyProductCount(companyId, utils.COMPANY_PRODUCT_RAI_ID)
+		if e != nil {
+			err = errors.New("获取用户申请信息失败, Err: " + e.Error())
+			return
+		}
+		if raiCount == 1 {
+			if applyCount > 0 {
+				permission = 2
+			} else {
+				permission = 3
+			}
+		} else {
+			//ficc 客户
+			ficcCount, e := models.GetCompanyProductCount(companyId, utils.COMPANY_PRODUCT_FICC_ID)
+			if e != nil {
+				err = errors.New("获取用户申请信息失败, Err: " + e.Error())
+				return
+			}
+			if ficcCount == 1 {
+				if applyCount > 0 {
+					permission = 4
+				} else {
+					permission = 5
+				}
+			}
+		}
+	}
+	return
+}
+
 // 用户详情页获取用户权限状态  https://hzstatic.hzinsights.com/static/images/202402/20240205/LpE6dspJCLzfQoCoE8SFMDiLuxXk.png(状态码说明)
 func GetUserDetailPermissionCode(userId, companyId int) (permission int, err error) {
 	// 用户申请记录