article.go 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660
  1. package controllers
  2. import (
  3. "bufio"
  4. "github.com/pdfcpu/pdfcpu/pkg/api"
  5. "github.com/pdfcpu/pdfcpu/pkg/pdfcpu"
  6. "io"
  7. //"bufio"
  8. "encoding/json"
  9. "fmt"
  10. "github.com/medivhzhan/weapp/v2"
  11. "os"
  12. //"github.com/pdfcpu/pdfcpu/pkg/api"
  13. //"github.com/pdfcpu/pdfcpu/pkg/pdfcpu"
  14. "hongze/hongze_cygx/models"
  15. "hongze/hongze_cygx/services"
  16. "hongze/hongze_cygx/utils"
  17. "html"
  18. nhttp "net/http"
  19. "strconv"
  20. "strings"
  21. "time"
  22. )
  23. type ArticleController struct {
  24. BaseAuthController
  25. }
  26. type ArticleCommonController struct {
  27. BaseCommonController
  28. }
  29. type ArticleControllerMobile struct {
  30. BaseAuthMobileController
  31. }
  32. // @Title 获取报告详情
  33. // @Description 获取报告详情接口
  34. // @Param ArticleId query int true "报告ID"
  35. // @Success 200 {object} models.ArticleDetailResp
  36. // @router /detail [get]
  37. func (this *ArticleController) Detail() {
  38. br := new(models.BaseResponse).Init()
  39. defer func() {
  40. this.Data["json"] = br
  41. this.ServeJSON()
  42. }()
  43. user := this.User
  44. if user == nil {
  45. br.Msg = "请登录"
  46. br.ErrMsg = "请登录,用户信息为空"
  47. br.Ret = 408
  48. return
  49. }
  50. uid := user.UserId
  51. articleId, err := this.GetInt("ArticleId")
  52. if articleId <= 0 {
  53. br.Msg = "文章不存在"
  54. br.ErrMsg = "文章不存在,文章ID错误"
  55. return
  56. }
  57. detail := new(models.ArticleDetail)
  58. hasPermission := 0
  59. var haveResearch bool
  60. //判断是否已经申请过
  61. applyCount, err := models.GetApplyRecordCount(uid)
  62. if err != nil && err.Error() != utils.ErrNoRow() {
  63. br.Msg = "获取信息失败"
  64. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  65. return
  66. }
  67. resp := new(models.ArticleDetailResp)
  68. detail, err = models.GetArticleDetailById(articleId)
  69. if err != nil {
  70. br.Msg = "获取信息失败"
  71. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  72. return
  73. }
  74. //是否属于专项调研报告
  75. if detail.SubCategoryName == "专项调研" {
  76. detail.IsSpecialArticle = true
  77. havePower, err := services.GetSpecialArticleDetailUserPower(user, detail)
  78. if err != nil {
  79. br.Msg = "获取信息失败"
  80. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  81. return
  82. }
  83. resp.IsSpecialArticle = true
  84. if !havePower {
  85. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionArticle(user)
  86. if err != nil {
  87. br.Msg = "获取信息失败"
  88. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  89. return
  90. }
  91. resp.PopupMsg = popupMsg
  92. resp.HasPermission = hasPermission
  93. resp.SellerName = sellerName
  94. resp.SellerMobile = sellerMobile
  95. detail.Body = ""
  96. detail.Abstract = ""
  97. detail.BodyText = ""
  98. detail.SellerName = sellerName
  99. detail.SellerMobile = sellerMobile
  100. resp.Detail = detail
  101. br.Ret = 200
  102. br.Success = true
  103. br.Msg = "获取成功"
  104. br.Data = resp
  105. return
  106. }
  107. }
  108. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  109. if user.CompanyId > 1 {
  110. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  111. if err != nil {
  112. br.Msg = "获取信息失败"
  113. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  114. return
  115. }
  116. detail.PublishDate = utils.TimeRemoveHms2(detail.PublishDate)
  117. detail.Body = html.UnescapeString(detail.Body)
  118. detail.Body = strings.Replace(detail.Body, "<p data-f-id=\"pbf\" style=\"text-align: center; font-size: 14px; margin-top: 30px; opacity: 0.65; font-family: sans-serif;\">Powered by <a href=\"https://www.froala.com/wysiwyg-editor?pb=1\" title=\"Froala Editor\">Froala Editor</a></p>", "", -1)
  119. detail.Body = strings.Replace(detail.Body, "pre", "div", -1)
  120. //detail.Abstract = html.UnescapeString(detail.Abstract)
  121. detail.Abstract, _ = services.GetReportContentTextSubNew(detail.Abstract)
  122. if companyPermission == "" {
  123. if applyCount > 0 {
  124. hasPermission = 5
  125. } else {
  126. hasPermission = 2
  127. }
  128. goto Loop
  129. } else {
  130. var articlePermissionPermissionName string
  131. if detail.CategoryId > 0 {
  132. articlePermission, err := models.GetArticlePermission(detail.CategoryId)
  133. if err != nil {
  134. br.Msg = "获取信息失败"
  135. br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  136. return
  137. }
  138. if articlePermission == nil {
  139. br.Msg = "获取信息失败"
  140. br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  141. return
  142. }
  143. articlePermissionPermissionName = articlePermission.PermissionName
  144. } else {
  145. articlePermissionPermissionName = detail.CategoryName
  146. }
  147. var hasPersion bool
  148. slice := strings.Split(articlePermissionPermissionName, ",")
  149. for _, v := range slice {
  150. if strings.Contains(companyPermission, v) {
  151. hasPersion = true
  152. }
  153. }
  154. if strings.Contains(detail.CategoryName, "研选") {
  155. detail.IsResearch = true
  156. }
  157. userType, _, err := services.GetUserType(user.CompanyId)
  158. if err != nil {
  159. br.Msg = "获取信息失败"
  160. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  161. return
  162. }
  163. if userType == 1 && strings.Contains(detail.CategoryName, "研选") {
  164. hasPersion = false
  165. }
  166. if detail.IsReport == 1 {
  167. detailCategory, err := models.GetdetailByCategoryIdSando(detail.CategoryId)
  168. if err != nil && err.Error() != utils.ErrNoRow() {
  169. br.Msg = "获取信息失败"
  170. br.ErrMsg = "获取信息失败,Err:" + err.Error() + "categoryID 不存在:" + strconv.Itoa(detail.CategoryId)
  171. return
  172. }
  173. permissionStr, err := models.GetCompanyPermissionByUser(user.CompanyId)
  174. if err != nil {
  175. br.Msg = "获取信息失败"
  176. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  177. return
  178. }
  179. if detailCategory != nil {
  180. if detailCategory.PermissionType == 1 {
  181. if !strings.Contains(permissionStr, detailCategory.ChartPermissionName+"(主观)") {
  182. hasPersion = false
  183. }
  184. } else if detailCategory.PermissionType == 2 {
  185. if !strings.Contains(permissionStr, detailCategory.ChartPermissionName+"(客观)") {
  186. hasPersion = false
  187. }
  188. }
  189. }
  190. }
  191. if hasPersion {
  192. hasPermission = 1
  193. historyRecord := new(models.CygxArticleHistoryRecord)
  194. historyRecord.UserId = uid
  195. historyRecord.ArticleId = articleId
  196. historyRecord.CreateTime = time.Now()
  197. historyRecord.Mobile = user.Mobile
  198. historyRecord.Email = user.Email
  199. historyRecord.CompanyId = user.CompanyId
  200. historyRecord.CompanyName = user.CompanyName
  201. recordCount, _ := models.GetNoAddStoptimeArticleCount(uid, articleId)
  202. if recordCount == 0 {
  203. go models.AddCygxArticleHistoryRecord(historyRecord)
  204. } else {
  205. detailNew, err := models.GetNewArticleHistoryRecord(uid, articleId)
  206. if err != nil {
  207. br.Msg = "获取信息失败"
  208. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  209. return
  210. }
  211. if detailNew.StopTime > 0 {
  212. go models.AddCygxArticleHistoryRecord(historyRecord)
  213. }
  214. }
  215. //30分钟之内阅读同一篇文章不错二次推送
  216. key := "CYGX_ARTICLE_READ" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  217. if !utils.Rc.IsExist(key) {
  218. go services.ArticleUserRemind(user, detail, 1)
  219. utils.Rc.Put(key, 1, 30*time.Second)
  220. }
  221. } else { //无该行业权限
  222. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  223. if err == nil && companyDetail.ProductId == 1 {
  224. hasPermission = 2
  225. } else {
  226. hasPermission = 3
  227. }
  228. }
  229. if hasPermission == 1 {
  230. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  231. if !utils.Rc.IsExist(key) {
  232. //新增浏览记录
  233. record := new(models.CygxArticleViewRecord)
  234. record.UserId = uid
  235. record.ArticleId = articleId
  236. record.CreateTime = time.Now()
  237. record.Mobile = user.Mobile
  238. record.Email = user.Email
  239. record.CompanyId = user.CompanyId
  240. record.CompanyName = user.CompanyName
  241. go models.AddCygxArticleViewRecord(record)
  242. utils.Rc.Put(key, 1, 5*time.Second)
  243. models.ModifyReportLastViewTime(uid)
  244. }
  245. }
  246. }
  247. collectCount, err := models.GetArticleCollectCount(uid, articleId)
  248. if err != nil && err.Error() != utils.ErrNoRow() {
  249. br.Msg = "获取信息失败"
  250. br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  251. return
  252. }
  253. if collectCount > 0 {
  254. detail.IsCollect = true
  255. }
  256. interviewApplyItem, err := models.GetArticleInterviewApply(uid, articleId)
  257. if err != nil && err.Error() != utils.ErrNoRow() {
  258. br.Msg = "获取信息失败"
  259. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  260. return
  261. }
  262. if interviewApplyItem != nil && interviewApplyItem.InterviewApplyId > 0 {
  263. detail.IsInterviewApply = true
  264. detail.InterviewApplyStatus = interviewApplyItem.Status
  265. }
  266. //获取销售手机号
  267. sellerItem, err := models.GetSellerByCompanyId(user.CompanyId)
  268. if err != nil && err.Error() != utils.ErrNoRow() {
  269. br.Msg = "获取信息失败"
  270. br.ErrMsg = "获取销售数据失败2,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  271. return
  272. }
  273. if sellerItem != nil {
  274. detail.SellerMobile = sellerItem.Mobile
  275. detail.SellerName = sellerItem.RealName
  276. }
  277. sellerList, err := models.GetSellerList(articleId)
  278. if err != nil {
  279. br.Msg = "获取信息失败"
  280. br.ErrMsg = "获取销售数据失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  281. return
  282. }
  283. if detail.ArticleId >= utils.SummaryArticleId && strings.Contains(detail.SellerAndMobile, "-") {
  284. strnum := strings.Index(detail.SellerAndMobile, "-")
  285. detail.SellerAndMobile = detail.SellerAndMobile[0:strnum]
  286. if strnum > 0 {
  287. nickName := detail.SellerAndMobile[0:strnum]
  288. sellerAndMobile := &models.SellerRep{
  289. SellerMobile: "",
  290. SellerName: nickName,
  291. }
  292. sellerList = append(sellerList, sellerAndMobile)
  293. }
  294. }
  295. detail.SellerList = sellerList
  296. //作者头像
  297. if detail.DepartmentId > 0 {
  298. departmentDetail, err := models.GetArticleDepartmentDateilById(detail.DepartmentId)
  299. if err == nil {
  300. detail.DepartmentImgUrl = departmentDetail.ImgUrl
  301. }
  302. }
  303. } else { //潜在客户
  304. if applyCount > 0 {
  305. hasPermission = 5
  306. } else {
  307. hasPermission = 4
  308. }
  309. }
  310. Loop:
  311. if hasPermission != 1 {
  312. detail.Body = ""
  313. detail.BodyText = ""
  314. } else {
  315. articleFollowdetail, err := models.GetArticleFollowDetail(articleId, uid)
  316. if err != nil {
  317. br.Msg = "获取信息失败"
  318. br.ErrMsg = "获取关注信息失败,Err:" + err.Error()
  319. return
  320. }
  321. detail.FollowNum = articleFollowdetail.DNum
  322. detail.CollectionNum = articleFollowdetail.AcNum
  323. if articleFollowdetail.MdNum > 0 {
  324. detail.IsFollow = true
  325. }
  326. if detail.IsSummary == 1 {
  327. detail.IsBelongSummary = true
  328. }
  329. if detail.IsReport == 1 {
  330. detail.IsBelongReport = true
  331. }
  332. haveResearch = true
  333. }
  334. if hasPermission == 5 {
  335. companyPermissionNoStatus, err := models.GetCompanyPermissionByUserNoStatus(user.CompanyId)
  336. if err != nil {
  337. br.Msg = "获取信息失败"
  338. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  339. return
  340. }
  341. if companyPermissionNoStatus != "" {
  342. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  343. if err != nil && err.Error() != utils.ErrNoRow() {
  344. br.Msg = "获取信息失败"
  345. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  346. return
  347. }
  348. if sellerItemQy != nil {
  349. hasPermission = 3
  350. detail.SellerMobile = sellerItemQy.Mobile
  351. detail.SellerName = sellerItemQy.RealName
  352. }
  353. }
  354. }
  355. if hasPermission == 2 || hasPermission == 4 {
  356. //获取销售手机号
  357. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  358. if err != nil && err.Error() != utils.ErrNoRow() {
  359. br.Msg = "获取信息失败"
  360. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  361. return
  362. }
  363. if sellerItemQy != nil {
  364. hasPermission = 3
  365. detail.SellerMobile = sellerItemQy.Mobile
  366. detail.SellerName = sellerItemQy.RealName
  367. }
  368. }
  369. if detail.ArticleId < utils.SummaryArticleId {
  370. if user.Mobile != "" {
  371. chartUserTokenByMobile, _ := services.GetUserTokenByMobile(user.Mobile)
  372. detail.HttpUrl = utils.StrategyPlatform + strconv.Itoa(articleId) + "?token=" + chartUserTokenByMobile
  373. } else {
  374. detail.HttpUrl = utils.StrategyPlatform + strconv.Itoa(articleId)
  375. }
  376. detail.IsNeedJump = true
  377. }
  378. // 处理研选下面的路演精华 的报告链接是否跳转
  379. if hasPermission == 1 && detail.ArticleId > utils.SummaryArticleId && detail.ArticleTypeId > 0 {
  380. //detail.PublishDate = utils.TimeRemoveHms2(detail.PublishDate)
  381. if detail.ReportLink != "" {
  382. chartUserTokenByMobile, _ := services.GetUserTokenByMobile(user.Mobile)
  383. detail.ReportLink += "?token=" + chartUserTokenByMobile
  384. }
  385. }
  386. resp.HasPermission = hasPermission
  387. resp.HaveResearch = haveResearch
  388. resp.Detail = detail
  389. if user.Mobile != "" {
  390. resp.Mobile = user.Mobile
  391. } else {
  392. resp.Mobile = user.Email
  393. }
  394. br.Ret = 200
  395. br.Success = true
  396. br.Msg = "获取成功"
  397. br.Data = resp
  398. }
  399. // @Title 收藏
  400. // @Description 收藏
  401. // @Param request body models.ArticleCollectReq true "type json string"
  402. // @Success 200 {object} models.FontsCollectResp
  403. // @router /collect [post]
  404. func (this *ArticleController) ArticleCollect() {
  405. br := new(models.BaseResponse).Init()
  406. defer func() {
  407. this.Data["json"] = br
  408. this.ServeJSON()
  409. }()
  410. user := this.User
  411. if user == nil {
  412. br.Msg = "请重新登录"
  413. br.Ret = 408
  414. return
  415. }
  416. uid := user.UserId
  417. var req models.ArticleCollectReq
  418. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  419. if err != nil {
  420. br.Msg = "参数解析异常!"
  421. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  422. return
  423. }
  424. articleId := req.ArticleId
  425. detail, err := models.GetArticleDetailById(articleId)
  426. if err != nil {
  427. br.Msg = "获取信息失败"
  428. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  429. return
  430. }
  431. count, err := models.GetArticleCollectCount(uid, articleId)
  432. if err != nil {
  433. br.Msg = "获取数据失败!"
  434. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  435. return
  436. }
  437. resp := new(models.ArticleCollectResp)
  438. if count <= 0 {
  439. item := new(models.CygxArticleCollect)
  440. item.ArticleId = req.ArticleId
  441. item.UserId = uid
  442. item.CreateTime = time.Now()
  443. item.Mobile = user.Mobile
  444. item.Email = user.Email
  445. item.CompanyId = user.CompanyId
  446. item.CompanyName = user.CompanyName
  447. item.RealName = user.RealName
  448. _, err = models.AddCygxArticleCollect(item)
  449. if err != nil {
  450. br.Msg = "收藏失败"
  451. br.ErrMsg = "收藏失败,Err:" + err.Error()
  452. return
  453. }
  454. br.Msg = "收藏成功"
  455. resp.Status = 1
  456. // 文章收藏消息发送
  457. go services.ArticleUserRemind(user, detail, 2)
  458. } else {
  459. err = models.RemoveArticleCollect(uid, articleId)
  460. if err != nil {
  461. br.Msg = "取消收藏失败"
  462. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  463. return
  464. }
  465. br.Msg = "已取消收藏"
  466. resp.Status = 2
  467. }
  468. collectTotal, err := models.GetArticleCollectUsersCount(articleId)
  469. if err != nil {
  470. br.Msg = "获取数据失败"
  471. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  472. return
  473. }
  474. resp.CollectCount = collectTotal
  475. br.Ret = 200
  476. br.Success = true
  477. br.Data = resp
  478. }
  479. // @Title 访谈申请
  480. // @Description 访谈申请
  481. // @Param request body models.ArticleInterviewApplyReq true "type json string"
  482. // @Success 200 {object} models.FontsCollectResp
  483. // @router /interview/apply [post]
  484. func (this *ArticleController) InterviewApply() {
  485. br := new(models.BaseResponse).Init()
  486. defer func() {
  487. this.Data["json"] = br
  488. this.ServeJSON()
  489. }()
  490. user := this.User
  491. if user == nil {
  492. br.Msg = "请重新登录"
  493. br.Ret = 408
  494. return
  495. }
  496. uid := user.UserId
  497. var req models.ArticleInterviewApplyReq
  498. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  499. if err != nil {
  500. br.Msg = "参数解析异常!"
  501. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  502. return
  503. }
  504. article, err := models.GetArticleDetailById(req.ArticleId)
  505. if err != nil {
  506. br.Msg = "获取纪要失败!"
  507. br.ErrMsg = "获取纪要失败,Err:" + err.Error()
  508. return
  509. }
  510. count, err := models.GetArticleInterviewApplyCount(uid, req.ArticleId)
  511. if err != nil {
  512. br.Msg = "获取数据失败!"
  513. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  514. return
  515. }
  516. resp := new(models.ArticleInterviewApplyResp)
  517. if count <= 0 {
  518. item := new(models.CygxInterviewApply)
  519. item.ArticleId = req.ArticleId
  520. item.UserId = uid
  521. item.CompanyId = user.CompanyId
  522. item.Status = "待邀请"
  523. item.Sort = 1
  524. item.ArticleTitle = article.Title
  525. item.CreateTime = time.Now()
  526. item.ModifyTime = time.Now()
  527. item.ArticleIdMd5 = article.ArticleIdMd5
  528. _, err = models.AddCygxInterviewApply(item)
  529. if err != nil {
  530. br.Msg = "申请失败"
  531. br.ErrMsg = "申请失败,Err:" + err.Error()
  532. return
  533. }
  534. br.Msg = "申请成功"
  535. resp.Status = 1
  536. //发送模板消息
  537. if user.CompanyId > 1 {
  538. mobile := user.Mobile
  539. if mobile == "" {
  540. mobile = user.Email
  541. }
  542. sellerItem, _ := models.GetSellerByCompanyId(user.CompanyId)
  543. if sellerItem != nil && sellerItem.AdminId > 0 && user.Mobile != "" {
  544. openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  545. if openIpItem != nil && openIpItem.OpenId != "" {
  546. go services.SendInterviewApplyTemplateMsg(user.RealName, sellerItem.CompanyName, mobile, article.Title, openIpItem)
  547. }
  548. }
  549. }
  550. } else {
  551. err = models.RemoveArticleInterviewApply(uid, req.ArticleId)
  552. if err != nil {
  553. br.Msg = "取消申请失败"
  554. br.ErrMsg = "取消申请失败,Err:" + err.Error()
  555. return
  556. }
  557. br.Msg = "已取消申请"
  558. resp.Status = 2
  559. if user.CompanyId > 1 {
  560. mobile := user.Mobile
  561. if mobile == "" {
  562. mobile = user.Email
  563. }
  564. sellerItem, _ := models.GetSellerByCompanyId(user.CompanyId)
  565. if sellerItem != nil && sellerItem.AdminId > 0 && user.Mobile != "" {
  566. openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  567. if openIpItem != nil && openIpItem.OpenId != "" {
  568. go services.SendInterviewApplyCancelTemplateMsg(user.RealName, sellerItem.CompanyName, mobile, article.Title, openIpItem)
  569. }
  570. }
  571. }
  572. }
  573. br.Ret = 200
  574. br.Success = true
  575. br.Data = resp
  576. }
  577. // @Title 获取报告详情
  578. // @Description 获取报告详情接口
  579. // @Param ArticleIdMd5 query int true "报告ID"
  580. // @Success 200 {object} models.ArticleDetailResp
  581. // @router /look/detail [get]
  582. func (this *ArticleControllerMobile) DetailMd5() {
  583. br := new(models.BaseResponse).Init()
  584. defer func() {
  585. this.Data["json"] = br
  586. this.ServeJSON()
  587. }()
  588. user := this.User
  589. if user == nil {
  590. br.Msg = "请登录"
  591. br.ErrMsg = "请登录,用户信息为空"
  592. br.Ret = 408
  593. return
  594. }
  595. uid := user.UserId
  596. articleIdMd5 := this.GetString("ArticleIdMd5")
  597. if articleIdMd5 == "" {
  598. br.Msg = "参数错误"
  599. br.ErrMsg = "参数错误"
  600. return
  601. }
  602. resp := new(models.ArticleDetailResp)
  603. detail, err := models.GetArticleDetailByIdMd5(articleIdMd5)
  604. if err != nil {
  605. br.Msg = "获取信息失败"
  606. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  607. return
  608. }
  609. articleId := detail.ArticleId
  610. detail.Body = html.UnescapeString(detail.Body)
  611. hasPermission := 2
  612. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  613. if user.CompanyId > 1 {
  614. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  615. if err != nil {
  616. br.Msg = "获取信息失败"
  617. br.ErrMsg = "获取公司权限失败,Err:" + err.Error()
  618. return
  619. }
  620. detail.Body = html.UnescapeString(detail.Body)
  621. detail.Body = strings.Replace(detail.Body, "<p data-f-id=\"pbf\" style=\"text-align: center; font-size: 14px; margin-top: 30px; opacity: 0.65; font-family: sans-serif;\">Powered by <a href=\"https://www.froala.com/wysiwyg-editor?pb=1\" title=\"Froala Editor\">Froala Editor</a></p>", "", -1)
  622. detail.Body = strings.Replace(detail.Body, "pre", "div", -1)
  623. detail.Abstract, _ = services.GetReportContentTextSubNew(detail.Abstract)
  624. if companyPermission == "" {
  625. hasPermission = 2
  626. } else {
  627. var articlePermissionPermissionName string
  628. if detail.CategoryId > 0 {
  629. articlePermission, err := models.GetArticlePermission(detail.CategoryId)
  630. if err != nil {
  631. br.Msg = "获取信息失败"
  632. br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + articleIdMd5
  633. return
  634. }
  635. if articlePermission == nil {
  636. br.Msg = "获取信息失败"
  637. br.ErrMsg = "报告权限不存在,Err:" + articleIdMd5
  638. return
  639. }
  640. articlePermissionPermissionName = articlePermission.PermissionName
  641. } else {
  642. articlePermissionPermissionName = detail.CategoryName
  643. }
  644. var hasPersion bool
  645. slice := strings.Split(articlePermissionPermissionName, ",")
  646. for _, v := range slice {
  647. if strings.Contains(companyPermission, v) {
  648. hasPersion = true
  649. }
  650. }
  651. userType, _, err := services.GetUserType(user.CompanyId)
  652. if err != nil {
  653. br.Msg = "获取信息失败"
  654. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  655. return
  656. }
  657. if userType == 1 && strings.Contains(detail.CategoryName, "研选") {
  658. hasPersion = false
  659. }
  660. if detail.IsReport == 1 {
  661. detailCategory, err := models.GetdetailByCategoryIdSando(detail.CategoryId)
  662. if err != nil && err.Error() != utils.ErrNoRow() {
  663. br.Msg = "获取信息失败"
  664. br.ErrMsg = "获取信息失败,Err:" + err.Error() + "categoryID 不存在:" + strconv.Itoa(detail.CategoryId)
  665. return
  666. }
  667. permissionStr, err := models.GetCompanyPermissionByUser(user.CompanyId)
  668. if err != nil {
  669. br.Msg = "获取信息失败"
  670. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  671. return
  672. }
  673. if detailCategory != nil {
  674. if detailCategory.PermissionType == 1 {
  675. if !strings.Contains(permissionStr, detailCategory.ChartPermissionName+"(主观)") {
  676. hasPersion = false
  677. }
  678. } else if detailCategory.PermissionType == 2 {
  679. if !strings.Contains(permissionStr, detailCategory.ChartPermissionName+"(客观)") {
  680. hasPersion = false
  681. }
  682. }
  683. }
  684. }
  685. if hasPersion {
  686. hasPermission = 1
  687. record := new(models.CygxArticleHistoryRecordNewpv)
  688. record.UserId = uid
  689. record.ArticleId = articleId
  690. record.CreateTime = time.Now()
  691. record.ModifyTime = time.Now()
  692. record.Mobile = user.Mobile
  693. record.Email = user.Email
  694. record.CompanyId = user.CompanyId
  695. record.CompanyName = user.CompanyName
  696. //新增浏览记录
  697. go models.AddCygxArticleViewRecordNewpv(record)
  698. //30分钟之内阅读同一篇文章不错二次推送
  699. key := "CYGX_ARTICLE_READ" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  700. if !utils.Rc.IsExist(key) {
  701. go services.ArticleUserRemind(user, detail, 1)
  702. utils.Rc.Put(key, 1, 30*time.Second)
  703. }
  704. }
  705. if hasPermission == 1 {
  706. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  707. if !utils.Rc.IsExist(key) {
  708. //新增浏览记录
  709. record := new(models.CygxArticleViewRecord)
  710. record.UserId = uid
  711. record.ArticleId = articleId
  712. record.CreateTime = time.Now()
  713. record.Mobile = user.Mobile
  714. record.Email = user.Email
  715. record.CompanyId = user.CompanyId
  716. record.CompanyName = user.CompanyName
  717. go models.AddCygxArticleViewRecord(record)
  718. utils.Rc.Put(key, 1, 5*time.Second)
  719. models.ModifyReportLastViewTime(uid)
  720. }
  721. }
  722. }
  723. //作者头像
  724. if detail.DepartmentId > 0 {
  725. departmentDetail, err := models.GetArticleDepartmentDateilById(detail.DepartmentId)
  726. if err == nil {
  727. detail.DepartmentImgUrl = departmentDetail.ImgUrl
  728. detail.NickName = departmentDetail.NickName
  729. }
  730. }
  731. }
  732. detail.SellerAndMobile = "" //业务需要强制处理为空
  733. resp.HasPermission = hasPermission
  734. if hasPermission == 1 {
  735. detail.Abstract, _ = services.GetReportContentTextSub(detail.Abstract)
  736. resp.Detail = detail
  737. } else {
  738. if user.Mobile != "" {
  739. resp.Mobile = user.Mobile
  740. } else {
  741. resp.Mobile = user.Email
  742. }
  743. }
  744. br.Ret = 200
  745. br.Success = true
  746. br.Msg = "获取成功"
  747. br.Data = resp
  748. }
  749. // @Title 上传文章阅读时间
  750. // @Description 上传文章阅读时间接口
  751. // @Param request body models.AddStopTimeRep true "type json string"
  752. // @Success 200 {object} models.ArticleDetailResp
  753. // @router /addStopTime [post]
  754. func (this *ArticleController) AddStopTime() {
  755. br := new(models.BaseResponse).Init()
  756. defer func() {
  757. this.Data["json"] = br
  758. this.ServeJSON()
  759. }()
  760. user := this.User
  761. if user == nil {
  762. br.Msg = "请登录"
  763. br.ErrMsg = "请登录,用户信息为空"
  764. br.Ret = 408
  765. return
  766. }
  767. var req models.AddStopTimeRep
  768. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  769. if err != nil {
  770. br.Msg = "参数解析异常!"
  771. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  772. return
  773. }
  774. uid := user.UserId
  775. articleId := req.ArticleId
  776. stopTime := req.StopTime
  777. outType := req.OutType
  778. source := req.Source
  779. if articleId <= 0 {
  780. br.Msg = "参数错误"
  781. br.ErrMsg = "参数错误"
  782. return
  783. }
  784. if stopTime == 0 {
  785. stopTime = 1
  786. }
  787. if outType != 2 {
  788. outType = 1
  789. }
  790. if source != "PC" {
  791. source = "MOBILE"
  792. }
  793. detail := new(models.ArticleDetail)
  794. hasPermission := 0
  795. hasFree := 0
  796. //判断是否已经申请过
  797. applyCount, err := models.GetApplyRecordCount(uid)
  798. if err != nil && err.Error() != utils.ErrNoRow() {
  799. br.Msg = "获取信息失败"
  800. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  801. return
  802. }
  803. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  804. if user.CompanyId > 1 {
  805. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  806. if err != nil {
  807. br.Msg = "获取信息失败"
  808. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  809. return
  810. }
  811. detail, err = models.GetArticleDetailById(articleId)
  812. if err != nil {
  813. br.Msg = "获取信息失败"
  814. br.ErrMsg = "获取文章信息失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  815. return
  816. }
  817. if companyPermission == "" {
  818. if applyCount > 0 {
  819. hasPermission = 5
  820. } else {
  821. hasPermission = 2
  822. }
  823. hasFree = 2
  824. goto Loop
  825. } else {
  826. hasFree = 1
  827. var articlePermissionPermissionName string
  828. if detail.CategoryId > 0 {
  829. articlePermission, err := models.GetArticlePermission(detail.CategoryId)
  830. if err != nil {
  831. br.Msg = "获取信息失败"
  832. br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  833. return
  834. }
  835. if articlePermission == nil {
  836. br.Msg = "获取信息失败"
  837. br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  838. return
  839. }
  840. articlePermissionPermissionName = articlePermission.PermissionName
  841. } else {
  842. articlePermissionPermissionName = detail.CategoryName
  843. }
  844. var hasPersion bool
  845. slice := strings.Split(articlePermissionPermissionName, ",")
  846. for _, v := range slice {
  847. if strings.Contains(companyPermission, v) {
  848. hasPersion = true
  849. }
  850. }
  851. if hasPersion {
  852. detailNew, err := models.GetNewArticleHistoryRecord(uid, articleId)
  853. if err == nil {
  854. hasPermission = 1
  855. historyRecord := new(models.AddStopTimeNewRep)
  856. historyRecord.StopTime = detailNew.StopTime + stopTime
  857. historyRecord.Id = detailNew.Id
  858. historyRecord.OutType = outType
  859. go models.UpdateArticleStopTime(historyRecord)
  860. }
  861. //不统计本公司的阅读记录、正常退出的不做时间差统计
  862. if stopTime > 3 {
  863. key := "CYGX_ARTICLE_PV" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid) + "_" + strconv.Itoa(user.CompanyId) + "_" + strconv.Itoa(outType)
  864. record := new(models.CygxArticleHistoryRecordNewpv)
  865. record.UserId = uid
  866. record.ArticleId = articleId
  867. record.CreateTime = time.Now().Add(-time.Second * time.Duration(stopTime))
  868. record.ModifyTime = time.Now()
  869. record.Mobile = user.Mobile
  870. record.Email = user.Email
  871. record.CompanyId = user.CompanyId
  872. record.CompanyName = user.CompanyName
  873. record.StopTime = stopTime
  874. record.OutType = outType
  875. record.Source = source
  876. if !utils.Rc.IsExist(key) || outType != 2 {
  877. //新增浏览记录
  878. go models.AddCygxArticleViewRecordNewpv(record)
  879. recordRedis := new(services.ReportViewRecord)
  880. recordRedis.UserId = user.UserId
  881. recordRedis.ReportId = articleId
  882. recordRedis.Mobile = user.Mobile
  883. recordRedis.Email = user.Email
  884. recordRedis.RealName = user.RealName
  885. recordRedis.CompanyName = user.CompanyName
  886. recordRedis.CreateTime = time.Now().Add(-time.Second * time.Duration(stopTime))
  887. go services.PushViewRecordNewRedisData(recordRedis, user.CompanyId)
  888. } else {
  889. go models.UpdateCygxArticleViewRecordNewpv(record, stopTime)
  890. }
  891. utils.Rc.Put(key, 1, 10*time.Minute)
  892. }
  893. models.ModifyReportLastViewTime(uid)
  894. } else { //无该行业权限
  895. hasPermission = 3
  896. }
  897. }
  898. } else { //潜在客户
  899. if applyCount > 0 {
  900. hasPermission = 5
  901. } else {
  902. hasPermission = 4
  903. }
  904. }
  905. Loop:
  906. resp := new(models.ArticleDetailAddStopTimeRep)
  907. resp.HasPermission = hasPermission
  908. resp.HasFree = hasFree
  909. br.Ret = 200
  910. br.Success = true
  911. br.Msg = "操作成功"
  912. br.Data = resp
  913. }
  914. // @Title 文章带问
  915. // @Description 新增文章带问接口
  916. // @Param request body models.AddArticleAskRep true "type json string"
  917. // @Success Ret=200 新增成功
  918. // @router /askAdd [post]
  919. func (this *ArticleController) AskAdd() {
  920. br := new(models.BaseResponse).Init()
  921. defer func() {
  922. this.Data["json"] = br
  923. this.ServeJSON()
  924. }()
  925. user := this.User
  926. if user == nil {
  927. br.Msg = "请登录"
  928. br.ErrMsg = "请登录,SysUser Is Empty"
  929. br.Ret = 408
  930. return
  931. }
  932. var req models.AddArticleAskRep
  933. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  934. if err != nil {
  935. br.Msg = "参数解析异常!"
  936. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  937. return
  938. }
  939. if req.Content == "" {
  940. br.Msg = "建议内容不可为空"
  941. return
  942. }
  943. content := req.Content
  944. itemToken, err := services.WxGetToken()
  945. if err != nil {
  946. br.Msg = "GetWxAccessToken Err:" + err.Error()
  947. return
  948. }
  949. if itemToken.AccessToken == "" {
  950. br.Msg = "accessToken is empty"
  951. return
  952. }
  953. commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  954. if err != nil {
  955. br.Msg = "内容校验失败!"
  956. br.ErrMsg = "内容校验失败,Err:" + err.Error()
  957. return
  958. }
  959. if commerr.ErrCode != 0 {
  960. br.Msg = "内容违规,请重新提交!"
  961. br.ErrMsg = "颜文字内容违规,Err:" + commerr.ErrMSG
  962. return
  963. }
  964. articleId := req.ArticleId
  965. count, _ := models.GetArticleCountById(articleId)
  966. if count == 0 {
  967. br.Msg = "操作失败"
  968. br.ErrMsg = "文章ID错误,不存在 articleId:" + strconv.Itoa(articleId)
  969. return
  970. }
  971. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  972. if err != nil {
  973. br.Msg = "提交失败!"
  974. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  975. return
  976. }
  977. if companyDetail == nil {
  978. br.Msg = "提交失败!"
  979. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  980. return
  981. }
  982. item := new(models.CygxArticleAsk)
  983. item.UserId = user.UserId
  984. item.ArticleId = req.ArticleId
  985. item.CompanyId = user.CompanyId
  986. item.CompanyName = companyDetail.CompanyName
  987. item.CreateTime = time.Now()
  988. item.Mobile = user.Mobile
  989. item.Email = user.Email
  990. item.Content = content
  991. _, err = models.AddArticleAsk(item)
  992. if err != nil {
  993. br.Msg = "提交失败"
  994. br.ErrMsg = "提交失败,Err:" + err.Error()
  995. return
  996. }
  997. companyItem, err := models.GetSellerDetailAllByCompanyId(user.CompanyId)
  998. if err != nil {
  999. br.Msg = "获取信息失败"
  1000. br.ErrMsg = "获取所属销售信息失败,Err:" + err.Error()
  1001. return
  1002. }
  1003. var mobile string
  1004. if utils.RunMode == "release" {
  1005. //mobile = utils.WxMsgTemplateIdAskMsgMobileAll + "," + companyItem.Mobile
  1006. mobile = utils.WxMsgTemplateIdAskMsgMobileAll
  1007. } else {
  1008. mobile = utils.WxMsgTemplateIdAskMsgMobile
  1009. }
  1010. openIdList, err := models.GetWxOpenIdByMobileList(mobile)
  1011. if err != nil {
  1012. br.Msg = "提交失败"
  1013. br.ErrMsg = "提交失败,Err:" + err.Error()
  1014. return
  1015. }
  1016. detail, err := models.GetArticleDetailById(articleId)
  1017. if err != nil {
  1018. br.Msg = "获取信息失败"
  1019. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1020. return
  1021. }
  1022. companyName := user.CompanyName + "-" + user.RealName + "(" + companyItem.SellerName + ")"
  1023. go services.SendWxMsgWithAsk(companyName, time.Now().Format(utils.FormatDateTime), content, detail.Title, openIdList, req.ArticleId)
  1024. br.Ret = 200
  1025. br.Success = true
  1026. br.Msg = "提交成功"
  1027. }
  1028. // @Title 下载PDF打水印
  1029. // @Description 下载PDF打水印接口
  1030. // @Param ArticleId query int true "报告ID"
  1031. // @Success 200 {object} models.ArticleDetailFileLink
  1032. // @router /pdfwatermark [get]
  1033. func (this *ArticleController) Pdfwatermark() {
  1034. br := new(models.BaseResponse).Init()
  1035. defer func() {
  1036. this.Data["json"] = br
  1037. this.ServeJSON()
  1038. }()
  1039. user := this.User
  1040. if user == nil {
  1041. br.Msg = "请登录"
  1042. br.ErrMsg = "请登录,用户信息为空"
  1043. br.Ret = 408
  1044. return
  1045. }
  1046. uid := user.UserId
  1047. articleId, err := this.GetInt("ArticleId")
  1048. if articleId <= 0 {
  1049. br.Msg = "文章不存在"
  1050. br.ErrMsg = "文章不存在,文章ID错误"
  1051. return
  1052. }
  1053. //缓存校验
  1054. cacheKey := fmt.Sprint("xygx:apply_record:add:", uid, "ArticleId_", articleId)
  1055. ttlTime := utils.Rc.GetRedisTTL(cacheKey)
  1056. if ttlTime > 0 && user.CompanyId != 16 {
  1057. br.Msg = "下载失败,下载过于频繁"
  1058. br.ErrMsg = "下载失败,下载过于频繁:mobile" + user.Mobile
  1059. return
  1060. }
  1061. resp := new(models.ArticleDetailFileLink)
  1062. detail := new(models.ArticleDetail)
  1063. detail, err = models.GetArticleDetailById(articleId)
  1064. if err != nil {
  1065. br.Msg = "获取信息失败"
  1066. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1067. return
  1068. }
  1069. fileLink := detail.FileLink
  1070. if fileLink == "" {
  1071. br.Msg = "下载失败"
  1072. br.ErrMsg = "下载失败,报告链接不存在"
  1073. return
  1074. }
  1075. mobile := user.Mobile
  1076. if mobile == "" {
  1077. mobile = user.Email
  1078. }
  1079. sliceLink := strings.Split(fileLink, "/")
  1080. uploadDir := "static/pdf/"
  1081. //判断文件夹是否存在,不存在则创建
  1082. if !utils.FileIsExist(uploadDir) {
  1083. err = os.MkdirAll(uploadDir, 0755)
  1084. if err != nil {
  1085. br.Msg = "下载失败"
  1086. br.ErrMsg = "存储目录创建失败,Err:" + err.Error()
  1087. return
  1088. }
  1089. }
  1090. var oldFile string
  1091. var newFile string
  1092. //获取PDF源文件名称
  1093. pdfName := sliceLink[len(sliceLink)-1]
  1094. pdfName = utils.MD5(pdfName) + ".pdf"
  1095. oldFile = uploadDir + pdfName
  1096. //判断PDF本地是否存在,不存在则保存到本地
  1097. if !utils.FileIsExist(oldFile) {
  1098. res, err := nhttp.Get(fileLink)
  1099. if err != nil {
  1100. br.Msg = "下载失败"
  1101. br.ErrMsg = "获取源文件失败,Err:" + err.Error()
  1102. return
  1103. }
  1104. defer res.Body.Close()
  1105. // 获得get请求响应的reader对象
  1106. reader := bufio.NewReaderSize(res.Body, 32*1024)
  1107. file, err := os.Create(oldFile)
  1108. if err != nil {
  1109. br.Msg = "下载失败"
  1110. br.ErrMsg = "保存源文件到本地失败,Err:" + err.Error()
  1111. return
  1112. }
  1113. defer file.Close()
  1114. //获得文件的writer对象
  1115. writer := bufio.NewWriter(file)
  1116. written, _ := io.Copy(writer, reader)
  1117. fmt.Printf("Total length: %d", written)
  1118. }
  1119. newFile = uploadDir + "new_" + pdfName
  1120. onTop := true
  1121. wm, err := pdfcpu.ParseTextWatermarkDetails(mobile, " op:.4, pos:c ,points:16 ", onTop, 1)
  1122. if err != nil {
  1123. br.Msg = "下载失败"
  1124. br.ErrMsg = "生成水印文件失败,Err:" + err.Error()
  1125. return
  1126. }
  1127. err = api.AddWatermarksFile(oldFile, newFile, nil, wm, nil)
  1128. if err != nil {
  1129. //br.Msg = "下载失败"
  1130. //br.ErrMsg = "生成水印PDF失败,Err:" + err.Error()
  1131. resp.FileLink = fileLink
  1132. br.Ret = 200
  1133. br.Success = true
  1134. br.Msg = "获取成功"
  1135. br.Data = resp
  1136. return
  1137. }
  1138. randStr := utils.GetRandStringNoSpecialChar(28)
  1139. fileName := randStr + ".pdf"
  1140. savePath := uploadDir + time.Now().Format("200601/20060102/")
  1141. savePath += fileName
  1142. //上传到阿里云
  1143. err = services.UploadFileToAliyun(fileName, newFile, savePath)
  1144. if err != nil {
  1145. br.Msg = "下载失败"
  1146. br.ErrMsg = "文件上传失败,Err:" + err.Error()
  1147. return
  1148. }
  1149. fileHost := "https://hzstatic.hzinsights.com/"
  1150. resourceUrl := fileHost + savePath
  1151. defer func() {
  1152. os.Remove(newFile)
  1153. }()
  1154. utils.Rc.SetNX(cacheKey, user.Mobile, time.Minute*5)
  1155. resp.FileLink = resourceUrl
  1156. br.Ret = 200
  1157. br.Success = true
  1158. br.Msg = "获取成功"
  1159. br.Data = resp
  1160. }
  1161. // @Title 获取报告详情(无需token)
  1162. // @Description 获取报告详情接口
  1163. // @Param ArticleId query int true "报告ID"
  1164. // @Param CompanyCode query string false "机构编号"
  1165. // @Param CompanyName query string false "机构名称"
  1166. // @Param Email query string false "邮箱"
  1167. // @Param Sign query string false "加密签名"
  1168. // @Success 200 {object} models.ArticleDetailHtgjResp
  1169. // @router /detailPublic [get]
  1170. func (this *ArticleCommonController) DetailPublic() {
  1171. br := new(models.BaseResponse).Init()
  1172. defer func() {
  1173. this.Data["json"] = br
  1174. this.ServeJSON()
  1175. }()
  1176. articleId, _ := this.GetInt("ArticleId")
  1177. companyCode := this.GetString("CompanyCode")
  1178. companyNameHt := this.GetString("CompanyName")
  1179. email := this.GetString("Email")
  1180. sign := this.GetString("Sign")
  1181. resp := new(models.ArticleDetailHtgjResp)
  1182. if companyCode == "" || email == "" {
  1183. resp.HasPermission = 2
  1184. br.Ret = 200
  1185. br.Success = true
  1186. br.Msg = "获取成功"
  1187. br.Data = resp
  1188. return
  1189. }
  1190. if articleId <= 0 {
  1191. br.Msg = "文章不存在"
  1192. br.ErrMsg = "文章不存在,文章ID错误"
  1193. return
  1194. }
  1195. errMsg, err, wxUser, companyName := services.CheckHtgj(companyCode, companyNameHt, email, sign)
  1196. if errMsg != "" {
  1197. br.Msg = errMsg
  1198. return
  1199. }
  1200. companyPermission, err := models.GetCompanyPermission(wxUser.CompanyId)
  1201. if err != nil {
  1202. br.Msg = "获取信息失败"
  1203. br.ErrMsg = "获取用户权限失败,Err:" + err.Error() + ";articleId" + strconv.Itoa(articleId)
  1204. return
  1205. }
  1206. hasPermission := 0
  1207. uid := wxUser.UserId
  1208. detail, err := models.GetArticleDetailById(articleId)
  1209. if err != nil {
  1210. br.Msg = "获取信息失败"
  1211. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1212. return
  1213. }
  1214. detail.Body = html.UnescapeString(detail.Body)
  1215. detail.Body = strings.Replace(detail.Body, "<p data-f-id=\"pbf\" style=\"text-align: center; font-size: 14px; margin-top: 30px; opacity: 0.65; font-family: sans-serif;\">Powered by <a href=\"https://www.froala.com/wysiwyg-editor?pb=1\" title=\"Froala Editor\">Froala Editor</a></p>", "", -1)
  1216. detail.Body = strings.Replace(detail.Body, "pre", "div", -1)
  1217. detail.Abstract, _ = services.GetReportContentTextSub(detail.Abstract)
  1218. var articlePermissionPermissionName string
  1219. if detail.CategoryId > 0 {
  1220. articlePermission, err := models.GetArticlePermission(detail.CategoryId)
  1221. if err != nil {
  1222. br.Msg = "获取信息失败"
  1223. br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(wxUser.UserId) + ";articleId" + strconv.Itoa(articleId)
  1224. return
  1225. }
  1226. if articlePermission == nil {
  1227. br.Msg = "获取信息失败"
  1228. br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(wxUser.UserId) + ";articleId" + strconv.Itoa(articleId)
  1229. return
  1230. }
  1231. articlePermissionPermissionName = articlePermission.PermissionName
  1232. } else {
  1233. articlePermissionPermissionName = detail.CategoryName
  1234. }
  1235. var hasPersion bool
  1236. slice := strings.Split(articlePermissionPermissionName, ",")
  1237. for _, v := range slice {
  1238. if strings.Contains(companyPermission, v) {
  1239. hasPersion = true
  1240. }
  1241. }
  1242. if hasPersion {
  1243. hasPermission = 1
  1244. }
  1245. if strings.Contains(detail.CategoryName, "研选") {
  1246. detail.IsResearch = true
  1247. }
  1248. resp.HasPermission = hasPermission
  1249. if hasPermission == 1 {
  1250. //获取销售手机号
  1251. sellerItem, err := models.GetSellerByCompanyId(wxUser.CompanyId)
  1252. if err != nil {
  1253. br.Msg = "获取信息失败"
  1254. br.ErrMsg = "获取销售数据失败2,Err:" + strconv.Itoa(wxUser.UserId) + ";articleId" + strconv.Itoa(articleId)
  1255. return
  1256. }
  1257. if sellerItem != nil {
  1258. detail.SellerMobile = sellerItem.Mobile
  1259. detail.SellerName = sellerItem.RealName
  1260. }
  1261. sellerList, err := models.GetSellerList(articleId)
  1262. if err != nil {
  1263. br.Msg = "获取信息失败"
  1264. br.ErrMsg = "获取销售数据失败,Err:" + err.Error() + strconv.Itoa(wxUser.UserId) + ";articleId" + strconv.Itoa(articleId)
  1265. return
  1266. }
  1267. if detail.ArticleId >= utils.SummaryArticleId && strings.Contains(detail.SellerAndMobile, "-") {
  1268. strnum := strings.Index(detail.SellerAndMobile, "-")
  1269. detail.SellerAndMobile = detail.SellerAndMobile[0:strnum]
  1270. if strnum > 0 {
  1271. nickName := detail.SellerAndMobile[0:strnum]
  1272. sellerAndMobile := &models.SellerRep{
  1273. SellerMobile: "",
  1274. SellerName: nickName,
  1275. }
  1276. sellerList = append(sellerList, sellerAndMobile)
  1277. }
  1278. }
  1279. detail.SellerList = sellerList
  1280. resp.Detail = detail
  1281. historyRecord := new(models.CygxArticleHistoryRecord)
  1282. historyRecord.UserId = wxUser.UserId
  1283. historyRecord.ArticleId = articleId
  1284. historyRecord.CreateTime = time.Now()
  1285. historyRecord.Mobile = wxUser.Mobile
  1286. historyRecord.Email = wxUser.Email
  1287. historyRecord.CompanyId = wxUser.CompanyId
  1288. historyRecord.CompanyName = companyName
  1289. recordCount, _ := models.GetNoAddStoptimeArticleCount(wxUser.UserId, articleId)
  1290. if recordCount == 0 {
  1291. go models.AddCygxArticleHistoryRecord(historyRecord)
  1292. } else {
  1293. detailNew, err := models.GetNewArticleHistoryRecord(wxUser.UserId, articleId)
  1294. if err != nil {
  1295. br.Msg = "获取信息失败"
  1296. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1297. return
  1298. }
  1299. if detailNew.StopTime > 0 {
  1300. go models.AddCygxArticleHistoryRecord(historyRecord)
  1301. }
  1302. }
  1303. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(wxUser.UserId)
  1304. if !utils.Rc.IsExist(key) {
  1305. //新增浏览记录
  1306. record := new(models.CygxArticleViewRecord)
  1307. record.UserId = wxUser.UserId
  1308. record.ArticleId = articleId
  1309. record.CreateTime = time.Now()
  1310. record.Mobile = wxUser.Mobile
  1311. record.Email = wxUser.Email
  1312. record.CompanyId = wxUser.CompanyId
  1313. record.CompanyName = companyName
  1314. go models.AddCygxArticleViewRecord(record)
  1315. utils.Rc.Put(key, 1, 5*time.Second)
  1316. models.ModifyReportLastViewTime(wxUser.UserId)
  1317. }
  1318. if detail.ArticleId < utils.SummaryArticleId {
  1319. chartUserTokenByMobile, _ := services.GetUserTokenByMobile(utils.HtgjPublicMobile)
  1320. detail.HttpUrl = utils.StrategyPlatform + strconv.Itoa(articleId) + "?token=" + chartUserTokenByMobile
  1321. detail.IsNeedJump = true
  1322. }
  1323. if detail.ArticleId < utils.SummaryArticleId {
  1324. chartUserTokenByMobile, _ := services.GetUserTokenByMobile(utils.HtgjPublicMobile)
  1325. detail.HttpUrl = utils.StrategyPlatform + strconv.Itoa(articleId) + "?token=" + chartUserTokenByMobile
  1326. detail.IsNeedJump = true
  1327. }
  1328. collectCount, err := models.GetArticleCollectCount(uid, articleId)
  1329. if err != nil && err.Error() != utils.ErrNoRow() {
  1330. br.Msg = "获取信息失败"
  1331. br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1332. return
  1333. }
  1334. if collectCount > 0 {
  1335. detail.IsCollect = true
  1336. }
  1337. interviewApplyItem, err := models.GetArticleInterviewApply(uid, articleId)
  1338. if err != nil && err.Error() != utils.ErrNoRow() {
  1339. br.Msg = "获取信息失败"
  1340. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1341. return
  1342. }
  1343. if interviewApplyItem != nil && interviewApplyItem.InterviewApplyId > 0 {
  1344. detail.IsInterviewApply = true
  1345. detail.InterviewApplyStatus = interviewApplyItem.Status
  1346. }
  1347. articleFollowdetail, err := models.GetArticleFollowDetail(articleId, uid)
  1348. if err != nil {
  1349. br.Msg = "获取信息失败"
  1350. br.ErrMsg = "获取关注信息失败,Err:" + err.Error()
  1351. return
  1352. }
  1353. detail.FollowNum = articleFollowdetail.DNum
  1354. detail.CollectionNum = articleFollowdetail.AcNum
  1355. resp.Detail = detail
  1356. }
  1357. resp.CompanyName = companyName
  1358. br.Ret = 200
  1359. br.Success = true
  1360. br.Msg = "获取成功"
  1361. br.Data = resp
  1362. }
  1363. // @Title 上传文章阅读时间(无需token)
  1364. // @Description 上传文章阅读时间接口(无需token)
  1365. // @Param request body models.AddStopTimeHtgjRep true "type json string"
  1366. // @Success 200 {object} models.ArticleDetailResp
  1367. // @router /addStopTimePublic [post]
  1368. func (this *ArticleCommonController) AddStopTimePublic() {
  1369. br := new(models.BaseResponse).Init()
  1370. defer func() {
  1371. this.Data["json"] = br
  1372. this.ServeJSON()
  1373. }()
  1374. var req models.AddStopTimeHtgjRep
  1375. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1376. if err != nil {
  1377. br.Msg = "参数解析异常!"
  1378. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1379. return
  1380. }
  1381. articleId := req.ArticleId
  1382. stopTime := req.StopTime
  1383. outType := req.OutType
  1384. source := req.Source
  1385. companyCode := req.CompanyCode
  1386. companyName := req.CompanyName
  1387. wxuUserName := req.Email
  1388. sign := req.Sign
  1389. if companyCode == "" || companyName == "" || wxuUserName == "" || sign == "" {
  1390. br.Msg = "上传失败"
  1391. br.ErrMsg = "必填参数不能为空"
  1392. return
  1393. }
  1394. companyNameHt := companyCode + "_" + companyName
  1395. errMsg := services.CheckSign(companyCode+companyName+wxuUserName, sign)
  1396. if errMsg != "" {
  1397. br.Msg = errMsg
  1398. return
  1399. }
  1400. companyInfo, err := models.GetCompanyByThirdName(companyNameHt)
  1401. if err != nil {
  1402. br.Msg = "获取信息失败"
  1403. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  1404. return
  1405. }
  1406. user, err := models.GetUserByThirdName(companyInfo.CompanyId, wxuUserName)
  1407. if err != nil {
  1408. br.Msg = "获取信息失败"
  1409. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1410. return
  1411. }
  1412. uid := user.UserId
  1413. if articleId <= 0 {
  1414. br.Msg = "文章ID不存在"
  1415. br.ErrMsg = "参数错误"
  1416. return
  1417. }
  1418. if stopTime == 0 {
  1419. stopTime = 1
  1420. }
  1421. if outType != 2 {
  1422. outType = 1
  1423. }
  1424. if source != "PC" {
  1425. source = "MOBILE"
  1426. }
  1427. detail := new(models.ArticleDetail)
  1428. hasPermission := 0
  1429. hasFree := 0
  1430. //判断是否已经申请过
  1431. applyCount, err := models.GetApplyRecordCount(uid)
  1432. if err != nil && err.Error() != utils.ErrNoRow() {
  1433. br.Msg = "获取信息失败"
  1434. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1435. return
  1436. }
  1437. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  1438. if user.CompanyId > 1 {
  1439. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  1440. if err != nil {
  1441. br.Msg = "获取信息失败"
  1442. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1443. return
  1444. }
  1445. detail, err = models.GetArticleDetailById(articleId)
  1446. if err != nil {
  1447. br.Msg = "获取信息失败"
  1448. br.ErrMsg = "获取文章信息失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1449. return
  1450. }
  1451. if companyPermission == "" {
  1452. if applyCount > 0 {
  1453. hasPermission = 5
  1454. } else {
  1455. hasPermission = 2
  1456. }
  1457. hasFree = 2
  1458. goto Loop
  1459. } else {
  1460. hasFree = 1
  1461. var articlePermissionPermissionName string
  1462. if detail.CategoryId > 0 {
  1463. articlePermission, err := models.GetArticlePermission(detail.CategoryId)
  1464. if err != nil {
  1465. br.Msg = "获取信息失败"
  1466. br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1467. return
  1468. }
  1469. if articlePermission == nil {
  1470. br.Msg = "获取信息失败"
  1471. br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1472. return
  1473. }
  1474. articlePermissionPermissionName = articlePermission.PermissionName
  1475. } else {
  1476. articlePermissionPermissionName = detail.CategoryName
  1477. }
  1478. var hasPersion bool
  1479. slice := strings.Split(articlePermissionPermissionName, ",")
  1480. for _, v := range slice {
  1481. if strings.Contains(companyPermission, v) {
  1482. hasPersion = true
  1483. }
  1484. }
  1485. if hasPersion {
  1486. detailNew, err := models.GetNewArticleHistoryRecord(uid, articleId)
  1487. if err == nil {
  1488. hasPermission = 1
  1489. historyRecord := new(models.AddStopTimeNewRep)
  1490. historyRecord.StopTime = detailNew.StopTime + stopTime
  1491. historyRecord.Id = detailNew.Id
  1492. historyRecord.OutType = outType
  1493. go models.UpdateArticleStopTime(historyRecord)
  1494. }
  1495. //不统计本公司的阅读记录、正常退出的不做时间差统计
  1496. if user.CompanyId != 16 && stopTime > 3 {
  1497. key := "CYGX_ARTICLE_PV" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid) + "_" + strconv.Itoa(user.CompanyId) + "_" + strconv.Itoa(outType)
  1498. record := new(models.CygxArticleHistoryRecordNewpv)
  1499. record.UserId = uid
  1500. record.ArticleId = articleId
  1501. record.CreateTime = time.Now().Add(-time.Second * time.Duration(stopTime))
  1502. record.ModifyTime = time.Now()
  1503. record.Mobile = user.Mobile
  1504. record.Email = user.Email
  1505. record.CompanyId = user.CompanyId
  1506. record.CompanyName = companyInfo.CompanyName
  1507. record.StopTime = stopTime
  1508. record.OutType = outType
  1509. record.Source = source
  1510. if !utils.Rc.IsExist(key) || outType != 2 {
  1511. //新增浏览记录
  1512. go models.AddCygxArticleViewRecordNewpv(record)
  1513. recordRedis := new(services.ReportViewRecord)
  1514. recordRedis.UserId = user.UserId
  1515. recordRedis.ReportId = articleId
  1516. recordRedis.Mobile = user.Mobile
  1517. recordRedis.Email = user.Email
  1518. recordRedis.RealName = user.RealName
  1519. recordRedis.CompanyName = companyName
  1520. recordRedis.CreateTime = time.Now().Add(-time.Second * time.Duration(stopTime))
  1521. go services.PushViewRecordNewRedisData(recordRedis, user.CompanyId)
  1522. } else {
  1523. go models.UpdateCygxArticleViewRecordNewpv(record, stopTime)
  1524. }
  1525. utils.Rc.Put(key, 1, 10*time.Minute)
  1526. }
  1527. models.ModifyReportLastViewTime(uid)
  1528. } else { //无该行业权限
  1529. hasPermission = 3
  1530. }
  1531. }
  1532. } else { //潜在客户
  1533. if applyCount > 0 {
  1534. hasPermission = 5
  1535. } else {
  1536. hasPermission = 4
  1537. }
  1538. }
  1539. Loop:
  1540. resp := new(models.ArticleDetailAddStopTimeRep)
  1541. resp.HasPermission = hasPermission
  1542. resp.HasFree = hasFree
  1543. br.Ret = 200
  1544. br.Success = true
  1545. br.Msg = "操作成功"
  1546. br.Data = resp
  1547. }
  1548. // @Title 页面访问统计(无需token)
  1549. // @Description 上传页面访问统计(无需token)
  1550. // @Param request body models.CygxPageHistoryRecordHtgjRep true "type json string"
  1551. // @Success Ret=200 新增成功
  1552. // @router /pageHistoryPublic [post]
  1553. func (this *ArticleCommonController) PageHistoryPublic() {
  1554. br := new(models.BaseResponse).Init()
  1555. defer func() {
  1556. this.Data["json"] = br
  1557. this.ServeJSON()
  1558. }()
  1559. var req models.CygxPageHistoryRecordHtgjRep
  1560. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1561. if err != nil {
  1562. br.Msg = "参数解析异常!"
  1563. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1564. return
  1565. }
  1566. companyCode := req.CompanyCode
  1567. companyName := req.CompanyName
  1568. wxuUserName := req.Email
  1569. sign := req.Sign
  1570. if companyCode == "" || companyName == "" || wxuUserName == "" || sign == "" {
  1571. br.Msg = "上传失败"
  1572. br.ErrMsg = "必填参数不能为空"
  1573. return
  1574. }
  1575. companyNameHt := companyCode + "_" + companyName
  1576. errMsg := services.CheckSign(companyCode+companyName+wxuUserName, sign)
  1577. if errMsg != "" {
  1578. br.Msg = errMsg
  1579. return
  1580. }
  1581. companyInfo, err := models.GetCompanyByThirdName(companyNameHt)
  1582. if err != nil {
  1583. br.Msg = "获取信息失败"
  1584. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  1585. return
  1586. }
  1587. user, err := models.GetUserByThirdName(companyInfo.CompanyId, wxuUserName)
  1588. if err != nil {
  1589. br.Msg = "获取信息失败"
  1590. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1591. return
  1592. }
  1593. item := new(models.CygxPageHistoryRecord)
  1594. item.UserId = user.UserId
  1595. item.CreateTime = time.Now()
  1596. item.Mobile = user.Mobile
  1597. item.Email = user.Email
  1598. item.CompanyId = user.CompanyId
  1599. item.CompanyName = companyName
  1600. item.DetailId = req.DetailId
  1601. item.ChartPermissionId = req.ChartPermissionId
  1602. item.IndustrialManagementId = req.IndustrialManagementId
  1603. item.PageType = "ArticleCopy"
  1604. _, err = models.AddCygxPageHistoryRecord(item)
  1605. if err != nil {
  1606. br.Msg = "记录信息失败"
  1607. br.ErrMsg = "新增访问记录失败,Err:" + err.Error()
  1608. return
  1609. }
  1610. br.Ret = 200
  1611. br.Success = true
  1612. br.Msg = "新增成功"
  1613. }