report.go 122 KB

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