report.go 125 KB

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