Selaa lähdekoodia

查研观向8.7

xingzai 2 vuotta sitten
vanhempi
commit
921cfb19bb

+ 227 - 2
controllers/activity.go

@@ -1057,6 +1057,23 @@ func (this *ActivityCoAntroller) Detail() {
 		//处理按钮是否展示问题
 		resp.Detail = services.ActivityButtonShow(activityInfo)
 	}
+
+	collectCount1, err := models.GetActivityVoiceCollectCount(uid, activityId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";activityId" + strconv.Itoa(activityId)
+		return
+	}
+	collectCount2, err := models.GetActivityVideoCollectCountByActivityId(uid, activityId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";activityId" + strconv.Itoa(activityId)
+		return
+	}
+	if collectCount1+collectCount2 > 0 {
+		resp.Detail.IsCollect = true
+	}
+
 	resp.HasPermission = hasPermission
 	br.Ret = 200
 	br.Success = true
@@ -2435,7 +2452,7 @@ func (this *ActivityCoAntroller) LabelMoreList() {
 // @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
 // @Param   Label   query   string  false       "搜索主题 多个用 , 隔开"
 // @Param   ChartPermissionIds   query   string  false     "行业id 多个用 , 隔开"
-// @Param   WhichDay   query   string  false       "哪一天 今天:1、明天:2,多个用 , 隔开"
+// @Param   WhichDay   query   string  false       "哪一天 1今天、2明天,3本周,4上周,5本月,6上月 多个用 , 隔开"
 // @Param   ActiveState   query   string  false       "活动进行状态 未开始:1、进行中2、已结束3"
 // @Param   ActivityTypeId   query   string  false     "活动类型id 多个用 , 隔开"
 // @Param   Source   query   int  false     "来源 0手机 ,1Pc 默认0"
@@ -2444,6 +2461,7 @@ func (this *ActivityCoAntroller) LabelMoreList() {
 // @Param   KeyWord   query   string  false       "搜索关键词 多个用 , 隔开"
 // @Param   ActivityId   query   int  false       "活动列表传过来的活动ID"
 // @Param   Filter			query	int		false	"筛选条件 0:全部 1:视频 2:音频"
+// @Param   TypeName   query   string  false       "电话会类型 ,1专家电话会 2分析师电话会"
 // @Success 200 {object} models.GetCygxActivityListRep
 // @router /listNew [get]
 func (this *ActivityCoAntroller) ActivityListNew() {
@@ -2470,6 +2488,7 @@ func (this *ActivityCoAntroller) ActivityListNew() {
 	keyWord := this.GetString("KeyWord")
 	playBack, _ := this.GetInt("PlayBack")
 	filter, _ := this.GetInt("Filter")
+	typeName := this.GetString("TypeName")
 	activityId, _ := this.GetInt("ActivityId") // 仅用于判断【新】标签
 
 	if label == "undefined" {
@@ -2578,7 +2597,8 @@ func (this *ActivityCoAntroller) ActivityListNew() {
 	}
 
 	condition += conditionOrder
-	list, errList := models.GetActivityListNew(condition, pars, uid, startSize, pageSize, playBack, filter)
+
+	list, errList := models.GetActivityListNew(condition, pars, uid, startSize, pageSize, playBack, filter, typeName)
 	if errList != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败,Err:" + errList.Error()
@@ -4630,3 +4650,208 @@ func (this *ActivityCoAntroller) ActivityListSearch() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 已结束的活动
+// @Description 获取已结束的活动接口
+// @Param   ChartPermissionIds   query   string  false     "行业id 多个用 , 隔开"
+// @Param   WhichDay   query   string  false       "哪一天 3本周、4上周,5本月,6上月 可多选"
+// @Param   IsPower   query   string  false       "是否选择有权限行业 ,1是 0 否 默认0"
+// @Param   TypeName   query   string  false       "电话会类型 ,1专家电话会 2分析师电话会"
+// @Success 200 {object} models.GetCygxActivityLabelListRep
+// @router /overActivityList [get]
+func (this *ActivityCoAntroller) OverActivityList() {
+	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
+	}
+
+	isPower, _ := this.GetInt("IsPower")
+	chartPermissionIds := this.GetString("ChartPermissionIds")
+	whichDay := this.GetString("WhichDay")
+	fmt.Println("whichDay:", whichDay)
+	typeName := this.GetString("TypeName")
+
+	//入参为 undefined 时的处理
+	if chartPermissionIds == "undefined" {
+		chartPermissionIds = ""
+	}
+	if whichDay == "undefined" {
+		whichDay = ""
+	}
+	resp := new(models.GetCygxActivityLabelListRep)
+	if user.CompanyId <= 1 {
+		resp.List = make([]*models.CygxActivityLabelList, 0)
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+		return
+	}
+	userType, permissionStr, err := services.GetUserType(user.CompanyId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	//var startSize, pageSize int
+	//pageSize = 24
+	var condition string
+	var conditionSpecial string
+	var sortTime string
+	//var conditionStatus string
+	var pars []interface{}
+	//活动可见限制
+	var sqlExport string
+
+	slicePer := strings.Split(permissionStr, ",")
+	var permissionSqlStr string
+	for _, v := range slicePer {
+		if userType == 1 {
+			//if v != "研选" {
+			if !strings.Contains(v, "研选") {
+				permissionSqlStr += "'" + v + "',"
+			}
+		} else {
+			permissionSqlStr += "'" + v + "',"
+		}
+	}
+	permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
+	permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
+	permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
+	permissionSqlStr = ` AND art.chart_permission_name  IN (` + permissionSqlStr + `)`
+	sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
+	if userType == 2 {
+		sqlExport += ` OR  art.customer_type_ids LIKE '%3%' `
+	}
+	if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
+		sqlExport += ` OR  art.customer_type_ids LIKE '%4%' `
+	}
+	sqlExport += `) `
+
+	//已结束的活动
+	var conditionOr string
+	conditionOr = ""
+	condition = ` AND art.publish_status = 1  AND art.label != ''  AND art.active_state = 3 `
+	if isPower == 1 {
+		condition += permissionSqlStr + sqlExport + conditionOr
+	}
+	if whichDay != "" {
+		var startDate string
+		var endDate string
+		if whichDay == "3" {
+			startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
+		} else if whichDay == "4" {
+			startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetLastWeekSunday().Format(utils.FormatDate)
+		} else if whichDay == "5" {
+			startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate)
+			endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
+		} else if whichDay == "6" {
+			startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
+			endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate)
+		} else if whichDay == "3,4" {
+			startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
+		} else if whichDay == "5,6" {
+			startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
+			endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
+		} else {
+			startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
+		}
+		condition += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
+		condition += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
+
+		conditionSpecial += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
+		conditionSpecial += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
+
+	}
+	if len(chartPermissionIds) > 0 {
+		condition += ` AND art.chart_permission_id  IN (` + chartPermissionIds + `)`
+	}
+	if typeName != "" {
+		typeSlice := strings.Split(typeName, ",")
+		tempCondition := ""
+		for _, s := range typeSlice {
+			if s == "1" {
+				tempCondition += "'专家电话会',"
+			} else if s == "2" {
+				tempCondition += "'分析师电话会',"
+			} else if s == "1,2" {
+				tempCondition += "'专家电话会','分析师电话会',"
+			}
+		}
+		tempCondition = strings.TrimRight(tempCondition, ",")
+		condition += ` AND art.activity_type_name IN (` + tempCondition + `)`
+	}
+
+	conditionActivity, err := services.GetActivityonditionList(user, "", chartPermissionIds, whichDay, "3", "", 0, 0, "", 0)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
+		return
+	}
+	//已结束的活动
+	sortTime = ` activity_time DESC `
+
+	//如果是永续的就按照普通的权限逻辑来查,如果不是就按照升级的逻辑来查
+
+	companyDetail, err := models.GetCompanyDetailByIdGroupTrip(user.CompanyId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	if companyDetail.Status == "永续" {
+		conditionSpecial, err = services.HandleActivityLabelSpecialPermission(user)
+	} else {
+		conditionSpecial, err = services.HandleActivityLabelSpecialTripPermission(user)
+	}
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	conditionSpecial += ` AND art.days >0  AND art.publish_status =1   AND art.is_offline = 0  `
+	conditionSpecial += ` AND art.activity_time_end <  ` + "'" + time.Now().Format(utils.FormatDateTime) + "'"
+	condition += conditionActivity
+	list, err := models.GetActivityLabelListAllNoLimit(condition, sortTime, pars, conditionSpecial)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	//标签字段关联的产业与标签处理
+	mapKeyWord := make(map[string]string)
+	for _, v := range list {
+		keyWord := services.LabelStr(v.KeyWord)
+		if _, ok := mapKeyWord[keyWord]; ok {
+			continue
+		}
+		v.KeyWord = keyWord
+		resp.List = append(resp.List, v)
+		mapKeyWord[keyWord] = keyWord
+	}
+	//添加更多主题访问记录
+	item := new(models.CygxPageHistoryRecord)
+	item.UserId = user.UserId
+	item.CreateTime = time.Now()
+	item.Mobile = user.Mobile
+	item.Email = user.Email
+	item.CompanyId = user.CompanyId
+	item.CompanyName = user.CompanyName
+	item.PageType = "OverActivity"
+	go models.AddCygxPageHistoryRecord(item)
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 502 - 2
controllers/micro_roadshow.go

@@ -7,6 +7,7 @@ import (
 	"hongze/hongze_cygx/services"
 	"hongze/hongze_cygx/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -22,6 +23,9 @@ type MicroRoadShowController struct {
 // @Param   KeyWord			query	string	false	"搜索关键词"
 // @Param   AudioId			query	int		false	"音频ID"
 // @Param   VideoId			query	int		false	"视频ID"
+// @Param   AudioIds			query	string		false	"活动音频IDs"
+// @Param   ActivityVideoIds	query	string		false	"活动视频IDs"
+// @Param   VideoIds			query	string		false	"视频IDs"
 // @Param   ActivityVideoId			query	int		false	"活动视频ID"
 // @Param   Filter			query	int		false	"筛选条件 0:全部 1:视频 2:音频"
 // @Success 200 {object} models.HomeListResp
@@ -44,6 +48,9 @@ func (this *MicroRoadShowController) List() {
 	keywords := this.GetString("KeyWord")
 	audioId, _ := this.GetInt("AudioId")
 	videoId, _ := this.GetInt("VideoId")
+	audioIds := this.GetString("AudioIds")
+	videoIds := this.GetString("VideoIds")
+	activityVideoIds := this.GetString("ActivityVideoIds")
 	activityVideoId, _ := this.GetInt("ActivityVideoId")
 	filter, _ := this.GetInt("Filter", 0)
 
@@ -55,13 +62,48 @@ func (this *MicroRoadShowController) List() {
 	}
 
 	// 微路演列表
-	list, total, e := services.GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, filter, keywords)
+	list, total, e := services.GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, filter, keywords, audioIds, videoIds, activityVideoIds)
 	if e != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
 		return
 	}
-
+	for _, item := range list {
+		if item.Type == 1 {
+			//音频
+			count, err := models.GetVoiceCollectCount(user.UserId, item.Id)
+			if err != nil {
+				br.Msg = "获取数据失败!"
+				br.ErrMsg = "获取数据失败,Err:" + err.Error()
+				return
+			}
+			if count > 0 {
+				item.IsCollect = true
+			}
+		} else if item.Type == 2 {
+			//活动视频
+			count, err := models.GetActivityVideoCollectCount(user.UserId, item.Id)
+			if err != nil {
+				br.Msg = "获取数据失败!"
+				br.ErrMsg = "获取数据失败,Err:" + err.Error()
+				return
+			}
+			if count > 0 {
+				item.IsCollect = true
+			}
+		} else if item.Type == 3 {
+			//微路演视频
+			count, err := models.GetVideoCollectCount(user.UserId, item.Id)
+			if err != nil {
+				br.Msg = "获取数据失败!"
+				br.ErrMsg = "获取数据失败,Err:" + err.Error()
+				return
+			}
+			if count > 0 {
+				item.IsCollect = true
+			}
+		}
+	}
 	// 用户权限
 	authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
 	if e != nil {
@@ -238,3 +280,461 @@ func (this *MicroRoadShowController) VideoHistoryAdd() {
 	br.Msg = "操作成功"
 	return
 }
+
+// @Title 微路演新增留言
+// @Description 微路演新增留言接口
+// @Param	request	body models.AddVideoCommnetReq true "type json string"
+// @Success Ret=200 {object} models.AppointmentResp
+// @router /comment/add [post]
+func (this *MicroRoadShowController) CommentAdd() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	uid := user.UserId
+	var req models.AddVideoCommnetReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	sourceType := req.SourceType
+
+	if sourceType == 0 {
+		sourceType = 1
+	}
+	item := models.CygxArticleComment{
+		UserId:      uid,
+		CreateTime:  time.Now(),
+		RealName:    user.RealName,
+		Mobile:      user.Mobile,
+		Email:       user.Email,
+		CompanyId:   user.CompanyId,
+		CompanyName: user.CompanyName,
+		Content:     req.Content,
+		Title:       req.Title,
+	}
+	if sourceType == 1 {
+		activityVoiceInfo, _ := models.GetCygxActivityVoiceByActivityId(req.Id)
+		if activityVoiceInfo == nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(req.Id)
+			return
+		}
+		item.ActivityId = req.Id
+		item.ActivityVoiceId = activityVoiceInfo.ActivityVoiceId
+	} else if sourceType == 2 {
+		activityInfo, _ := models.GetCygxActivityVideoByActivityId(req.Id)
+		if activityInfo == nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(req.Id)
+			return
+		}
+		item.VideoId = activityInfo.VideoId
+		item.ActivityId = req.Id
+	} else if sourceType == 3 {
+		item.VideoId = req.Id
+		microVideo, e := models.GetMicroRoadshowVideoById(req.Id)
+		if e != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "微路演视频信息有误, 不存在的VideoId: " + strconv.Itoa(req.Id)
+			return
+		}
+		item.IndustryId = microVideo.IndustryId
+	}
+	_, err = models.AddArticleComment(&item)
+	if err != nil {
+		br.Msg = "提交失败"
+		br.ErrMsg = "提交留言失败,Err:" + err.Error()
+		return
+	}
+
+	services.SendWxMsgWithMicroRoadshowAsk(req, user)
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功"
+	return
+}
+
+// @Title 微路演收藏
+// @Description 微路演收藏
+// @Param	request	body models.MicroRoadshowCollectReq true "type json string"
+// @Success 200 {object} models.FontsCollectResp
+// @router /collect [post]
+func (this *MicroRoadShowController) Collect() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	uid := user.UserId
+	var req models.MicroRoadshowCollectReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.SourceType == 1 {
+		_, err := models.GetCygxActivityVoiceById(req.Id)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			return
+		}
+		count, err := models.GetVoiceCollectCount(uid, req.Id)
+		if err != nil {
+			br.Msg = "获取数据失败!"
+			br.ErrMsg = "获取数据失败,Err:" + err.Error()
+			return
+		}
+		resp := new(models.ArticleCollectResp)
+		if count <= 0 {
+			item := new(models.CygxArticleCollect)
+			item.ActivityVoiceId = req.Id
+			item.UserId = uid
+			item.CreateTime = time.Now()
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.CompanyId = user.CompanyId
+			item.CompanyName = user.CompanyName
+			item.RealName = user.RealName
+			_, err = models.AddCygxArticleCollect(item)
+			if err != nil {
+				br.Msg = "收藏失败"
+				br.ErrMsg = "收藏失败,Err:" + err.Error()
+				return
+			}
+			br.Msg = "收藏成功"
+			resp.Status = 1
+			// 文章收藏消息发送
+			//go services.ArticleUserRemind(user, detail, 2)
+		} else {
+			err = models.RemoveVoiceCollect(uid, req.Id)
+			if err != nil {
+				br.Msg = "取消收藏失败"
+				br.ErrMsg = "取消收藏失败,Err:" + err.Error()
+				return
+			}
+			br.Msg = "已取消收藏"
+			resp.Status = 2
+		}
+		collectTotal, err := models.GetVoiceCollectUsersCount(req.Id)
+		if err != nil {
+			br.Msg = "获取数据失败"
+			br.ErrMsg = "获取数据失败,Err:" + err.Error()
+			return
+		}
+		resp.CollectCount = collectTotal
+		br.Ret = 200
+		br.Success = true
+		br.Data = resp
+	} else if req.SourceType == 2 {
+		_, err := models.GetCygxActivityVideoById(req.Id)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			return
+		}
+		count, err := models.GetActivityVideoCollectCount(uid, req.Id)
+		if err != nil {
+			br.Msg = "获取数据失败!"
+			br.ErrMsg = "获取数据失败,Err:" + err.Error()
+			return
+		}
+		resp := new(models.ArticleCollectResp)
+		if count <= 0 {
+			item := new(models.CygxArticleCollect)
+			item.ActivityVideoId = req.Id
+			item.UserId = uid
+			item.CreateTime = time.Now()
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.CompanyId = user.CompanyId
+			item.CompanyName = user.CompanyName
+			item.RealName = user.RealName
+			_, err = models.AddCygxArticleCollect(item)
+			if err != nil {
+				br.Msg = "收藏失败"
+				br.ErrMsg = "收藏失败,Err:" + err.Error()
+				return
+			}
+			br.Msg = "收藏成功"
+			resp.Status = 1
+			// 文章收藏消息发送
+			//go services.ArticleUserRemind(user, detail, 2)
+		} else {
+			err = models.RemoveActivityVideoCollect(uid, req.Id)
+			if err != nil {
+				br.Msg = "取消收藏失败"
+				br.ErrMsg = "取消收藏失败,Err:" + err.Error()
+				return
+			}
+			br.Msg = "已取消收藏"
+			resp.Status = 2
+		}
+		collectTotal, err := models.GetActivityVideoCollectUsersCount(req.Id)
+		if err != nil {
+			br.Msg = "获取数据失败"
+			br.ErrMsg = "获取数据失败,Err:" + err.Error()
+			return
+		}
+		resp.CollectCount = collectTotal
+		br.Ret = 200
+		br.Success = true
+		br.Data = resp
+	} else if req.SourceType == 3 {
+		_, err := models.GetMicroRoadshowVideoById(req.Id)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			return
+		}
+		count, err := models.GetVideoCollectCount(uid, req.Id)
+		if err != nil {
+			br.Msg = "获取数据失败!"
+			br.ErrMsg = "获取数据失败,Err:" + err.Error()
+			return
+		}
+		resp := new(models.ArticleCollectResp)
+		if count <= 0 {
+			item := new(models.CygxArticleCollect)
+			item.VideoId = req.Id
+			item.UserId = uid
+			item.CreateTime = time.Now()
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.CompanyId = user.CompanyId
+			item.CompanyName = user.CompanyName
+			item.RealName = user.RealName
+			_, err = models.AddCygxArticleCollect(item)
+			if err != nil {
+				br.Msg = "收藏失败"
+				br.ErrMsg = "收藏失败,Err:" + err.Error()
+				return
+			}
+			br.Msg = "收藏成功"
+			resp.Status = 1
+			// 文章收藏消息发送
+			//go services.ArticleUserRemind(user, detail, 2)
+		} else {
+			err = models.RemoveVideoCollect(uid, req.Id)
+			if err != nil {
+				br.Msg = "取消收藏失败"
+				br.ErrMsg = "取消收藏失败,Err:" + err.Error()
+				return
+			}
+			br.Msg = "已取消收藏"
+			resp.Status = 2
+		}
+		collectTotal, err := models.GetVideoCollectUsersCount(req.Id)
+		if err != nil {
+			br.Msg = "获取数据失败"
+			br.ErrMsg = "获取数据失败,Err:" + err.Error()
+			return
+		}
+		resp.CollectCount = collectTotal
+		br.Ret = 200
+		br.Success = true
+		br.Data = resp
+	}
+}
+
+// @Title 我的收藏微路演列表
+// @Description 我的收藏微路演列表接口
+// @Param   PageSize		query	int		true	"每页数据条数"
+// @Param   CurrentIndex	query	int		true	"当前页页码,从1开始"
+// @Success 200 {object} models.HomeListResp
+// @router /mycollect [get]
+func (this *MicroRoadShowController) Mycollect() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	userId := user.UserId
+	listMycollect, err := models.GetUserMicroRoadshowCollectList(userId)
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+
+	var audioIds []string
+	var videoIds []string
+	var activityVideoIds []string
+	for _, item := range listMycollect {
+		if item.ActivityVoiceId > 0 {
+			audioIds = append(audioIds, strconv.Itoa(item.ActivityVoiceId))
+		} else if item.VideoId > 0 {
+			videoIds = append(videoIds, strconv.Itoa(item.VideoId))
+		} else if item.ActivityVideoId > 0 {
+			activityVideoIds = append(activityVideoIds, strconv.Itoa(item.ActivityVideoId))
+		}
+	}
+	if len(audioIds) == 0 && len(videoIds) == 0 && len(activityVideoIds) == 0 {
+		resp := new(models.MicroRoadShowListResp)
+		page := paging.GetPaging(currentIndex, pageSize, 0)
+		resp.List = make([]*models.MicroRoadShowPageList, 0)
+		resp.Paging = page
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+		return
+	}
+
+	audioIdstr := strings.Join(audioIds, ",")
+	ideoIdsStr := strings.Join(videoIds, ",")
+	activityVideoIdsStr := strings.Join(activityVideoIds, ",")
+	// 微路演列表
+	list, total, e := services.GetMicroRoadShowMycollect(pageSize, currentIndex, audioIdstr, ideoIdsStr, activityVideoIdsStr)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
+		return
+	}
+	for _, item := range list {
+		if item.Type == 1 {
+			//音频
+			count, err := models.GetVoiceCollectCount(user.UserId, item.Id)
+			if err != nil {
+				br.Msg = "获取数据失败!"
+				br.ErrMsg = "获取数据失败,Err:" + err.Error()
+				return
+			}
+			if count > 0 {
+				item.IsCollect = true
+			}
+		} else if item.Type == 2 {
+			//活动视频
+			count, err := models.GetActivityVideoCollectCount(user.UserId, item.Id)
+			if err != nil {
+				br.Msg = "获取数据失败!"
+				br.ErrMsg = "获取数据失败,Err:" + err.Error()
+				return
+			}
+			if count > 0 {
+				item.IsCollect = true
+			}
+		} else if item.Type == 3 {
+			//微路演视频
+			count, err := models.GetVideoCollectCount(user.UserId, item.Id)
+			if err != nil {
+				br.Msg = "获取数据失败!"
+				br.ErrMsg = "获取数据失败,Err:" + err.Error()
+				return
+			}
+			if count > 0 {
+				item.IsCollect = true
+			}
+		}
+	}
+	// 用户权限
+	authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
+		return
+	}
+
+	// 获取默认图配置
+	audioMap, videoMap, audioShareMap, videoShareMap, e := services.GetMicroRoadShowDefaultImgConfig()
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
+		return
+	}
+
+	for i := range list {
+		// 权限
+		au := new(models.UserPermissionAuthInfo)
+		au.SellerName = authInfo.SellerName
+		au.SellerMobile = authInfo.SellerMobile
+		au.HasPermission = authInfo.HasPermission
+		au.OperationMode = authInfo.OperationMode
+		if au.HasPermission == 1 {
+			// 非宏观权限进一步判断是否有权限
+			if list[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, list[i].ChartPermissionName) {
+				au.HasPermission = 2
+			}
+		}
+		// 无权限的弹框提示
+		if au.HasPermission != 1 {
+			if au.OperationMode == services.UserPermissionOperationModeCall {
+				if list[i].Type == 1 {
+					au.PopupMsg = services.UserPermissionPopupMsgCallActivity
+				} else {
+					au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
+				}
+			} else {
+				if list[i].Type == 1 {
+					au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
+				} else {
+					au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
+				}
+			}
+		}
+		list[i].AuthInfo = au
+		list[i].PublishTime = utils.StrTimeToTime(list[i].PublishTime).Format(utils.FormatDate)
+		// 默认图
+		if list[i].BackgroundImg == "" {
+			if list[i].Type == 1 {
+				list[i].BackgroundImg = audioMap[list[i].ChartPermissionId]
+			} else {
+				list[i].BackgroundImg = videoMap[list[i].ChartPermissionId]
+			}
+		}
+		// 分享图
+		if list[i].ShareImg == "" {
+			if list[i].Type == 1 {
+				list[i].ShareImg = audioShareMap[list[i].ChartPermissionId]
+			} else {
+				list[i].ShareImg = videoShareMap[list[i].ChartPermissionId]
+			}
+		}
+	}
+
+	resp := new(models.MicroRoadShowListResp)
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp.List = list
+	resp.Paging = page
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 1 - 0
controllers/report.go

