report.go 107 KB

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