package services import ( "errors" "fmt" "hongze/hongze_clpt/models" "hongze/hongze_clpt/utils" "strconv" "time" ) // 记录用户活动音频播放记录 func AddAskserieVideoHistoryRecord(user *models.WxUserItem, askserieVideoId, playSeconds int) { // 十分钟之内的合并 key := utils.CYGX_VIDEO_HISTORY_KEY + utils.CYGX_OBJ_ASKSERIEVIDEO + strconv.Itoa(askserieVideoId) + "_" + strconv.Itoa(user.UserId) if utils.Rc.IsExist(key) { return } utils.Rc.Put(key, 1, 10*time.Minute) var err error defer func() { if err != nil { go utils.SendAlarmMsg(fmt.Sprint("记录用户活动音频播放记录失败 AddAskserieVideoHistoryRecord Err:", err.Error(), "askserieVideoId:", askserieVideoId, "UserId:", user.UserId), 2) } }() item := new(models.CygxAskserieVideoHistoryRecord) item.UserId = user.UserId item.RealName = user.RealName item.AskserieVideoId = askserieVideoId item.VideoDuration = playSeconds item.Mobile = user.Mobile item.Email = user.Email item.CompanyId = user.CompanyId item.CompanyName = user.CompanyName item.CreateTime = time.Now() item.ModifyTime = time.Now() item.RegisterPlatform = utils.REGISTER_PLATFORM sellerItem, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2) if e != nil && e.Error() != utils.ErrNoRow() { err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error()) return } if sellerItem != nil { item.SellerName = sellerItem.RealName } //添加记录 e = models.AddCygxAskserieVideoHistoryRecord(item) if e != nil { err = errors.New("AddCygxAskserieVideoHistoryRecord, Err: " + e.Error()) return } //播放记录加1 e = models.UpdateAskserieVideoCounts(askserieVideoId) if e != nil { err = errors.New("UpdateAskserieVideoCounts, Err: " + e.Error()) return } return } // 系列问答视频留言记录 func AddCygxAskserieVideoCollection(user *models.WxUserItem, askserieVideoId int, content string) { var err error defer func() { if err != nil { go utils.SendAlarmMsg(fmt.Sprint("记录用户活动音频播放记录失败 AddAskserieVideoHistoryRecord Err:", err.Error(), "askserieVideoId:", askserieVideoId, "UserId:", user.UserId), 2) } }() item := new(models.CygxAskserieVideoCollection) item.UserId = user.UserId item.RealName = user.RealName item.AskserieVideoId = askserieVideoId item.Content = content item.Mobile = user.Mobile item.Email = user.Email item.CompanyId = user.CompanyId item.CompanyName = user.CompanyName item.CreateTime = time.Now() item.ModifyTime = time.Now() item.RegisterPlatform = utils.REGISTER_PLATFORM sellerItem, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2) if e != nil && e.Error() != utils.ErrNoRow() { err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error()) return } if sellerItem != nil { item.SellerName = sellerItem.RealName } //添加记录 e = models.AddCygxAskserieVideoCollection(item) if e != nil { err = errors.New("AddCygxAskserieVideoCollection, Err: " + e.Error()) return } //播放记录加1 e = models.UpdateAskserieVideoCommentNum(askserieVideoId) if e != nil { err = errors.New("UpdateAskserieVideoCommentNum, Err: " + e.Error()) return } return }