From 090667063e4e1a4ab1e93578af2a3954527ff37d Mon Sep 17 00:00:00 2001 From: lwl0608 Date: Sat, 30 Dec 2023 12:43:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/mix/service/logic/vas.go | 1 + library/mediafiller/mediafiller.go | 39 ++++++++++++++---------- library/mediafiller/mediafillerhelper.go | 10 ++++-- 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/app/mix/service/logic/vas.go b/app/mix/service/logic/vas.go index 26af1bc9..59de60fb 100644 --- a/app/mix/service/logic/vas.go +++ b/app/mix/service/logic/vas.go @@ -1386,6 +1386,7 @@ func (v *Vas) H5DirectUnlockWechat(ctx *gin.Context, req *vasproto.H5DirectUnloc ProductId: dbstruct.ProductIdH5ContactWechat, PayType: req.PayType, From: dbstruct.VasCoinOrderFromH5, + CustomCoins: uVas.GetH5WechatCoinPrice(), CalcPrice: uVas.GetH5WechatCoinPrice() * 10, Uid: uid, Oid1: fmt.Sprintf("%d", uid), diff --git a/library/mediafiller/mediafiller.go b/library/mediafiller/mediafiller.go index 786aa4b7..b79b7958 100644 --- a/library/mediafiller/mediafiller.go +++ b/library/mediafiller/mediafiller.go @@ -35,21 +35,24 @@ func SetFileServerDomainName(fileServerDomainName string) { } func FillEntity(ctx *gin.Context, entity MediaFillable) error { - - imageIds := entity.GetImageIds() videoIds := entity.GetVideoIds() - - imageMap, err := getImageMapByIds(ctx, imageIds) - if err != nil { - logger.Error("mediafiller component getImageMapByIds failed : %v", err) - return err - } videoMap, err := getVideoMapByIds(ctx, videoIds) if err != nil { logger.Error("mediafiller component getVideoMapByIds failed : %v", err) return err } + imageIds := entity.GetImageIds() + // 获取视频封面 + for _, v := range videoMap { + imageIds = append(imageIds, v.CoverId) + } + imageMap, err := getImageMapByIds(ctx, imageIds) + if err != nil { + logger.Error("mediafiller component getImageMapByIds failed : %v", err) + return err + } + images := make([]*dbstruct.ToCImage, 0) videos := make([]*dbstruct.ToCVideo, 0) @@ -60,7 +63,7 @@ func FillEntity(ctx *gin.Context, entity MediaFillable) error { } for _, videoId := range videoIds { if video, ok := videoMap[videoId]; ok { - videos = append(videos, transToCVideo(video)) + videos = append(videos, transToCVideo(video, imageMap[video.CoverId])) } } entity.SetImages(images) @@ -71,7 +74,6 @@ func FillEntity(ctx *gin.Context, entity MediaFillable) error { } func FillList(ctx *gin.Context, list []MediaFillable) error { - imageIds := make([]int64, 0) videoIds := make([]int64, 0) @@ -80,17 +82,22 @@ func FillList(ctx *gin.Context, list []MediaFillable) error { videoIds = append(videoIds, v.GetVideoIds()...) } - imageMap, err := getImageMapByIds(ctx, imageIds) - if err != nil { - logger.Error("mediafiller component getImageMapByIds failed : %v", err) - return err - } videoMap, err := getVideoMapByIds(ctx, videoIds) if err != nil { logger.Error("mediafiller component getVideoMapByIds failed : %v", err) return err } + // 获取视频封面 + for _, v := range videoMap { + imageIds = append(imageIds, v.CoverId) + } + imageMap, err := getImageMapByIds(ctx, imageIds) + if err != nil { + logger.Error("mediafiller component getImageMapByIds failed : %v", err) + return err + } + for _, v := range list { images := make([]*dbstruct.ToCImage, 0) @@ -102,7 +109,7 @@ func FillList(ctx *gin.Context, list []MediaFillable) error { } for _, videoId := range v.GetVideoIds() { if video, ok := videoMap[videoId]; ok { - videos = append(videos, transToCVideo(video)) + videos = append(videos, transToCVideo(video, imageMap[video.CoverId])) } } v.SetImages(images) diff --git a/library/mediafiller/mediafillerhelper.go b/library/mediafiller/mediafillerhelper.go index c42ff8dd..a3d21a2c 100644 --- a/library/mediafiller/mediafillerhelper.go +++ b/library/mediafiller/mediafillerhelper.go @@ -56,14 +56,18 @@ func transToCImage(image *dbstruct.Image) *dbstruct.ToCImage { } // todo -func transToCVideo(video *dbstruct.Video) *dbstruct.ToCVideo { +func transToCVideo(video *dbstruct.Video, coverImg *dbstruct.Image) *dbstruct.ToCVideo { if video == nil { return nil } - return &dbstruct.ToCVideo{ + ret := &dbstruct.ToCVideo{ Id: video.Id, Dur: video.Dur, - CoverUrls: []string{"todo"}, + CoverUrls: []string{}, Urls: []string{defaultMediaFiller.fileServerDomainName + video.SrcId}, } + if coverImg != nil { + ret.CoverUrls = []string{defaultMediaFiller.fileServerDomainName + coverImg.SrcId} + } + return ret }