diff --git a/zlt-business/order-center/src/main/java/com/central/order/controller/OrderFileController.java b/zlt-business/order-center/src/main/java/com/central/order/controller/OrderFileController.java index 07cd5d20..e25ac6da 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/controller/OrderFileController.java +++ b/zlt-business/order-center/src/main/java/com/central/order/controller/OrderFileController.java @@ -7,6 +7,7 @@ import com.central.order.enums.OrderStatus; import com.central.order.feign.FileCenterService; import com.central.order.feign.UserCenterService; import com.central.order.model.*; +import com.central.order.model.EditTask; import com.central.order.service.*; import com.central.order.util.DateUtils; import io.swagger.v3.oas.annotations.Operation; @@ -167,44 +168,44 @@ public class OrderFileController { log.warn("参数为空,orderFile: {}", orderFile); return Result.failed(orderFile,"参数为空"); } - + // 校验订单是否存在 Order order = orderService.getOrderByNumber(orderFile.getOrderNo()); if (order == null) { log.warn("订单不存在,订单号: {}", orderFile.getOrderNo()); return Result.failed(orderFile,"订单不存在"); } - + // 校验文件路径是否为空 if (orderFile.getFilePath() == null || orderFile.getFilePath().trim().isEmpty()) { log.warn("素材路径为空,订单号: {}", orderFile.getOrderNo()); return Result.failed(orderFile,"素材路径为空"); } - + // 先校验记录是否已经存在 OrderFile existingOrderFile = orderFileService.getOrderFileByFilePath(orderFile.getFilePath()); if (existingOrderFile != null) { log.info("记录已存在,不再重复创建,订单号: {}, 文件路径: {}", orderFile.getOrderNo(), orderFile.getFilePath()); return Result.succeed(existingOrderFile, "记录已存在,无需重复创建"); } - + // 设置订单相关信息 orderFile.setOrderNo(order.getOrderNo()); orderFile.setUserId(order.getUserId()); - + // 创建文件信息 FileInfo fileInfo = fileCenterService.creatFileInfo(orderFile.getFilePath()); if (fileInfo == null) { log.warn("文件信息创建失败,filePath: {}", orderFile.getFilePath()); return Result.failed(orderFile,"文件信息创建失败"); } - + // 设置文件相关信息 orderFile.setFileId(fileInfo.getId()); orderFile.setFilePath(fileInfo.getPath()); orderFile.setFileType(fileInfo.getContentType()); orderFile.setTourismId(order.getTourismId()); - + // 保存记录 boolean saved = orderFileService.save(orderFile); if (saved) { @@ -257,27 +258,46 @@ public class OrderFileController { //发送用户素材上传成功通知 sendMessageForResouresUploaded(order,tourism); - //触发一键成片 - // 1. 创建新任务 - EditTask task = editTaskService.createTask(order.getOrderNo(), order.getUserId()); + // 检查是否开启一键成片功能 + if (isVideoEditEnabled(qrCode)) { + log.info("二维码已开启一键成片功能,开始触发一键成片: orderNo={}, codeId={}", + order.getOrderNo(), order.getCodeId()); - // 2. 获取素材文件 - List orderFiles = orderFileService.getOrderFileByOrderNo(order.getOrderNo()); + //触发一键成片 + // 1. 创建新任务 + EditTask task = editTaskService.createTask(order.getOrderNo(), order.getUserId()); - // 3. 提交编辑任务 - String jobId = videoEditService.submitEditTask(order.getOrderNo(), orderFiles); - log.info("提交一键成片任务成功: orderNo={}, jobId={}, totalMediaFiles={}", - order.getOrderNo(), jobId, orderFiles.size()); - // 4. 更新任务信息 - task.setJobId(jobId); - task.setStatus(EditTaskStatus.PROCESSING); - editTaskService.saveOrUpdateTask(task); + // 2. 获取素材文件 + List orderFiles = orderFileService.getOrderFileByOrderNo(order.getOrderNo()); + + // 3. 提交编辑任务 + String jobId = videoEditService.submitEditTask(order.getOrderNo(), orderFiles); + log.info("提交一键成片任务成功: orderNo={}, jobId={}, totalMediaFiles={}", + order.getOrderNo(), jobId, orderFiles.size()); + // 4. 更新任务信息 + task.setJobId(jobId); + task.setStatus(EditTaskStatus.PROCESSING); + editTaskService.saveOrUpdateTask(task); + } else { + log.info("二维码未开启一键成片功能,跳过一键成片: orderNo={}, codeId={}, enableVideoEdit={}", + order.getOrderNo(), order.getCodeId(), qrCode.getEnableVideoEdit()); + } } } catch (Exception e) { log.error("检查素材数量异常,订单号: {}", order.getOrderNo(), e); } } + /** + * 检查是否开启一键成片功能 + */ + private boolean isVideoEditEnabled(QrCode qrCode) { + return qrCode != null + && qrCode.getEnableVideoEdit() != null + && qrCode.getEnableVideoEdit() == 1 + && qrCode.getTemplateId() != null; // 确保有模板ID + } + /** * 素材上传完成小程序通知 * @param order @@ -324,21 +344,21 @@ public class OrderFileController { if (filePath == null || filePath.trim().isEmpty()) { return Result.failed("文件路径不能为空"); } - + OrderFile orderFile = orderFileService.getOrderFileByFilePath(filePath); if (orderFile == null) { return Result.failed("未找到对应的订单文件记录"); } - + // 设置文件查看URL orderFile.setViewUrl(fileCenterService.getViewUrlByPath(orderFile.getFilePath())); - + // 设置压缩文件查看URL Map fileMap = new HashMap<>(); fileMap.put("style", fileStyle); fileMap.put("path", orderFile.getFilePath()); orderFile.setZipViewUrl(fileCenterService.getViewUrlByPathStyle(fileMap)); - + return Result.succeed(orderFile, "记录已存在"); } catch (Exception e) { log.error("根据文件路径查询订单文件记录失败: filePath={}", filePath, e); @@ -353,10 +373,10 @@ public class OrderFileController { if (filePath == null || filePath.trim().isEmpty()) { return Result.failed("文件路径不能为空"); } - + OrderFile orderFile = orderFileService.getOrderFileByFilePath(filePath); boolean exists = orderFile != null; - + if (exists) { return Result.succeed(true, "记录已存在"); } else {