report.go 122 KB

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