report.go 125 KB

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