ソースを参照

Merge branch 'master' of http://8.136.199.33:3000/hongze/hongze_cygx into cygx_fix_need_9.22

xingzai 2 年 前
コミット
275fefd6f9

+ 146 - 19
controllers/activity.go

@@ -663,6 +663,25 @@ func (this *ActivityCoAntroller) Detail() {
 	if activityInfo.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
 		activityInfo.IsCClassMeeting = true
 	}
+	//处理冻结客户,流失客户的弹窗提示
+	if user.CompanyId > 1 {
+		sellerMobile, sellerRealName, err := services.CheckActivityUserPermission(user)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+			return
+		}
+		if sellerMobile != "" {
+			resp.HasPermission = 2
+			resp.SellerMobile = sellerMobile
+			resp.SellerName = sellerRealName
+			br.Ret = 200
+			br.Success = true
+			br.Msg = "获取成功"
+			br.Data = resp
+			return
+		}
+	}
 	applyCount, err := models.GetApplyRecordCount(uid)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取信息失败"
@@ -949,7 +968,7 @@ func (this *ActivityCoAntroller) Detail() {
 				var condition string
 				condition = ` AND m.industrial_management_id IN (` + industrialManagementId + `)`
 				condition += ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId)
-				listIndustrialGrop, err := models.GetSearchResourceList(condition)
+				listIndustrialGrop, err := models.GetSearchResourceList(condition, 0, 0)
 				if err != nil && err.Error() != utils.ErrNoRow() {
 					br.Msg = "获取信息失败"
 					br.ErrMsg = "GetSearchResourceList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
@@ -1041,6 +1060,25 @@ func (this *ActivityCoAntroller) SignupAdd() {
 	if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
 		resp.GoBindEmail = true
 	}
+	//处理冻结客户,流失客户的弹窗提示
+	if user.CompanyId > 1 {
+		sellerMobile, sellerRealName, err := services.CheckActivityUserPermission(user)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+			return
+		}
+		if sellerMobile != "" {
+			resp.HasPermission = 2
+			resp.SellerMobile = sellerMobile
+			resp.SellerName = sellerRealName
+			br.Ret = 200
+			br.Success = true
+			br.Msg = "获取成功"
+			br.Data = resp
+			return
+		}
+	}
 	//判断是否已经申请过
 	applyCount, err := models.GetApplyRecordCount(uid)
 	if err != nil && err.Error() != utils.ErrNoRow() {
@@ -1724,6 +1762,26 @@ func (this *ActivityCoAntroller) MeetingReminderAdd() {
 	item := new(models.CygxActivityMeetingReminder)
 	resp := new(models.SignupStatus)
 	hasPermission := 0
+
+	//处理冻结客户,流失客户的弹窗提示
+	if user.CompanyId > 1 {
+		sellerMobile, sellerRealName, err := services.CheckActivityUserPermission(user)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+			return
+		}
+		if sellerMobile != "" {
+			resp.HasPermission = 2
+			resp.SellerMobile = sellerMobile
+			resp.SellerName = sellerRealName
+			br.Ret = 200
+			br.Success = true
+			br.Msg = "获取成功"
+			br.Data = resp
+			return
+		}
+	}
 	var companyDetailStatus string
 	if user.CompanyId <= 1 {
 		companyDetailStatus = ""
@@ -3292,6 +3350,26 @@ func (this *ActivityCoAntroller) CheckAsk() {
 		return
 	}
 	resp := new(models.SignupStatus)
+
+	//处理冻结客户,流失客户的弹窗提示
+	if user.CompanyId > 1 {
+		sellerMobile, sellerRealName, err := services.CheckActivityUserPermission(user)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+			return
+		}
+		if sellerMobile != "" {
+			resp.HasPermission = 2
+			resp.SellerMobile = sellerMobile
+			resp.SellerName = sellerRealName
+			br.Ret = 200
+			br.Success = true
+			br.Msg = "获取成功"
+			br.Data = resp
+			return
+		}
+	}
 	hasPermission := 0
 	var companyDetailStatus string
 	if user.CompanyId <= 1 {
@@ -3654,9 +3732,11 @@ func (this *ActivityCoAntroller) LabelTypeListV5() {
 		br.ErrMsg = "获取活动【新】标签Map失败, Err: " + e.Error()
 		return
 	}
-	for k := range list {
-		for k2 := range list[k].List {
-			list[k].List[k2].IsNew = newLabelMap[list[k].List[k2].ActivityId]
+	for k, v := range list {
+		if v.ActivityTypeId == 1 {
+			for k2 := range list[k].List {
+				list[k].List[k2].IsNew = newLabelMap[list[k].List[k2].ActivityId]
+			}
 		}
 	}
 
@@ -4754,6 +4834,25 @@ func (this *ActivityCoAntroller) ActivityAppointmentAdd() {
 	//SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
 	item := new(models.CygxActivityAppointment)
 	resp := new(models.SignupStatus)
+	//处理冻结客户,流失客户的弹窗提示
+	if user.CompanyId > 1 {
+		sellerMobile, sellerRealName, err := services.CheckActivityUserPermission(user)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+			return
+		}
+		if sellerMobile != "" {
+			resp.HasPermission = 2
+			resp.SellerMobile = sellerMobile
+			resp.SellerName = sellerRealName
+			br.Ret = 200
+			br.Success = true
+			br.Msg = "获取成功"
+			br.Data = resp
+			return
+		}
+	}
 	hasPermission := 0
 	var companyDetailStatus string
 	if user.CompanyId <= 1 {
@@ -5051,7 +5150,10 @@ func (this *ActivityCoAntroller) ActivityVoiceHistoryAdd() {
 		br.ErrMsg = "参数解析失败,Err:" + err.Error()
 		return
 	}
+
 	activityId := req.ActivityId
+	playSeconds := req.PlaySeconds
+
 	activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
 	if activityInfo == nil {
 		br.Msg = "操作失败"
@@ -5070,21 +5172,46 @@ func (this *ActivityCoAntroller) ActivityVoiceHistoryAdd() {
 		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
 		return
 	}
-	item := new(models.CygxActivityVoiceHistory)
-	item.UserId = uid
-	item.ActivityId = activityId
-	item.CreateTime = time.Now()
-	item.Mobile = user.Mobile
-	item.Email = user.Email
-	item.CompanyId = user.CompanyId
-	item.CompanyName = user.CompanyName
-	item.SellerName = sellerName
-	item.RealName = user.RealName
-	err = models.AddCygxActivityVoiceHistory(item)
-	if err != nil {
-		br.Msg = "操作失败"
-		br.ErrMsg = "操作失败,Err:" + err.Error()
-		return
+	item := models.CygxActivityVoiceHistory{
+		ActivityId:  activityId,
+		UserId:      uid,
+		CreateTime:  time.Now(),
+		Mobile:      user.Mobile,
+		Email:       user.Email,
+		CompanyId:   user.CompanyId,
+		CompanyName: user.CompanyName,
+		RealName:    user.RealName,
+		SellerName:  sellerName,
+		PlaySeconds: strconv.Itoa(req.PlaySeconds),
+		ModifyTime:  time.Now(),
+	}
+
+	if playSeconds != 0 {
+		lastItem, err := models.GetLastCygxActivityVoiceHistory(activityId, user.UserId)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "操作失败,GetLastCygxActivityVoiceHistory Err:" + err.Error()
+			return
+		}
+		err = models.UpdateLastCygxActivityVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
+		if err != nil {
+			br.Msg = "更新失败"
+			br.ErrMsg = "更新失败,UpdateLastCygxActivityVoiceHistory Err:" + err.Error()
+			return
+		}
+	} else {
+		err = models.AddCygxActivityVoiceHistory(&item)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "操作失败,Err:" + err.Error()
+			return
+		}
+		err = models.UpdateCygxActivityVoiceCounts(activityId)
+		if err != nil {
+			br.Msg = "更新失败"
+			br.ErrMsg = "更新失败,Err:" + err.Error()
+			return
+		}
 	}
 	br.Ret = 200
 	br.Success = true

+ 22 - 1
controllers/article.go

@@ -312,6 +312,27 @@ Loop:
 		}
 		haveResearch = true
 	}
+	if hasPermission == 5 {
+		companyPermissionNoStatus, err := models.GetCompanyPermissionByUserNoStatus(user.CompanyId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
+			return
+		}
+		if companyPermissionNoStatus != "" {
+			sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+				return
+			}
+			if sellerItemQy != nil {
+				hasPermission = 3
+				detail.SellerMobile = sellerItemQy.Mobile
+				detail.SellerName = sellerItemQy.RealName
+			}
+		}
+	}
 
 	if hasPermission == 2 || hasPermission == 4 {
 		//获取销售手机号
@@ -327,6 +348,7 @@ Loop:
 			detail.SellerName = sellerItemQy.RealName
 		}
 	}
+
 	if detail.ArticleId < utils.SummaryArticleId {
 		if user.Mobile != "" {
 			chartUserTokenByMobile, _ := services.GetUserTokenByMobile(user.Mobile)
@@ -353,7 +375,6 @@ Loop:
 			chartUserTokenByMobile, _ := services.GetUserTokenByMobile(user.Mobile)
 			detail.ReportLink += "?token=" + chartUserTokenByMobile
 		}
-
 	}
 	resp := new(models.ArticleDetailResp)
 	resp.HasPermission = hasPermission

+ 95 - 18
controllers/home.go

@@ -1,6 +1,7 @@
 package controllers
 
 import (
+	"encoding/json"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/services"
@@ -325,8 +326,58 @@ func (this *BaseHomeController) ListHomePublic() {
 	br.Data = resp
 }
 
-// @Title 首页列表接口v6版本
-// @Description 首页列表接口v6版本
+// @Title 首页/搜索头部导航接口
+// @Description 首页/搜索头部导航接口
+// @Param   SearchPage  query  int  false  "是否为搜索页面"
+// @Success 200 {object} models.HomeListResp
+// @router /header_tab [get]
+func (this *HomeController) HeaderTab() {
+	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
+	}
+	searchPage, _ := this.GetInt("SearchPage")
+
+	key := models.HomeHeaderTabConfigKey
+	conf, e := models.GetConfigByCode(key)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取首页头部导航失败, Err: " + e.Error()
+		return
+	}
+	if conf.ConfigValue == "" {
+		br.Msg = "获取失败"
+		br.ErrMsg = "首页头部导航配置值有误"
+		return
+	}
+
+	list := new(models.HomeHeaderTabList)
+	if e = json.Unmarshal([]byte(conf.ConfigValue), &list); e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "首页头部导航配置值解析失败, Err: " + e.Error()
+		return
+	}
+	resp := list.Home
+	if searchPage == 1 {
+		resp = list.SearchPage
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 首页列表接口v7.6版本
+// @Description 首页列表接口v7.6版本
 // @Param   PageSize   query   int  true       "每页数据条数"
 // @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
 // @Param   ChartPermissionId   query   int  true       "品类id,最新传0"
@@ -373,6 +424,8 @@ func (this *HomeController) ListHomeArtAndChart() {
 	resp.HaveResearch = true
 	var chartList []*models.HomeChartListResp
 	var err error
+
+	// 最新
 	if listType == 1 {
 		if currentIndex <= 2 {
 			listCtagId := [10]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
@@ -396,9 +449,11 @@ func (this *HomeController) ListHomeArtAndChart() {
 				br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
 				return
 			}
-
 		}
-	} else if listType == 3 {
+	}
+
+	// 图表
+	if listType == 3 {
 		if chartPermissionId > 0 {
 			condition += ` AND a.ptag_id =? `
 			pars = append(pars, chartPermissionId)
@@ -438,6 +493,7 @@ func (this *HomeController) ListHomeArtAndChart() {
 	}
 	resp.ChartList = chartList
 
+	// 最新/纪要
 	if listType != 3 {
 		userType, _, err := services.GetUserType(user.CompanyId)
 		if err != nil {
@@ -453,13 +509,13 @@ func (this *HomeController) ListHomeArtAndChart() {
 				br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
 				return
 			}
-			categoryinfo, err := models.GetChartPermissionById(chartPermissionId)
+			categoryInfo, err := models.GetChartPermissionById(chartPermissionId)
 			if err != nil {
 				br.Msg = "获取信息失败"
 				br.ErrMsg = "获取信息失败,Err:" + err.Error()
 				return
 			}
-			if userType == 1 && strings.Contains(categoryinfo.PermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
+			if userType == 1 && strings.Contains(categoryInfo.PermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
 				resp.HaveResearch = false
 				resp.Paging = page
 				br.Ret = 200
@@ -480,19 +536,36 @@ func (this *HomeController) ListHomeArtAndChart() {
 		if userType == 1 {
 			condition += ` AND  category_name  NOT LIKE '%` + utils.CHART_PERMISSION_NAME_YANXUAN + `%'`
 		}
-		total, err = models.GetHomeCount(condition, pars)
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.Msg = "获取帖子总数失败,Err:" + err.Error()
-			return
-		}
 
-		list, err := models.GetHomeList(condition, pars, startSize, pageSize)
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.Msg = "获取帖子数据失败,Err:" + err.Error()
-			return
+		list := make([]*models.HomeArticle, 0)
+		// 7.6-与音频作联合查询, 整体进行发布时间的排序(代码写的嘎嘎烂, 将就着用吧=_=!)
+		if listType == 1 {
+			var unionPars []interface{}
+			unionList, unionTotal, e := services.GetHomeNewestList(user.UserId, user.CompanyId, startSize, pageSize, condition, unionPars)
+			if e != nil {
+				br.Msg = "获取信息失败"
+				br.Msg = "获取纪要音频联合列表失败, Err: " + e.Error()
+				return
+			}
+			total = unionTotal
+			list = unionList
+		} else {
+			total, err = models.GetHomeCount(condition, pars)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.Msg = "获取帖子总数失败,Err:" + err.Error()
+				return
+			}
+
+			homeList, err := models.GetHomeList(condition, pars, startSize, pageSize)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.Msg = "获取帖子数据失败,Err:" + err.Error()
+				return
+			}
+			list = homeList
 		}
+
 		//研选的五张图片
 		detailResearch, err := models.GetConfigByCode("category_research_img_url")
 		if err != nil {
@@ -520,6 +593,9 @@ func (this *HomeController) ListHomeArtAndChart() {
 		}
 
 		for k, v := range list {
+			if v.HomeType != 0 {
+				continue
+			}
 			item := list[k]
 			//如果文章一开始的内容是图片,优先展示第一张图片
 			imgurl, _ := services.FixArticleImgUrl(html.UnescapeString(list[k].Body))
@@ -528,7 +604,7 @@ func (this *HomeController) ListHomeArtAndChart() {
 			if imgurl != "" {
 				list[k].BodyHtml = imgurl
 			}
-			list[k].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDateTimeNoSecond) //时间字符串格式转时间格式
+			list[k].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
 			if strings.Contains(item.CategoryName, utils.CHART_PERMISSION_NAME_YANXUAN) {
 				list[k].IsResearch = true
 			}
@@ -553,6 +629,7 @@ func (this *HomeController) ListHomeArtAndChart() {
 	if chartTotal > total {
 		total = chartTotal
 	}
+
 	page = paging.GetPaging(currentIndex, pageSize, total)
 	resp.Paging = page
 	br.Ret = 200

+ 217 - 0
controllers/micro_roadshow.go

@@ -0,0 +1,217 @@
+package controllers
+
+import (
+	"encoding/json"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/services"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+	"time"
+)
+
+// 微路演
+type MicroRoadShowController struct {
+	BaseAuthController
+}
+
+// @Title 微路演列表
+// @Description 微路演列表接口
+// @Param   PageSize		query	int		true	"每页数据条数"
+// @Param   CurrentIndex	query	int		true	"当前页页码,从1开始"
+// @Param   KeyWord			query	string	false	"搜索关键词"
+// @Param   AudioId			query	int		false	"音频ID"
+// @Param   VideoId			query	int		false	"视频ID"
+// @Success 200 {object} models.HomeListResp
+// @router /list [get]
+func (this *MicroRoadShowController) List() {
+	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")
+	keywords := this.GetString("KeyWord")
+	audioId, _ := this.GetInt("AudioId")
+	videoId, _ := this.GetInt("VideoId")
+
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+
+	// 微路演列表
+	list, total, e := services.GetMicroRoadShowPageList(pageSize, currentIndex, audioId, videoId, keywords)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
+		return
+	}
+
+	// 用户权限
+	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].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
+}
+
+// @Title 记录用户浏览音频回放接口
+// @Description 记录用户浏览音频回放接口
+// @Param	request	body models.ActivityIdRep true "type json string"
+// @Success Ret=200 {object} models.AppointmentResp
+// @router /videoHistory/add [post]
+func (this *MicroRoadShowController) VideoHistoryAdd() {
+	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.AddVideoHistoryReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	videoId := req.VideoId
+	playSeconds := req.PlaySeconds
+
+	var sellerName string
+	sellerName, err = models.GetCompanySellerName(user.CompanyId)
+	if err != nil {
+		br.Msg = "报名失败!"
+		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+		return
+	}
+	item := models.CygxMicroRoadshowVideoHistory{
+		VideoId:     videoId,
+		UserId:      uid,
+		Mobile:      user.Mobile,
+		Email:       user.Email,
+		CompanyId:   user.CompanyId,
+		CompanyName: user.CompanyName,
+		RealName:    user.RealName,
+		SellerName:  sellerName,
+		PlaySeconds: strconv.Itoa(playSeconds),
+		CreateTime:  time.Now(),
+		ModifyTime:  time.Now(),
+	}
+
+	if playSeconds != 0 {
+		lastItem, err := models.GetLastCygxMicroRoadshowVideoHistory(videoId, user.UserId)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "操作失败,GetLastCygxMicroRoadshowVideoHistory Err:" + err.Error()
+			return
+		}
+		err = models.UpdateLastCygxActivityVideoHistory(strconv.Itoa(playSeconds), lastItem.Id)
+		if err != nil {
+			br.Msg = "更新失败"
+			br.ErrMsg = "更新失败,UpdateLastCygxActivityVideoHistory Err:" + err.Error()
+			return
+		}
+	} else {
+		err = models.AddCygxMicroRoadshowVideoHistory(&item)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "操作失败,Err:" + err.Error()
+			return
+		}
+		err = models.UpdateCygxActivityVideoCounts(videoId)
+		if err != nil {
+			br.Msg = "更新失败"
+			br.ErrMsg = "更新失败,Err:" + err.Error()
+			return
+		}
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功"
+	return
+}

+ 194 - 7
controllers/report.go

@@ -357,7 +357,7 @@ func (this *ReportController) ArticleCategoryList() {
 		br.ErrMsg = "获取信息失败,Err:" + err.Error()
 		return
 	}
-	list, err := models.IndustrialToArticleCategory(industrialManagementId, detail.ChartPermissionId)
+	list, err := models.IndustrialToArticleCategoryNew(industrialManagementId)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
@@ -1210,11 +1210,17 @@ func (this *ReportController) IsShow() {
 		return
 	}
 	var resp models.IsShow
-
+	IsShowFreeButton, err := services.GetfreeButtonIsShow(user)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,GetfreeButtonIsShow Err:" + err.Error()
+		return
+	}
 	resp.IsShowChart = true
 	resp.IsShowResearch = true
 	resp.LinkWxExplain = utils.LINK_WX_EXPLAIN
 	resp.YanXuan_Explain = true
+	resp.IsShowFreeButton = IsShowFreeButton
 	mobile := user.Mobile
 	if mobile == "" {
 		br.Ret = 200
@@ -1226,6 +1232,11 @@ func (this *ReportController) IsShow() {
 	if total > 0 {
 		resp.IsShowList = true
 	}
+	resp.SearchTxtList.SummarySearch = "全局搜索"
+	resp.SearchTxtList.ReportSearch = "全局搜索"
+	resp.SearchTxtList.YanXuanSearch = "全局搜索"
+	resp.SearchTxtList.ActivitySearch = "全局搜索"
+	resp.SearchTxtList.TabSearch = "请输入关键词"
 	resp.IsShow = true
 	br.Ret = 200
 	br.Success = true
@@ -1285,13 +1296,20 @@ func (this *ReportController) ReportListByType() {
 		return
 	}
 	fmt.Println(tbdb)
-	condition = ` AND publish_status = 1`
+	condition = ` AND publish_status = 1  `
+
 	total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
 		return
 	}
+	//研究汇总--报告精选 只显示最新一期,往期都隐藏
+	if reportType == "1" {
+		startSize = 0
+		pageSize = 1
+		total = 1
+	}
 	readSql = ` (SELECT COUNT(1) AS  count  FROM cygx_report_history_record AS h WHERE h.article_id = art.article_id AND  report_type ='` + reportTypeStr + `' AND h.user_id = ` + strconv.Itoa(uid) + `) as read_num`
 	page = paging.GetPaging(currentIndex, pageSize, total)
 	list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
@@ -2332,8 +2350,6 @@ func (this *ReportController) SearchReport() {
 	condition = `AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
 	sqlGroup = ` GROUP BY  a.article_id  ORDER BY a.publish_date DESC  `
 	//对应产业名称、标的名称。
-	//OR a.article_id IN ( SELECT article_id FROM cygx_industrial_article_group_subject WHERE industrial_subject_id IN ( SELECT industrial_subject_id FROM cygx_industrial_subject WHERE subject_name LIKE '%` + keyWord + `%' ) )
-	//OR a.article_id IN ( SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE industry_name LIKE '%` + keyWord + `%' ) )
 	listYx, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
 	if err != nil {
 		br.Msg = "获取信息失败"
@@ -2419,7 +2435,7 @@ func (this *ReportController) SearchResource() {
 	conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + `  AND publish_status = 1 ) `
 	condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
 
-	listHz, err := models.GetSearchResourceList(condition)
+	listHz, err := models.GetSearchResourceList(condition, 0, 0)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
@@ -2429,7 +2445,7 @@ func (this *ReportController) SearchResource() {
 	conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + `  AND publish_status = 1 ) `
 	condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
 
-	listYx, err := models.GetSearchResourceList(condition)
+	listYx, err := models.GetSearchResourceList(condition, 0, 0)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
@@ -2509,3 +2525,174 @@ func (this *ReportController) SearchResource() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 报告搜索、资源包搜索接口
+// @Description 报告搜索、资源包搜索接口接口
+// @Param   KeyWord   query   string  true       "搜索关键词"
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Success 200 {object} models.SearchReportAndResourceResp
+// @router /searchReportAndResource [get]
+func (this *ReportController) SearchReportAndResource() {
+	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
+	keyWord := this.GetString("KeyWord")
+	pageSize, _ := this.GetInt("PageSize")
+	var condition string
+	var sqlGroup string
+	//匹配报告标题、
+	condition = `AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
+	sqlGroup = ` GROUP BY  a.article_id  ORDER BY a.publish_date DESC  `
+	if pageSize > 0 {
+		sqlGroup += ` LIMIT 5 `
+	}
+	ListYxReport, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
+		return
+	}
+	for k, v := range ListYxReport {
+		ListYxReport[k].Source = 2
+		if v.MyCollectNum > 0 {
+			ListYxReport[k].IsCollect = true
+		}
+	}
+	ListHzReport, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition+` OR ( article_type = 'lyjh' `+condition+` ) `+sqlGroup, user.UserId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
+		return
+	}
+	for k, v := range ListHzReport {
+		ListHzReport[k].Source = 1
+		if v.MyCollectNum > 0 {
+			ListHzReport[k].IsCollect = true
+		}
+	}
+
+	if len(ListYxReport) == 0 {
+		ListYxReport = make([]*models.ArticleCollectionResp, 0)
+	}
+	if len(ListHzReport) == 0 {
+		ListHzReport = make([]*models.ArticleCollectionResp, 0)
+	}
+
+	fllowList, err := models.GetUserFllowIndustrialList(uid)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
+		return
+	}
+	fllowMap := make(map[int]int)
+	if len(fllowList) > 0 {
+		for _, v := range fllowList {
+			fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
+		}
+	}
+
+	var conditionOr string
+	conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + `  AND publish_status = 1 ) `
+	condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
+
+	listHzResource, err := models.GetSearchResourceList(condition, 0, pageSize)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+
+	conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + `  AND publish_status = 1 ) `
+	condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
+
+	listYxResource, err := models.GetSearchResourceList(condition, 0, pageSize)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
+		return
+	}
+	//合并产业关联的标的
+	listSubjcet, err := models.GetThemeHeatSubjectList("")
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
+		return
+	}
+	industrialIdArr := make([]int, 0)
+	for k, v := range listHzResource {
+		listHzResource[k].Source = 1
+		if fllowMap[v.IndustrialManagementId] > 0 {
+			listHzResource[k].IsFollw = true
+		}
+		industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
+	}
+
+	for k, v := range listYxResource {
+		listYxResource[k].Source = 2
+		if fllowMap[v.IndustrialManagementId] > 0 {
+			listYxResource[k].IsFollw = true
+		}
+		industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
+	}
+
+	if len(industrialIdArr) > 0 {
+		//合并产业关联的标的
+		listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
+			return
+		}
+		mapIndustrial := make(map[string]int)
+		for _, v := range listSubjcet {
+			for k2, v2 := range listYxResource {
+				if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 {
+					listYxResource[k2].IndustrialSubjectList = append(listYxResource[k2].IndustrialSubjectList, v)
+					mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
+				}
+			}
+			for k2, v2 := range listHzResource {
+				if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
+					listHzResource[k2].IndustrialSubjectList = append(listHzResource[k2].IndustrialSubjectList, v)
+					mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
+				}
+			}
+		}
+	}
+
+	resp := new(models.SearchReportAndResourceResp)
+	if len(listYxResource) == 0 {
+		listYxResource = make([]*models.IndustrialManagementHotResp, 0)
+	}
+	if len(listHzResource) == 0 {
+		listHzResource = make([]*models.IndustrialManagementHotResp, 0)
+	}
+
+	if keyWord != "" {
+		keyWordItem := new(models.CygxUserSearchKeyWord)
+		keyWordItem.UserId = user.UserId
+		keyWordItem.KeyWord = keyWord
+		keyWordItem.PageType = "ReortSearch"
+		keyWordItem.CreateTime = time.Now()
+		go models.AddUserSearchKeyWord(keyWordItem)
+		go services.AddUserSearchLog(user, keyWord, 5)
+	}
+
+	resp.ListHzResource = listHzResource
+	resp.ListYxResource = listYxResource
+	resp.ListYxReport = ListYxReport
+	resp.ListHzReport = ListHzReport
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 172 - 0
controllers/search.go

