report.go 119 KB

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