|
@@ -1,10 +1,12 @@
|
|
|
package controllers
|
|
|
|
|
|
import (
|
|
|
+ "encoding/json"
|
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
|
"hongze/hongze_cygx/models"
|
|
|
"hongze/hongze_cygx/services"
|
|
|
"hongze/hongze_cygx/utils"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
// 微路演
|
|
@@ -84,7 +86,7 @@ func (this *MicroRoadShowController) VideoHistoryAdd() {
|
|
|
return
|
|
|
}
|
|
|
uid := user.UserId
|
|
|
- var req models.ActivityIdRep
|
|
|
+ var req models.AddVideoHistoryReq
|
|
|
err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
if err != nil {
|
|
|
br.Msg = "参数解析异常!"
|
|
@@ -92,20 +94,9 @@ func (this *MicroRoadShowController) VideoHistoryAdd() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- activityId := req.ActivityId
|
|
|
+ videoId := req.VideoId
|
|
|
playSeconds := req.PlaySeconds
|
|
|
|
|
|
- activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
|
|
|
- if activityInfo == nil {
|
|
|
- br.Msg = "操作失败"
|
|
|
- br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
|
|
|
- return
|
|
|
- }
|
|
|
- if errInfo != nil {
|
|
|
- br.Msg = "操作失败"
|
|
|
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
|
|
|
- return
|
|
|
- }
|
|
|
var sellerName string
|
|
|
sellerName, err = models.GetCompanySellerName(user.CompanyId)
|
|
|
if err != nil {
|
|
@@ -113,26 +104,25 @@ func (this *MicroRoadShowController) VideoHistoryAdd() {
|
|
|
br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- item := models.CygxActivityVoiceHistory{
|
|
|
- ActivityId: activityId,
|
|
|
+ item := models.CygxMicroRoadshowVideoHistory{
|
|
|
+ VideoId: videoId,
|
|
|
UserId: uid,
|
|
|
- CreateTime: time.Now(),
|
|
|
Mobile: user.Mobile,
|
|
|
Email: user.Email,
|
|
|
CompanyId: user.CompanyId,
|
|
|
CompanyName: user.CompanyName,
|
|
|
RealName: user.RealName,
|
|
|
- SellerId: 0,
|
|
|
SellerName: sellerName,
|
|
|
PlaySeconds: playSeconds,
|
|
|
+ CreateTime: time.Now(),
|
|
|
ModifyTime: time.Now(),
|
|
|
}
|
|
|
|
|
|
if playSeconds != ""{
|
|
|
- lastItem, err := models.GetLastCygxActivityVoiceHistory(activityId)
|
|
|
+ lastItem, err := models.GetLastCygxMicroRoadshowVideoHistory(videoId)
|
|
|
if err != nil {
|
|
|
br.Msg = "操作失败"
|
|
|
- br.ErrMsg = "操作失败,GetLastCygxActivityVoiceHistory Err:" + err.Error()
|
|
|
+ br.ErrMsg = "操作失败,GetLastCygxMicroRoadshowVideoHistory Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
err = models.UpdateLastCygxActivityVoiceHistory(playSeconds, lastItem.Id)
|
|
@@ -141,12 +131,13 @@ func (this *MicroRoadShowController) VideoHistoryAdd() {
|
|
|
br.ErrMsg = "更新失败,UpdateLastCygxActivityVoiceHistory Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- }
|
|
|
- err = models.AddCygxActivityVoiceHistory(&item)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "操作失败"
|
|
|
- br.ErrMsg = "操作失败,Err:" + err.Error()
|
|
|
- return
|
|
|
+ } else {
|
|
|
+ err = models.AddCygxMicroRoadshowVideoHistory(&item)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "操作失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|