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