report.go 101 KB

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