report.go 119 KB

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