report.go 120 KB

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