report.go 119 KB

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