report.go 101 KB

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