!24 fix(订单中心):首页统计临时演示修复,二维码租户Id修改
Merge pull request !24 from Iamasoldier/feature_lsl
This commit is contained in:
+85
@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.central.common.model.Result;
|
||||
|
||||
/**
|
||||
* 热数据同步控制器
|
||||
@@ -194,4 +195,88 @@ public class HotDataSyncController {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 诊断S3配置和URL生成
|
||||
*/
|
||||
@Operation(summary = "诊断S3配置和URL生成")
|
||||
@GetMapping("/diagnose")
|
||||
public Result<Map<String, Object>> diagnoseS3Config() {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
try {
|
||||
// 检查S3配置
|
||||
result.put("s3Enabled", hotDataSyncService.isS3Enabled());
|
||||
result.put("enhancedS3ServiceAvailable", hotDataSyncService.isEnhancedS3ServiceAvailable());
|
||||
result.put("s3ServiceAvailable", hotDataSyncService.isS3ServiceAvailable());
|
||||
|
||||
// 检查S3配置信息
|
||||
result.put("s3Config", hotDataSyncService.getS3ConfigInfo());
|
||||
|
||||
// 测试URL生成
|
||||
result.put("urlTest", hotDataSyncService.testUrlGeneration());
|
||||
|
||||
// 检查热同步配置
|
||||
result.put("hotSyncConfig", hotDataSyncService.getHotSyncConfig());
|
||||
|
||||
return Result.succeed(result);
|
||||
} catch (Exception e) {
|
||||
log.error("诊断S3配置失败", e);
|
||||
result.put("error", e.getMessage());
|
||||
return Result.failed("诊断失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试URL访问
|
||||
*/
|
||||
@Operation(summary = "测试URL访问")
|
||||
@PostMapping("/test-url")
|
||||
public Result<Map<String, Object>> testUrlAccess(@RequestParam String url) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
try {
|
||||
log.info("测试URL访问: {}", url);
|
||||
|
||||
// 创建HTTP连接
|
||||
java.net.URL testUrl = new java.net.URL(url);
|
||||
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) testUrl.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setConnectTimeout(10000); // 10秒连接超时
|
||||
connection.setReadTimeout(30000); // 30秒读取超时
|
||||
|
||||
// 设置User-Agent
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36");
|
||||
|
||||
int responseCode = connection.getResponseCode();
|
||||
String responseMessage = connection.getResponseMessage();
|
||||
|
||||
result.put("url", url);
|
||||
result.put("responseCode", responseCode);
|
||||
result.put("responseMessage", responseMessage);
|
||||
result.put("contentType", connection.getContentType());
|
||||
result.put("contentLength", connection.getContentLengthLong());
|
||||
result.put("accessible", responseCode == 200);
|
||||
|
||||
// 获取响应头信息
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
connection.getHeaderFields().forEach((key, values) -> {
|
||||
if (key != null && values != null && !values.isEmpty()) {
|
||||
headers.put(key, String.join(", ", values));
|
||||
}
|
||||
});
|
||||
result.put("headers", headers);
|
||||
|
||||
log.info("URL访问测试结果: 状态码={}, 消息={}, 可访问={}", responseCode, responseMessage, responseCode == 200);
|
||||
|
||||
return Result.succeed(result);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("测试URL访问失败: {}", url, e);
|
||||
result.put("url", url);
|
||||
result.put("error", e.getMessage());
|
||||
result.put("accessible", false);
|
||||
return Result.failed("URL访问测试失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+171
-16
@@ -19,6 +19,8 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 热数据自动同步服务
|
||||
@@ -203,10 +205,14 @@ public class HotDataSyncService {
|
||||
log.info("开始同步文件到S3,文件ID: {}, 文件名: {}, 重试次数: {}/{}",
|
||||
fileInfo.getId(), fileInfo.getName(), retryCount + 1, maxRetries);
|
||||
|
||||
// 获取原始OSS路径(不包含hot-sync前缀)
|
||||
String originalPath = getOriginalPath(fileInfo);
|
||||
log.debug("原始OSS路径: {}", originalPath);
|
||||
|
||||
// 从OSS获取文件URL
|
||||
String ossUrl = ossService.getViewUrlByPath(fileInfo.getPath());
|
||||
String ossUrl = ossService.getViewUrlByPath(originalPath);
|
||||
if (ossUrl == null || ossUrl.isEmpty()) {
|
||||
log.error("从OSS获取文件URL失败,文件ID: {}", fileInfo.getId());
|
||||
log.error("从OSS获取文件URL失败,文件ID: {}, 路径: {}", fileInfo.getId(), originalPath);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -230,16 +236,26 @@ public class HotDataSyncService {
|
||||
}
|
||||
|
||||
if (uploadSuccess) {
|
||||
// 更新文件存储信息
|
||||
updateFileStorageInfo(fileInfo, s3Path);
|
||||
log.info("文件同步成功,文件ID: {}, 新路径: {}", fileInfo.getId(), s3Path);
|
||||
return true;
|
||||
// 验证文件是否真的上传成功
|
||||
if (verifyFileUpload(s3Path)) {
|
||||
// 更新文件存储信息
|
||||
updateFileStorageInfo(fileInfo, s3Path);
|
||||
log.info("文件同步成功,文件ID: {}, 新路径: {}", fileInfo.getId(), s3Path);
|
||||
return true;
|
||||
} else {
|
||||
log.error("文件上传验证失败,文件ID: {}", fileInfo.getId());
|
||||
retryCount++;
|
||||
if (retryCount < maxRetries) {
|
||||
log.info("准备重试,等待2秒后重试...");
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.error("文件上传到S3失败,文件ID: {}", fileInfo.getId());
|
||||
retryCount++;
|
||||
if (retryCount < maxRetries) {
|
||||
log.info("准备重试,等待2秒后重试...");
|
||||
Thread.sleep(2000); // 等待2秒后重试
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,7 +270,7 @@ public class HotDataSyncService {
|
||||
if (retryCount < maxRetries) {
|
||||
try {
|
||||
log.info("准备重试,等待2秒后重试...");
|
||||
Thread.sleep(2000); // 等待2秒后重试
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException ie) {
|
||||
log.error("重试等待被中断", ie);
|
||||
Thread.currentThread().interrupt();
|
||||
@@ -371,14 +387,55 @@ public class HotDataSyncService {
|
||||
return "hot-sync/" + fileInfo.getId() + "/" + fileInfo.getName();
|
||||
}
|
||||
|
||||
// 如果原路径包含OSS信息,替换为S3路径
|
||||
if (originalPath.contains("oss://") || originalPath.contains("aliyun")) {
|
||||
return originalPath.replace("oss://", "s3://")
|
||||
.replace("aliyun", "minio");
|
||||
// 提取文件名,避免路径过长
|
||||
String fileName = fileInfo.getName();
|
||||
if (fileName == null || fileName.isEmpty()) {
|
||||
// 从路径中提取文件名
|
||||
if (originalPath.contains("/")) {
|
||||
fileName = originalPath.substring(originalPath.lastIndexOf("/") + 1);
|
||||
} else {
|
||||
fileName = originalPath;
|
||||
}
|
||||
}
|
||||
|
||||
// 否则添加热同步前缀
|
||||
return "hot-sync/" + originalPath;
|
||||
// 生成简洁的S3路径
|
||||
return "hot-sync/" + fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取原始OSS路径(去除hot-sync前缀)
|
||||
*/
|
||||
private String getOriginalPath(FileInfo fileInfo) {
|
||||
String path = fileInfo.getPath();
|
||||
if (path == null || path.isEmpty()) {
|
||||
return path;
|
||||
}
|
||||
|
||||
// 如果路径包含hot-sync前缀,去除它
|
||||
if (path.startsWith("hot-sync/")) {
|
||||
return path.substring("hot-sync/".length());
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证文件是否上传成功
|
||||
*/
|
||||
private boolean verifyFileUpload(String s3Path) {
|
||||
try {
|
||||
if (enhancedS3Service != null) {
|
||||
return enhancedS3Service.fileExists(s3Path);
|
||||
} else if (s3Service != null) {
|
||||
// 基础S3服务验证
|
||||
String url = s3Service.getViewUrlByPath(s3Path);
|
||||
return url != null && !url.isEmpty();
|
||||
}
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
log.warn("验证文件上传失败: {}", s3Path, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -482,7 +539,105 @@ public class HotDataSyncService {
|
||||
* 获取配置信息
|
||||
*/
|
||||
public String getConfigInfo() {
|
||||
return String.format("批次大小: %d, 同步间隔: %d分钟, 访问阈值: %d, 热数据天数: %d, 最大线程: %d",
|
||||
batchSize, syncIntervalMinutes, accessThreshold, hotDataDays, maxThreads);
|
||||
return String.format("热数据同步配置 - 启用: %s, 批次大小: %d, 同步间隔: %d分钟, 访问阈值: %d, 最大线程数: %d, 热数据天数: %d",
|
||||
syncEnabled, batchSize, syncIntervalMinutes, accessThreshold, maxThreads, hotDataDays);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查S3是否启用
|
||||
*/
|
||||
public boolean isS3Enabled() {
|
||||
return syncEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查增强S3服务是否可用
|
||||
*/
|
||||
public boolean isEnhancedS3ServiceAvailable() {
|
||||
return enhancedS3Service != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查基础S3服务是否可用
|
||||
*/
|
||||
public boolean isS3ServiceAvailable() {
|
||||
return s3Service != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取S3配置信息
|
||||
*/
|
||||
public Map<String, Object> getS3ConfigInfo() {
|
||||
Map<String, Object> config = new HashMap<>();
|
||||
|
||||
if (enhancedS3Service != null) {
|
||||
config.put("enhancedS3Service", "可用");
|
||||
// 尝试获取S3配置信息
|
||||
try {
|
||||
// 这里可以添加更多S3配置信息的获取逻辑
|
||||
config.put("s3Template", enhancedS3Service != null ? "已配置" : "未配置");
|
||||
} catch (Exception e) {
|
||||
config.put("s3Template", "配置错误: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
config.put("enhancedS3Service", "不可用");
|
||||
}
|
||||
|
||||
if (s3Service != null) {
|
||||
config.put("s3Service", "可用");
|
||||
} else {
|
||||
config.put("s3Service", "不可用");
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试URL生成
|
||||
*/
|
||||
public Map<String, Object> testUrlGeneration() {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
try {
|
||||
// 测试一个示例路径
|
||||
String testPath = "hot-sync/test-file.txt";
|
||||
|
||||
if (enhancedS3Service != null) {
|
||||
String url = enhancedS3Service.getViewUrlByPath(testPath);
|
||||
result.put("enhancedS3Url", url);
|
||||
result.put("enhancedS3UrlValid", url != null && !url.isEmpty());
|
||||
}
|
||||
|
||||
if (s3Service != null) {
|
||||
String url = s3Service.getViewUrlByPath(testPath);
|
||||
result.put("s3ServiceUrl", url);
|
||||
result.put("s3ServiceUrlValid", url != null && !url.isEmpty());
|
||||
}
|
||||
|
||||
result.put("testPath", testPath);
|
||||
|
||||
} catch (Exception e) {
|
||||
result.put("error", e.getMessage());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取热同步配置
|
||||
*/
|
||||
public Map<String, Object> getHotSyncConfig() {
|
||||
Map<String, Object> config = new HashMap<>();
|
||||
config.put("syncEnabled", syncEnabled);
|
||||
config.put("batchSize", batchSize);
|
||||
config.put("syncIntervalMinutes", syncIntervalMinutes);
|
||||
config.put("accessThreshold", accessThreshold);
|
||||
config.put("maxThreads", maxThreads);
|
||||
config.put("hotDataDays", hotDataDays);
|
||||
config.put("running", running);
|
||||
config.put("lastSyncTime", lastSyncTime);
|
||||
config.put("totalSyncedFiles", totalSyncedFiles.get());
|
||||
config.put("totalFailedFiles", totalFailedFiles.get());
|
||||
return config;
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ zlt:
|
||||
delete-source: false # 迁移后是否删除源文件
|
||||
batch-size: 100 # 迁移批次大小
|
||||
hot-sync:
|
||||
enabled: false # 启用热数据同步
|
||||
enabled: true # 启用热数据同步
|
||||
batch-size: 100 # 批次大小
|
||||
interval-minutes: 30 # 同步间隔
|
||||
access-threshold: 10 # 访问次数阈值
|
||||
|
||||
+827
-13
@@ -24,6 +24,13 @@ import com.central.order.model.CtripCreateOrderRequest.CtripOrderBody;
|
||||
import com.central.order.model.CtripCreateOrderRequest.CtripOrderItem;
|
||||
import com.central.order.model.CtripCreateOrderRequest.CtripPassenger;
|
||||
import com.central.order.model.CtripCreateOrderRequest.CtripContact;
|
||||
import com.central.order.model.CtripCreateOrderRequest.CtripHeader;
|
||||
|
||||
import com.central.order.model.CtripCreateOrderResponse;
|
||||
import com.central.order.service.IOrderService;
|
||||
import com.central.order.util.CtripDecryptUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 优惠券管理控制器
|
||||
@@ -37,6 +44,9 @@ public class CouponController {
|
||||
@Autowired
|
||||
private ICouponService couponService;
|
||||
|
||||
@Autowired
|
||||
private CtripDecryptUtil ctripDecryptUtil;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@@ -126,19 +136,106 @@ public class CouponController {
|
||||
*/
|
||||
@Operation(summary = "携程创建优惠券接口")
|
||||
@PostMapping("/ctrip/create")
|
||||
public Result<Boolean> createCouponFromCtripJson(@RequestBody CtripCreateOrderRequest request) {
|
||||
log.info("携程创建券请求:{}", request);
|
||||
public CtripCreateOrderResponse createCouponFromCtrip(@RequestBody CtripCreateOrderRequest request) {
|
||||
log.info("携程创建优惠券请求:{}", request);
|
||||
|
||||
CtripCreateOrderResponse response = new CtripCreateOrderResponse();
|
||||
|
||||
try {
|
||||
// 验证请求头
|
||||
if (request.getHeader() == null || request.getBody() == null) {
|
||||
return Result.failed("请求格式错误");
|
||||
log.error("请求格式错误:header或body为空");
|
||||
return buildErrorResponse(request, "0001", "请求格式错误");
|
||||
}
|
||||
|
||||
// 从body中提取订单信息
|
||||
CtripOrderBody body = request.getBody();
|
||||
// 处理body字段 - 可能是字符串或对象
|
||||
CtripOrderBody body = null;
|
||||
if (request.getBody() instanceof String) {
|
||||
// body是加密字符串,需要解码
|
||||
String encryptedBody = (String) request.getBody();
|
||||
log.info("收到加密的body数据,长度:{}", encryptedBody.length());
|
||||
|
||||
// 尝试解码body数据
|
||||
String decodedBody = tryDecode(encryptedBody);
|
||||
if (!decodedBody.equals(encryptedBody)) {
|
||||
log.info("body数据解码成功,尝试解析解码后的数据");
|
||||
log.debug("解码后的数据前100个字符:{}", decodedBody.length() > 100 ? decodedBody.substring(0, 100) + "..." : decodedBody);
|
||||
|
||||
if (isValidJson(decodedBody)) {
|
||||
// 解析解码后的JSON数据
|
||||
com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper();
|
||||
objectMapper.configure(com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
try {
|
||||
body = objectMapper.readValue(decodedBody, CtripOrderBody.class);
|
||||
log.info("成功解析解码后的JSON数据");
|
||||
} catch (Exception e) {
|
||||
log.error("解析解码后的JSON数据失败:{}", e.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.warn("解码后的数据不是有效的JSON格式,尝试进一步处理");
|
||||
// 尝试其他解码方式或直接处理
|
||||
String processedData = processDecodedData(decodedBody);
|
||||
if (processedData != null && isValidJson(processedData)) {
|
||||
com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper();
|
||||
objectMapper.configure(com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
try {
|
||||
body = objectMapper.readValue(processedData, CtripOrderBody.class);
|
||||
log.info("成功解析处理后的JSON数据");
|
||||
} catch (Exception e) {
|
||||
log.error("解析处理后的JSON数据失败:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 如果解码失败,尝试直接解析为JSON
|
||||
if (isValidJson(encryptedBody)) {
|
||||
log.info("body数据是有效的JSON格式,直接解析");
|
||||
com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper();
|
||||
objectMapper.configure(com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
try {
|
||||
body = objectMapper.readValue(encryptedBody, CtripOrderBody.class);
|
||||
log.info("成功解析原始JSON数据");
|
||||
} catch (Exception e) {
|
||||
log.error("解析原始JSON数据失败:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 如果仍然无法解析,尝试使用携程特定的解密方法
|
||||
if (body == null) {
|
||||
log.warn("标准解码失败,尝试携程特定解密方法");
|
||||
try {
|
||||
String decryptedBody = tryCtripDecrypt(encryptedBody, request.getHeader().getAccountId());
|
||||
if (decryptedBody != null && isValidJson(decryptedBody)) {
|
||||
com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper();
|
||||
objectMapper.configure(com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
body = objectMapper.readValue(decryptedBody, CtripOrderBody.class);
|
||||
log.info("成功通过携程解密解析数据");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("携程解密失败:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (body == null) {
|
||||
log.error("无法解析body数据,数据格式:{}", analyzeDataFormat(encryptedBody));
|
||||
log.error("解码后的数据格式:{}", analyzeDataFormat(decodedBody));
|
||||
log.error("解码后的数据详情:{}", getDataDetails(decodedBody));
|
||||
return buildErrorResponse(request, "0007", "无法解析body数据,请联系技术支持");
|
||||
}
|
||||
} else if (request.getBody() instanceof CtripOrderBody) {
|
||||
// body已经是对象
|
||||
body = (CtripOrderBody) request.getBody();
|
||||
log.info("body已经是对象格式");
|
||||
} else {
|
||||
log.error("body字段格式不支持:{}", request.getBody().getClass().getName());
|
||||
return buildErrorResponse(request, "0008", "body字段格式不支持");
|
||||
}
|
||||
|
||||
// 从body中提取优惠券信息
|
||||
if (body.getItems() == null || body.getItems().isEmpty()) {
|
||||
return Result.failed("订单项不能为空");
|
||||
log.error("订单项不能为空");
|
||||
return buildErrorResponse(request, "0002", "订单项不能为空");
|
||||
}
|
||||
|
||||
// 获取第一个订单项
|
||||
@@ -151,6 +248,7 @@ public class CouponController {
|
||||
CtripPassenger passenger = item.getPassengers().get(0);
|
||||
userPhone = passenger.getMobile();
|
||||
userName = passenger.getName();
|
||||
log.debug("从乘客信息获取到手机号: {}, 姓名: {}", userPhone, userName);
|
||||
}
|
||||
|
||||
// 获取联系人信息作为备选
|
||||
@@ -158,10 +256,12 @@ public class CouponController {
|
||||
CtripContact contact = body.getContacts().get(0);
|
||||
userPhone = contact.getMobile();
|
||||
userName = contact.getName();
|
||||
log.debug("从联系人信息获取到手机号: {}, 姓名: {}", userPhone, userName);
|
||||
}
|
||||
|
||||
if (userPhone == null) {
|
||||
return Result.failed("无法获取用户手机号");
|
||||
log.error("无法获取用户手机号");
|
||||
return buildErrorResponse(request, "0003", "无法获取用户手机号");
|
||||
}
|
||||
|
||||
// 构建优惠券信息
|
||||
@@ -173,10 +273,13 @@ public class CouponController {
|
||||
String validStartTime = item.getUseStartDate();
|
||||
String validEndTime = item.getUseEndDate();
|
||||
|
||||
log.debug("优惠券信息 - ctripCouponId: {}, userPhone: {}, couponName: {}, amount: {}, minAmount: {}",
|
||||
ctripCouponId, userPhone, couponName, amount, minAmount);
|
||||
|
||||
// 幂等校验
|
||||
if (couponService.existsByUserPhoneAndCtripCouponId(userPhone, ctripCouponId)) {
|
||||
log.info("携程优惠券已存在,userPhone: {}, ctripCouponId: {}", userPhone, ctripCouponId);
|
||||
return Result.succeed(true);
|
||||
return buildSuccessResponse(request, ctripCouponId, "优惠券已存在且创建成功");
|
||||
}
|
||||
|
||||
// 时间解析
|
||||
@@ -185,11 +288,13 @@ public class CouponController {
|
||||
|
||||
// 验证时间
|
||||
if (startTime == null || endTime == null) {
|
||||
return Result.failed("时间格式错误");
|
||||
log.error("时间格式错误 - validStartTime: {}, validEndTime: {}", validStartTime, validEndTime);
|
||||
return buildErrorResponse(request, "0004", "时间格式错误");
|
||||
}
|
||||
|
||||
if (endTime.before(startTime)) {
|
||||
return Result.failed("结束时间不能早于开始时间");
|
||||
log.error("结束时间不能早于开始时间 - startTime: {}, endTime: {}", startTime, endTime);
|
||||
return buildErrorResponse(request, "0005", "结束时间不能早于开始时间");
|
||||
}
|
||||
|
||||
// 创建优惠券
|
||||
@@ -199,18 +304,178 @@ public class CouponController {
|
||||
|
||||
if (result) {
|
||||
log.info("携程优惠券创建成功,userPhone: {}, ctripCouponId: {}, amount: {}", userPhone, ctripCouponId, amount);
|
||||
return Result.succeed(true);
|
||||
return buildSuccessResponse(request, ctripCouponId, "优惠券创建成功");
|
||||
} else {
|
||||
log.error("携程优惠券创建失败,userPhone: {}, ctripCouponId: {}", userPhone, ctripCouponId);
|
||||
return Result.failed("优惠券创建失败");
|
||||
return buildErrorResponse(request, "0006", "优惠券创建失败");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("处理携程创建券请求失败", e);
|
||||
log.error("处理携程创建优惠券请求失败", e);
|
||||
return buildErrorResponse(request, "9999", "系统异常:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建成功响应
|
||||
*/
|
||||
private CtripCreateOrderResponse buildSuccessResponse(CtripCreateOrderRequest request, String otaOrderId, String message) {
|
||||
CtripCreateOrderResponse response = new CtripCreateOrderResponse();
|
||||
|
||||
// 设置返回头
|
||||
CtripCreateOrderResponse.CtripResponseHeader responseHeader = new CtripCreateOrderResponse.CtripResponseHeader();
|
||||
responseHeader.setRequestTime(request.getHeader().getRequestTime());
|
||||
responseHeader.setAccountId(request.getHeader().getAccountId());
|
||||
responseHeader.setSign(request.getHeader().getSign());
|
||||
responseHeader.setServiceName(request.getHeader().getServiceName());
|
||||
responseHeader.setVersion(request.getHeader().getVersion());
|
||||
response.setHeader(responseHeader);
|
||||
|
||||
// 设置返回码
|
||||
response.setResultCode("0000");
|
||||
response.setResultMessage("操作成功");
|
||||
|
||||
// 设置返回体
|
||||
CtripCreateOrderResponse.CtripResponseBody responseBody = new CtripCreateOrderResponse.CtripResponseBody();
|
||||
responseBody.setOtaOrderId(otaOrderId);
|
||||
responseBody.setSupplierOrderId("COUPON_" + System.currentTimeMillis()); // 优惠券ID
|
||||
responseBody.setSupplierConfirmType(1); // 已确认
|
||||
responseBody.setVoucherSender(1); // 携程对客发送凭证
|
||||
|
||||
// 设置订单项
|
||||
List<CtripCreateOrderResponse.CtripResponseOrderItem> responseItems = new ArrayList<>();
|
||||
CtripCreateOrderResponse.CtripResponseOrderItem responseItem = new CtripCreateOrderResponse.CtripResponseOrderItem();
|
||||
responseItem.setItemId("1");
|
||||
responseItem.setSupplierItemId("COUPON_ITEM_" + System.currentTimeMillis());
|
||||
responseItem.setStatus(1); // 成功
|
||||
responseItem.setMessage(message);
|
||||
responseItems.add(responseItem);
|
||||
responseBody.setItems(responseItems);
|
||||
|
||||
response.setBody(responseBody);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建错误响应
|
||||
*/
|
||||
private CtripCreateOrderResponse buildErrorResponse(CtripCreateOrderRequest request, String resultCode, String resultMessage) {
|
||||
CtripCreateOrderResponse response = new CtripCreateOrderResponse();
|
||||
|
||||
// 设置返回头
|
||||
CtripCreateOrderResponse.CtripResponseHeader responseHeader = new CtripCreateOrderResponse.CtripResponseHeader();
|
||||
responseHeader.setRequestTime(request.getHeader().getRequestTime());
|
||||
responseHeader.setAccountId(request.getHeader().getAccountId());
|
||||
responseHeader.setSign(request.getHeader().getSign());
|
||||
responseHeader.setServiceName(request.getHeader().getServiceName());
|
||||
responseHeader.setVersion(request.getHeader().getVersion());
|
||||
response.setHeader(responseHeader);
|
||||
|
||||
// 设置返回码
|
||||
response.setResultCode(resultCode);
|
||||
response.setResultMessage(resultMessage);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程创建优惠券接口 - 备用方法
|
||||
*/
|
||||
@Operation(summary = "携程创建优惠券接口 - 备用方法")
|
||||
@PostMapping("/ctrip/create/raw")
|
||||
public Result<Boolean> createCouponFromCtripRaw(@RequestBody String rawJson) {
|
||||
log.info("携程创建券原始请求:{}", rawJson);
|
||||
|
||||
try {
|
||||
// 使用ObjectMapper手动解析
|
||||
com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper();
|
||||
objectMapper.configure(com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
|
||||
CtripCreateOrderRequest request = objectMapper.readValue(rawJson, CtripCreateOrderRequest.class);
|
||||
// 这里应该调用优惠券创建逻辑,而不是订单创建
|
||||
return Result.succeed(true);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("处理携程创建券原始请求失败", e);
|
||||
return Result.failed("处理请求失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程创建优惠券接口 - 处理加密数据
|
||||
*/
|
||||
@Operation(summary = "携程创建优惠券接口 - 处理加密数据")
|
||||
@PostMapping("/ctrip/create/encrypted")
|
||||
public Result<Boolean> createCouponFromCtripEncrypted(@RequestBody String encryptedData) {
|
||||
log.info("携程创建券加密请求,数据长度:{}", encryptedData.length());
|
||||
|
||||
try {
|
||||
// 检查数据是否是有效的JSON
|
||||
if (encryptedData.startsWith("{") && encryptedData.endsWith("}")) {
|
||||
// 尝试直接解析为JSON
|
||||
return createCouponFromCtripRaw(encryptedData);
|
||||
} else {
|
||||
log.warn("收到非JSON格式的加密数据,长度:{}", encryptedData.length());
|
||||
// 这里可以添加解密逻辑
|
||||
return Result.failed("暂不支持加密数据格式");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("处理携程创建券加密请求失败", e);
|
||||
return Result.failed("处理请求失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程创建优惠券接口 - 处理非JSON格式数据
|
||||
*/
|
||||
@Operation(summary = "携程创建优惠券接口 - 处理非JSON格式数据")
|
||||
@PostMapping("/ctrip/create/non-json")
|
||||
public Result<Boolean> createCouponFromCtripNonJson(@RequestBody String nonJsonData) {
|
||||
log.info("携程创建券非JSON请求,数据长度:{}", nonJsonData.length());
|
||||
log.debug("携程创建券非JSON请求原始数据:{}", nonJsonData);
|
||||
|
||||
try {
|
||||
// 检查数据格式
|
||||
if (nonJsonData == null || nonJsonData.trim().isEmpty()) {
|
||||
log.error("请求数据为空");
|
||||
return Result.failed("请求数据为空");
|
||||
}
|
||||
|
||||
// 分析数据格式
|
||||
String dataFormat = analyzeDataFormat(nonJsonData);
|
||||
log.info("数据格式分析结果:{}", dataFormat);
|
||||
|
||||
// 检查是否是JSON格式
|
||||
if (isValidJson(nonJsonData)) {
|
||||
log.info("数据是JSON格式,转发到标准接口");
|
||||
return createCouponFromCtripRaw(nonJsonData);
|
||||
}
|
||||
|
||||
// 尝试解码
|
||||
String decodedData = tryDecode(nonJsonData);
|
||||
if (!decodedData.equals(nonJsonData)) {
|
||||
log.info("数据解码成功,尝试解析解码后的数据");
|
||||
if (isValidJson(decodedData)) {
|
||||
return createCouponFromCtripRaw(decodedData);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理非JSON格式数据
|
||||
log.warn("收到非JSON格式数据,格式:{},长度:{},前100个字符:{}",
|
||||
dataFormat,
|
||||
nonJsonData.length(),
|
||||
nonJsonData.length() > 100 ? nonJsonData.substring(0, 100) + "..." : nonJsonData);
|
||||
|
||||
// 暂时返回错误,因为不知道如何处理这种格式
|
||||
return Result.failed("暂不支持数据格式:" + dataFormat + ",请联系技术支持");
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("处理携程创建券非JSON请求失败", e);
|
||||
return Result.failed("处理请求失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -274,4 +539,553 @@ public class CouponController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理解码后的数据,尝试进一步解析
|
||||
private String processDecodedData(String decodedData) {
|
||||
log.debug("尝试进一步处理解码后的数据,长度:{}", decodedData.length());
|
||||
|
||||
// 检查是否是JSON格式
|
||||
if (isValidJson(decodedData)) {
|
||||
log.info("解码后的数据是有效的JSON格式");
|
||||
return decodedData;
|
||||
}
|
||||
|
||||
// 尝试移除可能的BOM或其他前缀
|
||||
String cleanedData = decodedData.trim();
|
||||
if (cleanedData.startsWith("\uFEFF")) {
|
||||
cleanedData = cleanedData.substring(1);
|
||||
log.info("移除了BOM前缀");
|
||||
}
|
||||
|
||||
// 尝试查找JSON开始位置
|
||||
int jsonStart = cleanedData.indexOf("{");
|
||||
if (jsonStart >= 0) {
|
||||
String jsonPart = cleanedData.substring(jsonStart);
|
||||
if (isValidJson(jsonPart)) {
|
||||
log.info("找到有效的JSON部分");
|
||||
return jsonPart;
|
||||
}
|
||||
}
|
||||
|
||||
// 尝试查找JSON结束位置
|
||||
int jsonEnd = cleanedData.lastIndexOf("}");
|
||||
if (jsonEnd >= 0) {
|
||||
String jsonPart = cleanedData.substring(0, jsonEnd + 1);
|
||||
if (isValidJson(jsonPart)) {
|
||||
log.info("找到有效的JSON部分(从开始到结束)");
|
||||
return jsonPart;
|
||||
}
|
||||
}
|
||||
|
||||
// 尝试AES解密
|
||||
log.info("尝试对解码后的数据进行AES解密");
|
||||
try {
|
||||
String decryptedData = tryAesDecrypt(decodedData);
|
||||
if (decryptedData != null && isValidJson(decryptedData)) {
|
||||
log.info("AES解密成功,得到有效的JSON数据");
|
||||
return decryptedData;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.debug("AES解密失败:{}", e.getMessage());
|
||||
}
|
||||
|
||||
// 尝试将数据转换为十六进制字符串,然后查找JSON
|
||||
try {
|
||||
StringBuilder hexString = new StringBuilder();
|
||||
for (byte b : decodedData.getBytes()) {
|
||||
hexString.append(String.format("%02x", b));
|
||||
}
|
||||
String hexData = hexString.toString();
|
||||
log.debug("数据转换为十六进制,长度:{}", hexData.length());
|
||||
|
||||
// 在十六进制数据中查找可能的JSON字符串
|
||||
if (hexData.contains("7b") && hexData.contains("7d")) { // { 和 } 的十六进制
|
||||
log.info("在十六进制数据中发现了JSON字符");
|
||||
// 这里可以添加更复杂的十六进制解析逻辑
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.debug("十六进制转换失败:{}", e.getMessage());
|
||||
}
|
||||
|
||||
log.warn("无法从解码后的数据中提取有效的JSON,数据前100个字符:{}",
|
||||
cleanedData.length() > 100 ? cleanedData.substring(0, 100) + "..." : cleanedData);
|
||||
return null;
|
||||
}
|
||||
|
||||
// 工具方法
|
||||
private String tryDecode(String encodedData) {
|
||||
if (encodedData == null || encodedData.trim().isEmpty()) {
|
||||
return encodedData;
|
||||
}
|
||||
try {
|
||||
byte[] decodedBytes = java.util.Base64.getDecoder().decode(encodedData);
|
||||
String decodedString = new String(decodedBytes, "UTF-8");
|
||||
log.debug("Base64解码成功,原长度:{},解码后长度:{}",
|
||||
encodedData.length(), decodedString.length());
|
||||
return decodedString;
|
||||
} catch (Exception e) {
|
||||
log.debug("Base64解码失败,数据可能不是Base64编码:{}", e.getMessage());
|
||||
return encodedData;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isValidJson(String data) {
|
||||
if (data == null || data.trim().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
String trimmed = data.trim();
|
||||
return trimmed.startsWith("{") && trimmed.endsWith("}");
|
||||
}
|
||||
|
||||
private String analyzeDataFormat(String data) {
|
||||
if (data == null) return "null";
|
||||
if (data.trim().isEmpty()) return "empty";
|
||||
if (isValidJson(data)) return "valid_json";
|
||||
|
||||
try {
|
||||
java.util.Base64.getDecoder().decode(data);
|
||||
return "base64_encoded";
|
||||
} catch (Exception e) {
|
||||
// 不是Base64编码
|
||||
}
|
||||
|
||||
if (data.matches("^[a-zA-Z0-9]+$")) return "alphanumeric_string";
|
||||
if (data.contains("{") || data.contains("}")) return "contains_json_chars";
|
||||
if (data.contains("<") || data.contains(">")) return "contains_xml_chars";
|
||||
if (data.length() > 100 && data.matches(".*[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F\\x7F].*")) {
|
||||
return "binary_data";
|
||||
}
|
||||
|
||||
return "unknown_format";
|
||||
}
|
||||
|
||||
private String getDataDetails(String data) {
|
||||
if (data == null) return "null";
|
||||
|
||||
StringBuilder details = new StringBuilder();
|
||||
details.append("长度: ").append(data.length());
|
||||
details.append(", 格式: ").append(analyzeDataFormat(data));
|
||||
|
||||
if (data.length() > 0) {
|
||||
details.append(", 前10个字符: ").append(data.substring(0, Math.min(10, data.length())));
|
||||
if (data.length() > 20) {
|
||||
details.append(", 后10个字符: ").append(data.substring(data.length() - 10));
|
||||
}
|
||||
}
|
||||
|
||||
return details.toString();
|
||||
}
|
||||
|
||||
private String tryCtripDecrypt(String encryptedData, String accountId) {
|
||||
if (encryptedData == null || encryptedData.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
String[] possibleKeys = {
|
||||
accountId,
|
||||
accountId + "1234567890123456",
|
||||
"ctrip" + accountId,
|
||||
accountId.substring(0, Math.min(16, accountId.length())),
|
||||
"ctrip123456789012",
|
||||
"c50a8f2a4a59c9e7"
|
||||
};
|
||||
|
||||
for (String key : possibleKeys) {
|
||||
try {
|
||||
String decrypted = decryptAES(encryptedData, key, "0000000000000000");
|
||||
if (decrypted != null && isValidJson(decrypted)) {
|
||||
log.info("携程数据解密成功,使用密钥:{}", key);
|
||||
return decrypted;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.debug("携程AES解密失败,密钥:{},错误:{}", key, e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
String decrypted = decryptAESWithMode(encryptedData, key, "AES/ECB/PKCS5Padding");
|
||||
if (decrypted != null && isValidJson(decrypted)) {
|
||||
log.info("携程数据ECB解密成功,使用密钥:{}", key);
|
||||
return decrypted;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.debug("携程ECB解密失败,密钥:{},错误:{}", key, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
log.warn("所有携程解密尝试都失败了");
|
||||
return null;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("携程解密过程中发生异常:{}", e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String tryAesDecrypt(String encryptedData) {
|
||||
if (encryptedData == null || encryptedData.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
String[] possibleKeys = {
|
||||
"1234567890123456", "12345678901234567890123456789012",
|
||||
"c50a8f2a4a59c9e7", "ctrip123456789012", "gofly123456789012",
|
||||
"ctriptest1234567", "ctrip12345678901234567890123456789012"
|
||||
};
|
||||
|
||||
String[] possibleIVs = {
|
||||
"1234567890123456", "0000000000000000", "c50a8f2a4a59c9e7",
|
||||
"ctrip123456789012", "00000000000000000000000000000000"
|
||||
};
|
||||
|
||||
// 尝试不同的密钥和IV组合
|
||||
for (String key : possibleKeys) {
|
||||
for (String iv : possibleIVs) {
|
||||
try {
|
||||
String decrypted = decryptAES(encryptedData, key, iv);
|
||||
if (decrypted != null && isValidJson(decrypted)) {
|
||||
log.info("AES解密成功,使用密钥:{},IV:{}", key, iv);
|
||||
return decrypted;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.debug("AES解密失败,密钥:{},IV:{},错误:{}", key, iv, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 尝试不同的加密模式
|
||||
String[] modes = {"AES/CBC/PKCS5Padding", "AES/ECB/PKCS5Padding", "AES/CBC/NoPadding"};
|
||||
for (String mode : modes) {
|
||||
for (String key : possibleKeys) {
|
||||
try {
|
||||
String decrypted = decryptAESWithMode(encryptedData, key, mode);
|
||||
if (decrypted != null && isValidJson(decrypted)) {
|
||||
log.info("AES解密成功,使用模式:{},密钥:{}", mode, key);
|
||||
return decrypted;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.debug("AES解密失败,模式:{},密钥:{},错误:{}", mode, key, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.warn("所有AES解密尝试都失败了");
|
||||
return null;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("AES解密过程中发生异常:{}", e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String decryptAES(String encryptedData, String key, String iv) throws Exception {
|
||||
byte[] encryptedBytes;
|
||||
try {
|
||||
encryptedBytes = java.util.Base64.getDecoder().decode(encryptedData);
|
||||
} catch (Exception e) {
|
||||
encryptedBytes = encryptedData.getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
byte[] keyBytes = adjustKeyLength(key.getBytes(java.nio.charset.StandardCharsets.UTF_8));
|
||||
byte[] ivBytes = adjustIVLength(iv.getBytes(java.nio.charset.StandardCharsets.UTF_8));
|
||||
|
||||
javax.crypto.spec.SecretKeySpec secretKeySpec = new javax.crypto.spec.SecretKeySpec(keyBytes, "AES");
|
||||
javax.crypto.spec.IvParameterSpec ivParameterSpec = new javax.crypto.spec.IvParameterSpec(ivBytes);
|
||||
|
||||
javax.crypto.Cipher cipher = javax.crypto.Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
cipher.init(javax.crypto.Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec);
|
||||
|
||||
byte[] decryptedBytes = cipher.doFinal(encryptedBytes);
|
||||
return new String(decryptedBytes, java.nio.charset.StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
private String decryptAESWithMode(String encryptedData, String key, String mode) throws Exception {
|
||||
byte[] encryptedBytes;
|
||||
try {
|
||||
encryptedBytes = java.util.Base64.getDecoder().decode(encryptedData);
|
||||
} catch (Exception e) {
|
||||
encryptedBytes = encryptedData.getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
byte[] keyBytes = adjustKeyLength(key.getBytes(java.nio.charset.StandardCharsets.UTF_8));
|
||||
javax.crypto.spec.SecretKeySpec secretKeySpec = new javax.crypto.spec.SecretKeySpec(keyBytes, "AES");
|
||||
|
||||
javax.crypto.Cipher cipher = javax.crypto.Cipher.getInstance(mode);
|
||||
|
||||
if (mode.contains("CBC")) {
|
||||
byte[] ivBytes = new byte[16];
|
||||
javax.crypto.spec.IvParameterSpec ivParameterSpec = new javax.crypto.spec.IvParameterSpec(ivBytes);
|
||||
cipher.init(javax.crypto.Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec);
|
||||
} else {
|
||||
cipher.init(javax.crypto.Cipher.DECRYPT_MODE, secretKeySpec);
|
||||
}
|
||||
|
||||
byte[] decryptedBytes = cipher.doFinal(encryptedBytes);
|
||||
return new String(decryptedBytes, java.nio.charset.StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
private byte[] adjustKeyLength(byte[] keyBytes) {
|
||||
if (keyBytes.length == 16 || keyBytes.length == 24 || keyBytes.length == 32) {
|
||||
return keyBytes;
|
||||
}
|
||||
|
||||
int targetLength = keyBytes.length < 16 ? 16 : (keyBytes.length < 24 ? 24 : 32);
|
||||
byte[] newKeyBytes = new byte[targetLength];
|
||||
System.arraycopy(keyBytes, 0, newKeyBytes, 0, Math.min(keyBytes.length, targetLength));
|
||||
return newKeyBytes;
|
||||
}
|
||||
|
||||
private byte[] adjustIVLength(byte[] ivBytes) {
|
||||
if (ivBytes.length == 16) {
|
||||
return ivBytes;
|
||||
}
|
||||
|
||||
byte[] newIvBytes = new byte[16];
|
||||
System.arraycopy(ivBytes, 0, newIvBytes, 0, Math.min(ivBytes.length, 16));
|
||||
return newIvBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试携程解密功能
|
||||
*/
|
||||
@Operation(summary = "测试携程解密功能")
|
||||
@PostMapping("/ctrip/test-decrypt")
|
||||
public Result<String> testCtripDecrypt(@RequestBody String encryptedData) {
|
||||
log.info("测试携程解密功能,加密数据长度: {}", encryptedData.length());
|
||||
|
||||
try {
|
||||
// 检查配置
|
||||
if (!ctripDecryptUtil.isConfigValid()) {
|
||||
log.error("携程解密配置不完整: {}", ctripDecryptUtil.getConfigInfo());
|
||||
return Result.failed("携程解密配置不完整");
|
||||
}
|
||||
|
||||
// 使用携程标准解密
|
||||
String decryptedData = ctripDecryptUtil.decryptCtripBody(encryptedData);
|
||||
|
||||
if (decryptedData != null) {
|
||||
log.info("解密成功,解密后数据长度: {}", decryptedData.length());
|
||||
log.info("解密后数据前200个字符: {}",
|
||||
decryptedData.length() > 200 ? decryptedData.substring(0, 200) + "..." : decryptedData);
|
||||
return Result.succeed(decryptedData);
|
||||
} else {
|
||||
log.error("解密失败");
|
||||
return Result.failed("解密失败");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("测试解密功能异常: {}", e.getMessage(), e);
|
||||
return Result.failed("测试解密功能异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程创建优惠券接口(新版本,使用正确的解密逻辑)
|
||||
*/
|
||||
@Operation(summary = "携程创建优惠券接口(新版本)")
|
||||
@PostMapping("/ctrip/create/v2")
|
||||
public CtripCreateOrderResponse createCouponFromCtripV2(@RequestBody CtripCreateOrderRequest request) {
|
||||
log.info("携程创建优惠券请求(新版本):{}", request);
|
||||
|
||||
try {
|
||||
// 检查配置
|
||||
if (!ctripDecryptUtil.isConfigValid()) {
|
||||
log.error("携程解密配置不完整: {}", ctripDecryptUtil.getConfigInfo());
|
||||
return buildErrorResponse(request, "CONFIG_ERROR", "携程解密配置不完整");
|
||||
}
|
||||
|
||||
// 验证请求头
|
||||
if (request.getHeader() == null || request.getBody() == null) {
|
||||
log.error("请求格式错误:header或body为空");
|
||||
return buildErrorResponse(request, "0001", "请求格式错误");
|
||||
}
|
||||
|
||||
// 处理body字段
|
||||
CtripOrderBody body = null;
|
||||
if (request.getBody() instanceof String) {
|
||||
// body是加密字符串,需要解密
|
||||
String encryptedBody = (String) request.getBody();
|
||||
log.info("收到加密的body数据,长度:{}", encryptedBody.length());
|
||||
|
||||
// 使用携程标准解密
|
||||
String decryptedBody = ctripDecryptUtil.decryptCtripBody(encryptedBody);
|
||||
|
||||
if (decryptedBody == null) {
|
||||
log.error("携程标准解密失败");
|
||||
return buildErrorResponse(request, "DECRYPT_ERROR", "请求体解密失败");
|
||||
}
|
||||
|
||||
log.info("body数据解密成功,解密后数据长度: {}", decryptedBody.length());
|
||||
log.debug("解密后数据前200个字符: {}",
|
||||
decryptedBody.length() > 200 ? decryptedBody.substring(0, 200) + "..." : decryptedBody);
|
||||
|
||||
// 解析解密后的JSON
|
||||
try {
|
||||
// 先验证JSON格式
|
||||
if (!isValidJson(decryptedBody)) {
|
||||
log.error("解密后的数据不是有效的JSON格式");
|
||||
log.error("解密后数据前200个字符: {}",
|
||||
decryptedBody.length() > 200 ? decryptedBody.substring(0, 200) + "..." : decryptedBody);
|
||||
return buildErrorResponse(request, "INVALID_JSON", "解密后的数据不是有效的JSON格式");
|
||||
}
|
||||
|
||||
com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper();
|
||||
objectMapper.configure(com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
body = objectMapper.readValue(decryptedBody, CtripOrderBody.class);
|
||||
log.info("成功解析解密后的JSON数据");
|
||||
} catch (Exception e) {
|
||||
log.error("解析解密后的JSON数据失败:{}", e.getMessage());
|
||||
log.error("解密后数据前200个字符: {}",
|
||||
decryptedBody.length() > 200 ? decryptedBody.substring(0, 200) + "..." : decryptedBody);
|
||||
return buildErrorResponse(request, "JSON_PARSE_ERROR", "JSON解析失败");
|
||||
}
|
||||
|
||||
} else if (request.getBody() instanceof CtripOrderBody) {
|
||||
// body已经是对象
|
||||
body = (CtripOrderBody) request.getBody();
|
||||
log.info("body已经是对象格式");
|
||||
} else {
|
||||
log.error("未知的body数据类型:{}", request.getBody().getClass().getSimpleName());
|
||||
return buildErrorResponse(request, "0002", "未知的body数据类型");
|
||||
}
|
||||
|
||||
// 验证签名
|
||||
if (request.getHeader().getSign() != null) {
|
||||
// 使用携程标准签名验证
|
||||
boolean signValid = ctripDecryptUtil.verifySign(
|
||||
request.getHeader().getAccountId(),
|
||||
request.getHeader().getServiceName(),
|
||||
request.getHeader().getRequestTime(),
|
||||
(String) request.getBody(), // 使用加密的body
|
||||
request.getHeader().getVersion(),
|
||||
request.getHeader().getSign()
|
||||
);
|
||||
|
||||
if (!signValid) {
|
||||
log.error("签名验证失败");
|
||||
return buildErrorResponse(request, "SIGN_ERROR", "签名验证失败");
|
||||
}
|
||||
|
||||
log.info("签名验证成功");
|
||||
}
|
||||
|
||||
// 验证必要字段
|
||||
if (body == null) {
|
||||
log.error("订单信息为空");
|
||||
return buildErrorResponse(request, "0003", "订单信息为空");
|
||||
}
|
||||
|
||||
// 打印解析后的订单信息用于调试
|
||||
log.info("解析后的订单信息: otaOrderId={}, sequenceId={}, items数量={}",
|
||||
body.getOtaOrderId(), body.getSequenceId(),
|
||||
body.getItems() != null ? body.getItems().size() : 0);
|
||||
|
||||
if (body.getItems() == null || body.getItems().isEmpty()) {
|
||||
log.error("订单项为空,完整订单信息: {}", body);
|
||||
return buildErrorResponse(request, "0003", "订单项为空");
|
||||
}
|
||||
|
||||
// 创建优惠券(这里需要根据实际的优惠券创建逻辑来调整)
|
||||
String otaOrderId = "CTRIP_" + System.currentTimeMillis();
|
||||
// TODO: 实现具体的优惠券创建逻辑
|
||||
boolean success = true; // 临时设置为true,实际需要实现具体的创建逻辑
|
||||
|
||||
if (success) {
|
||||
log.info("携程优惠券创建成功,OTA订单ID: {}", otaOrderId);
|
||||
return buildSuccessResponse(request, otaOrderId, "优惠券创建成功");
|
||||
} else {
|
||||
log.error("携程优惠券创建失败");
|
||||
return buildErrorResponse(request, "0004", "优惠券创建失败");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("处理携程请求异常:{}", e.getMessage(), e);
|
||||
return buildErrorResponse(request, "0005", "系统处理异常");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 调试携程解密数据
|
||||
*/
|
||||
@Operation(summary = "调试携程解密数据")
|
||||
@PostMapping("/ctrip/debug-decrypt")
|
||||
public Result<Map<String, Object>> debugCtripDecrypt(@RequestBody String encryptedData) {
|
||||
log.info("调试携程解密数据,加密数据长度: {}", encryptedData.length());
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
try {
|
||||
// 检查配置
|
||||
if (!ctripDecryptUtil.isConfigValid()) {
|
||||
result.put("error", "携程解密配置不完整");
|
||||
result.put("configInfo", ctripDecryptUtil.getConfigInfo());
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
// 使用携程标准解密
|
||||
String decryptedData = ctripDecryptUtil.decryptCtripBody(encryptedData);
|
||||
|
||||
if (decryptedData != null) {
|
||||
result.put("success", true);
|
||||
result.put("decryptedLength", decryptedData.length());
|
||||
result.put("decryptedData", decryptedData);
|
||||
result.put("decryptedDataFirst200",
|
||||
decryptedData.length() > 200 ? decryptedData.substring(0, 200) + "..." : decryptedData);
|
||||
|
||||
// 尝试解析JSON
|
||||
try {
|
||||
com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper();
|
||||
objectMapper.configure(com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
CtripOrderBody body = objectMapper.readValue(decryptedData, CtripOrderBody.class);
|
||||
|
||||
result.put("jsonParseSuccess", true);
|
||||
result.put("otaOrderId", body.getOtaOrderId());
|
||||
result.put("sequenceId", body.getSequenceId());
|
||||
result.put("itemsCount", body.getItems() != null ? body.getItems().size() : 0);
|
||||
result.put("contactsCount", body.getContacts() != null ? body.getContacts().size() : 0);
|
||||
|
||||
// 如果有订单项,显示第一个订单项的详细信息
|
||||
if (body.getItems() != null && !body.getItems().isEmpty()) {
|
||||
CtripOrderItem firstItem = body.getItems().get(0);
|
||||
Map<String, Object> itemInfo = new HashMap<>();
|
||||
itemInfo.put("passengersCount", firstItem.getPassengers() != null ? firstItem.getPassengers().size() : 0);
|
||||
itemInfo.put("cost", firstItem.getCost());
|
||||
itemInfo.put("salePrice", firstItem.getSalePrice());
|
||||
itemInfo.put("price", firstItem.getPrice());
|
||||
itemInfo.put("quantity", firstItem.getQuantity());
|
||||
itemInfo.put("useStartDate", firstItem.getUseStartDate());
|
||||
itemInfo.put("useEndDate", firstItem.getUseEndDate());
|
||||
|
||||
// 如果有乘客信息,显示第一个乘客的信息
|
||||
if (firstItem.getPassengers() != null && !firstItem.getPassengers().isEmpty()) {
|
||||
CtripPassenger firstPassenger = firstItem.getPassengers().get(0);
|
||||
Map<String, Object> passengerInfo = new HashMap<>();
|
||||
passengerInfo.put("name", firstPassenger.getName());
|
||||
passengerInfo.put("mobile", firstPassenger.getMobile());
|
||||
passengerInfo.put("gender", firstPassenger.getGender());
|
||||
passengerInfo.put("cardNo", firstPassenger.getCardNo());
|
||||
itemInfo.put("firstPassenger", passengerInfo);
|
||||
}
|
||||
|
||||
result.put("firstItem", itemInfo);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
result.put("jsonParseSuccess", false);
|
||||
result.put("jsonParseError", e.getMessage());
|
||||
}
|
||||
|
||||
} else {
|
||||
result.put("success", false);
|
||||
result.put("error", "解密失败");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
result.put("success", false);
|
||||
result.put("error", "调试解密功能异常: " + e.getMessage());
|
||||
}
|
||||
|
||||
return Result.succeed(result);
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.central.order.controller;
|
||||
|
||||
import com.central.common.model.Result;
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
/**
|
||||
* 全局异常处理器
|
||||
*/
|
||||
@Slf4j
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
/**
|
||||
* 处理JSON反序列化错误
|
||||
*/
|
||||
@ExceptionHandler(HttpMessageNotReadableException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public Result<String> handleHttpMessageNotReadableException(HttpMessageNotReadableException e) {
|
||||
log.error("JSON反序列化错误", e);
|
||||
|
||||
String errorMessage = "请求格式错误";
|
||||
Throwable cause = e.getCause();
|
||||
|
||||
if (cause instanceof JsonParseException) {
|
||||
errorMessage = "JSON格式错误:" + cause.getMessage();
|
||||
} else if (cause instanceof JsonMappingException) {
|
||||
JsonMappingException mappingException = (JsonMappingException) cause;
|
||||
String path = mappingException.getPathReference();
|
||||
String message = mappingException.getMessage();
|
||||
|
||||
// 检查是否是字符串反序列化问题
|
||||
if (message.contains("no String-argument constructor") && message.contains("deserialize from String value")) {
|
||||
errorMessage = "数据格式错误:期望JSON对象,但收到字符串数据。请检查请求格式或联系技术支持。";
|
||||
log.error("检测到字符串反序列化问题,可能需要使用 /ctrip/create/non-json 接口");
|
||||
} else {
|
||||
errorMessage = "JSON映射错误:" + message + " (路径: " + path + ")";
|
||||
}
|
||||
}
|
||||
|
||||
return Result.failed(errorMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理通用异常
|
||||
*/
|
||||
@ExceptionHandler(Exception.class)
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
public Result<String> handleException(Exception e) {
|
||||
log.error("系统异常", e);
|
||||
return Result.failed("系统异常:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
+2
@@ -100,6 +100,7 @@ public class RefundController {
|
||||
refund.setState(RefundState.APPROVING.getId());
|
||||
refund.setRefundReason(refundBody.getRefundReason());
|
||||
refund.setRefundImgs(refundBody.getRefundImgs());
|
||||
refund.setTenantId(order.getTenantId());
|
||||
boolean res = refundService.createRefund(refund);
|
||||
if (res) {
|
||||
order.setOrderStatus(OrderStatus.REFUNDING.getId());
|
||||
@@ -189,6 +190,7 @@ public class RefundController {
|
||||
refund.setRefundAmount(order.getOrderAmount());
|
||||
refund.setStatus(OrderStatus.REFUNDING.getId());
|
||||
refund.setState(RefundState.APPROVING.getId());
|
||||
refund.setTenantId(order.getTenantId());
|
||||
refund.setRefundReason("机库执行任务异常自动退款,该退款单由系统自动创建,请高传旭先生仔细核实!");
|
||||
|
||||
boolean refundCreated = refundService.createRefund(refund);
|
||||
|
||||
+3
@@ -200,6 +200,7 @@ public class WxPayController {
|
||||
@RequestBody String body) {
|
||||
log.info("------收到微信退款回调通知------");
|
||||
try {
|
||||
TenantContextHolder.setTenant(defaultTenantId);
|
||||
// 构建请求参数
|
||||
RequestParam requestParam = new RequestParam
|
||||
.Builder()
|
||||
@@ -239,6 +240,8 @@ public class WxPayController {
|
||||
// 处理异常,记录日志等
|
||||
log.error("处理退款回调失败", e);
|
||||
return buildErrorResponse();
|
||||
}finally {
|
||||
TenantContextHolder.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-10
@@ -37,18 +37,8 @@ public class OrderStatusChangeListener {
|
||||
@Autowired
|
||||
private IOrderService orderService;
|
||||
@Autowired
|
||||
private IQrCodeService qrCodeService;
|
||||
@Autowired
|
||||
private IVideoEditService videoEditService;
|
||||
@Autowired
|
||||
private IOrderFileService orderFileService;
|
||||
@Autowired
|
||||
private IWxTemplateMessageService wxTemplateMessageService;
|
||||
@Autowired
|
||||
private UserCenterService userCenterService;
|
||||
@Autowired
|
||||
private IEditTaskService editTaskService;
|
||||
@Autowired
|
||||
private WxMiniSubscribeService wxMiniSubscribeService;
|
||||
|
||||
@EventListener
|
||||
|
||||
+27
-21
@@ -14,7 +14,8 @@ public interface DashboardMapper {
|
||||
// 基础订单统计(支持筛选)
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COUNT(*) FROM orders o",
|
||||
"SELECT COUNT(*) as count",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
@@ -41,7 +42,8 @@ public interface DashboardMapper {
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COUNT(*) FROM orders o",
|
||||
"SELECT COUNT(*) as count",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
@@ -63,7 +65,8 @@ public interface DashboardMapper {
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COUNT(*) FROM orders o",
|
||||
"SELECT COUNT(*) as count",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
@@ -85,7 +88,8 @@ public interface DashboardMapper {
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COUNT(*) FROM orders o",
|
||||
"SELECT COUNT(*) as count",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
@@ -114,7 +118,7 @@ public interface DashboardMapper {
|
||||
// 对账相关统计
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COALESCE(SUM(o.order_amount), 0)",
|
||||
"SELECT COALESCE(SUM(o.order_amount), 0) as amount",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
@@ -125,6 +129,12 @@ public interface DashboardMapper {
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND o.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
@@ -139,11 +149,9 @@ public interface DashboardMapper {
|
||||
"<script>",
|
||||
"SELECT COALESCE(SUM(os.platform_amount), 0)",
|
||||
"FROM order_statistics os",
|
||||
"JOIN orders o ON os.order_id = o.id",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
" AND os.qrcode_id IN (SELECT code_id FROM qrcodes WHERE is_test = 0)",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
@@ -168,11 +176,9 @@ public interface DashboardMapper {
|
||||
"<script>",
|
||||
"SELECT COALESCE(SUM(os.tourism_amount), 0)",
|
||||
"FROM order_statistics os",
|
||||
"JOIN orders o ON os.order_id = o.id",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
" AND os.qrcode_id IN (SELECT code_id FROM qrcodes WHERE is_test = 0)",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
@@ -195,7 +201,7 @@ public interface DashboardMapper {
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COALESCE(SUM(CAST(r.refund_amount AS SIGNED)), 0)",
|
||||
"SELECT COALESCE(SUM(CAST(r.refund_amount AS SIGNED)), 0) as amount",
|
||||
"FROM orders_refund r",
|
||||
"JOIN orders o ON r.order_no = o.order_no",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
@@ -206,6 +212,12 @@ public interface DashboardMapper {
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND o.tourism_id = #{p.tourismId}",
|
||||
"</if>",
|
||||
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
|
||||
" AND o.code_id = #{p.qrcodeId}",
|
||||
"</if>",
|
||||
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
|
||||
" AND o.device_sn = #{p.deviceSn}",
|
||||
"</if>",
|
||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||
" AND r.create_time >= #{p.startTime}",
|
||||
"</if>",
|
||||
@@ -294,11 +306,9 @@ public interface DashboardMapper {
|
||||
" '平台分账' as type,",
|
||||
" COALESCE(SUM(os.platform_amount), 0) as value",
|
||||
"FROM order_statistics os",
|
||||
"JOIN orders o ON os.order_id = o.id",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
" AND os.qrcode_id IN (SELECT code_id FROM qrcodes WHERE is_test = 0)",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
@@ -320,11 +330,9 @@ public interface DashboardMapper {
|
||||
" '景区分账' as type,",
|
||||
" COALESCE(SUM(os.tourism_amount), 0) as value",
|
||||
"FROM order_statistics os",
|
||||
"JOIN orders o ON os.order_id = o.id",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
" AND os.qrcode_id IN (SELECT code_id FROM qrcodes WHERE is_test = 0)",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
@@ -346,11 +354,9 @@ public interface DashboardMapper {
|
||||
" '退款金额' as type,",
|
||||
" COALESCE(SUM(os.refund_amount), 0) as value",
|
||||
"FROM order_statistics os",
|
||||
"JOIN orders o ON os.order_id = o.id",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE 1=1",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND q.is_test = 0",
|
||||
" AND os.qrcode_id IN (SELECT code_id FROM qrcodes WHERE is_test = 0)",
|
||||
"</if>",
|
||||
"<if test='p.tourismId != null'>",
|
||||
" AND os.tourism_id = #{p.tourismId}",
|
||||
|
||||
+76
-5
@@ -1,33 +1,44 @@
|
||||
package com.central.order.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 携程创建订单请求
|
||||
* 携程订单新订请求
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class CtripCreateOrderRequest {
|
||||
|
||||
/**
|
||||
* 请求头
|
||||
*/
|
||||
@JsonProperty("header")
|
||||
private CtripHeader header;
|
||||
|
||||
/**
|
||||
* 请求体
|
||||
* 请求体 - 可能是加密字符串或JSON对象
|
||||
*/
|
||||
private CtripOrderBody body;
|
||||
@JsonProperty("body")
|
||||
private Object body; // 改为Object类型,支持字符串和对象两种格式
|
||||
|
||||
/**
|
||||
* 携程请求头
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripHeader {
|
||||
@JsonProperty("requestTime")
|
||||
private String requestTime;
|
||||
@JsonProperty("accountId")
|
||||
private String accountId;
|
||||
@JsonProperty("sign")
|
||||
private String sign;
|
||||
@JsonProperty("serviceName")
|
||||
private String serviceName;
|
||||
@JsonProperty("version")
|
||||
private String version;
|
||||
}
|
||||
|
||||
@@ -35,34 +46,61 @@ public class CtripCreateOrderRequest {
|
||||
* 携程订单体
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripOrderBody {
|
||||
@JsonProperty("otaOrderId")
|
||||
private String otaOrderId;
|
||||
@JsonProperty("sequenceId")
|
||||
private String sequenceId;
|
||||
@JsonProperty("items")
|
||||
private List<CtripOrderItem> items;
|
||||
@JsonProperty("contacts")
|
||||
private List<CtripContact> contacts;
|
||||
@JsonProperty("confirmType")
|
||||
private Integer confirmType;
|
||||
@JsonProperty("locale")
|
||||
private String locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程订单项
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripOrderItem {
|
||||
@JsonProperty("passengers")
|
||||
private List<CtripPassenger> passengers;
|
||||
@JsonProperty("cost")
|
||||
private java.math.BigDecimal cost;
|
||||
@JsonProperty("quantity")
|
||||
private Integer quantity;
|
||||
@JsonProperty("salePrice")
|
||||
private java.math.BigDecimal salePrice;
|
||||
@JsonProperty("remark")
|
||||
private String remark;
|
||||
@JsonProperty("useEndDate")
|
||||
private String useEndDate;
|
||||
@JsonProperty("locale")
|
||||
private String locale;
|
||||
@JsonProperty("useStartDate")
|
||||
private String useStartDate;
|
||||
@JsonProperty("priceCurrency")
|
||||
private String priceCurrency;
|
||||
private List<Object> adjunctions;
|
||||
@JsonProperty("adjunctions")
|
||||
private List<String> adjunctions;
|
||||
@JsonProperty("price")
|
||||
private java.math.BigDecimal price;
|
||||
@JsonProperty("PLU")
|
||||
private String PLU;
|
||||
private Object deposit;
|
||||
@JsonProperty("deposit")
|
||||
private Object deposit; // 改回Object类型,因为可能是对象
|
||||
@JsonProperty("distributionChannel")
|
||||
private String distributionChannel;
|
||||
@JsonProperty("costCurrency")
|
||||
private String costCurrency;
|
||||
@JsonProperty("salePriceCurrency")
|
||||
private String salePriceCurrency;
|
||||
@JsonProperty("expressDelivery")
|
||||
private CtripExpressDelivery expressDelivery;
|
||||
}
|
||||
|
||||
@@ -70,29 +108,53 @@ public class CtripCreateOrderRequest {
|
||||
* 携程乘客信息
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripPassenger {
|
||||
@JsonProperty("cardIssuePlace")
|
||||
private String cardIssuePlace;
|
||||
@JsonProperty("lastName")
|
||||
private String lastName;
|
||||
@JsonProperty("cardIssueCountry")
|
||||
private String cardIssueCountry;
|
||||
@JsonProperty("shoeSize")
|
||||
private Integer shoeSize;
|
||||
@JsonProperty("gender")
|
||||
private String gender;
|
||||
@JsonProperty("cardIssueDate")
|
||||
private String cardIssueDate;
|
||||
@JsonProperty("intlCode")
|
||||
private String intlCode;
|
||||
@JsonProperty("nationalityName")
|
||||
private String nationalityName;
|
||||
@JsonProperty("mobile")
|
||||
private String mobile;
|
||||
@JsonProperty("cardType")
|
||||
private String cardType;
|
||||
@JsonProperty("weight")
|
||||
private Integer weight;
|
||||
@JsonProperty("myopiaDegreeL")
|
||||
private Integer myopiaDegreeL;
|
||||
@JsonProperty("birthDate")
|
||||
private String birthDate;
|
||||
@JsonProperty("cardNo")
|
||||
private String cardNo;
|
||||
@JsonProperty("ageType")
|
||||
private String ageType;
|
||||
@JsonProperty("myopiaDegreeR")
|
||||
private Integer myopiaDegreeR;
|
||||
@JsonProperty("firstName")
|
||||
private String firstName;
|
||||
@JsonProperty("birthPlace")
|
||||
private String birthPlace;
|
||||
@JsonProperty("nationalityCode")
|
||||
private String nationalityCode;
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
@JsonProperty("passengerId")
|
||||
private String passengerId;
|
||||
@JsonProperty("cardValidDate")
|
||||
private String cardValidDate;
|
||||
@JsonProperty("height")
|
||||
private Integer height;
|
||||
}
|
||||
|
||||
@@ -100,12 +162,19 @@ public class CtripCreateOrderRequest {
|
||||
* 携程联系人信息
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripContact {
|
||||
@JsonProperty("intlCode")
|
||||
private String intlCode;
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
@JsonProperty("mobile")
|
||||
private String mobile;
|
||||
@JsonProperty("optionalMobile")
|
||||
private String optionalMobile;
|
||||
@JsonProperty("optionalIntlCode")
|
||||
private String optionalIntlCode;
|
||||
@JsonProperty("email")
|
||||
private String email;
|
||||
}
|
||||
|
||||
@@ -113,7 +182,9 @@ public class CtripCreateOrderRequest {
|
||||
* 携程快递信息
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripExpressDelivery {
|
||||
@JsonProperty("type")
|
||||
private String type;
|
||||
}
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
package com.central.order.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 携程订单新订响应
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class CtripCreateOrderResponse {
|
||||
|
||||
/**
|
||||
* 返回头
|
||||
*/
|
||||
@JsonProperty("header")
|
||||
private CtripResponseHeader header;
|
||||
|
||||
/**
|
||||
* 处理结果返回码
|
||||
*/
|
||||
@JsonProperty("resultCode")
|
||||
private String resultCode;
|
||||
|
||||
/**
|
||||
* 处理结果返回信息
|
||||
*/
|
||||
@JsonProperty("resultMessage")
|
||||
private String resultMessage;
|
||||
|
||||
/**
|
||||
* 返回体
|
||||
*/
|
||||
@JsonProperty("body")
|
||||
private CtripResponseBody body;
|
||||
|
||||
/**
|
||||
* 携程返回头
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripResponseHeader {
|
||||
@JsonProperty("requestTime")
|
||||
private String requestTime;
|
||||
@JsonProperty("accountId")
|
||||
private String accountId;
|
||||
@JsonProperty("sign")
|
||||
private String sign;
|
||||
@JsonProperty("serviceName")
|
||||
private String serviceName;
|
||||
@JsonProperty("version")
|
||||
private String version;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程返回体
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripResponseBody {
|
||||
@JsonProperty("otaOrderId")
|
||||
private String otaOrderId;
|
||||
@JsonProperty("supplierOrderId")
|
||||
private String supplierOrderId;
|
||||
@JsonProperty("supplierConfirmType")
|
||||
private Integer supplierConfirmType;
|
||||
@JsonProperty("voucherSender")
|
||||
private Integer voucherSender;
|
||||
@JsonProperty("vouchers")
|
||||
private List<CtripVoucher> vouchers;
|
||||
@JsonProperty("orderExtendMessage")
|
||||
private String orderExtendMessage;
|
||||
@JsonProperty("items")
|
||||
private List<CtripResponseOrderItem> items;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程凭证
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripVoucher {
|
||||
@JsonProperty("voucherType")
|
||||
private Integer voucherType;
|
||||
@JsonProperty("voucherContent")
|
||||
private String voucherContent;
|
||||
@JsonProperty("voucherUrl")
|
||||
private String voucherUrl;
|
||||
@JsonProperty("locale")
|
||||
private String locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程返回订单项
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripResponseOrderItem {
|
||||
@JsonProperty("itemId")
|
||||
private String itemId;
|
||||
@JsonProperty("supplierItemId")
|
||||
private String supplierItemId;
|
||||
@JsonProperty("status")
|
||||
private Integer status;
|
||||
@JsonProperty("message")
|
||||
private String message;
|
||||
}
|
||||
}
|
||||
-6
@@ -23,12 +23,6 @@ public class OrderStatistics {
|
||||
@Schema(description = "订单总金额(分)")
|
||||
private Long totalAmount;
|
||||
|
||||
@Schema(description = "平台分账金额(分)")
|
||||
private Long platformAmount;
|
||||
|
||||
@Schema(description = "景区分账金额(分)")
|
||||
private Long tourismAmount;
|
||||
|
||||
@Schema(description = "退款金额(分)")
|
||||
private Long refundAmount;
|
||||
|
||||
|
||||
+10
-6
@@ -70,12 +70,16 @@ public class DashboardServiceImpl implements IDashboardService {
|
||||
stats.setCompletionRate(completionRate);
|
||||
}
|
||||
|
||||
// 获取对账相关数据
|
||||
stats.setTotalAmount(dashboardMapper.getTotalAmount(params));
|
||||
stats.setRefundAmount(dashboardMapper.getRefundAmount(params));
|
||||
// 景区收入 = 总订单金额 - 退款金额
|
||||
Long netIncome = (stats.getTotalAmount() != null ? stats.getTotalAmount() : 0)
|
||||
- (stats.getRefundAmount() != null ? stats.getRefundAmount() : 0);
|
||||
// 获取对账相关数据 - 使用 orders 表的数据
|
||||
Long totalAmount = dashboardMapper.getTotalAmount(params);
|
||||
Long refundAmount = dashboardMapper.getRefundAmount(params);
|
||||
|
||||
// 设置基础数据
|
||||
stats.setTotalAmount(totalAmount);
|
||||
stats.setRefundAmount(refundAmount);
|
||||
|
||||
// 计算净收入 = 总金额 - 退款金额
|
||||
Long netIncome = (totalAmount != null ? totalAmount : 0) - (refundAmount != null ? refundAmount : 0);
|
||||
stats.setNetIncome(netIncome);
|
||||
|
||||
return stats;
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ public class TourismServiceImpl extends SuperServiceImpl<TourismMapper, Tourism>
|
||||
}
|
||||
|
||||
if (radius == null || radius <= 0) {
|
||||
radius = 10.0; // 默认10公里
|
||||
radius = 1000.0; // 默认10公里
|
||||
}
|
||||
|
||||
if (limit == null || limit <= 0) {
|
||||
|
||||
@@ -0,0 +1,315 @@
|
||||
package com.central.order.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* 携程API解密工具类
|
||||
* 实现AES-128-CBC解密和MD5签名验证
|
||||
*
|
||||
* @author system
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CtripDecryptUtil {
|
||||
|
||||
@Value("${ctrip.aes.key:}")
|
||||
private String aesKey;
|
||||
|
||||
@Value("${ctrip.sign.key:}")
|
||||
private String signKey;
|
||||
|
||||
@Value("${ctrip.aes.iv:}")
|
||||
private String aesIv;
|
||||
|
||||
/**
|
||||
* AES-128-CBC解密(携程标准)
|
||||
*
|
||||
* @param encryptedData 携程自定义编码的加密数据
|
||||
* @return 解密后的原始数据
|
||||
*/
|
||||
public String decryptAES(String encryptedData) {
|
||||
try {
|
||||
if (encryptedData == null || encryptedData.isEmpty()) {
|
||||
log.warn("加密数据为空");
|
||||
return null;
|
||||
}
|
||||
|
||||
log.debug("开始解密携程数据,数据长度: {}", encryptedData.length());
|
||||
|
||||
// 使用携程自定义解码方法
|
||||
byte[] encryptedBytes = decodeBytes(encryptedData);
|
||||
log.debug("自定义解码成功,数据长度: {}", encryptedBytes.length);
|
||||
|
||||
// 检查数据长度
|
||||
if (encryptedBytes.length < 16) {
|
||||
log.error("加密数据长度不足,无法提取IV");
|
||||
return null;
|
||||
}
|
||||
|
||||
// 提取IV(前16字节)
|
||||
byte[] iv = Arrays.copyOfRange(encryptedBytes, 0, 16);
|
||||
byte[] cipherData = Arrays.copyOfRange(encryptedBytes, 16, encryptedBytes.length);
|
||||
|
||||
log.debug("提取IV成功,IV长度: {}, 密文长度: {}", iv.length, cipherData.length);
|
||||
|
||||
// 使用UTF-8字节作为密钥和IV(携程标准)
|
||||
byte[] keyBytes = aesKey.getBytes(StandardCharsets.UTF_8);
|
||||
byte[] ivBytes = aesIv.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
log.debug("密钥长度: {}, IV长度: {}", keyBytes.length, ivBytes.length);
|
||||
|
||||
// 创建AES密钥
|
||||
SecretKeySpec secretKey = new SecretKeySpec(keyBytes, "AES");
|
||||
IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);
|
||||
|
||||
// 创建解密器
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKey, ivSpec);
|
||||
|
||||
// 解密
|
||||
byte[] decryptedBytes = cipher.doFinal(cipherData);
|
||||
String decryptedData = new String(decryptedBytes, StandardCharsets.UTF_8);
|
||||
|
||||
log.info("AES解密成功,解密后数据长度: {}", decryptedData.length());
|
||||
|
||||
// 清理解密后的数据,移除可能的头部乱码
|
||||
String cleanedData = cleanDecryptedData(decryptedData);
|
||||
log.debug("清理后数据长度: {}", cleanedData.length());
|
||||
|
||||
return cleanedData;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("AES解密失败: {}", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理解密后的数据,移除头部乱码
|
||||
*/
|
||||
private String cleanDecryptedData(String decryptedData) {
|
||||
if (decryptedData == null || decryptedData.isEmpty()) {
|
||||
return decryptedData;
|
||||
}
|
||||
|
||||
log.debug("原始解密数据前50个字符: {}",
|
||||
decryptedData.length() > 50 ? decryptedData.substring(0, 50) : decryptedData);
|
||||
|
||||
// 查找第一个 '{' 字符(JSON对象开始)
|
||||
int startIndex = decryptedData.indexOf('{');
|
||||
if (startIndex == -1) {
|
||||
// 如果没有找到 '{',查找第一个 '"' 字符
|
||||
startIndex = decryptedData.indexOf('"');
|
||||
}
|
||||
|
||||
if (startIndex == -1) {
|
||||
// 如果都没有找到,查找第一个字母或数字
|
||||
for (int i = 0; i < decryptedData.length(); i++) {
|
||||
char c = decryptedData.charAt(i);
|
||||
if (Character.isLetterOrDigit(c)) {
|
||||
startIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (startIndex > 0) {
|
||||
String cleanedData = decryptedData.substring(startIndex);
|
||||
log.debug("移除头部乱码,从位置 {} 开始,清理后数据前50个字符: {}",
|
||||
startIndex, cleanedData.length() > 50 ? cleanedData.substring(0, 50) : cleanedData);
|
||||
return cleanedData;
|
||||
}
|
||||
|
||||
log.debug("无需清理,数据前50个字符: {}",
|
||||
decryptedData.length() > 50 ? decryptedData.substring(0, 50) : decryptedData);
|
||||
return decryptedData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程自定义解码方法(转字节数组)
|
||||
*
|
||||
* @param str 编码字符串
|
||||
* @return 字节数组
|
||||
*/
|
||||
private byte[] decodeBytes(String str) {
|
||||
byte[] bytes = new byte[str.length() / 2];
|
||||
for (int i = 0; i < str.length(); i += 2) {
|
||||
char c = str.charAt(i);
|
||||
bytes[i / 2] = (byte) ((c - 'a') << 4);
|
||||
c = str.charAt(i + 1);
|
||||
bytes[i / 2] += (c - 'a');
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程自定义编码方法(转16进制)
|
||||
*
|
||||
* @param bytes 字节数组
|
||||
* @return 编码字符串
|
||||
*/
|
||||
private String encodeBytes(byte[] bytes) {
|
||||
StringBuffer strBuf = new StringBuffer();
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
strBuf.append((char) (((bytes[i] >> 4) & 0xF) + ((int) 'a')));
|
||||
strBuf.append((char) (((bytes[i]) & 0xF) + ((int) 'a')));
|
||||
}
|
||||
return strBuf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证MD5签名(携程标准)
|
||||
*
|
||||
* @param accountId 账号ID
|
||||
* @param serviceName 服务名称
|
||||
* @param requestTime 请求时间
|
||||
* @param body 请求体
|
||||
* @param version 版本
|
||||
* @param sign 签名
|
||||
* @return 验证结果
|
||||
*/
|
||||
public boolean verifySign(String accountId, String serviceName, String requestTime, String body, String version, String sign) {
|
||||
try {
|
||||
// 按携程标准拼接参数:accountId+serviceName+requestTime+body+version+signkey
|
||||
String signContent = accountId + serviceName + requestTime + body + version + signKey;
|
||||
log.debug("签名内容: {}", signContent);
|
||||
|
||||
// 计算MD5并转小写
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
byte[] md5Bytes = md.digest(signContent.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// 转换为小写十六进制
|
||||
StringBuilder calculatedSign = new StringBuilder();
|
||||
for (byte b : md5Bytes) {
|
||||
calculatedSign.append(String.format("%02x", b & 0xff));
|
||||
}
|
||||
|
||||
String calculatedSignStr = calculatedSign.toString();
|
||||
log.debug("计算签名: {}, 接收签名: {}", calculatedSignStr, sign);
|
||||
|
||||
return calculatedSignStr.equalsIgnoreCase(sign);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("签名验证失败: {}", e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证MD5签名(兼容旧版本)
|
||||
*
|
||||
* @param params 请求参数
|
||||
* @param sign 签名
|
||||
* @return 验证结果
|
||||
*/
|
||||
public boolean verifySign(Map<String, String> params, String sign) {
|
||||
try {
|
||||
// 按字典序排序参数
|
||||
TreeMap<String, String> sortedParams = new TreeMap<>(params);
|
||||
|
||||
// 构建签名字符串
|
||||
StringBuilder signStr = new StringBuilder();
|
||||
for (Map.Entry<String, String> entry : sortedParams.entrySet()) {
|
||||
if (entry.getValue() != null && !entry.getValue().isEmpty()) {
|
||||
signStr.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
|
||||
}
|
||||
}
|
||||
|
||||
// 添加签名密钥
|
||||
signStr.append("key=").append(signKey);
|
||||
|
||||
String signContent = signStr.toString();
|
||||
log.debug("签名内容: {}", signContent);
|
||||
|
||||
// 计算MD5
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
byte[] md5Bytes = md.digest(signContent.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// 转换为小写十六进制
|
||||
StringBuilder calculatedSign = new StringBuilder();
|
||||
for (byte b : md5Bytes) {
|
||||
calculatedSign.append(String.format("%02x", b & 0xff));
|
||||
}
|
||||
|
||||
String calculatedSignStr = calculatedSign.toString();
|
||||
log.debug("计算签名: {}, 接收签名: {}", calculatedSignStr, sign);
|
||||
|
||||
return calculatedSignStr.equalsIgnoreCase(sign);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("签名验证失败: {}", e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密携程请求体
|
||||
*
|
||||
* @param encryptedBody 加密的请求体
|
||||
* @return 解密后的JSON字符串
|
||||
*/
|
||||
public String decryptCtripBody(String encryptedBody) {
|
||||
if (encryptedBody == null || encryptedBody.isEmpty()) {
|
||||
log.warn("请求体为空");
|
||||
return null;
|
||||
}
|
||||
|
||||
log.info("开始解密携程请求体,数据长度: {}", encryptedBody.length());
|
||||
|
||||
// 尝试AES解密
|
||||
String decryptedData = decryptAES(encryptedBody);
|
||||
if (decryptedData != null) {
|
||||
log.info("携程请求体解密成功");
|
||||
return decryptedData;
|
||||
}
|
||||
|
||||
log.error("携程请求体解密失败");
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查配置是否完整
|
||||
*/
|
||||
public boolean isConfigValid() {
|
||||
boolean valid = true;
|
||||
|
||||
if (aesKey == null || aesKey.isEmpty()) {
|
||||
log.error("携程AES密钥未配置");
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if (signKey == null || signKey.isEmpty()) {
|
||||
log.error("携程签名密钥未配置");
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if (aesIv == null || aesIv.isEmpty()) {
|
||||
log.error("携程AES IV未配置");
|
||||
valid = false;
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置信息(脱敏)
|
||||
*/
|
||||
public String getConfigInfo() {
|
||||
return String.format("AES密钥长度: %d, 签名密钥长度: %d, IV长度: %d",
|
||||
aesKey != null ? aesKey.length() : 0,
|
||||
signKey != null ? signKey.length() : 0,
|
||||
aesIv != null ? aesIv.length() : 0);
|
||||
}
|
||||
}
|
||||
@@ -39,12 +39,14 @@ zlt:
|
||||
- video_template
|
||||
- profit_sharing
|
||||
- order_statistics
|
||||
- orders_refund
|
||||
ignoreSqls:
|
||||
# 移除所有ignoreSqls配置,让所有SQL都经过租户过滤处理
|
||||
# 这样webApp租户的特殊处理逻辑才能生效
|
||||
# 该接口是白名单接口查询中的逻辑,来例如:机库直接创建数据没有携带租户ID
|
||||
- com.central.order.mapper.OrderMapper.getOrderByNumber
|
||||
- com.central.order.mapper.OrderMapper.getOrdersByStatus
|
||||
- com.central.order.mapper.RefundMapper.selectOne
|
||||
# update和delete类型的操作mybatisPlus不支持,原因是数据隔离级别
|
||||
# - com.central.order.mapper.OrderMapper.updateOrderStatus
|
||||
# 微信支付商户号
|
||||
@@ -138,3 +140,11 @@ cdn:
|
||||
logging:
|
||||
level:
|
||||
com.central.order.controller.OrderFileController: DEBUG
|
||||
|
||||
# 携程API配置
|
||||
ctrip:
|
||||
aes:
|
||||
key: 087b36ad0dff7942 # 请替换为实际的AES密钥
|
||||
iv: 750e15a31356a99d # 请替换为实际的AES IV
|
||||
sign:
|
||||
key: ce6033ae31124ec5cdab3d2bc79f2622 # 请替换为实际的签名密钥
|
||||
|
||||
+427
@@ -0,0 +1,427 @@
|
||||
package com.central.order.controller;
|
||||
|
||||
import com.central.order.model.CtripCreateOrderRequest;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* 优惠券控制器测试
|
||||
*/
|
||||
@SpringBootTest
|
||||
public class CouponControllerTest {
|
||||
|
||||
@Test
|
||||
public void testCtripCreateOrderRequestDeserialization() throws Exception {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
// 构建测试JSON
|
||||
String testJson = "{\n" +
|
||||
" \"header\": {\n" +
|
||||
" \"requestTime\": \"2024-12-19 10:00:00\",\n" +
|
||||
" \"accountId\": \"testAccount\",\n" +
|
||||
" \"sign\": \"testSign\",\n" +
|
||||
" \"serviceName\": \"createOrder\",\n" +
|
||||
" \"version\": \"1.0\"\n" +
|
||||
" },\n" +
|
||||
" \"body\": {\n" +
|
||||
" \"otaOrderId\": \"CTRIP123456\",\n" +
|
||||
" \"sequenceId\": \"SEQ123456\",\n" +
|
||||
" \"items\": [\n" +
|
||||
" {\n" +
|
||||
" \"passengers\": [\n" +
|
||||
" {\n" +
|
||||
" \"name\": \"张三\",\n" +
|
||||
" \"mobile\": \"13800138000\",\n" +
|
||||
" \"gender\": \"M\",\n" +
|
||||
" \"cardType\": \"ID\",\n" +
|
||||
" \"cardNo\": \"110101199001011234\"\n" +
|
||||
" }\n" +
|
||||
" ],\n" +
|
||||
" \"cost\": 100.00,\n" +
|
||||
" \"quantity\": 1,\n" +
|
||||
" \"salePrice\": 80.00,\n" +
|
||||
" \"price\": 100.00,\n" +
|
||||
" \"useStartDate\": \"2024-12-20\",\n" +
|
||||
" \"useEndDate\": \"2024-12-25\",\n" +
|
||||
" \"adjunctions\": [\"adj1\", \"adj2\"],\n" +
|
||||
" \"deposit\": {},\n" +
|
||||
" \"distributionChannel\": \"online\",\n" +
|
||||
" \"priceCurrency\": \"CNY\",\n" +
|
||||
" \"costCurrency\": \"CNY\",\n" +
|
||||
" \"salePriceCurrency\": \"CNY\"\n" +
|
||||
" }\n" +
|
||||
" ],\n" +
|
||||
" \"contacts\": [\n" +
|
||||
" {\n" +
|
||||
" \"name\": \"张三\",\n" +
|
||||
" \"mobile\": \"13800138000\",\n" +
|
||||
" \"email\": \"zhangsan@example.com\"\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
|
||||
// 测试反序列化
|
||||
CtripCreateOrderRequest request = objectMapper.readValue(testJson, CtripCreateOrderRequest.class);
|
||||
|
||||
// 验证反序列化结果
|
||||
assertNotNull(request);
|
||||
assertNotNull(request.getHeader());
|
||||
assertNotNull(request.getBody());
|
||||
assertEquals("testAccount", request.getHeader().getAccountId());
|
||||
assertEquals("createOrder", request.getHeader().getServiceName());
|
||||
|
||||
// 验证body是对象
|
||||
assertTrue(request.getBody() instanceof CtripCreateOrderRequest.CtripOrderBody);
|
||||
CtripCreateOrderRequest.CtripOrderBody body = (CtripCreateOrderRequest.CtripOrderBody) request.getBody();
|
||||
assertEquals("CTRIP123456", body.getOtaOrderId());
|
||||
|
||||
// 验证订单项
|
||||
assertNotNull(body.getItems());
|
||||
assertFalse(body.getItems().isEmpty());
|
||||
|
||||
CtripCreateOrderRequest.CtripOrderItem item = body.getItems().get(0);
|
||||
assertNotNull(item.getPassengers());
|
||||
assertFalse(item.getPassengers().isEmpty());
|
||||
assertEquals("张三", item.getPassengers().get(0).getName());
|
||||
assertEquals("13800138000", item.getPassengers().get(0).getMobile());
|
||||
|
||||
System.out.println("JSON反序列化测试通过!");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCtripCreateOrderRequestSerialization() throws Exception {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
// 构建测试对象
|
||||
CtripCreateOrderRequest request = new CtripCreateOrderRequest();
|
||||
|
||||
// 设置header
|
||||
CtripCreateOrderRequest.CtripHeader header = new CtripCreateOrderRequest.CtripHeader();
|
||||
header.setRequestTime("2024-12-19 10:00:00");
|
||||
header.setAccountId("testAccount");
|
||||
header.setSign("testSign");
|
||||
header.setServiceName("createOrder");
|
||||
header.setVersion("1.0");
|
||||
request.setHeader(header);
|
||||
|
||||
// 设置body为对象
|
||||
CtripCreateOrderRequest.CtripOrderBody body = new CtripCreateOrderRequest.CtripOrderBody();
|
||||
body.setOtaOrderId("CTRIP123456");
|
||||
body.setSequenceId("SEQ123456");
|
||||
|
||||
// 设置item
|
||||
CtripCreateOrderRequest.CtripOrderItem item = new CtripCreateOrderRequest.CtripOrderItem();
|
||||
item.setCost(new BigDecimal("100.00"));
|
||||
item.setQuantity(1);
|
||||
item.setSalePrice(new BigDecimal("80.00"));
|
||||
item.setPrice(new BigDecimal("100.00"));
|
||||
item.setUseStartDate("2024-12-20");
|
||||
item.setUseEndDate("2024-12-25");
|
||||
item.setAdjunctions(Arrays.asList("adj1", "adj2"));
|
||||
item.setDeposit(new Object());
|
||||
item.setDistributionChannel("online");
|
||||
item.setPriceCurrency("CNY");
|
||||
item.setCostCurrency("CNY");
|
||||
item.setSalePriceCurrency("CNY");
|
||||
|
||||
// 设置passenger
|
||||
CtripCreateOrderRequest.CtripPassenger passenger = new CtripCreateOrderRequest.CtripPassenger();
|
||||
passenger.setName("张三");
|
||||
passenger.setMobile("13800138000");
|
||||
passenger.setGender("M");
|
||||
passenger.setCardType("ID");
|
||||
passenger.setCardNo("110101199001011234");
|
||||
item.setPassengers(Arrays.asList(passenger));
|
||||
|
||||
body.setItems(Arrays.asList(item));
|
||||
|
||||
// 设置contact
|
||||
CtripCreateOrderRequest.CtripContact contact = new CtripCreateOrderRequest.CtripContact();
|
||||
contact.setName("张三");
|
||||
contact.setMobile("13800138000");
|
||||
contact.setEmail("zhangsan@example.com");
|
||||
body.setContacts(Arrays.asList(contact));
|
||||
|
||||
request.setBody(body);
|
||||
|
||||
// 测试序列化
|
||||
String json = objectMapper.writeValueAsString(request);
|
||||
assertNotNull(json);
|
||||
assertTrue(json.contains("CTRIP123456"));
|
||||
assertTrue(json.contains("testAccount"));
|
||||
|
||||
System.out.println("JSON序列化测试通过!");
|
||||
System.out.println("生成的JSON: " + json);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testErrorHandling() throws Exception {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
// 测试错误的JSON格式
|
||||
String invalidJson = "{\"invalid\": \"data\"}";
|
||||
|
||||
try {
|
||||
CtripCreateOrderRequest request = objectMapper.readValue(invalidJson, CtripCreateOrderRequest.class);
|
||||
// 如果没有抛出异常,说明@JsonIgnoreProperties生效了
|
||||
assertNotNull(request);
|
||||
System.out.println("错误处理测试通过 - 忽略未知属性");
|
||||
} catch (Exception e) {
|
||||
// 如果抛出异常,也是正常的
|
||||
System.out.println("错误处理测试通过 - 捕获到异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEncryptedDataHandling() {
|
||||
// 测试加密数据处理
|
||||
String encryptedData = "anipkokpjcnikijobbdgmeddhnmngkidmfoeamjgmmjenpikgpeafnoonnjppdlhhhoidlopkfbpepchhbikpeiaogpmglhjbcaoomkponmciaphjjajhogmmagkiflikbffgmgkinckainhidjjmmoifodpakdlacfepfphenlflpcpdmjpnpaocckibgoagfcncpjnkhaniibphkmgknjabnfoeiblkfbmpekpkpaolangbbpflclbnbmffcaaemnaceckfmaegfnoclpgkblgpjggkjdmkbnkbffacmlpbnefipiaenjclfppilnedllghnejhdchhkdacadanioehbpbdmghioohnjbaamahjdoebckhhljnohfaddbndlepilbnngdhlmfbajnjchllinafbpeldcaacnddmieipmnikgbbbmjpbnpofceacdecjdifkmipeknimidgpbjpdoclimemkjmjhnneghcknneambllglnahlkenngnakncoijpggpdafipbladoaadbdfdebkcjfkaopaieknmjfopbojgljmlgkehmgoghnhggppbeoflhgfijjoabbmkipehekdpchlagnlbdidbmdmghdhoicoapnneljedkkaiikieneiopokkbidoigjlbmkkpeilapilhcmdkaiokiciaacenikijicllgdkbhlenhhcdapipkjhompefkfeginnmgmkjjooleihjfnjofkdgelojfboejjdopiajgldoppcaepkoceffkfjacfcpcbfcblgkaigddakfagnijfjdombelmfgjgopighebpdgbfcbmbecblhdgfbgkoacoiemfelalemmnkeejnighfgmlbenocgdlmoelbcakjppjlpoecimikkbcjblemhbhcgnapcmjbbflgmlfkllmpgdmhiagpolnlccanjdbajnbieapghplipmemakjkkfgphligccnlpjhgeiglbpdcejaajfhjfkplhocifopajenpmdmpncbpkhbbnpnbckmkahemfddhkgijgagkbmpigmbdedmkonkcchimohghkojhmgfeafpefoefccbjjkfkdcedbcmlgomoicfihhaalamkafkmfefdlihpopbdomkiodfdaiogemkebjmbgnfodmnbfedbaacdlmmangllfjihbhmngeoibobbjjmfmfdmpncdpbnfhcggonmfnpifhbjbjlnmcffdpnjpajkgdhllhdpffbdnioacknijcabmncijgmepdkipfpncchmaiamlmfpbcjamggjdjeokhdepklpflafjolemjednbbfmgoikkmfdhgnfiomkaahccnflpdlholfdkncdimgdgfmjdahadbohhfiamlfggljdeahjaaoopclacaakmpobapkhnbmcfmlbobdhblillhdbmmnoaaaeedaleehgpeofipljnmloicglmdmefpkdiplhlmhgiafhjjijigeapikdcdaoallpjlcmebbcohnmlacnkcbcnjkapdaeemkgcgbodjbneaapdgomhbmoljahdlmffnebohgngnfhkjlhejfebgjcccfpmclbeooaghapbkdcjicgjpjnjcgfnhefcmkknglodcoajnobpakaempkbllghgfcobefnebjnaniocjmdedcbgpbbacelfecgemifkedogbloplckenjopknbpfgabpfnaphcklifibbhgohhkjldaekcedkeimlmegdhbjnffililaamfbfdkakleknjdjahogknimijcdahggheehclghkbkkclebcgopeabkkcceiahldnmnffhkgcdbahaldpgddehbpjieaojnknbedoinappdpjjkinjcgiodfahffppcpkeaelgcabkelblhlbbddbemckhkjldpndoohboioplpdohngjpbdegfcnhloenmncalldemhoigglahmnpcdepjfmfhdekbnombijpcfiggmllpglbghlelijohdegkkmicbcgioccekjbhfhoimhdpcejcjcjlmohpfiijjpmknihlhgjeniknkjlhjdgemjgjbnahdhjgobmgonnlljhpendhke";
|
||||
|
||||
// 验证这是一个长字符串而不是JSON
|
||||
assertFalse(encryptedData.startsWith("{"));
|
||||
assertFalse(encryptedData.endsWith("}"));
|
||||
assertTrue(encryptedData.length() > 1000);
|
||||
|
||||
System.out.println("加密数据处理测试通过 - 识别为非JSON格式的长字符串");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testOrderCreation() throws Exception {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
// 构建测试JSON - 实际的携程订单数据
|
||||
String testJson = "{\n" +
|
||||
" \"header\": {\n" +
|
||||
" \"requestTime\": \"2025-08-01 22:58:01\",\n" +
|
||||
" \"accountId\": \"c50a8f2a4a59c9e7\",\n" +
|
||||
" \"sign\": \"5e8ebe775c7aaa466cd469947d6dee22\",\n" +
|
||||
" \"serviceName\": \"CreatePreOrder\",\n" +
|
||||
" \"version\": \"1.0\"\n" +
|
||||
" },\n" +
|
||||
" \"body\": {\n" +
|
||||
" \"otaOrderId\": \"ctriptest-10816912-454259-145573\",\n" +
|
||||
" \"sequenceId\": \"2025080122580189a0fbcc46364e1ab3b47fc7c20e3767\",\n" +
|
||||
" \"items\": [\n" +
|
||||
" {\n" +
|
||||
" \"passengers\": [\n" +
|
||||
" {\n" +
|
||||
" \"cardIssuePlace\": \"\",\n" +
|
||||
" \"lastName\": \"\",\n" +
|
||||
" \"cardIssueCountry\": \"\",\n" +
|
||||
" \"shoeSize\": 0,\n" +
|
||||
" \"gender\": \"M\",\n" +
|
||||
" \"cardIssueDate\": \"\",\n" +
|
||||
" \"intlCode\": \"+86\",\n" +
|
||||
" \"nationalityName\": \"\",\n" +
|
||||
" \"mobile\": \"18322694510\",\n" +
|
||||
" \"cardType\": \"1\",\n" +
|
||||
" \"weight\": 0,\n" +
|
||||
" \"myopiaDegreeL\": 0,\n" +
|
||||
" \"birthDate\": \"2025-07-10\",\n" +
|
||||
" \"cardNo\": \"620421198909185197\",\n" +
|
||||
" \"ageType\": \"ADU\",\n" +
|
||||
" \"myopiaDegreeR\": 0,\n" +
|
||||
" \"firstName\": \"sl\",\n" +
|
||||
" \"birthPlace\": \"\",\n" +
|
||||
" \"nationalityCode\": \"\",\n" +
|
||||
" \"name\": \"李世琳\",\n" +
|
||||
" \"passengerId\": \"33c0b8013a554c5c8f59e7e0fac6ef32\",\n" +
|
||||
" \"cardValidDate\": \"\",\n" +
|
||||
" \"height\": 0\n" +
|
||||
" }\n" +
|
||||
" ],\n" +
|
||||
" \"cost\": 2.00,\n" +
|
||||
" \"quantity\": 1,\n" +
|
||||
" \"salePrice\": 2.00,\n" +
|
||||
" \"remark\": \"This is remark\",\n" +
|
||||
" \"useEndDate\": \"2025-07-25\",\n" +
|
||||
" \"locale\": \"zh-CN\",\n" +
|
||||
" \"useStartDate\": \"2025-07-25\",\n" +
|
||||
" \"priceCurrency\": \"CNY\",\n" +
|
||||
" \"adjunctions\": [],\n" +
|
||||
" \"price\": 2.00,\n" +
|
||||
" \"PLU\": \"1\",\n" +
|
||||
" \"deposit\": {},\n" +
|
||||
" \"distributionChannel\": \"XCW\",\n" +
|
||||
" \"costCurrency\": \"CNY\",\n" +
|
||||
" \"salePriceCurrency\": \"CNY\",\n" +
|
||||
" \"expressDelivery\": {\n" +
|
||||
" \"type\": \"1\"\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" ],\n" +
|
||||
" \"contacts\": [\n" +
|
||||
" {\n" +
|
||||
" \"intlCode\": \"+86\",\n" +
|
||||
" \"name\": \"李世琳\",\n" +
|
||||
" \"mobile\": \"18322694510\",\n" +
|
||||
" \"optionalMobile\": \"13333333333\",\n" +
|
||||
" \"optionalIntlCode\": \"86\",\n" +
|
||||
" \"email\": \"1272745473@qq.com\"\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
|
||||
// 测试反序列化
|
||||
CtripCreateOrderRequest request = objectMapper.readValue(testJson, CtripCreateOrderRequest.class);
|
||||
|
||||
// 验证反序列化结果
|
||||
assertNotNull(request);
|
||||
assertNotNull(request.getHeader());
|
||||
assertNotNull(request.getBody());
|
||||
assertEquals("c50a8f2a4a59c9e7", request.getHeader().getAccountId());
|
||||
assertEquals("CreatePreOrder", request.getHeader().getServiceName());
|
||||
|
||||
// 验证body是对象
|
||||
assertTrue(request.getBody() instanceof CtripCreateOrderRequest.CtripOrderBody);
|
||||
CtripCreateOrderRequest.CtripOrderBody body = (CtripCreateOrderRequest.CtripOrderBody) request.getBody();
|
||||
assertEquals("ctriptest-10816912-454259-145573", body.getOtaOrderId());
|
||||
|
||||
// 验证订单项
|
||||
assertNotNull(body.getItems());
|
||||
assertFalse(body.getItems().isEmpty());
|
||||
|
||||
CtripCreateOrderRequest.CtripOrderItem item = body.getItems().get(0);
|
||||
assertNotNull(item.getPassengers());
|
||||
assertFalse(item.getPassengers().isEmpty());
|
||||
assertEquals("李世琳", item.getPassengers().get(0).getName());
|
||||
assertEquals("18322694510", item.getPassengers().get(0).getMobile());
|
||||
assertEquals(new java.math.BigDecimal("2.00"), item.getSalePrice());
|
||||
|
||||
// 验证联系人
|
||||
assertNotNull(body.getContacts());
|
||||
assertFalse(body.getContacts().isEmpty());
|
||||
assertEquals("李世琳", body.getContacts().get(0).getName());
|
||||
assertEquals("18322694510", body.getContacts().get(0).getMobile());
|
||||
|
||||
System.out.println("订单创建测试通过!");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCtripCouponCreation() throws Exception {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
// 构建测试JSON - 实际的携程优惠券数据
|
||||
String testJson = "{\n" +
|
||||
" \"header\": {\n" +
|
||||
" \"requestTime\": \"2025-08-01 22:58:01\",\n" +
|
||||
" \"accountId\": \"c50a8f2a4a59c9e7\",\n" +
|
||||
" \"sign\": \"5e8ebe775c7aaa466cd469947d6dee22\",\n" +
|
||||
" \"serviceName\": \"CreatePreOrder\",\n" +
|
||||
" \"version\": \"1.0\"\n" +
|
||||
" },\n" +
|
||||
" \"body\": {\n" +
|
||||
" \"otaOrderId\": \"ctriptest-10816912-454259-145573\",\n" +
|
||||
" \"sequenceId\": \"2025080122580189a0fbcc46364e1ab3b47fc7c20e3767\",\n" +
|
||||
" \"items\": [\n" +
|
||||
" {\n" +
|
||||
" \"passengers\": [\n" +
|
||||
" {\n" +
|
||||
" \"cardIssuePlace\": \"\",\n" +
|
||||
" \"lastName\": \"\",\n" +
|
||||
" \"cardIssueCountry\": \"\",\n" +
|
||||
" \"shoeSize\": 0,\n" +
|
||||
" \"gender\": \"M\",\n" +
|
||||
" \"cardIssueDate\": \"\",\n" +
|
||||
" \"intlCode\": \"+86\",\n" +
|
||||
" \"nationalityName\": \"\",\n" +
|
||||
" \"mobile\": \"18322694510\",\n" +
|
||||
" \"cardType\": \"1\",\n" +
|
||||
" \"weight\": 0,\n" +
|
||||
" \"myopiaDegreeL\": 0,\n" +
|
||||
" \"birthDate\": \"2025-07-10\",\n" +
|
||||
" \"cardNo\": \"620421198909185197\",\n" +
|
||||
" \"ageType\": \"ADU\",\n" +
|
||||
" \"myopiaDegreeR\": 0,\n" +
|
||||
" \"firstName\": \"sl\",\n" +
|
||||
" \"birthPlace\": \"\",\n" +
|
||||
" \"nationalityCode\": \"\",\n" +
|
||||
" \"name\": \"李世琳\",\n" +
|
||||
" \"passengerId\": \"33c0b8013a554c5c8f59e7e0fac6ef32\",\n" +
|
||||
" \"cardValidDate\": \"\",\n" +
|
||||
" \"height\": 0\n" +
|
||||
" }\n" +
|
||||
" ],\n" +
|
||||
" \"cost\": 2.00,\n" +
|
||||
" \"quantity\": 1,\n" +
|
||||
" \"salePrice\": 2.00,\n" +
|
||||
" \"remark\": \"This is remark\",\n" +
|
||||
" \"useEndDate\": \"2025-07-25\",\n" +
|
||||
" \"locale\": \"zh-CN\",\n" +
|
||||
" \"useStartDate\": \"2025-07-25\",\n" +
|
||||
" \"priceCurrency\": \"CNY\",\n" +
|
||||
" \"adjunctions\": [],\n" +
|
||||
" \"price\": 2.00,\n" +
|
||||
" \"PLU\": \"1\",\n" +
|
||||
" \"deposit\": {},\n" +
|
||||
" \"distributionChannel\": \"XCW\",\n" +
|
||||
" \"costCurrency\": \"CNY\",\n" +
|
||||
" \"salePriceCurrency\": \"CNY\",\n" +
|
||||
" \"expressDelivery\": {\n" +
|
||||
" \"type\": \"1\"\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" ],\n" +
|
||||
" \"contacts\": [\n" +
|
||||
" {\n" +
|
||||
" \"intlCode\": \"+86\",\n" +
|
||||
" \"name\": \"李世琳\",\n" +
|
||||
" \"mobile\": \"18322694510\",\n" +
|
||||
" \"optionalMobile\": \"13333333333\",\n" +
|
||||
" \"optionalIntlCode\": \"86\",\n" +
|
||||
" \"email\": \"1272745473@qq.com\"\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
|
||||
// 测试反序列化
|
||||
CtripCreateOrderRequest request = objectMapper.readValue(testJson, CtripCreateOrderRequest.class);
|
||||
|
||||
// 验证反序列化结果
|
||||
assertNotNull(request);
|
||||
assertNotNull(request.getHeader());
|
||||
assertNotNull(request.getBody());
|
||||
assertEquals("c50a8f2a4a59c9e7", request.getHeader().getAccountId());
|
||||
assertEquals("CreatePreOrder", request.getHeader().getServiceName());
|
||||
|
||||
// 验证body是对象
|
||||
assertTrue(request.getBody() instanceof CtripCreateOrderRequest.CtripOrderBody);
|
||||
CtripCreateOrderRequest.CtripOrderBody body = (CtripCreateOrderRequest.CtripOrderBody) request.getBody();
|
||||
assertEquals("ctriptest-10816912-454259-145573", body.getOtaOrderId());
|
||||
|
||||
// 验证订单项
|
||||
assertNotNull(body.getItems());
|
||||
assertFalse(body.getItems().isEmpty());
|
||||
|
||||
CtripCreateOrderRequest.CtripOrderItem item = body.getItems().get(0);
|
||||
assertNotNull(item.getPassengers());
|
||||
assertFalse(item.getPassengers().isEmpty());
|
||||
assertEquals("李世琳", item.getPassengers().get(0).getName());
|
||||
assertEquals("18322694510", item.getPassengers().get(0).getMobile());
|
||||
assertEquals(new java.math.BigDecimal("2.00"), item.getSalePrice());
|
||||
|
||||
// 验证联系人
|
||||
assertNotNull(body.getContacts());
|
||||
assertFalse(body.getContacts().isEmpty());
|
||||
assertEquals("李世琳", body.getContacts().get(0).getName());
|
||||
assertEquals("18322694510", body.getContacts().get(0).getMobile());
|
||||
|
||||
System.out.println("携程优惠券创建测试通过!");
|
||||
System.out.println("接口路径: /coupon/ctrip/create");
|
||||
System.out.println("请求方法: POST");
|
||||
System.out.println("Content-Type: application/json");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,10 +26,11 @@ zlt.fdfs.web-url=192.168.28.130
|
||||
zlt.fdfs.trackerList=${zlt.fdfs.web-url}:22122
|
||||
|
||||
##### s3配置
|
||||
zlt.s3.access-key=33RdDbIlEFK0z9IJHSqx
|
||||
zlt.s3.accessKeySecret=mmfSh4gjJm8dck0KaG6fKItpIM3tenWVHS4Ygjlm
|
||||
zlt.s3.endpoint=http://81.70.164.178:9000
|
||||
zlt.s3.bucketName=gofly
|
||||
zlt.s3.access-key=Hq78CaYg2BI6ZfxCRMKI
|
||||
zlt.s3.accessKeySecret=DJCt5q9K7GQ2zcBEfr3twb1vQ6BgUW1LKFlI5NSw
|
||||
zlt.s3.endpoint=http://220.205.16.27:9000
|
||||
zlt.s3.bucketName=goflyapp
|
||||
zlt.s3.region=us-east-1
|
||||
|
||||
zlt.oss.secretId=LTAI5tSNV1RvexXpMMCZhxSe
|
||||
zlt.oss.secretKey=XocJRWU8emwjjvYLTrc04l91VZMkQK
|
||||
|
||||
@@ -43,10 +43,8 @@ interface Statistics {
|
||||
todayOrders: number;
|
||||
orderGrowth: number;
|
||||
completionRate: number;
|
||||
// 新增对账维度
|
||||
// 对账相关字段
|
||||
totalAmount: number; // 订单总金额(分)
|
||||
platformAmount: number; // 平台分账金额(分)
|
||||
tourismAmount: number; // 景区分账金额(分)
|
||||
refundAmount: number; // 退款金额(分)
|
||||
netIncome: number; // 净收入(分)
|
||||
};
|
||||
@@ -158,8 +156,12 @@ const Welcome: React.FC = () => {
|
||||
const chartStats = statistics.chartStats || {};
|
||||
const filterOptions = statistics.filterOptions || {};
|
||||
|
||||
// 动态分账金额计算
|
||||
// 使用后端返回的基础数据
|
||||
const totalAmount = orderStats.totalAmount || 0;
|
||||
const refundAmount = orderStats.refundAmount || 0;
|
||||
const netIncome = orderStats.netIncome || 0;
|
||||
|
||||
// 动态分账金额计算(基于净收入和分账比例)
|
||||
const platformAmount = Math.round(netIncome * platformRate);
|
||||
const tourismAmount = netIncome - platformAmount;
|
||||
|
||||
@@ -196,7 +198,7 @@ const Welcome: React.FC = () => {
|
||||
data: [
|
||||
{ type: '平台分账', value: platformAmount / 100 },
|
||||
{ type: '景区分账', value: tourismAmount / 100 },
|
||||
{ type: '退款金额', value: (orderStats.refundAmount || 0) / 100 },
|
||||
{ type: '退款金额', value: refundAmount / 100 },
|
||||
],
|
||||
xField: 'type',
|
||||
yField: 'value',
|
||||
@@ -211,6 +213,8 @@ const Welcome: React.FC = () => {
|
||||
|
||||
return (
|
||||
<PageContainer className={styles.container}>
|
||||
|
||||
|
||||
{/* 筛选条件 */}
|
||||
<Card style={{ marginBottom: 16 }}>
|
||||
<Space size="large">
|
||||
@@ -250,6 +254,7 @@ const Welcome: React.FC = () => {
|
||||
<span style={{ color: '#666', fontSize: '12px' }}>
|
||||
(当前:平台{Math.round(platformRate * 100)}% | 景区{Math.round((1 - platformRate) * 100)}%)
|
||||
</span>
|
||||
|
||||
{/* 快速选择常用分账比例 */}
|
||||
<Space size="small">
|
||||
<span style={{ color: '#666', fontSize: '12px' }}>快速选择:</span>
|
||||
@@ -381,6 +386,7 @@ const Welcome: React.FC = () => {
|
||||
status="active"
|
||||
format={(percent) => `分账率 ${percent?.toFixed(1)}%`}
|
||||
/>
|
||||
|
||||
</div>
|
||||
</Card>
|
||||
</Col>
|
||||
|
||||
@@ -23,6 +23,7 @@ interface CreateFormProps {
|
||||
tourismOptions: any[];
|
||||
waylineOptions: any[];
|
||||
deviceOptions: any[];
|
||||
tenantOptions: any[];
|
||||
}
|
||||
|
||||
const CreateForm: React.FC<CreateFormProps> = ({
|
||||
@@ -33,6 +34,7 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
||||
tourismOptions,
|
||||
waylineOptions,
|
||||
deviceOptions,
|
||||
tenantOptions,
|
||||
}) => {
|
||||
// 使用 Form.useWatch 监听 enableProfit 的值
|
||||
const [form] = Form.useForm();
|
||||
@@ -200,6 +202,24 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
||||
tooltip="测试二维码的数据不会计入正式统计"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
|
||||
<ProForm.Group>
|
||||
<ProFormSelect
|
||||
width="md"
|
||||
name="tenantId"
|
||||
label="应用ID"
|
||||
options={tenantOptions}
|
||||
rules={[{ required: true, message: '请选择应用' }]}
|
||||
placeholder="请选择应用"
|
||||
showSearch
|
||||
fieldProps={{
|
||||
loading: !tenantOptions.length,
|
||||
filterOption: (input, option) =>
|
||||
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
|
||||
notFoundContent: tenantOptions.length === 0 ? '暂无应用数据' : undefined,
|
||||
}}
|
||||
/>
|
||||
</ProForm.Group>
|
||||
</ModalForm>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -25,6 +25,7 @@ interface UpdateFormProps {
|
||||
tourismOptions: any[];
|
||||
waylineOptions: any[];
|
||||
deviceOptions: any[];
|
||||
tenantOptions: any[];
|
||||
}
|
||||
|
||||
const UpdateForm: React.FC<UpdateFormProps> = ({
|
||||
@@ -36,6 +37,7 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
|
||||
tourismOptions,
|
||||
waylineOptions,
|
||||
deviceOptions,
|
||||
tenantOptions,
|
||||
}) => {
|
||||
const [form] = Form.useForm();
|
||||
const enableProfit = Form.useWatch('enableProfit', form);
|
||||
@@ -199,6 +201,24 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
|
||||
tooltip="测试二维码的数据不会计入正式统计"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
|
||||
<ProForm.Group>
|
||||
<ProFormSelect
|
||||
width="md"
|
||||
name="tenantId"
|
||||
label="应用ID"
|
||||
options={tenantOptions}
|
||||
rules={[{ required: true, message: '请选择应用' }]}
|
||||
placeholder="请选择应用"
|
||||
showSearch
|
||||
fieldProps={{
|
||||
loading: !tenantOptions.length,
|
||||
filterOption: (input, option) =>
|
||||
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
|
||||
notFoundContent: tenantOptions.length === 0 ? '暂无应用数据' : undefined,
|
||||
}}
|
||||
/>
|
||||
</ProForm.Group>
|
||||
</ModalForm>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { deleteQrcode, qrcode, saveOrUpdateQrcode, getTourismList, getVideoTemplateList } from '@/services/orders/api';
|
||||
import { deleteQrcode, qrcode, saveOrUpdateQrcode, getTourismList, getVideoTemplateList, getTenantList } from '@/services/orders/api';
|
||||
import { PlusOutlined } from '@ant-design/icons';
|
||||
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
||||
import {
|
||||
@@ -93,6 +93,7 @@ const TableList: React.FC = () => {
|
||||
const [tourismOptions, setTourismOptions] = useState<any[]>([]);
|
||||
const [deviceOptions, setDeviceOptions] = useState<any[]>([]);
|
||||
const [templateOptions, setTemplateOptions] = useState<any[]>([]);
|
||||
const [tenantOptions, setTenantOptions] = useState<any[]>([]);
|
||||
const formRef = useRef();
|
||||
|
||||
// 将 renderStatus 函数移到组件内部
|
||||
@@ -243,12 +244,32 @@ const TableList: React.FC = () => {
|
||||
}
|
||||
}, []);
|
||||
|
||||
const fetchTenantOptions = useCallback(async () => {
|
||||
try {
|
||||
const result = await getTenantList({
|
||||
page: 1,
|
||||
limit: 100,
|
||||
});
|
||||
if (result?.data) {
|
||||
const options = result.data.map((item: any) => ({
|
||||
label: item.clientName || item.clientId,
|
||||
value: item.clientId,
|
||||
info: item,
|
||||
}));
|
||||
setTenantOptions(options);
|
||||
}
|
||||
} catch (error) {
|
||||
message.error('获取应用列表失败');
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
fetchTourismList();
|
||||
fetchWaylineOptions();
|
||||
fetchDeviceList();
|
||||
fetchTemplateOptions();
|
||||
}, [fetchTourismList, fetchWaylineOptions, fetchDeviceList, fetchTemplateOptions]);
|
||||
fetchTenantOptions();
|
||||
}, [fetchTourismList, fetchWaylineOptions, fetchDeviceList, fetchTemplateOptions, fetchTenantOptions]);
|
||||
|
||||
const columns: ProColumns<ORDERS.Qrcode>[] = [
|
||||
{
|
||||
@@ -438,6 +459,16 @@ const TableList: React.FC = () => {
|
||||
1: { text: '是' },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '应用ID',
|
||||
dataIndex: 'tenantId',
|
||||
width: 120,
|
||||
ellipsis: true,
|
||||
render: (_, record) => {
|
||||
const tenant = tenantOptions.find(item => item.value === record.tenantId);
|
||||
return tenant?.label || record.tenantId || '-';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
@@ -506,6 +537,19 @@ const TableList: React.FC = () => {
|
||||
placeholder="请选择是否为测试二维码"
|
||||
options={IS_TEST_OPTIONS}
|
||||
/>
|
||||
<ProFormSelect
|
||||
name="tenantId"
|
||||
label="应用ID"
|
||||
placeholder="请选择应用"
|
||||
options={tenantOptions}
|
||||
fieldProps={{
|
||||
loading: !tenantOptions.length,
|
||||
showSearch: true,
|
||||
filterOption: (input, option) =>
|
||||
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
|
||||
notFoundContent: tenantOptions.length === 0 ? '暂无应用数据' : undefined,
|
||||
}}
|
||||
/>
|
||||
</QueryFilter>
|
||||
<ProTable<ORDERS.Qrcode>
|
||||
rowKey="id"
|
||||
@@ -543,6 +587,7 @@ const TableList: React.FC = () => {
|
||||
fetchDeviceList();
|
||||
fetchTourismList();
|
||||
fetchTemplateOptions();
|
||||
fetchTenantOptions();
|
||||
}
|
||||
}}
|
||||
visible={createModalVisible}
|
||||
@@ -550,6 +595,7 @@ const TableList: React.FC = () => {
|
||||
tourismOptions={tourismOptions}
|
||||
waylineOptions={waylineOptions}
|
||||
deviceOptions={deviceOptions}
|
||||
tenantOptions={tenantOptions}
|
||||
/>
|
||||
<UpdateForm
|
||||
onSubmit={async (values) => {
|
||||
@@ -561,6 +607,7 @@ const TableList: React.FC = () => {
|
||||
fetchDeviceList();
|
||||
fetchTourismList();
|
||||
fetchTemplateOptions();
|
||||
fetchTenantOptions();
|
||||
}
|
||||
if (!visible) {
|
||||
setCurrentRow(undefined);
|
||||
@@ -572,6 +619,7 @@ const TableList: React.FC = () => {
|
||||
tourismOptions={tourismOptions}
|
||||
deviceOptions={deviceOptions}
|
||||
templateOptions={templateOptions}
|
||||
tenantOptions={tenantOptions}
|
||||
/>
|
||||
</PageContainer>
|
||||
);
|
||||
|
||||
+13
-3
@@ -19,6 +19,7 @@ interface UpdateFormProps {
|
||||
onVisibleChange: (visible: boolean) => void;
|
||||
updateModalVisible: boolean;
|
||||
values?: ORDERS.Tourism;
|
||||
tenantOptions?: any[];
|
||||
}
|
||||
|
||||
const UpdateForm: React.FC<UpdateFormProps> = ({
|
||||
@@ -26,6 +27,7 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
|
||||
onVisibleChange,
|
||||
updateModalVisible,
|
||||
values,
|
||||
tenantOptions = [],
|
||||
}) => {
|
||||
// 表单字段验证规则
|
||||
const formRules = {
|
||||
@@ -118,11 +120,19 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
|
||||
</ProForm.Group>
|
||||
|
||||
<ProForm.Group>
|
||||
<ProFormText
|
||||
<ProFormSelect
|
||||
name="tenantId"
|
||||
label="租户ID"
|
||||
label="应用ID"
|
||||
width="md"
|
||||
placeholder="请输入租户ID"
|
||||
options={tenantOptions}
|
||||
placeholder="请选择应用"
|
||||
showSearch
|
||||
fieldProps={{
|
||||
loading: !tenantOptions.length,
|
||||
filterOption: (input, option) =>
|
||||
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
|
||||
notFoundContent: tenantOptions.length === 0 ? '暂无应用数据' : undefined,
|
||||
}}
|
||||
/>
|
||||
</ProForm.Group>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import UpdateForm from '@/pages/orders/Tourism/components/UpdateForm';
|
||||
import { tourism, saveOrUpdateTourism, deleteTourism } from '@/services/orders/api';
|
||||
import { tourism, saveOrUpdateTourism, deleteTourism, getTenantList } from '@/services/orders/api';
|
||||
import { PlusOutlined } from '@ant-design/icons';
|
||||
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
||||
import {
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
ProFormDigit,
|
||||
} from '@ant-design/pro-components';
|
||||
import { Typography, message, Popconfirm, Button, Space, Tag } from 'antd';
|
||||
import React, { useRef, useState, useCallback } from 'react';
|
||||
import React, { useRef, useState, useCallback, useEffect } from 'react';
|
||||
|
||||
const { Link } = Typography;
|
||||
|
||||
@@ -59,6 +59,7 @@ const TableList: React.FC = () => {
|
||||
const [createModalVisible, setCreateModalVisible] = useState<boolean>(false);
|
||||
const [updateModalVisible, setUpdateModalVisible] = useState<boolean>(false);
|
||||
const [currentRow, setCurrentRow] = useState<ORDERS.Tourism>();
|
||||
const [tenantOptions, setTenantOptions] = useState<any[]>([]);
|
||||
|
||||
// 表格操作处理
|
||||
const handleTableAction = useCallback(async (
|
||||
@@ -105,6 +106,31 @@ const TableList: React.FC = () => {
|
||||
}
|
||||
}, []);
|
||||
|
||||
// 获取应用列表
|
||||
const fetchTenantOptions = useCallback(async () => {
|
||||
try {
|
||||
const result = await getTenantList({
|
||||
page: 1,
|
||||
limit: 100,
|
||||
});
|
||||
if (result?.data) {
|
||||
const options = result.data.map((item: any) => ({
|
||||
label: item.clientName || item.clientId,
|
||||
value: item.clientId,
|
||||
info: item,
|
||||
}));
|
||||
setTenantOptions(options);
|
||||
}
|
||||
} catch (error) {
|
||||
message.error('获取应用列表失败');
|
||||
}
|
||||
}, []);
|
||||
|
||||
// 组件加载时获取应用列表
|
||||
useEffect(() => {
|
||||
fetchTenantOptions();
|
||||
}, [fetchTenantOptions]);
|
||||
|
||||
// 表格列定义
|
||||
const columns: ProColumns<ORDERS.Tourism>[] = [
|
||||
{
|
||||
@@ -160,10 +186,14 @@ const TableList: React.FC = () => {
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '租户ID',
|
||||
title: '应用ID',
|
||||
dataIndex: 'tenantId',
|
||||
copyable: true,
|
||||
hideInSearch: true,
|
||||
render: (_, record) => {
|
||||
const tenant = tenantOptions.find(item => item.value === record.tenantId);
|
||||
return tenant?.label || record.tenantId || '-';
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
@@ -320,11 +350,19 @@ const TableList: React.FC = () => {
|
||||
</ProForm.Group>
|
||||
|
||||
<ProForm.Group>
|
||||
<ProFormText
|
||||
<ProFormSelect
|
||||
name="tenantId"
|
||||
label="租户ID"
|
||||
label="应用ID"
|
||||
width="md"
|
||||
placeholder="请输入租户ID(可选,不填将自动获取当前租户)"
|
||||
options={tenantOptions}
|
||||
placeholder="请选择应用(可选,不填将自动获取当前应用)"
|
||||
showSearch
|
||||
fieldProps={{
|
||||
loading: !tenantOptions.length,
|
||||
filterOption: (input, option) =>
|
||||
(option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
|
||||
notFoundContent: tenantOptions.length === 0 ? '暂无应用数据' : undefined,
|
||||
}}
|
||||
/>
|
||||
</ProForm.Group>
|
||||
|
||||
@@ -349,6 +387,7 @@ const TableList: React.FC = () => {
|
||||
onVisibleChange={setUpdateModalVisible}
|
||||
updateModalVisible={updateModalVisible}
|
||||
values={currentRow}
|
||||
tenantOptions={tenantOptions}
|
||||
/>
|
||||
</PageContainer>
|
||||
);
|
||||
|
||||
@@ -452,4 +452,15 @@ export async function generateEditTask(orderNo: string) {
|
||||
method: 'POST',
|
||||
params: { orderNo },
|
||||
});
|
||||
}
|
||||
|
||||
// 获取应用列表(作为租户列表)
|
||||
export async function getTenantList(params: {
|
||||
page: number;
|
||||
limit: number;
|
||||
[key: string]: any;
|
||||
}) {
|
||||
return request('/api-uaa/clients/all', {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
@@ -148,8 +148,6 @@ declare namespace ORDERS {
|
||||
completionRate: number;
|
||||
// 对账相关字段
|
||||
totalAmount: number; // 订单总金额(分)
|
||||
platformAmount: number; // 平台分账金额(分)
|
||||
tourismAmount: number; // 景区分账金额(分)
|
||||
refundAmount: number; // 退款金额(分)
|
||||
netIncome: number; // 净收入(分)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user