@@ -450,6 +450,7 @@ func (this *SearchController) ListHomeArtAndChart() {
 				result[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
 			}
 			result[k].Source = 1
+			result[k].PublishDate = utils.StrTimeToTime(result[k].PublishDate).Format(utils.FormatDate)
 		}
 	}
 	// ListType   query   int  true       "列表类型,1最新/全部,2 纪要 ,3图表 默认1"
@@ -470,6 +471,177 @@ func (this *SearchController) ListHomeArtAndChart() {
 	if listType == 1 {
 		total = total + int64(chartTotal)
 	}
+	if len(result) == 0 {
+		result = make([]*models.SearchItem, 0)
+	}
+	page := paging.GetPaging(currentIndex, pageSize, int(total))
+	resp.Paging = page
+	resp.List = result
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 搜索接口
+// @Description 搜索接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   KeyWord   query   string  true       "搜索关键词"
+// @Param   OrderColumn   query   int  true       "排序字段 ,Comprehensive综合 ,Matching匹配度 ,PublishDate 发布时间 "
+// @Success 200 {object} models.SearchItem
+// @router /artAndChart/listPage [get]
+func (this *SearchController) ListHomeArtAndChartPage() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	// @Param   ListType   query   int  true       "列表类型,1最新/全部,2 纪要 ,3图表 默认1"
+	listType, _ := this.GetInt("ListType")
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	listType = 1
+	startSize = paging.StartIndex(currentIndex, pageSize)
+	keyWord := this.GetString("KeyWord")
+	orderColumn := this.GetString("OrderColumn")
+	if keyWord == "" {
+		br.Msg = "请输入搜索词"
+		br.ErrMsg = "请输入搜索词"
+		return
+	}
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+
+	//研选的五张图片
+	detailResearch, errConfig := models.GetConfigByCode("category_research_img_url")
+	if errConfig != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "获取数据研选分类图片失败,Err:" + errConfig.Error()
+		return
+	}
+	researchList := strings.Split(detailResearch.ConfigValue, "{|}")
+	//对应分类的所图片
+	detailCategoryUrl, errConfig := models.GetConfigByCode("category_map_img_url")
+	if errConfig != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "行业配置信息失败,Err:" + errConfig.Error()
+		return
+	}
+	categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
+	mapCategoryUrl := make(map[string]string)
+	var categoryId string
+	var imgUrlChart string
+	for _, v := range categoryUrlList {
+		vslice := strings.Split(v, "_")
+		categoryId = vslice[0]
+		imgUrlChart = vslice[len(vslice)-1]
+		mapCategoryUrl[categoryId] = imgUrlChart
+	}
+	if orderColumn == "" {
+		orderColumn = "Matching"
+	}
+	var chartTotal int
+	resp := new(models.SearchResp)
+	var chartList []*models.HomeChartListResp
+	var err error
+	var condition string
+	var pars []interface{}
+	if listType == 1 || listType == 3 {
+		if currentIndex <= 2 {
+			condition = ` AND title LIKE '%` + keyWord + `%'`
+			chartList, err = models.GetChartList(condition, pars, startSize, pageSize)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
+				return
+			}
+			chartTotal, err = models.GetChartCount(condition, pars)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.Msg = "获取帖子总数失败,Err:" + err.Error()
+				return
+			}
+		}
+	}
+	for k, v := range chartList {
+		chartList[k].IsNeedJump = true
+		chartList[k].Source = 2
+		if v.PtagName != "" {
+			chartList[k].CtagNamePc = v.PtagName
+		}
+		if v.CtagName != "" {
+			chartList[k].CtagNamePc += "," + v.CtagName
+		}
+		if v.PtagNameTwo != "" {
+			chartList[k].CtagNamePc += "," + v.PtagNameTwo
+		}
+		if v.CtagNameTwo != "" {
+			chartList[k].CtagNamePc += "," + v.CtagNameTwo
+		}
+	}
+	if len(chartList) == 0 {
+		chartList = make([]*models.HomeChartListResp, 0)
+	}
+	resp.ChartList = chartList
+	var result []*models.SearchItem
+	var total int64
+	if listType == 1 || listType == 2 {
+		tmpResult, tmpTotal, tmpErr := services.EsArticleSearch(keyWord, startSize, pageSize, orderColumn)
+		result = tmpResult
+		total = tmpTotal
+		err = tmpErr
+		if err != nil {
+			br.Msg = "检索失败"
+			br.ErrMsg = "检索失败,Err:" + err.Error()
+			return
+		}
+		if len(result) == 0 {
+			result = make([]*models.SearchItem, 0)
+		}
+
+		for k, v := range result {
+			//如果是研选系列的任意取五张图片的中的一张
+			if v.CategoryId == "0" {
+				knum := v.ArticleId % 5
+				result[k].ImgUrlPc = researchList[knum]
+			} else {
+				result[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
+			}
+			result[k].Source = 1
+		}
+	}
+	//记录用户搜索关键词
+	var source int
+	if listType == 1 {
+		source = 3
+	} else if listType == 2 {
+		source = 1
+	} else {
+		source = 2
+	}
+	go services.AddSearchKeyWord(user, keyWord, source)
+
+	if chartTotal > int(total) {
+		total = int64(chartTotal)
+	}
+	if listType == 1 {
+		total = total + int64(chartTotal)
+	}
+	if len(result) == 0 {
+		result = make([]*models.SearchItem, 0)
+	}
 	page := paging.GetPaging(currentIndex, pageSize, int(total))
 	resp.Paging = page
 	resp.List = result

+ 25 - 6
controllers/user.go

@@ -802,6 +802,7 @@ func (this *UserController) ApplyTryOut() {
 	var title string
 	tryType := req.TryType
 	detailId := req.DetailId
+
 	if tryType == "Article" {
 		detail, err := models.GetArticleDetailById(detailId)
 		if err != nil {
@@ -818,6 +819,24 @@ func (this *UserController) ApplyTryOut() {
 			return
 		}
 		title = detail.ActivityName
+	} else if tryType == "MicroAudio" {
+		// 微路演音频
+		microAudio, e := models.GetCygxActivityVoiceById(detailId)
+		if e != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "微路演音频信息有误, 不存在的VoiceId: " + strconv.Itoa(detailId)
+			return
+		}
+		title = microAudio.VoiceName
+	} else if tryType == "MicroVideo" {
+		// 微路演视频
+		microVideo, e := models.GetMicroRoadshowVideoById(detailId)
+		if e != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "微路演视频信息有误, 不存在的VideoId: " + strconv.Itoa(detailId)
+			return
+		}
+		title = microVideo.VideoName
 	}
 
 	fmt.Println(title)
@@ -1037,12 +1056,12 @@ func (this *UserController) CountryCcode() {
 		br.Ret = 408
 		return
 	}
-	if uid == 0 {
-		br.Msg = "请登录"
-		br.ErrMsg = "请登录,用户信息为空"
-		br.Ret = 408
-		return
-	}
+	//if uid == 0 {
+	//	br.Msg = "请登录"
+	//	br.ErrMsg = "请登录,用户信息为空"
+	//	br.Ret = 408
+	//	return
+	//}
 	resp := new(models.CountryCode)
 	if user.CountryCode == "" && len(user.Mobile) >= 11 {
 		err := models.ChangeUserOutboundMobileByMobile(uid)

+ 1 - 0
models/activity.go

@@ -75,6 +75,7 @@ type Activity struct {
 }
 type ActivityIdRep struct {
 	ActivityId int `description:"活动id"`
+	PlaySeconds int `description:"播放时长"`
 }
 
 type ActivitySingnupRep struct {

+ 110 - 5
models/activity_signup_detail.go

@@ -43,15 +43,15 @@ func GetActivitySattusToComplete() (items []*CygxActivity, err error) {
 		}
 	}()
 	o := orm.NewOrm()
-	resultTime_30 := time.Now().Add(-time.Minute * 30).Format(utils.FormatDateTime)
-	resultTime_60 := time.Now().Add(-time.Minute * 60).Format(utils.FormatDateTime)
+	//resultTime_30 := time.Now().Add(-time.Minute * 30).Format(utils.FormatDateTime)
+	//resultTime_60 := time.Now().Add(-time.Minute * 60).Format(utils.FormatDateTime)
 	startTime := time.Now().Format(utils.FormatDate)
 	var condition string
-	condition += ` AND (activity_type_id IN ( 1, 2, 3, 7 ) AND  activity_time < '` + resultTime_30 + `'  AND  activity_time > '` + startTime + `')`
+	condition += `  AND  activity_time > '` + startTime + `'`
 	//condition += ` AND (activity_type_id IN ( 1, 2, 3, 7 ) AND  activity_time < '` + resultTime_30 + `')`
-	condition += ` OR(activity_type_id IN ( 4, 5, 6 ) AND  activity_time < '` + resultTime_60 + `')`
+	//condition += ` OR(activity_type_id IN ( 4, 5, 6 ) AND  activity_time < '` + resultTime_60 + `')`
 	//condition += ` OR(activity_type_id IN ( 4, 5, 6 ) AND  activity_time < '` + resultTime_60 + `'  AND  activity_time > '` + startTime + `')`
-	sql := " SELECT * FROM cygx_activity   WHERE 1 = 1 " + condition
+	sql := " SELECT * FROM cygx_activity   WHERE 1 = 1  AND active_state = 3 " + condition
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
@@ -141,3 +141,108 @@ func UpdateActivitySignupDetailMulti(items []*CygxActivitySignupDetail) (err err
 	}
 	return
 }
+
+type CygxActivitySignupDetailCopy struct {
+	Id                    int       `orm:"column(id);pk"`
+	ActivityId            int       `description:"活动ID"`
+	UserId                int       `description:"用户ID"`
+	CreateTime            time.Time `description:"创建时间"`
+	Mobile                string    `description:"手机号"`
+	Email                 string    `description:"邮箱"`
+	CompanyId             int       `description:"公司id"`
+	CompanyName           string    `description:"公司名称"`
+	FailType              int       `description:"失败原因,0,未失败,1总人数已满,2单机构超限制,3,爽约次数超限"`
+	SignupType            int       `description:"报名方式,1预约外呼,2自主拨入,3我要报名"`
+	DoFailType            int       `description:"失败原因,0,未失败,1总人数已满,2单机构超限制,3,爽约次数超限"`
+	OutboundMobile        string    `description:"外呼手机号"`
+	CountryCode           string    `description:"手机国家区号"`
+	RealName              string    `description:"用户实际名称"`
+	SellerName            string    `description:"所属销售"`
+	FirstMeetingTime      string    `description:"首次入会时间"`
+	LastMeetingTime       string    `description:"最后退出时间"`
+	Duration              string    `description:"参会时长"`
+	MeetingTypeStr        string    `description:"参会方式"`
+	MeetingAuthentication string    `description:"参会权鉴"`
+	MeetingStatusStr      string    `description:"参会状态"`
+	Position              string    `description:"职位"`
+	IsMeeting             int       `description:"是否到会,1到会,0未到会"`
+	UseridEntity          int       `description:"参会者身份. 1:主讲人, 2:主持人, 3:嘉宾, 4:普通参会者, 5:联席主讲人, 6:会议助理"`
+	ActivityTime          string    `description:"活动时间"`
+	CrmCompanyMapStatusId int       `description:"转换后的对应状态信息:1=正式客户, 2=曾使用客户, 3=其他"`
+}
+
+//添加
+func AddCygxActivitySignupDetailCopy(items []*CygxActivitySignupDetailCopy) (err error) {
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+	if len(items) > 0 {
+		//批量添加
+		_, err = o.InsertMulti(len(items), items)
+		if err != nil {
+			return err
+		}
+	}
+	return
+}
+
+// UpdateActivitySignupDetailMulti 批量修改用户报名信息且报名的人
+func UpdateActivitySignupDetailMultiCopy(items []*CygxActivitySignupDetailCopy) (err error) {
+	o := orm.NewOrm()
+	p, err := o.Raw(` UPDATE cygx_activity_signup_detail_copy SET 
+							first_meeting_time = ?,
+							last_meeting_time = ?,
+							duration = ?,
+							meeting_type_str = ?,
+							meeting_authentication = ?,
+							meeting_status_str = ?,
+							position = ?,
+							is_meeting = ?,
+							userid_entity = ?,
+							activity_time = ?,
+							crm_company_map_status_id = ?
+							WHERE mobile = ? AND activity_id = ? `).Prepare()
+	if err != nil {
+		return
+	}
+	defer func() {
+		_ = p.Close() // 别忘记关闭 statement
+	}()
+	for _, v := range items {
+		_, err = p.Exec(
+			v.FirstMeetingTime,
+			v.LastMeetingTime,
+			v.Duration,
+			v.MeetingTypeStr,
+			v.MeetingAuthentication,
+			v.MeetingStatusStr,
+			v.Position,
+			v.IsMeeting,
+			v.UseridEntity,
+			v.ActivityTime,
+			v.CrmCompanyMapStatusId,
+			v.Mobile, v.ActivityId)
+		if err != nil {
+			return
+		}
+	}
+	return
+}
+
+// 获取参会记录表列表
+func GetSignupDetailListCopy(condition string, pars []interface{}) (list []*CygxActivitySignupDetail, err error) {
+	sql := `SELECT * FROM cygx_activity_signup_detail_copy  WHERE  1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
+	return
+}

+ 16 - 0
models/activity_voice.go

@@ -13,6 +13,8 @@ type CygxActivityVoice struct {
 	VoiceUrl         string    `description:"音频地址"`
 	VoiceName        string    `description:"音频名称"`
 	VoicePlaySeconds string    `description:"音频时长"`
+	VoiceCounts         int    `description:"播放量"`
+	ModifyTime          string `description:"更新时间"`
 	CreateTime       time.Time `description:"创建时间"`
 }
 
@@ -46,3 +48,17 @@ func GetCygxActivityVoiceReqList(activityIds []int) (items []*CygxActivityVoiceR
 	_, err = o.Raw(sql, endTime, activityIds).QueryRows(&items)
 	return
 }
+
+func UpdateCygxActivityVoiceCounts(activityId int) (err error) {
+	sql := `UPDATE cygx_activity_voice SET voice_counts = voice_counts+1 WHERE activity_id = ?  `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, activityId).Exec()
+	return
+}
+
+// GetCygxActivityVoiceById 主键获取活动音频
+func GetCygxActivityVoiceById(videoId int) (item *CygxActivityVoice, err error) {
+	sql := `SELECT * FROM cygx_activity_voice WHERE activity_voice_id = ? LIMIT 1`
+	err = orm.NewOrm().Raw(sql, videoId).QueryRow(&item)
+	return
+}

+ 17 - 1
models/activity_voice_history.go

@@ -15,7 +15,9 @@ type CygxActivityVoiceHistory struct {
 	CompanyId   int       `description:"公司id"`
 	CompanyName string    `description:"公司名称"`
 	RealName    string    `description:"用户实际名称"`
-	SellerName  string    `description:"所属销售"`
+	SellerName      string    `description:"所属销售"`
+	PlaySeconds     string    `description:"播放时间 单位s"`
+	ModifyTime      time.Time `description:"视频修改时间"`
 }
 
 //添加
@@ -24,3 +26,17 @@ func AddCygxActivityVoiceHistory(item *CygxActivityVoiceHistory) (err error) {
 	_, err = o.Insert(item)
 	return
 }
+
+func GetLastCygxActivityVoiceHistory(activityId, userId int) (item *CygxActivityVoiceHistory, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT * FROM cygx_activity_voice_history WHERE activity_id=? AND user_id=? ORDER BY create_time DESC limit 1 `
+	err = o.Raw(sql, activityId, userId).QueryRow(&item)
+	return
+}
+
+func UpdateLastCygxActivityVoiceHistory(playSeconds string, lastId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` UPDATE cygx_activity_voice_history SET play_seconds =? WHERE id=? `
+	_, err = o.Raw(sql, playSeconds, lastId).Exec()
+	return
+}

+ 25 - 22
models/article.go

@@ -82,26 +82,28 @@ func AddCygxArticle(item *CygxArticle) (lastId int64, err error) {
 }
 
 type HomeArticle struct {
-	ArticleId        int    `description:"文章id"`
-	Title            string `description:"标题"`
-	TitleEn          string `description:"英文标题 "`
-	UpdateFrequency  string `description:"更新周期"`
-	CreateDate       string `description:"创建时间"`
-	PublishDate      string `description:"发布时间"`
-	Body             string `description:"内容"`
-	BodyHtml         string `description:"内容带有HTML标签"`
-	Abstract         string `description:"摘要"`
-	CategoryName     string `description:"一级分类"`
-	SubCategoryName  string `description:"二级分类"`
-	ExpertBackground string `description:"专家背景"`
-	IsResearch       bool   `description:"是否属于研选"`
-	Pv               int    `description:"PV"`
-	ImgUrlPc         string `description:"图片链接"`
-	CategoryId       string `description:"文章分类"`
-	HttpUrl          string `description:"文章链接跳转地址"`
-	IsNeedJump       bool   `description:"是否需要跳转链接地址"`
-	Source           int    `description:"来源  1:文章, 2:图表"`
-	Annotation       string `description:"核心观点"`
+	ArticleId        int                  `description:"文章id"`
+	Title            string               `description:"标题"`
+	TitleEn          string               `description:"英文标题 "`
+	UpdateFrequency  string               `description:"更新周期"`
+	CreateDate       string               `description:"创建时间"`
+	PublishDate      string               `description:"发布时间"`
+	Body             string               `description:"内容"`
+	BodyHtml         string               `description:"内容带有HTML标签"`
+	Abstract         string               `description:"摘要"`
+	CategoryName     string               `description:"一级分类"`
+	SubCategoryName  string               `description:"二级分类"`
+	ExpertBackground string               `description:"专家背景"`
+	IsResearch       bool                 `description:"是否属于研选"`
+	Pv               int                  `description:"PV"`
+	ImgUrlPc         string               `description:"图片链接"`
+	CategoryId       string               `description:"文章分类"`
+	HttpUrl          string               `description:"文章链接跳转地址"`
+	IsNeedJump       bool                 `description:"是否需要跳转链接地址"`
+	Source           int                  `description:"来源  1:文章, 2:图表"`
+	Annotation       string               `description:"核心观点"`
+	HomeType         int                  `description:"数据类型:0-纪要(默认); 1-微路演音频"`
+	MicroAudio       *MicroAudioUnionList `description:"微路演音频"`
 }
 
 type ArticleDetail struct {
@@ -261,8 +263,9 @@ func GetArticleAll() (item []*ArticleDetail, err error) {
 }
 func GetArticleAllDate(endDate string) (item []*ArticleDetail, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM cygx_article WHERE is_summary=1 AND publish_date >= ?  `
-	_, err = o.Raw(sql, endDate).QueryRows(&item)
+	sql := `SELECT * FROM cygx_article WHERE is_summary=1 AND publish_date >= ? AND  article_id = 7297  `
+	sql = `SELECT * FROM cygx_article WHERE article_id = ?  `
+	_, err = o.Raw(sql, 7297).QueryRows(&item)
 	return
 }
 

+ 34 - 0
models/config.go

@@ -5,6 +5,13 @@ import (
 	"time"
 )
 
+var (
+	HomeHeaderTabConfigKey              = "home_header_tab"
+	MicroRoadShowListDataRatioConfigKey = "micro_roadshow_list_data_ratio"
+	HomeNewListAudioNumKey              = "home_new_list_audio_num"
+	MicroRoadshowDefaultImgKey          = "micro_roadshow_default_img"
+)
+
 type CygxConfig struct {
 	ConfigId    int    `json:"-" orm:"column(config_id);pk"`
 	ConfigCode  string `json:"-"`
@@ -63,3 +70,30 @@ func GetHotSearch() (permission string, err error) {
 	err = o.Raw(sql).QueryRow(&permission)
 	return
 }
+
+// HomeHeaderTabList 首页头部导航列表
+type HomeHeaderTabList struct {
+	Home       []*HomeHeaderTab `description:"首页"`
+	SearchPage []*HomeHeaderTab `description:"搜索页"`
+}
+
+// HomeHeaderTab 首页头部导航
+type HomeHeaderTab struct {
+	Id     int    `description:"导航ID"`
+	Name   string `description:"导航名称"`
+	IsShow bool   `description:"是否展示"`
+}
+
+// MicroRoadShowDefaultImgList 微路演行业默认背景图列表
+type MicroRoadShowDefaultImgList struct {
+	Audio []*MicroRoadShowDefaultImg `description:"音频"`
+	Video []*MicroRoadShowDefaultImg `description:"视频"`
+}
+
+// MicroRoadShowDefaultImg 微路演行业默认背景图
+type MicroRoadShowDefaultImg struct {
+	ChartPermissionId   int    `description:"行业ID"`
+	ChartPermissionName string `description:"行业名称"`
+	ImgUrl              string `description:"背景图"`
+	ShareImg            string `description:"分享图"`
+}

+ 3 - 0
models/db.go

@@ -121,6 +121,9 @@ func init() {
 		new(CygxIndustrialArticleGroupManagement),
 		new(ArticleTopHistoryRecord),
 		new(CygxActivitySignupDetail),
+		new(CygxActivitySignupDetailCopy),
+		new(CygxMicroRoadshowVideoHistory),
+		new(MicroRoadshowVideo),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 266 - 0
models/micro_roadshow.go

@@ -0,0 +1,266 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"time"
+)
+
+// MicroRoadShowListResp 微路演列表响应体
+type MicroRoadShowListResp struct {
+	Paging *paging.PagingItem
+	List   []*MicroRoadShowPageList
+}
+
+// MicroRoadShowPageList 微路演列表
+type MicroRoadShowPageList struct {
+	Id                  int    `description:"音视频ID"`
+	Title               string `description:"标题"`
+	ResourceUrl         string `description:"链接"`
+	Type                int    `description:"类型: 1-音频; 2-视频"`
+	PublishTime         string `description:"发布时间"`
+	BackgroundImg       string `description:"背景图"`
+	ShareImg            string `description:"分享封面图"`
+	ChartPermissionId   int    `description:"行业ID"`
+	ChartPermissionName string `description:"行业名称"`
+	PlaySeconds         string `description:"音视频时长"`
+	ActivityId          int    `description:"活动ID"`
+	AuthInfo            *UserPermissionAuthInfo
+}
+
+// GetMicroRoadShowAudioPageList 获取微路演音频列表-分页
+func GetMicroRoadShowAudioPageList(startSize, pageSize int, condition string, pars []interface{}) (total int, list []*MicroRoadShowPageList, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+				a.activity_voice_id AS id,
+				a.voice_name AS title,
+				a.voice_url AS resource_url,
+				1 AS type,
+				b.activity_time AS publish_time,
+				b.chart_permission_id,
+				b.chart_permission_name,
+				a.voice_play_seconds AS play_seconds,
+				a.img_url AS background_img,
+				a.activity_id
+			FROM
+				cygx_activity_voice AS a
+			JOIN cygx_activity AS b ON a.activity_id = b.activity_id
+			WHERE 1 = 1 `
+	if condition != `` {
+		sql += condition
+	}
+	sql += ` ORDER BY publish_time DESC`
+
+	totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
+	err = o.Raw(totalSql, pars).QueryRow(&total)
+	if err != nil {
+		return
+	}
+
+	sql += ` LIMIT ?,?`
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
+	return
+}
+
+// GetMicroRoadShowVideoPageList 获取微路演视频列表-分页
+func GetMicroRoadShowVideoPageList(startSize, pageSize int, condition string, pars []interface{}) (total int, list []*MicroRoadShowPageList, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+				video_id AS id,
+				video_name AS title,
+				video_url AS resource_url,
+				2 AS type,
+				publish_date AS publish_time,
+				chart_permission_id,
+				chart_permission_name,
+				video_duration AS play_seconds,
+				img_url AS background_img
+			FROM
+				cygx_micro_roadshow_video
+			WHERE
+				publish_status = 1 `
+	if condition != `` {
+		sql += condition
+	}
+	sql += ` ORDER BY publish_time DESC`
+
+	totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
+	err = o.Raw(totalSql, pars).QueryRow(&total)
+	if err != nil {
+		return
+	}
+
+	sql += ` LIMIT ?,?`
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
+	return
+}
+
+type AddVideoHistoryReq struct {
+	VideoId     int `description:"视频ID"`
+	PlaySeconds int `description:"播放时长"`
+}
+
+type CygxMicroRoadshowVideoHistory struct {
+	Id          int       `orm:"column(id);pk"description:"微路演视频浏览记录表id"`
+	VideoId     int       `description:"微路演视频id"`
+	UserId      int       `description:"用户id"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司Id"`
+	CompanyName string    `description:"公司名称"`
+	RealName    string    `description:"用户实际名称"`
+	SellerName  string    `description:"所属销售"`
+	PlaySeconds string    `description:"播放时间 单位s"`
+	CreateTime  time.Time `description:"视频创建时间"`
+	ModifyTime  time.Time `description:"视频修改时间"`
+}
+
+func GetLastCygxMicroRoadshowVideoHistory(videoId, userId int) (item *CygxMicroRoadshowVideoHistory, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT * FROM cygx_micro_roadshow_video_history WHERE video_id=? AND user_id=? ORDER BY create_time DESC limit 1 `
+	err = o.Raw(sql, videoId, userId).QueryRow(&item)
+	return
+}
+
+func AddCygxMicroRoadshowVideoHistory(item *CygxMicroRoadshowVideoHistory) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+// MicroAudioUnionList 微路演音频联合列表
+type MicroAudioUnionList struct {
+	Id                       int    `description:"音视频ID"`
+	AudioTitle               string `description:"标题"`
+	AudioResourceUrl         string `description:"链接"`
+	AudioType                int    `description:"类型: 1-音频; 2-视频"`
+	AudioPublishTime         string `description:"发布时间"`
+	AudioImgUrl              string `description:"背景图"`
+	AudioShareImg            string `description:"分享图"`
+	AudioChartPermissionId   int    `description:"行业ID"`
+	AudioChartPermissionName string `description:"行业名称"`
+	AudioPlaySeconds         string `description:"音视频时长"`
+	AudioActivityId          int    `description:"活动ID"`
+	AuthInfo                 *UserPermissionAuthInfo
+}
+
+// HomeNewestUnionList 首页最新纪要-音频联合查询结果
+type HomeNewestUnionList struct {
+	ArticleId        int    `description:"文章id"`
+	Title            string `description:"标题"`
+	TitleEn          string `description:"英文标题 "`
+	UpdateFrequency  string `description:"更新周期"`
+	CreateDate       string `description:"创建时间"`
+	PublishDate      string `description:"发布时间"`
+	Body             string `description:"内容"`
+	BodyHtml         string `description:"内容带有HTML标签"`
+	Abstract         string `description:"摘要"`
+	CategoryName     string `description:"一级分类"`
+	SubCategoryName  string `description:"二级分类"`
+	ExpertBackground string `description:"专家背景"`
+	IsResearch       bool   `description:"是否属于研选"`
+	Pv               int    `description:"PV"`
+	ImgUrlPc         string `description:"图片链接"`
+	CategoryId       string `description:"文章分类"`
+	HttpUrl          string `description:"文章链接跳转地址"`
+	IsNeedJump       bool   `description:"是否需要跳转链接地址"`
+	Source           int    `description:"来源  1:文章, 2:图表"`
+	Annotation       string `description:"核心观点"`
+	HomeType         int    `description:"数据类型:0-纪要(默认); 1-微路演音频"`
+	MicroAudioUnionList
+}
+
+// GetHomeNewestListUnionList 首页最新纪要-音频联合查询
+func GetHomeNewestListUnionList(condition string, pars []interface{}, startSize, pageSize int) (list []*HomeNewestUnionList, err error) {
+	sql := `SELECT
+				id, article_id, title, title_en, update_frequency, create_date, publish_date, body, abstract, category_name, sub_category_name, expert_background, category_id, source, annotation,
+				(SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = art.article_id ) as pv,
+				0 AS home_type, "" AS audio_title, "" AS audio_resource_url, 0 AS audio_type, "" AS audio_publish_time, 0 AS audio_chart_permission_id, "" AS audio_chart_permission_name,
+				"" AS audio_play_seconds, "" AS audio_img_url, 0 AS audio_activity_id
+			FROM
+				cygx_article AS art
+			WHERE
+				art.publish_status = 1 `
+	if condition != `` {
+		sql += condition
+	}
+	sql += ` UNION ALL
+			
+			SELECT
+				a.activity_voice_id, 0, "", "", "", "", b.activity_time, "", "", "", "", "", 0, 0, "",
+				0, 1, a.voice_name, a.voice_url, 1, b.activity_time,
+				b.chart_permission_id, b.chart_permission_name, a.voice_play_seconds AS audio_play_seconds, a.img_url AS audio_img_url, a.activity_id AS audio_activity_id
+			FROM
+				cygx_activity_voice AS a
+			JOIN cygx_activity AS b ON a.activity_id = b.activity_id`
+	sql += ` ORDER BY publish_date DESC`
+	sql += ` LIMIT ?,?`
+	_, err = orm.NewOrm().Raw(sql, pars, startSize, pageSize).QueryRows(&list)
+	return
+}
+
+// GetHomeNewestListUnionCount 首页最新纪要-音频联合查询总数
+func GetHomeNewestListUnionCount(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+				COUNT(1) AS count
+			FROM
+				(
+					SELECT
+						art.id
+					FROM
+						cygx_article AS art
+					WHERE
+						art.publish_status = 1 `
+	if condition != `` {
+		sql += condition
+	}
+	sql += ` UNION ALL
+				SELECT
+					a.activity_voice_id
+				FROM
+					cygx_activity_voice AS a
+				JOIN cygx_activity AS b ON a.activity_id = b.activity_id
+			) z `
+	err = o.Raw(sql, pars).QueryRow(&count)
+	return
+}
+
+func UpdateLastCygxActivityVideoHistory(playSeconds string, lastId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` UPDATE cygx_micro_roadshow_video_history SET play_seconds =? WHERE id=? `
+	_, err = o.Raw(sql, playSeconds, lastId).Exec()
+	return
+}
+
+// MicroRoadshowVideo 微路演视频
+type MicroRoadshowVideo struct {
+	VideoId             int       `orm:"column(video_id);pk" description:"视频ID"`
+	VideoName           string    `description:"视频标题"`
+	ChartPermissionId   int       `description:"行业ID"`
+	ChartPermissionName string    `description:"行业名称"`
+	IndustryId          int       `description:"产业ID"`
+	IndustryName        string    `description:"产业名称"`
+	PublishStatus       int       `description:"发布状态:0-未发布;1-已发布"`
+	ModifyDate          time.Time `description:"更新时间"`
+	PublishDate         time.Time `description:"发布时间"`
+	VideoCounts         int       `description:"视频播放量"`
+	VideoDuration       int       `description:"视频时长"`
+	VideoUrl            string    `description:"视频地址"`
+	CreateTime          time.Time `description:"创建时间"`
+	ImgUrl              string    `description:"背景图链接"`
+}
+
+// GetMicroRoadshowVideoById 主键获取微路演视频
+func GetMicroRoadshowVideoById(videoId int) (item *MicroRoadshowVideo, err error) {
+	sql := `SELECT * FROM cygx_micro_roadshow_video WHERE video_id = ? LIMIT 1`
+	err = orm.NewOrm().Raw(sql, videoId).QueryRow(&item)
+	return
+}
+
+func UpdateCygxActivityVideoCounts(activityId int) (err error) {
+	sql := `UPDATE cygx_micro_roadshow_video SET video_counts = video_counts+1 WHERE video_id = ?  `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, activityId).Exec()
+	return
+}

+ 46 - 7
models/report.go

@@ -109,6 +109,23 @@ func IndustrialToArticleCategory(industrialManagementId, chartPermissionId int)
 	return
 }
 
