|
@@ -0,0 +1,71 @@
|
|
|
+package services
|
|
|
+
|
|
|
+import (
|
|
|
+ "hongze/hongze_cygx/models"
|
|
|
+ "hongze/hongze_cygx/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
|
|
|
+ material := "material/info"
|
|
|
+ activity := "activity/detail"
|
|
|
+ indepth := "indepth/info"
|
|
|
+ about := "/about"
|
|
|
+ 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 {
|
|
|
+ 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
|
|
|
+}
|