1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- package english_report
- import (
- "hongze/hongze_yb_en_api/models/english_company"
- "hongze/hongze_yb_en_api/models/english_report_email"
- "hongze/hongze_yb_en_api/models/english_video"
- "hongze/hongze_yb_en_api/services/alarm_msg"
- "hongze/hongze_yb_en_api/utils"
- "time"
- )
- func DealVideoEmail(reportItem *english_video.EnglishVideo, reportCode string, shareEmailId int) (err error, errMsg string) {
- defer func() {
- if err != nil {
- alarm_msg.SendAlarmMsg(utils.APPNAME+"更新英文报告邮箱PV失败, ErrMsg: "+errMsg, 2)
- }
- }()
- emailItem := new(english_report_email.Email)
- userEmail, err := emailItem.GetById(shareEmailId)
- if err != nil && err != utils.ErrNoRow {
- errMsg = "获取客户邮箱信息失败, Err:" + err.Error()
- return
- }
- if userEmail == nil {
- return
- }
- // 更新报告邮箱pv(冗余)
- if err = reportItem.UpdatePvEmailByVideoCode(reportCode); err != nil {
- errMsg = "更新报告邮箱PV失败, Err:" + err.Error()
- return
- }
- // 记录邮箱PV
- pv := &english_report_email.EmailPv{
- ReportId: reportItem.Id,
- EmailId: userEmail.Id,
- ReportType: 1,
- CreateTime: time.Now().Local(),
- }
- if err = pv.Add(); err != nil {
- errMsg = "新增邮箱PV失败, Err: " + err.Error()
- return
- }
- // 更新阅读量
- if err = emailItem.UpdateViewTotalById(userEmail.Id); err != nil {
- errMsg = "更新英文联系人阅读量失败, Err: " + err.Error()
- return
- }
- if userEmail.CompanyId > 0 {
- companyItem := new(english_company.Company)
- if err = companyItem.UpdateViewTotalByCompanyId(userEmail.CompanyId); err != nil {
- errMsg = "更新英文客户阅读量, Err: " + err.Error()
- return
- }
- }
- return
- }
|