Browse Source

微路演我的收藏改写

xingzai 2 years ago
parent
commit
1abab3f940

+ 13 - 62
controllers/activity.go

@@ -4685,7 +4685,15 @@ func (this *ActivityCoAntroller) OverActivityList() {
 	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 = "获取失败"
@@ -4701,7 +4709,7 @@ func (this *ActivityCoAntroller) OverActivityList() {
 	var pars []interface{}
 	//活动可见限制
 	var sqlExport string
-	resp := new(models.GetCygxActivityLabelListRep)
+
 	slicePer := strings.Split(permissionStr, ",")
 	var permissionSqlStr string
 	for _, v := range slicePer {
@@ -4727,61 +4735,10 @@ func (this *ActivityCoAntroller) OverActivityList() {
 	}
 	sqlExport += `) `
 
-	////进行中的活动
-	//condition = ` AND art.publish_status = 1  AND art.label != ''  AND art.active_state = 2 `
-	//var conditionOr string
-	//if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
-	//	conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%'	 ` + condition + `) `
-	//}
-	//if (userType == 5) && strings.Contains(permissionStr, "专家") {
-	//	conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%'	 ` + condition + `) `
-	//}
-	//if userType == 1 {
-	//	conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
-	//} 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 != "" {
-	//		conditionOr += ` OR (  art.scale LIKE '%` + companyProduct.Scale + `%'	 ` + condition + `) `
-	//	}
-	//}
-	//condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
-	//
-	////进行中的活动
-	//sortTime = ` mintimesort ASC `
-	//list, errList := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
-	//if errList != nil {
-	//	br.Msg = "获取失败"
-	//	br.ErrMsg = "获取失败,Err:" + errList.Error()
-	//	return
-	//}
-
 	//已结束的活动
 	var conditionOr string
 	conditionOr = ""
 	condition = ` AND art.publish_status = 1  AND art.label != ''  AND art.active_state = 3 `
-	//if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
-	//	conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%'	 ` + condition + `) `
-	//}
-	//if (userType == 5) && strings.Contains(permissionStr, "专家") {
-	//	conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%'	 ` + condition + `) `
-	//}
-	//if userType == 1 {
-	//	conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
-	//} else {
-	//	conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
-	//}
-	//startSize = 0
-
 	if isPower == 1 {
 		condition += permissionSqlStr + sqlExport + conditionOr
 	}
@@ -4835,9 +4792,6 @@ func (this *ActivityCoAntroller) OverActivityList() {
 		tempCondition = strings.TrimRight(tempCondition, ",")
 		condition += ` AND art.activity_type_name IN (` + tempCondition + `)`
 	}
-
-	//pageSize = 24 - len(list)
-
 	//已结束的活动
 	sortTime = ` activity_time DESC `
 
@@ -4868,17 +4822,15 @@ func (this *ActivityCoAntroller) OverActivityList() {
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
-	//for _, v := range listEnd {
-	//	list = append(list, v)
-	//}
 	//标签字段关联的产业与标签处理
 	mapKeyWord := make(map[string]string)
-	for k, v := range list {
+	for _, v := range list {
 		keyWord := services.LabelStr(v.KeyWord)
 		if _, ok := mapKeyWord[keyWord]; ok {
 			continue
 		}
-		list[k].KeyWord = keyWord
+		v.KeyWord = keyWord
+		resp.List = append(resp.List, v)
 		mapKeyWord[keyWord] = keyWord
 	}
 	//添加更多主题访问记录
@@ -4891,7 +4843,6 @@ func (this *ActivityCoAntroller) OverActivityList() {
 	item.CompanyName = user.CompanyName
 	item.PageType = "OverActivity"
 	go models.AddCygxPageHistoryRecord(item)
-	resp.List = list
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 183 - 0
controllers/micro_roadshow.go

@@ -7,6 +7,7 @@ import (
 	"hongze/hongze_cygx/services"
 	"hongze/hongze_cygx/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -555,3 +556,185 @@ func (this *MicroRoadShowController) Collect() {
 		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
+}

+ 9 - 0
routers/commentsRouter.go

@@ -709,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",

+ 42 - 38
services/activity.go

@@ -1556,48 +1556,52 @@ 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)) + `) 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 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
-			}
-		}
-	}
-	//产业关联的弘则报告发布日期在三个月以内的活动、产业显示 NEW标签
-	articNewLabel, e := GetArticNewLabelWhithActivity3Month()
 	for k := range articNewLabel {
 		labelMap[k] = true
 	}

+ 5 - 7
services/article.go

@@ -1589,16 +1589,16 @@ func GetSpecialArticleDetailUserPower(user *models.WxUserItem, articleInfo *mode
 	return
 }
 
-func init() {
-	GetArticNewLabelWhithActivity3Month()
-}
+//func init() {
+//	GetArticNewLabelWhithActivity3Month()
+//}
 
 //弘则报告发布日期在三个月以内的
 func GetArticNewLabelWhithActivity3Month() (labelMap map[int]bool, err error) {
 	var condition string
 	var pars []interface{}
-	condition += ` AND publish_date  >= ? `
-	pars = append(pars, time.Now().AddDate(0, -3, 0))
+	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())
@@ -1639,7 +1639,5 @@ func GetArticNewLabelWhithActivity3Month() (labelMap map[int]bool, err error) {
 	for _, v := range groups {
 		labelMap[v.ActivityId] = true
 	}
-
-	fmt.Println(labelMap[89])
 	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
-}
+}

+ 64 - 2
services/micro_roadshow.go

@@ -178,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 {
@@ -211,7 +211,7 @@ func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activi
 	var videoCondAct string
 	var videoPars []interface{}
 	var videoParsAct []interface{}
-	if audioId > 0 || filter == 2{
+	if audioId > 0 || filter == 2 {
 		fmt.Println("22222")
 		videoCond = ""
 	} else {
@@ -270,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
+}