report.go 125 KB

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