修改
This commit is contained in:
parent
e7f8993fa5
commit
bca6eb9009
@ -32,3 +32,49 @@ type ArtistVideoDetail struct {
|
||||
Instagram string `json:"instagram"`
|
||||
TikTok string `json:"tiktok"`
|
||||
}
|
||||
type CreateRequest struct {
|
||||
Type string `json:"Type"`
|
||||
DepartmentID int64 `json:"DepartmentID"`
|
||||
Domain string `json:"Domain"`
|
||||
MenuType int32 `json:"menuType"`
|
||||
SaasPublishVideo *SaasPublishVideo `json:"SaasPublishVideo"`
|
||||
}
|
||||
|
||||
type SaasPublishVideo struct {
|
||||
Title string `json:"Title"`
|
||||
Describe string `json:"Describe"`
|
||||
IsYoutubeSee int32 `json:"IsYoutubeSee"`
|
||||
IsTiktokScreen int32 `json:"IsTiktokScreen"`
|
||||
IsTiktokComment int32 `json:"IsTiktokComment"`
|
||||
IsTiktokQuote int32 `json:"IsTiktokQuote"`
|
||||
IsTiktokAiGenerate int32 `json:"IsTiktokAiGenerate"`
|
||||
Cover string `json:"Cover"`
|
||||
PlatformIds []int32 `json:"PlatformIds"`
|
||||
PublishAccounts []PublishAccount `json:"PublishAccounts"`
|
||||
Videos []Video `json:"Videos"`
|
||||
}
|
||||
|
||||
type PublishAccount struct {
|
||||
AccountName string `json:"AccountName"`
|
||||
AccountID string `json:"AccountID"`
|
||||
}
|
||||
|
||||
type Video struct {
|
||||
VideoAddress string `json:"VideoAddress"`
|
||||
VideoThumbnail string `json:"VideoThumbnail"`
|
||||
}
|
||||
type APIResponse struct {
|
||||
Status int `json:"status"`
|
||||
Data ApprovalResponse `json:"data"`
|
||||
Msg string `json:"msg"`
|
||||
Code int `json:"code"`
|
||||
Error interface{} `json:"error"`
|
||||
Err string `json:"err"`
|
||||
Keys []string `json:"keys"`
|
||||
Positions interface{} `json:"positions"`
|
||||
}
|
||||
|
||||
type ApprovalResponse struct {
|
||||
ID uint64 `json:"ID"`
|
||||
Success bool `json:"Success"`
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
package imports
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"fonchain-fiee/api/accountFiee"
|
||||
"fonchain-fiee/api/bundle"
|
||||
apiCast "fonchain-fiee/api/cast"
|
||||
"fonchain-fiee/api/files"
|
||||
"fonchain-fiee/pkg/config"
|
||||
@ -12,7 +15,9 @@ import (
|
||||
"fonchain-fiee/pkg/service"
|
||||
"fonchain-fiee/pkg/service/cast"
|
||||
"fonchain-fiee/pkg/service/upload"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
@ -216,7 +221,6 @@ func ImportPublish(c *gin.Context) {
|
||||
Instagram: artist.Instagram,
|
||||
TikTok: artist.TikTok,
|
||||
})
|
||||
|
||||
}
|
||||
excelUrl, err := exportRecordsToExcel(artistResp)
|
||||
if err != nil {
|
||||
@ -330,7 +334,7 @@ func matchArtistMedia(artists []ArtistMedia, unzipPath string) ([]ArtistMedia, e
|
||||
return nil, err
|
||||
}
|
||||
var httpType string
|
||||
if config.IsHttps {
|
||||
if config.AppMode == "prod" {
|
||||
url := "saas.fiee.com"
|
||||
httpType = fmt.Sprintf("%s%s", model.HttpsType, url)
|
||||
} else {
|
||||
@ -426,3 +430,110 @@ func exportRecordsToExcel(artistInfos []ArtistVideoDetail) (string, error) {
|
||||
}
|
||||
return excelUrl, nil
|
||||
}
|
||||
func updateApproval(ctx *gin.Context, artistId uint64, workUuid string, accountInfos []*apiCast.MediaUserInfo, videoUrl, imgUrl, title string) error {
|
||||
var publishAccounts []PublishAccount
|
||||
var publishPlatformIds []int32
|
||||
|
||||
for _, v := range accountInfos {
|
||||
publishAccounts = append(publishAccounts, PublishAccount{
|
||||
AccountName: v.PlatformUserName,
|
||||
AccountID: v.MediaAccountUuid,
|
||||
})
|
||||
publishPlatformIds = append(publishPlatformIds, int32(v.PlatformID))
|
||||
}
|
||||
var req CreateRequest
|
||||
var url string
|
||||
saasPublishVideo := &SaasPublishVideo{
|
||||
Title: title,
|
||||
Describe: title,
|
||||
IsYoutubeSee: 1,
|
||||
IsTiktokScreen: 1,
|
||||
IsTiktokComment: 1,
|
||||
IsTiktokQuote: 1,
|
||||
IsTiktokAiGenerate: 1,
|
||||
Cover: imgUrl,
|
||||
PlatformIds: publishPlatformIds,
|
||||
PublishAccounts: publishAccounts,
|
||||
Videos: []Video{
|
||||
{
|
||||
VideoAddress: videoUrl,
|
||||
VideoThumbnail: imgUrl,
|
||||
},
|
||||
},
|
||||
}
|
||||
if config.AppMode == "prod" {
|
||||
url = "https://erp.fonchain.com/approval/v2/create"
|
||||
req = CreateRequest{
|
||||
Type: "SaasPublishVideo",
|
||||
DepartmentID: 3,
|
||||
Domain: "7bfa3942cceb20389822af7b57c5798e",
|
||||
MenuType: 2,
|
||||
SaasPublishVideo: saasPublishVideo,
|
||||
}
|
||||
} else {
|
||||
url = "http://114.218.158.24:9020/approval/v2/create"
|
||||
req = CreateRequest{
|
||||
Type: "SaasPublishVideo",
|
||||
DepartmentID: 3,
|
||||
Domain: "7bfa3942cceb20389822af7b57c5798e",
|
||||
MenuType: 2,
|
||||
SaasPublishVideo: saasPublishVideo,
|
||||
}
|
||||
}
|
||||
jsonBytes, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
res, err := http.Post(url, "application/json", bytes.NewBuffer(jsonBytes))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
responseBodyBytes, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var apiResp APIResponse
|
||||
err = json.Unmarshal(responseBodyBytes, &apiResp)
|
||||
if err != nil {
|
||||
// 处理错误
|
||||
return err
|
||||
}
|
||||
fmt.Println("拿到审批ID:", apiResp.Data.ID)
|
||||
_, err = service.CastProvider.UpdateStatus(ctx, &apiCast.UpdateStatusReq{
|
||||
WorkUuid: workUuid,
|
||||
WorkAction: apiCast.WorkActionENUM_APPROVAL,
|
||||
ApprovalID: strconv.FormatUint(apiResp.Data.ID, 10),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = service.CastProvider.UpdateStatus(ctx, &apiCast.UpdateStatusReq{
|
||||
WorkUuid: workUuid,
|
||||
WorkAction: apiCast.WorkActionENUM_APPROVAL_PASS,
|
||||
ApprovalID: strconv.FormatUint(apiResp.Data.ID, 10),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = service.BundleProvider.AddBundleBalance(ctx, &bundle.AddBundleBalanceReq{
|
||||
UserId: int32(artistId),
|
||||
VideoConsumptionNumber: 1,
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf(fmt.Sprintf("扣除余额失败: %s", err.Error()))
|
||||
return err
|
||||
}
|
||||
_, err = service.CastProvider.UpdateStatus(ctx, &apiCast.UpdateStatusReq{
|
||||
WorkAction: apiCast.WorkActionENUM_CONFIRM,
|
||||
WorkUuid: workUuid,
|
||||
ConfirmRemark: "",
|
||||
ConfirmStatus: 1,
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf(fmt.Sprintf("更新状态失败: %s", err.Error()))
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user