report.go 121 KB

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