@@ -3217,6 +3217,7 @@ func (this *ReportController) CommentAdd() {
 		CompanyId:   user.CompanyId,
 		CompanyName: companyDetail.CompanyName,
 		Content:     content,
+		Title:       articleInfo.Title,
 	}
 	_, err = models.AddArticleComment(&item)
 	if err != nil {

+ 154 - 11
controllers/user.go

@@ -257,25 +257,59 @@ func (this *UserController) Detail() {
 			if companyItem != nil && companyItem.CompanyId > 0 {
 				detail.CompanyName = companyItem.CompanyName
 				//if companyItem.Status == "试用" || companyItem.Status == "永续" || companyItem.Status == "正式" {
-				permissionStr, err := models.GetCompanyPermissionByUser(companyItem.CompanyId)
+				//permissionStr, err := models.GetCompanyPermissionByUser(companyItem.CompanyId)
+				//if err != nil {
+				//	br.Msg = "获取信息失败"
+				//	br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+				//	return
+				//}
+				var permissionStr string
+				permissionList, err := models.GetCompanyPermissionList(companyItem.CompanyId)
 				if err != nil {
 					br.Msg = "获取信息失败"
 					br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
 					return
 				}
-				permissionStrOld, err := models.GetCompanyPermission(companyItem.CompanyId)
-				if err != nil {
-					br.Msg = "获取信息失败"
-					br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
-					return
+
+				mapIsUpgrade := make(map[string]string)
+				mapZhukKeGuan := make(map[string]int)
+				for _, v := range permissionList {
+					mapZhukKeGuan[v.PermissionName] += 1
+					if v.IsUpgrade == 1 {
+						mapIsUpgrade[v.PermissionName] = v.PermissionName + "(升级)"
+					}
 				}
-				permissionStrListOld := strings.Split(permissionStrOld, ",")
-				for _, v := range permissionStrListOld {
-					if strings.Count(permissionStr, v) > 1 {
-						permissionStr = strings.Replace(permissionStr, v+"(主观)", v, -1)
-						permissionStr = strings.Replace(permissionStr, v+"(客观),", "", -1)
+				mapPermissionName := make(map[string]string)
+				//处理升级,并且合并主客观
+				for _, v := range permissionList {
+					if _, ok := mapPermissionName[v.PermissionName]; ok {
+						continue
 					}
+					if _, ok := mapIsUpgrade[v.PermissionName]; ok {
+						permissionStr += mapIsUpgrade[v.PermissionName] + ","
+					} else {
+						if mapZhukKeGuan[v.PermissionName] == 1 {
+							permissionStr += v.Remark + ","
+						} else {
+							permissionStr += v.PermissionName + ","
+						}
+					}
+					mapPermissionName[v.PermissionName] = v.PermissionName
 				}
+				permissionStr = strings.TrimRight(permissionStr, ",")
+				//permissionStrOld, err := models.GetCompanyPermission(companyItem.CompanyId)
+				//if err != nil {
+				//	br.Msg = "获取信息失败"
+				//	br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+				//	return
+				//}
+				//permissionStrListOld := strings.Split(permissionStrOld, ",")
+				//for _, v := range permissionStrListOld {
+				//	if strings.Count(permissionStr, v) > 1 {
+				//		permissionStr = strings.Replace(permissionStr, v+"(主观)", v, -1)
+				//		permissionStr = strings.Replace(permissionStr, v+"(客观),", "", -1)
+				//	}
+				//}
 
 				detail.PermissionName = permissionStr
 				//} else {
@@ -294,6 +328,14 @@ func (this *UserController) Detail() {
 				}
 				detail.ScheduleNum += tatolSpecil
 
+				microRoadshowCollectcount, err := models.GetUserMicroRoadshowCollectcount(user.UserId)
+				if err != nil {
+					br.Msg = "获取信息失败"
+					br.ErrMsg = "获取微路演收藏信息失败,GetUserMicroRoadshowCollectcount Err:" + err.Error()
+					return
+				}
+				detail.ConNum += microRoadshowCollectcount
+
 			} else {
 				hasPermission = 1
 			}
@@ -1543,3 +1585,104 @@ func (this *UserCommonController) LoginPublic() {
 	br.Data = resp
 	br.Msg = "登录成功"
 }
+
+// @Title 获取我的留言
+// @Description 获取我的留言列表
+// @Success 200 {object} models.CygxCommentListResp
+// @router /comment/list [get]
+func (this *UserController) CommnetList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+
+	userId := this.User.UserId
+	commentlist, err := models.GetCommentList(userId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取我的留言列表失败,Err:" + err.Error()
+		return
+	}
+
+	resp := new(models.CygxCommentListResp)
+
+	for _, comment := range commentlist {
+		item := models.CygxArticleCommentResp{
+			Id:          comment.Id,
+			UserId:      comment.UserId,
+			ArticleId:   comment.ArticleId,
+			IndustryId:  comment.IndustryId,
+			ActivityId:  comment.ActivityId,
+			CreateTime:  comment.CreateTime,
+			Mobile:      comment.Mobile,
+			Email:       comment.Email,
+			CompanyId:   comment.CompanyId,
+			CompanyName: comment.CompanyName,
+			Content:     comment.Content,
+			Title:       comment.Title,
+		}
+		if comment.ArticleId > 0 {
+			item.RedirectType = 1
+		} else if comment.IndustryId > 0 {
+			item.RedirectType = 3
+		} else if comment.ActivityId > 0 {
+			item.RedirectType = 2
+		}
+		resp.List = append(resp.List, &item)
+	}
+
+	br.Msg = "获取成功!"
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+}
+
+// @Title 获取我的收藏
+// @Description 获取我的收藏列表
+// @Success 200 {object} models.ArticleCollectListResp
+// @router /collect/list/microRoadshow [get]
+func (this *UserController) MicroRoadshowCollectList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	userId := this.User.UserId
+
+	list, err := models.GetUserMicroRoadshowCollectList(userId)
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+
+	resp := new(models.MicroRoadshowCollectList)
+	var audioIds []string
+	var videoIds []string
+	var activityVideoIds []string
+	for _, item := range list {
+		if item.ActivityVoiceId > 0 {
+			audioIds = append(audioIds, strconv.Itoa(item.ActivityVoiceId))
+		} else if item.VideoId > 0 {
+			videoIds = append(videoIds, strconv.Itoa(item.VideoId))
+		} else if item.ActivityVideoId > 0 {
+			activityVideoIds = append(activityVideoIds, strconv.Itoa(item.ActivityVideoId))
+		}
+	}
+	resp.AudioIds = strings.Join(audioIds, ",")
+	resp.VideoIds = strings.Join(videoIds, ",")
+	resp.ActivityVideoIds = strings.Join(activityVideoIds, ",")
+
+	br.Msg = "获取成功!"
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+}

+ 45 - 2
models/activity.go

@@ -191,6 +191,7 @@ type ActivityDetail struct {
 	VisibleRange            int                        `description:"可见范围 1,仅本组可见 、2,全部客户可见"`
 	VideoDetail             *CygxActivityVideoListResp `description:"视频数据"`
 	FileType                int                        `description:"类型: 1-音频; 2-视频"`
+	IsCollect               bool                       `description:"是否收藏"`
 	SourceType              int                        `description:"活动来源。 1:活动 、2:专项产业调研"`
 	TripImgLink             string                     `description:"专项产业调研行程链接"`
 	ActivityTimeEnd         string                     `description:"专项产业调研活动预期结束时间"`
@@ -688,7 +689,7 @@ type CygxActivityLabelList struct {
 	Resource          int    `description:"位置 ,1:活动 ,2:专项产业调研"`
 	TemporaryLabel    string `description:"临时标签"`
 	IsNew             bool   `description:"是否为新:活动存在关联的的产业所关联的报告均在3个月内/无报告则标记新"`
-	YidongActivityId   int   `description:"易董活动ID"`
+	YidongActivityId  int    `description:"易董活动ID"`
 	IsExternalLabel   bool   `description:"是否为外部资源"`
 }
 
@@ -1014,7 +1015,7 @@ func GetActivitySpecialSearcheList(condition string, pars []interface{}, conditi
 }
 
 //列表
-func GetActivityListNew(condition string, pars []interface{}, uid, startSize, pageSize, playBack, filter int) (items []*ActivityDetail, err error) {
+func GetActivityListNew(condition string, pars []interface{}, uid, startSize, pageSize, playBack, filter int, typeName string) (items []*ActivityDetail, err error) {
 	var sqlJiontable string
 	if playBack == 1 {
 		//sqlJiontable = ` INNER JOIN cygx_activity_voice AS ac ON ac.activity_id = art.activity_id `
@@ -1038,6 +1039,48 @@ func GetActivityListNew(condition string, pars []interface{}, uid, startSize, pa
 		sql += condition
 	}
 	sql += ` LIMIT ?,?`
+
+	if typeName != "" {
+		typeSlice := strings.Split(typeName, ",")
+		tempCondition := ""
+		for _, s := range typeSlice {
+			if s == "1" {
+				tempCondition += "'专家电话会',"
+			} else if s == "2" {
+				tempCondition += "'分析师电话会',"
+			} else if s == "1,2" {
+				tempCondition += "'专家电话会','分析师电话会',"
+			}
+		}
+		tempCondition = strings.TrimRight(tempCondition, ",")
+		sql = `SELECT * FROM(` + sql + `) AS t WHERE t.activity_type_name IN (` + tempCondition + `)`
+	}
 	_, err = o.Raw(sql, pars, uid, uid, uid, startSize, pageSize).QueryRows(&items)
 	return
 }
+
+//主题列表
+func GetActivityLabelListAllNoLimit(condition, sortTime string, pars []interface{}, conditionSpecial string) (items []*CygxActivityLabelList, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT	activity_id, label,temporary_label,is_show_subject_name, art.activity_time,	1 AS resource, yidong_activity_id 
+		FROM cygx_activity as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += `  UNION ALL `
+	sql += ` SELECT
+			art.activity_id,
+			art.label,
+			art.temporary_label,
+			is_show_subject_name,
+			art.activity_time,
+			2 AS resource,
+			'' AS yidong_activity_id 
+		FROM
+			cygx_activity_special AS art   WHERE 1= 1 ` + conditionSpecial
+
+	sql += ` GROUP BY label,resource  ORDER BY ` + sortTime + ` , activity_id DESC `
+
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 13 - 4
models/activity_voice.go

@@ -20,10 +20,11 @@ type CygxActivityVoice struct {
 
 // ActivityVoiceReq 音频数据
 type CygxActivityVoiceReq struct {
-	ActivityId  int    ` description:"活动ID"`
-	Url         string `description:"音频资源url地址"`
-	Name        string `description:"音频名称"`
-	PlaySeconds int    `description:"音频时长"`
+	ActivityId      int    ` description:"活动ID"`
+	ActivityVoiceId int    ` description:"音频ID"`
+	Url             string `description:"音频资源url地址"`
+	Name            string `description:"音频名称"`
+	PlaySeconds     int    `description:"音频时长"`
 }
 
 // GetCygxActivityVoiceReqList 获取活动ID的音频
@@ -36,6 +37,7 @@ func GetCygxActivityVoiceReqList(activityIds []int) (items []*CygxActivityVoiceR
 	//endTime := time.Now().AddDate(0, 0, -30).Format("2006-01-02 15:04:05")
 	sql := `SELECT
 			v.activity_id,
+			v.activity_voice_id,
 			v.voice_url AS url,
 			v.voice_name AS name,
 			v.voice_play_seconds AS play_seconds 
@@ -74,3 +76,10 @@ func GetActivityVoiceListAll(condition string, pars []interface{}, startSize, pa
 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
 	return
 }
+
+// GetCygxActivityVoiceByActivityId 主键获取活动音频
+func GetCygxActivityVoiceByActivityId(activityId int) (item *CygxActivityVoice, err error) {
+	sql := `SELECT * FROM cygx_activity_voice WHERE activity_id = ? LIMIT 1`
+	err = orm.NewOrm().Raw(sql, activityId).QueryRow(&item)
+	return
+}

+ 8 - 0
models/article.go

@@ -282,6 +282,14 @@ func GetArticleAll2() (item []*ArticleDetail, err error) {
 	return
 }
 
+//获取文章列表
+func GetArticleList(condition string, pars []interface{}) (items []*ArticleDetail, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT	article_id FROM cygx_article  WHERE 1= 1 ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
 func ModifyArticleContent(articleId int, content, expertNumStr, expertContentStr, interviewDateStr string) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE cygx_article SET body=?,expert_background=?,expert_number=?,interview_date=? WHERE article_id=? `

+ 104 - 9
models/article_collect.go

@@ -7,15 +7,18 @@ import (
 )
 
 type CygxArticleCollect struct {
-	Id          int `orm:"column(id);pk"`
-	ArticleId   int
-	UserId      int
-	CreateTime  time.Time
-	Mobile      string `description:"手机号"`
-	Email       string `description:"邮箱"`
-	CompanyId   int    `description:"公司id"`
-	CompanyName string `description:"公司名称"`
-	RealName    string `description:"用户实际名称"`
+	Id              int `orm:"column(id);pk"`
+	ArticleId       int
+	ActivityVoiceId int
+	ActivityVideoId int
+	VideoId         int
+	UserId          int
+	CreateTime      time.Time
+	Mobile          string `description:"手机号"`
+	Email           string `description:"邮箱"`
+	CompanyId       int    `description:"公司id"`
+	CompanyName     string `description:"公司名称"`
+	RealName        string `description:"用户实际名称"`
 }
 
 //添加收藏信息
@@ -149,3 +152,95 @@ func GetArticleCollectNum(articleId []string, uid int) (items []*CygxArticleNum,
 	_, err = o.Raw(sql, uid, articleId).QueryRows(&items)
 	return
 }
+
+type MicroRoadshowCollectList struct {
+	AudioIds         string
+	VideoIds         string
+	ActivityVideoIds string
+}
+
+func GetVideoCollectCount(userId, videoId int) (count int, err error) {
+	sql := `SELECT COUNT(1) AS count FROM cygx_article_collect WHERE user_id=? AND video_id=? `
+	err = orm.NewOrm().Raw(sql, userId, videoId).QueryRow(&count)
+	return
+}
+
+func RemoveVideoCollect(userId, videoId int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE FROM cygx_article_collect WHERE user_id=? AND video_id=? `
+	_, err = o.Raw(sql, userId, videoId).Exec()
+	return
+}
+
+func GetVideoCollectUsersCount(videoId int) (count int, err error) {
+	sql := `SELECT COUNT(user_id) AS count FROM cygx_article_collect WHERE video_id=? `
+	err = orm.NewOrm().Raw(sql, videoId).QueryRow(&count)
+	return
+}
+
+func GetVoiceCollectCount(userId, voiceId int) (count int, err error) {
+	sql := `SELECT COUNT(1) AS count FROM cygx_article_collect WHERE user_id=? AND activity_voice_id=? `
+	err = orm.NewOrm().Raw(sql, userId, voiceId).QueryRow(&count)
+	return
+}
+
+func RemoveVoiceCollect(userId, voiceId int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE FROM cygx_article_collect WHERE user_id=? AND activity_voice_id=? `
+	_, err = o.Raw(sql, userId, voiceId).Exec()
+	return
+}
+
+func GetVoiceCollectUsersCount(voiceId int) (count int, err error) {
+	sql := `SELECT COUNT(user_id) AS count FROM cygx_article_collect WHERE activity_voice_id=? `
+	err = orm.NewOrm().Raw(sql, voiceId).QueryRow(&count)
+	return
+}
+
+func GetActivityVideoCollectCount(userId, activityVideoId int) (count int, err error) {
+	sql := `SELECT COUNT(1) AS count FROM cygx_article_collect WHERE user_id=? AND activity_video_id=? `
+	err = orm.NewOrm().Raw(sql, userId, activityVideoId).QueryRow(&count)
+	return
+}
+
+func RemoveActivityVideoCollect(userId, activityVideoId int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE FROM cygx_article_collect WHERE user_id=? AND activity_video_id=? `
+	_, err = o.Raw(sql, userId, activityVideoId).Exec()
+	return
+}
+
+func GetActivityVideoCollectUsersCount(videoId int) (count int, err error) {
+	sql := `SELECT COUNT(user_id) AS count FROM cygx_article_collect WHERE activity_video_id=? `
+	err = orm.NewOrm().Raw(sql, videoId).QueryRow(&count)
+	return
+}
+
+func GetActivityVoiceCollectCount(userId, activityId int) (count int, err error) {
+	sql := `SELECT
+	COUNT( 1 ) AS count 
+FROM
+	cygx_article_collect AS c
+	INNER JOIN cygx_activity_voice AS vc 
+WHERE
+	c.user_id =? 
+	AND vc.activity_id =? 
+	AND c.activity_voice_id = vc.activity_voice_id`
+	err = orm.NewOrm().Raw(sql, userId, activityId,).QueryRow(&count)
+
+	return
+}
+
+func GetActivityVideoCollectCountByActivityId(userId, activityId int) (count int, err error) {
+	sql := `SELECT
+	COUNT( 1 ) AS count 
+FROM
+	cygx_article_collect AS c
+	INNER JOIN cygx_activity_video AS vd 
+WHERE
+	c.user_id =? 
+	AND vd.activity_id =? 
+	AND c.activity_video_id = vd.video_id`
+	err = orm.NewOrm().Raw(sql, userId, activityId,).QueryRow(&count)
+	return
+}

+ 50 - 12
models/article_comment.go

@@ -6,18 +6,23 @@ import (
 )
 
 type CygxArticleComment struct {
-	Id       int       `orm:"column(id);pk" description:"留言id"`
-	UserId      int       `description:"用户id"`
-	ArticleId  int       `description:"活动id"`
-	CreateTime  time.Time `description:"创建时间"`
-	Mobile      string    `description:"手机号"`
-	Email       string    `description:"邮箱"`
-	CompanyId   int       `description:"公司id"`
-	CompanyName string    `description:"公司名称"`
-	Content     string    `description:"内容"`
+	Id              int       `orm:"column(id);pk" description:"留言id"`
+	UserId          int       `description:"用户id"`
+	RealName        string    `description:"用户姓名"`
+	ArticleId       int       `description:"文章id"`
+	ActivityId      int       `description:"活动id"`
+	VideoId         int       `description:"视频id"`
+	ActivityVoiceId int       `description:"活动音频ID"`
+	IndustryId      int       `description:"产业id"`
+	CreateTime      time.Time `description:"创建时间"`
+	Mobile          string    `description:"手机号"`
+	Email           string    `description:"邮箱"`
+	CompanyId       int       `description:"公司id"`
+	CompanyName     string    `description:"公司名称"`
+	Content         string    `description:"内容"`
+	Title           string    `description:"标题"`
 }
 
-
 //添加留言
 func AddArticleComment(item *CygxArticleComment) (lastId int64, err error) {
 	o := orm.NewOrm()
@@ -25,8 +30,41 @@ func AddArticleComment(item *CygxArticleComment) (lastId int64, err error) {
 	return
 }
 
-
 type AddCygxArticleCommentReq struct {
 	ArticleId int    `description:"文章id"`
-	Content    string `description:"内容"`
+	Content   string `description:"内容"`
+}
+
+//我的留言列表
+func GetCommentList(userId int) (items []*CygxArticleComment, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			* 
+		FROM
+			cygx_article_comment AS c
+		WHERE
+			user_id = ? ORDER BY c.create_time DESC`
+
+	_, err = o.Raw(sql, userId).QueryRows(&items)
+	return
+}
+
+type CygxArticleCommentResp struct {
+	Id           int       `orm:"column(id);pk" description:"留言id"`
+	UserId       int       `description:"用户id"`
+	ArticleId    int       `description:"文章id"`
+	IndustryId   int       `description:"产业id"`
+	ActivityId   int       `description:"活动id"`
+	CreateTime   time.Time `description:"创建时间"`
+	Mobile       string    `description:"手机号"`
+	Email        string    `description:"邮箱"`
+	CompanyId    int       `description:"公司id"`
+	CompanyName  string    `description:"公司名称"`
+	Content      string    `description:"内容"`
+	Title        string    `description:"标题"`
+	RedirectType int       `description:"跳转类型 1文章 2活动 3产业资源包"`
+}
+
+type CygxCommentListResp struct {
+	List []*CygxArticleCommentResp
 }

+ 22 - 0
models/company.go

@@ -106,6 +106,28 @@ func GetCompanyPermissionByUser(companyId int) (permission string, err error) {
 	return
 }
 
+type PermissionItem struct {
+	ChartPermissionId int    `description:"权限id"`
+	PermissionName    string `description:"权限名称"`
+	IsUpgrade         int    `description:"是否升级,1是,0否"`
+	Remark            string `description:"备注区分主观客观"`
+}
+
+func GetCompanyPermissionList(companyId int) (items []*PermissionItem, err error) {
+	sql := ` SELECT b.chart_permission_id,b.permission_name,b.remark,a.is_upgrade
+			FROM company_report_permission AS a
+			INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
+			INNER JOIN company_product AS c ON a.company_id=c.company_id AND a.product_id=c.product_id
+			WHERE  a.company_id=?
+			AND c.is_suspend=0
+            AND b.cygx_auth=1
+			AND c.status IN('正式','试用','永续')
+			AND a.status IN('正式','试用','永续')   ORDER BY b.sort ASC `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, companyId).QueryRows(&items)
+	return
+}
+
 //获取用户权限不限制状态
 func GetCompanyPermissionByUserNoStatus(companyId int) (permission string, err error) {
 	sql := ` SELECT GROUP_CONCAT(DISTINCT b.remark  ORDER BY b.sort ASC  SEPARATOR ',') AS permission

+ 15 - 0
models/industrial_article_group_management.go

@@ -63,3 +63,18 @@ func GetIndustryArticleMinMaxPublishTime(condition string, pars []interface{}) (
 	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
 	return
 }
+
+// GetIndustrialArticleGroupManagementList  查询产业
+func GetIndustrialArticleGroupManagementList(condition string, pars []interface{}) (list []*CygxIndustrialArticleGroupManagement, err error) {
+	sql := `SELECT
+				*
+			FROM
+				cygx_industrial_article_group_management AS a
+			WHERE
+				1 = 1 `
+	if condition != `` {
+		sql += condition
+	}
+	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
+	return
+}

+ 16 - 3
models/micro_roadshow.go

@@ -27,6 +27,7 @@ type MicroRoadShowPageList struct {
 	IndustryName        string `description:"产业名称"`
 	PlaySeconds         string `description:"音视频时长"`
 	ActivityId          int    `description:"活动ID"`
+	IsCollect           bool   `description:"是否收藏"`
 	AuthInfo            *UserPermissionAuthInfo
 }
 
@@ -34,7 +35,7 @@ type MicroRoadShowPageList struct {
 func GetMicroRoadShowVideoPageListV8(startSize, pageSize int, condition string, pars []interface{}, conditionAct string, parsAct []interface{}, conditionAudio string, parsAudio []interface{}, audioId, videoId, activityVideoId, filter int) (total int, list []*MicroRoadShowPageList, err error) {
 	o := orm.NewOrm()
 	var sql string
-	if audioId+activityVideoId == 0 && filter != 2{
+	if audioId+activityVideoId == 0 && filter != 2 {
 		sql += `SELECT
 			video_id AS id,
 			video_name AS title,
@@ -60,7 +61,7 @@ func GetMicroRoadShowVideoPageListV8(startSize, pageSize int, condition string,
 		sql += `  UNION ALL `
 	}
 
-	if audioId+videoId == 0 && filter != 2{
+	if audioId+videoId == 0 && filter != 2 {
 		sql += `
 		SELECT
 			video_id AS id,
@@ -303,4 +304,16 @@ func GetMicroRoadshowVideoByIndustryId(industryId int) (item *MicroRoadshowVideo
 	sql := `SELECT * FROM cygx_micro_roadshow_video WHERE industry_id = ? and publish_status = 1`
 	err = orm.NewOrm().Raw(sql, industryId).QueryRow(&item)
 	return
-}
+}
+
+type AddVideoCommnetReq struct {
+	Id         int    `description:"活动或产业ID"`
+	SourceType int    `description:"视频来源: 1-音频; 2-活动视频; 3-微路演视频 (不传默认为1)"`
+	Content    string `description:"内容"`
+	Title      string `description:"标题"`
+}
+
+type MicroRoadshowCollectReq struct {
+	Id         int `description:"音频或视频ID"`
+	SourceType int `description:"视频来源: 1-音频; 2-活动视频; 3-微路演视频 (不传默认为1)"`
+}

+ 1 - 1
models/page_history_record.go

@@ -16,7 +16,7 @@ type CygxPageHistoryRecord struct {
 	DetailId               string    `description:"详情ID"`
 	ChartPermissionId      int       `description:"行业ID"`
 	IndustrialManagementId string    `description:"产业ID"`
-	PageType               string    `description:"页面类型,纪要:Summary,纪要搜索:SummarySearch,报告:Report,报告搜索:ReportSearch,产业列表:IndustryList,活动:Activit,活动搜索:ActivitSearch,活动详情:ActivitParticulars,报告详情:ReportParticulars"`
+	PageType               string    `description:"页面类型,纪要:Summary,纪要搜索:SummarySearch,报告:Report,报告搜索:ReportSearch,产业列表:IndustryList,活动:Activit,活动搜索:ActivitSearch,活动详情:ActivitParticulars,报告详情:ReportParticulars,已结束活动:OverActivity"`
 }
 
 type CygxPageHistoryRecordRep struct {

+ 19 - 0
models/user.go

@@ -472,3 +472,22 @@ type UserPermissionAuthInfo struct {
 	OperationMode string `description:"操作方式:Apply-立即申请; Call-拨号"`
 	PopupMsg      string `description:"权限弹窗信息"`
 }
+
+func GetUserMicroRoadshowCollectList(userId int) (items []*CygxArticleCollect, err error) {
+	sql := `SELECT a.* FROM cygx_article_collect AS a 
+			WHERE a.user_id=?  
+			AND a.article_id =0 
+           ORDER BY a.create_time DESC `
+	_, err = orm.NewOrm().Raw(sql, userId).QueryRows(&items)
+	return
+}
+
+func GetUserMicroRoadshowCollectcount(userId int) (count int, err error) {
+	sqlCount := `SELECT  COUNT(1) AS count FROM cygx_article_collect AS a 
+			WHERE a.user_id=?  
+			AND a.article_id =0 
+           ORDER BY a.create_time DESC `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, userId).QueryRow(&count)
+	return
+}

+ 54 - 0
routers/commentsRouter.go

@@ -151,6 +151,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: "OverActivityList",
+            Router: `/overActivityList`,
+            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: "ScheduleList",
@@ -673,6 +682,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:MicroRoadShowController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:MicroRoadShowController"],
+        beego.ControllerComments{
+            Method: "Collect",
+            Router: `/collect`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:MicroRoadShowController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:MicroRoadShowController"],
+        beego.ControllerComments{
+            Method: "CommentAdd",
+            Router: `/comment/add`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:MicroRoadShowController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:MicroRoadShowController"],
         beego.ControllerComments{
             Method: "List",
@@ -682,6 +709,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:MicroRoadShowController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:MicroRoadShowController"],
+        beego.ControllerComments{
+            Method: "Mycollect",
+            Router: `/mycollect`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:MicroRoadShowController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:MicroRoadShowController"],
         beego.ControllerComments{
             Method: "VideoHistoryAdd",
@@ -1132,6 +1168,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"],
+        beego.ControllerComments{
+            Method: "MicroRoadshowCollectList",
+            Router: `/collect/list/microRoadshow`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"],
+        beego.ControllerComments{
+            Method: "CommnetList",
+            Router: `/comment/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"],
         beego.ControllerComments{
             Method: "AddCountryCcode",

+ 65 - 35
services/activity.go

@@ -588,6 +588,27 @@ func GetActivityonditionList(user *models.WxUserItem, activityTypeId, chartPermi
 		} else if whichDay == "2" {
 			startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
 			endDate = startDate
+		} else if whichDay == "3" {
+			startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
+		} else if whichDay == "4" {
+			startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetLastWeekSunday().Format(utils.FormatDate)
+		} else if whichDay == "5" {
+			startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate)
+			endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
+		} else if whichDay == "6" {
+			startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
+			endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate)
+		} else if whichDay == "1,2" {
+			startDate = time.Now().Format(utils.FormatDate)
+			endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
+		} else if whichDay == "3,4" {
+			startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
+		} else if whichDay == "5,6" {
+			startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
+			endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
 		} else {
 			startDate = time.Now().Format(utils.FormatDate)
 			endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
@@ -1535,45 +1556,54 @@ func ActivityButtonShow(item *models.ActivityDetail) (articleDetail *models.Acti
 func GetActivityNewLabelMap(activityIds []int) (labelMap map[int]bool, industryNewMap map[int]bool, err error) {
 	labelMap = make(map[int]bool, 0)
 	industryNewMap = make(map[int]bool, 0)
-	if len(activityIds) == 0 {
-		return
-	}
-
-	// 获取活动关联的产业
-	var groupCond string
-	var groupPars []interface{}
-	groupCond += ` AND a.activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `)`
-	groupPars = append(groupPars, activityIds)
-	groups, e := models.GetActivityIndustryRelationList(groupCond, groupPars)
-	if e != nil {
-		err = errors.New("获取活动产业关联列表失败, Err: " + e.Error())
-		return
-	}
-	activityIndustryMap := make(map[int][]int, 0)
-	industryIds := make([]int, 0)
-	for i := range groups {
-		industryIds = append(industryIds, groups[i].IndustrialManagementId)
-		activityIndustryMap[groups[i].ActivityId] = append(activityIndustryMap[groups[i].ActivityId], groups[i].IndustrialManagementId)
-	}
-
-	// 获取新产业Map
-	industryLabelMap, e := GetIndustryNewLabelMap(industryIds)
+	//if len(activityIds) == 0 {
+	//	return
+	//}
+	//
+	//// 获取活动关联的产业
+	//var groupCond string
+	//var groupPars []interface{}
+	//groupCond += ` AND a.activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `) AND b.source = 1 `
+	//groupPars = append(groupPars, activityIds)
+	//groups, e := models.GetActivityIndustryRelationList(groupCond, groupPars)
+	//if e != nil {
+	//	err = errors.New("获取活动产业关联列表失败, Err: " + e.Error())
+	//	return
+	//}
+	//activityIndustryMap := make(map[int][]int, 0)
+	//industryIds := make([]int, 0)
+	//for i := range groups {
+	//	industryIds = append(industryIds, groups[i].IndustrialManagementId)
+	//	activityIndustryMap[groups[i].ActivityId] = append(activityIndustryMap[groups[i].ActivityId], groups[i].IndustrialManagementId)
+	//}
+	//
+	//// 获取新产业Map
+	//industryLabelMap, e := GetIndustryNewLabelMap(industryIds)
+	//if e != nil {
+	//	err = errors.New("获取产业新标签Map失败, Err: " + e.Error())
+	//	return
+	//}
+	//
+	//// 判断活动是否为新
+	//for k := range industryLabelMap {
+	//	for k2, v2 := range activityIndustryMap {
+	//		if labelMap[k2] {
+	//			continue
+	//		}
+	//		// 活动的产业ID中存在一个新产业即为新活动
+	//		if utils.InArrayByInt(v2, k) {
+	//			labelMap[k2] = true
+	//		}
+	//	}
+	//}
+	//产业关联的弘则报告发布日期在三个月以内的活动、产业显示 NEW标签
+	articNewLabel, e := GetArticNewLabelWhithActivity3Month()
 	if e != nil {
 		err = errors.New("获取产业新标签Map失败, Err: " + e.Error())
 		return
 	}
-
-	// 判断活动是否为新
-	for k := range industryLabelMap {
-		for k2, v2 := range activityIndustryMap {
-			if labelMap[k2] {
-				continue
-			}
-			// 活动的产业ID中存在一个新产业即为新活动
-			if utils.InArrayByInt(v2, k) {
-				labelMap[k2] = true
-			}
-		}
+	for k := range articNewLabel {
+		labelMap[k] = true
 	}
 
 	return

+ 53 - 0
services/article.go

@@ -1588,3 +1588,56 @@ func GetSpecialArticleDetailUserPower(user *models.WxUserItem, articleInfo *mode
 	}
 	return
 }
+
+//func init() {
+//	GetArticNewLabelWhithActivity3Month()
+//}
+
+//弘则报告发布日期在三个月以内的
+func GetArticNewLabelWhithActivity3Month() (labelMap map[int]bool, err error) {
+	var condition string
+	var pars []interface{}
+	condition += ` AND publish_date  >= ?  AND article_id < ? `
+	pars = append(pars, time.Now().AddDate(0, -3, 0), utils.SummaryArticleId)
+	articleList, e := models.GetArticleList(condition, pars)
+	if e != nil {
+		err = errors.New("GetArticleList, Err: " + e.Error())
+		return
+	}
+	var articleIds []int
+	for _, v := range articleList {
+		articleIds = append(articleIds, v.ArticleId)
+	}
+	if len(articleIds) == 0 {
+		return
+	}
+
+	pars = make([]interface{}, 0)
+	condition = ` AND article_id IN (` + utils.GetOrmInReplace(len(articleIds)) + `)`
+	pars = append(pars, articleIds)
+	industrialList, e := models.GetIndustrialArticleGroupManagementList(condition, pars)
+	if e != nil {
+		err = errors.New("GetIndustrialArticleGroupManagementList, Err: " + e.Error())
+		return
+	}
+	labelMap = make(map[int]bool, 0)
+	var industrialIds []int
+	for _, v := range industrialList {
+		industrialIds = append(industrialIds, v.IndustrialManagementId)
+	}
+
+	// 获取活动关联的产业
+	var groupCond string
+	var groupPars []interface{}
+	groupCond += ` AND b.industrial_management_id IN (` + utils.GetOrmInReplace(len(industrialIds)) + `)  AND b.source = 1  `
+	groupPars = append(groupPars, industrialIds)
+	groups, e := models.GetActivityIndustryRelationList(groupCond, groupPars)
+	if e != nil {
+		err = errors.New("获取活动产业关联列表失败, Err: " + e.Error())
+		return
+	}
+	for _, v := range groups {
+		labelMap[v.ActivityId] = true
+	}
+	return
+}

+ 5 - 1
services/industrial_management.go

@@ -233,6 +233,10 @@ func GetIndustryNewLabelMap(industryIds []int) (labelMap map[int]bool, err error
 		timeCond += ` AND a.industrial_management_id IN (` + utils.GetOrmInReplace(industryIdLen) + `)`
 		timePars = append(timePars, industryIds)
 	}
+	//只要弘则报告,不要研选报告
+	timeCond += ` AND b.article_id < ? `
+	timePars = append(timePars, utils.SummaryArticleId)
+
 	industryTimeList, e := models.GetIndustryArticleMinMaxPublishTime(timeCond, timePars)
 	if e != nil {
 		err = errors.New("获取产业文章最大最小发布时间失败, Err: " + e.Error())
@@ -261,4 +265,4 @@ func GetIndustryNewLabelMap(industryIds []int) (labelMap map[int]bool, err error
 		}
 	}
 	return
-}
+}

+ 93 - 3
services/micro_roadshow.go

@@ -6,6 +6,7 @@ import (
 	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
+	"strings"
 )
 
 // GetMicroRoadShowDefaultImgConfig 获取微路演默认图/分享图配置
@@ -163,7 +164,7 @@ func GetHomeNewestList(userId, companyId, startSize, pageSize int, condition str
 }
 
 // GetMicroRoadShowPageList 获取微路演列表添加活动视频 更新与8.1版本
-func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, filter int, keywords string) (respList []*models.MicroRoadShowPageList, total int, err error) {
+func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, filter int, keywords, audioIds, videoIds, activityVideoIds string) (respList []*models.MicroRoadShowPageList, total int, err error) {
 	var e error
 	// 根据每页数据量获取音视频配比
 	startSize := utils.StartIndex(currentIndex, pageSize)
@@ -177,7 +178,7 @@ func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activi
 	var audioPars []interface{}
 	// 如果筛选条件为指定视频ID或只看视频则不做音频查询
 	fmt.Println("filter:", filter)
-	if videoId > 0 || activityVideoId > 0 || filter == 1{
+	if videoId > 0 || activityVideoId > 0 || filter == 1 {
 		fmt.Println("11111")
 		audioCond = ""
 	} else {
@@ -195,13 +196,22 @@ func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activi
 			audioCond += ` AND a.activity_voice_id = ?`
 			audioPars = append(audioPars, audioId)
 		}
+		if audioIds != "" {
+			sliceId := strings.Split(audioIds, ",")
+			var idSqlStr string
+			for _, v := range sliceId {
+				idSqlStr += "'" + v + "',"
+			}
+			idSqlStr = strings.TrimRight(idSqlStr, ",")
+			audioCond += ` AND a.activity_voice_id IN (` + idSqlStr + `)`
+		}
 	}
 	//视频的处理
 	var videoCond string
 	var videoCondAct string
 	var videoPars []interface{}
 	var videoParsAct []interface{}
-	if audioId > 0 || filter == 2{
+	if audioId > 0 || filter == 2 {
 		fmt.Println("22222")
 		videoCond = ""
 	} else {
@@ -219,6 +229,15 @@ func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activi
 			videoCondAct += ` AND video_id = ?`
 			videoParsAct = append(videoParsAct, activityVideoId)
 		}
+		if activityVideoIds != "" {
+			sliceId := strings.Split(activityVideoIds, ",")
+			var idSqlStr string
+			for _, v := range sliceId {
+				idSqlStr += "'" + v + "',"
+			}
+			idSqlStr = strings.TrimRight(idSqlStr, ",")
+			videoCondAct += ` AND v.video_id IN (` + idSqlStr + `)`
+		}
 
 		//如果传了路演的或者活动的视频ID只查询一个
 		if videoId > 0 {
@@ -232,6 +251,15 @@ func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activi
 		//	videoCondAct += ` AND art.activity_time > ? `
 		//	videoParsAct = append(videoParsAct, endTime)
 		//}
+		if videoIds != "" {
+			sliceId := strings.Split(videoIds, ",")
+			var idSqlStr string
+			for _, v := range sliceId {
+				idSqlStr += "'" + v + "',"
+			}
+			idSqlStr = strings.TrimRight(idSqlStr, ",")
+			videoCond += ` AND video_id IN (` + idSqlStr + `)`
+		}
 		videoCond += ` AND publish_status = 1`
 	}
 	total, videoList, e = models.GetMicroRoadShowVideoPageListV8(startSize, pageSize, videoCond, videoPars, videoCondAct, videoParsAct, audioCond, audioPars, audioId, videoId, activityVideoId, filter)
@@ -242,3 +270,65 @@ func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activi
 	respList = videoList
 	return
 }
+
+// 我的收藏
+func GetMicroRoadShowMycollect(pageSize, currentIndex int, audioIds, videoIds, activityVideoIds string) (respList []*models.MicroRoadShowPageList, total int, err error) {
+	var e error
+	// 根据每页数据量获取音视频配比
+	startSize := utils.StartIndex(currentIndex, pageSize)
+	videoList := make([]*models.MicroRoadShowPageList, 0)
+
+	//音频的查询
+	var audioCond string
+	var audioPars []interface{}
+	// 如果筛选条件为指定视频ID或只看视频则不做音频查询
+	// 活动已发布且已结束
+	audioCond += ` AND b.publish_status = 1 AND b.active_state = 3`
+	if audioIds != "" {
+		sliceId := strings.Split(audioIds, ",")
+		var idSqlStr string
+		for _, v := range sliceId {
+			idSqlStr += "'" + v + "',"
+		}
+		idSqlStr = strings.TrimRight(idSqlStr, ",")
+		audioCond += ` AND a.activity_voice_id IN (` + idSqlStr + `)`
+	} else {
+		audioCond += ` AND a.activity_voice_id = 0 `
+	}
+	//视频的处理
+	var videoCond string
+	var videoCondAct string
+	if activityVideoIds != "" {
+		sliceId := strings.Split(activityVideoIds, ",")
+		var idSqlStr string
+		for _, v := range sliceId {
+			idSqlStr += "'" + v + "',"
+		}
+		idSqlStr = strings.TrimRight(idSqlStr, ",")
+		videoCondAct += ` AND v.video_id IN (` + idSqlStr + `)`
+	} else {
+		videoCondAct += ` AND v.video_id  = 0 `
+	}
+	var videoPars []interface{}
+	var videoParsAct []interface{}
+	if videoIds != "" {
+		sliceId := strings.Split(videoIds, ",")
+		var idSqlStr string
+		for _, v := range sliceId {
+			idSqlStr += "'" + v + "',"
+		}
+		idSqlStr = strings.TrimRight(idSqlStr, ",")
+		videoCond += ` AND video_id IN (` + idSqlStr + `)`
+	} else {
+		videoCond += ` AND video_id  = 0 `
+	}
+	videoCond += ` AND publish_status = 1`
+
+	total, videoList, e = models.GetMicroRoadShowVideoPageListV8(startSize, pageSize, videoCond, videoPars, videoCondAct, videoParsAct, audioCond, audioPars, 0, 0, 0, 0)
+	if e != nil {
+		err = errors.New("获取微路演音视频列表失败, Err: " + e.Error())
+		return
+	}
+	respList = videoList
+	return
+}

+ 64 - 2
services/wx_template_msg.go

@@ -3,6 +3,7 @@ package services
 import (
 	"bytes"
 	"encoding/json"
+	"errors"
 	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
@@ -679,7 +680,7 @@ func SendCommentWxTemplateMsg(title, companyName, userName, sellerName, createTi
 		return
 	}
 	var first string
-	first = "【"+title+"】有新的留言,请及时处理"
+	first = "【" + title + "】有新的留言,请及时处理"
 	keyword1 := companyName + "--" + userName + "(" + sellerName + ")"
 	keyword2 := "-"
 	keyword3 := createTime
@@ -698,4 +699,65 @@ func SendCommentWxTemplateMsg(title, companyName, userName, sellerName, createTi
 	sendMap["data"] = sendData
 	WxSendTemplateMsg(sendUrl, sendMap, openIdList, strconv.Itoa(articleId), utils.TEMPLATE_MSG_CYGX_COMMENT)
 	return
-}
+}
+
+//微路演新增留言提问消息提醒
+func SendWxMsgWithMicroRoadshowAsk(req models.AddVideoCommnetReq, user *models.WxUserItem) (err error) {
+	var msg string
+	defer func() {
+		if err != nil || msg != "" {
+			go utils.SendEmail("发送模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
+			go utils.SendAlarmMsg(fmt.Sprint("发送微路演新增留言提问消息提醒失败,用户名", req.Title, "ID:", req.Id), 2)
+			utils.FileLog.Info("发送模版消息失败,Err:%s", err.Error())
+		}
+	}()
+
+	companyItem, e := models.GetSellerDetailAllByCompanyId(user.CompanyId)
+	if e != nil {
+		return
+	}
+	if companyItem == nil {
+		msg = "获取客户所属销售信息失败,UserID:" + strconv.Itoa(user.UserId)
+	}
+	var first string
+	var keyword1 string
+	var keyword2 string
+	var keyword3 string
+	var keyword4 string
+	var remark string
+	first = req.Title + "有新的留言,请及时处理"
+	keyword1 = user.CompanyName + "——" + user.RealName + "(" + companyItem.SellerName + ")"
+	keyword3 = time.Now().Format(utils.FormatDateTime)
+	keyword2 = ""
+	keyword4 = req.Content
+	remark = ""
+	mobile := companyItem.Mobile + "," + utils.WxMsgTemplateIdAskMsgMobilePublic
+	openIdList, e := models.GetWxOpenIdByMobileList(mobile)
+	if e != nil {
+		err = errors.New("GetWxOpenIdByMobileList, Err: " + e.Error())
+		return
+	}
+	openIdArr := make([]string, 0)
+	for _, v := range openIdList {
+		openIdArr = append(openIdArr, v.OpenId)
+	}
+	redirectUrl := ""
+	sendInfo := new(SendWxTemplate)
+	sendInfo.First = first
+	sendInfo.Keyword1 = keyword1
+	sendInfo.Keyword2 = keyword2
+	sendInfo.Keyword3 = keyword3
+	sendInfo.Keyword4 = keyword4
+	sendInfo.Remark = remark
+	sendInfo.TemplateId = utils.WxMsgTemplateIdAskMsgXzs
+	sendInfo.RedirectUrl = redirectUrl
+	sendInfo.RedirectTarget = 3
+	sendInfo.Resource = strconv.Itoa(req.Id)
+	sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+	sendInfo.OpenIdArr = openIdArr
+	err = PublicSendTemplateMsg(sendInfo)
+	if err != nil {
+		return
+	}
+	return
+}

+ 58 - 0
utils/common.go

@@ -754,3 +754,61 @@ func InArrayByStr(idStrList []string, searchId string) (has bool) {
 	}
 	return
 }
+
+// GetNowWeekMonday 获取本周周一的时间
+func GetNowWeekMonday() time.Time {
+	offset := int(time.Monday - time.Now().Weekday())
+	if offset == 1 { //正好是周日,但是按照中国人的理解,周日是一周最后一天,而不是一周开始的第一天
+		offset = -6
+	}
+	mondayTime := time.Now().AddDate(0, 0, offset)
+	mondayTime = time.Date(mondayTime.Year(), mondayTime.Month(), mondayTime.Day(), 0, 0, 0, 0, mondayTime.Location())
+	return mondayTime
+}
+
+// GetLastWeekMonday 获取上周周一的时间
+func GetLastWeekMonday() time.Time {
+	offset := int(time.Monday - time.Now().Weekday())
+	if offset == 1 { //正好是周日,但是按照中国人的理解,周日是一周最后一天,而不是一周开始的第一天
+		offset = -6
+	}
+	mondayTime := time.Now().AddDate(0, 0, offset-7)
+	mondayTime = time.Date(mondayTime.Year(), mondayTime.Month(), mondayTime.Day(), 0, 0, 0, 0, mondayTime.Location())
+	return mondayTime
+}
+
+// GetNowWeekSunDay 获取本周周日的时间
+func GetNowWeekSunday() time.Time {
+	return GetNowWeekMonday().AddDate(0, 0, 6)
+}
+
+// GetLastWeekSunday 获取上周周日的时间
+func GetLastWeekSunday() time.Time {
+	return GetLastWeekMonday().AddDate(0, 0, 6)
+}
+
+// GetNowMonthFirstDay 获取本月第一天的时间
+func GetNowMonthFirstDay() time.Time {
+	nowMonthFirstDay := time.Date(time.Now().Year(), time.Now().Month(), 1, 0, 0, 0, 0, time.Now().Location())
+	return nowMonthFirstDay
+}
+
+// GetNowMonthLastDay 获取本月最后一天的时间
+func GetNowMonthLastDay() time.Time {
+	nowMonthLastDay := time.Date(time.Now().Year(), time.Now().Month(), 1, 0, 0, 0, 0, time.Now().Location()).AddDate(0, 1, -1)
+	nowMonthLastDay = time.Date(nowMonthLastDay.Year(), nowMonthLastDay.Month(), nowMonthLastDay.Day(), 23, 59, 59, 0, nowMonthLastDay.Location())
+	return nowMonthLastDay
+}
+
+// GetNowMonthFirstDay 获取上月第一天的时间
+func GetLastMonthFirstDay() time.Time {
+	nowMonthFirstDay := time.Date(time.Now().Year(), time.Now().AddDate(0, -1, 0).Month(), 1, 0, 0, 0, 0, time.Now().Location())
+	return nowMonthFirstDay
+}
+
+// GetNowMonthLastDay 获取上月最后一天的时间
+func GetLastMonthLastDay() time.Time {
+	nowMonthLastDay := time.Date(time.Now().Year(), time.Now().AddDate(0, -1, 0).Month(), 1, 0, 0, 0, 0, time.Now().Location()).AddDate(0, 1, -1)
+	nowMonthLastDay = time.Date(nowMonthLastDay.Year(), nowMonthLastDay.Month(), nowMonthLastDay.Day(), 23, 59, 59, 0, nowMonthLastDay.Location())
+	return nowMonthLastDay
+}

+ 3 - 1
utils/config.go

@@ -38,7 +38,8 @@ var (
 	WxMsgTemplateIdAskMsg               string //手机号用户【XXX】发送模板消息模板ID
 	WxMsgTemplateIdAskMsgXzs            string //手机号用户【XXX】发送模板消息模板ID(小助手)
 	WxMsgTemplateIdAskMsgMobile         string //手机号用户【XXX】发送模板消息
-	WxMsgTemplateIdAskMsgMobileAll      string //手机号用户【XXX】发送模板消rm -
+	WxMsgTemplateIdAskMsgMobileAll      string //手机号用户【XXX】发送模板消rm --
+	WxMsgTemplateIdAskMsgMobilePublic   string //手机号用户【XXX】发送模板消rm --
 	TemplateIdByProductXzs              string //产品运行报告通知-模板ID(小助手)
 	WxMsgTemplateIdArticleUserRemind    string //用户阅读报告通知-模板ID
 	WxMsgTemplateIdArticleUserRemindXzs string //用户阅读报告通知-模板ID(小助手)
@@ -140,6 +141,7 @@ func init() {
 	YanxSummaryPermissionId = 1001     //研选纪要分类ID
 	YanxViewpointPermissionId = 1002   //研选观点分类ID
 	WxMsgTemplateIdAskMsgMobileAll = "15557270714,18767183922,18621268829,15618524605"
+	WxMsgTemplateIdAskMsgMobilePublic = "15557270714,18767183922,18621268829"
 	HtgjDefaultSaleName = "王芳"
 	HtgjSalt = "HTGJ&HZ"
 	HtgjName = "海通国际"