refactor: 抽离企业级微服务脚手架
- 删除业务特定模块(device-center, order-center, coupon-center, msg-center) - 保留核心通用模块(user-center, file-center, search-center, code-generator) - 创建 demo-center 示例模块 - 清理业务特定文档和前端项目 - 创建数据库初始化脚本 - 更新 README 和快速开始文档 - 保留所有 zlt-commons 公共组件库
This commit is contained in:
@@ -80,7 +80,8 @@
|
|||||||
"Bash(pip install:*)",
|
"Bash(pip install:*)",
|
||||||
"Bash(python3:*)",
|
"Bash(python3:*)",
|
||||||
"Bash(npx:*)",
|
"Bash(npx:*)",
|
||||||
"Bash(xargs head:*)"
|
"Bash(xargs head:*)",
|
||||||
|
"Bash(rm:*)"
|
||||||
],
|
],
|
||||||
"deny": [],
|
"deny": [],
|
||||||
"ask": []
|
"ask": []
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
# 仓库指南(Repository Guidelines)
|
|
||||||
|
|
||||||
## 语言与注释规范(Agent 专用)
|
|
||||||
- 所有交互回答必须使用中文(简体),包括解释、建议与错误信息。
|
|
||||||
- 代码片段中的注释、日志消息、文档内容与示例说明均应为中文;编程语言关键字与三方 API 标识符保持原文。
|
|
||||||
- 提交信息(commit)、合并请求(PR)描述与 Issue 标题/内容默认使用中文;涉及外部专有名词可保留英文缩写。
|
|
||||||
- 所有中文都使用utf-8
|
|
||||||
|
|
||||||
## 权限与执行策略
|
|
||||||
- 默认权限:Codex 在本仓库内可直接读取与编辑文件,无需额外审批。
|
|
||||||
- 命令执行:在具备网络访问权限时,可直接执行包含网络的命令(如依赖下载、API 请求、构建/测试脚本)。
|
|
||||||
- 安全边界:遵循最小影响原则,避免破坏性操作(如强制删除、重置历史、批量改名)。如确需此类操作,请在回复中明确风险与范围,并征得用户同意。
|
|
||||||
- 可追溯性:在回复或提交说明中简要标注关键命令、影响模块与文件路径,便于审计。
|
|
||||||
- Git 操作限制:除非用户明确要求,否则不要执行任何 Git 相关操作(包括但不限于 `commit`、`push`、`pull`、`merge`、`rebase`、`tag`、`branch`、`reset` 等)。如需读取 Git 元数据(如 `git log`、`git status`),也需先获得用户确认。
|
|
||||||
|
|
||||||
## 项目结构与模块组织
|
|
||||||
- 父聚合工程:`pom.xml`(Java 17,Spring Boot 3.1,Spring Cloud 2022)。
|
|
||||||
- 核心模块:
|
|
||||||
- `zlt-commons`(公共 starter、工具)
|
|
||||||
- `zlt-uaa`(认证),`zlt-gateway/sc-gateway`(API 网关)
|
|
||||||
- `zlt-business/*`(业务服务:用户/文件/订单等)
|
|
||||||
- `zlt-monitor/sc-admin`(监控),`zlt-config`(配置),`zlt-web/*`(前端)
|
|
||||||
- 标准目录:`src/main/java`、`src/main/resources`,单测放在 `src/test/java`。
|
|
||||||
|
|
||||||
## 构建、测试与本地运行
|
|
||||||
- 全量构建:`mvn -q -DskipTests clean package`
|
|
||||||
- 全量测试:`mvn -q test`
|
|
||||||
- 指定模块构建+测试:`mvn -pl zlt-business/user-center -am clean verify`
|
|
||||||
- 本地运行示例:
|
|
||||||
- 网关:`mvn -pl zlt-gateway/sc-gateway -am spring-boot:run`
|
|
||||||
- 认证:`mvn -pl zlt-uaa -am spring-boot:run`
|
|
||||||
- 从 JAR 运行:`java -jar zlt-gateway/sc-gateway/target/*.jar`
|
|
||||||
先决条件:JDK 17、Maven 3.8+。
|
|
||||||
|
|
||||||
## 编码风格与命名约定
|
|
||||||
- Java 使用 4 空格缩进、UTF-8、同一行左大括号。
|
|
||||||
- 包名使用 `com.central.*`;模块名称以 `zlt-*` 为前缀。
|
|
||||||
- 已使用处优先采用 Lombok 注解(如 `@Data`、`@Slf4j`)。
|
|
||||||
- 方法/字段使用 lowerCamelCase;类名使用 PascalCase。
|
|
||||||
|
|
||||||
## 测试规范
|
|
||||||
- 测试框架:JUnit 4 与 JUnit 5(按模块而定)。
|
|
||||||
- 用例命名以 `*Test.java` 结尾,放在 `src/test/java`。
|
|
||||||
- 为新增逻辑与关键路径补充单测;保持可重复、相互独立。
|
|
||||||
- 提 PR 前执行:`mvn -pl <module> -am test`。
|
|
||||||
|
|
||||||
## 提交与合并请求规范
|
|
||||||
- 采用约定式提交:`type(scope): 简要说明`,示例:`fix(订单中心): 修复事件处理逻辑`。
|
|
||||||
- 常见类型:`feat`、`fix`、`docs`、`refactor`、`test`、`chore`。
|
|
||||||
- 小步且描述清晰;必要时关联 Issue。
|
|
||||||
- PR 需包含:目的/影响、涉及模块、测试说明;前端改动请附截图(`zlt-web/*`)。
|
|
||||||
|
|
||||||
## 安全与配置提示
|
|
||||||
- 多模块使用 Nacos。请在本地提供 `spring.cloud.nacos.server-addr`,或在 `bootstrap.yml` 注释相关配置以单机运行。
|
|
||||||
- 外部依赖常见:MySQL/Redis/Elasticsearch。按模块检查 `application.yml` 的端口/连接串。
|
|
||||||
- 禁止提交密钥与凭据;使用环境变量或本地覆盖配置。
|
|
||||||
@@ -1,94 +1,104 @@
|
|||||||
# Go-Fly Platform Services - AI开发团队配置
|
# Central Platform - 企业级微服务脚手架 AI 开发指南
|
||||||
|
|
||||||
## 项目概述
|
## 项目概述
|
||||||
**项目类型**: 企业级Spring Cloud微服务平台
|
**项目类型**: 企业级Spring Cloud微服务脚手架
|
||||||
**主要业务**: 旅游景区管理 + IoT设备控制 + 支付分润系统
|
**主要功能**: 用户权限管理 + 文件存储 + 全文搜索 + 微服务基础设施
|
||||||
**技术栈**: Java 17 + Spring Cloud + React + MySQL + Redis + Elasticsearch
|
**技术栈**: Java 17 + Spring Cloud + React + MySQL + Redis + Elasticsearch
|
||||||
**复杂度**: Enterprise级 (8+专业领域)
|
**定位**: 通用后台管理系统脚手架
|
||||||
|
|
||||||
## 专属AI代理团队
|
## 核心模块
|
||||||
|
|
||||||
### 🏗️ 架构与基础设施层
|
### 🏗️ 基础设施层
|
||||||
- **spring-cloud-microservice-architect** (opus) - 微服务架构设计与优化专家
|
- **API网关** - Spring Cloud Gateway + Sentinel 限流熔断
|
||||||
- **mysql-data-architect** (sonnet) - MySQL数据库架构与MyBatis Plus优化专家
|
- **认证中心** - OAuth2 + JWT + Spring Security
|
||||||
- **file-storage-specialist** (sonnet) - 多云存储与CDN集成专家
|
- **配置中心** - Nacos Config 集中配置管理
|
||||||
|
- **监控中心** - Spring Boot Admin 应用监控
|
||||||
|
|
||||||
### 🎯 业务领域专家层
|
### 📦 公共组件库
|
||||||
- **tourism-business-specialist** (sonnet) - 旅游行业业务逻辑与景区管理专家
|
- **通用工具** - 核心工具类、通用配置
|
||||||
- **iot-device-integration-specialist** (sonnet) - IoT设备管理与大疆无人机集成专家
|
- **数据库集成** - MyBatis Plus + 多数据源
|
||||||
- **payment-system-specialist** (opus) - 微信支付服务商模式与分润系统专家
|
- **缓存集成** - Redis + Redisson 分布式锁
|
||||||
|
- **日志集成** - 集中式日志收集
|
||||||
|
- **搜索集成** - Elasticsearch 全文搜索
|
||||||
|
- **存储集成** - 多云对象存储(OSS、MinIO)
|
||||||
|
|
||||||
### 💻 前端与质量保障层
|
### 💼 业务模块
|
||||||
- **react-dashboard-developer** (sonnet) - React + Ant Design Pro仪表板开发专家
|
- **用户中心** - 用户、角色、权限、租户管理
|
||||||
- **platform-testing-specialist** (sonnet) - 微服务平台综合测试策略专家
|
- **文件中心** - 文件上传下载、多云存储
|
||||||
|
- **搜索中心** - 全文搜索服务
|
||||||
## 团队协作策略
|
- **代码生成器** - 基于数据库表的代码生成
|
||||||
|
|
||||||
### 🚀 智能任务分发规则
|
|
||||||
**Level 1-2 任务**: 直接调用对应专业代理
|
|
||||||
**Level 3-4 任务**: 根据依赖关系串行或并行调用
|
|
||||||
**Level 5 任务**: 由task-dispatch-director协调分发
|
|
||||||
|
|
||||||
### ⚡ 关键协作流程
|
|
||||||
1. **架构设计**: cto → spring-cloud-microservice-architect → mysql-data-architect
|
|
||||||
2. **业务开发**: 业务专家并行 → react-dashboard-developer → platform-testing-specialist
|
|
||||||
3. **集成测试**: 所有专家 → platform-testing-specialist → devops-engineer
|
|
||||||
|
|
||||||
### 🔧 依赖管理
|
|
||||||
- **高依赖**: 架构 → 数据 → 业务 (必须串行)
|
|
||||||
- **中等依赖**: 支付 ↔ 旅游, 设备 → 文件存储 (混合执行)
|
|
||||||
- **零依赖**: React组件 + 测试编写 (完全并行)
|
|
||||||
|
|
||||||
## 开发工作流
|
## 开发工作流
|
||||||
|
|
||||||
### 🎯 新功能开发
|
### 🎯 新功能开发
|
||||||
```bash
|
```bash
|
||||||
# 示例: 景区门票预订功能
|
# 示例: 添加新的业务模块
|
||||||
/ai "开发景区门票在线预订和支付功能"
|
参考 demo-center 示例模块创建新的业务服务
|
||||||
→ tourism-business-specialist (业务逻辑)
|
1. 创建模块目录结构
|
||||||
→ payment-system-specialist (支付集成)
|
2. 配置 pom.xml 依赖
|
||||||
→ react-dashboard-developer (管理界面)
|
3. 实现业务逻辑
|
||||||
→ platform-testing-specialist (端到端测试)
|
4. 注册到 Nacos
|
||||||
```
|
```
|
||||||
|
|
||||||
### 🔧 系统优化
|
### 🔧 系统优化
|
||||||
```bash
|
```bash
|
||||||
# 示例: 微服务性能优化
|
# 示例: 微服务性能优化
|
||||||
/ai "优化微服务间通信性能和数据库查询效率"
|
1. 分析服务调用链路
|
||||||
→ spring-cloud-microservice-architect (服务优化)
|
2. 优化数据库查询
|
||||||
→ mysql-data-architect (查询优化)
|
3. 添加缓存策略
|
||||||
→ platform-testing-specialist (性能测试)
|
4. 配置限流规则
|
||||||
```
|
```
|
||||||
|
|
||||||
### 🚨 问题排查
|
### 🚨 问题排查
|
||||||
```bash
|
```bash
|
||||||
# 示例: 支付异常排查
|
# 示例: 服务异常排查
|
||||||
/ai "排查订单支付失败和分润异常问题"
|
1. 查看 Nacos 服务注册状态
|
||||||
→ payment-system-specialist (支付逻辑检查)
|
2. 检查日志中心日志
|
||||||
→ mysql-data-architect (数据一致性验证)
|
3. 查看监控中心指标
|
||||||
→ platform-testing-specialist (问题复现测试)
|
4. 验证配置中心配置
|
||||||
```
|
```
|
||||||
|
|
||||||
## 技术规范
|
## 技术规范
|
||||||
|
|
||||||
### 📋 开发标准
|
### 📋 开发标准
|
||||||
- **后端**: Spring Boot 3.1.6 + MyBatis Plus 3.5.4 + Java 17
|
- **后端**: Spring Boot 3.1.6 + MyBatis Plus 3.5.4 + Java 17
|
||||||
- **前端**: React 17 + Ant Design 4.20 + UmiJS 3.5 + TypeScript
|
- **前端**: React 17 + Ant Design 4.20 + UmiJS 3.5
|
||||||
- **数据库**: MySQL 8.0 + Redis 7.0 + Elasticsearch 7.13
|
- **数据库**: MySQL 8.0 + Redis 7.0 + Elasticsearch 7.13
|
||||||
- **部署**: Docker + Kubernetes + Spring Cloud Gateway
|
- **部署**: Docker + Kubernetes + Nacos
|
||||||
|
|
||||||
### 🔒 安全要求
|
### 🔒 安全要求
|
||||||
- OAuth2 + JWT认证授权
|
- OAuth2 + JWT 认证授权
|
||||||
- 支付数据加密存储
|
|
||||||
- 多租户数据隔离
|
- 多租户数据隔离
|
||||||
- API访问频率限制
|
- API 访问频率限制
|
||||||
|
- 敏感数据加密存储
|
||||||
|
|
||||||
### 📊 监控指标
|
### 📊 性能指标
|
||||||
- 服务响应时间 < 200ms
|
- 服务响应时间 < 200ms
|
||||||
- 数据库查询优化 (N+1问题避免)
|
- 数据库查询优化(避免 N+1 问题)
|
||||||
- 支付成功率 > 99.9%
|
- 缓存命中率 > 80%
|
||||||
- 设备连接稳定性 > 99%
|
- 服务可用性 > 99.9%
|
||||||
|
|
||||||
|
## 快速开始
|
||||||
|
|
||||||
|
### 环境准备
|
||||||
|
1. JDK 17+
|
||||||
|
2. Maven 3.6+
|
||||||
|
3. MySQL 8.0+
|
||||||
|
4. Redis 7.0+
|
||||||
|
5. Nacos 2.0+
|
||||||
|
|
||||||
|
### 启动步骤
|
||||||
|
1. 初始化数据库: `mysql < zlt-doc/database/init.sql`
|
||||||
|
2. 启动 Nacos
|
||||||
|
3. 启动网关 (9900)
|
||||||
|
4. 启动认证中心 (8000)
|
||||||
|
5. 启动用户中心 (7000)
|
||||||
|
6. 启动文件中心 (5000)
|
||||||
|
|
||||||
|
### 默认账号
|
||||||
|
- 用户名: `admin`
|
||||||
|
- 密码: `admin123`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**🚀 专属AI团队已就绪!使用 `/ai "具体任务描述"` 即可调用专业团队协作完成复杂任务。**
|
**🚀 企业级微服务脚手架,快速构建你的业务系统!**
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
# 贡献指南 (Contributing Guide)
|
|
||||||
|
|
||||||
## 快速开始
|
|
||||||
- Fork 本仓库(GitHub/Gitee),克隆到本地:`git clone <your_fork_url>`。
|
|
||||||
- 目标分支:优先提交到 `develop`(如无则 `master`)。
|
|
||||||
- 创建特性分支:`git checkout -b feature/<简要描述>`(缺陷用 `bugfix/`,文档用 `docs/`)。
|
|
||||||
- 环境要求:JDK 17,Maven 3.8+。
|
|
||||||
|
|
||||||
## 构建与本地运行
|
|
||||||
- 全量构建:`mvn -q -DskipTests clean package`
|
|
||||||
- 全量测试:`mvn -q test`
|
|
||||||
- 指定模块构建+测试:`mvn -pl zlt-business/user-center -am clean verify`
|
|
||||||
- 本地运行示例:
|
|
||||||
- 网关:`mvn -pl zlt-gateway/sc-gateway -am spring-boot:run`
|
|
||||||
- 认证:`mvn -pl zlt-uaa -am spring-boot:run`
|
|
||||||
- 从 JAR 运行:`java -jar zlt-gateway/sc-gateway/target/*.jar`
|
|
||||||
|
|
||||||
## 代码风格
|
|
||||||
- Java:4 空格缩进、UTF-8、左大括号同行。
|
|
||||||
- 包命名:`com.central.*`;模块命名:`zlt-*`。
|
|
||||||
- 项目已使用 Lombok(如 `@Data`、`@Slf4j`),保持一致。
|
|
||||||
|
|
||||||
## 测试要求
|
|
||||||
- 测试框架:JUnit 4/5(按模块而定)。
|
|
||||||
- 测试类放在 `src/test/java`,命名以 `*Test.java` 结尾。
|
|
||||||
- 为新增/变更逻辑补充单测;尽量使用 mock,避免依赖真实外部服务。
|
|
||||||
- 提交前运行:`mvn -pl <module> -am test`,确保通过。
|
|
||||||
|
|
||||||
## 提交规范(Conventional Commits)
|
|
||||||
- 格式:`type(scope): 简要说明`,示例:`fix(订单中心): 修复事件处理逻辑`。
|
|
||||||
- 常用类型:`feat`、`fix`、`docs`、`refactor`、`test`、`chore`。
|
|
||||||
- 正文可描述动机/实现要点;页脚关联问题:`Closes #123`。
|
|
||||||
|
|
||||||
## Pull Request 规范
|
|
||||||
- 内容包含:变更目的与影响、涉及模块、测试方式与结果;前端改动(`zlt-web/*`)请附截图。
|
|
||||||
- 保持 PR 粒度清晰、可审查;避免混入无关格式化改动。
|
|
||||||
- 确保构建与测试通过,冲突已解决。
|
|
||||||
|
|
||||||
## 配置与安全
|
|
||||||
- 多模块使用 Nacos;本地可提供 `spring.cloud.nacos.server-addr`,或在 `bootstrap.yml` 注释相关配置以单机运行。
|
|
||||||
- 常见外部依赖:MySQL/Redis/Elasticsearch。按模块检查 `application.yml`。
|
|
||||||
- 禁止提交密钥、证书与账户;使用环境变量或本地覆盖配置。
|
|
||||||
|
|
||||||
## 问题反馈
|
|
||||||
- 提交 Issue 时请附:期望/实际结果、复现步骤、相关日志与环境信息(模块名、版本、OS、JDK)。
|
|
||||||
+168
@@ -0,0 +1,168 @@
|
|||||||
|
# 快速开始指南
|
||||||
|
|
||||||
|
本指南将帮助你快速搭建和运行 Central Platform 微服务脚手架。
|
||||||
|
|
||||||
|
## 前置准备
|
||||||
|
|
||||||
|
### 1. 安装必要软件
|
||||||
|
|
||||||
|
- **JDK 17**: [下载地址](https://www.oracle.com/java/technologies/downloads/)
|
||||||
|
- **Maven 3.6+**: [下载地址](https://maven.apache.org/download.cgi)
|
||||||
|
- **MySQL 8.0+**: [下载地址](https://dev.mysql.com/downloads/mysql/)
|
||||||
|
- **Redis 7.0+**: [下载地址](https://redis.io/download)
|
||||||
|
- **Nacos 2.0+**: [下载地址](https://github.com/alibaba/nacos/releases)
|
||||||
|
|
||||||
|
### 2. 验证安装
|
||||||
|
|
||||||
|
```bash
|
||||||
|
java -version # 应显示 Java 17
|
||||||
|
mvn -version # 应显示 Maven 3.6+
|
||||||
|
mysql --version # 应显示 MySQL 8.0+
|
||||||
|
redis-server --version # 应显示 Redis 7.0+
|
||||||
|
```
|
||||||
|
|
||||||
|
## 第一步:数据库初始化
|
||||||
|
|
||||||
|
### 1. 创建数据库
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mysql -u root -p
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. 执行初始化脚本
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mysql -u root -p < zlt-doc/database/init.sql
|
||||||
|
```
|
||||||
|
|
||||||
|
脚本会自动创建:
|
||||||
|
- 数据库 `central_platform`
|
||||||
|
- 核心表(用户、角色、菜单等)
|
||||||
|
- 默认管理员账号(admin/admin123)
|
||||||
|
|
||||||
|
## 第二步:启动 Nacos
|
||||||
|
|
||||||
|
### 1. 下载并解压 Nacos
|
||||||
|
|
||||||
|
```bash
|
||||||
|
wget https://github.com/alibaba/nacos/releases/download/2.2.0/nacos-server-2.2.0.tar.gz
|
||||||
|
tar -xvf nacos-server-2.2.0.tar.gz
|
||||||
|
cd nacos
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. 单机模式启动
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Linux/Mac
|
||||||
|
sh bin/startup.sh -m standalone
|
||||||
|
|
||||||
|
# Windows
|
||||||
|
cmd bin/startup.cmd -m standalone
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. 访问控制台
|
||||||
|
|
||||||
|
- 地址: http://localhost:8848/nacos
|
||||||
|
- 账号: nacos
|
||||||
|
- 密码: nacos
|
||||||
|
|
||||||
|
## 第三步:启动 Redis
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Linux/Mac
|
||||||
|
redis-server
|
||||||
|
|
||||||
|
# Windows
|
||||||
|
redis-server.exe
|
||||||
|
```
|
||||||
|
|
||||||
|
## 第四步:编译项目
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd central-platform
|
||||||
|
mvn clean install -DskipTests
|
||||||
|
```
|
||||||
|
|
||||||
|
## 第五步:启动服务
|
||||||
|
|
||||||
|
### 方式一:IDE 启动(推荐开发环境)
|
||||||
|
|
||||||
|
按以下顺序启动:
|
||||||
|
|
||||||
|
1. **网关服务** - `zlt-gateway/sc-gateway/src/main/java/com/central/gateway/GatewayApp.java`
|
||||||
|
2. **认证中心** - `zlt-uaa/src/main/java/com/central/oauth/UaaServerApplication.java`
|
||||||
|
3. **用户中心** - `zlt-business/user-center/src/main/java/com/central/user/UserCenterApplication.java`
|
||||||
|
4. **文件中心** - `zlt-business/file-center/src/main/java/com/central/file/FileCenterApplication.java`
|
||||||
|
|
||||||
|
### 方式二:命令行启动
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 启动网关
|
||||||
|
cd zlt-gateway/sc-gateway
|
||||||
|
mvn spring-boot:run
|
||||||
|
|
||||||
|
# 启动认证中心
|
||||||
|
cd zlt-uaa
|
||||||
|
mvn spring-boot:run
|
||||||
|
|
||||||
|
# 启动用户中心
|
||||||
|
cd zlt-business/user-center
|
||||||
|
mvn spring-boot:run
|
||||||
|
|
||||||
|
# 启动文件中心
|
||||||
|
cd zlt-business/file-center
|
||||||
|
mvn spring-boot:run
|
||||||
|
```
|
||||||
|
|
||||||
|
## 第六步:验证服务
|
||||||
|
|
||||||
|
### 1. 检查 Nacos 服务注册
|
||||||
|
|
||||||
|
访问 http://localhost:8848/nacos,在"服务管理 > 服务列表"中应该看到:
|
||||||
|
- sc-gateway
|
||||||
|
- uaa-server
|
||||||
|
- user-center
|
||||||
|
- file-center
|
||||||
|
|
||||||
|
### 2. 访问 API 文档
|
||||||
|
|
||||||
|
http://localhost:9900/doc.html
|
||||||
|
|
||||||
|
### 3. 测试登录接口
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X POST "http://localhost:9900/api-uaa/oauth/token" \
|
||||||
|
-H "Authorization: Basic d2ViQXBwOndlYkFwcA==" \
|
||||||
|
-d "username=admin&password=admin123&grant_type=password"
|
||||||
|
```
|
||||||
|
|
||||||
|
## 常见问题
|
||||||
|
|
||||||
|
### 1. 端口被占用
|
||||||
|
|
||||||
|
修改各服务的 `application.yml` 中的 `server.port` 配置。
|
||||||
|
|
||||||
|
### 2. Nacos 连接失败
|
||||||
|
|
||||||
|
检查 `bootstrap.yml` 中的 Nacos 地址配置:
|
||||||
|
```yaml
|
||||||
|
spring:
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
server-addr: localhost:8848
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. 数据库连接失败
|
||||||
|
|
||||||
|
检查 Nacos 配置中心的数据库配置。
|
||||||
|
|
||||||
|
## 下一步
|
||||||
|
|
||||||
|
- 查看 [开发指南](./DEVELOPMENT.md)
|
||||||
|
- 了解 [架构设计](./ARCHITECTURE.md)
|
||||||
|
- 参考 [API 文档](http://localhost:9900/doc.html)
|
||||||
|
|
||||||
|
## 获取帮助
|
||||||
|
|
||||||
|
- GitHub Issues: https://github.com/zlt2000/microservices-platform/issues
|
||||||
@@ -1,47 +1,123 @@
|
|||||||
|
# Central Platform - 企业级微服务脚手架
|
||||||
|
|
||||||
|
[](https://www.oracle.com/java/)
|
||||||
|
[](https://spring.io/projects/spring-boot)
|
||||||
|
[](https://spring.io/projects/spring-cloud)
|
||||||
|
[](https://www.apache.org/licenses/LICENSE-2.0)
|
||||||
|
|
||||||
|
## 项目简介
|
||||||
|
|
||||||
|
Central Platform 是一个基于 Spring Cloud 的企业级微服务脚手架,提供完整的微服务基础设施和通用业务模块,帮助快速构建企业级应用。
|
||||||
|
|
||||||
|
### 核心特性
|
||||||
|
|
||||||
|
- ✅ **微服务架构** - 基于 Spring Cloud 2022.0.4
|
||||||
|
- ✅ **服务治理** - Nacos 服务注册发现与配置中心
|
||||||
|
- ✅ **API 网关** - Spring Cloud Gateway + Sentinel 限流熔断
|
||||||
|
- ✅ **认证授权** - OAuth2 + JWT + Spring Security
|
||||||
|
- ✅ **多租户支持** - 完整的多租户数据隔离方案
|
||||||
|
- ✅ **分布式缓存** - Redis + Redisson 分布式锁
|
||||||
|
- ✅ **数据库** - MyBatis Plus + 多数据源
|
||||||
|
- ✅ **全文搜索** - Elasticsearch 集成
|
||||||
|
- ✅ **文件存储** - 多云存储支持(阿里云OSS、七牛云、MinIO)
|
||||||
|
- ✅ **监控中心** - Spring Boot Admin 应用监控
|
||||||
|
- ✅ **代码生成** - 基于数据库表的代码生成器
|
||||||
|
|
||||||
|
## 技术栈
|
||||||
|
|
||||||
|
| 技术 | 版本 | 说明 |
|
||||||
|
|------|------|------|
|
||||||
|
| Java | 17 | 编程语言 |
|
||||||
|
| Spring Boot | 3.1.6 | 应用框架 |
|
||||||
|
| Spring Cloud | 2022.0.4 | 微服务框架 |
|
||||||
|
| Spring Cloud Alibaba | 2022.0.0.0 | 阿里云组件 |
|
||||||
|
| MyBatis Plus | 3.5.4.1 | ORM 框架 |
|
||||||
|
| MySQL | 8.0+ | 关系数据库 |
|
||||||
|
| Redis | 7.0+ | 缓存数据库 |
|
||||||
|
| Elasticsearch | 7.13.4 | 搜索引擎 |
|
||||||
|
| Nacos | Latest | 注册中心/配置中心 |
|
||||||
|
| Sentinel | Latest | 限流熔断 |
|
||||||
|
|
||||||
|
## 模块说明
|
||||||
|
|
||||||
## 5. 模块说明
|
|
||||||
```lua
|
```lua
|
||||||
central-platform -- 父项目,公共依赖
|
central-platform -- 父项目,公共依赖
|
||||||
│ ├─zlt-business -- 业务模块一级工程
|
│ ├─zlt-business -- 业务模块一级工程
|
||||||
│ │ ├─user-center -- 用户中心[7000]
|
│ │ ├─user-center -- 用户中心[7000]
|
||||||
│ │ ├─file-center -- 文件中心[5000]
|
│ │ ├─file-center -- 文件中心[5000]
|
||||||
│ │ ├─code-generator -- 代码生成器[7300]
|
|
||||||
│ │ ├─search-center -- 搜索中心
|
│ │ ├─search-center -- 搜索中心
|
||||||
│ │ │ ├─search-client -- 搜索中心客户端
|
│ │ │ ├─search-client -- 搜索中心客户端
|
||||||
│ │ │ ├─search-server -- 搜索中心服务端[7100]
|
│ │ │ ├─search-server -- 搜索中心服务端[7100]
|
||||||
│ │─zlt-commons -- 通用工具一级工程
|
│ │ ├─code-generator -- 代码生成器[7300]
|
||||||
│ │ ├─zlt-auth-client-spring-boot-starter -- 封装spring security client端的通用操作逻辑
|
│ │ └─demo-center -- 示例模块[8100]
|
||||||
│ │ ├─zlt-common-core -- 封装通用操作逻辑
|
│ ├─zlt-commons -- 通用工具一级工程
|
||||||
│ │ ├─zlt-common-spring-boot-starter -- 封装通用操作逻辑
|
│ │ ├─zlt-common-core -- 核心工具类
|
||||||
│ │ ├─zlt-db-spring-boot-starter -- 封装数据库通用操作逻辑
|
│ │ ├─zlt-common-spring-boot-starter -- 通用配置
|
||||||
│ │ ├─zlt-log-spring-boot-starter -- 封装log通用操作逻辑
|
│ │ ├─zlt-db-spring-boot-starter -- 数据库集成
|
||||||
│ │ ├─zlt-redis-spring-boot-starter -- 封装Redis通用操作逻辑
|
│ │ ├─zlt-redis-spring-boot-starter -- Redis集成
|
||||||
│ │ ├─zlt-loadbalancer-spring-boot-starter -- 封装Loadbalancer和Feign的通用操作逻辑
|
│ │ ├─zlt-log-spring-boot-starter -- 日志集成
|
||||||
│ │ ├─zlt-sentinel-spring-boot-starter -- 封装Sentinel的通用操作逻辑
|
│ │ ├─zlt-auth-client-spring-boot-starter -- 认证客户端
|
||||||
│ │ ├─zlt-elasticsearch-spring-boot-starter -- 封装Elasticsearch通用操作逻辑
|
│ │ ├─zlt-loadbalancer-spring-boot-starter -- 负载均衡
|
||||||
│ │ ├─zlt-oss-spring-boot-starter -- 封装对象存储通用操作逻辑
|
│ │ ├─zlt-sentinel-spring-boot-starter -- 限流熔断
|
||||||
│ │ ├─zlt-zookeeper-spring-boot-starter -- 封装Zookeeper通用操作逻辑
|
│ │ ├─zlt-elasticsearch-spring-boot-starter -- 搜索引擎
|
||||||
|
│ │ ├─zlt-oss-spring-boot-starter -- 对象存储
|
||||||
|
│ │ ├─zlt-sms-spring-boot-starter -- 短信集成
|
||||||
|
│ │ ├─zlt-zookeeper-spring-boot-starter -- Zookeeper集成
|
||||||
|
│ │ ├─zlt-wechat-common-core -- 微信通用核心
|
||||||
|
│ │ └─zlt-wechat-spring-boot-starter -- 微信集成
|
||||||
|
│ ├─zlt-gateway -- API网关[9900]
|
||||||
|
│ ├─zlt-uaa -- 认证授权中心[8000]
|
||||||
│ ├─zlt-config -- 配置中心
|
│ ├─zlt-config -- 配置中心
|
||||||
│ ├─zlt-doc -- 项目文档
|
│ ├─zlt-monitor -- 监控中心
|
||||||
│ ├─zlt-gateway -- api网关一级工程
|
|
||||||
│ │ ├─sc-gateway -- spring-cloud-gateway[9900]
|
|
||||||
│ ├─zlt-monitor -- 监控一级工程
|
|
||||||
│ │ ├─sc-admin -- 应用监控[6500]
|
│ │ ├─sc-admin -- 应用监控[6500]
|
||||||
│ │ ├─log-center -- 日志中心[7200]
|
│ │ └─log-center -- 日志中心[7200]
|
||||||
│ ├─zlt-uaa -- spring-security认证中心[8000]
|
│ └─zlt-doc -- 项目文档
|
||||||
│ ├─zlt-register -- 注册中心Nacos[8848]
|
└─database -- 数据库脚本
|
||||||
│ ├─zlt-web -- 前端一级工程
|
|
||||||
│ │ ├─layui-web -- layui前端[8066]
|
|
||||||
│ │ ├─react-web -- react前端[8066]
|
|
||||||
│ ├─zlt-demo -- demo一级工程
|
|
||||||
│ │ ├─dubbo-demo -- dubbo服务demo
|
|
||||||
│ │ ├─resource-server-demo -- 资源服务器demo
|
|
||||||
│ │ ├─seata-demo -- seata分布式事务demo
|
|
||||||
│ │ ├─sharding-jdbc-demo -- sharding-jdbc分库分表demo
|
|
||||||
│ │ ├─rocketmq-demo -- rocketmq和mq事务demo
|
|
||||||
│ │ ├─sso-demo -- 单点登录demo
|
|
||||||
│ │ ├─websocket-demo -- websocket demo
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 快速开始
|
||||||
|
|
||||||
|
### 环境要求
|
||||||
|
|
||||||
|
- JDK 17+
|
||||||
|
- Maven 3.6+
|
||||||
|
- MySQL 8.0+
|
||||||
|
- Redis 7.0+
|
||||||
|
- Nacos 2.0+
|
||||||
|
|
||||||
|
### 数据库初始化
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mysql -u root -p < zlt-doc/database/init.sql
|
||||||
|
```
|
||||||
|
|
||||||
|
### 启动 Nacos
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 单机模式启动
|
||||||
|
sh nacos/bin/startup.sh -m standalone
|
||||||
|
```
|
||||||
|
|
||||||
|
访问: http://localhost:8848/nacos (账号: nacos/nacos)
|
||||||
|
|
||||||
|
### 编译项目
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mvn clean install -DskipTests
|
||||||
|
```
|
||||||
|
|
||||||
|
### 启动服务
|
||||||
|
|
||||||
|
1. 启动网关 (9900)
|
||||||
|
2. 启动认证中心 (8000)
|
||||||
|
3. 启动用户中心 (7000)
|
||||||
|
4. 启动文件中心 (5000)
|
||||||
|
|
||||||
|
### 默认账号
|
||||||
|
|
||||||
|
- 用户名: `admin`
|
||||||
|
- 密码: `admin123`
|
||||||
|
|
||||||
|
## 许可证
|
||||||
|
|
||||||
|
Apache License 2.0
|
||||||
|
|||||||
@@ -1,215 +0,0 @@
|
|||||||
# 🌤️ 天气规则系统 - 完整实现
|
|
||||||
|
|
||||||
## 项目概述
|
|
||||||
|
|
||||||
天气规则系统是一个用于在订单创建、任务下发、航线作业等场景下检查天气条件是否满足飞行要求的规则引擎。
|
|
||||||
|
|
||||||
**✅ 已完成集成 Open-Meteo 免费天气API,无需API Key即可使用!**
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 核心特性
|
|
||||||
|
|
||||||
- ✅ **三级规则体系**:租户级别、景区级别、设备级别(优先级:设备 > 景区 > 租户)
|
|
||||||
- ✅ **灵活的规则配置**:支持8种天气参数、4种运算符、AND/OR逻辑
|
|
||||||
- ✅ **规则引擎**:自动评估天气条件,返回详细的检查结果
|
|
||||||
- ✅ **免费天气API**:集成Open-Meteo,无需注册,无请求限制
|
|
||||||
- ✅ **缓存机制**:Redis缓存 + 数据库缓存,减少API调用
|
|
||||||
- ✅ **检查日志**:记录所有天气检查历史,便于追溯和分析
|
|
||||||
- ✅ **前端管理界面**:React + Ant Design Pro,可视化管理规则
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 快速开始
|
|
||||||
|
|
||||||
### 1. 执行数据库脚本
|
|
||||||
|
|
||||||
```bash
|
|
||||||
mysql -u root -p < zlt-business/order-center/src/main/resources/db/migration/V1.0__weather_rule_system_init.sql
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. 确保景区有经纬度
|
|
||||||
|
|
||||||
```sql
|
|
||||||
UPDATE tourisms SET longitude = 118.1673, latitude = 30.1333 WHERE id = 10001;
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. 重启服务
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd zlt-business/order-center
|
|
||||||
mvn clean package -DskipTests
|
|
||||||
java -jar target/order-center.jar
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4. 测试
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 测试天气API
|
|
||||||
curl "https://api.open-meteo.com/v1/forecast?latitude=39.9042&longitude=116.4074¤t=temperature_2m,wind_speed_10m&timezone=Asia/Shanghai"
|
|
||||||
|
|
||||||
# 测试后端接口
|
|
||||||
curl -X POST "http://localhost:8080/api-order/weather/check/order" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{"tourismId": 10001, "orderNo": "ORDER001"}'
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 文档导航
|
|
||||||
|
|
||||||
| 文档 | 说明 | 路径 |
|
|
||||||
|------|------|------|
|
|
||||||
| **使用指南** | 快速上手,包含测试示例 | [USAGE_GUIDE.md](zlt-business/order-center/src/main/java/com/central/order/weather/USAGE_GUIDE.md) |
|
|
||||||
| **快速开始** | 部署和测试步骤 | [QUICKSTART.md](zlt-business/order-center/src/main/java/com/central/order/weather/QUICKSTART.md) |
|
|
||||||
| **技术设计** | 完整的技术设计文档 | [WEATHER_RULE_SYSTEM_DESIGN.md](zlt-business/order-center/src/main/resources/doc/WEATHER_RULE_SYSTEM_DESIGN.md) |
|
|
||||||
| **Open-Meteo集成** | 天气API集成说明 | [OPEN_METEO_INTEGRATION.md](zlt-business/order-center/src/main/java/com/central/order/weather/OPEN_METEO_INTEGRATION.md) |
|
|
||||||
| **实现说明** | 后端实现细节 | [README.md](zlt-business/order-center/src/main/java/com/central/order/weather/README.md) |
|
|
||||||
| **完成总结** | 项目完成情况总结 | [WEATHER_SYSTEM_SUMMARY.md](WEATHER_SYSTEM_SUMMARY.md) |
|
|
||||||
| **前端使用** | 前端管理页面使用说明 | [README.md](zlt-web/react-web-next/src/pages/orders/WeatherRule/README.md) |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 项目结构
|
|
||||||
|
|
||||||
```
|
|
||||||
go-fly-platform-services/
|
|
||||||
├── zlt-business/order-center/
|
|
||||||
│ ├── src/main/java/com/central/order/weather/
|
|
||||||
│ │ ├── config/ # 配置类
|
|
||||||
│ │ ├── constants/ # 常量定义
|
|
||||||
│ │ ├── controller/ # REST API控制器
|
|
||||||
│ │ ├── engine/ # 规则引擎
|
|
||||||
│ │ ├── enums/ # 枚举类
|
|
||||||
│ │ ├── mapper/ # MyBatis Mapper
|
|
||||||
│ │ ├── model/ # 实体类
|
|
||||||
│ │ ├── provider/ # 天气数据提供者
|
|
||||||
│ │ ├── scheduler/ # 定时任务
|
|
||||||
│ │ └── service/ # 业务逻辑层
|
|
||||||
│ ├── src/main/resources/
|
|
||||||
│ │ ├── mapper/ # Mapper XML
|
|
||||||
│ │ ├── db/migration/ # 数据库脚本
|
|
||||||
│ │ ├── config/ # 配置示例
|
|
||||||
│ │ ├── scripts/ # 测试脚本
|
|
||||||
│ │ └── doc/ # 技术文档
|
|
||||||
│ └── src/test/java/ # 单元测试
|
|
||||||
└── zlt-web/react-web-next/
|
|
||||||
└── src/pages/orders/WeatherRule/
|
|
||||||
├── index.tsx # 主列表页面
|
|
||||||
└── components/ # React组件
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## API接口
|
|
||||||
|
|
||||||
### 规则管理
|
|
||||||
|
|
||||||
- `GET /api-order/weather/rules/list` - 查询规则列表
|
|
||||||
- `POST /api-order/weather/rules/create` - 创建规则
|
|
||||||
- `PUT /api-order/weather/rules/{id}` - 更新规则
|
|
||||||
- `PUT /api-order/weather/rules/{id}/status` - 更新规则状态
|
|
||||||
- `DELETE /api-order/weather/rules/{id}` - 删除规则
|
|
||||||
- `GET /api-order/weather/rules/{id}` - 查询规则详情
|
|
||||||
|
|
||||||
### 天气检查
|
|
||||||
|
|
||||||
- `POST /api-order/weather/check/order` - 订单创建天气检查
|
|
||||||
- `POST /api-order/weather/check/mission` - 任务创建天气检查
|
|
||||||
- `POST /api-order/weather/check/linejob` - 航线作业天气检查
|
|
||||||
- `POST /api-order/weather/check/validate` - 通用天气检查
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 技术栈
|
|
||||||
|
|
||||||
### 后端
|
|
||||||
- Java 17
|
|
||||||
- Spring Boot 3.1.6
|
|
||||||
- MyBatis Plus 3.5.4
|
|
||||||
- MySQL 8.0
|
|
||||||
- Redis 7.0
|
|
||||||
- Open-Meteo API
|
|
||||||
|
|
||||||
### 前端
|
|
||||||
- React 18
|
|
||||||
- TypeScript
|
|
||||||
- Ant Design Pro
|
|
||||||
- UmiJS
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 代码统计
|
|
||||||
|
|
||||||
- **后端代码**: 29个Java类,3个Mapper XML,1个测试类,约4000行
|
|
||||||
- **前端代码**: 3个React组件,约800行TypeScript
|
|
||||||
- **文档**: 7个Markdown文档,约20000字
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 使用示例
|
|
||||||
|
|
||||||
### 在订单创建流程中集成
|
|
||||||
|
|
||||||
```java
|
|
||||||
@Service
|
|
||||||
public class OrderServiceImpl implements IOrderService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private IWeatherRuleValidator weatherRuleValidator;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Result<Order> createOrder(OrderCreateDTO orderDTO) {
|
|
||||||
// 天气检查
|
|
||||||
WeatherCheckResult checkResult = weatherRuleValidator.validateForOrder(
|
|
||||||
orderDTO.getTourismId(),
|
|
||||||
orderDTO.getOrderNo()
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!checkResult.getPassed()) {
|
|
||||||
return Result.failed("当前天气不适合飞行: " +
|
|
||||||
String.join("; ", checkResult.getFailReasons()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 继续创建订单...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 常见问题
|
|
||||||
|
|
||||||
### Q: 需要申请API Key吗?
|
|
||||||
|
|
||||||
**A**: 不需要!我们使用的是 Open-Meteo 免费API,无需注册,无需API Key,完全免费。
|
|
||||||
|
|
||||||
### Q: 支持哪些地区?
|
|
||||||
|
|
||||||
**A**: Open-Meteo 支持全球任意经纬度查询,覆盖全球所有地区。
|
|
||||||
|
|
||||||
### Q: 数据准确吗?
|
|
||||||
|
|
||||||
**A**: Open-Meteo 的数据来源于多个权威气象机构(NOAA, DWD等),准确度很高。
|
|
||||||
|
|
||||||
### Q: 有请求限制吗?
|
|
||||||
|
|
||||||
**A**: 没有!Open-Meteo 不限制请求次数,可以放心使用。
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 贡献者
|
|
||||||
|
|
||||||
- AI Team
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 许可证
|
|
||||||
|
|
||||||
本项目遵循公司内部许可协议。
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**项目状态**: ✅ 已完成(含天气API集成)
|
|
||||||
**版本**: v1.1
|
|
||||||
**最后更新**: 2026-01-26
|
|
||||||
@@ -60,10 +60,6 @@
|
|||||||
<tomcat-embed-core.version>10.1.11</tomcat-embed-core.version>
|
<tomcat-embed-core.version>10.1.11</tomcat-embed-core.version>
|
||||||
<httpclient.version>5.2.1</httpclient.version>
|
<httpclient.version>5.2.1</httpclient.version>
|
||||||
<oauth2-oidc-sdk.version>11.7</oauth2-oidc-sdk.version>
|
<oauth2-oidc-sdk.version>11.7</oauth2-oidc-sdk.version>
|
||||||
<dji-cloud-sdk.version>1.3.1</dji-cloud-sdk.version>
|
|
||||||
<okhttp3.version>4.9.1</okhttp3.version>
|
|
||||||
<glassfish-jaxb.version>2.3.3</glassfish-jaxb.version>
|
|
||||||
<javax-jaxb.version>2.3.0</javax-jaxb.version>
|
|
||||||
<easyexcel.version>3.3.3</easyexcel.version>
|
<easyexcel.version>3.3.3</easyexcel.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|||||||
@@ -1,225 +0,0 @@
|
|||||||
# 优惠券中心服务 (Coupon Center Service)
|
|
||||||
|
|
||||||
## 项目简介
|
|
||||||
|
|
||||||
优惠券中心服务是一个基于Spring Boot的微服务,专门处理优惠券相关的业务逻辑,包括与携程API的集成。
|
|
||||||
|
|
||||||
## 功能特性
|
|
||||||
|
|
||||||
- ✅ 优惠券管理(创建、查询、使用、过期处理)
|
|
||||||
- ✅ 携程API集成(订单创建、退款、核销通知)
|
|
||||||
- ✅ AES加密/解密支持
|
|
||||||
- ✅ MD5签名验证
|
|
||||||
- ✅ 多租户支持
|
|
||||||
- ✅ 软删除支持
|
|
||||||
|
|
||||||
## 技术栈
|
|
||||||
|
|
||||||
- **Spring Boot 3.x**
|
|
||||||
- **MyBatis Plus**
|
|
||||||
- **MySQL 8.0**
|
|
||||||
- **Redis** (可选)
|
|
||||||
- **Nacos** (服务发现和配置管理)
|
|
||||||
|
|
||||||
## 快速开始
|
|
||||||
|
|
||||||
### 1. 数据库初始化
|
|
||||||
|
|
||||||
首先需要创建数据库和表结构:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 连接到MySQL数据库
|
|
||||||
mysql -u your_username -p
|
|
||||||
|
|
||||||
# 执行数据库初始化脚本
|
|
||||||
source sql/create_ctrip_order_tables.sql
|
|
||||||
```
|
|
||||||
|
|
||||||
或者手动执行:
|
|
||||||
|
|
||||||
```sql
|
|
||||||
-- 创建数据库
|
|
||||||
CREATE DATABASE IF NOT EXISTS `coupon-center` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|
||||||
|
|
||||||
-- 使用数据库
|
|
||||||
USE `coupon-center`;
|
|
||||||
|
|
||||||
-- 执行sql/create_ctrip_order_tables.sql中的所有建表语句
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. 配置数据库连接
|
|
||||||
|
|
||||||
修改 `application.yml` 中的数据库配置:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
spring:
|
|
||||||
datasource:
|
|
||||||
url: jdbc:mysql://your_mysql_host:3306/coupon-center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
|
||||||
username: your_username
|
|
||||||
password: your_password
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. 配置携程API参数
|
|
||||||
|
|
||||||
确保 `application.yml` 中的携程API配置正确:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
ctrip:
|
|
||||||
aes:
|
|
||||||
key: 087b36ad0dff7942 # AES密钥
|
|
||||||
iv: 750e15a31356a99d # AES IV
|
|
||||||
sign:
|
|
||||||
key: ce6033ae31124ec5cdab3d2bc79f2622 # 签名密钥
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4. 启动服务
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 编译项目
|
|
||||||
mvn clean compile
|
|
||||||
|
|
||||||
# 启动服务
|
|
||||||
mvn spring-boot:run
|
|
||||||
```
|
|
||||||
|
|
||||||
或者打包后运行:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 打包
|
|
||||||
mvn clean package
|
|
||||||
|
|
||||||
# 运行jar包
|
|
||||||
java -jar target/coupon-center.jar
|
|
||||||
```
|
|
||||||
|
|
||||||
## API接口
|
|
||||||
|
|
||||||
### 携程相关接口
|
|
||||||
|
|
||||||
#### 创建优惠券
|
|
||||||
- **URL**: `POST /api-order/coupon/ctrip/create`
|
|
||||||
- **描述**: 接收携程创建优惠券请求
|
|
||||||
- **请求格式**: 加密的JSON数据
|
|
||||||
|
|
||||||
#### 验证优惠券
|
|
||||||
- **URL**: `POST /api-order/coupon/ctrip/verify`
|
|
||||||
- **描述**: 验证优惠券有效性
|
|
||||||
|
|
||||||
#### 取消优惠券
|
|
||||||
- **URL**: `POST /api-order/coupon/ctrip/cancel`
|
|
||||||
- **描述**: 取消优惠券
|
|
||||||
|
|
||||||
#### 查询优惠券状态
|
|
||||||
- **URL**: `GET /api-order/coupon/ctrip/status/{ctripCouponId}`
|
|
||||||
- **描述**: 查询优惠券状态
|
|
||||||
|
|
||||||
### 测试接口
|
|
||||||
|
|
||||||
#### 签名调试
|
|
||||||
- **URL**: `POST /api-order/coupon/ctrip/test/debug-sign`
|
|
||||||
- **描述**: 调试签名计算过程
|
|
||||||
|
|
||||||
#### 实际请求测试
|
|
||||||
- **URL**: `POST /api-order/coupon/ctrip/test/real-request`
|
|
||||||
- **描述**: 测试实际请求数据解析
|
|
||||||
|
|
||||||
## 数据库表结构
|
|
||||||
|
|
||||||
### 主要表
|
|
||||||
|
|
||||||
1. **t_coupon** - 优惠券主表
|
|
||||||
2. **t_ctrip_order** - 携程订单表
|
|
||||||
3. **t_ctrip_order_item** - 携程订单项目表
|
|
||||||
4. **t_ctrip_passenger** - 携程乘客表
|
|
||||||
5. **t_ctrip_contact** - 携程联系人表
|
|
||||||
6. **t_ctrip_coupon** - 携程优惠券表
|
|
||||||
7. **t_ctrip_voucher** - 携程凭证表
|
|
||||||
8. **t_ctrip_refund** - 携程退款表
|
|
||||||
9. **t_ctrip_refund_item** - 携程退款项目表
|
|
||||||
10. **t_ctrip_consumed** - 携程核销表
|
|
||||||
11. **t_ctrip_consumed_passenger** - 携程核销乘客表
|
|
||||||
12. **t_ctrip_consumed_voucher** - 携程核销凭证表
|
|
||||||
|
|
||||||
## 携程API集成
|
|
||||||
|
|
||||||
### 加密解密
|
|
||||||
|
|
||||||
服务支持携程的AES-128-CBC加密和自定义编码:
|
|
||||||
|
|
||||||
- **AES加密**: 使用CBC模式,PKCS5Padding填充
|
|
||||||
- **自定义编码**: 非标准Base64编码,使用字母a-p表示4位数据
|
|
||||||
|
|
||||||
### 签名验证
|
|
||||||
|
|
||||||
使用MD5算法进行签名验证:
|
|
||||||
|
|
||||||
```
|
|
||||||
签名字符串 = accountId + serviceName + requestTime + body + version + signKey
|
|
||||||
签名 = MD5(签名字符串).toLowerCase()
|
|
||||||
```
|
|
||||||
|
|
||||||
## 故障排除
|
|
||||||
|
|
||||||
### 常见问题
|
|
||||||
|
|
||||||
1. **数据库连接失败**
|
|
||||||
- 检查数据库配置
|
|
||||||
- 确保数据库和表已创建
|
|
||||||
|
|
||||||
2. **签名验证失败**
|
|
||||||
- 检查签名密钥配置
|
|
||||||
- 使用调试接口分析签名计算过程
|
|
||||||
|
|
||||||
3. **AES解密失败**
|
|
||||||
- 检查AES密钥和IV配置
|
|
||||||
- 确认使用正确的自定义编码
|
|
||||||
|
|
||||||
### 调试工具
|
|
||||||
|
|
||||||
- **签名调试**: `/api-order/coupon/ctrip/test/debug-sign`
|
|
||||||
- **AES测试**: `/api-order/coupon/ctrip/test/aes`
|
|
||||||
- **配置验证**: `/api-order/coupon/ctrip/test/aes-config`
|
|
||||||
|
|
||||||
## 开发指南
|
|
||||||
|
|
||||||
### 添加新的API接口
|
|
||||||
|
|
||||||
1. 在 `controller` 包中创建控制器
|
|
||||||
2. 在 `service` 包中实现业务逻辑
|
|
||||||
3. 在 `mapper` 包中定义数据访问方法
|
|
||||||
4. 在 `entity` 包中定义实体类
|
|
||||||
|
|
||||||
### 数据库迁移
|
|
||||||
|
|
||||||
1. 创建新的SQL脚本
|
|
||||||
2. 更新实体类和Mapper
|
|
||||||
3. 测试数据访问功能
|
|
||||||
|
|
||||||
## 部署
|
|
||||||
|
|
||||||
### Docker部署
|
|
||||||
|
|
||||||
```dockerfile
|
|
||||||
FROM openjdk:17-jre-slim
|
|
||||||
COPY target/coupon-center.jar app.jar
|
|
||||||
EXPOSE 8002
|
|
||||||
ENTRYPOINT ["java", "-jar", "/app.jar"]
|
|
||||||
```
|
|
||||||
|
|
||||||
### 环境变量
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 数据库配置
|
|
||||||
ZLT_DATASOURCE_IP=your_mysql_host
|
|
||||||
ZLT_DATASOURCE_USERNAME=your_username
|
|
||||||
ZLT_DATASOURCE_PASSWORD=your_password
|
|
||||||
|
|
||||||
# 携程API配置
|
|
||||||
CTRIP_AES_KEY=087b36ad0dff7942
|
|
||||||
CTRIP_AES_IV=750e15a31356a99d
|
|
||||||
CTRIP_SIGN_KEY=ce6033ae31124ec5cdab3d2bc79f2622
|
|
||||||
```
|
|
||||||
|
|
||||||
## 许可证
|
|
||||||
|
|
||||||
本项目采用 MIT 许可证。
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
-- 调试查询脚本
|
|
||||||
-- 用于检查数据库中的数据情况
|
|
||||||
|
|
||||||
-- 1. 检查订单表数据
|
|
||||||
SELECT
|
|
||||||
id,
|
|
||||||
ota_order_id,
|
|
||||||
supplier_order_id,
|
|
||||||
total_amount,
|
|
||||||
currency,
|
|
||||||
status,
|
|
||||||
create_time
|
|
||||||
FROM t_ctrip_order
|
|
||||||
ORDER BY create_time DESC
|
|
||||||
LIMIT 10;
|
|
||||||
|
|
||||||
-- 2. 检查乘客表数据
|
|
||||||
SELECT
|
|
||||||
id,
|
|
||||||
order_id,
|
|
||||||
passenger_name,
|
|
||||||
phone,
|
|
||||||
create_time
|
|
||||||
FROM t_ctrip_passenger
|
|
||||||
ORDER BY create_time DESC
|
|
||||||
LIMIT 10;
|
|
||||||
|
|
||||||
-- 3. 检查联系人表数据
|
|
||||||
SELECT
|
|
||||||
id,
|
|
||||||
order_id,
|
|
||||||
name,
|
|
||||||
mobile,
|
|
||||||
email,
|
|
||||||
create_time
|
|
||||||
FROM t_ctrip_contact
|
|
||||||
ORDER BY create_time DESC
|
|
||||||
LIMIT 10;
|
|
||||||
|
|
||||||
-- 4. 检查订单项表数据
|
|
||||||
SELECT
|
|
||||||
id,
|
|
||||||
order_id,
|
|
||||||
item_id,
|
|
||||||
item_name,
|
|
||||||
plu,
|
|
||||||
quantity,
|
|
||||||
unit_price,
|
|
||||||
total_price,
|
|
||||||
create_time
|
|
||||||
FROM t_ctrip_order_item
|
|
||||||
ORDER BY create_time DESC
|
|
||||||
LIMIT 10;
|
|
||||||
|
|
||||||
-- 5. 根据手机号查询乘客信息
|
|
||||||
SELECT
|
|
||||||
p.id,
|
|
||||||
p.order_id,
|
|
||||||
p.passenger_name,
|
|
||||||
p.phone,
|
|
||||||
o.ota_order_id,
|
|
||||||
o.total_amount,
|
|
||||||
o.status
|
|
||||||
FROM t_ctrip_passenger p
|
|
||||||
JOIN t_ctrip_order o ON p.order_id = o.id
|
|
||||||
WHERE p.phone = '18322694510'
|
|
||||||
ORDER BY p.create_time DESC;
|
|
||||||
|
|
||||||
-- 6. 根据手机号查询联系人信息
|
|
||||||
SELECT
|
|
||||||
c.id,
|
|
||||||
c.order_id,
|
|
||||||
c.name,
|
|
||||||
c.mobile,
|
|
||||||
c.email,
|
|
||||||
o.ota_order_id,
|
|
||||||
o.total_amount,
|
|
||||||
o.status
|
|
||||||
FROM t_ctrip_contact c
|
|
||||||
JOIN t_ctrip_order o ON c.order_id = o.id
|
|
||||||
WHERE c.mobile = '18322694510'
|
|
||||||
ORDER BY c.create_time DESC;
|
|
||||||
|
|
||||||
-- 7. 查询所有订单的价格分布
|
|
||||||
SELECT
|
|
||||||
total_amount,
|
|
||||||
COUNT(*) as count
|
|
||||||
FROM t_ctrip_order
|
|
||||||
WHERE total_amount IS NOT NULL
|
|
||||||
GROUP BY total_amount
|
|
||||||
ORDER BY total_amount;
|
|
||||||
@@ -1,201 +0,0 @@
|
|||||||
# 酒店优惠券二维码需求实现方案
|
|
||||||
|
|
||||||
## 1. 背景与目标
|
|
||||||
- 为协商酒店提供一次性实体二维码优惠券,入住绑定用户后可在设备端免支付下单。
|
|
||||||
- 确保券码唯一、不可重复使用,订单需区分优惠券订单类型,保证业务闭环(生成-发放-绑定-核销-订单-设备任务)。
|
|
||||||
- 方案部署在 coupon-center 模块,可扩展到其他券类型/渠道。
|
|
||||||
|
|
||||||
## 2. 业务角色与定义
|
|
||||||
- 协商酒店:已签约的酒店实体,负责发放线下券。
|
|
||||||
- 优惠券批次:一次生成的一组券码,绑定同一酒店、有效期、面值规则。
|
|
||||||
- 优惠券券码/二维码:携带唯一券码和签名的二维码图片,实体印刷,状态流转 UNBOUND -> BOUND -> USED/VOID/EXPIRED。
|
|
||||||
- 用户:入住客人,登录后绑定券码;同一用户同一酒店默认仅可绑定一张(可配置)。
|
|
||||||
- 设备端:自助设备/终端,负责扫码下单并执行任务。
|
|
||||||
- 订单类型:`NORMAL` 普通订单;`HOTEL_COUPON_FREE` 酒店券免单订单;预留 `HOTEL_COUPON_DEDUCTION` 抵扣类。
|
|
||||||
|
|
||||||
## 3. 流程说明
|
|
||||||
### 3.1 券码生成与发放
|
|
||||||
- 管理端选择酒店、配置面值(默认免单0元)、有效期、单用户限领数、生成数量。
|
|
||||||
- 系统创建批次,生成唯一 `coupon_code`,写入券码表,构造绑定入口 `https://xxx/h5/hotel-coupon/bind?code=...&hotelId=...&ts=...&sign=...`,生成二维码图片并打包 zip 提供下载。
|
|
||||||
- 下载记录写入事件表,批次状态从 `GENERATED` -> `FINISHED`,券码状态初始为 `UNBOUND`。
|
|
||||||
|
|
||||||
### 3.2 入住绑定
|
|
||||||
- 前台发放实体码,用户扫码进入 H5,登录后调用绑定接口。
|
|
||||||
- 校验:有效期、券码状态=UNBOUND、酒店匹配、用户在同酒店限领数未超限;签名校验防伪。
|
|
||||||
- 事务内执行:`UPDATE t_hotel_coupon_code SET status='BOUND', bind_user_id=?, bind_time=NOW(), version=version+1 WHERE coupon_code=? AND status='UNBOUND'`;写入事件流水。
|
|
||||||
- 返回成功页并展示可用状态;重复提交按幂等返回已绑定信息。
|
|
||||||
|
|
||||||
### 3.3 设备扫码下单与核销
|
|
||||||
- 设备端通过用户身份/手机号调用“查询可用券”接口,若存在 BOUND 且未过期券,前端金额置零并将 `orderType=HOTEL_COUPON_FREE`。
|
|
||||||
- 下单接口在同一事务内写入订单表、将券码从 BOUND 更新为 USED,落订单-券码关联,推送设备执行任务。
|
|
||||||
- 同步返回订单号;失败时回滚券状态,设备收到失败提示继续正常付费路径。
|
|
||||||
- 若用户无绑定券或券不可用,则按 `NORMAL` 下单,不影响其他流程。
|
|
||||||
|
|
||||||
### 3.4 异常/风控
|
|
||||||
- 管理端支持作废券码/批次(status->VOID),并记录原因;VOID 后绑定/核销均拒绝。
|
|
||||||
- 定时任务每日凌晨标记过期,写事件流水;订单幂等使用 `requestId`/`orderNo` 双重校验。
|
|
||||||
- 券码字符串含签名与时间戳,服务端校验防止伪造;绑定、核销接口限流并记录审计。
|
|
||||||
|
|
||||||
## 4. 数据库表设计(coupon-center)
|
|
||||||
### 4.1 协商酒店表 t_partner_hotel
|
|
||||||
```sql
|
|
||||||
CREATE TABLE `t_partner_hotel` (
|
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
|
||||||
`hotel_code` varchar(64) NOT NULL COMMENT '酒店编码(对外展示/查询)',
|
|
||||||
`hotel_name` varchar(100) NOT NULL COMMENT '酒店名称',
|
|
||||||
`contact_name` varchar(50) DEFAULT NULL COMMENT '联系人',
|
|
||||||
`contact_phone` varchar(20) DEFAULT NULL COMMENT '联系电话',
|
|
||||||
`address` varchar(255) DEFAULT NULL COMMENT '地址',
|
|
||||||
`status` varchar(20) DEFAULT 'ENABLED' COMMENT 'ENABLED/ DISABLED',
|
|
||||||
`remark` varchar(255) DEFAULT NULL,
|
|
||||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
||||||
`deleted` tinyint(1) DEFAULT 0,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `uk_hotel_code` (`hotel_code`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='协商酒店';
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4.2 优惠券批次表 t_hotel_coupon_batch
|
|
||||||
```sql
|
|
||||||
CREATE TABLE `t_hotel_coupon_batch` (
|
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
|
||||||
`batch_no` varchar(64) NOT NULL COMMENT '批次号',
|
|
||||||
`hotel_id` bigint NOT NULL COMMENT '关联酒店',
|
|
||||||
`coupon_type` varchar(20) NOT NULL COMMENT 'FREE_ORDER/DEDUCTION',
|
|
||||||
`face_value` decimal(10,2) NOT NULL DEFAULT 0 COMMENT '面值,免单为0',
|
|
||||||
`quantity` int NOT NULL COMMENT '生成数量',
|
|
||||||
`valid_start_time` datetime NOT NULL,
|
|
||||||
`valid_end_time` datetime NOT NULL,
|
|
||||||
`per_user_limit` int NOT NULL DEFAULT 1 COMMENT '同酒店同用户限领数',
|
|
||||||
`order_type` varchar(20) NOT NULL DEFAULT 'HOTEL_COUPON_FREE' COMMENT '下单类型标识',
|
|
||||||
`qr_payload_prefix` varchar(255) NOT NULL COMMENT '绑定入口前缀/域名',
|
|
||||||
`download_url` varchar(500) DEFAULT NULL COMMENT '二维码zip存储路径',
|
|
||||||
`status` varchar(20) DEFAULT 'GENERATED' COMMENT 'GENERATED/PROCESSING/FINISHED/CLOSED',
|
|
||||||
`created_by` varchar(50) DEFAULT NULL,
|
|
||||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
||||||
`deleted` tinyint(1) DEFAULT 0,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `uk_batch_no` (`batch_no`),
|
|
||||||
KEY `idx_hotel` (`hotel_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='酒店优惠券批次';
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4.3 券码表 t_hotel_coupon_code
|
|
||||||
```sql
|
|
||||||
CREATE TABLE `t_hotel_coupon_code` (
|
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
|
||||||
`batch_id` bigint NOT NULL,
|
|
||||||
`hotel_id` bigint NOT NULL,
|
|
||||||
`coupon_code` varchar(128) NOT NULL COMMENT '唯一券码',
|
|
||||||
`qr_content` varchar(500) NOT NULL COMMENT '二维码携带内容(含签名)',
|
|
||||||
`qr_image_url` varchar(500) DEFAULT NULL COMMENT '二维码图片地址',
|
|
||||||
`status` varchar(20) NOT NULL DEFAULT 'UNBOUND' COMMENT 'UNBOUND/BOUND/USED/EXPIRED/VOID',
|
|
||||||
`bind_user_id` bigint DEFAULT NULL,
|
|
||||||
`bind_user_name` varchar(50) DEFAULT NULL,
|
|
||||||
`bind_user_phone` varchar(20) DEFAULT NULL,
|
|
||||||
`bind_time` datetime DEFAULT NULL,
|
|
||||||
`bind_channel` varchar(30) DEFAULT NULL COMMENT 'H5/MINI/FRONT_DESK',
|
|
||||||
`use_time` datetime DEFAULT NULL,
|
|
||||||
`use_order_no` varchar(64) DEFAULT NULL,
|
|
||||||
`use_device_code` varchar(64) DEFAULT NULL,
|
|
||||||
`order_type` varchar(20) DEFAULT NULL COMMENT '下单类型冗余',
|
|
||||||
`expire_time` datetime DEFAULT NULL,
|
|
||||||
`version` int NOT NULL DEFAULT 0 COMMENT '乐观锁',
|
|
||||||
`deleted` tinyint(1) DEFAULT 0,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `uk_coupon_code` (`coupon_code`),
|
|
||||||
KEY `idx_batch` (`batch_id`),
|
|
||||||
KEY `idx_hotel_status` (`hotel_id`,`status`),
|
|
||||||
KEY `idx_user` (`bind_user_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='酒店优惠券券码';
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4.4 事件流水表 t_hotel_coupon_event
|
|
||||||
```sql
|
|
||||||
CREATE TABLE `t_hotel_coupon_event` (
|
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
|
||||||
`coupon_code` varchar(128) NOT NULL,
|
|
||||||
`hotel_id` bigint NOT NULL,
|
|
||||||
`batch_id` bigint NOT NULL,
|
|
||||||
`user_id` bigint DEFAULT NULL,
|
|
||||||
`device_code` varchar(64) DEFAULT NULL,
|
|
||||||
`event_type` varchar(30) NOT NULL COMMENT 'GENERATE/BIND/USE/EXPIRE/VOID/DOWNLOAD',
|
|
||||||
`request_id` varchar(64) DEFAULT NULL COMMENT '幂等/追踪ID',
|
|
||||||
`remark` varchar(500) DEFAULT NULL,
|
|
||||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `idx_coupon_event` (`coupon_code`,`event_type`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='券码事件流水';
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4.5 订单表 t_hotel_coupon_order
|
|
||||||
```sql
|
|
||||||
CREATE TABLE `t_hotel_coupon_order` (
|
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
|
||||||
`order_no` varchar(64) NOT NULL,
|
|
||||||
`user_id` bigint NOT NULL,
|
|
||||||
`user_phone` varchar(20) DEFAULT NULL,
|
|
||||||
`hotel_id` bigint NOT NULL,
|
|
||||||
`device_code` varchar(64) NOT NULL,
|
|
||||||
`coupon_code` varchar(128) DEFAULT NULL,
|
|
||||||
`order_type` varchar(20) NOT NULL COMMENT 'NORMAL/HOTEL_COUPON_FREE/HOTEL_COUPON_DEDUCTION',
|
|
||||||
`origin_amount` decimal(10,2) NOT NULL COMMENT '原价',
|
|
||||||
`pay_amount` decimal(10,2) NOT NULL COMMENT '实付,免单为0',
|
|
||||||
`status` varchar(20) NOT NULL DEFAULT 'CREATED' COMMENT 'CREATED/DOING/DONE/CANCELLED/FAILED',
|
|
||||||
`task_payload` json DEFAULT NULL COMMENT '下发设备任务数据',
|
|
||||||
`remark` varchar(255) DEFAULT NULL,
|
|
||||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `uk_order_no` (`order_no`),
|
|
||||||
KEY `idx_user_type` (`user_id`,`order_type`),
|
|
||||||
KEY `idx_coupon` (`coupon_code`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='设备订单(含优惠券)';
|
|
||||||
```
|
|
||||||
|
|
||||||
## 5. 接口设计(关键)
|
|
||||||
### 5.1 管理端(需认证)
|
|
||||||
- `POST /admin/hotel` 创建/编辑酒店;`GET /admin/hotel` 列表筛选,`PUT /admin/hotel/{id}/status` 启停。
|
|
||||||
- `POST /admin/hotel/{hotelId}/coupon-batches` 创建批次(quantity/validity/perUserLimit/faceValue/orderType);异步生成券码。
|
|
||||||
- `GET /admin/coupon-batches` 按酒店/时间查询;`GET /admin/coupon-batches/{id}/download` 下载二维码zip;`POST /admin/coupon-batches/{id}/close` 关闭批次。
|
|
||||||
- `GET /admin/coupons` 券码明细分页;`POST /admin/coupons/{code}/void` 作废单码;导出报表。
|
|
||||||
|
|
||||||
### 5.2 H5 绑定
|
|
||||||
- `GET /public/hotel-coupon/{code}/precheck?hotelId=...&ts=...&sign=...` 校验二维码、返回酒店名/有效期/状态。
|
|
||||||
- `POST /public/hotel-coupon/bind` 绑定券码,入参:`code, hotelId, userId, userPhone, deviceCode(optional)`;返回绑定结果和可用状态。
|
|
||||||
|
|
||||||
### 5.3 设备侧下单/核销
|
|
||||||
- `GET /device/hotel-coupon/available?userId=...&hotelId=...` 返回可用券及订单类型;无券时返回空。
|
|
||||||
- `POST /device/hotel-coupon/use` 入参:`code/orderNo/userId/userPhone/hotelId/deviceCode/orderAmount/requestId`;事务化校验并落订单,成功返回免单订单号,失败返回原因。
|
|
||||||
- `POST /device/hotel-coupon/order` 可直接创建订单(包含 taskPayload),内部调用 use 接口扣券并设置 `orderType`。
|
|
||||||
|
|
||||||
### 5.4 运维/风控
|
|
||||||
- 事件列表接口:根据券码/用户/时间查询绑定、核销流水。
|
|
||||||
- 定时任务/手动触发接口:补偿过期、批量作废、重新生成二维码。
|
|
||||||
|
|
||||||
## 6. 核心实现要点
|
|
||||||
- 一次性二维码:券码唯一+签名+状态机控制;绑定/核销均通过 `status` + `version` 条件更新,避免并发复用。
|
|
||||||
- 订单类型:下单时写入 `t_hotel_coupon_order.order_type` 与设备任务记录,用于报表、风控、资金对账。
|
|
||||||
- 扩展性:`coupon_type/order_type` 预留,订单表 `task_payload`、券码表 `qr_content` 可存 JSON 扩展;批次/券码表均含 `deleted/status` 便于软删除和扩展。
|
|
||||||
- 监控审计:事件流水表记录全链路;关键接口打印 `requestId`;Prometheus/日志可按券码/酒店打标签。
|
|
||||||
- 定时任务:复用 `CouponExpireTask` 思路新增批次/券码过期处理;对过期券写事件并禁止绑定/核销。
|
|
||||||
|
|
||||||
## 7. 前端管理页面方案(zlt-web/react-web)
|
|
||||||
- 新增菜单「酒店优惠券」下包含:
|
|
||||||
- 「协商酒店管理」:列表/搜索/启停,表单字段:酒店名称、编码、联系人、电话、地址、备注。
|
|
||||||
- 「优惠券批次」:表单配置酒店、面值/类型、有效期、生成数量、单用户限领、二维码域名;表格展示状态、下载、关闭、查看日志。
|
|
||||||
- 「券码明细」:按批次/状态/用户过滤,支持导出、作废单码,展示绑定人、绑定时间、使用订单、设备号。
|
|
||||||
- H5 绑定页:展示酒店名称、有效期、状态文案;登录校验后点击「立即绑定」,提示绑定成功/失败原因。
|
|
||||||
- 交互提示:批次生成异步轮询,下载二维码给出 zip 地址;作废操作二次确认并展示影响范围。
|
|
||||||
|
|
||||||
## 8. 测试验证
|
|
||||||
- 单测/接口测试:批次生成数量正确、二维码签名校验、绑定幂等、并发绑定/核销互斥、过期/作废拦截。
|
|
||||||
- 联调:H5 绑定 -> 设备查询可用券 -> 免单下单 -> 设备任务执行 -> 订单状态回写。
|
|
||||||
- 回归:无券用户正常下单流程不受影响;报表统计区分订单类型。
|
|
||||||
|
|
||||||
## 9. 上线与配置
|
|
||||||
- SQL:新增表写入 `coupon-center/sql`,发布前执行;确保 DB 字符集 utf8mb4。
|
|
||||||
- 配置:新增二维码生成域名、OSS/本地存储路径、签名密钥;绑定/核销接口在网关配置白名单/限流。
|
|
||||||
- 发布:优先低峰期启用新定时任务,观察事件流水与日志;确认前端菜单、H5 入口发布同步。
|
|
||||||
@@ -1,772 +0,0 @@
|
|||||||
# 发明专利申请书
|
|
||||||
|
|
||||||
## 一、发明名称
|
|
||||||
|
|
||||||
**一种基于实体二维码的酒店优惠券发放与自动核销系统及方法**
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 二、技术领域
|
|
||||||
|
|
||||||
本发明涉及电子商务与旅游信息化技术领域,尤其涉及一种基于实体二维码的酒店优惠券发放与自动核销系统及方法。
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 三、背景技术
|
|
||||||
|
|
||||||
随着旅游行业的快速发展,景区与酒店的合作营销成为重要的获客渠道。酒店作为游客集中的场所,具有天然的流量优势,如何有效地将酒店住客引流至合作景区成为行业关注的重点。
|
|
||||||
|
|
||||||
然而,现有的酒店与景区合作营销方案存在以下技术问题:
|
|
||||||
|
|
||||||
1. **优惠券发放效率低**:传统纸质优惠券需要人工发放,容易遗失、伪造,且无法精准追踪发放和使用情况。
|
|
||||||
|
|
||||||
2. **优惠券核销流程繁琐**:用户使用优惠券时需要手动出示、人工核验,影响用户体验,增加景区运营成本。
|
|
||||||
|
|
||||||
3. **缺乏一码一用机制**:传统优惠券容易被复制传播,难以控制实际使用量,造成营销成本失控。
|
|
||||||
|
|
||||||
4. **数据追踪困难**:无法准确统计优惠券的发放、绑定、使用情况,难以评估合作效果和优化营销策略。
|
|
||||||
|
|
||||||
5. **系统对接复杂**:优惠券系统与订单系统分离,需要人工核对,容易出现核销遗漏或重复核销问题。
|
|
||||||
|
|
||||||
6. **有效期管理粗放**:无法支持灵活的有效期策略(如固定时间或绑定后N天有效),用户体验欠佳。
|
|
||||||
|
|
||||||
因此,亟需一种能够实现优惠券自动化发放、一码一用、自动核销的技术方案。
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 四、发明内容
|
|
||||||
|
|
||||||
### 4.1 发明目的
|
|
||||||
|
|
||||||
本发明的目的在于提供一种基于实体二维码的酒店优惠券发放与自动核销系统及方法,解决现有技术中优惠券发放效率低、核销流程繁琐、缺乏一码一用机制、数据追踪困难等技术问题。
|
|
||||||
|
|
||||||
### 4.2 技术方案
|
|
||||||
|
|
||||||
为实现上述目的,本发明提供以下技术方案:
|
|
||||||
|
|
||||||
#### 4.2.1 一种基于实体二维码的酒店优惠券发放与自动核销系统
|
|
||||||
|
|
||||||
所述系统包括:
|
|
||||||
|
|
||||||
**合作酒店管理模块**,用于管理与景区建立合作关系的酒店信息,包括:
|
|
||||||
- 酒店基本信息(名称、地址、联系人等);
|
|
||||||
- 合作有效期管理;
|
|
||||||
- 酒店状态管理(启用/禁用);
|
|
||||||
|
|
||||||
**优惠券批量生成模块**,用于为指定酒店批量生成带有唯一标识码的优惠券,包括:
|
|
||||||
- 生成唯一的批次号标识同一批次优惠券;
|
|
||||||
- 为每张优惠券生成全局唯一的优惠券码;
|
|
||||||
- 根据优惠券码生成对应的二维码图片;
|
|
||||||
- 支持配置优惠券类型(免费体验券、折扣券、满减券);
|
|
||||||
- 支持配置适用范围(指定景区、指定设备);
|
|
||||||
- 支持配置有效期策略(固定时间或绑定后N天);
|
|
||||||
|
|
||||||
**二维码图片管理模块**,用于管理优惠券二维码图片,包括:
|
|
||||||
- 将二维码图片上传至云存储服务;
|
|
||||||
- 支持按批次或按条件批量下载二维码图片;
|
|
||||||
- 将二维码打包为压缩文件供酒店打印制作实体二维码;
|
|
||||||
|
|
||||||
**用户扫码绑定模块**,用于处理用户扫描实体二维码后的绑定请求,包括:
|
|
||||||
- 解析二维码获取优惠券码;
|
|
||||||
- 校验优惠券状态(是否存在、是否已绑定、是否已过期、是否已作废);
|
|
||||||
- 采用分布式锁机制确保一码只能被一个用户绑定;
|
|
||||||
- 创建优惠券与用户的绑定关系;
|
|
||||||
- 根据有效期策略计算优惠券的实际生效时间;
|
|
||||||
- 更新优惠券状态为已绑定;
|
|
||||||
|
|
||||||
**用户优惠券查询模块**,用于为用户提供已绑定优惠券的查询功能,包括:
|
|
||||||
- 展示用户所有已绑定的优惠券列表;
|
|
||||||
- 支持按状态筛选(可用、已使用、已过期);
|
|
||||||
- 展示优惠券详情和适用范围;
|
|
||||||
|
|
||||||
**可用优惠券检测模块**,用于在用户下单前检测是否有可用优惠券,包括:
|
|
||||||
- 根据当前景区和设备信息查询用户的可用优惠券;
|
|
||||||
- 校验优惠券是否在有效期内;
|
|
||||||
- 校验优惠券是否适用于当前景区和设备;
|
|
||||||
- 返回可用优惠券信息供下单使用;
|
|
||||||
|
|
||||||
**自动核销模块**,用于在订单创建时自动完成优惠券核销,包括:
|
|
||||||
- 在订单创建流程中嵌入优惠券核销逻辑;
|
|
||||||
- 根据优惠券类型计算优惠金额;
|
|
||||||
- 创建零金额订单(免费体验券)或优惠后金额订单;
|
|
||||||
- 更新优惠券状态和绑定记录状态为已使用;
|
|
||||||
- 创建详细的核销记录用于数据追踪;
|
|
||||||
|
|
||||||
**订单类型标记模块**,用于在订单中标记优惠券使用信息,包括:
|
|
||||||
- 订单类型标记(普通订单/优惠券订单);
|
|
||||||
- 关联的优惠券标识;
|
|
||||||
- 原始金额、优惠金额、实付金额;
|
|
||||||
|
|
||||||
**过期处理模块**,用于定时处理过期的优惠券,包括:
|
|
||||||
- 定时扫描超过有效期的优惠券;
|
|
||||||
- 更新未使用的过期优惠券状态;
|
|
||||||
- 更新过期的绑定记录状态;
|
|
||||||
|
|
||||||
**数据统计模块**,用于统计优惠券的发放和使用情况,包括:
|
|
||||||
- 按酒店统计优惠券发放数量;
|
|
||||||
- 统计已绑定、已使用、已过期数量;
|
|
||||||
- 支持按批次、按时间维度统计;
|
|
||||||
|
|
||||||
#### 4.2.2 一种基于实体二维码的酒店优惠券发放与自动核销方法
|
|
||||||
|
|
||||||
所述方法包括以下步骤:
|
|
||||||
|
|
||||||
**步骤S1:酒店合作关系建立**
|
|
||||||
- S1.1:在系统中录入合作酒店基本信息;
|
|
||||||
- S1.2:设置合作有效期;
|
|
||||||
- S1.3:生成酒店唯一编码;
|
|
||||||
|
|
||||||
**步骤S2:优惠券批量生成**
|
|
||||||
- S2.1:选择目标酒店,配置优惠券参数;
|
|
||||||
- S2.2:系统生成批次号,格式为:B + 年月日 + 4位序号;
|
|
||||||
- S2.3:循环生成指定数量的优惠券码,格式为:HC + 批次号 + 6位序号;
|
|
||||||
- S2.4:为每个优惠券码生成二维码图片,二维码内容为小程序页面路径加优惠券码参数;
|
|
||||||
- S2.5:将二维码图片上传至云存储;
|
|
||||||
- S2.6:批量写入优惠券记录至数据库,初始状态为未绑定;
|
|
||||||
|
|
||||||
**步骤S3:实体二维码制作与投放**
|
|
||||||
- S3.1:管理人员按批次下载二维码图片压缩包;
|
|
||||||
- S3.2:将二维码图片打印制作成实体二维码卡片或海报;
|
|
||||||
- S3.3:将实体二维码投放至合作酒店指定位置;
|
|
||||||
|
|
||||||
**步骤S4:用户扫码绑定**
|
|
||||||
- S4.1:用户在酒店扫描实体二维码;
|
|
||||||
- S4.2:小程序打开优惠券绑定页面,获取优惠券码参数;
|
|
||||||
- S4.3:调用绑定接口,系统获取分布式锁防止并发绑定;
|
|
||||||
- S4.4:校验优惠券状态,确保未被绑定、未过期、未作废;
|
|
||||||
- S4.5:根据有效期策略计算优惠券的实际生效开始时间和结束时间;
|
|
||||||
- S4.6:创建优惠券与用户的绑定记录;
|
|
||||||
- S4.7:更新优惠券状态为已绑定;
|
|
||||||
- S4.8:释放分布式锁,返回绑定成功信息;
|
|
||||||
|
|
||||||
**步骤S5:设备端下单检测**
|
|
||||||
- S5.1:用户在景区设备端准备下单;
|
|
||||||
- S5.2:系统调用可用优惠券检测接口;
|
|
||||||
- S5.3:查询用户已绑定且状态为有效的优惠券;
|
|
||||||
- S5.4:过滤出适用于当前景区和设备的优惠券;
|
|
||||||
- S5.5:过滤出在有效期内的优惠券;
|
|
||||||
- S5.6:若存在可用优惠券,前端展示免费体验或优惠信息;
|
|
||||||
|
|
||||||
**步骤S6:订单创建与自动核销**
|
|
||||||
- S6.1:用户确认使用优惠券下单;
|
|
||||||
- S6.2:创建订单,设置订单类型为优惠券订单;
|
|
||||||
- S6.3:根据优惠券类型计算优惠金额:
|
|
||||||
- 免费体验券:优惠金额等于订单原始金额,实付金额为0;
|
|
||||||
- 折扣券:优惠金额等于原始金额乘以折扣率,实付金额为原始金额减优惠金额;
|
|
||||||
- 满减券:满足最低消费条件时,优惠金额等于满减金额;
|
|
||||||
- S6.4:在订单中记录优惠券标识和优惠金额;
|
|
||||||
- S6.5:调用核销接口完成优惠券核销;
|
|
||||||
- S6.6:更新优惠券状态为已使用;
|
|
||||||
- S6.7:更新绑定记录状态为已使用;
|
|
||||||
- S6.8:创建核销记录,记录核销详情;
|
|
||||||
- S6.9:触发设备执行任务;
|
|
||||||
|
|
||||||
**步骤S7:过期优惠券处理**
|
|
||||||
- S7.1:定时任务每日扫描所有优惠券;
|
|
||||||
- S7.2:将超过有效期且状态仍为未绑定的优惠券状态更新为已过期;
|
|
||||||
- S7.3:将超过有效期且状态仍为已绑定的绑定记录状态更新为已过期;
|
|
||||||
|
|
||||||
### 4.3 有益效果
|
|
||||||
|
|
||||||
本发明与现有技术相比,具有以下有益效果:
|
|
||||||
|
|
||||||
1. **一码一用防滥用**:每个优惠券码全局唯一,通过分布式锁确保同一时刻只有一个用户能成功绑定,有效防止优惠券被复制滥用。
|
|
||||||
|
|
||||||
2. **自动核销提效率**:优惠券核销与订单创建流程无缝集成,用户下单时自动完成核销,无需人工核验,提升用户体验和运营效率。
|
|
||||||
|
|
||||||
3. **实体二维码易投放**:将优惠券二维码制作成实体卡片或海报投放至酒店,无需酒店培训人员发放,降低合作门槛。
|
|
||||||
|
|
||||||
4. **灵活的有效期策略**:支持固定时间有效期和绑定后N天有效期两种策略,满足不同营销场景需求。
|
|
||||||
|
|
||||||
5. **精准的适用范围控制**:可配置优惠券仅适用于指定景区或指定设备,实现精细化营销。
|
|
||||||
|
|
||||||
6. **完整的数据追踪链路**:从发放、绑定、使用到过期,全链路数据可追溯,便于评估营销效果和优化策略。
|
|
||||||
|
|
||||||
7. **多类型优惠券支持**:支持免费体验券、折扣券、满减券等多种类型,可根据营销目标灵活配置。
|
|
||||||
|
|
||||||
8. **批量操作高效率**:支持批量生成优惠券、批量下载二维码,满足大规模投放需求。
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 五、附图说明
|
|
||||||
|
|
||||||
### 图1:系统整体架构图
|
|
||||||
|
|
||||||
```
|
|
||||||
┌─────────────────────────────────────────────────────────────────────┐
|
|
||||||
│ 前端应用层 │
|
|
||||||
├────────────────┬────────────────┬────────────────────────────────────┤
|
|
||||||
│ 管理后台 │ 用户小程序 │ 设备端 │
|
|
||||||
│ (优惠券管理) │ (扫码绑定) │ (自动核销) │
|
|
||||||
└───────┬────────┴───────┬────────┴───────────────┬────────────────────┘
|
|
||||||
│ │ │
|
|
||||||
▼ ▼ ▼
|
|
||||||
┌─────────────────────────────────────────────────────────────────────┐
|
|
||||||
│ 业务服务层 │
|
|
||||||
├─────────────────────────────────────────────────────────────────────┤
|
|
||||||
│ 合作酒店 优惠券生成 扫码绑定 可用检测 自动核销 过期处理 │
|
|
||||||
│ 管理 模块 模块 模块 模块 模块 │
|
|
||||||
└─────────────────────────────────────────────────────────────────────┘
|
|
||||||
│ │ │
|
|
||||||
▼ ▼ ▼
|
|
||||||
┌─────────────────────────────────────────────────────────────────────┐
|
|
||||||
│ 数据存储层 │
|
|
||||||
├─────────────────────────────────────────────────────────────────────┤
|
|
||||||
│ 合作酒店表 优惠券表 绑定记录表 核销记录表 订单表 │
|
|
||||||
└─────────────────────────────────────────────────────────────────────┘
|
|
||||||
│
|
|
||||||
▼
|
|
||||||
┌─────────────────────────────────────────────────────────────────────┐
|
|
||||||
│ 基础设施层 │
|
|
||||||
├─────────────────────────────────────────────────────────────────────┤
|
|
||||||
│ 云存储(二维码图片) │ 分布式锁(Redis) │
|
|
||||||
└─────────────────────────────────────────────────────────────────────┘
|
|
||||||
```
|
|
||||||
|
|
||||||
### 图2:优惠券生命周期状态图
|
|
||||||
|
|
||||||
```
|
|
||||||
┌─────────────────────────────────────────────────────────────────────┐
|
|
||||||
│ 优惠券状态流转 │
|
|
||||||
├─────────────────────────────────────────────────────────────────────┤
|
|
||||||
│ │
|
|
||||||
│ ┌───────────┐ │
|
|
||||||
│ │ 生成优惠券 │ │
|
|
||||||
│ └─────┬─────┘ │
|
|
||||||
│ │ │
|
|
||||||
│ ▼ │
|
|
||||||
│ ┌───────────┐ │
|
|
||||||
│ ┌─────────│ 未绑定(0) │─────────┐ │
|
|
||||||
│ │ └─────┬─────┘ │ │
|
|
||||||
│ │ │ │ │
|
|
||||||
│ ▼ ▼ ▼ │
|
|
||||||
│ ┌───────────┐ ┌───────────┐ ┌───────────┐ │
|
|
||||||
│ │ 已作废(4) │ │ 已绑定(1) │ │ 已过期(3) │ │
|
|
||||||
│ └───────────┘ └─────┬─────┘ └───────────┘ │
|
|
||||||
│ │ │
|
|
||||||
│ ┌─────────┼─────────┐ │
|
|
||||||
│ │ │ │ │
|
|
||||||
│ ▼ ▼ ▼ │
|
|
||||||
│ ┌───────────┐ ┌───────────┐ │
|
|
||||||
│ │ 已过期(3) │ │ 已使用(2) │ │
|
|
||||||
│ └───────────┘ └───────────┘ │
|
|
||||||
│ │
|
|
||||||
└─────────────────────────────────────────────────────────────────────┘
|
|
||||||
```
|
|
||||||
|
|
||||||
### 图3:核心业务流程图
|
|
||||||
|
|
||||||
```
|
|
||||||
┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
|
|
||||||
│ 创建合作酒店 │ ──> │ 生成优惠券码 │ ──> │ 用户扫码绑定 │ ──> │ 设备端核销 │
|
|
||||||
└─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘
|
|
||||||
│ │ │ │
|
|
||||||
▼ ▼ ▼ ▼
|
|
||||||
酒店基本信息 批量生成二维码 一码一用 订单金额为0
|
|
||||||
合作有效期 可批量下载 绑定用户ID 区分订单类型
|
|
||||||
```
|
|
||||||
|
|
||||||
### 图4:用户扫码绑定流程图
|
|
||||||
|
|
||||||
```
|
|
||||||
┌─────────────────────────────────────────────────────────────────┐
|
|
||||||
│ 用户扫码绑定流程 │
|
|
||||||
├─────────────────────────────────────────────────────────────────┤
|
|
||||||
│ 1. 用户在酒店扫描实体二维码 │
|
|
||||||
│ ↓ │
|
|
||||||
│ 2. 小程序打开绑定页面,获取优惠券码 │
|
|
||||||
│ ↓ │
|
|
||||||
│ 3. 调用绑定接口,获取分布式锁 │
|
|
||||||
│ ↓ │
|
|
||||||
│ 4. 后端校验: │
|
|
||||||
│ ├─ 优惠券是否存在 │
|
|
||||||
│ ├─ 优惠券是否已被绑定 │
|
|
||||||
│ ├─ 优惠券是否已过期 │
|
|
||||||
│ └─ 优惠券是否已作废 │
|
|
||||||
│ ↓ │
|
|
||||||
│ 5. 创建绑定记录 │
|
|
||||||
│ - 计算生效时间(固定时间或绑定后N天) │
|
|
||||||
│ ↓ │
|
|
||||||
│ 6. 更新优惠券状态为"已绑定" │
|
|
||||||
│ ↓ │
|
|
||||||
│ 7. 释放分布式锁,返回绑定成功信息 │
|
|
||||||
└─────────────────────────────────────────────────────────────────┘
|
|
||||||
```
|
|
||||||
|
|
||||||
### 图5:自动核销流程图
|
|
||||||
|
|
||||||
```
|
|
||||||
┌─────────────────────────────────────────────────────────────────┐
|
|
||||||
│ 优惠券核销流程 │
|
|
||||||
├─────────────────────────────────────────────────────────────────┤
|
|
||||||
│ 1. 用户在设备端扫码准备下单 │
|
|
||||||
│ ↓ │
|
|
||||||
│ 2. 前端调用检查可用优惠券接口 │
|
|
||||||
│ ↓ │
|
|
||||||
│ 3. 后端查询用户绑定的有效优惠券 │
|
|
||||||
│ - 状态为有效 │
|
|
||||||
│ - 在有效期内 │
|
|
||||||
│ - 适用于当前景区/设备 │
|
|
||||||
│ ↓ │
|
|
||||||
│ 4. 如有可用优惠券,前端展示"免费体验" │
|
|
||||||
│ ↓ │
|
|
||||||
│ 5. 用户确认下单 │
|
|
||||||
│ ↓ │
|
|
||||||
│ 6. 创建订单 │
|
|
||||||
│ - order_type = 2(优惠券订单) │
|
|
||||||
│ - pay_type = 2(优惠券支付) │
|
|
||||||
│ - order_amount = 0 │
|
|
||||||
│ - coupon_id = 优惠券ID │
|
|
||||||
│ ↓ │
|
|
||||||
│ 7. 调用优惠券核销接口 │
|
|
||||||
│ ↓ │
|
|
||||||
│ 8. 更新优惠券状态和绑定记录状态为"已使用" │
|
|
||||||
│ ↓ │
|
|
||||||
│ 9. 创建核销记录 │
|
|
||||||
│ ↓ │
|
|
||||||
│ 10. 触发设备执行任务 │
|
|
||||||
└─────────────────────────────────────────────────────────────────┘
|
|
||||||
```
|
|
||||||
|
|
||||||
### 图6:数据表关系图
|
|
||||||
|
|
||||||
```
|
|
||||||
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
|
|
||||||
│ partner_hotel │ │ hotel_coupon │ │ coupon_binding │
|
|
||||||
│ (合作酒店表) │ 1───n │ (优惠券表) │ 1───1 │ (绑定记录表) │
|
|
||||||
├──────────────────┤ ├──────────────────┤ ├──────────────────┤
|
|
||||||
│ id (PK) │ │ id (PK) │ │ id (PK) │
|
|
||||||
│ hotel_code (UQ) │◄──────│ hotel_id (FK) │◄──────│ coupon_id (FK) │
|
|
||||||
│ hotel_name │ │ coupon_code (UQ) │ │ coupon_code │
|
|
||||||
│ contact_name │ │ batch_no │ │ user_id │
|
|
||||||
│ cooperation_ │ │ coupon_type │ │ bind_time │
|
|
||||||
│ start_date │ │ valid_start_time │ │ effective_ │
|
|
||||||
│ cooperation_ │ │ valid_end_time │ │ start_time │
|
|
||||||
│ end_date │ │ status │ │ effective_ │
|
|
||||||
│ status │ │ qrcode_url │ │ end_time │
|
|
||||||
│ ... │ │ ... │ │ status │
|
|
||||||
└──────────────────┘ └──────────────────┘ └──────────────────┘
|
|
||||||
│ │
|
|
||||||
│ │
|
|
||||||
▼ ▼
|
|
||||||
┌──────────────────┐ ┌──────────────────┐
|
|
||||||
│ coupon_usage │ │ orders │
|
|
||||||
│ (核销记录表) │ │ (订单表) │
|
|
||||||
├──────────────────┤ ├──────────────────┤
|
|
||||||
│ id (PK) │ │ id (PK) │
|
|
||||||
│ coupon_id │ │ order_no (UQ) │
|
|
||||||
│ binding_id │ │ order_type │
|
|
||||||
│ user_id │ │ coupon_id │
|
|
||||||
│ order_id │───────│ coupon_code │
|
|
||||||
│ order_no │ │ original_amount │
|
|
||||||
│ original_amount │ │ discount_amount │
|
|
||||||
│ discount_amount │ │ order_amount │
|
|
||||||
│ actual_amount │ │ ... │
|
|
||||||
│ usage_time │ └──────────────────┘
|
|
||||||
│ ... │
|
|
||||||
└──────────────────┘
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 六、具体实施方式
|
|
||||||
|
|
||||||
### 6.1 实施例一:优惠券批量生成
|
|
||||||
|
|
||||||
本实施例描述为合作酒店批量生成优惠券的过程:
|
|
||||||
|
|
||||||
**步骤1**:管理员在后台选择合作酒店"XX国际酒店"(ID=1),配置优惠券参数:
|
|
||||||
- 优惠券名称:酒店住客免费体验券
|
|
||||||
- 优惠券类型:免费体验券
|
|
||||||
- 生成数量:1000张
|
|
||||||
- 有效期类型:固定时间
|
|
||||||
- 有效期:2024-11-25 至 2025-11-25
|
|
||||||
- 适用景区:景区A、景区B
|
|
||||||
|
|
||||||
**步骤2**:系统生成批次号:
|
|
||||||
```
|
|
||||||
批次号 = "B" + "20241125" + "0001" = "B202411250001"
|
|
||||||
```
|
|
||||||
|
|
||||||
**步骤3**:循环生成1000个优惠券码:
|
|
||||||
```
|
|
||||||
优惠券码1 = "HC" + "202411250001" + "000001" = "HC202411250001000001"
|
|
||||||
优惠券码2 = "HC" + "202411250001" + "000002" = "HC202411250001000002"
|
|
||||||
...
|
|
||||||
优惠券码1000 = "HC" + "202411250001" + "001000" = "HC202411250001001000"
|
|
||||||
```
|
|
||||||
|
|
||||||
**步骤4**:为每个优惠券码生成二维码,二维码内容:
|
|
||||||
```
|
|
||||||
pages/coupon/bind?code=HC202411250001000001
|
|
||||||
```
|
|
||||||
|
|
||||||
**步骤5**:将二维码图片上传至云存储,保存访问URL。
|
|
||||||
|
|
||||||
**步骤6**:批量插入优惠券记录到数据库:
|
|
||||||
```
|
|
||||||
{
|
|
||||||
coupon_code: "HC202411250001000001",
|
|
||||||
hotel_id: 1,
|
|
||||||
batch_no: "B202411250001",
|
|
||||||
coupon_name: "酒店住客免费体验券",
|
|
||||||
coupon_type: 1,
|
|
||||||
valid_start_time: "2024-11-25 00:00:00",
|
|
||||||
valid_end_time: "2025-11-25 23:59:59",
|
|
||||||
status: 0, // 未绑定
|
|
||||||
applicable_tourism_ids: "1,2",
|
|
||||||
qrcode_url: "https://oss.xxx.com/coupon/HC202411250001000001.png"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 6.2 实施例二:用户扫码绑定
|
|
||||||
|
|
||||||
本实施例描述用户在酒店扫描实体二维码绑定优惠券的过程:
|
|
||||||
|
|
||||||
**前置条件**:酒店已投放优惠券二维码海报,用户已登录小程序。
|
|
||||||
|
|
||||||
**步骤1**:用户张三(user_id=10001)在酒店前台扫描二维码海报。
|
|
||||||
|
|
||||||
**步骤2**:小程序解析二维码获取页面路径:
|
|
||||||
```
|
|
||||||
pages/coupon/bind?code=HC202411250001000001
|
|
||||||
```
|
|
||||||
|
|
||||||
**步骤3**:小程序打开绑定页面,提取优惠券码,调用绑定接口:
|
|
||||||
```
|
|
||||||
POST /coupon/user/bind
|
|
||||||
{
|
|
||||||
"couponCode": "HC202411250001000001"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**步骤4**:后端获取分布式锁,锁键值:
|
|
||||||
```
|
|
||||||
coupon:bind:HC202411250001000001
|
|
||||||
```
|
|
||||||
|
|
||||||
**步骤5**:后端查询优惠券信息并校验:
|
|
||||||
- 优惠券存在 ✓
|
|
||||||
- 状态为未绑定(0) ✓
|
|
||||||
- 在有效期内 ✓
|
|
||||||
- 未被作废 ✓
|
|
||||||
|
|
||||||
**步骤6**:创建绑定记录:
|
|
||||||
```
|
|
||||||
{
|
|
||||||
coupon_id: 1,
|
|
||||||
coupon_code: "HC202411250001000001",
|
|
||||||
user_id: 10001,
|
|
||||||
user_openid: "oXXXXX",
|
|
||||||
bind_time: "2024-11-26 10:30:00",
|
|
||||||
bind_source: 1, // 扫码绑定
|
|
||||||
effective_start_time: "2024-11-25 00:00:00",
|
|
||||||
effective_end_time: "2025-11-25 23:59:59",
|
|
||||||
status: 1 // 有效
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**步骤7**:更新优惠券状态为已绑定:
|
|
||||||
```
|
|
||||||
UPDATE hotel_coupon SET status = 1 WHERE id = 1
|
|
||||||
```
|
|
||||||
|
|
||||||
**步骤8**:释放分布式锁,返回绑定成功:
|
|
||||||
```
|
|
||||||
{
|
|
||||||
"code": 0,
|
|
||||||
"msg": "绑定成功",
|
|
||||||
"data": {
|
|
||||||
"couponName": "酒店住客免费体验券",
|
|
||||||
"effectiveEndTime": "2025-11-25 23:59:59",
|
|
||||||
"applicableTourisms": ["景区A", "景区B"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 6.3 实施例三:设备端自动核销
|
|
||||||
|
|
||||||
本实施例描述用户在景区设备端使用优惠券下单的自动核销过程:
|
|
||||||
|
|
||||||
**前置条件**:用户张三已绑定优惠券,现在景区A的设备DEVICE001前准备下单。
|
|
||||||
|
|
||||||
**步骤1**:用户扫描设备二维码进入下单页面。
|
|
||||||
|
|
||||||
**步骤2**:前端调用可用优惠券检测接口:
|
|
||||||
```
|
|
||||||
GET /coupon/user/check-available?tourismId=1&deviceSn=DEVICE001
|
|
||||||
```
|
|
||||||
|
|
||||||
**步骤3**:后端查询用户可用优惠券:
|
|
||||||
```sql
|
|
||||||
SELECT cb.*, hc.* FROM coupon_binding cb
|
|
||||||
JOIN hotel_coupon hc ON cb.coupon_id = hc.id
|
|
||||||
WHERE cb.user_id = 10001
|
|
||||||
AND cb.status = 1
|
|
||||||
AND cb.effective_end_time > NOW()
|
|
||||||
AND (hc.applicable_tourism_ids IS NULL
|
|
||||||
OR FIND_IN_SET('1', hc.applicable_tourism_ids))
|
|
||||||
```
|
|
||||||
|
|
||||||
**步骤4**:返回可用优惠券信息:
|
|
||||||
```
|
|
||||||
{
|
|
||||||
"hasCoupon": true,
|
|
||||||
"coupon": {
|
|
||||||
"couponId": 1,
|
|
||||||
"couponName": "酒店住客免费体验券",
|
|
||||||
"couponType": 1,
|
|
||||||
"discountValue": 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**步骤5**:前端展示"您有可用的免费体验券",用户点击确认使用。
|
|
||||||
|
|
||||||
**步骤6**:创建订单,设置订单类型为优惠券订单:
|
|
||||||
```
|
|
||||||
{
|
|
||||||
order_no: "ORD202411260001",
|
|
||||||
order_type: 2, // 优惠券订单
|
|
||||||
pay_type: 2, // 优惠券支付
|
|
||||||
coupon_id: 1,
|
|
||||||
coupon_code: "HC202411250001000001",
|
|
||||||
original_amount: 99.00,
|
|
||||||
discount_amount: 99.00,
|
|
||||||
order_amount: 0.00, // 实付金额为0
|
|
||||||
order_status: 2 // 已支付(无需支付)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**步骤7**:调用优惠券核销接口:
|
|
||||||
```
|
|
||||||
POST /coupon/internal/use
|
|
||||||
{
|
|
||||||
"userId": 10001,
|
|
||||||
"couponId": 1,
|
|
||||||
"orderId": 1,
|
|
||||||
"orderNo": "ORD202411260001",
|
|
||||||
"tourismId": 1,
|
|
||||||
"tourismName": "景区A",
|
|
||||||
"deviceSn": "DEVICE001",
|
|
||||||
"originalAmount": 99.00
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**步骤8**:更新优惠券和绑定记录状态为已使用:
|
|
||||||
```sql
|
|
||||||
UPDATE hotel_coupon SET status = 2 WHERE id = 1;
|
|
||||||
UPDATE coupon_binding SET status = 2 WHERE coupon_id = 1;
|
|
||||||
```
|
|
||||||
|
|
||||||
**步骤9**:创建核销记录:
|
|
||||||
```
|
|
||||||
{
|
|
||||||
coupon_id: 1,
|
|
||||||
coupon_code: "HC202411250001000001",
|
|
||||||
binding_id: 1,
|
|
||||||
user_id: 10001,
|
|
||||||
order_id: 1,
|
|
||||||
order_no: "ORD202411260001",
|
|
||||||
tourism_id: 1,
|
|
||||||
tourism_name: "景区A",
|
|
||||||
device_sn: "DEVICE001",
|
|
||||||
original_amount: 99.00,
|
|
||||||
discount_amount: 99.00,
|
|
||||||
actual_amount: 0.00,
|
|
||||||
usage_time: "2024-11-26 14:30:00",
|
|
||||||
usage_type: 1 // 自动核销
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**步骤10**:触发设备执行任务,完成服务交付。
|
|
||||||
|
|
||||||
### 6.4 实施例四:绑定后N天有效期计算
|
|
||||||
|
|
||||||
本实施例描述"绑定后N天有效"类型优惠券的有效期计算:
|
|
||||||
|
|
||||||
**配置**:优惠券配置为"绑定后30天有效"。
|
|
||||||
|
|
||||||
**绑定时间**:2024-11-26 10:30:00
|
|
||||||
|
|
||||||
**有效期计算**:
|
|
||||||
```
|
|
||||||
effective_start_time = 绑定时间 = 2024-11-26 10:30:00
|
|
||||||
effective_end_time = 绑定时间 + 30天 = 2024-12-26 10:30:00
|
|
||||||
```
|
|
||||||
|
|
||||||
**存储的绑定记录**:
|
|
||||||
```
|
|
||||||
{
|
|
||||||
bind_time: "2024-11-26 10:30:00",
|
|
||||||
effective_start_time: "2024-11-26 10:30:00",
|
|
||||||
effective_end_time: "2024-12-26 10:30:00"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 6.5 实施例五:并发绑定控制
|
|
||||||
|
|
||||||
本实施例描述两个用户同时扫描同一优惠券二维码时的处理:
|
|
||||||
|
|
||||||
**场景**:用户A和用户B同时扫描优惠券码HC202411250001000001。
|
|
||||||
|
|
||||||
**时序**:
|
|
||||||
```
|
|
||||||
T1: 用户A调用绑定接口
|
|
||||||
T2: 用户A尝试获取分布式锁,成功
|
|
||||||
T3: 用户B调用绑定接口
|
|
||||||
T4: 用户B尝试获取分布式锁,等待
|
|
||||||
T5: 用户A完成绑定,释放锁
|
|
||||||
T6: 用户B获取到锁
|
|
||||||
T7: 用户B查询优惠券状态,发现已被绑定
|
|
||||||
T8: 用户B返回错误:优惠券已被其他用户绑定
|
|
||||||
T9: 用户B释放锁
|
|
||||||
```
|
|
||||||
|
|
||||||
**结果**:只有用户A成功绑定优惠券,用户B收到"优惠券已被其他用户绑定"的提示。
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 七、权利要求书
|
|
||||||
|
|
||||||
### 权利要求1
|
|
||||||
|
|
||||||
一种基于实体二维码的酒店优惠券发放与自动核销系统,其特征在于,包括:
|
|
||||||
|
|
||||||
合作酒店管理模块,用于管理与景区建立合作关系的酒店信息;
|
|
||||||
|
|
||||||
优惠券批量生成模块,用于为指定酒店批量生成带有唯一标识码的优惠券,并为每张优惠券生成对应的二维码图片;
|
|
||||||
|
|
||||||
二维码图片管理模块,用于将二维码图片上传至云存储并支持批量下载,供酒店制作实体二维码投放;
|
|
||||||
|
|
||||||
用户扫码绑定模块,用于处理用户扫描实体二维码后的绑定请求,采用分布式锁机制确保一码只能被一个用户绑定;
|
|
||||||
|
|
||||||
可用优惠券检测模块,用于在用户下单前根据当前景区和设备信息检测是否有可用优惠券;
|
|
||||||
|
|
||||||
自动核销模块,用于在订单创建时自动完成优惠券核销,更新优惠券状态并创建核销记录。
|
|
||||||
|
|
||||||
### 权利要求2
|
|
||||||
|
|
||||||
根据权利要求1所述的系统,其特征在于,所述优惠券批量生成模块支持配置多种优惠券类型,包括免费体验券、折扣券和满减券,并支持配置适用范围包括指定景区和指定设备。
|
|
||||||
|
|
||||||
### 权利要求3
|
|
||||||
|
|
||||||
根据权利要求1所述的系统,其特征在于,所述优惠券批量生成模块支持两种有效期策略:固定时间有效期和绑定后N天有效期,所述用户扫码绑定模块根据有效期策略计算优惠券的实际生效时间。
|
|
||||||
|
|
||||||
### 权利要求4
|
|
||||||
|
|
||||||
根据权利要求1所述的系统,其特征在于,所述用户扫码绑定模块的具体处理过程为:
|
|
||||||
|
|
||||||
解析二维码获取优惠券码;
|
|
||||||
|
|
||||||
获取分布式锁;
|
|
||||||
|
|
||||||
校验优惠券状态,确保未被绑定、未过期、未作废;
|
|
||||||
|
|
||||||
根据有效期策略计算优惠券的实际生效开始时间和结束时间;
|
|
||||||
|
|
||||||
创建优惠券与用户的绑定记录;
|
|
||||||
|
|
||||||
更新优惠券状态为已绑定;
|
|
||||||
|
|
||||||
释放分布式锁。
|
|
||||||
|
|
||||||
### 权利要求5
|
|
||||||
|
|
||||||
根据权利要求1所述的系统,其特征在于,所述自动核销模块在订单创建流程中嵌入核销逻辑,根据优惠券类型计算优惠金额,创建标记为优惠券订单的订单记录,并在订单中记录优惠券标识和优惠金额。
|
|
||||||
|
|
||||||
### 权利要求6
|
|
||||||
|
|
||||||
根据权利要求1所述的系统,其特征在于,还包括:
|
|
||||||
|
|
||||||
过期处理模块,用于定时扫描超过有效期的优惠券,更新未使用的过期优惠券状态和过期的绑定记录状态;
|
|
||||||
|
|
||||||
数据统计模块,用于按酒店、按批次统计优惠券的发放、绑定、使用、过期数量。
|
|
||||||
|
|
||||||
### 权利要求7
|
|
||||||
|
|
||||||
一种基于实体二维码的酒店优惠券发放与自动核销方法,其特征在于,包括以下步骤:
|
|
||||||
|
|
||||||
S1:为合作酒店批量生成带有唯一标识码的优惠券,并为每张优惠券生成对应的二维码图片上传至云存储;
|
|
||||||
|
|
||||||
S2:将二维码图片批量下载并制作成实体二维码投放至酒店;
|
|
||||||
|
|
||||||
S3:用户扫描实体二维码后,系统获取分布式锁,校验优惠券状态后创建用户与优惠券的绑定关系;
|
|
||||||
|
|
||||||
S4:用户在景区设备端下单时,系统检测用户是否有适用于当前景区和设备的可用优惠券;
|
|
||||||
|
|
||||||
S5:若有可用优惠券,创建优惠券订单,根据优惠券类型计算优惠金额,自动完成优惠券核销。
|
|
||||||
|
|
||||||
### 权利要求8
|
|
||||||
|
|
||||||
根据权利要求7所述的方法,其特征在于,步骤S3中获取分布式锁的锁键值为优惠券码,确保同一优惠券在同一时刻只能被一个用户绑定。
|
|
||||||
|
|
||||||
### 权利要求9
|
|
||||||
|
|
||||||
根据权利要求7所述的方法,其特征在于,步骤S3中根据优惠券配置的有效期策略计算实际生效时间:若为固定时间策略,使用配置的有效期;若为绑定后N天策略,以绑定时间为起点计算有效期。
|
|
||||||
|
|
||||||
### 权利要求10
|
|
||||||
|
|
||||||
根据权利要求7所述的方法,其特征在于,步骤S5中自动核销的具体过程为:
|
|
||||||
|
|
||||||
在订单中设置订单类型为优惠券订单;
|
|
||||||
|
|
||||||
根据优惠券类型计算优惠金额和实付金额;
|
|
||||||
|
|
||||||
记录优惠券标识和优惠金额到订单;
|
|
||||||
|
|
||||||
更新优惠券状态和绑定记录状态为已使用;
|
|
||||||
|
|
||||||
创建包含核销详情的核销记录。
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 八、摘要
|
|
||||||
|
|
||||||
### 说明书摘要
|
|
||||||
|
|
||||||
本发明公开了一种基于实体二维码的酒店优惠券发放与自动核销系统及方法,涉及电子商务与旅游信息化技术领域。系统包括合作酒店管理模块、优惠券批量生成模块、二维码图片管理模块、用户扫码绑定模块、可用优惠券检测模块和自动核销模块。通过为每张优惠券生成唯一标识码和对应二维码,制作成实体二维码投放至酒店,用户扫码后完成绑定,在景区设备端下单时自动检测并核销优惠券。本发明采用分布式锁机制确保一码一用,支持多种优惠券类型和灵活的有效期策略,将核销逻辑嵌入订单创建流程实现自动核销,具有发放效率高、核销自动化、防滥用、数据可追溯等优点。
|
|
||||||
|
|
||||||
### 摘要附图
|
|
||||||
|
|
||||||
(选用图3:核心业务流程图)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 九、附加说明
|
|
||||||
|
|
||||||
### 9.1 技术关键点
|
|
||||||
|
|
||||||
1. **一码一用机制**:每个优惠券码全局唯一,通过分布式锁防止并发绑定,确保一个优惠券只能被一个用户使用。
|
|
||||||
|
|
||||||
2. **实体二维码投放**:将数字优惠券转化为实体二维码,无需酒店人员培训,降低合作门槛。
|
|
||||||
|
|
||||||
3. **自动核销集成**:核销逻辑与订单创建流程无缝集成,用户无感知完成核销,提升体验。
|
|
||||||
|
|
||||||
4. **灵活有效期策略**:支持固定时间和绑定后N天两种策略,适应不同营销场景。
|
|
||||||
|
|
||||||
5. **精准适用范围**:可限定优惠券适用的景区和设备,实现精细化营销。
|
|
||||||
|
|
||||||
### 9.2 应用场景
|
|
||||||
|
|
||||||
- 酒店与景区合作营销
|
|
||||||
- 酒店与游乐园合作营销
|
|
||||||
- 民宿与周边景点合作营销
|
|
||||||
- 其他需要线下发放、线上核销的优惠券场景
|
|
||||||
|
|
||||||
### 9.3 技术创新点
|
|
||||||
|
|
||||||
1. 首次提出将实体二维码与一码一用机制结合的酒店优惠券发放方案
|
|
||||||
2. 首次实现优惠券核销与订单创建流程的无缝集成
|
|
||||||
3. 首次提出支持"绑定后N天有效"的动态有效期计算机制
|
|
||||||
4. 首次将分布式锁应用于优惠券绑定场景防止并发滥用
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**申请人**:湖北高飞智航科技有限责任公司
|
|
||||||
|
|
||||||
**发明人**:杜志超
|
|
||||||
|
|
||||||
**申请日期**:2025年12月01日
|
|
||||||
|
|
||||||
**文档版本**:v1.0
|
|
||||||
@@ -1,218 +0,0 @@
|
|||||||
# 优惠券核销订单状态更新设计说明
|
|
||||||
|
|
||||||
## 功能概述
|
|
||||||
|
|
||||||
当优惠券核销成功后,需要自动更新订单中心的订单状态为"已支付",以便订单能够进入正常的业务流程(排队、执行等)。
|
|
||||||
|
|
||||||
## 设计方案
|
|
||||||
|
|
||||||
### 1. 绑定关系设计
|
|
||||||
|
|
||||||
在 `t_ctrip_order` 表中添加 `order_no` 字段,建立携程订单与订单中心订单的关联关系:
|
|
||||||
|
|
||||||
```sql
|
|
||||||
ALTER TABLE `t_ctrip_order`
|
|
||||||
ADD COLUMN `order_no` varchar(50) DEFAULT NULL COMMENT '关联的订单中心订单号' AFTER `ota_order_id`;
|
|
||||||
|
|
||||||
-- 添加索引
|
|
||||||
ALTER TABLE `t_ctrip_order` ADD INDEX `idx_order_no` (`order_no`);
|
|
||||||
ALTER TABLE `t_ctrip_order` ADD UNIQUE INDEX `uk_order_no` (`order_no`);
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. 数据流程
|
|
||||||
|
|
||||||
```
|
|
||||||
用户下单 → 创建订单中心订单 → 关联携程订单 → 核销优惠券 → 更新订单状态
|
|
||||||
```
|
|
||||||
|
|
||||||
1. **用户下单时**:在订单中心创建订单,记录订单号
|
|
||||||
2. **关联携程订单**:将订单中心的订单号关联到携程订单的 `order_no` 字段
|
|
||||||
3. **核销优惠券**:调用携程核销接口
|
|
||||||
4. **更新订单状态**:核销成功后,通过 `order_no` 调用订单中心接口更新订单状态
|
|
||||||
|
|
||||||
### 3. 核心组件
|
|
||||||
|
|
||||||
#### 3.1 数据库表结构
|
|
||||||
|
|
||||||
**t_ctrip_order 表新增字段:**
|
|
||||||
- `order_no` varchar(50) - 关联的订单中心订单号
|
|
||||||
|
|
||||||
#### 3.2 实体类更新
|
|
||||||
|
|
||||||
**CtripOrder.java:**
|
|
||||||
```java
|
|
||||||
/**
|
|
||||||
* 关联的订单中心订单号
|
|
||||||
*/
|
|
||||||
private String orderNo;
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 3.3 Mapper 接口
|
|
||||||
|
|
||||||
**CtripOrderMapper.java:**
|
|
||||||
```java
|
|
||||||
/**
|
|
||||||
* 根据订单中心订单号查询携程订单
|
|
||||||
*/
|
|
||||||
CtripOrder selectByOrderNo(@Param("orderNo") String orderNo);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 3.4 Feign 客户端
|
|
||||||
|
|
||||||
**OrderCenterService.java:**
|
|
||||||
```java
|
|
||||||
/**
|
|
||||||
* 更新订单状态为已支付(优惠券核销成功后调用)
|
|
||||||
*/
|
|
||||||
@PostMapping("/order/{orderNo}/status/paid")
|
|
||||||
Result<String> updateOrderStatusToPaid(@PathVariable("orderNo") String orderNo);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据订单号获取订单信息
|
|
||||||
*/
|
|
||||||
@GetMapping("/order/{orderNo}")
|
|
||||||
Result<OrderInfo> getOrderByOrderNo(@PathVariable("orderNo") String orderNo);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 3.5 订单中心接口
|
|
||||||
|
|
||||||
**OrderController.java 新增接口:**
|
|
||||||
```java
|
|
||||||
@Operation(summary = "更新订单状态为已支付(优惠券核销成功后调用)")
|
|
||||||
@PostMapping("/order/{orderNo}/status/paid")
|
|
||||||
public Result<String> updateOrderStatusToPaid(@PathVariable("orderNo") String orderNo)
|
|
||||||
|
|
||||||
@Operation(summary = "根据订单号获取订单信息")
|
|
||||||
@GetMapping("/order/{orderNo}")
|
|
||||||
public Result<Order> getOrderByOrderNo(@PathVariable("orderNo") String orderNo)
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4. 核销流程更新
|
|
||||||
|
|
||||||
#### 4.1 核销服务更新
|
|
||||||
|
|
||||||
**CtripConsumedServiceImpl.java:**
|
|
||||||
```java
|
|
||||||
/**
|
|
||||||
* 更新订单中心订单状态
|
|
||||||
*/
|
|
||||||
private void updateOrderCenterStatus(CtripOrder order) {
|
|
||||||
try {
|
|
||||||
if (StringUtils.hasText(order.getOrderNo())) {
|
|
||||||
log.info("开始更新订单中心订单状态,orderNo: {}", order.getOrderNo());
|
|
||||||
|
|
||||||
// 调用订单中心接口更新订单状态为已支付(状态1)
|
|
||||||
Result<String> result = orderCenterService.updateOrderStatusToPaid(order.getOrderNo());
|
|
||||||
|
|
||||||
if (result != null && result.getResp_code() == 0) {
|
|
||||||
log.info("订单中心订单状态更新成功,orderNo: {}", order.getOrderNo());
|
|
||||||
} else {
|
|
||||||
log.error("订单中心订单状态更新失败,orderNo: {}, result: {}",
|
|
||||||
order.getOrderNo(), result);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.warn("携程订单未关联订单中心订单号,无法更新订单状态,otaOrderId: {}",
|
|
||||||
order.getOtaOrderId());
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("更新订单中心订单状态异常,orderNo: {}", order.getOrderNo(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 5. 订单状态映射
|
|
||||||
|
|
||||||
| 订单中心状态 | 状态值 | 说明 |
|
|
||||||
|-------------|--------|------|
|
|
||||||
| UNPAID | 0 | 待支付 |
|
|
||||||
| PAID | 1 | 已支付排队中 |
|
|
||||||
| CANCELED | 2 | 已取消 |
|
|
||||||
| COMPLETE | 3 | 设备执行完成 |
|
|
||||||
| DOING | 4 | 正在服务中 |
|
|
||||||
| UPLOADING | 5 | 素材上传中 |
|
|
||||||
| UPLOADED | 6 | 素材上传完成 |
|
|
||||||
|
|
||||||
**核销成功后更新为:**
|
|
||||||
- 订单状态:`PAID` (1) - 已支付排队中
|
|
||||||
- 支付类型:`COUPON_PAY` (2) - 优惠券支付
|
|
||||||
- 支付时间:当前时间
|
|
||||||
|
|
||||||
### 6. 使用方式
|
|
||||||
|
|
||||||
#### 6.1 创建订单时建立关联
|
|
||||||
|
|
||||||
```java
|
|
||||||
// 1. 创建订单中心订单
|
|
||||||
Order order = new Order();
|
|
||||||
order.setOrderNo("ORDER_20250901_001");
|
|
||||||
// ... 设置其他字段
|
|
||||||
orderService.createOrder(order);
|
|
||||||
|
|
||||||
// 2. 创建携程订单并关联
|
|
||||||
CtripOrder ctripOrder = new CtripOrder();
|
|
||||||
ctripOrder.setOtaOrderId("ctriptest-xxx");
|
|
||||||
ctripOrder.setOrderNo("ORDER_20250901_001"); // 关联订单号
|
|
||||||
// ... 设置其他字段
|
|
||||||
ctripOrderMapper.insert(ctripOrder);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 6.2 核销时自动更新状态
|
|
||||||
|
|
||||||
```java
|
|
||||||
// 核销成功后,系统会自动:
|
|
||||||
// 1. 更新携程订单状态为已使用(状态8)
|
|
||||||
// 2. 调用订单中心接口更新订单状态为已支付(状态1)
|
|
||||||
// 3. 设置支付类型为优惠券支付(类型2)
|
|
||||||
```
|
|
||||||
|
|
||||||
### 7. 错误处理
|
|
||||||
|
|
||||||
#### 7.1 关联关系不存在
|
|
||||||
- 日志记录:`携程订单未关联订单中心订单号,无法更新订单状态`
|
|
||||||
- 不影响核销流程,只影响订单状态更新
|
|
||||||
|
|
||||||
#### 7.2 订单中心接口调用失败
|
|
||||||
- 日志记录:`订单中心订单状态更新失败`
|
|
||||||
- 不影响核销流程,只影响订单状态更新
|
|
||||||
|
|
||||||
#### 7.3 订单状态不正确
|
|
||||||
- 只有 `UNPAID` 状态的订单才能更新为 `PAID`
|
|
||||||
- 其他状态会返回错误信息
|
|
||||||
|
|
||||||
### 8. 监控和日志
|
|
||||||
|
|
||||||
#### 8.1 关键日志点
|
|
||||||
- 核销开始:`开始执行核销订单`
|
|
||||||
- 状态更新开始:`开始更新订单中心订单状态`
|
|
||||||
- 状态更新成功:`订单中心订单状态更新成功`
|
|
||||||
- 状态更新失败:`订单中心订单状态更新失败`
|
|
||||||
|
|
||||||
#### 8.2 监控指标
|
|
||||||
- 核销成功率
|
|
||||||
- 订单状态更新成功率
|
|
||||||
- 接口调用响应时间
|
|
||||||
|
|
||||||
### 9. 注意事项
|
|
||||||
|
|
||||||
1. **数据一致性**:确保携程订单和订单中心订单的关联关系正确
|
|
||||||
2. **幂等性**:多次核销同一订单时,状态更新应该是幂等的
|
|
||||||
3. **事务性**:核销和状态更新应该在同一个事务中
|
|
||||||
4. **异常处理**:订单中心接口调用失败不应影响核销流程
|
|
||||||
5. **性能考虑**:状态更新是异步的,不应阻塞核销流程
|
|
||||||
|
|
||||||
### 10. 测试验证
|
|
||||||
|
|
||||||
#### 10.1 单元测试
|
|
||||||
- 测试核销流程
|
|
||||||
- 测试状态更新逻辑
|
|
||||||
- 测试异常情况处理
|
|
||||||
|
|
||||||
#### 10.2 集成测试
|
|
||||||
- 测试完整的核销到状态更新流程
|
|
||||||
- 测试订单中心接口调用
|
|
||||||
- 测试数据一致性
|
|
||||||
|
|
||||||
#### 10.3 端到端测试
|
|
||||||
- 测试用户下单到核销的完整流程
|
|
||||||
- 测试订单状态变化
|
|
||||||
- 测试业务流程连续性
|
|
||||||
@@ -1,398 +0,0 @@
|
|||||||
# 前端优惠券查询核销接口文档
|
|
||||||
|
|
||||||
## 概述
|
|
||||||
|
|
||||||
本文档描述了前端查询可核销订单和核销优惠券的完整接口流程。
|
|
||||||
|
|
||||||
## 基础信息
|
|
||||||
|
|
||||||
- **服务地址**: `http://localhost:8002/coupon`
|
|
||||||
- **接口前缀**: `/api/order-detail`
|
|
||||||
- **请求方式**: POST/GET
|
|
||||||
- **数据格式**: JSON
|
|
||||||
|
|
||||||
## 1. 查询可核销订单接口
|
|
||||||
|
|
||||||
### 接口信息
|
|
||||||
- **接口地址**: `POST /api/order-detail/query`
|
|
||||||
- **功能描述**: 根据二维码ID查询可核销的订单(手机号从登录上下文获取,价格从二维码信息获取)
|
|
||||||
- **请求方式**: POST
|
|
||||||
|
|
||||||
### 请求参数
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"codeId": "5e0b3d9d-fc1a-4c8f-9c1a-7f4d2d9b6a11",
|
|
||||||
"page": 1,
|
|
||||||
"size": 10
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 参数说明
|
|
||||||
|
|
||||||
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
|
||||||
|--------|------|------|--------|------|
|
|
||||||
| codeId | String | 是 | - | 二维码ID(订单中的codeId) |
|
|
||||||
| page | Integer | 否 | 1 | 页码,从1开始(必须 ≥ 1) |
|
|
||||||
| size | Integer | 否 | 10 | 每页数量(必须 ≥ 1,最大100) |
|
|
||||||
|
|
||||||
说明:
|
|
||||||
- 后端通过 `LoginUserContextHolder.getUser().getMobile()` 获取用户手机号。
|
|
||||||
- 后端通过 Feign 调用订单中心 `/qrcode/{codeId}` 获取二维码信息中的价格,并据此匹配订单金额。
|
|
||||||
- **重要**:页码从1开始,不是从0开始。如果传入page=0,系统会自动调整为page=1。
|
|
||||||
- 页大小限制在1-100之间,超出范围会自动调整。
|
|
||||||
|
|
||||||
### 响应结果
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"resp_code": 0,
|
|
||||||
"resp_msg": "",
|
|
||||||
"data": {
|
|
||||||
"count": 1,
|
|
||||||
"resp_code": 0,
|
|
||||||
"data": [
|
|
||||||
{
|
|
||||||
"orderId": 137,
|
|
||||||
"otaOrderId": "ctriptest-10816828-454259-145573",
|
|
||||||
"supplierOrderId": "SUPPLIER_ctriptest-10816828-454259-145573_301495ef",
|
|
||||||
"orderStatus": 13,
|
|
||||||
"orderStatusDesc": "支付确认",
|
|
||||||
"totalAmount": 2.0,
|
|
||||||
"currency": "CNY",
|
|
||||||
"createTime": "2025-09-01T10:30:00",
|
|
||||||
"canConsume": true,
|
|
||||||
"consumeReason": null,
|
|
||||||
"orderItems": [
|
|
||||||
{
|
|
||||||
"itemId": 456,
|
|
||||||
"productId": "1801589811",
|
|
||||||
"itemName": "门票",
|
|
||||||
"itemType": "1",
|
|
||||||
"plu": "1",
|
|
||||||
"quantity": 2,
|
|
||||||
"unitPrice": 1.0,
|
|
||||||
"totalPrice": 2.0,
|
|
||||||
"currency": "CNY",
|
|
||||||
"useStartDate": "2025-07-25",
|
|
||||||
"useEndDate": "2025-07-25",
|
|
||||||
"canConsume": true,
|
|
||||||
"usedQuantity": 0,
|
|
||||||
"availableQuantity": 2
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"passengers": [
|
|
||||||
{
|
|
||||||
"passengerId": "PASS_1",
|
|
||||||
"passengerName": "张三",
|
|
||||||
"phone": "18322694510",
|
|
||||||
"passengerStatus": 0,
|
|
||||||
"passengerStatusDesc": "未使用",
|
|
||||||
"idCard": "110101199001011234",
|
|
||||||
"gender": "ADULT",
|
|
||||||
"age": null
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"contact": {
|
|
||||||
"name": "张三",
|
|
||||||
"mobile": "18322694510",
|
|
||||||
"email": "zhangsan@example.com",
|
|
||||||
"contactType": "CONTACT"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 响应字段说明
|
|
||||||
|
|
||||||
#### 订单信息 (OrderDetailVO)
|
|
||||||
| 字段名 | 类型 | 说明 |
|
|
||||||
|--------|------|------|
|
|
||||||
| orderId | Long | 订单ID |
|
|
||||||
| otaOrderId | String | 携程订单号 |
|
|
||||||
| supplierOrderId | String | 供应商订单号 |
|
|
||||||
| orderStatus | Integer | 订单状态码 |
|
|
||||||
| orderStatusDesc | String | 订单状态描述 |
|
|
||||||
| totalAmount | BigDecimal | 订单总金额 |
|
|
||||||
| currency | String | 货币类型 |
|
|
||||||
| createTime | String | 创建时间 |
|
|
||||||
| canConsume | Boolean | 是否可核销 |
|
|
||||||
| consumeReason | String | 不可核销原因(如果不可核销) |
|
|
||||||
|
|
||||||
#### 订单项信息 (OrderItemDetailVO)
|
|
||||||
| 字段名 | 类型 | 说明 |
|
|
||||||
|--------|------|------|
|
|
||||||
| itemId | Long | 订单项ID |
|
|
||||||
| productId | String | 商品ID(用于核销) |
|
|
||||||
| itemName | String | 商品名称 |
|
|
||||||
| itemType | String | 商品类型 |
|
|
||||||
| plu | String | 商品编码 |
|
|
||||||
| quantity | Integer | 总数量 |
|
|
||||||
| unitPrice | BigDecimal | 单价 |
|
|
||||||
| totalPrice | BigDecimal | 总价 |
|
|
||||||
| currency | String | 货币类型 |
|
|
||||||
| useStartDate | String | 使用开始日期 |
|
|
||||||
| useEndDate | String | 使用结束日期 |
|
|
||||||
| canConsume | Boolean | 是否可核销 |
|
|
||||||
| usedQuantity | Integer | 已使用数量 |
|
|
||||||
| availableQuantity | Integer | 可用数量 |
|
|
||||||
|
|
||||||
#### 乘客信息 (PassengerDetailVO)
|
|
||||||
| 字段名 | 类型 | 说明 |
|
|
||||||
|--------|------|------|
|
|
||||||
| passengerId | String | 乘客ID |
|
|
||||||
| passengerName | String | 乘客姓名 |
|
|
||||||
| phone | String | 乘客手机号 |
|
|
||||||
| passengerStatus | Integer | 乘客状态 |
|
|
||||||
| passengerStatusDesc | String | 乘客状态描述 |
|
|
||||||
| idCard | String | 身份证号 |
|
|
||||||
| gender | String | 性别 |
|
|
||||||
| age | Integer | 年龄 |
|
|
||||||
|
|
||||||
#### 联系人信息 (ContactDetailVO)
|
|
||||||
| 字段名 | 类型 | 说明 |
|
|
||||||
|--------|------|------|
|
|
||||||
| name | String | 联系人姓名 |
|
|
||||||
| mobile | String | 联系人手机号 |
|
|
||||||
| email | String | 联系人邮箱 |
|
|
||||||
| contactType | String | 联系人类型 |
|
|
||||||
|
|
||||||
## 2. 简化核销接口(推荐)
|
|
||||||
|
|
||||||
### 接口信息
|
|
||||||
- **接口地址**: `POST /api/order-detail/consume-simple`
|
|
||||||
- **功能描述**: 核销单个订单项
|
|
||||||
- **请求方式**: POST
|
|
||||||
|
|
||||||
### 请求参数
|
|
||||||
|
|
||||||
| 参数名 | 类型 | 必填 | 说明 |
|
|
||||||
|--------|------|------|------|
|
|
||||||
| otaOrderId | String | 是 | 携程订单号 |
|
|
||||||
| orderNo | String | 否 | 关联的订单中心订单号(用于更新订单状态) |
|
|
||||||
| itemId | String | 是 | 商品ID |
|
|
||||||
| useQuantity | Integer | 是 | 核销数量 |
|
|
||||||
| remark | String | 否 | 备注信息 |
|
|
||||||
|
|
||||||
**请求示例:**
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"otaOrderId": "ctriptest-10816828-454259-145573",
|
|
||||||
"orderNo": "ORDER_20250901_001",
|
|
||||||
"itemId": "1801589811",
|
|
||||||
"useQuantity": 1,
|
|
||||||
"remark": "使用优惠券核销门票"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**业务逻辑:**
|
|
||||||
1. 验证携程订单是否存在且可核销
|
|
||||||
2. 如果传入了 `orderNo`,建立携程订单与订单中心订单的关联关系
|
|
||||||
3. 执行核销操作,更新携程订单状态为已使用(状态8)
|
|
||||||
4. 如果有关联的订单号,自动调用订单中心接口更新订单状态为已支付(状态1)
|
|
||||||
5. 设置支付类型为优惠券支付(类型2)
|
|
||||||
|
|
||||||
### 参数说明
|
|
||||||
|
|
||||||
| 参数名 | 类型 | 必填 | 说明 |
|
|
||||||
|--------|------|------|------|
|
|
||||||
| otaOrderId | String | 是 | 携程订单号 |
|
|
||||||
| itemId | String | 是 | 商品ID(使用查询接口返回的productId) |
|
|
||||||
| useQuantity | Integer | 是 | 核销数量 |
|
|
||||||
| remark | String | 否 | 备注信息 |
|
|
||||||
|
|
||||||
### 响应结果
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"resp_code": 0,
|
|
||||||
"resp_msg": "核销成功",
|
|
||||||
"data": true
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 错误响应
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"resp_code": 1,
|
|
||||||
"resp_msg": "核销失败: 订单不存在",
|
|
||||||
"data": false
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 3. 复杂核销接口(支持批量)
|
|
||||||
|
|
||||||
### 接口信息
|
|
||||||
- **接口地址**: `POST /api/order-detail/consume`
|
|
||||||
- **功能描述**: 批量核销多个订单项
|
|
||||||
- **请求方式**: POST
|
|
||||||
|
|
||||||
### 请求参数
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"otaOrderId": "ctriptest-10816828-454259-145573",
|
|
||||||
"supplierOrderId": "SUPPLIER_ctriptest-10816828-454259-145573_301495ef",
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"itemId": "1801589811",
|
|
||||||
"plu": "1",
|
|
||||||
"quantity": 1,
|
|
||||||
"passengerIds": ["PASS_1"],
|
|
||||||
"voucherIds": ["VOUCHER_1"]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"remark": "使用优惠券核销门票"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 参数说明
|
|
||||||
|
|
||||||
| 参数名 | 类型 | 必填 | 说明 |
|
|
||||||
|--------|------|------|------|
|
|
||||||
| otaOrderId | String | 是 | 携程订单号 |
|
|
||||||
| supplierOrderId | String | 是 | 供应商订单号 |
|
|
||||||
| items | Array | 是 | 核销项目列表 |
|
|
||||||
| remark | String | 否 | 备注信息 |
|
|
||||||
|
|
||||||
#### items数组元素
|
|
||||||
| 参数名 | 类型 | 必填 | 说明 |
|
|
||||||
|--------|------|------|------|
|
|
||||||
| itemId | String | 是 | 商品ID |
|
|
||||||
| plu | String | 是 | 商品编码 |
|
|
||||||
| quantity | Integer | 是 | 核销数量 |
|
|
||||||
| passengerIds | Array | 否 | 乘客ID列表 |
|
|
||||||
| voucherIds | Array | 否 | 凭证ID列表 |
|
|
||||||
|
|
||||||
### 响应结果
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"resp_code": 0,
|
|
||||||
"resp_msg": "核销成功",
|
|
||||||
"data": true
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 4. 验证订单是否可核销
|
|
||||||
|
|
||||||
### 接口信息
|
|
||||||
- **接口地址**: `GET /api/order-detail/{otaOrderId}/validate`
|
|
||||||
- **功能描述**: 验证指定订单是否可核销
|
|
||||||
- **请求方式**: GET
|
|
||||||
|
|
||||||
### 请求参数
|
|
||||||
|
|
||||||
| 参数名 | 类型 | 必填 | 说明 |
|
|
||||||
|--------|------|------|------|
|
|
||||||
| otaOrderId | String | 是 | 携程订单号(路径参数) |
|
|
||||||
|
|
||||||
### 响应结果
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"resp_code": 0,
|
|
||||||
"resp_msg": "",
|
|
||||||
"data": true
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 5. 调试接口
|
|
||||||
|
|
||||||
### 接口信息
|
|
||||||
- **接口地址**: `GET /api/order-detail/debug/data`
|
|
||||||
- **功能描述**: 调试接口,检查数据库中的数据情况
|
|
||||||
- **请求方式**: GET
|
|
||||||
|
|
||||||
### 响应结果
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"resp_code": 0,
|
|
||||||
"resp_msg": "",
|
|
||||||
"data": {
|
|
||||||
"orderCount": 10,
|
|
||||||
"passengerCount": 20,
|
|
||||||
"contactCount": 15,
|
|
||||||
"orderItemCount": 25,
|
|
||||||
"latestOrders": [...],
|
|
||||||
"passengersForPhone": 1,
|
|
||||||
"passengerDetails": [...],
|
|
||||||
"contactsForPhone": 1,
|
|
||||||
"contactDetails": [...]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 6. 前端集成示例
|
|
||||||
|
|
||||||
### JavaScript/TypeScript 示例
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
// 查询可核销订单
|
|
||||||
async function queryConsumableOrdersByCode(codeId: string, page = 1, size = 10) {
|
|
||||||
const response = await fetch('/api/order-detail/query', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ codeId, page, size })
|
|
||||||
});
|
|
||||||
const result = await response.json();
|
|
||||||
return result.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 简化核销订单
|
|
||||||
async function consumeOrderSimple(otaOrderId: string, itemId: string, useQuantity: number, remark: string) {
|
|
||||||
const response = await fetch('/api/order-detail/consume-simple', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ otaOrderId, itemId, useQuantity, remark })
|
|
||||||
});
|
|
||||||
const result = await response.json();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 注意
|
|
||||||
- 无需传手机号和价格,后端会自动从登录上下文与二维码信息中获取。
|
|
||||||
|
|
||||||
## 7. 错误码说明
|
|
||||||
|
|
||||||
| 错误码 | 说明 |
|
|
||||||
|--------|------|
|
|
||||||
| 0 | 成功 |
|
|
||||||
| 1 | 失败 |
|
|
||||||
| 1001 | 参数错误 |
|
|
||||||
| 1002 | 订单不存在 |
|
|
||||||
| 1003 | 订单不可核销 |
|
|
||||||
| 1004 | 商品不存在 |
|
|
||||||
| 1005 | 核销数量超出限制 |
|
|
||||||
|
|
||||||
## 8. 注意事项
|
|
||||||
|
|
||||||
1. **手机号格式**: 建议统一使用11位数字格式,如 `18322694510`
|
|
||||||
2. **价格精度**: 使用 `BigDecimal` 类型处理价格,避免精度问题
|
|
||||||
3. **itemId映射**: 核销时使用查询接口返回的 `productId` 作为 `itemId`
|
|
||||||
4. **状态验证**: 只有状态为1(已确认)或13(支付确认)的订单可以核销
|
|
||||||
5. **数量限制**: 核销数量不能超过 `availableQuantity`
|
|
||||||
6. **错误处理**: 前端需要处理核销失败的情况,并给出用户友好的提示
|
|
||||||
|
|
||||||
## 9. 测试用例
|
|
||||||
|
|
||||||
### 测试数据
|
|
||||||
- 手机号: `18322694510`
|
|
||||||
- 优惠券价格: `2.0`
|
|
||||||
- 订单号: `ctriptest-10816828-454259-145573`
|
|
||||||
- 商品ID: `1801589811`
|
|
||||||
|
|
||||||
### 测试步骤
|
|
||||||
1. 调用查询接口,确认能返回订单数据
|
|
||||||
2. 调用验证接口,确认订单可核销
|
|
||||||
3. 调用核销接口,确认核销成功
|
|
||||||
4. 再次调用查询接口,确认订单状态已更新
|
|
||||||
@@ -1,191 +0,0 @@
|
|||||||
# 前端核销传参方案
|
|
||||||
|
|
||||||
## 核销接口参数结构
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"otaOrderId": "ctriptest-10816870-454259-145573",
|
|
||||||
"itemId": "106943568",
|
|
||||||
"useQuantity": 1,
|
|
||||||
"remark": "门票入园核销"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 前端传参方案
|
|
||||||
|
|
||||||
### 方案一:直接使用订单项ID
|
|
||||||
|
|
||||||
**查询接口返回的订单项数据:**
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"orderItems": [
|
|
||||||
{
|
|
||||||
"itemId": 456, // 数据库主键ID
|
|
||||||
"productId": "106943568", // 商品ID(携程的itemId)
|
|
||||||
"itemName": "门票",
|
|
||||||
"plu": "1",
|
|
||||||
"quantity": 2,
|
|
||||||
"canConsume": true,
|
|
||||||
"availableQuantity": 2
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**前端传参:**
|
|
||||||
```javascript
|
|
||||||
// 选择第一个可核销的订单项
|
|
||||||
const orderItem = order.orderItems.find(item => item.canConsume);
|
|
||||||
const consumeParams = {
|
|
||||||
otaOrderId: order.otaOrderId,
|
|
||||||
itemId: orderItem.productId, // 使用productId作为itemId
|
|
||||||
useQuantity: 1, // 核销数量
|
|
||||||
remark: "使用优惠券核销门票"
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
### 方案二:支持批量核销
|
|
||||||
|
|
||||||
如果需要支持一次核销多个订单项,可以这样设计:
|
|
||||||
|
|
||||||
**前端传参:**
|
|
||||||
```javascript
|
|
||||||
// 核销多个订单项
|
|
||||||
const consumeParams = {
|
|
||||||
otaOrderId: order.otaOrderId,
|
|
||||||
items: [
|
|
||||||
{
|
|
||||||
itemId: "106943568",
|
|
||||||
useQuantity: 1,
|
|
||||||
remark: "核销门票1张"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
itemId: "106943569",
|
|
||||||
useQuantity: 1,
|
|
||||||
remark: "核销门票1张"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
## 推荐实现方案
|
|
||||||
|
|
||||||
### 1. 使用简化核销接口
|
|
||||||
|
|
||||||
**接口地址:** `POST /api/order-detail/consume-simple`
|
|
||||||
|
|
||||||
**请求参数:**
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"otaOrderId": "ctriptest-10816870-454259-145573",
|
|
||||||
"itemId": "106943568",
|
|
||||||
"useQuantity": 1,
|
|
||||||
"remark": "使用优惠券核销门票"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. 前端实现示例
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
interface SimpleConsumeRequest {
|
|
||||||
otaOrderId: string;
|
|
||||||
itemId: string;
|
|
||||||
useQuantity: number;
|
|
||||||
remark?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 简化核销订单
|
|
||||||
async function consumeOrderSimple(request: SimpleConsumeRequest) {
|
|
||||||
const response = await fetch('/api/order-detail/consume-simple', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify(request)
|
|
||||||
});
|
|
||||||
|
|
||||||
return response.json();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 使用示例
|
|
||||||
function handleConsume() {
|
|
||||||
const orderItem = order.orderItems.find(item => item.canConsume);
|
|
||||||
|
|
||||||
if (orderItem) {
|
|
||||||
const consumeRequest: SimpleConsumeRequest = {
|
|
||||||
otaOrderId: order.otaOrderId,
|
|
||||||
itemId: orderItem.productId, // 使用productId作为itemId
|
|
||||||
useQuantity: 1, // 核销数量
|
|
||||||
remark: `使用优惠券核销${orderItem.itemName}`
|
|
||||||
};
|
|
||||||
|
|
||||||
consumeOrderSimple(consumeRequest);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. 前端UI交互设计
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
// 订单项选择组件
|
|
||||||
function OrderItemSelector({ orderItem, onSelect }) {
|
|
||||||
const [selectedQuantity, setSelectedQuantity] = useState(0);
|
|
||||||
const maxQuantity = orderItem.availableQuantity;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="order-item">
|
|
||||||
<div className="item-info">
|
|
||||||
<span>{orderItem.itemName}</span>
|
|
||||||
<span>可用数量: {maxQuantity}</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{orderItem.canConsume && (
|
|
||||||
<div className="quantity-selector">
|
|
||||||
<button
|
|
||||||
onClick={() => setSelectedQuantity(Math.max(0, selectedQuantity - 1))}
|
|
||||||
disabled={selectedQuantity <= 0}
|
|
||||||
>
|
|
||||||
-
|
|
||||||
</button>
|
|
||||||
<span>{selectedQuantity}</span>
|
|
||||||
<button
|
|
||||||
onClick={() => setSelectedQuantity(Math.min(maxQuantity, selectedQuantity + 1))}
|
|
||||||
disabled={selectedQuantity >= maxQuantity}
|
|
||||||
>
|
|
||||||
+
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 核销按钮
|
|
||||||
function ConsumeButton({ order, selectedItems }) {
|
|
||||||
const canConsume = selectedItems.length > 0 &&
|
|
||||||
selectedItems.every(item => item.useQuantity > 0);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
onClick={() => handleConsume(order, selectedItems)}
|
|
||||||
disabled={!canConsume}
|
|
||||||
>
|
|
||||||
确认核销
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 数据映射关系
|
|
||||||
|
|
||||||
| 查询接口返回字段 | 核销接口参数 | 说明 |
|
|
||||||
|----------------|-------------|------|
|
|
||||||
| `orderItems[].productId` | `itemId` | 携程的商品ID |
|
|
||||||
| `orderItems[].availableQuantity` | `useQuantity` | 可核销数量 |
|
|
||||||
| `orderItems[].itemName` | `remark` | 商品名称用于备注 |
|
|
||||||
|
|
||||||
## 注意事项
|
|
||||||
|
|
||||||
1. **itemId映射**:使用 `productId` 作为核销接口的 `itemId`
|
|
||||||
2. **数量验证**:核销数量不能超过 `availableQuantity`
|
|
||||||
3. **状态检查**:只允许核销 `canConsume=true` 的订单项
|
|
||||||
4. **批量支持**:建议支持一次核销多个订单项
|
|
||||||
5. **错误处理**:前端需要处理核销失败的情况
|
|
||||||
@@ -1,288 +0,0 @@
|
|||||||
# 订单明细查询核销接口使用示例
|
|
||||||
|
|
||||||
## 场景描述
|
|
||||||
|
|
||||||
用户有一张100元的优惠券,想要查询可以用这张优惠券核销的携程订单。
|
|
||||||
|
|
||||||
## 使用步骤
|
|
||||||
|
|
||||||
### 1. 查询可核销订单
|
|
||||||
|
|
||||||
**请求:**
|
|
||||||
```bash
|
|
||||||
curl -X POST http://localhost:8002/coupon/api/order-detail/query \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{
|
|
||||||
"userPhone": "13800138000",
|
|
||||||
"couponPrice": 100.00,
|
|
||||||
"onlyConsumable": true,
|
|
||||||
"page": 1,
|
|
||||||
"size": 10
|
|
||||||
}'
|
|
||||||
```
|
|
||||||
|
|
||||||
**响应:**
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"resp_code": 0,
|
|
||||||
"resp_msg": "",
|
|
||||||
"data": {
|
|
||||||
"data": [
|
|
||||||
{
|
|
||||||
"orderId": 123,
|
|
||||||
"otaOrderId": "ctriptest-10816828-454259-145573",
|
|
||||||
"supplierOrderId": "SUPPLIER_ctriptest-10816828-454259-145573_301495ef",
|
|
||||||
"orderStatus": 1,
|
|
||||||
"orderStatusDesc": "已确认",
|
|
||||||
"totalAmount": 100.00,
|
|
||||||
"currency": "CNY",
|
|
||||||
"createTime": "2025-08-30T09:33:42",
|
|
||||||
"orderItems": [
|
|
||||||
{
|
|
||||||
"itemId": 456,
|
|
||||||
"productId": "1801589811",
|
|
||||||
"itemName": "门票",
|
|
||||||
"itemType": "1",
|
|
||||||
"plu": "1",
|
|
||||||
"quantity": 2,
|
|
||||||
"unitPrice": 50.00,
|
|
||||||
"totalPrice": 100.00,
|
|
||||||
"currency": "CNY",
|
|
||||||
"useStartDate": "2025-07-25",
|
|
||||||
"useEndDate": "2025-07-25",
|
|
||||||
"canConsume": true,
|
|
||||||
"usedQuantity": 0,
|
|
||||||
"availableQuantity": 2
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"passengers": [
|
|
||||||
{
|
|
||||||
"passengerId": "PASS_1",
|
|
||||||
"passengerName": "张三",
|
|
||||||
"phone": "13800138000",
|
|
||||||
"passengerStatus": 0,
|
|
||||||
"passengerStatusDesc": "未使用",
|
|
||||||
"idCard": "110101199001011234",
|
|
||||||
"gender": "ADULT",
|
|
||||||
"age": null
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"contact": {
|
|
||||||
"name": "张三",
|
|
||||||
"mobile": "13800138000",
|
|
||||||
"email": "zhangsan@example.com",
|
|
||||||
"contactType": "BOOKER"
|
|
||||||
},
|
|
||||||
"canConsume": true,
|
|
||||||
"consumeReason": null
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"count": 1,
|
|
||||||
"resp_code": 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. 验证订单是否可核销
|
|
||||||
|
|
||||||
**请求:**
|
|
||||||
```bash
|
|
||||||
curl -X GET http://localhost:8002/coupon/api/order-detail/ctriptest-10816828-454259-145573/validate
|
|
||||||
```
|
|
||||||
|
|
||||||
**响应:**
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"resp_code": 0,
|
|
||||||
"resp_msg": "",
|
|
||||||
"data": true
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. 执行简化核销操作
|
|
||||||
|
|
||||||
**请求:**
|
|
||||||
```bash
|
|
||||||
curl -X POST http://localhost:8002/coupon/api/order-detail/consume-simple \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{
|
|
||||||
"otaOrderId": "ctriptest-10816870-454259-145573",
|
|
||||||
"itemId": "106943568",
|
|
||||||
"useQuantity": 1,
|
|
||||||
"remark": "使用100元优惠券核销门票"
|
|
||||||
}'
|
|
||||||
```
|
|
||||||
|
|
||||||
**响应:**
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"resp_code": 0,
|
|
||||||
"resp_msg": "核销成功",
|
|
||||||
"data": true
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 前端集成示例
|
|
||||||
|
|
||||||
### JavaScript/TypeScript
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
// 查询可核销订单
|
|
||||||
async function queryConsumableOrders(userPhone: string, couponPrice: number) {
|
|
||||||
const response = await fetch('/api/order-detail/query', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
userPhone,
|
|
||||||
couponPrice,
|
|
||||||
onlyConsumable: true,
|
|
||||||
page: 1,
|
|
||||||
size: 10
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = await response.json();
|
|
||||||
return result.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 简化核销订单
|
|
||||||
async function consumeOrderSimple(otaOrderId: string, itemId: string, useQuantity: number, remark: string) {
|
|
||||||
const response = await fetch('/api/order-detail/consume-simple', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
otaOrderId,
|
|
||||||
itemId,
|
|
||||||
useQuantity,
|
|
||||||
remark
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = await response.json();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 使用示例
|
|
||||||
async function useCoupon() {
|
|
||||||
const userPhone = '13800138000';
|
|
||||||
const couponPrice = 100.00;
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 1. 查询可核销订单
|
|
||||||
const orders = await queryConsumableOrders(userPhone, couponPrice);
|
|
||||||
console.log('可核销订单:', orders);
|
|
||||||
|
|
||||||
if (orders.data.length > 0) {
|
|
||||||
const order = orders.data[0];
|
|
||||||
const orderItem = order.orderItems.find(item => item.canConsume);
|
|
||||||
|
|
||||||
if (orderItem) {
|
|
||||||
// 2. 执行简化核销
|
|
||||||
const consumeResult = await consumeOrderSimple(
|
|
||||||
order.otaOrderId,
|
|
||||||
orderItem.productId, // 使用productId作为itemId
|
|
||||||
1, // 核销数量
|
|
||||||
'使用优惠券核销'
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log('核销结果:', consumeResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('操作失败:', error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### React Hook 示例
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
import { useState, useEffect } from 'react';
|
|
||||||
|
|
||||||
interface OrderDetail {
|
|
||||||
orderId: number;
|
|
||||||
otaOrderId: string;
|
|
||||||
supplierOrderId: string;
|
|
||||||
totalAmount: number;
|
|
||||||
canConsume: boolean;
|
|
||||||
orderItems: any[];
|
|
||||||
passengers: any[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useConsumableOrders(userPhone: string, couponPrice: number) {
|
|
||||||
const [orders, setOrders] = useState<OrderDetail[]>([]);
|
|
||||||
const [loading, setLoading] = useState(false);
|
|
||||||
const [error, setError] = useState<string | null>(null);
|
|
||||||
|
|
||||||
const fetchOrders = async () => {
|
|
||||||
setLoading(true);
|
|
||||||
setError(null);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch('/api/order-detail/query', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify({
|
|
||||||
userPhone,
|
|
||||||
couponPrice,
|
|
||||||
onlyConsumable: true,
|
|
||||||
page: 1,
|
|
||||||
size: 10
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = await response.json();
|
|
||||||
|
|
||||||
if (result.resp_code === 0) {
|
|
||||||
setOrders(result.data.data);
|
|
||||||
} else {
|
|
||||||
setError(result.resp_msg);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
setError('查询失败');
|
|
||||||
} finally {
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const consumeOrder = async (order: OrderDetail, itemId: string, useQuantity: number) => {
|
|
||||||
try {
|
|
||||||
const response = await fetch('/api/order-detail/consume-simple', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify({
|
|
||||||
otaOrderId: order.otaOrderId,
|
|
||||||
itemId: itemId,
|
|
||||||
useQuantity: useQuantity,
|
|
||||||
remark: '使用优惠券核销'
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = await response.json();
|
|
||||||
return result.resp_code === 0;
|
|
||||||
} catch (err) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (userPhone && couponPrice) {
|
|
||||||
fetchOrders();
|
|
||||||
}
|
|
||||||
}, [userPhone, couponPrice]);
|
|
||||||
|
|
||||||
return { orders, loading, error, consumeOrder, refetch: fetchOrders };
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 注意事项
|
|
||||||
|
|
||||||
1. **优惠券价格匹配**:订单总金额必须与优惠券价格完全匹配
|
|
||||||
2. **可核销条件**:只有已确认且在使用有效期内的订单才能核销
|
|
||||||
3. **数量限制**:核销数量不能超过订单项的剩余可用数量
|
|
||||||
4. **幂等性**:重复核销同一订单项会返回成功,但不会重复扣减数量
|
|
||||||
5. **错误处理**:建议在前端做好错误处理和用户提示
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
# 携程API配置说明
|
|
||||||
|
|
||||||
## 配置结构
|
|
||||||
|
|
||||||
### 1. 配置文件位置
|
|
||||||
- **配置文件**: `src/main/resources/application.yml`
|
|
||||||
|
|
||||||
### 2. 配置项说明
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
spring:
|
|
||||||
# 环境配置:test(测试环境) / prod(生产环境)
|
|
||||||
profiles:
|
|
||||||
active: test
|
|
||||||
|
|
||||||
ctrip:
|
|
||||||
# AES加密配置
|
|
||||||
aes:
|
|
||||||
key: 087b36ad0dff7942 # AES密钥
|
|
||||||
iv: 750e15a31356a99d # AES IV
|
|
||||||
|
|
||||||
# API配置
|
|
||||||
api:
|
|
||||||
test-url: https://ttdopen.ctrip.com/api # 测试环境URL
|
|
||||||
prod-url: https://ttdentry.ctrip.com/ttd-connect-orderentryapi/supplier # 生产环境URL
|
|
||||||
environment: test # 当前环境:test/prod
|
|
||||||
timeout: 30000 # 请求超时时间(毫秒)
|
|
||||||
retry-times: 3 # 重试次数
|
|
||||||
|
|
||||||
# 账户配置
|
|
||||||
account:
|
|
||||||
id: c50a8f2a59c9e7 # 账户ID
|
|
||||||
secret: ce6033ae31124ec5cdab3d2bc79f2622 # 账户密钥
|
|
||||||
```
|
|
||||||
|
|
||||||
## 环境切换
|
|
||||||
|
|
||||||
### 1. 测试环境(默认)
|
|
||||||
```bash
|
|
||||||
# 使用默认配置(测试环境)
|
|
||||||
java -jar coupon-center.jar
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. 生产环境
|
|
||||||
```bash
|
|
||||||
# 使用生产环境配置
|
|
||||||
java -jar coupon-center.jar --spring.profiles.active=prod
|
|
||||||
```
|
|
||||||
|
|
||||||
或者在 `application.yml` 中设置:
|
|
||||||
```yaml
|
|
||||||
spring:
|
|
||||||
profiles:
|
|
||||||
active: prod
|
|
||||||
```
|
|
||||||
|
|
||||||
## URL配置说明
|
|
||||||
|
|
||||||
### 1. 测试环境
|
|
||||||
- **基础URL**: `https://ttdopen.ctrip.com/api`
|
|
||||||
- **订单通知接口**: `https://ttdopen.ctrip.com/api/order/notice.do`
|
|
||||||
|
|
||||||
### 2. 生产环境
|
|
||||||
- **基础URL**: `https://ttdentry.ctrip.com/ttd-connect-orderentryapi/supplier`
|
|
||||||
- **订单通知接口**: `https://ttdentry.ctrip.com/ttd-connect-orderentryapi/supplier/order/notice.do`
|
|
||||||
|
|
||||||
## 代码使用
|
|
||||||
|
|
||||||
### 1. 注入配置
|
|
||||||
```java
|
|
||||||
@Autowired
|
|
||||||
private CtripApiConfig ctripApiConfig;
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. 获取URL
|
|
||||||
```java
|
|
||||||
// 获取当前环境的订单通知URL
|
|
||||||
String url = ctripApiConfig.getApi().getOrderNoticeUrl();
|
|
||||||
|
|
||||||
// 获取当前环境的基础URL
|
|
||||||
String baseUrl = ctripApiConfig.getApi().getBaseUrl();
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. 获取账户信息
|
|
||||||
```java
|
|
||||||
String accountId = ctripApiConfig.getAccount().getId();
|
|
||||||
String accountSecret = ctripApiConfig.getAccount().getSecret();
|
|
||||||
```
|
|
||||||
|
|
||||||
## 安全注意事项
|
|
||||||
|
|
||||||
1. **生产环境密钥**: 生产环境的AES密钥和账户密钥应该通过环境变量或配置中心管理
|
|
||||||
2. **日志级别**: 生产环境建议将敏感信息的日志级别设置为WARN或ERROR
|
|
||||||
3. **网络访问**: 确保服务器能够访问携程的API地址
|
|
||||||
4. **超时配置**: 根据网络情况调整timeout和retry-times参数
|
|
||||||
|
|
||||||
## 故障排查
|
|
||||||
|
|
||||||
### 1. 网络连接问题
|
|
||||||
```bash
|
|
||||||
# 测试网络连接
|
|
||||||
curl -I https://ttdentry.ctrip.com/ttd-connect-orderentryapi/supplier/order/notice.do
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. 配置验证
|
|
||||||
```java
|
|
||||||
// 在启动时验证配置
|
|
||||||
@PostConstruct
|
|
||||||
public void validateConfig() {
|
|
||||||
log.info("当前环境: {}", ctripApiConfig.getApi().getEnvironment());
|
|
||||||
log.info("API URL: {}", ctripApiConfig.getApi().getOrderNoticeUrl());
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. 日志监控
|
|
||||||
```yaml
|
|
||||||
logging:
|
|
||||||
level:
|
|
||||||
com.central.coupon.service.impl.CtripConsumedServiceImpl: DEBUG
|
|
||||||
com.central.coupon.util.CtripDecryptUtil: DEBUG
|
|
||||||
```
|
|
||||||
@@ -1,209 +0,0 @@
|
|||||||
# 携程核销订单状态更新确认
|
|
||||||
|
|
||||||
## 完整流程确认
|
|
||||||
|
|
||||||
### 1. 前端调用核销接口
|
|
||||||
```java
|
|
||||||
// 前端调用 OrderDetailController.consumeOrderSimple
|
|
||||||
POST /api-coupon/api/order-detail/consume-simple
|
|
||||||
{
|
|
||||||
"otaOrderId": "ctriptest-xxx",
|
|
||||||
"orderNo": "ORDER_20250901_001", // 关联的订单中心订单号
|
|
||||||
"itemId": "123456",
|
|
||||||
"useQuantity": 1,
|
|
||||||
"remark": "优惠券核销"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. 建立订单关联关系
|
|
||||||
```java
|
|
||||||
// OrderDetailController.consumeOrderSimple 第3步
|
|
||||||
if (consumeDTO.getOrderNo() != null && !consumeDTO.getOrderNo().trim().isEmpty()) {
|
|
||||||
if (order.getOrderNo() == null || order.getOrderNo().trim().isEmpty()) {
|
|
||||||
// 更新携程订单的orderNo字段
|
|
||||||
order.setOrderNo(consumeDTO.getOrderNo());
|
|
||||||
ctripOrderMapper.updateById(order);
|
|
||||||
log.info("建立订单关联关系,otaOrderId: {}, orderNo: {}",
|
|
||||||
consumeDTO.getOtaOrderId(), consumeDTO.getOrderNo());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. 调用核销服务
|
|
||||||
```java
|
|
||||||
// OrderDetailController.consumeOrderSimple 第4步
|
|
||||||
CtripConsumedNoticeResponse response = ctripConsumedService.consumeOrder(request);
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4. 核销服务执行流程
|
|
||||||
```java
|
|
||||||
// CtripConsumedServiceImpl.consumeOrder()
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public CtripConsumedNoticeResponse consumeOrder(CtripConsumeRequest request) {
|
|
||||||
// 1. 验证请求参数
|
|
||||||
// 2. 检查订单是否存在
|
|
||||||
// 3. 生成序列号
|
|
||||||
// 4. 保存核销记录到本地数据库
|
|
||||||
// 5. 更新订单状态 ← 这里会触发订单中心更新
|
|
||||||
updateOrderStatus(order, request.getUseQuantity());
|
|
||||||
// 6. 生成OrderConsumedNotice请求体
|
|
||||||
// 7. 返回成功响应
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 5. 更新携程订单状态
|
|
||||||
```java
|
|
||||||
// CtripConsumedServiceImpl.updateOrderStatus()
|
|
||||||
private void updateOrderStatus(CtripOrder order, Integer useQuantity) {
|
|
||||||
// 查询该订单的所有核销记录
|
|
||||||
List<CtripConsumed> consumedList = ctripConsumedMapper.selectByOtaOrderId(order.getOtaOrderId());
|
|
||||||
|
|
||||||
// 计算总使用数量
|
|
||||||
int totalUseQuantity = consumedList.stream()
|
|
||||||
.mapToInt(c -> c.getUseQuantity() != null ? c.getUseQuantity() : 0)
|
|
||||||
.sum();
|
|
||||||
|
|
||||||
// 如果使用数量大于0,更新订单状态为已使用(状态8)
|
|
||||||
if (totalUseQuantity > 0) {
|
|
||||||
order.setStatus(8); // 已使用状态
|
|
||||||
ctripOrderMapper.updateById(order);
|
|
||||||
log.info("订单状态更新为已使用,otaOrderId: {}, totalUseQuantity: {}",
|
|
||||||
order.getOtaOrderId(), totalUseQuantity);
|
|
||||||
|
|
||||||
// 6. 更新订单中心订单状态(如果有关联的订单号)
|
|
||||||
updateOrderCenterStatus(order);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 6. 更新订单中心状态
|
|
||||||
```java
|
|
||||||
// CtripConsumedServiceImpl.updateOrderCenterStatus()
|
|
||||||
private void updateOrderCenterStatus(CtripOrder order) {
|
|
||||||
if (StringUtils.hasText(order.getOrderNo())) {
|
|
||||||
log.info("开始更新订单中心订单状态,orderNo: {}", order.getOrderNo());
|
|
||||||
|
|
||||||
// 调用订单中心接口更新订单状态为已支付(状态1)
|
|
||||||
Result<String> result = orderCenterService.updateOrderStatusToPaid(order.getOrderNo());
|
|
||||||
|
|
||||||
if (result != null && result.getResp_code() == 0) {
|
|
||||||
log.info("订单中心订单状态更新成功,orderNo: {}", order.getOrderNo());
|
|
||||||
} else {
|
|
||||||
log.error("订单中心订单状态更新失败,orderNo: {}, result: {}",
|
|
||||||
order.getOrderNo(), result);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.warn("携程订单未关联订单中心订单号,无法更新订单状态,otaOrderId: {}",
|
|
||||||
order.getOtaOrderId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 7. 订单中心状态更新接口
|
|
||||||
```java
|
|
||||||
// OrderController.updateOrderStatusToPaid()
|
|
||||||
@PostMapping("/order/{orderNo}/status/paid")
|
|
||||||
public Result<String> updateOrderStatusToPaid(@PathVariable("orderNo") String orderNo) {
|
|
||||||
Order order = orderService.getOrderByNumber(orderNo);
|
|
||||||
|
|
||||||
if (order.getOrderStatus().equals(OrderStatus.UNPAID.getId())) {
|
|
||||||
// 更新订单状态为已支付排队中
|
|
||||||
order.setOrderStatus(OrderStatus.PAID.getId());
|
|
||||||
// 设置支付类型为优惠券支付
|
|
||||||
order.setPayType(2); // 2表示优惠券支付
|
|
||||||
// 设置支付时间
|
|
||||||
order.setPayTime(new Date());
|
|
||||||
|
|
||||||
boolean result = orderService.updateOrder(order);
|
|
||||||
if (result) {
|
|
||||||
log.info("订单状态更新成功,orderNo: {}, 新状态: {}", orderNo, OrderStatus.PAID.getId());
|
|
||||||
return Result.succeed("订单状态更新成功");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 关键日志点确认
|
|
||||||
|
|
||||||
### 成功流程日志
|
|
||||||
```
|
|
||||||
简化核销订单,订单号: ctriptest-xxx, 商品ID: 123456, 数量: 1, 关联订单号: ORDER_20250901_001
|
|
||||||
建立订单关联关系,otaOrderId: ctriptest-xxx, orderNo: ORDER_20250901_001
|
|
||||||
开始执行核销订单,otaOrderId: ctriptest-xxx, itemId: 123456, useQuantity: 1
|
|
||||||
核销记录保存成功,sequenceId: 20250901xxx
|
|
||||||
订单状态更新为已使用,otaOrderId: ctriptest-xxx, totalUseQuantity: 1
|
|
||||||
开始更新订单中心订单状态,orderNo: ORDER_20250901_001
|
|
||||||
订单中心订单状态更新成功,orderNo: ORDER_20250901_001
|
|
||||||
核销订单执行成功,otaOrderId: ctriptest-xxx, sequenceId: 20250901xxx
|
|
||||||
核销成功,订单号: ctriptest-xxx, 关联订单号: ORDER_20250901_001
|
|
||||||
```
|
|
||||||
|
|
||||||
### 订单中心日志
|
|
||||||
```
|
|
||||||
优惠券核销成功,更新订单状态为已支付,orderNo: ORDER_20250901_001
|
|
||||||
订单状态更新成功,orderNo: ORDER_20250901_001, 新状态: 1
|
|
||||||
```
|
|
||||||
|
|
||||||
## 数据库状态变化确认
|
|
||||||
|
|
||||||
### 携程订单表 (t_ctrip_order)
|
|
||||||
```sql
|
|
||||||
-- 核销前
|
|
||||||
SELECT ota_order_id, order_no, status FROM t_ctrip_order WHERE ota_order_id = 'ctriptest-xxx';
|
|
||||||
-- 结果: status = 1 (已确认), order_no = NULL
|
|
||||||
|
|
||||||
-- 核销后
|
|
||||||
SELECT ota_order_id, order_no, status FROM t_ctrip_order WHERE ota_order_id = 'ctriptest-xxx';
|
|
||||||
-- 结果: status = 8 (已使用), order_no = 'ORDER_20250901_001'
|
|
||||||
```
|
|
||||||
|
|
||||||
### 订单中心表 (orders)
|
|
||||||
```sql
|
|
||||||
-- 核销前
|
|
||||||
SELECT order_no, order_status, pay_type, pay_time FROM orders WHERE order_no = 'ORDER_20250901_001';
|
|
||||||
-- 结果: order_status = 0 (未支付), pay_type = NULL, pay_time = NULL
|
|
||||||
|
|
||||||
-- 核销后
|
|
||||||
SELECT order_no, order_status, pay_type, pay_time FROM orders WHERE order_no = 'ORDER_20250901_001';
|
|
||||||
-- 结果: order_status = 1 (已支付), pay_type = 2 (优惠券支付), pay_time = 2025-09-01 17:32:30
|
|
||||||
```
|
|
||||||
|
|
||||||
### 核销记录表 (t_ctrip_consumed)
|
|
||||||
```sql
|
|
||||||
-- 核销后新增记录
|
|
||||||
SELECT ota_order_id, supplier_order_id, item_id, use_quantity, create_time
|
|
||||||
FROM t_ctrip_consumed WHERE ota_order_id = 'ctriptest-xxx';
|
|
||||||
-- 结果: 新增一条核销记录
|
|
||||||
```
|
|
||||||
|
|
||||||
## 状态映射确认
|
|
||||||
|
|
||||||
| 系统 | 状态值 | 状态含义 | 说明 |
|
|
||||||
|------|--------|----------|------|
|
|
||||||
| 携程订单 | 0 | 待确认 | 预下单创建后 |
|
|
||||||
| 携程订单 | 1 | 已确认 | 预下单确认后 |
|
|
||||||
| 携程订单 | 8 | 已使用 | 核销成功后 |
|
|
||||||
| 订单中心 | 0 | 未支付 | 订单创建后 |
|
|
||||||
| 订单中心 | 1 | 已支付 | 核销成功后更新 |
|
|
||||||
|
|
||||||
## 支付类型确认
|
|
||||||
|
|
||||||
| 支付类型值 | 支付方式 | 说明 |
|
|
||||||
|------------|----------|------|
|
|
||||||
| 1 | 微信支付 | 用户通过微信支付 |
|
|
||||||
| 2 | 优惠券支付 | 用户使用优惠券核销 |
|
|
||||||
|
|
||||||
## 结论
|
|
||||||
|
|
||||||
✅ **流程完整**:前端调用 → 建立关联 → 核销执行 → 状态更新 → 订单中心更新
|
|
||||||
|
|
||||||
✅ **状态正确**:携程订单状态8(已使用),订单中心状态1(已支付)
|
|
||||||
|
|
||||||
✅ **关联正确**:通过orderNo字段建立携程订单与订单中心订单的关联
|
|
||||||
|
|
||||||
✅ **日志完整**:每个关键步骤都有详细的日志记录
|
|
||||||
|
|
||||||
✅ **异常处理**:即使订单中心更新失败,也不会影响核销流程
|
|
||||||
|
|
||||||
✅ **事务安全**:核销操作在事务中执行,确保数据一致性
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
# 携程订单状态说明
|
|
||||||
|
|
||||||
## 订单状态定义
|
|
||||||
|
|
||||||
| 状态码 | 状态名称 | 中文描述 | 是否可核销 | 说明 |
|
|
||||||
|--------|----------|----------|------------|------|
|
|
||||||
| 0 | PENDING | 待确认 | ❌ | 订单已创建但未确认 |
|
|
||||||
| 1 | CONFIRMED | 已确认 | ✅ | 订单已确认,可以核销 |
|
|
||||||
| 2 | CANCELLED | 已取消 | ❌ | 订单已取消 |
|
|
||||||
| 3 | REFUNDED | 已退款 | ❌ | 订单已退款 |
|
|
||||||
| 4 | CONSUMED | 已核销 | ❌ | 订单已核销完成 |
|
|
||||||
| 5 | FULLY_CANCELLED | 已取消 | ❌ | 订单完全取消 |
|
|
||||||
| 11 | WAITING_PAYMENT | 待支付 | ❌ | 等待支付 |
|
|
||||||
| 12 | PAYMENT_PENDING | 支付中 | ❌ | 支付处理中 |
|
|
||||||
| 13 | PAYMENT_CONFIRMED | 支付确认 | ✅ | 支付已确认,可以核销 |
|
|
||||||
| 14 | PRE_ORDER_CANCELLED | 预订单已取消 | ❌ | 预订单已取消 |
|
|
||||||
|
|
||||||
## 可核销状态
|
|
||||||
|
|
||||||
根据携程API文档和业务逻辑,以下状态的订单可以进行核销:
|
|
||||||
|
|
||||||
1. **状态1 - 已确认 (CONFIRMED)**
|
|
||||||
- 订单已确认,供应商已接受订单
|
|
||||||
- 可以进行核销操作
|
|
||||||
|
|
||||||
2. **状态13 - 支付确认 (PAYMENT_CONFIRMED)**
|
|
||||||
- 支付已确认,订单已支付完成
|
|
||||||
- 可以进行核销操作
|
|
||||||
|
|
||||||
## 核销验证逻辑
|
|
||||||
|
|
||||||
```java
|
|
||||||
// 检查订单状态是否允许核销
|
|
||||||
if (order.getStatus() == null || (order.getStatus() != 1 && order.getStatus() != 13)) {
|
|
||||||
return false; // 订单状态不允许核销
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 状态转换流程
|
|
||||||
|
|
||||||
```
|
|
||||||
创建订单 (0) → 确认订单 (1) → 支付确认 (13) → 核销 (4)
|
|
||||||
↓
|
|
||||||
取消 (2/5/14)
|
|
||||||
```
|
|
||||||
|
|
||||||
## 注意事项
|
|
||||||
|
|
||||||
1. **状态13是最常见的可核销状态**,因为大多数订单在支付确认后就可以进行核销
|
|
||||||
2. **状态1通常用于预付费订单**,在支付前就确认的订单
|
|
||||||
3. **状态4表示已核销**,核销完成后订单状态会变为4
|
|
||||||
4. **状态0、11、12** 表示订单还未完全确认,不能进行核销
|
|
||||||
5. **状态2、3、5、14** 表示订单已取消或退款,不能进行核销
|
|
||||||
@@ -1,240 +0,0 @@
|
|||||||
# 优惠券核销流程测试用例
|
|
||||||
|
|
||||||
## 测试目标
|
|
||||||
|
|
||||||
验证优惠券核销成功后,能够正确更新订单中心订单状态为"已支付"。
|
|
||||||
|
|
||||||
## 测试环境
|
|
||||||
|
|
||||||
- 优惠券中心服务:`coupon-center`
|
|
||||||
- 订单中心服务:`order-center`
|
|
||||||
- 数据库:MySQL
|
|
||||||
|
|
||||||
## 测试步骤
|
|
||||||
|
|
||||||
### 1. 准备测试数据
|
|
||||||
|
|
||||||
#### 1.1 创建订单中心订单
|
|
||||||
```sql
|
|
||||||
-- 在订单中心数据库中创建测试订单
|
|
||||||
INSERT INTO orders (
|
|
||||||
order_no, user_id, tourism_id, order_amount, order_status,
|
|
||||||
pay_type, code_id, device_sn, tenant_id, create_time, update_time
|
|
||||||
) VALUES (
|
|
||||||
'TEST_ORDER_001', 1, 1, '9990', 0, -- 0表示待支付
|
|
||||||
1, 'test-code-id', 'TEST_DEVICE_001', 'test-tenant',
|
|
||||||
NOW(), NOW()
|
|
||||||
);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 1.2 创建携程订单(不关联订单号)
|
|
||||||
```sql
|
|
||||||
-- 在优惠券中心数据库中创建携程订单
|
|
||||||
INSERT INTO t_ctrip_order (
|
|
||||||
ota_order_id, supplier_order_id, sequence_id, status,
|
|
||||||
total_amount, currency, create_time, update_time
|
|
||||||
) VALUES (
|
|
||||||
'ctriptest-test-001', 'SUPPLIER_test_001', 'test-sequence-001', 13, -- 13表示支付已确认
|
|
||||||
99.90, 'CNY', NOW(), NOW()
|
|
||||||
);
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. 测试场景
|
|
||||||
|
|
||||||
#### 场景1:核销时传入orderNo,建立关联关系
|
|
||||||
|
|
||||||
**请求:**
|
|
||||||
```bash
|
|
||||||
curl -X POST http://localhost:8002/api-coupon/api/order-detail/consume-simple \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{
|
|
||||||
"otaOrderId": "ctriptest-test-001",
|
|
||||||
"orderNo": "TEST_ORDER_001",
|
|
||||||
"itemId": "test-item-001",
|
|
||||||
"useQuantity": 1,
|
|
||||||
"remark": "测试核销"
|
|
||||||
}'
|
|
||||||
```
|
|
||||||
|
|
||||||
**预期结果:**
|
|
||||||
1. 核销成功,返回 `{"resp_code": 0, "resp_msg": "核销成功", "data": true}`
|
|
||||||
2. 携程订单状态更新为已使用(状态8)
|
|
||||||
3. 携程订单的 `order_no` 字段被设置为 `TEST_ORDER_001`
|
|
||||||
4. 订单中心订单状态更新为已支付(状态1)
|
|
||||||
5. 订单中心订单的 `pay_type` 字段被设置为优惠券支付(类型2)
|
|
||||||
|
|
||||||
**验证SQL:**
|
|
||||||
```sql
|
|
||||||
-- 验证携程订单状态和关联关系
|
|
||||||
SELECT ota_order_id, order_no, status FROM t_ctrip_order WHERE ota_order_id = 'ctriptest-test-001';
|
|
||||||
|
|
||||||
-- 验证订单中心订单状态
|
|
||||||
SELECT order_no, order_status, pay_type, pay_time FROM orders WHERE order_no = 'TEST_ORDER_001';
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 场景2:核销时未传入orderNo
|
|
||||||
|
|
||||||
**请求:**
|
|
||||||
```bash
|
|
||||||
curl -X POST http://localhost:8002/api-coupon/api/order-detail/consume-simple \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{
|
|
||||||
"otaOrderId": "ctriptest-test-002",
|
|
||||||
"itemId": "test-item-002",
|
|
||||||
"useQuantity": 1,
|
|
||||||
"remark": "测试核销(无关联)"
|
|
||||||
}'
|
|
||||||
```
|
|
||||||
|
|
||||||
**预期结果:**
|
|
||||||
1. 核销成功,返回 `{"resp_code": 0, "resp_msg": "核销成功", "data": true}`
|
|
||||||
2. 携程订单状态更新为已使用(状态8)
|
|
||||||
3. 携程订单的 `order_no` 字段为空
|
|
||||||
4. 不会调用订单中心接口更新状态
|
|
||||||
5. 日志中显示:`携程订单未关联订单中心订单号,无法更新订单状态`
|
|
||||||
|
|
||||||
#### 场景3:核销已关联的订单
|
|
||||||
|
|
||||||
**请求:**
|
|
||||||
```bash
|
|
||||||
curl -X POST http://localhost:8002/api-coupon/api/order-detail/consume-simple \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{
|
|
||||||
"otaOrderId": "ctriptest-test-001",
|
|
||||||
"orderNo": "TEST_ORDER_002", -- 传入不同的订单号
|
|
||||||
"itemId": "test-item-003",
|
|
||||||
"useQuantity": 1,
|
|
||||||
"remark": "测试核销(已关联)"
|
|
||||||
}'
|
|
||||||
```
|
|
||||||
|
|
||||||
**预期结果:**
|
|
||||||
1. 核销成功
|
|
||||||
2. 日志中显示:`订单关联关系不匹配,数据库orderNo: TEST_ORDER_001, 前端orderNo: TEST_ORDER_002`
|
|
||||||
3. 不会更新关联关系,继续使用原有的 `TEST_ORDER_001`
|
|
||||||
4. 订单中心订单状态正常更新
|
|
||||||
|
|
||||||
### 3. 日志验证
|
|
||||||
|
|
||||||
#### 3.1 成功核销日志
|
|
||||||
```
|
|
||||||
简化核销订单,订单号: ctriptest-test-001, 商品ID: test-item-001, 数量: 1, 关联订单号: TEST_ORDER_001
|
|
||||||
建立订单关联关系,otaOrderId: ctriptest-test-001, orderNo: TEST_ORDER_001
|
|
||||||
开始执行核销订单,otaOrderId: ctriptest-test-001, itemId: test-item-001, useQuantity: 1
|
|
||||||
订单状态更新为已使用,otaOrderId: ctriptest-test-001, totalUseQuantity: 1
|
|
||||||
开始更新订单中心订单状态,orderNo: TEST_ORDER_001
|
|
||||||
订单中心订单状态更新成功,orderNo: TEST_ORDER_001
|
|
||||||
核销成功,订单号: ctriptest-test-001, 关联订单号: TEST_ORDER_001
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 3.2 无关联订单日志
|
|
||||||
```
|
|
||||||
简化核销订单,订单号: ctriptest-test-002, 商品ID: test-item-002, 数量: 1, 关联订单号: null
|
|
||||||
开始执行核销订单,otaOrderId: ctriptest-test-002, itemId: test-item-002, useQuantity: 1
|
|
||||||
订单状态更新为已使用,otaOrderId: ctriptest-test-002, totalUseQuantity: 1
|
|
||||||
携程订单未关联订单中心订单号,无法更新订单状态,otaOrderId: ctriptest-test-002
|
|
||||||
核销成功,订单号: ctriptest-test-002, 关联订单号: null
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4. 异常场景测试
|
|
||||||
|
|
||||||
#### 4.1 订单不存在
|
|
||||||
**请求:**
|
|
||||||
```bash
|
|
||||||
curl -X POST http://localhost:8002/api-coupon/api/order-detail/consume-simple \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{
|
|
||||||
"otaOrderId": "non-existent-order",
|
|
||||||
"itemId": "test-item-001",
|
|
||||||
"useQuantity": 1
|
|
||||||
}'
|
|
||||||
```
|
|
||||||
|
|
||||||
**预期结果:**
|
|
||||||
- 返回错误:`{"resp_code": -1, "resp_msg": "订单不存在"}`
|
|
||||||
|
|
||||||
#### 4.2 订单中心接口调用失败
|
|
||||||
**模拟场景:** 订单中心服务不可用
|
|
||||||
|
|
||||||
**预期结果:**
|
|
||||||
- 核销成功
|
|
||||||
- 日志显示:`订单中心订单状态更新失败,orderNo: TEST_ORDER_001, result: null`
|
|
||||||
- 不影响核销流程
|
|
||||||
|
|
||||||
#### 4.3 订单状态不正确
|
|
||||||
**模拟场景:** 订单中心订单状态不是待支付(状态0)
|
|
||||||
|
|
||||||
**预期结果:**
|
|
||||||
- 订单中心接口返回:`订单状态不正确,无法更新为已支付`
|
|
||||||
- 不影响核销流程
|
|
||||||
|
|
||||||
### 5. 性能测试
|
|
||||||
|
|
||||||
#### 5.1 并发核销测试
|
|
||||||
```bash
|
|
||||||
# 使用Apache Bench进行并发测试
|
|
||||||
ab -n 100 -c 10 -p test_data.json -T application/json \
|
|
||||||
http://localhost:8002/api-coupon/api/order-detail/consume-simple
|
|
||||||
```
|
|
||||||
|
|
||||||
**预期结果:**
|
|
||||||
- 所有请求成功处理
|
|
||||||
- 无数据竞争问题
|
|
||||||
- 订单状态正确更新
|
|
||||||
|
|
||||||
### 6. 数据一致性验证
|
|
||||||
|
|
||||||
#### 6.1 事务回滚测试
|
|
||||||
**模拟场景:** 在核销过程中发生异常
|
|
||||||
|
|
||||||
**预期结果:**
|
|
||||||
- 携程订单状态回滚
|
|
||||||
- 核销记录回滚
|
|
||||||
- 订单中心状态不更新
|
|
||||||
|
|
||||||
#### 6.2 幂等性测试
|
|
||||||
**操作:** 对同一订单多次核销
|
|
||||||
|
|
||||||
**预期结果:**
|
|
||||||
- 第一次核销成功
|
|
||||||
- 后续核销返回已核销状态
|
|
||||||
- 订单中心状态只更新一次
|
|
||||||
|
|
||||||
## 测试报告模板
|
|
||||||
|
|
||||||
### 测试结果汇总
|
|
||||||
|
|
||||||
| 测试场景 | 预期结果 | 实际结果 | 状态 |
|
|
||||||
|----------|----------|----------|------|
|
|
||||||
| 场景1:传入orderNo | 核销成功,状态更新 | | |
|
|
||||||
| 场景2:未传入orderNo | 核销成功,无状态更新 | | |
|
|
||||||
| 场景3:已关联订单 | 核销成功,使用原关联 | | |
|
|
||||||
| 异常场景1:订单不存在 | 返回错误 | | |
|
|
||||||
| 异常场景2:接口调用失败 | 核销成功,状态更新失败 | | |
|
|
||||||
| 异常场景3:状态不正确 | 核销成功,状态更新失败 | | |
|
|
||||||
| 性能测试:并发核销 | 100%成功率 | | |
|
|
||||||
| 数据一致性:事务回滚 | 数据回滚正确 | | |
|
|
||||||
| 数据一致性:幂等性 | 幂等性正确 | | |
|
|
||||||
|
|
||||||
### 问题记录
|
|
||||||
|
|
||||||
| 问题描述 | 严重程度 | 状态 | 备注 |
|
|
||||||
|----------|----------|------|------|
|
|
||||||
| | | | |
|
|
||||||
|
|
||||||
### 测试结论
|
|
||||||
|
|
||||||
- [ ] 所有测试场景通过
|
|
||||||
- [ ] 性能满足要求
|
|
||||||
- [ ] 数据一致性正确
|
|
||||||
- [ ] 异常处理完善
|
|
||||||
- [ ] 日志记录完整
|
|
||||||
|
|
||||||
## 部署验证清单
|
|
||||||
|
|
||||||
- [ ] 数据库表结构已更新(添加 `order_no` 字段)
|
|
||||||
- [ ] 优惠券中心服务已部署
|
|
||||||
- [ ] 订单中心服务已部署
|
|
||||||
- [ ] Feign客户端配置正确
|
|
||||||
- [ ] 日志级别配置正确
|
|
||||||
- [ ] 监控告警配置正确
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
# 核销流程验证
|
|
||||||
|
|
||||||
## 验证目标
|
|
||||||
|
|
||||||
确认前端调用的 `consumeOrderSimple` 接口能够正确触发订单中心状态更新。
|
|
||||||
|
|
||||||
## 调用链验证
|
|
||||||
|
|
||||||
### 1. 前端接口调用
|
|
||||||
```java
|
|
||||||
// OrderDetailController.consumeOrderSimple()
|
|
||||||
@PostMapping("/consume-simple")
|
|
||||||
public Result<Boolean> consumeOrderSimple(@Valid @RequestBody SimpleConsumeDTO consumeDTO)
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. 建立订单关联
|
|
||||||
```java
|
|
||||||
// 如果前端传入了orderNo,建立关联关系
|
|
||||||
if (consumeDTO.getOrderNo() != null && !consumeDTO.getOrderNo().trim().isEmpty()) {
|
|
||||||
if (order.getOrderNo() == null || order.getOrderNo().trim().isEmpty()) {
|
|
||||||
order.setOrderNo(consumeDTO.getOrderNo());
|
|
||||||
ctripOrderMapper.updateById(order);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. 调用核销服务
|
|
||||||
```java
|
|
||||||
// 调用携程核销服务
|
|
||||||
CtripConsumedNoticeResponse response = ctripConsumedService.consumeOrder(request);
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4. 核销服务执行
|
|
||||||
```java
|
|
||||||
// CtripConsumedServiceImpl.consumeOrder()
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public CtripConsumedNoticeResponse consumeOrder(CtripConsumeRequest request) {
|
|
||||||
// ... 验证和保存逻辑 ...
|
|
||||||
|
|
||||||
// 5. 更新订单状态 ← 这里会触发订单中心更新
|
|
||||||
updateOrderStatus(order, request.getUseQuantity());
|
|
||||||
|
|
||||||
// ... 其他逻辑 ...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 5. 订单状态更新
|
|
||||||
```java
|
|
||||||
// CtripConsumedServiceImpl.updateOrderStatus()
|
|
||||||
private void updateOrderStatus(CtripOrder order, Integer useQuantity) {
|
|
||||||
// ... 更新携程订单状态 ...
|
|
||||||
|
|
||||||
// 6. 更新订单中心订单状态 ← 这里调用订单中心接口
|
|
||||||
updateOrderCenterStatus(order);
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 6. 订单中心状态更新
|
|
||||||
```java
|
|
||||||
// CtripConsumedServiceImpl.updateOrderCenterStatus()
|
|
||||||
private void updateOrderCenterStatus(CtripOrder order) {
|
|
||||||
if (StringUtils.hasText(order.getOrderNo())) {
|
|
||||||
// 调用订单中心接口更新订单状态为已支付(状态1)
|
|
||||||
Result<String> result = orderCenterService.updateOrderStatusToPaid(order.getOrderNo());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 关键日志点
|
|
||||||
|
|
||||||
### 成功流程日志
|
|
||||||
```
|
|
||||||
简化核销订单,订单号: xxx, 商品ID: xxx, 数量: 1, 关联订单号: ORDER_001
|
|
||||||
建立订单关联关系,otaOrderId: xxx, orderNo: ORDER_001
|
|
||||||
开始执行核销订单,otaOrderId: xxx, itemId: xxx, useQuantity: 1
|
|
||||||
订单状态更新为已使用,otaOrderId: xxx, totalUseQuantity: 1
|
|
||||||
开始更新订单中心订单状态,orderNo: ORDER_001
|
|
||||||
订单中心订单状态更新成功,orderNo: ORDER_001
|
|
||||||
核销成功,订单号: xxx, 关联订单号: ORDER_001
|
|
||||||
```
|
|
||||||
|
|
||||||
### 无关联订单日志
|
|
||||||
```
|
|
||||||
简化核销订单,订单号: xxx, 商品ID: xxx, 数量: 1, 关联订单号: null
|
|
||||||
开始执行核销订单,otaOrderId: xxx, itemId: xxx, useQuantity: 1
|
|
||||||
订单状态更新为已使用,otaOrderId: xxx, totalUseQuantity: 1
|
|
||||||
携程订单未关联订单中心订单号,无法更新订单状态,otaOrderId: xxx
|
|
||||||
核销成功,订单号: xxx, 关联订单号: null
|
|
||||||
```
|
|
||||||
|
|
||||||
## 验证方法
|
|
||||||
|
|
||||||
### 1. 数据库验证
|
|
||||||
```sql
|
|
||||||
-- 验证携程订单关联关系
|
|
||||||
SELECT ota_order_id, order_no, status FROM t_ctrip_order WHERE ota_order_id = 'your-ota-order-id';
|
|
||||||
|
|
||||||
-- 验证订单中心订单状态
|
|
||||||
SELECT order_no, order_status, pay_type, pay_time FROM orders WHERE order_no = 'your-order-no';
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. 日志验证
|
|
||||||
检查应用日志中是否包含上述关键日志点。
|
|
||||||
|
|
||||||
### 3. 接口验证
|
|
||||||
```bash
|
|
||||||
# 测试核销接口
|
|
||||||
curl -X POST http://localhost:8002/api-coupon/api/order-detail/consume-simple \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{
|
|
||||||
"otaOrderId": "your-ota-order-id",
|
|
||||||
"orderNo": "your-order-no",
|
|
||||||
"itemId": "your-item-id",
|
|
||||||
"useQuantity": 1,
|
|
||||||
"remark": "测试核销"
|
|
||||||
}'
|
|
||||||
```
|
|
||||||
|
|
||||||
## 结论
|
|
||||||
|
|
||||||
✅ **调用链完整**:`consumeOrderSimple` → `consumeOrder` → `updateOrderStatus` → `updateOrderCenterStatus`
|
|
||||||
|
|
||||||
✅ **逻辑正确**:前端传入的 `orderNo` 会被正确处理,核销成功后会自动更新订单中心状态
|
|
||||||
|
|
||||||
✅ **异常处理**:即使订单中心接口调用失败,也不会影响核销流程
|
|
||||||
|
|
||||||
✅ **日志完整**:所有关键步骤都有详细的日志记录
|
|
||||||
@@ -1,251 +0,0 @@
|
|||||||
# 订单明细查询核销接口说明
|
|
||||||
|
|
||||||
## 概述
|
|
||||||
|
|
||||||
本接口提供通过手机号和优惠券价格查询可核销的携程订单明细的功能,支持用户选择订单进行核销操作。
|
|
||||||
|
|
||||||
## 接口列表
|
|
||||||
|
|
||||||
### 1. 查询可核销订单明细
|
|
||||||
|
|
||||||
**接口地址:** `POST /api/order-detail/query`
|
|
||||||
|
|
||||||
**请求参数:**
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"userPhone": "13800138000", // 用户手机号(必填)
|
|
||||||
"couponPrice": 100.00, // 优惠券价格(可选,用于筛选匹配的订单)
|
|
||||||
"onlyConsumable": true, // 是否只查询可核销的订单(默认true)
|
|
||||||
"page": 1, // 页码(默认1)
|
|
||||||
"size": 10 // 页大小(默认10)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**响应结果:**
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"resp_code": 0,
|
|
||||||
"resp_msg": "",
|
|
||||||
"data": {
|
|
||||||
"data": [
|
|
||||||
{
|
|
||||||
"orderId": 123,
|
|
||||||
"otaOrderId": "ctriptest-10816828-454259-145573",
|
|
||||||
"supplierOrderId": "SUPPLIER_ctriptest-10816828-454259-145573_301495ef",
|
|
||||||
"orderStatus": 1,
|
|
||||||
"orderStatusDesc": "已确认",
|
|
||||||
"totalAmount": 100.00,
|
|
||||||
"currency": "CNY",
|
|
||||||
"createTime": "2025-08-30T09:33:42",
|
|
||||||
"orderItems": [
|
|
||||||
{
|
|
||||||
"itemId": 456,
|
|
||||||
"productId": "1801589811",
|
|
||||||
"itemName": "门票",
|
|
||||||
"itemType": "1",
|
|
||||||
"plu": "1",
|
|
||||||
"quantity": 2,
|
|
||||||
"unitPrice": 50.00,
|
|
||||||
"totalPrice": 100.00,
|
|
||||||
"currency": "CNY",
|
|
||||||
"useStartDate": "2025-07-25",
|
|
||||||
"useEndDate": "2025-07-25",
|
|
||||||
"canConsume": true,
|
|
||||||
"usedQuantity": 0,
|
|
||||||
"availableQuantity": 2
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"passengers": [
|
|
||||||
{
|
|
||||||
"passengerId": "PASS_1",
|
|
||||||
"passengerName": "张三",
|
|
||||||
"phone": "13800138000",
|
|
||||||
"passengerStatus": 0,
|
|
||||||
"passengerStatusDesc": "未使用",
|
|
||||||
"idCard": "110101199001011234",
|
|
||||||
"gender": "ADULT",
|
|
||||||
"age": null
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"contact": {
|
|
||||||
"name": "张三",
|
|
||||||
"mobile": "13800138000",
|
|
||||||
"email": "zhangsan@example.com",
|
|
||||||
"contactType": "BOOKER"
|
|
||||||
},
|
|
||||||
"canConsume": true,
|
|
||||||
"consumeReason": null
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"count": 1,
|
|
||||||
"resp_code": 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. 查询单个订单明细
|
|
||||||
|
|
||||||
**接口地址:** `GET /api/order-detail/{otaOrderId}`
|
|
||||||
|
|
||||||
**路径参数:**
|
|
||||||
- `otaOrderId`: 携程订单号
|
|
||||||
|
|
||||||
**响应结果:**
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"resp_code": 0,
|
|
||||||
"resp_msg": "",
|
|
||||||
"data": {
|
|
||||||
// 同上面的订单明细结构
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. 核销订单
|
|
||||||
|
|
||||||
**接口地址:** `POST /api/order-detail/consume`
|
|
||||||
|
|
||||||
**请求参数:**
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"otaOrderId": "ctriptest-10816828-454259-145573",
|
|
||||||
"supplierOrderId": "SUPPLIER_ctriptest-10816828-454259-145573_301495ef",
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"itemId": "1801589811",
|
|
||||||
"plu": "1",
|
|
||||||
"quantity": 1,
|
|
||||||
"passengerIds": ["PASS_1"],
|
|
||||||
"voucherIds": ["VOUCHER_1"]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"remark": "门票入园核销"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**响应结果:**
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"resp_code": 0,
|
|
||||||
"resp_msg": "核销成功",
|
|
||||||
"data": true
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4. 简化核销订单(单商品)
|
|
||||||
|
|
||||||
**接口地址:** `POST /api/order-detail/consume-simple`
|
|
||||||
|
|
||||||
**请求参数:**
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"otaOrderId": "ctriptest-10816870-454259-145573",
|
|
||||||
"itemId": "106943568",
|
|
||||||
"useQuantity": 1,
|
|
||||||
"remark": "门票入园核销"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**响应结果:**
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"resp_code": 0,
|
|
||||||
"resp_msg": "核销成功",
|
|
||||||
"data": true
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 5. 验证订单是否可核销
|
|
||||||
|
|
||||||
**接口地址:** `GET /api/order-detail/{otaOrderId}/validate`
|
|
||||||
|
|
||||||
**路径参数:**
|
|
||||||
- `otaOrderId`: 携程订单号
|
|
||||||
|
|
||||||
**响应结果:**
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"resp_code": 0,
|
|
||||||
"resp_msg": "",
|
|
||||||
"data": true
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 业务逻辑说明
|
|
||||||
|
|
||||||
### 订单查询逻辑
|
|
||||||
|
|
||||||
1. **根据手机号查询订单**:
|
|
||||||
- 通过乘客信息表(t_ctrip_passenger)查询手机号匹配的订单
|
|
||||||
- 通过联系人信息表(t_ctrip_contact)查询手机号匹配的订单
|
|
||||||
- 合并去重后返回订单列表
|
|
||||||
|
|
||||||
2. **订单筛选**:
|
|
||||||
- 支持按优惠券价格筛选(订单总金额必须与优惠券价格匹配)
|
|
||||||
- 默认只返回可核销的订单(onlyConsumable=true)
|
|
||||||
- 支持分页查询
|
|
||||||
|
|
||||||
3. **可核销订单条件**:
|
|
||||||
- 订单状态为"已确认"(1)
|
|
||||||
- 订单项在使用有效期内
|
|
||||||
- 订单项有剩余可用数量
|
|
||||||
- 订单总金额与优惠券价格匹配
|
|
||||||
|
|
||||||
4. **订单状态说明**:
|
|
||||||
- 0: 待确认
|
|
||||||
- 1: 已确认
|
|
||||||
- 2: 已取消
|
|
||||||
- 3: 已退款
|
|
||||||
- 4: 已核销
|
|
||||||
- 5: 已取消
|
|
||||||
- 11: 待支付
|
|
||||||
- 12: 支付中
|
|
||||||
- 13: 支付确认
|
|
||||||
- 14: 预订单已取消
|
|
||||||
|
|
||||||
### 核销验证逻辑
|
|
||||||
|
|
||||||
1. **订单状态验证**:
|
|
||||||
- 只有状态为"已确认"(1)的订单才能核销
|
|
||||||
|
|
||||||
2. **订单项验证**:
|
|
||||||
- 检查使用日期是否在有效期内
|
|
||||||
- 检查剩余可用数量是否足够
|
|
||||||
|
|
||||||
3. **核销流程**:
|
|
||||||
- 验证订单和订单项的可核销性
|
|
||||||
- 调用携程核销接口
|
|
||||||
- 更新本地核销记录
|
|
||||||
|
|
||||||
### 使用场景
|
|
||||||
|
|
||||||
1. **用户查询可核销订单**:
|
|
||||||
- 用户输入手机号和优惠券价格
|
|
||||||
- 系统返回匹配的可核销订单列表
|
|
||||||
- 用户查看订单详细信息和核销状态
|
|
||||||
|
|
||||||
2. **选择核销订单**:
|
|
||||||
- 用户从查询结果中选择要核销的订单
|
|
||||||
- 系统显示订单的可核销状态和原因
|
|
||||||
|
|
||||||
3. **执行核销操作**:
|
|
||||||
- 用户选择要核销的商品和数量
|
|
||||||
- 系统验证核销条件
|
|
||||||
- 调用携程接口完成核销
|
|
||||||
|
|
||||||
## 错误码说明
|
|
||||||
|
|
||||||
- `0000`: 成功
|
|
||||||
- `0001`: 参数错误
|
|
||||||
- `0002`: 订单不存在
|
|
||||||
- `0003`: 订单状态不正确
|
|
||||||
- `0004`: 订单项不可核销
|
|
||||||
- `0005`: 核销失败
|
|
||||||
|
|
||||||
## 注意事项
|
|
||||||
|
|
||||||
1. **手机号查询**:系统会同时查询乘客信息和联系人信息,确保能找到用户的所有订单
|
|
||||||
2. **核销限制**:只有已确认的订单才能进行核销操作
|
|
||||||
3. **数量控制**:核销数量不能超过订单项的剩余可用数量
|
|
||||||
4. **日期验证**:核销日期必须在商品的使用有效期内
|
|
||||||
5. **幂等性**:重复核销同一订单项会返回成功,但不会重复扣减数量
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,167 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>com.zlt</groupId>
|
|
||||||
<artifactId>central-platform</artifactId>
|
|
||||||
<version>6.0.0</version>
|
|
||||||
<relativePath>../../pom.xml</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>coupon-center</artifactId>
|
|
||||||
<description>优惠券中心服务</description>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- 公共实体类模块 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zlt</groupId>
|
|
||||||
<artifactId>zlt-config</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zlt</groupId>
|
|
||||||
<artifactId>zlt-log-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zlt</groupId>
|
|
||||||
<artifactId>zlt-common-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zlt</groupId>
|
|
||||||
<artifactId>zlt-db-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zlt</groupId>
|
|
||||||
<artifactId>zlt-redis-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zlt</groupId>
|
|
||||||
<artifactId>zlt-loadbalancer-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zlt</groupId>
|
|
||||||
<artifactId>zlt-sentinel-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- swagger -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.xiaoymin</groupId>
|
|
||||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zlt</groupId>
|
|
||||||
<artifactId>search-client</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>mysql</groupId>
|
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.micrometer</groupId>
|
|
||||||
<artifactId>micrometer-registry-prometheus</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.hibernate</groupId>
|
|
||||||
<artifactId>hibernate-validator</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
|
||||||
<version>4.0.1</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-webflux</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.aliyun</groupId>
|
|
||||||
<artifactId>alibabacloud-ice20201109</artifactId>
|
|
||||||
<version>5.0.3</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-commons</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.trip</groupId>
|
|
||||||
<artifactId>tourop</artifactId>
|
|
||||||
<version>1.1</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>repackage</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>com.spotify</groupId>
|
|
||||||
<artifactId>docker-maven-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
|
|
||||||
<imageTags>
|
|
||||||
<imageTag>${project.version}</imageTag>
|
|
||||||
<imageTag>latest</imageTag>
|
|
||||||
</imageTags>
|
|
||||||
<forceTags>true</forceTags>
|
|
||||||
<baseImage>${docker.baseImage}</baseImage>
|
|
||||||
<volumes>${docker.volumes}</volumes>
|
|
||||||
<env>
|
|
||||||
<JAVA_OPTS>${docker.java.opts}</JAVA_OPTS>
|
|
||||||
</env>
|
|
||||||
<entryPoint>["sh","-c","java $JAVA_OPTS ${docker.java.security.egd} -jar /${project.build.finalName}.jar"]</entryPoint>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<targetPath>/</targetPath>
|
|
||||||
<directory>${project.build.directory}</directory>
|
|
||||||
<include>${project.build.finalName}.jar</include>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
<finalName>${project.artifactId}</finalName>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
-- 为 t_ctrip_order 表添加 order_no 字段,用于关联订单中心的订单号
|
|
||||||
-- 这样核销成功后可以通过这个关联关系更新订单状态
|
|
||||||
|
|
||||||
ALTER TABLE `t_ctrip_order`
|
|
||||||
ADD COLUMN `order_no` varchar(50) DEFAULT NULL COMMENT '关联的订单中心订单号' AFTER `ota_order_id`;
|
|
||||||
|
|
||||||
-- 添加索引以提高查询性能
|
|
||||||
ALTER TABLE `t_ctrip_order`
|
|
||||||
ADD INDEX `idx_order_no` (`order_no`);
|
|
||||||
|
|
||||||
-- 添加唯一索引确保一个订单号只能关联一个携程订单
|
|
||||||
ALTER TABLE `t_ctrip_order`
|
|
||||||
ADD UNIQUE INDEX `uk_order_no` (`order_no`);
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
-- 修复 t_ctrip_order 表字段不匹配问题
|
|
||||||
-- 添加缺失的字段,修改字段名称以匹配实体类
|
|
||||||
|
|
||||||
-- 1. 添加 supplier_order_id 字段
|
|
||||||
ALTER TABLE `t_ctrip_order`
|
|
||||||
ADD COLUMN `supplier_order_id` varchar(100) DEFAULT NULL COMMENT '供应商订单号' AFTER `ota_order_id`;
|
|
||||||
|
|
||||||
-- 2. 添加 confirm_type 字段
|
|
||||||
ALTER TABLE `t_ctrip_order`
|
|
||||||
ADD COLUMN `confirm_type` int(11) DEFAULT NULL COMMENT '确认类型:1-仅通知,2-需确认' AFTER `sequence_id`;
|
|
||||||
|
|
||||||
-- 3. 添加 status 字段(重命名 order_status)
|
|
||||||
ALTER TABLE `t_ctrip_order`
|
|
||||||
ADD COLUMN `status` int(11) DEFAULT 0 COMMENT '订单状态:0-待确认,1-已确认,2-已取消' AFTER `confirm_type`;
|
|
||||||
|
|
||||||
-- 4. 修改 total_amount_currency 为 currency
|
|
||||||
ALTER TABLE `t_ctrip_order`
|
|
||||||
ADD COLUMN `currency` varchar(10) DEFAULT 'CNY' COMMENT '货币类型' AFTER `total_amount`;
|
|
||||||
|
|
||||||
-- 5. 为新字段添加索引
|
|
||||||
ALTER TABLE `t_ctrip_order`
|
|
||||||
ADD INDEX `idx_supplier_order_id` (`supplier_order_id`);
|
|
||||||
|
|
||||||
ALTER TABLE `t_ctrip_order`
|
|
||||||
ADD INDEX `idx_status` (`status`);
|
|
||||||
|
|
||||||
-- 6. 可选:删除旧的字段(先确认数据迁移完成后再执行)
|
|
||||||
-- ALTER TABLE `t_ctrip_order` DROP COLUMN `order_status`;
|
|
||||||
-- ALTER TABLE `t_ctrip_order` DROP COLUMN `total_amount_currency`;
|
|
||||||
-- ALTER TABLE `t_ctrip_order` DROP COLUMN `contact_name`;
|
|
||||||
-- ALTER TABLE `t_ctrip_order` DROP COLUMN `contact_phone`;
|
|
||||||
-- ALTER TABLE `t_ctrip_order` DROP COLUMN `contact_email`;
|
|
||||||
-- ALTER TABLE `t_ctrip_order` DROP COLUMN `contact_type`;
|
|
||||||
-- ALTER TABLE `t_ctrip_order` DROP COLUMN `order_create_time`;
|
|
||||||
|
|
||||||
-- 执行完毕后,表结构将与实体类匹配
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
@@ -1,278 +0,0 @@
|
|||||||
-- 创建数据库
|
|
||||||
CREATE DATABASE IF NOT EXISTS `coupon-center` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|
||||||
|
|
||||||
USE `coupon-center`;
|
|
||||||
|
|
||||||
-- 优惠券表
|
|
||||||
CREATE TABLE IF NOT EXISTS `t_coupon` (
|
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
|
||||||
`tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID',
|
|
||||||
`coupon_name` varchar(100) NOT NULL COMMENT '优惠券名称',
|
|
||||||
`coupon_type` varchar(20) NOT NULL COMMENT '优惠券类型',
|
|
||||||
`amount` decimal(10,2) NOT NULL COMMENT '优惠券金额',
|
|
||||||
`amount_currency` varchar(10) DEFAULT 'CNY' COMMENT '货币类型',
|
|
||||||
`user_phone` varchar(20) NOT NULL COMMENT '用户手机号',
|
|
||||||
`ctrip_coupon_id` varchar(100) DEFAULT NULL COMMENT '携程优惠券ID',
|
|
||||||
`ctrip_order_id` varchar(100) DEFAULT NULL COMMENT '携程订单ID',
|
|
||||||
`status` varchar(20) DEFAULT 'UNUSED' COMMENT '状态:UNUSED-未使用,USED-已使用,EXPIRED-已过期,VOIDED-已作废',
|
|
||||||
`valid_start_time` datetime NOT NULL COMMENT '有效期开始时间',
|
|
||||||
`valid_end_time` datetime NOT NULL COMMENT '有效期结束时间',
|
|
||||||
`used_time` datetime DEFAULT NULL COMMENT '使用时间',
|
|
||||||
`used_order_no` varchar(100) DEFAULT NULL COMMENT '使用订单号',
|
|
||||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
|
||||||
`create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
|
|
||||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
|
||||||
`update_by` varchar(50) DEFAULT NULL COMMENT '更新人',
|
|
||||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
|
||||||
`deleted` tinyint(1) DEFAULT 0 COMMENT '是否删除',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `idx_user_phone` (`user_phone`),
|
|
||||||
KEY `idx_ctrip_coupon_id` (`ctrip_coupon_id`),
|
|
||||||
KEY `idx_status` (`status`),
|
|
||||||
KEY `idx_valid_end_time` (`valid_end_time`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='优惠券表';
|
|
||||||
|
|
||||||
-- 携程订单表
|
|
||||||
CREATE TABLE IF NOT EXISTS `t_ctrip_order` (
|
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
|
||||||
`tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID',
|
|
||||||
`ota_order_id` varchar(100) NOT NULL COMMENT 'OTA订单ID',
|
|
||||||
`sequence_id` varchar(100) NOT NULL COMMENT '序列号ID',
|
|
||||||
`order_status` varchar(20) DEFAULT 'PENDING' COMMENT '订单状态',
|
|
||||||
`total_amount` decimal(10,2) DEFAULT NULL COMMENT '订单总金额',
|
|
||||||
`total_amount_currency` varchar(10) DEFAULT 'CNY' COMMENT '货币类型',
|
|
||||||
`contact_name` varchar(50) DEFAULT NULL COMMENT '联系人姓名',
|
|
||||||
`contact_phone` varchar(20) DEFAULT NULL COMMENT '联系人电话',
|
|
||||||
`contact_email` varchar(100) DEFAULT NULL COMMENT '联系人邮箱',
|
|
||||||
`contact_type` varchar(20) DEFAULT NULL COMMENT '联系人类型',
|
|
||||||
`order_create_time` datetime DEFAULT NULL COMMENT '订单创建时间',
|
|
||||||
`order_last_confirm_time` datetime DEFAULT NULL COMMENT '订单最后确认时间',
|
|
||||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
|
||||||
`create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
|
|
||||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
|
||||||
`update_by` varchar(50) DEFAULT NULL COMMENT '更新人',
|
|
||||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
|
||||||
`deleted` tinyint(1) DEFAULT 0 COMMENT '是否删除',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `uk_sequence_id` (`sequence_id`),
|
|
||||||
KEY `idx_ota_order_id` (`ota_order_id`),
|
|
||||||
KEY `idx_order_status` (`order_status`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='携程订单表';
|
|
||||||
|
|
||||||
-- 携程订单项目表
|
|
||||||
CREATE TABLE IF NOT EXISTS `t_ctrip_order_item` (
|
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
|
||||||
`tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID',
|
|
||||||
`order_id` bigint(20) NOT NULL COMMENT '订单ID',
|
|
||||||
`item_id` varchar(100) NOT NULL COMMENT '项目ID',
|
|
||||||
`item_name` varchar(200) DEFAULT NULL COMMENT '项目名称',
|
|
||||||
`item_type` varchar(50) DEFAULT NULL COMMENT '项目类型',
|
|
||||||
`quantity` int(11) DEFAULT 1 COMMENT '数量',
|
|
||||||
`unit_price` decimal(10,2) DEFAULT NULL COMMENT '单价',
|
|
||||||
`total_price` decimal(10,2) DEFAULT NULL COMMENT '总价',
|
|
||||||
`total_price_currency` varchar(10) DEFAULT 'CNY' COMMENT '货币类型',
|
|
||||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
|
||||||
`create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
|
|
||||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
|
||||||
`update_by` varchar(50) DEFAULT NULL COMMENT '更新人',
|
|
||||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
|
||||||
`deleted` tinyint(1) DEFAULT 0 COMMENT '是否删除',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `uk_order_item` (`order_id`, `item_id`),
|
|
||||||
KEY `idx_order_id` (`order_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='携程订单项目表';
|
|
||||||
|
|
||||||
-- 携程乘客表
|
|
||||||
CREATE TABLE IF NOT EXISTS `t_ctrip_passenger` (
|
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
|
||||||
`tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID',
|
|
||||||
`order_id` bigint(20) NOT NULL COMMENT '订单ID',
|
|
||||||
`item_id` varchar(100) NOT NULL COMMENT '项目ID',
|
|
||||||
`passenger_id` varchar(100) NOT NULL COMMENT '乘客ID',
|
|
||||||
`passenger_name` varchar(50) NOT NULL COMMENT '乘客姓名',
|
|
||||||
`passenger_type` varchar(20) DEFAULT NULL COMMENT '乘客类型',
|
|
||||||
`id_type` varchar(20) DEFAULT NULL COMMENT '证件类型',
|
|
||||||
`id_number` varchar(50) DEFAULT NULL COMMENT '证件号码',
|
|
||||||
`phone` varchar(20) DEFAULT NULL COMMENT '手机号',
|
|
||||||
`gender` varchar(10) DEFAULT NULL COMMENT '性别',
|
|
||||||
`birth_date` date DEFAULT NULL COMMENT '出生日期',
|
|
||||||
`age_type` varchar(20) DEFAULT NULL COMMENT '年龄类型',
|
|
||||||
`nationality_code` varchar(10) DEFAULT NULL COMMENT '国籍代码',
|
|
||||||
`nationality_name` varchar(50) DEFAULT NULL COMMENT '国籍名称',
|
|
||||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
|
||||||
`create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
|
|
||||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
|
||||||
`update_by` varchar(50) DEFAULT NULL COMMENT '更新人',
|
|
||||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
|
||||||
`deleted` tinyint(1) DEFAULT 0 COMMENT '是否删除',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `idx_order_id` (`order_id`),
|
|
||||||
KEY `idx_item_id` (`item_id`),
|
|
||||||
KEY `idx_passenger_id` (`passenger_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='携程乘客表';
|
|
||||||
|
|
||||||
-- 携程联系人表
|
|
||||||
CREATE TABLE IF NOT EXISTS `t_ctrip_contact` (
|
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
|
||||||
`tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID',
|
|
||||||
`order_id` bigint(20) NOT NULL COMMENT '订单ID',
|
|
||||||
`name` varchar(50) NOT NULL COMMENT '联系人姓名',
|
|
||||||
`mobile` varchar(20) NOT NULL COMMENT '手机号',
|
|
||||||
`email` varchar(100) DEFAULT NULL COMMENT '邮箱',
|
|
||||||
`intl_code` varchar(10) DEFAULT '+86' COMMENT '国际区号',
|
|
||||||
`optional_mobile` varchar(20) DEFAULT NULL COMMENT '备用手机号',
|
|
||||||
`optional_intl_code` varchar(10) DEFAULT NULL COMMENT '备用国际区号',
|
|
||||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
|
||||||
`create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
|
|
||||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
|
||||||
`update_by` varchar(50) DEFAULT NULL COMMENT '更新人',
|
|
||||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
|
||||||
`deleted` tinyint(1) DEFAULT 0 COMMENT '是否删除',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `idx_order_id` (`order_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='携程联系人表';
|
|
||||||
|
|
||||||
-- 携程优惠券表
|
|
||||||
CREATE TABLE IF NOT EXISTS `t_ctrip_coupon` (
|
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
|
||||||
`tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID',
|
|
||||||
`order_id` bigint(20) NOT NULL COMMENT '订单ID',
|
|
||||||
`coupon_id` varchar(100) NOT NULL COMMENT '优惠券ID',
|
|
||||||
`coupon_type` varchar(20) DEFAULT NULL COMMENT '优惠券类型',
|
|
||||||
`amount` decimal(10,2) DEFAULT NULL COMMENT '优惠券金额',
|
|
||||||
`amount_currency` varchar(10) DEFAULT 'CNY' COMMENT '货币类型',
|
|
||||||
`status` varchar(20) DEFAULT 'UNUSED' COMMENT '状态',
|
|
||||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
|
||||||
`create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
|
|
||||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
|
||||||
`update_by` varchar(50) DEFAULT NULL COMMENT '更新人',
|
|
||||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
|
||||||
`deleted` tinyint(1) DEFAULT 0 COMMENT '是否删除',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `idx_order_id` (`order_id`),
|
|
||||||
KEY `idx_coupon_id` (`coupon_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='携程优惠券表';
|
|
||||||
|
|
||||||
-- 携程凭证表
|
|
||||||
CREATE TABLE IF NOT EXISTS `t_ctrip_voucher` (
|
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
|
||||||
`tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID',
|
|
||||||
`order_id` bigint(20) NOT NULL COMMENT '订单ID',
|
|
||||||
`voucher_id` varchar(100) NOT NULL COMMENT '凭证ID',
|
|
||||||
`voucher_type` varchar(20) DEFAULT NULL COMMENT '凭证类型',
|
|
||||||
`voucher_code` varchar(100) DEFAULT NULL COMMENT '凭证码',
|
|
||||||
`status` varchar(20) DEFAULT 'UNUSED' COMMENT '状态',
|
|
||||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
|
||||||
`create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
|
|
||||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
|
||||||
`update_by` varchar(50) DEFAULT NULL COMMENT '更新人',
|
|
||||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
|
||||||
`deleted` tinyint(1) DEFAULT 0 COMMENT '是否删除',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `idx_order_id` (`order_id`),
|
|
||||||
KEY `idx_voucher_id` (`voucher_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='携程凭证表';
|
|
||||||
|
|
||||||
-- 携程退款表
|
|
||||||
CREATE TABLE IF NOT EXISTS `t_ctrip_refund` (
|
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
|
||||||
`tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID',
|
|
||||||
`order_id` bigint(20) NOT NULL COMMENT '订单ID',
|
|
||||||
`refund_id` varchar(100) NOT NULL COMMENT '退款ID',
|
|
||||||
`refund_amount` decimal(10,2) DEFAULT NULL COMMENT '退款金额',
|
|
||||||
`refund_amount_currency` varchar(10) DEFAULT 'CNY' COMMENT '货币类型',
|
|
||||||
`refund_status` varchar(20) DEFAULT 'PENDING' COMMENT '退款状态',
|
|
||||||
`refund_reason` varchar(200) DEFAULT NULL COMMENT '退款原因',
|
|
||||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
|
||||||
`create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
|
|
||||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
|
||||||
`update_by` varchar(50) DEFAULT NULL COMMENT '更新人',
|
|
||||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
|
||||||
`deleted` tinyint(1) DEFAULT 0 COMMENT '是否删除',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `idx_order_id` (`order_id`),
|
|
||||||
KEY `idx_refund_id` (`refund_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='携程退款表';
|
|
||||||
|
|
||||||
-- 携程退款项目表
|
|
||||||
CREATE TABLE IF NOT EXISTS `t_ctrip_refund_item` (
|
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
|
||||||
`tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID',
|
|
||||||
`refund_id` bigint(20) NOT NULL COMMENT '退款ID',
|
|
||||||
`item_id` varchar(100) NOT NULL COMMENT '项目ID',
|
|
||||||
`item_name` varchar(200) DEFAULT NULL COMMENT '项目名称',
|
|
||||||
`quantity` int(11) DEFAULT 1 COMMENT '数量',
|
|
||||||
`refund_amount` decimal(10,2) DEFAULT NULL COMMENT '退款金额',
|
|
||||||
`refund_amount_currency` varchar(10) DEFAULT 'CNY' COMMENT '货币类型',
|
|
||||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
|
||||||
`create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
|
|
||||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
|
||||||
`update_by` varchar(50) DEFAULT NULL COMMENT '更新人',
|
|
||||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
|
||||||
`deleted` tinyint(1) DEFAULT 0 COMMENT '是否删除',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `idx_refund_id` (`refund_id`),
|
|
||||||
KEY `idx_item_id` (`item_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='携程退款项目表';
|
|
||||||
|
|
||||||
-- 携程核销表
|
|
||||||
CREATE TABLE IF NOT EXISTS `t_ctrip_consumed` (
|
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
|
||||||
`tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID',
|
|
||||||
`order_id` bigint(20) NOT NULL COMMENT '订单ID',
|
|
||||||
`consumed_id` varchar(100) NOT NULL COMMENT '核销ID',
|
|
||||||
`total_quantity` int(11) DEFAULT 0 COMMENT '总数量',
|
|
||||||
`consumed_status` varchar(20) DEFAULT 'PENDING' COMMENT '核销状态',
|
|
||||||
`consumed_time` datetime DEFAULT NULL COMMENT '核销时间',
|
|
||||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
|
||||||
`create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
|
|
||||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
|
||||||
`update_by` varchar(50) DEFAULT NULL COMMENT '更新人',
|
|
||||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
|
||||||
`deleted` tinyint(1) DEFAULT 0 COMMENT '是否删除',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `idx_order_id` (`order_id`),
|
|
||||||
KEY `idx_consumed_id` (`consumed_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='携程核销表';
|
|
||||||
|
|
||||||
-- 携程核销乘客表
|
|
||||||
CREATE TABLE IF NOT EXISTS `t_ctrip_consumed_passenger` (
|
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
|
||||||
`tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID',
|
|
||||||
`consumed_id` bigint(20) NOT NULL COMMENT '核销ID',
|
|
||||||
`passenger_id` varchar(100) NOT NULL COMMENT '乘客ID',
|
|
||||||
`passenger_name` varchar(50) NOT NULL COMMENT '乘客姓名',
|
|
||||||
`quantity` int(11) DEFAULT 1 COMMENT '数量',
|
|
||||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
|
||||||
`create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
|
|
||||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
|
||||||
`update_by` varchar(50) DEFAULT NULL COMMENT '更新人',
|
|
||||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
|
||||||
`deleted` tinyint(1) DEFAULT 0 COMMENT '是否删除',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `idx_consumed_id` (`consumed_id`),
|
|
||||||
KEY `idx_passenger_id` (`passenger_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='携程核销乘客表';
|
|
||||||
|
|
||||||
-- 携程核销凭证表
|
|
||||||
CREATE TABLE IF NOT EXISTS `t_ctrip_consumed_voucher` (
|
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
|
||||||
`tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID',
|
|
||||||
`consumed_id` bigint(20) NOT NULL COMMENT '核销ID',
|
|
||||||
`voucher_id` varchar(100) NOT NULL COMMENT '凭证ID',
|
|
||||||
`voucher_code` varchar(100) DEFAULT NULL COMMENT '凭证码',
|
|
||||||
`quantity` int(11) DEFAULT 1 COMMENT '数量',
|
|
||||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
|
||||||
`create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
|
|
||||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
|
||||||
`update_by` varchar(50) DEFAULT NULL COMMENT '更新人',
|
|
||||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
|
||||||
`deleted` tinyint(1) DEFAULT 0 COMMENT '是否删除',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `idx_consumed_id` (`consumed_id`),
|
|
||||||
KEY `idx_voucher_id` (`voucher_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='携程核销凭证表';
|
|
||||||
|
|
||||||
-- 插入测试数据
|
|
||||||
INSERT INTO `t_coupon` (`coupon_name`, `coupon_type`, `amount`, `user_phone`, `status`, `valid_start_time`, `valid_end_time`, `create_by`)
|
|
||||||
VALUES ('测试优惠券', 'DISCOUNT', 10.00, '18322694510', 'UNUSED', NOW(), DATE_ADD(NOW(), INTERVAL 30 DAY), 'system');
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
-- 删除旧的优惠券相关表
|
|
||||||
-- 这些表已被 t_user_coupon 表替代
|
|
||||||
|
|
||||||
-- 删除 t_coupon 表
|
|
||||||
DROP TABLE IF EXISTS `t_coupon`;
|
|
||||||
|
|
||||||
-- 删除 t_ctrip_coupon 表
|
|
||||||
DROP TABLE IF EXISTS `t_ctrip_coupon`;
|
|
||||||
|
|
||||||
-- 删除相关的索引(如果存在)
|
|
||||||
-- 注意:DROP TABLE 会自动删除相关的索引,所以这里不需要单独删除
|
|
||||||
|
|
||||||
-- 验证表是否已删除
|
|
||||||
SELECT
|
|
||||||
TABLE_NAME
|
|
||||||
FROM
|
|
||||||
INFORMATION_SCHEMA.TABLES
|
|
||||||
WHERE
|
|
||||||
TABLE_SCHEMA = DATABASE()
|
|
||||||
AND TABLE_NAME IN ('t_coupon', 't_ctrip_coupon');
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
-- 修复 t_ctrip_order 和 t_ctrip_order_item 表缺少的字段
|
|
||||||
-- 执行前请备份数据库
|
|
||||||
|
|
||||||
USE `coupon-center`;
|
|
||||||
|
|
||||||
-- ========================================
|
|
||||||
-- 修复 t_ctrip_order 表
|
|
||||||
-- ========================================
|
|
||||||
|
|
||||||
-- 1. 添加 supplier_order_id 字段
|
|
||||||
ALTER TABLE `t_ctrip_order`
|
|
||||||
ADD COLUMN `supplier_order_id` varchar(100) DEFAULT NULL COMMENT '供应商订单ID'
|
|
||||||
AFTER `ota_order_id`;
|
|
||||||
|
|
||||||
-- 2. 添加 confirm_type 字段
|
|
||||||
ALTER TABLE `t_ctrip_order`
|
|
||||||
ADD COLUMN `confirm_type` int(11) DEFAULT NULL COMMENT '确认类型'
|
|
||||||
AFTER `sequence_id`;
|
|
||||||
|
|
||||||
-- 3. 添加 status 字段(如果不存在)
|
|
||||||
ALTER TABLE `t_ctrip_order`
|
|
||||||
ADD COLUMN `status` int(11) DEFAULT 0 COMMENT '订单状态:0-待确认,1-已确认,2-已取消'
|
|
||||||
AFTER `confirm_type`;
|
|
||||||
|
|
||||||
-- 4. 添加 currency 字段(如果不存在)
|
|
||||||
ALTER TABLE `t_ctrip_order`
|
|
||||||
ADD COLUMN `currency` varchar(10) DEFAULT 'CNY' COMMENT '货币类型'
|
|
||||||
AFTER `total_amount`;
|
|
||||||
|
|
||||||
-- 5. 添加索引
|
|
||||||
ALTER TABLE `t_ctrip_order`
|
|
||||||
ADD INDEX `idx_supplier_order_id` (`supplier_order_id`);
|
|
||||||
|
|
||||||
-- ========================================
|
|
||||||
-- 修复 t_ctrip_order_item 表
|
|
||||||
-- ========================================
|
|
||||||
|
|
||||||
-- 1. 添加 currency 字段(如果不存在)
|
|
||||||
ALTER TABLE `t_ctrip_order_item`
|
|
||||||
ADD COLUMN `currency` varchar(10) DEFAULT 'CNY' COMMENT '货币类型'
|
|
||||||
AFTER `total_price`;
|
|
||||||
|
|
||||||
-- 2. 添加 use_start_date 字段(如果不存在)
|
|
||||||
ALTER TABLE `t_ctrip_order_item`
|
|
||||||
ADD COLUMN `use_start_date` date DEFAULT NULL COMMENT '使用开始日期'
|
|
||||||
AFTER `currency`;
|
|
||||||
|
|
||||||
-- 3. 添加 use_end_date 字段(如果不存在)
|
|
||||||
ALTER TABLE `t_ctrip_order_item`
|
|
||||||
ADD COLUMN `use_end_date` date DEFAULT NULL COMMENT '使用结束日期'
|
|
||||||
AFTER `use_start_date`;
|
|
||||||
|
|
||||||
-- 4. 添加 plu 字段(如果不存在)
|
|
||||||
ALTER TABLE `t_ctrip_order_item`
|
|
||||||
ADD COLUMN `plu` varchar(100) DEFAULT NULL COMMENT 'PLU编码'
|
|
||||||
AFTER `item_type`;
|
|
||||||
|
|
||||||
-- 5. 添加 price 字段(如果不存在)
|
|
||||||
ALTER TABLE `t_ctrip_order_item`
|
|
||||||
ADD COLUMN `price` decimal(10,2) DEFAULT NULL COMMENT '原价'
|
|
||||||
AFTER `plu`;
|
|
||||||
|
|
||||||
-- 6. 添加 sale_price 字段(如果不存在)
|
|
||||||
ALTER TABLE `t_ctrip_order_item`
|
|
||||||
ADD COLUMN `sale_price` decimal(10,2) DEFAULT NULL COMMENT '销售价'
|
|
||||||
AFTER `price`;
|
|
||||||
|
|
||||||
-- 7. 添加 create_by 字段(如果不存在)
|
|
||||||
ALTER TABLE `t_ctrip_order_item`
|
|
||||||
ADD COLUMN `create_by` varchar(50) DEFAULT NULL COMMENT '创建人'
|
|
||||||
AFTER `update_time`;
|
|
||||||
|
|
||||||
-- 8. 添加 update_by 字段(如果不存在)
|
|
||||||
ALTER TABLE `t_ctrip_order_item`
|
|
||||||
ADD COLUMN `update_by` varchar(50) DEFAULT NULL COMMENT '更新人'
|
|
||||||
AFTER `create_by`;
|
|
||||||
|
|
||||||
-- 9. 添加 remark 字段(如果不存在)
|
|
||||||
ALTER TABLE `t_ctrip_order_item`
|
|
||||||
ADD COLUMN `remark` varchar(500) DEFAULT NULL COMMENT '备注'
|
|
||||||
AFTER `update_by`;
|
|
||||||
|
|
||||||
-- 10. 添加 tenant_id 字段(如果不存在)
|
|
||||||
ALTER TABLE `t_ctrip_order_item`
|
|
||||||
ADD COLUMN `tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID'
|
|
||||||
AFTER `remark`;
|
|
||||||
|
|
||||||
-- 11. 添加 voucher_id 字段(用于PayPreOrderConfirm)
|
|
||||||
ALTER TABLE `t_ctrip_order_item`
|
|
||||||
ADD COLUMN `voucher_id` varchar(100) DEFAULT NULL COMMENT '凭证ID(用于PayPreOrderConfirm)'
|
|
||||||
AFTER `use_end_date`;
|
|
||||||
|
|
||||||
-- 12. 添加 passenger_id 字段(用于PayPreOrderConfirm)
|
|
||||||
ALTER TABLE `t_ctrip_order_item`
|
|
||||||
ADD COLUMN `passenger_id` varchar(100) DEFAULT NULL COMMENT '乘客ID(用于PayPreOrderConfirm)'
|
|
||||||
AFTER `voucher_id`;
|
|
||||||
|
|
||||||
-- 13. 添加 passenger_voucher_id 字段(用于PayPreOrderConfirm,与voucher_id不同)
|
|
||||||
ALTER TABLE `t_ctrip_order_item`
|
|
||||||
ADD COLUMN `passenger_voucher_id` varchar(100) DEFAULT NULL COMMENT '乘客凭证ID(用于PayPreOrderConfirm,与voucher_id不同)'
|
|
||||||
AFTER `passenger_id`;
|
|
||||||
|
|
||||||
-- 14. 添加索引
|
|
||||||
ALTER TABLE `t_ctrip_order_item`
|
|
||||||
ADD INDEX `idx_currency` (`currency`);
|
|
||||||
|
|
||||||
-- ========================================
|
|
||||||
-- 验证表结构
|
|
||||||
-- ========================================
|
|
||||||
|
|
||||||
-- 验证 t_ctrip_order 表结构
|
|
||||||
DESCRIBE `t_ctrip_order`;
|
|
||||||
|
|
||||||
-- 验证 t_ctrip_order_item 表结构
|
|
||||||
DESCRIBE `t_ctrip_order_item`;
|
|
||||||
|
|
||||||
-- 显示修复后的完整表结构
|
|
||||||
SHOW CREATE TABLE `t_ctrip_order`;
|
|
||||||
SHOW CREATE TABLE `t_ctrip_order_item`;
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
-- 紧急修复 t_ctrip_order 表字段不匹配问题
|
|
||||||
-- 只添加立即需要的关键字段
|
|
||||||
|
|
||||||
-- 检查字段是否存在,如果不存在则添加
|
|
||||||
-- 1. 添加 supplier_order_id 字段
|
|
||||||
SET @sql = CONCAT('ALTER TABLE t_ctrip_order ADD COLUMN supplier_order_id varchar(100) DEFAULT NULL COMMENT ''供应商订单号'' AFTER ota_order_id');
|
|
||||||
SET @exist = (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 't_ctrip_order' AND COLUMN_NAME = 'supplier_order_id');
|
|
||||||
SET @sql = IF(@exist = 0, @sql, 'SELECT ''supplier_order_id already exists'' AS info');
|
|
||||||
PREPARE stmt FROM @sql;
|
|
||||||
EXECUTE stmt;
|
|
||||||
DEALLOCATE PREPARE stmt;
|
|
||||||
|
|
||||||
-- 2. 添加 confirm_type 字段
|
|
||||||
SET @sql = CONCAT('ALTER TABLE t_ctrip_order ADD COLUMN confirm_type int(11) DEFAULT NULL COMMENT ''确认类型:1-仅通知,2-需确认'' AFTER sequence_id');
|
|
||||||
SET @exist = (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 't_ctrip_order' AND COLUMN_NAME = 'confirm_type');
|
|
||||||
SET @sql = IF(@exist = 0, @sql, 'SELECT ''confirm_type already exists'' AS info');
|
|
||||||
PREPARE stmt FROM @sql;
|
|
||||||
EXECUTE stmt;
|
|
||||||
DEALLOCATE PREPARE stmt;
|
|
||||||
|
|
||||||
-- 3. 添加 status 字段
|
|
||||||
SET @sql = CONCAT('ALTER TABLE t_ctrip_order ADD COLUMN status int(11) DEFAULT 0 COMMENT ''订单状态:0-待确认,1-已确认,2-已取消'' AFTER confirm_type');
|
|
||||||
SET @exist = (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 't_ctrip_order' AND COLUMN_NAME = 'status');
|
|
||||||
SET @sql = IF(@exist = 0, @sql, 'SELECT ''status already exists'' AS info');
|
|
||||||
PREPARE stmt FROM @sql;
|
|
||||||
EXECUTE stmt;
|
|
||||||
DEALLOCATE PREPARE stmt;
|
|
||||||
|
|
||||||
-- 4. 添加 currency 字段
|
|
||||||
SET @sql = CONCAT('ALTER TABLE t_ctrip_order ADD COLUMN currency varchar(10) DEFAULT ''CNY'' COMMENT ''货币类型'' AFTER total_amount');
|
|
||||||
SET @exist = (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 't_ctrip_order' AND COLUMN_NAME = 'currency');
|
|
||||||
SET @sql = IF(@exist = 0, @sql, 'SELECT ''currency already exists'' AS info');
|
|
||||||
PREPARE stmt FROM @sql;
|
|
||||||
EXECUTE stmt;
|
|
||||||
DEALLOCATE PREPARE stmt;
|
|
||||||
|
|
||||||
-- 5. 添加索引(如果不存在)
|
|
||||||
SET @sql = 'CREATE INDEX idx_supplier_order_id ON t_ctrip_order (supplier_order_id)';
|
|
||||||
SET @exist = (SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 't_ctrip_order' AND INDEX_NAME = 'idx_supplier_order_id');
|
|
||||||
SET @sql = IF(@exist = 0, @sql, 'SELECT ''idx_supplier_order_id already exists'' AS info');
|
|
||||||
PREPARE stmt FROM @sql;
|
|
||||||
EXECUTE stmt;
|
|
||||||
DEALLOCATE PREPARE stmt;
|
|
||||||
|
|
||||||
SET @sql = 'CREATE INDEX idx_status ON t_ctrip_order (status)';
|
|
||||||
SET @exist = (SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 't_ctrip_order' AND INDEX_NAME = 'idx_status');
|
|
||||||
SET @sql = IF(@exist = 0, @sql, 'SELECT ''idx_status already exists'' AS info');
|
|
||||||
PREPARE stmt FROM @sql;
|
|
||||||
EXECUTE stmt;
|
|
||||||
DEALLOCATE PREPARE stmt;
|
|
||||||
|
|
||||||
-- 完成提示
|
|
||||||
SELECT 'Database schema update completed successfully!' AS result;
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
-- 携程退款功能表结构更新脚本
|
|
||||||
-- 执行前请备份数据
|
|
||||||
|
|
||||||
USE `coupon-center`;
|
|
||||||
|
|
||||||
-- 更新 t_ctrip_refund 表结构(如果表已存在则修改,否则创建)
|
|
||||||
DROP TABLE IF EXISTS `t_ctrip_refund_backup`;
|
|
||||||
|
|
||||||
-- 检查表是否存在,如果存在则备份
|
|
||||||
CREATE TABLE IF NOT EXISTS `t_ctrip_refund_backup` AS SELECT * FROM `t_ctrip_refund` WHERE 1=0;
|
|
||||||
INSERT INTO `t_ctrip_refund_backup` SELECT * FROM `t_ctrip_refund` WHERE 1=1;
|
|
||||||
|
|
||||||
-- 删除旧表并重建
|
|
||||||
DROP TABLE IF EXISTS `t_ctrip_refund`;
|
|
||||||
|
|
||||||
CREATE TABLE `t_ctrip_refund` (
|
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
|
||||||
`ota_order_id` varchar(100) NOT NULL COMMENT '携程订单号',
|
|
||||||
`supplier_order_id` varchar(100) DEFAULT NULL COMMENT '供应商订单号',
|
|
||||||
`sequence_id` varchar(100) NOT NULL COMMENT '携程批次流水号',
|
|
||||||
`refund_amount` decimal(10,2) NOT NULL COMMENT '退款金额',
|
|
||||||
`currency` varchar(10) DEFAULT 'CNY' COMMENT '货币类型',
|
|
||||||
`refund_status` int(11) DEFAULT 0 COMMENT '退款状态:0-待确认,1-已确认,2-已拒绝',
|
|
||||||
`confirm_result_code` varchar(50) DEFAULT NULL COMMENT '确认结果码',
|
|
||||||
`confirm_result_message` varchar(500) DEFAULT NULL COMMENT '确认结果信息',
|
|
||||||
`last_confirm_time` datetime DEFAULT NULL COMMENT '最晚确认时间',
|
|
||||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
|
||||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
|
||||||
`create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
|
|
||||||
`update_by` varchar(50) DEFAULT NULL COMMENT '更新人',
|
|
||||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
|
||||||
`tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `uk_sequence_id` (`sequence_id`),
|
|
||||||
KEY `idx_ota_order_id` (`ota_order_id`),
|
|
||||||
KEY `idx_supplier_order_id` (`supplier_order_id`),
|
|
||||||
KEY `idx_refund_status` (`refund_status`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='携程退款表';
|
|
||||||
|
|
||||||
-- 更新 t_ctrip_refund_item 表结构
|
|
||||||
DROP TABLE IF EXISTS `t_ctrip_refund_item_backup`;
|
|
||||||
|
|
||||||
-- 检查表是否存在,如果存在则备份
|
|
||||||
CREATE TABLE IF NOT EXISTS `t_ctrip_refund_item_backup` AS SELECT * FROM `t_ctrip_refund_item` WHERE 1=0;
|
|
||||||
INSERT INTO `t_ctrip_refund_item_backup` SELECT * FROM `t_ctrip_refund_item` WHERE 1=1;
|
|
||||||
|
|
||||||
-- 删除旧表并重建
|
|
||||||
DROP TABLE IF EXISTS `t_ctrip_refund_item`;
|
|
||||||
|
|
||||||
CREATE TABLE `t_ctrip_refund_item` (
|
|
||||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
|
||||||
`refund_id` bigint(20) NOT NULL COMMENT '退款ID',
|
|
||||||
`item_id` varchar(100) DEFAULT NULL COMMENT '订单项编号',
|
|
||||||
`plu` varchar(100) DEFAULT NULL COMMENT '供应商产品最小单位',
|
|
||||||
`refund_amount` decimal(10,2) DEFAULT NULL COMMENT '退款金额',
|
|
||||||
`currency` varchar(10) DEFAULT 'CNY' COMMENT '货币类型',
|
|
||||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
|
||||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
|
||||||
`deleted` tinyint(1) DEFAULT 0 COMMENT '是否删除:0-未删除,1-已删除',
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
KEY `idx_refund_id` (`refund_id`),
|
|
||||||
KEY `idx_item_id` (`item_id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='携程退款项表';
|
|
||||||
|
|
||||||
-- 确保 t_ctrip_order 表有 status 字段(整数类型)
|
|
||||||
-- 订单状态:0-待确认,1-已确认,2-已取消,3-已过期,4-退款中,5-已退款
|
|
||||||
ALTER TABLE `t_ctrip_order`
|
|
||||||
MODIFY COLUMN `status` int(11) DEFAULT 0 COMMENT '订单状态:0-待确认,1-已确认,2-已取消,3-已过期,4-退款中,5-已退款';
|
|
||||||
|
|
||||||
-- 如果 status 字段不存在,则添加
|
|
||||||
-- ALTER TABLE `t_ctrip_order` ADD COLUMN `status` int(11) DEFAULT 0 COMMENT '订单状态:0-待确认,1-已确认,2-已取消,3-已过期,4-退款中,5-已退款';
|
|
||||||
|
|
||||||
-- 清理备份表(可选,确认数据无误后执行)
|
|
||||||
-- DROP TABLE IF EXISTS `t_ctrip_refund_backup`;
|
|
||||||
-- DROP TABLE IF EXISTS `t_ctrip_refund_item_backup`;
|
|
||||||
-27
@@ -1,27 +0,0 @@
|
|||||||
package com.central.coupon;
|
|
||||||
|
|
||||||
import com.central.common.lb.annotation.EnableFeignInterceptor;
|
|
||||||
import com.central.search.annotation.EnableSearchClient;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 优惠券中心启动类
|
|
||||||
*
|
|
||||||
* @author system
|
|
||||||
* @date 2024-12-19
|
|
||||||
*/
|
|
||||||
@EnableDiscoveryClient
|
|
||||||
@EnableSearchClient
|
|
||||||
@EnableTransactionManagement
|
|
||||||
@EnableFeignInterceptor
|
|
||||||
@SpringBootApplication
|
|
||||||
public class CouponCenterApplication {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(CouponCenterApplication.class, args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-64
@@ -1,64 +0,0 @@
|
|||||||
package com.central.coupon.config;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程API配置
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Component
|
|
||||||
@ConfigurationProperties(prefix = "ctrip")
|
|
||||||
public class CtripApiConfig {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* AES加密配置
|
|
||||||
*/
|
|
||||||
private AesConfig aes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* API配置
|
|
||||||
*/
|
|
||||||
private ApiConfig api;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 账户配置
|
|
||||||
*/
|
|
||||||
private AccountConfig account;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class AesConfig {
|
|
||||||
private String key;
|
|
||||||
private String iv;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class ApiConfig {
|
|
||||||
private String testUrl;
|
|
||||||
private String prodUrl;
|
|
||||||
private String environment;
|
|
||||||
private Integer timeout;
|
|
||||||
private Integer retryTimes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前环境的API基础URL
|
|
||||||
*/
|
|
||||||
public String getBaseUrl() {
|
|
||||||
return "prod".equals(environment) ? prodUrl : testUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取订单通知接口的完整URL
|
|
||||||
*/
|
|
||||||
public String getOrderNoticeUrl() {
|
|
||||||
return getBaseUrl() + "/order/notice.do";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class AccountConfig {
|
|
||||||
private String id;
|
|
||||||
private String secret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-32
@@ -1,32 +0,0 @@
|
|||||||
package com.central.coupon.config;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
|
||||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RestTemplate配置类
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class RestTemplateConfig {
|
|
||||||
|
|
||||||
@Value("${ctrip.api.timeout:30000}")
|
|
||||||
private int timeout;
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public RestTemplate restTemplate() {
|
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
|
||||||
restTemplate.setRequestFactory(clientHttpRequestFactory());
|
|
||||||
return restTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ClientHttpRequestFactory clientHttpRequestFactory() {
|
|
||||||
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
|
||||||
factory.setConnectTimeout(timeout);
|
|
||||||
factory.setReadTimeout(timeout);
|
|
||||||
return factory;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-117
@@ -1,117 +0,0 @@
|
|||||||
package com.central.coupon.controller;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.central.common.model.Result;
|
|
||||||
import com.central.common.model.PageResult;
|
|
||||||
import com.central.coupon.entity.Coupon;
|
|
||||||
import com.central.coupon.service.ICouponService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameters;
|
|
||||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 优惠券管理控制器
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/coupon")
|
|
||||||
@Tag(name = "优惠券管理")
|
|
||||||
public class CouponController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ICouponService couponService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列表
|
|
||||||
*/
|
|
||||||
@Operation(summary = "查询列表")
|
|
||||||
@Parameters({
|
|
||||||
@Parameter(name = "page",description = "分页起始位置",required = true,in=ParameterIn.QUERY),
|
|
||||||
@Parameter(name = "limit",description = "分页结束位置",required = true,in=ParameterIn.QUERY)
|
|
||||||
})
|
|
||||||
@GetMapping
|
|
||||||
public PageResult<Coupon> list(@RequestParam Map<String, Object> params) {
|
|
||||||
return couponService.findList(params);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据ID查询优惠券
|
|
||||||
*/
|
|
||||||
@Operation(summary = "根据ID查询优惠券")
|
|
||||||
@GetMapping("/{id}")
|
|
||||||
public Result<Coupon> getCouponById(@PathVariable Long id) {
|
|
||||||
Coupon coupon = couponService.getById(id);
|
|
||||||
return Result.succeed(coupon);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建优惠券
|
|
||||||
*/
|
|
||||||
@Operation(summary = "创建优惠券")
|
|
||||||
@PostMapping
|
|
||||||
public Result<Boolean> createCoupon(@RequestBody Coupon coupon) {
|
|
||||||
boolean result = couponService.createCoupon(coupon);
|
|
||||||
return Result.succeed(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新优惠券
|
|
||||||
*/
|
|
||||||
@Operation(summary = "更新优惠券")
|
|
||||||
@PutMapping("/{id}")
|
|
||||||
public Result<Boolean> updateCoupon(@PathVariable Long id, @RequestBody Coupon coupon) {
|
|
||||||
coupon.setId(id);
|
|
||||||
boolean result = couponService.updateCoupon(coupon);
|
|
||||||
return Result.succeed(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除优惠券
|
|
||||||
*/
|
|
||||||
@Operation(summary = "删除优惠券")
|
|
||||||
@DeleteMapping("/{id}")
|
|
||||||
public Result<Boolean> deleteCoupon(@PathVariable Long id) {
|
|
||||||
boolean result = couponService.deleteCoupon(id);
|
|
||||||
return Result.succeed(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据手机号查询用户优惠券
|
|
||||||
*/
|
|
||||||
@Operation(summary = "根据手机号查询用户优惠券")
|
|
||||||
@GetMapping("/user/{userPhone}")
|
|
||||||
public Result<List<Coupon>> getCouponsByUserPhone(@PathVariable String userPhone) {
|
|
||||||
List<Coupon> coupons = couponService.getCouponsByUserPhone(userPhone);
|
|
||||||
return Result.succeed(coupons);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据手机号查询可用优惠券
|
|
||||||
*/
|
|
||||||
@Operation(summary = "根据手机号查询可用优惠券")
|
|
||||||
@GetMapping("/user/{userPhone}/available")
|
|
||||||
public Result<List<Coupon>> getAvailableCouponsByUserPhone(@PathVariable String userPhone) {
|
|
||||||
List<Coupon> coupons = couponService.getAvailableCouponsByUserPhone(userPhone);
|
|
||||||
return Result.succeed(coupons);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用优惠券
|
|
||||||
*/
|
|
||||||
@Operation(summary = "使用优惠券")
|
|
||||||
@PostMapping("/{id}/use")
|
|
||||||
public Result<Boolean> useCoupon(@PathVariable Long id, @RequestParam String orderNo) {
|
|
||||||
boolean result = couponService.useCoupon(id, orderNo);
|
|
||||||
return Result.succeed(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-334
@@ -1,334 +0,0 @@
|
|||||||
package com.central.coupon.controller;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.central.common.model.Result;
|
|
||||||
import com.central.coupon.entity.CtripContact;
|
|
||||||
import com.central.coupon.entity.CtripOrder;
|
|
||||||
import com.central.coupon.entity.CtripRefund;
|
|
||||||
import com.central.coupon.enums.CtripOrderStatus;
|
|
||||||
import com.central.coupon.mapper.CtripContactMapper;
|
|
||||||
import com.central.coupon.mapper.CtripOrderMapper;
|
|
||||||
import com.central.coupon.mapper.CtripRefundMapper;
|
|
||||||
import com.central.coupon.model.CtripAdminRefundRequest;
|
|
||||||
import com.central.coupon.service.ICtripAdminRefundService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程管理后台退款控制器
|
|
||||||
* 用于管理后台发起携程订单退款
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Tag(name = "携程管理后台退款接口")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/coupon/ctrip/admin/refund")
|
|
||||||
public class CtripAdminRefundController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ICtripAdminRefundService ctripAdminRefundService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripOrderMapper ctripOrderMapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripRefundMapper ctripRefundMapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripContactMapper ctripContactMapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 管理后台发起携程退款
|
|
||||||
*/
|
|
||||||
@Operation(summary = "管理后台发起携程退款")
|
|
||||||
@PostMapping("/apply")
|
|
||||||
public Result<String> applyRefund(@RequestBody CtripAdminRefundRequest request) {
|
|
||||||
log.info("管理后台发起携程退款请求,orderNo: {}, refundAmount: {}",
|
|
||||||
request.getOrderNo(), request.getRefundAmount());
|
|
||||||
|
|
||||||
try {
|
|
||||||
return ctripAdminRefundService.processAdminRefund(request);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("管理后台携程退款异常,orderNo: {}", request.getOrderNo(), e);
|
|
||||||
return Result.failed("退款处理异常: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取可退金额
|
|
||||||
*/
|
|
||||||
@Operation(summary = "获取订单可退金额")
|
|
||||||
@GetMapping("/available/{orderNo}")
|
|
||||||
public Result<Map<String, Object>> getAvailableRefundAmount(
|
|
||||||
@Parameter(description = "订单中心订单号") @PathVariable String orderNo) {
|
|
||||||
log.info("获取订单可退金额,orderNo: {}", orderNo);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 根据orderNo查询携程订单
|
|
||||||
CtripOrder ctripOrder = ctripOrderMapper.selectByOrderNo(orderNo);
|
|
||||||
if (ctripOrder == null) {
|
|
||||||
return Result.failed("未找到关联的携程订单");
|
|
||||||
}
|
|
||||||
|
|
||||||
BigDecimal availableAmount = ctripAdminRefundService.getAvailableRefundAmount(orderNo);
|
|
||||||
boolean canRefund = ctripAdminRefundService.canRefund(orderNo);
|
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
|
||||||
result.put("orderNo", orderNo);
|
|
||||||
result.put("otaOrderId", ctripOrder.getOtaOrderId());
|
|
||||||
result.put("totalAmount", ctripOrder.getTotalAmount());
|
|
||||||
result.put("availableRefundAmount", availableAmount);
|
|
||||||
result.put("canRefund", canRefund);
|
|
||||||
result.put("orderStatus", ctripOrder.getStatus());
|
|
||||||
result.put("orderStatusDesc", getOrderStatusDesc(ctripOrder.getStatus()));
|
|
||||||
|
|
||||||
return Result.succeed(result);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("获取可退金额异常,orderNo: {}", orderNo, e);
|
|
||||||
return Result.failed("获取可退金额异常: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查订单是否可退款
|
|
||||||
*/
|
|
||||||
@Operation(summary = "检查订单是否可退款")
|
|
||||||
@GetMapping("/check/{orderNo}")
|
|
||||||
public Result<Map<String, Object>> checkCanRefund(
|
|
||||||
@Parameter(description = "订单中心订单号") @PathVariable String orderNo) {
|
|
||||||
log.info("检查订单是否可退款,orderNo: {}", orderNo);
|
|
||||||
|
|
||||||
try {
|
|
||||||
CtripOrder ctripOrder = ctripOrderMapper.selectByOrderNo(orderNo);
|
|
||||||
if (ctripOrder == null) {
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
|
||||||
result.put("orderNo", orderNo);
|
|
||||||
result.put("canRefund", false);
|
|
||||||
result.put("reason", "未找到关联的携程订单");
|
|
||||||
return Result.succeed(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean canRefund = ctripAdminRefundService.canRefund(orderNo);
|
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
|
||||||
result.put("orderNo", orderNo);
|
|
||||||
result.put("otaOrderId", ctripOrder.getOtaOrderId());
|
|
||||||
result.put("canRefund", canRefund);
|
|
||||||
result.put("orderStatus", ctripOrder.getStatus());
|
|
||||||
result.put("orderStatusDesc", getOrderStatusDesc(ctripOrder.getStatus()));
|
|
||||||
if (!canRefund) {
|
|
||||||
result.put("reason", "订单状态不支持退款,当前状态: " + getOrderStatusDesc(ctripOrder.getStatus()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Result.succeed(result);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("检查订单是否可退款异常,orderNo: {}", orderNo, e);
|
|
||||||
return Result.failed("检查失败: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询退款记录
|
|
||||||
*/
|
|
||||||
@Operation(summary = "查询订单退款记录")
|
|
||||||
@GetMapping("/records/{orderNo}")
|
|
||||||
public Result<List<CtripRefund>> getRefundRecords(
|
|
||||||
@Parameter(description = "订单中心订单号") @PathVariable String orderNo) {
|
|
||||||
log.info("查询订单退款记录,orderNo: {}", orderNo);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 根据orderNo查询携程订单
|
|
||||||
CtripOrder ctripOrder = ctripOrderMapper.selectByOrderNo(orderNo);
|
|
||||||
if (ctripOrder == null) {
|
|
||||||
return Result.failed("未找到关联的携程订单");
|
|
||||||
}
|
|
||||||
|
|
||||||
List<CtripRefund> refunds = ctripRefundMapper.selectByOtaOrderId(ctripOrder.getOtaOrderId());
|
|
||||||
return Result.succeed(refunds);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("查询退款记录异常,orderNo: {}", orderNo, e);
|
|
||||||
return Result.failed("查询失败: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取订单状态描述
|
|
||||||
*/
|
|
||||||
private String getOrderStatusDesc(Integer status) {
|
|
||||||
if (status == null) {
|
|
||||||
return "未知";
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return CtripOrderStatus.fromNumericValue(status).getDescription();
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
return "未知状态";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取退款状态描述
|
|
||||||
*/
|
|
||||||
private String getRefundStatusDesc(Integer status) {
|
|
||||||
if (status == null) {
|
|
||||||
return "未知";
|
|
||||||
}
|
|
||||||
switch (status) {
|
|
||||||
case 0:
|
|
||||||
return "待确认";
|
|
||||||
case 1:
|
|
||||||
return "已确认";
|
|
||||||
case 2:
|
|
||||||
return "已拒绝";
|
|
||||||
default:
|
|
||||||
return "未知状态";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询携程订单列表
|
|
||||||
*/
|
|
||||||
@Operation(summary = "分页查询携程订单列表")
|
|
||||||
@GetMapping("/orders")
|
|
||||||
public Result<Map<String, Object>> getCtripOrderList(
|
|
||||||
@Parameter(description = "页码") @RequestParam(defaultValue = "1") Integer page,
|
|
||||||
@Parameter(description = "每页数量") @RequestParam(defaultValue = "20") Integer limit,
|
|
||||||
@Parameter(description = "携程订单号") @RequestParam(required = false) String otaOrderId,
|
|
||||||
@Parameter(description = "关联订单号") @RequestParam(required = false) String orderNo,
|
|
||||||
@Parameter(description = "订单状态") @RequestParam(required = false) Integer status,
|
|
||||||
@Parameter(description = "联系人姓名") @RequestParam(required = false) String contactName,
|
|
||||||
@Parameter(description = "联系人手机号") @RequestParam(required = false) String contactMobile) {
|
|
||||||
log.info("分页查询携程订单列表,page: {}, limit: {}, otaOrderId: {}, orderNo: {}, status: {}, contactName: {}, contactMobile: {}",
|
|
||||||
page, limit, otaOrderId, orderNo, status, contactName, contactMobile);
|
|
||||||
|
|
||||||
try {
|
|
||||||
LambdaQueryWrapper<CtripOrder> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
if (StringUtils.hasText(otaOrderId)) {
|
|
||||||
queryWrapper.like(CtripOrder::getOtaOrderId, otaOrderId);
|
|
||||||
}
|
|
||||||
if (StringUtils.hasText(orderNo)) {
|
|
||||||
queryWrapper.like(CtripOrder::getOrderNo, orderNo);
|
|
||||||
}
|
|
||||||
if (status != null) {
|
|
||||||
queryWrapper.eq(CtripOrder::getStatus, status);
|
|
||||||
}
|
|
||||||
queryWrapper.orderByDesc(CtripOrder::getCreateTime);
|
|
||||||
|
|
||||||
Page<CtripOrder> pageParam = new Page<>(page, limit);
|
|
||||||
IPage<CtripOrder> pageResult = ctripOrderMapper.selectPage(pageParam, queryWrapper);
|
|
||||||
|
|
||||||
// 关联查询联系人信息
|
|
||||||
List<Map<String, Object>> dataWithContact = new ArrayList<>();
|
|
||||||
for (CtripOrder order : pageResult.getRecords()) {
|
|
||||||
Map<String, Object> orderMap = new HashMap<>();
|
|
||||||
orderMap.put("id", order.getId());
|
|
||||||
orderMap.put("otaOrderId", order.getOtaOrderId());
|
|
||||||
orderMap.put("orderNo", order.getOrderNo());
|
|
||||||
orderMap.put("supplierOrderId", order.getSupplierOrderId());
|
|
||||||
orderMap.put("sequenceId", order.getSequenceId());
|
|
||||||
orderMap.put("confirmType", order.getConfirmType());
|
|
||||||
orderMap.put("orderLastConfirmTime", order.getOrderLastConfirmTime());
|
|
||||||
orderMap.put("status", order.getStatus());
|
|
||||||
orderMap.put("totalAmount", order.getTotalAmount());
|
|
||||||
orderMap.put("currency", order.getCurrency());
|
|
||||||
orderMap.put("createTime", order.getCreateTime());
|
|
||||||
orderMap.put("updateTime", order.getUpdateTime());
|
|
||||||
orderMap.put("remark", order.getRemark());
|
|
||||||
orderMap.put("tenantId", order.getTenantId());
|
|
||||||
|
|
||||||
// 查询联系人信息
|
|
||||||
List<CtripContact> contacts = ctripContactMapper.selectByOrderId(order.getId());
|
|
||||||
if (contacts != null && !contacts.isEmpty()) {
|
|
||||||
CtripContact contact = contacts.get(0); // 取第一个联系人
|
|
||||||
orderMap.put("contactName", contact.getName());
|
|
||||||
orderMap.put("contactMobile", contact.getMobile());
|
|
||||||
orderMap.put("contactEmail", contact.getEmail());
|
|
||||||
} else {
|
|
||||||
orderMap.put("contactName", null);
|
|
||||||
orderMap.put("contactMobile", null);
|
|
||||||
orderMap.put("contactEmail", null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果有联系人筛选条件,进行过滤
|
|
||||||
if (StringUtils.hasText(contactName) || StringUtils.hasText(contactMobile)) {
|
|
||||||
String name = (String) orderMap.get("contactName");
|
|
||||||
String mobile = (String) orderMap.get("contactMobile");
|
|
||||||
boolean matchName = !StringUtils.hasText(contactName) || (name != null && name.contains(contactName));
|
|
||||||
boolean matchMobile = !StringUtils.hasText(contactMobile) || (mobile != null && mobile.contains(contactMobile));
|
|
||||||
if (matchName && matchMobile) {
|
|
||||||
dataWithContact.add(orderMap);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
dataWithContact.add(orderMap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
|
||||||
result.put("data", dataWithContact);
|
|
||||||
// 如果有联系人筛选,总数需要重新计算(简化处理,返回当前页数量)
|
|
||||||
result.put("count", (StringUtils.hasText(contactName) || StringUtils.hasText(contactMobile))
|
|
||||||
? dataWithContact.size() : pageResult.getTotal());
|
|
||||||
result.put("page", page);
|
|
||||||
result.put("limit", limit);
|
|
||||||
|
|
||||||
return Result.succeed(result);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("查询携程订单列表异常", e);
|
|
||||||
return Result.failed("查询失败: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询携程退款列表
|
|
||||||
*/
|
|
||||||
@Operation(summary = "分页查询携程退款列表")
|
|
||||||
@GetMapping("/refunds")
|
|
||||||
public Result<Map<String, Object>> getCtripRefundList(
|
|
||||||
@Parameter(description = "页码") @RequestParam(defaultValue = "1") Integer page,
|
|
||||||
@Parameter(description = "每页数量") @RequestParam(defaultValue = "20") Integer limit,
|
|
||||||
@Parameter(description = "携程订单号") @RequestParam(required = false) String otaOrderId,
|
|
||||||
@Parameter(description = "供应商订单号") @RequestParam(required = false) String supplierOrderId,
|
|
||||||
@Parameter(description = "退款状态") @RequestParam(required = false) Integer refundStatus) {
|
|
||||||
log.info("分页查询携程退款列表,page: {}, limit: {}, otaOrderId: {}, supplierOrderId: {}, refundStatus: {}",
|
|
||||||
page, limit, otaOrderId, supplierOrderId, refundStatus);
|
|
||||||
|
|
||||||
try {
|
|
||||||
LambdaQueryWrapper<CtripRefund> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
if (StringUtils.hasText(otaOrderId)) {
|
|
||||||
queryWrapper.like(CtripRefund::getOtaOrderId, otaOrderId);
|
|
||||||
}
|
|
||||||
if (StringUtils.hasText(supplierOrderId)) {
|
|
||||||
queryWrapper.like(CtripRefund::getSupplierOrderId, supplierOrderId);
|
|
||||||
}
|
|
||||||
if (refundStatus != null) {
|
|
||||||
queryWrapper.eq(CtripRefund::getRefundStatus, refundStatus);
|
|
||||||
}
|
|
||||||
queryWrapper.orderByDesc(CtripRefund::getCreateTime);
|
|
||||||
|
|
||||||
Page<CtripRefund> pageParam = new Page<>(page, limit);
|
|
||||||
IPage<CtripRefund> pageResult = ctripRefundMapper.selectPage(pageParam, queryWrapper);
|
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
|
||||||
result.put("data", pageResult.getRecords());
|
|
||||||
result.put("count", pageResult.getTotal());
|
|
||||||
result.put("page", page);
|
|
||||||
result.put("limit", limit);
|
|
||||||
|
|
||||||
return Result.succeed(result);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("查询携程退款列表异常", e);
|
|
||||||
return Result.failed("查询失败: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-78
@@ -1,78 +0,0 @@
|
|||||||
package com.central.coupon.controller;
|
|
||||||
|
|
||||||
import com.central.coupon.model.CtripCancelOrderRequest;
|
|
||||||
import com.central.coupon.model.CtripCancelOrderResponse;
|
|
||||||
import com.central.coupon.service.CtripCancelOrderService;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程取消订单控制器
|
|
||||||
* 参考文档: https://open.trip.com/apiplatform/order.jsp#operation/CancelOrder
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/ctrip")
|
|
||||||
public class CtripCancelOrderController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripCancelOrderService ctripCancelOrderService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理取消订单请求
|
|
||||||
* @param request 取消订单请求
|
|
||||||
* @param httpRequest HTTP请求对象
|
|
||||||
* @return 取消订单响应
|
|
||||||
*/
|
|
||||||
@PostMapping("/cancelOrder")
|
|
||||||
public CtripCancelOrderResponse processCancelOrderRequest(@RequestBody CtripCancelOrderRequest request,
|
|
||||||
HttpServletRequest httpRequest) {
|
|
||||||
log.info("收到携程取消订单请求,serviceName: {}", request.getHeader().getServiceName());
|
|
||||||
return ctripCancelOrderService.cancelOrder(request, httpRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理取消订单请求(统一接口调用)
|
|
||||||
* @param requestBody 请求体
|
|
||||||
* @param httpRequest HTTP请求对象
|
|
||||||
* @return 取消订单响应
|
|
||||||
*/
|
|
||||||
public CtripCancelOrderResponse processCancelOrderRequest(Object requestBody, jakarta.servlet.http.HttpServletRequest httpRequest) {
|
|
||||||
log.info("收到携程取消订单请求(统一接口)");
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 将Object转换为CtripCancelOrderRequest
|
|
||||||
CtripCancelOrderRequest request = objectMapper.convertValue(requestBody, CtripCancelOrderRequest.class);
|
|
||||||
|
|
||||||
// 处理请求
|
|
||||||
CtripCancelOrderResponse response = ctripCancelOrderService.cancelOrder(request, httpRequest);
|
|
||||||
|
|
||||||
log.info("携程取消订单请求处理完成,resultCode: {}",
|
|
||||||
response.getHeader() != null ? response.getHeader().getResultCode() : "unknown");
|
|
||||||
|
|
||||||
return response;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("处理携程取消订单请求异常", e);
|
|
||||||
|
|
||||||
// 返回错误响应
|
|
||||||
CtripCancelOrderResponse errorResponse = new CtripCancelOrderResponse();
|
|
||||||
CtripCancelOrderResponse.CtripResponseHeader header = new CtripCancelOrderResponse.CtripResponseHeader();
|
|
||||||
header.setResultCode("0001");
|
|
||||||
header.setResultMessage("处理请求异常: " + e.getMessage());
|
|
||||||
errorResponse.setHeader(header);
|
|
||||||
|
|
||||||
return errorResponse;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-114
@@ -1,114 +0,0 @@
|
|||||||
package com.central.coupon.controller;
|
|
||||||
|
|
||||||
import com.central.coupon.model.CtripCancelPreOrderRequest;
|
|
||||||
import com.central.coupon.model.CtripCancelPreOrderResponse;
|
|
||||||
import com.central.coupon.service.CtripCancelPreOrderService;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程取消预下单控制器
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/coupon/ctrip")
|
|
||||||
public class CtripCancelPreOrderController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripCancelPreOrderService ctripCancelPreOrderService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 取消预下单接口
|
|
||||||
*/
|
|
||||||
@PostMapping("/cancelPreOrder")
|
|
||||||
public CtripCancelPreOrderResponse cancelPreOrder(@RequestBody CtripCancelPreOrderRequest request, HttpServletRequest httpRequest) {
|
|
||||||
String clientIp = getClientIp(httpRequest);
|
|
||||||
log.info("收到携程取消预下单请求,IP: {}, serviceName: {}", clientIp,
|
|
||||||
request.getHeader() != null ? request.getHeader().getServiceName() : "unknown");
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 保存原始加密体用于签名验证
|
|
||||||
request.setOriginalEncryptedBody(request.getBody());
|
|
||||||
|
|
||||||
// 处理请求
|
|
||||||
CtripCancelPreOrderResponse response = ctripCancelPreOrderService.processCancelPreOrderRequest(request);
|
|
||||||
|
|
||||||
log.info("携程取消预下单请求处理完成,IP: {}, resultCode: {}", clientIp,
|
|
||||||
response.getHeader() != null ? response.getHeader().getResultCode() : "unknown");
|
|
||||||
|
|
||||||
return response;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("处理携程取消预下单请求异常,IP: {}", clientIp, e);
|
|
||||||
|
|
||||||
// 返回错误响应
|
|
||||||
CtripCancelPreOrderResponse errorResponse = new CtripCancelPreOrderResponse();
|
|
||||||
CtripCancelPreOrderResponse.CtripResponseHeader header = new CtripCancelPreOrderResponse.CtripResponseHeader();
|
|
||||||
header.setResultCode("0001");
|
|
||||||
header.setResultMessage("处理请求异常: " + e.getMessage());
|
|
||||||
errorResponse.setHeader(header);
|
|
||||||
|
|
||||||
return errorResponse;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 取消预下单接口(统一接口调用)
|
|
||||||
*/
|
|
||||||
public CtripCancelPreOrderResponse processCancelPreOrderRequest(Object requestBody, jakarta.servlet.http.HttpServletRequest httpRequest) {
|
|
||||||
String clientIp = getClientIp(httpRequest);
|
|
||||||
log.info("收到携程取消预下单请求(统一接口),IP: {}", clientIp);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 将Object转换为CtripCancelPreOrderRequest
|
|
||||||
CtripCancelPreOrderRequest request = objectMapper.convertValue(requestBody, CtripCancelPreOrderRequest.class);
|
|
||||||
|
|
||||||
// 保存原始加密体用于签名验证
|
|
||||||
request.setOriginalEncryptedBody(request.getBody());
|
|
||||||
|
|
||||||
// 处理请求
|
|
||||||
CtripCancelPreOrderResponse response = ctripCancelPreOrderService.processCancelPreOrderRequest(request);
|
|
||||||
|
|
||||||
log.info("携程取消预下单请求处理完成,IP: {}, resultCode: {}", clientIp,
|
|
||||||
response.getHeader() != null ? response.getHeader().getResultCode() : "unknown");
|
|
||||||
|
|
||||||
return response;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("处理携程取消预下单请求异常,IP: {}", clientIp, e);
|
|
||||||
|
|
||||||
// 返回错误响应
|
|
||||||
CtripCancelPreOrderResponse errorResponse = new CtripCancelPreOrderResponse();
|
|
||||||
CtripCancelPreOrderResponse.CtripResponseHeader header = new CtripCancelPreOrderResponse.CtripResponseHeader();
|
|
||||||
header.setResultCode("0001");
|
|
||||||
header.setResultMessage("处理请求异常: " + e.getMessage());
|
|
||||||
errorResponse.setHeader(header);
|
|
||||||
|
|
||||||
return errorResponse;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取客户端IP地址
|
|
||||||
*/
|
|
||||||
private String getClientIp(HttpServletRequest request) {
|
|
||||||
String xForwardedFor = request.getHeader("X-Forwarded-For");
|
|
||||||
if (xForwardedFor != null && !xForwardedFor.isEmpty() && !"unknown".equalsIgnoreCase(xForwardedFor)) {
|
|
||||||
return xForwardedFor.split(",")[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
String xRealIp = request.getHeader("X-Real-IP");
|
|
||||||
if (xRealIp != null && !xRealIp.isEmpty() && !"unknown".equalsIgnoreCase(xRealIp)) {
|
|
||||||
return xRealIp;
|
|
||||||
}
|
|
||||||
|
|
||||||
return request.getRemoteAddr();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-169
@@ -1,169 +0,0 @@
|
|||||||
package com.central.coupon.controller;
|
|
||||||
|
|
||||||
import com.central.coupon.model.CtripConsumedNoticeRequest;
|
|
||||||
import com.central.coupon.model.CtripConsumedNoticeResponse;
|
|
||||||
import com.central.coupon.service.CtripConsumedService;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程核销业务接口Controller
|
|
||||||
* 用于业务系统调用,向携程发送核销通知
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/ctrip/consumed")
|
|
||||||
public class CtripConsumedController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripConsumedService ctripConsumedService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 核销订单接口
|
|
||||||
* 业务系统调用此接口执行核销操作
|
|
||||||
*
|
|
||||||
* @param request 核销请求参数
|
|
||||||
* @return 核销结果
|
|
||||||
*/
|
|
||||||
@PostMapping("/consume")
|
|
||||||
public CtripConsumedNoticeResponse consumeOrder(@RequestBody CtripConsumeRequest request) {
|
|
||||||
log.info("收到核销订单请求,otaOrderId: {}, itemId: {}, useQuantity: {}",
|
|
||||||
request.getOtaOrderId(), request.getItemId(), request.getUseQuantity());
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 执行核销逻辑
|
|
||||||
CtripConsumedNoticeResponse response = ctripConsumedService.consumeOrder(request);
|
|
||||||
|
|
||||||
log.info("核销订单处理完成,otaOrderId: {}, resultCode: {}",
|
|
||||||
request.getOtaOrderId(), response.getHeader().getResultCode());
|
|
||||||
|
|
||||||
return response;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("核销订单异常,otaOrderId: {}", request.getOtaOrderId(), e);
|
|
||||||
return buildErrorResponse("0003", "核销异常: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量核销订单接口
|
|
||||||
*
|
|
||||||
* @param request 批量核销请求
|
|
||||||
* @return 核销结果
|
|
||||||
*/
|
|
||||||
@PostMapping("/consume-batch")
|
|
||||||
public CtripConsumedNoticeResponse consumeOrderBatch(@RequestBody CtripConsumeBatchRequest request) {
|
|
||||||
log.info("收到批量核销订单请求,订单数量: {}", request.getItems().size());
|
|
||||||
|
|
||||||
try {
|
|
||||||
CtripConsumedNoticeResponse response = ctripConsumedService.consumeOrderBatch(request);
|
|
||||||
|
|
||||||
log.info("批量核销订单处理完成,resultCode: {}", response.getHeader().getResultCode());
|
|
||||||
|
|
||||||
return response;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("批量核销订单异常", e);
|
|
||||||
return buildErrorResponse("0003", "批量核销异常: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询核销记录接口
|
|
||||||
*
|
|
||||||
* @param otaOrderId 携程订单号
|
|
||||||
* @return 核销记录列表
|
|
||||||
*/
|
|
||||||
@GetMapping("/records/{otaOrderId}")
|
|
||||||
public List<Map<String, Object>> getConsumedRecords(@PathVariable String otaOrderId) {
|
|
||||||
log.info("查询核销记录,otaOrderId: {}", otaOrderId);
|
|
||||||
|
|
||||||
try {
|
|
||||||
return ctripConsumedService.getConsumedRecords(otaOrderId);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("查询核销记录异常,otaOrderId: {}", otaOrderId, e);
|
|
||||||
return List.of();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建错误响应
|
|
||||||
*/
|
|
||||||
private CtripConsumedNoticeResponse buildErrorResponse(String resultCode, String resultMessage) {
|
|
||||||
CtripConsumedNoticeResponse response = new CtripConsumedNoticeResponse();
|
|
||||||
CtripConsumedNoticeResponse.CtripResponseHeader header = new CtripConsumedNoticeResponse.CtripResponseHeader();
|
|
||||||
header.setResultCode(resultCode);
|
|
||||||
header.setResultMessage(resultMessage);
|
|
||||||
response.setHeader(header);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 核销请求参数
|
|
||||||
*/
|
|
||||||
public static class CtripConsumeRequest {
|
|
||||||
private String otaOrderId; // 携程订单号
|
|
||||||
private String supplierOrderId; // 供应商订单号
|
|
||||||
private String itemId; // 订单项编号
|
|
||||||
private String useStartDate; // 使用开始日期
|
|
||||||
private String useEndDate; // 使用结束日期
|
|
||||||
private Integer quantity; // 订单总份数
|
|
||||||
private Integer useQuantity; // 已核销份数
|
|
||||||
private List<String> passengerIds; // 乘客ID列表
|
|
||||||
private List<String> voucherIds; // 凭证ID列表
|
|
||||||
private String remark; // 备注信息
|
|
||||||
private Integer lostAmount; // 损失金额
|
|
||||||
private String lostAmountCurrency; // 损失金额货币类型
|
|
||||||
|
|
||||||
// getters and setters
|
|
||||||
public String getOtaOrderId() { return otaOrderId; }
|
|
||||||
public void setOtaOrderId(String otaOrderId) { this.otaOrderId = otaOrderId; }
|
|
||||||
|
|
||||||
public String getSupplierOrderId() { return supplierOrderId; }
|
|
||||||
public void setSupplierOrderId(String supplierOrderId) { this.supplierOrderId = supplierOrderId; }
|
|
||||||
|
|
||||||
public String getItemId() { return itemId; }
|
|
||||||
public void setItemId(String itemId) { this.itemId = itemId; }
|
|
||||||
|
|
||||||
public String getUseStartDate() { return useStartDate; }
|
|
||||||
public void setUseStartDate(String useStartDate) { this.useStartDate = useStartDate; }
|
|
||||||
|
|
||||||
public String getUseEndDate() { return useEndDate; }
|
|
||||||
public void setUseEndDate(String useEndDate) { this.useEndDate = useEndDate; }
|
|
||||||
|
|
||||||
public Integer getQuantity() { return quantity; }
|
|
||||||
public void setQuantity(Integer quantity) { this.quantity = quantity; }
|
|
||||||
|
|
||||||
public Integer getUseQuantity() { return useQuantity; }
|
|
||||||
public void setUseQuantity(Integer useQuantity) { this.useQuantity = useQuantity; }
|
|
||||||
|
|
||||||
public List<String> getPassengerIds() { return passengerIds; }
|
|
||||||
public void setPassengerIds(List<String> passengerIds) { this.passengerIds = passengerIds; }
|
|
||||||
|
|
||||||
public List<String> getVoucherIds() { return voucherIds; }
|
|
||||||
public void setVoucherIds(List<String> voucherIds) { this.voucherIds = voucherIds; }
|
|
||||||
|
|
||||||
public String getRemark() { return remark; }
|
|
||||||
public void setRemark(String remark) { this.remark = remark; }
|
|
||||||
|
|
||||||
public Integer getLostAmount() { return lostAmount; }
|
|
||||||
public void setLostAmount(Integer lostAmount) { this.lostAmount = lostAmount; }
|
|
||||||
|
|
||||||
public String getLostAmountCurrency() { return lostAmountCurrency; }
|
|
||||||
public void setLostAmountCurrency(String lostAmountCurrency) { this.lostAmountCurrency = lostAmountCurrency; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量核销请求参数
|
|
||||||
*/
|
|
||||||
public static class CtripConsumeBatchRequest {
|
|
||||||
private List<CtripConsumeRequest> items;
|
|
||||||
|
|
||||||
public List<CtripConsumeRequest> getItems() { return items; }
|
|
||||||
public void setItems(List<CtripConsumeRequest> items) { this.items = items; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-83
@@ -1,83 +0,0 @@
|
|||||||
package com.central.coupon.controller;
|
|
||||||
|
|
||||||
import com.central.coupon.model.CtripConsumedNoticeRequest;
|
|
||||||
import com.central.coupon.model.CtripConsumedNoticeResponse;
|
|
||||||
import com.central.coupon.service.CtripConsumedNoticeService;
|
|
||||||
import com.central.coupon.util.CtripDecryptUtil;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程核销优惠券通知接口Controller
|
|
||||||
* 参考文档:https://open.trip.com/apiplatform/order.jsp#operation/OrderConsumedNotice
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/ctrip")
|
|
||||||
public class CtripConsumedNoticeController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripConsumedNoticeService ctripConsumedNoticeService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripDecryptUtil ctripDecryptUtil;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程核销优惠券通知接口
|
|
||||||
*
|
|
||||||
* @param encryptedRequest 加密的请求体
|
|
||||||
* @return 核销通知响应
|
|
||||||
*/
|
|
||||||
@PostMapping("/consumed-notice")
|
|
||||||
public CtripConsumedNoticeResponse consumedNotice(@RequestBody String encryptedRequest) {
|
|
||||||
log.info("收到携程核销优惠券通知请求,加密请求体长度: {}", encryptedRequest.length());
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 1. 解密请求体
|
|
||||||
String decryptedBody = ctripDecryptUtil.decryptAES(encryptedRequest);
|
|
||||||
if (decryptedBody == null) {
|
|
||||||
log.error("解密携程核销通知请求体失败");
|
|
||||||
return buildErrorResponse("0001", "解密请求失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("携程核销通知请求体解密成功,内容: {}", decryptedBody);
|
|
||||||
|
|
||||||
// 2. 解析请求体
|
|
||||||
CtripConsumedNoticeRequest request = objectMapper.readValue(decryptedBody, CtripConsumedNoticeRequest.class);
|
|
||||||
if (request == null) {
|
|
||||||
log.error("解析携程核销通知请求失败");
|
|
||||||
return buildErrorResponse("0002", "解析请求失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 处理核销通知
|
|
||||||
CtripConsumedNoticeResponse response = ctripConsumedNoticeService.processConsumedNotice(request);
|
|
||||||
|
|
||||||
log.info("携程核销优惠券通知处理完成,sequenceId: {}", request.getBody().getSequenceId());
|
|
||||||
return response;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("处理携程核销优惠券通知异常", e);
|
|
||||||
return buildErrorResponse("0003", "处理异常: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建错误响应
|
|
||||||
*/
|
|
||||||
private CtripConsumedNoticeResponse buildErrorResponse(String resultCode, String resultMessage) {
|
|
||||||
CtripConsumedNoticeResponse response = new CtripConsumedNoticeResponse();
|
|
||||||
CtripConsumedNoticeResponse.CtripResponseHeader header = new CtripConsumedNoticeResponse.CtripResponseHeader();
|
|
||||||
header.setResultCode(resultCode);
|
|
||||||
header.setResultMessage(resultMessage);
|
|
||||||
response.setHeader(header);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-106
@@ -1,106 +0,0 @@
|
|||||||
package com.central.coupon.controller;
|
|
||||||
|
|
||||||
import com.central.coupon.service.CtripDataCleanupService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程数据清理控制器
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/coupon/ctrip/cleanup")
|
|
||||||
@Tag(name = "携程数据清理", description = "携程数据清理相关接口")
|
|
||||||
public class CtripDataCleanupController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripDataCleanupService ctripDataCleanupService;
|
|
||||||
|
|
||||||
@PostMapping("/duplicate-order-items/{otaOrderId}")
|
|
||||||
@Operation(summary = "清理指定订单的重复订单项记录", description = "删除itemId为PLU值的旧记录,保留真实的携程itemId记录")
|
|
||||||
public Map<String, Object> cleanupDuplicateOrderItems(
|
|
||||||
@Parameter(description = "携程订单号") @PathVariable String otaOrderId) {
|
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
|
||||||
|
|
||||||
try {
|
|
||||||
log.info("开始清理重复订单项记录,otaOrderId: {}", otaOrderId);
|
|
||||||
|
|
||||||
boolean success = ctripDataCleanupService.cleanupDuplicateOrderItems(otaOrderId);
|
|
||||||
|
|
||||||
result.put("success", success);
|
|
||||||
result.put("message", success ? "清理成功" : "清理失败");
|
|
||||||
result.put("otaOrderId", otaOrderId);
|
|
||||||
|
|
||||||
log.info("清理重复订单项记录完成,otaOrderId: {}, 结果: {}", otaOrderId, success);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("清理重复订单项记录异常,otaOrderId: {}", otaOrderId, e);
|
|
||||||
result.put("success", false);
|
|
||||||
result.put("message", "清理异常: " + e.getMessage());
|
|
||||||
result.put("otaOrderId", otaOrderId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/duplicate-order-items-by-order-id/{orderId}")
|
|
||||||
@Operation(summary = "根据订单ID清理重复订单项记录", description = "删除itemId为PLU值的旧记录,保留真实的携程itemId记录")
|
|
||||||
public Map<String, Object> cleanupDuplicateOrderItemsByOrderId(
|
|
||||||
@Parameter(description = "订单ID") @PathVariable Long orderId) {
|
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
|
||||||
|
|
||||||
try {
|
|
||||||
log.info("开始清理重复订单项记录,orderId: {}", orderId);
|
|
||||||
|
|
||||||
boolean success = ctripDataCleanupService.cleanupDuplicateOrderItemsByOrderId(orderId);
|
|
||||||
|
|
||||||
result.put("success", success);
|
|
||||||
result.put("message", success ? "清理成功" : "清理失败");
|
|
||||||
result.put("orderId", orderId);
|
|
||||||
|
|
||||||
log.info("清理重复订单项记录完成,orderId: {}, 结果: {}", orderId, success);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("清理重复订单项记录异常,orderId: {}", orderId, e);
|
|
||||||
result.put("success", false);
|
|
||||||
result.put("message", "清理异常: " + e.getMessage());
|
|
||||||
result.put("orderId", orderId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/all-duplicate-order-items")
|
|
||||||
@Operation(summary = "清理所有订单的重复订单项记录", description = "清理所有订单中的重复订单项记录")
|
|
||||||
public Map<String, Object> cleanupAllDuplicateOrderItems() {
|
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
|
||||||
|
|
||||||
try {
|
|
||||||
log.info("开始清理所有订单的重复订单项记录");
|
|
||||||
|
|
||||||
boolean success = ctripDataCleanupService.cleanupAllDuplicateOrderItems();
|
|
||||||
|
|
||||||
result.put("success", success);
|
|
||||||
result.put("message", success ? "清理成功" : "清理失败");
|
|
||||||
|
|
||||||
log.info("清理所有重复订单项记录完成,结果: {}", success);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("清理所有重复订单项记录异常", e);
|
|
||||||
result.put("success", false);
|
|
||||||
result.put("message", "清理异常: " + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-421
@@ -1,421 +0,0 @@
|
|||||||
package com.central.coupon.controller;
|
|
||||||
|
|
||||||
import com.central.coupon.model.CtripPayPreOrderConfirmRequest;
|
|
||||||
import com.central.coupon.model.CtripPayPreOrderConfirmResponse;
|
|
||||||
import com.central.coupon.service.ICtripPayPreOrderConfirmService;
|
|
||||||
import com.central.coupon.util.CtripDecryptUtil;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程支付确认控制器
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/coupon/ctrip/confirm")
|
|
||||||
public class CtripPayPreOrderConfirmController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ICtripPayPreOrderConfirmService payPreOrderConfirmService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripDecryptUtil ctripDecryptUtil;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
@Value("${ctrip.account.id}")
|
|
||||||
private String ctripAccountId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理支付确认请求
|
|
||||||
*/
|
|
||||||
@PostMapping("/pay")
|
|
||||||
public CtripPayPreOrderConfirmResponse processPayPreOrderConfirm(@RequestBody Map<String, Object> requestMap,
|
|
||||||
HttpServletRequest request) {
|
|
||||||
String clientIp = getClientIp(request);
|
|
||||||
log.info("收到携程支付确认请求,IP: {}", clientIp);
|
|
||||||
log.info("请求URL: {}", request.getRequestURL());
|
|
||||||
log.info("请求URI: {}", request.getRequestURI());
|
|
||||||
log.info("请求方法: {}", request.getMethod());
|
|
||||||
log.info("请求体类型: {}", requestMap.getClass().getSimpleName());
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 1. 解析请求体
|
|
||||||
CtripPayPreOrderConfirmRequest ctripRequest = parseRequest(requestMap);
|
|
||||||
if (ctripRequest == null) {
|
|
||||||
log.error("解析支付确认请求失败");
|
|
||||||
return buildErrorResponse("0001", "请求解析失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 验证签名
|
|
||||||
if (!validateSignature(ctripRequest)) {
|
|
||||||
log.error("支付确认请求签名验证失败");
|
|
||||||
return buildErrorResponse("0001", "签名验证失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 处理业务逻辑
|
|
||||||
CtripPayPreOrderConfirmResponse response = payPreOrderConfirmService.processPayPreOrderConfirm(
|
|
||||||
ctripRequest.getHeader(), ctripRequest.getBody());
|
|
||||||
|
|
||||||
log.info("携程支付确认处理完成,otaOrderId: {}",
|
|
||||||
ctripRequest.getBody() != null ? ctripRequest.getBody().getOtaOrderId() : "unknown");
|
|
||||||
|
|
||||||
return response;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("处理携程支付确认请求异常", e);
|
|
||||||
return buildErrorResponse("1100", "处理请求异常:" + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 手动调用支付确认接口(用于测试)
|
|
||||||
*/
|
|
||||||
@PostMapping("/manual")
|
|
||||||
public CtripPayPreOrderConfirmResponse manualPayPreOrderConfirm(@RequestBody Map<String, Object> requestMap,
|
|
||||||
HttpServletRequest request) {
|
|
||||||
String clientIp = getClientIp(request);
|
|
||||||
log.info("=== 收到手动支付确认请求(测试接口) ===");
|
|
||||||
log.info("IP: {}", clientIp);
|
|
||||||
log.info("请求URL: {}", request.getRequestURL());
|
|
||||||
log.info("请求URI: {}", request.getRequestURI());
|
|
||||||
log.info("请求方法: {}", request.getMethod());
|
|
||||||
log.info("请求体类型: {}", requestMap.getClass().getSimpleName());
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 1. 解析请求体
|
|
||||||
CtripPayPreOrderConfirmRequest ctripRequest = parseRequest(requestMap);
|
|
||||||
if (ctripRequest == null) {
|
|
||||||
log.error("解析支付确认请求失败");
|
|
||||||
return buildErrorResponse("0001", "请求解析失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 验证签名(手动调用时可选)
|
|
||||||
boolean signatureValid = validateSignature(ctripRequest);
|
|
||||||
if (!signatureValid) {
|
|
||||||
log.warn("签名验证失败,但继续处理(手动调用模式)");
|
|
||||||
} else {
|
|
||||||
log.info("签名验证通过");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 处理业务逻辑
|
|
||||||
CtripPayPreOrderConfirmResponse response = payPreOrderConfirmService.processPayPreOrderConfirm(
|
|
||||||
ctripRequest.getHeader(), ctripRequest.getBody());
|
|
||||||
|
|
||||||
log.info("=== 手动支付确认处理完成 ===");
|
|
||||||
log.info("otaOrderId: {}",
|
|
||||||
ctripRequest.getBody() != null ? ctripRequest.getBody().getOtaOrderId() : "unknown");
|
|
||||||
|
|
||||||
return response;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("处理手动支付确认请求异常", e);
|
|
||||||
return buildErrorResponse("1100", "处理请求异常:" + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 简化手动调用接口(无需签名验证)
|
|
||||||
*/
|
|
||||||
@PostMapping("/simple")
|
|
||||||
public CtripPayPreOrderConfirmResponse simplePayPreOrderConfirm(@RequestBody Map<String, Object> requestMap,
|
|
||||||
HttpServletRequest request) {
|
|
||||||
String clientIp = getClientIp(request);
|
|
||||||
log.info("=== 收到简化支付确认请求(测试接口) ===");
|
|
||||||
log.info("IP: {}", clientIp);
|
|
||||||
log.info("请求体: {}", requestMap);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 直接构建请求对象,跳过签名验证
|
|
||||||
CtripPayPreOrderConfirmRequest ctripRequest = new CtripPayPreOrderConfirmRequest();
|
|
||||||
|
|
||||||
// 构建header
|
|
||||||
CtripPayPreOrderConfirmRequest.CtripHeader header = new CtripPayPreOrderConfirmRequest.CtripHeader();
|
|
||||||
header.setAccountId(ctripAccountId);
|
|
||||||
header.setServiceName("PayPreOrderConfirm");
|
|
||||||
header.setRequestTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
||||||
header.setVersion("1.0");
|
|
||||||
header.setSign("manual_test_sign");
|
|
||||||
ctripRequest.setHeader(header);
|
|
||||||
|
|
||||||
// 构建body
|
|
||||||
CtripPayPreOrderConfirmRequest.CtripPayPreOrderConfirmBody body =
|
|
||||||
objectMapper.convertValue(requestMap, CtripPayPreOrderConfirmRequest.CtripPayPreOrderConfirmBody.class);
|
|
||||||
ctripRequest.setBody(body);
|
|
||||||
|
|
||||||
// 3. 处理业务逻辑
|
|
||||||
CtripPayPreOrderConfirmResponse response = payPreOrderConfirmService.processPayPreOrderConfirm(header, body);
|
|
||||||
|
|
||||||
log.info("=== 简化支付确认处理完成 ===");
|
|
||||||
log.info("otaOrderId: {}", body.getOtaOrderId());
|
|
||||||
|
|
||||||
return response;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("处理简化支付确认请求异常", e);
|
|
||||||
return buildErrorResponse("1100", "处理请求异常:" + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建加密+签名后的请求(生成给Postman使用)
|
|
||||||
* 入参格式:{"accountId":"...","version":"1.0","requestTime":"可选,默认当前","body":{...明文body...}}
|
|
||||||
*/
|
|
||||||
@PostMapping("/buildPayload")
|
|
||||||
public Map<String, Object> buildEncryptedSignedPayload(@RequestBody Map<String, Object> payload) {
|
|
||||||
try {
|
|
||||||
String accountId = (String) payload.getOrDefault("accountId", ctripAccountId);
|
|
||||||
String version = (String) payload.getOrDefault("version", "1.0");
|
|
||||||
String requestTime = (String) payload.getOrDefault(
|
|
||||||
"requestTime", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
||||||
Object bodyObj = payload.get("body");
|
|
||||||
if (bodyObj == null) {
|
|
||||||
throw new IllegalArgumentException("body不能为空");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 验证body中的必需字段
|
|
||||||
if (bodyObj instanceof Map) {
|
|
||||||
Map<String, Object> bodyMap = (Map<String, Object>) bodyObj;
|
|
||||||
|
|
||||||
// 检查必需字段
|
|
||||||
String[] requiredFields = {"sequenceId", "otaOrderId", "supplierOrderId", "confirmResultCode", "confirmResultMessage"};
|
|
||||||
for (String field : requiredFields) {
|
|
||||||
if (!bodyMap.containsKey(field) || bodyMap.get(field) == null ||
|
|
||||||
(bodyMap.get(field) instanceof String && ((String) bodyMap.get(field)).trim().isEmpty())) {
|
|
||||||
throw new IllegalArgumentException("body中缺少必需字段或字段为空: " + field);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 特殊检查sequenceId格式
|
|
||||||
String sequenceId = (String) bodyMap.get("sequenceId");
|
|
||||||
if (sequenceId != null && sequenceId.length() < 40) {
|
|
||||||
log.warn("sequenceId长度可能不符合要求,建议格式:yyyyMMdd + 32位GUID,当前长度: {}", sequenceId.length());
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("验证通过,sequenceId: {}, otaOrderId: {}, supplierOrderId: {}",
|
|
||||||
sequenceId, bodyMap.get("otaOrderId"), bodyMap.get("supplierOrderId"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 固定服务名
|
|
||||||
String serviceName = "PayPreOrderConfirm";
|
|
||||||
// 序列化 body 为 JSON
|
|
||||||
String bodyJson = objectMapper.writeValueAsString(bodyObj);
|
|
||||||
log.info("序列化后的body JSON: {}", bodyJson);
|
|
||||||
|
|
||||||
// 加密 body
|
|
||||||
String encryptedBody = ctripDecryptUtil.encryptAES(bodyJson);
|
|
||||||
if (encryptedBody == null) {
|
|
||||||
throw new IllegalStateException("加密失败");
|
|
||||||
}
|
|
||||||
log.info("加密后的body长度: {}", encryptedBody.length());
|
|
||||||
|
|
||||||
// 生成 sign(注意使用加密后的 body)
|
|
||||||
String sign = ctripDecryptUtil.generateSign(accountId, serviceName, requestTime, encryptedBody, version);
|
|
||||||
if (sign == null) {
|
|
||||||
throw new IllegalStateException("签名失败");
|
|
||||||
}
|
|
||||||
log.info("生成的签名: {}", sign);
|
|
||||||
|
|
||||||
// 组装返回
|
|
||||||
Map<String, Object> header = new HashMap<>();
|
|
||||||
header.put("accountId", accountId);
|
|
||||||
header.put("serviceName", serviceName);
|
|
||||||
header.put("requestTime", requestTime);
|
|
||||||
header.put("version", version);
|
|
||||||
header.put("sign", sign);
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
|
||||||
result.put("header", header);
|
|
||||||
result.put("body", encryptedBody);
|
|
||||||
// 便于核对:透传明文 body
|
|
||||||
result.put("plainBody", bodyObj);
|
|
||||||
return result;
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("构建加密签名请求失败", e);
|
|
||||||
Map<String, Object> err = new HashMap<>();
|
|
||||||
err.put("error", e.getMessage());
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解析请求体
|
|
||||||
*/
|
|
||||||
private CtripPayPreOrderConfirmRequest parseRequest(Map<String, Object> requestMap) {
|
|
||||||
try {
|
|
||||||
log.info("请求体内容: {}", requestMap);
|
|
||||||
|
|
||||||
if (requestMap == null || requestMap.isEmpty()) {
|
|
||||||
log.warn("请求体为空");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查是否包含header和body
|
|
||||||
if (!requestMap.containsKey("header") || !requestMap.containsKey("body")) {
|
|
||||||
log.warn("请求体格式不正确,缺少header或body");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Object> headerMap = (Map<String, Object>) requestMap.get("header");
|
|
||||||
Object bodyObj = requestMap.get("body");
|
|
||||||
|
|
||||||
log.info("字段: header = {}", headerMap);
|
|
||||||
log.info("字段: body = {}", bodyObj);
|
|
||||||
|
|
||||||
// 构建请求对象
|
|
||||||
CtripPayPreOrderConfirmRequest request = new CtripPayPreOrderConfirmRequest();
|
|
||||||
|
|
||||||
// 设置header
|
|
||||||
CtripPayPreOrderConfirmRequest.CtripHeader header = objectMapper.convertValue(headerMap,
|
|
||||||
CtripPayPreOrderConfirmRequest.CtripHeader.class);
|
|
||||||
request.setHeader(header);
|
|
||||||
|
|
||||||
// 检查body是否为加密字符串
|
|
||||||
if (bodyObj instanceof String) {
|
|
||||||
String encryptedBody = (String) bodyObj;
|
|
||||||
log.info("body是加密字符串,长度: {}", encryptedBody.length());
|
|
||||||
|
|
||||||
// 保存原始加密body用于签名验证
|
|
||||||
request.setOriginalEncryptedBody(encryptedBody);
|
|
||||||
|
|
||||||
// 解密body
|
|
||||||
String decryptedBody = ctripDecryptUtil.decryptAES(encryptedBody);
|
|
||||||
if (decryptedBody == null) {
|
|
||||||
log.error("解密body失败");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("解密成功,解密后body长度: {}", decryptedBody.length());
|
|
||||||
log.info("解密后body内容: {}", decryptedBody);
|
|
||||||
|
|
||||||
// 解析解密后的body
|
|
||||||
Map<String, Object> bodyMap = objectMapper.readValue(decryptedBody, Map.class);
|
|
||||||
log.info("解析body成功,新的请求体: {}", bodyMap);
|
|
||||||
|
|
||||||
// 设置body
|
|
||||||
CtripPayPreOrderConfirmRequest.CtripPayPreOrderConfirmBody body = objectMapper.convertValue(bodyMap,
|
|
||||||
CtripPayPreOrderConfirmRequest.CtripPayPreOrderConfirmBody.class);
|
|
||||||
request.setBody(body);
|
|
||||||
|
|
||||||
log.info("检测到携程加密请求格式");
|
|
||||||
return request;
|
|
||||||
|
|
||||||
} else if (bodyObj instanceof Map) {
|
|
||||||
// body是JSON对象(明文格式)
|
|
||||||
log.info("body是JSON对象格式(明文)");
|
|
||||||
|
|
||||||
// 设置body
|
|
||||||
CtripPayPreOrderConfirmRequest.CtripPayPreOrderConfirmBody body = objectMapper.convertValue(bodyObj,
|
|
||||||
CtripPayPreOrderConfirmRequest.CtripPayPreOrderConfirmBody.class);
|
|
||||||
request.setBody(body);
|
|
||||||
|
|
||||||
// 对于明文格式,需要将body序列化为JSON字符串用于签名验证
|
|
||||||
String bodyJson = objectMapper.writeValueAsString(bodyObj);
|
|
||||||
log.info("明文body JSON: {}", bodyJson);
|
|
||||||
|
|
||||||
// 加密body用于签名验证
|
|
||||||
String encryptedBody = ctripDecryptUtil.encryptAES(bodyJson);
|
|
||||||
if (encryptedBody != null) {
|
|
||||||
request.setOriginalEncryptedBody(encryptedBody);
|
|
||||||
log.info("明文body加密成功,用于签名验证");
|
|
||||||
} else {
|
|
||||||
log.warn("明文body加密失败,签名验证可能失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("检测到携程明文请求格式");
|
|
||||||
return request;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
log.warn("body格式不支持: {}", bodyObj.getClass().getSimpleName());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("解析支付确认请求异常", e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证签名
|
|
||||||
*/
|
|
||||||
private boolean validateSignature(CtripPayPreOrderConfirmRequest request) {
|
|
||||||
try {
|
|
||||||
if (request.getHeader() == null) {
|
|
||||||
log.warn("请求头为空,无法验证签名");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String accountId = request.getHeader().getAccountId();
|
|
||||||
String serviceName = request.getHeader().getServiceName();
|
|
||||||
String requestTime = request.getHeader().getRequestTime();
|
|
||||||
String version = request.getHeader().getVersion();
|
|
||||||
String sign = request.getHeader().getSign();
|
|
||||||
|
|
||||||
if (accountId == null || serviceName == null || requestTime == null || version == null || sign == null) {
|
|
||||||
log.warn("签名验证参数不完整");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 使用原始加密body进行签名验证
|
|
||||||
String originalEncryptedBody = request.getOriginalEncryptedBody();
|
|
||||||
if (originalEncryptedBody == null) {
|
|
||||||
log.warn("原始加密body为空,无法验证签名");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String expectedSign = ctripDecryptUtil.generateSign(accountId, serviceName, requestTime,
|
|
||||||
originalEncryptedBody, version);
|
|
||||||
|
|
||||||
boolean isValid = sign.equals(expectedSign);
|
|
||||||
log.info("签名验证结果: {}, 期望签名: {}, 实际签名: {}", isValid, expectedSign, sign);
|
|
||||||
|
|
||||||
return isValid;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("验证签名异常", e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取客户端IP
|
|
||||||
*/
|
|
||||||
private String getClientIp(HttpServletRequest request) {
|
|
||||||
String xForwardedFor = request.getHeader("X-Forwarded-For");
|
|
||||||
if (xForwardedFor != null && !xForwardedFor.isEmpty() && !"unknown".equalsIgnoreCase(xForwardedFor)) {
|
|
||||||
return xForwardedFor.split(",")[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
String xRealIp = request.getHeader("X-Real-IP");
|
|
||||||
if (xRealIp != null && !xRealIp.isEmpty() && !"unknown".equalsIgnoreCase(xRealIp)) {
|
|
||||||
return xRealIp;
|
|
||||||
}
|
|
||||||
|
|
||||||
return request.getRemoteAddr();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建错误响应
|
|
||||||
*/
|
|
||||||
private CtripPayPreOrderConfirmResponse buildErrorResponse(String resultCode, String resultMessage) {
|
|
||||||
CtripPayPreOrderConfirmResponse response = new CtripPayPreOrderConfirmResponse();
|
|
||||||
|
|
||||||
CtripPayPreOrderConfirmResponse.CtripResponseHeader header = new CtripPayPreOrderConfirmResponse.CtripResponseHeader();
|
|
||||||
header.setResultCode(resultCode);
|
|
||||||
header.setResultMessage(resultMessage);
|
|
||||||
header.setVersion("1.0");
|
|
||||||
response.setHeader(header);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-200
@@ -1,200 +0,0 @@
|
|||||||
package com.central.coupon.controller;
|
|
||||||
|
|
||||||
import com.central.coupon.model.CtripPayPreOrderRequest;
|
|
||||||
import com.central.coupon.model.CtripPayPreOrderResponse;
|
|
||||||
import com.central.coupon.service.CtripPayPreOrderService;
|
|
||||||
import com.central.coupon.util.CtripDecryptUtil;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程预下单支付控制器
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/coupon/ctrip/pay")
|
|
||||||
public class CtripPayPreOrderController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripPayPreOrderService ctripPayPreOrderService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripDecryptUtil ctripDecryptUtil;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理携程预下单支付请求
|
|
||||||
*/
|
|
||||||
@PostMapping("")
|
|
||||||
public CtripPayPreOrderResponse payPreOrder(@RequestBody Object requestBody, HttpServletRequest request) {
|
|
||||||
log.info("收到携程预下单支付请求,IP: {}", request.getRemoteAddr());
|
|
||||||
log.info("请求URL: {}", request.getRequestURL());
|
|
||||||
log.info("请求URI: {}", request.getRequestURI());
|
|
||||||
log.info("请求方法: {}", request.getMethod());
|
|
||||||
log.info("请求体类型: {}", requestBody.getClass().getSimpleName());
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 解析请求体
|
|
||||||
CtripPayPreOrderRequest ctripRequest = parseRequestBody(requestBody);
|
|
||||||
if (ctripRequest == null) {
|
|
||||||
log.error("解析请求体失败");
|
|
||||||
return buildErrorResponse("0001", "请求体解析失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 验证签名
|
|
||||||
if (!validateSignature(ctripRequest)) {
|
|
||||||
log.error("签名验证失败");
|
|
||||||
return buildErrorResponse("0002", "签名验证失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理预下单支付请求
|
|
||||||
return ctripPayPreOrderService.processPayPreOrderRequest(ctripRequest);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("处理携程预下单支付请求异常", e);
|
|
||||||
return buildErrorResponse("0003", "处理请求异常: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解析请求体
|
|
||||||
*/
|
|
||||||
private CtripPayPreOrderRequest parseRequestBody(Object requestBody) {
|
|
||||||
try {
|
|
||||||
if (requestBody instanceof Map) {
|
|
||||||
// 如果已经是Map格式,直接转换
|
|
||||||
log.info("请求体已经是Map格式");
|
|
||||||
Map<String, Object> requestMap = (Map<String, Object>) requestBody;
|
|
||||||
log.info("请求体内容: {}", requestMap);
|
|
||||||
|
|
||||||
// 检查是否是携程标准请求格式
|
|
||||||
if (requestMap.containsKey("header") && requestMap.containsKey("body")) {
|
|
||||||
log.info("检测到携程标准请求格式(包含header和body)");
|
|
||||||
Object bodyObj = requestMap.get("body");
|
|
||||||
|
|
||||||
if (bodyObj instanceof String) {
|
|
||||||
// body是加密字符串
|
|
||||||
String encryptedBody = (String) bodyObj;
|
|
||||||
log.info("body是加密字符串,长度: {}", encryptedBody.length());
|
|
||||||
|
|
||||||
// 保存原始加密body用于签名验证
|
|
||||||
CtripPayPreOrderRequest request = new CtripPayPreOrderRequest();
|
|
||||||
request.setOriginalEncryptedBody(encryptedBody);
|
|
||||||
|
|
||||||
// 解密body
|
|
||||||
String decryptedBody = ctripDecryptUtil.decryptAES(encryptedBody);
|
|
||||||
if (decryptedBody == null) {
|
|
||||||
log.error("解密body失败");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("解密成功,解密后body长度: {}", decryptedBody.length());
|
|
||||||
log.info("解密后body内容: {}", decryptedBody);
|
|
||||||
|
|
||||||
// 解析header
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Map<String, Object> headerMap = (Map<String, Object>) requestMap.get("header");
|
|
||||||
CtripPayPreOrderRequest.CtripRequestHeader header = objectMapper.convertValue(headerMap, CtripPayPreOrderRequest.CtripRequestHeader.class);
|
|
||||||
request.setHeader(header);
|
|
||||||
|
|
||||||
// 解析解密后的body
|
|
||||||
CtripPayPreOrderRequest.CtripPayPreOrderBody body = objectMapper.readValue(decryptedBody, CtripPayPreOrderRequest.CtripPayPreOrderBody.class);
|
|
||||||
request.setBody(body);
|
|
||||||
|
|
||||||
log.info("解析body成功,新的请求体: {}", body);
|
|
||||||
return request;
|
|
||||||
} else {
|
|
||||||
// body已经是对象
|
|
||||||
log.info("body已经是对象格式");
|
|
||||||
CtripPayPreOrderRequest request = new CtripPayPreOrderRequest();
|
|
||||||
|
|
||||||
// 解析header
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Map<String, Object> headerMap = (Map<String, Object>) requestMap.get("header");
|
|
||||||
CtripPayPreOrderRequest.CtripRequestHeader header = objectMapper.convertValue(headerMap, CtripPayPreOrderRequest.CtripRequestHeader.class);
|
|
||||||
request.setHeader(header);
|
|
||||||
|
|
||||||
// 解析body
|
|
||||||
CtripPayPreOrderRequest.CtripPayPreOrderBody body = objectMapper.convertValue(bodyObj, CtripPayPreOrderRequest.CtripPayPreOrderBody.class);
|
|
||||||
request.setBody(body);
|
|
||||||
|
|
||||||
return request;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 直接解析整个请求体
|
|
||||||
log.info("直接解析整个请求体");
|
|
||||||
return objectMapper.convertValue(requestBody, CtripPayPreOrderRequest.class);
|
|
||||||
}
|
|
||||||
} else if (requestBody instanceof String) {
|
|
||||||
// 如果是字符串,直接解析
|
|
||||||
log.info("请求体是字符串格式");
|
|
||||||
return objectMapper.readValue((String) requestBody, CtripPayPreOrderRequest.class);
|
|
||||||
} else {
|
|
||||||
// 其他格式,尝试直接转换
|
|
||||||
log.info("尝试直接转换请求体");
|
|
||||||
return objectMapper.convertValue(requestBody, CtripPayPreOrderRequest.class);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("解析请求体异常", e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证签名
|
|
||||||
*/
|
|
||||||
private boolean validateSignature(CtripPayPreOrderRequest request) {
|
|
||||||
try {
|
|
||||||
if (request.getHeader() == null || request.getHeader().getSign() == null) {
|
|
||||||
log.error("请求头或签名为空");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String receivedSign = request.getHeader().getSign();
|
|
||||||
log.info("收到的签名: {}", receivedSign);
|
|
||||||
|
|
||||||
// 使用原始加密body计算签名
|
|
||||||
String originalEncryptedBody = request.getOriginalEncryptedBody();
|
|
||||||
if (originalEncryptedBody == null) {
|
|
||||||
log.error("原始加密body为空,无法验证签名");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String calculatedSign = ctripDecryptUtil.generateSign(
|
|
||||||
request.getHeader().getAccountId(),
|
|
||||||
request.getHeader().getServiceName(),
|
|
||||||
request.getHeader().getRequestTime(),
|
|
||||||
originalEncryptedBody,
|
|
||||||
request.getHeader().getVersion()
|
|
||||||
);
|
|
||||||
log.info("计算的签名: {}", calculatedSign);
|
|
||||||
|
|
||||||
boolean isValid = receivedSign.equals(calculatedSign);
|
|
||||||
log.info("签名验证结果: {}", isValid);
|
|
||||||
|
|
||||||
return isValid;
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("验证签名异常", e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建错误响应
|
|
||||||
*/
|
|
||||||
private CtripPayPreOrderResponse buildErrorResponse(String resultCode, String resultMessage) {
|
|
||||||
CtripPayPreOrderResponse response = new CtripPayPreOrderResponse();
|
|
||||||
CtripPayPreOrderResponse.CtripResponseHeader header = new CtripPayPreOrderResponse.CtripResponseHeader();
|
|
||||||
header.setResultCode(resultCode);
|
|
||||||
header.setResultMessage(resultMessage);
|
|
||||||
response.setHeader(header);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-498
@@ -1,498 +0,0 @@
|
|||||||
package com.central.coupon.controller;
|
|
||||||
|
|
||||||
import com.alibaba.nacos.common.utils.JacksonUtils;
|
|
||||||
import com.central.coupon.model.CtripQueryOrderRequest;
|
|
||||||
import com.central.coupon.model.CtripQueryOrderResponse;
|
|
||||||
import com.central.coupon.service.ICtripQueryOrderService;
|
|
||||||
import com.central.coupon.util.CtripDecryptUtil;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单查询控制器
|
|
||||||
* 专门处理携程订单查询相关接口
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/coupon/ctrip/query")
|
|
||||||
@Tag(name = "携程订单查询")
|
|
||||||
public class CtripQueryOrderController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ICtripQueryOrderService ctripQueryOrderService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripDecryptUtil ctripDecryptUtil;
|
|
||||||
|
|
||||||
// 携程SDK配置参数(保持兼容但不使用硬编码默认值)
|
|
||||||
@Value("${ctrip.account.id}")
|
|
||||||
private String ctripAccountId;
|
|
||||||
|
|
||||||
@Value("${ctrip.aes.key:750e15a31356a99d}")
|
|
||||||
private String ctripAesKey;
|
|
||||||
|
|
||||||
@Value("${ctrip.aes.iv:087b36ad0dff7942}")
|
|
||||||
private String ctripAesIv;
|
|
||||||
|
|
||||||
@Value("${ctrip.account.secret:ce6033ae31124ec5cdab3d2bc79f2622}")
|
|
||||||
private String ctripAccountSecret;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单查询接口
|
|
||||||
* 携程调用此接口查询订单详细信息
|
|
||||||
*
|
|
||||||
* 请求格式:
|
|
||||||
* {
|
|
||||||
* "header": {
|
|
||||||
* "accountId": "c50a8f2a4a59c9e7",
|
|
||||||
* "serviceName": "QueryOrder",
|
|
||||||
* "requestTime": "2025-01-23 14:57:34",
|
|
||||||
* "version": "1.0",
|
|
||||||
* "sign": "md5签名"
|
|
||||||
* },
|
|
||||||
* "body": "加密的JSON字符串"
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
@Operation(summary = "携程订单查询接口")
|
|
||||||
@PostMapping("/order")
|
|
||||||
public CtripQueryOrderResponse queryOrder(@RequestBody Object requestBody,
|
|
||||||
jakarta.servlet.http.HttpServletRequest httpRequest) {
|
|
||||||
return processQueryOrderRequest(requestBody, httpRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理查询订单请求(内部方法,供统一接口调用)
|
|
||||||
*/
|
|
||||||
public CtripQueryOrderResponse processQueryOrderRequest(Object requestBody,
|
|
||||||
jakarta.servlet.http.HttpServletRequest httpRequest) {
|
|
||||||
log.info("收到携程订单查询请求,IP: {}", httpRequest.getRemoteAddr());
|
|
||||||
log.info("请求URL: {}", httpRequest.getRequestURL());
|
|
||||||
log.info("请求URI: {}", httpRequest.getRequestURI());
|
|
||||||
log.info("请求方法: {}", httpRequest.getMethod());
|
|
||||||
log.info("请求体类型: {}", requestBody != null ? requestBody.getClass().getSimpleName() : "null");
|
|
||||||
|
|
||||||
CtripQueryOrderRequest request = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 1. 解析请求体
|
|
||||||
if (requestBody instanceof Map) {
|
|
||||||
Map<String, Object> requestMap = (Map<String, Object>) requestBody;
|
|
||||||
log.info("请求体内容: {}", requestMap);
|
|
||||||
|
|
||||||
// 检查是否是携程标准请求格式(包含header和body)
|
|
||||||
if (requestMap.containsKey("header") && requestMap.containsKey("body")) {
|
|
||||||
log.info("检测到携程标准请求格式(包含header和body)");
|
|
||||||
|
|
||||||
// 构建请求对象
|
|
||||||
request = new CtripQueryOrderRequest();
|
|
||||||
|
|
||||||
// 解析header
|
|
||||||
Map<String, Object> headerMap = (Map<String, Object>) requestMap.get("header");
|
|
||||||
CtripQueryOrderRequest.CtripHeader header = new CtripQueryOrderRequest.CtripHeader();
|
|
||||||
header.setAccountId((String) headerMap.get("accountId"));
|
|
||||||
header.setServiceName((String) headerMap.get("serviceName"));
|
|
||||||
header.setRequestTime((String) headerMap.get("requestTime"));
|
|
||||||
header.setVersion((String) headerMap.get("version"));
|
|
||||||
header.setSign((String) headerMap.get("sign"));
|
|
||||||
request.setHeader(header);
|
|
||||||
|
|
||||||
// 处理body
|
|
||||||
Object bodyObj = requestMap.get("body");
|
|
||||||
if (bodyObj instanceof String) {
|
|
||||||
// body是加密字符串,需要解密
|
|
||||||
String encryptedBody = (String) bodyObj;
|
|
||||||
log.info("body是加密字符串,长度: {}", encryptedBody.length());
|
|
||||||
|
|
||||||
// 保存原始的加密body用于签名验证
|
|
||||||
request.setOriginalEncryptedBody(encryptedBody);
|
|
||||||
|
|
||||||
String decryptedBody = ctripDecryptUtil.decryptAES(encryptedBody);
|
|
||||||
if (decryptedBody == null) {
|
|
||||||
log.error("解密body失败");
|
|
||||||
return buildErrorResponse("0001", "解密body失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("解密成功,解密后body长度: {}", decryptedBody.length());
|
|
||||||
log.info("解密后body内容: {}", decryptedBody);
|
|
||||||
|
|
||||||
request.setBody(decryptedBody);
|
|
||||||
} else {
|
|
||||||
// body已经是对象
|
|
||||||
request.setBody(bodyObj);
|
|
||||||
log.info("body已经是对象格式");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.error("请求格式不正确,缺少header或body字段");
|
|
||||||
return buildErrorResponse("0001", "请求格式不正确");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.error("未知的请求体类型:{}", requestBody != null ? requestBody.getClass().getSimpleName() : "null");
|
|
||||||
return buildErrorResponse("0001", "未知的请求体类型");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 验证服务名称
|
|
||||||
if (!"QueryOrder".equals(request.getHeader().getServiceName())) {
|
|
||||||
log.error("服务名称不正确: {}", request.getHeader().getServiceName());
|
|
||||||
return buildErrorResponse("0002", "服务名称不正确");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 验证账号
|
|
||||||
if (!validateAccountId(request.getHeader().getAccountId())) {
|
|
||||||
log.error("无效的accountId: {}", request.getHeader().getAccountId());
|
|
||||||
return buildErrorResponse("0003", "账号错误");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. 验证签名
|
|
||||||
if (!validateSignature(request)) {
|
|
||||||
log.error("签名验证失败");
|
|
||||||
return buildErrorResponse("0002", "签名验证失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5. 解析请求体
|
|
||||||
CtripQueryOrderRequest.CtripQueryOrderBody body = parseRequestBody(request.getBody());
|
|
||||||
if (body == null) {
|
|
||||||
log.error("请求体解析失败");
|
|
||||||
return buildErrorResponse("0004", "请求体解析失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 6. 验证查询条件
|
|
||||||
if (!validateQueryConditions(body)) {
|
|
||||||
log.error("查询条件不完整");
|
|
||||||
return buildErrorResponse("0005", "查询条件不完整,至少需要提供otaOrderId、supplierOrderId或sequenceId中的一个");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 7. 处理查询请求
|
|
||||||
CtripQueryOrderResponse response = ctripQueryOrderService.processQueryOrder(request.getHeader(), body);
|
|
||||||
|
|
||||||
log.info("携程订单查询处理完成");
|
|
||||||
return response;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("处理携程订单查询请求异常", e);
|
|
||||||
return buildErrorResponse("1100", "处理请求异常: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据携程订单号查询订单(内部接口)
|
|
||||||
*/
|
|
||||||
@Operation(summary = "根据携程订单号查询订单")
|
|
||||||
@GetMapping("/order/ota/{otaOrderId}")
|
|
||||||
public CtripQueryOrderResponse queryOrderByOtaOrderId(@PathVariable("otaOrderId") String otaOrderId) {
|
|
||||||
log.info("根据携程订单号查询订单: {}", otaOrderId);
|
|
||||||
return ctripQueryOrderService.queryOrderByOtaOrderId(otaOrderId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据供应商订单号查询订单(内部接口)
|
|
||||||
*/
|
|
||||||
@Operation(summary = "根据供应商订单号查询订单")
|
|
||||||
@GetMapping("/order/supplier/{supplierOrderId}")
|
|
||||||
public CtripQueryOrderResponse queryOrderBySupplierOrderId(@PathVariable("supplierOrderId") String supplierOrderId) {
|
|
||||||
log.info("根据供应商订单号查询订单: {}", supplierOrderId);
|
|
||||||
return ctripQueryOrderService.queryOrderBySupplierOrderId(supplierOrderId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据流水号查询订单(内部接口)
|
|
||||||
*/
|
|
||||||
@Operation(summary = "根据流水号查询订单")
|
|
||||||
@GetMapping("/order/sequence/{sequenceId}")
|
|
||||||
public CtripQueryOrderResponse queryOrderBySequenceId(@PathVariable("sequenceId") String sequenceId) {
|
|
||||||
log.info("根据流水号查询订单: {}", sequenceId);
|
|
||||||
return ctripQueryOrderService.queryOrderBySequenceId(sequenceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证签名
|
|
||||||
*/
|
|
||||||
private boolean validateSignature(CtripQueryOrderRequest request) {
|
|
||||||
try {
|
|
||||||
String accountId = request.getHeader().getAccountId();
|
|
||||||
String serviceName = request.getHeader().getServiceName();
|
|
||||||
String requestTime = request.getHeader().getRequestTime();
|
|
||||||
String version = request.getHeader().getVersion();
|
|
||||||
String sign = request.getHeader().getSign();
|
|
||||||
|
|
||||||
// 获取原始的加密body(用于签名验证)
|
|
||||||
// 根据官方示例:需要使用原始的加密body,而不是解密后的body
|
|
||||||
String encryptedBody = request.getOriginalEncryptedBody();
|
|
||||||
if (encryptedBody == null) {
|
|
||||||
// 如果没有原始加密body,尝试使用当前body
|
|
||||||
encryptedBody = request.getBody().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 验证签名
|
|
||||||
boolean isValid = ctripDecryptUtil.verifySign(accountId, serviceName, requestTime, encryptedBody, version, sign);
|
|
||||||
|
|
||||||
if (!isValid) {
|
|
||||||
log.error("签名验证失败,期望签名: {}, 计算签名: {}", sign,
|
|
||||||
ctripDecryptUtil.generateSign(accountId, serviceName, requestTime, encryptedBody, version));
|
|
||||||
|
|
||||||
// 额外的调试信息
|
|
||||||
log.debug("签名验证详细信息:");
|
|
||||||
log.debug("- accountId: {}", accountId);
|
|
||||||
log.debug("- serviceName: {}", serviceName);
|
|
||||||
log.debug("- requestTime: {}", requestTime);
|
|
||||||
log.debug("- version: {}", version);
|
|
||||||
log.debug("- encryptedBody长度: {}", encryptedBody != null ? encryptedBody.length() : 0);
|
|
||||||
log.debug("- accountSecret: {}", ctripDecryptUtil.getAccountSecret());
|
|
||||||
}
|
|
||||||
|
|
||||||
return isValid;
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("验证签名异常", e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证账号ID
|
|
||||||
*/
|
|
||||||
private boolean validateAccountId(String accountId) {
|
|
||||||
return ctripAccountId.equals(accountId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解析请求体
|
|
||||||
*/
|
|
||||||
private CtripQueryOrderRequest.CtripQueryOrderBody parseRequestBody(Object body) {
|
|
||||||
try {
|
|
||||||
if (body instanceof String) {
|
|
||||||
// 此时body已经是解密后的JSON字符串,直接解析
|
|
||||||
String jsonBody = body.toString();
|
|
||||||
log.debug("解析JSON字符串: {}", jsonBody);
|
|
||||||
return objectMapper.readValue(jsonBody, CtripQueryOrderRequest.CtripQueryOrderBody.class);
|
|
||||||
} else {
|
|
||||||
// 如果是JSON对象,直接转换
|
|
||||||
return objectMapper.convertValue(body, CtripQueryOrderRequest.CtripQueryOrderBody.class);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("解析请求体异常", e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证查询条件
|
|
||||||
*/
|
|
||||||
private boolean validateQueryConditions(CtripQueryOrderRequest.CtripQueryOrderBody body) {
|
|
||||||
return (body.getOtaOrderId() != null && !body.getOtaOrderId().trim().isEmpty()) ||
|
|
||||||
(body.getSupplierOrderId() != null && !body.getSupplierOrderId().trim().isEmpty()) ||
|
|
||||||
(body.getSequenceId() != null && !body.getSequenceId().trim().isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建错误响应
|
|
||||||
*/
|
|
||||||
private CtripQueryOrderResponse buildErrorResponse(String resultCode, String resultMessage) {
|
|
||||||
CtripQueryOrderResponse response = new CtripQueryOrderResponse();
|
|
||||||
|
|
||||||
CtripQueryOrderResponse.CtripResponseHeader header = new CtripQueryOrderResponse.CtripResponseHeader();
|
|
||||||
header.setResultCode(resultCode);
|
|
||||||
header.setResultMessage(resultMessage);
|
|
||||||
response.setHeader(header);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 测试MD5计算(内部测试用)
|
|
||||||
*/
|
|
||||||
@Operation(summary = "测试MD5计算")
|
|
||||||
@PostMapping("/test/md5")
|
|
||||||
public Map<String, Object> testMD5(@RequestBody Map<String, String> request) {
|
|
||||||
log.info("测试MD5计算,请求参数: {}", request);
|
|
||||||
|
|
||||||
Map<String, Object> result = new java.util.HashMap<>();
|
|
||||||
|
|
||||||
try {
|
|
||||||
String input = request.get("input");
|
|
||||||
String md5Result = ctripDecryptUtil.testMD5(input);
|
|
||||||
|
|
||||||
result.put("input", input);
|
|
||||||
result.put("md5Result", md5Result);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("测试MD5计算异常", e);
|
|
||||||
result.put("error", e.getMessage());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 测试签名计算(内部测试用)
|
|
||||||
*/
|
|
||||||
@Operation(summary = "测试签名计算")
|
|
||||||
@PostMapping("/test/sign")
|
|
||||||
public Map<String, Object> testSignCalculation(@RequestBody Map<String, Object> request) {
|
|
||||||
log.info("测试签名计算,请求参数: {}", request);
|
|
||||||
|
|
||||||
Map<String, Object> result = new java.util.HashMap<>();
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 解析请求
|
|
||||||
Map<String, Object> headerMap = (Map<String, Object>) request.get("header");
|
|
||||||
Object bodyObj = request.get("body");
|
|
||||||
|
|
||||||
String accountId = (String) headerMap.get("accountId");
|
|
||||||
String serviceName = (String) headerMap.get("serviceName");
|
|
||||||
String requestTime = (String) headerMap.get("requestTime");
|
|
||||||
String version = (String) headerMap.get("version");
|
|
||||||
String expectedSign = (String) headerMap.get("sign");
|
|
||||||
|
|
||||||
// 解密body
|
|
||||||
String decryptedBody = null;
|
|
||||||
if (bodyObj instanceof String) {
|
|
||||||
decryptedBody = ctripDecryptUtil.decryptAES((String) bodyObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
result.put("accountId", accountId);
|
|
||||||
result.put("serviceName", serviceName);
|
|
||||||
result.put("requestTime", requestTime);
|
|
||||||
result.put("version", version);
|
|
||||||
result.put("expectedSign", expectedSign);
|
|
||||||
result.put("decryptedBody", decryptedBody);
|
|
||||||
result.put("accountSecret", ctripDecryptUtil.getAccountSecret());
|
|
||||||
|
|
||||||
// 计算签名
|
|
||||||
String calculatedSign = ctripDecryptUtil.generateSign(accountId, serviceName, requestTime, decryptedBody, version);
|
|
||||||
result.put("calculatedSign", calculatedSign);
|
|
||||||
result.put("isMatch", expectedSign.equalsIgnoreCase(calculatedSign));
|
|
||||||
|
|
||||||
// 详细调试信息
|
|
||||||
Map<String, Object> debugInfo = ctripDecryptUtil.debugSignCalculation(accountId, serviceName, requestTime, decryptedBody, version, expectedSign);
|
|
||||||
result.put("debugInfo", debugInfo);
|
|
||||||
|
|
||||||
log.info("签名测试结果: {}", result);
|
|
||||||
return result;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("测试签名计算异常", e);
|
|
||||||
result.put("error", e.getMessage());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 测试QueryOrder接口(内部测试用)
|
|
||||||
*/
|
|
||||||
@Operation(summary = "测试QueryOrder接口")
|
|
||||||
@PostMapping("/test")
|
|
||||||
public CtripQueryOrderResponse testQueryOrder(@RequestBody Map<String, Object> request) {
|
|
||||||
log.info("测试QueryOrder接口,请求参数: {}", request);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 构建测试请求
|
|
||||||
CtripQueryOrderRequest testRequest = new CtripQueryOrderRequest();
|
|
||||||
|
|
||||||
// 设置请求头
|
|
||||||
CtripQueryOrderRequest.CtripHeader header = new CtripQueryOrderRequest.CtripHeader();
|
|
||||||
header.setAccountId(ctripAccountId);
|
|
||||||
header.setServiceName("QueryOrder");
|
|
||||||
header.setRequestTime(java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
||||||
header.setVersion("1.0");
|
|
||||||
header.setSign("test_sign"); // 测试时跳过签名验证
|
|
||||||
testRequest.setHeader(header);
|
|
||||||
|
|
||||||
// 设置请求体
|
|
||||||
CtripQueryOrderRequest.CtripQueryOrderBody body = new CtripQueryOrderRequest.CtripQueryOrderBody();
|
|
||||||
body.setOtaOrderId((String) request.get("otaOrderId"));
|
|
||||||
body.setSupplierOrderId((String) request.get("supplierOrderId"));
|
|
||||||
body.setSequenceId((String) request.get("sequenceId"));
|
|
||||||
testRequest.setBody(body);
|
|
||||||
|
|
||||||
// 调用查询服务
|
|
||||||
return ctripQueryOrderService.processQueryOrder(header, body);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("测试QueryOrder接口异常", e);
|
|
||||||
return buildErrorResponse("1100", "测试异常: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 测试QueryOrder接口解密(内部测试用)
|
|
||||||
*/
|
|
||||||
@Operation(summary = "测试QueryOrder接口解密")
|
|
||||||
@PostMapping("/test/decrypt")
|
|
||||||
public Map<String, Object> testQueryOrderDecrypt(@RequestBody Object requestBody) {
|
|
||||||
log.info("测试QueryOrder接口解密,请求体类型: {}", requestBody != null ? requestBody.getClass().getSimpleName() : "null");
|
|
||||||
|
|
||||||
Map<String, Object> result = new java.util.HashMap<>();
|
|
||||||
result.put("requestType", requestBody != null ? requestBody.getClass().getSimpleName() : "null");
|
|
||||||
result.put("requestContent", requestBody);
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (requestBody instanceof Map) {
|
|
||||||
Map<String, Object> requestMap = (Map<String, Object>) requestBody;
|
|
||||||
result.put("requestSize", requestMap.size());
|
|
||||||
result.put("requestKeys", requestMap.keySet());
|
|
||||||
|
|
||||||
// 检查是否是携程标准请求格式
|
|
||||||
if (requestMap.containsKey("header") && requestMap.containsKey("body")) {
|
|
||||||
result.put("isStandardFormat", true);
|
|
||||||
|
|
||||||
// 解析header
|
|
||||||
Map<String, Object> headerMap = (Map<String, Object>) requestMap.get("header");
|
|
||||||
result.put("header", headerMap);
|
|
||||||
|
|
||||||
// 处理body
|
|
||||||
Object bodyObj = requestMap.get("body");
|
|
||||||
if (bodyObj instanceof String) {
|
|
||||||
String encryptedBody = (String) bodyObj;
|
|
||||||
result.put("bodyType", "encrypted");
|
|
||||||
result.put("encryptedBodyLength", encryptedBody.length());
|
|
||||||
result.put("encryptedBodyPreview", encryptedBody.length() > 100 ? encryptedBody.substring(0, 100) + "..." : encryptedBody);
|
|
||||||
|
|
||||||
// 尝试解密
|
|
||||||
String decryptedBody = ctripDecryptUtil.decryptAES(encryptedBody);
|
|
||||||
if (decryptedBody != null) {
|
|
||||||
result.put("decryptSuccess", true);
|
|
||||||
result.put("decryptedBodyLength", decryptedBody.length());
|
|
||||||
result.put("decryptedBody", decryptedBody);
|
|
||||||
|
|
||||||
// 尝试解析JSON
|
|
||||||
try {
|
|
||||||
Object jsonObj = objectMapper.readValue(decryptedBody, Object.class);
|
|
||||||
result.put("jsonParseSuccess", true);
|
|
||||||
result.put("parsedJson", jsonObj);
|
|
||||||
} catch (Exception e) {
|
|
||||||
result.put("jsonParseSuccess", false);
|
|
||||||
result.put("jsonParseError", e.getMessage());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result.put("decryptSuccess", false);
|
|
||||||
result.put("decryptError", "解密失败");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result.put("bodyType", "object");
|
|
||||||
result.put("body", bodyObj);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result.put("isStandardFormat", false);
|
|
||||||
result.put("error", "不是携程标准请求格式");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result.put("error", "请求体不是Map类型");
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
result.put("error", "处理异常: " + e.getMessage());
|
|
||||||
log.error("测试QueryOrder接口解密异常", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-453
@@ -1,453 +0,0 @@
|
|||||||
package com.central.coupon.controller;
|
|
||||||
|
|
||||||
import com.central.coupon.model.CtripRefundOrderRequest;
|
|
||||||
import com.central.coupon.model.CtripRefundOrderResponse;
|
|
||||||
import com.central.coupon.service.ICtripRefundOrderService;
|
|
||||||
import com.central.coupon.util.CtripDecryptUtil;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单退款控制器
|
|
||||||
* 专门处理携程订单退款相关接口
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/coupon/ctrip/refund")
|
|
||||||
@Tag(name = "携程订单退款")
|
|
||||||
public class CtripRefundOrderController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ICtripRefundOrderService ctripRefundOrderService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripDecryptUtil ctripDecryptUtil;
|
|
||||||
|
|
||||||
// 携程SDK配置参数
|
|
||||||
@Value("${ctrip.account.id}")
|
|
||||||
private String ctripAccountId;
|
|
||||||
|
|
||||||
@Value("${ctrip.aes.key:750e15a31356a99d}")
|
|
||||||
private String ctripAesKey;
|
|
||||||
|
|
||||||
@Value("${ctrip.aes.iv:087b36ad0dff7942}")
|
|
||||||
private String ctripAesIv;
|
|
||||||
|
|
||||||
@Value("${ctrip.account.secret:ce6033ae31124ec5cdab3d2bc79f2622}")
|
|
||||||
private String ctripAccountSecret;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单退款接口
|
|
||||||
* 携程调用此接口申请订单退款
|
|
||||||
*
|
|
||||||
* 请求格式:
|
|
||||||
* {
|
|
||||||
* "header": {
|
|
||||||
* "accountId": "c50a8f2a4a59c9e7",
|
|
||||||
* "serviceName": "RefundOrder",
|
|
||||||
* "requestTime": "2025-01-23 14:57:34",
|
|
||||||
* "version": "1.0",
|
|
||||||
* "sign": "md5签名"
|
|
||||||
* },
|
|
||||||
* "body": "加密的JSON字符串"
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
@Operation(summary = "携程订单退款接口")
|
|
||||||
@PostMapping("/order")
|
|
||||||
public CtripRefundOrderResponse refundOrder(@RequestBody Object requestBody,
|
|
||||||
jakarta.servlet.http.HttpServletRequest httpRequest) {
|
|
||||||
return processRefundOrderRequest(requestBody, httpRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理退款订单请求(内部方法,供统一接口调用)
|
|
||||||
*/
|
|
||||||
public CtripRefundOrderResponse processRefundOrderRequest(Object requestBody,
|
|
||||||
jakarta.servlet.http.HttpServletRequest httpRequest) {
|
|
||||||
log.info("收到携程订单退款请求,IP: {}", httpRequest.getRemoteAddr());
|
|
||||||
log.info("请求URL: {}", httpRequest.getRequestURL());
|
|
||||||
log.info("请求URI: {}", httpRequest.getRequestURI());
|
|
||||||
log.info("请求方法: {}", httpRequest.getMethod());
|
|
||||||
log.info("请求体类型: {}", requestBody != null ? requestBody.getClass().getSimpleName() : "null");
|
|
||||||
|
|
||||||
CtripRefundOrderRequest request = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 1. 解析请求体
|
|
||||||
if (requestBody instanceof Map) {
|
|
||||||
Map<String, Object> requestMap = (Map<String, Object>) requestBody;
|
|
||||||
log.info("请求体内容: {}", requestMap);
|
|
||||||
|
|
||||||
// 检查是否是携程标准请求格式(包含header和body)
|
|
||||||
if (requestMap.containsKey("header") && requestMap.containsKey("body")) {
|
|
||||||
log.info("检测到携程标准请求格式(包含header和body)");
|
|
||||||
|
|
||||||
// 构建请求对象
|
|
||||||
request = new CtripRefundOrderRequest();
|
|
||||||
|
|
||||||
// 解析header
|
|
||||||
Map<String, Object> headerMap = (Map<String, Object>) requestMap.get("header");
|
|
||||||
CtripRefundOrderRequest.CtripHeader header = new CtripRefundOrderRequest.CtripHeader();
|
|
||||||
header.setAccountId((String) headerMap.get("accountId"));
|
|
||||||
header.setServiceName((String) headerMap.get("serviceName"));
|
|
||||||
header.setRequestTime((String) headerMap.get("requestTime"));
|
|
||||||
header.setVersion((String) headerMap.get("version"));
|
|
||||||
header.setSign((String) headerMap.get("sign"));
|
|
||||||
request.setHeader(header);
|
|
||||||
|
|
||||||
// 处理body
|
|
||||||
Object bodyObj = requestMap.get("body");
|
|
||||||
if (bodyObj instanceof String) {
|
|
||||||
// body是加密字符串,需要解密
|
|
||||||
String encryptedBody = (String) bodyObj;
|
|
||||||
log.info("body是加密字符串,长度: {}", encryptedBody.length());
|
|
||||||
|
|
||||||
// 保存原始的加密body用于签名验证
|
|
||||||
request.setOriginalEncryptedBody(encryptedBody);
|
|
||||||
|
|
||||||
String decryptedBody = ctripDecryptUtil.decryptAES(encryptedBody);
|
|
||||||
if (decryptedBody == null) {
|
|
||||||
log.error("解密body失败");
|
|
||||||
return buildErrorResponse("0001", "解密body失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("解密成功,解密后body长度: {}", decryptedBody.length());
|
|
||||||
log.info("解密后body内容: {}", decryptedBody);
|
|
||||||
|
|
||||||
request.setBody(decryptedBody);
|
|
||||||
} else {
|
|
||||||
// body已经是对象
|
|
||||||
request.setBody(bodyObj);
|
|
||||||
log.info("body已经是对象格式");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.error("请求格式不正确,缺少header或body字段");
|
|
||||||
return buildErrorResponse("0001", "请求格式不正确");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.error("未知的请求体类型:{}", requestBody != null ? requestBody.getClass().getSimpleName() : "null");
|
|
||||||
return buildErrorResponse("0001", "未知的请求体类型");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 验证请求头
|
|
||||||
if (request.getHeader() == null) {
|
|
||||||
log.error("请求头为空");
|
|
||||||
return buildErrorResponse("0001", "请求头不能为空");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 验证服务名称
|
|
||||||
if (!"RefundOrder".equals(request.getHeader().getServiceName())) {
|
|
||||||
log.error("服务名称不正确: {}", request.getHeader().getServiceName());
|
|
||||||
return buildErrorResponse("0002", "服务名称不正确");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 验证签名
|
|
||||||
if (!validateSignature(request)) {
|
|
||||||
log.error("签名验证失败");
|
|
||||||
return buildErrorResponse("0003", "签名验证失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. 解析请求体
|
|
||||||
CtripRefundOrderRequest.CtripRefundOrderBody body = parseRequestBody(request.getBody());
|
|
||||||
if (body == null) {
|
|
||||||
log.error("请求体解析失败");
|
|
||||||
return buildErrorResponse("0004", "请求体解析失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5. 验证退款参数
|
|
||||||
if (!validateRefundParameters(body)) {
|
|
||||||
log.error("退款参数验证失败");
|
|
||||||
return buildErrorResponse("0005", "退款参数验证失败,请检查订单号、退款金额等参数");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 6. 处理退款请求
|
|
||||||
CtripRefundOrderResponse response = ctripRefundOrderService.processRefundOrder(request.getHeader(), body);
|
|
||||||
|
|
||||||
log.info("携程订单退款处理完成");
|
|
||||||
return response;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("处理携程订单退款请求异常", e);
|
|
||||||
return buildErrorResponse("1100", "处理请求异常: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证退款金额(内部接口)
|
|
||||||
*/
|
|
||||||
@Operation(summary = "验证退款金额")
|
|
||||||
@GetMapping("/validate/{otaOrderId}")
|
|
||||||
public Map<String, Object> validateRefundAmount(@PathVariable("otaOrderId") String otaOrderId,
|
|
||||||
@RequestParam("refundAmount") java.math.BigDecimal refundAmount) {
|
|
||||||
log.info("验证退款金额,otaOrderId: {}, refundAmount: {}", otaOrderId, refundAmount);
|
|
||||||
|
|
||||||
try {
|
|
||||||
boolean isValid = ctripRefundOrderService.validateRefundAmount(otaOrderId, null, refundAmount);
|
|
||||||
java.math.BigDecimal availableAmount = ctripRefundOrderService.getAvailableRefundAmount(otaOrderId, null);
|
|
||||||
|
|
||||||
Map<String, Object> result = Map.of(
|
|
||||||
"otaOrderId", otaOrderId,
|
|
||||||
"refundAmount", refundAmount,
|
|
||||||
"availableAmount", availableAmount,
|
|
||||||
"isValid", isValid,
|
|
||||||
"message", isValid ? "退款金额验证通过" : "退款金额大于可退金额"
|
|
||||||
);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("验证退款金额异常,otaOrderId: {}", otaOrderId, e);
|
|
||||||
return Map.of(
|
|
||||||
"otaOrderId", otaOrderId,
|
|
||||||
"refundAmount", refundAmount,
|
|
||||||
"availableAmount", java.math.BigDecimal.ZERO,
|
|
||||||
"isValid", false,
|
|
||||||
"message", "验证异常: " + e.getMessage()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取可退金额(内部接口)
|
|
||||||
*/
|
|
||||||
@Operation(summary = "获取可退金额")
|
|
||||||
@GetMapping("/available/{otaOrderId}")
|
|
||||||
public Map<String, Object> getAvailableRefundAmount(@PathVariable("otaOrderId") String otaOrderId) {
|
|
||||||
log.info("获取可退金额,otaOrderId: {}", otaOrderId);
|
|
||||||
|
|
||||||
try {
|
|
||||||
java.math.BigDecimal availableAmount = ctripRefundOrderService.getAvailableRefundAmount(otaOrderId, null);
|
|
||||||
|
|
||||||
return Map.of(
|
|
||||||
"otaOrderId", otaOrderId,
|
|
||||||
"availableAmount", availableAmount,
|
|
||||||
"message", "获取成功"
|
|
||||||
);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("获取可退金额异常,otaOrderId: {}", otaOrderId, e);
|
|
||||||
return Map.of(
|
|
||||||
"otaOrderId", otaOrderId,
|
|
||||||
"availableAmount", java.math.BigDecimal.ZERO,
|
|
||||||
"message", "获取异常: " + e.getMessage()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 测试RefundOrder接口(内部测试用)
|
|
||||||
*/
|
|
||||||
@Operation(summary = "测试RefundOrder接口")
|
|
||||||
@PostMapping("/test")
|
|
||||||
public CtripRefundOrderResponse testRefundOrder(@RequestBody Map<String, Object> request) {
|
|
||||||
log.info("测试RefundOrder接口,请求参数: {}", request);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 构建测试请求
|
|
||||||
CtripRefundOrderRequest testRequest = new CtripRefundOrderRequest();
|
|
||||||
|
|
||||||
// 设置请求头
|
|
||||||
CtripRefundOrderRequest.CtripHeader header = new CtripRefundOrderRequest.CtripHeader();
|
|
||||||
header.setAccountId(ctripAccountId);
|
|
||||||
header.setServiceName("RefundOrder");
|
|
||||||
header.setRequestTime(java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
||||||
header.setVersion("1.0");
|
|
||||||
header.setSign("test_sign"); // 测试时跳过签名验证
|
|
||||||
testRequest.setHeader(header);
|
|
||||||
|
|
||||||
// 设置请求体
|
|
||||||
CtripRefundOrderRequest.CtripRefundOrderBody body = new CtripRefundOrderRequest.CtripRefundOrderBody();
|
|
||||||
body.setOtaOrderId((String) request.get("otaOrderId"));
|
|
||||||
body.setSupplierOrderId((String) request.get("supplierOrderId"));
|
|
||||||
body.setSequenceId((String) request.get("sequenceId"));
|
|
||||||
body.setTotalAmount(new java.math.BigDecimal(request.get("totalAmount").toString()));
|
|
||||||
body.setTotalAmountCurrency((String) request.get("totalAmountCurrency"));
|
|
||||||
body.setLastConfirmTime((String) request.get("lastConfirmTime"));
|
|
||||||
body.setRefundReason((String) request.get("refundReason"));
|
|
||||||
testRequest.setBody(body);
|
|
||||||
|
|
||||||
// 调用退款服务
|
|
||||||
return ctripRefundOrderService.processRefundOrder(header, body);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("测试RefundOrder接口异常", e);
|
|
||||||
return buildErrorResponse("1100", "测试异常: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证签名
|
|
||||||
*/
|
|
||||||
private boolean validateSignature(CtripRefundOrderRequest request) {
|
|
||||||
try {
|
|
||||||
String accountId = request.getHeader().getAccountId();
|
|
||||||
String serviceName = request.getHeader().getServiceName();
|
|
||||||
String requestTime = request.getHeader().getRequestTime();
|
|
||||||
String version = request.getHeader().getVersion();
|
|
||||||
String sign = request.getHeader().getSign();
|
|
||||||
|
|
||||||
// 获取原始的加密body(用于签名验证)
|
|
||||||
// 根据官方示例:需要使用原始的加密body,而不是解密后的body
|
|
||||||
String encryptedBody = request.getOriginalEncryptedBody();
|
|
||||||
if (encryptedBody == null) {
|
|
||||||
// 如果没有原始加密body,尝试使用当前body
|
|
||||||
encryptedBody = request.getBody().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 验证签名
|
|
||||||
boolean isValid = ctripDecryptUtil.verifySign(accountId, serviceName, requestTime, encryptedBody, version, sign);
|
|
||||||
|
|
||||||
if (!isValid) {
|
|
||||||
log.error("签名验证失败,期望签名: {}, 计算签名: {}", sign,
|
|
||||||
ctripDecryptUtil.generateSign(accountId, serviceName, requestTime, encryptedBody, version));
|
|
||||||
}
|
|
||||||
|
|
||||||
return isValid;
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("验证签名异常", e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解析请求体
|
|
||||||
*/
|
|
||||||
private CtripRefundOrderRequest.CtripRefundOrderBody parseRequestBody(Object body) {
|
|
||||||
try {
|
|
||||||
if (body instanceof String) {
|
|
||||||
// 此时body已经是解密后的JSON字符串,直接解析
|
|
||||||
String jsonBody = body.toString();
|
|
||||||
log.debug("解析JSON字符串: {}", jsonBody);
|
|
||||||
return objectMapper.readValue(jsonBody, CtripRefundOrderRequest.CtripRefundOrderBody.class);
|
|
||||||
} else {
|
|
||||||
// 如果是JSON对象,直接转换
|
|
||||||
return objectMapper.convertValue(body, CtripRefundOrderRequest.CtripRefundOrderBody.class);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("解析请求体异常", e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证退款参数
|
|
||||||
*/
|
|
||||||
private boolean validateRefundParameters(CtripRefundOrderRequest.CtripRefundOrderBody body) {
|
|
||||||
// 验证订单号
|
|
||||||
if (body.getOtaOrderId() == null || body.getOtaOrderId().trim().isEmpty()) {
|
|
||||||
log.error("携程订单号为空");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 验证退款金额
|
|
||||||
if (body.getTotalAmount() == null || body.getTotalAmount().compareTo(java.math.BigDecimal.ZERO) <= 0) {
|
|
||||||
log.error("退款金额无效: {}", body.getTotalAmount());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 验证流水号
|
|
||||||
if (body.getSequenceId() == null || body.getSequenceId().trim().isEmpty()) {
|
|
||||||
log.error("流水号为空");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 测试RefundOrder接口解密(内部测试用)
|
|
||||||
*/
|
|
||||||
@Operation(summary = "测试RefundOrder接口解密")
|
|
||||||
@PostMapping("/test/decrypt")
|
|
||||||
public Map<String, Object> testRefundOrderDecrypt(@RequestBody Object requestBody) {
|
|
||||||
log.info("测试RefundOrder接口解密,请求体类型: {}", requestBody != null ? requestBody.getClass().getSimpleName() : "null");
|
|
||||||
|
|
||||||
Map<String, Object> result = new java.util.HashMap<>();
|
|
||||||
result.put("requestType", requestBody != null ? requestBody.getClass().getSimpleName() : "null");
|
|
||||||
result.put("requestContent", requestBody);
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (requestBody instanceof Map) {
|
|
||||||
Map<String, Object> requestMap = (Map<String, Object>) requestBody;
|
|
||||||
result.put("requestSize", requestMap.size());
|
|
||||||
result.put("requestKeys", requestMap.keySet());
|
|
||||||
|
|
||||||
// 检查是否是携程标准请求格式
|
|
||||||
if (requestMap.containsKey("header") && requestMap.containsKey("body")) {
|
|
||||||
result.put("isStandardFormat", true);
|
|
||||||
|
|
||||||
// 解析header
|
|
||||||
Map<String, Object> headerMap = (Map<String, Object>) requestMap.get("header");
|
|
||||||
result.put("header", headerMap);
|
|
||||||
|
|
||||||
// 处理body
|
|
||||||
Object bodyObj = requestMap.get("body");
|
|
||||||
if (bodyObj instanceof String) {
|
|
||||||
String encryptedBody = (String) bodyObj;
|
|
||||||
result.put("bodyType", "encrypted");
|
|
||||||
result.put("encryptedBodyLength", encryptedBody.length());
|
|
||||||
result.put("encryptedBodyPreview", encryptedBody.length() > 100 ? encryptedBody.substring(0, 100) + "..." : encryptedBody);
|
|
||||||
|
|
||||||
// 尝试解密
|
|
||||||
String decryptedBody = ctripDecryptUtil.decryptAES(encryptedBody);
|
|
||||||
if (decryptedBody != null) {
|
|
||||||
result.put("decryptSuccess", true);
|
|
||||||
result.put("decryptedBodyLength", decryptedBody.length());
|
|
||||||
result.put("decryptedBody", decryptedBody);
|
|
||||||
|
|
||||||
// 尝试解析JSON
|
|
||||||
try {
|
|
||||||
Object jsonObj = objectMapper.readValue(decryptedBody, Object.class);
|
|
||||||
result.put("jsonParseSuccess", true);
|
|
||||||
result.put("parsedJson", jsonObj);
|
|
||||||
} catch (Exception e) {
|
|
||||||
result.put("jsonParseSuccess", false);
|
|
||||||
result.put("jsonParseError", e.getMessage());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result.put("decryptSuccess", false);
|
|
||||||
result.put("decryptError", "解密失败");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result.put("bodyType", "object");
|
|
||||||
result.put("body", bodyObj);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result.put("isStandardFormat", false);
|
|
||||||
result.put("error", "不是携程标准请求格式");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result.put("error", "请求体不是Map类型");
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
result.put("error", "处理异常: " + e.getMessage());
|
|
||||||
log.error("测试RefundOrder接口解密异常", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建错误响应
|
|
||||||
*/
|
|
||||||
private CtripRefundOrderResponse buildErrorResponse(String resultCode, String resultMessage) {
|
|
||||||
CtripRefundOrderResponse response = new CtripRefundOrderResponse();
|
|
||||||
|
|
||||||
CtripRefundOrderResponse.CtripResponseHeader header = new CtripRefundOrderResponse.CtripResponseHeader();
|
|
||||||
header.setResultCode(resultCode);
|
|
||||||
header.setResultMessage(resultMessage);
|
|
||||||
response.setHeader(header);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-373
@@ -1,373 +0,0 @@
|
|||||||
package com.central.coupon.controller;
|
|
||||||
|
|
||||||
import com.central.coupon.model.CtripCouponResponse;
|
|
||||||
import com.central.coupon.model.CtripQueryOrderResponse;
|
|
||||||
import com.central.coupon.model.CtripRefundOrderResponse;
|
|
||||||
import com.central.coupon.service.ICtripQueryOrderService;
|
|
||||||
import com.central.coupon.service.ICtripRefundOrderService;
|
|
||||||
import com.central.coupon.util.CtripDecryptUtil;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import com.central.coupon.service.CtripCancelPreOrderService;
|
|
||||||
import com.central.coupon.service.ICtripOrderService;
|
|
||||||
import com.central.coupon.model.CtripCreateOrderRequest;
|
|
||||||
import com.central.coupon.model.CtripCreateOrderResponse;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程统一接口控制器
|
|
||||||
* 根据请求头中的serviceName路由到不同的处理方法
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/coupon/ctrip")
|
|
||||||
@Tag(name = "携程统一接口")
|
|
||||||
public class CtripUnifiedController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripQueryOrderController ctripQueryOrderController;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripRefundOrderController ctripRefundOrderController;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripPayPreOrderController ctripPayPreOrderController;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripCancelPreOrderController ctripCancelPreOrderController;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripCancelOrderController ctripCancelOrderController;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripCancelPreOrderService ctripCancelPreOrderService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ICtripOrderService ctripOrderService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripDecryptUtil ctripDecryptUtil;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程统一接口入口
|
|
||||||
* 根据serviceName路由到不同的处理方法
|
|
||||||
*/
|
|
||||||
@Operation(summary = "携程统一接口")
|
|
||||||
@PostMapping("/create")
|
|
||||||
public Object handleCtripRequest(@RequestBody Object requestBody,
|
|
||||||
jakarta.servlet.http.HttpServletRequest httpRequest) {
|
|
||||||
log.info("收到携程统一接口请求,IP: {}", httpRequest.getRemoteAddr());
|
|
||||||
log.info("请求URL: {}", httpRequest.getRequestURL());
|
|
||||||
log.info("请求URI: {}", httpRequest.getRequestURI());
|
|
||||||
log.info("请求方法: {}", httpRequest.getMethod());
|
|
||||||
log.info("请求体类型: {}", requestBody != null ? requestBody.getClass().getSimpleName() : "null");
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 解析请求体
|
|
||||||
Map<String, Object> request = parseRequestBody(requestBody);
|
|
||||||
if (request == null) {
|
|
||||||
return buildErrorResponse("0001", "请求体解析失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取请求头
|
|
||||||
Map<String, Object> header = (Map<String, Object>) request.get("header");
|
|
||||||
if (header == null) {
|
|
||||||
log.error("请求头为空");
|
|
||||||
return buildErrorResponse("0001", "请求头不能为空");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取serviceName
|
|
||||||
String serviceName = (String) header.get("serviceName");
|
|
||||||
log.info("携程请求的serviceName: {}", serviceName);
|
|
||||||
|
|
||||||
// 根据serviceName路由到不同的处理方法
|
|
||||||
switch (serviceName) {
|
|
||||||
case "CreatePreOrder":
|
|
||||||
log.info("路由到创建订单接口");
|
|
||||||
return processCreatePreOrder(request, header);
|
|
||||||
|
|
||||||
case "QueryOrder":
|
|
||||||
log.info("路由到查询订单接口");
|
|
||||||
return ctripQueryOrderController.processQueryOrderRequest(requestBody, httpRequest);
|
|
||||||
|
|
||||||
case "RefundOrder":
|
|
||||||
log.info("路由到退款订单接口");
|
|
||||||
return ctripRefundOrderController.processRefundOrderRequest(requestBody, httpRequest);
|
|
||||||
|
|
||||||
case "PayPreOrder":
|
|
||||||
log.info("路由到预下单支付接口");
|
|
||||||
return ctripPayPreOrderController.payPreOrder(requestBody, httpRequest);
|
|
||||||
|
|
||||||
case "CancelPreOrder":
|
|
||||||
log.info("路由到取消预下单接口");
|
|
||||||
return ctripCancelPreOrderController.processCancelPreOrderRequest(requestBody, httpRequest);
|
|
||||||
|
|
||||||
case "CancelOrder":
|
|
||||||
log.info("路由到取消订单接口");
|
|
||||||
return ctripCancelOrderController.processCancelOrderRequest(requestBody, httpRequest);
|
|
||||||
|
|
||||||
default:
|
|
||||||
log.error("未知的serviceName: {}", serviceName);
|
|
||||||
return buildErrorResponse("0002", "未知的服务名称: " + serviceName);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("处理携程统一接口请求异常", e);
|
|
||||||
return buildErrorResponse("1100", "处理请求异常: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解析请求体
|
|
||||||
*/
|
|
||||||
private Map<String, Object> parseRequestBody(Object requestBody) {
|
|
||||||
try {
|
|
||||||
if (requestBody instanceof Map) {
|
|
||||||
return (Map<String, Object>) requestBody;
|
|
||||||
} else if (requestBody instanceof String) {
|
|
||||||
// 如果是加密字符串,先解密
|
|
||||||
String decryptedBody = ctripDecryptUtil.decryptAES((String) requestBody);
|
|
||||||
if (decryptedBody == null) {
|
|
||||||
log.error("解密请求体失败");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return objectMapper.readValue(decryptedBody, Map.class);
|
|
||||||
} else {
|
|
||||||
log.error("未知的请求体类型: {}", requestBody != null ? requestBody.getClass().getSimpleName() : "null");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("解析请求体异常", e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建错误响应
|
|
||||||
*/
|
|
||||||
private CtripCouponResponse buildErrorResponse(String resultCode, String resultMessage) {
|
|
||||||
CtripCouponResponse response = new CtripCouponResponse();
|
|
||||||
|
|
||||||
CtripCouponResponse.CtripResponseHeader header = new CtripCouponResponse.CtripResponseHeader();
|
|
||||||
header.setResultCode(resultCode);
|
|
||||||
header.setResultMessage(resultMessage);
|
|
||||||
response.setHeader(header);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建CreatePreOrder错误响应
|
|
||||||
*/
|
|
||||||
private CtripCreateOrderResponse buildCreatePreOrderErrorResponse(String resultCode, String resultMessage) {
|
|
||||||
CtripCreateOrderResponse response = new CtripCreateOrderResponse();
|
|
||||||
|
|
||||||
CtripCreateOrderResponse.CtripResponseHeader header = new CtripCreateOrderResponse.CtripResponseHeader();
|
|
||||||
header.setResultCode(resultCode);
|
|
||||||
header.setResultMessage(resultMessage);
|
|
||||||
response.setHeader(header);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理CreatePreOrder请求
|
|
||||||
*/
|
|
||||||
private Object processCreatePreOrder(Map<String, Object> request, Map<String, Object> header) {
|
|
||||||
try {
|
|
||||||
log.info("开始处理CreatePreOrder请求");
|
|
||||||
|
|
||||||
// 调试:打印整个请求结构
|
|
||||||
log.info("CreatePreOrder完整请求结构: {}", request);
|
|
||||||
log.info("request.get('body')类型: {}, 值: {}",
|
|
||||||
request.get("body") != null ? request.get("body").getClass().getSimpleName() : "null",
|
|
||||||
request.get("body"));
|
|
||||||
|
|
||||||
// 获取请求体
|
|
||||||
Object bodyObj = request.get("body");
|
|
||||||
Map<String, Object> body;
|
|
||||||
|
|
||||||
if (bodyObj instanceof String) {
|
|
||||||
// 如果body是加密字符串,需要先解密
|
|
||||||
log.info("检测到body是加密字符串,开始解密");
|
|
||||||
String decryptedBody = ctripDecryptUtil.decryptAES((String) bodyObj);
|
|
||||||
if (decryptedBody == null) {
|
|
||||||
log.error("解密CreatePreOrder请求体失败");
|
|
||||||
return buildCreatePreOrderErrorResponse("0001", "解密请求体失败");
|
|
||||||
}
|
|
||||||
log.info("解密后的body: {}", decryptedBody);
|
|
||||||
body = objectMapper.readValue(decryptedBody, Map.class);
|
|
||||||
} else if (bodyObj instanceof Map) {
|
|
||||||
body = (Map<String, Object>) bodyObj;
|
|
||||||
} else {
|
|
||||||
log.error("CreatePreOrder请求体类型不支持: {}", bodyObj != null ? bodyObj.getClass().getSimpleName() : "null");
|
|
||||||
return buildCreatePreOrderErrorResponse("0001", "请求体类型不支持");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (body == null) {
|
|
||||||
log.error("CreatePreOrder请求体为空");
|
|
||||||
return buildCreatePreOrderErrorResponse("0001", "请求体不能为空");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 调试:打印请求体结构
|
|
||||||
log.info("CreatePreOrder请求体结构: {}", body);
|
|
||||||
log.info("contacts字段类型: {}, 值: {}",
|
|
||||||
body.get("contacts") != null ? body.get("contacts").getClass().getSimpleName() : "null",
|
|
||||||
body.get("contacts"));
|
|
||||||
log.info("items字段类型: {}, 值: {}",
|
|
||||||
body.get("items") != null ? body.get("items").getClass().getSimpleName() : "null",
|
|
||||||
body.get("items"));
|
|
||||||
log.info("coupons字段类型: {}, 值: {}",
|
|
||||||
body.get("coupons") != null ? body.get("coupons").getClass().getSimpleName() : "null",
|
|
||||||
body.get("coupons"));
|
|
||||||
|
|
||||||
// 构建请求对象
|
|
||||||
CtripCreateOrderRequest createOrderRequest = new CtripCreateOrderRequest();
|
|
||||||
|
|
||||||
// 构建请求头
|
|
||||||
CtripCreateOrderRequest.CtripHeader requestHeader = new CtripCreateOrderRequest.CtripHeader();
|
|
||||||
requestHeader.setAccountId((String) header.get("accountId"));
|
|
||||||
requestHeader.setServiceName((String) header.get("serviceName"));
|
|
||||||
requestHeader.setRequestTime((String) header.get("requestTime"));
|
|
||||||
requestHeader.setVersion((String) header.get("version"));
|
|
||||||
requestHeader.setSign((String) header.get("sign"));
|
|
||||||
createOrderRequest.setHeader(requestHeader);
|
|
||||||
|
|
||||||
// 构建请求体
|
|
||||||
CtripCreateOrderRequest.CtripOrderBody requestBody = new CtripCreateOrderRequest.CtripOrderBody();
|
|
||||||
requestBody.setOtaOrderId((String) body.get("otaOrderId"));
|
|
||||||
requestBody.setSequenceId((String) body.get("sequenceId"));
|
|
||||||
requestBody.setConfirmType((Integer) body.get("confirmType"));
|
|
||||||
requestBody.setOrderLastConfirmTime((String) body.get("orderLastConfirmTime"));
|
|
||||||
|
|
||||||
// 注意:乘客信息是在订单项中,不是在订单体中,所以这里不需要处理body级别的passengers
|
|
||||||
|
|
||||||
// 处理联系人信息
|
|
||||||
if (body.get("contacts") != null) {
|
|
||||||
Object contactsObj = body.get("contacts");
|
|
||||||
if (contactsObj instanceof List) {
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
List<Map<String, Object>> contactsData = (List<Map<String, Object>>) contactsObj;
|
|
||||||
List<CtripCreateOrderRequest.CtripContact> contacts = new ArrayList<>();
|
|
||||||
for (Map<String, Object> contactData : contactsData) {
|
|
||||||
CtripCreateOrderRequest.CtripContact contact = new CtripCreateOrderRequest.CtripContact();
|
|
||||||
contact.setName((String) contactData.get("name"));
|
|
||||||
contact.setMobile((String) contactData.get("mobile"));
|
|
||||||
contact.setEmail((String) contactData.get("email"));
|
|
||||||
contacts.add(contact);
|
|
||||||
}
|
|
||||||
requestBody.setContacts(contacts);
|
|
||||||
} else {
|
|
||||||
log.warn("contacts字段不是List类型,跳过处理: {}", contactsObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理订单项信息
|
|
||||||
if (body.get("items") != null) {
|
|
||||||
Object itemsObj = body.get("items");
|
|
||||||
if (itemsObj instanceof List) {
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
List<Map<String, Object>> itemsData = (List<Map<String, Object>>) itemsObj;
|
|
||||||
List<CtripCreateOrderRequest.CtripOrderItem> items = new ArrayList<>();
|
|
||||||
for (Map<String, Object> itemData : itemsData) {
|
|
||||||
CtripCreateOrderRequest.CtripOrderItem item = new CtripCreateOrderRequest.CtripOrderItem();
|
|
||||||
|
|
||||||
// 如果itemId不存在,保持为空(携程期望空值)
|
|
||||||
String itemId = (String) itemData.get("itemId");
|
|
||||||
if (itemId == null || itemId.trim().isEmpty()) {
|
|
||||||
log.info("itemId为空,保持为空值(携程期望)");
|
|
||||||
}
|
|
||||||
item.setItemId(itemId);
|
|
||||||
|
|
||||||
item.setPLU((String) itemData.get("PLU"));
|
|
||||||
item.setUseStartDate((String) itemData.get("useStartDate"));
|
|
||||||
item.setUseEndDate((String) itemData.get("useEndDate"));
|
|
||||||
item.setQuantity((Integer) itemData.get("quantity"));
|
|
||||||
if (itemData.get("price") != null) {
|
|
||||||
item.setPrice(new java.math.BigDecimal(itemData.get("price").toString()));
|
|
||||||
}
|
|
||||||
item.setPriceCurrency((String) itemData.get("priceCurrency"));
|
|
||||||
|
|
||||||
// 处理订单项中的乘客信息
|
|
||||||
if (itemData.get("passengers") != null) {
|
|
||||||
Object passengersObj = itemData.get("passengers");
|
|
||||||
if (passengersObj instanceof List) {
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
List<Map<String, Object>> passengersData = (List<Map<String, Object>>) passengersObj;
|
|
||||||
List<CtripCreateOrderRequest.CtripPassenger> passengers = new ArrayList<>();
|
|
||||||
for (Map<String, Object> passengerData : passengersData) {
|
|
||||||
CtripCreateOrderRequest.CtripPassenger passenger = new CtripCreateOrderRequest.CtripPassenger();
|
|
||||||
passenger.setPassengerId((String) passengerData.get("passengerId"));
|
|
||||||
passenger.setName((String) passengerData.get("name"));
|
|
||||||
passenger.setMobile((String) passengerData.get("mobile"));
|
|
||||||
passenger.setCardNo((String) passengerData.get("cardNo"));
|
|
||||||
passengers.add(passenger);
|
|
||||||
}
|
|
||||||
item.setPassengers(passengers);
|
|
||||||
} else {
|
|
||||||
log.warn("订单项中的passengers字段不是List类型,跳过处理: {}", passengersObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
items.add(item);
|
|
||||||
}
|
|
||||||
requestBody.setItems(items);
|
|
||||||
} else {
|
|
||||||
log.warn("items字段不是List类型,跳过处理: {}", itemsObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理优惠券信息
|
|
||||||
if (body.get("coupons") != null) {
|
|
||||||
Object couponsObj = body.get("coupons");
|
|
||||||
if (couponsObj instanceof List) {
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
List<Map<String, Object>> couponsData = (List<Map<String, Object>>) couponsObj;
|
|
||||||
List<CtripCreateOrderRequest.CtripCoupon> coupons = new ArrayList<>();
|
|
||||||
for (Map<String, Object> couponData : couponsData) {
|
|
||||||
CtripCreateOrderRequest.CtripCoupon coupon = new CtripCreateOrderRequest.CtripCoupon();
|
|
||||||
coupon.setType((Integer) couponData.get("type"));
|
|
||||||
coupon.setCode((String) couponData.get("code"));
|
|
||||||
coupon.setName((String) couponData.get("name"));
|
|
||||||
if (couponData.get("amount") != null) {
|
|
||||||
coupon.setAmount(new java.math.BigDecimal(couponData.get("amount").toString()));
|
|
||||||
}
|
|
||||||
coupon.setAmountCurrency((String) couponData.get("amountCurrency"));
|
|
||||||
coupons.add(coupon);
|
|
||||||
}
|
|
||||||
requestBody.setCoupons(coupons);
|
|
||||||
} else {
|
|
||||||
log.warn("coupons字段不是List类型,跳过处理: {}", couponsObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
createOrderRequest.setBody(requestBody);
|
|
||||||
|
|
||||||
// 调用订单服务处理
|
|
||||||
CtripCreateOrderResponse response = ctripOrderService.processCreateOrder(requestHeader, requestBody);
|
|
||||||
|
|
||||||
// 检查响应是否成功
|
|
||||||
if (response != null && response.getHeader() != null) {
|
|
||||||
log.info("CreatePreOrder处理完成,resultCode: {}", response.getHeader().getResultCode());
|
|
||||||
return response;
|
|
||||||
} else {
|
|
||||||
log.error("CreatePreOrder处理失败,响应为空");
|
|
||||||
return buildErrorResponse("1100", "CreatePreOrder处理失败,响应为空");
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("处理CreatePreOrder请求异常", e);
|
|
||||||
return buildErrorResponse("1100", "处理CreatePreOrder请求异常: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-283
@@ -1,283 +0,0 @@
|
|||||||
package com.central.coupon.controller;
|
|
||||||
|
|
||||||
import com.central.coupon.dto.OrderQueryDTO;
|
|
||||||
import com.central.coupon.dto.ConsumeOrderDTO;
|
|
||||||
import com.central.coupon.dto.SimpleConsumeDTO;
|
|
||||||
import com.central.coupon.vo.OrderDetailVO;
|
|
||||||
import com.central.coupon.service.IOrderDetailService;
|
|
||||||
import com.central.coupon.entity.CtripOrder;
|
|
||||||
import com.central.coupon.mapper.CtripOrderMapper;
|
|
||||||
import com.central.coupon.controller.CtripConsumedController;
|
|
||||||
import com.central.coupon.model.CtripConsumedNoticeResponse;
|
|
||||||
import com.central.coupon.service.CtripConsumedService;
|
|
||||||
import com.central.common.model.PageResult;
|
|
||||||
import com.central.common.model.Result;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.central.coupon.entity.CtripPassenger;
|
|
||||||
import com.central.coupon.mapper.CtripPassengerMapper;
|
|
||||||
import com.central.coupon.entity.CtripContact;
|
|
||||||
import com.central.coupon.mapper.CtripContactMapper;
|
|
||||||
import com.central.coupon.entity.CtripOrderItem;
|
|
||||||
import com.central.coupon.mapper.CtripOrderItemMapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单明细控制器
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/order-detail")
|
|
||||||
public class OrderDetailController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private IOrderDetailService orderDetailService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripOrderMapper ctripOrderMapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripConsumedService ctripConsumedService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripPassengerMapper ctripPassengerMapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripContactMapper ctripContactMapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CtripOrderItemMapper ctripOrderItemMapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据二维码ID查询可核销的订单明细
|
|
||||||
*
|
|
||||||
* @param queryDTO 查询条件(codeId、page、size)
|
|
||||||
* @return 订单明细分页结果
|
|
||||||
*/
|
|
||||||
@PostMapping("/query")
|
|
||||||
public Result<PageResult<OrderDetailVO>> queryOrderDetails(@Valid @RequestBody OrderQueryDTO queryDTO) {
|
|
||||||
log.info("查询可核销订单明细,codeId: {},page: {},size: {}", queryDTO.getCodeId(), queryDTO.getPage(), queryDTO.getSize());
|
|
||||||
|
|
||||||
try {
|
|
||||||
PageResult<OrderDetailVO> result = orderDetailService.queryOrderDetails(queryDTO);
|
|
||||||
return Result.succeed(result);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("查询可核销订单明细异常", e);
|
|
||||||
return Result.failed("查询可核销订单明细失败: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据订单号查询订单明细
|
|
||||||
*
|
|
||||||
* @param otaOrderId 携程订单号
|
|
||||||
* @return 订单明细
|
|
||||||
*/
|
|
||||||
@GetMapping("/{otaOrderId}")
|
|
||||||
public Result<OrderDetailVO> getOrderDetail(@PathVariable String otaOrderId) {
|
|
||||||
log.info("查询订单明细,订单号: {}", otaOrderId);
|
|
||||||
|
|
||||||
try {
|
|
||||||
OrderDetailVO orderDetail = orderDetailService.getOrderDetail(otaOrderId);
|
|
||||||
if (orderDetail == null) {
|
|
||||||
return Result.failed("订单不存在");
|
|
||||||
}
|
|
||||||
return Result.succeed(orderDetail);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("查询订单明细异常,订单号: {}", otaOrderId, e);
|
|
||||||
return Result.failed("查询订单明细失败: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 核销订单
|
|
||||||
*
|
|
||||||
* @param consumeDTO 核销请求
|
|
||||||
* @return 核销结果
|
|
||||||
*/
|
|
||||||
@PostMapping("/consume")
|
|
||||||
public Result<Boolean> consumeOrder(@Valid @RequestBody ConsumeOrderDTO consumeDTO) {
|
|
||||||
log.info("核销订单,订单号: {}", consumeDTO.getOtaOrderId());
|
|
||||||
|
|
||||||
try {
|
|
||||||
boolean result = orderDetailService.consumeOrder(consumeDTO);
|
|
||||||
if (result) {
|
|
||||||
return Result.succeed(true, "核销成功");
|
|
||||||
} else {
|
|
||||||
return Result.failed("核销失败");
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("核销订单异常,订单号: {}", consumeDTO.getOtaOrderId(), e);
|
|
||||||
return Result.failed("核销失败: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证订单是否可核销
|
|
||||||
*
|
|
||||||
* @param otaOrderId 携程订单号
|
|
||||||
* @return 是否可核销
|
|
||||||
*/
|
|
||||||
@GetMapping("/{otaOrderId}/validate")
|
|
||||||
public Result<Boolean> validateOrderForConsume(@PathVariable String otaOrderId) {
|
|
||||||
log.info("验证订单是否可核销,订单号: {}", otaOrderId);
|
|
||||||
|
|
||||||
try {
|
|
||||||
boolean canConsume = orderDetailService.validateOrderForConsume(otaOrderId);
|
|
||||||
return Result.succeed(canConsume);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("验证订单核销异常,订单号: {}", otaOrderId, e);
|
|
||||||
return Result.failed("验证失败: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 简化核销订单(单商品)
|
|
||||||
*
|
|
||||||
* @param consumeDTO 核销请求
|
|
||||||
* @return 核销结果
|
|
||||||
*/
|
|
||||||
@PostMapping("/consume-simple")
|
|
||||||
public Result<Boolean> consumeOrderSimple(@Valid @RequestBody SimpleConsumeDTO consumeDTO) {
|
|
||||||
log.info("简化核销订单,订单号: {}, 商品ID: {}, 数量: {}, 关联订单号: {}",
|
|
||||||
consumeDTO.getOtaOrderId(), consumeDTO.getItemId(), consumeDTO.getUseQuantity(), consumeDTO.getOrderNo());
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 1. 验证订单是否存在
|
|
||||||
CtripOrder order = ctripOrderMapper.selectByOtaOrderId(consumeDTO.getOtaOrderId());
|
|
||||||
if (order == null) {
|
|
||||||
log.error("订单不存在,订单号: {}", consumeDTO.getOtaOrderId());
|
|
||||||
return Result.failed("订单不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 验证订单是否可核销
|
|
||||||
if (!orderDetailService.validateOrderForConsume(consumeDTO.getOtaOrderId())) {
|
|
||||||
log.error("订单不可核销,订单号: {}", consumeDTO.getOtaOrderId());
|
|
||||||
return Result.failed("订单不可核销");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 建立订单关联关系(如果前端传入了orderNo)
|
|
||||||
if (consumeDTO.getOrderNo() != null && !consumeDTO.getOrderNo().trim().isEmpty()) {
|
|
||||||
if (order.getOrderNo() == null || order.getOrderNo().trim().isEmpty()) {
|
|
||||||
// 更新携程订单的orderNo字段
|
|
||||||
order.setOrderNo(consumeDTO.getOrderNo());
|
|
||||||
ctripOrderMapper.updateById(order);
|
|
||||||
log.info("建立订单关联关系,otaOrderId: {}, orderNo: {}",
|
|
||||||
consumeDTO.getOtaOrderId(), consumeDTO.getOrderNo());
|
|
||||||
} else if (!order.getOrderNo().equals(consumeDTO.getOrderNo())) {
|
|
||||||
log.warn("订单关联关系不匹配,数据库orderNo: {}, 前端orderNo: {}",
|
|
||||||
order.getOrderNo(), consumeDTO.getOrderNo());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. 调用携程核销服务
|
|
||||||
CtripConsumedController.CtripConsumeRequest request = new CtripConsumedController.CtripConsumeRequest();
|
|
||||||
request.setOtaOrderId(consumeDTO.getOtaOrderId());
|
|
||||||
request.setSupplierOrderId(order.getSupplierOrderId());
|
|
||||||
request.setItemId(consumeDTO.getItemId());
|
|
||||||
request.setUseQuantity(consumeDTO.getUseQuantity());
|
|
||||||
request.setRemark(consumeDTO.getRemark());
|
|
||||||
|
|
||||||
CtripConsumedNoticeResponse response = ctripConsumedService.consumeOrder(request);
|
|
||||||
boolean success = response != null && "0000".equals(response.getHeader().getResultCode());
|
|
||||||
|
|
||||||
if (success) {
|
|
||||||
log.info("核销成功,订单号: {}, 关联订单号: {}", consumeDTO.getOtaOrderId(), order.getOrderNo());
|
|
||||||
return Result.succeed(true, "核销成功");
|
|
||||||
} else {
|
|
||||||
log.error("核销失败,订单号: {}, 错误信息: {}", consumeDTO.getOtaOrderId(),
|
|
||||||
response != null ? response.getHeader().getResultMessage() : "未知错误");
|
|
||||||
return Result.failed("核销失败: " + (response != null ? response.getHeader().getResultMessage() : "未知错误"));
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("简化核销订单异常,订单号: {}", consumeDTO.getOtaOrderId(), e);
|
|
||||||
return Result.failed("核销失败: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 调试接口 - 检查数据库中的数据
|
|
||||||
*/
|
|
||||||
@GetMapping("/debug/data")
|
|
||||||
public Result<Map<String, Object>> debugData() {
|
|
||||||
log.info("调试接口 - 检查数据库中的数据");
|
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 1. 检查订单总数
|
|
||||||
long orderCount = ctripOrderMapper.selectCount(null);
|
|
||||||
result.put("orderCount", orderCount);
|
|
||||||
|
|
||||||
// 2. 检查乘客总数
|
|
||||||
long passengerCount = ctripPassengerMapper.selectCount(null);
|
|
||||||
result.put("passengerCount", passengerCount);
|
|
||||||
|
|
||||||
// 3. 检查联系人总数
|
|
||||||
long contactCount = ctripContactMapper.selectCount(null);
|
|
||||||
result.put("contactCount", contactCount);
|
|
||||||
|
|
||||||
// 4. 检查订单项总数
|
|
||||||
long orderItemCount = ctripOrderItemMapper.selectCount(null);
|
|
||||||
result.put("orderItemCount", orderItemCount);
|
|
||||||
|
|
||||||
// 5. 查询最新的几个订单
|
|
||||||
List<CtripOrder> latestOrders = ctripOrderMapper.selectList(
|
|
||||||
new QueryWrapper<CtripOrder>().orderByDesc("create_time").last("LIMIT 5")
|
|
||||||
);
|
|
||||||
result.put("latestOrders", latestOrders.stream().map(order -> {
|
|
||||||
Map<String, Object> orderInfo = new HashMap<>();
|
|
||||||
orderInfo.put("id", order.getId());
|
|
||||||
orderInfo.put("otaOrderId", order.getOtaOrderId());
|
|
||||||
orderInfo.put("totalAmount", order.getTotalAmount());
|
|
||||||
orderInfo.put("status", order.getStatus());
|
|
||||||
orderInfo.put("createTime", order.getCreateTime());
|
|
||||||
return orderInfo;
|
|
||||||
}).collect(Collectors.toList()));
|
|
||||||
|
|
||||||
// 6. 查询手机号18322694510的乘客信息
|
|
||||||
List<CtripPassenger> passengers = ctripPassengerMapper.selectByPhone("18322694510");
|
|
||||||
result.put("passengersForPhone", passengers != null ? passengers.size() : 0);
|
|
||||||
if (passengers != null && !passengers.isEmpty()) {
|
|
||||||
result.put("passengerDetails", passengers.stream().map(passenger -> {
|
|
||||||
Map<String, Object> passengerInfo = new HashMap<>();
|
|
||||||
passengerInfo.put("id", passenger.getId());
|
|
||||||
passengerInfo.put("orderId", passenger.getOrderId());
|
|
||||||
passengerInfo.put("passengerName", passenger.getPassengerName());
|
|
||||||
passengerInfo.put("phone", passenger.getPhone());
|
|
||||||
return passengerInfo;
|
|
||||||
}).collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 7. 查询手机号18322694510的联系人信息
|
|
||||||
List<CtripContact> contacts = ctripContactMapper.selectByMobile("18322694510");
|
|
||||||
result.put("contactsForPhone", contacts != null ? contacts.size() : 0);
|
|
||||||
if (contacts != null && !contacts.isEmpty()) {
|
|
||||||
result.put("contactDetails", contacts.stream().map(contact -> {
|
|
||||||
Map<String, Object> contactInfo = new HashMap<>();
|
|
||||||
contactInfo.put("id", contact.getId());
|
|
||||||
contactInfo.put("orderId", contact.getOrderId());
|
|
||||||
contactInfo.put("name", contact.getName());
|
|
||||||
contactInfo.put("mobile", contact.getMobile());
|
|
||||||
return contactInfo;
|
|
||||||
}).collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Result.succeed(result);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("调试接口异常", e);
|
|
||||||
result.put("error", e.getMessage());
|
|
||||||
return Result.failed("调试接口异常: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
package com.central.coupon.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 核销项目DTO
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class ConsumeItemDTO {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商品ID
|
|
||||||
*/
|
|
||||||
private String itemId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PLU码
|
|
||||||
*/
|
|
||||||
private String plu;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 核销数量
|
|
||||||
*/
|
|
||||||
private Integer quantity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 乘客ID列表
|
|
||||||
*/
|
|
||||||
private String[] passengerIds;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 凭证ID列表
|
|
||||||
*/
|
|
||||||
private String[] voucherIds;
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package com.central.coupon.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 核销订单DTO
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class ConsumeOrderDTO {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单号
|
|
||||||
*/
|
|
||||||
private String otaOrderId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 供应商订单号
|
|
||||||
*/
|
|
||||||
private String supplierOrderId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 核销项目列表
|
|
||||||
*/
|
|
||||||
private List<ConsumeItemDTO> items;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 核销备注
|
|
||||||
*/
|
|
||||||
private String remark;
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
package com.central.coupon.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import javax.validation.constraints.Min;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单查询DTO
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class OrderQueryDTO {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 二维码ID(来自订单的codeId)
|
|
||||||
*/
|
|
||||||
@NotNull(message = "二维码ID不能为空")
|
|
||||||
private String codeId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否只查询可核销的订单(内部控制,前端不必传,默认true)
|
|
||||||
*/
|
|
||||||
private Boolean onlyConsumable = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 页码
|
|
||||||
*/
|
|
||||||
@Min(value = 1, message = "页码必须大于等于1")
|
|
||||||
private Integer page = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 页大小
|
|
||||||
*/
|
|
||||||
@Min(value = 1, message = "页大小必须大于等于1")
|
|
||||||
private Integer size = 10;
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
package com.central.coupon.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 简化核销DTO
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class SimpleConsumeDTO {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单号
|
|
||||||
*/
|
|
||||||
private String otaOrderId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关联的订单中心订单号
|
|
||||||
*/
|
|
||||||
private String orderNo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商品ID
|
|
||||||
*/
|
|
||||||
private String itemId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 核销数量
|
|
||||||
*/
|
|
||||||
private Integer useQuantity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 备注信息
|
|
||||||
*/
|
|
||||||
private String remark;
|
|
||||||
}
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
package com.central.coupon.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 优惠券实体类
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
@TableName("t_coupon")
|
|
||||||
public class Coupon implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键ID
|
|
||||||
*/
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 租户ID
|
|
||||||
*/
|
|
||||||
private String tenantId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 优惠券名称
|
|
||||||
*/
|
|
||||||
private String couponName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 优惠券类型
|
|
||||||
*/
|
|
||||||
private String couponType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 优惠券金额
|
|
||||||
*/
|
|
||||||
private BigDecimal amount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 货币类型
|
|
||||||
*/
|
|
||||||
private String amountCurrency;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户手机号
|
|
||||||
*/
|
|
||||||
private String userPhone;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程优惠券ID
|
|
||||||
*/
|
|
||||||
private String ctripCouponId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单ID
|
|
||||||
*/
|
|
||||||
private String ctripOrderId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 状态:UNUSED-未使用,USED-已使用,EXPIRED-已过期,VOIDED-已作废
|
|
||||||
*/
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 有效期开始时间
|
|
||||||
*/
|
|
||||||
private Date validStartTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 有效期结束时间
|
|
||||||
*/
|
|
||||||
private Date validEndTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用时间
|
|
||||||
*/
|
|
||||||
private Date usedTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用订单号
|
|
||||||
*/
|
|
||||||
private String usedOrderNo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 备注
|
|
||||||
*/
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建人
|
|
||||||
*/
|
|
||||||
private String createBy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新人
|
|
||||||
*/
|
|
||||||
private String updateBy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否删除
|
|
||||||
*/
|
|
||||||
private Integer deleted;
|
|
||||||
}
|
|
||||||
-118
@@ -1,118 +0,0 @@
|
|||||||
package com.central.coupon.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程核销记录实体类
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
@TableName("t_ctrip_consumed")
|
|
||||||
public class CtripConsumed {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键ID
|
|
||||||
*/
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单ID
|
|
||||||
*/
|
|
||||||
@TableField("ota_order_id")
|
|
||||||
private String otaOrderId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 供应商订单ID
|
|
||||||
*/
|
|
||||||
@TableField("supplier_order_id")
|
|
||||||
private String supplierOrderId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 序列号ID
|
|
||||||
*/
|
|
||||||
@TableField("sequence_id")
|
|
||||||
private String sequenceId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商品ID
|
|
||||||
*/
|
|
||||||
@TableField("item_id")
|
|
||||||
private String itemId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用开始日期
|
|
||||||
*/
|
|
||||||
@TableField("use_start_date")
|
|
||||||
private String useStartDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用结束日期
|
|
||||||
*/
|
|
||||||
@TableField("use_end_date")
|
|
||||||
private String useEndDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 总数量
|
|
||||||
*/
|
|
||||||
@TableField("quantity")
|
|
||||||
private Integer quantity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 已使用数量
|
|
||||||
*/
|
|
||||||
@TableField("use_quantity")
|
|
||||||
private Integer useQuantity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 乘客ID列表(JSON格式)
|
|
||||||
*/
|
|
||||||
@TableField("passenger_ids")
|
|
||||||
private String passengerIds;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 凭证ID列表(JSON格式)
|
|
||||||
*/
|
|
||||||
@TableField("voucher_ids")
|
|
||||||
private String voucherIds;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 备注信息
|
|
||||||
*/
|
|
||||||
@TableField("remark")
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 折扣政策列表(JSON格式)
|
|
||||||
*/
|
|
||||||
@TableField("discount_policy")
|
|
||||||
private String discountPolicy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 损失金额
|
|
||||||
*/
|
|
||||||
@TableField("lost_amount")
|
|
||||||
private Integer lostAmount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 损失金额货币类型
|
|
||||||
*/
|
|
||||||
@TableField("lost_amount_currency")
|
|
||||||
private String lostAmountCurrency;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
}
|
|
||||||
-61
@@ -1,61 +0,0 @@
|
|||||||
package com.central.coupon.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程核销乘客表
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
@TableName("t_ctrip_consumed_passenger")
|
|
||||||
public class CtripConsumedPassenger implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键ID
|
|
||||||
*/
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 核销ID
|
|
||||||
*/
|
|
||||||
private Long consumedId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 乘客ID
|
|
||||||
*/
|
|
||||||
private String passengerId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 乘客姓名
|
|
||||||
*/
|
|
||||||
private String passengerName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否删除:0-未删除,1-已删除
|
|
||||||
*/
|
|
||||||
private Integer deleted;
|
|
||||||
}
|
|
||||||
-61
@@ -1,61 +0,0 @@
|
|||||||
package com.central.coupon.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程核销凭证表
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
@TableName("t_ctrip_consumed_voucher")
|
|
||||||
public class CtripConsumedVoucher implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键ID
|
|
||||||
*/
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 核销ID
|
|
||||||
*/
|
|
||||||
private Long consumedId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 凭证编号
|
|
||||||
*/
|
|
||||||
private String voucherId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 凭证码
|
|
||||||
*/
|
|
||||||
private String voucherCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否删除:0-未删除,1-已删除
|
|
||||||
*/
|
|
||||||
private Integer deleted;
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
package com.central.coupon.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程联系人信息表
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
@TableName("t_ctrip_contact")
|
|
||||||
public class CtripContact implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键ID
|
|
||||||
*/
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单ID
|
|
||||||
*/
|
|
||||||
private Long orderId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 联系人姓名
|
|
||||||
*/
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 联系人电话
|
|
||||||
*/
|
|
||||||
private String mobile;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 联系人邮箱
|
|
||||||
*/
|
|
||||||
private String email;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否删除:0-未删除,1-已删除
|
|
||||||
*/
|
|
||||||
private Integer deleted;
|
|
||||||
}
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
package com.central.coupon.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程优惠券信息表
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
@TableName("t_ctrip_coupon")
|
|
||||||
public class CtripCoupon implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键ID
|
|
||||||
*/
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单ID
|
|
||||||
*/
|
|
||||||
private Long orderId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 优惠券类型
|
|
||||||
*/
|
|
||||||
private String couponType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 优惠券代码
|
|
||||||
*/
|
|
||||||
private String couponCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 优惠券名称
|
|
||||||
*/
|
|
||||||
private String couponName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 优惠券金额
|
|
||||||
*/
|
|
||||||
private BigDecimal couponAmount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 货币类型
|
|
||||||
*/
|
|
||||||
private String currency;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 优惠券状态:1-有效,2-已使用,3-已过期
|
|
||||||
*/
|
|
||||||
private Integer couponStatus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用时间
|
|
||||||
*/
|
|
||||||
private LocalDateTime useTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否删除:0-未删除,1-已删除
|
|
||||||
*/
|
|
||||||
private Integer deleted;
|
|
||||||
}
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
package com.central.coupon.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单表
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
@TableName("t_ctrip_order")
|
|
||||||
public class CtripOrder implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键ID
|
|
||||||
*/
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单号
|
|
||||||
*/
|
|
||||||
private String otaOrderId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关联的订单中心订单号
|
|
||||||
*/
|
|
||||||
private String orderNo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 供应商订单号
|
|
||||||
*/
|
|
||||||
private String supplierOrderId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程批次流水号
|
|
||||||
*/
|
|
||||||
private String sequenceId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 确认类型:1-仅通知,2-需确认
|
|
||||||
*/
|
|
||||||
private Integer confirmType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最晚确认时间
|
|
||||||
*/
|
|
||||||
private LocalDateTime orderLastConfirmTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单状态:0-待确认,1-已确认,2-已取消,3-已过期
|
|
||||||
*/
|
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单总金额
|
|
||||||
*/
|
|
||||||
private BigDecimal totalAmount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 货币类型
|
|
||||||
*/
|
|
||||||
private String currency;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建人
|
|
||||||
*/
|
|
||||||
private String createBy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新人
|
|
||||||
*/
|
|
||||||
private String updateBy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 备注
|
|
||||||
*/
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 租户ID
|
|
||||||
*/
|
|
||||||
private String tenantId;
|
|
||||||
}
|
|
||||||
-149
@@ -1,149 +0,0 @@
|
|||||||
package com.central.coupon.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单项表
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
@TableName("t_ctrip_order_item")
|
|
||||||
public class CtripOrderItem implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键ID
|
|
||||||
*/
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单ID
|
|
||||||
*/
|
|
||||||
private Long orderId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单项编号
|
|
||||||
*/
|
|
||||||
@TableField("item_id")
|
|
||||||
private String itemId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单项名称
|
|
||||||
*/
|
|
||||||
private String itemName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单项类型
|
|
||||||
*/
|
|
||||||
private String itemType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PLU编码
|
|
||||||
*/
|
|
||||||
private String plu;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数量
|
|
||||||
*/
|
|
||||||
private Integer quantity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单价
|
|
||||||
*/
|
|
||||||
private BigDecimal unitPrice;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 原价
|
|
||||||
*/
|
|
||||||
private BigDecimal price;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 销售价
|
|
||||||
*/
|
|
||||||
private BigDecimal salePrice;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 总价
|
|
||||||
*/
|
|
||||||
private BigDecimal totalPrice;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 货币类型
|
|
||||||
*/
|
|
||||||
private String currency;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用开始日期
|
|
||||||
*/
|
|
||||||
private LocalDate useStartDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用结束日期
|
|
||||||
*/
|
|
||||||
private LocalDate useEndDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 凭证ID(用于PayPreOrderConfirm)
|
|
||||||
*/
|
|
||||||
private String voucherId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 乘客ID(用于PayPreOrderConfirm)
|
|
||||||
*/
|
|
||||||
private String passengerId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 乘客凭证ID(用于PayPreOrderConfirm,与voucherId不同)
|
|
||||||
*/
|
|
||||||
private String passengerVoucherId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建人
|
|
||||||
*/
|
|
||||||
private String createBy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新人
|
|
||||||
*/
|
|
||||||
private String updateBy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 备注
|
|
||||||
*/
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 租户ID
|
|
||||||
*/
|
|
||||||
private String tenantId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否删除:0-未删除,1-已删除
|
|
||||||
*/
|
|
||||||
private Integer deleted;
|
|
||||||
}
|
|
||||||
-87
@@ -1,87 +0,0 @@
|
|||||||
package com.central.coupon.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程乘客信息表
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
@TableName("t_ctrip_passenger")
|
|
||||||
public class CtripPassenger implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键ID
|
|
||||||
*/
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单ID
|
|
||||||
*/
|
|
||||||
private Long orderId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单项编号
|
|
||||||
*/
|
|
||||||
private String itemId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 乘客ID
|
|
||||||
*/
|
|
||||||
private String passengerId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 乘客姓名
|
|
||||||
*/
|
|
||||||
private String passengerName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 乘客类型:ADULT-成人,CHILD-儿童,INFANT-婴儿
|
|
||||||
*/
|
|
||||||
private String passengerType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 证件类型:ID_CARD-身份证,PASSPORT-护照
|
|
||||||
*/
|
|
||||||
private String idType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 证件号码
|
|
||||||
*/
|
|
||||||
private String idNumber;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 手机号码
|
|
||||||
*/
|
|
||||||
private String phone;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否删除:0-未删除,1-已删除
|
|
||||||
*/
|
|
||||||
private Integer deleted;
|
|
||||||
}
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
package com.central.coupon.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程退款表
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
@TableName("t_ctrip_refund")
|
|
||||||
public class CtripRefund implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键ID
|
|
||||||
*/
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单号
|
|
||||||
*/
|
|
||||||
private String otaOrderId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 供应商订单号
|
|
||||||
*/
|
|
||||||
private String supplierOrderId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程批次流水号
|
|
||||||
*/
|
|
||||||
private String sequenceId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退款金额
|
|
||||||
*/
|
|
||||||
private BigDecimal refundAmount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 货币类型
|
|
||||||
*/
|
|
||||||
private String currency;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退款状态:0-待确认,1-已确认,2-已拒绝
|
|
||||||
*/
|
|
||||||
private Integer refundStatus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 确认结果码
|
|
||||||
*/
|
|
||||||
private String confirmResultCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 确认结果信息
|
|
||||||
*/
|
|
||||||
private String confirmResultMessage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最晚确认时间
|
|
||||||
*/
|
|
||||||
private LocalDateTime lastConfirmTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建人
|
|
||||||
*/
|
|
||||||
private String createBy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新人
|
|
||||||
*/
|
|
||||||
private String updateBy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 备注
|
|
||||||
*/
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 租户ID
|
|
||||||
*/
|
|
||||||
private String tenantId;
|
|
||||||
}
|
|
||||||
-72
@@ -1,72 +0,0 @@
|
|||||||
package com.central.coupon.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程退款项表
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
@TableName("t_ctrip_refund_item")
|
|
||||||
public class CtripRefundItem implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键ID
|
|
||||||
*/
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退款ID
|
|
||||||
*/
|
|
||||||
private Long refundId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单项编号
|
|
||||||
*/
|
|
||||||
private String itemId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 供应商产品最小单位
|
|
||||||
*/
|
|
||||||
private String plu;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退款金额
|
|
||||||
*/
|
|
||||||
private BigDecimal refundAmount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 货币类型
|
|
||||||
*/
|
|
||||||
private String currency;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否删除:0-未删除,1-已删除
|
|
||||||
*/
|
|
||||||
private Integer deleted;
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
package com.central.coupon.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程凭证信息表
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
@TableName("t_ctrip_voucher")
|
|
||||||
public class CtripVoucher implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键ID
|
|
||||||
*/
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单ID
|
|
||||||
*/
|
|
||||||
private Long orderId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单项编号
|
|
||||||
*/
|
|
||||||
private String itemId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 凭证编号
|
|
||||||
*/
|
|
||||||
private String voucherId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 凭证码
|
|
||||||
*/
|
|
||||||
private String voucherCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 凭证类型
|
|
||||||
*/
|
|
||||||
private String voucherType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 凭证状态:1-未使用,2-已使用,3-已过期
|
|
||||||
*/
|
|
||||||
private Integer voucherStatus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用时间
|
|
||||||
*/
|
|
||||||
private LocalDateTime useTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否删除:0-未删除,1-已删除
|
|
||||||
*/
|
|
||||||
private Integer deleted;
|
|
||||||
}
|
|
||||||
-89
@@ -1,89 +0,0 @@
|
|||||||
package com.central.coupon.enums;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单状态枚举
|
|
||||||
* 用于映射数字状态值和字符串状态值
|
|
||||||
*/
|
|
||||||
public enum CtripOrderStatus {
|
|
||||||
|
|
||||||
// 数字状态值 -> 字符串状态值映射
|
|
||||||
PENDING(0, "PENDING", "待确认"),
|
|
||||||
CONFIRMED(1, "CONFIRMED", "已确认"),
|
|
||||||
CANCELLED(2, "CANCELLED", "已取消"),
|
|
||||||
EXPIRED(3, "EXPIRED", "已过期"),
|
|
||||||
PARTIAL_CANCELLED(4, "PARTIAL_CANCELLED", "部分取消"),
|
|
||||||
FULLY_CANCELLED(5, "FULLY_CANCELLED", "全部取消"),
|
|
||||||
PICKED_UP(6, "PICKED_UP", "已取物品"),
|
|
||||||
PARTIAL_USED(7, "PARTIAL_USED", "部分使用"),
|
|
||||||
FULLY_USED(8, "FULLY_USED", "全部使用"),
|
|
||||||
RETURNED(9, "RETURNED", "已还物品"),
|
|
||||||
EXPIRED_AFTER_PAYMENT(10, "EXPIRED_AFTER_PAYMENT", "已过期"),
|
|
||||||
WAITING_PAYMENT(11, "WAITING_PAYMENT", "待支付"),
|
|
||||||
PAYMENT_PENDING(12, "PAYMENT_PENDING", "支付待确认"),
|
|
||||||
PAYMENT_CONFIRMED(13, "PAYMENT_CONFIRMED", "支付已确认"),
|
|
||||||
PRE_ORDER_CANCELLED(14, "PRE_ORDER_CANCELLED", "预下单取消成功"),
|
|
||||||
// 管理后台主动发起退款的状态
|
|
||||||
ADMIN_REFUNDING(15, "ADMIN_REFUNDING", "退款中"),
|
|
||||||
ADMIN_REFUNDED(16, "ADMIN_REFUNDED", "已退款"),
|
|
||||||
ADMIN_PART_REFUNDED(17, "ADMIN_PART_REFUNDED", "部分退款");
|
|
||||||
|
|
||||||
private final int numericValue;
|
|
||||||
private final String stringValue;
|
|
||||||
private final String description;
|
|
||||||
|
|
||||||
CtripOrderStatus(int numericValue, String stringValue, String description) {
|
|
||||||
this.numericValue = numericValue;
|
|
||||||
this.stringValue = stringValue;
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNumericValue() {
|
|
||||||
return numericValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStringValue() {
|
|
||||||
return stringValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据数字值获取状态枚举
|
|
||||||
*/
|
|
||||||
public static CtripOrderStatus fromNumericValue(int numericValue) {
|
|
||||||
for (CtripOrderStatus status : values()) {
|
|
||||||
if (status.numericValue == numericValue) {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new IllegalArgumentException("Unknown numeric status value: " + numericValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据字符串值获取状态枚举
|
|
||||||
*/
|
|
||||||
public static CtripOrderStatus fromStringValue(String stringValue) {
|
|
||||||
for (CtripOrderStatus status : values()) {
|
|
||||||
if (status.stringValue.equals(stringValue)) {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new IllegalArgumentException("Unknown string status value: " + stringValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据数字值获取字符串值
|
|
||||||
*/
|
|
||||||
public static String getStringValue(int numericValue) {
|
|
||||||
return fromNumericValue(numericValue).stringValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据字符串值获取数字值
|
|
||||||
*/
|
|
||||||
public static int getNumericValue(String stringValue) {
|
|
||||||
return fromStringValue(stringValue).numericValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-139
@@ -1,139 +0,0 @@
|
|||||||
package com.central.coupon.exception;
|
|
||||||
|
|
||||||
import com.central.common.model.Result;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
||||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 全局异常处理器
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RestControllerAdvice
|
|
||||||
public class GlobalExceptionHandler {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 优惠券不存在异常
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(CouponNotFoundException.class)
|
|
||||||
public Result<String> handleCouponNotFoundException(CouponNotFoundException e) {
|
|
||||||
log.error("优惠券不存在异常", e);
|
|
||||||
return Result.failed("COUPON_NOT_FOUND", e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 优惠券状态不正确异常
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(CouponInvalidException.class)
|
|
||||||
public Result<String> handleCouponInvalidException(CouponInvalidException e) {
|
|
||||||
log.error("优惠券状态不正确异常", e);
|
|
||||||
return Result.failed("COUPON_INVALID", e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 优惠券已过期异常
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(CouponExpiredException.class)
|
|
||||||
public Result<String> handleCouponExpiredException(CouponExpiredException e) {
|
|
||||||
log.error("优惠券已过期异常", e);
|
|
||||||
return Result.failed("COUPON_EXPIRED", e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 优惠券使用条件不满足异常
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(CouponUsageException.class)
|
|
||||||
public Result<String> handleCouponUsageException(CouponUsageException e) {
|
|
||||||
log.error("优惠券使用条件不满足异常", e);
|
|
||||||
return Result.failed("COUPON_USAGE_ERROR", e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程核销失败异常
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(CouponVerifyException.class)
|
|
||||||
public Result<String> handleCouponVerifyException(CouponVerifyException e) {
|
|
||||||
log.error("携程核销失败异常", e);
|
|
||||||
return Result.failed("COUPON_VERIFY_FAILED", e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 优惠券更新失败异常
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(CouponUpdateException.class)
|
|
||||||
public Result<String> handleCouponUpdateException(CouponUpdateException e) {
|
|
||||||
log.error("优惠券更新失败异常", e);
|
|
||||||
return Result.failed("COUPON_UPDATE_FAILED", e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 参数验证异常
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(IllegalArgumentException.class)
|
|
||||||
public Result<String> handleIllegalArgumentException(IllegalArgumentException e) {
|
|
||||||
log.error("参数验证异常", e);
|
|
||||||
return Result.failed("PARAM_ERROR", e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* HTTP消息读取异常(请求体解析失败)
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(HttpMessageNotReadableException.class)
|
|
||||||
public Result<String> handleHttpMessageNotReadableException(HttpMessageNotReadableException e) {
|
|
||||||
log.error("HTTP消息读取异常,请求体解析失败", e);
|
|
||||||
String errorMessage = "请求体格式错误";
|
|
||||||
if (e.getMessage() != null && e.getMessage().contains("empty String")) {
|
|
||||||
errorMessage = "请求体不能为空,请提供有效的JSON数据";
|
|
||||||
} else if (e.getMessage() != null && e.getMessage().contains("JSON parse error")) {
|
|
||||||
errorMessage = "JSON格式错误,请检查请求体格式";
|
|
||||||
}
|
|
||||||
return Result.failed("REQUEST_BODY_ERROR", errorMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统异常
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(Exception.class)
|
|
||||||
public Result<String> handleException(Exception e) {
|
|
||||||
log.error("系统异常", e);
|
|
||||||
return Result.failed("SYSTEM_ERROR", "系统异常:" + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
// 自定义异常类
|
|
||||||
public static class CouponNotFoundException extends RuntimeException {
|
|
||||||
public CouponNotFoundException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class CouponInvalidException extends RuntimeException {
|
|
||||||
public CouponInvalidException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class CouponExpiredException extends RuntimeException {
|
|
||||||
public CouponExpiredException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class CouponUsageException extends RuntimeException {
|
|
||||||
public CouponUsageException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class CouponVerifyException extends RuntimeException {
|
|
||||||
public CouponVerifyException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class CouponUpdateException extends RuntimeException {
|
|
||||||
public CouponUpdateException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-50
@@ -1,50 +0,0 @@
|
|||||||
package com.central.coupon.feign;
|
|
||||||
|
|
||||||
import com.central.common.constant.ServiceNameConstants;
|
|
||||||
import com.central.common.model.Result;
|
|
||||||
import com.central.coupon.feign.dto.QrCodeInfo;
|
|
||||||
import com.central.coupon.feign.dto.OrderInfo;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@FeignClient(name = ServiceNameConstants.ORDER_SERVICE, dismiss404 = true)
|
|
||||||
public interface OrderCenterService {
|
|
||||||
@GetMapping("/qrcode/{codeId}")
|
|
||||||
Result<QrCodeInfo> getQrCode(@PathVariable("codeId") String codeId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据订单号获取订单信息
|
|
||||||
*/
|
|
||||||
@GetMapping("/order/{orderNo}")
|
|
||||||
Result<OrderInfo> getOrderByOrderNo(@PathVariable("orderNo") String orderNo);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新订单状态为已支付(优惠券核销成功后调用)
|
|
||||||
*/
|
|
||||||
@PostMapping("/order/{orderNo}/status/paid")
|
|
||||||
Result<String> updateOrderStatusToPaid(@PathVariable("orderNo") String orderNo);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新订单状态为退款中
|
|
||||||
*/
|
|
||||||
@PostMapping("/order/{orderNo}/status/refunding")
|
|
||||||
Result<String> updateOrderStatusToRefunding(@PathVariable("orderNo") String orderNo);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新订单状态为已退款
|
|
||||||
*/
|
|
||||||
@PostMapping("/order/{orderNo}/status/refunded")
|
|
||||||
Result<String> updateOrderStatusToRefunded(@PathVariable("orderNo") String orderNo);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建退款记录
|
|
||||||
*/
|
|
||||||
@PostMapping("/refund/ctrip/{orderNo}")
|
|
||||||
Result<String> createCtripRefund(@PathVariable("orderNo") String orderNo, @RequestBody Map<String, Object> refundInfo);
|
|
||||||
}
|
|
||||||
-13
@@ -1,13 +0,0 @@
|
|||||||
package com.central.coupon.feign;
|
|
||||||
|
|
||||||
import com.central.common.constant.ServiceNameConstants;
|
|
||||||
import com.central.coupon.feign.dto.SysUserDTO;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
|
|
||||||
@FeignClient(name = ServiceNameConstants.USER_SERVICE, dismiss404 = true)
|
|
||||||
public interface UserCenterService {
|
|
||||||
@GetMapping("/users/{id}")
|
|
||||||
SysUserDTO findUserById(@PathVariable("id") Long id);
|
|
||||||
}
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
package com.central.coupon.feign.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单信息DTO
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class OrderInfo {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单ID
|
|
||||||
*/
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单号
|
|
||||||
*/
|
|
||||||
private String orderNo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户ID
|
|
||||||
*/
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 景区ID
|
|
||||||
*/
|
|
||||||
private Long tourismId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单金额
|
|
||||||
*/
|
|
||||||
private String orderAmount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单状态
|
|
||||||
*/
|
|
||||||
private Integer orderStatus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付类型(1:微信支付,2:优惠券支付)
|
|
||||||
*/
|
|
||||||
private Integer payType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付时间
|
|
||||||
*/
|
|
||||||
private LocalDateTime payTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 二维码ID
|
|
||||||
*/
|
|
||||||
private String codeId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设备SN
|
|
||||||
*/
|
|
||||||
private String deviceSn;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 租户ID
|
|
||||||
*/
|
|
||||||
private String tenantId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package com.central.coupon.feign.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class QrCodeInfo {
|
|
||||||
private String codeId;
|
|
||||||
private String price;
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package com.central.coupon.feign.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class SysUserDTO {
|
|
||||||
private Long id;
|
|
||||||
private String mobile;
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
package com.central.coupon.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.central.coupon.entity.Coupon;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
import org.apache.ibatis.annotations.Update;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 优惠券Mapper接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface CouponMapper extends BaseMapper<Coupon> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询优惠券列表
|
|
||||||
*/
|
|
||||||
IPage<Coupon> selectCouponPage(Page<Coupon> page, @Param("coupon") Coupon coupon);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据手机号查询用户优惠券
|
|
||||||
*/
|
|
||||||
List<Coupon> selectByUserPhone(@Param("userPhone") String userPhone);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据手机号查询可用优惠券
|
|
||||||
*/
|
|
||||||
List<Coupon> selectAvailableByUserPhone(@Param("userPhone") String userPhone);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据携程优惠券ID查询
|
|
||||||
*/
|
|
||||||
Coupon selectByCtripCouponId(@Param("ctripCouponId") String ctripCouponId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据携程订单ID查询优惠券
|
|
||||||
*/
|
|
||||||
List<Coupon> selectByCtripOrderId(@Param("ctripOrderId") String ctripOrderId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据携程优惠券ID模糊查询优惠券
|
|
||||||
*/
|
|
||||||
List<Coupon> selectByCtripCouponIdLike(@Param("ctripCouponIdPattern") String ctripCouponIdPattern);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据订单号查询使用的优惠券
|
|
||||||
*/
|
|
||||||
Coupon selectByUsedOrderNo(@Param("usedOrderNo") String usedOrderNo);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新优惠券状态为已使用
|
|
||||||
*/
|
|
||||||
int updateCouponUsed(@Param("id") Long id, @Param("usedOrderNo") String usedOrderNo);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量更新过期优惠券状态
|
|
||||||
*/
|
|
||||||
int updateExpiredCoupons();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查用户手机号和携程优惠券ID是否已存在
|
|
||||||
*/
|
|
||||||
int countByUserPhoneAndCtripCouponId(@Param("userPhone") String userPhone, @Param("ctripCouponId") String ctripCouponId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新优惠券状态(避免DateMetaObjectHandler干扰)
|
|
||||||
*
|
|
||||||
* @param id 优惠券ID
|
|
||||||
* @param status 状态
|
|
||||||
* @return 更新结果
|
|
||||||
*/
|
|
||||||
int updateCouponStatus(@Param("id") Long id, @Param("status") String status);
|
|
||||||
}
|
|
||||||
-35
@@ -1,35 +0,0 @@
|
|||||||
package com.central.coupon.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.central.coupon.entity.CtripConsumed;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程核销记录Mapper接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface CtripConsumedMapper extends BaseMapper<CtripConsumed> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据携程订单ID查询核销记录
|
|
||||||
*/
|
|
||||||
List<CtripConsumed> selectByOtaOrderId(@Param("otaOrderId") String otaOrderId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据序列号ID查询核销记录
|
|
||||||
*/
|
|
||||||
CtripConsumed selectBySequenceId(@Param("sequenceId") String sequenceId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据供应商订单ID查询核销记录
|
|
||||||
*/
|
|
||||||
List<CtripConsumed> selectBySupplierOrderId(@Param("supplierOrderId") String supplierOrderId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据商品ID查询核销记录
|
|
||||||
*/
|
|
||||||
List<CtripConsumed> selectByItemId(@Param("itemId") String itemId);
|
|
||||||
}
|
|
||||||
-31
@@ -1,31 +0,0 @@
|
|||||||
package com.central.coupon.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.central.coupon.entity.CtripConsumedPassenger;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程核销乘客Mapper接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface CtripConsumedPassengerMapper extends BaseMapper<CtripConsumedPassenger> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据核销ID查询乘客列表
|
|
||||||
*
|
|
||||||
* @param consumedId 核销ID
|
|
||||||
* @return 乘客列表
|
|
||||||
*/
|
|
||||||
List<CtripConsumedPassenger> selectByConsumedId(@Param("consumedId") Long consumedId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据乘客ID查询核销乘客记录
|
|
||||||
*
|
|
||||||
* @param passengerId 乘客ID
|
|
||||||
* @return 核销乘客记录列表
|
|
||||||
*/
|
|
||||||
List<CtripConsumedPassenger> selectByPassengerId(@Param("passengerId") String passengerId);
|
|
||||||
}
|
|
||||||
-31
@@ -1,31 +0,0 @@
|
|||||||
package com.central.coupon.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.central.coupon.entity.CtripConsumedVoucher;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程核销凭证Mapper接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface CtripConsumedVoucherMapper extends BaseMapper<CtripConsumedVoucher> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据核销ID查询凭证列表
|
|
||||||
*
|
|
||||||
* @param consumedId 核销ID
|
|
||||||
* @return 凭证列表
|
|
||||||
*/
|
|
||||||
List<CtripConsumedVoucher> selectByConsumedId(@Param("consumedId") Long consumedId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据凭证编号查询核销凭证记录
|
|
||||||
*
|
|
||||||
* @param voucherId 凭证编号
|
|
||||||
* @return 核销凭证记录列表
|
|
||||||
*/
|
|
||||||
List<CtripConsumedVoucher> selectByVoucherId(@Param("voucherId") String voucherId);
|
|
||||||
}
|
|
||||||
-31
@@ -1,31 +0,0 @@
|
|||||||
package com.central.coupon.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.central.coupon.entity.CtripContact;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程联系人Mapper接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface CtripContactMapper extends BaseMapper<CtripContact> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据订单ID查询联系人列表
|
|
||||||
*
|
|
||||||
* @param orderId 订单ID
|
|
||||||
* @return 联系人列表
|
|
||||||
*/
|
|
||||||
List<CtripContact> selectByOrderId(@Param("orderId") Long orderId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据手机号查询联系人列表
|
|
||||||
*
|
|
||||||
* @param mobile 手机号
|
|
||||||
* @return 联系人列表
|
|
||||||
*/
|
|
||||||
List<CtripContact> selectByMobile(@Param("mobile") String mobile);
|
|
||||||
}
|
|
||||||
-40
@@ -1,40 +0,0 @@
|
|||||||
package com.central.coupon.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.central.coupon.entity.CtripCoupon;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程优惠券Mapper接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface CtripCouponMapper extends BaseMapper<CtripCoupon> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据订单ID查询优惠券列表
|
|
||||||
*
|
|
||||||
* @param orderId 订单ID
|
|
||||||
* @return 优惠券列表
|
|
||||||
*/
|
|
||||||
List<CtripCoupon> selectByOrderId(@Param("orderId") Long orderId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据优惠券代码查询优惠券
|
|
||||||
*
|
|
||||||
* @param couponCode 优惠券代码
|
|
||||||
* @return 优惠券信息
|
|
||||||
*/
|
|
||||||
CtripCoupon selectByCouponCode(@Param("couponCode") String couponCode);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据订单ID和优惠券状态查询优惠券
|
|
||||||
*
|
|
||||||
* @param orderId 订单ID
|
|
||||||
* @param couponStatus 优惠券状态
|
|
||||||
* @return 优惠券列表
|
|
||||||
*/
|
|
||||||
List<CtripCoupon> selectByOrderIdAndStatus(@Param("orderId") Long orderId, @Param("couponStatus") Integer couponStatus);
|
|
||||||
}
|
|
||||||
-58
@@ -1,58 +0,0 @@
|
|||||||
package com.central.coupon.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.central.coupon.entity.CtripOrderItem;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单项Mapper接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface CtripOrderItemMapper extends BaseMapper<CtripOrderItem> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据订单ID查询订单项列表
|
|
||||||
*
|
|
||||||
* @param orderId 订单ID
|
|
||||||
* @return 订单项列表
|
|
||||||
*/
|
|
||||||
List<CtripOrderItem> selectByOrderId(@Param("orderId") Long orderId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据订单项编号查询订单项
|
|
||||||
*
|
|
||||||
* @param itemId 订单项编号
|
|
||||||
* @return 订单项信息
|
|
||||||
*/
|
|
||||||
CtripOrderItem selectByItemId(@Param("itemId") String itemId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据订单ID和订单项编号查询订单项
|
|
||||||
*
|
|
||||||
* @param orderId 订单ID
|
|
||||||
* @param itemId 订单项编号
|
|
||||||
* @return 订单项信息
|
|
||||||
*/
|
|
||||||
CtripOrderItem selectByOrderIdAndItemId(@Param("orderId") Long orderId, @Param("itemId") String itemId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据携程订单号和订单项编号查询订单项
|
|
||||||
*
|
|
||||||
* @param otaOrderId 携程订单号
|
|
||||||
* @param itemId 订单项编号
|
|
||||||
* @return 订单项信息
|
|
||||||
*/
|
|
||||||
CtripOrderItem selectByOtaOrderIdAndItemId(@Param("otaOrderId") String otaOrderId, @Param("itemId") String itemId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据携程订单号和PLU查询订单项
|
|
||||||
*
|
|
||||||
* @param otaOrderId 携程订单号
|
|
||||||
* @param plu PLU编码
|
|
||||||
* @return 订单项信息
|
|
||||||
*/
|
|
||||||
CtripOrderItem selectByOtaOrderIdAndPlu(@Param("otaOrderId") String otaOrderId, @Param("plu") String plu);
|
|
||||||
}
|
|
||||||
-56
@@ -1,56 +0,0 @@
|
|||||||
package com.central.coupon.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.central.coupon.entity.CtripOrder;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单Mapper接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface CtripOrderMapper extends BaseMapper<CtripOrder> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据携程订单号查询订单
|
|
||||||
*
|
|
||||||
* @param otaOrderId 携程订单号
|
|
||||||
* @return 订单信息
|
|
||||||
*/
|
|
||||||
CtripOrder selectByOtaOrderId(@Param("otaOrderId") String otaOrderId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据订单中心订单号查询携程订单
|
|
||||||
*/
|
|
||||||
CtripOrder selectByOrderNo(@Param("orderNo") String orderNo);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据携程订单号更新订单
|
|
||||||
*/
|
|
||||||
int updateByOtaOrderId(CtripOrder order);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据供应商订单号查询订单
|
|
||||||
*
|
|
||||||
* @param supplierOrderId 供应商订单号
|
|
||||||
* @return 订单信息
|
|
||||||
*/
|
|
||||||
CtripOrder selectBySupplierOrderId(@Param("supplierOrderId") String supplierOrderId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据流水号查询订单
|
|
||||||
*
|
|
||||||
* @param sequenceId 流水号
|
|
||||||
* @return 订单信息
|
|
||||||
*/
|
|
||||||
CtripOrder selectBySequenceId(@Param("sequenceId") String sequenceId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新订单的 order_status 字段
|
|
||||||
*
|
|
||||||
* @param orderId 订单ID
|
|
||||||
* @param orderStatus 订单状态(字符串值)
|
|
||||||
* @return 更新结果
|
|
||||||
*/
|
|
||||||
int updateOrderStatus(@Param("orderId") Long orderId, @Param("orderStatus") String orderStatus);
|
|
||||||
}
|
|
||||||
-47
@@ -1,47 +0,0 @@
|
|||||||
package com.central.coupon.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.central.coupon.entity.CtripPassenger;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程乘客Mapper接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface CtripPassengerMapper extends BaseMapper<CtripPassenger> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据订单ID查询乘客列表
|
|
||||||
*
|
|
||||||
* @param orderId 订单ID
|
|
||||||
* @return 乘客列表
|
|
||||||
*/
|
|
||||||
List<CtripPassenger> selectByOrderId(@Param("orderId") Long orderId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据订单项编号查询乘客列表
|
|
||||||
*
|
|
||||||
* @param itemId 订单项编号
|
|
||||||
* @return 乘客列表
|
|
||||||
*/
|
|
||||||
List<CtripPassenger> selectByItemId(@Param("itemId") String itemId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据乘客ID查询乘客信息
|
|
||||||
*
|
|
||||||
* @param passengerId 乘客ID
|
|
||||||
* @return 乘客信息
|
|
||||||
*/
|
|
||||||
CtripPassenger selectByPassengerId(@Param("passengerId") String passengerId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据手机号查询乘客列表
|
|
||||||
*
|
|
||||||
* @param phone 手机号
|
|
||||||
* @return 乘客列表
|
|
||||||
*/
|
|
||||||
List<CtripPassenger> selectByPhone(@Param("phone") String phone);
|
|
||||||
}
|
|
||||||
-31
@@ -1,31 +0,0 @@
|
|||||||
package com.central.coupon.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.central.coupon.entity.CtripRefundItem;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程退款项Mapper接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface CtripRefundItemMapper extends BaseMapper<CtripRefundItem> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据退款ID查询退款项列表
|
|
||||||
*
|
|
||||||
* @param refundId 退款ID
|
|
||||||
* @return 退款项列表
|
|
||||||
*/
|
|
||||||
List<CtripRefundItem> selectByRefundId(@Param("refundId") Long refundId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据订单项编号查询退款项
|
|
||||||
*
|
|
||||||
* @param itemId 订单项编号
|
|
||||||
* @return 退款项列表
|
|
||||||
*/
|
|
||||||
List<CtripRefundItem> selectByItemId(@Param("itemId") String itemId);
|
|
||||||
}
|
|
||||||
-39
@@ -1,39 +0,0 @@
|
|||||||
package com.central.coupon.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.central.coupon.entity.CtripRefund;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程退款Mapper接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface CtripRefundMapper extends BaseMapper<CtripRefund> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据携程订单号查询退款记录
|
|
||||||
*
|
|
||||||
* @param otaOrderId 携程订单号
|
|
||||||
* @return 退款记录列表
|
|
||||||
*/
|
|
||||||
List<CtripRefund> selectByOtaOrderId(@Param("otaOrderId") String otaOrderId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据供应商订单号查询退款记录
|
|
||||||
*
|
|
||||||
* @param supplierOrderId 供应商订单号
|
|
||||||
* @return 退款记录列表
|
|
||||||
*/
|
|
||||||
List<CtripRefund> selectBySupplierOrderId(@Param("supplierOrderId") String supplierOrderId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据批次流水号查询退款记录
|
|
||||||
*
|
|
||||||
* @param sequenceId 批次流水号
|
|
||||||
* @return 退款记录
|
|
||||||
*/
|
|
||||||
CtripRefund selectBySequenceId(@Param("sequenceId") String sequenceId);
|
|
||||||
}
|
|
||||||
-47
@@ -1,47 +0,0 @@
|
|||||||
package com.central.coupon.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.central.coupon.entity.CtripVoucher;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程凭证Mapper接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface CtripVoucherMapper extends BaseMapper<CtripVoucher> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据订单ID查询凭证列表
|
|
||||||
*
|
|
||||||
* @param orderId 订单ID
|
|
||||||
* @return 凭证列表
|
|
||||||
*/
|
|
||||||
List<CtripVoucher> selectByOrderId(@Param("orderId") Long orderId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据订单项ID查询凭证列表
|
|
||||||
*
|
|
||||||
* @param itemId 订单项ID
|
|
||||||
* @return 凭证列表
|
|
||||||
*/
|
|
||||||
List<CtripVoucher> selectByItemId(@Param("itemId") String itemId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据凭证编号查询凭证
|
|
||||||
*
|
|
||||||
* @param voucherId 凭证编号
|
|
||||||
* @return 凭证信息
|
|
||||||
*/
|
|
||||||
CtripVoucher selectByVoucherId(@Param("voucherId") String voucherId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据凭证码查询凭证
|
|
||||||
*
|
|
||||||
* @param voucherCode 凭证码
|
|
||||||
* @return 凭证信息
|
|
||||||
*/
|
|
||||||
CtripVoucher selectByVoucherCode(@Param("voucherCode") String voucherCode);
|
|
||||||
}
|
|
||||||
-59
@@ -1,59 +0,0 @@
|
|||||||
package com.central.coupon.model;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 管理后台携程退款请求
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class CtripAdminRefundRequest {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单中心订单号
|
|
||||||
*/
|
|
||||||
private String orderNo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退款金额
|
|
||||||
*/
|
|
||||||
private BigDecimal refundAmount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退款原因
|
|
||||||
*/
|
|
||||||
private String refundReason;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退款项列表(可选)
|
|
||||||
*/
|
|
||||||
private List<RefundItem> items;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退款项
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public static class RefundItem {
|
|
||||||
/**
|
|
||||||
* 订单项编号
|
|
||||||
*/
|
|
||||||
private String itemId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PLU编码
|
|
||||||
*/
|
|
||||||
private String plu;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退款金额
|
|
||||||
*/
|
|
||||||
private BigDecimal amount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 货币类型
|
|
||||||
*/
|
|
||||||
private String amountCurrency;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-87
@@ -1,87 +0,0 @@
|
|||||||
package com.central.coupon.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 CtripCancelOrderConfirmRequest {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求头
|
|
||||||
*/
|
|
||||||
@JsonProperty("header")
|
|
||||||
private CtripHeader header;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求体 - 可能是加密字符串或JSON对象
|
|
||||||
*/
|
|
||||||
@JsonProperty("body")
|
|
||||||
private Object body;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程请求头
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public static class CtripHeader {
|
|
||||||
@JsonProperty("accountId")
|
|
||||||
private String accountId; // 供应商帐号,由携程分配
|
|
||||||
@JsonProperty("serviceName")
|
|
||||||
private String serviceName; // 接口名称: CancelOrderConfirm
|
|
||||||
@JsonProperty("requestTime")
|
|
||||||
private String requestTime; // 请求时间(格式: yyyy-MM-dd HH:mm:ss)
|
|
||||||
@JsonProperty("version")
|
|
||||||
private String version; // 版本号, 1.0
|
|
||||||
@JsonProperty("sign")
|
|
||||||
private String sign; // 签名
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单取消确认体
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public static class CtripCancelOrderConfirmBody {
|
|
||||||
@JsonProperty("sequenceId")
|
|
||||||
private String sequenceId; // 供应商处理批次流水号
|
|
||||||
@JsonProperty("otaOrderId")
|
|
||||||
private String otaOrderId; // 携程订单号
|
|
||||||
@JsonProperty("supplierOrderId")
|
|
||||||
private String supplierOrderId; // 供应商订单号
|
|
||||||
@JsonProperty("confirmResultCode")
|
|
||||||
private String confirmResultCode; // 确认结果返回码
|
|
||||||
@JsonProperty("confirmResultMessage")
|
|
||||||
private String confirmResultMessage; // 确认结果信息
|
|
||||||
@JsonProperty("items")
|
|
||||||
private List<CtripCancelOrderConfirmItem> items; // 订单项节点
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单取消确认项
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public static class CtripCancelOrderConfirmItem {
|
|
||||||
@JsonProperty("itemId")
|
|
||||||
private String itemId; // 订单项编号
|
|
||||||
@JsonProperty("vouchers")
|
|
||||||
private List<CtripVoucher> vouchers; // 已取消的凭证
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程凭证
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public static class CtripVoucher {
|
|
||||||
@JsonProperty("voucherId")
|
|
||||||
private String voucherId; // 凭证编号
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-34
@@ -1,34 +0,0 @@
|
|||||||
package com.central.coupon.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单取消确认响应
|
|
||||||
* 不接受同批次的取消推送多次不同操作(接受、拒绝)结果给到携程
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public class CtripCancelOrderConfirmResponse {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回头
|
|
||||||
*/
|
|
||||||
@JsonProperty("header")
|
|
||||||
private CtripResponseHeader header;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程返回头
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public static class CtripResponseHeader {
|
|
||||||
@JsonProperty("resultCode")
|
|
||||||
private String resultCode; // 处理结果返回码
|
|
||||||
@JsonProperty("resultMessage")
|
|
||||||
private String resultMessage; // 处理结果返回信息
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-85
@@ -1,85 +0,0 @@
|
|||||||
package com.central.coupon.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程取消订单请求模型
|
|
||||||
* 参考文档: https://open.trip.com/apiplatform/order.jsp#operation/CancelOrder
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public class CtripCancelOrderRequest {
|
|
||||||
|
|
||||||
@JsonProperty("header")
|
|
||||||
private CtripHeader header;
|
|
||||||
|
|
||||||
@JsonProperty("body")
|
|
||||||
private String body; // 加密的请求体
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public static class CtripHeader {
|
|
||||||
@JsonProperty("accountId")
|
|
||||||
private String accountId;
|
|
||||||
|
|
||||||
@JsonProperty("serviceName")
|
|
||||||
private String serviceName;
|
|
||||||
|
|
||||||
@JsonProperty("requestTime")
|
|
||||||
private String requestTime;
|
|
||||||
|
|
||||||
@JsonProperty("version")
|
|
||||||
private String version;
|
|
||||||
|
|
||||||
@JsonProperty("sign")
|
|
||||||
private String sign;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public static class CtripCancelOrderBody {
|
|
||||||
@JsonProperty("sequenceId")
|
|
||||||
private String sequenceId; // 携程处理批次流水号
|
|
||||||
|
|
||||||
@JsonProperty("otaOrderId")
|
|
||||||
private String otaOrderId; // 携程订单号
|
|
||||||
|
|
||||||
@JsonProperty("supplierOrderId")
|
|
||||||
private String supplierOrderId; // 供应商订单号
|
|
||||||
|
|
||||||
@JsonProperty("cancelReason")
|
|
||||||
private String cancelReason; // 取消原因
|
|
||||||
|
|
||||||
@JsonProperty("confirmType")
|
|
||||||
private Integer confirmType; // 确认类型:1-仅通知,2-供应商确认
|
|
||||||
|
|
||||||
@JsonProperty("items")
|
|
||||||
private List<CtripCancelOrderItem> items; // 取消的订单项列表
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public static class CtripCancelOrderItem {
|
|
||||||
@JsonProperty("itemId")
|
|
||||||
private String itemId; // 订单项ID
|
|
||||||
|
|
||||||
@JsonProperty("cancelQuantity")
|
|
||||||
private Integer cancelQuantity; // 取消数量
|
|
||||||
|
|
||||||
@JsonProperty("PLU")
|
|
||||||
private String plu; // 供应商产品最小单位
|
|
||||||
|
|
||||||
@JsonProperty("lastConfirmTime")
|
|
||||||
private String lastConfirmTime; // 最后确认时间
|
|
||||||
|
|
||||||
@JsonProperty("quantity")
|
|
||||||
private Integer quantity; // 数量
|
|
||||||
|
|
||||||
@JsonProperty("cancelType")
|
|
||||||
private Integer cancelType; // 取消类型
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-92
@@ -1,92 +0,0 @@
|
|||||||
package com.central.coupon.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程取消订单响应模型
|
|
||||||
* 参考文档: https://open.trip.com/apiplatform/order.jsp#operation/CancelOrder
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class CtripCancelOrderResponse {
|
|
||||||
|
|
||||||
@JsonProperty("header")
|
|
||||||
private CtripResponseHeader header;
|
|
||||||
|
|
||||||
@JsonProperty("body")
|
|
||||||
private String body; // 加密的响应体
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripResponseHeader {
|
|
||||||
@JsonProperty("resultCode")
|
|
||||||
private String resultCode;
|
|
||||||
|
|
||||||
@JsonProperty("resultMessage")
|
|
||||||
private String resultMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripCancelOrderResponseBody {
|
|
||||||
@JsonProperty("otaOrderId")
|
|
||||||
private String otaOrderId; // 携程订单号
|
|
||||||
|
|
||||||
@JsonProperty("supplierOrderId")
|
|
||||||
private String supplierOrderId; // 供应商订单号
|
|
||||||
|
|
||||||
@JsonProperty("supplierConfirmType")
|
|
||||||
private Integer supplierConfirmType; // 供应商确认类型:1-确认,2-拒绝
|
|
||||||
|
|
||||||
@JsonProperty("items")
|
|
||||||
private List<CtripCancelOrderResponseItem> items; // 订单项列表
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripCancelOrderResponseItem {
|
|
||||||
@JsonProperty("itemId")
|
|
||||||
private String itemId; // 订单项ID
|
|
||||||
|
|
||||||
@JsonProperty("useStartDate")
|
|
||||||
private String useStartDate; // 使用开始日期
|
|
||||||
|
|
||||||
@JsonProperty("useEndDate")
|
|
||||||
private String useEndDate; // 使用结束日期
|
|
||||||
|
|
||||||
@JsonProperty("orderStatus")
|
|
||||||
private Integer orderStatus; // 订单状态:10-已取消
|
|
||||||
|
|
||||||
@JsonProperty("quantity")
|
|
||||||
private Integer quantity; // 总数量
|
|
||||||
|
|
||||||
@JsonProperty("useQuantity")
|
|
||||||
private Integer useQuantity; // 已使用数量
|
|
||||||
|
|
||||||
@JsonProperty("cancelQuantity")
|
|
||||||
private Integer cancelQuantity; // 取消数量
|
|
||||||
|
|
||||||
@JsonProperty("passengers")
|
|
||||||
private List<CtripPassenger> passengers; // 乘客信息
|
|
||||||
|
|
||||||
@JsonProperty("vouchers")
|
|
||||||
private List<CtripVoucher> vouchers; // 凭证信息
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripPassenger {
|
|
||||||
@JsonProperty("passengerId")
|
|
||||||
private String passengerId; // 乘客ID
|
|
||||||
|
|
||||||
@JsonProperty("passengerStatus")
|
|
||||||
private Integer passengerStatus; // 乘客状态:2-已取消
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripVoucher {
|
|
||||||
@JsonProperty("voucherId")
|
|
||||||
private String voucherId; // 凭证ID
|
|
||||||
|
|
||||||
@JsonProperty("voucherStatus")
|
|
||||||
private Integer voucherStatus; // 凭证状态:2-已取消
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-70
@@ -1,70 +0,0 @@
|
|||||||
package com.central.coupon.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程取消预下单请求模型
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class CtripCancelPreOrderRequest {
|
|
||||||
|
|
||||||
@JsonProperty("header")
|
|
||||||
private CtripHeader header;
|
|
||||||
|
|
||||||
@JsonProperty("body")
|
|
||||||
private String body; // 加密的请求体
|
|
||||||
|
|
||||||
@JsonProperty("originalEncryptedBody")
|
|
||||||
private String originalEncryptedBody; // 原始加密体,用于签名验证
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripHeader {
|
|
||||||
@JsonProperty("accountId")
|
|
||||||
private String accountId;
|
|
||||||
|
|
||||||
@JsonProperty("serviceName")
|
|
||||||
private String serviceName;
|
|
||||||
|
|
||||||
@JsonProperty("requestTime")
|
|
||||||
private String requestTime;
|
|
||||||
|
|
||||||
@JsonProperty("version")
|
|
||||||
private String version;
|
|
||||||
|
|
||||||
@JsonProperty("sign")
|
|
||||||
private String sign;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripCancelPreOrderBody {
|
|
||||||
@JsonProperty("sequenceId")
|
|
||||||
private String sequenceId;
|
|
||||||
|
|
||||||
@JsonProperty("otaOrderId")
|
|
||||||
private String otaOrderId;
|
|
||||||
|
|
||||||
@JsonProperty("supplierOrderId")
|
|
||||||
private String supplierOrderId;
|
|
||||||
|
|
||||||
@JsonProperty("cancelReason")
|
|
||||||
private String cancelReason;
|
|
||||||
|
|
||||||
@JsonProperty("items")
|
|
||||||
private List<CtripCancelPreOrderItem> items;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripCancelPreOrderItem {
|
|
||||||
@JsonProperty("itemId")
|
|
||||||
private String itemId;
|
|
||||||
|
|
||||||
@JsonProperty("cancelQuantity")
|
|
||||||
private Integer cancelQuantity;
|
|
||||||
|
|
||||||
@JsonProperty("cancelReason")
|
|
||||||
private String cancelReason;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-88
@@ -1,88 +0,0 @@
|
|||||||
package com.central.coupon.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程取消预下单响应模型(与QueryOrder响应格式相同)
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class CtripCancelPreOrderResponse {
|
|
||||||
|
|
||||||
@JsonProperty("header")
|
|
||||||
private CtripResponseHeader header;
|
|
||||||
|
|
||||||
@JsonProperty("body")
|
|
||||||
private String body; // 加密的响应体
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripResponseHeader {
|
|
||||||
@JsonProperty("resultCode")
|
|
||||||
private String resultCode;
|
|
||||||
|
|
||||||
@JsonProperty("resultMessage")
|
|
||||||
private String resultMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripCancelPreOrderResponseBody {
|
|
||||||
@JsonProperty("otaOrderId")
|
|
||||||
private String otaOrderId;
|
|
||||||
|
|
||||||
@JsonProperty("supplierOrderId")
|
|
||||||
private String supplierOrderId;
|
|
||||||
|
|
||||||
@JsonProperty("items")
|
|
||||||
private List<CtripCancelPreOrderResponseItem> items;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripCancelPreOrderResponseItem {
|
|
||||||
@JsonProperty("itemId")
|
|
||||||
private String itemId;
|
|
||||||
|
|
||||||
@JsonProperty("useStartDate")
|
|
||||||
private String useStartDate;
|
|
||||||
|
|
||||||
@JsonProperty("useEndDate")
|
|
||||||
private String useEndDate;
|
|
||||||
|
|
||||||
@JsonProperty("orderStatus")
|
|
||||||
private Integer orderStatus;
|
|
||||||
|
|
||||||
@JsonProperty("quantity")
|
|
||||||
private Integer quantity;
|
|
||||||
|
|
||||||
@JsonProperty("useQuantity")
|
|
||||||
private Integer useQuantity;
|
|
||||||
|
|
||||||
@JsonProperty("cancelQuantity")
|
|
||||||
private Integer cancelQuantity;
|
|
||||||
|
|
||||||
@JsonProperty("passengers")
|
|
||||||
private List<CtripPassenger> passengers;
|
|
||||||
|
|
||||||
@JsonProperty("vouchers")
|
|
||||||
private List<CtripVoucher> vouchers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripPassenger {
|
|
||||||
@JsonProperty("passengerId")
|
|
||||||
private String passengerId;
|
|
||||||
|
|
||||||
@JsonProperty("passengerStatus")
|
|
||||||
private Integer passengerStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripVoucher {
|
|
||||||
@JsonProperty("voucherId")
|
|
||||||
private String voucherId;
|
|
||||||
|
|
||||||
@JsonProperty("voucherStatus")
|
|
||||||
private Integer voucherStatus;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-126
@@ -1,126 +0,0 @@
|
|||||||
package com.central.coupon.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单核销通知请求
|
|
||||||
* 当订单在新订确认后,供应商可将客人出行后的使用情况或归还物品等信息调用该接口将对应的最终结果同步给携程系统
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class CtripConsumedNoticeRequest {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程请求头
|
|
||||||
*/
|
|
||||||
@JsonProperty("header")
|
|
||||||
private CtripHeader header;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程请求体
|
|
||||||
*/
|
|
||||||
@JsonProperty("body")
|
|
||||||
private CtripConsumedNoticeBody body;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程请求头
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public static class CtripHeader {
|
|
||||||
@JsonProperty("accountId")
|
|
||||||
private String accountId;
|
|
||||||
@JsonProperty("serviceName")
|
|
||||||
private String serviceName;
|
|
||||||
@JsonProperty("requestTime")
|
|
||||||
private String requestTime;
|
|
||||||
@JsonProperty("version")
|
|
||||||
private String version;
|
|
||||||
@JsonProperty("sign")
|
|
||||||
private String sign;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程核销通知体
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public static class CtripConsumedNoticeBody {
|
|
||||||
@JsonProperty("sequenceId")
|
|
||||||
private String sequenceId;
|
|
||||||
@JsonProperty("otaOrderId")
|
|
||||||
private String otaOrderId;
|
|
||||||
@JsonProperty("supplierOrderId")
|
|
||||||
private String supplierOrderId;
|
|
||||||
@JsonProperty("items")
|
|
||||||
private List<CtripConsumedNoticeItem> items;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程核销通知项
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public static class CtripConsumedNoticeItem {
|
|
||||||
@JsonProperty("itemId")
|
|
||||||
private String itemId;
|
|
||||||
@JsonProperty("useStartDate")
|
|
||||||
private String useStartDate;
|
|
||||||
@JsonProperty("useEndDate")
|
|
||||||
private String useEndDate;
|
|
||||||
@JsonProperty("quantity")
|
|
||||||
private Integer quantity;
|
|
||||||
@JsonProperty("useQuantity")
|
|
||||||
private Integer useQuantity;
|
|
||||||
@JsonProperty("passengers")
|
|
||||||
private List<CtripConsumedPassenger> passengers;
|
|
||||||
@JsonProperty("vouchers")
|
|
||||||
private List<CtripConsumedVoucher> vouchers;
|
|
||||||
@JsonProperty("remark")
|
|
||||||
private String remark;
|
|
||||||
@JsonProperty("discount")
|
|
||||||
private CtripDiscount discount;
|
|
||||||
@JsonProperty("lostAmount")
|
|
||||||
private BigDecimal lostAmount;
|
|
||||||
@JsonProperty("lostAmountCurrency")
|
|
||||||
private String lostAmountCurrency;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程核销乘客
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public static class CtripConsumedPassenger {
|
|
||||||
@JsonProperty("passengerId")
|
|
||||||
private String passengerId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程核销凭证
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public static class CtripConsumedVoucher {
|
|
||||||
@JsonProperty("voucherId")
|
|
||||||
private String voucherId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程折扣信息
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public static class CtripDiscount {
|
|
||||||
@JsonProperty("policyList")
|
|
||||||
private List<CtripDiscountPolicy> policyList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程折扣政策
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public static class CtripDiscountPolicy {
|
|
||||||
@JsonProperty("date")
|
|
||||||
private String date;
|
|
||||||
@JsonProperty("quantity")
|
|
||||||
private Integer quantity;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-24
@@ -1,24 +0,0 @@
|
|||||||
package com.central.coupon.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程核销优惠券通知接口响应模型
|
|
||||||
* 参考文档:https://open.trip.com/apiplatform/order.jsp#operation/OrderConsumedNotice
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class CtripConsumedNoticeResponse {
|
|
||||||
|
|
||||||
@JsonProperty("header")
|
|
||||||
private CtripResponseHeader header;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripResponseHeader {
|
|
||||||
@JsonProperty("resultCode")
|
|
||||||
private String resultCode;
|
|
||||||
|
|
||||||
@JsonProperty("resultMessage")
|
|
||||||
private String resultMessage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-68
@@ -1,68 +0,0 @@
|
|||||||
package com.central.coupon.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程优惠券接口响应
|
|
||||||
* 供应商在收到携程的优惠券请求时的标准响应格式
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public class CtripCouponResponse {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回头
|
|
||||||
*/
|
|
||||||
@JsonProperty("header")
|
|
||||||
private CtripResponseHeader header;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回体(传输时该字段需要AES加密)
|
|
||||||
* 该节点在返回码为0000时必填,其他均为非必填
|
|
||||||
* 可以是CtripCouponResponseBody对象或加密后的字符串
|
|
||||||
*/
|
|
||||||
@JsonProperty("body")
|
|
||||||
private Object body;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程返回头
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public static class CtripResponseHeader {
|
|
||||||
@JsonProperty("resultCode")
|
|
||||||
private String resultCode; // 处理结果返回码
|
|
||||||
@JsonProperty("resultMessage")
|
|
||||||
private String resultMessage; // 处理结果返回信息
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程优惠券返回体
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public static class CtripCouponResponseBody {
|
|
||||||
@JsonProperty("otaOrderId")
|
|
||||||
private String otaOrderId; // 携程订单ID
|
|
||||||
@JsonProperty("supplierOrderId")
|
|
||||||
private String supplierOrderId; // 供应商订单ID
|
|
||||||
@JsonProperty("ctripCouponId")
|
|
||||||
private String ctripCouponId; // 携程优惠券ID
|
|
||||||
@JsonProperty("userPhone")
|
|
||||||
private String userPhone; // 用户手机号
|
|
||||||
@JsonProperty("couponName")
|
|
||||||
private String couponName; // 优惠券名称
|
|
||||||
@JsonProperty("couponType")
|
|
||||||
private String couponType; // 优惠券类型
|
|
||||||
@JsonProperty("amount")
|
|
||||||
private java.math.BigDecimal amount; // 优惠券金额
|
|
||||||
@JsonProperty("status")
|
|
||||||
private String status; // 优惠券状态
|
|
||||||
@JsonProperty("validStartTime")
|
|
||||||
private java.util.Date validStartTime; // 有效期开始时间
|
|
||||||
@JsonProperty("validEndTime")
|
|
||||||
private java.util.Date validEndTime; // 有效期结束时间
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-270
@@ -1,270 +0,0 @@
|
|||||||
package com.central.coupon.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单新订请求
|
|
||||||
* 当客人在携程平台进行订单预定后,携程会通过该接口向供应商系统提交客人的预定信息来完成订单预定
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public class CtripCreateOrderRequest {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求头
|
|
||||||
*/
|
|
||||||
@JsonProperty("header")
|
|
||||||
private CtripHeader header;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求体 - 可能是加密字符串或JSON对象
|
|
||||||
*/
|
|
||||||
@JsonProperty("body")
|
|
||||||
private Object body; // 改为Object类型,支持字符串和对象两种格式
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程请求头
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public static class CtripHeader {
|
|
||||||
@JsonProperty("accountId")
|
|
||||||
private String accountId; // 供应商帐号,由携程分配
|
|
||||||
@JsonProperty("serviceName")
|
|
||||||
private String serviceName; // 接口名称: CreatePreOrder
|
|
||||||
@JsonProperty("requestTime")
|
|
||||||
private String requestTime; // 请求时间(格式: yyyy-MM-dd HH:mm:ss)
|
|
||||||
@JsonProperty("version")
|
|
||||||
private String version; // 版本号, 1.0
|
|
||||||
@JsonProperty("sign")
|
|
||||||
private String sign; // 签名
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单体
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public static class CtripOrderBody {
|
|
||||||
@JsonProperty("sequenceId")
|
|
||||||
private String sequenceId; // 携程处理批次流水号。格式为处理日期(yyyyMMdd)+32位去分隔符的Guid
|
|
||||||
@JsonProperty("otaOrderId")
|
|
||||||
private String otaOrderId; // 携程订单号
|
|
||||||
@JsonProperty("confirmType")
|
|
||||||
private Integer confirmType; // 确认类型:1-仅通知供应商订单操作,2-供应商系统确认
|
|
||||||
@JsonProperty("orderLastConfirmTime")
|
|
||||||
private String orderLastConfirmTime; // 供应商最晚确认时间,格式:yyyy-MM-dd hh:mm:ss
|
|
||||||
@JsonProperty("contacts")
|
|
||||||
private List<CtripContact> contacts; // 联系人节点,为此笔订单联系人,并非实际出行人
|
|
||||||
@JsonProperty("coupons")
|
|
||||||
private List<CtripCoupon> coupons; // 优惠信息节点
|
|
||||||
@JsonProperty("items")
|
|
||||||
private List<CtripOrderItem> items; // 订单项节点
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单项
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public static class CtripOrderItem {
|
|
||||||
@JsonProperty("itemId")
|
|
||||||
private String itemId; // 订单项编号
|
|
||||||
@JsonProperty("openId")
|
|
||||||
private String openId; // 用户对外标识
|
|
||||||
@JsonProperty("PLU")
|
|
||||||
private String PLU; // 供应商产品最小单位
|
|
||||||
@JsonProperty("locale")
|
|
||||||
private String locale; // 语言-地区
|
|
||||||
@JsonProperty("distributionChannel")
|
|
||||||
private String distributionChannel; // 销售渠道
|
|
||||||
@JsonProperty("useStartDate")
|
|
||||||
private String useStartDate; // 使用日期
|
|
||||||
@JsonProperty("useEndDate")
|
|
||||||
private String useEndDate; // 最晚可使用日期
|
|
||||||
@JsonProperty("lastConfirmTime")
|
|
||||||
private String lastConfirmTime; // 供应商最晚确认时间(已废弃)
|
|
||||||
@JsonProperty("remark")
|
|
||||||
private String remark; // 备注信息
|
|
||||||
@JsonProperty("price")
|
|
||||||
private BigDecimal price; // 单位客人实付金额
|
|
||||||
@JsonProperty("priceCurrency")
|
|
||||||
private String priceCurrency; // 客人实付金额币种
|
|
||||||
@JsonProperty("salePrice")
|
|
||||||
private BigDecimal salePrice; // 单价卖价
|
|
||||||
@JsonProperty("salePriceCurrency")
|
|
||||||
private String salePriceCurrency; // 单位卖价币种
|
|
||||||
@JsonProperty("cost")
|
|
||||||
private BigDecimal cost; // 单价结算价
|
|
||||||
@JsonProperty("costCurrency")
|
|
||||||
private String costCurrency; // 单价结算价单位
|
|
||||||
@JsonProperty("suggestedPrice")
|
|
||||||
private BigDecimal suggestedPrice; // 供应商建议携程卖价
|
|
||||||
@JsonProperty("suggestedPriceCurrency")
|
|
||||||
private String suggestedPriceCurrency; // 供应商建议携程卖价单位
|
|
||||||
@JsonProperty("quantity")
|
|
||||||
private Integer quantity; // 订单数量
|
|
||||||
@JsonProperty("passengers")
|
|
||||||
private List<CtripPassenger> passengers; // 乘客信息
|
|
||||||
@JsonProperty("adjunctions")
|
|
||||||
private List<CtripAdjunction> adjunctions; // 附加信息
|
|
||||||
@JsonProperty("deposit")
|
|
||||||
private CtripDeposit deposit; // 押金信息
|
|
||||||
@JsonProperty("expressDelivery")
|
|
||||||
private CtripExpressDelivery expressDelivery; // 快递信息
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程乘客信息
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public static class CtripPassenger {
|
|
||||||
@JsonProperty("passengerId")
|
|
||||||
private String passengerId; // 出行人编号
|
|
||||||
@JsonProperty("name")
|
|
||||||
private String name; // 姓名
|
|
||||||
@JsonProperty("firstName")
|
|
||||||
private String firstName; // 拼音或英文名
|
|
||||||
@JsonProperty("lastName")
|
|
||||||
private String lastName; // 拼音或英文姓
|
|
||||||
@JsonProperty("mobile")
|
|
||||||
private String mobile; // 手机号码/国际电话号码
|
|
||||||
@JsonProperty("intlCode")
|
|
||||||
private String intlCode; // 国际标准电话区号
|
|
||||||
@JsonProperty("cardType")
|
|
||||||
private String cardType; // 证件类型
|
|
||||||
@JsonProperty("cardNo")
|
|
||||||
private String cardNo; // 证件号
|
|
||||||
@JsonProperty("birthDate")
|
|
||||||
private String birthDate; // 生日
|
|
||||||
@JsonProperty("ageType")
|
|
||||||
private String ageType; // 年龄类型:ADU-成人,CHI-儿童,BAB-婴儿
|
|
||||||
@JsonProperty("gender")
|
|
||||||
private String gender; // 性别:M-男,F-女
|
|
||||||
@JsonProperty("nationalityCode")
|
|
||||||
private String nationalityCode; // 国籍代码
|
|
||||||
@JsonProperty("nationalityName")
|
|
||||||
private String nationalityName; // 国籍名称
|
|
||||||
@JsonProperty("cardIssueCountry")
|
|
||||||
private String cardIssueCountry; // 证件签发国
|
|
||||||
@JsonProperty("cardIssuePlace")
|
|
||||||
private String cardIssuePlace; // 证件签发地
|
|
||||||
@JsonProperty("cardIssueDate")
|
|
||||||
private String cardIssueDate; // 证件签发日期
|
|
||||||
@JsonProperty("cardValidDate")
|
|
||||||
private String cardValidDate; // 证件有效期
|
|
||||||
@JsonProperty("cardIssueNumber")
|
|
||||||
private Integer cardIssueNumber; // 证件签发次数
|
|
||||||
@JsonProperty("birthPlace")
|
|
||||||
private String birthPlace; // 出生地
|
|
||||||
@JsonProperty("height")
|
|
||||||
private Integer height; // 身高
|
|
||||||
@JsonProperty("weight")
|
|
||||||
private Integer weight; // 体重
|
|
||||||
@JsonProperty("myopiaDegreeL")
|
|
||||||
private Integer myopiaDegreeL; // 左眼近视度数
|
|
||||||
@JsonProperty("myopiaDegreeR")
|
|
||||||
private Integer myopiaDegreeR; // 右眼近视度数
|
|
||||||
@JsonProperty("shoeSize")
|
|
||||||
private Integer shoeSize; // 鞋码
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程联系人信息
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public static class CtripContact {
|
|
||||||
@JsonProperty("name")
|
|
||||||
private String name; // 姓名
|
|
||||||
@JsonProperty("mobile")
|
|
||||||
private String mobile; // 手机号码/国际电话号码
|
|
||||||
@JsonProperty("intlCode")
|
|
||||||
private String intlCode; // 国际标准电话区号
|
|
||||||
@JsonProperty("optionalMobile")
|
|
||||||
private String optionalMobile; // 备选的手机号码/国际电话号码
|
|
||||||
@JsonProperty("optionalIntlCode")
|
|
||||||
private String optionalIntlCode; // 备选的国际标准电话区号
|
|
||||||
@JsonProperty("email")
|
|
||||||
private String email; // 邮箱地址
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程优惠券信息
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public static class CtripCoupon {
|
|
||||||
@JsonProperty("type")
|
|
||||||
private Integer type; // 优惠券源类型:1-携程,2-供应商
|
|
||||||
@JsonProperty("code")
|
|
||||||
private String code; // 优惠券编码
|
|
||||||
@JsonProperty("name")
|
|
||||||
private String name; // 优惠券名称
|
|
||||||
@JsonProperty("amount")
|
|
||||||
private BigDecimal amount; // 优惠券金额
|
|
||||||
@JsonProperty("amountCurrency")
|
|
||||||
private String amountCurrency; // 优惠券金额单位
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程附加信息
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public static class CtripAdjunction {
|
|
||||||
@JsonProperty("name")
|
|
||||||
private String name; // 名称
|
|
||||||
@JsonProperty("nameCode")
|
|
||||||
private String nameCode; // 名称编码(系统标识)
|
|
||||||
@JsonProperty("content")
|
|
||||||
private String content; // 内容
|
|
||||||
@JsonProperty("contentCode")
|
|
||||||
private String contentCode; // 内容编码(系统标识)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程押金信息
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public static class CtripDeposit {
|
|
||||||
@JsonProperty("type")
|
|
||||||
private Integer type; // 押金/保证金类型:1-网站预付,2-景区现付
|
|
||||||
@JsonProperty("amount")
|
|
||||||
private BigDecimal amount; // 押金/保证金金额
|
|
||||||
@JsonProperty("amountCurrency")
|
|
||||||
private String amountCurrency; // 押金/保证金单位
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程快递信息
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public static class CtripExpressDelivery {
|
|
||||||
@JsonProperty("type")
|
|
||||||
private String type; // 配送类型:1-客人自提,2-供应商配送
|
|
||||||
@JsonProperty("name")
|
|
||||||
private String name; // 中文或英文姓名
|
|
||||||
@JsonProperty("mobile")
|
|
||||||
private String mobile; // 手机号码/国际电话号码
|
|
||||||
@JsonProperty("intlCode")
|
|
||||||
private String intlCode; // 国际标准电话区号
|
|
||||||
@JsonProperty("country")
|
|
||||||
private String country; // 国家
|
|
||||||
@JsonProperty("province")
|
|
||||||
private String province; // 省/直辖市
|
|
||||||
@JsonProperty("city")
|
|
||||||
private String city; // 市
|
|
||||||
@JsonProperty("district")
|
|
||||||
private String district; // 县/区
|
|
||||||
@JsonProperty("address")
|
|
||||||
private String address; // 详细地址
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-109
@@ -1,109 +0,0 @@
|
|||||||
package com.central.coupon.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单新订响应模型
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class CtripCreateOrderResponse {
|
|
||||||
|
|
||||||
@JsonProperty("header")
|
|
||||||
private CtripResponseHeader header;
|
|
||||||
|
|
||||||
@JsonProperty("body")
|
|
||||||
private String body; // 加密的响应体
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripResponseHeader {
|
|
||||||
@JsonProperty("resultCode")
|
|
||||||
private String resultCode;
|
|
||||||
|
|
||||||
@JsonProperty("resultMessage")
|
|
||||||
private String resultMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
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
|
|
||||||
public static class CtripVoucher {
|
|
||||||
@JsonProperty("itemId")
|
|
||||||
private String itemId;
|
|
||||||
|
|
||||||
@JsonProperty("voucherId")
|
|
||||||
private String voucherId;
|
|
||||||
|
|
||||||
@JsonProperty("voucherType")
|
|
||||||
private Integer voucherType;
|
|
||||||
|
|
||||||
@JsonProperty("voucherCode")
|
|
||||||
private String voucherCode;
|
|
||||||
|
|
||||||
@JsonProperty("voucherData")
|
|
||||||
private String voucherData;
|
|
||||||
|
|
||||||
@JsonProperty("voucherSeatInfo")
|
|
||||||
private String voucherSeatInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripResponseOrderItem {
|
|
||||||
@JsonProperty("itemId")
|
|
||||||
private String itemId;
|
|
||||||
|
|
||||||
@JsonProperty("PLU")
|
|
||||||
private String plu;
|
|
||||||
|
|
||||||
@JsonProperty("isCredentialVouchers")
|
|
||||||
private Integer isCredentialVouchers;
|
|
||||||
|
|
||||||
@JsonProperty("passengerVouchers")
|
|
||||||
private List<CtripPassengerVoucher> passengerVouchers;
|
|
||||||
|
|
||||||
@JsonProperty("inventorys")
|
|
||||||
private List<CtripInventory> inventorys;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripPassengerVoucher {
|
|
||||||
@JsonProperty("passengerId")
|
|
||||||
private String passengerId;
|
|
||||||
|
|
||||||
@JsonProperty("voucherId")
|
|
||||||
private String voucherId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripInventory {
|
|
||||||
@JsonProperty("useDate")
|
|
||||||
private String useDate;
|
|
||||||
|
|
||||||
@JsonProperty("quantity")
|
|
||||||
private Integer quantity;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-67
@@ -1,67 +0,0 @@
|
|||||||
package com.central.coupon.model;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程支付确认请求
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class CtripPayPreOrderConfirmRequest {
|
|
||||||
|
|
||||||
private CtripHeader header;
|
|
||||||
private CtripPayPreOrderConfirmBody body;
|
|
||||||
private String originalEncryptedBody; // 保存原始加密的body,用于签名验证
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripHeader {
|
|
||||||
private String accountId;
|
|
||||||
private String serviceName;
|
|
||||||
private String requestTime;
|
|
||||||
private String version;
|
|
||||||
private String sign;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripPayPreOrderConfirmBody {
|
|
||||||
private String sequenceId;
|
|
||||||
private String otaOrderId;
|
|
||||||
private String supplierOrderId;
|
|
||||||
private String confirmResultCode;
|
|
||||||
private String confirmResultMessage;
|
|
||||||
private Integer voucherSender;
|
|
||||||
private List<CtripVoucher> vouchers;
|
|
||||||
private String orderExtendMessage;
|
|
||||||
private List<CtripItem> items;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripVoucher {
|
|
||||||
private String itemId;
|
|
||||||
private String voucherId;
|
|
||||||
private Integer voucherType;
|
|
||||||
private String voucherCode;
|
|
||||||
private String voucherData;
|
|
||||||
private String voucherSeatInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripItem {
|
|
||||||
private String itemId;
|
|
||||||
private String isCredentialVouchers;
|
|
||||||
private List<CtripPassengerVoucher> passengerVouchers;
|
|
||||||
private List<CtripInventory> inventorys;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripPassengerVoucher {
|
|
||||||
private String passengerId;
|
|
||||||
private String voucherId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripInventory {
|
|
||||||
private String useDate;
|
|
||||||
private Integer quantity;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-20
@@ -1,20 +0,0 @@
|
|||||||
package com.central.coupon.model;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程支付确认响应
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class CtripPayPreOrderConfirmResponse {
|
|
||||||
|
|
||||||
private CtripResponseHeader header;
|
|
||||||
private String body; // 加密的响应体
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripResponseHeader {
|
|
||||||
private String resultCode;
|
|
||||||
private String resultMessage;
|
|
||||||
private String version;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-93
@@ -1,93 +0,0 @@
|
|||||||
package com.central.coupon.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程预下单支付请求模型
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class CtripPayPreOrderRequest {
|
|
||||||
|
|
||||||
@JsonProperty("header")
|
|
||||||
private CtripRequestHeader header;
|
|
||||||
|
|
||||||
@JsonProperty("body")
|
|
||||||
private CtripPayPreOrderBody body;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 原始加密的body,用于签名验证
|
|
||||||
*/
|
|
||||||
private String originalEncryptedBody;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripRequestHeader {
|
|
||||||
@JsonProperty("accountId")
|
|
||||||
private String accountId;
|
|
||||||
|
|
||||||
@JsonProperty("serviceName")
|
|
||||||
private String serviceName;
|
|
||||||
|
|
||||||
@JsonProperty("requestTime")
|
|
||||||
private String requestTime;
|
|
||||||
|
|
||||||
@JsonProperty("version")
|
|
||||||
private String version;
|
|
||||||
|
|
||||||
@JsonProperty("sign")
|
|
||||||
private String sign;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripPayPreOrderBody {
|
|
||||||
@JsonProperty("sequenceId")
|
|
||||||
private String sequenceId;
|
|
||||||
|
|
||||||
@JsonProperty("otaOrderId")
|
|
||||||
private String otaOrderId;
|
|
||||||
|
|
||||||
@JsonProperty("supplierOrderId")
|
|
||||||
private String supplierOrderId;
|
|
||||||
|
|
||||||
@JsonProperty("confirmType")
|
|
||||||
private Integer confirmType;
|
|
||||||
|
|
||||||
@JsonProperty("orderLastConfirmTime")
|
|
||||||
private String orderLastConfirmTime;
|
|
||||||
|
|
||||||
@JsonProperty("items")
|
|
||||||
private List<CtripPayPreOrderItem> items;
|
|
||||||
|
|
||||||
@JsonProperty("coupons")
|
|
||||||
private List<CtripPayPreOrderCoupon> coupons;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripPayPreOrderItem {
|
|
||||||
@JsonProperty("itemId")
|
|
||||||
private String itemId;
|
|
||||||
|
|
||||||
@JsonProperty("PLU")
|
|
||||||
private String plu;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripPayPreOrderCoupon {
|
|
||||||
@JsonProperty("type")
|
|
||||||
private Integer type;
|
|
||||||
|
|
||||||
@JsonProperty("code")
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
@JsonProperty("name")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@JsonProperty("amount")
|
|
||||||
private Integer amount;
|
|
||||||
|
|
||||||
@JsonProperty("amountCurrency")
|
|
||||||
private String amountCurrency;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-106
@@ -1,106 +0,0 @@
|
|||||||
package com.central.coupon.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程预下单支付响应模型
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class CtripPayPreOrderResponse {
|
|
||||||
|
|
||||||
@JsonProperty("header")
|
|
||||||
private CtripResponseHeader header;
|
|
||||||
|
|
||||||
@JsonProperty("body")
|
|
||||||
private String body; // 加密的响应体
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripResponseHeader {
|
|
||||||
@JsonProperty("resultCode")
|
|
||||||
private String resultCode;
|
|
||||||
|
|
||||||
@JsonProperty("resultMessage")
|
|
||||||
private String resultMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripPayPreOrderResponseBody {
|
|
||||||
@JsonProperty("otaOrderId")
|
|
||||||
private String otaOrderId;
|
|
||||||
|
|
||||||
@JsonProperty("supplierOrderId")
|
|
||||||
private String supplierOrderId;
|
|
||||||
|
|
||||||
@JsonProperty("supplierConfirmType")
|
|
||||||
private Integer supplierConfirmType;
|
|
||||||
|
|
||||||
@JsonProperty("voucherSender")
|
|
||||||
private Integer voucherSender;
|
|
||||||
|
|
||||||
@JsonProperty("vouchers")
|
|
||||||
private List<CtripPayPreOrderVoucher> vouchers;
|
|
||||||
|
|
||||||
@JsonProperty("orderExtendMessage")
|
|
||||||
private String orderExtendMessage;
|
|
||||||
|
|
||||||
@JsonProperty("items")
|
|
||||||
private List<CtripPayPreOrderResponseItem> items;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripPayPreOrderVoucher {
|
|
||||||
@JsonProperty("itemId")
|
|
||||||
private String itemId;
|
|
||||||
|
|
||||||
@JsonProperty("voucherId")
|
|
||||||
private String voucherId;
|
|
||||||
|
|
||||||
@JsonProperty("voucherType")
|
|
||||||
private Integer voucherType;
|
|
||||||
|
|
||||||
@JsonProperty("voucherCode")
|
|
||||||
private String voucherCode;
|
|
||||||
|
|
||||||
@JsonProperty("voucherData")
|
|
||||||
private String voucherData;
|
|
||||||
|
|
||||||
@JsonProperty("voucherSeatInfo")
|
|
||||||
private String voucherSeatInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripPayPreOrderResponseItem {
|
|
||||||
@JsonProperty("itemId")
|
|
||||||
private String itemId;
|
|
||||||
|
|
||||||
@JsonProperty("isCredentialVouchers")
|
|
||||||
private String isCredentialVouchers;
|
|
||||||
|
|
||||||
@JsonProperty("passengerVouchers")
|
|
||||||
private List<CtripPassengerVoucher> passengerVouchers;
|
|
||||||
|
|
||||||
@JsonProperty("inventorys")
|
|
||||||
private List<CtripInventory> inventorys;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripPassengerVoucher {
|
|
||||||
@JsonProperty("passengerId")
|
|
||||||
private String passengerId;
|
|
||||||
|
|
||||||
@JsonProperty("voucherId")
|
|
||||||
private String voucherId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CtripInventory {
|
|
||||||
@JsonProperty("useDate")
|
|
||||||
private String useDate;
|
|
||||||
|
|
||||||
@JsonProperty("quantity")
|
|
||||||
private Integer quantity;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-64
@@ -1,64 +0,0 @@
|
|||||||
package com.central.coupon.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单查询请求
|
|
||||||
* 用于查询携程订单的详细信息
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public class CtripQueryOrderRequest {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求头
|
|
||||||
*/
|
|
||||||
@JsonProperty("header")
|
|
||||||
private CtripHeader header;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求体 - 可能是加密字符串或JSON对象
|
|
||||||
*/
|
|
||||||
@JsonProperty("body")
|
|
||||||
private Object body; // 改为Object类型,支持字符串和对象两种格式
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 原始的加密body(用于签名验证)
|
|
||||||
* 根据官方示例,签名验证需要使用原始的加密body
|
|
||||||
*/
|
|
||||||
private String originalEncryptedBody;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程请求头
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public static class CtripHeader {
|
|
||||||
@JsonProperty("accountId")
|
|
||||||
private String accountId; // 供应商帐号,由携程分配
|
|
||||||
@JsonProperty("serviceName")
|
|
||||||
private String serviceName; // 接口名称: QueryOrder
|
|
||||||
@JsonProperty("requestTime")
|
|
||||||
private String requestTime; // 请求时间(格式: yyyy-MM-dd HH:mm:ss)
|
|
||||||
@JsonProperty("version")
|
|
||||||
private String version; // 版本号, 1.0
|
|
||||||
@JsonProperty("sign")
|
|
||||||
private String sign; // 签名
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 携程订单查询体
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
||||||
public static class CtripQueryOrderBody {
|
|
||||||
@JsonProperty("otaOrderId")
|
|
||||||
private String otaOrderId; // 携程订单号
|
|
||||||
@JsonProperty("supplierOrderId")
|
|
||||||
private String supplierOrderId; // 供应商订单号
|
|
||||||
@JsonProperty("sequenceId")
|
|
||||||
private String sequenceId; // 携程处理批次流水号
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user