report.go 122 KB

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