report.go 120 KB

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