+//产业下所关联的文章分类列表 2022-10-13
+func IndustrialToArticleCategoryNew(industrialManagementId int) (items []*IndustrialToArticleCategoryRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT map.match_type_name,map.category_id
+    FROM cygx_report_mapping AS map
+	INNER JOIN cygx_article AS art ON art.category_id = map.category_id
+	INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = art.article_id
+	WHERE map.report_type = 2
+	AND map.is_report = 1
+    AND art.is_report = 1
+    AND art.publish_status = 1
+	AND man_g.industrial_management_id =?
+	GROUP BY map.match_type_name`
+	_, err = o.Raw(sql, industrialManagementId).QueryRows(&items)
+	return
+}
+
 //判断用户是否阅读该产业下,某一分类的文章
 func IndustrialUserRecordArticleCount(userId, industrialManagementId, categoryId int) (count int, err error) {
 	o := orm.NewOrm()
@@ -208,12 +225,22 @@ func GetWhichDepartmentCount(condition string) (count int, err error) {
 }
 
 type IsShow struct {
-	IsShow          bool   `description:"绝密内参按钮是否展示"`
-	IsShowResearch  bool   `description:"研选是否展示限免"`
-	IsShowChart     bool   `description:"图表是否展示限免"`
-	IsShowList      bool   `description:"榜单是否展示"`
-	LinkWxExplain   string `description:"关注微信公众号链接说明地址"`
-	YanXuan_Explain bool   `description:"研选说明"`
+	IsShow           bool      `description:"绝密内参按钮是否展示"`
+	IsShowFreeButton bool      `description:"免费送月卡按钮是否展示"`
+	IsShowResearch   bool      `description:"研选是否展示限免"`
+	IsShowChart      bool      `description:"图表是否展示限免"`
+	IsShowList       bool      `description:"榜单是否展示"`
+	LinkWxExplain    string    `description:"关注微信公众号链接说明地址"`
+	YanXuan_Explain  bool      `description:"研选说明"`
+	SearchTxtList    SearchTxt `description:"搜索栏回显内容说明"`
+}
+
+type SearchTxt struct {
+	SummarySearch  string `description:"素材库搜索说明"`
+	ReportSearch   string `description:"报告搜索说明"`
+	YanXuanSearch  string `description:"研选搜索说明"`
+	ActivitySearch string `description:"活动搜索说明"`
+	TabSearch      string `description:"素材库搜索说明"`
 }
 
 //获取用户是否有查看权限
@@ -664,8 +691,16 @@ type SearchResourceResp struct {
 	ListYx []*IndustrialManagementHotResp `description:"研选"`
 }
 
+//搜索资源包 start
+type SearchReportAndResourceResp struct {
+	ListHzResource []*IndustrialManagementHotResp `description:"弘则资源包"`
+	ListYxResource []*IndustrialManagementHotResp `description:"研选资源包"`
+	ListYxReport   []*ArticleCollectionResp       `description:"研选报告"`
+	ListHzReport   []*ArticleCollectionResp       `description:"弘则报告"`
+}
+
 //产业列表
-func GetSearchResourceList(condition string) (items []*IndustrialManagementHotResp, err error) {
+func GetSearchResourceList(condition string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
 			m.industry_name,
@@ -679,6 +714,10 @@ func GetSearchResourceList(condition string) (items []*IndustrialManagementHotRe
 		WHERE
 			1 = 1
 			AND publish_status = 1 ` + condition + `  GROUP BY m.industrial_management_id  ORDER BY publish_date_order DESC `
+
+	if startSize > 0 || pageSize > 0 {
+		sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
+	}
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }

