report.go 118 KB

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