video.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package english_report
  2. import (
  3. "hongze/hongze_yb_en_api/models/english_company"
  4. "hongze/hongze_yb_en_api/models/english_report_email"
  5. "hongze/hongze_yb_en_api/models/english_video"
  6. "hongze/hongze_yb_en_api/services/alarm_msg"
  7. "hongze/hongze_yb_en_api/utils"
  8. "time"
  9. )
  10. func DealVideoEmail(reportItem *english_video.EnglishVideo, reportCode string, shareEmailId int) (err error, errMsg string) {
  11. defer func() {
  12. if err != nil {
  13. alarm_msg.SendAlarmMsg(utils.APPNAME+"更新英文报告邮箱PV失败, ErrMsg: "+errMsg, 2)
  14. }
  15. }()
  16. emailItem := new(english_report_email.Email)
  17. userEmail, err := emailItem.GetById(shareEmailId)
  18. if err != nil && err != utils.ErrNoRow {
  19. errMsg = "获取客户邮箱信息失败, Err:" + err.Error()
  20. return
  21. }
  22. if userEmail == nil {
  23. return
  24. }
  25. // 更新报告邮箱pv(冗余)
  26. if err = reportItem.UpdatePvEmailByVideoCode(reportCode); err != nil {
  27. errMsg = "更新报告邮箱PV失败, Err:" + err.Error()
  28. return
  29. }
  30. // 记录邮箱PV
  31. pv := &english_report_email.EmailPv{
  32. ReportId: reportItem.Id,
  33. EmailId: userEmail.Id,
  34. ReportType: 1,
  35. CreateTime: time.Now().Local(),
  36. }
  37. if err = pv.Add(); err != nil {
  38. errMsg = "新增邮箱PV失败, Err: " + err.Error()
  39. return
  40. }
  41. // 更新阅读量
  42. if err = emailItem.UpdateViewTotalById(userEmail.Id); err != nil {
  43. errMsg = "更新英文联系人阅读量失败, Err: " + err.Error()
  44. return
  45. }
  46. if userEmail.CompanyId > 0 {
  47. companyItem := new(english_company.Company)
  48. if err = companyItem.UpdateViewTotalByCompanyId(userEmail.CompanyId); err != nil {
  49. errMsg = "更新英文客户阅读量, Err: " + err.Error()
  50. return
  51. }
  52. }
  53. return
  54. }