+ 10 - 1
models/user.go

@@ -211,7 +211,7 @@ type ApplyTryReq struct {
 	RealName        string `description:"姓名"`
 	CompanyName     string `description:"公司名称"`
 	ApplyMethod     int    `description:"1:已付费客户申请试用,2:非客户申请试用,3:非客户申请试用(ficc下,不需要进行数据校验)"`
-	TryType         string `description:"提交类型,Article:文章、Activity:活动"`
+	TryType         string `description:"提交类型,Article:文章、Activity:活动; MicroVideo-微路演视频"`
 	DetailId        int    `description:"详情ID"`
 }
 
@@ -463,3 +463,12 @@ func UpdateUserInteractionNum(interactionNum, userId int) (err error) {
 	_, err = o.Raw(sql, interactionNum, userId).Exec()
 	return
 }
+
+// UserPermissionAuthInfo 用户通用权限信息
+type UserPermissionAuthInfo struct {
+	HasPermission int    `description:"是否有权限:1-有权限; 2-无权限; 3-潜在客户未提交申请; 4-潜在客户已提交申请 5-仅有FICC权限"`
+	SellerMobile  string `description:"销售手机号"`
+	SellerName    string `description:"销售名称"`
+	OperationMode string `description:"操作方式:Apply-立即申请; Call-拨号"`
+	PopupMsg      string `description:"权限弹窗信息"`
+}

