report.go 107 KB

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