report.go 122 KB

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