report.go 125 KB

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