report.go 125 KB

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