一键成片功能优化,生成剪辑url存储逻辑
This commit is contained in:
@@ -123,10 +123,11 @@
|
|||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-webflux</artifactId>
|
<artifactId>spring-webflux</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.aliyun</groupId>
|
<groupId>com.aliyun</groupId>
|
||||||
<artifactId>ice20201109</artifactId>
|
<artifactId>alibabacloud-ice20201109</artifactId>
|
||||||
<version>1.4.0</version>
|
<version>5.0.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
+24
-14
@@ -1,7 +1,9 @@
|
|||||||
package com.central.order.config;
|
package com.central.order.config;
|
||||||
|
|
||||||
import com.aliyun.ice20201109.Client;
|
import com.aliyun.auth.credentials.Credential;
|
||||||
import com.aliyun.teaopenapi.models.Config;
|
import com.aliyun.auth.credentials.provider.StaticCredentialProvider;
|
||||||
|
import com.aliyun.sdk.service.ice20201109.AsyncClient;
|
||||||
|
import darabonba.core.client.ClientOverrideConfiguration;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@@ -11,22 +13,30 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
@Configuration
|
@Configuration
|
||||||
@ConfigurationProperties(prefix = "aliyun.ims")
|
@ConfigurationProperties(prefix = "aliyun.ims")
|
||||||
public class AliyunImsConfig {
|
public class AliyunImsConfig {
|
||||||
private String endpoint = "ice.cn-beijing.aliyuncs.com";
|
private String endpoint; // ice.cn-beijing.aliyuncs.com
|
||||||
|
private String ossEndpoint; // oss-cn-beijing.aliyuncs.com
|
||||||
private String accessKeyId;
|
private String accessKeyId;
|
||||||
private String accessKeySecret;
|
private String accessKeySecret;
|
||||||
private String region;
|
private String region; // cn-beijing
|
||||||
private String projectName;
|
private String bucket; // goflyapp
|
||||||
private String pipelineName;
|
|
||||||
private String templateId;
|
|
||||||
private String callbackUrl;
|
private String callbackUrl;
|
||||||
private String bucket;
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Client imsClient() throws Exception {
|
public AsyncClient imsClient() {
|
||||||
Config config = new Config()
|
// 配置凭证
|
||||||
.setAccessKeyId(accessKeyId)
|
StaticCredentialProvider provider = StaticCredentialProvider.create(Credential.builder()
|
||||||
.setAccessKeySecret(accessKeySecret)
|
.accessKeyId(accessKeyId)
|
||||||
.setEndpoint(endpoint);
|
.accessKeySecret(accessKeySecret)
|
||||||
return new Client(config);
|
.build());
|
||||||
|
|
||||||
|
// 配置客户端
|
||||||
|
return AsyncClient.builder()
|
||||||
|
.region(region)
|
||||||
|
.credentialsProvider(provider)
|
||||||
|
.overrideConfiguration(
|
||||||
|
ClientOverrideConfiguration.create()
|
||||||
|
.setEndpointOverride(endpoint)
|
||||||
|
)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-106
@@ -4,22 +4,22 @@ import com.central.common.model.PageResult;
|
|||||||
import com.central.common.model.Result;
|
import com.central.common.model.Result;
|
||||||
import com.central.order.constants.EditTaskStatus;
|
import com.central.order.constants.EditTaskStatus;
|
||||||
import com.central.order.enums.OrderStatus;
|
import com.central.order.enums.OrderStatus;
|
||||||
import com.central.order.feign.FileCenterService;
|
import com.central.order.model.EditTask;
|
||||||
import com.central.order.model.*;
|
import com.central.order.model.Order;
|
||||||
|
import com.central.order.model.OrderFile;
|
||||||
import com.central.order.model.dto.CallbackDTO;
|
import com.central.order.model.dto.CallbackDTO;
|
||||||
import com.central.order.model.params.EditTaskQueryParams;
|
import com.central.order.model.params.EditTaskQueryParams;
|
||||||
import com.central.order.service.*;
|
import com.central.order.service.IEditTaskService;
|
||||||
|
import com.central.order.service.IOrderFileService;
|
||||||
|
import com.central.order.service.IOrderService;
|
||||||
|
import com.central.order.service.IVideoEditService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,16 +33,6 @@ import java.util.List;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class AutoCutVideoController {
|
public class AutoCutVideoController {
|
||||||
|
|
||||||
@Value("${videos.edit-config.url}")
|
|
||||||
private String url;
|
|
||||||
|
|
||||||
@Value("${videos.edit-config.app-id}")
|
|
||||||
private String appId;
|
|
||||||
|
|
||||||
@Value("${videos.edit-config.callback-url}")
|
|
||||||
private String callbackUrl;
|
|
||||||
|
|
||||||
private RestTemplate restTemplate;
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IOrderService orderService;
|
private IOrderService orderService;
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -50,10 +40,6 @@ public class AutoCutVideoController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IOrderFileService orderFileService;
|
private IOrderFileService orderFileService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ITourismFileService tourismFileService;
|
|
||||||
@Autowired
|
|
||||||
private FileCenterService fileCenterService;
|
|
||||||
@Autowired
|
|
||||||
private IVideoEditService videoEditService;
|
private IVideoEditService videoEditService;
|
||||||
|
|
||||||
@Operation(summary = "根据订单号生成视频")
|
@Operation(summary = "根据订单号生成视频")
|
||||||
@@ -77,13 +63,14 @@ public class AutoCutVideoController {
|
|||||||
|
|
||||||
// 4. 获取素材文件
|
// 4. 获取素材文件
|
||||||
List<OrderFile> orderFiles = orderFileService.getOrderFileByOrderNo(orderNo);
|
List<OrderFile> orderFiles = orderFileService.getOrderFileByOrderNo(orderNo);
|
||||||
List<TourismFile> tourismFiles = tourismFileService.getByTourismId(order.getTourismId());
|
|
||||||
|
|
||||||
// 5. 提交编辑任务
|
// 5. 提交编辑任务
|
||||||
String jobId = videoEditService.submitEditTask(orderNo, orderFiles, tourismFiles);
|
String jobId = videoEditService.submitEditTask(orderNo, orderFiles);
|
||||||
|
|
||||||
// 6. 更新任务信息
|
// 6. 更新任务信息
|
||||||
editTaskService.updateTaskStatus(jobId, EditTaskStatus.PROCESSING, null);
|
task.setJobId(jobId);
|
||||||
|
task.setStatus(EditTaskStatus.PROCESSING);
|
||||||
|
editTaskService.saveOrUpdateTask(task);
|
||||||
|
|
||||||
return Result.succeed(jobId);
|
return Result.succeed(jobId);
|
||||||
|
|
||||||
@@ -157,88 +144,6 @@ public class AutoCutVideoController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建素材数据
|
|
||||||
*/
|
|
||||||
private SourceDTO buildSourceDTO(List<OrderFile> orderFiles, List<TourismFile> tourismFiles) {
|
|
||||||
// 1. 初始化列表
|
|
||||||
List<String> textList = new ArrayList<>();
|
|
||||||
List<String> videoList = new ArrayList<>();
|
|
||||||
List<String> audioList = new ArrayList<>();
|
|
||||||
List<String> imageList = new ArrayList<>();
|
|
||||||
|
|
||||||
// 2. 处理订单文件
|
|
||||||
if (!orderFiles.isEmpty()) {
|
|
||||||
for (OrderFile file : orderFiles) {
|
|
||||||
String fileUrl = fileCenterService.getViewUrlByPath(file.getFilePath());
|
|
||||||
|
|
||||||
// 根据文件类型分类
|
|
||||||
switch (getFileType(file.getFileType())) {
|
|
||||||
case "video":
|
|
||||||
videoList.add(fileUrl);
|
|
||||||
break;
|
|
||||||
case "audio":
|
|
||||||
audioList.add(fileUrl);
|
|
||||||
break;
|
|
||||||
case "image":
|
|
||||||
imageList.add(fileUrl);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 处理景区素材
|
|
||||||
if (!tourismFiles.isEmpty()) {
|
|
||||||
for (TourismFile file : tourismFiles) {
|
|
||||||
String fileUrl = fileCenterService.getViewUrlByPath(file.getImageUrl());
|
|
||||||
imageList.add(fileUrl);
|
|
||||||
|
|
||||||
// 如果有景区描述,添加到文本列表
|
|
||||||
if (StringUtils.hasText(file.getDescription())) {
|
|
||||||
textList.add(file.getDescription());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. 构建返回对象
|
|
||||||
return new SourceDTO(textList, videoList, audioList, imageList);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建请求参数
|
|
||||||
*/
|
|
||||||
private RequestParamsEntity buildRequestParams(Order order, SourceDTO sourceDTO) {
|
|
||||||
return RequestParamsEntity.builder()
|
|
||||||
.appId(appId) // 使用配置文件中的appId
|
|
||||||
.taskId(order.getOrderNo())
|
|
||||||
.callbackUrl(callbackUrl) // 使用配置文件中的callbackUrl
|
|
||||||
.source(sourceDTO)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取文件类型
|
|
||||||
*/
|
|
||||||
private String getFileType(String mimeType) {
|
|
||||||
if (mimeType == null) {
|
|
||||||
return "other";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mimeType.startsWith("video/")) {
|
|
||||||
return "video";
|
|
||||||
} else if (mimeType.startsWith("audio/")) {
|
|
||||||
return "audio";
|
|
||||||
} else if (mimeType.startsWith("image/")) {
|
|
||||||
return "image";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "other";
|
|
||||||
}
|
|
||||||
|
|
||||||
private String extractJobId(Object response) {
|
|
||||||
// Implementation of extractJobId method
|
|
||||||
return null; // Placeholder return, actual implementation needed
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isValidCallback(CallbackDTO callback) {
|
private boolean isValidCallback(CallbackDTO callback) {
|
||||||
// Implementation of isValidCallback method
|
// Implementation of isValidCallback method
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.central.db.mapper.SuperMapper;
|
|||||||
import com.central.order.model.OrderFile;
|
import com.central.order.model.OrderFile;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -40,4 +41,9 @@ public interface OrderFileMapper extends SuperMapper<OrderFile> {
|
|||||||
|
|
||||||
List<OrderFile> findListByUser(Page<OrderFile> page, @Param("p") Map<String, Object> params);
|
List<OrderFile> findListByUser(Page<OrderFile> page, @Param("p") Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取订单的视频文件
|
||||||
|
*/
|
||||||
|
@Select("SELECT * FROM order_files WHERE order_no = #{orderNo} AND file_type = 'video/mp4' ORDER BY create_time ASC")
|
||||||
|
List<OrderFile> getOrderVideoFiles(@Param("orderNo") String orderNo);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-2
@@ -6,9 +6,12 @@ import java.util.List;
|
|||||||
|
|
||||||
public interface IMediaService {
|
public interface IMediaService {
|
||||||
/**
|
/**
|
||||||
* 提交智能一键成片任务
|
* 提交编辑任务
|
||||||
|
* @param orderNo 订单号
|
||||||
|
* @param orderFiles 订单文件列表
|
||||||
|
* @return 任务ID
|
||||||
*/
|
*/
|
||||||
String submitEditTask(String orderNo, List<OrderFile> orderFiles, List<TourismFile> tourismFiles);
|
String submitEditTask(String orderNo, List<OrderFile> orderFiles);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询任务状态
|
* 查询任务状态
|
||||||
|
|||||||
+7
@@ -72,5 +72,12 @@ public interface IOrderFileService extends ISuperService<OrderFile> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int delete(Long id);
|
int delete(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取订单的视频文件列表
|
||||||
|
* @param orderNo 订单号
|
||||||
|
* @return 视频文件列表
|
||||||
|
*/
|
||||||
|
List<OrderFile> getOrderVideoFiles(String orderNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -1,7 +1,6 @@
|
|||||||
package com.central.order.service;
|
package com.central.order.service;
|
||||||
|
|
||||||
import com.central.order.model.OrderFile;
|
import com.central.order.model.OrderFile;
|
||||||
import com.central.order.model.TourismFile;
|
|
||||||
import com.central.order.model.dto.VideoEditStatus;
|
import com.central.order.model.dto.VideoEditStatus;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -15,10 +14,9 @@ public interface IVideoEditService {
|
|||||||
*
|
*
|
||||||
* @param orderNo 订单号
|
* @param orderNo 订单号
|
||||||
* @param orderFiles 订单相关文件
|
* @param orderFiles 订单相关文件
|
||||||
* @param tourismFiles 景区相关文件
|
|
||||||
* @return 任务ID
|
* @return 任务ID
|
||||||
*/
|
*/
|
||||||
String submitEditTask(String orderNo, List<OrderFile> orderFiles, List<TourismFile> tourismFiles);
|
String submitEditTask(String orderNo, List<OrderFile> orderFiles);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询编辑任务状态
|
* 查询编辑任务状态
|
||||||
|
|||||||
+172
-147
@@ -1,73 +1,112 @@
|
|||||||
package com.central.order.service.impl;
|
package com.central.order.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.aliyun.ice20201109.Client;
|
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||||
import com.aliyun.ice20201109.models.GetMediaProducingJobRequest;
|
import com.aliyun.sdk.service.ice20201109.AsyncClient;
|
||||||
import com.aliyun.ice20201109.models.GetMediaProducingJobResponse;
|
import com.aliyun.sdk.service.ice20201109.models.GetMediaProducingJobRequest;
|
||||||
import com.aliyun.ice20201109.models.SubmitMediaProducingJobRequest;
|
import com.aliyun.sdk.service.ice20201109.models.GetMediaProducingJobResponse;
|
||||||
import com.aliyun.ice20201109.models.SubmitMediaProducingJobResponse;
|
import com.aliyun.sdk.service.ice20201109.models.SubmitMediaProducingJobRequest;
|
||||||
|
import com.aliyun.sdk.service.ice20201109.models.SubmitMediaProducingJobResponse;
|
||||||
import com.central.common.exception.BusinessException;
|
import com.central.common.exception.BusinessException;
|
||||||
import com.central.order.config.AliyunImsConfig;
|
import com.central.order.config.AliyunImsConfig;
|
||||||
|
import com.central.order.feign.FileCenterService;
|
||||||
|
import com.central.order.model.Order;
|
||||||
import com.central.order.model.OrderFile;
|
import com.central.order.model.OrderFile;
|
||||||
import com.central.order.model.TourismFile;
|
import com.central.order.model.QrCode;
|
||||||
import com.central.order.service.IMediaService;
|
import com.central.order.service.IMediaService;
|
||||||
|
import com.central.order.service.IOrderFileService;
|
||||||
|
import com.central.order.service.IOrderService;
|
||||||
|
import com.central.order.service.IQrCodeService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class MediaServiceImpl implements IMediaService {
|
public class MediaServiceImpl implements IMediaService {
|
||||||
|
|
||||||
private final Client imsClient;
|
@Autowired
|
||||||
private final AliyunImsConfig imsConfig;
|
private AsyncClient imsClient;
|
||||||
|
@Autowired
|
||||||
|
private AliyunImsConfig imsConfig;
|
||||||
|
@Autowired
|
||||||
|
private IQrCodeService qrCodeService;
|
||||||
|
@Autowired
|
||||||
|
private IOrderService orderService;
|
||||||
|
@Autowired
|
||||||
|
private IOrderFileService orderFileService;
|
||||||
|
@Autowired
|
||||||
|
private FileCenterService fileCenterService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String submitEditTask(String orderNo, List<OrderFile> orderFiles, List<TourismFile> tourismFiles) {
|
public String submitEditTask(String orderNo, List<OrderFile> orderFiles) {
|
||||||
try {
|
try {
|
||||||
// 1. 构建时间线配置
|
// 1. 获取订单信息
|
||||||
String timeline = buildTimeline(orderFiles, tourismFiles);
|
Order order = orderService.getOrderByNumber(orderNo);
|
||||||
|
if (order == null) {
|
||||||
// 2. 构建输出配置
|
throw new BusinessException("订单不存在");
|
||||||
String outputConfig = buildOutputConfig(orderNo);
|
|
||||||
|
|
||||||
// 3. 构建项目元数据
|
|
||||||
String projectMetadata = buildProjectMetadata(orderNo);
|
|
||||||
|
|
||||||
// 4. 构建userData
|
|
||||||
String userData = buildUserData(orderNo);
|
|
||||||
|
|
||||||
// 打印请求参数,方便调试
|
|
||||||
log.info("提交任务参数: timeline={}, outputConfig={}, projectMetadata={}, userData={}",
|
|
||||||
timeline, outputConfig, projectMetadata, userData);
|
|
||||||
|
|
||||||
// 5. 构建请求
|
|
||||||
SubmitMediaProducingJobRequest request = new SubmitMediaProducingJobRequest()
|
|
||||||
.setTimeline(timeline)
|
|
||||||
.setOutputMediaConfig(outputConfig)
|
|
||||||
.setProjectMetadata(projectMetadata)
|
|
||||||
.setUserData(userData);
|
|
||||||
|
|
||||||
// 6. 提交任务
|
|
||||||
SubmitMediaProducingJobResponse response = imsClient.submitMediaProducingJob(request);
|
|
||||||
|
|
||||||
if (response != null && response.getStatusCode() == 200) {
|
|
||||||
String jobId = response.getBody().getJobId();
|
|
||||||
log.info("提交智能一键成片任务成功: orderNo={}, jobId={}, projectId={}",
|
|
||||||
orderNo, jobId, response.getBody().getProjectId());
|
|
||||||
return jobId;
|
|
||||||
} else {
|
|
||||||
throw new BusinessException("提交任务失败: " + (response != null ? response.getBody().getRequestId() : "未知错误"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2. 获取二维码信息
|
||||||
|
QrCode qrCode = qrCodeService.getByCodeId(order.getCodeId());
|
||||||
|
if (qrCode == null || qrCode.getTemplateId() == null) {
|
||||||
|
throw new BusinessException("未配置视频模板ID");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 获取订单视频文件
|
||||||
|
List<OrderFile> videoFiles = orderFileService.getOrderVideoFiles(orderNo);
|
||||||
|
if (videoFiles == null || videoFiles.size() < 2) {
|
||||||
|
throw new BusinessException("订单视频文件数量不足,至少需要2个视频文件");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建并验证参数
|
||||||
|
String clipsParam = buildClipsParam(orderNo, videoFiles);
|
||||||
|
String outputConfig = buildOutputConfig(orderNo);
|
||||||
|
String userData = buildUserData(order, qrCode);
|
||||||
|
|
||||||
|
// 打印完整的请求参数用于调试
|
||||||
|
log.info("提交任务参数: orderNo={}, templateId={}", orderNo, qrCode.getTemplateId());
|
||||||
|
log.info("clips参数: {}", clipsParam);
|
||||||
|
log.info("输出配置: {}", outputConfig);
|
||||||
|
log.info("用户数据: {}", userData);
|
||||||
|
|
||||||
|
// 构建请求
|
||||||
|
SubmitMediaProducingJobRequest request = SubmitMediaProducingJobRequest.builder()
|
||||||
|
.templateId(qrCode.getTemplateId())
|
||||||
|
.clipsParam(clipsParam)
|
||||||
|
.outputMediaConfig(outputConfig)
|
||||||
|
.userData(userData)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 提交任务
|
||||||
|
CompletableFuture<SubmitMediaProducingJobResponse> future =
|
||||||
|
imsClient.submitMediaProducingJob(request);
|
||||||
|
SubmitMediaProducingJobResponse response = future.get(30, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
// 6. 处理响应
|
||||||
|
if (response != null && response.getBody() != null) {
|
||||||
|
String jobId = response.getBody().getJobId();
|
||||||
|
log.info("提交智能一键成片任务成功: orderNo={}, jobId={}, templateId={}",
|
||||||
|
orderNo, jobId, qrCode.getTemplateId());
|
||||||
|
return jobId;
|
||||||
|
} else {
|
||||||
|
throw new BusinessException("提交任务失败: 响应为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (TimeoutException e) {
|
||||||
|
log.error("提交任务超时: orderNo={}", orderNo, e);
|
||||||
|
throw new BusinessException("提交任务超时");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("提交智能一键成片任务失败: orderNo={}", orderNo, e);
|
log.error("提交智能一键成片任务失败: orderNo={}, error={}", orderNo, e.getMessage(), e);
|
||||||
throw new BusinessException("提交任务失败: " + e.getMessage());
|
throw new BusinessException("提交任务失败: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,10 +114,13 @@ public class MediaServiceImpl implements IMediaService {
|
|||||||
@Override
|
@Override
|
||||||
public String getTaskStatus(String jobId) {
|
public String getTaskStatus(String jobId) {
|
||||||
try {
|
try {
|
||||||
GetMediaProducingJobRequest request = new GetMediaProducingJobRequest()
|
GetMediaProducingJobRequest request = GetMediaProducingJobRequest.builder()
|
||||||
.setJobId(jobId);
|
.jobId(jobId)
|
||||||
|
.build();
|
||||||
|
|
||||||
GetMediaProducingJobResponse response = imsClient.getMediaProducingJob(request);
|
CompletableFuture<GetMediaProducingJobResponse> future =
|
||||||
|
imsClient.getMediaProducingJob(request);
|
||||||
|
GetMediaProducingJobResponse response = future.get(10, TimeUnit.SECONDS);
|
||||||
|
|
||||||
if (response != null && response.getBody() != null
|
if (response != null && response.getBody() != null
|
||||||
&& response.getBody().getMediaProducingJob() != null) {
|
&& response.getBody().getMediaProducingJob() != null) {
|
||||||
@@ -95,16 +137,15 @@ public class MediaServiceImpl implements IMediaService {
|
|||||||
@Override
|
@Override
|
||||||
public String getTaskResult(String jobId) {
|
public String getTaskResult(String jobId) {
|
||||||
try {
|
try {
|
||||||
GetMediaProducingJobRequest request = new GetMediaProducingJobRequest()
|
GetMediaProducingJobRequest getMediaProducingJobRequest =
|
||||||
.setJobId(jobId);
|
GetMediaProducingJobRequest
|
||||||
|
.builder()
|
||||||
GetMediaProducingJobResponse response = imsClient.getMediaProducingJob(request);
|
.jobId(jobId)
|
||||||
|
.build();
|
||||||
if (response != null && response.getBody() != null
|
CompletableFuture<GetMediaProducingJobResponse> response =
|
||||||
&& response.getBody().getMediaProducingJob() != null) {
|
imsClient.getMediaProducingJob(getMediaProducingJobRequest);
|
||||||
return response.getBody().getMediaProducingJob().getMediaURL();
|
GetMediaProducingJobResponse resp = response.get();
|
||||||
}
|
return new Gson().toJson(resp);
|
||||||
return null;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("获取任务结果失败: jobId={}", jobId, e);
|
log.error("获取任务结果失败: jobId={}", jobId, e);
|
||||||
@@ -112,103 +153,87 @@ public class MediaServiceImpl implements IMediaService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建输出配置
|
|
||||||
* 按照阿里云文档格式:
|
|
||||||
* {
|
|
||||||
* "MediaURL": "oss://bucket-name/output/example.mp4"
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
private String buildOutputConfig(String orderNo) {
|
|
||||||
Map<String, String> config = new HashMap<>();
|
|
||||||
// 注意:这里只需要设置MediaURL
|
|
||||||
config.put("MediaURL", String.format("oss://%s/output/%s_%s.mp4",
|
|
||||||
imsConfig.getBucket(),
|
|
||||||
orderNo,
|
|
||||||
System.currentTimeMillis()
|
|
||||||
));
|
|
||||||
|
|
||||||
String configJson = JSON.toJSONString(config);
|
|
||||||
log.debug("输出配置: {}", configJson);
|
|
||||||
return configJson;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建时间线配置
|
|
||||||
* 按照阿里云文档格式:
|
|
||||||
* {
|
|
||||||
* "VideoTracks": [{
|
|
||||||
* "VideoTrackClips": [{
|
|
||||||
* "MediaId": "xxxxx"
|
|
||||||
* }]
|
|
||||||
* }]
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
private String buildTimeline(List<OrderFile> orderFiles, List<TourismFile> tourismFiles) {
|
|
||||||
Map<String, Object> timeline = new HashMap<>();
|
|
||||||
List<Map<String, Object>> videoTracks = new ArrayList<>();
|
|
||||||
Map<String, Object> videoTrack = new HashMap<>();
|
|
||||||
List<Map<String, Object>> videoTrackClips = new ArrayList<>();
|
|
||||||
|
|
||||||
// 处理订单文件
|
|
||||||
if (orderFiles != null) {
|
|
||||||
for (OrderFile file : orderFiles) {
|
|
||||||
Map<String, Object> clip = new HashMap<>();
|
|
||||||
clip.put("MediaId", getMediaId(file.getFilePath()));
|
|
||||||
videoTrackClips.add(clip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理景区文件
|
|
||||||
if (tourismFiles != null) {
|
|
||||||
for (TourismFile file : tourismFiles) {
|
|
||||||
Map<String, Object> clip = new HashMap<>();
|
|
||||||
clip.put("MediaId", getMediaId(file.getImageUrl()));
|
|
||||||
videoTrackClips.add(clip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
videoTrack.put("VideoTrackClips", videoTrackClips);
|
|
||||||
videoTracks.add(videoTrack);
|
|
||||||
timeline.put("VideoTracks", videoTracks);
|
|
||||||
|
|
||||||
String timelineJson = JSON.toJSONString(timeline);
|
|
||||||
log.debug("时间线配置: {}", timelineJson);
|
|
||||||
return timelineJson;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建项目元数据
|
|
||||||
*/
|
|
||||||
private String buildProjectMetadata(String orderNo) {
|
|
||||||
Map<String, String> metadata = new HashMap<>();
|
|
||||||
metadata.put("title", "订单视频_" + orderNo);
|
|
||||||
metadata.put("description", "智能一键成片生成的视频");
|
|
||||||
metadata.put("tags", "订单视频,自动生成");
|
|
||||||
|
|
||||||
String metadataJson = JSON.toJSONString(metadata);
|
|
||||||
log.debug("项目元数据: {}", metadataJson);
|
|
||||||
return metadataJson;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建用户数据
|
* 构建用户数据
|
||||||
*/
|
*/
|
||||||
private String buildUserData(String orderNo) {
|
private String buildUserData(Order order, QrCode qrCode) {
|
||||||
Map<String, String> userData = new HashMap<>();
|
try {
|
||||||
userData.put("orderNo", orderNo);
|
Map<String, Object> userData = new HashMap<>();
|
||||||
|
// 订单信息
|
||||||
|
userData.put("orderNo", order.getOrderNo());
|
||||||
|
userData.put("orderId", order.getId());
|
||||||
|
// 二维码信息
|
||||||
|
userData.put("codeId", order.getCodeId());
|
||||||
|
userData.put("templateId", qrCode.getTemplateId());
|
||||||
|
// 其他信息
|
||||||
|
userData.put("timestamp", System.currentTimeMillis());
|
||||||
|
userData.put("source", "order_center");
|
||||||
|
|
||||||
String userDataJson = JSON.toJSONString(userData);
|
String userDataJson = JSON.toJSONString(userData);
|
||||||
log.debug("用户数据: {}", userDataJson);
|
log.debug("用户数据: {}", userDataJson);
|
||||||
return userDataJson;
|
return userDataJson;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("构建用户数据失败: orderNo={}", order.getOrderNo(), e);
|
||||||
|
throw new BusinessException("构建用户数据失败: " + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取媒体ID
|
* 构建剪辑参数
|
||||||
*/
|
*/
|
||||||
private String getMediaId(String filePath) {
|
private String buildClipsParam(String orderNo, List<OrderFile> videoFiles) {
|
||||||
// TODO: 这里需要实现获取MediaId的逻辑
|
try {
|
||||||
// 可能需要先将文件上传到阿里云,然后获取MediaId
|
Map<String, String> clips = new HashMap<>();
|
||||||
return filePath;
|
|
||||||
|
// 使用完整的OSS URL
|
||||||
|
String firstUrl = fileCenterService.getViewUrlByPath(videoFiles.get(0).getFilePath());
|
||||||
|
clips.put("1", firstUrl);
|
||||||
|
|
||||||
|
String secondUrl = fileCenterService.getViewUrlByPath(videoFiles.get(1).getFilePath());
|
||||||
|
clips.put("2", secondUrl);
|
||||||
|
|
||||||
|
String clipsJson = JSON.toJSONString(clips);
|
||||||
|
log.info("剪辑参数: orderNo={}, clips={}", orderNo, clipsJson);
|
||||||
|
return clipsJson;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("构建剪辑参数失败: orderNo={}", orderNo, e);
|
||||||
|
throw new BusinessException("构建剪辑参数失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建输出配置
|
||||||
|
*/
|
||||||
|
private String buildOutputConfig(String orderNo) {
|
||||||
|
try {
|
||||||
|
Map<String, String> config = new HashMap<>();
|
||||||
|
// 使用正确的OSS路径格式
|
||||||
|
config.put("MediaURL", String.format("https://"+imsConfig.getBucket()+"."+imsConfig.getOssEndpoint()+"/output/%s_%s.mp4",
|
||||||
|
orderNo,
|
||||||
|
System.currentTimeMillis()
|
||||||
|
));
|
||||||
|
|
||||||
|
String configJson = JSON.toJSONString(config);
|
||||||
|
log.info("输出配置: {}", configJson);
|
||||||
|
return configJson;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("构建输出配置失败: orderNo={}", orderNo, e);
|
||||||
|
throw new BusinessException("构建输出配置失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取媒体URL
|
||||||
|
*/
|
||||||
|
private String getMediaUrl(String filePath) {
|
||||||
|
try {
|
||||||
|
return String.format("https://goflyapp.%s/picture/%s",
|
||||||
|
imsConfig.getOssEndpoint(),
|
||||||
|
filePath
|
||||||
|
);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("生成媒体URL失败: filePath={}", filePath, e);
|
||||||
|
throw new BusinessException("生成媒体URL失败: " + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
@@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.commons.collections4.MapUtils;
|
import org.apache.commons.collections4.MapUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -81,4 +82,15 @@ public class OrderFileServiceImpl extends SuperServiceImpl<OrderFileMapper, Orde
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OrderFile> getOrderVideoFiles(String orderNo) {
|
||||||
|
try {
|
||||||
|
log.debug("查询订单视频文件: orderNo={}", orderNo);
|
||||||
|
return baseMapper.getOrderVideoFiles(orderNo);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("查询订单视频文件失败: orderNo={}", orderNo, e);
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -3,7 +3,6 @@ package com.central.order.service.impl;
|
|||||||
import com.central.common.exception.BusinessException;
|
import com.central.common.exception.BusinessException;
|
||||||
import com.central.order.constants.EditTaskStatus;
|
import com.central.order.constants.EditTaskStatus;
|
||||||
import com.central.order.model.OrderFile;
|
import com.central.order.model.OrderFile;
|
||||||
import com.central.order.model.TourismFile;
|
|
||||||
import com.central.order.model.dto.VideoEditStatus;
|
import com.central.order.model.dto.VideoEditStatus;
|
||||||
import com.central.order.service.IEditTaskService;
|
import com.central.order.service.IEditTaskService;
|
||||||
import com.central.order.service.IMediaService;
|
import com.central.order.service.IMediaService;
|
||||||
@@ -28,10 +27,10 @@ public class VideoEditServiceImpl implements IVideoEditService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public String submitEditTask(String orderNo, List<OrderFile> orderFiles, List<TourismFile> tourismFiles) {
|
public String submitEditTask(String orderNo, List<OrderFile> orderFiles) {
|
||||||
try {
|
try {
|
||||||
// 提交智能一键成片任务
|
// 提交智能一键成片任务
|
||||||
String jobId = mediaService.submitEditTask(orderNo, orderFiles, tourismFiles);
|
String jobId = mediaService.submitEditTask(orderNo, orderFiles);
|
||||||
|
|
||||||
// 更新任务状态
|
// 更新任务状态
|
||||||
editTaskService.updateTaskStatus(jobId, EditTaskStatus.PROCESSING, null);
|
editTaskService.updateTaskStatus(jobId, EditTaskStatus.PROCESSING, null);
|
||||||
|
|||||||
@@ -73,20 +73,13 @@ file:
|
|||||||
# jdbc-url: jdbc:mysql://${zlt.datasource.ip}:3306/logger-center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
|
# jdbc-url: jdbc:mysql://${zlt.datasource.ip}:3306/logger-center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
|
||||||
# username: ${zlt.datasource.username}
|
# username: ${zlt.datasource.username}
|
||||||
# password: ${zlt.datasource.password}
|
# password: ${zlt.datasource.password}
|
||||||
videos:
|
|
||||||
edit-config:
|
|
||||||
url: ${VIDEOS_EDIT_URL:http://example.com/api/edit}
|
|
||||||
app-id: ${VIDEOS_APP_ID:gcb4432dcc7e4e3a92063807f3e75d58}
|
|
||||||
callback-url: ${VIDEOS_CALLBACK_URL:http://img.goflytec.com/api-order/auto/cut/callback}
|
|
||||||
|
|
||||||
aliyun:
|
aliyun:
|
||||||
ims:
|
ims:
|
||||||
|
oss-endpoint: oss-cn-beijing.aliyuncs.com
|
||||||
|
access-key-id: LTAI5tSNV1RvexXpMMCZhxSe
|
||||||
|
access-key-secret: XocJRWU8emwjjvYLTrc04l91VZMkQK
|
||||||
endpoint: ice.cn-beijing.aliyuncs.com
|
endpoint: ice.cn-beijing.aliyuncs.com
|
||||||
access-key-id: ${zlt.oss.secretId}
|
|
||||||
access-key-secret: ${zlt.oss.secretKey}
|
|
||||||
region: cn-beijing
|
region: cn-beijing
|
||||||
project-name: ${IMS_PROJECT_NAME}
|
bucket: goflyapp # 使用实际存在的bucket名称
|
||||||
pipeline-name: ${IMS_PIPELINE_NAME}
|
|
||||||
template-id: ${IMS_TEMPLATE_ID:e26a222d7cfb4a1dae85077efaeb05cd}
|
|
||||||
callback-url: ${IMS_CALLBACK_URL:http://img.goflytec.com/api-order/auto/cut/callback}
|
|
||||||
bucket: ${zlt.oss.bucketName}
|
|
||||||
|
|||||||
@@ -127,9 +127,9 @@ const TableList: React.FC = () => {
|
|||||||
|
|
||||||
if (response.resp_code === 0) {
|
if (response.resp_code === 0) {
|
||||||
return {
|
return {
|
||||||
data: response.data.records || [],
|
data: response.data.data || [],
|
||||||
success: true,
|
success: true,
|
||||||
total: response.data.total || 0,
|
total: response.data.count || 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
message.error(response.resp_msg);
|
message.error(response.resp_msg);
|
||||||
|
|||||||
+24
-4
@@ -6,6 +6,8 @@ import {
|
|||||||
ProFormText,
|
ProFormText,
|
||||||
ProFormDigit,
|
ProFormDigit,
|
||||||
} from '@ant-design/pro-components';
|
} from '@ant-design/pro-components';
|
||||||
|
import { Form } from 'antd';
|
||||||
|
import { ENABLE_PROFIT_OPTIONS, PAYEE_TYPE_OPTIONS } from '../index';
|
||||||
|
|
||||||
interface CreateFormProps {
|
interface CreateFormProps {
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
@@ -26,6 +28,10 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
|||||||
waylineOptions,
|
waylineOptions,
|
||||||
deviceOptions,
|
deviceOptions,
|
||||||
}) => {
|
}) => {
|
||||||
|
// 使用 Form.useWatch 监听 enableProfit 的值
|
||||||
|
const [form] = Form.useForm();
|
||||||
|
const enableProfit = Form.useWatch('enableProfit', form);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalForm
|
<ModalForm
|
||||||
title="新增二维码"
|
title="新增二维码"
|
||||||
@@ -33,6 +39,10 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
|||||||
onVisibleChange={onVisibleChange}
|
onVisibleChange={onVisibleChange}
|
||||||
modalProps={{ destroyOnClose: true }}
|
modalProps={{ destroyOnClose: true }}
|
||||||
onFinish={onSubmit}
|
onFinish={onSubmit}
|
||||||
|
form={form}
|
||||||
|
initialValues={{
|
||||||
|
enableProfit: 0, // 默认不开启分润
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
<ProFormText
|
<ProFormText
|
||||||
@@ -114,22 +124,31 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
|||||||
/>
|
/>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
|
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormSelect
|
||||||
|
width="md"
|
||||||
|
name="enableProfit"
|
||||||
|
label="是否开启分润"
|
||||||
|
options={ENABLE_PROFIT_OPTIONS}
|
||||||
|
rules={[{ required: true, message: '请选择是否开启分润' }]}
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
width="md"
|
width="md"
|
||||||
name="payeeType"
|
name="payeeType"
|
||||||
label="分账账号类型"
|
label="分账账号类型"
|
||||||
options={[
|
options={PAYEE_TYPE_OPTIONS}
|
||||||
{ label: '商户ID', value: 'MERCHANT_ID' },
|
|
||||||
{ label: '个人openid', value: 'PERSONAL_OPENID' },
|
|
||||||
]}
|
|
||||||
placeholder="请选择分账账号类型"
|
placeholder="请选择分账账号类型"
|
||||||
|
disabled={enableProfit === 0}
|
||||||
/>
|
/>
|
||||||
<ProFormText
|
<ProFormText
|
||||||
width="md"
|
width="md"
|
||||||
name="payeeAccount"
|
name="payeeAccount"
|
||||||
label="分账账号"
|
label="分账账号"
|
||||||
placeholder="请输入分账账号"
|
placeholder="请输入分账账号"
|
||||||
|
disabled={enableProfit === 0}
|
||||||
/>
|
/>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
|
|
||||||
@@ -141,6 +160,7 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
|||||||
min={0}
|
min={0}
|
||||||
max={100}
|
max={100}
|
||||||
placeholder="请输入分账比例"
|
placeholder="请输入分账比例"
|
||||||
|
disabled={enableProfit === 0}
|
||||||
/>
|
/>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
</ModalForm>
|
</ModalForm>
|
||||||
|
|||||||
+23
-6
@@ -6,7 +6,7 @@ import {
|
|||||||
ProFormText,
|
ProFormText,
|
||||||
ProFormDigit,
|
ProFormDigit,
|
||||||
} from '@ant-design/pro-components';
|
} from '@ant-design/pro-components';
|
||||||
import { STATUS_OPTIONS, PAYEE_TYPE_OPTIONS } from '../index';
|
import { STATUS_OPTIONS, PAYEE_TYPE_OPTIONS, ENABLE_PROFIT_OPTIONS } from '../index';
|
||||||
import { Form, Space } from 'antd';
|
import { Form, Space } from 'antd';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
@@ -31,6 +31,9 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
|
|||||||
waylineOptions,
|
waylineOptions,
|
||||||
deviceOptions,
|
deviceOptions,
|
||||||
}) => {
|
}) => {
|
||||||
|
const [form] = Form.useForm();
|
||||||
|
const enableProfit = Form.useWatch('enableProfit', form);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalForm
|
<ModalForm
|
||||||
title="修改二维码"
|
title="修改二维码"
|
||||||
@@ -38,7 +41,11 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
|
|||||||
onVisibleChange={onVisibleChange}
|
onVisibleChange={onVisibleChange}
|
||||||
modalProps={{ destroyOnClose: true }}
|
modalProps={{ destroyOnClose: true }}
|
||||||
onFinish={onSubmit}
|
onFinish={onSubmit}
|
||||||
initialValues={values}
|
form={form}
|
||||||
|
initialValues={{
|
||||||
|
...values,
|
||||||
|
enableProfit: values?.enableProfit ?? 0,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
<ProFormText
|
<ProFormText
|
||||||
@@ -119,22 +126,31 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
|
|||||||
/>
|
/>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
|
|
||||||
|
<ProForm.Group>
|
||||||
|
<ProFormSelect
|
||||||
|
width="md"
|
||||||
|
name="enableProfit"
|
||||||
|
label="是否开启分润"
|
||||||
|
options={ENABLE_PROFIT_OPTIONS}
|
||||||
|
rules={[{ required: true, message: '请选择是否开启分润' }]}
|
||||||
|
/>
|
||||||
|
</ProForm.Group>
|
||||||
|
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
width="md"
|
width="md"
|
||||||
name="payeeType"
|
name="payeeType"
|
||||||
label="分账账号类型"
|
label="分账账号类型"
|
||||||
options={[
|
options={PAYEE_TYPE_OPTIONS}
|
||||||
{ label: '商户ID', value: 'MERCHANT_ID' },
|
|
||||||
{ label: '个人openid', value: 'PERSONAL_OPENID' },
|
|
||||||
]}
|
|
||||||
placeholder="请选择分账账号类型"
|
placeholder="请选择分账账号类型"
|
||||||
|
disabled={enableProfit === 0}
|
||||||
/>
|
/>
|
||||||
<ProFormText
|
<ProFormText
|
||||||
width="md"
|
width="md"
|
||||||
name="payeeAccount"
|
name="payeeAccount"
|
||||||
label="分账账号"
|
label="分账账号"
|
||||||
placeholder="请输入分账账号"
|
placeholder="请输入分账账号"
|
||||||
|
disabled={enableProfit === 0}
|
||||||
/>
|
/>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
|
|
||||||
@@ -146,6 +162,7 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
|
|||||||
min={0}
|
min={0}
|
||||||
max={100}
|
max={100}
|
||||||
placeholder="请输入分账比例"
|
placeholder="请输入分账比例"
|
||||||
|
disabled={enableProfit === 0}
|
||||||
/>
|
/>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
</ModalForm>
|
</ModalForm>
|
||||||
|
|||||||
@@ -43,6 +43,12 @@ export const PAYEE_STATUS_OPTIONS = [
|
|||||||
{ label: '验证失败', value: 2 },
|
{ label: '验证失败', value: 2 },
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
|
// 添加分润状态常量
|
||||||
|
export const ENABLE_PROFIT_OPTIONS = [
|
||||||
|
{ label: '否', value: 0 },
|
||||||
|
{ label: '是', value: 1 },
|
||||||
|
] as const;
|
||||||
|
|
||||||
const handleApiRequest = async (
|
const handleApiRequest = async (
|
||||||
apiCall: () => Promise<any>,
|
apiCall: () => Promise<any>,
|
||||||
loadingMessage: string,
|
loadingMessage: string,
|
||||||
@@ -301,25 +307,36 @@ const TableList: React.FC = () => {
|
|||||||
render: (status) => renderStatus(status as number),
|
render: (status) => renderStatus(status as number),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '分账账号',
|
title: '是否开启分润',
|
||||||
dataIndex: 'payeeAccount',
|
dataIndex: 'enableProfit',
|
||||||
width: 140,
|
width: 120,
|
||||||
ellipsis: true,
|
render: (_, record) => {
|
||||||
|
const status = record.enableProfit === 1 ? '是' : '否';
|
||||||
|
const color = record.enableProfit === 1 ? 'green' : 'default';
|
||||||
|
return <Tag color={color}>{status}</Tag>;
|
||||||
|
},
|
||||||
|
valueEnum: {
|
||||||
|
0: { text: '否' },
|
||||||
|
1: { text: '是' },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '账号类型',
|
title: '分账账号',
|
||||||
dataIndex: 'payeeType',
|
dataIndex: 'payeeAccount',
|
||||||
width: 100,
|
width: 180,
|
||||||
valueEnum: {
|
render: (_, record) => {
|
||||||
'MERCHANT_ID': { text: '商户ID' },
|
if (record.enableProfit !== 1) return '-';
|
||||||
'PERSONAL_OPENID': { text: '个人openid' },
|
return record.payeeAccount || '-';
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '分账比例',
|
title: '分账比例',
|
||||||
dataIndex: 'profitRate',
|
dataIndex: 'profitRate',
|
||||||
width: 100,
|
width: 100,
|
||||||
render: (val) => val ? `${val}%` : '-',
|
render: (_, record) => {
|
||||||
|
if (record.enableProfit !== 1) return '-';
|
||||||
|
return record.profitRate ? `${record.profitRate}%` : '-';
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '验证状态',
|
title: '验证状态',
|
||||||
@@ -358,6 +375,15 @@ const TableList: React.FC = () => {
|
|||||||
width: 160,
|
width: 160,
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '账号类型',
|
||||||
|
dataIndex: 'payeeType',
|
||||||
|
width: 100,
|
||||||
|
valueEnum: {
|
||||||
|
'MERCHANT_ID': { text: '商户ID' },
|
||||||
|
'PERSONAL_OPENID': { text: '个人openid' },
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
key: 'action',
|
key: 'action',
|
||||||
|
|||||||
Reference in New Issue
Block a user