# HoneyBox API 抽奖系统接口测试文件
# 用于验证所有抽奖系统相关的控制器接口
# 抽奖系统迁移 - Task 17.2

@baseUrl = http://localhost:5238/api
@contentType = application/json

# 测试用Token（需要通过登录接口获取真实Token后替换）
# 下面是一个有效的测试Token（用户ID: 21583），有效期至2026年
@authToken = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoi5b6u5L-h55So5oi3MTMxMCIsImV4cCI6MTc2NzQzMTM1OCwidWlkIjoiMzMyMjY2IiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvbmFtZWlkZW50aWZpZXIiOiIyMTU4MyIsImF1ZCI6IkhvbmV5Qm94VXNlcnMiLCJpc3MiOiJIb25leUJveCJ9.700XWIUmzEumNk5tNYRshh7M42A8MG1X4yTHuz9PZbc

# 测试用参数（需要替换为数据库中存在的数据）
@testGoodsId = 1
@testOrderNum = TEST_ORDER_001
@testInfiniteOrderNum = INF_ORDER_001
@testOrderListIds = 1,2,3

### ============================================
### 1. 健康检查接口
### ============================================

### 1.1 健康检查 - 验证服务是否正常运行
# GET /api/health
GET {{baseUrl}}/health
Accept: {{contentType}}

### ============================================
### 2. 一番赏抽奖结果查询接口 (OrderController)
### Requirements: 1.1-1.4
### ============================================

### 2.1 一番赏抽奖结果查询 - 有效订单号
# POST /api/prizeorderlog
# Requirements: 1.1, 1.3
POST {{baseUrl}}/prizeorderlog
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_num": "{{testOrderNum}}"
}

### 2.2 一番赏抽奖结果查询 - 无效订单号（应返回空列表）
# POST /api/prizeorderlog
# Requirements: 1.2
POST {{baseUrl}}/prizeorderlog
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_num": "INVALID_ORDER_NUM"
}

### 2.3 一番赏抽奖结果查询 - 空订单号（应返回错误）
# POST /api/prizeorderlog
# Requirements: 1.4
POST {{baseUrl}}/prizeorderlog
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_num": ""
}

### 2.4 一番赏抽奖结果查询 - 未授权访问
# POST /api/prizeorderlog
POST {{baseUrl}}/prizeorderlog
Content-Type: {{contentType}}

{
    "order_num": "{{testOrderNum}}"
}

### ============================================
### 3. 无限赏抽奖结果查询接口 (OrderController)
### Requirements: 2.1-2.3
### ============================================

### 3.1 无限赏抽奖结果查询 - 有效订单号
# POST /api/infinite_prizeorderlog
# Requirements: 2.1, 2.2
POST {{baseUrl}}/infinite_prizeorderlog
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_num": "{{testInfiniteOrderNum}}"
}

### 3.2 无限赏抽奖结果查询 - 无效订单号（应返回空列表）
# POST /api/infinite_prizeorderlog
# Requirements: 2.1
POST {{baseUrl}}/infinite_prizeorderlog
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_num": "INVALID_ORDER_NUM"
}

### 3.3 无限赏抽奖结果查询 - 空订单号（应返回错误）
# POST /api/infinite_prizeorderlog
# Requirements: 2.3
POST {{baseUrl}}/infinite_prizeorderlog
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "order_num": ""
}

### 3.4 无限赏抽奖结果查询 - 未授权访问
# POST /api/infinite_prizeorderlog
POST {{baseUrl}}/infinite_prizeorderlog
Content-Type: {{contentType}}

{
    "order_num": "{{testInfiniteOrderNum}}"
}

### ============================================
### 4. 无限赏中奖记录查询接口 (OrderController)
### Requirements: 4.1-4.3
### ============================================

### 4.1 无限赏中奖记录查询 - 基本查询（全部赏品）
# POST /api/infinite_shang_log
# Requirements: 4.1
POST {{baseUrl}}/infinite_shang_log
Content-Type: {{contentType}}

