report.go 103 KB

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