report.go 120 KB

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