report.go 115 KB

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