report.go 122 KB

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