report.go 119 KB

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