feat(user): 注销账号数据级联清理 + 后台删除端点 #115
Open
liujiahui
wants to merge 1 commits from
7-4ljh into main
pull from: 7-4ljh
merge into: WonderableAI:main
WonderableAI:main
WonderableAI:feature/direct-vendor-push-main-20260702
WonderableAI:feat/wechat-login
WonderableAI:feat/llm-token-cost
WonderableAI:fix/withdraw-repeat-login-state
WonderableAI:feat/per-session-ad-revenue
WonderableAI:79ljh
WonderableAI:dev0708
WonderableAI:feat/coupon-success-rate
WonderableAI:feat/analytics-success-rate
WonderableAI:admin-custom-perms
WonderableAI:fix/dashboard-reward-coin-feed-scene
WonderableAI:7-6ljh
WonderableAI:feat/marquee-real-shuffle-and-browse
WonderableAI:origin/intern/chenshuobo/dashboard-jd-cps-20260628
WonderableAI:feat/marquee-preview-mode-and-default-nickname
WonderableAI:fix/invite-cash-ledger-reconcile
WonderableAI:feat/admin-dashboard-metrics
WonderableAI:feat/openobserve-api-metrics
WonderableAI:feat/ad-report-period-dau-arpu
WonderableAI:feat/admin-rbac-config-compare
WonderableAI:feat/meituan-cps-city-geo
WonderableAI:feat/compare-record-backend-harvest
WonderableAI:7-1ljh-invite-reward-notest
WonderableAI:7-3-ljh-testlab
WonderableAI:feat/api-docs-reorg
WonderableAI:refactor/simplify-login-ratelimit
WonderableAI:feature/direct-vendor-push-20260702
WonderableAI:7-1ljh
WonderableAI:fix/heartbeat-timeout-1h
WonderableAI:feat/h5-sgbridge
WonderableAI:feat/h5-offline-pool
WonderableAI:feat/feedback-type-reply-withdraw-type
WonderableAI:feat/ad-revenue-trace-aggregate
WonderableAI:fix/alembic-merge-heads
WonderableAI:intern/chenshuobo/dashboard-jd-cps-20260628
WonderableAI:chore/pangle-revenue-timer
WonderableAI:feat/coupon-data-dashboard
WonderableAI:6-29ljh
WonderableAI:feat/admin-adjust-cash-account
WonderableAI:feat/h5-sgbridge-gk
WonderableAI:feat/admin-feedback-pricereport-api
WonderableAI:fix/ad-revenue-ecpm-cap-appenv
WonderableAI:intern/chenshuobo/wechat-login-20260629
WonderableAI:feat/pangle-report-revenue
WonderableAI:feat/launch-confirm-self-evolution
WonderableAI:intern/chenshuobo/meituan-feed-improve-20260610
WonderableAI:feat/mine-h5
WonderableAI:perf/pricebot-shared-httpx-client
WonderableAI:feat/wysiwyg-display-coin
WonderableAI:fix/ad-ecpm-dedup-500
WonderableAI:feat/ad-revenue-report-paging-audit
WonderableAI:feature/draw-feed-ad
WonderableAI:feat/invite-v2-cash-reward
WonderableAI:feat/analytics-events
WonderableAI:feat/cps-day-user-drilldown
WonderableAI:feat/sms-login-rate-limit
WonderableAI:feat/admin-device-liveness
WonderableAI:fix/ad-reward-env-isolation
WonderableAI:feat/cps-wx-userinfo-auth
WonderableAI:feat/wx-cps-meituan-jd-uinfo-auth
WonderableAI:feat/withdrawal-rewarded-ad
WonderableAI:fix/wx-cps-click-dup-insert
WonderableAI:feat/ad-revenue-per-event
WonderableAI:intern/chenshuobo/alembic-merge-heads-20260623
WonderableAI:intern/chenshuobo/meituan-coupon-image-size-20260623
WonderableAI:feat/default-nickname-user-prefix
WonderableAI:feat/test-account
WonderableAI:feat/marquee-nickname-mask
WonderableAI:feat/a11y-liveness-pull
WonderableAI:fix/ad-config-default-feed-slot
WonderableAI:feat/withdraw-detail-tweaks
WonderableAI:intern/chenshuobo/feedback-review-20260622
WonderableAI:feat/compare-record-status
WonderableAI:feat/feed-ad-realcoin-orb
WonderableAI:feat/cps-distribution
WonderableAI:feat/ops-config-ad-flags-reconcile
WonderableAI:intern/chenshuobo/meituan-etl-nul-fix-20260616
WonderableAI:intern/chenshuobo/meituan-multi-city-etl-20260616
WonderableAI:feat/jd-and-launch-confirm
WonderableAI:feat/ad-revenue-report
WonderableAI:feat/a11y-liveness-heartbeat
WonderableAI:feat/jd-deeplink-invalid-share-switch
WonderableAI:integration/0615
WonderableAI:feature/6.14-coupon
WonderableAI:feat/feedback-iteration
WonderableAI:fix/admin-review-hardening
WonderableAI:feat/taobao-shopid-store-mapping
WonderableAI:fix/marquee-mask-deterministic
WonderableAI:feat/unbind-wechat-reviewing-confirm
WonderableAI:feat/nickname-maxlength-20
WonderableAI:feat/daily-auto-exchange
WonderableAI:coupon-checkout-funnel
WonderableAI:feat/home-facade-stats-and-marquee
WonderableAI:feat/meituan-precoupon
WonderableAI:feat/onboarding-completion
WonderableAI:intern/chenshuobo/meituan-etl-feed-20260610
WonderableAI:coupon_home_ui
WonderableAI:docs/coupon-tables
WonderableAI:fix/alembic-linearize-debug-trace
WonderableAI:feat/invite-landing-store
WonderableAI:feat/debug-trace-link
WonderableAI:feat/admin-price-report-review
WonderableAI:intern/chenshuobo/meituan-feed-tabs-20260609
WonderableAI:feat/home-feed-sort-tabs
WonderableAI:feat/ad-coin-ecpm-unit-audit
WonderableAI:feat/invite-display
WonderableAI:chore/merge-alembic-heads
WonderableAI:feat/coupon-flow-improvements
WonderableAI:feat/coin-system-phase2-ad-ecpm
WonderableAI:feature/withdraw-review-ops
WonderableAI:fix/created-at-beijing-tz
WonderableAI:feat/invite-mvp
WonderableAI:feat/coupon-daily-claim-gate
WonderableAI:intern/chenshuobo/meituan-coupon-etl-20260606
WonderableAI:feat/platform-stats-display
WonderableAI:feature/coupon-claim-integration
WonderableAI:feat/price-observation-pipeline
WonderableAI:feat/concurrency-multi-instance
WonderableAI:feat/sls-json-logging
WonderableAI:feat/wxpay-transfer-auth
WonderableAI:feat/admin-api-db-docs
WonderableAI:feat/wip-20260606
WonderableAI:feat/pricebot-native-async
WonderableAI:feat/admin-app-config
WonderableAI:feat/recompare-deeplink
WonderableAI:feat/price-report
WonderableAI:feat/signin-remark-and-milestone-no-coin
WonderableAI:feat/ad-ecpm-and-cooldown
WonderableAI:feat/savings-accounting-clean
WonderableAI:feat/savings-accounting-m1
WonderableAI:feat/user-profile-feedback-api
WonderableAI:dev/integration
WonderableAI:feat/postgres-migration-and-bootstrap-script
WonderableAI:feat/welfare-video-round-cooldown
WonderableAI:feat/home-feed-ranking-mvp
WonderableAI:feature/welfare-withdraw-ad
WonderableAI:feat/user-order-records
No Reviewers
Labels
No items
No Label
Milestone
No items
No Milestone
Projects
Clear projects
No project
Assignees
gaomengzhuo
guke
kongderong
liujiahui
marco
wangyaoguang
wanlangjie
wusiyi
zhuzihao
zuochenyong
Clear assignees
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: WonderableAI/shaguabijia-app-server#115
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "7-4ljh"
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?
注销账号:数据级联清理 + 后台删除端点
弹窗承诺「永久删除」但后端此前只软删 user 行、业务数据全残留(合规/隐私违约)。本 PR 让删除名副其实。
清理策略(按「删了是否破坏对账 / 影响别人 / 是否 PII」分类)
资金前置闸(C 端与后台一致)
有未提现现金 / 邀请奖励金 / 在审提现单 →
409拒绝,账号不被删、余额不清零。改动
api/v1/user.pyDELETE /api/v1/user加三道资金 409 前置校验repositories/user.pysoft_delete_account落地分类删除(补ad_watch_log埋点删除 + docstring 说明 ad_* 保留理由)repositories/wallet.pyget_invite_cash_balance_cents(邀请金 409 校验用)admin/routers/users.pyDELETE /admin/api/users/{id}复用soft_delete_account+ 审计,仅super_admin;审计与清理同一 commit 原子admin/schemas/user.pyDeleteUserRequest(必填reason入审计)测试
test_delete_account.py:级联删除个人表删空 / 余额归零 / 保留表存活 + 匿名化 + 409 闸 + 旧 token 失效(6 测)test_admin_write.py:后台删除 + 审计留痕 + operator 403 + 重复删 400 + 有钱 409(4 测)pytest:除 5 个与本 PR 无关的预存失败(coupon proxy body 转发 / 返佣发币)外全绿🤖 Generated with Claude Code
C 端与后台复用同一套 soft_delete_account:物理删除个人内容/行为/PII 表(比价/省钱/ 签到/领券/任务/设备/价格上报/反馈/引导/埋点/看广告时长/邀请指纹)+ 清零余额 + 匿名化 user 行释放唯一约束;保留资金流水/邀请关系/广告幂等+对账表(对账/幂等/邀请人侧归属)。 - api/v1/user.py: DELETE /api/v1/user 加资金前置闸(未提现现金/邀请金 / 在审提现单 → 409) - repositories/user.py: soft_delete_account 落地分类删除(补 ad_watch_log 埋点删除) - repositories/wallet.py: 新增 get_invite_cash_balance_cents(邀请金 409 校验用) - admin/routers/users.py: DELETE /admin/api/users/{id} 复用清理 + 审计,仅 super_admin - admin/schemas/user.py: DeleteUserRequest(必填 reason 入审计) - tests: 级联删除/余额归零/保留表存活 6 测 + admin 删除/审计/403/400/409 4 测 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.