report.go 102 KB

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