report.go 121 KB

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