Browse Source

no message

xingzai 1 year ago
parent
commit
3eaf83a86c
4 changed files with 104 additions and 1 deletions
  1. 9 1
      controllers/user.go
  2. 7 0
      models/company.go
  3. 2 0
      models/user.go
  4. 86 0
      services/user_permission.go

+ 9 - 1
controllers/user.go

@@ -240,7 +240,6 @@ func (this *UserController) Detail() {
 		resp.Headimgurl = utils.DefaultHeadimgurl
 	}
 	userYanxunaDetail, err := models.GetCygxUserYanxuanPermissionDetailByUserId(user.UserId)
-
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取信息失败,GetCygxUserYanxuanPermissionDetailByUserId Err:" + err.Error()
@@ -251,6 +250,15 @@ func (this *UserController) Detail() {
 			resp.PermissionName = append(resp.PermissionName, utils.CHART_PERMISSION_NAME_MF_YANXUAN)
 		}
 	}
+	hasPermission, err := services.GetUserDetailPermissionCode(user.UserId, user.CompanyId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取信息失败,GetUserDetailPermissionCode Err:" + err.Error()
+		return
+	}
+	specialAuthorCheck := services.GetYanxuanSpecialAuthorInfo(user) //用户是否没开通研选专栏以及,专栏信息是否完善
+	resp.IsAuthor = specialAuthorCheck.IsAuthor
+	resp.HasPermission = hasPermission
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 7 - 0
models/company.go

@@ -193,6 +193,13 @@ func GetCompanyProductDetail(companyId, productId int) (item *CompanyProductDeti
 	return
 }
 
+func GetCompanyProductCount(companyId, productId int) (count int, err error) {
+	sql := ` SELECT COUNT(1) AS count FROM  company_product WHERE company_id = ? AND product_id = ? `
+	o := orm.NewOrmUsingDB("weekly_report")
+	err = o.Raw(sql, companyId, productId).QueryRow(&count)
+	return
+}
+
 type PermissionItem struct {
 	ChartPermissionId int    `description:"权限id"`
 	PermissionName    string `description:"权限名称"`

+ 2 - 0
models/user.go

@@ -150,6 +150,8 @@ type UserDetailResp struct {
 	StartDate           string   `description:"开始日期"`
 	EndDate             string   `description:"结束日期"`
 	CompanyPointsNum    float64  `description:"公司剩余点数"`
+	HasPermission       int      `description:"1:有该行业权限,正常展示"`
+	IsAuthor            bool     `description:"是否开通了研选专栏"`
 }
 
 type CheckStatusResp struct {

+ 86 - 0
services/user_permission.go

@@ -198,3 +198,89 @@ func GetUserRaiPermissionYanXuanInfo(user *models.WxUserItem) (hasPermission int
 	}
 	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
+	}
+	//权益客户
+	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
+			}
+		} else {
+			// 潜在用户
+			if applyCount > 0 {
+				permission = 6
+			} else {
+				permission = 7
+			}
+		}
+	}
+	return
+}
+
+// 用户详情页获取用户权限状态  https://hzstatic.hzinsights.com/static/images/202402/20240205/LpE6dspJCLzfQoCoE8SFMDiLuxXk.png(状态码说明)
+func GetUserDetailPermissionCode(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
+	}
+	//权益客户
+	raiCount, e := models.GetCompanyProductCount(companyId, utils.COMPANY_PRODUCT_RAI_ID)
+	if e != nil {
+		err = errors.New("获取用户申请信息失败, Err: " + e.Error())
+		return
+	}
+	if raiCount == 1 {
+		permission = 1
+	} 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
+			}
+		} else {
+			// 潜在用户
+			if applyCount > 0 {
+				permission = 6
+			} else {
+				permission = 7
+			}
+		}
+	}
+	return
+}