report.go 118 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "fmt"
  6. "github.com/medivhzhan/weapp/v2"
  7. "github.com/rdlucklib/rdluck_tools/paging"
  8. "hongze/hongze_cygx/models"
  9. "hongze/hongze_cygx/services"
  10. "hongze/hongze_cygx/utils"
  11. "html"
  12. "strconv"
  13. "strings"
  14. "time"
  15. )
  16. // 报告
  17. type ReportController struct {
  18. BaseAuthController
  19. }
  20. type ReportCommonController struct {
  21. BaseCommonController
  22. }
  23. // @Title 行业报告分类列表接口
  24. // @Description 获取行业报告分类列表接口
  25. // @Param ChartPermissionId query int true "分类ID"
  26. // @Success 200 {object} models.IndustrialManagementList
  27. // @router /home/tradeList [get]
  28. func (this *ReportController) TradeList() {
  29. br := new(models.BaseResponse).Init()
  30. defer func() {
  31. this.Data["json"] = br
  32. this.ServeJSON()
  33. }()
  34. user := this.User
  35. if user == nil {
  36. br.Msg = "请重新登录"
  37. br.Ret = 408
  38. return
  39. }
  40. uid := user.UserId
  41. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  42. if ChartPermissionId < 1 {
  43. br.Msg = "请输入分类ID"
  44. return
  45. }
  46. list, err := models.GetTradeAll(ChartPermissionId)
  47. if err != nil {
  48. br.Msg = "获取信息失败"
  49. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  50. return
  51. }
  52. var condition string
  53. var pars []interface{}
  54. for k, v := range list {
  55. if v.PolymerizationId != "" {
  56. condition = ` AND a.category_id IN(` + v.PolymerizationId + `)`
  57. } else {
  58. condition = ` AND a.category_id IN(` + strconv.Itoa(v.CategoryId) + `)`
  59. }
  60. listArticle, err := models.GetHomeList(condition, pars, 0, 1)
  61. if err != nil && err.Error() != utils.ErrNoRow() {
  62. br.Msg = "获取信息失败"
  63. br.Msg = "GetHomeList,Err:" + err.Error()
  64. return
  65. }
  66. if len(listArticle) > 0 {
  67. list[k].UpdateTime = utils.StrTimeToTime(listArticle[0].PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
  68. count, err := models.CheckThisCategoryNewArticleIsRead(uid, v.CategoryId)
  69. if err != nil {
  70. br.Msg = "获取信息失败"
  71. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  72. return
  73. }
  74. if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.UpdateTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.UpdateTime)) {
  75. list[k].IsRed = true
  76. }
  77. }
  78. }
  79. resp := new(models.TradeReportMappingResp)
  80. resp.List = list
  81. br.Ret = 200
  82. br.Success = true
  83. br.Msg = "获取成功"
  84. br.Data = resp
  85. }
  86. // @Title 产业报告分类列表接口
  87. // @Description 获取产业报告分类列表接口
  88. // @Param ChartPermissionId query int true "分类ID"
  89. // @Param IsNewLabel query string true "是否属于新标签,1是,0否"
  90. // @Param IsDeepLabel query string true "是否属于深标签,1是,0否"
  91. // @Param KeyWord query string true "搜索关键词"
  92. // @Param OrderColumn query int true "排序字段 ,NewTime 最近更新 ,Recommend弘则推荐"
  93. // @Param DeepCover query int false "深度覆盖:0-否;1-是"
  94. // @Param RecommendFocus query int false "推荐关注:0-否;1-是"
  95. // @Param PageSize query int true "每页数据条数"
  96. // @Param CurrentIndex query int true "当前页页码,从1开始"
  97. // @Success 200 {object} models.IndustrialManagementList
  98. // @router /home/industryList [get]
  99. func (this *ReportController) IndustryList() {
  100. br := new(models.BaseResponse).Init()
  101. defer func() {
  102. this.Data["json"] = br
  103. this.ServeJSON()
  104. }()
  105. user := this.User
  106. if user == nil {
  107. br.Msg = "请重新登录"
  108. br.Ret = 408
  109. return
  110. }
  111. uid := user.UserId
  112. fmt.Println(uid)
  113. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  114. orderColumn := this.GetString("OrderColumn")
  115. orderColumnNew := this.GetString("OrderColumn")
  116. isNewLabel := this.GetString("IsNewLabel")
  117. isDeepLabel := this.GetString("IsDeepLabel")
  118. keyWord := this.GetString("KeyWord")
  119. pageSize, _ := this.GetInt("PageSize")
  120. currentIndex, _ := this.GetInt("CurrentIndex")
  121. deepCover, _ := this.GetInt("DeepCover")
  122. recommendFocus, _ := this.GetInt("RecommendFocus")
  123. var orderSrt string
  124. var condition string
  125. var startSize int
  126. resp := new(models.IndustrialManagementList)
  127. if pageSize <= 0 {
  128. pageSize = utils.PageSize20
  129. }
  130. if currentIndex <= 0 {
  131. currentIndex = 1
  132. }
  133. startSize = paging.StartIndex(currentIndex, pageSize)
  134. if isNewLabel == "1" {
  135. condition += ` AND is_new_label = ` + isNewLabel
  136. }
  137. if isDeepLabel == "1" {
  138. condition += ` AND is_deep_label = ` + isDeepLabel
  139. }
  140. if keyWord != "" {
  141. condition += ` AND subject_names LIKE '%` + keyWord + `%'`
  142. }
  143. var sqlChartPermissionId string
  144. if ChartPermissionId > 0 {
  145. sqlChartPermissionId += ` AND man_g.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE chart_permission_id = ` + strconv.Itoa(ChartPermissionId) + ` ) `
  146. condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
  147. }
  148. // 深度覆盖
  149. if deepCover == 1 {
  150. // 查询深标签产业报告数
  151. var deepCondition string
  152. var deepPars []interface{}
  153. deepCondition += ` AND man.is_deep_label = 1`
  154. if ChartPermissionId > 0 {
  155. deepCondition += ` AND man.chart_permission_id = ?`
  156. deepPars = append(deepPars, ChartPermissionId)
  157. }
  158. industryCountList, e := models.GetIndustryArtCountByCondition(deepCondition, deepPars)
  159. if e != nil {
  160. br.Msg = "获取信息失败"
  161. br.ErrMsg = "获取深标签产业报告数失败, Err: " + e.Error()
  162. return
  163. }
  164. deepIdArr := make([]string, 0)
  165. for i := range industryCountList {
  166. if industryCountList[i].ArtNum > 10 {
  167. deepIdArr = append(deepIdArr, strconv.Itoa(industryCountList[i].IndustrialManagementId))
  168. }
  169. }
  170. deepIds := strings.Join(deepIdArr, ",")
  171. if deepIds != "" {
  172. condition = `AND man.industrial_management_id IN (` + deepIds + `)`
  173. }
  174. }
  175. // 推荐关注
  176. if recommendFocus == 1 {
  177. condition += ` AND man.recommended_index >= 80`
  178. }
  179. // 列表总数据量
  180. var list []*models.IndustrialManagement
  181. total, err := models.GetIndustrialManagementAllCount(condition)
  182. if err != nil {
  183. br.Msg = "获取信息失败"
  184. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  185. return
  186. }
  187. page := paging.GetPaging(currentIndex, pageSize, total)
  188. if orderColumn == "" {
  189. orderColumn = "NewTime"
  190. }
  191. if orderColumn == "NewTime" {
  192. orderSrt = "update_time DESC"
  193. } else {
  194. orderSrt = "man.recommended_index DESC,update_time DESC"
  195. }
  196. if ChartPermissionId == 0 {
  197. ChartPermissionId = 20
  198. }
  199. // 阅读第三的产业详情
  200. //detailHot3, err := models.GetIndustrialManagementHot3(ChartPermissionId)
  201. //if err != nil {
  202. // br.Msg = "获取信息失败"
  203. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  204. // return
  205. //}
  206. list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize)
  207. if err != nil {
  208. br.Msg = "获取信息失败"
  209. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  210. return
  211. }
  212. // 获取近一个月产业报告阅读次数最多的产业
  213. var topCond string
  214. var topPars []interface{}
  215. //topReadIndustryId := 0
  216. if ChartPermissionId > 0 {
  217. topCond += ` AND chart_permission_id = ?`
  218. topPars = append(topPars, ChartPermissionId)
  219. }
  220. list, err = services.HandleIndustryList(list, user)
  221. if orderColumnNew != "" {
  222. item := new(models.CygxReportIndustrialSeaarchHistory)
  223. item.UserId = user.UserId
  224. item.Mobile = user.Mobile
  225. item.CompanyId = user.CompanyId
  226. item.CompanyName = user.CompanyName
  227. item.CreateTime = time.Now()
  228. item.IsDeepLabel = isDeepLabel
  229. item.IsNewLabel = isNewLabel
  230. item.ChartPermissionId = ChartPermissionId
  231. if orderColumnNew == "NewTime" {
  232. item.OrderColumn = "0"
  233. } else {
  234. item.OrderColumn = "1"
  235. }
  236. go models.AddCygxReportIndustrialSeaarchHistory(item)
  237. }
  238. resp.List = list
  239. resp.Paging = page
  240. br.Ret = 200
  241. br.Success = true
  242. br.Msg = "获取成功"
  243. br.Data = resp
  244. }
  245. // @Title 产业下所关联的文章分类列表
  246. // @Description 产业下所关联的文章分类列表接口
  247. // @Param IndustrialManagementId query int true "产业ID"
  248. // @Param ShowTimeLine query int true "是否展示时间线 0不展示,1展示"
  249. // @Success 200 {object} models.IndustrialToArticleCategoryListRep
  250. // @router /toArticleCategoryList [get]
  251. func (this *ReportController) ArticleCategoryList() {
  252. br := new(models.BaseResponse).Init()
  253. defer func() {
  254. this.Data["json"] = br
  255. this.ServeJSON()
  256. }()
  257. user := this.User
  258. if user == nil {
  259. br.Msg = "请重新登录"
  260. br.Ret = 408
  261. return
  262. }
  263. uid := user.UserId
  264. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  265. if industrialManagementId < 1 {
  266. br.Msg = "请输入分类ID"
  267. return
  268. }
  269. showTimeLine, _ := this.GetInt("ShowTimeLine", 0)
  270. detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  271. if err != nil {
  272. br.Msg = "获取信息失败"
  273. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  274. return
  275. }
  276. list, err := models.IndustrialToArticleCategoryNew(industrialManagementId)
  277. if err != nil {
  278. br.Msg = "获取信息失败"
  279. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  280. return
  281. }
  282. for k, v := range list {
  283. recordCount, err := models.IndustrialUserRecordArticleCount(uid, industrialManagementId, v.CategoryId)
  284. if err != nil && err.Error() != utils.ErrNoRow() {
  285. br.Msg = "获取信息失败"
  286. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  287. return
  288. }
  289. Newdetail, err := models.GetNewIndustrialUserRecordArticle(industrialManagementId, v.CategoryId)
  290. if err != nil && err.Error() != utils.ErrNoRow() {
  291. br.Msg = "获取信息失败"
  292. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  293. return
  294. }
  295. if Newdetail != nil {
  296. if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
  297. list[k].IsRed = true
  298. }
  299. }
  300. }
  301. // 用户权限
  302. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  303. if e != nil {
  304. br.Msg = "获取失败"
  305. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  306. return
  307. }
  308. videoSimple := new(models.MicroVideoSimpleInfo)
  309. // 权限
  310. var au *models.UserPermissionAuthInfo
  311. video, err := models.GetMicroRoadshowVideoByIndustryId(industrialManagementId)
  312. if err != nil {
  313. if err.Error() != utils.ErrNoRow() {
  314. br.Msg = "获取产业视频失败"
  315. br.ErrMsg = "获取产业视频失败,Err:" + err.Error()
  316. return
  317. }
  318. } else {
  319. videoSimple.Id = video.VideoId
  320. videoSimple.Title = "5min逻辑【" + video.IndustryName + "】解析"
  321. videoSimple.BackgroundImg = video.ImgUrl
  322. videoSimple.DetailImgUrl = video.DetailImgUrl
  323. if videoSimple.BackgroundImg == "" {
  324. // 获取默认图配置
  325. _, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
  326. if e != nil {
  327. br.Msg = "获取视频默认配置图失败"
  328. br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
  329. return
  330. }
  331. videoSimple.BackgroundImg = videoMap[video.ChartPermissionId]
  332. }
  333. videoSimple.PlaySeconds = video.VideoDuration
  334. videoSimple.ResourceUrl = video.VideoUrl
  335. au = new(models.UserPermissionAuthInfo)
  336. au.SellerName = authInfo.SellerName
  337. au.SellerMobile = authInfo.SellerMobile
  338. au.HasPermission = authInfo.HasPermission
  339. au.OperationMode = authInfo.OperationMode
  340. if au.HasPermission == 1 {
  341. // 非宏观权限进一步判断是否有权限
  342. if video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) {
  343. au.HasPermission = 2
  344. }
  345. }
  346. // 无权限的弹框提示
  347. if au.HasPermission != 1 {
  348. if au.OperationMode == services.UserPermissionOperationModeCall {
  349. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  350. } else {
  351. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  352. }
  353. videoSimple.ResourceUrl = ""
  354. }
  355. }
  356. //时间线
  357. if showTimeLine == 1 {
  358. timeLineItem := models.IndustrialToArticleCategoryRep{
  359. CategoryId: 99999,
  360. MatchTypeName: "时间线",
  361. }
  362. timeLineList, err := models.GetTimeLineReportIndustrialList(user.UserId, industrialManagementId, 0, 30)
  363. if err != nil {
  364. br.Msg = "获取信息失败"
  365. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  366. return
  367. }
  368. //查询用户今天是否看过时间线
  369. haveMorningMeeting := false
  370. var morningMeetingTime string
  371. count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
  372. if err != nil {
  373. br.Msg = "查询浏览记录数量失败"
  374. br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
  375. return
  376. }
  377. var recordItem *models.CygxPageHistoryRecord
  378. if count > 1 {
  379. recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
  380. if err != nil {
  381. br.Msg = "查询浏览记录失败"
  382. br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
  383. return
  384. }
  385. }
  386. for _, v := range timeLineList {
  387. if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishTime)) {
  388. if v.SubCategoryName == "时间线" {
  389. haveMorningMeeting = true
  390. morningMeetingTime = v.PublishTime
  391. continue
  392. }
  393. timeLineItem.IsRed = true
  394. }
  395. }
  396. //因为无法记录用户是否看过晨会点评,所以用用户今天是否看过时间线来判断是否显示小红点,这里是判断分类的小红点
  397. timeLineRed := false
  398. if count < 2 {
  399. timeLineRed = true
  400. } else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(morningMeetingTime)) {
  401. timeLineRed = true
  402. }
  403. if !timeLineItem.IsRed && timeLineRed && haveMorningMeeting {
  404. timeLineItem.IsRed = true
  405. }
  406. list = append([]*models.IndustrialToArticleCategoryRep{&timeLineItem}, list...)
  407. }
  408. resp := new(models.IndustrialToArticleCategoryListRep)
  409. resp.List = list
  410. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  411. resp.IndustryName = detail.IndustryName
  412. resp.IndustrialManagementId = industrialManagementId
  413. resp.AuthInfo = au
  414. if videoSimple.Id > 0 {
  415. resp.IndustryVideo = videoSimple
  416. }
  417. br.Ret = 200
  418. br.Success = true
  419. br.Msg = "获取成功"
  420. br.Data = resp
  421. }
  422. // @Title 产业文章列表接口
  423. // @Description 获取产业文章列表接口
  424. // @Param PageSize query int true "每页数据条数"
  425. // @Param CurrentIndex query int true "当前页页码,从1开始"
  426. // @Param CategoryId query int true "分类ID"
  427. // @Param IndustrialManagementId query int true "产业ID"
  428. // @Success 200 {object} models.TacticsListResp
  429. // @router /industry/ArticleList [get]
  430. func (this *ReportController) List() {
  431. br := new(models.BaseResponse).Init()
  432. defer func() {
  433. this.Data["json"] = br
  434. this.ServeJSON()
  435. }()
  436. user := this.User
  437. if user == nil {
  438. br.Msg = "请重新登录"
  439. br.Ret = 408
  440. return
  441. }
  442. uid := user.UserId
  443. pageSize, _ := this.GetInt("PageSize")
  444. currentIndex, _ := this.GetInt("CurrentIndex")
  445. categoryId, _ := this.GetInt("CategoryId")
  446. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  447. var startSize int
  448. if pageSize <= 0 {
  449. pageSize = utils.PageSize20
  450. }
  451. if currentIndex <= 0 {
  452. currentIndex = 1
  453. }
  454. startSize = paging.StartIndex(currentIndex, pageSize)
  455. var pars []interface{}
  456. var total int
  457. page := paging.GetPaging(currentIndex, pageSize, total)
  458. if categoryId < 1 {
  459. br.Msg = "请输入分类ID"
  460. return
  461. }
  462. if industrialManagementId < 1 {
  463. br.Msg = "请输入产业ID"
  464. return
  465. }
  466. if categoryId != 99999 {
  467. resp := new(models.TacticsListResp)
  468. //获取该产业下所对应的行业图片
  469. detail, errCategory := models.GetdetailByCategoryIdOne(categoryId)
  470. if errCategory != nil {
  471. br.Msg = "获取信息失败"
  472. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  473. return
  474. }
  475. //对应行业的图片
  476. detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  477. if err != nil {
  478. br.Msg = "获取数据失败"
  479. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  480. return
  481. }
  482. chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  483. mapChartPermission := make(map[string]string)
  484. var permissionName string
  485. var imgUrlChartPermission string
  486. for _, v := range chartPermissionUrlList {
  487. vslice := strings.Split(v, "_")
  488. permissionName = vslice[0]
  489. imgUrlChartPermission = vslice[len(vslice)-1]
  490. mapChartPermission[permissionName] = imgUrlChartPermission
  491. }
  492. total, err = models.GetReportIndustrialCount(categoryId, industrialManagementId)
  493. if err != nil {
  494. br.Msg = "获取信息失败"
  495. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  496. return
  497. }
  498. page = paging.GetPaging(currentIndex, pageSize, total)
  499. list, err := models.GetReportIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
  500. if err != nil {
  501. br.Msg = "获取信息失败"
  502. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  503. return
  504. }
  505. //对应分类的所图片
  506. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  507. if err != nil {
  508. br.Msg = "获取数据失败"
  509. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  510. return
  511. }
  512. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  513. mapCategoryUrl := make(map[string]string)
  514. var categoryIdStr string
  515. var imgUrlChart string
  516. for _, v := range categoryUrlList {
  517. vslice := strings.Split(v, "_")
  518. categoryIdStr = vslice[0]
  519. imgUrlChart = vslice[len(vslice)-1]
  520. mapCategoryUrl[categoryIdStr] = imgUrlChart
  521. }
  522. lenList := len(list)
  523. for i := 0; i < lenList; i++ {
  524. item := list[i]
  525. list[i].Body, _ = services.GetReportContentTextSub(item.Body)
  526. //list[i].Abstract = html.UnescapeString(item.Abstract)
  527. list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  528. //list[i].Annotation = services.GetAnnotationTextSub(item.Annotation)
  529. }
  530. for k, v := range list {
  531. if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  532. list[k].IsRed = true
  533. }
  534. if v.VideoUrl != "" {
  535. list[k].IsHaveVideo = true
  536. }
  537. list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  538. if mapCategoryUrl[v.CategoryId] == "" {
  539. if detail.ChartPermissionId == utils.YI_YAO_ID {
  540. list[k].ImgUrlPc = utils.YI_YAO_QI_TA
  541. }
  542. }
  543. }
  544. resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  545. resp.ChartPermissionId = detail.ChartPermissionId
  546. resp.List = list
  547. resp.Paging = page
  548. br.Ret = 200
  549. br.Success = true
  550. br.Msg = "获取成功"
  551. br.Data = resp
  552. } else {
  553. //获取该产业下所对应的行业图片
  554. //因为时间线不属于数据表里的二级分类,所以图片Id用产业id查到的list中的任意一个categoryId取到的图片替代
  555. categoryList, err := models.IndustrialToArticleCategoryNew(industrialManagementId)
  556. if err != nil {
  557. br.Msg = "获取信息失败"
  558. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  559. return
  560. }
  561. var timeLineCategoryId int
  562. if len(categoryList) > 0 {
  563. timeLineCategoryId = categoryList[0].CategoryId
  564. }
  565. var detail *models.ReportMapping
  566. var errCategory error
  567. if timeLineCategoryId > 0 {
  568. detail, errCategory = models.GetdetailByCategoryIdOne(timeLineCategoryId)
  569. if errCategory != nil {
  570. br.Msg = "获取信息失败"
  571. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  572. return
  573. }
  574. }
  575. //对应行业的图片
  576. detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  577. if err != nil {
  578. br.Msg = "获取数据失败"
  579. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  580. return
  581. }
  582. chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  583. mapChartPermission := make(map[string]string)
  584. var permissionName string
  585. var imgUrlChartPermission string
  586. for _, v := range chartPermissionUrlList {
  587. vslice := strings.Split(v, "_")
  588. permissionName = vslice[0]
  589. imgUrlChartPermission = vslice[len(vslice)-1]
  590. mapChartPermission[permissionName] = imgUrlChartPermission
  591. }
  592. total, err := models.GetTimeLineReportIndustrialCount(industrialManagementId)
  593. if err != nil {
  594. br.Msg = "获取信息失败"
  595. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  596. return
  597. }
  598. page = paging.GetPaging(currentIndex, pageSize, total)
  599. list, err := models.GetTimeLineReportIndustrialList(user.UserId, industrialManagementId, startSize, pageSize)
  600. if err != nil {
  601. br.Msg = "获取信息失败"
  602. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  603. return
  604. }
  605. //对应分类的所图片
  606. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  607. if err != nil {
  608. br.Msg = "获取数据失败"
  609. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  610. return
  611. }
  612. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  613. mapCategoryUrl := make(map[string]string)
  614. var categoryIdStr string
  615. var imgUrlChart string
  616. for _, v := range categoryUrlList {
  617. vslice := strings.Split(v, "_")
  618. categoryIdStr = vslice[0]
  619. imgUrlChart = vslice[len(vslice)-1]
  620. mapCategoryUrl[categoryIdStr] = imgUrlChart
  621. }
  622. //lenList := len(list)
  623. //for i := 0; i < lenList; i++ {
  624. // item := list[i]
  625. // list[i].Content, _ = services.GetReportContentTextSub(item.Content)
  626. // //list[i].Abstract = html.UnescapeString(item.Abstract)
  627. // //list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  628. //}
  629. //查询用户今天是否看过时间线
  630. count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
  631. if err != nil {
  632. br.Msg = "查询浏览记录数量失败"
  633. br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
  634. return
  635. }
  636. var recordItem *models.CygxPageHistoryRecord
  637. if count > 1 {
  638. recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
  639. if err != nil {
  640. br.Msg = "查询浏览记录失败"
  641. br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
  642. return
  643. }
  644. }
  645. for k, v := range list {
  646. if v.SubCategoryName != "时间线" && v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishTime)) {
  647. list[k].IsRed = true
  648. }
  649. timeLineRed := false
  650. if count < 2 && v.SubCategoryName == "时间线" {
  651. timeLineRed = true
  652. } else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishTime)) {
  653. timeLineRed = true
  654. }
  655. if v.SubCategoryName == "时间线" && timeLineRed {
  656. list[k].IsRed = true
  657. }
  658. if v.VideoUrl != "" {
  659. list[k].IsHaveVideo = true
  660. }
  661. id := strconv.Itoa(timeLineCategoryId)
  662. list[k].ImgUrlPc = mapCategoryUrl[id]
  663. if mapCategoryUrl[id] == "" {
  664. if detail.ChartPermissionId == utils.YI_YAO_ID {
  665. list[k].ImgUrlPc = utils.YI_YAO_QI_TA
  666. }
  667. }
  668. }
  669. resp := new(models.TimeLineReportListResp)
  670. resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  671. resp.List = list
  672. resp.Paging = page
  673. br.Ret = 200
  674. br.Success = true
  675. br.Msg = "获取成功"
  676. br.Data = resp
  677. }
  678. }
  679. // @Title 置顶/取消置顶
  680. // @Description 置顶
  681. // @Param request body models.CygxIndustryTopRep true "type json string"
  682. // @Success 200
  683. // @router /top [post]
  684. func (this *ReportController) ArticleCollect() {
  685. br := new(models.BaseResponse).Init()
  686. defer func() {
  687. this.Data["json"] = br
  688. this.ServeJSON()
  689. }()
  690. user := this.User
  691. if user == nil {
  692. br.Msg = "请重新登录"
  693. br.Ret = 408
  694. return
  695. }
  696. uid := user.UserId
  697. var req models.CygxIndustryTopRep
  698. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  699. if err != nil {
  700. br.Msg = "参数解析异常!"
  701. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  702. return
  703. }
  704. industrialManagementId := req.IndustrialManagementId
  705. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  706. if err != nil {
  707. br.Msg = "获取数据失败!"
  708. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  709. return
  710. }
  711. if countIndustrial == 0 {
  712. br.Msg = "产业不存在!"
  713. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  714. return
  715. }
  716. count, err := models.GetCygxIndustryTop(uid, industrialManagementId)
  717. if err != nil {
  718. br.Msg = "获取数据失败!"
  719. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  720. return
  721. }
  722. resp := new(models.ArticleCollectResp)
  723. if count <= 0 {
  724. item := new(models.CygxIndustryTop)
  725. item.IndustrialManagementId = req.IndustrialManagementId
  726. item.UserId = uid
  727. item.CreateTime = time.Now()
  728. _, err = models.AddCygxIndustryTop(item)
  729. if err != nil {
  730. br.Msg = "置顶失败"
  731. br.ErrMsg = "置顶失败,Err:" + err.Error()
  732. return
  733. }
  734. br.Msg = "置顶成功"
  735. resp.Status = 1
  736. } else {
  737. err = models.RemoveCygxIndustryTop(uid, industrialManagementId)
  738. if err != nil {
  739. br.Msg = "取消置顶失败"
  740. br.ErrMsg = "取消置顶失败,Err:" + err.Error()
  741. return
  742. }
  743. br.Msg = "已取消置顶"
  744. resp.Status = 2
  745. }
  746. br.Ret = 200
  747. br.Success = true
  748. br.Data = resp
  749. }
  750. // @Title 关注/取消关注产业
  751. // @Description 关注/取消关注 接口
  752. // @Param request body models.CygxIndustryFllowRep true "type json string"
  753. // @Success 200
  754. // @router /fllow [post]
  755. func (this *ReportController) Fllow() {
  756. br := new(models.BaseResponse).Init()
  757. defer func() {
  758. this.Data["json"] = br
  759. this.ServeJSON()
  760. }()
  761. user := this.User
  762. if user == nil {
  763. br.Msg = "请重新登录"
  764. br.Ret = 408
  765. return
  766. }
  767. uid := user.UserId
  768. var req models.CygxIndustryFllowRep
  769. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  770. if err != nil {
  771. br.Msg = "参数解析异常!"
  772. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  773. return
  774. }
  775. industrialManagementId := req.IndustrialManagementId
  776. var condition string
  777. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  778. if err != nil {
  779. br.Msg = "获取数据失败!"
  780. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  781. return
  782. }
  783. if countIndustrial == 0 {
  784. br.Msg = "产业不存在!"
  785. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  786. return
  787. }
  788. count, err := models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
  789. if err != nil {
  790. br.Msg = "获取数据失败!"
  791. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  792. return
  793. }
  794. resp := new(models.CygxIndustryFllowResp)
  795. countUser, err := models.GetCountCygxIndustryFllowByUid(uid)
  796. if countUser == 0 {
  797. resp.GoFollow = true
  798. }
  799. if count == 0 {
  800. item := new(models.CygxIndustryFllow)
  801. item.IndustrialManagementId = industrialManagementId
  802. item.UserId = uid
  803. item.Email = user.Email
  804. item.Mobile = user.Mobile
  805. item.RealName = user.RealName
  806. item.CompanyId = user.CompanyId
  807. item.CompanyName = user.CompanyName
  808. item.Type = 1
  809. item.CreateTime = time.Now()
  810. item.ModifyTime = time.Now()
  811. _, err = models.AddCygxIndustryFllow(item)
  812. if err != nil {
  813. br.Msg = "操作失败"
  814. br.ErrMsg = "操作失败,Err:" + err.Error()
  815. return
  816. }
  817. resp.Status = 1
  818. } else {
  819. err = models.RemoveCygxIndustryFllow(uid, industrialManagementId)
  820. if err != nil {
  821. br.Msg = "操作失败"
  822. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  823. return
  824. }
  825. }
  826. //处理是否关注全部赛道字段
  827. go services.IndustryFllowWithTrack(industrialManagementId, count, uid)
  828. br.Msg = "操作成功"
  829. br.Ret = 200
  830. br.Success = true
  831. br.Data = resp
  832. }
  833. // @Title 产业报告分类关联作者列表接口
  834. // @Description 获取产业报告分类关联作者列表接口
  835. // @Param ChartPermissionId query int true "分类ID"
  836. // @Param PageSize query int true "每页数据条数"
  837. // @Param CurrentIndex query int true "当前页页码,从1开始"
  838. // @Success 200 {object} models.CygxArticleDepartmentList
  839. // @router /industryListByDepartment [get]
  840. func (this *ReportController) IndustryListByDepartment() {
  841. br := new(models.BaseResponse).Init()
  842. defer func() {
  843. this.Data["json"] = br
  844. this.ServeJSON()
  845. }()
  846. user := this.User
  847. if user == nil {
  848. br.Msg = "请重新登录"
  849. br.Ret = 408
  850. return
  851. }
  852. uid := user.UserId
  853. pageSize, _ := this.GetInt("PageSize")
  854. currentIndex, _ := this.GetInt("CurrentIndex")
  855. //chartPermissionId, _ := this.GetInt("ChartPermissionId")
  856. var startSize int
  857. var condition string
  858. //condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  859. condition = ` AND a.publish_status=1 `
  860. if pageSize <= 0 {
  861. pageSize = utils.PageSize20
  862. }
  863. if currentIndex <= 0 {
  864. currentIndex = 1
  865. }
  866. startSize = paging.StartIndex(currentIndex, pageSize)
  867. total, err := models.GetArticleDepartmentCount(condition)
  868. page := paging.GetPaging(currentIndex, pageSize, total)
  869. resp := new(models.CygxArticleDepartmentList)
  870. userType, _, err := services.GetUserType(user.CompanyId)
  871. if err != nil {
  872. br.Msg = "获取信息失败"
  873. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  874. return
  875. }
  876. if userType == 1 {
  877. resp.Paging = page
  878. br.Ret = 200
  879. br.Success = true
  880. br.Msg = "获取成功"
  881. br.Data = resp
  882. return
  883. }
  884. resp.HaveResearch = true
  885. //获取作者信息,并排序
  886. list, err := models.GetCygxArticleDepartmentList(startSize, pageSize, condition, uid)
  887. if err != nil {
  888. br.Msg = "获取信息失败"
  889. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  890. return
  891. }
  892. for k, v := range list {
  893. artList, err := models.GetArticleByDepartmentId(v.DepartmentId)
  894. if err != nil {
  895. br.Msg = "获取信息失败"
  896. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  897. return
  898. }
  899. for k2, v2 := range artList {
  900. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  901. if err != nil {
  902. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  903. br.ErrMsg = "获取失败,Err:" + err.Error()
  904. return
  905. }
  906. var subjectNamesNew string
  907. if len(subjectNames) > 0 {
  908. slice := strings.Split(subjectNames, "/")
  909. for k3, v3 := range slice {
  910. if k3 < 4 {
  911. subjectNamesNew += v3 + "/"
  912. }
  913. }
  914. }
  915. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  916. if err != nil && err.Error() != utils.ErrNoRow() {
  917. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  918. br.ErrMsg = "获取失败,Err:" + err.Error()
  919. return
  920. }
  921. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  922. artList[k2].SubjectName = subjectNamesNew
  923. artList[k2].DepartmentId = v.DepartmentId
  924. if subjectNamesNew == "" {
  925. artList[k2].IndustryName = industryName
  926. } else {
  927. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  928. }
  929. if artList[k2].IsReport == "1" {
  930. artList[k2].IndustryName = "【观点】" + artList[k2].IndustryName
  931. } else {
  932. artList[k2].IndustryName = "【纪要】" + artList[k2].IndustryName
  933. }
  934. }
  935. list[k].List = artList
  936. if v.FollowNum > 0 {
  937. list[k].IsMyFollow = true
  938. }
  939. }
  940. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  941. if err != nil {
  942. br.Msg = "获取信息失败"
  943. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  944. return
  945. }
  946. if len(listnNew) > 0 {
  947. for _, v := range listnNew {
  948. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  949. Management := new(models.IndustrialManagementIdInt)
  950. if firstStr == 0 {
  951. Management.IndustryName = v.IndustryName
  952. } else {
  953. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  954. if err != nil {
  955. br.Msg = "获取信息失败"
  956. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  957. return
  958. }
  959. var subjectNamesNew string
  960. for _, v1 := range listSub {
  961. subjectNamesNew += v1.SubjectName + "/"
  962. }
  963. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  964. Management.IndustryName = subjectNamesNew
  965. }
  966. Management.IndustrialManagementId = v.IndustrialManagementId
  967. Management.ArticleId = v.ArticleId
  968. resp.ListnNew = append(resp.ListnNew, Management)
  969. }
  970. }
  971. resp.List = list
  972. resp.Paging = page
  973. br.Ret = 200
  974. br.Success = true
  975. br.Msg = "获取成功"
  976. br.Data = resp
  977. }
  978. // @Title 关注作者/取消关注作者
  979. // @Description 关注作者/取消关注作者 接口
  980. // @Param request body models.CygxArticleDepartmentId true "type json string"
  981. // @Success 200
  982. // @router /fllowDepartment [post]
  983. func (this *ReportController) FllowDepartment() {
  984. br := new(models.BaseResponse).Init()
  985. defer func() {
  986. this.Data["json"] = br
  987. this.ServeJSON()
  988. }()
  989. user := this.User
  990. if user == nil {
  991. br.Msg = "请重新登录"
  992. br.Ret = 408
  993. return
  994. }
  995. uid := user.UserId
  996. var req models.CygxArticleDepartmentId
  997. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  998. if err != nil {
  999. br.Msg = "参数解析异常!"
  1000. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1001. return
  1002. }
  1003. departmentId := req.DepartmentId
  1004. var condition string
  1005. countDepartment, err := models.GetDepartmentCount(departmentId)
  1006. if err != nil {
  1007. br.Msg = "获取数据失败!"
  1008. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1009. return
  1010. }
  1011. if countDepartment == 0 {
  1012. br.Msg = "作者不存在!"
  1013. br.ErrMsg = "作者ID不存在:" + strconv.Itoa(departmentId)
  1014. return
  1015. }
  1016. countUser, err := models.GetArticleDepartmentFollowByUid(uid)
  1017. count, err := models.GetArticleDepartmentFollow(uid, departmentId, condition)
  1018. if err != nil {
  1019. br.Msg = "获取数据失败!"
  1020. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1021. return
  1022. }
  1023. resp := new(models.CygxArticleDepartmentFollowResp)
  1024. if countUser == 0 {
  1025. resp.GoFollow = true
  1026. }
  1027. if count == 0 {
  1028. item := new(models.CygxArticleDepartmentFollow)
  1029. item.DepartmentId = departmentId
  1030. item.UserId = uid
  1031. item.Email = user.Email
  1032. item.Mobile = user.Mobile
  1033. item.RealName = user.RealName
  1034. item.CompanyId = user.CompanyId
  1035. item.CompanyName = user.CompanyName
  1036. item.Type = 1
  1037. item.CreateTime = time.Now()
  1038. item.ModifyTime = time.Now()
  1039. _, err = models.AddArticleDepartmentFollow(item)
  1040. if err != nil {
  1041. br.Msg = "操作失败"
  1042. br.ErrMsg = "操作失败,Err:" + err.Error()
  1043. return
  1044. }
  1045. resp.Status = 1
  1046. } else {
  1047. var doType int
  1048. condition = ` AND type = 1`
  1049. count, err = models.GetArticleDepartmentFollow(uid, departmentId, condition)
  1050. if err != nil {
  1051. br.Msg = "操作失败!"
  1052. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1053. return
  1054. }
  1055. if count == 1 {
  1056. resp.Status = 2
  1057. doType = 2
  1058. } else {
  1059. resp.Status = 1
  1060. doType = 1
  1061. }
  1062. err = models.RemoveArticleDepartmentFollow(uid, departmentId, doType)
  1063. if err != nil {
  1064. br.Msg = "操作失败"
  1065. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  1066. return
  1067. }
  1068. }
  1069. br.Msg = "操作成功"
  1070. br.Ret = 200
  1071. br.Success = true
  1072. br.Data = resp
  1073. }
  1074. // @Title 研选文章列表接口
  1075. // @Description 获取研选文章列表接口
  1076. // @Param PageSize query int true "每页数据条数"
  1077. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1078. // @Param ArticleId query int true "文章id"
  1079. // @Param DepartmentId query int true "作者ID"
  1080. // @Param IndustrialManagementId query int true "产业ID"
  1081. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  1082. // @router /industry/reportList [get]
  1083. func (this *ReportController) ReportList() {
  1084. br := new(models.BaseResponse).Init()
  1085. defer func() {
  1086. this.Data["json"] = br
  1087. this.ServeJSON()
  1088. }()
  1089. user := this.User
  1090. if user == nil {
  1091. br.Msg = "请重新登录"
  1092. br.Ret = 408
  1093. return
  1094. }
  1095. uid := user.UserId
  1096. pageSize, _ := this.GetInt("PageSize")
  1097. currentIndex, _ := this.GetInt("CurrentIndex")
  1098. departmentId, _ := this.GetInt("DepartmentId")
  1099. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  1100. articleId, _ := this.GetInt("ArticleId")
  1101. var condition string
  1102. var startSize int
  1103. if pageSize <= 0 {
  1104. pageSize = utils.PageSize20
  1105. }
  1106. if currentIndex <= 0 {
  1107. currentIndex = 1
  1108. }
  1109. startSize = paging.StartIndex(currentIndex, pageSize)
  1110. var pars []interface{}
  1111. var total int
  1112. resp := new(models.ReportArticleWhichIndustrialRepList)
  1113. page := paging.GetPaging(currentIndex, pageSize, total)
  1114. userType, _, err := services.GetUserType(user.CompanyId)
  1115. if err != nil {
  1116. br.Msg = "获取信息失败"
  1117. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1118. return
  1119. }
  1120. if userType == 1 {
  1121. resp.Paging = page
  1122. br.Ret = 200
  1123. br.Success = true
  1124. br.Msg = "获取成功"
  1125. br.Data = resp
  1126. return
  1127. }
  1128. resp.HaveResearch = true
  1129. if departmentId > 0 {
  1130. condition += ` AND art.department_id = ` + strconv.Itoa(departmentId)
  1131. detail, err := models.GetArticleDepartmentDateilById(departmentId)
  1132. if err != nil {
  1133. br.Msg = "获取信息失败"
  1134. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1135. return
  1136. }
  1137. resp.NickName = detail.NickName
  1138. }
  1139. if industrialManagementId > 0 {
  1140. condition += ` AND m.industrial_management_id = ` + strconv.Itoa(industrialManagementId)
  1141. }
  1142. if articleId > 0 {
  1143. detail, err := models.GetArticleDetailById(articleId)
  1144. if err != nil {
  1145. br.Msg = "获取信息失败"
  1146. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1147. return
  1148. }
  1149. condition += ` AND art.subject_ids = '` + detail.SubjectIds + `'`
  1150. }
  1151. total, err = models.GetWhichDepartmentCount(condition)
  1152. if err != nil {
  1153. br.Msg = "获取信息失败"
  1154. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1155. return
  1156. }
  1157. page = paging.GetPaging(currentIndex, pageSize, total)
  1158. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  1159. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  1160. if err != nil {
  1161. br.Msg = "获取失败"
  1162. br.ErrMsg = "获取失败,Err:" + err.Error()
  1163. return
  1164. }
  1165. for k, v := range list {
  1166. if v.Readnum == 0 {
  1167. list[k].IsRed = true
  1168. }
  1169. list[k].IsResearch = true
  1170. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1171. if err != nil {
  1172. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1173. br.ErrMsg = "获取失败,Err:" + err.Error()
  1174. return
  1175. }
  1176. var subjectNamesNew string
  1177. if len(subjectNames) > 0 {
  1178. slice := strings.Split(subjectNames, "/")
  1179. for k3, v3 := range slice {
  1180. if k3 < 4 {
  1181. subjectNamesNew += v3 + "/"
  1182. }
  1183. }
  1184. }
  1185. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1186. if err != nil && err.Error() != utils.ErrNoRow() {
  1187. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1188. br.ErrMsg = "获取失败,Err:" + err.Error()
  1189. return
  1190. }
  1191. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1192. list[k].SubjectName = subjectNamesNew
  1193. if subjectNamesNew != "" {
  1194. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1195. } else {
  1196. list[k].IndustryName = industryName
  1197. }
  1198. resp.IndustryName = industryName
  1199. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  1200. }
  1201. resp.List = list
  1202. resp.Paging = page
  1203. br.Ret = 200
  1204. br.Success = true
  1205. br.Msg = "获取成功"
  1206. br.Data = resp
  1207. }
  1208. // @Title 研选最新主题关键词文章列表接口
  1209. // @Description 获取研选最新主题关键词文章列表接口
  1210. // @Param PageSize query int true "每页数据条数"
  1211. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1212. // @Param ArticleId query int true "文章id"
  1213. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  1214. // @router /industry/reportListNew [get]
  1215. func (this *ReportController) ReportListNew() {
  1216. br := new(models.BaseResponse).Init()
  1217. defer func() {
  1218. this.Data["json"] = br
  1219. this.ServeJSON()
  1220. }()
  1221. user := this.User
  1222. if user == nil {
  1223. br.Msg = "请重新登录"
  1224. br.Ret = 408
  1225. return
  1226. }
  1227. uid := user.UserId
  1228. pageSize, _ := this.GetInt("PageSize")
  1229. currentIndex, _ := this.GetInt("CurrentIndex")
  1230. articleId, _ := this.GetInt("ArticleId")
  1231. var condition string
  1232. var startSize int
  1233. if pageSize <= 0 {
  1234. pageSize = utils.PageSize20
  1235. }
  1236. if currentIndex <= 0 {
  1237. currentIndex = 1
  1238. }
  1239. startSize = paging.StartIndex(currentIndex, pageSize)
  1240. var pars []interface{}
  1241. var total int
  1242. resp := new(models.ReportArticleWhichIndustrialRepList)
  1243. page := paging.GetPaging(currentIndex, pageSize, total)
  1244. userType, _, err := services.GetUserType(user.CompanyId)
  1245. if err != nil {
  1246. br.Msg = "获取信息失败"
  1247. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1248. return
  1249. }
  1250. if userType == 1 {
  1251. resp.Paging = page
  1252. br.Ret = 200
  1253. br.Success = true
  1254. br.Msg = "获取成功"
  1255. br.Data = resp
  1256. return
  1257. }
  1258. resp.HaveResearch = true
  1259. if articleId > 0 {
  1260. detail, err := models.GetArticleDetailById(articleId)
  1261. if err != nil {
  1262. br.Msg = "获取信息失败"
  1263. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1264. return
  1265. }
  1266. firstStr := strings.Index(detail.IndustrialAndSubjectIds, "—")
  1267. if firstStr == 0 {
  1268. condition += ` AND art.industrial_management_id = '` + strconv.Itoa(detail.IndustrialManagementId) + `'`
  1269. } else {
  1270. condition += ` AND art.industrial_and_subject_ids = '` + detail.IndustrialAndSubjectIds + `'`
  1271. }
  1272. }
  1273. total, err = models.GetWhichDepartmentCount(condition)
  1274. if err != nil {
  1275. br.Msg = "获取信息失败"
  1276. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1277. return
  1278. }
  1279. page = paging.GetPaging(currentIndex, pageSize, total)
  1280. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  1281. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  1282. if err != nil {
  1283. br.Msg = "获取失败"
  1284. br.ErrMsg = "获取失败,Err:" + err.Error()
  1285. return
  1286. }
  1287. for k, v := range list {
  1288. if v.Readnum == 0 {
  1289. list[k].IsRed = true
  1290. }
  1291. list[k].IsResearch = true
  1292. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  1293. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1294. if err != nil {
  1295. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1296. br.ErrMsg = "获取失败,Err:" + err.Error()
  1297. return
  1298. }
  1299. var subjectNamesNew string
  1300. if len(subjectNames) > 0 {
  1301. slice := strings.Split(subjectNames, "/")
  1302. for k3, v3 := range slice {
  1303. if k3 < 4 {
  1304. subjectNamesNew += v3 + "/"
  1305. }
  1306. }
  1307. }
  1308. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1309. if err != nil && err.Error() != utils.ErrNoRow() {
  1310. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1311. br.ErrMsg = "获取失败,Err:" + err.Error()
  1312. return
  1313. }
  1314. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1315. list[k].SubjectName = subjectNamesNew
  1316. if subjectNamesNew != "" {
  1317. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1318. } else {
  1319. list[k].IndustryName = industryName
  1320. }
  1321. resp.IndustryName = industryName
  1322. }
  1323. resp.List = list
  1324. resp.Paging = page
  1325. br.Ret = 200
  1326. br.Success = true
  1327. br.Msg = "获取成功"
  1328. br.Data = resp
  1329. }
  1330. // @Title 是否展示绝密内参
  1331. // @Description 获取是否展示绝密内参接口
  1332. // @Param request body models.IsShow true "type json string"
  1333. // @Success 200
  1334. // @router /isShow [get]
  1335. func (this *ReportController) IsShow() {
  1336. br := new(models.BaseResponse).Init()
  1337. defer func() {
  1338. this.Data["json"] = br
  1339. this.ServeJSON()
  1340. }()
  1341. user := this.User
  1342. if user == nil {
  1343. br.Msg = "请重新登录"
  1344. br.Ret = 408
  1345. return
  1346. }
  1347. var resp models.IsShow
  1348. IsShowFreeButton, err := services.GetfreeButtonIsShow(user)
  1349. if err != nil {
  1350. br.Msg = "获取失败"
  1351. br.ErrMsg = "获取失败,GetfreeButtonIsShow Err:" + err.Error()
  1352. return
  1353. }
  1354. resp.IsShowChart = true
  1355. //resp.IsShowResearch = true
  1356. resp.LinkWxExplain = utils.LINK_WX_EXPLAIN
  1357. resp.ActivitySpecialExplain = utils.ACTIVITY_SPECIAL_EXPLAIN
  1358. //resp.YanXuan_Explain = true
  1359. resp.IsShowFreeButton = IsShowFreeButton
  1360. //mobile := user.Mobile
  1361. //if mobile == "" {
  1362. // br.Ret = 200
  1363. // br.Success = true
  1364. // br.Data = resp
  1365. // return
  1366. //}
  1367. //total, _ := models.GetUserIsAdminCount(mobile)
  1368. //if total > 0 {
  1369. // resp.IsShowList = true
  1370. //}
  1371. resp.IsShowList = true
  1372. resp.SearchTxtList.SummarySearch = "全局搜索"
  1373. resp.SearchTxtList.ReportSearch = "全局搜索"
  1374. resp.SearchTxtList.YanXuanSearch = "全局搜索"
  1375. resp.SearchTxtList.ActivitySearch = "全局搜索"
  1376. resp.SearchTxtList.TabSearch = "请输入关键词"
  1377. resp.IsShow = true
  1378. br.Ret = 200
  1379. br.Success = true
  1380. br.Data = resp
  1381. }
  1382. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1383. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1384. // @Param PageSize query int true "每页数据条数"
  1385. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1386. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1387. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1388. // @router /reportList/byType [get]
  1389. func (this *ReportController) ReportListByType() {
  1390. br := new(models.BaseResponse).Init()
  1391. defer func() {
  1392. this.Data["json"] = br
  1393. this.ServeJSON()
  1394. }()
  1395. user := this.User
  1396. if user == nil {
  1397. br.Msg = "请重新登录"
  1398. br.Ret = 408
  1399. return
  1400. }
  1401. uid := user.UserId
  1402. pageSize, _ := this.GetInt("PageSize")
  1403. currentIndex, _ := this.GetInt("CurrentIndex")
  1404. reportType := this.GetString("ReportType")
  1405. var condition string
  1406. var startSize int
  1407. if pageSize <= 0 {
  1408. pageSize = utils.PageSize20
  1409. }
  1410. if currentIndex <= 0 {
  1411. currentIndex = 1
  1412. }
  1413. startSize = paging.StartIndex(currentIndex, pageSize)
  1414. var pars []interface{}
  1415. var total int
  1416. resp := new(models.CygxReportSelectionListPublicRep)
  1417. page := paging.GetPaging(currentIndex, pageSize, total)
  1418. var tbdb string
  1419. var readSql string
  1420. var reportTypeStr string
  1421. if reportType == "1" {
  1422. tbdb = "cygx_report_selection"
  1423. reportTypeStr = "bgjx"
  1424. } else if reportType == "2" {
  1425. tbdb = "cygx_research_summary"
  1426. reportTypeStr = "bzyjhz"
  1427. } else if reportType == "3" {
  1428. tbdb = "cygx_minutes_summary"
  1429. reportTypeStr = "szjyhz"
  1430. } else {
  1431. br.Msg = "请选择报告类型"
  1432. return
  1433. }
  1434. fmt.Println(tbdb)
  1435. condition = ` AND publish_status = 1 `
  1436. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1437. if err != nil {
  1438. br.Msg = "获取信息失败"
  1439. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1440. return
  1441. }
  1442. //研究汇总--报告精选 只显示最新一期,往期都隐藏
  1443. if reportType == "1" {
  1444. startSize = 0
  1445. pageSize = 1
  1446. total = 1
  1447. }
  1448. 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`
  1449. page = paging.GetPaging(currentIndex, pageSize, total)
  1450. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1451. if err != nil {
  1452. br.Msg = "获取失败"
  1453. br.ErrMsg = "获取失败,Err:" + err.Error()
  1454. return
  1455. }
  1456. for k, v := range list {
  1457. if reportType == "1" {
  1458. list[k].Abstract = v.UpdateDescription
  1459. }
  1460. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1461. if v.ReadNum == 0 {
  1462. list[k].IsRed = true
  1463. }
  1464. }
  1465. resp.List = list
  1466. resp.Paging = page
  1467. br.Ret = 200
  1468. br.Success = true
  1469. br.Msg = "获取成功"
  1470. br.Data = resp
  1471. }
  1472. // @Title 获取报告精选详情
  1473. // @Description 获取报告精选详情接口
  1474. // @Param ArticleId query int true "报告ID"
  1475. // @Param IsBestNew query bool false "是否获取最新的一篇报告"
  1476. // @Success 200 {object} models.ReportSelectionLetailResp
  1477. // @router /reportSelection/detail [get]
  1478. func (this *ReportController) Detail() {
  1479. br := new(models.BaseResponse).Init()
  1480. defer func() {
  1481. this.Data["json"] = br
  1482. this.ServeJSON()
  1483. }()
  1484. user := this.User
  1485. if user == nil {
  1486. br.Msg = "请重新登录"
  1487. br.Ret = 408
  1488. return
  1489. }
  1490. uid := user.UserId
  1491. articleId, _ := this.GetInt("ArticleId")
  1492. isBestNew, _ := this.GetBool("IsBestNew")
  1493. if isBestNew {
  1494. tbdb := "cygx_report_selection"
  1495. reportTypeStr := "bgjx"
  1496. condition := ` AND publish_status = 1 `
  1497. var pars []interface{}
  1498. 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`
  1499. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, 0, 1)
  1500. if err != nil {
  1501. br.Msg = "获取失败"
  1502. br.ErrMsg = "获取失败,Err:" + err.Error()
  1503. return
  1504. }
  1505. for _, v := range list {
  1506. articleId = v.ArticleId
  1507. }
  1508. }
  1509. if articleId < 0 {
  1510. br.Msg = "参数错误"
  1511. br.ErrMsg = "参数错误"
  1512. return
  1513. }
  1514. resp := new(models.ReportSelectionLetailResp)
  1515. //判断用户权限
  1516. hasPermission, err := services.GetUserhasPermission(user)
  1517. if err != nil {
  1518. br.Msg = "获取信息失败"
  1519. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1520. }
  1521. resp.HasPermission = hasPermission
  1522. if hasPermission != 1 {
  1523. br.Ret = 200
  1524. br.Success = true
  1525. br.Msg = "获取成功"
  1526. br.Data = resp
  1527. return
  1528. }
  1529. detail, err := models.GetCygxReportSelectionInfoById(articleId)
  1530. if err != nil {
  1531. br.Msg = "获取信息失败"
  1532. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1533. return
  1534. }
  1535. //较上一期有观点变化(后台填写的核心逻辑汇总内容、标签内容有更新),或者新增的公司,显示new标签
  1536. var isAllNew bool // 判断是否都打新的标签
  1537. lastPeriods := detail.Periods - 1
  1538. mapBodyChartSummary := make(map[int]string)
  1539. mapLabel := make(map[int]string)
  1540. if lastPeriods > 0 {
  1541. detailLast, err := models.GetCygxReportSelectionInfoById(articleId)
  1542. if err != nil {
  1543. br.Msg = "获取信息失败"
  1544. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1545. return
  1546. }
  1547. articleIdLast := detailLast.ArticleId
  1548. listLogLast, err := models.GetReportSelectionlogListAll(articleIdLast)
  1549. if err != nil {
  1550. br.Msg = "获取失败"
  1551. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1552. return
  1553. }
  1554. for _, v := range listLogLast {
  1555. mapBodyChartSummary[v.IndustrialSubjectId] = v.Body
  1556. mapLabel[v.IndustrialSubjectId] = v.Label
  1557. }
  1558. } else {
  1559. isAllNew = true
  1560. }
  1561. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1562. existMap := make(map[int]int)
  1563. var items []*models.ReportSelectionChartPermission
  1564. var itemsSubject []*models.ReportSelectionChartLogPermission
  1565. listLog, err := models.GetReportSelectionlogListAll(articleId)
  1566. if err != nil {
  1567. br.Msg = "获取失败"
  1568. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1569. return
  1570. }
  1571. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1572. //获取行业核心逻辑汇总
  1573. listChartLog, err := models.GetCygxReportSelectionChartLogRepList(articleId)
  1574. if err != nil {
  1575. br.Msg = "获取失败"
  1576. br.ErrMsg = "获取失败,Err:" + err.Error()
  1577. return
  1578. }
  1579. mapChartLog := make(map[string]string)
  1580. for _, v := range listChartLog {
  1581. mapChartLog[v.ChartPermissionName] = v.BodyChartSummary
  1582. }
  1583. for _, v := range listLog {
  1584. item := new(models.ReportSelectionChartPermission)
  1585. itemSubject := new(models.ReportSelectionChartLogPermission)
  1586. itemSubject.PermissionName = v.PermissionName
  1587. if existMap[v.ChartPermissionId] == 0 {
  1588. //item.PermissionName = v.PermissionName + "领域深度报告和调研"
  1589. item.PermissionName = v.PermissionName
  1590. item.IcoLink = v.IcoLink
  1591. listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
  1592. if err != nil && err.Error() != utils.ErrNoRow() {
  1593. br.Msg = "获取信息失败"
  1594. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1595. return
  1596. }
  1597. for k2, v2 := range listSonLog {
  1598. var isNew bool
  1599. if isAllNew {
  1600. isNew = true
  1601. } else {
  1602. if mapBodyChartSummary[v2.IndustrialSubjectId] != v2.Body || mapLabel[v2.IndustrialSubjectId] != v2.Label {
  1603. isNew = true
  1604. }
  1605. }
  1606. if v2.IndustrialManagementId != "" {
  1607. listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
  1608. if err != nil && err.Error() != utils.ErrNoRow() {
  1609. br.Msg = "获取信息失败"
  1610. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1611. return
  1612. }
  1613. v2.IsNew = isNew
  1614. listSonLog[k2].List = listIndustrial
  1615. if v2.Label != "" {
  1616. v2.CompanyLabel = strings.Split(v2.Label, "{|}")
  1617. }
  1618. }
  1619. itemSubject.ListSubject = append(itemSubject.ListSubject, &models.ReportSelectionChartLogSubjectName{SubjectName: v2.SubjectName, IsNew: isNew, IndustrialSubjectId: v2.IndustrialSubjectId})
  1620. }
  1621. item.BodyChartSummary = mapChartLog[v.PermissionName]
  1622. item.List = listSonLog
  1623. items = append(items, item)
  1624. itemsSubject = append(itemsSubject, itemSubject)
  1625. //itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)
  1626. }
  1627. existMap[v.ChartPermissionId] = v.ChartPermissionId
  1628. }
  1629. historyRecord := new(models.CygxReportHistoryRecord)
  1630. historyRecord.UserId = uid
  1631. historyRecord.ArticleId = articleId
  1632. historyRecord.CreateTime = time.Now()
  1633. historyRecord.Mobile = user.Mobile
  1634. historyRecord.Email = user.Email
  1635. historyRecord.CompanyId = user.CompanyId
  1636. historyRecord.CompanyName = user.CompanyName
  1637. historyRecord.ReportType = "bgjx"
  1638. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1639. if err != nil && err.Error() != utils.ErrNoRow() {
  1640. br.Msg = "获取信息失败"
  1641. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1642. return
  1643. }
  1644. historyRecord.RealName = user.RealName
  1645. if sellerItem != nil {
  1646. historyRecord.SellerName = sellerItem.RealName
  1647. }
  1648. go models.AddCygxReportHistoryRecord(historyRecord)
  1649. resp.List = items
  1650. resp.ListPermissionSubject = itemsSubject
  1651. resp.Detail = detail
  1652. br.Ret = 200
  1653. br.Success = true
  1654. br.Msg = "获取成功"
  1655. br.Data = resp
  1656. }
  1657. // @Title 获取本周研究汇总详情
  1658. // @Description 获取本周研究汇总详情接口
  1659. // @Param ArticleId query int true "报告ID"
  1660. // @Success 200 {object} models.ResearchSummaryLetailResp
  1661. // @router /researchSummary/detail [get]
  1662. func (this *ReportController) ResearchDetail() {
  1663. br := new(models.BaseResponse).Init()
  1664. defer func() {
  1665. this.Data["json"] = br
  1666. this.ServeJSON()
  1667. }()
  1668. user := this.User
  1669. if user == nil {
  1670. br.Msg = "请重新登录"
  1671. br.Ret = 408
  1672. return
  1673. }
  1674. uid := user.UserId
  1675. articleId, _ := this.GetInt("ArticleId")
  1676. if articleId < 0 {
  1677. br.Msg = "参数错误"
  1678. br.ErrMsg = "参数错误"
  1679. return
  1680. }
  1681. resp := new(models.ResearchSummaryLetailResp)
  1682. //判断用户权限
  1683. hasPermission, err := services.GetUserhasPermission(user)
  1684. if err != nil {
  1685. br.Msg = "获取信息失败"
  1686. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1687. }
  1688. resp.HasPermission = hasPermission
  1689. if hasPermission != 1 {
  1690. br.Ret = 200
  1691. br.Success = true
  1692. br.Msg = "获取成功"
  1693. br.Data = resp
  1694. return
  1695. }
  1696. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1697. if err != nil {
  1698. br.Msg = "获取信息失败"
  1699. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1700. return
  1701. }
  1702. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1703. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1704. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1705. if err != nil {
  1706. br.Msg = "获取失败"
  1707. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1708. return
  1709. }
  1710. listArticleType, err := models.GetCygxArticleTypeList()
  1711. if err != nil {
  1712. br.Msg = "获取失败"
  1713. br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
  1714. return
  1715. }
  1716. for k, v := range listFirst {
  1717. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1718. if err != nil && err.Error() != utils.ErrNoRow() {
  1719. br.Msg = "获取信息失败"
  1720. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1721. return
  1722. }
  1723. for k2, v2 := range listSecond {
  1724. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1725. if err != nil && err.Error() != utils.ErrNoRow() {
  1726. br.Msg = "获取信息失败"
  1727. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1728. return
  1729. }
  1730. for _, vType := range listArticleType {
  1731. if v2.ChartPermissionId == vType.YanxPermissionId {
  1732. listSecond[k2].IcoLink = vType.IcoLinkM
  1733. listSecond[k2].PermissionName = vType.YanxPermissionName
  1734. }
  1735. }
  1736. //if v2.ChartPermissionId == utils.YanxSummaryPermissionId {
  1737. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1738. // listSecond[k2].PermissionName = "买方研选纪要"
  1739. //} else if v2.ChartPermissionId == utils.YanxViewpointPermissionId {
  1740. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1741. // listSecond[k2].PermissionName = "买方研选观点"
  1742. //}
  1743. if len(listThird) > 0 {
  1744. for k3, v3 := range listThird {
  1745. if v3.VideoUrl != "" {
  1746. listThird[k3].IsHaveVideo = true
  1747. }
  1748. if v3.ReportLink == "0" {
  1749. listThird[k3].ReportLink = ""
  1750. }
  1751. }
  1752. listSecond[k2].List = listThird
  1753. }
  1754. }
  1755. if len(listSecond) > 0 {
  1756. listFirst[k].List = listSecond
  1757. }
  1758. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1759. if v.Type == "SDBG" {
  1760. listFirst[k].ListName = "深度报告"
  1761. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1762. } else if v.Type == "BZCHJH" {
  1763. listFirst[k].ListName = "本周晨会精华"
  1764. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1765. } else if v.Type == "CYDYJY" {
  1766. listFirst[k].ListName = "产业调研纪要"
  1767. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1768. } else if v.Type == "SSGS" {
  1769. listFirst[k].ListName = "上市公司调研纪要篇"
  1770. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1771. } else if v.Type == "SJDP" {
  1772. listFirst[k].ListName = "事件点评"
  1773. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1774. } else if v.Type == "YANX" {
  1775. listFirst[k].ListName = "买方研选"
  1776. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1777. }
  1778. }
  1779. historyRecord := new(models.CygxReportHistoryRecord)
  1780. historyRecord.UserId = uid
  1781. historyRecord.ArticleId = articleId
  1782. historyRecord.CreateTime = time.Now()
  1783. historyRecord.Mobile = user.Mobile
  1784. historyRecord.Email = user.Email
  1785. historyRecord.CompanyId = user.CompanyId
  1786. historyRecord.CompanyName = user.CompanyName
  1787. historyRecord.ReportType = "bzyjhz"
  1788. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1789. if err != nil && err.Error() != utils.ErrNoRow() {
  1790. br.Msg = "获取信息失败"
  1791. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1792. return
  1793. }
  1794. historyRecord.RealName = user.RealName
  1795. if sellerItem != nil {
  1796. historyRecord.SellerName = sellerItem.RealName
  1797. }
  1798. go models.AddCygxReportHistoryRecord(historyRecord)
  1799. resp.List = listFirst
  1800. resp.Detail = detail
  1801. br.Ret = 200
  1802. br.Success = true
  1803. br.Msg = "获取成功"
  1804. br.Data = resp
  1805. }
  1806. // @Title 上周纪要汇总内容详情
  1807. // @Description 获取上周纪要汇总内容详情接口
  1808. // @Param ArticleId query int true "报告ID"
  1809. // @Success 200 {object} models.MinutesSummaryLetailResp
  1810. // @router /minutesSummary/detailv4 [get]
  1811. func (this *ReportController) MinutesDetailV4() {
  1812. br := new(models.BaseResponse).Init()
  1813. defer func() {
  1814. this.Data["json"] = br
  1815. this.ServeJSON()
  1816. }()
  1817. user := this.User
  1818. if user == nil {
  1819. br.Msg = "请重新登录"
  1820. br.Ret = 408
  1821. return
  1822. }
  1823. uid := user.UserId
  1824. articleId, _ := this.GetInt("ArticleId")
  1825. if articleId < 0 {
  1826. br.Msg = "参数错误"
  1827. br.ErrMsg = "参数错误"
  1828. return
  1829. }
  1830. resp := new(models.MinutesSummaryLetailRespV4)
  1831. //判断用户权限
  1832. hasPermission, err := services.GetUserhasPermission(user)
  1833. if err != nil {
  1834. br.Msg = "获取信息失败"
  1835. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1836. }
  1837. resp.HasPermission = hasPermission
  1838. if hasPermission != 1 {
  1839. br.Ret = 200
  1840. br.Success = true
  1841. br.Msg = "获取成功"
  1842. br.Data = resp
  1843. return
  1844. }
  1845. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1846. if err != nil {
  1847. br.Msg = "获取信息失败"
  1848. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1849. return
  1850. }
  1851. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1852. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1853. listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
  1854. if err != nil {
  1855. br.Msg = "获取失败"
  1856. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1857. return
  1858. }
  1859. for k, v := range listFirst {
  1860. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  1861. if err != nil && err.Error() != utils.ErrNoRow() {
  1862. br.Msg = "获取信息失败"
  1863. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1864. return
  1865. }
  1866. for k2, v2 := range listSecond {
  1867. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  1868. if err != nil && err.Error() != utils.ErrNoRow() {
  1869. br.Msg = "获取信息失败"
  1870. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1871. return
  1872. }
  1873. if len(listThird) > 0 {
  1874. for k3, v3 := range listThird {
  1875. if v3.VideoUrl != "" {
  1876. listThird[k3].IsHaveVideo = true
  1877. }
  1878. if v3.ReportLink == "0" {
  1879. listThird[k3].ReportLink = ""
  1880. }
  1881. }
  1882. listSecond[k2].List = listThird
  1883. }
  1884. }
  1885. if len(listSecond) > 0 {
  1886. listFirst[k].List = listSecond
  1887. }
  1888. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1889. if v.Type == "CYDYJY" {
  1890. listFirst[k].ListName = "产业调研纪要"
  1891. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1892. } else if v.Type == "SSGS" {
  1893. listFirst[k].ListName = "上市公司调研纪要篇"
  1894. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1895. } else if v.Type == "YANX" {
  1896. listFirst[k].ListName = "买方研选纪要"
  1897. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1898. }
  1899. }
  1900. historyRecord := new(models.CygxReportHistoryRecord)
  1901. historyRecord.UserId = uid
  1902. historyRecord.ArticleId = articleId
  1903. historyRecord.CreateTime = time.Now()
  1904. historyRecord.Mobile = user.Mobile
  1905. historyRecord.Email = user.Email
  1906. historyRecord.CompanyId = user.CompanyId
  1907. historyRecord.CompanyName = user.CompanyName
  1908. historyRecord.ReportType = "szjyhz"
  1909. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1910. if err != nil && err.Error() != utils.ErrNoRow() {
  1911. br.Msg = "获取信息失败"
  1912. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1913. return
  1914. }
  1915. historyRecord.RealName = user.RealName
  1916. if sellerItem != nil {
  1917. historyRecord.SellerName = sellerItem.RealName
  1918. }
  1919. go models.AddCygxReportHistoryRecord(historyRecord)
  1920. resp.List = listFirst
  1921. resp.Detail = detail
  1922. br.Ret = 200
  1923. br.Success = true
  1924. br.Msg = "获取成功"
  1925. br.Data = resp
  1926. }
  1927. // @Title 上周纪要汇总内容详情
  1928. // @Description 获取上周纪要汇总内容详情接口
  1929. // @Param ArticleId query int true "报告ID"
  1930. // @Success 200 {object} models.MinutesSummaryLetailResp
  1931. // @router /minutesSummary/detail [get]
  1932. func (this *ReportController) MinutesDetail() {
  1933. br := new(models.BaseResponse).Init()
  1934. defer func() {
  1935. this.Data["json"] = br
  1936. this.ServeJSON()
  1937. }()
  1938. user := this.User
  1939. if user == nil {
  1940. br.Msg = "请重新登录"
  1941. br.Ret = 408
  1942. return
  1943. }
  1944. uid := user.UserId
  1945. articleId, _ := this.GetInt("ArticleId")
  1946. if articleId < 0 {
  1947. br.Msg = "参数错误"
  1948. br.ErrMsg = "参数错误"
  1949. return
  1950. }
  1951. resp := new(models.MinutesSummaryLetailResp)
  1952. //判断用户权限
  1953. hasPermission, err := services.GetUserhasPermission(user)
  1954. if err != nil {
  1955. br.Msg = "获取信息失败"
  1956. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1957. }
  1958. resp.HasPermission = hasPermission
  1959. if hasPermission != 1 {
  1960. br.Ret = 200
  1961. br.Success = true
  1962. br.Msg = "获取成功"
  1963. br.Data = resp
  1964. return
  1965. }
  1966. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1967. if err != nil {
  1968. br.Msg = "获取信息失败"
  1969. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1970. return
  1971. }
  1972. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1973. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1974. listLog, err := models.GetMinutesSummarylogListAll(articleId)
  1975. if err != nil {
  1976. br.Msg = "获取失败"
  1977. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1978. return
  1979. }
  1980. for k, v := range listLog {
  1981. listSonLog, err := models.GetMinutesSummarylogSonListAll(articleId, v.ChartPermissionId)
  1982. if err != nil && err.Error() != utils.ErrNoRow() {
  1983. br.Msg = "获取信息失败"
  1984. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1985. return
  1986. }
  1987. if len(listSonLog) > 0 {
  1988. listLog[k].List = listSonLog
  1989. for k2, v2 := range listSonLog {
  1990. if v2.ReportLink == "0" {
  1991. listSonLog[k2].ReportLink = ""
  1992. }
  1993. }
  1994. }
  1995. }
  1996. historyRecord := new(models.CygxReportHistoryRecord)
  1997. historyRecord.UserId = uid
  1998. historyRecord.ArticleId = articleId
  1999. historyRecord.CreateTime = time.Now()
  2000. historyRecord.Mobile = user.Mobile
  2001. historyRecord.Email = user.Email
  2002. historyRecord.CompanyId = user.CompanyId
  2003. historyRecord.CompanyName = user.CompanyName
  2004. historyRecord.ReportType = "szjyhz"
  2005. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  2006. if err != nil && err.Error() != utils.ErrNoRow() {
  2007. br.Msg = "获取信息失败"
  2008. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  2009. return
  2010. }
  2011. historyRecord.RealName = user.RealName
  2012. if sellerItem != nil {
  2013. historyRecord.SellerName = sellerItem.RealName
  2014. }
  2015. go models.AddCygxReportHistoryRecord(historyRecord)
  2016. resp.List = listLog
  2017. resp.Detail = detail
  2018. br.Ret = 200
  2019. br.Success = true
  2020. br.Msg = "获取成功"
  2021. br.Data = resp
  2022. }
  2023. // @Title 获取路演精华详情
  2024. // @Description 获取路演精华详情接口
  2025. // @Param ArticleId query int true "报告ID"
  2026. // @Success 200 {object} models.RoadshowDetailResp
  2027. // @router /roadshowEssence/detail [get]
  2028. func (this *ReportController) RoadshowDetail() {
  2029. br := new(models.BaseResponse).Init()
  2030. defer func() {
  2031. this.Data["json"] = br
  2032. this.ServeJSON()
  2033. }()
  2034. user := this.User
  2035. if user == nil {
  2036. br.Msg = "请登录"
  2037. br.ErrMsg = "请登录,用户信息为空"
  2038. br.Ret = 408
  2039. return
  2040. }
  2041. uid := user.UserId
  2042. articleId, err := this.GetInt("ArticleId")
  2043. if articleId <= 0 {
  2044. br.Msg = "文章不存在"
  2045. br.ErrMsg = "文章不存在,文章ID错误"
  2046. return
  2047. }
  2048. detail := new(models.ReportDetailRoadshow)
  2049. hasPermission := 0
  2050. hasFree := 0
  2051. //判断是否已经申请过
  2052. applyCount, err := models.GetApplyRecordCount(uid)
  2053. if err != nil && err.Error() != utils.ErrNoRow() {
  2054. br.Msg = "获取信息失败"
  2055. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2056. return
  2057. }
  2058. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  2059. if user.CompanyId > 1 {
  2060. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  2061. if err != nil {
  2062. br.Msg = "获取信息失败"
  2063. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  2064. return
  2065. }
  2066. detail, err = models.GetReportRoadshowDetailById(articleId)
  2067. if err != nil {
  2068. br.Msg = "获取信息失败"
  2069. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2070. return
  2071. }
  2072. detail.Body = html.UnescapeString(detail.Body)
  2073. detail.Abstract, _ = services.GetReportContentTextSubNew(detail.Abstract)
  2074. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  2075. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  2076. if detail.ReportLink == "0" {
  2077. detail.ReportLink = ""
  2078. }
  2079. if companyPermission == "" {
  2080. if applyCount > 0 {
  2081. hasPermission = 5
  2082. } else {
  2083. hasPermission = 2
  2084. }
  2085. hasFree = 2
  2086. goto Loop
  2087. } else {
  2088. hasFree = 1
  2089. var articlePermissionPermissionName string
  2090. articlePermissionPermissionName = detail.CategoryName
  2091. var hasPersion bool
  2092. slice := strings.Split(articlePermissionPermissionName, ",")
  2093. for _, v := range slice {
  2094. if strings.Contains(companyPermission, v) {
  2095. hasPersion = true
  2096. }
  2097. }
  2098. if hasPersion {
  2099. hasPermission = 1
  2100. historyRecord := new(models.CygxArticleHistoryRecord)
  2101. historyRecord.UserId = uid
  2102. historyRecord.ArticleId = articleId
  2103. historyRecord.CreateTime = time.Now()
  2104. historyRecord.Mobile = user.Mobile
  2105. historyRecord.Email = user.Email
  2106. historyRecord.CompanyId = user.CompanyId
  2107. historyRecord.CompanyName = user.CompanyName
  2108. go models.AddCygxArticleHistoryRecord(historyRecord)
  2109. } else { //无该行业权限
  2110. hasPermission = 3
  2111. }
  2112. if hasPermission == 1 {
  2113. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  2114. if !utils.Rc.IsExist(key) {
  2115. //新增浏览记录
  2116. record := new(models.CygxArticleViewRecord)
  2117. record.UserId = uid
  2118. record.ArticleId = articleId
  2119. record.CreateTime = time.Now()
  2120. record.Mobile = user.Mobile
  2121. record.Email = user.Email
  2122. record.CompanyId = user.CompanyId
  2123. record.CompanyName = user.CompanyName
  2124. go models.AddCygxArticleViewRecord(record)
  2125. utils.Rc.Put(key, 1, 5*time.Second)
  2126. models.ModifyReportLastViewTime(uid)
  2127. }
  2128. }
  2129. }
  2130. } else { //潜在客户
  2131. if applyCount > 0 {
  2132. hasPermission = 5
  2133. } else {
  2134. hasPermission = 4
  2135. }
  2136. }
  2137. Loop:
  2138. if hasPermission != 1 {
  2139. detail.Body = ""
  2140. detail.Abstract = ""
  2141. }
  2142. resp := new(models.RoadshowDetailResp)
  2143. resp.HasPermission = hasPermission
  2144. resp.HasFree = hasFree
  2145. resp.Detail = detail
  2146. br.Ret = 200
  2147. br.Success = true
  2148. br.Msg = "获取成功"
  2149. br.Data = resp
  2150. }
  2151. // @Title 产业文章列表接口
  2152. // @Description 获取产业文章列表接口
  2153. // @Param KeyWord query string true "搜索关键词"
  2154. // @Success 200 {object} models.CygxIndustrySearchList
  2155. // @router /industryAndArticle/list [get]
  2156. func (this *ReportController) IndustryAndArticleList() {
  2157. br := new(models.BaseResponse).Init()
  2158. defer func() {
  2159. this.Data["json"] = br
  2160. this.ServeJSON()
  2161. }()
  2162. user := this.User
  2163. if user == nil {
  2164. br.Msg = "请重新登录"
  2165. br.Ret = 408
  2166. return
  2167. }
  2168. uid := user.UserId
  2169. keyWord := this.GetString("KeyWord")
  2170. orderSrt := "update_time DESC"
  2171. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  2172. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  2173. if err != nil {
  2174. br.Msg = "获取信息失败"
  2175. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2176. return
  2177. }
  2178. for k, v := range list {
  2179. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  2180. if err != nil {
  2181. br.Msg = "获取信息失败"
  2182. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2183. return
  2184. }
  2185. list[k].IndustrialSubjectList = industrialSubjectList
  2186. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  2187. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  2188. if err != nil {
  2189. br.Msg = "获取信息失败"
  2190. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2191. return
  2192. }
  2193. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  2194. }
  2195. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  2196. if err != nil {
  2197. br.Msg = "获取失败"
  2198. br.ErrMsg = "获取失败,Err:" + err.Error()
  2199. return
  2200. }
  2201. for k2, v2 := range artList {
  2202. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  2203. if err != nil {
  2204. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  2205. br.ErrMsg = "获取失败,Err:" + err.Error()
  2206. return
  2207. }
  2208. var subjectNamesNew string
  2209. if len(subjectNames) > 0 {
  2210. slice := strings.Split(subjectNames, "/")
  2211. for k3, v3 := range slice {
  2212. if k3 < 4 {
  2213. subjectNamesNew += v3 + "/"
  2214. }
  2215. }
  2216. }
  2217. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  2218. if err != nil && err.Error() != utils.ErrNoRow() {
  2219. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  2220. br.ErrMsg = "获取失败,Err:" + err.Error()
  2221. return
  2222. }
  2223. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  2224. artList[k2].SubjectName = subjectNamesNew
  2225. if subjectNamesNew == "" {
  2226. artList[k2].IndustryName = industryName
  2227. } else {
  2228. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  2229. }
  2230. }
  2231. if keyWord != "" {
  2232. keyWordItem := new(models.CygxUserSearchKeyWord)
  2233. keyWordItem.UserId = user.UserId
  2234. keyWordItem.KeyWord = keyWord
  2235. keyWordItem.PageType = "ReortSearch"
  2236. keyWordItem.CreateTime = time.Now()
  2237. go models.AddUserSearchKeyWord(keyWordItem)
  2238. }
  2239. resp := new(models.CygxIndustrySearchList)
  2240. resp.ArtList = artList
  2241. resp.IndList = list
  2242. br.Ret = 200
  2243. br.Success = true
  2244. br.Msg = "获取成功"
  2245. br.Data = resp
  2246. }
  2247. // @Title 产业报告分类关联作者列表接口Pc端
  2248. // @Description 获取产业报告分类关联作者列表接口Pc端
  2249. // @Param ChartPermissionId query int true "分类ID"
  2250. // @Param KeyWord query string true "搜索关键词"
  2251. // @Param PageSize query int true "每页数据条数"
  2252. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2253. // @Success 200 {object} models.CygxArticleDepartmentListPc
  2254. // @router /industryListByDepartmentPc [get]
  2255. func (this *ReportController) IndustryListByDepartmentPc() {
  2256. br := new(models.BaseResponse).Init()
  2257. defer func() {
  2258. this.Data["json"] = br
  2259. this.ServeJSON()
  2260. }()
  2261. user := this.User
  2262. if user == nil {
  2263. br.Msg = "请重新登录"
  2264. br.Ret = 408
  2265. return
  2266. }
  2267. uid := user.UserId
  2268. pageSize, _ := this.GetInt("PageSize")
  2269. currentIndex, _ := this.GetInt("CurrentIndex")
  2270. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  2271. keyWord := this.GetString("KeyWord")
  2272. var startSize int
  2273. var condition string
  2274. condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  2275. if pageSize <= 0 {
  2276. pageSize = utils.PageSize20
  2277. }
  2278. if currentIndex <= 0 {
  2279. currentIndex = 1
  2280. }
  2281. var articleIdGroup string
  2282. if keyWord != "" {
  2283. //获取标的关联的文章ID
  2284. articleIdSub, err := models.GetArticleIdSubjectGroup(keyWord)
  2285. if err != nil {
  2286. br.Msg = "获取信息失败"
  2287. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2288. return
  2289. }
  2290. //获取产业关联的标的
  2291. articleIdInd, err := models.GetArticleIndustrialIdGroup(keyWord)
  2292. if err != nil {
  2293. br.Msg = "获取信息失败"
  2294. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  2295. return
  2296. }
  2297. if articleIdSub != "" && articleIdInd != "" {
  2298. articleIdGroup = articleIdSub + "," + articleIdInd
  2299. } else if articleIdSub != "" && articleIdInd == "" {
  2300. articleIdGroup = articleIdSub
  2301. } else if articleIdSub == "" && articleIdInd != "" {
  2302. articleIdGroup = articleIdInd
  2303. }
  2304. slice := strings.Split(keyWord, "/")
  2305. if len(slice) > 1 {
  2306. var subjectIds string
  2307. for _, v := range slice {
  2308. subjectId, err := models.GetcygxIndustrialSubjectByName(v)
  2309. if err != nil && err.Error() != utils.ErrNoRow() {
  2310. br.Msg = "获取信息失败"
  2311. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  2312. return
  2313. }
  2314. if subjectId != "" {
  2315. subjectIds += subjectId + ","
  2316. }
  2317. }
  2318. subjectIds = strings.TrimRight(subjectIds, ",")
  2319. if len(subjectIds) > 0 {
  2320. articleBySub, err := models.GetArticleIdsBySubId(subjectIds)
  2321. if err != nil {
  2322. br.Msg = "获取信息失败"
  2323. br.ErrMsg = "获取文章关联的标的失败,Err:" + err.Error()
  2324. return
  2325. }
  2326. if articleIdGroup != "" {
  2327. if articleBySub != "" {
  2328. articleIdGroup += "," + articleBySub
  2329. }
  2330. } else {
  2331. articleIdGroup = articleBySub
  2332. }
  2333. }
  2334. }
  2335. }
  2336. if articleIdGroup != "" {
  2337. condition += ` AND a.article_id IN (` + articleIdGroup + `)`
  2338. }
  2339. startSize = paging.StartIndex(currentIndex, pageSize)
  2340. total, err := models.GetArticleDepartmentCount(condition)
  2341. page := paging.GetPaging(currentIndex, pageSize, total)
  2342. resp := new(models.CygxArticleDepartmentListPc)
  2343. userType, _, err := services.GetUserType(user.CompanyId)
  2344. if err != nil {
  2345. br.Msg = "获取信息失败"
  2346. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  2347. return
  2348. }
  2349. if userType == 1 {
  2350. resp.Paging = page
  2351. br.Ret = 200
  2352. br.Success = true
  2353. br.Msg = "获取成功"
  2354. br.Data = resp
  2355. return
  2356. }
  2357. resp.HaveResearch = true
  2358. //获取作者信息,并排序
  2359. list, err := models.GetCygxArticleDepartmentListPc(startSize, pageSize, condition, uid)
  2360. if err != nil {
  2361. br.Msg = "获取信息失败"
  2362. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2363. return
  2364. }
  2365. for k, v := range list {
  2366. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIdGroup)
  2367. if err != nil {
  2368. br.Msg = "获取信息失败"
  2369. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2370. return
  2371. }
  2372. for k2, v2 := range artList {
  2373. if artList[k2].IsReport == "1" {
  2374. artList[k2].Title = v2.Title
  2375. } else {
  2376. artList[k2].Title = v2.Title
  2377. }
  2378. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2379. }
  2380. list[k].List = artList
  2381. if v.FollowNum > 0 {
  2382. list[k].IsMyFollow = true
  2383. }
  2384. }
  2385. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  2386. if err != nil {
  2387. br.Msg = "获取信息失败"
  2388. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2389. return
  2390. }
  2391. if len(listnNew) > 0 {
  2392. for _, v := range listnNew {
  2393. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  2394. Management := new(models.IndustrialManagementIdInt)
  2395. if firstStr == 0 {
  2396. Management.IndustryName = v.IndustryName
  2397. } else {
  2398. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  2399. if err != nil {
  2400. br.Msg = "获取信息失败"
  2401. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  2402. return
  2403. }
  2404. var subjectNamesNew string
  2405. for _, v1 := range listSub {
  2406. subjectNamesNew += v1.SubjectName + "/"
  2407. }
  2408. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  2409. Management.IndustryName = subjectNamesNew
  2410. }
  2411. Management.IndustrialManagementId = v.IndustrialManagementId
  2412. Management.ArticleId = v.ArticleId
  2413. resp.ListnNew = append(resp.ListnNew, Management)
  2414. }
  2415. }
  2416. resp.List = list
  2417. resp.Paging = page
  2418. br.Ret = 200
  2419. br.Success = true
  2420. br.Msg = "获取成功"
  2421. br.Data = resp
  2422. }
  2423. // @Title 产业文章列表接口Pc端
  2424. // @Description 获取产业文章列表接口Pc端
  2425. // @Param KeyWord query string true "搜索关键词"
  2426. // @Success 200 {object} models.CygxIndustrySearchListPc
  2427. // @router /industryAndArticle/listPc [get]
  2428. func (this *ReportController) IndustryAndArticleListPc() {
  2429. br := new(models.BaseResponse).Init()
  2430. defer func() {
  2431. this.Data["json"] = br
  2432. this.ServeJSON()
  2433. }()
  2434. user := this.User
  2435. if user == nil {
  2436. br.Msg = "请重新登录"
  2437. br.Ret = 408
  2438. return
  2439. }
  2440. uid := user.UserId
  2441. keyWord := this.GetString("KeyWord")
  2442. resp := new(models.CygxIndustrySearchListPc)
  2443. orderSrt := "update_time DESC"
  2444. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  2445. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  2446. if err != nil {
  2447. br.Msg = "获取信息失败"
  2448. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2449. return
  2450. }
  2451. for k, v := range list {
  2452. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  2453. if err != nil {
  2454. br.Msg = "获取信息失败"
  2455. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2456. return
  2457. }
  2458. list[k].IndustrialSubjectList = industrialSubjectList
  2459. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  2460. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  2461. if err != nil {
  2462. br.Msg = "获取信息失败"
  2463. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2464. return
  2465. }
  2466. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  2467. }
  2468. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  2469. if err != nil {
  2470. br.Msg = "获取失败"
  2471. br.ErrMsg = "获取失败,Err:" + err.Error()
  2472. return
  2473. }
  2474. if len(artList) > 0 {
  2475. var articleIds string
  2476. for _, v := range artList {
  2477. articleIds += strconv.Itoa(v.ArticleId) + ","
  2478. }
  2479. articleIds = strings.TrimRight(articleIds, ",")
  2480. if articleIds != "" {
  2481. condition = ` AND a.article_id IN (` + articleIds + `)`
  2482. DepartmentList, err := models.GetCygxArticleDepartmentListPc(0, 20, condition, uid)
  2483. if err != nil {
  2484. br.Msg = "获取信息失败"
  2485. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2486. return
  2487. }
  2488. for k, v := range DepartmentList {
  2489. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIds)
  2490. if err != nil {
  2491. br.Msg = "获取信息失败"
  2492. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2493. return
  2494. }
  2495. for k2, v2 := range artList {
  2496. if artList[k2].IsReport == "1" {
  2497. artList[k2].Title = v2.Title
  2498. } else {
  2499. artList[k2].Title = v2.Title
  2500. }
  2501. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2502. }
  2503. DepartmentList[k].List = artList
  2504. if v.FollowNum > 0 {
  2505. DepartmentList[k].IsMyFollow = true
  2506. }
  2507. }
  2508. resp.DepartmentList = DepartmentList
  2509. }
  2510. }
  2511. if keyWord != "" {
  2512. keyWordItem := new(models.CygxUserSearchKeyWord)
  2513. keyWordItem.UserId = user.UserId
  2514. keyWordItem.KeyWord = keyWord
  2515. keyWordItem.PageType = "ReortSearch"
  2516. keyWordItem.CreateTime = time.Now()
  2517. go models.AddUserSearchKeyWord(keyWordItem)
  2518. }
  2519. resp.IndList = list
  2520. br.Ret = 200
  2521. br.Success = true
  2522. br.Msg = "获取成功"
  2523. br.Data = resp
  2524. }
  2525. // @Title 报告搜索
  2526. // @Description 报告搜索接口
  2527. // @Param KeyWord query string true "搜索关键词"
  2528. // @Success 200 {object} models.ReoprtSearchResp
  2529. // @router /searchReport [get]
  2530. func (this *ReportController) SearchReport() {
  2531. br := new(models.BaseResponse).Init()
  2532. defer func() {
  2533. this.Data["json"] = br
  2534. this.ServeJSON()
  2535. }()
  2536. user := this.User
  2537. if user == nil {
  2538. br.Msg = "请重新登录"
  2539. br.Ret = 408
  2540. return
  2541. }
  2542. keyWord := this.GetString("KeyWord")
  2543. var condition string
  2544. var sqlGroup string
  2545. //匹配报告标题、
  2546. 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 `
  2547. sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2548. //对应产业名称、标的名称。
  2549. listYx, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
  2550. if err != nil {
  2551. br.Msg = "获取信息失败"
  2552. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2553. return
  2554. }
  2555. for k, v := range listYx {
  2556. listYx[k].Source = 2
  2557. if v.MyCollectNum > 0 {
  2558. listYx[k].IsCollect = true
  2559. }
  2560. }
  2561. listHz, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition+` OR ( article_type = 'lyjh' `+condition+` ) `+sqlGroup, user.UserId)
  2562. if err != nil {
  2563. br.Msg = "获取信息失败"
  2564. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2565. return
  2566. }
  2567. for k, v := range listHz {
  2568. listHz[k].Source = 1
  2569. if v.MyCollectNum > 0 {
  2570. listHz[k].IsCollect = true
  2571. }
  2572. }
  2573. if keyWord != "" {
  2574. keyWordItem := new(models.CygxUserSearchKeyWord)
  2575. keyWordItem.UserId = user.UserId
  2576. keyWordItem.KeyWord = keyWord
  2577. keyWordItem.PageType = "ReortSearch"
  2578. keyWordItem.CreateTime = time.Now()
  2579. go models.AddUserSearchKeyWord(keyWordItem)
  2580. //go services.AddUserSearchLog(user, keyWord, 5)
  2581. }
  2582. if len(listYx) == 0 {
  2583. listYx = make([]*models.ArticleCollectionResp, 0)
  2584. }
  2585. if len(listHz) == 0 {
  2586. listHz = make([]*models.ArticleCollectionResp, 0)
  2587. }
  2588. resp := new(models.ReoprtSearchResp)
  2589. resp.ListYx = listYx
  2590. resp.ListHz = listHz
  2591. br.Ret = 200
  2592. br.Success = true
  2593. br.Msg = "获取成功"
  2594. br.Data = resp
  2595. }
  2596. // @Title 资源包搜索
  2597. // @Description 资源包搜索接口
  2598. // @Param KeyWord query string true "搜索关键词"
  2599. // @Success 200 {object} models.SearchResourceResp
  2600. // @router /searchResource [get]
  2601. func (this *ReportController) SearchResource() {
  2602. br := new(models.BaseResponse).Init()
  2603. defer func() {
  2604. this.Data["json"] = br
  2605. this.ServeJSON()
  2606. }()
  2607. user := this.User
  2608. if user == nil {
  2609. br.Msg = "请重新登录"
  2610. br.Ret = 408
  2611. return
  2612. }
  2613. uid := user.UserId
  2614. fllowList, err := models.GetUserFllowIndustrialList(uid)
  2615. if err != nil {
  2616. br.Msg = "获取失败"
  2617. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  2618. return
  2619. }
  2620. fllowMap := make(map[int]int)
  2621. if len(fllowList) > 0 {
  2622. for _, v := range fllowList {
  2623. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  2624. }
  2625. }
  2626. keyWord := this.GetString("KeyWord")
  2627. var condition string
  2628. var conditionOr string
  2629. //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2630. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2631. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2632. listHz, err := models.GetSearchResourceList(user.UserId, condition, 0, 0)
  2633. if err != nil {
  2634. br.Msg = "获取信息失败"
  2635. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2636. return
  2637. }
  2638. //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2639. conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2640. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2641. listYx, err := models.GetSearchResourceList(user.UserId, condition, 0, 0)
  2642. if err != nil {
  2643. br.Msg = "获取信息失败"
  2644. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2645. return
  2646. }
  2647. //合并产业关联的标的
  2648. listSubjcet, err := models.GetThemeHeatSubjectList("")
  2649. if err != nil {
  2650. br.Msg = "获取信息失败"
  2651. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2652. return
  2653. }
  2654. industrialIdArr := make([]int, 0)
  2655. for k, v := range listHz {
  2656. listHz[k].Source = 1
  2657. if fllowMap[v.IndustrialManagementId] > 0 {
  2658. listHz[k].IsFollw = true
  2659. }
  2660. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2661. }
  2662. for k, v := range listYx {
  2663. listYx[k].Source = 2
  2664. if fllowMap[v.IndustrialManagementId] > 0 {
  2665. listYx[k].IsFollw = true
  2666. }
  2667. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2668. }
  2669. if len(industrialIdArr) > 0 {
  2670. //合并产业关联的标的
  2671. listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  2672. if err != nil {
  2673. br.Msg = "获取信息失败"
  2674. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2675. return
  2676. }
  2677. mapIndustrial := make(map[string]int)
  2678. for _, v := range listSubjcet {
  2679. for k2, v2 := range listYx {
  2680. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 {
  2681. listYx[k2].IndustrialSubjectList = append(listYx[k2].IndustrialSubjectList, v)
  2682. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  2683. }
  2684. }
  2685. for k2, v2 := range listHz {
  2686. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  2687. listHz[k2].IndustrialSubjectList = append(listHz[k2].IndustrialSubjectList, v)
  2688. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  2689. }
  2690. }
  2691. }
  2692. }
  2693. if keyWord != "" {
  2694. keyWordItem := new(models.CygxUserSearchKeyWord)
  2695. keyWordItem.UserId = user.UserId
  2696. keyWordItem.KeyWord = keyWord
  2697. keyWordItem.PageType = "ReortSearch"
  2698. keyWordItem.CreateTime = time.Now()
  2699. go models.AddUserSearchKeyWord(keyWordItem)
  2700. }
  2701. resp := new(models.SearchResourceResp)
  2702. if len(listYx) == 0 {
  2703. listYx = make([]*models.IndustrialManagementHotResp, 0)
  2704. }
  2705. if len(listHz) == 0 {
  2706. listHz = make([]*models.IndustrialManagementHotResp, 0)
  2707. }
  2708. resp.ListYx = listYx
  2709. resp.ListHz = listHz
  2710. br.Ret = 200
  2711. br.Success = true
  2712. br.Msg = "获取成功"
  2713. br.Data = resp
  2714. }
  2715. // @Title 报告搜索、资源包搜索接口
  2716. // @Description 报告搜索、资源包搜索接口接口
  2717. // @Param KeyWord query string true "搜索关键词"
  2718. // @Param PageSize query int true "每页数据条数"
  2719. // @Success 200 {object} models.SearchReportAndResourceResp
  2720. // @router /searchReportAndResource [get]
  2721. func (this *ReportController) SearchReportAndResource() {
  2722. br := new(models.BaseResponse).Init()
  2723. defer func() {
  2724. this.Data["json"] = br
  2725. this.ServeJSON()
  2726. }()
  2727. user := this.User
  2728. if user == nil {
  2729. br.Msg = "请重新登录"
  2730. br.Ret = 408
  2731. return
  2732. }
  2733. uid := user.UserId
  2734. keyWord := this.GetString("KeyWord")
  2735. pageSize, _ := this.GetInt("PageSize")
  2736. var condition string
  2737. var sqlGroup string
  2738. //匹配报告标题、
  2739. 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 `
  2740. sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2741. if pageSize > 0 {
  2742. sqlGroup += ` LIMIT 5 `
  2743. } else {
  2744. sqlGroup += ` LIMIT 100 `
  2745. }
  2746. ListYxReport, err := models.GetArticleCollectionList(` AND a.article_type_id IN (`+utils.YAN_XUAN_ARTICLE_TYPE_IDS+`) `+condition+sqlGroup, user.UserId)
  2747. if err != nil {
  2748. br.Msg = "获取信息失败"
  2749. br.ErrMsg = "获取研选文章列表失败,Err:" + err.Error()
  2750. return
  2751. }
  2752. ListHzReport, err := models.GetReoprtSearchList(` AND a.article_type_id NOT IN (`+utils.YAN_XUAN_ARTICLE_TYPE_IDS+`) `+condition+sqlGroup, user.UserId)
  2753. if err != nil {
  2754. br.Msg = "获取信息失败"
  2755. br.ErrMsg = "获取弘则报告文章列表失败,Err:" + err.Error()
  2756. return
  2757. }
  2758. keyWordArr, err := services.GetIndustryMapNameSliceV3(keyWord)
  2759. if err != nil {
  2760. br.Msg = "获取失败"
  2761. br.ErrMsg = "获取分词失败,GetIndustryMapNameSliceV3 Err: " + err.Error()
  2762. return
  2763. }
  2764. keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
  2765. var keyWordIk string
  2766. if len(keyWordArr) > 1 {
  2767. keyWordIk = services.KeyWordArrSqlRegexp(keyWordArr)
  2768. var conditionIk string
  2769. var sqlGroupIk string
  2770. conditionIk = `AND ( a.title REGEXP '` + keyWordIk + `' OR a.annotation REGEXP '` + keyWordIk + `' OR a.abstract REGEXP '` + keyWordIk + `') AND a.publish_status = 1 `
  2771. sqlGroupIk = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2772. if pageSize > 0 {
  2773. sqlGroupIk += ` LIMIT 5 `
  2774. } else {
  2775. sqlGroupIk += ` LIMIT 20 `
  2776. }
  2777. //研选的联想词列表
  2778. ListYxReportIk, err := models.GetArticleCollectionList(` AND a.article_type_id IN (`+utils.YAN_XUAN_ARTICLE_TYPE_IDS+`) `+conditionIk+sqlGroupIk, user.UserId)
  2779. if err != nil && err.Error() != utils.ErrNoRow() {
  2780. br.Msg = "获取信息失败"
  2781. br.ErrMsg = "获取研选IK文章列表失败,Err:" + err.Error()
  2782. return
  2783. }
  2784. if len(ListYxReportIk) > 0 {
  2785. for _, v := range ListYxReportIk {
  2786. ListYxReport = append(ListYxReport, v)
  2787. }
  2788. }
  2789. //弘则的联想词列表
  2790. ListHzReportIk, err := models.GetReoprtSearchList(` AND a.article_type_id NOT IN (`+utils.YAN_XUAN_ARTICLE_TYPE_IDS+`) `+conditionIk+sqlGroupIk, user.UserId)
  2791. if err != nil && err.Error() != utils.ErrNoRow() {
  2792. br.Msg = "获取信息失败"
  2793. br.ErrMsg = "获取研选IK文章列表失败,Err:" + err.Error()
  2794. return
  2795. }
  2796. if len(ListHzReportIk) > 0 {
  2797. for _, v := range ListHzReportIk {
  2798. ListHzReport = append(ListHzReport, v)
  2799. }
  2800. }
  2801. }
  2802. for k, v := range ListHzReport {
  2803. ListHzReport[k].Source = 1
  2804. if v.MyCollectNum > 0 {
  2805. ListHzReport[k].IsCollect = true
  2806. }
  2807. }
  2808. for k, v := range ListYxReport {
  2809. ListYxReport[k].Source = 2
  2810. if v.MyCollectNum > 0 {
  2811. ListYxReport[k].IsCollect = true
  2812. }
  2813. }
  2814. var articleIds string
  2815. for _, v := range ListHzReport {
  2816. articleIds += strconv.Itoa(v.ArticleId) + ","
  2817. }
  2818. for _, v := range ListYxReport {
  2819. articleIds += strconv.Itoa(v.ArticleId) + ","
  2820. }
  2821. articleIds = strings.TrimRight(articleIds, ",")
  2822. silcearticleIds := strings.Split(articleIds, ",")
  2823. var parsindustrial []interface{}
  2824. parsindustrial = make([]interface{}, 0)
  2825. articleIdList := make([]string, 0)
  2826. for _, v := range silcearticleIds {
  2827. articleIdList = append(articleIdList, v)
  2828. }
  2829. conditionindustrial := ` AND mg.article_id IN ( ` + utils.GetOrmInReplace(len(silcearticleIds)) + ` ) `
  2830. parsindustrial = append(parsindustrial, articleIdList)
  2831. industrialList, err := models.GetIndustrialListByarticleId(parsindustrial, conditionindustrial)
  2832. if err != nil {
  2833. return
  2834. }
  2835. industrialMap := make(map[int][]*models.IndustrialManagementResp)
  2836. if len(industrialList) > 0 {
  2837. for _, v := range industrialList {
  2838. item := new(models.IndustrialManagementResp)
  2839. //item.ArticleId = v.ArticleId
  2840. item.IndustrialManagementId = v.IndustrialManagementId
  2841. item.IndustryName = v.IndustryName
  2842. item.ChartPermissionId = v.ChartPermissionId
  2843. industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
  2844. }
  2845. }
  2846. for k, v := range ListHzReport {
  2847. if len(industrialMap[v.ArticleId]) > 0 {
  2848. ListHzReport[k].List = industrialMap[v.ArticleId]
  2849. } else {
  2850. ListHzReport[k].List = make([]*models.IndustrialManagementResp, 0)
  2851. }
  2852. }
  2853. for k, v := range ListYxReport {
  2854. if len(industrialMap[v.ArticleId]) > 0 {
  2855. ListYxReport[k].List = industrialMap[v.ArticleId]
  2856. } else {
  2857. ListYxReport[k].List = make([]*models.IndustrialManagementResp, 0)
  2858. }
  2859. }
  2860. //获取文章关联的产业
  2861. if len(ListYxReport) == 0 {
  2862. ListYxReport = make([]*models.ArticleCollectionResp, 0)
  2863. }
  2864. if len(ListHzReport) == 0 {
  2865. ListHzReport = make([]*models.ArticleCollectionResp, 0)
  2866. }
  2867. fllowList, err := models.GetUserFllowIndustrialList(uid)
  2868. if err != nil {
  2869. br.Msg = "获取失败"
  2870. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  2871. return
  2872. }
  2873. fllowMap := make(map[int]int)
  2874. if len(fllowList) > 0 {
  2875. for _, v := range fllowList {
  2876. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  2877. }
  2878. }
  2879. condition = ` AND a.publish_status = 1 AND a.article_type_id NOT IN (` + utils.YAN_XUAN_ARTICLE_TYPE_IDS + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
  2880. listHzResource, err := models.GetSearchResourceList(user.UserId, condition, 0, pageSize)
  2881. if err != nil {
  2882. br.Msg = "获取信息失败"
  2883. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2884. return
  2885. }
  2886. condition = ` AND a.publish_status = 1 AND a.article_type_id IN (` + utils.YAN_XUAN_ARTICLE_TYPE_IDS + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
  2887. listYxResource, err := models.GetSearchResourceList(user.UserId, condition, 0, pageSize)
  2888. if err != nil {
  2889. br.Msg = "获取信息失败"
  2890. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2891. return
  2892. }
  2893. //合并产业关联的标的
  2894. listSubjcet, err := models.GetThemeHeatSubjectList("")
  2895. if err != nil {
  2896. br.Msg = "获取信息失败"
  2897. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2898. return
  2899. }
  2900. industrialIdArr := make([]int, 0)
  2901. nowTime := time.Now().Local()
  2902. threeMonBefore := nowTime.AddDate(0, -3, 0)
  2903. mapHot := make(map[string]int)
  2904. hotCondition := ` ORDER BY sum_num DESC `
  2905. listHot, err := models.GetThemeHeatList(user.UserId, hotCondition, 0, 3)
  2906. if err != nil {
  2907. br.Msg = "获取信息失败"
  2908. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2909. return
  2910. }
  2911. for _, v := range listHot {
  2912. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2913. mapHot[v.IndustryName] = v.IndustrialManagementId
  2914. }
  2915. orderSrt := "man.recommended_index DESC,update_time DESC"
  2916. for k, v := range listHzResource {
  2917. // 关联报告发布时间均在3个月内则标记New
  2918. if v.MinReportTime != "" {
  2919. t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
  2920. if e != nil {
  2921. err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
  2922. return
  2923. }
  2924. if t.After(threeMonBefore) {
  2925. listHzResource[k].IsNew = true
  2926. }
  2927. }
  2928. //弘则资源包不展示hot标签
  2929. //if mapHot[v.IndustryName] > 0 {
  2930. // listHzResource[k].IsHot = true
  2931. //}
  2932. listHzResource[k].Source = 1
  2933. if fllowMap[v.IndustrialManagementId] > 0 {
  2934. listHzResource[k].IsFollw = true
  2935. }
  2936. industrialIdSlice := make([]int, 0)
  2937. articleIdArr := make([]int, 0)
  2938. industrialIdSlice = append(industrialIdSlice, v.IndustrialManagementId)
  2939. listUpdateTime, err := models.GetNewArticleDetailByIndustrialIds(industrialIdSlice)
  2940. if err != nil && err.Error() != utils.ErrNoRow() {
  2941. return
  2942. }
  2943. for _, v := range listUpdateTime {
  2944. articleIdArr = append(articleIdArr, v.ArticleId)
  2945. }
  2946. if err != nil {
  2947. return
  2948. }
  2949. mapHistroyArticleId := make(map[int]int)
  2950. if user.UserId > 0 {
  2951. listArticleHistory, e := models.GetUserToArticleHistory(user.UserId, articleIdArr)
  2952. if e != nil && e.Error() != utils.ErrNoRow() {
  2953. err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
  2954. return
  2955. }
  2956. for _, v := range listArticleHistory {
  2957. mapHistroyArticleId[v.ArticleId] = v.ArticleId
  2958. }
  2959. }
  2960. condition2 := ` AND man.industry_name LIKE '%` + keyWord + `%' `
  2961. list, err := models.GetIndustrialManagementAll(uid, condition2, orderSrt, 0, 20)
  2962. if err != nil {
  2963. br.Msg = "获取信息失败"
  2964. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2965. return
  2966. }
  2967. mapUPdateTime := make(map[int]string)
  2968. //获取这些产业下最新更新的文章
  2969. //时间线的更新时间
  2970. // maptimelineUPdateTime := make(map[int]string)
  2971. listtimelinePublishdate, err := models.GetTimeLineReportIndustrialPublishdateList(industrialIdArr)
  2972. if err != nil && err.Error() != utils.ErrNoRow() {
  2973. return
  2974. }
  2975. for _, v := range listtimelinePublishdate {
  2976. if mapUPdateTime[v.IndustrialManagementId] != "" {
  2977. if utils.StrTimeToTime(v.PublishDate).After(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  2978. mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
  2979. }
  2980. }
  2981. }
  2982. //mapHistroyArticleId := make(map[int]int)
  2983. //if userId > 0 {
  2984. // listArticleHistory, e := models.GetUserToArticleHistory(userId, articleIdArr)
  2985. // if e != nil && e.Error() != utils.ErrNoRow() {
  2986. // err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
  2987. // return
  2988. // }
  2989. // for _, v := range listArticleHistory {
  2990. // mapHistroyArticleId[v.ArticleId] = v.ArticleId
  2991. // }
  2992. //}
  2993. var industrialIds string
  2994. for _, id := range industrialIdArr {
  2995. industrialIds += strconv.Itoa(id) + ","
  2996. }
  2997. industrialIds = strings.TrimRight(industrialIds, ",")
  2998. articleList, err := models.GetReportIndustrialReadNumList(user.UserId, industrialIds, user.CreatedTime)
  2999. mapHistroyindustrialId := make(map[int]int)
  3000. for _, v := range articleList {
  3001. mapHistroyindustrialId[v.IndustrialManagementId] = v.Readnum
  3002. }
  3003. //nowTime := time.Now().Local()
  3004. //threeMonBefore := nowTime.AddDate(0, -3, 0)
  3005. //查询用户今天是否看过时间线
  3006. //haveMorningMeeting := false
  3007. //var morningMeetingTime string
  3008. recrodList, err := models.GetTimeLineRecordAllCount(user.UserId, time.Now().Format(utils.FormatDate))
  3009. if err != nil {
  3010. return
  3011. }
  3012. var industrialManagementIdstr string
  3013. industrialIdMap := make(map[string]time.Time)
  3014. for _, v := range recrodList {
  3015. industrialManagementIdstr = strings.TrimLeft(v.Parameter, "PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=")
  3016. if createTime, ok := industrialIdMap[industrialManagementIdstr]; ok {
  3017. if createTime.Before(v.CreateTime) {
  3018. industrialIdMap[industrialManagementIdstr] = v.CreateTime
  3019. }
  3020. } else {
  3021. industrialIdMap[industrialManagementIdstr] = v.CreateTime
  3022. }
  3023. }
  3024. mmList, err := models.GetCygxMorningMeetingReviewsListByIndustrialIds(industrialIds)
  3025. if err != nil {
  3026. return
  3027. }
  3028. morningMeetingTimeMap := make(map[int]time.Time)
  3029. for _, v := range mmList {
  3030. morningMeetingTimeMap[v.IndustryId] = v.CreateTime
  3031. }
  3032. timeLineRedMap := make(map[int]bool, 0)
  3033. for _, industrialId := range industrialIdArr {
  3034. if createTime, ok := industrialIdMap[strconv.Itoa(industrialId)]; ok {
  3035. if createTime.Before(morningMeetingTimeMap[industrialId]) {
  3036. timeLineRedMap[industrialId] = true
  3037. }
  3038. }
  3039. }
  3040. for k, v := range list {
  3041. list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
  3042. if user.UserId > 0 {
  3043. //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
  3044. if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
  3045. if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3046. list[k].IsRed = true
  3047. }
  3048. }
  3049. } else {
  3050. if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3051. list[k].IsRed = true
  3052. }
  3053. list[k].IsFollow = 0
  3054. }
  3055. list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
  3056. if user.UserId > 0 {
  3057. //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
  3058. if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
  3059. if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3060. list[k].IsRed = true
  3061. }
  3062. }
  3063. } else {
  3064. if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3065. list[k].IsRed = true
  3066. }
  3067. list[k].IsFollow = 0
  3068. }
  3069. }
  3070. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  3071. }
  3072. for k, v := range listYxResource {
  3073. // 关联报告发布时间均在3个月内则标记New
  3074. if v.MinReportTime != "" {
  3075. t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
  3076. if e != nil {
  3077. err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
  3078. return
  3079. }
  3080. if t.After(threeMonBefore) {
  3081. listYxResource[k].IsNew = true
  3082. }
  3083. }
  3084. if mapHot[v.IndustryName] > 0 {
  3085. listYxResource[k].IsHot = true
  3086. }
  3087. listYxResource[k].Source = 2
  3088. if fllowMap[v.IndustrialManagementId] > 0 {
  3089. listYxResource[k].IsFollw = true
  3090. }
  3091. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  3092. }
  3093. if len(industrialIdArr) > 0 {
  3094. //查询产业视频
  3095. industrialVideoMap := make(map[int]*models.MicroVideoSimpleInfo)
  3096. // 获取默认图配置
  3097. _, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
  3098. if e != nil {
  3099. br.Msg = "获取视频默认配置图失败"
  3100. br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
  3101. return
  3102. }
  3103. videoList, err := models.GetMicroRoadshowVideoByIndustryIds(industrialIdArr)
  3104. if err != nil {
  3105. br.Msg = "产业视频列表失败"
  3106. br.ErrMsg = "产业视频列表失败, Err: " + err.Error()
  3107. return
  3108. }
  3109. for _, v := range videoList {
  3110. tmp := &models.MicroVideoSimpleInfo{
  3111. Id: v.VideoId,
  3112. Title: "5min逻辑【" + v.IndustryName + "】解析",
  3113. ResourceUrl: v.VideoUrl,
  3114. BackgroundImg: v.ImgUrl,
  3115. PlaySeconds: v.VideoDuration,
  3116. DetailImgUrl: v.DetailImgUrl,
  3117. ChartPermissionName: v.ChartPermissionName,
  3118. ChartPermissionId: v.ChartPermissionId,
  3119. }
  3120. if tmp.BackgroundImg == "" {
  3121. tmp.BackgroundImg = videoMap[v.ChartPermissionId]
  3122. }
  3123. industrialVideoMap[v.IndustryId] = tmp
  3124. }
  3125. //查询权限
  3126. // 用户权限
  3127. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  3128. if e != nil {
  3129. br.Msg = "获取失败"
  3130. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  3131. return
  3132. }
  3133. for k, v := range listHzResource {
  3134. //展示产业视频
  3135. if video, ok := industrialVideoMap[v.IndustrialManagementId]; ok {
  3136. au := new(models.UserPermissionAuthInfo)
  3137. au.SellerName = authInfo.SellerName
  3138. au.SellerMobile = authInfo.SellerMobile
  3139. au.HasPermission = authInfo.HasPermission
  3140. au.OperationMode = authInfo.OperationMode
  3141. if au.HasPermission == 1 {
  3142. // 非宏观权限进一步判断是否有权限
  3143. if video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) {
  3144. au.HasPermission = 2
  3145. }
  3146. }
  3147. // 无权限的弹框提示
  3148. if au.HasPermission != 1 {
  3149. if au.OperationMode == services.UserPermissionOperationModeCall {
  3150. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  3151. } else {
  3152. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  3153. }
  3154. video.ResourceUrl = ""
  3155. }
  3156. listHzResource[k].AuthInfo = au
  3157. listHzResource[k].IndustryVideo = video
  3158. }
  3159. }
  3160. //合并产业关联的标的
  3161. listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  3162. if err != nil {
  3163. br.Msg = "获取信息失败"
  3164. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  3165. return
  3166. }
  3167. //严选的产业只关联研选下面的标的
  3168. var yxcondition string
  3169. var yxPer []interface{}
  3170. yxcondition = ` AND ag.article_id >= ?`
  3171. yxPer = append(yxPer, utils.SummaryArticleId)
  3172. listYxAticleSubject, err := models.GetSubjectArticleGroupManagementList(yxcondition, yxPer)
  3173. if err != nil && err.Error() != utils.ErrNoRow() {
  3174. br.Msg = "获取信息失败"
  3175. br.ErrMsg = "获取研选报告关联的标的信息失败,GetSubjectArticleGroupManagementListErr:" + err.Error()
  3176. return
  3177. }
  3178. mapYxSubject := make(map[int]int)
  3179. for _, v := range listYxAticleSubject {
  3180. mapYxSubject[v.IndustrialSubjectId] = v.IndustrialSubjectId
  3181. }
  3182. mapIndustrial := make(map[string]int)
  3183. for _, v := range listSubjcet {
  3184. for k2, v2 := range listYxResource {
  3185. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 && mapYxSubject[v.IndustrialSubjectId] > 0 {
  3186. listYxResource[k2].IndustrialSubjectList = append(listYxResource[k2].IndustrialSubjectList, v)
  3187. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  3188. }
  3189. }
  3190. for k2, v2 := range listHzResource {
  3191. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  3192. listHzResource[k2].IndustrialSubjectList = append(listHzResource[k2].IndustrialSubjectList, v)
  3193. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  3194. }
  3195. }
  3196. }
  3197. }
  3198. resp := new(models.SearchReportAndResourceResp)
  3199. if len(listYxResource) == 0 {
  3200. listYxResource = make([]*models.IndustrialManagementHotResp, 0)
  3201. }
  3202. if len(listHzResource) == 0 {
  3203. listHzResource = make([]*models.IndustrialManagementHotResp, 0)
  3204. }
  3205. if keyWord != "" {
  3206. keyWordItem := new(models.CygxUserSearchKeyWord)
  3207. keyWordItem.UserId = user.UserId
  3208. keyWordItem.KeyWord = keyWord
  3209. keyWordItem.PageType = "ReortSearch"
  3210. keyWordItem.CreateTime = time.Now()
  3211. go models.AddUserSearchKeyWord(keyWordItem)
  3212. //go services.AddUserSearchLog(user, keyWord, 5)
  3213. }
  3214. resp.ListHzResource = listHzResource
  3215. resp.ListYxResource = listYxResource
  3216. resp.ListYxReport = ListYxReport
  3217. resp.ListHzReport = ListHzReport
  3218. br.Ret = 200
  3219. br.Success = true
  3220. br.Msg = "获取成功"
  3221. br.Data = resp
  3222. }
  3223. // @Title 产业报告公司列表
  3224. // @Description 获取产业报告公司列表接口
  3225. // @Param ChartPermissionId query int true "行业id"
  3226. // @Success 200 {object} models.IndustrialManagementList
  3227. // @router /home/stockName [get]
  3228. func (this *ReportController) StockNameList() {
  3229. br := new(models.BaseResponse).Init()
  3230. defer func() {
  3231. this.Data["json"] = br
  3232. this.ServeJSON()
  3233. }()
  3234. user := this.User
  3235. if user == nil {
  3236. br.Msg = "请重新登录"
  3237. br.Ret = 408
  3238. return
  3239. }
  3240. //uid := user.UserId
  3241. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  3242. list, err := models.GetSummaryArticle(chartPermissionId)
  3243. if err != nil {
  3244. br.Msg = "获取综述报告公司名称失败"
  3245. br.ErrMsg = "获取综述报告公司名称失败,Err:" + err.Error()
  3246. return
  3247. }
  3248. var respList []*models.SummaryArticleStock
  3249. for _, item := range list {
  3250. sliceSubjects := strings.Split(item.Stock, "/")
  3251. if len(sliceSubjects) > 0 {
  3252. for i, vSubject := range sliceSubjects {
  3253. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  3254. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  3255. subject := sliceXiahuaxian[0]
  3256. if i > 0 {
  3257. newItem := models.SummaryArticleStock{
  3258. Id: item.Id,
  3259. ArticleId: item.ArticleId,
  3260. Stock: subject,
  3261. }
  3262. respList = append(respList, &newItem)
  3263. } else {
  3264. item.Stock = subject
  3265. respList = append(respList, item)
  3266. }
  3267. }
  3268. }
  3269. //index := strings.Index(item.Stock, "(")
  3270. //item.Stock = item.Stock[:index]
  3271. //if strings.Contains(item.Stock, "-B"){
  3272. // item.Stock = strings.Replace(item.Stock, "-B", "", -1)
  3273. //}
  3274. //if strings.Contains(item.Stock, "-W"){
  3275. // item.Stock = strings.Replace(item.Stock, "-W", "", -1)
  3276. //}
  3277. }
  3278. resp := new(models.SummaryArticleStockResp)
  3279. resp.List = respList
  3280. br.Ret = 200
  3281. br.Success = true
  3282. br.Msg = "获取成功"
  3283. br.Data = resp
  3284. }
  3285. // @Title 文章留言接口
  3286. // @Description 文章留言接口
  3287. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  3288. // @Success 200 {object} models.TacticsListResp
  3289. // @router /commentAdd [post]
  3290. func (this *ReportController) CommentAdd() {
  3291. br := new(models.BaseResponse).Init()
  3292. defer func() {
  3293. this.Data["json"] = br
  3294. this.ServeJSON()
  3295. }()
  3296. user := this.User
  3297. if user == nil {
  3298. br.Msg = "请重新登录"
  3299. br.Ret = 408
  3300. return
  3301. }
  3302. var req models.AddCygxArticleCommentReq
  3303. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3304. if err != nil {
  3305. br.Msg = "参数解析异常!"
  3306. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3307. return
  3308. }
  3309. if req.ArticleId <= 0 {
  3310. br.Msg = "文章不存在"
  3311. br.ErrMsg = "文章不存在,文章ID错误"
  3312. return
  3313. }
  3314. if req.Content == "" {
  3315. br.Msg = "建议内容不可为空"
  3316. return
  3317. }
  3318. content := req.Content
  3319. itemToken, err := services.WxGetToken()
  3320. if err != nil {
  3321. br.Msg = "GetWxAccessToken Err:" + err.Error()
  3322. return
  3323. }
  3324. if itemToken.AccessToken == "" {
  3325. br.Msg = "accessToken is empty"
  3326. return
  3327. }
  3328. commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  3329. if err != nil {
  3330. br.Msg = "内容校验失败!"
  3331. br.ErrMsg = "内容校验失败,Err:" + err.Error()
  3332. return
  3333. }
  3334. if commerr.ErrCode != 0 {
  3335. br.Msg = "内容违规,请重新提交!"
  3336. br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
  3337. return
  3338. }
  3339. articleId := req.ArticleId
  3340. articleInfo, errInfo := models.GetArticleDetailById(articleId)
  3341. if articleInfo == nil {
  3342. br.Msg = "操作失败"
  3343. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3344. return
  3345. }
  3346. if errInfo != nil {
  3347. br.Msg = "操作失败"
  3348. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3349. return
  3350. }
  3351. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  3352. if err != nil {
  3353. br.Msg = "提交失败!"
  3354. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3355. return
  3356. }
  3357. if companyDetail == nil {
  3358. br.Msg = "提交失败!"
  3359. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  3360. return
  3361. }
  3362. item := models.CygxArticleComment{
  3363. UserId: user.UserId,
  3364. ArticleId: req.ArticleId,
  3365. CreateTime: time.Now(),
  3366. Mobile: user.Mobile,
  3367. Email: user.Email,
  3368. CompanyId: user.CompanyId,
  3369. CompanyName: companyDetail.CompanyName,
  3370. Content: content,
  3371. Title: articleInfo.Title,
  3372. }
  3373. _, err = models.AddArticleComment(&item)
  3374. if err != nil {
  3375. br.Msg = "提交失败"
  3376. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  3377. return
  3378. }
  3379. //获取销售信息
  3380. //sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  3381. //if err != nil && err.Error() != utils.ErrNoRow() {
  3382. // br.Msg = "提交失败"
  3383. // br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  3384. // return
  3385. //}
  3386. //// 给所属销售发送消息
  3387. //var openIdList []*models.OpenIdList
  3388. //if sellerItem != nil {
  3389. // list, _ := models.GetWxOpenIdByMobileList(sellerItem.Mobile)
  3390. // for _, idList := range list {
  3391. // openIdList = append(openIdList, idList)
  3392. // }
  3393. // if openIdList != nil {
  3394. // // 给芳姐发消息
  3395. // cnf, _ := models.GetConfigByCode("tpl_msg")
  3396. // if cnf != nil {
  3397. // list, _ := models.GetWxOpenIdByMobileList(cnf.ConfigValue)
  3398. // for _, idList := range list {
  3399. // openIdList = append(openIdList, idList)
  3400. // }
  3401. // }
  3402. // if articleId > 1000000 {
  3403. // //发给汪洋
  3404. // list, _ := models.GetWxOpenIdByMobileList(utils.ActSendMsgMobile)
  3405. // for _, idList := range list {
  3406. // openIdList = append(openIdList, idList)
  3407. // }
  3408. // }
  3409. // services.SendCommentWxTemplateMsg(articleInfo.Title, user.CompanyName, user.RealName, sellerItem.RealName, item.CreateTime.Format(utils.FormatDateTime), req.Content, openIdList, req.ArticleId)
  3410. // }
  3411. //}
  3412. services.SendCommentWxTemplateMsg(req, user, articleInfo)
  3413. br.Ret = 200
  3414. br.Success = true
  3415. br.Msg = "提交成功"
  3416. }
  3417. // @Title 记录用户浏览音频回放接口
  3418. // @Description 记录用户浏览音频回放接口
  3419. // @Param request body models.ArticleIdReq true "type json string"
  3420. // @Success Ret=200 操作成功
  3421. // @router /voiceHistory/add [post]
  3422. func (this *ReportController) ResearchSummaryVoiceHistoryAdd() {
  3423. br := new(models.BaseResponse).Init()
  3424. defer func() {
  3425. this.Data["json"] = br
  3426. this.ServeJSON()
  3427. }()
  3428. user := this.User
  3429. if user == nil {
  3430. br.Msg = "请登录"
  3431. br.ErrMsg = "请登录,用户信息为空"
  3432. br.Ret = 408
  3433. return
  3434. }
  3435. uid := user.UserId
  3436. var req models.ArticleIdReq
  3437. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3438. if err != nil {
  3439. br.Msg = "参数解析异常!"
  3440. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3441. return
  3442. }
  3443. articleId := req.ArticleId
  3444. playSeconds := req.PlaySeconds
  3445. pageRouter := req.PageRouter
  3446. if pageRouter == "本周研究汇总" {
  3447. articleInfo, errInfo := models.GetCygxResearchSummaryInfoById(articleId)
  3448. if articleInfo == nil {
  3449. br.Msg = "操作失败"
  3450. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3451. return
  3452. }
  3453. if errInfo != nil {
  3454. br.Msg = "操作失败"
  3455. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3456. return
  3457. }
  3458. var sellerName string
  3459. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3460. if err != nil {
  3461. br.Msg = "报名失败!"
  3462. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3463. return
  3464. }
  3465. item := models.CygxResearchSummaryVoiceHistory{
  3466. ArticleId: articleId,
  3467. UserId: uid,
  3468. CreateTime: time.Now(),
  3469. Mobile: user.Mobile,
  3470. Email: user.Email,
  3471. CompanyId: user.CompanyId,
  3472. CompanyName: user.CompanyName,
  3473. RealName: user.RealName,
  3474. SellerName: sellerName,
  3475. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3476. ModifyTime: time.Now(),
  3477. }
  3478. if playSeconds != 0 {
  3479. lastItem, err := models.GetLastCygxResearchSummaryVoiceHistory(articleId, user.UserId)
  3480. if err != nil {
  3481. br.Msg = "操作失败"
  3482. br.ErrMsg = "操作失败,GetLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  3483. return
  3484. }
  3485. err = models.UpdateLastCygxResearchSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3486. if err != nil {
  3487. br.Msg = "更新失败"
  3488. br.ErrMsg = "更新失败,UpdateLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  3489. return
  3490. }
  3491. } else {
  3492. err = models.AddCygxResearchSummaryVoiceHistory(&item)
  3493. if err != nil {
  3494. br.Msg = "操作失败"
  3495. br.ErrMsg = "操作失败,Err:" + err.Error()
  3496. return
  3497. }
  3498. err = models.UpdateResearchSummaryVoiceCounts(articleId)
  3499. if err != nil {
  3500. br.Msg = "更新失败"
  3501. br.ErrMsg = "更新失败,Err:" + err.Error()
  3502. return
  3503. }
  3504. }
  3505. } else if pageRouter == "上周纪要汇总" {
  3506. articleInfo, errInfo := models.GetCygxMinutesSummaryInfoById(articleId)
  3507. if articleInfo == nil {
  3508. br.Msg = "操作失败"
  3509. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3510. return
  3511. }
  3512. if errInfo != nil {
  3513. br.Msg = "操作失败"
  3514. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3515. return
  3516. }
  3517. var sellerName string
  3518. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3519. if err != nil {
  3520. br.Msg = "报名失败!"
  3521. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3522. return
  3523. }
  3524. item := models.CygxMinutesSummaryVoiceHistory{
  3525. ArticleId: articleId,
  3526. UserId: uid,
  3527. CreateTime: time.Now(),
  3528. Mobile: user.Mobile,
  3529. Email: user.Email,
  3530. CompanyId: user.CompanyId,
  3531. CompanyName: user.CompanyName,
  3532. RealName: user.RealName,
  3533. SellerName: sellerName,
  3534. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3535. ModifyTime: time.Now(),
  3536. }
  3537. if playSeconds != 0 {
  3538. lastItem, err := models.GetLastCygxMinutesSummaryVoiceHistory(articleId, user.UserId)
  3539. if err != nil {
  3540. br.Msg = "操作失败"
  3541. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  3542. return
  3543. }
  3544. err = models.UpdateLastCygxMinutesSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3545. if err != nil {
  3546. br.Msg = "更新失败"
  3547. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  3548. return
  3549. }
  3550. } else {
  3551. err = models.AddCygxMinutesSummaryVoiceHistory(&item)
  3552. if err != nil {
  3553. br.Msg = "操作失败"
  3554. br.ErrMsg = "操作失败,Err:" + err.Error()
  3555. return
  3556. }
  3557. err = models.UpdateMinutesSummaryVoiceCounts(articleId)
  3558. if err != nil {
  3559. br.Msg = "更新失败"
  3560. br.ErrMsg = "更新失败,Err:" + err.Error()
  3561. return
  3562. }
  3563. }
  3564. } else if pageRouter == "报告精选" {
  3565. articleInfo, errInfo := models.GetCygxReportSelectionInfoById(articleId)
  3566. if articleInfo == nil {
  3567. br.Msg = "操作失败"
  3568. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3569. return
  3570. }
  3571. if errInfo != nil {
  3572. br.Msg = "操作失败"
  3573. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3574. return
  3575. }
  3576. var sellerName string
  3577. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3578. if err != nil {
  3579. br.Msg = "报名失败!"
  3580. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3581. return
  3582. }
  3583. item := models.CygxReportSelectionVoiceHistory{
  3584. ArticleId: articleId,
  3585. UserId: uid,
  3586. CreateTime: time.Now(),
  3587. Mobile: user.Mobile,
  3588. Email: user.Email,
  3589. CompanyId: user.CompanyId,
  3590. CompanyName: user.CompanyName,
  3591. RealName: user.RealName,
  3592. SellerName: sellerName,
  3593. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3594. ModifyTime: time.Now(),
  3595. }
  3596. if playSeconds != 0 {
  3597. lastItem, err := models.GetLastCygxReportSelectionVoiceHistory(articleId, user.UserId)
  3598. if err != nil {
  3599. br.Msg = "操作失败"
  3600. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  3601. return
  3602. }
  3603. err = models.UpdateLastCygxReportSelectionVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3604. if err != nil {
  3605. br.Msg = "更新失败"
  3606. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  3607. return
  3608. }
  3609. } else {
  3610. err = models.AddCygxReportSelectionVoiceHistory(&item)
  3611. if err != nil {
  3612. br.Msg = "操作失败"
  3613. br.ErrMsg = "操作失败,Err:" + err.Error()
  3614. return
  3615. }
  3616. err = models.UpdateReportSelectionVoiceCounts(articleId)
  3617. if err != nil {
  3618. br.Msg = "更新失败"
  3619. br.ErrMsg = "更新失败,Err:" + err.Error()
  3620. return
  3621. }
  3622. }
  3623. }
  3624. br.Ret = 200
  3625. br.Success = true
  3626. br.Msg = "操作成功"
  3627. return
  3628. }