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({ "