report.go 117 KB

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