report.go 123 KB

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