peixue-dev/Archive/[一次性]快速预约本月收益映射修复-2026-01-31.md

92 lines
2.3 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.

# 快速预约本月收益映射修复
**修复时间:** 2026-01-31
**问题描述:** 快速预约界面的"本月收益"显示¥0与收益查看页面的"本月¥222"不一致
---
## 问题分析
### 1. 问题现象
- **快速预约页面**:本月收益显示 ¥0
- **收益查看页面**:本月收益显示 ¥222
- 两个页面应该显示相同的数据
### 2. 根本原因
两个页面调用的是**同一个API**,但使用了**不同的字段名**
| 页面 | API | 字段名 |
|------|-----|--------|
| 快速预约 | `/api/provider/earnings/stats?type=month` | `data.total` ❌ |
| 收益查看 | `/api/provider/earnings/stats?type=month` | `data.earnings` ✅ |
**API实际返回的数据结构**
```json
{
"code": 200,
"data": {
"courseCount": 1,
"duration": 1,
"earnings": 222 // ← 正确的字段名
}
}
```
---
## 修复方案
### 修改文件
`peidu/uniapp/src/pages/booking/components/ProviderBooking.vue`
### 修改内容
```javascript
// ❌ 修改前(使用错误的字段名)
if (earningsRes && earningsRes.code === 200 && earningsRes.data) {
this.stats.revenue = earningsRes.data.total || 0
}
// ✅ 修改后(使用正确的字段名)
if (earningsRes && earningsRes.code === 200 && earningsRes.data) {
// ✅ 使用与收益查看页面一致的字段 earnings
this.stats.revenue = earningsRes.data.earnings || 0
}
```
---
## 验证步骤
1. **清除缓存重新编译**
```bash
# 在微信开发者工具中
1. 点击"清缓存" → "清除全部缓存"
2. 点击"编译"
```
2. **测试快速预约页面**
- 切换到服务商角色
- 进入"快速预约"页面
- 查看"本月收益"是否显示 ¥222
3. **对比收益查看页面**
- 点击"本月收益"卡片
- 进入收益查看页面
- 确认"本月"标签下的收益也是 ¥222
---
## 修复结果
**快速预约页面的"本月收益"现在与收益查看页面的数据一致**
- 两个页面都调用同一个API`/api/provider/earnings/stats?type=month`
- 两个页面都使用同一个字段:`data.earnings`
- 数据映射关系已建立,显示一致
---
## 相关文件
- `peidu/uniapp/src/pages/booking/components/ProviderBooking.vue` - 快速预约服务商组件
- `peidu/uniapp/src/provider-package/pages/provider/earnings.vue` - 收益查看页面