banner.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package services
  2. import (
  3. "hongze/hongze_mfyx/models"
  4. "hongze/hongze_mfyx/utils"
  5. "strconv"
  6. "time"
  7. )
  8. func AddCygxBannerHistory(user *models.WxUserItem, bannerId int) (err error) {
  9. if user.UserId == 0 {
  10. return
  11. }
  12. defer func() {
  13. if err != nil {
  14. go utils.SendAlarmMsg("banner点击信息记录失败"+err.Error()+"bannerId"+strconv.Itoa(bannerId)+"userId:"+strconv.Itoa(user.UserId), 2)
  15. }
  16. }()
  17. historyRecord := new(models.CygxBannerHistory)
  18. historyRecord.UserId = user.UserId
  19. historyRecord.BannerId = bannerId
  20. historyRecord.CreateTime = time.Now()
  21. historyRecord.Mobile = user.Mobile
  22. historyRecord.Email = user.Email
  23. historyRecord.CompanyId = user.CompanyId
  24. historyRecord.CompanyName = user.CompanyName
  25. historyRecord.RegisterPlatform = utils.REGISTER_PLATFORM
  26. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  27. if err != nil && err.Error() != utils.ErrNoRow() {
  28. return
  29. }
  30. historyRecord.RealName = user.RealName
  31. if sellerItem != nil {
  32. historyRecord.SellerName = sellerItem.RealName
  33. }
  34. _, err = models.AddCygxBannerHistory(historyRecord)
  35. return
  36. }