report.go 120 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807
  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. if user.CompanyId != utils.HZ_COMPANY_ID {
  1503. br.Msg = "报告编辑中,请稍后"
  1504. br.IsSendEmail = false
  1505. return
  1506. }
  1507. uid := user.UserId
  1508. articleId, _ := this.GetInt("ArticleId")
  1509. isBestNew, _ := this.GetBool("IsBestNew")
  1510. if isBestNew {
  1511. tbdb := "cygx_report_selection"
  1512. //reportTypeStr := "bgjx"
  1513. condition := ` AND publish_status = 1 `
  1514. var pars []interface{}
  1515. list, err := models.GetReportSelectionListPublic(condition, "1", tbdb, pars, 0, 1)
  1516. if err != nil {
  1517. br.Msg = "获取失败"
  1518. br.ErrMsg = "获取失败,Err:" + err.Error()
  1519. return
  1520. }
  1521. for _, v := range list {
  1522. articleId = v.ArticleId
  1523. }
  1524. }
  1525. if articleId < 1 {
  1526. br.Msg = "获取信息失败"
  1527. br.ErrMsg = "报告ID错误" + strconv.Itoa(articleId)
  1528. return
  1529. }
  1530. resp := new(models.ReportSelectionLetailResp)
  1531. //判断用户权限
  1532. hasPermission, err := services.GetUserhasPermission(user)
  1533. if err != nil {
  1534. br.Msg = "获取信息失败"
  1535. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1536. }
  1537. resp.HasPermission = hasPermission
  1538. if hasPermission != 1 {
  1539. br.Ret = 200
  1540. br.Success = true
  1541. br.Msg = "获取成功"
  1542. br.Data = resp
  1543. return
  1544. }
  1545. detail, err := models.GetCygxReportSelectionInfoById(articleId)
  1546. if err != nil {
  1547. br.Msg = "获取信息失败"
  1548. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1549. return
  1550. }
  1551. if detail.ReportLink != "" {
  1552. articleIdLink, _ := services.GetReportLinkToArticleid(detail.ReportLink)
  1553. detail.CeLueArticleId = articleIdLink
  1554. }
  1555. //较上一期有观点变化(后台填写的核心逻辑汇总内容、标签内容有更新),或者新增的公司,显示new标签
  1556. var isAllNew bool // 判断是否都打新的标签
  1557. lastPeriods := detail.Periods - 1
  1558. mapBodyChartSummary := make(map[int]string)
  1559. mapLabel := make(map[int]string)
  1560. if lastPeriods > 0 {
  1561. detailLast, err := models.GetCygxReportSelectionInfoByperiods(lastPeriods)
  1562. if err != nil && err.Error() != utils.ErrNoRow() {
  1563. br.Msg = "获取信息失败"
  1564. br.ErrMsg = "报告不存在,Err:" + err.Error() + "Periods:" + strconv.Itoa(lastPeriods)
  1565. return
  1566. }
  1567. if detailLast != nil {
  1568. articleIdLast := detailLast.ArticleId
  1569. listLogLast, err := models.GetReportSelectionlogListAll(articleIdLast)
  1570. if err != nil {
  1571. br.Msg = "获取失败"
  1572. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1573. return
  1574. }
  1575. for _, v := range listLogLast {
  1576. mapBodyChartSummary[v.IndustrialSubjectId], _ = services.GetReportContentTextSubNew(v.Body)
  1577. mapLabel[v.IndustrialSubjectId] = v.Label
  1578. }
  1579. }
  1580. } else {
  1581. isAllNew = true
  1582. }
  1583. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1584. existMap := make(map[int]int)
  1585. var items []*models.ReportSelectionChartPermission
  1586. var itemsSubject []*models.ReportSelectionChartLogPermission
  1587. listLog, err := models.GetReportSelectionlogListAll(articleId)
  1588. if err != nil {
  1589. br.Msg = "获取失败"
  1590. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1591. return
  1592. }
  1593. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1594. //获取行业核心逻辑汇总
  1595. listChartLog, err := models.GetCygxReportSelectionChartLogRepList(articleId)
  1596. if err != nil {
  1597. br.Msg = "获取失败"
  1598. br.ErrMsg = "获取失败,Err:" + err.Error()
  1599. return
  1600. }
  1601. mapChartLog := make(map[string]string)
  1602. for _, v := range listChartLog {
  1603. mapChartLog[v.ChartPermissionName] = v.BodyChartSummary
  1604. }
  1605. for _, v := range listLog {
  1606. item := new(models.ReportSelectionChartPermission)
  1607. itemSubject := new(models.ReportSelectionChartLogPermission)
  1608. itemSubject.PermissionName = v.PermissionName
  1609. if existMap[v.ChartPermissionId] == 0 {
  1610. //item.PermissionName = v.PermissionName + "领域深度报告和调研"
  1611. item.PermissionName = v.PermissionName
  1612. item.IcoLink = v.IcoLink
  1613. listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
  1614. if err != nil && err.Error() != utils.ErrNoRow() {
  1615. br.Msg = "获取信息失败"
  1616. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1617. return
  1618. }
  1619. for k2, v2 := range listSonLog {
  1620. var isNew bool
  1621. if isAllNew {
  1622. isNew = true
  1623. } else {
  1624. v2Body, _ := services.GetReportContentTextSubNew(v2.Body)
  1625. if mapBodyChartSummary[v2.IndustrialSubjectId] != v2Body || mapLabel[v2.IndustrialSubjectId] != v2.Label {
  1626. isNew = true
  1627. }
  1628. }
  1629. if v2.IndustrialManagementId != "" {
  1630. listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
  1631. if err != nil && err.Error() != utils.ErrNoRow() {
  1632. br.Msg = "获取信息失败"
  1633. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1634. return
  1635. }
  1636. //v2.IsNew = isNew
  1637. listSonLog[k2].List = listIndustrial
  1638. if v2.Label != "" {
  1639. v2.CompanyLabel = strings.Split(v2.Label, "{|}")
  1640. }
  1641. }
  1642. isNew = false
  1643. itemSubject.ListSubject = append(itemSubject.ListSubject, &models.ReportSelectionChartLogSubjectName{SubjectName: v2.SubjectName, IsNew: isNew, IndustrialSubjectId: v2.IndustrialSubjectId})
  1644. }
  1645. item.BodyChartSummary = mapChartLog[v.PermissionName]
  1646. item.List = listSonLog
  1647. items = append(items, item)
  1648. itemsSubject = append(itemsSubject, itemSubject)
  1649. //itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)
  1650. }
  1651. existMap[v.ChartPermissionId] = v.ChartPermissionId
  1652. }
  1653. historyRecord := new(models.CygxReportHistoryRecord)
  1654. historyRecord.UserId = uid
  1655. historyRecord.ArticleId = articleId
  1656. historyRecord.CreateTime = time.Now()
  1657. historyRecord.Mobile = user.Mobile
  1658. historyRecord.Email = user.Email
  1659. historyRecord.CompanyId = user.CompanyId
  1660. historyRecord.CompanyName = user.CompanyName
  1661. historyRecord.ReportType = "bgjx"
  1662. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1663. if err != nil && err.Error() != utils.ErrNoRow() {
  1664. br.Msg = "获取信息失败"
  1665. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1666. return
  1667. }
  1668. historyRecord.RealName = user.RealName
  1669. if sellerItem != nil {
  1670. historyRecord.SellerName = sellerItem.RealName
  1671. }
  1672. go models.AddCygxReportHistoryRecord(historyRecord)
  1673. resp.List = items
  1674. resp.ListPermissionSubject = itemsSubject
  1675. resp.Detail = detail
  1676. br.Ret = 200
  1677. br.Success = true
  1678. br.Msg = "获取成功"
  1679. br.Data = resp
  1680. }
  1681. // @Title 获取本周研究汇总详情
  1682. // @Description 获取本周研究汇总详情接口
  1683. // @Param ArticleId query int true "报告ID"
  1684. // @Success 200 {object} models.ResearchSummaryLetailResp
  1685. // @router /researchSummary/detail [get]
  1686. func (this *ReportController) ResearchDetail() {
  1687. br := new(models.BaseResponse).Init()
  1688. defer func() {
  1689. this.Data["json"] = br
  1690. this.ServeJSON()
  1691. }()
  1692. user := this.User
  1693. if user == nil {
  1694. br.Msg = "请重新登录"
  1695. br.Ret = 408
  1696. return
  1697. }
  1698. uid := user.UserId
  1699. articleId, _ := this.GetInt("ArticleId")
  1700. if articleId < 0 {
  1701. br.Msg = "参数错误"
  1702. br.ErrMsg = "参数错误"
  1703. return
  1704. }
  1705. resp := new(models.ResearchSummaryLetailResp)
  1706. //判断用户权限
  1707. hasPermission, err := services.GetUserhasPermission(user)
  1708. if err != nil {
  1709. br.Msg = "获取信息失败"
  1710. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1711. }
  1712. resp.HasPermission = hasPermission
  1713. if hasPermission != 1 {
  1714. br.Ret = 200
  1715. br.Success = true
  1716. br.Msg = "获取成功"
  1717. br.Data = resp
  1718. return
  1719. }
  1720. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1721. if err != nil {
  1722. br.Msg = "获取信息失败"
  1723. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1724. return
  1725. }
  1726. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1727. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1728. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1729. if err != nil {
  1730. br.Msg = "获取失败"
  1731. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1732. return
  1733. }
  1734. listArticleType, err := models.GetCygxArticleTypeList()
  1735. if err != nil {
  1736. br.Msg = "获取失败"
  1737. br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
  1738. return
  1739. }
  1740. for k, v := range listFirst {
  1741. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1742. if err != nil && err.Error() != utils.ErrNoRow() {
  1743. br.Msg = "获取信息失败"
  1744. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1745. return
  1746. }
  1747. for k2, v2 := range listSecond {
  1748. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1749. if err != nil && err.Error() != utils.ErrNoRow() {
  1750. br.Msg = "获取信息失败"
  1751. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1752. return
  1753. }
  1754. for _, vType := range listArticleType {
  1755. if v2.ChartPermissionId == vType.YanxPermissionId {
  1756. listSecond[k2].IcoLink = vType.IcoLinkM
  1757. listSecond[k2].PermissionName = vType.YanxPermissionName
  1758. }
  1759. }
  1760. //if v2.ChartPermissionId == utils.YanxSummaryPermissionId {
  1761. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1762. // listSecond[k2].PermissionName = "买方研选纪要"
  1763. //} else if v2.ChartPermissionId == utils.YanxViewpointPermissionId {
  1764. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1765. // listSecond[k2].PermissionName = "买方研选观点"
  1766. //}
  1767. if len(listThird) > 0 {
  1768. for k3, v3 := range listThird {
  1769. if v3.VideoUrl != "" {
  1770. listThird[k3].IsHaveVideo = true
  1771. }
  1772. if v3.ReportLink == "0" {
  1773. listThird[k3].ReportLink = ""
  1774. }
  1775. }
  1776. listSecond[k2].List = listThird
  1777. }
  1778. }
  1779. if len(listSecond) > 0 {
  1780. listFirst[k].List = listSecond
  1781. }
  1782. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1783. if v.Type == "SDBG" {
  1784. listFirst[k].ListName = "深度报告"
  1785. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1786. } else if v.Type == "BZCHJH" {
  1787. listFirst[k].ListName = "本周晨会精华"
  1788. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1789. } else if v.Type == "CYDYJY" {
  1790. listFirst[k].ListName = "产业调研纪要"
  1791. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1792. } else if v.Type == "SSGS" {
  1793. listFirst[k].ListName = "上市公司调研纪要篇"
  1794. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1795. } else if v.Type == "SJDP" {
  1796. listFirst[k].ListName = "事件点评"
  1797. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1798. } else if v.Type == "YANX" {
  1799. listFirst[k].ListName = "买方研选"
  1800. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1801. }
  1802. }
  1803. historyRecord := new(models.CygxReportHistoryRecord)
  1804. historyRecord.UserId = uid
  1805. historyRecord.ArticleId = articleId
  1806. historyRecord.CreateTime = time.Now()
  1807. historyRecord.Mobile = user.Mobile
  1808. historyRecord.Email = user.Email
  1809. historyRecord.CompanyId = user.CompanyId
  1810. historyRecord.CompanyName = user.CompanyName
  1811. historyRecord.ReportType = "bzyjhz"
  1812. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1813. if err != nil && err.Error() != utils.ErrNoRow() {
  1814. br.Msg = "获取信息失败"
  1815. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1816. return
  1817. }
  1818. historyRecord.RealName = user.RealName
  1819. if sellerItem != nil {
  1820. historyRecord.SellerName = sellerItem.RealName
  1821. }
  1822. go models.AddCygxReportHistoryRecord(historyRecord)
  1823. resp.List = listFirst
  1824. resp.Detail = detail
  1825. br.Ret = 200
  1826. br.Success = true
  1827. br.Msg = "获取成功"
  1828. br.Data = resp
  1829. }
  1830. // @Title 上周纪要汇总内容详情
  1831. // @Description 获取上周纪要汇总内容详情接口
  1832. // @Param ArticleId query int true "报告ID"
  1833. // @Success 200 {object} models.MinutesSummaryLetailResp
  1834. // @router /minutesSummary/detailv4 [get]
  1835. func (this *ReportController) MinutesDetailV4() {
  1836. br := new(models.BaseResponse).Init()
  1837. defer func() {
  1838. this.Data["json"] = br
  1839. this.ServeJSON()
  1840. }()
  1841. user := this.User
  1842. if user == nil {
  1843. br.Msg = "请重新登录"
  1844. br.Ret = 408
  1845. return
  1846. }
  1847. uid := user.UserId
  1848. articleId, _ := this.GetInt("ArticleId")
  1849. if articleId < 0 {
  1850. br.Msg = "参数错误"
  1851. br.ErrMsg = "参数错误"
  1852. return
  1853. }
  1854. resp := new(models.MinutesSummaryLetailRespV4)
  1855. //判断用户权限
  1856. hasPermission, err := services.GetUserhasPermission(user)
  1857. if err != nil {
  1858. br.Msg = "获取信息失败"
  1859. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1860. }
  1861. resp.HasPermission = hasPermission
  1862. if hasPermission != 1 {
  1863. br.Ret = 200
  1864. br.Success = true
  1865. br.Msg = "获取成功"
  1866. br.Data = resp
  1867. return
  1868. }
  1869. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1870. if err != nil {
  1871. br.Msg = "获取信息失败"
  1872. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1873. return
  1874. }
  1875. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1876. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1877. listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
  1878. if err != nil {
  1879. br.Msg = "获取失败"
  1880. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1881. return
  1882. }
  1883. for k, v := range listFirst {
  1884. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  1885. if err != nil && err.Error() != utils.ErrNoRow() {
  1886. br.Msg = "获取信息失败"
  1887. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1888. return
  1889. }
  1890. for k2, v2 := range listSecond {
  1891. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  1892. if err != nil && err.Error() != utils.ErrNoRow() {
  1893. br.Msg = "获取信息失败"
  1894. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1895. return
  1896. }
  1897. if len(listThird) > 0 {
  1898. for k3, v3 := range listThird {
  1899. if v3.VideoUrl != "" {
  1900. listThird[k3].IsHaveVideo = true
  1901. }
  1902. if v3.ReportLink == "0" {
  1903. listThird[k3].ReportLink = ""
  1904. }
  1905. }
  1906. listSecond[k2].List = listThird
  1907. }
  1908. }
  1909. if len(listSecond) > 0 {
  1910. listFirst[k].List = listSecond
  1911. }
  1912. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1913. if v.Type == "CYDYJY" {
  1914. listFirst[k].ListName = "产业调研纪要"
  1915. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1916. } else if v.Type == "SSGS" {
  1917. listFirst[k].ListName = "上市公司调研纪要篇"
  1918. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1919. } else if v.Type == "YANX" {
  1920. listFirst[k].ListName = "买方研选纪要"
  1921. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1922. }
  1923. }
  1924. historyRecord := new(models.CygxReportHistoryRecord)
  1925. historyRecord.UserId = uid
  1926. historyRecord.ArticleId = articleId
  1927. historyRecord.CreateTime = time.Now()
  1928. historyRecord.Mobile = user.Mobile
  1929. historyRecord.Email = user.Email
  1930. historyRecord.CompanyId = user.CompanyId
  1931. historyRecord.CompanyName = user.CompanyName
  1932. historyRecord.ReportType = "szjyhz"
  1933. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1934. if err != nil && err.Error() != utils.ErrNoRow() {
  1935. br.Msg = "获取信息失败"
  1936. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1937. return
  1938. }
  1939. historyRecord.RealName = user.RealName
  1940. if sellerItem != nil {
  1941. historyRecord.SellerName = sellerItem.RealName
  1942. }
  1943. go models.AddCygxReportHistoryRecord(historyRecord)
  1944. resp.List = listFirst
  1945. resp.Detail = detail
  1946. br.Ret = 200
  1947. br.Success = true
  1948. br.Msg = "获取成功"
  1949. br.Data = resp
  1950. }
  1951. // @Title 上周纪要汇总内容详情
  1952. // @Description 获取上周纪要汇总内容详情接口
  1953. // @Param ArticleId query int true "报告ID"
  1954. // @Success 200 {object} models.MinutesSummaryLetailResp
  1955. // @router /minutesSummary/detail [get]
  1956. func (this *ReportController) MinutesDetail() {
  1957. br := new(models.BaseResponse).Init()
  1958. defer func() {
  1959. this.Data["json"] = br
  1960. this.ServeJSON()
  1961. }()
  1962. user := this.User
  1963. if user == nil {
  1964. br.Msg = "请重新登录"
  1965. br.Ret = 408
  1966. return
  1967. }
  1968. uid := user.UserId
  1969. articleId, _ := this.GetInt("ArticleId")
  1970. if articleId < 0 {
  1971. br.Msg = "参数错误"
  1972. br.ErrMsg = "参数错误"
  1973. return
  1974. }
  1975. resp := new(models.MinutesSummaryLetailResp)
  1976. //判断用户权限
  1977. hasPermission, err := services.GetUserhasPermission(user)
  1978. if err != nil {
  1979. br.Msg = "获取信息失败"
  1980. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1981. }
  1982. resp.HasPermission = hasPermission
  1983. if hasPermission != 1 {
  1984. br.Ret = 200
  1985. br.Success = true
  1986. br.Msg = "获取成功"
  1987. br.Data = resp
  1988. return
  1989. }
  1990. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1991. if err != nil {
  1992. br.Msg = "获取信息失败"
  1993. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1994. return
  1995. }
  1996. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1997. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1998. listLog, err := models.GetMinutesSummarylogListAll(articleId)
  1999. if err != nil {
  2000. br.Msg = "获取失败"
  2001. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  2002. return
  2003. }
  2004. for k, v := range listLog {
  2005. listSonLog, err := models.GetMinutesSummarylogSonListAll(articleId, v.ChartPermissionId)
  2006. if err != nil && err.Error() != utils.ErrNoRow() {
  2007. br.Msg = "获取信息失败"
  2008. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2009. return
  2010. }
  2011. if len(listSonLog) > 0 {
  2012. listLog[k].List = listSonLog
  2013. for k2, v2 := range listSonLog {
  2014. if v2.ReportLink == "0" {
  2015. listSonLog[k2].ReportLink = ""
  2016. }
  2017. }
  2018. }
  2019. }
  2020. historyRecord := new(models.CygxReportHistoryRecord)
  2021. historyRecord.UserId = uid
  2022. historyRecord.ArticleId = articleId
  2023. historyRecord.CreateTime = time.Now()
  2024. historyRecord.Mobile = user.Mobile
  2025. historyRecord.Email = user.Email
  2026. historyRecord.CompanyId = user.CompanyId
  2027. historyRecord.CompanyName = user.CompanyName
  2028. historyRecord.ReportType = "szjyhz"
  2029. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  2030. if err != nil && err.Error() != utils.ErrNoRow() {
  2031. br.Msg = "获取信息失败"
  2032. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  2033. return
  2034. }
  2035. historyRecord.RealName = user.RealName
  2036. if sellerItem != nil {
  2037. historyRecord.SellerName = sellerItem.RealName
  2038. }
  2039. go models.AddCygxReportHistoryRecord(historyRecord)
  2040. resp.List = listLog
  2041. resp.Detail = detail
  2042. br.Ret = 200
  2043. br.Success = true
  2044. br.Msg = "获取成功"
  2045. br.Data = resp
  2046. }
  2047. // @Title 获取路演精华详情
  2048. // @Description 获取路演精华详情接口
  2049. // @Param ArticleId query int true "报告ID"
  2050. // @Success 200 {object} models.RoadshowDetailResp
  2051. // @router /roadshowEssence/detail [get]
  2052. func (this *ReportController) RoadshowDetail() {
  2053. br := new(models.BaseResponse).Init()
  2054. defer func() {
  2055. this.Data["json"] = br
  2056. this.ServeJSON()
  2057. }()
  2058. user := this.User
  2059. if user == nil {
  2060. br.Msg = "请登录"
  2061. br.ErrMsg = "请登录,用户信息为空"
  2062. br.Ret = 408
  2063. return
  2064. }
  2065. uid := user.UserId
  2066. articleId, err := this.GetInt("ArticleId")
  2067. if articleId <= 0 {
  2068. br.Msg = "文章不存在"
  2069. br.ErrMsg = "文章不存在,文章ID错误"
  2070. return
  2071. }
  2072. detail := new(models.ReportDetailRoadshow)
  2073. hasPermission := 0
  2074. hasFree := 0
  2075. //判断是否已经申请过
  2076. applyCount, err := models.GetApplyRecordCount(uid)
  2077. if err != nil && err.Error() != utils.ErrNoRow() {
  2078. br.Msg = "获取信息失败"
  2079. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2080. return
  2081. }
  2082. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  2083. if user.CompanyId > 1 {
  2084. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  2085. if err != nil {
  2086. br.Msg = "获取信息失败"
  2087. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  2088. return
  2089. }
  2090. detail, err = models.GetReportRoadshowDetailById(articleId)
  2091. if err != nil {
  2092. br.Msg = "获取信息失败"
  2093. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2094. return
  2095. }
  2096. detail.Body = html.UnescapeString(detail.Body)
  2097. detail.Abstract, _ = services.GetReportContentTextSubNew(detail.Abstract)
  2098. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  2099. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  2100. if detail.ReportLink == "0" {
  2101. detail.ReportLink = ""
  2102. }
  2103. if companyPermission == "" {
  2104. if applyCount > 0 {
  2105. hasPermission = 5
  2106. } else {
  2107. hasPermission = 2
  2108. }
  2109. hasFree = 2
  2110. goto Loop
  2111. } else {
  2112. hasFree = 1
  2113. var articlePermissionPermissionName string
  2114. articlePermissionPermissionName = detail.CategoryName
  2115. var hasPersion bool
  2116. slice := strings.Split(articlePermissionPermissionName, ",")
  2117. for _, v := range slice {
  2118. if strings.Contains(companyPermission, v) {
  2119. hasPersion = true
  2120. }
  2121. }
  2122. if hasPersion {
  2123. hasPermission = 1
  2124. historyRecord := new(models.CygxArticleHistoryRecord)
  2125. historyRecord.UserId = uid
  2126. historyRecord.ArticleId = articleId
  2127. historyRecord.CreateTime = time.Now()
  2128. historyRecord.Mobile = user.Mobile
  2129. historyRecord.Email = user.Email
  2130. historyRecord.CompanyId = user.CompanyId
  2131. historyRecord.CompanyName = user.CompanyName
  2132. go models.AddCygxArticleHistoryRecord(historyRecord)
  2133. } else { //无该行业权限
  2134. hasPermission = 3
  2135. }
  2136. if hasPermission == 1 {
  2137. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  2138. if !utils.Rc.IsExist(key) {
  2139. //新增浏览记录
  2140. record := new(models.CygxArticleViewRecord)
  2141. record.UserId = uid
  2142. record.ArticleId = articleId
  2143. record.CreateTime = time.Now()
  2144. record.Mobile = user.Mobile
  2145. record.Email = user.Email
  2146. record.CompanyId = user.CompanyId
  2147. record.CompanyName = user.CompanyName
  2148. go models.AddCygxArticleViewRecord(record)
  2149. utils.Rc.Put(key, 1, 5*time.Second)
  2150. models.ModifyReportLastViewTime(uid)
  2151. }
  2152. }
  2153. }
  2154. } else { //潜在客户
  2155. if applyCount > 0 {
  2156. hasPermission = 5
  2157. } else {
  2158. hasPermission = 4
  2159. }
  2160. }
  2161. Loop:
  2162. if hasPermission != 1 {
  2163. detail.Body = ""
  2164. detail.Abstract = ""
  2165. }
  2166. resp := new(models.RoadshowDetailResp)
  2167. resp.HasPermission = hasPermission
  2168. resp.HasFree = hasFree
  2169. resp.Detail = detail
  2170. br.Ret = 200
  2171. br.Success = true
  2172. br.Msg = "获取成功"
  2173. br.Data = resp
  2174. }
  2175. // @Title 产业文章列表接口
  2176. // @Description 获取产业文章列表接口
  2177. // @Param KeyWord query string true "搜索关键词"
  2178. // @Success 200 {object} models.CygxIndustrySearchList
  2179. // @router /industryAndArticle/list [get]
  2180. func (this *ReportController) IndustryAndArticleList() {
  2181. br := new(models.BaseResponse).Init()
  2182. defer func() {
  2183. this.Data["json"] = br
  2184. this.ServeJSON()
  2185. }()
  2186. user := this.User
  2187. if user == nil {
  2188. br.Msg = "请重新登录"
  2189. br.Ret = 408
  2190. return
  2191. }
  2192. uid := user.UserId
  2193. keyWord := this.GetString("KeyWord")
  2194. orderSrt := "update_time DESC"
  2195. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  2196. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  2197. if err != nil {
  2198. br.Msg = "获取信息失败"
  2199. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2200. return
  2201. }
  2202. for k, v := range list {
  2203. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  2204. if err != nil {
  2205. br.Msg = "获取信息失败"
  2206. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2207. return
  2208. }
  2209. list[k].IndustrialSubjectList = industrialSubjectList
  2210. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  2211. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  2212. if err != nil {
  2213. br.Msg = "获取信息失败"
  2214. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2215. return
  2216. }
  2217. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  2218. }
  2219. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  2220. if err != nil {
  2221. br.Msg = "获取失败"
  2222. br.ErrMsg = "获取失败,Err:" + err.Error()
  2223. return
  2224. }
  2225. for k2, v2 := range artList {
  2226. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  2227. if err != nil {
  2228. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  2229. br.ErrMsg = "获取失败,Err:" + err.Error()
  2230. return
  2231. }
  2232. var subjectNamesNew string
  2233. if len(subjectNames) > 0 {
  2234. slice := strings.Split(subjectNames, "/")
  2235. for k3, v3 := range slice {
  2236. if k3 < 4 {
  2237. subjectNamesNew += v3 + "/"
  2238. }
  2239. }
  2240. }
  2241. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  2242. if err != nil && err.Error() != utils.ErrNoRow() {
  2243. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  2244. br.ErrMsg = "获取失败,Err:" + err.Error()
  2245. return
  2246. }
  2247. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  2248. artList[k2].SubjectName = subjectNamesNew
  2249. if subjectNamesNew == "" {
  2250. artList[k2].IndustryName = industryName
  2251. } else {
  2252. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  2253. }
  2254. }
  2255. if keyWord != "" {
  2256. keyWordItem := new(models.CygxUserSearchKeyWord)
  2257. keyWordItem.UserId = user.UserId
  2258. keyWordItem.KeyWord = keyWord
  2259. keyWordItem.PageType = "ReortSearch"
  2260. keyWordItem.CreateTime = time.Now()
  2261. go models.AddUserSearchKeyWord(keyWordItem)
  2262. }
  2263. resp := new(models.CygxIndustrySearchList)
  2264. resp.ArtList = artList
  2265. resp.IndList = list
  2266. br.Ret = 200
  2267. br.Success = true
  2268. br.Msg = "获取成功"
  2269. br.Data = resp
  2270. }
  2271. // @Title 产业报告分类关联作者列表接口Pc端
  2272. // @Description 获取产业报告分类关联作者列表接口Pc端
  2273. // @Param ChartPermissionId query int true "分类ID"
  2274. // @Param KeyWord query string true "搜索关键词"
  2275. // @Param PageSize query int true "每页数据条数"
  2276. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2277. // @Success 200 {object} models.CygxArticleDepartmentListPc
  2278. // @router /industryListByDepartmentPc [get]
  2279. func (this *ReportController) IndustryListByDepartmentPc() {
  2280. br := new(models.BaseResponse).Init()
  2281. defer func() {
  2282. this.Data["json"] = br
  2283. this.ServeJSON()
  2284. }()
  2285. user := this.User
  2286. if user == nil {
  2287. br.Msg = "请重新登录"
  2288. br.Ret = 408
  2289. return
  2290. }
  2291. uid := user.UserId
  2292. pageSize, _ := this.GetInt("PageSize")
  2293. currentIndex, _ := this.GetInt("CurrentIndex")
  2294. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  2295. keyWord := this.GetString("KeyWord")
  2296. var startSize int
  2297. var condition string
  2298. condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  2299. if pageSize <= 0 {
  2300. pageSize = utils.PageSize20
  2301. }
  2302. if currentIndex <= 0 {
  2303. currentIndex = 1
  2304. }
  2305. var articleIdGroup string
  2306. if keyWord != "" {
  2307. //获取标的关联的文章ID
  2308. articleIdSub, err := models.GetArticleIdSubjectGroup(keyWord)
  2309. if err != nil {
  2310. br.Msg = "获取信息失败"
  2311. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2312. return
  2313. }
  2314. //获取产业关联的标的
  2315. articleIdInd, err := models.GetArticleIndustrialIdGroup(keyWord)
  2316. if err != nil {
  2317. br.Msg = "获取信息失败"
  2318. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  2319. return
  2320. }
  2321. if articleIdSub != "" && articleIdInd != "" {
  2322. articleIdGroup = articleIdSub + "," + articleIdInd
  2323. } else if articleIdSub != "" && articleIdInd == "" {
  2324. articleIdGroup = articleIdSub
  2325. } else if articleIdSub == "" && articleIdInd != "" {
  2326. articleIdGroup = articleIdInd
  2327. }
  2328. slice := strings.Split(keyWord, "/")
  2329. if len(slice) > 1 {
  2330. var subjectIds string
  2331. for _, v := range slice {
  2332. subjectId, err := models.GetcygxIndustrialSubjectByName(v)
  2333. if err != nil && err.Error() != utils.ErrNoRow() {
  2334. br.Msg = "获取信息失败"
  2335. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  2336. return
  2337. }
  2338. if subjectId != "" {
  2339. subjectIds += subjectId + ","
  2340. }
  2341. }
  2342. subjectIds = strings.TrimRight(subjectIds, ",")
  2343. if len(subjectIds) > 0 {
  2344. articleBySub, err := models.GetArticleIdsBySubId(subjectIds)
  2345. if err != nil {
  2346. br.Msg = "获取信息失败"
  2347. br.ErrMsg = "获取文章关联的标的失败,Err:" + err.Error()
  2348. return
  2349. }
  2350. if articleIdGroup != "" {
  2351. if articleBySub != "" {
  2352. articleIdGroup += "," + articleBySub
  2353. }
  2354. } else {
  2355. articleIdGroup = articleBySub
  2356. }
  2357. }
  2358. }
  2359. }
  2360. if articleIdGroup != "" {
  2361. condition += ` AND a.article_id IN (` + articleIdGroup + `)`
  2362. }
  2363. startSize = paging.StartIndex(currentIndex, pageSize)
  2364. total, err := models.GetArticleDepartmentCount(condition)
  2365. page := paging.GetPaging(currentIndex, pageSize, total)
  2366. resp := new(models.CygxArticleDepartmentListPc)
  2367. userType, _, err := services.GetUserType(user.CompanyId)
  2368. if err != nil {
  2369. br.Msg = "获取信息失败"
  2370. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  2371. return
  2372. }
  2373. if userType == 1 {
  2374. resp.Paging = page
  2375. br.Ret = 200
  2376. br.Success = true
  2377. br.Msg = "获取成功"
  2378. br.Data = resp
  2379. return
  2380. }
  2381. resp.HaveResearch = true
  2382. //获取作者信息,并排序
  2383. list, err := models.GetCygxArticleDepartmentListPc(startSize, pageSize, condition, uid)
  2384. if err != nil {
  2385. br.Msg = "获取信息失败"
  2386. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2387. return
  2388. }
  2389. for k, v := range list {
  2390. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIdGroup)
  2391. if err != nil {
  2392. br.Msg = "获取信息失败"
  2393. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2394. return
  2395. }
  2396. for k2, v2 := range artList {
  2397. if artList[k2].IsReport == "1" {
  2398. artList[k2].Title = v2.Title
  2399. } else {
  2400. artList[k2].Title = v2.Title
  2401. }
  2402. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2403. }
  2404. list[k].List = artList
  2405. if v.FollowNum > 0 {
  2406. list[k].IsMyFollow = true
  2407. }
  2408. }
  2409. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  2410. if err != nil {
  2411. br.Msg = "获取信息失败"
  2412. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2413. return
  2414. }
  2415. if len(listnNew) > 0 {
  2416. for _, v := range listnNew {
  2417. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  2418. Management := new(models.IndustrialManagementIdInt)
  2419. if firstStr == 0 {
  2420. Management.IndustryName = v.IndustryName
  2421. } else {
  2422. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  2423. if err != nil {
  2424. br.Msg = "获取信息失败"
  2425. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  2426. return
  2427. }
  2428. var subjectNamesNew string
  2429. for _, v1 := range listSub {
  2430. subjectNamesNew += v1.SubjectName + "/"
  2431. }
  2432. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  2433. Management.IndustryName = subjectNamesNew
  2434. }
  2435. Management.IndustrialManagementId = v.IndustrialManagementId
  2436. Management.ArticleId = v.ArticleId
  2437. resp.ListnNew = append(resp.ListnNew, Management)
  2438. }
  2439. }
  2440. resp.List = list
  2441. resp.Paging = page
  2442. br.Ret = 200
  2443. br.Success = true
  2444. br.Msg = "获取成功"
  2445. br.Data = resp
  2446. }
  2447. // @Title 产业文章列表接口Pc端
  2448. // @Description 获取产业文章列表接口Pc端
  2449. // @Param KeyWord query string true "搜索关键词"
  2450. // @Success 200 {object} models.CygxIndustrySearchListPc
  2451. // @router /industryAndArticle/listPc [get]
  2452. func (this *ReportController) IndustryAndArticleListPc() {
  2453. br := new(models.BaseResponse).Init()
  2454. defer func() {
  2455. this.Data["json"] = br
  2456. this.ServeJSON()
  2457. }()
  2458. user := this.User
  2459. if user == nil {
  2460. br.Msg = "请重新登录"
  2461. br.Ret = 408
  2462. return
  2463. }
  2464. uid := user.UserId
  2465. keyWord := this.GetString("KeyWord")
  2466. resp := new(models.CygxIndustrySearchListPc)
  2467. orderSrt := "update_time DESC"
  2468. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  2469. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  2470. if err != nil {
  2471. br.Msg = "获取信息失败"
  2472. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2473. return
  2474. }
  2475. for k, v := range list {
  2476. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  2477. if err != nil {
  2478. br.Msg = "获取信息失败"
  2479. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2480. return
  2481. }
  2482. list[k].IndustrialSubjectList = industrialSubjectList
  2483. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  2484. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  2485. if err != nil {
  2486. br.Msg = "获取信息失败"
  2487. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2488. return
  2489. }
  2490. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  2491. }
  2492. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  2493. if err != nil {
  2494. br.Msg = "获取失败"
  2495. br.ErrMsg = "获取失败,Err:" + err.Error()
  2496. return
  2497. }
  2498. if len(artList) > 0 {
  2499. var articleIds string
  2500. for _, v := range artList {
  2501. articleIds += strconv.Itoa(v.ArticleId) + ","
  2502. }
  2503. articleIds = strings.TrimRight(articleIds, ",")
  2504. if articleIds != "" {
  2505. condition = ` AND a.article_id IN (` + articleIds + `)`
  2506. DepartmentList, err := models.GetCygxArticleDepartmentListPc(0, 20, condition, uid)
  2507. if err != nil {
  2508. br.Msg = "获取信息失败"
  2509. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2510. return
  2511. }
  2512. for k, v := range DepartmentList {
  2513. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIds)
  2514. if err != nil {
  2515. br.Msg = "获取信息失败"
  2516. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2517. return
  2518. }
  2519. for k2, v2 := range artList {
  2520. if artList[k2].IsReport == "1" {
  2521. artList[k2].Title = v2.Title
  2522. } else {
  2523. artList[k2].Title = v2.Title
  2524. }
  2525. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2526. }
  2527. DepartmentList[k].List = artList
  2528. if v.FollowNum > 0 {
  2529. DepartmentList[k].IsMyFollow = true
  2530. }
  2531. }
  2532. resp.DepartmentList = DepartmentList
  2533. }
  2534. }
  2535. if keyWord != "" {
  2536. keyWordItem := new(models.CygxUserSearchKeyWord)
  2537. keyWordItem.UserId = user.UserId
  2538. keyWordItem.KeyWord = keyWord
  2539. keyWordItem.PageType = "ReortSearch"
  2540. keyWordItem.CreateTime = time.Now()
  2541. go models.AddUserSearchKeyWord(keyWordItem)
  2542. }
  2543. resp.IndList = list
  2544. br.Ret = 200
  2545. br.Success = true
  2546. br.Msg = "获取成功"
  2547. br.Data = resp
  2548. }
  2549. // @Title 报告搜索
  2550. // @Description 报告搜索接口
  2551. // @Param KeyWord query string true "搜索关键词"
  2552. // @Success 200 {object} models.ReoprtSearchResp
  2553. // @router /searchReport [get]
  2554. func (this *ReportController) SearchReport() {
  2555. br := new(models.BaseResponse).Init()
  2556. defer func() {
  2557. this.Data["json"] = br
  2558. this.ServeJSON()
  2559. }()
  2560. user := this.User
  2561. if user == nil {
  2562. br.Msg = "请重新登录"
  2563. br.Ret = 408
  2564. return
  2565. }
  2566. keyWord := this.GetString("KeyWord")
  2567. var condition string
  2568. var sqlGroup string
  2569. //匹配报告标题、
  2570. 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 `
  2571. sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2572. //对应产业名称、标的名称。
  2573. listYx, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
  2574. if err != nil {
  2575. br.Msg = "获取信息失败"
  2576. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2577. return
  2578. }
  2579. for k, v := range listYx {
  2580. listYx[k].Source = 2
  2581. if v.MyCollectNum > 0 {
  2582. listYx[k].IsCollect = true
  2583. }
  2584. }
  2585. listHz, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition+` OR ( article_type = 'lyjh' `+condition+` ) `+sqlGroup, user.UserId)
  2586. if err != nil {
  2587. br.Msg = "获取信息失败"
  2588. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2589. return
  2590. }
  2591. for k, v := range listHz {
  2592. listHz[k].Source = 1
  2593. if v.MyCollectNum > 0 {
  2594. listHz[k].IsCollect = true
  2595. }
  2596. }
  2597. if keyWord != "" {
  2598. keyWordItem := new(models.CygxUserSearchKeyWord)
  2599. keyWordItem.UserId = user.UserId
  2600. keyWordItem.KeyWord = keyWord
  2601. keyWordItem.PageType = "ReortSearch"
  2602. keyWordItem.CreateTime = time.Now()
  2603. go models.AddUserSearchKeyWord(keyWordItem)
  2604. //go services.AddUserSearchLog(user, keyWord, 5)
  2605. }
  2606. if len(listYx) == 0 {
  2607. listYx = make([]*models.ArticleCollectionResp, 0)
  2608. }
  2609. if len(listHz) == 0 {
  2610. listHz = make([]*models.ArticleCollectionResp, 0)
  2611. }
  2612. resp := new(models.ReoprtSearchResp)
  2613. resp.ListYx = listYx
  2614. resp.ListHz = listHz
  2615. br.Ret = 200
  2616. br.Success = true
  2617. br.Msg = "获取成功"
  2618. br.Data = resp
  2619. }
  2620. // @Title 资源包搜索
  2621. // @Description 资源包搜索接口
  2622. // @Param KeyWord query string true "搜索关键词"
  2623. // @Success 200 {object} models.SearchResourceResp
  2624. // @router /searchResource [get]
  2625. func (this *ReportController) SearchResource() {
  2626. br := new(models.BaseResponse).Init()
  2627. defer func() {
  2628. this.Data["json"] = br
  2629. this.ServeJSON()
  2630. }()
  2631. user := this.User
  2632. if user == nil {
  2633. br.Msg = "请重新登录"
  2634. br.Ret = 408
  2635. return
  2636. }
  2637. uid := user.UserId
  2638. fllowList, err := models.GetUserFllowIndustrialList(uid)
  2639. if err != nil {
  2640. br.Msg = "获取失败"
  2641. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  2642. return
  2643. }
  2644. fllowMap := make(map[int]int)
  2645. if len(fllowList) > 0 {
  2646. for _, v := range fllowList {
  2647. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  2648. }
  2649. }
  2650. keyWord := this.GetString("KeyWord")
  2651. var condition string
  2652. var conditionOr string
  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. listHz, 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. //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2663. conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2664. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2665. listYx, err := models.GetSearchResourceList(user.UserId, condition, 0, 0)
  2666. if err != nil {
  2667. br.Msg = "获取信息失败"
  2668. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2669. return
  2670. }
  2671. //合并产业关联的标的
  2672. listSubjcet, err := models.GetThemeHeatSubjectList("")
  2673. if err != nil {
  2674. br.Msg = "获取信息失败"
  2675. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2676. return
  2677. }
  2678. industrialIdArr := make([]int, 0)
  2679. for k, v := range listHz {
  2680. listHz[k].Source = 1
  2681. if fllowMap[v.IndustrialManagementId] > 0 {
  2682. listHz[k].IsFollw = true
  2683. }
  2684. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2685. }
  2686. for k, v := range listYx {
  2687. listYx[k].Source = 2
  2688. if fllowMap[v.IndustrialManagementId] > 0 {
  2689. listYx[k].IsFollw = true
  2690. }
  2691. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2692. }
  2693. if len(industrialIdArr) > 0 {
  2694. //合并产业关联的标的
  2695. listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  2696. if err != nil {
  2697. br.Msg = "获取信息失败"
  2698. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2699. return
  2700. }
  2701. mapIndustrial := make(map[string]int)
  2702. for _, v := range listSubjcet {
  2703. for k2, v2 := range listYx {
  2704. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 {
  2705. listYx[k2].IndustrialSubjectList = append(listYx[k2].IndustrialSubjectList, v)
  2706. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  2707. }
  2708. }
  2709. for k2, v2 := range listHz {
  2710. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  2711. listHz[k2].IndustrialSubjectList = append(listHz[k2].IndustrialSubjectList, v)
  2712. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  2713. }
  2714. }
  2715. }
  2716. }
  2717. if keyWord != "" {
  2718. keyWordItem := new(models.CygxUserSearchKeyWord)
  2719. keyWordItem.UserId = user.UserId
  2720. keyWordItem.KeyWord = keyWord
  2721. keyWordItem.PageType = "ReortSearch"
  2722. keyWordItem.CreateTime = time.Now()
  2723. go models.AddUserSearchKeyWord(keyWordItem)
  2724. }
  2725. resp := new(models.SearchResourceResp)
  2726. if len(listYx) == 0 {
  2727. listYx = make([]*models.IndustrialManagementHotResp, 0)
  2728. }
  2729. if len(listHz) == 0 {
  2730. listHz = make([]*models.IndustrialManagementHotResp, 0)
  2731. }
  2732. resp.ListYx = listYx
  2733. resp.ListHz = listHz
  2734. br.Ret = 200
  2735. br.Success = true
  2736. br.Msg = "获取成功"
  2737. br.Data = resp
  2738. }
  2739. // @Title 报告搜索、资源包搜索接口
  2740. // @Description 报告搜索、资源包搜索接口接口
  2741. // @Param KeyWord query string true "搜索关键词"
  2742. // @Param PageSize query int true "每页数据条数"
  2743. // @Success 200 {object} models.SearchReportAndResourceResp
  2744. // @router /searchReportAndResource [get]
  2745. func (this *ReportController) SearchReportAndResource() {
  2746. br := new(models.BaseResponse).Init()
  2747. defer func() {
  2748. this.Data["json"] = br
  2749. this.ServeJSON()
  2750. }()
  2751. user := this.User
  2752. if user == nil {
  2753. br.Msg = "请重新登录"
  2754. br.Ret = 408
  2755. return
  2756. }
  2757. uid := user.UserId
  2758. keyWord := this.GetString("KeyWord")
  2759. pageSize, _ := this.GetInt("PageSize")
  2760. var condition string
  2761. var sqlGroup string
  2762. articleTypeIds, err := services.GetYanXuanArticleTypeIds()
  2763. if err != nil {
  2764. br.Msg = "获取信息失败"
  2765. br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
  2766. return
  2767. }
  2768. if articleTypeIds == "" {
  2769. br.Msg = "获取信息失败"
  2770. br.ErrMsg = "研选分类ID不能为空"
  2771. return
  2772. }
  2773. //匹配报告标题、
  2774. 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 `
  2775. sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2776. if pageSize > 0 {
  2777. sqlGroup += ` LIMIT 5 `
  2778. } else {
  2779. sqlGroup += ` LIMIT 100 `
  2780. }
  2781. ListYxReport, err := models.GetArticleCollectionList(` AND a.article_type_id IN (`+articleTypeIds+`) `+condition+sqlGroup, user.UserId)
  2782. if err != nil {
  2783. br.Msg = "获取信息失败"
  2784. br.ErrMsg = "获取研选文章列表失败,Err:" + err.Error()
  2785. return
  2786. }
  2787. ListHzReport, err := models.GetReoprtSearchList(` AND a.article_type_id NOT IN (`+articleTypeIds+`) `+condition+sqlGroup, user.UserId)
  2788. if err != nil {
  2789. br.Msg = "获取信息失败"
  2790. br.ErrMsg = "获取弘则报告文章列表失败,Err:" + err.Error()
  2791. return
  2792. }
  2793. keyWordArr, err := services.GetIndustryMapNameSliceV3(keyWord)
  2794. if err != nil {
  2795. br.Msg = "获取失败"
  2796. br.ErrMsg = "获取分词失败,GetIndustryMapNameSliceV3 Err: " + err.Error()
  2797. return
  2798. }
  2799. keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
  2800. var keyWordIk string
  2801. if len(keyWordArr) > 1 {
  2802. keyWordIk = services.KeyWordArrSqlRegexp(keyWordArr)
  2803. var conditionIk string
  2804. var sqlGroupIk string
  2805. conditionIk = `AND ( a.title REGEXP '` + keyWordIk + `' OR a.annotation REGEXP '` + keyWordIk + `' OR a.abstract REGEXP '` + keyWordIk + `') AND a.publish_status = 1 `
  2806. sqlGroupIk = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2807. if pageSize > 0 {
  2808. sqlGroupIk += ` LIMIT 5 `
  2809. } else {
  2810. sqlGroupIk += ` LIMIT 20 `
  2811. }
  2812. conditionIk += ` AND ( a.title NOT LIKE '%` + keyWord + `%' AND a.body NOT LIKE '%` + keyWord + `%' AND a.annotation NOT LIKE '%` + keyWord + `%' AND a.abstract NOT LIKE '%` + keyWord + `%') `
  2813. //研选的联想词列表
  2814. ListYxReportIk, err := models.GetArticleCollectionList(` AND a.article_type_id IN (`+articleTypeIds+`) `+conditionIk+sqlGroupIk, user.UserId)
  2815. if err != nil && err.Error() != utils.ErrNoRow() {
  2816. br.Msg = "获取信息失败"
  2817. br.ErrMsg = "获取研选IK文章列表失败,Err:" + err.Error()
  2818. return
  2819. }
  2820. if len(ListYxReportIk) > 0 {
  2821. for _, v := range ListYxReportIk {
  2822. ListYxReport = append(ListYxReport, v)
  2823. }
  2824. }
  2825. //弘则的联想词列表
  2826. ListHzReportIk, err := models.GetReoprtSearchList(` AND a.article_type_id NOT IN (`+articleTypeIds+`) `+conditionIk+sqlGroupIk, user.UserId)
  2827. if err != nil && err.Error() != utils.ErrNoRow() {
  2828. br.Msg = "获取信息失败"
  2829. br.ErrMsg = "获取研选IK文章列表失败,Err:" + err.Error()
  2830. return
  2831. }
  2832. if len(ListHzReportIk) > 0 {
  2833. for _, v := range ListHzReportIk {
  2834. ListHzReport = append(ListHzReport, v)
  2835. }
  2836. }
  2837. }
  2838. for k, v := range ListHzReport {
  2839. ListHzReport[k].Source = 1
  2840. if v.MyCollectNum > 0 {
  2841. ListHzReport[k].IsCollect = true
  2842. }
  2843. }
  2844. for k, v := range ListYxReport {
  2845. ListYxReport[k].Source = 2
  2846. if v.MyCollectNum > 0 {
  2847. ListYxReport[k].IsCollect = true
  2848. }
  2849. }
  2850. var articleIds string
  2851. for _, v := range ListHzReport {
  2852. articleIds += strconv.Itoa(v.ArticleId) + ","
  2853. }
  2854. for _, v := range ListYxReport {
  2855. articleIds += strconv.Itoa(v.ArticleId) + ","
  2856. }
  2857. articleIds = strings.TrimRight(articleIds, ",")
  2858. silcearticleIds := strings.Split(articleIds, ",")
  2859. var parsindustrial []interface{}
  2860. parsindustrial = make([]interface{}, 0)
  2861. articleIdList := make([]string, 0)
  2862. for _, v := range silcearticleIds {
  2863. articleIdList = append(articleIdList, v)
  2864. }
  2865. conditionindustrial := ` AND mg.article_id IN ( ` + utils.GetOrmInReplace(len(silcearticleIds)) + ` ) `
  2866. parsindustrial = append(parsindustrial, articleIdList)
  2867. industrialList, err := models.GetIndustrialListByarticleId(parsindustrial, conditionindustrial)
  2868. if err != nil {
  2869. return
  2870. }
  2871. industrialMap := make(map[int][]*models.IndustrialManagementResp)
  2872. if len(industrialList) > 0 {
  2873. for _, v := range industrialList {
  2874. item := new(models.IndustrialManagementResp)
  2875. //item.ArticleId = v.ArticleId
  2876. item.IndustrialManagementId = v.IndustrialManagementId
  2877. item.IndustryName = v.IndustryName
  2878. item.ChartPermissionId = v.ChartPermissionId
  2879. industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
  2880. }
  2881. }
  2882. for k, v := range ListHzReport {
  2883. if len(industrialMap[v.ArticleId]) > 0 {
  2884. ListHzReport[k].List = industrialMap[v.ArticleId]
  2885. } else {
  2886. ListHzReport[k].List = make([]*models.IndustrialManagementResp, 0)
  2887. }
  2888. }
  2889. for k, v := range ListYxReport {
  2890. if len(industrialMap[v.ArticleId]) > 0 {
  2891. ListYxReport[k].List = industrialMap[v.ArticleId]
  2892. } else {
  2893. ListYxReport[k].List = make([]*models.IndustrialManagementResp, 0)
  2894. }
  2895. }
  2896. //获取文章关联的产业
  2897. if len(ListYxReport) == 0 {
  2898. ListYxReport = make([]*models.ArticleCollectionResp, 0)
  2899. }
  2900. if len(ListHzReport) == 0 {
  2901. ListHzReport = make([]*models.ArticleCollectionResp, 0)
  2902. }
  2903. fllowList, err := models.GetUserFllowIndustrialList(uid)
  2904. if err != nil {
  2905. br.Msg = "获取失败"
  2906. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  2907. return
  2908. }
  2909. fllowMap := make(map[int]int)
  2910. if len(fllowList) > 0 {
  2911. for _, v := range fllowList {
  2912. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  2913. }
  2914. }
  2915. condition = ` AND a.publish_status = 1 AND a.article_type_id NOT IN (` + articleTypeIds + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
  2916. listHzResource, err := models.GetSearchResourceList(user.UserId, condition, 0, pageSize)
  2917. if err != nil {
  2918. br.Msg = "获取信息失败"
  2919. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2920. return
  2921. }
  2922. condition = ` AND a.publish_status = 1 AND a.article_type_id IN (` + articleTypeIds + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
  2923. hotMapindustrial, e := services.IndustrialManagementHotMapGropuPermission()
  2924. if e != nil {
  2925. br.Msg = "获取信息失败"
  2926. br.ErrMsg = "获取hot标签失败,IndustrialManagementHotMapGropuPermission ,Err:" + err.Error()
  2927. return
  2928. }
  2929. listYxResource, err := models.GetSearchResourceList(user.UserId, condition, 0, pageSize)
  2930. if err != nil {
  2931. br.Msg = "获取信息失败"
  2932. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2933. return
  2934. }
  2935. //合并产业关联的标的
  2936. listSubjcet, err := models.GetThemeHeatSubjectList("")
  2937. if err != nil {
  2938. br.Msg = "获取信息失败"
  2939. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2940. return
  2941. }
  2942. industrialIdArr := make([]int, 0)
  2943. nowTime := time.Now().Local()
  2944. threeMonBefore := nowTime.AddDate(0, -3, 0)
  2945. mapHot := make(map[int]bool)
  2946. //if themeType == 2 {
  2947. mapHot, err = services.GetYanXuanIndustrialManagementIdHotMap(articleTypeIds)
  2948. if err != nil {
  2949. br.Msg = "获取信息失败"
  2950. br.ErrMsg = "GetYanXuanIndustrialManagementIdNewMap,Err:" + err.Error()
  2951. return
  2952. }
  2953. //conditionOrder := ` ORDER BY sum_num DESC `
  2954. //listHot, err := models.GetThemeHeatList(user.UserId, condition, conditionOrder, 0, 3)
  2955. //if err != nil {
  2956. // br.Msg = "获取信息失败"
  2957. // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2958. // return
  2959. //}
  2960. for k, _ := range mapHot {
  2961. industrialIdArr = append(industrialIdArr, k)
  2962. }
  2963. orderSrt := "man.recommended_index DESC,update_time DESC"
  2964. for k, v := range listHzResource {
  2965. // 关联报告发布时间均在3个月内则标记New
  2966. if v.MinReportTime != "" {
  2967. t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
  2968. if e != nil {
  2969. err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
  2970. return
  2971. }
  2972. if t.After(threeMonBefore) {
  2973. listHzResource[k].IsNew = true
  2974. }
  2975. }
  2976. //弘则资源包不展示hot标签
  2977. //if mapHot[v.IndustryName] > 0 {
  2978. // listHzResource[k].IsHot = true
  2979. //}
  2980. listHzResource[k].Source = 1
  2981. if fllowMap[v.IndustrialManagementId] > 0 {
  2982. listHzResource[k].IsFollw = true
  2983. }
  2984. v.IsHot = hotMapindustrial[v.IndustrialManagementId]
  2985. industrialIdSlice := make([]int, 0)
  2986. articleIdArr := make([]int, 0)
  2987. industrialIdSlice = append(industrialIdSlice, v.IndustrialManagementId)
  2988. listUpdateTime, err := models.GetNewArticleDetailByIndustrialIds(industrialIdSlice)
  2989. if err != nil && err.Error() != utils.ErrNoRow() {
  2990. return
  2991. }
  2992. for _, v := range listUpdateTime {
  2993. articleIdArr = append(articleIdArr, v.ArticleId)
  2994. }
  2995. if err != nil {
  2996. return
  2997. }
  2998. mapHistroyArticleId := make(map[int]int)
  2999. if user.UserId > 0 {
  3000. listArticleHistory, e := models.GetUserToArticleHistory(user.UserId, articleIdArr)
  3001. if e != nil && e.Error() != utils.ErrNoRow() {
  3002. err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
  3003. return
  3004. }
  3005. for _, v := range listArticleHistory {
  3006. mapHistroyArticleId[v.ArticleId] = v.ArticleId
  3007. }
  3008. }
  3009. condition2 := ` AND man.industry_name LIKE '%` + keyWord + `%' `
  3010. list, err := models.GetIndustrialManagementAll(uid, condition2, orderSrt, 0, 20)
  3011. if err != nil {
  3012. br.Msg = "获取信息失败"
  3013. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  3014. return
  3015. }
  3016. mapUPdateTime := make(map[int]string)
  3017. //获取这些产业下最新更新的文章
  3018. //时间线的更新时间
  3019. // maptimelineUPdateTime := make(map[int]string)
  3020. listtimelinePublishdate, err := models.GetTimeLineReportIndustrialPublishdateList(industrialIdArr)
  3021. if err != nil && err.Error() != utils.ErrNoRow() {
  3022. br.Msg = "获取信息失败"
  3023. br.ErrMsg = "GetTimeLineReportIndustrialPublishdateList,Err:" + err.Error()
  3024. return
  3025. }
  3026. for _, v := range listtimelinePublishdate {
  3027. if mapUPdateTime[v.IndustrialManagementId] != "" {
  3028. if utils.StrTimeToTime(v.PublishDate).After(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3029. mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
  3030. }
  3031. }
  3032. }
  3033. //mapHistroyArticleId := make(map[int]int)
  3034. //if userId > 0 {
  3035. // listArticleHistory, e := models.GetUserToArticleHistory(userId, articleIdArr)
  3036. // if e != nil && e.Error() != utils.ErrNoRow() {
  3037. // err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
  3038. // return
  3039. // }
  3040. // for _, v := range listArticleHistory {
  3041. // mapHistroyArticleId[v.ArticleId] = v.ArticleId
  3042. // }
  3043. //}
  3044. var industrialIds string
  3045. for _, id := range industrialIdArr {
  3046. industrialIds += strconv.Itoa(id) + ","
  3047. }
  3048. industrialIds = strings.TrimRight(industrialIds, ",")
  3049. articleList, err := models.GetReportIndustrialReadNumList(user.UserId, industrialIds, user.CreatedTime)
  3050. if err != nil && err.Error() != utils.ErrNoRow() {
  3051. br.Msg = "获取信息失败"
  3052. br.ErrMsg = "GetReportIndustrialReadNumList,Err:" + err.Error()
  3053. return
  3054. }
  3055. mapHistroyindustrialId := make(map[int]int)
  3056. for _, v := range articleList {
  3057. mapHistroyindustrialId[v.IndustrialManagementId] = v.Readnum
  3058. }
  3059. //nowTime := time.Now().Local()
  3060. //threeMonBefore := nowTime.AddDate(0, -3, 0)
  3061. //查询用户今天是否看过时间线
  3062. //haveMorningMeeting := false
  3063. //var morningMeetingTime string
  3064. recrodList, err := models.GetTimeLineRecordAllCount(user.UserId, time.Now().Format(utils.FormatDate))
  3065. if err != nil {
  3066. br.Msg = "获取信息失败"
  3067. br.ErrMsg = "GetTimeLineRecordAllCount,Err:" + err.Error()
  3068. return
  3069. }
  3070. var industrialManagementIdstr string
  3071. industrialIdMap := make(map[string]time.Time)
  3072. for _, v := range recrodList {
  3073. industrialManagementIdstr = strings.TrimLeft(v.Parameter, "PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=")
  3074. if createTime, ok := industrialIdMap[industrialManagementIdstr]; ok {
  3075. if createTime.Before(v.CreateTime) {
  3076. industrialIdMap[industrialManagementIdstr] = v.CreateTime
  3077. }
  3078. } else {
  3079. industrialIdMap[industrialManagementIdstr] = v.CreateTime
  3080. }
  3081. }
  3082. mmList, err := models.GetCygxMorningMeetingReviewsListByIndustrialIds(industrialIds)
  3083. if err != nil {
  3084. return
  3085. }
  3086. morningMeetingTimeMap := make(map[int]time.Time)
  3087. for _, v := range mmList {
  3088. morningMeetingTimeMap[v.IndustryId] = v.CreateTime
  3089. }
  3090. timeLineRedMap := make(map[int]bool, 0)
  3091. for _, industrialId := range industrialIdArr {
  3092. if createTime, ok := industrialIdMap[strconv.Itoa(industrialId)]; ok {
  3093. if createTime.Before(morningMeetingTimeMap[industrialId]) {
  3094. timeLineRedMap[industrialId] = true
  3095. }
  3096. }
  3097. }
  3098. for k, v := range list {
  3099. list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
  3100. if user.UserId > 0 {
  3101. //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
  3102. if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
  3103. if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3104. list[k].IsRed = true
  3105. }
  3106. }
  3107. } else {
  3108. if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3109. list[k].IsRed = true
  3110. }
  3111. list[k].IsFollow = 0
  3112. }
  3113. list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
  3114. if user.UserId > 0 {
  3115. //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
  3116. if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
  3117. if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3118. list[k].IsRed = true
  3119. }
  3120. }
  3121. } else {
  3122. if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3123. list[k].IsRed = true
  3124. }
  3125. list[k].IsFollow = 0
  3126. }
  3127. }
  3128. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  3129. }
  3130. for k, v := range listYxResource {
  3131. // 关联报告发布时间均在3个月内则标记New
  3132. if v.MinReportTime != "" {
  3133. t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
  3134. if e != nil {
  3135. err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
  3136. return
  3137. }
  3138. if t.After(threeMonBefore) {
  3139. listYxResource[k].IsNew = true
  3140. }
  3141. }
  3142. listYxResource[k].IsHot = mapHot[v.IndustrialManagementId]
  3143. listYxResource[k].Source = 2
  3144. if fllowMap[v.IndustrialManagementId] > 0 {
  3145. listYxResource[k].IsFollw = true
  3146. }
  3147. v.IsHot = hotMapindustrial[v.IndustrialManagementId]
  3148. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  3149. }
  3150. if len(industrialIdArr) > 0 {
  3151. //查询产业视频
  3152. industrialVideoMap := make(map[int]*models.MicroVideoSimpleInfo)
  3153. // 获取默认图配置
  3154. _, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
  3155. if e != nil {
  3156. br.Msg = "获取视频默认配置图失败"
  3157. br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
  3158. return
  3159. }
  3160. videoList, err := models.GetMicroRoadshowVideoByIndustryIds(industrialIdArr)
  3161. if err != nil {
  3162. br.Msg = "产业视频列表失败"
  3163. br.ErrMsg = "产业视频列表失败, Err: " + err.Error()
  3164. return
  3165. }
  3166. for _, v := range videoList {
  3167. tmp := &models.MicroVideoSimpleInfo{
  3168. Id: v.VideoId,
  3169. Title: "5min逻辑【" + v.IndustryName + "】解析",
  3170. ResourceUrl: v.VideoUrl,
  3171. BackgroundImg: v.ImgUrl,
  3172. PlaySeconds: v.VideoDuration,
  3173. DetailImgUrl: v.DetailImgUrl,
  3174. ChartPermissionName: v.ChartPermissionName,
  3175. ChartPermissionId: v.ChartPermissionId,
  3176. }
  3177. if tmp.BackgroundImg == "" {
  3178. tmp.BackgroundImg = videoMap[v.ChartPermissionId]
  3179. }
  3180. industrialVideoMap[v.IndustryId] = tmp
  3181. }
  3182. //查询权限
  3183. // 用户权限
  3184. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  3185. if e != nil {
  3186. br.Msg = "获取失败"
  3187. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  3188. return
  3189. }
  3190. for k, v := range listHzResource {
  3191. //展示产业视频
  3192. if video, ok := industrialVideoMap[v.IndustrialManagementId]; ok {
  3193. au := new(models.UserPermissionAuthInfo)
  3194. au.SellerName = authInfo.SellerName
  3195. au.SellerMobile = authInfo.SellerMobile
  3196. au.HasPermission = authInfo.HasPermission
  3197. au.OperationMode = authInfo.OperationMode
  3198. if au.HasPermission == 1 {
  3199. // 非宏观权限进一步判断是否有权限
  3200. if video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) {
  3201. au.HasPermission = 2
  3202. }
  3203. }
  3204. // 无权限的弹框提示
  3205. if au.HasPermission != 1 {
  3206. if au.OperationMode == services.UserPermissionOperationModeCall {
  3207. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  3208. } else {
  3209. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  3210. }
  3211. video.ResourceUrl = ""
  3212. }
  3213. listHzResource[k].AuthInfo = au
  3214. listHzResource[k].IndustryVideo = video
  3215. }
  3216. }
  3217. //合并产业关联的标的
  3218. listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  3219. if err != nil {
  3220. br.Msg = "获取信息失败"
  3221. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  3222. return
  3223. }
  3224. //严选的产业只关联研选下面的标的
  3225. var yxcondition string
  3226. var yxPer []interface{}
  3227. yxcondition = ` AND ag.article_id >= ?`
  3228. yxPer = append(yxPer, utils.SummaryArticleId)
  3229. listYxAticleSubject, err := models.GetSubjectArticleGroupManagementList(yxcondition, yxPer)
  3230. if err != nil && err.Error() != utils.ErrNoRow() {
  3231. br.Msg = "获取信息失败"
  3232. br.ErrMsg = "获取研选报告关联的标的信息失败,GetSubjectArticleGroupManagementListErr:" + err.Error()
  3233. return
  3234. }
  3235. mapYxSubject := make(map[int]int)
  3236. for _, v := range listYxAticleSubject {
  3237. mapYxSubject[v.IndustrialSubjectId] = v.IndustrialSubjectId
  3238. }
  3239. mapIndustrial := make(map[string]int)
  3240. for _, v := range listSubjcet {
  3241. for k2, v2 := range listYxResource {
  3242. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 && mapYxSubject[v.IndustrialSubjectId] > 0 {
  3243. listYxResource[k2].IndustrialSubjectList = append(listYxResource[k2].IndustrialSubjectList, v)
  3244. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  3245. }
  3246. }
  3247. for k2, v2 := range listHzResource {
  3248. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  3249. listHzResource[k2].IndustrialSubjectList = append(listHzResource[k2].IndustrialSubjectList, v)
  3250. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  3251. }
  3252. }
  3253. }
  3254. }
  3255. resp := new(models.SearchReportAndResourceResp)
  3256. if len(listYxResource) == 0 {
  3257. listYxResource = make([]*models.IndustrialManagementHotResp, 0)
  3258. }
  3259. if len(listHzResource) == 0 {
  3260. listHzResource = make([]*models.IndustrialManagementHotResp, 0)
  3261. }
  3262. if keyWord != "" {
  3263. keyWordItem := new(models.CygxUserSearchKeyWord)
  3264. keyWordItem.UserId = user.UserId
  3265. keyWordItem.KeyWord = keyWord
  3266. keyWordItem.PageType = "ReortSearch"
  3267. keyWordItem.CreateTime = time.Now()
  3268. go models.AddUserSearchKeyWord(keyWordItem)
  3269. //go services.AddUserSearchLog(user, keyWord, 5)
  3270. }
  3271. resp.ListHzResource = listHzResource
  3272. resp.ListYxResource = listYxResource
  3273. resp.ListYxReport = ListYxReport
  3274. resp.ListHzReport = ListHzReport
  3275. br.Ret = 200
  3276. br.Success = true
  3277. br.Msg = "获取成功"
  3278. br.Data = resp
  3279. }
  3280. // @Title 产业报告公司列表
  3281. // @Description 获取产业报告公司列表接口
  3282. // @Param ChartPermissionId query int true "行业id"
  3283. // @Success 200 {object} models.IndustrialManagementList
  3284. // @router /home/stockName [get]
  3285. func (this *ReportController) StockNameList() {
  3286. br := new(models.BaseResponse).Init()
  3287. defer func() {
  3288. this.Data["json"] = br
  3289. this.ServeJSON()
  3290. }()
  3291. user := this.User
  3292. if user == nil {
  3293. br.Msg = "请重新登录"
  3294. br.Ret = 408
  3295. return
  3296. }
  3297. //uid := user.UserId
  3298. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  3299. list, err := models.GetSummaryArticle(chartPermissionId)
  3300. if err != nil {
  3301. br.Msg = "获取综述报告公司名称失败"
  3302. br.ErrMsg = "获取综述报告公司名称失败,Err:" + err.Error()
  3303. return
  3304. }
  3305. var respList []*models.SummaryArticleStock
  3306. for _, item := range list {
  3307. sliceSubjects := strings.Split(item.Stock, "/")
  3308. if len(sliceSubjects) > 0 {
  3309. for i, vSubject := range sliceSubjects {
  3310. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  3311. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  3312. subject := sliceXiahuaxian[0]
  3313. if i > 0 {
  3314. newItem := models.SummaryArticleStock{
  3315. Id: item.Id,
  3316. ArticleId: item.ArticleId,
  3317. Stock: subject,
  3318. }
  3319. respList = append(respList, &newItem)
  3320. } else {
  3321. item.Stock = subject
  3322. respList = append(respList, item)
  3323. }
  3324. }
  3325. }
  3326. //index := strings.Index(item.Stock, "(")
  3327. //item.Stock = item.Stock[:index]
  3328. //if strings.Contains(item.Stock, "-B"){
  3329. // item.Stock = strings.Replace(item.Stock, "-B", "", -1)
  3330. //}
  3331. //if strings.Contains(item.Stock, "-W"){
  3332. // item.Stock = strings.Replace(item.Stock, "-W", "", -1)
  3333. //}
  3334. }
  3335. resp := new(models.SummaryArticleStockResp)
  3336. resp.List = respList
  3337. br.Ret = 200
  3338. br.Success = true
  3339. br.Msg = "获取成功"
  3340. br.Data = resp
  3341. }
  3342. // @Title 文章留言接口
  3343. // @Description 文章留言接口
  3344. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  3345. // @Success 200 {object} models.TacticsListResp
  3346. // @router /commentAdd [post]
  3347. func (this *ReportController) CommentAdd() {
  3348. br := new(models.BaseResponse).Init()
  3349. defer func() {
  3350. this.Data["json"] = br
  3351. this.ServeJSON()
  3352. }()
  3353. user := this.User
  3354. if user == nil {
  3355. br.Msg = "请重新登录"
  3356. br.Ret = 408
  3357. return
  3358. }
  3359. var req models.AddCygxArticleCommentReq
  3360. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3361. if err != nil {
  3362. br.Msg = "参数解析异常!"
  3363. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3364. return
  3365. }
  3366. if req.ArticleId <= 0 {
  3367. br.Msg = "文章不存在"
  3368. br.ErrMsg = "文章不存在,文章ID错误"
  3369. return
  3370. }
  3371. if req.Content == "" {
  3372. br.Msg = "建议内容不可为空"
  3373. return
  3374. }
  3375. content := req.Content
  3376. itemToken, err := services.WxGetToken()
  3377. if err != nil {
  3378. br.Msg = "GetWxAccessToken Err:" + err.Error()
  3379. return
  3380. }
  3381. if itemToken.AccessToken == "" {
  3382. br.Msg = "accessToken is empty"
  3383. return
  3384. }
  3385. commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  3386. if err != nil {
  3387. br.Msg = "内容校验失败!"
  3388. br.ErrMsg = "内容校验失败,Err:" + err.Error()
  3389. return
  3390. }
  3391. if commerr.ErrCode != 0 {
  3392. br.Msg = "内容违规,请重新提交!"
  3393. br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
  3394. return
  3395. }
  3396. articleId := req.ArticleId
  3397. articleInfo, errInfo := models.GetArticleDetailById(articleId)
  3398. if articleInfo == nil {
  3399. br.Msg = "操作失败"
  3400. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3401. return
  3402. }
  3403. if errInfo != nil {
  3404. br.Msg = "操作失败"
  3405. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3406. return
  3407. }
  3408. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  3409. if err != nil {
  3410. br.Msg = "提交失败!"
  3411. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3412. return
  3413. }
  3414. if companyDetail == nil {
  3415. br.Msg = "提交失败!"
  3416. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  3417. return
  3418. }
  3419. item := models.CygxArticleComment{
  3420. UserId: user.UserId,
  3421. ArticleId: req.ArticleId,
  3422. CreateTime: time.Now(),
  3423. Mobile: user.Mobile,
  3424. Email: user.Email,
  3425. CompanyId: user.CompanyId,
  3426. CompanyName: companyDetail.CompanyName,
  3427. Content: content,
  3428. Title: articleInfo.Title,
  3429. }
  3430. _, err = models.AddArticleComment(&item)
  3431. if err != nil {
  3432. br.Msg = "提交失败"
  3433. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  3434. return
  3435. }
  3436. //获取销售信息
  3437. //sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  3438. //if err != nil && err.Error() != utils.ErrNoRow() {
  3439. // br.Msg = "提交失败"
  3440. // br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  3441. // return
  3442. //}
  3443. //// 给所属销售发送消息
  3444. //var openIdList []*models.OpenIdList
  3445. //if sellerItem != nil {
  3446. // list, _ := models.GetWxOpenIdByMobileList(sellerItem.Mobile)
  3447. // for _, idList := range list {
  3448. // openIdList = append(openIdList, idList)
  3449. // }
  3450. // if openIdList != nil {
  3451. // // 给芳姐发消息
  3452. // cnf, _ := models.GetConfigByCode("tpl_msg")
  3453. // if cnf != nil {
  3454. // list, _ := models.GetWxOpenIdByMobileList(cnf.ConfigValue)
  3455. // for _, idList := range list {
  3456. // openIdList = append(openIdList, idList)
  3457. // }
  3458. // }
  3459. // if articleId > 1000000 {
  3460. // //发给汪洋
  3461. // list, _ := models.GetWxOpenIdByMobileList(utils.ActSendMsgMobile)
  3462. // for _, idList := range list {
  3463. // openIdList = append(openIdList, idList)
  3464. // }
  3465. // }
  3466. // services.SendCommentWxTemplateMsg(articleInfo.Title, user.CompanyName, user.RealName, sellerItem.RealName, item.CreateTime.Format(utils.FormatDateTime), req.Content, openIdList, req.ArticleId)
  3467. // }
  3468. //}
  3469. services.SendCommentWxTemplateMsg(req, user, articleInfo)
  3470. br.Ret = 200
  3471. br.Success = true
  3472. br.Msg = "提交成功"
  3473. }
  3474. // @Title 记录用户浏览音频回放接口
  3475. // @Description 记录用户浏览音频回放接口
  3476. // @Param request body models.ArticleIdReq true "type json string"
  3477. // @Success Ret=200 操作成功
  3478. // @router /voiceHistory/add [post]
  3479. func (this *ReportController) ResearchSummaryVoiceHistoryAdd() {
  3480. br := new(models.BaseResponse).Init()
  3481. defer func() {
  3482. this.Data["json"] = br
  3483. this.ServeJSON()
  3484. }()
  3485. user := this.User
  3486. if user == nil {
  3487. br.Msg = "请登录"
  3488. br.ErrMsg = "请登录,用户信息为空"
  3489. br.Ret = 408
  3490. return
  3491. }
  3492. uid := user.UserId
  3493. var req models.ArticleIdReq
  3494. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3495. if err != nil {
  3496. br.Msg = "参数解析异常!"
  3497. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3498. return
  3499. }
  3500. articleId := req.ArticleId
  3501. playSeconds := req.PlaySeconds
  3502. pageRouter := req.PageRouter
  3503. if pageRouter == "本周研究汇总" {
  3504. articleInfo, errInfo := models.GetCygxResearchSummaryInfoById(articleId)
  3505. if articleInfo == nil {
  3506. br.Msg = "操作失败"
  3507. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3508. return
  3509. }
  3510. if errInfo != nil {
  3511. br.Msg = "操作失败"
  3512. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3513. return
  3514. }
  3515. var sellerName string
  3516. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3517. if err != nil {
  3518. br.Msg = "报名失败!"
  3519. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3520. return
  3521. }
  3522. item := models.CygxResearchSummaryVoiceHistory{
  3523. ArticleId: articleId,
  3524. UserId: uid,
  3525. CreateTime: time.Now(),
  3526. Mobile: user.Mobile,
  3527. Email: user.Email,
  3528. CompanyId: user.CompanyId,
  3529. CompanyName: user.CompanyName,
  3530. RealName: user.RealName,
  3531. SellerName: sellerName,
  3532. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3533. ModifyTime: time.Now(),
  3534. }
  3535. if playSeconds != 0 {
  3536. lastItem, err := models.GetLastCygxResearchSummaryVoiceHistory(articleId, user.UserId)
  3537. if err != nil {
  3538. br.Msg = "操作失败"
  3539. br.ErrMsg = "操作失败,GetLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  3540. return
  3541. }
  3542. err = models.UpdateLastCygxResearchSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3543. if err != nil {
  3544. br.Msg = "更新失败"
  3545. br.ErrMsg = "更新失败,UpdateLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  3546. return
  3547. }
  3548. } else {
  3549. err = models.AddCygxResearchSummaryVoiceHistory(&item)
  3550. if err != nil {
  3551. br.Msg = "操作失败"
  3552. br.ErrMsg = "操作失败,Err:" + err.Error()
  3553. return
  3554. }
  3555. err = models.UpdateResearchSummaryVoiceCounts(articleId)
  3556. if err != nil {
  3557. br.Msg = "更新失败"
  3558. br.ErrMsg = "更新失败,Err:" + err.Error()
  3559. return
  3560. }
  3561. }
  3562. } else if pageRouter == "上周纪要汇总" {
  3563. articleInfo, errInfo := models.GetCygxMinutesSummaryInfoById(articleId)
  3564. if articleInfo == nil {
  3565. br.Msg = "操作失败"
  3566. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3567. return
  3568. }
  3569. if errInfo != nil {
  3570. br.Msg = "操作失败"
  3571. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3572. return
  3573. }
  3574. var sellerName string
  3575. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3576. if err != nil {
  3577. br.Msg = "报名失败!"
  3578. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3579. return
  3580. }
  3581. item := models.CygxMinutesSummaryVoiceHistory{
  3582. ArticleId: articleId,
  3583. UserId: uid,
  3584. CreateTime: time.Now(),
  3585. Mobile: user.Mobile,
  3586. Email: user.Email,
  3587. CompanyId: user.CompanyId,
  3588. CompanyName: user.CompanyName,
  3589. RealName: user.RealName,
  3590. SellerName: sellerName,
  3591. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3592. ModifyTime: time.Now(),
  3593. }
  3594. if playSeconds != 0 {
  3595. lastItem, err := models.GetLastCygxMinutesSummaryVoiceHistory(articleId, user.UserId)
  3596. if err != nil {
  3597. br.Msg = "操作失败"
  3598. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  3599. return
  3600. }
  3601. err = models.UpdateLastCygxMinutesSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3602. if err != nil {
  3603. br.Msg = "更新失败"
  3604. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  3605. return
  3606. }
  3607. } else {
  3608. err = models.AddCygxMinutesSummaryVoiceHistory(&item)
  3609. if err != nil {
  3610. br.Msg = "操作失败"
  3611. br.ErrMsg = "操作失败,Err:" + err.Error()
  3612. return
  3613. }
  3614. err = models.UpdateMinutesSummaryVoiceCounts(articleId)
  3615. if err != nil {
  3616. br.Msg = "更新失败"
  3617. br.ErrMsg = "更新失败,Err:" + err.Error()
  3618. return
  3619. }
  3620. }
  3621. } else if pageRouter == "报告精选" {
  3622. articleInfo, errInfo := models.GetCygxReportSelectionInfoById(articleId)
  3623. if articleInfo == nil {
  3624. br.Msg = "操作失败"
  3625. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3626. return
  3627. }
  3628. if errInfo != nil {
  3629. br.Msg = "操作失败"
  3630. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3631. return
  3632. }
  3633. var sellerName string
  3634. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3635. if err != nil {
  3636. br.Msg = "报名失败!"
  3637. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3638. return
  3639. }
  3640. item := models.CygxReportSelectionVoiceHistory{
  3641. ArticleId: articleId,
  3642. UserId: uid,
  3643. CreateTime: time.Now(),
  3644. Mobile: user.Mobile,
  3645. Email: user.Email,
  3646. CompanyId: user.CompanyId,
  3647. CompanyName: user.CompanyName,
  3648. RealName: user.RealName,
  3649. SellerName: sellerName,
  3650. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3651. ModifyTime: time.Now(),
  3652. }
  3653. if playSeconds != 0 {
  3654. lastItem, err := models.GetLastCygxReportSelectionVoiceHistory(articleId, user.UserId)
  3655. if err != nil {
  3656. br.Msg = "操作失败"
  3657. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  3658. return
  3659. }
  3660. err = models.UpdateLastCygxReportSelectionVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3661. if err != nil {
  3662. br.Msg = "更新失败"
  3663. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  3664. return
  3665. }
  3666. } else {
  3667. err = models.AddCygxReportSelectionVoiceHistory(&item)
  3668. if err != nil {
  3669. br.Msg = "操作失败"
  3670. br.ErrMsg = "操作失败,Err:" + err.Error()
  3671. return
  3672. }
  3673. err = models.UpdateReportSelectionVoiceCounts(articleId)
  3674. if err != nil {
  3675. br.Msg = "更新失败"
  3676. br.ErrMsg = "更新失败,Err:" + err.Error()
  3677. return
  3678. }
  3679. }
  3680. }
  3681. br.Ret = 200
  3682. br.Success = true
  3683. br.Msg = "操作成功"
  3684. return
  3685. }