micro_roadshow.go 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177
  1. package services
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "fmt"
  6. "hongze/hongze_mfyx/models"
  7. "hongze/hongze_mfyx/utils"
  8. "strconv"
  9. "strings"
  10. "time"
  11. )
  12. // GetMicroRoadShowDefaultImgConfig 获取微路演默认图/分享图配置
  13. func GetMicroRoadShowDefaultImgConfig() (audioMap, videoMap, audioShareMap, videoShareMap map[int]string, err error) {
  14. audioMap = make(map[int]string, 0)
  15. videoMap = make(map[int]string, 0)
  16. audioShareMap = make(map[int]string, 0)
  17. videoShareMap = make(map[int]string, 0)
  18. key := models.MicroRoadshowDefaultImgKey
  19. conf, e := models.GetConfigByCode(key)
  20. if e != nil {
  21. err = errors.New("获取微路演默认图配置失败, Err: " + e.Error())
  22. return
  23. }
  24. if conf.ConfigValue == "" {
  25. err = errors.New("获取微路演默认图配置有误")
  26. return
  27. }
  28. list := new(models.MicroRoadShowDefaultImgList)
  29. if e = json.Unmarshal([]byte(conf.ConfigValue), &list); e != nil {
  30. err = errors.New("微路演默认图配置配置值解析失败, Err: " + e.Error())
  31. return
  32. }
  33. audioList := list.Audio
  34. for i := range audioList {
  35. audioMap[audioList[i].ChartPermissionId] = audioList[i].ImgUrl
  36. audioShareMap[audioList[i].ChartPermissionId] = audioList[i].ShareImg
  37. }
  38. videoList := list.Video
  39. for i := range videoList {
  40. videoMap[videoList[i].ChartPermissionId] = videoList[i].ImgUrl
  41. videoShareMap[videoList[i].ChartPermissionId] = videoList[i].ShareImg
  42. }
  43. return
  44. }
  45. // GetHomeNewestList 获取首页最新列表
  46. func GetHomeNewestList(userId, companyId, startSize, pageSize int, condition string, pars []interface{}) (resp []*models.HomeArticle, total int, err error) {
  47. resp = make([]*models.HomeArticle, 0)
  48. unionList, e := models.GetHomeNewestListUnionList(condition, pars, startSize, pageSize)
  49. if e != nil {
  50. err = errors.New("获取首页最新列表失败")
  51. return
  52. }
  53. unionTotal, e := models.GetHomeNewestListUnionCount(condition, pars)
  54. if e != nil {
  55. err = errors.New("获取首页最新列表总数失败")
  56. return
  57. }
  58. total = unionTotal
  59. // 用户权限
  60. authInfo, permissionArr, e := GetUserRaiPermissionInfo(userId, companyId)
  61. if e != nil {
  62. err = errors.New("获取用户权限失败, Err: " + e.Error())
  63. return
  64. }
  65. // 获取默认图配置
  66. audioMap, videoMap, audioShareMap, videoShareMap, e := GetMicroRoadShowDefaultImgConfig()
  67. if e != nil {
  68. err = errors.New("获取微路演默认图配置失败, Err: " + e.Error())
  69. return
  70. }
  71. // 此处没有直接使用HomeArticle结构体而是多加了一层, 纯粹是为了方便前端区分纪要和微路演音频=_=!
  72. for _, v := range unionList {
  73. item := new(models.HomeArticle)
  74. item.HomeType = v.HomeType
  75. // 纪要
  76. if item.HomeType == 0 {
  77. item.ArticleId = v.ArticleId
  78. item.Title = v.Title
  79. item.TitleEn = v.TitleEn
  80. item.UpdateFrequency = v.UpdateFrequency
  81. item.CreateDate = v.CreateDate
  82. item.PublishDate = v.PublishDate
  83. item.Body = v.Body
  84. item.BodyHtml = v.BodyHtml
  85. item.Abstract = v.Abstract
  86. item.CategoryName = v.CategoryName
  87. item.SubCategoryName = v.SubCategoryName
  88. item.ExpertBackground = v.ExpertBackground
  89. item.IsResearch = v.IsResearch
  90. item.Pv = v.Pv
  91. item.ImgUrlPc = v.ImgUrlPc
  92. item.CategoryId = v.CategoryId
  93. item.HttpUrl = v.HttpUrl
  94. item.IsNeedJump = v.IsNeedJump
  95. item.Source = v.Source
  96. item.Annotation = v.Annotation
  97. }
  98. // 音频
  99. if v.HomeType == 1 {
  100. ad := new(models.MicroAudioUnionList)
  101. ad.Id = v.Id
  102. ad.AudioTitle = v.AudioTitle
  103. ad.AudioResourceUrl = v.AudioResourceUrl
  104. ad.AudioType = v.AudioType
  105. ad.AudioPublishTime = utils.StrTimeToTime(v.AudioPublishTime).Format(utils.FormatDate)
  106. ad.AudioImgUrl = v.AudioImgUrl
  107. ad.AudioChartPermissionId = v.AudioChartPermissionId
  108. ad.AudioChartPermissionName = v.AudioChartPermissionName
  109. ad.AudioPlaySeconds = v.AudioPlaySeconds
  110. ad.AudioPlaySeconds = v.AudioPlaySeconds
  111. ad.AudioActivityId = v.AudioActivityId
  112. item.MicroAudio = ad
  113. // 默认图
  114. if ad.AudioImgUrl == "" {
  115. if ad.AudioType == 1 {
  116. ad.AudioImgUrl = audioMap[ad.AudioChartPermissionId]
  117. } else {
  118. ad.AudioImgUrl = videoMap[ad.AudioChartPermissionId]
  119. }
  120. }
  121. // 分享图
  122. if ad.AudioType == 1 {
  123. ad.AudioShareImg = audioShareMap[ad.AudioChartPermissionId]
  124. } else {
  125. ad.AudioShareImg = videoShareMap[ad.AudioChartPermissionId]
  126. }
  127. // 权限
  128. au := new(models.UserPermissionAuthInfo)
  129. au.SellerName = authInfo.SellerName
  130. au.SellerMobile = authInfo.SellerMobile
  131. au.HasPermission = authInfo.HasPermission
  132. au.OperationMode = authInfo.OperationMode
  133. if au.HasPermission == 1 {
  134. // 非宏观权限进一步判断是否有权限
  135. if ad.AudioChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, ad.AudioChartPermissionName) {
  136. au.HasPermission = 2
  137. }
  138. }
  139. // 无权限的弹框提示
  140. if au.HasPermission != 1 {
  141. if au.OperationMode == UserPermissionOperationModeCall {
  142. if ad.AudioType == 1 {
  143. au.PopupMsg = UserPermissionPopupMsgCallActivity
  144. } else {
  145. au.PopupMsg = UserPermissionPopupMsgCallMicroVideo
  146. }
  147. } else {
  148. if ad.AudioType == 1 {
  149. au.PopupMsg = UserPermissionPopupMsgApplyActivity
  150. } else {
  151. au.PopupMsg = UserPermissionPopupMsgApplyMicroVideo
  152. }
  153. }
  154. }
  155. ad.AuthInfo = au
  156. }
  157. resp = append(resp, item)
  158. }
  159. return
  160. }
  161. // GetMicroRoadShowPageList 获取微路演列表添加活动视频 更新与8.1版本
  162. func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId int, filter, keywords, audioIds, videoIds, activityVideoIds, chartPermissionIds string) (respList []*models.MicroRoadShowPageList, total int, err error) {
  163. var e error
  164. // 根据每页数据量获取音视频配比
  165. startSize := utils.StartIndex(currentIndex, pageSize)
  166. videoList := make([]*models.MicroRoadShowPageList, 0)
  167. if keywords != "" {
  168. keywords = "%" + keywords + "%"
  169. }
  170. //音频的查询
  171. var audioCond string
  172. var audioPars []interface{}
  173. // 如果筛选条件为指定视频ID或只看视频则不做音频查询
  174. //if videoId > 0 || activityVideoId > 0 || filter == 1 {
  175. // audioCond = ""
  176. //} else {
  177. // 活动已发布且已结束
  178. audioCond += ` AND b.publish_status = 1 AND b.active_state = 3`
  179. //活动音频,设置有效时间为30天,失效后该活动就不再支持音频回放。有效期起始时间为活动的开始时间
  180. //endTime := time.Now().AddDate(0, 0, -30).Format("2006-01-02 15:04:05")
  181. //audioCond += ` AND b.activity_time > ? `
  182. //audioPars = append(audioPars, endTime)
  183. if keywords != "" {
  184. audioCond += ` AND ( a.voice_name LIKE ? OR b.label LIKE ? )`
  185. audioPars = append(audioPars, keywords, keywords)
  186. }
  187. if audioId > 0 {
  188. audioCond += ` AND a.activity_voice_id = ?`
  189. audioPars = append(audioPars, audioId)
  190. }
  191. if audioIds != "" {
  192. sliceId := strings.Split(audioIds, ",")
  193. var idSqlStr string
  194. for _, v := range sliceId {
  195. idSqlStr += "'" + v + "',"
  196. }
  197. idSqlStr = strings.TrimRight(idSqlStr, ",")
  198. audioCond += ` AND a.activity_voice_id IN (` + idSqlStr + `)`
  199. }
  200. //}
  201. //视频的处理
  202. var videoCond string
  203. var videoCondAct string
  204. var videoPars []interface{}
  205. var videoParsAct []interface{}
  206. //if audioId > 0 || filter == 2 {
  207. // videoCond = ""
  208. //} else {
  209. if keywords != "" {
  210. videoCond += ` AND video_name LIKE ?`
  211. videoPars = append(videoPars, keywords)
  212. videoCondAct += ` AND (video_name LIKE ? OR art.label LIKE ?)`
  213. videoParsAct = append(videoParsAct, keywords, keywords)
  214. }
  215. if videoId > 0 {
  216. videoCond += ` AND video_id = ?`
  217. videoPars = append(videoPars, videoId)
  218. }
  219. if activityVideoId > 0 {
  220. videoCondAct += ` AND video_id = ?`
  221. videoParsAct = append(videoParsAct, activityVideoId)
  222. }
  223. if activityVideoIds != "" {
  224. sliceId := strings.Split(activityVideoIds, ",")
  225. var idSqlStr string
  226. for _, v := range sliceId {
  227. idSqlStr += "'" + v + "',"
  228. }
  229. idSqlStr = strings.TrimRight(idSqlStr, ",")
  230. videoCondAct += ` AND v.video_id IN (` + idSqlStr + `)`
  231. }
  232. //如果传了路演的或者活动的视频ID只查询一个
  233. if videoId > 0 {
  234. videoCondAct += ` AND video_id = 0 `
  235. audioCond += ` AND a.activity_voice_id = 0 `
  236. }
  237. if activityVideoId > 0 {
  238. videoCond += ` AND video_id = 0 `
  239. audioCond += ` AND a.activity_voice_id = 0 `
  240. }
  241. if audioId > 0 {
  242. videoCondAct += ` AND video_id = 0 `
  243. videoCond += ` AND video_id = 0 `
  244. }
  245. if strings.Contains(filter, "1") && !strings.Contains(filter, "2") {
  246. audioCond += ` AND a.activity_voice_id = 0 `
  247. } else if !strings.Contains(filter, "1") && strings.Contains(filter, "2") {
  248. videoCondAct += ` AND video_id = 0 `
  249. videoCond += ` AND video_id = 0 `
  250. }
  251. if strings.Contains(filter, "3") && !strings.Contains(filter, "4") {
  252. audioCond += ` AND a.activity_voice_id = 0 `
  253. videoCondAct += ` AND video_id = 0 `
  254. } else if strings.Contains(filter, "3") && !strings.Contains(filter, "4") {
  255. videoCond += ` AND video_id = 0 `
  256. }
  257. if videoIds != "" {
  258. sliceId := strings.Split(videoIds, ",")
  259. var idSqlStr string
  260. for _, v := range sliceId {
  261. idSqlStr += "'" + v + "',"
  262. }
  263. idSqlStr = strings.TrimRight(idSqlStr, ",")
  264. videoCond += ` AND video_id IN (` + idSqlStr + `)`
  265. }
  266. videoCond += ` AND publish_status = 1`
  267. if chartPermissionIds != "" {
  268. videoCond += ` AND chart_permission_id IN (` + chartPermissionIds + `)`
  269. audioCond += ` AND b.chart_permission_id IN (` + chartPermissionIds + `)`
  270. videoCondAct += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
  271. }
  272. //}
  273. total, videoList, e = models.GetMicroRoadShowVideoPageListV8(startSize, pageSize, videoCond, videoPars, videoCondAct, videoParsAct, audioCond, audioPars)
  274. if e != nil {
  275. err = errors.New("获取微路演音视频列表失败, Err: " + e.Error())
  276. return
  277. }
  278. respList = videoList
  279. return
  280. }
  281. // GetMicroRoadShowPageList 获取微路演列表添加活动视频 更新与8.1版本
  282. func GetMicroRoadShowPageListV12(pageSize, currentIndex, sourceId, tableType int, filter, keywords, searchType, chartPermissionIds string) (respList []*models.MicroRoadShowPageList, total int, err error) {
  283. //Type int `description:"类型: 1-活动音频; 2-活动视频; 3-产业视频; 4-系列问答"`
  284. var e error
  285. // 根据每页数据量获取音视频配比
  286. startSize := utils.StartIndex(currentIndex, pageSize)
  287. videoList := make([]*models.MicroRoadShowPageList, 0)
  288. var audioAct string // 活动音频 1
  289. var audioActPars []interface{}
  290. var videoAct string // 活动视频 2
  291. var videoActPars []interface{}
  292. //视频的处理
  293. var videoMico string //产业视频 3
  294. var videoMicoPars []interface{}
  295. var conditionAskserie string // 系列问答 4
  296. var askseriePars []interface{}
  297. if sourceId > 0 && tableType > 0 {
  298. //先给不相干的表查询ID = 0
  299. audioAct += ` AND b.chart_permission_id = 0 `
  300. videoAct += ` AND b.chart_permission_id = 0`
  301. videoMico += ` AND a.chart_permission_id = 0 `
  302. conditionAskserie += ` AND a.chart_permission_id = 0 `
  303. switch tableType {
  304. case 1:
  305. audioAct += ` OR a.activity_id = ` + strconv.Itoa(sourceId)
  306. case 2:
  307. videoAct += ` OR a.activity_id = ` + strconv.Itoa(sourceId)
  308. case 3:
  309. videoMico += ` OR a.video_id = ` + strconv.Itoa(sourceId)
  310. case 4:
  311. conditionAskserie += ` OR a.askserie_video_id = ` + strconv.Itoa(sourceId)
  312. }
  313. }
  314. if filter == "1" {
  315. audioAct += ` AND b.chart_permission_id = 0 `
  316. } else if filter == "2" {
  317. videoAct += ` AND b.chart_permission_id = 0 `
  318. videoMico += ` AND a.chart_permission_id = 0 `
  319. conditionAskserie += ` AND a.chart_permission_id = 0 `
  320. }
  321. if searchType != "" {
  322. // @Param SearchType string int true "搜索类型: 1-路演回放; 2-问答系列; 3-调研反馈 多个用 , 隔开"
  323. videoMico += ` AND a.chart_permission_id = 0 ` // 产业视频不在搜索范围内
  324. if strings.Contains(searchType, "1") && !strings.Contains(searchType, "3") {
  325. audioAct += ` AND a.file_type = 1 `
  326. videoAct += ` AND a.file_type = 1 `
  327. }
  328. if !strings.Contains(searchType, "1") && strings.Contains(searchType, "3") {
  329. audioAct += ` AND a.file_type = 2 `
  330. videoAct += ` AND a.file_type = 2 `
  331. }
  332. if !strings.Contains(searchType, "2") {
  333. conditionAskserie += ` AND a.chart_permission_id = 0 `
  334. }
  335. if !strings.Contains(searchType, "3") && !strings.Contains(searchType, "1") {
  336. audioAct += ` AND b.chart_permission_id = 0 `
  337. videoAct += ` AND b.chart_permission_id = 0 `
  338. }
  339. }
  340. if keywords != "" {
  341. keywords = "%" + keywords + "%"
  342. audioAct += ` AND a.voice_name LIKE ? `
  343. videoAct += ` AND a.video_name LIKE ? `
  344. videoMico += ` AND a.video_name LIKE ? `
  345. conditionAskserie += ` AND a.video_name LIKE ? `
  346. audioActPars = append(audioActPars, keywords)
  347. videoActPars = append(videoActPars, keywords)
  348. videoMicoPars = append(videoMicoPars, keywords)
  349. askseriePars = append(askseriePars, keywords)
  350. }
  351. //行业筛选
  352. if chartPermissionIds != "" {
  353. audioAct += ` AND b.chart_permission_id IN (` + chartPermissionIds + `)`
  354. videoAct += ` AND b.chart_permission_id IN (` + chartPermissionIds + `)`
  355. videoMico += ` AND a.chart_permission_id IN (` + chartPermissionIds + `)`
  356. conditionAskserie += ` AND a.chart_permission_id IN (` + chartPermissionIds + `)`
  357. }
  358. //发布状态
  359. audioAct += ` AND b.publish_status = 1 `
  360. videoAct += ` AND b.publish_status = 1 `
  361. videoMico += ` AND a.publish_status = 1 `
  362. conditionAskserie += ` AND a.publish_status = 1 `
  363. total, videoList, e = models.GetMicroRoadShowVideoPageListV12(startSize, pageSize, audioAct, audioActPars, videoAct, videoActPars, videoMico, videoMicoPars, conditionAskserie, askseriePars)
  364. if e != nil {
  365. err = errors.New("获取微路演音视频列表失败, Err: " + e.Error())
  366. return
  367. }
  368. for _, v := range videoList {
  369. v.LabelType = v.Type
  370. if v.Type == 1 || v.Type == 2 {
  371. v.LabelType = v.ActivityFileType
  372. }
  373. }
  374. respList = videoList
  375. return
  376. }
  377. // GetMicroRoadShowPageListIkWord 添加IK分词联想词 获取微路演列表添加活动视频 更新与8.1版本
  378. func CountMicroRoadShowPageListIkWord(audioId, videoId, activityVideoId int, keywordArr []string, filter, audioIds, videoIds, activityVideoIds string) (total int, err error) {
  379. var e error
  380. var keywords string
  381. if len(keywordArr) > 0 {
  382. keywords = KeyWordArrSqlRegexpAll(keywordArr)
  383. }
  384. //if keywords == "" {
  385. // return
  386. //}
  387. //音频的查询
  388. var audioCond string
  389. var audioPars []interface{}
  390. // 如果筛选条件为指定视频ID或只看视频则不做音频查询
  391. //if videoId > 0 || activityVideoId > 0 || filter == 1 {
  392. // audioCond += ` AND a.activity_voice_id = 0 `
  393. //} else {
  394. // 活动已发布且已结束
  395. audioCond += ` AND b.publish_status = 1 AND b.active_state = 3`
  396. if keywords != "" {
  397. audioCond += ` AND (a.voice_name REGEXP ? OR b.label REGEXP ? ) `
  398. audioPars = append(audioPars, keywords, keywords)
  399. }
  400. if audioId > 0 {
  401. audioCond += ` AND a.activity_voice_id = ?`
  402. audioPars = append(audioPars, audioId)
  403. }
  404. if audioIds != "" {
  405. sliceId := strings.Split(audioIds, ",")
  406. var idSqlStr string
  407. for _, v := range sliceId {
  408. idSqlStr += "'" + v + "',"
  409. }
  410. idSqlStr = strings.TrimRight(idSqlStr, ",")
  411. audioCond += ` AND a.activity_voice_id IN (` + idSqlStr + `)`
  412. }
  413. //}
  414. //视频的处理
  415. var videoCond string
  416. var videoCondAct string
  417. var videoPars []interface{}
  418. var videoParsAct []interface{}
  419. //if audioId > 0 || filter == 2 {
  420. // videoCond = ""
  421. //} else {
  422. if keywords != "" {
  423. videoCond += ` AND video_name REGEXP ? `
  424. videoPars = append(videoPars, keywords)
  425. videoCondAct += ` AND (video_name REGEXP ? OR art.label REGEXP ? )`
  426. videoParsAct = append(videoParsAct, keywords, keywords)
  427. }
  428. if videoId > 0 {
  429. videoCond += ` AND video_id = ? `
  430. videoPars = append(videoPars, videoId)
  431. }
  432. if activityVideoId > 0 {
  433. videoCondAct += ` AND video_id = ?`
  434. videoParsAct = append(videoParsAct, activityVideoId)
  435. }
  436. if activityVideoIds != "" {
  437. sliceId := strings.Split(activityVideoIds, ",")
  438. var idSqlStr string
  439. for _, v := range sliceId {
  440. idSqlStr += "'" + v + "',"
  441. }
  442. idSqlStr = strings.TrimRight(idSqlStr, ",")
  443. videoCondAct += ` AND v.video_id IN (` + idSqlStr + `)`
  444. }
  445. //如果传了路演的或者活动的视频ID只查询一个
  446. if videoId > 0 {
  447. videoCondAct += ` AND video_id = 0 `
  448. audioCond += ` AND a.activity_voice_id = 0 `
  449. }
  450. if activityVideoId > 0 {
  451. videoCond += ` AND video_id = 0 `
  452. audioCond += ` AND a.activity_voice_id = 0 `
  453. }
  454. if audioId > 0 {
  455. videoCondAct += ` AND video_id = 0 `
  456. videoCond += ` AND video_id = 0 `
  457. }
  458. if strings.Contains(filter, "1") && !strings.Contains(filter, "2") {
  459. audioCond += ` AND a.activity_voice_id = 0 `
  460. } else if !strings.Contains(filter, "1") && strings.Contains(filter, "2") {
  461. videoCondAct += ` AND video_id = 0 `
  462. videoCond += ` AND video_id = 0 `
  463. }
  464. if strings.Contains(filter, "3") && !strings.Contains(filter, "4") {
  465. audioCond += ` AND a.activity_voice_id = 0 `
  466. videoCondAct += ` AND video_id = 0 `
  467. } else if strings.Contains(filter, "3") && !strings.Contains(filter, "4") {
  468. videoCond += ` AND video_id = 0 `
  469. }
  470. if videoIds != "" {
  471. sliceId := strings.Split(videoIds, ",")
  472. var idSqlStr string
  473. for _, v := range sliceId {
  474. idSqlStr += "'" + v + "',"
  475. }
  476. idSqlStr = strings.TrimRight(idSqlStr, ",")
  477. videoCond += ` AND video_id IN (` + idSqlStr + `)`
  478. }
  479. videoCond += ` AND publish_status = 1`
  480. //}
  481. total, e = models.CountMicroRoadShowVideoPageList(videoCond, videoPars, videoCondAct, videoParsAct, audioCond, audioPars)
  482. if e != nil {
  483. err = errors.New("获取微路演音视频列表失败, Err: " + e.Error())
  484. return
  485. }
  486. return
  487. }
  488. // GetMicroRoadShowPageListIkWord 添加IK分词联想词 获取微路演列表添加活动视频 更新与8.1版本
  489. func GetMicroRoadShowPageListIkWord(startSize, pageSize, audioId, videoId, activityVideoId int, keywordArr []string, filter, audioIds, videoIds, activityVideoIds, keywords string) (respList []*models.MicroRoadShowPageList, err error) {
  490. videoList := make([]*models.MicroRoadShowPageList, 0)
  491. var e error
  492. var keywordsIk string
  493. if len(keywordArr) > 1 {
  494. keywordsIk = KeyWordArrSqlRegexp(keywordArr)
  495. }
  496. if keywords != "" {
  497. keywords = "%" + keywords + "%"
  498. }
  499. //音频的查询
  500. var audioCond string
  501. var audioPars []interface{}
  502. // 如果筛选条件为指定视频ID或只看视频则不做音频查询
  503. //if videoId > 0 || activityVideoId > 0 || filter == 1 {
  504. // audioCond += ` AND a.activity_voice_id = 0 `
  505. //} else {
  506. // 活动已发布且已结束
  507. audioCond += ` AND b.publish_status = 1 AND b.active_state = 3`
  508. if keywordsIk != "" {
  509. audioCond += ` AND ( a.voice_name REGEXP ? OR b.label REGEXP ? )`
  510. audioCond += ` AND ( a.voice_name NOT LIKE ? AND b.label NOT LIKE ? )`
  511. audioPars = append(audioPars, keywordsIk, keywordsIk, keywords, keywords)
  512. }
  513. if audioId > 0 {
  514. audioCond += ` AND a.activity_voice_id = ?`
  515. audioPars = append(audioPars, audioId)
  516. }
  517. if audioIds != "" {
  518. sliceId := strings.Split(audioIds, ",")
  519. var idSqlStr string
  520. for _, v := range sliceId {
  521. idSqlStr += "'" + v + "',"
  522. }
  523. idSqlStr = strings.TrimRight(idSqlStr, ",")
  524. audioCond += ` AND a.activity_voice_id IN (` + idSqlStr + `)`
  525. }
  526. //}
  527. //视频的处理
  528. var videoCond string
  529. var videoCondAct string
  530. var videoPars []interface{}
  531. var videoParsAct []interface{}
  532. //if audioId > 0 || filter == 2 {
  533. // videoCond = ""
  534. //} else {
  535. if keywordsIk != "" {
  536. videoCond += ` AND video_name REGEXP ?`
  537. videoPars = append(videoPars, keywordsIk)
  538. videoCondAct += ` AND ( v.video_name REGEXP ? OR art.label REGEXP ? )`
  539. videoCondAct += ` AND ( v.video_name NOT LIKE ? AND art.label NOT LIKE ? )`
  540. //videoCondAct += ` AND video_name REGEXP ?`
  541. videoParsAct = append(videoParsAct, keywordsIk, keywordsIk, keywords, keywords)
  542. }
  543. if videoId > 0 {
  544. videoCond += ` AND video_id = ?`
  545. videoPars = append(videoPars, videoId)
  546. }
  547. if activityVideoId > 0 {
  548. videoCondAct += ` AND video_id = ?`
  549. videoParsAct = append(videoParsAct, activityVideoId)
  550. }
  551. if activityVideoIds != "" {
  552. sliceId := strings.Split(activityVideoIds, ",")
  553. var idSqlStr string
  554. for _, v := range sliceId {
  555. idSqlStr += "'" + v + "',"
  556. }
  557. idSqlStr = strings.TrimRight(idSqlStr, ",")
  558. videoCondAct += ` AND v.video_id IN (` + idSqlStr + `)`
  559. }
  560. //如果传了路演的或者活动的视频ID只查询一个
  561. if videoId > 0 {
  562. videoCondAct += ` AND video_id = 0 `
  563. audioCond += ` AND a.activity_voice_id = 0 `
  564. }
  565. if activityVideoId > 0 {
  566. videoCond += ` AND video_id = 0 `
  567. audioCond += ` AND a.activity_voice_id = 0 `
  568. }
  569. if audioId > 0 {
  570. videoCondAct += ` AND video_id = 0 `
  571. videoCond += ` AND video_id = 0 `
  572. }
  573. if strings.Contains(filter, "1") && !strings.Contains(filter, "2") {
  574. audioCond += ` AND a.activity_voice_id = 0 `
  575. } else if !strings.Contains(filter, "1") && strings.Contains(filter, "2") {
  576. videoCondAct += ` AND video_id = 0 `
  577. videoCond += ` AND video_id = 0 `
  578. }
  579. if strings.Contains(filter, "3") && !strings.Contains(filter, "4") {
  580. audioCond += ` AND a.activity_voice_id = 0 `
  581. videoCondAct += ` AND video_id = 0 `
  582. } else if strings.Contains(filter, "3") && !strings.Contains(filter, "4") {
  583. videoCond += ` AND video_id = 0 `
  584. }
  585. if videoIds != "" {
  586. sliceId := strings.Split(videoIds, ",")
  587. var idSqlStr string
  588. for _, v := range sliceId {
  589. idSqlStr += "'" + v + "',"
  590. }
  591. idSqlStr = strings.TrimRight(idSqlStr, ",")
  592. videoCond += ` AND video_id IN (` + idSqlStr + `)`
  593. }
  594. videoCond += ` AND publish_status = 1`
  595. //}
  596. videoList, e = models.GetMicroRoadShowVideoPageListIkWord(startSize, pageSize, videoCond, videoPars, videoCondAct, videoParsAct, audioCond, audioPars)
  597. if e != nil {
  598. err = errors.New("获取微路演音视频列表失败分词, Err: " + e.Error())
  599. return
  600. }
  601. respList = videoList
  602. return
  603. }
  604. // 我的收藏
  605. func GetMicroRoadShowMycollect(pageSize, currentIndex int, audioIds, videoIds, activityVideoIds string) (respList []*models.MicroRoadShowPageList, total int, err error) {
  606. var e error
  607. // 根据每页数据量获取音视频配比
  608. startSize := utils.StartIndex(currentIndex, pageSize)
  609. videoList := make([]*models.MicroRoadShowPageList, 0)
  610. //音频的查询
  611. var audioCond string
  612. var audioPars []interface{}
  613. // 如果筛选条件为指定视频ID或只看视频则不做音频查询
  614. // 活动已发布且已结束
  615. audioCond += ` AND b.publish_status = 1 AND b.active_state = 3`
  616. if audioIds != "" {
  617. sliceId := strings.Split(audioIds, ",")
  618. var idSqlStr string
  619. for _, v := range sliceId {
  620. idSqlStr += "'" + v + "',"
  621. }
  622. idSqlStr = strings.TrimRight(idSqlStr, ",")
  623. audioCond += ` AND a.activity_voice_id IN (` + idSqlStr + `)`
  624. } else {
  625. audioCond += ` AND a.activity_voice_id = 0 `
  626. }
  627. //视频的处理
  628. var videoCond string
  629. var videoCondAct string
  630. if activityVideoIds != "" {
  631. sliceId := strings.Split(activityVideoIds, ",")
  632. var idSqlStr string
  633. for _, v := range sliceId {
  634. idSqlStr += "'" + v + "',"
  635. }
  636. idSqlStr = strings.TrimRight(idSqlStr, ",")
  637. videoCondAct += ` AND v.video_id IN (` + idSqlStr + `)`
  638. } else {
  639. videoCondAct += ` AND v.video_id = 0 `
  640. }
  641. var videoPars []interface{}
  642. var videoParsAct []interface{}
  643. if videoIds != "" {
  644. sliceId := strings.Split(videoIds, ",")
  645. var idSqlStr string
  646. for _, v := range sliceId {
  647. idSqlStr += "'" + v + "',"
  648. }
  649. idSqlStr = strings.TrimRight(idSqlStr, ",")
  650. videoCond += ` AND video_id IN (` + idSqlStr + `)`
  651. } else {
  652. videoCond += ` AND video_id = 0 `
  653. }
  654. videoCond += ` AND publish_status = 1`
  655. total, videoList, e = models.GetMicroRoadShowVideoPageListV8(startSize, pageSize, videoCond, videoPars, videoCondAct, videoParsAct, audioCond, audioPars)
  656. if e != nil {
  657. err = errors.New("获取微路演音视频列表失败, Err: " + e.Error())
  658. return
  659. }
  660. respList = videoList
  661. return
  662. }
  663. // 我的收藏
  664. func GetMicroRoadShowMycollectV12(pageSize, currentIndex int, audioIds, activityVideoIds, roadshowIdsStr, askserieVideoIds string, user *models.WxUserItem) (respList []*models.MicroRoadShowPageList, total int, err error) {
  665. //Type int `description:"类型: 1-活动音频; 2-活动视频; 3-产业视频; 4-系列问答"`
  666. var e error
  667. // 根据每页数据量获取音视频配比
  668. startSize := utils.StartIndex(currentIndex, pageSize)
  669. videoList := make([]*models.MicroRoadShowPageList, 0)
  670. var audioAct string // 活动音频 1
  671. var audioActPars []interface{}
  672. var videoAct string // 活动视频 2
  673. var videoActPars []interface{}
  674. //视频的处理
  675. var videoMico string //产业视频 3
  676. var videoMicoPars []interface{}
  677. var conditionAskserie string // 系列问答 4
  678. var askseriePars []interface{}
  679. if audioIds != "" {
  680. sliceId := strings.Split(audioIds, ",")
  681. audioAct += ` AND a.activity_voice_id IN (` + strings.Join(sliceId, ",") + `)`
  682. } else {
  683. audioAct += ` AND a.activity_voice_id = 0 `
  684. }
  685. if activityVideoIds != "" {
  686. sliceId := strings.Split(activityVideoIds, ",")
  687. videoAct += ` AND a.video_id IN (` + strings.Join(sliceId, ",") + `)`
  688. } else {
  689. videoAct += ` AND a.video_id = 0 `
  690. }
  691. if roadshowIdsStr != "" {
  692. sliceId := strings.Split(roadshowIdsStr, ",")
  693. videoMico += ` AND a.video_id IN (` + strings.Join(sliceId, ",") + `)`
  694. } else {
  695. videoMico += ` AND a.video_id = 0 `
  696. }
  697. if askserieVideoIds != "" {
  698. sliceId := strings.Split(askserieVideoIds, ",")
  699. conditionAskserie += ` AND a.askserie_video_id IN (` + strings.Join(sliceId, ",") + `)`
  700. } else {
  701. conditionAskserie += ` AND a.askserie_video_id = 0 `
  702. }
  703. //发布状态
  704. audioAct += ` AND b.publish_status = 1 `
  705. videoAct += ` AND b.publish_status = 1 `
  706. videoMico += ` AND a.publish_status = 1 `
  707. conditionAskserie += ` AND a.publish_status = 1 `
  708. total, videoList, e = models.GetMicroRoadShowVideoPageListV12(startSize, pageSize, audioAct, audioActPars, videoAct, videoActPars, videoMico, videoMicoPars, conditionAskserie, askseriePars)
  709. if e != nil {
  710. err = errors.New("获取微路演音视频列表失败, Err: " + e.Error())
  711. return
  712. }
  713. userId := user.UserId
  714. listMycollect, e := models.GetUserMicroRoadshowCollectList(userId)
  715. if e != nil {
  716. err = errors.New("GetUserMicroRoadshowCollectList, Err: " + e.Error())
  717. return
  718. }
  719. mapaudioIds := make(map[int]int) //活动音频
  720. mapvideoIds := make(map[int]int) // 微路演视频
  721. mapactivityVideoIds := make(map[int]int) // 活动视频
  722. mapAskserieVideoIds := make(map[int]int) // 活动视频
  723. for _, item := range listMycollect {
  724. if item.ActivityVoiceId > 0 {
  725. mapaudioIds[item.ActivityVoiceId] = item.ActivityVoiceId
  726. } else if item.VideoId > 0 {
  727. mapvideoIds[item.VideoId] = item.VideoId
  728. } else if item.ActivityVideoId > 0 {
  729. mapactivityVideoIds[item.ActivityVideoId] = item.ActivityVideoId
  730. }
  731. }
  732. listAskserieVideoCollect, e := models.GetUserCygxAskserieVideoCollectList(userId)
  733. if e != nil {
  734. err = errors.New("GetUserCygxAskserieVideoCollectList, Err: " + e.Error())
  735. return
  736. }
  737. for _, v := range listAskserieVideoCollect {
  738. if v.AskserieVideoId > 0 {
  739. mapAskserieVideoIds[v.AskserieVideoId] = v.AskserieVideoId
  740. }
  741. }
  742. for _, item := range videoList {
  743. if item.Type == 1 {
  744. //音频
  745. if mapaudioIds[item.Id] > 0 {
  746. item.IsCollect = true
  747. }
  748. } else if item.Type == 2 {
  749. //活动视频
  750. if mapactivityVideoIds[item.Id] > 0 {
  751. item.IsCollect = true
  752. }
  753. } else if item.Type == 3 {
  754. //微路演视频
  755. if mapvideoIds[item.Id] > 0 {
  756. item.IsCollect = true
  757. }
  758. } else if item.Type == 4 {
  759. //系列问答视频
  760. if mapAskserieVideoIds[item.SourceId] > 0 {
  761. item.IsCollect = true
  762. }
  763. }
  764. }
  765. for _, v := range videoList {
  766. v.LabelType = v.Type
  767. if v.Type == 1 || v.Type == 2 {
  768. v.LabelType = v.ActivityFileType
  769. }
  770. }
  771. respList = videoList
  772. return
  773. }
  774. // GetMicroRoadshowVideoMap 获取已经发布的微路演的产业ID
  775. func GetMicroRoadshowVideoMap() (items map[int]int, err error) {
  776. list, e := models.GetMicroRoadshowVideoList()
  777. if e != nil && e.Error() != utils.ErrNoRow() {
  778. err = errors.New("获取已经发布的微路演的产业失败,GetMicroRoadshowVideoList " + e.Error())
  779. return
  780. }
  781. mapindustrialId := make(map[int]int)
  782. for _, v := range list {
  783. mapindustrialId[v.IndustryId] = v.IndustryId
  784. }
  785. items = mapindustrialId
  786. return
  787. }
  788. func GetindustryVideo(user *models.WxUserItem, industrialManagementId int) (industryVideo *models.MicroVideoSimpleInfo, AuthInfo *models.UserPermissionAuthInfo, err error) {
  789. total, e := models.GetMicroRoadshowVideoByIndustryIdCount(industrialManagementId)
  790. if e != nil {
  791. err = errors.New("获取产业关联的视频失败,GetMicroRoadshowVideoByIndustryIdCount " + e.Error())
  792. return
  793. }
  794. if total == 0 {
  795. return
  796. }
  797. // 用户权限
  798. authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  799. if e != nil {
  800. err = errors.New("获取用户权限失败,GetUserRaiPermissionInfo " + e.Error())
  801. return
  802. }
  803. videoSimple := new(models.MicroVideoSimpleInfo)
  804. // 权限
  805. var au *models.UserPermissionAuthInfo
  806. video, e := models.GetMicroRoadshowVideoByIndustryId(industrialManagementId)
  807. if e != nil {
  808. err = errors.New("获取产业关联的视频失败,GetMicroRoadshowVideoByIndustryId " + e.Error())
  809. return
  810. } else {
  811. videoSimple.Id = video.VideoId
  812. videoSimple.Title = "5min【" + video.IndustryName + "】逻辑解析"
  813. videoSimple.BackgroundImg = video.ImgUrl
  814. videoSimple.DetailImgUrl = video.DetailImgUrl
  815. if videoSimple.BackgroundImg == "" {
  816. // 获取默认图配置
  817. _, videoMap, _, _, e := GetMicroRoadShowDefaultImgConfig()
  818. if e != nil {
  819. err = errors.New("获取视频默认配置图失败,GetMicroRoadshowVideoByIndustryId " + e.Error())
  820. return
  821. }
  822. videoSimple.BackgroundImg = videoMap[video.ChartPermissionId]
  823. }
  824. videoSimple.PlaySeconds = video.VideoDuration
  825. videoSimple.ResourceUrl = video.VideoUrl
  826. au = new(models.UserPermissionAuthInfo)
  827. au.SellerName = authInfo.SellerName
  828. au.SellerMobile = authInfo.SellerMobile
  829. au.HasPermission = authInfo.HasPermission
  830. au.OperationMode = authInfo.OperationMode
  831. if au.HasPermission == 1 {
  832. // 非宏观权限进一步判断是否有权限
  833. if video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) {
  834. au.HasPermission = 2
  835. }
  836. }
  837. // 无权限的弹框提示
  838. if au.HasPermission != 1 {
  839. if au.OperationMode == UserPermissionOperationModeCall {
  840. au.PopupMsg = UserPermissionPopupMsgCallMicroVideo
  841. } else {
  842. au.PopupMsg = UserPermissionPopupMsgApplyMicroVideo
  843. }
  844. videoSimple.ResourceUrl = ""
  845. }
  846. }
  847. industryVideo = videoSimple
  848. AuthInfo = au
  849. return
  850. }
  851. // 用户微路演视频回放操作操作行为,模板消息推送
  852. func MicroRoadshowVideoUserRmind(user *models.WxUserItem, videoId int) (err error) {
  853. defer func() {
  854. if err != nil {
  855. go utils.SendAlarmMsg("用户音视频回放操作操作行为,模板消息推送失败"+err.Error(), 2)
  856. }
  857. }()
  858. countUser, err := models.GetUserRemind(user.UserId)
  859. if err != nil {
  860. return err
  861. }
  862. if countUser == 0 {
  863. return err
  864. }
  865. var first string
  866. var keyword1 string
  867. var keyword2 string
  868. var keyword3 string
  869. var keyword4 string
  870. var remark string
  871. //获取销售手机号
  872. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  873. if err != nil && err.Error() != utils.ErrNoRow() {
  874. return err
  875. }
  876. if sellerItemQy != nil {
  877. sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
  878. if e != nil {
  879. err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
  880. return
  881. }
  882. sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
  883. openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
  884. if e != nil {
  885. err = errors.New("GetSellerByAdminId, Err: " + e.Error())
  886. return
  887. }
  888. videoInfo, e := models.GetMicroRoadshowVideoByVideoId(videoId)
  889. if e != nil {
  890. err = errors.New("GetCygxActivitySpecialDetailById, Err: " + e.Error())
  891. return
  892. }
  893. if videoInfo == nil {
  894. return
  895. }
  896. first = fmt.Sprint(user.RealName, "--", user.CompanyName, ",有新的互动:播放微路演详视频")
  897. keyword1 = videoInfo.VideoName
  898. keyword2 = fmt.Sprint("互动:播放微路演详视频,", user.RealName, "--", user.CompanyName)
  899. remark = "点击查看微路演详情"
  900. openIdArr := make([]string, 0)
  901. for _, v := range openIdList {
  902. openIdArr = append(openIdArr, v.OpenId)
  903. }
  904. redirectUrl := utils.WX_MSG_PATH_ACTIVITY_INDUSTRYR_EPORT + strconv.Itoa(videoInfo.IndustryId)
  905. sendInfo := new(SendWxTemplate)
  906. sendInfo.First = first
  907. sendInfo.Keyword1 = keyword1
  908. sendInfo.Keyword2 = keyword2
  909. sendInfo.Keyword3 = keyword3
  910. sendInfo.Keyword4 = keyword4
  911. sendInfo.Remark = remark
  912. sendInfo.TemplateId = utils.WxMsgTemplateIdArticleUserRemind
  913. sendInfo.RedirectUrl = redirectUrl
  914. sendInfo.RedirectTarget = 3
  915. sendInfo.Resource = strconv.Itoa(videoId)
  916. sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
  917. sendInfo.OpenIdArr = openIdArr
  918. err = PublicSendTemplateMsg(sendInfo)
  919. if err != nil {
  920. return
  921. }
  922. }
  923. return
  924. }
  925. // 记录产业视频播放记录
  926. func AddMicroRoadshowVideoRecord(user *models.WxUserItem, videoId, playSeconds int) {
  927. //if playSeconds == 0 {
  928. // return
  929. //}
  930. key := utils.CYGX_VIDEO_HISTORY_KEY + utils.CYGX_OBJ_ROADSHOW + strconv.Itoa(videoId) + "_" + strconv.Itoa(user.UserId)
  931. if utils.Rc.IsExist(key) {
  932. return
  933. }
  934. utils.Rc.Put(key, 1, 10*time.Minute)
  935. var err error
  936. defer func() {
  937. if err != nil {
  938. go utils.SendAlarmMsg(fmt.Sprint("记录用户活动音频播放记录失败 AddMicroRoadshowVideoRecord Err:", err.Error(), "videoId:", videoId, "UserId:", user.UserId), 2)
  939. }
  940. }()
  941. item := new(models.CygxMicroRoadshowVideoHistory)
  942. item.UserId = user.UserId
  943. item.RealName = user.RealName
  944. item.VideoId = videoId
  945. item.PlaySeconds = strconv.Itoa(playSeconds)
  946. item.Mobile = user.Mobile
  947. item.Email = user.Email
  948. item.CompanyId = user.CompanyId
  949. item.CompanyName = user.CompanyName
  950. item.CreateTime = time.Now()
  951. item.ModifyTime = time.Now()
  952. item.RegisterPlatform = utils.REGISTER_PLATFORM
  953. sellerItem, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  954. if e != nil && e.Error() != utils.ErrNoRow() {
  955. err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error())
  956. return
  957. }
  958. if sellerItem != nil {
  959. item.SellerName = sellerItem.RealName
  960. }
  961. //if !utils.Rc.IsExist(key) {
  962. //添加记录
  963. e = models.AddCygxMicroRoadshowVideoHistory(item)
  964. if e != nil {
  965. err = errors.New("AddCygxMicroRoadshowVideoHistory, Err: " + e.Error())
  966. return
  967. }
  968. //播放记录加1
  969. e = models.UpdateCygxMicroRoadshowVideo(videoId)
  970. if e != nil {
  971. err = errors.New("UpdateCygxActivityVideoCounts, Err: " + e.Error())
  972. return
  973. }
  974. go MicroRoadshowVideoUserRmind(user, videoId)
  975. //utils.Rc.Put(key, 1, 10*time.Minute)
  976. //} else {
  977. // //更新停留时长
  978. // lastItem, e := models.GetLastCygxMicroRoadshowVideoHistory(videoId, user.UserId)
  979. // if e != nil {
  980. // err = errors.New("GetLastCygxMicroRoadshowVideoHistory, Err: " + e.Error())
  981. // return
  982. // }
  983. // //更新播放时间
  984. // e = models.UpdateLastCygxMicroRoadshowVideoHistory(strconv.Itoa(playSeconds), lastItem.Id)
  985. // if e != nil {
  986. // err = errors.New("UpdateLastCygxMicroRoadshowVideoHistory, Err: " + e.Error())
  987. // return
  988. // }
  989. //}
  990. //if playSeconds != 0 {
  991. // lastItem, e := models.GetLastCygxMicroRoadshowVideoHistory(videoId, user.UserId)
  992. // if e != nil {
  993. // err = errors.New("GetLastCygxMicroRoadshowVideoHistory, Err: " + e.Error())
  994. // return
  995. // }
  996. // e = models.UpdateLastCygxActivityVideoHistory(strconv.Itoa(playSeconds), lastItem.Id)
  997. // if e != nil {
  998. // err = errors.New("UpdateLastCygxActivityVideoHistory, Err: " + e.Error())
  999. // return
  1000. // }
  1001. // utils.Rc.Put(key, 1, 10*time.Second)
  1002. //} else {
  1003. // e = models.AddCygxMicroRoadshowVideoHistory(item)
  1004. // if e != nil {
  1005. // err = errors.New("AddCygxMicroRoadshowVideoHistory, Err: " + e.Error())
  1006. // return
  1007. // }
  1008. // e = models.UpdateCygxMicroRoadshowVideo(videoId)
  1009. // if e != nil {
  1010. // err = errors.New("UpdateCygxActivityVideoCounts, Err: " + e.Error())
  1011. // return
  1012. // }
  1013. // go MicroRoadshowVideoUserRmind(user, videoId)
  1014. //}
  1015. return
  1016. }
  1017. // 记录所有微路演音视频播放记录
  1018. func AddAllCygxVoiceAndVideoHistory(user *models.WxUserItem, sourceId, sourceType, playSeconds int) {
  1019. var err error
  1020. defer func() {
  1021. if err != nil {
  1022. go utils.SendAlarmMsg(fmt.Sprint("记录所有微路演音视频播放记录失败 AddAllCygxVoiceAndVideoHistory Err:", err.Error(), "sourceId:", sourceId, "UserId:", user.UserId), 2)
  1023. }
  1024. }()
  1025. item := new(models.CygxVoiceAndVideoHistory)
  1026. item.UserId = user.UserId
  1027. item.RealName = user.RealName
  1028. item.SourceId = sourceId
  1029. item.SourceType = sourceType
  1030. item.PlaySeconds = strconv.Itoa(playSeconds)
  1031. item.Mobile = user.Mobile
  1032. item.Email = user.Email
  1033. item.CompanyId = user.CompanyId
  1034. item.CompanyName = user.CompanyName
  1035. item.CreateTime = time.Now()
  1036. item.ModifyTime = time.Now()
  1037. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1038. sellerItem, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1039. if e != nil && e.Error() != utils.ErrNoRow() {
  1040. err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error())
  1041. return
  1042. }
  1043. if sellerItem != nil {
  1044. item.SellerName = sellerItem.RealName
  1045. }
  1046. _, e = models.AddCygxVoiceAndVideoHistory(item)
  1047. if e != nil {
  1048. err = errors.New("AddCygxVoiceAndVideoHistory, Err: " + e.Error())
  1049. return
  1050. }
  1051. return
  1052. }
  1053. // 获取满足路演回放的活动类型
  1054. func GetActivityLYHFMapByActivityIds(activityIds []int) (mapResp map[int]bool) {
  1055. var err error
  1056. defer func() {
  1057. if err != nil {
  1058. go utils.SendAlarmMsg("获取满足路演回放的活动类型 GetActivityLYHFMapByActivityIds,失败,活动ID:"+fmt.Sprint(activityIds)+err.Error(), 2)
  1059. }
  1060. }()
  1061. var condition string
  1062. var pars []interface{}
  1063. lenArr := len(activityIds)
  1064. if lenArr == 0 {
  1065. return
  1066. }
  1067. condition = ` AND activity_id IN (` + utils.GetOrmInReplace(lenArr) + `) `
  1068. pars = append(pars, activityIds)
  1069. list, e := models.GetCygxActivityList(condition, pars, 0, lenArr)
  1070. if e != nil {
  1071. err = errors.New("GetIndustrialManagementNewList, Err: " + e.Error())
  1072. return
  1073. }
  1074. mapResp = make(map[int]bool, 0)
  1075. for _, v := range list {
  1076. mapResp[v.ActivityId] = true
  1077. }
  1078. return
  1079. }
  1080. // 根据活动ID获取对应音视频时长
  1081. func GetActivityVivoByActivityIds(activityIds []int) (mapResp map[int]string) {
  1082. var err error
  1083. defer func() {
  1084. if err != nil {
  1085. go utils.SendAlarmMsg("根据活动ID获取对应音视频时长 GetActivityVivoByActivityIds,失败,活动ID:"+fmt.Sprint(activityIds)+err.Error(), 2)
  1086. }
  1087. }()
  1088. lenArr := len(activityIds)
  1089. if lenArr == 0 {
  1090. return
  1091. }
  1092. list, e := models.GetMicroRoadShowVideoPageListByActivityIds(activityIds)
  1093. if e != nil {
  1094. err = errors.New("GetIndustrialManagementNewList, Err: " + e.Error())
  1095. return
  1096. }
  1097. mapResp = make(map[int]string, 0)
  1098. for _, v := range list {
  1099. mapResp[v.ActivityId] = v.PlaySeconds
  1100. }
  1101. return
  1102. }