report.go 118 KB

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