report.go 123 KB

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