{
    "goods_id": {{testGoodsId}},
    "shang_id": 0,
    "is_mibao": 0,
    "page": 1,
    "page_size": 100
}

### 4.2 无限赏中奖记录查询 - 按赏品等级过滤
# POST /api/infinite_shang_log
# Requirements: 4.2
POST {{baseUrl}}/infinite_shang_log
Content-Type: {{contentType}}

{
    "goods_id": {{testGoodsId}},
    "shang_id": 34,
    "is_mibao": 0,
    "page": 1,
    "page_size": 100
}

### 4.3 无限赏中奖记录查询 - 秘宝池过滤
# POST /api/infinite_shang_log
# Requirements: 4.1
POST {{baseUrl}}/infinite_shang_log
Content-Type: {{contentType}}

{
    "goods_id": {{testGoodsId}},
    "shang_id": 0,
    "is_mibao": 1,
    "page": 1,
    "page_size": 100
}

### 4.4 无限赏中奖记录查询 - 分页第二页
# POST /api/infinite_shang_log
# Requirements: 4.1
POST {{baseUrl}}/infinite_shang_log
Content-Type: {{contentType}}

{
    "goods_id": {{testGoodsId}},
    "shang_id": 0,
    "is_mibao": 0,
    "page": 2,
    "page_size": 100
}

### 4.5 无限赏中奖记录查询 - 自定义分页大小
# POST /api/infinite_shang_log
# Requirements: 4.1
POST {{baseUrl}}/infinite_shang_log
Content-Type: {{contentType}}

{
    "goods_id": {{testGoodsId}},
    "shang_id": 0,
    "is_mibao": 0,
    "page": 1,
    "page_size": 20
}

### 4.6 无限赏中奖记录查询 - 商品ID为空（应返回错误）
# POST /api/infinite_shang_log
# Requirements: 4.3
POST {{baseUrl}}/infinite_shang_log
Content-Type: {{contentType}}

{
    "goods_id": 0,
    "shang_id": 0,
    "is_mibao": 0,
    "page": 1,
    "page_size": 100
}

### ============================================
### 5. 每日抽奖记录查询接口 (OrderController)
### Requirements: 5.1-5.3
### ============================================

### 5.1 每日抽奖记录查询 - 基本查询
# POST /api/infinite_prizerecords
# Requirements: 5.1, 5.2
POST {{baseUrl}}/infinite_prizerecords
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "goods_id": {{testGoodsId}},
    "page": 1,
    "page_size": 100
}

### 5.2 每日抽奖记录查询 - 分页第二页
# POST /api/infinite_prizerecords
# Requirements: 5.3
POST {{baseUrl}}/infinite_prizerecords
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "goods_id": {{testGoodsId}},
    "page": 2,
    "page_size": 100
}

### 5.3 每日抽奖记录查询 - 自定义分页大小
# POST /api/infinite_prizerecords
# Requirements: 5.1
POST {{baseUrl}}/infinite_prizerecords
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "goods_id": {{testGoodsId}},
    "page": 1,
    "page_size": 20
}

### 5.4 每日抽奖记录查询 - 商品ID为空（应返回错误）
# POST /api/infinite_prizerecords
# Requirements: 5.1
POST {{baseUrl}}/infinite_prizerecords
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "goods_id": 0,
    "page": 1,
    "page_size": 100
}

### 5.5 每日抽奖记录查询 - 未授权访问
# POST /api/infinite_prizerecords
POST {{baseUrl}}/infinite_prizerecords
Content-Type: {{contentType}}

{
    "goods_id": {{testGoodsId}},
    "page": 1,
    "page_size": 100
}

### ============================================
### 6. 道具卡抽奖接口 (OrderController)
### Requirements: 6.1-6.4
### ============================================

### 6.1 道具卡抽奖 - 有效道具卡
# POST /api/item_card_chou
# Requirements: 6.1, 6.2, 6.3
POST {{baseUrl}}/item_card_chou
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "goods_id": {{testGoodsId}},
    "order_list_ids": "{{testOrderListIds}}"
}

