|
@@ -161,7 +161,11 @@ func (this *MicroRoadShowController) VideoHistoryAdd() {
|
|
|
|
|
|
videoId := req.VideoId
|
|
|
playSeconds := req.PlaySeconds
|
|
|
+ sourceType := req.SourceType
|
|
|
|
|
|
+ if sourceType == 0 {
|
|
|
+ sourceType = 1
|
|
|
+ }
|
|
|
var sellerName string
|
|
|
sellerName, err = models.GetCompanySellerName(user.CompanyId)
|
|
|
if err != nil {
|
|
@@ -169,44 +173,52 @@ func (this *MicroRoadShowController) VideoHistoryAdd() {
|
|
|
br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- item := models.CygxMicroRoadshowVideoHistory{
|
|
|
- VideoId: videoId,
|
|
|
- UserId: uid,
|
|
|
- Mobile: user.Mobile,
|
|
|
- Email: user.Email,
|
|
|
- CompanyId: user.CompanyId,
|
|
|
- CompanyName: user.CompanyName,
|
|
|
- RealName: user.RealName,
|
|
|
- SellerName: sellerName,
|
|
|
- PlaySeconds: strconv.Itoa(playSeconds),
|
|
|
- CreateTime: time.Now(),
|
|
|
- ModifyTime: time.Now(),
|
|
|
- }
|
|
|
-
|
|
|
- if playSeconds != 0 {
|
|
|
- lastItem, err := models.GetLastCygxMicroRoadshowVideoHistory(videoId, user.UserId)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "操作失败"
|
|
|
- br.ErrMsg = "操作失败,GetLastCygxMicroRoadshowVideoHistory Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- err = models.UpdateLastCygxActivityVideoHistory(strconv.Itoa(playSeconds), lastItem.Id)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "更新失败"
|
|
|
- br.ErrMsg = "更新失败,UpdateLastCygxActivityVideoHistory Err:" + err.Error()
|
|
|
- return
|
|
|
+ if sourceType == 1 {
|
|
|
+ item := models.CygxMicroRoadshowVideoHistory{
|
|
|
+ VideoId: videoId,
|
|
|
+ UserId: uid,
|
|
|
+ Mobile: user.Mobile,
|
|
|
+ Email: user.Email,
|
|
|
+ CompanyId: user.CompanyId,
|
|
|
+ CompanyName: user.CompanyName,
|
|
|
+ RealName: user.RealName,
|
|
|
+ SellerName: sellerName,
|
|
|
+ PlaySeconds: strconv.Itoa(playSeconds),
|
|
|
+ CreateTime: time.Now(),
|
|
|
+ ModifyTime: time.Now(),
|
|
|
}
|
|
|
- } else {
|
|
|
- err = models.AddCygxMicroRoadshowVideoHistory(&item)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "操作失败"
|
|
|
- br.ErrMsg = "操作失败,Err:" + err.Error()
|
|
|
- return
|
|
|
+ if playSeconds != 0 {
|
|
|
+ lastItem, err := models.GetLastCygxMicroRoadshowVideoHistory(videoId, user.UserId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "操作失败,GetLastCygxMicroRoadshowVideoHistory Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = models.UpdateLastCygxActivityVideoHistory(strconv.Itoa(playSeconds), lastItem.Id)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "更新失败"
|
|
|
+ br.ErrMsg = "更新失败,UpdateLastCygxActivityVideoHistory Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ err = models.AddCygxMicroRoadshowVideoHistory(&item)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "操作失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = models.UpdateCygxActivityVideoCounts(videoId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "更新失败"
|
|
|
+ br.ErrMsg = "更新失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
- err = models.UpdateCygxActivityVideoCounts(videoId)
|
|
|
+ } else if sourceType == 2 {
|
|
|
+ err = services.AddActivityVideoHistory(user, videoId)
|
|
|
if err != nil {
|
|
|
br.Msg = "更新失败"
|
|
|
- br.ErrMsg = "更新失败,Err:" + err.Error()
|
|
|
+ br.ErrMsg = "更新失败,AddActivityVideoHistory Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
}
|