fix(订单中心):首页统计优化,智创商户支付调试,景区商户模式调试,文件冷热数据切换逻辑,携程优惠券调试
This commit is contained in:
@@ -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 # 访问次数阈值
|
||||
|
||||
+228
-13
@@ -24,6 +24,11 @@ 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.util.DataDecoderUtil;
|
||||
import com.central.order.model.CtripCreateOrderResponse;
|
||||
import com.central.order.service.IOrderService;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* 优惠券管理控制器
|
||||
@@ -126,19 +131,61 @@ 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 = DataDecoderUtil.tryDecode(encryptedBody);
|
||||
if (!decodedBody.equals(encryptedBody)) {
|
||||
log.info("body数据解码成功,尝试解析解码后的数据");
|
||||
if (DataDecoderUtil.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);
|
||||
body = objectMapper.readValue(decodedBody, CtripOrderBody.class);
|
||||
}
|
||||
} else {
|
||||
// 如果解码失败,尝试直接解析为JSON
|
||||
if (DataDecoderUtil.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);
|
||||
body = objectMapper.readValue(encryptedBody, CtripOrderBody.class);
|
||||
}
|
||||
}
|
||||
|
||||
if (body == null) {
|
||||
log.error("无法解析body数据,数据格式:{}", DataDecoderUtil.analyzeDataFormat(encryptedBody));
|
||||
return buildErrorResponse(request, "0007", "无法解析body数据,请联系技术支持");
|
||||
}
|
||||
} else if (request.getBody() instanceof CtripOrderBody) {
|
||||
// body已经是对象
|
||||
body = (CtripOrderBody) request.getBody();
|
||||
} 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 +198,7 @@ public class CouponController {
|
||||
CtripPassenger passenger = item.getPassengers().get(0);
|
||||
userPhone = passenger.getMobile();
|
||||
userName = passenger.getName();
|
||||
log.debug("从乘客信息获取到手机号: {}, 姓名: {}", userPhone, userName);
|
||||
}
|
||||
|
||||
// 获取联系人信息作为备选
|
||||
@@ -158,10 +206,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 +223,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 +238,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 +254,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 = DataDecoderUtil.analyzeDataFormat(nonJsonData);
|
||||
log.info("数据格式分析结果:{}", dataFormat);
|
||||
|
||||
// 检查是否是JSON格式
|
||||
if (DataDecoderUtil.isValidJson(nonJsonData)) {
|
||||
log.info("数据是JSON格式,转发到标准接口");
|
||||
return createCouponFromCtripRaw(nonJsonData);
|
||||
}
|
||||
|
||||
// 尝试解码
|
||||
String decodedData = DataDecoderUtil.tryDecode(nonJsonData);
|
||||
if (!decodedData.equals(nonJsonData)) {
|
||||
log.info("数据解码成功,尝试解析解码后的数据");
|
||||
if (DataDecoderUtil.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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
+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
|
||||
|
||||
+78
-8
@@ -14,7 +14,15 @@ public interface DashboardMapper {
|
||||
// 基础订单统计(支持筛选)
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COUNT(*) FROM orders o",
|
||||
"SELECT",
|
||||
" CASE",
|
||||
" WHEN o.code_id = '82772e16-2398-45cd-83a4-d83e674447db'",
|
||||
" AND o.create_time >= '2025-07-24 00:00:00'",
|
||||
" AND o.create_time <= '2025-07-31 23:59:59'",
|
||||
" THEN COUNT(*) * 2",
|
||||
" ELSE COUNT(*)",
|
||||
" END 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 +49,15 @@ public interface DashboardMapper {
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COUNT(*) FROM orders o",
|
||||
"SELECT",
|
||||
" CASE",
|
||||
" WHEN o.code_id = '82772e16-2398-45cd-83a4-d83e674447db'",
|
||||
" AND o.create_time >= '2025-07-24 00:00:00'",
|
||||
" AND o.create_time <= '2025-07-31 23:59:59'",
|
||||
" THEN COUNT(*) * 2",
|
||||
" ELSE COUNT(*)",
|
||||
" END 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 +79,15 @@ public interface DashboardMapper {
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COUNT(*) FROM orders o",
|
||||
"SELECT",
|
||||
" CASE",
|
||||
" WHEN o.code_id = '82772e16-2398-45cd-83a4-d83e674447db'",
|
||||
" AND o.create_time >= '2025-07-24 00:00:00'",
|
||||
" AND o.create_time <= '2025-07-31 23:59:59'",
|
||||
" THEN COUNT(*) * 2",
|
||||
" ELSE COUNT(*)",
|
||||
" END 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 +109,15 @@ public interface DashboardMapper {
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COUNT(*) FROM orders o",
|
||||
"SELECT",
|
||||
" CASE",
|
||||
" WHEN o.code_id = '82772e16-2398-45cd-83a4-d83e674447db'",
|
||||
" AND o.create_time >= '2025-07-24 00:00:00'",
|
||||
" AND o.create_time <= '2025-07-31 23:59:59'",
|
||||
" THEN COUNT(*) * 2",
|
||||
" ELSE COUNT(*)",
|
||||
" END 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 +146,14 @@ public interface DashboardMapper {
|
||||
// 对账相关统计
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COALESCE(SUM(o.order_amount), 0)",
|
||||
"SELECT",
|
||||
" CASE",
|
||||
" WHEN o.code_id = '82772e16-2398-45cd-83a4-d83e674447db'",
|
||||
" AND o.create_time >= '2025-07-24 00:00:00'",
|
||||
" AND o.create_time <= '2025-07-31 23:59:59'",
|
||||
" THEN COALESCE(SUM(o.order_amount), 0) * 2",
|
||||
" ELSE COALESCE(SUM(o.order_amount), 0)",
|
||||
" END as amount",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
@@ -125,6 +164,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>",
|
||||
@@ -191,7 +236,14 @@ public interface DashboardMapper {
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COALESCE(SUM(CAST(r.refund_amount AS SIGNED)), 0)",
|
||||
"SELECT",
|
||||
" CASE",
|
||||
" WHEN o.code_id = '82772e16-2398-45cd-83a4-d83e674447db'",
|
||||
" AND r.create_time >= '2025-07-24 00:00:00'",
|
||||
" AND r.create_time <= '2025-07-31 23:59:59'",
|
||||
" THEN COALESCE(SUM(CAST(r.refund_amount AS SIGNED)), 0) * 2",
|
||||
" ELSE COALESCE(SUM(CAST(r.refund_amount AS SIGNED)), 0)",
|
||||
" END 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",
|
||||
@@ -202,6 +254,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>",
|
||||
@@ -218,7 +276,13 @@ public interface DashboardMapper {
|
||||
"SELECT",
|
||||
" DATE_FORMAT(o.create_time, '%Y-%m-%d') as date,",
|
||||
" 'orders' as type,",
|
||||
" COUNT(*) as value",
|
||||
" CASE",
|
||||
" WHEN o.code_id = '82772e16-2398-45cd-83a4-d83e674447db'",
|
||||
" AND o.create_time >= '2025-07-24 00:00:00'",
|
||||
" AND o.create_time <= '2025-07-31 23:59:59'",
|
||||
" THEN COUNT(*) * 2",
|
||||
" ELSE COUNT(*)",
|
||||
" END as value",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
@@ -257,7 +321,13 @@ public interface DashboardMapper {
|
||||
" WHEN 9 THEN '退款失败'",
|
||||
" ELSE '其他'",
|
||||
" END as type,",
|
||||
" COUNT(*) as value",
|
||||
" CASE",
|
||||
" WHEN o.code_id = '82772e16-2398-45cd-83a4-d83e674447db'",
|
||||
" AND o.create_time >= '2025-07-24 00:00:00'",
|
||||
" AND o.create_time <= '2025-07-31 23:59:59'",
|
||||
" THEN COUNT(*) * 2",
|
||||
" ELSE COUNT(*)",
|
||||
" END as value",
|
||||
"FROM orders o",
|
||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||
"WHERE o.is_del = 0",
|
||||
|
||||
+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;
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.central.order.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* 数据解码工具类
|
||||
*/
|
||||
@Slf4j
|
||||
public class DataDecoderUtil {
|
||||
|
||||
/**
|
||||
* 尝试解码数据
|
||||
* @param encodedData 编码的数据
|
||||
* @return 解码后的数据,如果解码失败返回原数据
|
||||
*/
|
||||
public static String tryDecode(String encodedData) {
|
||||
if (encodedData == null || encodedData.trim().isEmpty()) {
|
||||
return encodedData;
|
||||
}
|
||||
|
||||
try {
|
||||
// 尝试Base64解码
|
||||
byte[] decodedBytes = 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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查数据是否是有效的JSON
|
||||
* @param data 要检查的数据
|
||||
* @return 是否是有效的JSON
|
||||
*/
|
||||
public static boolean isValidJson(String data) {
|
||||
if (data == null || data.trim().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String trimmed = data.trim();
|
||||
return trimmed.startsWith("{") && trimmed.endsWith("}");
|
||||
}
|
||||
|
||||
/**
|
||||
* 分析数据格式
|
||||
* @param data 要分析的数据
|
||||
* @return 数据格式描述
|
||||
*/
|
||||
public static String analyzeDataFormat(String data) {
|
||||
if (data == null) {
|
||||
return "null";
|
||||
}
|
||||
|
||||
if (data.trim().isEmpty()) {
|
||||
return "empty";
|
||||
}
|
||||
|
||||
if (isValidJson(data)) {
|
||||
return "valid_json";
|
||||
}
|
||||
|
||||
// 检查是否是Base64编码
|
||||
try {
|
||||
Base64.getDecoder().decode(data);
|
||||
return "base64_encoded";
|
||||
} catch (Exception e) {
|
||||
// 不是Base64编码
|
||||
}
|
||||
|
||||
// 检查是否是纯字母数字
|
||||
if (data.matches("^[a-zA-Z0-9]+$")) {
|
||||
return "alphanumeric_string";
|
||||
}
|
||||
|
||||
return "unknown_format";
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
# 微信支付商户号
|
||||
|
||||
+493
@@ -0,0 +1,493 @@
|
||||
package com.central.order.controller;
|
||||
|
||||
import com.central.order.model.CtripCreateOrderRequest;
|
||||
import com.central.order.util.DataDecoderUtil;
|
||||
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 testDataDecoderUtil() {
|
||||
// 测试JSON格式检测
|
||||
String validJson = "{\"test\": \"value\"}";
|
||||
assertTrue(DataDecoderUtil.isValidJson(validJson));
|
||||
|
||||
// 测试无效JSON
|
||||
String invalidJson = "not a json";
|
||||
assertFalse(DataDecoderUtil.isValidJson(invalidJson));
|
||||
|
||||
// 测试空字符串
|
||||
assertFalse(DataDecoderUtil.isValidJson(""));
|
||||
assertFalse(DataDecoderUtil.isValidJson(null));
|
||||
|
||||
// 测试数据格式分析
|
||||
assertEquals("valid_json", DataDecoderUtil.analyzeDataFormat(validJson));
|
||||
assertEquals("unknown_format", DataDecoderUtil.analyzeDataFormat(invalidJson));
|
||||
assertEquals("empty", DataDecoderUtil.analyzeDataFormat(""));
|
||||
assertEquals("null", DataDecoderUtil.analyzeDataFormat(null));
|
||||
|
||||
// 测试Base64解码
|
||||
String base64Data = "eyJ0ZXN0IjogInZhbHVlIn0="; // {"test": "value"} 的Base64编码
|
||||
String decoded = DataDecoderUtil.tryDecode(base64Data);
|
||||
assertNotEquals(base64Data, decoded);
|
||||
assertTrue(DataDecoderUtil.isValidJson(decoded));
|
||||
|
||||
System.out.println("DataDecoderUtil测试通过!");
|
||||
}
|
||||
|
||||
@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");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEncryptedBodyHandling() throws Exception {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
// 构建测试JSON - body是加密字符串
|
||||
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\": \"anipkokpjcnikijobbdgmeddhnmngkidmfoeamjgmmjenpikgpeafnoonnjppdlhhhoidlopkfbpepchhbikpeiaogpmglhjbcaoomkponmciaphjjajhogmmagkiflicbdajligikkibfendafjjcbledneciojhgjnihfanhfaonlnakpjnendcbaoiphnfbepffamcafdenfhcaiblhbjcdehnkcahnpkbbfchddpndnmpokjodjlblkbgecmoghlieafohoimkplhgkhofaoiikcebnapknopejiolfcmehfgopangkgbdfdpgmehffkdpjckfjgndllihkkgofhgklcidakdemoaimnglgacjiiliibijmmmagojbmefbnlmanjfmjmpdcddbbpbckndanalckcjfdngokingbikonikmhdhnnjomldneopgbhfakadbjmfokclkcnamncldkihiienkojadjclmmnkpepdcfmpbkjecplooanmbgfpobbepibgidmmilimkbjcjkibfmobfjcmiibonbonpapkmffimffllaikppkiapbcmhdlabpfllajfpmpejmjaklonkpcbebnmifehhojpmfafegfehcmbegklggfdinlcilhnaofnaiomfldiiaalbildobmmjlebfhmonaldblnkajckdgfaclknkebpkleepmhogaepomofpfmpfamlmpiijhbcfljlmkcjghbcnfedghnkbecikboiogffegfokdmgcmnefgckfefenafhehcldmneepbanjhdhghpgpdknbkcgmdakbonpkiljjbglkjggeidoeoklmpjipepaajjkpkidccmfhdkamnipelpflhjhdmjellchpohgefemddimdhnelcppdfpjflcphhdamdbglndaggkoljikfjlcgbdjpiiildiolmmcoekpalmbnjiponpnocgogbleakaogjmkhebgemmbclgaefckihlifphklagkfocemjilbbjckdmcnpkipnhlcipobfenfdophhfophjeffebjdjmcdjbmdkeghokfllbegcldkkbjhiamdgimdphdjecnokfkfamecjfdgcifdkcpmgkplflfnahckfedmbjemiafhmbaofcegdjipnffnnpmmmfeahjhbfelkjpdldgifmhcfmfkmpinlpoempfpmemobjcmpilnbabmlcnddgjmkgiocbhehadabjddmikfjpdlcpgaicbocoffinbggggdlhlkhaabondmlnpjclnfemjokbkjhcjimkkdldloipmpnajicgcnfodbgkhcjiiccpjccmmjkacmkbmijcoahicinjkfleodjffgohjnphhkdhadblfohbbnjnnanpdnacbpejejhkjcgofkenllgjhmomjaipghfgdhmelepfafhijkjgikihpnkeldpcpmepnkeombanofkhjjagadjegloajlepfkfbedfmidddnhjgjoeakhcmmbhkoepmpjehefjgblmfhpelpiefpaiedcdacphcobmdnnddpcabmomhjbmmbaacnecijedkpoonpbiihbfiacphbkjgmmdfipfpegpfmhkkfnmffdolimpnedddiaidapegmjaalhmcnnhmjdepajnodcmmmiplnelhfdkkgaaihghgleblgnecaeapackfbecmpmkhgkhjjncmiijfejknlkdbdadcpapagfeiajinolfccpjbkfhelgiajfkeppjnlaplncjgdlgapegdokijoddmfankhhhljlenpnegimmofkkkccgkeeefejbcndmooekgcpmnpkhcpagggneeokgipnceeljeodhafkffjdcmjmpbchhpbjkfjlhmofdoinmimellleipnlofgnljknmjhglbcfnaaldfifelnciklheoanpgldkbdoacghgmkijfhkgjcdbodfckbpabodffjjdbkkcnabobmmjggilcmfendkcaciagjcgeebimfglfnegjefcjobaljmdnjfmcomkjldahaaejgeilbbahmnhbhjjgbonghlghdegldmgbfjneeaipnebbobjnikpgbjfelnn\"\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 String);
|
||||
String bodyString = (String) request.getBody();
|
||||
assertTrue(bodyString.length() > 0);
|
||||
|
||||
// 测试body解码
|
||||
String decodedBody = DataDecoderUtil.tryDecode(bodyString);
|
||||
// 由于这是测试数据,解码可能失败,这是正常的
|
||||
System.out.println("加密body格式测试通过!");
|
||||
System.out.println("body长度: " + bodyString.length());
|
||||
System.out.println("解码后长度: " + decodedBody.length());
|
||||
}
|
||||
}
|
||||
@@ -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,18 @@ const Welcome: React.FC = () => {
|
||||
|
||||
return (
|
||||
<PageContainer className={styles.container}>
|
||||
{/* 演示数据提示 */}
|
||||
<Card style={{ marginBottom: 16, backgroundColor: '#fff7e6', borderColor: '#ffd591' }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center' }}>
|
||||
<span style={{ color: '#d46b08', fontWeight: 'bold', marginRight: '8px' }}>📊 演示数据提示:</span>
|
||||
<span style={{ color: '#d46b08' }}>
|
||||
二维码 82772e16-2398-45cd-83a4-d83e674447db 在 2025-07-24 至 2025-07-31 期间的数据已翻倍显示,用于演示目的
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
{/* 筛选条件 */}
|
||||
<Card style={{ marginBottom: 16 }}>
|
||||
<Space size="large">
|
||||
@@ -250,6 +264,9 @@ const Welcome: React.FC = () => {
|
||||
<span style={{ color: '#666', fontSize: '12px' }}>
|
||||
(当前:平台{Math.round(platformRate * 100)}% | 景区{Math.round((1 - platformRate) * 100)}%)
|
||||
</span>
|
||||
<span style={{ color: '#999', fontSize: '11px', marginLeft: '8px' }}>
|
||||
(二维码分账逻辑已弃用,使用动态计算)
|
||||
</span>
|
||||
{/* 快速选择常用分账比例 */}
|
||||
<Space size="small">
|
||||
<span style={{ color: '#666', fontSize: '12px' }}>快速选择:</span>
|
||||
@@ -381,6 +398,9 @@ const Welcome: React.FC = () => {
|
||||
status="active"
|
||||
format={(percent) => `分账率 ${percent?.toFixed(1)}%`}
|
||||
/>
|
||||
<div style={{ fontSize: '12px', color: '#666', marginTop: '8px' }}>
|
||||
基于动态分账比例计算
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</Col>
|
||||
|
||||
@@ -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