### 6.2 道具卡抽奖 - 单个订单项
# POST /api/item_card_chou
# Requirements: 6.1, 6.2
POST {{baseUrl}}/item_card_chou
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "goods_id": {{testGoodsId}},
    "order_list_ids": "1"
}

### 6.3 道具卡抽奖 - 商品ID为空（应返回错误）
# POST /api/item_card_chou
# Requirements: 6.4
POST {{baseUrl}}/item_card_chou
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "goods_id": 0,
    "order_list_ids": "{{testOrderListIds}}"
}

### 6.4 道具卡抽奖 - 订单项ID为空（应返回错误）
# POST /api/item_card_chou
# Requirements: 6.4
POST {{baseUrl}}/item_card_chou
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "goods_id": {{testGoodsId}},
    "order_list_ids": ""
}

### 6.5 道具卡抽奖 - 未授权访问
# POST /api/item_card_chou
# Requirements: 6.4
POST {{baseUrl}}/item_card_chou
Content-Type: {{contentType}}

{
    "goods_id": {{testGoodsId}},
    "order_list_ids": "{{testOrderListIds}}"
}

### 6.6 道具卡抽奖 - 无效订单项ID格式
# POST /api/item_card_chou
# Requirements: 6.4
POST {{baseUrl}}/item_card_chou
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "goods_id": {{testGoodsId}},
    "order_list_ids": "abc,def"
}

### ============================================
### 7. 一番赏中奖记录查询接口 (GoodsController)
### Requirements: 3.1-3.6
### ============================================

### 7.1 一番赏中奖记录查询 - 基本查询
# POST /api/goods_prize_logs
# Requirements: 3.1
POST {{baseUrl}}/goods_prize_logs
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "goods_id": {{testGoodsId}},
    "goods_num": 0,
    "shang_id": 0,
    "page": 1,
    "page_size": 15
}

### 7.2 一番赏中奖记录查询 - 按赏品等级过滤
# POST /api/goods_prize_logs
# Requirements: 3.2
POST {{baseUrl}}/goods_prize_logs
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "goods_id": {{testGoodsId}},
    "goods_num": 0,
    "shang_id": 1,
    "page": 1,
    "page_size": 15
}

### 7.3 一番赏中奖记录查询 - 指定箱号
# POST /api/goods_prize_logs
# Requirements: 3.1
POST {{baseUrl}}/goods_prize_logs
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "goods_id": {{testGoodsId}},
    "goods_num": 1,
    "shang_id": 0,
    "page": 1,
    "page_size": 15
}

### 7.4 一番赏中奖记录查询 - 分页第二页
# POST /api/goods_prize_logs
# Requirements: 3.1
POST {{baseUrl}}/goods_prize_logs
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "goods_id": {{testGoodsId}},
    "goods_num": 0,
    "shang_id": 0,
    "page": 2,
    "page_size": 15
}

### 7.5 一番赏中奖记录查询 - 自定义分页大小
# POST /api/goods_prize_logs
# Requirements: 3.1
POST {{baseUrl}}/goods_prize_logs
Content-Type: {{contentType}}
Authorization: Bearer {{authToken}}

{
    "goods_id": {{testGoodsId}},
    "goods_num": 0,
    "shang_id": 0,
    "page": 1,
    "page_size": 30
}

### ============================================
### 8. API响应格式验证
### Requirements: 10.1-10.4
### ============================================

### 8.1 验证响应格式 - 成功响应
# 验证返回格式: { "status": 1, "msg": "success", "data": {...} }
# Requirements: 10.1, 10.2
POST {{baseUrl}}/infinite_shang_log
Content-Type: {{contentType}}

{
    "goods_id": {{testGoodsId}},
    "shang_id": 0,
    "is_mibao": 0,
    "page": 1,
    "page_size": 10
}

### 8.2 验证响应格式 - 失败响应
# 验证返回格式: { "status": 0, "msg": "error message", "data": null }
# Requirements: 10.3
POST {{baseUrl}}/infinite_shang_log
Content-Type: {{contentType}}

{
    "goods_id": 0,
    "shang_id": 0,
    "is_mibao": 0,
    "page": 1,
    "page_size": 10
}

