xingzai 1 rok pred
rodič
commit
c21f6faa41

+ 3 - 46
controllers/micro_roadshow.go

@@ -325,54 +325,11 @@ func (this *MicroRoadShowController) VideoHistoryAdd() {
 	} else if sourceType == 2 {
 	} else if sourceType == 2 {
 		//添加活动视频的播放记录
 		//添加活动视频的播放记录
 		go services.AddActivityVideoHistory(user, sourceId, playSeconds)
 		go services.AddActivityVideoHistory(user, sourceId, playSeconds)
-		//if err != nil {
-		//	br.Msg = "更新失败"
-		//	br.ErrMsg = "更新失败,AddActivityVideoHistory Err:" + err.Error()
-		//	return
-		//}
 	} else if sourceType == 3 {
 	} else if sourceType == 3 {
-		item := models.CygxMicroRoadshowVideoHistory{
-			VideoId:     sourceId,
-			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(sourceId, 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(sourceId)
-			if err != nil {
-				br.Msg = "更新失败"
-				br.ErrMsg = "更新失败,Err:" + err.Error()
-				return
-			}
-		}
-		go services.MicroRoadshowVideoUserRmind(user, sourceId)
+		//添加产业视频播放记录
+		go services.AddMicroRoadshowVideoRecord(user, sourceId, playSeconds)
 	} else if sourceType == 4 {
 	} else if sourceType == 4 {
+		//问答系列音频播放记录
 		go services.AddAskserieVideoHistoryRecord(user, sourceId, playSeconds)
 		go services.AddAskserieVideoHistoryRecord(user, sourceId, playSeconds)
 	}
 	}
 	br.Ret = 200
 	br.Ret = 200

+ 13 - 12
models/micro_roadshow.go

@@ -70,18 +70,19 @@ type AddVideoHistoryReq struct {
 }
 }
 
 
 type CygxMicroRoadshowVideoHistory struct {
 type CygxMicroRoadshowVideoHistory struct {
-	Id          int       `orm:"column(id);pk"description:"微路演视频浏览记录表id"`
-	VideoId     int       `description:"微路演视频id"`
-	UserId      int       `description:"用户id"`
-	Mobile      string    `description:"手机号"`
-	Email       string    `description:"邮箱"`
-	CompanyId   int       `description:"公司Id"`
-	CompanyName string    `description:"公司名称"`
-	RealName    string    `description:"用户实际名称"`
-	SellerName  string    `description:"所属销售"`
-	PlaySeconds string    `description:"播放时间 单位s"`
-	CreateTime  time.Time `description:"视频创建时间"`
-	ModifyTime  time.Time `description:"视频修改时间"`
+	Id               int       `orm:"column(id);pk"description:"微路演视频浏览记录表id"`
+	VideoId          int       `description:"微路演视频id"`
+	UserId           int       `description:"用户id"`
+	Mobile           string    `description:"手机号"`
+	Email            string    `description:"邮箱"`
+	CompanyId        int       `description:"公司Id"`
+	CompanyName      string    `description:"公司名称"`
+	RealName         string    `description:"用户实际名称"`
+	SellerName       string    `description:"所属销售"`
+	PlaySeconds      string    `description:"播放时间 单位s"`
+	CreateTime       time.Time `description:"视频创建时间"`
+	ModifyTime       time.Time `description:"视频修改时间"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
 }
 }
 
 
 func GetLastCygxMicroRoadshowVideoHistory(videoId, userId int) (item *CygxMicroRoadshowVideoHistory, err error) {
 func GetLastCygxMicroRoadshowVideoHistory(videoId, userId int) (item *CygxMicroRoadshowVideoHistory, err error) {

+ 1 - 0
services/askserie_video.go

@@ -18,6 +18,7 @@ func AddAskserieVideoHistoryRecord(user *models.WxUserItem, askserieVideoId, pla
 	}()
 	}()
 	item := new(models.CygxAskserieVideoHistoryRecord)
 	item := new(models.CygxAskserieVideoHistoryRecord)
 	item.UserId = user.UserId
 	item.UserId = user.UserId
+	item.RealName = user.RealName
 	item.AskserieVideoId = askserieVideoId
 	item.AskserieVideoId = askserieVideoId
 	item.VideoDuration = playSeconds
 	item.VideoDuration = playSeconds
 	item.Mobile = user.Mobile
 	item.Mobile = user.Mobile

+ 2 - 0
services/cygx_activity_video_history.go

@@ -58,6 +58,7 @@ func AddActivityVideoHistory(user *models.WxUserItem, activityId, playSeconds in
 	}()
 	}()
 	item := new(models.CygxActivityVideoHistory)
 	item := new(models.CygxActivityVideoHistory)
 	item.UserId = user.UserId
 	item.UserId = user.UserId
+	item.RealName = user.RealName
 	item.ActivityId = activityId
 	item.ActivityId = activityId
 	item.PlaySeconds = strconv.Itoa(playSeconds)
 	item.PlaySeconds = strconv.Itoa(playSeconds)
 	item.Mobile = user.Mobile
 	item.Mobile = user.Mobile
@@ -102,6 +103,7 @@ func AddActivityVoiceHistory(user *models.WxUserItem, activityId, playSeconds in
 	}()
 	}()
 	item := new(models.CygxActivityVoiceHistory)
 	item := new(models.CygxActivityVoiceHistory)
 	item.UserId = user.UserId
 	item.UserId = user.UserId
+	item.RealName = user.RealName
 	item.ActivityId = activityId
 	item.ActivityId = activityId
 	item.PlaySeconds = strconv.Itoa(playSeconds)
 	item.PlaySeconds = strconv.Itoa(playSeconds)
 	item.Mobile = user.Mobile
 	item.Mobile = user.Mobile

+ 44 - 0
services/micro_roadshow.go

@@ -8,6 +8,7 @@ import (
 	"hongze/hongze_clpt/utils"
 	"hongze/hongze_clpt/utils"
 	"strconv"
 	"strconv"
 	"strings"
 	"strings"
+	"time"
 )
 )
 
 
 // GetMicroRoadShowDefaultImgConfig 获取微路演默认图/分享图配置
 // GetMicroRoadShowDefaultImgConfig 获取微路演默认图/分享图配置
@@ -751,3 +752,46 @@ func GetAskserieVideoDetailById(user *models.WxUserItem, askserieVideoId int) (i
 	AuthInfo = au
 	AuthInfo = au
 	return
 	return
 }
 }
+
+// 记录产业视频播放记录
+func AddMicroRoadshowVideoRecord(user *models.WxUserItem, videoId, playSeconds int) {
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("记录用户活动音频播放记录失败 AddMicroRoadshowVideoRecord Err:", err.Error(), "videoId:", videoId, "UserId:", user.UserId), 2)
+		}
+	}()
+	item := new(models.CygxMicroRoadshowVideoHistory)
+	item.UserId = user.UserId
+	item.RealName = user.RealName
+	item.VideoId = videoId
+	item.PlaySeconds = strconv.Itoa(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.AddCygxMicroRoadshowVideoHistory(item)
+	if e != nil {
+		err = errors.New("AddCygxMicroRoadshowVideoHistory, Err: " + e.Error())
+		return
+	}
+	e = models.UpdateCygxActivityVideoCounts(videoId)
+	if e != nil {
+		err = errors.New("UpdateCygxActivityVideoCounts, Err: " + e.Error())
+		return
+	}
+	go MicroRoadshowVideoUserRmind(user, videoId)
+
+	return
+}