report.go 120 KB

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