+ 45 - 0
routers/commentsRouter.go

@@ -547,6 +547,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:HomeController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:HomeController"],
+        beego.ControllerComments{
+            Method: "HeaderTab",
+            Router: `/header_tab`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:HomeController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:HomeController"],
         beego.ControllerComments{
             Method: "ListHome",
@@ -556,6 +565,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: "List",
+            Router: `/list`,
+            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",
+            Router: `/videoHistory/add`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportBillboardController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportBillboardController"],
         beego.ControllerComments{
             Method: "FllowList",
@@ -754,6 +781,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
+        beego.ControllerComments{
+            Method: "SearchReportAndResource",
+            Router: `/searchReportAndResource`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
         beego.ControllerComments{
             Method: "SearchResource",
@@ -871,6 +907,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:SearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:SearchController"],
+        beego.ControllerComments{
+            Method: "ListHomeArtAndChartPage",
+            Router: `/artAndChart/listPage`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:SearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:SearchController"],
         beego.ControllerComments{
             Method: "SearchList",

+ 5 - 0
routers/router.go

@@ -119,6 +119,11 @@ func init() {
 				&controllers.BaseYidongController{},
 			),
 		),
+		web.NSNamespace("/micro_roadshow",
+			web.NSInclude(
+				&controllers.MicroRoadShowController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 29 - 10
services/activity_signup_detail.go

@@ -32,12 +32,12 @@ func AddctivitySignupDetail(cont context.Context) (err error) {
 	var condition string
 	var pars []interface{}
 	if actLen > 0 {
-		//condition += ` AND activity_id IN (` + utils.GetOrmInReplace(actLen) + `)`
-		//pars = append(pars, activityIds)
+		condition += ` AND activity_id IN (` + utils.GetOrmInReplace(actLen) + `)`
+		pars = append(pars, activityIds)
 	} else {
 		return err
 	}
-	condition = ""
+	//condition = ""
 	//获取当天已经结束了 活动的报名人数
 	signUpList, err := models.GetSignupDetailBySignup(condition, pars)
 	if err != nil && err.Error() != utils.ErrNoRow() {
@@ -66,6 +66,7 @@ func AddctivitySignupDetail(cont context.Context) (err error) {
 				item.ActivityId = v.ActivityId
 				item.CreateTime = v.CreateTime
 				item.Mobile = v.Mobile
+				item.OutboundMobile = v.OutboundMobile
 				item.Email = v.Email
 				item.CompanyId = v.CompanyId
 				item.CompanyName = v.CompanyName
@@ -94,7 +95,6 @@ func AddctivitySignupDetail(cont context.Context) (err error) {
 
 //AddctivitySignupDetailByJmcj 通过进门财经添加用户参数信息
 func AddctivitySignupDetailByJmcj(itemsDetail []*models.CygxActivityAttendanceDetail, activityId int) (err error) {
-	fmt.Println()
 	defer func() {
 		if err != nil {
 			fmt.Println(err)
@@ -123,6 +123,20 @@ func AddctivitySignupDetailByJmcj(itemsDetail []*models.CygxActivityAttendanceDe
 			mapsignUpDetai[fmt.Sprint("ActivityId", v.ActivityId, "Mobile", v.Mobile)] = v.Mobile
 		}
 	}
+
+	//获取当天已经结束了 活动的报名人数
+	signUpList, err := models.GetSignupDetailBySignup(condition, pars)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return err
+	}
+	//建立外呼号与手机号的绑定
+	mapsignUp := make(map[string]string)
+	if len(signUpList) > 0 {
+		for _, v := range signUpList {
+			mapsignUp[fmt.Sprint(v.OutboundMobile)] = v.Mobile
+		}
+	}
+
 	var itemsAdd []*models.CygxActivitySignupDetail
 	var itemsUpdate []*models.CygxActivitySignupDetail
 
@@ -130,7 +144,13 @@ func AddctivitySignupDetailByJmcj(itemsDetail []*models.CygxActivityAttendanceDe
 		var item = new(models.CygxActivitySignupDetail)
 		item.ActivityId = v.ActivityId
 		item.RealName = v.RealName
-		item.Mobile = v.Mobile
+		//如果手机号存在那么就是报名的,不存在就是直接参与的
+		if _, ok := mapsignUp[v.Mobile]; ok {
+			item.Mobile = mapsignUp[v.Mobile]
+		} else {
+			item.Mobile = v.Mobile
+		}
+		item.OutboundMobile = v.Mobile
 		item.CompanyName = v.CompanyName
 		item.CompanyId = v.CompanyId
 		item.SellerName = v.SellerName
@@ -146,15 +166,14 @@ func AddctivitySignupDetailByJmcj(itemsDetail []*models.CygxActivityAttendanceDe
 		item.UseridEntity = v.UseridEntity
 		item.ActivityTime = v.ActivityTime
 		item.CrmCompanyMapStatusId = v.CrmCompanyMapStatusId
-		//fmt.Println(item)
-		//return err
-		if _, ok := mapsignUpDetai[fmt.Sprint("ActivityId", v.ActivityId, "Mobile", v.Mobile)]; !ok {
+
+		if _, ok := mapsignUpDetai[fmt.Sprint("ActivityId", v.ActivityId, "Mobile", item.Mobile)]; !ok {
 			itemsAdd = append(itemsAdd, item)
 		} else {
 			itemsUpdate = append(itemsUpdate, item)
 		}
 	}
-
+	//return err
 	if len(itemsAdd) > 0 {
 		err = models.AddCygxActivitySignupDetail(itemsAdd)
 		if err != nil {
@@ -162,7 +181,7 @@ func AddctivitySignupDetailByJmcj(itemsDetail []*models.CygxActivityAttendanceDe
 		}
 	}
 
-	if len(itemsAdd) > 0 {
+	if len(itemsUpdate) > 0 {
 		err = models.UpdateActivitySignupDetailMulti(itemsUpdate)
 		if err != nil {
 			return

+ 154 - 494
services/elastic.go

@@ -425,491 +425,6 @@ func EsDeleteData(indexName, docId string) (err error) {
 	return
 }
 
-func MappingModify(indexName, mappingJson string) {
-	client := utils.Client
-	//if err != nil {
-	//	return
-	//}
-	result, err := client.PutMapping().Index(indexName).BodyString(mappingJson).Do(context.Background())
-	fmt.Println(err)
-	fmt.Println(result)
-	return
-}
-
-func EsMatchQuery(indexName, keyWord string) (result []*models.SearchItem, err error) {
-	client := utils.Client
-	pageSize := 20
-	keyWordArr, err := GetIndustryMapNameSliceV2(keyWord)
-	fmt.Println(keyWordArr)
-	keyWordArr = RemoveDuplicatesAndEmpty(keyWordArr)
-	fmt.Println("-------------------------------")
-	fmt.Println(keyWordArr)
-	searchMap := make(map[int]int)
-	boolquery := elastic.NewBoolQuery()
-	keyLen := len(keyWordArr)
-	n := 5.0 * float64(keyLen)
-	matchArr := make([]elastic.Query, 0)
-	//
-	//matchq1 := elastic.NewMatchQuery("Title", keyWord).Boost(n + 1).Analyzer("ik_smart")
-	//matchq2 := elastic.NewMatchQuery("BodyText", keyWord).Boost(n + 1).Analyzer("ik_smart")
-	//
-	//matchArr = append(matchArr, matchq1)
-	//matchArr = append(matchArr, matchq2)
-	for _, v := range keyWordArr {
-		if v != "" {
-			matchq1 := elastic.NewMatchQuery("Title", v).Boost(n).Analyzer("ik_smart")
-			matchq2 := elastic.NewMatchQuery("BodyText", v).Boost(n).Analyzer("ik_smart")
-			matchArr = append(matchArr, matchq1)
-			matchArr = append(matchArr, matchq2)
-		}
-		n = n - 5
-	}
-	boolquery.Should(matchArr...)
-	highlight := elastic.NewHighlight()
-	highlight = highlight.Fields(elastic.NewHighlighterField("Title"), elastic.NewHighlighterField("BodyText"))
-	highlight = highlight.PreTags("<font color='red'>").PostTags("</font>")
-	request := client.Search(indexName).Highlight(highlight).Size(pageSize).Query(boolquery)
-	searchByMatch, err := request.Do(context.Background())
-	if searchByMatch.Hits != nil {
-		for _, v := range searchByMatch.Hits.Hits {
-			articleJson, err := v.Source.MarshalJSON()
-			if err != nil {
-				return nil, err
-			}
-			article := new(models.CygxArticle)
-			err = json.Unmarshal(articleJson, &article)
-			if err != nil {
-				return nil, err
-			}
-			if _, ok := searchMap[article.ArticleId]; !ok {
-				searchItem := new(models.SearchItem)
-				searchItem.ArticleId, _ = strconv.Atoi(v.Id)
-				if len(v.Highlight["BodyText"]) > 0 {
-					searchItem.Body = v.Highlight["BodyText"]
-				} else {
-					bodyRune := []rune(article.BodyText)
-					bodyRuneLen := len(bodyRune)
-					if bodyRuneLen > 100 {
-						bodyRuneLen = 100
-					}
-					body := string(bodyRune[:bodyRuneLen])
-					fmt.Println(body)
-					searchItem.Body = []string{body}
-				}
-				var title string
-				if len(v.Highlight["Title"]) > 0 {
-					title = v.Highlight["Title"][0]
-				} else {
-					title = article.Title
-				}
-				searchItem.Title = title
-				searchItem.PublishDate = article.PublishDate
-				result = append(result, searchItem)
-				searchMap[article.ArticleId] = article.ArticleId
-			}
-		}
-	}
-	return
-}
-
-func EsMatchPhraseQuery(indexName, keyWord string) (result []*models.SearchItem, err error) {
-	client := utils.Client
-	pageSize := 20
-	keyWordArr, err := GetIndustryMapNameSliceV2(keyWord)
-	fmt.Println(keyWordArr)
-	keyWordArr = RemoveDuplicatesAndEmpty(keyWordArr)
-	fmt.Println("-------------------------------")
-	fmt.Println(keyWordArr)
-	searchMap := make(map[int]int)
-	boolquery := elastic.NewBoolQuery()
-	//keyLen := len(keyWordArr)
-	//n := float64(keyLen)
-	matchArr := make([]elastic.Query, 0)
-	//matchq1 := elastic.NewMatchQuery("Title", keyWord).Boost(n + 1).Analyzer("ik_smart")
-	//matchq2 := elastic.NewMatchQuery("BodyText", keyWord).Boost(n + 1).Analyzer("ik_smart")
-	matchq1 := elastic.NewMatchPhraseQuery("Title", keyWord) //.Analyzer("ik_smart")
-	matchq2 := elastic.NewMatchPhraseQuery("BodyText", keyWord)
-	matchArr = append(matchArr, matchq1)
-	matchArr = append(matchArr, matchq2)
-	//matchArr = append(matchArr, matchq2)
-	//for _, v := range keyWordArr {
-	//	if v != "" {
-	//		matchq1 := elastic.NewMatchQuery("Title", v).Boost(n).Analyzer("ik_smart")
-	//		matchq2 := elastic.NewMatchQuery("BodyText", v).Boost(n).Analyzer("ik_smart")
-	//		matchArr = append(matchArr, matchq1)
-	//		matchArr = append(matchArr, matchq2)
-	//	}
-	//	n--
-	//}
-	//boolquery.Should(matchArr...)
-
-	boolquery.Should(matchArr...)
-
-	highlight := elastic.NewHighlight()
-	highlight = highlight.Fields(elastic.NewHighlighterField("Title"), elastic.NewHighlighterField("BodyText"))
-	highlight = highlight.PreTags("<font color='red'>").PostTags("</font>")
-	request := client.Search(indexName).Highlight(highlight).Size(pageSize).Query(boolquery)
-	searchByMatch, err := request.Do(context.Background())
-	fmt.Println("err:", err, searchByMatch)
-	return
-	if searchByMatch.Hits != nil {
-		for _, v := range searchByMatch.Hits.Hits {
-			articleJson, err := v.Source.MarshalJSON()
-			if err != nil {
-				return nil, err
-			}
-			article := new(models.CygxArticle)
-			err = json.Unmarshal(articleJson, &article)
-			if err != nil {
-				return nil, err
-			}
-			if _, ok := searchMap[article.ArticleId]; !ok {
-				searchItem := new(models.SearchItem)
-				searchItem.ArticleId, _ = strconv.Atoi(v.Id)
-				searchItem.Body = v.Highlight["BodyText"]
-				var title string
-				if len(v.Highlight["Title"]) > 0 {
-					title = v.Highlight["Title"][0]
-				} else {
-					title = article.Title
-				}
-				searchItem.Title = title
-				searchItem.PublishDate = article.PublishDate
-				result = append(result, searchItem)
-				searchMap[article.ArticleId] = article.ArticleId
-			}
-		}
-	}
-	return
-}
-
-func EsMatchFunctionScoreQuery(indexName, keyWord string, startSize, pageSize int) (result []*models.SearchItem, total int64, err error) {
-	client := utils.Client
-	keyWordArr, err := GetIndustryMapNameSliceV2(keyWord)
-	fmt.Println(keyWordArr)
-	keyWordArr = RemoveDuplicatesAndEmpty(keyWordArr)
-	fmt.Println("-------------------------------")
-	fmt.Println(keyWordArr)
-
-	searchMap := make(map[int]int)
-	boolquery := elastic.NewBoolQuery()
-	matchArr := make([]elastic.Query, 0)
-	//
-	//matchq1 := elastic.NewMatchQuery("Title", keyWord).Boost(n + 1).Analyzer("ik_smart")
-	//matchq2 := elastic.NewMatchQuery("BodyText", keyWord).Boost(n + 1).Analyzer("ik_smart")
-	//
-	//matchArr = append(matchArr, matchq1)
-	//matchArr = append(matchArr, matchq2)
-	n := 0
-	keyWordLen := len(keyWordArr)
-	if keyWordLen <= 0 {
-		keyWordArr = append(keyWordArr, keyWord)
-		keyWordLen = len(keyWordArr)
-	}
-	keyWordWeight := GetWeight(keyWordLen)
-
-	fmt.Println(keyWordArr)
-	fmt.Println(keyWordWeight)
-	for k, v := range keyWordArr {
-		if v != "" {
-			weight := float64(keyWordWeight[k])
-			titleMatchq := elastic.NewMatchQuery("Title", v).Analyzer("ik_smart")
-
-			bodyMatchq := elastic.NewMatchQuery("BodyText", v).Analyzer("ik_smart")
-
-			titleFunctionQuery := elastic.NewFunctionScoreQuery()
-			titleFunctionQuery.Query(titleMatchq)
-			titleFunctions := elastic.NewWeightFactorFunction(weight)
-			titleFunctionQuery.AddScoreFunc(titleFunctions)
-			titleFunctionQuery.BoostMode("replace")
-
-			bodyFunctionQuery := elastic.NewFunctionScoreQuery()
-			bodyFunctionQuery.Query(bodyMatchq)
-			bodyFunctions := elastic.NewWeightFactorFunction(weight)
-			bodyFunctionQuery.AddScoreFunc(bodyFunctions)
-			bodyFunctionQuery.BoostMode("replace")
-
-			matchArr = append(matchArr, titleFunctionQuery)
-			matchArr = append(matchArr, bodyFunctionQuery)
-		}
-		n++
-	}
-	boolquery.Should(matchArr...)
-	highlight := elastic.NewHighlight()
-	highlight = highlight.Fields(elastic.NewHighlighterField("Title"), elastic.NewHighlighterField("BodyText"))
-	highlight = highlight.PreTags("<font color='red'>").PostTags("</font>")
-	request := client.Search(indexName).Highlight(highlight).From(startSize).Size(pageSize).Query(boolquery)
-	searchByMatch, err := request.Do(context.Background())
-	//searchJson, err := json.Marshal(searchByMatch)
-	if searchByMatch != nil {
-		if searchByMatch.Hits != nil {
-			for _, v := range searchByMatch.Hits.Hits {
-				articleJson, err := v.Source.MarshalJSON()
-				if err != nil {
-					return nil, 0, err
-				}
-				article := new(models.CygxArticle)
-				err = json.Unmarshal(articleJson, &article)
-				if err != nil {
-					return nil, 0, err
-				}
-				if _, ok := searchMap[article.ArticleId]; !ok {
-					searchItem := new(models.SearchItem)
-					searchItem.ArticleId, _ = strconv.Atoi(v.Id)
-					if len(v.Highlight["BodyText"]) > 0 {
-						searchItem.Body = v.Highlight["BodyText"]
-					} else {
-						bodyRune := []rune(article.BodyText)
-						bodyRuneLen := len(bodyRune)
-						if bodyRuneLen > 100 {
-							bodyRuneLen = 100
-						}
-						body := string(bodyRune[:bodyRuneLen])
-						fmt.Println(body)
-						searchItem.Body = []string{body}
-					}
-					var title string
-					if len(v.Highlight["Title"]) > 0 {
-						title = v.Highlight["Title"][0]
-					} else {
-						title = article.Title
-					}
-					searchItem.Title = title
-					searchItem.PublishDate = article.PublishDate
-					result = append(result, searchItem)
-					searchMap[article.ArticleId] = article.ArticleId
-				}
-			}
-		}
-	}
-	total = searchByMatch.Hits.TotalHits.Value
-	return
-}
-
-func EsMultiMatchFunctionScoreQuery(indexName, keyWord string, startSize, pageSize, userId int) (result []*models.SearchItem, total int64, err error) {
-	client := utils.Client
-	keyWordArr, err := GetIndustryMapNameSliceV3(keyWord)
-	keyWordArr = RemoveDuplicatesAndEmpty(keyWordArr)
-	//artidArr := make([]elastic.Query, 0)
-	//matchArr := make([]elastic.Query, 0)
-	n := 0
-	keyWordLen := len(keyWordArr)
-	if keyWordLen <= 0 {
-		keyWordArr = append(keyWordArr, keyWord)
-		keyWordLen = len(keyWordArr)
-	}
-	utils.FileLog.Info("SearchKeyWord:%s, userId:%s", keyWordArr, strconv.Itoa(userId))
-	//keyWordWeight := GetWeight(keyWordLen)
-	for _, v := range keyWordArr {
-		if v != "" {
-			matchArr := make([]elastic.Query, 0)
-			boolquery := elastic.NewBoolQuery()
-			//weight := float64(keyWordWeight[k])
-			//multiMatch := elastic.NewMultiMatchQuery(v, "Title", "BodyText").Analyzer("ik_smart")
-			//bodyFunctionQuery := elastic.NewFunctionScoreQuery()
-			//bodyFunctionQuery.Query(multiMatch)
-			//bodyFunctions := elastic.NewWeightFactorFunction(weight)
-			//bodyFunctionQuery.AddScoreFunc(bodyFunctions)
-			//bodyFunctionQuery.BoostMode("replace")
-			//matchArr = append(matchArr, bodyFunctionQuery)
-			//weight := float64(keyWordWeight[k])
-			multiMatch := elastic.NewMultiMatchQuery(v, "Title", "BodyText").Analyzer("ik_smart")
-			bodyFunctionQuery := elastic.NewFunctionScoreQuery()
-			bodyFunctionQuery.Query(multiMatch)
-			//bodyFunctions := elastic.NewWeightFactorFunction(weight)
-			//bodyFunctionQuery.AddScoreFunc(bodyFunctions)
-			//bodyFunctionQuery.BoostMode("replace")
-			matchArr = append(matchArr, bodyFunctionQuery)
-			boolquery.Should(matchArr...)
-			highlight := elastic.NewHighlight()
-			highlight = highlight.Fields(elastic.NewHighlighterField("Title"), elastic.NewHighlighterField("BodyText"))
-			highlight = highlight.PreTags("<font color='red'>").PostTags("</font>")
-			request := client.Search(indexName).Highlight(highlight).From(startSize).Size(pageSize).Query(boolquery)
-			searchByMatch, err := request.Do(context.Background())
-			if err != nil {
-				return nil, 0, err
-			}
-			if searchByMatch != nil {
-				if searchByMatch.Hits != nil {
-					for _, v := range searchByMatch.Hits.Hits {
-						var isAppend bool
-						articleJson, err := v.Source.MarshalJSON()
-						if err != nil {
-							return nil, 0, err
-						}
-						article := new(models.CygxArticle)
-						err = json.Unmarshal(articleJson, &article)
-						if err != nil {
-							return nil, 0, err
-						}
-						searchItem := new(models.SearchItem)
-						searchItem.ArticleId, _ = strconv.Atoi(v.Id)
-						if len(v.Highlight["BodyText"]) > 0 {
-							searchItem.Body = v.Highlight["BodyText"]
-						} else {
-							bodyRune := []rune(article.BodyText)
-							bodyRuneLen := len(bodyRune)
-							if bodyRuneLen > 100 {
-								bodyRuneLen = 100
-							}
-							body := string(bodyRune[:bodyRuneLen])
-							searchItem.Body = []string{body}
-						}
-						var title string
-						if len(v.Highlight["Title"]) > 0 {
-							title = v.Highlight["Title"][0]
-						} else {
-							title = article.Title
-						}
-						searchItem.Title = title
-						searchItem.PublishDate = article.PublishDate
-						for _, v_result := range result {
-							if v_result.ArticleId == searchItem.ArticleId {
-								isAppend = true
-							}
-						}
-						if !isAppend {
-							result = append(result, searchItem)
-						}
-					}
-				}
-				//total += searchByMatch.Hits.TotalHits.Value
-			}
-		}
-		n++
-	}
-	total = int64(len(result))
-	//fmt.Println(result)
-	//boolquery.Should(matchArr...)
-	//highlight := elastic.NewHighlight()
-	//highlight = highlight.Fields(elastic.NewHighlighterField("Title"), elastic.NewHighlighterField("BodyText"))
-	//highlight = highlight.PreTags("<font color='red'>").PostTags("</font>")
-	//request := client.Search(indexName).Highlight(highlight).From(startSize).Size(pageSize).Query(boolquery)
-	//searchByMatch, err := request.Do(context.Background())
-	//if searchByMatch != nil {
-	//	if searchByMatch.Hits != nil {
-	//		for _, v := range searchByMatch.Hits.Hits {
-	//			articleJson, err := v.Source.MarshalJSON()
-	//			if err != nil {
-	//				return nil, 0, err
-	//			}
-	//			article := new(models.CygxArticle)
-	//			err = json.Unmarshal(articleJson, &article)
-	//			if err != nil {
-	//				return nil, 0, err
-	//			}
-	//			searchItem := new(models.SearchItem)
-	//			searchItem.ArticleId, _ = strconv.Atoi(v.Id)
-	//			if len(v.Highlight["BodyText"]) > 0 {
-	//				searchItem.Body = v.Highlight["BodyText"]
-	//			} else {
-	//				bodyRune := []rune(article.BodyText)
-	//				bodyRuneLen := len(bodyRune)
-	//				if bodyRuneLen > 100 {
-	//					bodyRuneLen = 100
-	//				}
-	//				body := string(bodyRune[:bodyRuneLen])
-	//				searchItem.Body = []string{body}
-	//			}
-	//			var title string
-	//			if len(v.Highlight["Title"]) > 0 {
-	//				title = v.Highlight["Title"][0]
-	//			} else {
-	//				title = article.Title
-	//			}
-	//			searchItem.Title = title
-	//			searchItem.PublishDate = article.PublishDate
-	//
-	//			result = append(result, searchItem)
-	//		}
-	//	}
-	//	total = searchByMatch.Hits.TotalHits.Value
-	//}
-	return
-}
-
-func EsMultiMatchFunctionScoreQueryFix(indexName, keyWord string, startSize, pageSize int) (result []*models.SearchItem, total int64, err error) {
-	client := utils.Client
-	keyWordArr, err := GetIndustryMapNameSliceV2(keyWord)
-
-	keyWordArr = RemoveDuplicatesAndEmpty(keyWordArr)
-	boolquery := elastic.NewBoolQuery()
-	matchArr := make([]elastic.Query, 0)
-
-	n := 0
-	keyWordLen := len(keyWordArr)
-	if keyWordLen <= 0 {
-		keyWordArr = append(keyWordArr, keyWord)
-		keyWordLen = len(keyWordArr)
-	}
-	fmt.Println(keyWordArr)
-
-	keyWordWeight := GetWeight(keyWordLen)
-	for k, v := range keyWordArr {
-		if v != "" {
-			weight := float64(keyWordWeight[k])
-			multiMatch := elastic.NewMultiMatchQuery(v, "Title", "BodyText").Analyzer("ik_smart")
-			bodyFunctionQuery := elastic.NewFunctionScoreQuery()
-			bodyFunctionQuery.Query(multiMatch)
-			bodyFunctions := elastic.NewWeightFactorFunction(weight)
-			bodyFunctionQuery.AddScoreFunc(bodyFunctions)
-			bodyFunctionQuery.BoostMode("replace")
-			matchArr = append(matchArr, bodyFunctionQuery)
-		}
-		n++
-	}
-	boolquery.Should(matchArr...)
-	highlight := elastic.NewHighlight()
-	highlight = highlight.Fields(elastic.NewHighlighterField("Title"), elastic.NewHighlighterField("BodyText"))
-	highlight = highlight.PreTags("<font color='red'>").PostTags("</font>")
-	request := client.Search(indexName).Highlight(highlight).From(startSize).Size(pageSize).Query(boolquery)
-	searchByMatch, err := request.Do(context.Background())
-	if searchByMatch != nil {
-
-		matchResult, _ := json.Marshal(searchByMatch)
-		utils.FileLog.Info("%s", string(matchResult))
-
-		if searchByMatch.Hits != nil {
-			for _, v := range searchByMatch.Hits.Hits {
-				articleJson, err := v.Source.MarshalJSON()
-				utils.FileLog.Info("%s", string(articleJson))
-				if err != nil {
-					return nil, 0, err
-				}
-				article := new(models.CygxArticle)
-				err = json.Unmarshal(articleJson, &article)
-				if err != nil {
-					return nil, 0, err
-				}
-				searchItem := new(models.SearchItem)
-				searchItem.ArticleId, _ = strconv.Atoi(v.Id)
-				if len(v.Highlight["BodyText"]) > 0 {
-					searchItem.Body = v.Highlight["BodyText"]
-				} else {
-					bodyRune := []rune(article.BodyText)
-					bodyRuneLen := len(bodyRune)
-					if bodyRuneLen > 100 {
-						bodyRuneLen = 100
-					}
-					body := string(bodyRune[:bodyRuneLen])
-					searchItem.Body = []string{body}
-				}
-				var title string
-				if len(v.Highlight["Title"]) > 0 {
-					title = v.Highlight["Title"][0]
-				} else {
-					title = article.Title
-				}
-				searchItem.Title = title
-				searchItem.PublishDate = article.PublishDate
-				result = append(result, searchItem)
-			}
-		}
-		total = searchByMatch.Hits.TotalHits.Value
-	}
-	return
-}
-
 func GetWeight(length int) []int {
 	steep := 10
 	intArr := make([]int, 0)
@@ -937,15 +452,6 @@ func GetArrSum(intArr []int) (sum int) {
 	return
 }
 
-//func init() {
-//	fmt.Println("start")
-//	keyWord:="阿里巴巴"
-//	keyWordArr, _ := GetIndustryMapNameSliceV2(keyWord)
-//	keyWordArr = RemoveDuplicatesAndEmpty(keyWordArr)
-//	fmt.Println(keyWordArr)
-//	fmt.Println("end")
-//}
-
 func EsMultiMatchFunctionScoreQuerySort(indexName, keyWord string, startSize, pageSize, userId int, orderColumn string) (result []*models.SearchItem, total int64, err error) {
 	client := utils.Client
 	keyWordArr, err := GetIndustryMapNameSliceV3(keyWord)
@@ -1378,3 +884,157 @@ func EsMultiMatchFunctionScoreQuerySortPage(indexName, keyWord string, startSize
 	total += searchByMatch.Hits.TotalHits.Value
 	return
 }
+
+func init23423() {
+	EsArticleSearch("立高食品", 0, 10, "34")
+}
+
+func EsArticleSearch(keyWord string, startSize, pageSize int, orderColumn string) (result []*models.SearchItem, total int64, err error) {
+	indexName := utils.IndexName
+	client := utils.Client
+	keyWordArr, err := GetIndustryMapNameSliceV3(keyWord)
+	keyWordArr = RemoveDuplicatesAndEmpty(keyWordArr)
+	keyWordLen := len(keyWordArr)
+	if keyWordLen <= 0 {
+		keyWordArr = append(keyWordArr, keyWord)
+		keyWordLen = len(keyWordArr)
+	}
+	//fmt.Println(keyWordArr)
+	mustMap := make([]interface{}, 0)
+	shouldMap := make(map[string]interface{}, 0)
+	//shouldMapquery := make(map[string]interface{}, 0)
+	shouldMapquery := make([]interface{}, 0)
+	// @Param   OrderColumn   query   int  true       "排序字段 ,Comprehensive综合 ,Matching匹配度 ,PublishDate 发布时间 "
+	//keyWordWeight := GetWeight(keyWordLen)
+	var boost int
+	lenkeyWordArr := len(keyWordArr)
+	for k, v := range keyWordArr {
+		if k == 0 {
+			boost = 2 * 1000
+		} else {
+			boost = 1000
+		}
+		if v != "" {
+			shouldMapquery = append(shouldMapquery, map[string]interface{}{
+				"function_score": map[string]interface{}{
+					"query": map[string]interface{}{
+						"multi_match": map[string]interface{}{
+							"boost":  (lenkeyWordArr - k) * boost, //给查询的值赋予权重
+							"fields": []interface{}{"Title"},
+							"query":  v,
+						},
+					},
+				},
+			})
+
+			shouldMapquery = append(shouldMapquery, map[string]interface{}{
+				"function_score": map[string]interface{}{
+					"query": map[string]interface{}{
+						"multi_match": map[string]interface{}{
+							"boost":  (lenkeyWordArr-k)*boost - 1, //给查询的值赋予权重
+							"fields": []interface{}{"BodyText"},
+							"query":  v,
+						},
+					},
+				},
+			})
+		}
+	}
+	shouldMap = map[string]interface{}{
+		"should": shouldMapquery,
+	}
+	//排序
+	sortMap := make([]interface{}, 0)
+	//时间
+	sortMap = append(sortMap, map[string]interface{}{
+		"PublishDate": map[string]interface{}{
+			"order": "desc",
+		},
+	})
+	//高亮
+	highlightMap := make(map[string]interface{}, 0)
+	highlightMap = map[string]interface{}{
+		"fields": map[string]interface{}{
+			"BodyText": map[string]interface{}{},
+			"Title":    map[string]interface{}{},
+		},
+		//样式 红色
+		"post_tags": []interface{}{"</font>"},
+		"pre_tags":  []interface{}{"<font color='red'>"},
+	}
+
+	mustMap = append(mustMap, map[string]interface{}{
+		"bool": shouldMap,
+	})
+	queryMap := map[string]interface{}{
+		"query": map[string]interface{}{
+			"bool": map[string]interface{}{
+				"must": mustMap,
+			},
+		},
+	}
+	if orderColumn == "PublishDate" {
+		queryMap["sort"] = sortMap
+	}
+	queryMap["from"] = startSize
+	queryMap["size"] = pageSize
+	queryMap["highlight"] = highlightMap
+	jsonBytes, _ := json.Marshal(queryMap)
+	fmt.Println(string(jsonBytes))
+	//utils.FileLog.Info(string(jsonBytes))
+	request := client.Search(indexName).Source(queryMap) // sets the JSON request
+	searchByMatch, err := request.Do(context.Background())
+	if searchByMatch != nil {
+		if searchByMatch.Hits != nil {
+			for _, v := range searchByMatch.Hits.Hits {
+				var isAppend bool
+				articleJson, err := v.Source.MarshalJSON()
+				if err != nil {
+					return nil, 0, err
+				}
+				article := new(models.CygxArticleEs)
+				err = json.Unmarshal(articleJson, &article)
+				if err != nil {
+					return nil, 0, err
+				}
+				searchItem := new(models.SearchItem)
+				searchItem.ArticleId, _ = strconv.Atoi(v.Id)
+				if len(v.Highlight["BodyText"]) > 0 {
+					searchItem.Body = v.Highlight["BodyText"]
+				} else {
+					bodyRune := []rune(article.BodyText)
+					bodyRuneLen := len(bodyRune)
+					if bodyRuneLen > 100 {
+						bodyRuneLen = 100
+					}
+					body := string(bodyRune[:bodyRuneLen])
+					searchItem.Body = []string{body}
+				}
+				var title string
+				if len(v.Highlight["Title"]) > 0 {
+					title = v.Highlight["Title"][0]
+				} else {
+					title = article.Title
+				}
+				searchItem.Title = title
+				searchItem.PublishDate = article.PublishDate
+				searchItem.ExpertBackground = article.ExpertBackground
+				searchItem.CategoryId = article.CategoryId
+				for _, v_result := range result {
+					if v_result.ArticleId == searchItem.ArticleId {
+						isAppend = true
+					}
+				}
+				if !isAppend {
+					result = append(result, searchItem)
+				}
+			}
+		}
+		total = searchByMatch.Hits.TotalHits.Value
+	}
+	//fmt.Println(result)
+	//for _, v := range result {
+	//	fmt.Println(v)
+	//}
+	return
+}

+ 324 - 0
services/micro_roadshow.go

@@ -0,0 +1,324 @@
+package services
+
+import (
+	"encoding/json"
+	"errors"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"math"
+	"strconv"
+	"strings"
+	"sync"
+)
+
+// GetMicroRoadShowPageList 获取微路演列表
+func GetMicroRoadShowPageList(pageSize, currentIndex, audioId, videoId int, keywords string) (respList []*models.MicroRoadShowPageList, total int, err error) {
+	var e error
+	// 根据每页数据量获取音视频配比
+	audioRatio, videoRatio, audioPageNum, videoPageNum, sliceNum, e := getMicroRoadShowDataRatio(pageSize)
+	if e != nil {
+		err = errors.New("获取微路演列表数据音视频配比失败, Err: " + e.Error())
+		return
+	}
+
+	audioTotal := 0
+	videoTotal := 0
+	audioList := make([]*models.MicroRoadShowPageList, 0)
+	videoList := make([]*models.MicroRoadShowPageList, 0)
+	if keywords != "" {
+		keywords = "%" + keywords + "%"
+	}
+	// 查询指定音频/视频时, 调整比例为1方便后面组合数据
+	if audioId > 0 || videoId > 0 {
+		audioRatio = 1
+		videoRatio = 1
+	}
+
+	wg := sync.WaitGroup{}
+
+	wg.Add(2)
+
+	// 分页查询音频
+	go func() {
+		defer wg.Done()
+		// 如果筛选条件为指定视频ID则不做音频查询
+		if videoId > 0 {
+			return
+		}
+		var audioCond string
+		var audioPars []interface{}
+		// 活动已发布且已结束
+		audioCond += ` AND b.publish_status = 1 AND b.active_state = 3`
+		if keywords != "" {
+			audioCond += ` AND a.voice_name LIKE ? OR b.label LIKE ?`
+			audioPars = append(audioPars, keywords, keywords)
+		}
+		if audioId > 0 {
+			audioCond += ` AND a.activity_voice_id = ?`
+			audioPars = append(audioPars, audioId)
+		}
+		audioStartSize := 0
+		if currentIndex > 1 {
+			audioStartSize = (currentIndex - 1) * audioPageNum
+		}
+		audioTotal, audioList, e = models.GetMicroRoadShowAudioPageList(audioStartSize, audioPageNum, audioCond, audioPars)
+	}()
+
+	// 分页查询视频
+	go func() {
+		defer wg.Done()
+		// 如果筛选条件为指定音频ID则不做视频查询
+		if audioId > 0 {
+			return
+		}
+		var videoCond string
+		var videoPars []interface{}
+		if keywords != "" {
+			videoCond += ` AND video_name LIKE ?`
+			videoPars = append(videoPars, keywords)
+		}
+		if videoId > 0 {
+			videoCond += ` AND video_id = ?`
+			videoPars = append(videoPars, videoId)
+		}
+		videoCond += ` AND publish_status = 1`
+		videoStartSize := 0
+		if currentIndex > 1 {
+			videoStartSize = (currentIndex - 1) * videoPageNum
+		}
+		videoTotal, videoList, e = models.GetMicroRoadShowVideoPageList(videoStartSize, videoPageNum, videoCond, videoPars)
+	}()
+
+	wg.Wait()
+
+	if e != nil {
+		err = errors.New("获取微路演音视频列表失败, Err: " + e.Error())
+		return
+	}
+
+	// 按比例组合列表
+	audioNum := 0
+	videoNum := 0
+	audioLen := len(audioList)
+	videoLen := len(videoList)
+	for i := 0; i < sliceNum; i++ {
+		// 音频-每次取对应比例的数据直至取完
+		for a := 0; a < audioRatio; a++ {
+			if audioNum >= audioLen {
+				break
+			}
+			respList = append(respList, audioList[audioNum])
+			audioNum += 1
+		}
+		// 视频
+		for b := 0; b < videoRatio; b++ {
+			if videoNum >= videoLen {
+				break
+			}
+			respList = append(respList, videoList[videoNum])
+			videoNum += 1
+		}
+	}
+	total = audioTotal + videoTotal
+	return
+}
+
+// getMicroRoadShowDataRatio 获取微路演列表数据音视频配比
+func getMicroRoadShowDataRatio(pageSize int) (audioRatio, videoRatio, audioPageNum, videoPageNum, sliceNum int, err error) {
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	key := models.MicroRoadShowListDataRatioConfigKey
+	config, e := models.GetConfigByCode(key)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("获取微路演列表数据量配置失败, Err: " + e.Error())
+		return
+	}
+
+	// 默认音频视频展示比例为4:1
+	ratio := "4:1"
+	if config != nil {
+		ratio = config.ConfigValue
+	}
+	ratioArr := strings.Split(ratio, ":")
+	if len(ratioArr) != 2 {
+		err = errors.New("微路演列表数据量配比有误")
+		return
+	}
+	audioRatio, e = strconv.Atoi(ratioArr[0])
+	if e != nil {
+		err = errors.New("微路演列表数据量配比有误")
+		return
+	}
+	videoRatio, e = strconv.Atoi(ratioArr[1])
+	if e != nil {
+		err = errors.New("微路演列表数据量配比有误")
+		return
+	}
+	totalRatio := audioRatio + videoRatio
+	if totalRatio == 0 {
+		err = errors.New("微路演列表数据量配比有误")
+		return
+	}
+
+	// 每比率对应数量(向上取整)
+	sliceNum = int(math.Ceil(float64(pageSize) / float64(totalRatio)))
+	audioPageNum = audioRatio * sliceNum
+	videoPageNum = videoRatio * sliceNum
+
+	return
+}
+
+// GetMicroRoadShowDefaultImgConfig 获取微路演默认图/分享图配置
+func GetMicroRoadShowDefaultImgConfig() (audioMap, videoMap, audioShareMap, videoShareMap map[int]string, err error) {
+	audioMap = make(map[int]string, 0)
+	videoMap = make(map[int]string, 0)
+	audioShareMap = make(map[int]string, 0)
+	videoShareMap = make(map[int]string, 0)
+	key := models.MicroRoadshowDefaultImgKey
+	conf, e := models.GetConfigByCode(key)
+	if e != nil {
+		err = errors.New("获取微路演默认图配置失败, Err: " + e.Error())
+		return
+	}
+	if conf.ConfigValue == "" {
+		err = errors.New("获取微路演默认图配置有误")
+		return
+	}
+	list := new(models.MicroRoadShowDefaultImgList)
+	if e = json.Unmarshal([]byte(conf.ConfigValue), &list); e != nil {
+		err = errors.New("微路演默认图配置配置值解析失败, Err: " + e.Error())
+		return
+	}
+	audioList := list.Audio
+	for i := range audioList {
+		audioMap[audioList[i].ChartPermissionId] = audioList[i].ImgUrl
+		audioShareMap[audioList[i].ChartPermissionId] = audioList[i].ShareImg
+	}
+	videoList := list.Video
+	for i := range videoList {
+		videoMap[videoList[i].ChartPermissionId] = videoList[i].ImgUrl
+		videoShareMap[videoList[i].ChartPermissionId] = videoList[i].ShareImg
+	}
+	return
+}
+
+// GetHomeNewestList 获取首页最新列表
+func GetHomeNewestList(userId, companyId, startSize, pageSize int, condition string, pars []interface{}) (resp []*models.HomeArticle, total int, err error) {
+	resp = make([]*models.HomeArticle, 0)
+	unionList, e := models.GetHomeNewestListUnionList(condition, pars, startSize, pageSize)
+	if e != nil {
+		err = errors.New("获取首页最新列表失败")
+		return
+	}
+	unionTotal, e := models.GetHomeNewestListUnionCount(condition, pars)
+	if e != nil {
+		err = errors.New("获取首页最新列表总数失败")
+		return
+	}
+	total = unionTotal
+
+	// 用户权限
+	authInfo, permissionArr, e := GetUserRaiPermissionInfo(userId, companyId)
+	if e != nil {
+		err = errors.New("获取用户权限失败, Err: " + e.Error())
+		return
+	}
+
+	// 获取默认图配置
+	audioMap, videoMap, audioShareMap, videoShareMap, e := GetMicroRoadShowDefaultImgConfig()
+	if e != nil {
+		err = errors.New("获取微路演默认图配置失败, Err: " + e.Error())
+		return
+	}
+
+	// 此处没有直接使用HomeArticle结构体而是多加了一层, 纯粹是为了方便前端区分纪要和微路演音频=_=!
+	for _, v := range unionList {
+		item := new(models.HomeArticle)
+		item.HomeType = v.HomeType
+		// 纪要
+		if item.HomeType == 0 {
+			item.ArticleId = v.ArticleId
+			item.Title = v.Title
+			item.TitleEn = v.TitleEn
+			item.UpdateFrequency = v.UpdateFrequency
+			item.CreateDate = v.CreateDate
+			item.PublishDate = v.PublishDate
+			item.Body = v.Body
+			item.BodyHtml = v.BodyHtml
+			item.Abstract = v.Abstract
+			item.CategoryName = v.CategoryName
+			item.SubCategoryName = v.SubCategoryName
+			item.ExpertBackground = v.ExpertBackground
+			item.IsResearch = v.IsResearch
+			item.Pv = v.Pv
+			item.ImgUrlPc = v.ImgUrlPc
+			item.CategoryId = v.CategoryId
+			item.HttpUrl = v.HttpUrl
+			item.IsNeedJump = v.IsNeedJump
+			item.Source = v.Source
+			item.Annotation = v.Annotation
+		}
+		// 音频
+		if v.HomeType == 1 {
+			ad := new(models.MicroAudioUnionList)
+			ad.Id = v.Id
+			ad.AudioTitle = v.AudioTitle
+			ad.AudioResourceUrl = v.AudioResourceUrl
+			ad.AudioType = v.AudioType
+			ad.AudioPublishTime = utils.StrTimeToTime(v.AudioPublishTime).Format(utils.FormatDate)
+			ad.AudioImgUrl = v.AudioImgUrl
+			ad.AudioChartPermissionId = v.AudioChartPermissionId
+			ad.AudioChartPermissionName = v.AudioChartPermissionName
+			ad.AudioPlaySeconds = v.AudioPlaySeconds
+			ad.AudioPlaySeconds = v.AudioPlaySeconds
+			ad.AudioActivityId = v.AudioActivityId
+			item.MicroAudio = ad
+			// 默认图
+			if ad.AudioImgUrl == "" {
+				if ad.AudioType == 1 {
+					ad.AudioImgUrl = audioMap[ad.AudioChartPermissionId]
+				} else {
+					ad.AudioImgUrl = videoMap[ad.AudioChartPermissionId]
+				}
+			}
+			// 分享图
+			if ad.AudioType == 1 {
+				ad.AudioShareImg = audioShareMap[ad.AudioChartPermissionId]
+			} else {
+				ad.AudioShareImg = videoShareMap[ad.AudioChartPermissionId]
+			}
+			// 权限
+			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 ad.AudioChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, ad.AudioChartPermissionName) {
+					au.HasPermission = 2
+				}
+			}
+			// 无权限的弹框提示
+			if au.HasPermission != 1 {
+				if au.OperationMode == UserPermissionOperationModeCall {
+					if ad.AudioType == 1 {
+						au.PopupMsg = UserPermissionPopupMsgCallActivity
+					} else {
+						au.PopupMsg = UserPermissionPopupMsgCallMicroVideo
+					}
+				} else {
+					if ad.AudioType == 1 {
+						au.PopupMsg = UserPermissionPopupMsgApplyActivity
+					} else {
+						au.PopupMsg = UserPermissionPopupMsgApplyMicroVideo
+					}
+				}
+			}
+			ad.AuthInfo = au
+		}
+		resp = append(resp, item)
+	}
+	return
+}

+ 1 - 0
services/tactics.go

@@ -745,6 +745,7 @@ func GetSummarytoEs(cont context.Context) (err error) {
 		item.ArticleId = v.ArticleId
 		item.Title = v.Title
 		item.PublishDate = v.PublishDate
+		bodyText, _ = GetReportContentTextSub(v.Body)
 		item.BodyText = bodyText
 		item.CategoryId = strconv.Itoa(v.CategoryId)
 		item.ExpertBackground = v.ExpertBackground

+ 8 - 8
services/task.go

@@ -40,6 +40,12 @@ func Task() {
 
 		getChartListByApi := task.NewTask("getChartListByApi", "0 */30 * * * *", GetChartListByApi) //同步图表
 		task.AddTask("getChartListByApi", getChartListByApi)
+
+		getYiDongActivity := task.NewTask("getYiDongActivity", "0 */10 * * * *", GetYiDongActivity) //同步易董的活动信息
+		task.AddTask("getYiDongActivity", getYiDongActivity)
+
+		getYiDongActivityMeeting := task.NewTask("getYiDongActivityMeeting", "0 */10 * * * *", GetYiDongActivityMeeting) //同步易董的活动信息
+		task.AddTask("getYiDongActivityMeeting", getYiDongActivityMeeting)
 	}
 
 	if utils.IsTask {
@@ -75,18 +81,12 @@ func Task() {
 		reportBillboardUpdate := task.NewTask("reportBillboardUpdate", "0 10 0 * * *", ReportBillboardUpdate) //报告榜单更新
 		task.AddTask("reportBillboardUpdate", reportBillboardUpdate)
 
-		//doActivityOnenIdWxTemplateMsg := task.NewTask("doActivityOnenIdWxTemplateMsg", "0 30 16 * * 0", DoActivityOnenIdWxTemplateMsg) //周日下午四点半推送全部活动
-		//task.AddTask("doActivityOnenIdWxTemplateMsg", doActivityOnenIdWxTemplateMsg)
+		doActivityOnenIdWxTemplateMsg := task.NewTask("doActivityOnenIdWxTemplateMsg", "0 30 16 * * 0", DoActivityOnenIdWxTemplateMsg) //周日下午四点半推送全部活动
+		task.AddTask("doActivityOnenIdWxTemplateMsg", doActivityOnenIdWxTemplateMsg)
 
 		updateCygxActivitySpecialSignupNum := task.NewTask("updateCygxActivitySpecialSignupNum", "0 25 0 * * *", UpdateCygxActivitySpecialSignupNum) //修改专项调研,用户与公司的参与数量
 		task.AddTask("updateCygxActivitySpecialSignupNum", updateCygxActivitySpecialSignupNum)
 
-		getYiDongActivity := task.NewTask("getYiDongActivity", "0 */10 * * * *", GetYiDongActivity) //同步易董的活动信息
-		task.AddTask("getYiDongActivity", getYiDongActivity)
-
-		getYiDongActivityMeeting := task.NewTask("getYiDongActivityMeeting", "0 */10 * * * *", GetYiDongActivityMeeting) //同步易董的活动信息
-		task.AddTask("getYiDongActivityMeeting", getYiDongActivityMeeting)
-
 		dotongbuShangHai := task.NewTask("dotongbuShangHai", "0 */20 * * * *", DotongbuShangHai) //把信息同步到上海策略品台
 		task.AddTask("同步用户到上海", dotongbuShangHai)
 

+ 33 - 0
services/user_activity_permission.go

@@ -0,0 +1,33 @@
+package services
+
+import (
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+)
+
+func CheckActivityUserPermission(user *models.WxUserItem) (sellerMobile, sellerRealName string, err error) {
+	companyPermission, e := models.GetCompanyPermission(user.CompanyId)
+	if e != nil {
+		err = e
+		return
+	}
+	if companyPermission == "" {
+		companyPermissionNoStatus, e := models.GetCompanyPermissionByUserNoStatus(user.CompanyId)
+		if e != nil {
+			err = e
+			return
+		}
+		if companyPermissionNoStatus != "" {
+			sellerItemQy, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+			if e != nil && e.Error() != utils.ErrNoRow() {
+				err = e
+				return
+			}
+			if sellerItemQy != nil {
+				sellerMobile = sellerItemQy.Mobile
+				sellerRealName = sellerItemQy.RealName
+			}
+		}
+	}
+	return
+}

+ 28 - 0
services/user_freee_button.go

@@ -0,0 +1,28 @@
+package services
+
+import (
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+)
+
+// GetfreeButtonIsShow 用户免费分享按钮是否回显
+func GetfreeButtonIsShow(user *models.WxUserItem) (isShow bool, err error) {
+	detail, err := models.GetConfigByCode("free_trial_card")
+	if err != nil {
+		return
+	}
+	companyDetail, err := models.GetCompanyDetailByIdGroup(user.CompanyId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return
+	}
+	count, err := models.CountCygxUserFreeeButton(user.UserId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return
+	}
+	if companyDetail != nil && companyDetail.IsSuspend == 0 {
+		if detail.ConfigValue == "1" && (companyDetail.Status == "正式" || companyDetail.Status == "试用" || companyDetail.Status == "永续") && count == 0 {
+			isShow = true
+		}
+	}
+	return
+}

+ 87 - 0
services/user_permission.go

@@ -0,0 +1,87 @@
+package services
+
+import (
+	"errors"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strings"
+)
+
+var (
+	UserPermissionOperationModeApply      = "Apply"
+	UserPermissionOperationModeCall       = "Call"
+	UserPermissionPopupMsgApplyActivity   = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
+	UserPermissionPopupMsgCallActivity    = "您暂无权限参加此活动,若想参加可以联系对口销售"
+	UserPermissionPopupMsgApplyMicroVideo = "您暂无权限查看此视频,若想查看可以申请开通对应的试用权限"
+	UserPermissionPopupMsgCallMicroVideo  = "您暂无权限查看此视频若想查看可以联系对口销售"
+)
+
+// GetUserRaiPermissionInfo 获取权限类型及信息
+// HasPermission 是否有权限:1-有权限; 2-无权限; 3-潜在客户未提交申请; 4-潜在客户已提交申请 5-仅有FICC权限
+func GetUserRaiPermissionInfo(userId, companyId int) (authInfo models.UserPermissionAuthInfo, permissionArr []string, err error) {
+	// 用户申请记录
+	applyCount, e := models.GetApplyRecordCount(userId)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("获取用户申请信息失败, Err: " + e.Error())
+		return
+	}
+
+	// 潜在用户
+	if companyId <= 1 {
+		authInfo.HasPermission = 3
+		if applyCount > 0 {
+			authInfo.HasPermission = 4
+		}
+		authInfo.OperationMode = UserPermissionOperationModeApply
+		authInfo.PopupMsg = UserPermissionPopupMsgApplyActivity
+		return
+	}
+
+	// 销售信息
+	ficcSeller, e := models.GetSellerByCompanyIdCheckFicc(companyId, utils.COMPANY_PRODUCT_FICC_ID)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("获取FICC销售信息失败, Err: " + e.Error())
+		return
+	}
+	raiSeller, e := models.GetSellerByCompanyIdCheckFicc(companyId, utils.COMPANY_PRODUCT_RAI_ID)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("获取权益销售信息失败, Err: " + e.Error())
+		return
+	}
+	if raiSeller != nil {
+		authInfo.SellerMobile = raiSeller.Mobile
+		authInfo.SellerName = raiSeller.RealName
+	}
+	// 仅有FICC权限
+	if ficcSeller != nil && raiSeller == nil {
+		authInfo.HasPermission = 5
+		authInfo.OperationMode = UserPermissionOperationModeApply
+		authInfo.PopupMsg = UserPermissionPopupMsgApplyActivity
+		return
+	}
+
+	// permissions示例: 医药,消费,科技,智造,策略,专家,买方研选
+	permissions, e := models.GetCompanyPermission(companyId)
+	if e != nil {
+		err = errors.New("获取客户权限失败, Err: " + e.Error())
+		return
+	}
+	if permissions == "" {
+		// 无权益权限
+		if raiSeller != nil {
+			// 有销售信息
+			authInfo.HasPermission = 2
+			authInfo.OperationMode = UserPermissionOperationModeCall
+			authInfo.PopupMsg = UserPermissionPopupMsgCallActivity
+			return
+		}
+		// 无销售信息, 无申请, 视作潜在用户
+		authInfo.HasPermission = 3
+		authInfo.OperationMode = UserPermissionOperationModeApply
+		return
+	}
+	// 有基本的权益权限
+	authInfo.HasPermission = 1
+	permissionArr = strings.Split(permissions, ",")
+	return
+}

+ 0 - 1
utils/common.go

@@ -733,7 +733,6 @@ func ReplaceSpaceAndWrap(str string) string {
 	return str
 }
 
-
 // InArrayByInt php中的in_array(判断Int类型的切片中是否存在该int值)
 func InArrayByInt(idIntList []int, searchId int) (has bool) {
 	for _, id := range idIntList {

+ 9 - 0
utils/constants.go

@@ -90,6 +90,8 @@ const (
 	ZHI_ZAO_ID                       int    = 19
 	LINK_WX_EXPLAIN                         = "https://mp.weixin.qq.com/s?__biz=Mzg2OTYzODk0Nw==&mid=2247483662&idx=1&sn=3752df99025189b9d77fe658bfc0edbd&chksm=ce98b742f9ef3e54b49986e647dd951a3aad74f323174b252174e0938c264c0562c8ec455106#rd" //用户阅读数据
 	HZ_COMPANY_ID                    int    = 16                                                                                                                                                                                                 // 弘则公司的ID
+	HONG_GUAN_NAME                   string = "宏观"
+	HONG_GUAN_ID                     int    = 1
 )
 
 const (
@@ -122,3 +124,10 @@ const (
 const (
 	YI_YAO_QI_TA = "https://hzstatic.hzinsights.com/static/temp/20220922202209/20220922/2OQMBFplQE1R3bX1y3obX7JSwSuA.png"
 )
+
+const (
+	COMPANY_PRODUCT_FICC_ID   = 1
+	COMPANY_PRODUCT_FICC_NAME = "ficc"
+	COMPANY_PRODUCT_RAI_ID    = 2
+	COMPANY_PRODUCT_RAI_NAME  = "权益"
+)