修复提现审核详情点击用户后提示操作失败 #171
Reference in New Issue
Block a user
Delete Branch "codex/fix-withdraw-detail-schema-compat"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
问题现象
在“提现审核”页点击用户所在行后,提现单主详情可以打开,但用户统计和金币记录区域为空,页面连续提示“操作失败”。
原因说明
打开抽屉时前端会继续请求两个子接口:
/admin/api/users/{user_id}/reward-stats/admin/api/users/{user_id}/coin-records这两个接口原来都使用
select(AdRewardRecord)加载完整 ORM 对象。SQLAlchemy 会把模型映射的所有列自动展开到 SQL 中,其中包括后来新增的boost_round_id。当旧本地数据库或滚动发布中的数据库尚未补齐该列时,即使提现详情本身完全不使用这个字段,查询仍会报no such column: ad_reward_record.boost_round_id,两个接口均返回 500。前端的统一错误处理只会展示响应 JSON 中字符串类型的
detail;该 500 返回的是普通Internal Server Error,因此最终回退成通用文案“操作失败”。本地前端开启了 React Strict Mode,初始化副作用在开发环境会执行两次,所以两个失败接口会形成截图中的四条“操作失败”提示。修复方案
ecpm_raw、coin等字段。ad_reward_record.boost_round_id的详情查询,并验证两个接口仍返回 200。该改动不会改变统计口径或返回结构。数据库迁移仍应正常执行;这里增加的是旧库及滚动发布期间的向后兼容保护。
验证结果
pytest tests/test_admin_read.py -q:17 passedreward-stats与coin-recordsgit diff --check:通过