Browse Source

活动列表升级权限修改

xingzai 2 years ago
parent
commit
134b9877cb
3 changed files with 66 additions and 76 deletions
  1. 2 2
      models/company_activity_trip.go
  2. 40 73
      services/activity.go
  3. 24 1
      services/activity_special.go

+ 2 - 2
models/company_activity_trip.go

@@ -60,7 +60,7 @@ func GetCompanyPermissionByUserTrip(companyId int) (permission string, err error
 	return
 }
 
-// 获取正式权限
+// 获取可查看升级权限的正式权限
 func GetCompanyPermissionByUserZhengShiTrip(companyId int) (permission string, err error) {
 	sql := ` SELECT GROUP_CONCAT(DISTINCT b.chart_permission_name  ORDER BY b.sort ASC  SEPARATOR ',') AS permission
 			FROM company_report_permission AS a
@@ -70,7 +70,7 @@ func GetCompanyPermissionByUserZhengShiTrip(companyId int) (permission string, e
 			AND c.is_suspend=0
             AND b.cygx_auth=1
 			AND a.is_upgrade = 1 
-			AND c.status IN('正式')  `
+			AND ( a.is_upgrade = 1 AND c.STATUS = '正式' OR c.STATUS = '永续' ) `
 	o := orm.NewOrm()
 	err = o.Raw(sql, companyId).QueryRow(&permission)
 	return

+ 40 - 73
services/activity.go

@@ -312,7 +312,6 @@ func EditUserOutboundMobile(cont context.Context) (err error) {
 
 // 获取 用户类型   //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户;6、冻结客户;7、流失客户
 func GetUserType(companyId int) (userType int, permissionStrnew string, err error) {
-
 	var permissionStr, permissionZhengShiStr string
 	if companyId <= 1 {
 		userType = 0
@@ -340,28 +339,12 @@ func GetUserType(companyId int) (userType int, permissionStrnew string, err erro
 				err = errs
 				return
 			}
-
 			//1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户、 10: 30W套餐客户
 			//大套餐客户定义:医药、消费、科技、智造、策略。5个行业中任意4个及以上是正式权限的,属于大套餐客户(医药、消费、科技、智造需要主客观都开)
 			if companyDetail.Status == "永续" {
 				userType = 1
 			} else if companyDetail.Status == "试用" {
 				userType = 5
-			} else if companyDetail.Status == "正式" {
-				//userType = 0
-				//if permissionStr == "专家" {
-				//	userType = 4
-				//}
-				//else if strings.Count(permissionZhengShiStr, "医药") == 2 && strings.Count(permissionZhengShiStr, "消费") == 2 && strings.Count(permissionZhengShiStr, "科技") == 2 && strings.Count(permissionZhengShiStr, "智造") == 2 && strings.Count(permissionZhengShiStr, "策略") == 1 {
-				//	userType = 2
-				//} else {
-				//	userType = 3
-				//}
-				//if userType == 3 {
-				//	if !strings.Contains(permissionStr, "医药") && !strings.Contains(permissionStr, "消费") && !strings.Contains(permissionStr, "科技") && !strings.Contains(permissionStr, "智造") {
-				//		userType = 4
-				//	}
-				//}
 			} else if companyDetail.Status == "冻结" {
 				userType = 6
 			} else if companyDetail.Status == "流失" {
@@ -390,16 +373,7 @@ func GetUserType(companyId int) (userType int, permissionStrnew string, err erro
 				} else if permissionZhegnshiNum == 4 {
 					userType = 10
 				} else {
-					permissionShengji, errs := models.GetCompanyPermissionByUserZhengShi(companyId)
-					if errs != nil {
-						err = errs
-						return
-					}
-					if permissionShengji != "" {
-						userType = 8
-					} else {
-						userType = 3
-					}
+					userType = 9
 				}
 			}
 		}
@@ -799,58 +773,51 @@ func GetActivityonditionList(user *models.WxUserItem, activityTypeId, chartPermi
 	//condition += ` AND art.visible_range != 1  AND art.publish_status = 1 `
 	condition += `   AND art.publish_status = 1 `
 
-	//permissionZhengShiStr, errs := models.GetCompanyPermissionByUserZhengShi(user.CompanyId)
-	//if errs != nil {
-	//	err = errs
-	//	return
-	//}
+	permissionZhengShiStr, errs := models.GetCompanyPermissionByUserZhengShi(user.CompanyId)
+	if errs != nil {
+		err = errs
+		return
+	}
 	//9:其他行业正式客户:前述所有正式客户以外的正式客户 查询处理
-	//if permissionZhengShiStr != "" {
-	//	slicePerZhengshi := strings.Split(permissionZhengShiStr, ",")
-	//	permissionZhengShiStr = ""
-	//	for _, v := range slicePerZhengshi {
-	//		if userType == 1 {
-	//			//研选权限处理(永续客户无法查看研选)
-	//			if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) {
-	//				permissionZhengShiStr += "'" + v + "',"
-	//			}
-	//		} else {
-	//			permissionZhengShiStr += "'" + v + "',"
-	//		}
-	//	}
-	//	permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(主观)", "", -1)
-	//	permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(客观)", "", -1)
-	//	permissionZhengShiStr = strings.TrimRight(permissionZhengShiStr, ",")
-	//	//conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%3%'	   AND art.chart_permission_name  IN (` + permissionZhengShiStr + `)` + condition + `) `
-	//
-	//	if userType == 9 {
-	//		conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%9%'	   AND art.chart_permission_name  NOT  IN (` + permissionZhengShiStr + `)` + condition + `) `
-	//	}
-	//}
-
-	if userType != 2 {
-		// 8: 行业升级套餐客户:该活动对应行业为升级权限的客户
-		permissionShengji, errs := models.GetCompanyPermissionByUserZhengShiTrip(user.CompanyId)
-		if errs != nil {
-			err = errs
-			return
+	if permissionZhengShiStr != "" && userType == 9 {
+		slicePerZhengshi := strings.Split(permissionZhengShiStr, ",")
+		permissionZhengShiStr = ""
+		for _, v := range slicePerZhengshi {
+			if userType == 1 {
+				//研选权限处理(永续客户无法查看研选)
+				if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) {
+					permissionZhengShiStr += "'" + v + "',"
+				}
+			} else {
+				permissionZhengShiStr += "'" + v + "',"
+			}
 		}
-		if permissionShengji != "" {
-			slicePerShengji := strings.Split(permissionShengji, ",")
-			permissionShengji = ""
-			for _, v := range slicePerShengji {
-				if userType == 1 {
-					//研选权限处理(永续客户无法查看研选)
-					if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) {
-						permissionShengji += "'" + v + "',"
-					}
-				} else {
+		permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(主观)", "", -1)
+		permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(客观)", "", -1)
+		permissionZhengShiStr = strings.TrimRight(permissionZhengShiStr, ",")
+		conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%9%'	   AND art.chart_permission_name  NOT  IN (` + permissionZhengShiStr + `)` + condition + `) `
+	}
+	// 8: 行业升级套餐客户:该活动对应行业为升级权限的客户
+	permissionShengji, errs := models.GetCompanyPermissionByUserZhengShiTrip(user.CompanyId)
+	if errs != nil {
+		err = errs
+		return
+	}
+	if permissionShengji != "" {
+		slicePerShengji := strings.Split(permissionShengji, ",")
+		permissionShengji = ""
+		for _, v := range slicePerShengji {
+			if userType == 1 {
+				//研选权限处理(永续客户无法查看研选)
+				if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) {
 					permissionShengji += "'" + v + "',"
 				}
+			} else {
+				permissionShengji += "'" + v + "',"
 			}
-			permissionShengji = strings.TrimRight(permissionShengji, ",")
-			conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%8%'	   AND art.chart_permission_name  IN (` + permissionShengji + `)` + condition + `) `
 		}
+		permissionShengji = strings.TrimRight(permissionShengji, ",")
+		conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%8%'	   AND art.chart_permission_name  IN (` + permissionShengji + `)` + condition + `) `
 	}
 
 	conditionHz = condition

+ 24 - 1
services/activity_special.go

@@ -298,7 +298,6 @@ func GetActivitySpecialPrepareList(user *models.WxUserItem, startSize, pageSize
 state 进行状态 1:未开始,2:进行中,3:已结束,4:未开始、进行中 不传默认查询全部items []*CygxActivitySpecialDetail
 */
 func GetActivityLabelSpecialConfirmList(user *models.WxUserItem, startSize, pageSize, state int, keywords string) (list []*models.CygxActivitySpecialDetail, totalConfirm int, err error) {
-	//var condition string
 	companyDetail, e := models.GetCompanyDetailByIdGroupTrip(user.CompanyId)
 	if e != nil {
 		err = errors.New("GetCompanyDetailByIdGroupTrip, Err: " + e.Error())
@@ -363,6 +362,30 @@ func GetActivityLabelSpecialConfirmList(user *models.WxUserItem, startSize, page
 		conditionOr += ` OR (  art.customer_type_ids LIKE '%8%' AND art.chart_permission_name  IN (` + permissionShengji + `)` + condition + `) `
 		pars = append(pars, pars)
 	}
+	//9:其他行业正式客户:前述所有正式客户以外的正式客户 查询处理
+	permissionZhengShiStr, errs := models.GetCompanyPermissionByUserZhengShi(user.CompanyId)
+	if errs != nil {
+		err = errs
+		return
+	}
+	if permissionZhengShiStr != "" && userType == 9 {
+		slicePerZhengshi := strings.Split(permissionZhengShiStr, ",")
+		permissionZhengShiStr = ""
+		for _, v := range slicePerZhengshi {
+			if userType == 1 {
+				//研选权限处理(永续客户无法查看研选)
+				if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) {
+					permissionZhengShiStr += "'" + v + "',"
+				}
+			} else {
+				permissionZhengShiStr += "'" + v + "',"
+			}
+		}
+		permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(主观)", "", -1)
+		permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(客观)", "", -1)
+		permissionZhengShiStr = strings.TrimRight(permissionZhengShiStr, ",")
+		conditionOr += ` OR (  art.customer_type_ids LIKE '%9%'	   AND art.chart_permission_name  NOT  IN (` + permissionZhengShiStr + `)` + condition + `) `
+	}
 
 	condition += conditionUser + conditionOr
 	totalConfirm, e = models.GetActivitySpecialCount(condition, pars)