report.go 124 KB

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