From 993fcc2fa454bbd78576d82a17305d854b697cfe Mon Sep 17 00:00:00 2001 From: Iamasoldier <1272745473@qq.com> Date: Thu, 14 Aug 2025 20:17:29 +0800 Subject: [PATCH 1/9] =?UTF-8?q?fix(=E4=BC=98=E6=83=A0=E5=88=B8=E4=B8=AD?= =?UTF-8?q?=E5=BF=83)=EF=BC=9A=E6=90=BA=E7=A8=8B=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5=E7=AC=AC=E4=B8=80=E7=89=88?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=AF=B9=E6=8E=A5,=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=AF=86=E8=AF=B7=E6=B1=82=E4=BD=93=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CtripCouponController.java | 80 +++++++++++++++++++ .../src/main/resources/application.yml | 8 +- .../order/controller/TourismController.java | 10 ++- .../central/order/mapper/DashboardMapper.java | 2 +- .../central/order/mapper/TourismMapper.java | 4 +- .../java/com/central/order/model/Tourism.java | 5 ++ .../order/service/ITourismService.java | 3 +- .../service/impl/TourismServiceImpl.java | 11 ++- .../main/resources/mapper/TourismMapper.xml | 15 ++++ .../src/main/frontend/src/pages/Welcome.tsx | 7 +- .../orders/Tourism/components/UpdateForm.tsx | 12 +++ .../src/pages/orders/Tourism/index.tsx | 29 +++++++ .../frontend/src/services/orders/typings.d.ts | 1 + 13 files changed, 172 insertions(+), 15 deletions(-) diff --git a/zlt-business/coupon-center/src/main/java/com/central/coupon/controller/CtripCouponController.java b/zlt-business/coupon-center/src/main/java/com/central/coupon/controller/CtripCouponController.java index 548af87e..10bc9607 100644 --- a/zlt-business/coupon-center/src/main/java/com/central/coupon/controller/CtripCouponController.java +++ b/zlt-business/coupon-center/src/main/java/com/central/coupon/controller/CtripCouponController.java @@ -1166,4 +1166,84 @@ public class CtripCouponController { return Result.succeed(result); } } + + /** + * 测试接口 - 生成携程核销优惠券请求的加密body + */ + @Operation(summary = "测试接口 - 生成携程核销优惠券请求的加密body") + @PostMapping("/test/generate-verify-request") + public Result> generateVerifyRequest(@RequestBody Map request) { + log.info("收到生成携程核销优惠券请求体请求"); + + // 验证请求体不为空 + if (request == null || request.isEmpty()) { + log.error("请求体为空"); + return Result.succeed(Map.of("success", false, "error", "请求体不能为空")); + } + + try { + // 解析请求参数 + String ctripCouponId = (String) request.get("ctripCouponId"); + String orderNo = (String) request.get("orderNo"); + + if (ctripCouponId == null || orderNo == null) { + log.error("参数不完整 - ctripCouponId: {}, orderNo: {}", ctripCouponId, orderNo); + return Result.succeed(Map.of("success", false, "error", "参数不完整")); + } + + log.info("开始生成携程核销优惠券请求体,ctripCouponId: {}, orderNo: {}", ctripCouponId, orderNo); + + // 构建核销请求的body - 按照携程核销优惠券接口规范 + Map requestBody = new HashMap<>(); + requestBody.put("userPhone", "13800138000"); // 默认用户手机号 + requestBody.put("orderNo", orderNo); + requestBody.put("orderAmount", 100.00); // 默认订单金额 + + // 构建完整的请求(包含header和body) + Map fullRequest = new HashMap<>(); + + // 构建header + Map header = new HashMap<>(); + header.put("accountId", "c50a8f2a4a59c9e7"); + header.put("serviceName", "VerifyCoupon"); + header.put("requestTime", java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + header.put("version", "1.0"); + + // 生成签名 + String bodyJson = objectMapper.writeValueAsString(requestBody); + String sign = ctripDecryptUtil.generateSign("c50a8f2a4a59c9e7", "VerifyCoupon", + header.get("requestTime").toString(), bodyJson, "1.0"); + header.put("sign", sign); + + // 使用AES加密body + String encryptedBody = ctripDecryptUtil.encryptAES(bodyJson); + + fullRequest.put("header", header); + fullRequest.put("body", encryptedBody); // 加密后的body + + // 生成JSON字符串 + String requestJson = objectMapper.writeValueAsString(fullRequest); + + Map result = new HashMap<>(); + result.put("success", true); + result.put("url", "/coupon/ctrip/verify"); + result.put("method", "POST"); + result.put("headers", Map.of("Content-Type", "application/json")); + result.put("originalBody", requestBody); + result.put("encryptedBody", encryptedBody); + result.put("fullRequest", fullRequest); + result.put("requestJson", requestJson); + result.put("message", "携程核销优惠券请求体生成成功"); + + log.info("携程核销优惠券请求体生成成功: {}", result); + return Result.succeed(result); + + } catch (Exception e) { + log.error("生成携程核销优惠券请求体失败", e); + Map result = new HashMap<>(); + result.put("success", false); + result.put("error", e.getMessage()); + return Result.succeed(result); + } + } } \ No newline at end of file diff --git a/zlt-business/coupon-center/src/main/resources/application.yml b/zlt-business/coupon-center/src/main/resources/application.yml index 5cba8b53..ae150ec3 100644 --- a/zlt-business/coupon-center/src/main/resources/application.yml +++ b/zlt-business/coupon-center/src/main/resources/application.yml @@ -46,8 +46,8 @@ logging: ctrip: # AES加密配置 aes: - key: 087b36ad0dff7942 # 请替换为实际的AES密钥 - iv: 750e15a31356a99d # 请替换为实际的AES IV + key: 087b36ad0dff7942 # 为实际的AES密钥 + iv: 750e15a31356a99d # 为实际的AES IV # 签名配置(使用账户密钥进行签名计算) # API配置 api: @@ -56,5 +56,5 @@ ctrip: retry-times: 3 # 重试次数 # 账户配置 account: - id: c50a8f2a4a59c9e7 # 请替换为实际的账户ID - secret: ce6033ae31124ec5cdab3d2bc79f2622 # 请替换为实际的账户密钥 + id: c50a8f2a4a59c9e7 # 为实际的账户ID + secret: ce6033ae31124ec5cdab3d2bc79f2622 # 实际的账户密钥 diff --git a/zlt-business/order-center/src/main/java/com/central/order/controller/TourismController.java b/zlt-business/order-center/src/main/java/com/central/order/controller/TourismController.java index b685b270..fdbefcab 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/controller/TourismController.java +++ b/zlt-business/order-center/src/main/java/com/central/order/controller/TourismController.java @@ -105,17 +105,19 @@ public class TourismController { @Parameter(name = "longitude", description = "经度", required = true, in = ParameterIn.QUERY), @Parameter(name = "latitude", description = "纬度", required = true, in = ParameterIn.QUERY), @Parameter(name = "radius", description = "搜索半径(公里),默认10km", required = false, in = ParameterIn.QUERY), - @Parameter(name = "limit", description = "返回数量限制,默认20个", required = false, in = ParameterIn.QUERY) + @Parameter(name = "limit", description = "返回数量限制,默认20个", required = false, in = ParameterIn.QUERY), + @Parameter(name = "showInHomepage", description = "是否在首页显示(0:不显示,1:显示),默认1(只显示设置为显示的景区)", required = false, in = ParameterIn.QUERY) }) @GetMapping("/nearby") public Result> findNearbyTourisms( @RequestParam BigDecimal longitude, @RequestParam BigDecimal latitude, @RequestParam(required = false) Double radius, - @RequestParam(required = false) Integer limit) { + @RequestParam(required = false) Integer limit, + @RequestParam(required = false, defaultValue = "1") Integer showInHomepage) { try { - log.info("查询附近景区,经度: {}, 纬度: {}, 半径: {}km, 限制数量: {}", longitude, latitude, radius, limit); - List tourisms = tourismService.findNearbyTourisms(longitude, latitude, radius, limit); + log.info("查询附近景区,经度: {}, 纬度: {}, 半径: {}km, 限制数量: {}, 首页显示: {}", longitude, latitude, radius, limit, showInHomepage); + List tourisms = tourismService.findNearbyTourisms(longitude, latitude, radius, limit, showInHomepage); return Result.succeed(tourisms, "查询附近景区成功"); } catch (Exception e) { log.error("查询附近景区失败", e); diff --git a/zlt-business/order-center/src/main/java/com/central/order/mapper/DashboardMapper.java b/zlt-business/order-center/src/main/java/com/central/order/mapper/DashboardMapper.java index 36f5a302..464c7cfa 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/mapper/DashboardMapper.java +++ b/zlt-business/order-center/src/main/java/com/central/order/mapper/DashboardMapper.java @@ -532,7 +532,7 @@ public interface DashboardMapper { @Select({ "