package services import ( "hongze/hongze_cygx/models" "hongze/hongze_cygx/utils" "strconv" "strings" "time" ) // GetProductInteriorUrl 处理产品内测中的连接并做跳转处理 func GetProductInteriorUrl(url string, urlMap map[string]string) (itemResp *models.ProductInteriorUrlResp) { //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 item := new(models.ProductInteriorUrlResp) item.Body = url if urlMap[url] == "" { item.Type = 1 } else { urlSlice := strings.Split(url, "/") lenurlSlice := len(urlSlice) sourceId, _ := strconv.Atoi(urlSlice[lenurlSlice-1]) item.SourceId = sourceId if strings.Contains(url, "material/info") { item.Type = 2 } else if strings.Contains(url, "activity/detail") { item.Type = 3 } else if strings.Contains(url, "indepth/info") { if lenurlSlice >= 2 { chartPermissionId, _ := strconv.Atoi(urlSlice[lenurlSlice-2]) item.ChartPermissionId = chartPermissionId } item.Type = 4 } } itemResp = item return } func AddCygxProductInteriorHistory(user *models.WxUserItem, articleId int) (err error) { defer func() { if err != nil { go utils.SendAlarmMsg("产品内测用户浏览信息记录失败"+err.Error(), 2) } }() historyRecord := new(models.CygxProductInteriorHistory) historyRecord.UserId = user.UserId historyRecord.ProductInteriorId = articleId historyRecord.CreateTime = time.Now() historyRecord.Mobile = user.Mobile historyRecord.Email = user.Email historyRecord.CompanyId = user.CompanyId historyRecord.CompanyName = user.CompanyName 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.AddCygxProductInteriorHistory(historyRecord) return }