|
@@ -5,6 +5,7 @@ import (
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
"hongze/hongze_cygx/models"
|
|
|
+ "hongze/hongze_cygx/models/company"
|
|
|
"hongze/hongze_cygx/utils"
|
|
|
"strconv"
|
|
|
"strings"
|
|
@@ -506,3 +507,57 @@ func UpdateYanxuanSpecialAuthoMomentsImg(cont context.Context) (err error) {
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// GetYanxuanSpecialDetailUserPower 处理用户查看研选专栏详情的权限
|
|
|
+func GetYanxuanSpecialDetailUserPower(user *models.WxUserItem) (havePower bool, err error) {
|
|
|
+ //研选专栏是否需要校验权限
|
|
|
+ detailChart, e := models.GetConfigByCode("yanxuan_special_power_check")
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetConfigByCode, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //如果没有开启校验,直接返回true
|
|
|
+ if detailChart.ConfigValue == "0" {
|
|
|
+ havePower = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ userId := user.UserId
|
|
|
+ companyId := user.CompanyId
|
|
|
+ //判断用户是否开通了个人研选权限
|
|
|
+ mfyxUserPermissionTotal := GetMfyxUserPermissionTotal(userId)
|
|
|
+
|
|
|
+ if mfyxUserPermissionTotal == 1 {
|
|
|
+ havePower = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //是否是权益客户
|
|
|
+ raiCount, e := company.GetCompanyProductCount(companyId, utils.COMPANY_PRODUCT_RAI_ID)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCompanyProductCount, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if raiCount == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ productDetail, e := company.GetCompanyProductDetailByCompanyId(companyId, 2)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCompanyProductDetailByCompanyId, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 永续客户无法查看研选权限
|
|
|
+ if productDetail.Status == utils.COMPANY_STATUS_FOREVER {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ permissionStr, e := models.GetCompanyPermission(companyId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCompanyPermission, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if strings.Contains(permissionStr, utils.CHART_PERMISSION_NAME_MF_YANXUAN) {
|
|
|
+ havePower = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|