fd65ae16
“wangming”
feat: inventory a...
|
1
2
3
4
5
6
7
8
9
10
11
|
# 仓库领用成本统计接口测试说明
## 📋 接口信息
- **接口路径**: `POST /api/Extend/LqInventoryUsage/get-store-receive-cost-statistics`
- **服务类**: `LqInventoryUsageService`
- **方法名**: `GetStoreReceiveCostStatistics`
## ⚠️ 测试前准备
1. **确保后端服务已重启**:接口代码修改后需要重新编译并重启服务
|
8daf47d0
“wangming”
修改访问地址
|
12
|
2. **确认服务运行正常**:访问 `http://localhost:2015/api/test` 验证服务是否运行
|
fd65ae16
“wangming”
feat: inventory a...
|
13
14
15
16
17
18
|
## 🧪 测试用例
### 测试1: 按月份查询(202601)
```bash
|
8daf47d0
“wangming”
修改访问地址
|
19
|
curl -X POST "http://localhost:2015/api/Extend/LqInventoryUsage/get-store-receive-cost-statistics" \
|
fd65ae16
“wangming”
feat: inventory a...
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
-H "Authorization: Bearer {TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"statisticsMonth": "202601",
"currentPage": 1,
"pageSize": 20
}'
```
**预期返回字段**:
- `StatisticsMonth`: 统计月份(如:202601)
- `StoreId`: 门店ID
- `StoreName`: 门店名称
- `ReceiveCount`: 领取数量(按批次去重)
- `ProductVarietyCount`: 领取品种数量
- `AvgUnitPrice`: 平均单价
- `TotalCostAmount`: 总价
- `WarehouseCount`: 涉及仓库数量
- `UsageRecordCount`: 领用记录数
- `AvgReceiveAmount`: 平均领用金额
- `AvgRecordAmount`: 平均单笔金额
- `TotalUsageQuantity`: 领用总数量
- `MaxRecordAmount`: 最大单笔金额
- `MinRecordAmount`: 最小单笔金额
### 测试2: 按时间范围查询
```bash
|
8daf47d0
“wangming”
修改访问地址
|
48
|
curl -X POST "http://localhost:2015/api/Extend/LqInventoryUsage/get-store-receive-cost-statistics" \
|
fd65ae16
“wangming”
feat: inventory a...
|
49
50
51
52
53
54
55
56
57
58
59
60
61
|
-H "Authorization: Bearer {TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"startMonth": "202512",
"endMonth": "202601",
"currentPage": 1,
"pageSize": 10
}'
```
### 测试3: 按门店查询
```bash
|
8daf47d0
“wangming”
修改访问地址
|
62
|
curl -X POST "http://localhost:2015/api/Extend/LqInventoryUsage/get-store-receive-cost-statistics" \
|
fd65ae16
“wangming”
feat: inventory a...
|
63
64
65
66
67
68
69
70
71
72
73
74
75
|
-H "Authorization: Bearer {TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"statisticsMonth": "202601",
"storeId": "1649328471923847193",
"currentPage": 1,
"pageSize": 20
}'
```
### 测试4: 按仓库筛选
```bash
|
8daf47d0
“wangming”
修改访问地址
|
76
|
curl -X POST "http://localhost:2015/api/Extend/LqInventoryUsage/get-store-receive-cost-statistics" \
|
fd65ae16
“wangming”
feat: inventory a...
|
77
78
79
80
81
82
83
84
85
86
87
88
89
|
-H "Authorization: Bearer {TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"statisticsMonth": "202601",
"warehouse": "福田仓库",
"currentPage": 1,
"pageSize": 20
}'
```
### 测试5: 排序测试
```bash
|
8daf47d0
“wangming”
修改访问地址
|
90
|
curl -X POST "http://localhost:2015/api/Extend/LqInventoryUsage/get-store-receive-cost-statistics" \
|
fd65ae16
“wangming”
feat: inventory a...
|
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
-H "Authorization: Bearer {TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"statisticsMonth": "202601",
"sidx": "TotalCostAmount",
"sort": "desc",
"currentPage": 1,
"pageSize": 5
}'
```
## 📝 使用测试脚本
运行测试脚本:
```bash
|
d8035736
“wangming”
Refactor project ...
|
107
|
bash 项目文档相关/scripts/sh/test_store_receive_cost_statistics.sh
|
fd65ae16
“wangming”
feat: inventory a...
|
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
```
## ✅ 验证要点
1. **接口返回码**: 应为 `200`
2. **数据结构**: 返回的 `list` 数组应包含统计记录
3. **分页信息**: `pagination` 应包含 `total`、`pageIndex`、`pageSize`
4. **字段完整性**: 每个记录应包含所有必需字段
5. **数据准确性**:
- `AvgUnitPrice` = `TotalCostAmount` / `ProductVarietyCount`
- `AvgReceiveAmount` = `TotalCostAmount` / `ReceiveCount`
- `AvgRecordAmount` = `TotalCostAmount` / `UsageRecordCount`
## 🔍 数据验证SQL
可以通过以下SQL验证数据:
```sql
-- 验证202601月份的统计数据
SELECT
DATE_FORMAT(a.F_ReceiveTime, '%Y%m') as StatisticsMonth,
u.F_StoreId as StoreId,
store.dm as StoreName,
COUNT(DISTINCT a.F_UsageBatchId) as ReceiveCount,
COUNT(DISTINCT u.F_ProductId) as ProductVarietyCount,
COALESCE(SUM(u.F_TotalAmount), 0) as TotalCostAmount,
COUNT(DISTINCT p.F_Warehouse) as WarehouseCount
FROM lq_inventory_usage u
INNER JOIN lq_inventory_usage_application a ON u.F_UsageBatchId = a.F_UsageBatchId
INNER JOIN lq_product p ON u.F_ProductId = p.F_Id
LEFT JOIN lq_mdxx store ON u.F_StoreId = store.F_Id
WHERE u.F_IsEffective = 1
AND a.F_IsEffective = 1
AND a.F_ApprovalStatus = '已通过'
AND a.F_IsReceived = 1
AND a.F_ReceiveTime IS NOT NULL
AND DATE_FORMAT(a.F_ReceiveTime, '%Y%m') = '202601'
GROUP BY
DATE_FORMAT(a.F_ReceiveTime, '%Y%m'),
u.F_StoreId,
store.dm
ORDER BY TotalCostAmount DESC
LIMIT 10;
```
## 🐛 常见问题
1. **404错误**: 服务未重启,需要重新编译并重启后端服务
2. **500错误**: 检查SQL查询是否正确,查看服务日志
3. **空数据**: 确认指定月份是否有已领取的仓库使用记录
4. **Token过期**: 重新获取Token
|