|
@@ -72,8 +72,38 @@ func UpdateCygxActivitySpecialSignupNum(cont context.Context) (err error) {
|
|
|
}
|
|
|
|
|
|
//处理专项调研的展示
|
|
|
-func GetActivityLabelSpecialList(userType, isPower int, chartPermissionIds, scale, permissionNameStr string) (item *models.ActivityTypeHome, err error) {
|
|
|
+func GetActivityLabelSpecialList(user *models.WxUserItem, isPower int, chartPermissionIds, permissionNameStr string) (item *models.ActivityTypeHome, err error) {
|
|
|
+ itemList := new(models.ActivityTypeHome)
|
|
|
+ userType, e := GetSpecialUserType(user)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetSpecialUserType, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if userType == 0 {
|
|
|
+ itemList.List = make([]*models.CygxActivityLabelList, 0)
|
|
|
+ item = itemList
|
|
|
+ return
|
|
|
+ }
|
|
|
+ companyDetail, e := models.GetCompanyDetailByIdGroupTrip(user.CompanyId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetCompanyDetailByIdGroupTrip, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //如果是永续的就按照普通的权限逻辑来查,如果不是就按照升级的逻辑来查
|
|
|
var condition string
|
|
|
+ if companyDetail.Status == "永续" {
|
|
|
+ condition, e = HandleActivityLabelSpecialPermission(user)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ condition, e = HandleActivityLabelSpecialTripPermission(user)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
var pars []interface{}
|
|
|
condition = ` AND art.publish_status = 1 AND art.label != '' `
|
|
|
|
|
@@ -84,11 +114,6 @@ func GetActivityLabelSpecialList(userType, isPower int, chartPermissionIds, scal
|
|
|
if chartPermissionIds != "" {
|
|
|
condition += ` AND art.chart_permission_id IN (` + chartPermissionIds + `) `
|
|
|
}
|
|
|
- var conditionOr string
|
|
|
- if scale != "" {
|
|
|
- conditionOr += ` OR ( art.scale LIKE '%` + scale + `%' ` + condition + `) `
|
|
|
- }
|
|
|
- condition += ` AND art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%'` + conditionOr
|
|
|
specialList, err := models.GetActivityLabelSpecialListAll(condition, pars, 0, 8)
|
|
|
if err != nil {
|
|
|
return
|
|
@@ -98,7 +123,7 @@ func GetActivityLabelSpecialList(userType, isPower int, chartPermissionIds, scal
|
|
|
specialList[k2].ImgUrlBg = "https://hzstatic.hzinsights.com/static/temp/20220426202204/20220426/XDLLsjC9XAAy8LIzQr7GsjrBbtX6.png"
|
|
|
specialList[k2].ImgUrlBg = utils.ACTIVITY_ZXDY_ImgUrl3
|
|
|
}
|
|
|
- itemList := new(models.ActivityTypeHome)
|
|
|
+
|
|
|
itemList.ActivityTypeName = "专项产业调研"
|
|
|
itemList.Resource = 2
|
|
|
itemList.List = specialList
|
|
@@ -135,12 +160,19 @@ func HandleActivityLabelSpecialPermission(user *models.WxUserItem) (condition st
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//HandleActivityLabelSpecialPermission 处理专项产业调研的查询权限sql 升级
|
|
|
+//HandleActivityLabelSpecialPermisseion 处理专项产业调研的查询权限sql 升级
|
|
|
func HandleActivityLabelSpecialTripPermission(user *models.WxUserItem) (condition string, err error) {
|
|
|
- userType, permissionStr, err := GetActivitySpecialUserType(user.CompanyId)
|
|
|
- if err != nil {
|
|
|
+ _, permissionStr, e := GetActivitySpecialUserType(user.CompanyId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetActivitySpecialUserType, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ userType, e := GetSpecialUserType(user)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetSpecialUserType, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
+ fmt.Println("userType", userType)
|
|
|
slicePer := strings.Split(permissionStr, ",")
|
|
|
var permissionSqlStr string
|
|
|
for _, v := range slicePer {
|
|
@@ -156,7 +188,9 @@ func HandleActivityLabelSpecialTripPermission(user *models.WxUserItem) (conditio
|
|
|
permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
|
|
|
permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
|
|
|
condition = ` AND art.publish_status = 1 AND art.label != '' AND art.is_offline = 0 `
|
|
|
- condition += ` AND art.chart_permission_name IN (` + permissionSqlStr + `) `
|
|
|
+ if permissionSqlStr != "" {
|
|
|
+ condition += ` AND art.chart_permission_name IN (` + permissionSqlStr + `) `
|
|
|
+ }
|
|
|
condition += ` AND art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
|
|
|
return
|
|
|
}
|
|
@@ -518,10 +552,8 @@ func GetActivitySpecialUserType(companyId int) (userType int, permissionStrnew s
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//GetSpeciUserhasPermissionType 获取专项产业调研的用户身份类型
|
|
|
-func GetSpeciUserhasPermissionType(user *models.WxUserItem, activityDetail *models.CygxActivitySpecialDetail) (hasPermissionType int, err error) {
|
|
|
- //var condition string
|
|
|
- //HasPermission int `description:"操作方式,1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请,5:有IFCC、无权益"`
|
|
|
+//GetSpecialUserType 获取专项产业调研的用户身份类型
|
|
|
+func GetSpecialUserType(user *models.WxUserItem) (userType int, err error) {
|
|
|
companyId := user.CompanyId
|
|
|
companyDetail, e := models.GetCompanyDetailByIdGroupTrip(companyId)
|
|
|
if e != nil {
|
|
@@ -529,16 +561,34 @@ func GetSpeciUserhasPermissionType(user *models.WxUserItem, activityDetail *mode
|
|
|
return
|
|
|
}
|
|
|
if companyId <= 1 {
|
|
|
- hasPermissionType = 0
|
|
|
+ userType = 0
|
|
|
} else {
|
|
|
if companyDetail.Status == "永续" {
|
|
|
- hasPermissionType = 1
|
|
|
+ userType = 1
|
|
|
} else {
|
|
|
- //total, e := models.GetCountCompanyDetailByIdGroup(companyId)
|
|
|
- //if e != nil {
|
|
|
- // err = errors.New("GetCountCompanyDetailByIdGroup, Err: " + e.Error())
|
|
|
- // return
|
|
|
- //}
|
|
|
+ if companyDetail.Status == "正式" {
|
|
|
+ list, e := models.GetCompanyReportPermissionUpgrade(companyId, 2)
|
|
|
+ if e != nil && e.Error() != utils.ErrNoRow() {
|
|
|
+ err = errors.New("GetCompanyReportPermissionUpgrade, Err: " + e.Error())
|
|
|
+ }
|
|
|
+ if len(list) == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(list) == 4 {
|
|
|
+ totalName, e := models.GetCompanyPermissionNameCheck(companyId, 2, "策略")
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("获取品种信息失败, Err:" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if totalName > 0 {
|
|
|
+ userType = 2
|
|
|
+ } else {
|
|
|
+ userType = 8
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ userType = 8
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return
|