report.go 122 KB

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