report.go 121 KB

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