report.go 119 KB

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