report.go 108 KB

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