report.go 121 KB

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