xingzai před 2 roky
rodič
revize
8876b55b73

+ 64 - 0
controllers/activity.go

@@ -4665,3 +4665,67 @@ func (this *ActivityCoAntroller) ActivityVideoHistoryAdd() {
 	br.Msg = "操作成功"
 	return
 }
+
+// @Title 活动、专项调研搜索
+// @Description 活动、专项调研搜索接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   KeyWord   query   string  false       "搜索关键词 多个用 , 隔开"
+// @Success 200 {object} models.GetCygxActivityListRep
+// @router /listSearch [get]
+func (this *ActivityCoAntroller) ActivityListSearch() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	source, _ := this.GetInt("Source")
+	keyWord := this.GetString("KeyWord")
+	playBack, _ := this.GetInt("PlayBack")
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+	var condition string
+	//活动可见限制
+	conditionActivity, err := services.GetActivityonditionList(user, "", "", "", "", "", 0, 1, keyWord, playBack)
+	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
+	list, total, err := services.GetActivitySpecialSearcheList(user, condition, startSize, pageSize, keyWord)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := new(models.GetCygxActivityListRep)
+	//添加活动搜索记录
+	if keyWord != "" {
+		go services.AddActivitykeyWordSearch(keyWord, user)
+	}
+	resp.Paging = page
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 67 - 0
models/activity.go

@@ -994,3 +994,70 @@ func UpdateActivityshowSubject(activityId int) (err error) {
 	_, err = o.Raw(sql, activityId).Exec()
 	return
 }
