|
@@ -48,16 +48,17 @@ import (
|
|
|
// return
|
|
|
//}
|
|
|
|
|
|
-// 记录用户活动音频播放记录
|
|
|
+// 添加活动视频的播放记录
|
|
|
func AddActivityVideoHistory(user *models.WxUserItem, activityId, playSeconds int) {
|
|
|
var err error
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
- go utils.SendAlarmMsg(fmt.Sprint("记录用户活动音频播放记录失败 AddActivityVoiceHistory Err:", err.Error(), "活动ID:", activityId, "UserId:", user.UserId), 2)
|
|
|
+ go utils.SendAlarmMsg(fmt.Sprint("添加活动视频的播放记录失败 AddActivityVideoHistory Err:", err.Error(), "活动ID:", activityId, "UserId:", user.UserId), 2)
|
|
|
}
|
|
|
}()
|
|
|
item := new(models.CygxActivityVideoHistory)
|
|
|
item.UserId = user.UserId
|
|
|
+ item.RealName = user.RealName
|
|
|
item.ActivityId = activityId
|
|
|
item.PlaySeconds = strconv.Itoa(playSeconds)
|
|
|
item.Mobile = user.Mobile
|
|
@@ -75,17 +76,33 @@ func AddActivityVideoHistory(user *models.WxUserItem, activityId, playSeconds in
|
|
|
if sellerItem != nil {
|
|
|
item.SellerName = sellerItem.RealName
|
|
|
}
|
|
|
- //添加记录
|
|
|
- e = models.AddCygxActivityVideoHistory(item)
|
|
|
- if e != nil {
|
|
|
- err = errors.New("AddCygxActivityVoiceHistory, Err: " + e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- //播放记录加1
|
|
|
- e = models.UpdateActivityVideoCounts(activityId)
|
|
|
- if e != nil {
|
|
|
- err = errors.New("UpdateCygxActivityVoiceCounts, Err: " + e.Error())
|
|
|
- return
|
|
|
+
|
|
|
+ //小程序端的回传两次,第一次没有播放时长,第二次有播放时长
|
|
|
+ if playSeconds != 0 {
|
|
|
+ lastItem, e := models.GetLastCygxActivityVideoHistory(activityId, user.UserId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetLastCygxActivityVideoHistory, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //更新播放时间
|
|
|
+ e = models.UpdateLastCygxActivityVideoHistory(strconv.Itoa(playSeconds), lastItem.Id)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("UpdateLastCygxActivityVideoHistory, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //播放记录加1
|
|
|
+ e = models.UpdateActivityVideoCounts(activityId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("UpdateActivityVideoCounts, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //添加记录
|
|
|
+ e = models.AddCygxActivityVideoHistory(item)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("AddCygxActivityVideoHistory, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
//设置消息提醒
|
|
|
go ActivityVideoUserRmind(user, activityId, 1)
|
|
@@ -102,6 +119,7 @@ func AddActivityVoiceHistory(user *models.WxUserItem, activityId, playSeconds in
|
|
|
}()
|
|
|
item := new(models.CygxActivityVoiceHistory)
|
|
|
item.UserId = user.UserId
|
|
|
+ item.RealName = user.RealName
|
|
|
item.ActivityId = activityId
|
|
|
item.PlaySeconds = strconv.Itoa(playSeconds)
|
|
|
item.Mobile = user.Mobile
|
|
@@ -119,18 +137,33 @@ func AddActivityVoiceHistory(user *models.WxUserItem, activityId, playSeconds in
|
|
|
if sellerItem != nil {
|
|
|
item.SellerName = sellerItem.RealName
|
|
|
}
|
|
|
- //添加记录
|
|
|
- e = models.AddCygxActivityVoiceHistory(item)
|
|
|
- if e != nil {
|
|
|
- err = errors.New("AddCygxActivityVoiceHistory, Err: " + e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- //播放记录加1
|
|
|
- e = models.UpdateCygxActivityVoiceCounts(activityId)
|
|
|
- if e != nil {
|
|
|
- err = errors.New("UpdateCygxActivityVoiceCounts, Err: " + e.Error())
|
|
|
- return
|
|
|
+ //小程序端的回传两次,第一次没有播放时长,第二次有播放时长
|
|
|
+ if playSeconds != 0 {
|
|
|
+ lastItem, e := models.GetLastCygxActivityVoiceHistory(activityId, user.UserId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetLastCygxActivityVoiceHistory, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ e = models.UpdateLastCygxActivityVoiceHistory(strconv.Itoa(playSeconds), lastItem.Id)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("UpdateLastCygxActivityVoiceHistory, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //播放记录加1
|
|
|
+ e = models.UpdateCygxActivityVoiceCounts(activityId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("UpdateCygxActivityVoiceCounts, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //添加记录
|
|
|
+ e = models.AddCygxActivityVoiceHistory(item)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("AddCygxActivityVoiceHistory, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
//设置消息提醒
|
|
|
go ActivityVideoUserRmind(user, activityId, 2)
|
|
|
return
|