report.go 106 KB

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