product_interior.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package services
  2. import (
  3. "hongze/hongze_cygx/models"
  4. "hongze/hongze_cygx/utils"
  5. "strconv"
  6. "strings"
  7. "time"
  8. )
  9. // GetProductInteriorUrl 处理产品内测中的连接并做跳转处理
  10. func GetProductInteriorUrl(url string, urlMap map[string]string) (itemResp *models.ProductInteriorUrlResp) {
  11. //2:文章详情 https://web.hzinsights.com/material/info/8436
  12. //3:活动详情 https://web.hzinsights.com/activity/detail/2701
  13. //4:产业详情 https://web.hzinsights.com/indepth/info/20/79
  14. item := new(models.ProductInteriorUrlResp)
  15. item.Body = url
  16. if urlMap[url] == "" {
  17. item.Type = 1
  18. } else {
  19. urlSlice := strings.Split(url, "/")
  20. lenurlSlice := len(urlSlice)
  21. sourceId, _ := strconv.Atoi(urlSlice[lenurlSlice-1])
  22. item.SourceId = sourceId
  23. if strings.Contains(url, "material/info") {
  24. item.Type = 2
  25. } else if strings.Contains(url, "activity/detail") {
  26. item.Type = 3
  27. } else if strings.Contains(url, "indepth/info") {
  28. if lenurlSlice >= 2 {
  29. chartPermissionId, _ := strconv.Atoi(urlSlice[lenurlSlice-2])
  30. item.ChartPermissionId = chartPermissionId
  31. }
  32. item.Type = 4
  33. }
  34. }
  35. itemResp = item
  36. return
  37. }
  38. func AddCygxProductInteriorHistory(user *models.WxUserItem, articleId int) (err error) {
  39. defer func() {
  40. if err != nil {
  41. go utils.SendAlarmMsg("产品内测用户浏览信息记录失败"+err.Error(), 2)
  42. }
  43. }()
  44. historyRecord := new(models.CygxProductInteriorHistory)
  45. historyRecord.UserId = user.UserId
  46. historyRecord.ProductInteriorId = articleId
  47. historyRecord.CreateTime = time.Now()
  48. historyRecord.Mobile = user.Mobile
  49. historyRecord.Email = user.Email
  50. historyRecord.CompanyId = user.CompanyId
  51. historyRecord.CompanyName = user.CompanyName
  52. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  53. if err != nil && err.Error() != utils.ErrNoRow() {
  54. return
  55. }
  56. historyRecord.RealName = user.RealName
  57. if sellerItem != nil {
  58. historyRecord.SellerName = sellerItem.RealName
  59. }
  60. _, err = models.AddCygxProductInteriorHistory(historyRecord)
  61. return
  62. }