report.go 102 KB

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