report.go 120 KB

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