123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- package services
- import (
- "hongze/hongze_clpt/models"
- "hongze/hongze_clpt/utils"
- "strconv"
- "strings"
- "time"
- )
- // GetBannerUrlBody 处理banner的连接并做跳转处理
- func GetBannerUrlBody(url string) (itemResp *models.BannerUrlResp) {
- //2:文章详情 https://web.hzinsights.com/material/info/8436
- //3:活动详情 https://web.hzinsights.com/activity/detail/2701
- //4:产业详情 https://web.hzinsights.com/indepth/info/20/79
- //5:关于我们 https://clpttest.hzinsights.com/about
- //6:产品内测 https://clpttest.hzinsights.com/internal/article/29
- material := "material/info"
- activity := "activity/detail"
- indepth := "indepth/info"
- about := "/about"
- internal := "internal/article"
- item := new(models.BannerUrlResp)
- item.Body = url
- urlSlice := strings.Split(url, "/")
- lenurlSlice := len(urlSlice)
- sourceId, _ := strconv.Atoi(urlSlice[lenurlSlice-1])
- item.SourceId = sourceId
- if strings.Contains(url, material) {
- item.Type = 2
- } else if strings.Contains(url, activity) {
- item.Type = 3
- } else if strings.Contains(url, indepth) {
- if lenurlSlice >= 2 {
- chartPermissionId, _ := strconv.Atoi(urlSlice[lenurlSlice-2])
- item.ChartPermissionId = chartPermissionId
- }
- item.Type = 4
- } else if strings.Contains(url, about) {
- item.Type = 5
- } else if strings.Contains(url, internal) {
- item.Type = 6
- } else {
- item.Type = 1
- }
- itemResp = item
- return
- }
- func AddCygxBannerHistory(user *models.WxUserItem, bannerId int) (err error) {
- defer func() {
- if err != nil {
- go utils.SendAlarmMsg("产品内测用户浏览信息记录失败"+err.Error(), 2)
- }
- }()
- historyRecord := new(models.CygxBannerHistory)
- historyRecord.UserId = user.UserId
- historyRecord.BannerId = bannerId
- historyRecord.CreateTime = time.Now()
- historyRecord.Mobile = user.Mobile
- historyRecord.Email = user.Email
- historyRecord.CompanyId = user.CompanyId
- historyRecord.CompanyName = user.CompanyName
- historyRecord.RegisterPlatform = utils.REGISTER_PLATFORM
- sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
- if err != nil && err.Error() != utils.ErrNoRow() {
- return
- }
- historyRecord.RealName = user.RealName
- if sellerItem != nil {
- historyRecord.SellerName = sellerItem.RealName
- }
- _, err = models.AddCygxBannerHistory(historyRecord)
- return
- }
|