report.go 122 KB

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