report.go 120 KB

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