fix(订单中心):一键成片逻辑优化,兼容素材数量为4个的订单
This commit is contained in:
+19
-10
@@ -131,7 +131,7 @@ public class MediaServiceImpl implements IMediaService {
|
||||
|
||||
// 3. 获取视频文件
|
||||
// List<OrderFile> videoFiles = orderFileService.getOrderVideoFiles(orderNo);
|
||||
if (orderFiles == null || orderFiles.size() < 7) {
|
||||
if (orderFiles == null || orderFiles.size() < qrCode.getMaterialCount()) {
|
||||
throw new BusinessException("订单视频文件数量不足,至少需要2个视频文件");
|
||||
}
|
||||
|
||||
@@ -188,16 +188,17 @@ public class MediaServiceImpl implements IMediaService {
|
||||
List<OrderFile> videoFiles = taskData.getVideoFiles();
|
||||
//@TODO 后期需要通过模板参数进行动态设置clips参数
|
||||
|
||||
clips.put("1", fileCenterService.getViewUrlByPath(videoFiles.get(4).getFilePath()));
|
||||
clips.put("2", fileCenterService.getViewUrlByPath(videoFiles.get(5).getFilePath()));
|
||||
clips.put("3", fileCenterService.getViewUrlByPath(videoFiles.get(6).getFilePath()));
|
||||
clips.put("4", fileCenterService.getViewUrlByPath(videoFiles.get(0).getFilePath()));
|
||||
clips.put("5", fileCenterService.getViewUrlByPath(videoFiles.get(1).getFilePath()));
|
||||
clips.put("6", fileCenterService.getViewUrlByPath(videoFiles.get(2).getFilePath()));
|
||||
clips.put("7", fileCenterService.getViewUrlByPath(videoFiles.get(3).getFilePath()));
|
||||
// 保持既有模板顺序;当索引越界或无素材时返回空URL
|
||||
clips.put("1", getUrlBySafeIndex(videoFiles, 4));
|
||||
clips.put("2", getUrlBySafeIndex(videoFiles, 5));
|
||||
clips.put("3", getUrlBySafeIndex(videoFiles, 6));
|
||||
clips.put("4", getUrlBySafeIndex(videoFiles, 0));
|
||||
clips.put("5", getUrlBySafeIndex(videoFiles, 1));
|
||||
clips.put("6", getUrlBySafeIndex(videoFiles, 2));
|
||||
clips.put("7", getUrlBySafeIndex(videoFiles, 3));
|
||||
|
||||
if (taskData.getVideoFiles().size() > 7) {
|
||||
clips.put("8", fileCenterService.getViewUrlByPath(videoFiles.get(7).getFilePath()));
|
||||
if (videoFiles != null && videoFiles.size() > 7) {
|
||||
clips.put("8", getUrlBySafeIndex(videoFiles, 7));
|
||||
}
|
||||
|
||||
return JSON.toJSONString(clips);
|
||||
@@ -206,6 +207,14 @@ public class MediaServiceImpl implements IMediaService {
|
||||
}
|
||||
}
|
||||
|
||||
private String getUrlBySafeIndex(List<OrderFile> videoFiles, int index) {
|
||||
int size = (videoFiles == null) ? 0 : videoFiles.size();
|
||||
if (size == 0 || index < 0 || index >= size) {
|
||||
return "";
|
||||
}
|
||||
return fileCenterService.getViewUrlByPath(videoFiles.get(index).getFilePath());
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建输出配置
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user