report.go 121 KB

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