report.go 121 KB

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