|
@@ -768,10 +768,14 @@ func GetIndustryNewLabelMap(industryIds []int) (labelMap map[int]bool, err error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// GetSpecialDetailUserPower 处理用户查看专项调研详情的权限
|
|
|
+// GetSpecialDetailUserPower 处理用户查看详情的权限
|
|
|
func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.ActivityDetail) (havePower bool, err error) {
|
|
|
var companyDetailStatus string
|
|
|
var userTypeStr string
|
|
|
+ if user.CompanyId == utils.HZ_COMPANY_ID {
|
|
|
+ havePower = true
|
|
|
+ return
|
|
|
+ }
|
|
|
userType, permissionStr, e := GetUserType(user.CompanyId)
|
|
|
if e != nil {
|
|
|
err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error())
|
|
@@ -784,10 +788,26 @@ func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.Ac
|
|
|
return
|
|
|
}
|
|
|
userTypeStr = mapUserType[userType]
|
|
|
- if !strings.Contains(userTypeStr, userTypeStr) {
|
|
|
- return
|
|
|
+ // 永续客户、大套餐客户、30W套餐客户可以查看行业升级套餐客户 权限
|
|
|
+ if userTypeStr == "1" || userTypeStr == "2" || userTypeStr == "AA" {
|
|
|
+ if strings.Contains(activityInfo.CustomerTypeIds, userTypeStr) && strings.Contains(activityInfo.CustomerTypeIds, "8") {
|
|
|
+ havePower = true
|
|
|
+ //return
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ //判断管理规模是否满足
|
|
|
+ companyProduct, e := models.GetCompanyProductDetail(user.CompanyId, 2)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if companyProduct != nil && activityInfo.Scale != "" {
|
|
|
+ if strings.Contains(activityInfo.Scale, companyProduct.Scale) {
|
|
|
+ havePower = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if user.CompanyId <= 1 {
|
|
|
return
|
|
|
} else {
|
|
@@ -819,12 +839,13 @@ func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.Ac
|
|
|
} else if (activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 3 || activityInfo.ActivityTypeId == 4 || activityInfo.ActivityTypeId == 5) && strings.Contains(permissionStr, "专家") {
|
|
|
havePower = true
|
|
|
}
|
|
|
+
|
|
|
if activityInfo.ActivityTypeId == 2 || activityInfo.ActivityTypeId == 6 || activityInfo.ActivityTypeId == 7 {
|
|
|
- if strings.Contains(permissionStr, activityInfo.ChartPermissionName+"(主观)") {
|
|
|
+ if strings.Contains(permissionStr, activityInfo.ChartPermissionName+"(主观)") && strings.Contains(activityInfo.CustomerTypeIds, userTypeStr) {
|
|
|
havePower = true
|
|
|
}
|
|
|
} else {
|
|
|
- if strings.Contains(permissionStr, activityInfo.ChartPermissionName+"(客观)") {
|
|
|
+ if strings.Contains(permissionStr, activityInfo.ChartPermissionName+"(客观)") && strings.Contains(activityInfo.CustomerTypeIds, userTypeStr) {
|
|
|
havePower = true
|
|
|
}
|
|
|
}
|
|
@@ -836,21 +857,19 @@ func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.Ac
|
|
|
havePower = true
|
|
|
}
|
|
|
|
|
|
- permissionShengji, errs := models.GetCompanyPermissionByUserZhengShiTrip(user.CompanyId)
|
|
|
+ permissionShengji, errs := models.GetCompanyPermissionByUserTrip(user.CompanyId)
|
|
|
if errs != nil {
|
|
|
err = errs
|
|
|
return
|
|
|
}
|
|
|
if strings.Contains(permissionShengji, activityInfo.ChartPermissionName) && strings.Contains(activityInfo.CustomerTypeIds, "8") {
|
|
|
havePower = true
|
|
|
- return
|
|
|
}
|
|
|
-
|
|
|
- if strings.Contains(permissionStr, activityInfo.ChartPermissionName) && strings.Contains(activityInfo.CustomerTypeIds, userTypeStr) {
|
|
|
- havePower = true
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
+ fmt.Println("主客观2", havePower)
|
|
|
+ //if strings.Contains(permissionStr, activityInfo.ChartPermissionName) && strings.Contains(activityInfo.CustomerTypeIds, userTypeStr) {
|
|
|
+ // havePower = true
|
|
|
+ //}
|
|
|
+ fmt.Println("主客观3", havePower)
|
|
|
if havePower && activityInfo.LimitPeopleNum > 0 {
|
|
|
//对于一些特殊的活动,即使权限满足也不给产看
|
|
|
noPower, e := GetShareNoPowe(activityInfo, permissionStr, userType, user)
|
|
@@ -871,23 +890,34 @@ func GetShareNoPowe(activityInfo *models.ActivityDetail, permissionStr string, u
|
|
|
if user.CompanyId == utils.HZ_COMPANY_ID {
|
|
|
return
|
|
|
}
|
|
|
- if (userType == 1 || userType == 4 || userType == 5) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(userType)) {
|
|
|
- noPower = true
|
|
|
- }
|
|
|
+ //var noPower bool
|
|
|
+ //if !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(userType)) {
|
|
|
+ // noPower = true
|
|
|
+ //}
|
|
|
//1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户
|
|
|
- if userType == 2 && strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(2)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(4)) {
|
|
|
- noPower = true
|
|
|
- }
|
|
|
- if userType == 2 && !strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(2)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) {
|
|
|
- noPower = true
|
|
|
- }
|
|
|
- if userType == 3 && strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(4)) {
|
|
|
- noPower = true
|
|
|
- }
|
|
|
- if userType == 3 && !strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) {
|
|
|
- noPower = true
|
|
|
+ //if userType == 2 && strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(2)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(4)) {
|
|
|
+ // noPower = true
|
|
|
+ //}
|
|
|
+ //if userType == 2 && !strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(2)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) {
|
|
|
+ // noPower = true
|
|
|
+ //}
|
|
|
+ //if userType == 3 && strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(4)) {
|
|
|
+ // noPower = true
|
|
|
+ //}
|
|
|
+ //if userType == 3 && !strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) {
|
|
|
+ // noPower = true
|
|
|
+ //}
|
|
|
+ if userType == 8 {
|
|
|
+ permissionShengji, errs := models.GetCompanyPermissionByUserZhengShiTrip(user.CompanyId)
|
|
|
+ if errs != nil {
|
|
|
+ err = errs
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if !strings.Contains(permissionShengji, activityInfo.ChartPermissionName) {
|
|
|
+ noPower = true
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
if !noPower {
|
|
|
noPower, err = CheckUserPowerByActivityChoose(user, activityInfo)
|
|
|
}
|