report.go 122 KB

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