report.go 106 KB

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