Browse Source

no message

xingzai 2 years ago
parent
commit
a039bec32b
2 changed files with 38 additions and 10 deletions
  1. 15 8
      controllers/activity.go
  2. 23 2
      services/activity.go

+ 15 - 8
controllers/activity.go

@@ -1,7 +1,6 @@
 package controllers
 
 import (
-	"fmt"
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/services"
 	"hongze/hongze_clpt/utils"
@@ -37,7 +36,7 @@ func (this *ActivityController) LabelTypeList() {
 	chartPermissionIds := this.GetString("ChartPermissionIds")
 	//isPower, _ := this.GetInt("IsPower")
 	whichDay := this.GetString("WhichDay")
-	//activeState := this.GetString("ActiveState")
+	activeState := this.GetString("ActiveState")
 	var condition string
 	var pars []interface{}
 	if whichDay != "" {
@@ -58,17 +57,25 @@ func (this *ActivityController) LabelTypeList() {
 		condition += `AND activity_time BETWEEN ? AND ? `
 		pars = append(pars, startDate, endDate)
 	}
-
-	condition += `AND activity_time > ? `
-	pars = append(pars, time.Now().AddDate(0, -3, 0).Format(utils.FormatDate))
-	activityList, err := models.GetCygxActivityList(condition, pars)
-	for _, v := range activityList {
-		fmt.Println(v)
+	if activeState == "" {
+		activeState = "1,2"
 	}
+	condition += ` AND active_state  IN (` + activeState + `) `
+
 	// 查研观向7.4-始终查询宏观的活动
 	if chartPermissionIds != "" {
 		chartPermissionIds += ",1"
 	}
+
+	condition += `AND activity_time > ? GROUP BY	label  ORDER BY activity_time DESC  `
+	pars = append(pars, time.Now().AddDate(0, -3, 0).Format(utils.FormatDate))
+	activityList, err := models.GetCygxActivityList(condition, pars)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+
 	list, err := models.GetActivityTypeHomeList()
 	if err != nil {
 		br.Msg = "获取失败"

+ 23 - 2
services/activity.go

@@ -1,17 +1,38 @@
 package services
 
 import (
+	"fmt"
 	"hongze/hongze_clpt/models"
 )
 
 //获取可见的活动
-func HandleActivityPowerList(items []*models.CygxActivity, user *models.WxUserItem) {
+func HandleActivityPowerList(listActivity []*models.CygxActivity, user *models.WxUserItem) (items []*models.CygxActivity, err error) {
 
 	return
 }
 
 //列表
 func HandleActivityTypeHomeList(listType []*models.ActivityTypeHome, listActivity []*models.CygxActivity, user *models.WxUserItem) (items []*models.ActivityTypeHome, err error) {
-
+	mapActivity := make(map[int][]*models.CygxActivityLabelList)
+	for _, v := range listActivity {
+		// 如果是C类电话会就不展示内容,且合并到分析师电话会
+		if v.ActivityTypeId == 7 {
+			v.ActivityTypeId = 1
+		}
+		item := new(models.CygxActivityLabelList)
+		item.KeyWord = v.Label
+		if len(mapActivity[v.ActivityTypeId]) > 10 {
+			continue
+		}
+		mapActivity[v.ActivityTypeId] = append(mapActivity[v.ActivityTypeId], item)
+	}
+	for _, v := range listType {
+		v.Resource = 1
+		if len(mapActivity[v.ActivityTypeId]) > 0 {
+			v.List = mapActivity[v.ActivityTypeId]
+		}
+	}
+	items = listType
+	fmt.Println(mapActivity)
 	return
 }