report.go 124 KB

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