report.go 102 KB

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