report.go 120 KB

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