report.go 102 KB

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