فهرست منبع

Merge branch 'master' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai 2 سال پیش
والد
کامیت
b7f4062b27
2فایلهای تغییر یافته به همراه59 افزوده شده و 96 حذف شده
  1. 21 96
      controllers/activity.go
  2. 38 0
      services/activity_special.go

+ 21 - 96
controllers/activity.go

@@ -3009,18 +3009,10 @@ func (this *ActivityCoAntroller) LabelTypeListV5() {
 	if activeState == "undefined" || activeState == "" {
 		activeState = "1"
 	}
-
 	// 查研观向7.4-始终查询宏观的活动
 	if chartPermissionIds != "" {
 		chartPermissionIds += ",1"
 	}
-
-	//adminIds, err := models.GetSelleridWhichGroup(user.CompanyId, 2)
-	//if err != nil {
-	//	br.Msg = "获取失败"
-	//	br.ErrMsg = "获取本组下的销售失败,Err:" + err.Error()
-	//	return
-	//}
 	userType, permissionStr, err := services.GetUserType(user.CompanyId)
 	if err != nil {
 		br.Msg = "获取失败"
@@ -3033,7 +3025,7 @@ func (this *ActivityCoAntroller) LabelTypeListV5() {
 	var pars []interface{}
 	//活动可见限制
 	slicePer := strings.Split(permissionStr, ",")
-	var permissionSqlStr string
+	//var permissionSqlStr string
 	var permissionNameStr string
 	for _, v := range slicePer {
 		if userType == 1 {
@@ -3071,7 +3063,7 @@ func (this *ActivityCoAntroller) LabelTypeListV5() {
 	}
 	//isMaker := user.IsMaker
 
-	var sqlExport string
+	//var sqlExport string
 	resp := new(models.ActivityTypeListHomeResp)
 	for k, v := range list {
 		// 如果是C类电话会就不展示内容,且合并到分析师电话会
@@ -3102,59 +3094,21 @@ func (this *ActivityCoAntroller) LabelTypeListV5() {
 		list[k].Resource = 1
 	}
 
-	//userType = 1
 	//查询专项产业调研展示权限 仅对大套餐客户跟永续客户展示
-	if whichDay == "" && (userType == 1 || userType == 2) {
-		var condition string
-		condition = ` AND art.publish_status = 1  AND art.label != '' `
-		if isPower == 1 {
-			condition += permissionSqlStr
-		}
-		//行业名称
-		if len(chartPermissionIds) > 0 {
-			condition += ` AND art.chart_permission_id  IN (` + chartPermissionIds + `)`
-		}
-		var conditionOr string
-
-		if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
-			conditionOr += ` OR (1=1 AND   art.customer_type_ids LIKE '%4%'	 ` + condition + `) `
-		}
-		if (userType == 5) && strings.Contains(permissionStr, "专家") {
-			conditionOr += ` OR (1=1 AND art.customer_type_ids LIKE '%5%'	 ` + condition + `) `
-		}
-		if userType == 1 {
-			conditionOr += ` OR (1=1 ` + condition + permissionSqlStr + `) `
-		}
-
+	if whichDay == "" {
+		var scale string
 		if companyProduct != nil {
-			if companyProduct.Scale != "" {
-				conditionOr += ` OR (  art.scale LIKE '%` + companyProduct.Scale + `%'	 ` + condition + `) `
-			}
+			scale = companyProduct.Scale
 		}
-
-		condition += sqlExport + conditionOr
-		specialList, err := models.GetActivityLabelSpecialListAll(condition, pars, startSize, 8)
+		speciaItem, err := services.GetActivityLabelSpecialList(userType, isPower, chartPermissionIds, scale, permissionNameStr)
 		if err != nil {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取失败,Err:" + err.Error()
 			return
 		}
-		for k2, v2 := range specialList {
-			specialList[k2].KeyWord = services.LabelStrV5(v2.KeyWord, v2.IsShowSubjectName, v2.TemporaryLabel)
-			specialList[k2].ImgUrlBg = "https://hzstatic.hzinsights.com/static/temp/20220426202204/20220426/XDLLsjC9XAAy8LIzQr7GsjrBbtX6.png"
-			specialList[k2].ImgUrlBg = utils.ACTIVITY_ZXDY_ImgUrl3
+		if len(speciaItem.List) > 0 {
+			list = append(list, speciaItem)
 		}
-
-		itemList := new(models.ActivityTypeHome)
-		itemList.ActivityTypeName = "专项产业调研"
-		itemList.Resource = 2
-		itemList.List = specialList
-		itemList.ActivityTypeId = 7
-		//itemList.ImgUrl = "https://hzstatic.hzinsights.com/static/temp/20220427202204/20220427/b2Bj3fGakP16iJRFKisQohCWnCNl.png"
-		itemList.ImgUrl = utils.ACTIVITY_ZXDY_ImgUrl1
-		//itemList.ImgUrlBg = "https://hzstatic.hzinsights.com/static/temp/20220427202204/20220427/OkunjfKEgo5KRLifzwwLX8cDZnnN.png"
-		itemList.ImgUrlBg = utils.ACTIVITY_ZXDY_ImgUrl2
-		list = append(list, itemList)
 	}
 
 	//获取对应活动的数量并排序
@@ -4047,7 +4001,6 @@ func (this *ActivityCoAntroller) LabelTypeListV6Pc() {
 	var pars []interface{}
 	//活动可见限制
 	slicePer := strings.Split(permissionStr, ",")
-	var permissionSqlStr string
 	var permissionNameStr string
 	for _, v := range slicePer {
 		if userType == 1 {
@@ -4125,57 +4078,29 @@ func (this *ActivityCoAntroller) LabelTypeListV6Pc() {
 		list[k].Resource = 1
 	}
 
-	if whichDay == "" && (userType == 1 || userType == 2) {
+	if whichDay == "" {
 		//查询专项产业调研展示权限
-		var condition string
-		condition = ` AND art.publish_status = 1  AND art.label != '' `
-		if isPower == 1 {
-			condition += permissionSqlStr
-		}
-		//行业名称
-		if len(chartPermissionIds) > 0 {
-			condition += ` AND art.chart_permission_id  IN (` + chartPermissionIds + `)`
-		}
-		var conditionOr string
-
-		if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
-			conditionOr += ` OR (1=1 AND   art.customer_type_ids LIKE '%4%'	 ` + condition + `) `
-		}
-		if (userType == 5) && strings.Contains(permissionStr, "专家") {
-			conditionOr += ` OR (1=1 AND art.customer_type_ids LIKE '%5%'	 ` + condition + `) `
-		}
-		if userType == 1 {
-			conditionOr += ` OR (1=1 ` + condition + permissionSqlStr + `) `
-		}
-
+		var scale string
 		if companyProduct != nil {
-			if companyProduct.Scale != "" {
-				conditionOr += ` OR (  art.scale LIKE '%` + companyProduct.Scale + `%'	 ` + condition + `) `
-			}
+			scale = companyProduct.Scale
 		}
-
-		condition += sqlExport + conditionOr
-		specialList, err := models.GetActivityLabelSpecialListAll(condition, pars, startSize, 8)
+		speciaItem, err := services.GetActivityLabelSpecialList(userType, isPower, chartPermissionIds, scale, permissionNameStr)
 		if err != nil {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取失败,Err:" + err.Error()
 			return
 		}
-		for k2, v2 := range specialList {
-			specialList[k2].KeyWord = services.LabelStrV5(v2.KeyWord, v2.IsShowSubjectName, v2.TemporaryLabel)
-			specialList[k2].Resource = 2
+		if len(speciaItem.List) > 0 {
+			itemList := new(models.ActivityTypeHomePc)
+			itemList.ActivityTypeName = "专项产业调研"
+			itemList.Resource = 2
+			itemList.List = speciaItem.List
+			itemList.ActivityTypeId = 7
+			itemList.OnlineIco = "https://hzstatic.hzinsights.com/static/temp/20220707202207/20220707/0H4md6VgZMuIttggMUnJxgrlayxC.png"
+			itemList.ImgUrlBgPc = "https://hzstatic.hzinsights.com/static/temp/20220707202207/20220707/rFwAM1c4fIMJM0EGoUkUYl25XH9L.png"
+			list = append(list, itemList)
 		}
-
-		itemList := new(models.ActivityTypeHomePc)
-		itemList.ActivityTypeName = "专项产业调研"
-		itemList.Resource = 2
-		itemList.List = specialList
-		itemList.ActivityTypeId = 7
-		itemList.OnlineIco = "https://hzstatic.hzinsights.com/static/temp/20220707202207/20220707/0H4md6VgZMuIttggMUnJxgrlayxC.png"
-		itemList.ImgUrlBgPc = "https://hzstatic.hzinsights.com/static/temp/20220707202207/20220707/rFwAM1c4fIMJM0EGoUkUYl25XH9L.png"
-		list = append(list, itemList)
 	}
-
 	// 查研观向7.4-活动【新】标签
 	activityIds := make([]int, 0)
 	for _, v := range list {

+ 38 - 0
services/activity_special.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
+	"strconv"
 	"time"
 )
 
@@ -67,3 +68,40 @@ func UpdateCygxActivitySpecialSignupNum(cont context.Context) (err error) {
 	fmt.Println("UpdateCygxActivitySpecialSignupNum end")
 	return
 }
+
+//处理专项调研的展示
+func GetActivityLabelSpecialList(userType, isPower int, chartPermissionIds, scale, permissionNameStr string) (item *models.ActivityTypeHome, err error) {
+	var condition string
+	var pars []interface{}
+	condition = ` AND art.publish_status = 1  AND art.label != '' `
+	condition += ` AND  art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%'`
+	//行业名称
+	if isPower == 1 {
+		condition += ` AND art.chart_permission_name  IN (` + permissionNameStr + `) `
+	}
+	if chartPermissionIds != "" {
+		condition += ` AND art.chart_permission_id  IN (` + chartPermissionIds + `) `
+	}
+	var conditionOr string
+	if scale != "" {
+		conditionOr += ` OR (  art.scale LIKE '%` + scale + `%'	 ` + condition + `) `
+	}
+	specialList, err := models.GetActivityLabelSpecialListAll(condition, pars, 0, 8)
+	if err != nil {
+		return
+	}
+	for k2, v2 := range specialList {
+		specialList[k2].KeyWord = LabelStrV5(v2.KeyWord, v2.IsShowSubjectName, v2.TemporaryLabel)
+		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
+	itemList.ActivityTypeId = 7
+	itemList.ImgUrl = utils.ACTIVITY_ZXDY_ImgUrl1
+	itemList.ImgUrlBg = utils.ACTIVITY_ZXDY_ImgUrl2
+	item = itemList
+	return
+}