xingzai il y a 2 ans
Parent
commit
f9979bd09f
4 fichiers modifiés avec 107 ajouts et 19 suppressions
  1. 87 17
      controllers/activity.go
  2. 17 0
      models/activity.go
  3. 1 0
      models/activity_type.go
  4. 2 2
      models/db.go

+ 87 - 17
controllers/activity.go

@@ -3227,9 +3227,18 @@ func (this *ActivityCoAntroller) LabelTypeListV5() {
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
+	fmt.Println(permissionNameStr)
+	//判断客户规模是否属于可见范围的活动
+	companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+		return
+	}
+	var sqlExport string
 	resp := new(models.ActivityTypeListHomeResp)
 	for k, v := range list {
-		var sqlExport string
+
 		var condition string
 		permissionSqlStr = ` AND art.chart_permission_name  IN (` + permissionNameStr + `)`
 		sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
@@ -3281,13 +3290,6 @@ func (this *ActivityCoAntroller) LabelTypeListV5() {
 		} else {
 			conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
 		}
-		//判断客户规模是否属于可见范围的活动
-		companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
-		if err != nil && err.Error() != utils.ErrNoRow() {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
-			return
-		}
 
 		if companyProduct != nil {
 			if companyProduct.Scale != "" {
@@ -3311,6 +3313,55 @@ func (this *ActivityCoAntroller) LabelTypeListV5() {
 		}
 		list[k].List = labelList
 	}
+
+	//userType = 1
+	//查询专项产业调研展示权限
+	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 (` + condition + permissionSqlStr + `) `
+	} else {
+		conditionOr += ` OR ( 1=1 ` + condition + `) `
+	}
+
+	if companyProduct != nil {
+		if companyProduct.Scale != "" {
+			conditionOr += ` OR (  art.scale LIKE '%` + companyProduct.Scale + `%'	 ` + condition + `) `
+		}
+	}
+
+	condition += sqlExport + conditionOr
+	specialList, err := models.GetActivityLabelSpecialListAll(condition, pars, startSize, 8)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	for k2, v2 := range specialList {
+		specialList[k2].KeyWord = services.LabelStr(v2.KeyWord)
+	}
+	itemList := new(models.ActivityTypeHome)
+	itemList.ActivityTypeName = "专项产业调研"
+	itemList.List = specialList
+	itemList.ActivityTypeId = 7
+	itemList.ImgUrl = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211216/YSo4QpqtQgwFJzYnxF9TNpAXrFIz.png"
+	itemList.ImgUrlBg = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/1tN4hKDCa6Nq2sZFMKWgJtMVdMvP.png"
+	list = append(list, itemList)
 	//获取对应活动的数量并排序
 	intArr := make([]int, 0)
 	var items []*models.ActivityTypeHome
@@ -3343,18 +3394,37 @@ func (this *ActivityCoAntroller) LabelTypeListV5() {
 			}
 		}
 	}
-	//如果第三个活动数量比第四个多,则两者调换
-	if len(itemsNew) > 3 {
-		if len(itemsNew[2].List) > len(itemsNew[3].List) {
-			var itemsNewCopy []*models.ActivityTypeHome
-			for _, v := range itemsNew {
-				itemsNewCopy = append(itemsNewCopy, v)
-			}
-			itemsNew[2] = itemsNewCopy[3]
-			itemsNew[3] = itemsNewCopy[2]
+	//按照像素进行排序
+	rowHeight := 83     //每一行的行高
+	basicsHeight := 178 // 基础高度
+	position := 1       // 初始化位置 ,1,左边, 2 右边
+	var leftPx, rightPx int
+	for k, v := range itemsNew {
+		if leftPx <= rightPx {
+			position = 1
+		} else {
+			position = 2
+		}
+		itemsNew[k].Position = position
+		if position == 1 {
+			leftPx += basicsHeight + rowHeight*len(v.List)
+		} else {
+			rightPx += basicsHeight + rowHeight*len(v.List)
 		}
 	}
 
+	////如果第三个活动数量比第四个多,则两者调换
+	//if len(itemsNew) > 3 {
+	//	if len(itemsNew[2].List) > len(itemsNew[3].List) {
+	//		var itemsNewCopy []*models.ActivityTypeHome
+	//		for _, v := range itemsNew {
+	//			itemsNewCopy = append(itemsNewCopy, v)
+	//		}
+	//		itemsNew[2] = itemsNewCopy[3]
+	//		itemsNew[3] = itemsNewCopy[2]
+	//	}
+	//}
+
 	//记录用户搜索的筛选条件
 
 	item := new(models.CygxActivitySearchHistory)

+ 17 - 0
models/activity.go

@@ -1,6 +1,7 @@
 package models
 
 import (
+	"fmt"
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"time"
@@ -561,3 +562,19 @@ func GetAskEmail() (item []*AskEmailRep, err error) {
 	_, err = o.Raw(sql).QueryRows(&item)
 	return
 }
+
+//主题列表
+func GetActivityLabelSpecialListAll(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityLabelList, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT	label
+		FROM cygx_activity_special as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY art.label ORDER BY art.last_updated_time DESC  LIMIT ?,? `
+
+	fmt.Println(sql)
+
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}

+ 1 - 0
models/activity_type.go

@@ -47,6 +47,7 @@ type ActivityTypeHome struct {
 	ImgUrl           string `description:"图片"`
 	ImgUrlBg         string `description:"背景图片"`
 	ImgUrlBgs        string `description:"背景图片"`
+	Position         int    `description:"位置 ,1:左 ,2:右边"`
 	List             []*CygxActivityLabelList
 }
 

+ 2 - 2
models/db.go

@@ -92,7 +92,7 @@ func init() {
 		new(UserInvitee),
 	)
 	// 记录ORM查询日志
-	orm.Debug = true
-	orm.DebugLog = orm.NewLog(utils.BinLog)
+	//orm.Debug = true
+	//orm.DebugLog = orm.NewLog(utils.BinLog)
 
 }