package services import ( "encoding/json" "errors" "fmt" "hongze/hongze_clpt/models" "hongze/hongze_clpt/utils" "strconv" "strings" "time" ) // 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 } func GetindustryVideo(user *models.WxUserItem, industrialManagementId int) (industryVideo *models.MicroVideoSimpleInfo, AuthInfo *models.UserPermissionAuthInfo, err error) { total, e := models.GetMicroRoadshowVideoByIndustryIdCount(industrialManagementId) if e != nil { err = errors.New("获取产业关联的视频失败,GetMicroRoadshowVideoByIndustryIdCount " + e.Error()) return } if total == 0 { return } // 用户权限 authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId) if e != nil { err = errors.New("获取用户权限失败,GetUserRaiPermissionInfo " + e.Error()) return } videoSimple := new(models.MicroVideoSimpleInfo) // 权限 var au *models.UserPermissionAuthInfo video, e := models.GetMicroRoadshowVideoByIndustryId(industrialManagementId) if e != nil { err = errors.New("获取产业关联的视频失败,GetMicroRoadshowVideoByIndustryId " + e.Error()) return } else { videoSimple.Id = video.VideoId videoSimple.Title = "5min【" + video.IndustryName + "】逻辑解析" videoSimple.BackgroundImg = video.ImgUrl videoSimple.DetailImgUrl = video.DetailImgUrl if videoSimple.BackgroundImg == "" { // 获取默认图配置 _, videoMap, _, _, e := GetMicroRoadShowDefaultImgConfig() if e != nil { err = errors.New("获取视频默认配置图失败,GetMicroRoadshowVideoByIndustryId " + e.Error()) return } videoSimple.BackgroundImg = videoMap[video.ChartPermissionId] } videoSimple.PlaySeconds = video.VideoDuration videoSimple.ResourceUrl = video.VideoUrl 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 video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) { au.HasPermission = 2 } } // 无权限的弹框提示 if au.HasPermission != 1 { if au.OperationMode == UserPermissionOperationModeCall { au.PopupMsg = UserPermissionPopupMsgCallMicroVideo } else { au.PopupMsg = UserPermissionPopupMsgApplyMicroVideo } videoSimple.ResourceUrl = "" } } videoSimple.Type = 3 industryVideo = videoSimple AuthInfo = au return } // GetindustryVideoDetailById 通过视频ID获取视频详情 func GetindustryVideoDetailById(user *models.WxUserItem, videoId int) (industryVideo *models.MicroVideoSimpleInfo, AuthInfo *models.UserPermissionAuthInfo, err error) { total, e := models.GetMicroRoadshowVideoByVideoIdCount(videoId) if e != nil { err = errors.New("获取产业关联的视频失败,GetMicroRoadshowVideoByIndustryIdCount " + e.Error()) return } if total == 0 { err = errors.New("视频不存在,或已取消发布") return } // 用户权限 authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId) if e != nil { err = errors.New("获取用户权限失败,GetUserRaiPermissionInfo " + e.Error()) return } videoSimple := new(models.MicroVideoSimpleInfo) // 权限 var au *models.UserPermissionAuthInfo video, e := models.GetMicroRoadshowVideoById(videoId) if e != nil { err = errors.New("获取产业关联的视频失败,GetMicroRoadshowVideoByIndustryId " + e.Error()) return } else { videoSimple.Id = video.VideoId videoSimple.Title = "5min【" + video.IndustryName + "】逻辑解析" videoSimple.BackgroundImg = video.ImgUrl videoSimple.DetailImgUrl = video.DetailImgUrl if videoSimple.BackgroundImg == "" { // 获取默认图配置 _, videoMap, _, _, e := GetMicroRoadShowDefaultImgConfig() if e != nil { err = errors.New("获取视频默认配置图失败,GetMicroRoadshowVideoByIndustryId " + e.Error()) return } videoSimple.BackgroundImg = videoMap[video.ChartPermissionId] } videoSimple.PlaySeconds = video.VideoDuration videoSimple.ResourceUrl = video.VideoUrl 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 video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) { au.HasPermission = 2 } } // 无权限的弹框提示 if au.HasPermission != 1 { if au.OperationMode == UserPermissionOperationModeCall { au.PopupMsg = UserPermissionPopupMsgCallMicroVideo } else { au.PopupMsg = UserPermissionPopupMsgApplyMicroVideo } videoSimple.ResourceUrl = "" } } videoSimple.Type = 3 industryVideo = videoSimple AuthInfo = au return } // GetMicroRoadshowVideoMap 获取已经发布的微路演的产业ID func GetMicroRoadshowVideoMap() (items map[int]int, err error) { list, e := models.GetMicroRoadshowVideoList() if e != nil && e.Error() != utils.ErrNoRow() { err = errors.New("获取已经发布的微路演的产业失败,GetMicroRoadshowVideoList " + e.Error()) return } mapindustrialId := make(map[int]int) for _, v := range list { mapindustrialId[v.IndustryId] = v.IndustryId } items = mapindustrialId return } // GetMicroRoadShowPageList 获取微路演列表添加活动视频 更新与8.1版本 func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId int, filter, keywords string) (respList []*models.MicroRoadShowPageList, total int, err error) { var e error // 根据每页数据量获取音视频配比 startSize := utils.StartIndex(currentIndex, pageSize) videoList := make([]*models.MicroRoadShowPageList, 0) if keywords != "" { keywords = "%" + keywords + "%" } //音频的查询 var audioCond string var audioPars []interface{} // 如果筛选条件为指定视频ID或只看视频则不做音频查询 // 活动已发布且已结束 audioCond += ` AND b.publish_status = 1 AND b.active_state = 3` //活动音频,设置有效时间为30天,失效后该活动就不再支持音频回放。有效期起始时间为活动的开始时间 //endTime := time.Now().AddDate(0, 0, -30).Format("2006-01-02 15:04:05") //audioCond += ` AND b.activity_time > ? ` //audioPars = append(audioPars, endTime) 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) } //} //视频的处理 var videoCond string var videoCondAct string var videoPars []interface{} var videoParsAct []interface{} if keywords != "" { videoCond += ` AND video_name LIKE ?` videoPars = append(videoPars, keywords) videoCondAct += ` AND ( video_name LIKE ? OR art.label LIKE ? )` videoParsAct = append(videoParsAct, keywords, keywords) } if videoId > 0 { videoCond += ` AND video_id = ?` videoPars = append(videoPars, videoId) } if activityVideoId > 0 { videoCondAct += ` AND video_id = ?` videoParsAct = append(videoParsAct, activityVideoId) } //如果传了路演的或者活动的视频ID只查询一个 if videoId > 0 { videoCondAct += ` AND video_id = 0 ` audioCond += ` AND a.activity_voice_id = 0 ` } if activityVideoId > 0 { videoCond += ` AND video_id = 0 ` audioCond += ` AND a.activity_voice_id = 0 ` } if audioId > 0 { videoCondAct += ` AND video_id = 0 ` videoCond += ` AND video_id = 0 ` } if strings.Contains(filter, "1") && !strings.Contains(filter, "2") { audioCond += ` AND a.activity_voice_id = 0 ` } else if !strings.Contains(filter, "1") && strings.Contains(filter, "2") { videoCondAct += ` AND video_id = 0 ` videoCond += ` AND video_id = 0 ` } if strings.Contains(filter, "3") && !strings.Contains(filter, "4") { audioCond += ` AND a.activity_voice_id = 0 ` videoCondAct += ` AND video_id = 0 ` } else if strings.Contains(filter, "3") && !strings.Contains(filter, "4") { videoCond += ` AND video_id = 0 ` } //if filter == "1" { // audioCond += ` AND a.activity_voice_id = 0 ` //} else if filter == "2" { // videoCondAct += ` AND video_id = 0 ` // videoCond += ` AND video_id = 0 ` //} videoCond += ` AND publish_status = 1` total, videoList, e = models.GetMicroRoadShowVideoPageListV8(startSize, pageSize, videoCond, videoPars, videoCondAct, videoParsAct, audioCond, audioPars, audioId, videoId, activityVideoId, 0) if e != nil { err = errors.New("获取微路演音视频列表失败, Err: " + e.Error()) return } if total == 0 { return } var activityIds []int for _, v := range videoList { if v.Type == 2 { activityIds = append(activityIds, v.ActivityId) } } if len(activityIds) > 0 { // 获取活动关联的产业 var groupCond string var groupPars []interface{} groupCond += ` AND a.activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `)` groupPars = append(groupPars, activityIds) groups, e := models.GetActivityIndustryRelationList(groupCond, groupPars) if e != nil { err = errors.New("获取活动产业关联列表失败, Err: " + e.Error()) return } activityIndustryMap := make(map[int]int, 0) for _, v := range groups { activityIndustryMap[v.ActivityId] = v.IndustrialManagementId } for _, v := range videoList { if v.Type == 2 { v.IndustrialManagementId = activityIndustryMap[v.ActivityId] } } } respList = videoList return } // GetMicroRoadShowPageList 获取微路演列表添加活动视频 更新与8.1版本 func GetMicroRoadShowPageListV12(pageSize, currentIndex, sourceId, tableType int, filter, keywords, searchType, chartPermissionIds string) (respList []*models.MicroRoadShowPageList, total int, err error) { //Type int `description:"类型: 1-活动音频; 2-活动视频; 3-产业视频; 4-系列问答"` var e error // 根据每页数据量获取音视频配比 startSize := utils.StartIndex(currentIndex, pageSize) videoList := make([]*models.MicroRoadShowPageList, 0) var audioAct string // 活动音频 1 var audioActPars []interface{} var videoAct string // 活动视频 2 var videoActPars []interface{} //视频的处理 var videoMico string //产业视频 3 var videoMicoPars []interface{} var conditionAskserie string // 系列问答 4 var askseriePars []interface{} if sourceId > 0 && tableType > 0 { //先给不相干的表查询ID = 0 audioAct += ` AND b.chart_permission_id = 0 ` videoAct += ` AND b.chart_permission_id = 0` videoMico += ` AND a.chart_permission_id = 0 ` conditionAskserie += ` AND a.chart_permission_id = 0 ` switch tableType { case 1: audioAct += ` OR a.activity_id = ` + strconv.Itoa(sourceId) case 2: videoAct += ` OR a.activity_id = ` + strconv.Itoa(sourceId) case 3: videoMico += ` OR a.video_id = ` + strconv.Itoa(sourceId) case 4: conditionAskserie += ` OR a.askserie_video_id = ` + strconv.Itoa(sourceId) } } if filter == "1" { audioAct += ` AND b.chart_permission_id = 0 ` } else if filter == "2" { videoAct += ` AND b.chart_permission_id = 0` videoMico += ` AND a.chart_permission_id = 0 ` conditionAskserie += ` AND a.chart_permission_id = 0 ` } if searchType != "" { // @Param SearchType string int true "搜索类型: 1-路演回放; 2-问答系列; 3-调研反馈 多个用 , 隔开" videoMico += ` AND a.chart_permission_id = 0 ` // 产业视频不在搜索范围内 if strings.Contains(searchType, "1") && !strings.Contains(searchType, "3") { audioAct += ` AND a.file_type = 1 ` videoAct += ` AND a.file_type = 1 ` } if !strings.Contains(searchType, "1") && strings.Contains(searchType, "3") { audioAct += ` AND a.file_type = 2 ` videoAct += ` AND a.file_type = 2 ` } if !strings.Contains(searchType, "2") { conditionAskserie += ` AND a.chart_permission_id = 0 ` } if !strings.Contains(searchType, "3") && !strings.Contains(searchType, "1") { audioAct += ` AND b.chart_permission_id = 0 ` videoAct += ` AND b.chart_permission_id = 0 ` } } if keywords != "" { keywords = "%" + keywords + "%" audioAct += ` AND a.voice_name LIKE ? ` videoAct += ` AND a.video_name LIKE ? ` videoMico += ` AND a.video_name LIKE ? ` conditionAskserie += ` AND a.video_name LIKE ? ` audioActPars = append(audioActPars, keywords) videoActPars = append(videoActPars, keywords) videoMicoPars = append(videoMicoPars, keywords) askseriePars = append(askseriePars, keywords) } //行业筛选 if chartPermissionIds != "" { audioAct += ` AND b.chart_permission_id IN (` + chartPermissionIds + `)` videoAct += ` AND b.chart_permission_id IN (` + chartPermissionIds + `)` videoMico += ` AND a.chart_permission_id IN (` + chartPermissionIds + `)` conditionAskserie += ` AND a.chart_permission_id IN (` + chartPermissionIds + `)` } //发布状态 audioAct += ` AND b.publish_status = 1 AND b.chart_permission_id != 31 AND a.is_hide = 0 ` videoAct += ` AND b.publish_status = 1 AND b.chart_permission_id != 31 AND a.is_hide = 0 ` videoMico += ` AND a.publish_status = 1 AND a.chart_permission_id != 31 ` conditionAskserie += ` AND a.publish_status = 1 AND a.chart_permission_id != 31 ` total, videoList, e = models.GetMicroRoadShowVideoPageListV12(startSize, pageSize, audioAct, audioActPars, videoAct, videoActPars, videoMico, videoMicoPars, conditionAskserie, askseriePars) if e != nil { err = errors.New("获取微路演音视频列表失败, Err: " + e.Error()) return } for _, v := range videoList { v.LabelType = v.Type if v.Type == 1 || v.Type == 2 { v.LabelType = v.ActivityFileType } } respList = videoList return } // GetMicroRoadShowPageListIkWord 添加IK分词联想词 获取微路演列表添加活动视频 更新与8.1版本 func CountMicroRoadShowPageListIkWord(audioId, videoId, activityVideoId int, keywordArr []string, filter string) (total int, err error) { var e error var keywords string if len(keywordArr) > 0 { keywords = KeyWordArrSqlRegexpAll(keywordArr) } //if keywords == "" { // return //} //音频的查询 var audioCond string var audioPars []interface{} // 如果筛选条件为指定视频ID或只看视频则不做音频查询 //if videoId > 0 || activityVideoId > 0 || filter == 1 { // audioCond += ` AND a.activity_voice_id = 0 ` //} else { // 活动已发布且已结束 audioCond += ` AND b.publish_status = 1 AND b.active_state = 3` if keywords != "" { audioCond += ` AND (a.voice_name REGEXP ? OR b.label REGEXP ? ) ` audioPars = append(audioPars, keywords, keywords) } if audioId > 0 { audioCond += ` AND a.activity_voice_id = ?` audioPars = append(audioPars, audioId) } //视频的处理 var videoCond string var videoCondAct string var videoPars []interface{} var videoParsAct []interface{} //if audioId > 0 || filter == 2 { // videoCond = "" //} else { if keywords != "" { videoCond += ` AND video_name REGEXP ?` videoPars = append(videoPars, keywords) videoCondAct += ` AND ( video_name REGEXP ? OR art.label REGEXP ? )` videoParsAct = append(videoParsAct, keywords, keywords) } if videoId > 0 { videoCond += ` AND video_id = ?` videoPars = append(videoPars, videoId) } if activityVideoId > 0 { videoCondAct += ` AND video_id = ?` videoParsAct = append(videoParsAct, activityVideoId) } //如果传了路演的或者活动的视频ID只查询一个 if videoId > 0 { videoCondAct += ` AND video_id = 0 ` audioCond += ` AND a.activity_voice_id = 0 ` } if activityVideoId > 0 { videoCond += ` AND video_id = 0 ` audioCond += ` AND a.activity_voice_id = 0 ` } if audioId > 0 { videoCondAct += ` AND video_id = 0 ` videoCond += ` AND video_id = 0 ` } if strings.Contains(filter, "1") && !strings.Contains(filter, "2") { audioCond += ` AND a.activity_voice_id = 0 ` } else if !strings.Contains(filter, "1") && strings.Contains(filter, "2") { videoCondAct += ` AND video_id = 0 ` videoCond += ` AND video_id = 0 ` } if strings.Contains(filter, "3") && !strings.Contains(filter, "4") { audioCond += ` AND a.activity_voice_id = 0 ` videoCondAct += ` AND video_id = 0 ` } else if strings.Contains(filter, "3") && !strings.Contains(filter, "4") { videoCond += ` AND video_id = 0 ` } // //if filter == "1" { // audioCond += ` AND a.activity_voice_id = 0 ` //} else if filter == "2" { // videoCondAct += ` AND video_id = 0 ` // videoCond += ` AND video_id = 0 ` //} videoCond += ` AND publish_status = 1` //} total, e = models.CountMicroRoadShowVideoPageList(videoCond, videoPars, videoCondAct, videoParsAct, audioCond, audioPars) if e != nil { err = errors.New("获取微路演音视频列表失败, Err: " + e.Error()) return } return } // GetMicroRoadShowPageListIkWord 添加IK分词联想词 获取微路演列表添加活动视频 更新与8.1版本 func GetMicroRoadShowPageListIkWord(startSize, pageSize, audioId, videoId, activityVideoId int, keywordArr []string, filter, keywords string) (respList []*models.MicroRoadShowPageList, err error) { videoList := make([]*models.MicroRoadShowPageList, 0) var e error var keywordsIk string if len(keywordArr) > 1 { keywordsIk = KeyWordArrSqlRegexp(keywordArr) } if keywords != "" { keywords = "%" + keywords + "%" } //音频的查询 var audioCond string var audioPars []interface{} // 如果筛选条件为指定视频ID或只看视频则不做音频查询 //if videoId > 0 || activityVideoId > 0 || filter == 1 { // audioCond += ` AND a.activity_voice_id = 0 ` //} else { // 活动已发布且已结束 audioCond += ` AND b.publish_status = 1 AND b.active_state = 3` if keywordsIk != "" { audioCond += ` AND ( a.voice_name REGEXP ? OR b.label REGEXP ? )` audioCond += ` AND ( a.voice_name NOT LIKE ? AND b.label NOT LIKE ? )` audioPars = append(audioPars, keywordsIk, keywordsIk, keywords, keywords) } if audioId > 0 { audioCond += ` AND a.activity_voice_id = ?` audioPars = append(audioPars, audioId) } //视频的处理 var videoCond string var videoCondAct string var videoPars []interface{} var videoParsAct []interface{} //if audioId > 0 || filter == 2 { // videoCond = "" //} else { if keywordsIk != "" { videoCond += ` AND video_name REGEXP ?` videoPars = append(videoPars, keywordsIk) videoCondAct += ` AND ( v.video_name REGEXP ? OR art.label REGEXP ? )` videoCondAct += ` AND ( v.video_name NOT LIKE ? AND art.label NOT LIKE ? )` videoParsAct = append(videoParsAct, keywordsIk, keywordsIk, keywords, keywords) } if videoId > 0 { videoCond += ` AND video_id = ?` videoPars = append(videoPars, videoId) } if activityVideoId > 0 { videoCondAct += ` AND video_id = ?` videoParsAct = append(videoParsAct, activityVideoId) } //如果传了路演的或者活动的视频ID只查询一个 if videoId > 0 { videoCondAct += ` AND video_id = 0 ` audioCond += ` AND a.activity_voice_id = 0 ` } if activityVideoId > 0 { videoCond += ` AND video_id = 0 ` audioCond += ` AND a.activity_voice_id = 0 ` } if audioId > 0 { videoCondAct += ` AND video_id = 0 ` videoCond += ` AND video_id = 0 ` } if strings.Contains(filter, "1") && !strings.Contains(filter, "2") { audioCond += ` AND a.activity_voice_id = 0 ` } else if !strings.Contains(filter, "1") && strings.Contains(filter, "2") { videoCondAct += ` AND video_id = 0 ` videoCond += ` AND video_id = 0 ` } if strings.Contains(filter, "3") && !strings.Contains(filter, "4") { audioCond += ` AND a.activity_voice_id = 0 ` videoCondAct += ` AND video_id = 0 ` } else if strings.Contains(filter, "3") && !strings.Contains(filter, "4") { videoCond += ` AND video_id = 0 ` } //if filter == "1" { // audioCond += ` AND a.activity_voice_id = 0 ` //} else if filter == "2" { // videoCondAct += ` AND video_id = 0 ` // videoCond += ` AND video_id = 0 ` //} videoCond += ` AND publish_status = 1` //} videoList, e = models.GetMicroRoadShowVideoPageListIkWord(startSize, pageSize, videoCond, videoPars, videoCondAct, videoParsAct, audioCond, audioPars, audioId, videoId, activityVideoId, 0) if e != nil { err = errors.New("获取微路演音视频列表失败分词, Err: " + e.Error()) return } respList = videoList return } // 用户微路演视频回放操作操作行为,模板消息推送 func MicroRoadshowVideoUserRmind(user *models.WxUserItem, videoId int) (err error) { defer func() { if err != nil { go utils.SendAlarmMsg("用户音视频回放操作操作行为,模板消息推送失败"+err.Error(), 2) } }() countUser, err := models.GetUserRemind(user.UserId) if err != nil { return err } if countUser == 0 { return err } var first string var keyword1 string var keyword2 string var keyword3 string var keyword4 string var remark string //获取销售手机号 sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2) if err != nil && err.Error() != utils.ErrNoRow() { return err } if sellerItemQy != nil { sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号 if e != nil { err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error()) return } sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",") openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles) if e != nil { err = errors.New("GetSellerByAdminId, Err: " + e.Error()) return } videoInfo, e := models.GetMicroRoadshowVideoByVideoId(videoId) if e != nil { err = errors.New("GetCygxActivitySpecialDetailById, Err: " + e.Error()) return } if videoInfo == nil { return } first = fmt.Sprint(user.RealName, "--", user.CompanyName, ",有新的互动:播放微路演详视频") keyword1 = videoInfo.VideoName keyword2 = fmt.Sprint("互动:播放微路演详视频,", user.RealName, "--", user.CompanyName) remark = "点击查看微路演详情" openIdArr := make([]string, 0) for _, v := range openIdList { openIdArr = append(openIdArr, v.OpenId) } redirectUrl := utils.WX_MSG_PATH_ACTIVITY_INDUSTRYR_EPORT + strconv.Itoa(videoInfo.IndustryId) sendInfo := new(SendWxTemplate) sendInfo.First = first sendInfo.Keyword1 = keyword1 sendInfo.Keyword2 = keyword2 sendInfo.Keyword3 = keyword3 sendInfo.Keyword4 = keyword4 sendInfo.Remark = remark sendInfo.TemplateId = utils.WxMsgTemplateIdArticleUserRemind sendInfo.RedirectUrl = redirectUrl sendInfo.RedirectTarget = 3 sendInfo.Resource = strconv.Itoa(videoId) sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD sendInfo.OpenIdArr = openIdArr err = PublicSendTemplateMsg(sendInfo) if err != nil { return } } return } // GetindustryVideoDetailById 通过视频ID获取视频详情 func GetAskserieVideoDetailById(user *models.WxUserItem, askserieVideoId int) (industryVideo *models.MicroVideoSimpleInfo, AuthInfo *models.UserPermissionAuthInfo, err error) { total, e := models.GetCygxAskserieVideoCountByVideoId(askserieVideoId) if e != nil { err = errors.New("获取产业关联的视频失败,GetCygxAskserieVideoCountByVideoId " + e.Error()) return } if total == 0 { err = errors.New("视频不存在,或已取消发布") return } // 用户权限 authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId) if e != nil { err = errors.New("获取用户权限失败,GetUserRaiPermissionInfo " + e.Error()) return } videoSimple := new(models.MicroVideoSimpleInfo) // 权限 var au *models.UserPermissionAuthInfo video, e := models.GetCygxAskserieVideoDetail(askserieVideoId) if e != nil { err = errors.New("获取产业关联的视频失败,GetMicroRoadshowVideoByIndustryId " + e.Error()) return } else { videoSimple.Id = video.AskserieVideoId videoSimple.Title = video.VideoName videoSimple.BackgroundImg = video.BackgroundImg videoSimple.DetailImgUrl = video.ShareImg if videoSimple.BackgroundImg == "" { // 获取默认图配置 _, videoMap, _, _, e := GetMicroRoadShowDefaultImgConfig() if e != nil { err = errors.New("获取视频默认配置图失败,GetMicroRoadshowVideoByIndustryId " + e.Error()) return } videoSimple.BackgroundImg = videoMap[video.ChartPermissionId] } videoSimple.PlaySeconds = video.VideoDuration videoSimple.ResourceUrl = video.VideoUrl 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 video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) { au.HasPermission = 2 } } // 无权限的弹框提示 if au.HasPermission != 1 { if au.OperationMode == UserPermissionOperationModeCall { au.PopupMsg = UserPermissionPopupMsgCallMicroVideo } else { au.PopupMsg = UserPermissionPopupMsgApplyMicroVideo } videoSimple.ResourceUrl = "" } } videoSimple.Type = 4 industryVideo = videoSimple AuthInfo = au return } // 记录产业视频播放记录 func AddMicroRoadshowVideoRecord(user *models.WxUserItem, videoId, playSeconds int) { // 十分钟之内的合并 key := utils.CYGX_VIDEO_HISTORY_KEY + utils.CYGX_OBJ_ROADSHOW + strconv.Itoa(videoId) + "_" + strconv.Itoa(user.UserId) if utils.Rc.IsExist(key) { return } utils.Rc.Put(key, 1, 10*time.Minute) var err error defer func() { if err != nil { go utils.SendAlarmMsg(fmt.Sprint("记录用户活动音频播放记录失败 AddMicroRoadshowVideoRecord Err:", err.Error(), "videoId:", videoId, "UserId:", user.UserId), 2) } }() item := new(models.CygxMicroRoadshowVideoHistory) item.UserId = user.UserId item.RealName = user.RealName item.VideoId = videoId item.PlaySeconds = strconv.Itoa(playSeconds) item.Mobile = user.Mobile item.Email = user.Email item.CompanyId = user.CompanyId item.CompanyName = user.CompanyName item.CreateTime = time.Now() item.ModifyTime = time.Now() item.RegisterPlatform = utils.REGISTER_PLATFORM sellerItem, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2) if e != nil && e.Error() != utils.ErrNoRow() { err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error()) return } if sellerItem != nil { item.SellerName = sellerItem.RealName } e = models.AddCygxMicroRoadshowVideoHistory(item) if e != nil { err = errors.New("AddCygxMicroRoadshowVideoHistory, Err: " + e.Error()) return } e = models.UpdateCygxActivityVideoCounts(videoId) if e != nil { err = errors.New("UpdateCygxActivityVideoCounts, Err: " + e.Error()) return } go MicroRoadshowVideoUserRmind(user, videoId) return } // 记录所有微路演音视频播放记录 func AddAllCygxVoiceAndVideoHistory(user *models.WxUserItem, sourceId, sourceType, playSeconds int) { var err error defer func() { if err != nil { go utils.SendAlarmMsg(fmt.Sprint("记录所有微路演音视频播放记录失败 AddAllCygxVoiceAndVideoHistory Err:", err.Error(), "sourceId:", sourceId, "UserId:", user.UserId), 2) } }() item := new(models.CygxVoiceAndVideoHistory) item.UserId = user.UserId item.RealName = user.RealName item.SourceId = sourceId item.SourceType = sourceType item.PlaySeconds = strconv.Itoa(playSeconds) item.Mobile = user.Mobile item.Email = user.Email item.CompanyId = user.CompanyId item.CompanyName = user.CompanyName item.CreateTime = time.Now() item.ModifyTime = time.Now() item.RegisterPlatform = utils.REGISTER_PLATFORM sellerItem, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2) if e != nil && e.Error() != utils.ErrNoRow() { err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error()) return } if sellerItem != nil { item.SellerName = sellerItem.RealName } _, e = models.AddCygxVoiceAndVideoHistory(item) if e != nil { err = errors.New("AddCygxVoiceAndVideoHistory, Err: " + e.Error()) return } return } // 获取满足路演回放的活动类型 func GetActivityLYHFMapByActivityIds(activityIds []int) (mapResp map[int]bool) { var err error defer func() { if err != nil { go utils.SendAlarmMsg("获取满足路演回放的活动类型 GetActivityLYHFMapByActivityIds,失败,活动ID:"+fmt.Sprint(activityIds)+err.Error(), 2) } }() var condition string var pars []interface{} lenArr := len(activityIds) if lenArr == 0 { return } condition = ` AND activity_id IN (` + utils.GetOrmInReplace(lenArr) + `) ` pars = append(pars, activityIds) list, e := models.GetActivityListByCondition(condition, pars) if e != nil { err = errors.New("GetIndustrialManagementNewList, Err: " + e.Error()) return } mapResp = make(map[int]bool, 0) for _, v := range list { mapResp[v.ActivityId] = true } return }