report.go 120 KB

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