report.go 121 KB

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