report.go 119 KB

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