Files
gofly-platform-services/zlt-business/coupon-center/订单明细查询核销接口说明.md
T

251 lines
6.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 订单明细查询核销接口说明
## 概述
本接口提供通过手机号和优惠券价格查询可核销的携程订单明细的功能,支持用户选择订单进行核销操作。
## 接口列表
### 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. **幂等性**:重复核销同一订单项会返回成功,但不会重复扣减数量