report.go 125 KB

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