report.go 121 KB

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