report.go 102 KB

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