Browse Source

no message

xingzai 2 years ago
parent
commit
9d80552962
2 changed files with 24 additions and 42 deletions
  1. 13 42
      services/activity.go
  2. 11 0
      services/activity_special.go

+ 13 - 42
services/activity.go

@@ -215,52 +215,23 @@ func GetActivityonditionList(user *models.WxUserItem, activityTypeId, chartPermi
 	condition += `   AND art.publish_status = 1 `
 	condition += `   AND art.publish_status = 1 `
 
 
 	// 8: 行业升级套餐客户:该活动对应行业为升级权限的客户
 	// 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 + `) `
-	}
 
 
-	//9:其他行业正式客户:前述所有正式客户以外的正式客户 查询处理
+	////9:其他行业正式客户:前述所有正式客户以外的正式客户 查询处理
 
 
-	permissionZhengShiStr, errs := models.GetCompanyPermissionByUserZhengShi(user.CompanyId)
-	if errs != nil {
-		err = errs
+	conditionShengji, conditionZhengshi, conditionHangYe, e := ActivityLabelSpecialUserSql(user)
+	if e != nil {
+		err = errors.New("ActivityLabelSpecialUserSql, Err: " + e.Error())
 		return
 		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.is_limit_people = 1 AND art.customer_type_ids LIKE '%9%'	   AND art.chart_permission_name  NOT  IN (` + permissionZhengShiStr + `)` + condition + `) `
+
+	if conditionShengji != "" {
+		conditionOr += ` OR (  art.is_limit_people = 1 AND ` + conditionShengji + condition + ` ) `
+	}
+	if conditionZhengshi != "" {
+		conditionOr += ` OR (  art.is_limit_people = 1 AND ` + conditionZhengshi + condition + ` ) `
+	}
+	if conditionHangYe != "" {
+		conditionOr += ` OR (  art.is_limit_people = 1 AND ` + conditionHangYe + condition + ` ) `
 	}
 	}
 
 
 	conditionHz = condition
 	conditionHz = condition

+ 11 - 0
services/activity_special.go

@@ -131,6 +131,7 @@ func ActivityLabelSpecialUserSql(user *models.WxUserItem) (conditionShengji, con
 		permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(主观)", "", -1)
 		permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(主观)", "", -1)
 		permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(客观)", "", -1)
 		permissionZhengShiStr = strings.Replace(permissionZhengShiStr, "(客观)", "", -1)
 		permissionZhengShiStr = strings.TrimRight(permissionZhengShiStr, ",")
 		permissionZhengShiStr = strings.TrimRight(permissionZhengShiStr, ",")
+		permissionZhengShiStr += `, '宏观'`
 		conditionHangYe = `  art.customer_type_ids LIKE '%3%'	   AND art.chart_permission_name    IN (` + permissionZhengShiStr + `)`
 		conditionHangYe = `  art.customer_type_ids LIKE '%3%'	   AND art.chart_permission_name    IN (` + permissionZhengShiStr + `)`
 		if userType == 9 {
 		if userType == 9 {
 			conditionZhengshi = `  art.customer_type_ids LIKE '%9%'	   AND art.chart_permission_name  NOT  IN (` + permissionZhengShiStr + `)`
 			conditionZhengshi = `  art.customer_type_ids LIKE '%9%'	   AND art.chart_permission_name  NOT  IN (` + permissionZhengShiStr + `)`
@@ -221,18 +222,25 @@ func GetActivityLabelSpecialList(user *models.WxUserItem, conditionActivitySpeci
 		conditionNoTrip += ` AND art.days = 0  `
 		conditionNoTrip += ` AND art.days = 0  `
 		var conditionShengjiNoTrip string
 		var conditionShengjiNoTrip string
 		var conditionZhengshiNoTrip string
 		var conditionZhengshiNoTrip string
+		var conditionHangYeNoTrip string
 		if conditionShengji != "" {
 		if conditionShengji != "" {
 			conditionShengjiNoTrip = ` OR ( ` + conditionShengji + conditionNoTrip + ` )`
 			conditionShengjiNoTrip = ` OR ( ` + conditionShengji + conditionNoTrip + ` )`
 		}
 		}
 		if conditionZhengshi != "" {
 		if conditionZhengshi != "" {
 			conditionZhengshiNoTrip = ` OR ( ` + conditionZhengshi + conditionNoTrip + ` )`
 			conditionZhengshiNoTrip = ` OR ( ` + conditionZhengshi + conditionNoTrip + ` )`
 		}
 		}
+		if conditionHangYe != "" {
+			conditionHangYeNoTrip = ` OR ( ` + conditionHangYe + conditionNoTrip + ` )`
+		}
 		if conditionShengji != "" {
 		if conditionShengji != "" {
 			conditionNoTrip += conditionShengjiNoTrip
 			conditionNoTrip += conditionShengjiNoTrip
 		}
 		}
 		if conditionZhengshi != "" {
 		if conditionZhengshi != "" {
 			conditionNoTrip += conditionZhengshiNoTrip
 			conditionNoTrip += conditionZhengshiNoTrip
 		}
 		}
+		if conditionHangYe != "" {
+			conditionNoTrip += conditionHangYeNoTrip
+		}
 		conditionNoTripSql += conditionUser + conditionNoTrip + ` ORDER BY art.last_updated_time DESC`
 		conditionNoTripSql += conditionUser + conditionNoTrip + ` ORDER BY art.last_updated_time DESC`
 		specialListNotrip, e := models.GetActivityLabelSpecialListAll(conditionNoTripSql, pars, 0, 200)
 		specialListNotrip, e := models.GetActivityLabelSpecialListAll(conditionNoTripSql, pars, 0, 200)
 		if e != nil {
 		if e != nil {
@@ -365,6 +373,9 @@ func GetActivitySpecialPrepareList(user *models.WxUserItem, startSize, pageSize
 	var conditionShengjiNoTrip string
 	var conditionShengjiNoTrip string
 	var conditionZhengshiNoTrip string
 	var conditionZhengshiNoTrip string
 	var conditionHangYeNoTrip string
 	var conditionHangYeNoTrip string
+	fmt.Println(conditionShengji)
+	fmt.Println(conditionZhengshi)
+	fmt.Println(conditionHangYe)
 	if conditionShengji != "" {
 	if conditionShengji != "" {
 		conditionShengjiNoTrip = ` OR ( ` + conditionShengji + conditionNoTrip + ` )`
 		conditionShengjiNoTrip = ` OR ( ` + conditionShengji + conditionNoTrip + ` )`
 	}
 	}