diff --git a/zlt-business/file-center/src/main/java/com/central/file/controller/FileController.java b/zlt-business/file-center/src/main/java/com/central/file/controller/FileController.java index 21d4ade6..7b628907 100644 --- a/zlt-business/file-center/src/main/java/com/central/file/controller/FileController.java +++ b/zlt-business/file-center/src/main/java/com/central/file/controller/FileController.java @@ -63,6 +63,12 @@ public class FileController { @Value("${zlt.security.tencent.getwxacodeUrl}") private String getwxacodeUrl; + @Value("${cdn.s3.domain:minicdn.goflytec.com}") + private String s3CdnDomain; + + @Value("${cdn.s3.enabled:true}") + private boolean s3CdnEnabled; + private final RestTemplate restTemplate = new RestTemplate(); @Value("${zlt.security.tencent.pagePath}") @@ -226,19 +232,19 @@ public class FileController { } /** - * 直接 S3 预签名(绕过 TimeWindowStorageService 智能路由) + * 直接 S3 无过期访问地址(绕过 TimeWindowStorageService 智能路由) + * 用于支付宝小程序二维码:与 AbstractIFileService.uploadForS3 上传时设置的 fileInfo.url 完全一致 —— + * 直接拼 https:///,不签名、不带过期、可被 CDN 缓存。 */ @GetMapping("/files/s3/path") public String getS3ViewUrlByPath(@RequestParam("path") String path) { if (path == null || path.isEmpty()) { return ""; } - try { - return fileService.getS3ViewUrlByPath(path); - } catch (Exception e) { - log.warn("获取S3预签名URL失败: path={}, err={}", path, e.getMessage()); - return ""; + if (s3CdnEnabled && s3CdnDomain != null && !s3CdnDomain.isEmpty()) { + return "https://" + s3CdnDomain + "/" + path; } + return path; } @PostMapping("/path") diff --git a/zlt-business/file-center/src/main/java/com/central/file/service/IFileService.java b/zlt-business/file-center/src/main/java/com/central/file/service/IFileService.java index a71671cf..57fb1c80 100644 --- a/zlt-business/file-center/src/main/java/com/central/file/service/IFileService.java +++ b/zlt-business/file-center/src/main/java/com/central/file/service/IFileService.java @@ -48,9 +48,4 @@ public interface IFileService extends IService { String getViewUrlByPathAndExpires(String name,int expires); String getS3UrlByPath(String path); - - /** - * 强制返回 S3 预签名 URL(绕开智能路由,用于支付宝小程序二维码展示) - */ - String getS3ViewUrlByPath(String path); } diff --git a/zlt-business/file-center/src/main/java/com/central/file/service/impl/AbstractIFileService.java b/zlt-business/file-center/src/main/java/com/central/file/service/impl/AbstractIFileService.java index 7b738a8f..e3dd4962 100644 --- a/zlt-business/file-center/src/main/java/com/central/file/service/impl/AbstractIFileService.java +++ b/zlt-business/file-center/src/main/java/com/central/file/service/impl/AbstractIFileService.java @@ -181,32 +181,6 @@ public abstract class AbstractIFileService extends ServiceImpl payOrder(@RequestBody Map body) { + public Result payOrder(@RequestBody Map body) { Object rawOrderId = body.get("orderId"); Assert.notNull(rawOrderId, "orderId 不能为空"); Long orderId = Long.valueOf(rawOrderId.toString()); @@ -91,7 +93,7 @@ public class AliPayController { Assert.notNull(order, "订单不存在: " + orderId); // 校验当前登录用户拥有该订单(防止替他人订单发起支付) - LoginAppUser currentUser = SecurityTenantUtils.getCurrentUser(); + LoginAppUser currentUser = LoginUserContextHolder.getUser(); Assert.notNull(currentUser, "未登录或登录已过期"); if (order.getUserId() == null || !order.getUserId().equals(currentUser.getId())) { throw new IllegalStateException("无权操作他人订单, orderId: " + orderId); @@ -143,16 +145,11 @@ public class AliPayController { } AlipayTradeCreateResponse response = alipayPayService.create(config, req); - - Map result = new HashMap<>(); if (response.isSuccess()) { - result.put("tradeNo", response.getTradeNo()); - result.put("outTradeNo", response.getOutTradeNo()); + return Result.succeed(response,response.getMsg()); } else { - result.put("error", response.getSubMsg()); - result.put("code", response.getCode()); + return Result.failed(response.getMsg()); } - return result; } // ==================== 支付异步回调 ====================