### 8.3 验证响应格式 - 未授权响应
# 验证返回格式: { "status": -1, "msg": "未登录", "data": null }
# Requirements: 10.4
POST {{baseUrl}}/prizeorderlog
Content-Type: {{contentType}}

{
    "order_num": "{{testOrderNum}}"
}

### ============================================
### 9. 边界条件测试
### ============================================

### 9.1 分页边界 - 页码为0（应使用默认值1）
POST {{baseUrl}}/infinite_shang_log
Content-Type: {{contentType}}

{
    "goods_id": {{testGoodsId}},
    "shang_id": 0,
    "is_mibao": 0,
    "page": 0,
    "page_size": 10
}

### 9.2 分页边界 - 页码为负数（应使用默认值1）
POST {{baseUrl}}/infinite_shang_log
Content-Type: {{contentType}}

{
    "goods_id": {{testGoodsId}},
    "shang_id": 0,
    "is_mibao": 0,
    "page": -1,
    "page_size": 10
}

### 9.3 分页边界 - 每页数量为0（应使用默认值）
POST {{baseUrl}}/infinite_shang_log
Content-Type: {{contentType}}

{
    "goods_id": {{testGoodsId}},
    "shang_id": 0,
    "is_mibao": 0,
    "page": 1,
    "page_size": 0
}

### 9.4 分页边界 - 每页数量为负数（应使用默认值）
POST {{baseUrl}}/infinite_shang_log
Content-Type: {{contentType}}

{
    "goods_id": {{testGoodsId}},
    "shang_id": 0,
    "is_mibao": 0,
    "page": 1,
    "page_size": -1
}

### 9.5 分页边界 - 超大页码（应返回空列表）
POST {{baseUrl}}/infinite_shang_log
Content-Type: {{contentType}}

{
    "goods_id": {{testGoodsId}},
    "shang_id": 0,
    "is_mibao": 0,
    "page": 99999,
    "page_size": 10
}

### 9.6 商品ID边界 - 不存在的商品ID
POST {{baseUrl}}/infinite_shang_log
Content-Type: {{contentType}}

{
    "goods_id": 999999,
    "shang_id": 0,
    "is_mibao": 0,
    "page": 1,
    "page_size": 10
}

### ============================================
### 10. 并发安全测试说明
### ============================================

# 注意：以下测试需要使用专门的并发测试工具（如 k6, JMeter）
# 这里仅提供测试用例说明

# 10.1 并发抽奖测试
# - 同时发起多个道具卡抽奖请求
# - 验证库存扣减的原子性
# - 验证不会出现超发情况

# 10.2 并发查询测试
# - 同时发起多个中奖记录查询请求
# - 验证响应数据的一致性

### ============================================
### 测试说明
### ============================================

# 1. 测试前准备：
#    - 确保服务已启动（默认端口5238）
#    - 替换 @authToken 为有效的JWT Token
#    - 替换测试参数为数据库中存在的数据

# 2. 测试顺序建议：
#    - 先执行健康检查确认服务正常
#    - 按顺序执行各接口测试
#    - 最后执行边界条件测试

# 3. 预期结果：
#    - 所有成功请求应返回 status=1
#    - 所有失败请求应返回 status=0 和错误信息
#    - 未授权请求应返回 status=-1

# 4. 接口迁移清单：
#    | 序号 | PHP接口 | 新接口地址 | 状态 |
#    |------|---------|-----------|------|
#    | 1 | POST /prizeorderlog | POST /api/prizeorderlog | ✅ |
#    | 2 | POST /infinite_prizeorderlog | POST /api/infinite_prizeorderlog | ✅ |
#    | 3 | POST /infinite_shang_log | POST /api/infinite_shang_log | ✅ |
#    | 4 | POST /infinite_prizerecords | POST /api/infinite_prizerecords | ✅ |
#    | 5 | POST /item_card_chou | POST /api/item_card_chou | ✅ |
#    | 6 | POST /shang_log | POST /api/goods_prize_logs | ✅ |
