report.go 120 KB

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