+
+//GetActivitySpecialSearcheList 活动与专项调研的搜索
+func GetActivitySpecialSearcheList(condition string, pars []interface{}, conditionSpecil string, parsSpecil []interface{}, startSize, pageSize int) (items []*ActivityDetail, total int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			art.activity_id,
+			art.activity_time_text,
+			art.activity_name,
+			art.chart_permission_id,
+			art.active_state,
+			t.activity_type,
+			art.chart_permission_name,
+			art.distinguished_guest,
+			art.expert,
+			art.speaker,
+			"" AS trip_img_link,
+			"" AS activity_time_end,
+			art.yidong_activity_id,
+			art.is_can_appointment_minutes,
+			art.activity_type_id,
+			art.limit_people_num,
+			1 AS source_type,
+			art.activity_time 
+		FROM
+			cygx_activity AS art
+			INNER JOIN cygx_activity_type AS t ON t.activity_type_id = art.activity_type_id
+		WHERE
+			1 = 1 `
+	if condition != `` {
+		sql += condition
+	}
+	sql += ` UNION ALL
+		SELECT
+			art.activity_id,
+			art.activity_time_text_by_day AS activity_time_text,
+			art.research_theme AS activity_name,
+			art.chart_permission_id,
+			"",
+			art.special_type AS activity_type,
+			art.chart_permission_name,
+			"",
+			"",
+			"",
+			art.trip_img_link_fix AS trip_img_link,
+			art.activity_time_end,
+			"",
+			"",
+			"",
+			"",
+			2 AS source_type,
+			art.activity_time 
+		FROM
+			cygx_activity_special AS art
+		WHERE
+			1 = 1`
+	if conditionSpecil != "" {
+		sql += conditionSpecil
+	}
+	totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
+	err = o.Raw(totalSql, pars, parsSpecil).QueryRow(&total)
+	if err != nil {
+		return
+	}
+	sql += ` ORDER BY activity_time DESC   LIMIT ?,?`
+	_, err = o.Raw(sql, pars, parsSpecil, startSize, pageSize).QueryRows(&items)
+	return
+}

+ 9 - 0
routers/commentsRouter.go

@@ -124,6 +124,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"],
+        beego.ControllerComments{
+            Method: "ActivityListSearch",
+            Router: `/listSearch`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"],
         beego.ControllerComments{
             Method: "MeetingReminderAdd",

+ 195 - 0
services/activity_button.go

@@ -4,6 +4,9 @@ import (
 	"errors"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
+	"strconv"
+	"strings"
+	"time"
 )
 
 //获取用户已经报名的活动
@@ -80,3 +83,195 @@ func GetActivityAppointmentUserMap(activityIds []int, user *models.WxUserItem) (
 	mapUserId = mapUid
 	return
 }
+
+//活动列表的展示  HandleActivityListButton
+func HandleActivityListButton(list []*models.ActivityDetail, user *models.WxUserItem) (items []*models.ActivityDetail, err error) {
+	var activityIds []int
+	var activitySpecilalIds []int
+	for k, v := range list {
+		if v.SourceType == 2 {
+			activitySpecilalIds = append(activitySpecilalIds, v.ActivityId)
+			//把专项调研的线下改为活动的线下类型
+			if v.ActivityType == 2 {
+				list[k].ActivityType = 0
+			}
+			list[k].IsShowSignup = true
+		} else {
+			activityIds = append(activityIds, v.ActivityId)
+		}
+	}
+	//处理活动
+	if len(activityIds) > 0 {
+		//处理用户是否报名
+		mapSignUp, e := GetActivitySignUpUserMap(activityIds, user)
+		if e != nil {
+			err = errors.New("GetActivitySignUpUserMap, Err: " + e.Error())
+			return
+		}
+		for k, v := range list {
+			if v.SourceType != 2 {
+				if _, ok := mapSignUp[v.ActivityId]; ok {
+					list[k].IsSignup = 1
+				}
+			}
+		}
+		//处理用户是否预约纪要
+		mapAppointment, e := GetActivityAppointmentUserMap(activityIds, user)
+		if e != nil {
+			err = errors.New("GetActivityAppointmentUserMap, Err: " + e.Error())
+			return
+		}
+		for k, v := range list {
+			if v.SourceType != 2 {
+				if _, ok := mapAppointment[v.ActivityId]; ok {
+					list[k].IsAppointment = 1
+				}
+			}
+		}
+		//处理用户是否预约会议提醒
+		mapReminder, e := GetActivityReminderUserMasp(activityIds, user)
+		if e != nil {
+			err = errors.New("GetActivityReminderUserMasp, Err: " + e.Error())
+			return
+		}
+		for k, v := range list {
+			if v.SourceType != 2 {
+				if _, ok := mapReminder[v.ActivityId]; ok {
+					list[k].IsCancelMeetingReminder = 1
+				}
+			}
+		}
+	}
+
+	//处理专项产业调研
+	if len(activitySpecilalIds) > 0 {
+		//处理用户是否报名
+		UserMap, e := GetSpecialTripUserMap(activitySpecilalIds, user.UserId)
+		if e != nil {
+			err = errors.New("GetSpecialTripUserMap, Err: " + e.Error())
+			return
+		}
+		for k, v := range list {
+			if v.SourceType == 2 {
+				if _, ok := UserMap[v.ActivityId]; ok {
+					list[k].IsSignup = 1
+				}
+			}
+		}
+
+		for k, v := range list {
+			if v.SourceType == 2 {
+				resultTimeStart := utils.StrTimeToTime(v.ActivityTime)  //时间字符串格式转时间格式
+				resultTimeEnd := utils.StrTimeToTime(v.ActivityTimeEnd) //时间字符串格式转时间格式
+				if resultTimeStart.After(time.Now()) {
+					list[k].ActiveState = strconv.Itoa(1)
+				} else if time.Now().After(resultTimeEnd) {
+					list[k].ActiveState = strconv.Itoa(2)
+				} else {
+					list[k].ActiveState = strconv.Itoa(3)
+				}
+			}
+		}
+	}
+
+	//var isShow bool
+	isShow, e := GetShowSustainableNew()
+	if e != nil {
+		err = errors.New("GetShowSustainableNew, Err: " + e.Error())
+		return
+	}
+	detail, e := models.GetConfigByCode("city_img_url")
+	if e != nil {
+		err = errors.New("GetConfigByCode, Err: " + e.Error())
+		return
+	}
+	detailChart, e := models.GetConfigByCode("chart_img_url")
+	if e != nil {
+		err = errors.New("GetConfigByCode, Err: " + e.Error())
+		return
+	}
+	addressList := strings.Split(detail.ConfigValue, "{|}")
+	mapAddress := make(map[string]string)
+	chartList := strings.Split(detailChart.ConfigValue, "{|}")
+	mapChart := make(map[string]string)
+	var cityName string
+	var chartName string
+	var imgUrl string
+	var imgUrlChart string
+	var mapActivityId []int
+	for _, v := range addressList {
+		vslice := strings.Split(v, "_")
+		cityName = vslice[0]
+		imgUrl = vslice[len(vslice)-1]
+		mapAddress[cityName] = imgUrl
+	}
+	for _, v := range chartList {
+		vslice := strings.Split(v, "_")
+		chartName = vslice[0]
+		imgUrlChart = vslice[len(vslice)-1]
+		mapChart[chartName] = imgUrlChart
+	}
+	for k, v := range list {
+		if strings.Contains(v.ActivityName, "【") {
+			list[k].IsBrackets = 1
+		}
+		if v.SignupNum > v.LimitPeopleNum {
+			list[k].SignupNum = v.LimitPeopleNum
+		}
+		if isShow && strings.Contains(v.ChartPermissionName, "研选") {
+			list[k].IsShowSustainable = true
+		}
+		if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
+			list[k].ActivityTypeName = "买方研选电话会"
+			list[k].ImgUrlText = utils.YAN_XUAN_IMG
+		}
+		if v.ActivityType == 0 {
+			if mapAddress[v.City] != "" {
+				list[k].ImgUrl = mapAddress[v.City]
+			} else {
+				list[k].ImgUrl = mapAddress["其它"]
+			}
+		} else {
+			if mapChart[v.ChartPermissionName] != "" {
+				list[k].ImgUrl = mapChart[v.ChartPermissionName]
+			}
+		}
+		expertTxt, _ := GetReportContentTextSub(v.Expert)
+		list[k].Expert = expertTxt
+		if v.IsHideAppointment == 0 {
+			list[k].IsShowAppointment = IsShowAppointment(v.ActivityTypeId, v.ChartPermissionName)
+		}
+		if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
+			list[k].IsCClassMeeting = true
+		}
+		mapActivityId = append(mapActivityId, v.ActivityId)
+	}
+
+	//处理音频回放
+	mapActivityVoice, e := GetActivityVoiceResp(mapActivityId)
+	if e != nil {
+		err = errors.New("GetActivityVoiceResp, Err: " + e.Error())
+		return
+	}
+
+	//处理视频回放
+	mapActivityVideo, e := GetActivityVideoResp(mapActivityId)
+	if e != nil {
+		err = errors.New("GetActivityVoiceResp, Err: " + e.Error())
+		return
+	}
+	for k, v := range list {
+		if mapActivityVoice[v.ActivityId] != nil {
+			list[k].FileType = 1
+			list[k].AudioLink = true
+			list[k].VoiceList = mapActivityVoice[v.ActivityId]
+		}
+		if mapActivityVideo[v.ActivityId] != nil {
+			list[k].FileType = 2
+			list[k].AudioLink = true
+			list[k].VideoDetail = mapActivityVideo[v.ActivityId]
+		}
+		items = append(items, ActivityButtonShow(v))
+	}
+	return
+}

+ 23 - 0
services/activity_special.go

@@ -379,3 +379,26 @@ func HandleActivitySpecialShow(activityDetail *models.CygxActivitySpecialDetail,
 	item = activityDetail
 	return
 }
+
+//活动与专项调研搜索 GetActivitySpecialSearcheList
+func GetActivitySpecialSearcheList(user *models.WxUserItem, condition string, startSize, pageSize int, keywords string) (items []*models.ActivityDetail, total int, err error) {
+	var conditionSpecil string
+	var pars, parsSpecil []interface{}
+	if keywords != "" {
+		keywords = "%" + keywords + "%"
+		conditionSpecil += ` AND art.research_theme LIKE ?`
+		parsSpecil = append(parsSpecil, keywords)
+	}
+	list, totalSearche, e := models.GetActivitySpecialSearcheList(condition, pars, conditionSpecil, parsSpecil, startSize, pageSize)
+	if e != nil {
+		err = errors.New("GetActivitySpecialSearcheList, Err: " + e.Error())
+		return
+	}
+	items, e = HandleActivityListButton(list, user)
+	if e != nil {
+		err = errors.New("HandleActivityListButton, Err: " + e.Error())
+		return
+	}
+	total = totalSearche
+	return
+}

+ 12 - 0
services/config.go

@@ -17,3 +17,15 @@ func GetShowSustainable() (isShowSustainable bool) {
 	}
 	return
 }
+
+func GetShowSustainableNew() (isShowSustainable bool, err error) {
+	total, err := models.GetShowSustainable()
+	if err != nil {
+		fmt.Println("GetShowSustainable Err:", err.Error())
+		return
+	}
+	if total > 0 {
+		isShowSustainable = true
+	}
+	return
+}