Browse Source

进行中的活动搜索的时候优先展示

xingzai 2 years ago
parent
commit
8e7daa1d17
2 changed files with 28 additions and 27 deletions
  1. 25 27
      controllers/activity.go
  2. 3 0
      services/activity.go

+ 25 - 27
controllers/activity.go

@@ -2786,33 +2786,31 @@ func (this *ActivityCoAntroller) ActivityListNew() {
 	var activityList []*models.ActivityDetail
 	mapDingActivityId := make(map[int]int)
 	//进行中的活动拍在最上面
-	//if keyWord != "" {
-	//	conditionActivity, err := services.GetActivityonditionList(user, activityTypeId, chartPermissionIds, whichDay, strconv.Itoa(2), label, 0, source, keyWord)
-	//	if err != nil && err.Error() != utils.ErrNoRow() {
-	//		br.Msg = "获取失败"
-	//		br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
-	//		return
-	//	}
-	//	if source == 1 {
-	//		condition += ` AND art.yidong_activity_id = '' `
-	//	}
-	//	condition += ` AND art.is_limit_people = 1 AND art.publish_status = 1 ` + conditionActivity
-	//	condition += ` ORDER BY art.activity_time ASC   `
-	//	listDing, err := models.GetActivityListAll(condition, pars, uid, startSize, pageSize, playBack)
-	//	if err != nil && err.Error() != utils.ErrNoRow() {
-	//		br.Msg = "获取失败"
-	//		br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
-	//		return
-	//	}
-	//	if len(listDing) > 0 {
-	//		for _, v := range listDing {
-	//			activityList = append(activityList, v)
-	//			mapDingActivityId[v.ActivityId] = v.ActivityId
-	//		}
-	//	}
-	//	return
-	//	fmt.Println("len", len(listDing))
-	//}
+	if keyWord != "" {
+		conditionActivity, err := services.GetActivityonditionList(user, activityTypeId, chartPermissionIds, whichDay, strconv.Itoa(2), label, 0, source, keyWord)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
+			return
+		}
+		if source == 1 {
+			condition += ` AND art.yidong_activity_id = '' `
+		}
+		condition += ` AND art.is_limit_people = 1 AND art.publish_status = 1 ` + conditionActivity
+		condition += ` ORDER BY art.activity_time ASC   `
+		listDing, err := models.GetActivityListAll(condition, pars, uid, startSize, pageSize, playBack)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
+			return
+		}
+		if len(listDing) > 0 {
+			for _, v := range listDing {
+				activityList = append(activityList, v)
+				mapDingActivityId[v.ActivityId] = v.ActivityId
+			}
+		}
+	}
 	condition = ""
 	//活动可见限制
 	conditionActivity, err := services.GetActivityonditionList(user, activityTypeId, chartPermissionIds, whichDay, activeState, label, 0, source, keyWord)

+ 3 - 0
services/activity.go

@@ -522,6 +522,9 @@ func GetActivityonditionList(user *models.WxUserItem, activityTypeId, chartPermi
 	//有搜索条件传过来时,不判进行状态条件
 	if keyWord != "" {
 		condition += ` AND (art.label  LIKE '%` + keyWord + `%' OR art.activity_name  LIKE '%` + keyWord + `%' ) `
+		if activeState == "2" {
+			condition += ` AND art.active_state  = 2 `
+		}
 	} else {
 		if activeState != "" {
 			// 默认查看未开始跟进行中