hailin
a609600cd8
feat(fiat-withdrawal): add complete fiat withdrawal system
...
实现完整的法币提现功能,支持银行卡、支付宝、微信三种收款方式。
此功能与现有的区块链划转功能完全独立,互不影响。
## 后端 (wallet-service)
### 数据库
- 新增 `fiat_withdrawal_orders` 表存储法币提现订单
- 与现有 `withdrawal_orders` 表(区块链划转)完全分离
- 添加完整索引支持高效查询
### 领域层
- 新增 `FiatWithdrawalStatus` 枚举(与 WithdrawalStatus 独立)
- 流程: PENDING -> FROZEN -> REVIEWING -> APPROVED -> PAYING -> COMPLETED
- 或 REJECTED / FAILED / CANCELLED
- 新增 `PaymentMethod` 枚举: BANK_CARD / ALIPAY / WECHAT
- 新增 `FiatWithdrawalOrder` 聚合根
- 新增 `IFiatWithdrawalOrderRepository` 仓储接口
- 新增 `FIAT_WITHDRAWAL` 账本流水类型
### 应用层
- 新增 `FiatWithdrawalApplicationService` 处理业务逻辑
- 发送短信验证码
- 申请法币提现(冻结余额)
- 提交审核
- 审核通过/驳回
- 开始打款
- 完成打款
### API层
- 新增 `FiatWithdrawalController` 提供用户端API
- POST /wallet/fiat-withdrawal/send-sms - 发送验证码
- POST /wallet/fiat-withdrawal - 申请提现
- GET /wallet/fiat-withdrawal - 获取提现记录
- 新增内部API供管理端调用
- GET /api/v1/wallets/fiat-withdrawals - 查询订单
- POST /api/v1/wallets/fiat-withdrawals/:orderNo/review - 审核
- POST /api/v1/wallets/fiat-withdrawals/:orderNo/start-payment - 开始打款
- POST /api/v1/wallets/fiat-withdrawals/:orderNo/complete-payment - 完成打款
## 前端 (admin-web)
- 新增法币提现审核管理页面 `/withdrawals`
- 支持按状态分 Tab 查看订单
- 支持审核通过/驳回
- 支持打款操作
- 支持查看订单详情
## 前端 (mobile-app)
- 新增 `WithdrawFiatPage` 法币提现页面
- 支持选择银行卡/支付宝/微信
- 输入收款账户信息
- 新增 `WithdrawFiatConfirmPage` 确认页面
- 短信验证码验证
- 密码验证
- 在 `WalletService` 中添加法币提现相关方法和模型
## 重要说明
此功能与现有的区块链划转功能 (withdraw_usdt_page.dart) 完全独立:
- 独立的数据库表
- 独立的聚合根
- 独立的状态枚举
- 独立的API端点
- 独立的前端页面
原有的区块链划转功能保持不变,不受任何影响。
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 06:39:11 -08:00
hailin
d614d18e97
Revert "feat(withdrawal): implement fiat withdrawal with bank/alipay/wechat"
...
This reverts commit 288d894746 .
2026-01-03 05:44:43 -08:00
hailin
288d894746
feat(withdrawal): implement fiat withdrawal with bank/alipay/wechat
...
Add complete fiat withdrawal feature that allows users to withdraw
green credits (绿积分) to their bank card, Alipay, or WeChat account
with 1:1 CNY conversion. Key changes:
Backend (wallet-service):
- Update Prisma schema with fiat withdrawal fields (paymentMethod,
bankName, bankCardNo, cardHolderName, alipay*, wechat*, review fields)
- Rewrite withdrawal status enum for fiat flow: PENDING → FROZEN →
REVIEWING → APPROVED → PAYING → COMPLETED (or REJECTED/FAILED)
- Add PaymentMethod enum: BANK_CARD, ALIPAY, WECHAT
- Update WithdrawalOrderAggregate with new fiat withdrawal methods
- Add review/payment workflow methods in WalletApplicationService
- Add internal API endpoints for admin withdrawal management
- Remove blockchain withdrawal event handler (no longer needed)
Frontend (admin-web):
- Add withdrawal review management page at /withdrawals
- Add tabs for reviewing/approved/paying order states
- Add withdrawal service and React Query hooks
- Add types for withdrawal orders and payment methods
- Add sidebar menu item for withdrawal review
Frontend (mobile-app):
- Add withdrawFiat() method to WalletService
- Add PaymentMethod enum with BANK_CARD/ALIPAY/WECHAT
- Create new WithdrawFiatPage for fiat withdrawal input
- Create WithdrawFiatConfirmPage with SMS + password verification
- Add routes for /withdraw/fiat and /withdraw/fiat/confirm
- Keep existing withdraw/usdt (划转) pages unchanged
Note: The existing withdraw_usdt_page.dart is for point-to-point
transfer (划转), which is a different feature from fiat withdrawal.
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 05:28:05 -08:00
hailin
f9222fed50
feat: 实现ID-to-ID内部转账功能
...
- 添加内部转账标识字段:is_internal_transfer, to_account_sequence, to_user_id
- 提现时自动检测目标地址是否为内部用户
- 内部转账确认后创建双向流水:发送方TRANSFER_OUT,接收方TRANSFER_IN
- 新增identity-service钱包地址查询API支持内部用户识别
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-22 22:22:47 -08:00
hailin
3f5203c142
feat: 已认种用户分享权益直接进入可结算状态
...
- 新增 hasPlanted 字段标记用户是否已认种
- 已认种用户的分享权益直接进入可结算余额,无需待领取
- 修正前端权益考核数值(576/288/252/144/108 绿积分)
- 修复账本明细筛选栏选择后滚动位置重置问题
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-22 21:10:49 -08:00
hailin
cb0f10af34
feat: 多项业务功能增强
...
- 动态提取手续费配置:支持固定/百分比两种费率类型,默认2绿积分/笔
- 找回密码功能:新增手机号+短信验证码重置密码流程
- 授权申请优化:自助申请时验证团队链授权状态
- UI文案调整:登录账号、监控页待开启等
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-22 19:00:02 -08:00
hailin
286e6aad01
fix(db): 添加缺失的数据库迁移文件
...
问题:
- wallet-service schema 中有 version 字段,但迁移文件中缺失
- presence-service 缺少初始化迁移文件
修复:
- wallet-service: 添加 20241216000000_add_version_column 迁移
- presence-service: 添加 20241204000000_init 初始化迁移(包含 version 字段)
- presence-service: 删除无效的 20251215100000 迁移(依赖不存在的表)
验证所有服务 schema 与 migration 一致性:
- identity-service: ✅ OK
- wallet-service: ✅ 已修复
- blockchain-service: ✅ OK (无 version 字段)
- planting-service: ✅ OK
- reward-service: ✅ OK
- referral-service: ✅ OK
- leaderboard-service: ✅ OK
- presence-service: ✅ 已修复
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-15 21:53:31 -08:00
hailin
b705c6aa91
feat(wallet-service): 新增分享权益池账户S0000000005
...
- 新增 S0000000005 分享权益池系统账户 (user_id = -5)
- 修改 reward-service: 无推荐人的分享权益(500 USDT/棵)进入分享权益池
- 与总部社区账户(S0000000001)分离,便于单独追踪无推荐人的分享权益
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-13 18:53:21 -08:00
hailin
8f81c46d75
feat: 省市团队账户及待领取奖励逐笔追踪
...
1. authorization-service:
- 省团队权益分配改用系统省团队账户 (7+provinceCode)
- 市团队权益分配改用系统市团队账户 (6+cityCode)
- 无推荐链时不再进总部,而是进对应团队账户
2. wallet-service:
- 新增 pending_rewards 表支持逐笔追踪待领取奖励
- ensureRegionAccounts 同时创建区域账户和团队账户
- 新增 getPendingRewards API 查询待领取列表
- 新增 settleUserPendingRewards 用户认种后结算
- 新增 processExpiredRewards 定时处理过期奖励
- PlantingCreatedHandler 监听认种事件触发结算
- ExpiredRewardsScheduler 每小时处理过期奖励
账户格式:
- 省区域: 9+provinceCode (如 9440000)
- 市区域: 8+cityCode (如 8440100)
- 省团队: 7+provinceCode (如 7440000)
- 市团队: 6+cityCode (如 6440100)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-13 03:32:47 -08:00
hailin
98d8bee20d
fix: 统一推荐码生成逻辑 - 由 identity-service 单点生成
...
重要变更:
- identity-service 生成用户推荐码,通过 Kafka 事件传递给 referral-service
- referral-service 不再自己生成推荐码,直接使用事件中的推荐码
- 修复两个服务推荐码不一致的问题
涉及服务:
- identity-service: 事件 payload 添加 referralCode 字段
- referral-service: 接收并存储 identity-service 生成的推荐码
- wallet-service: 添加区域账户动态创建接口
- planting-service: 调用区域账户创建接口
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-13 01:14:56 -08:00
hailin
ebbf2d971a
feat: 跨服务使用 accountSequence 查询推荐链 + 系统账户动态创建
...
1. reward-service 使用 accountSequence 查询推荐链
- event-consumer.controller.ts: 优先使用 accountSequence 作为用户标识
- reward-calculation.service.ts: 使用 accountSequence 查询推荐关系
- referral-service.client.ts: 参数从 userId 改为 accountSequence
2. referral-service 支持 accountSequence 格式的推荐链查询
- referral.controller.ts: /chain/:identifier 同时支持 userId 和 accountSequence
3. wallet-service 系统账户动态创建
- wallet-application.service.ts: allocateToUserWallet 使用 getOrCreate
- 支持省区域(9+code)和市区域(8+code)账户自动创建
- 新增 migration seed: 4个固定系统账户 (S0000000001-S0000000004)
4. planting-service 事件增强
- 事件中添加 accountSequence 字段用于跨服务关联
系统账户格式:
- S0000000001: 总部社区 (基础费9U + 兜底权益)
- S0000000002: 成本费账户 (400U)
- S0000000003: 运营费账户 (300U)
- S0000000004: RWAD底池账户 (800U)
- 9+provinceCode: 省区域系统账户 (动态创建)
- 8+cityCode: 市区域系统账户 (动态创建)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-12 23:22:01 -08:00
hailin
d94badfa53
fix(wallet-service): 修复 account_sequence 类型从 BIGINT 改为 VARCHAR(20)
...
与其他服务保持一致,accountSequence 格式为 D + YYMMDD + 5位序号
- wallet_accounts.account_sequence
- wallet_ledger_entries.account_sequence
- deposit_orders.account_sequence
- withdrawal_orders.account_sequence
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-12 18:46:37 -08:00
hailin
538aae4ef0
feat(sync): implement Outbox Pattern for reward-service to wallet-service sync
...
Add event synchronization infrastructure between reward-service and wallet-service:
reward-service changes:
- Add OutboxEvent model to prisma schema for reliable event publishing
- Add outbox.repository.ts for outbox table CRUD operations
- Add outbox-publisher.service.ts for polling and publishing events to Kafka
- Add event-ack.controller.ts to receive consumer confirmations
wallet-service changes:
- Add ProcessedEvent model to prisma schema for idempotency checking
- Add reward-event-consumer.controller.ts to consume reward.summary.updated events
- Add event-ack.publisher.ts to send ACK to reward-service
- Update kafka.module.ts with Kafka client configuration
- Update main.ts to connect Kafka microservice on startup
Event flow: reward-service -> Kafka (reward.summary.updated) -> wallet-service -> Kafka (reward.events.ack) -> reward-service
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 23:26:49 -08:00
hailin
b98844abe4
feat(db): add Prisma migrations for wallet-service and planting-service
...
- Add initial migration for wallet-service (wallet_accounts, ledger_entries, deposit/settlement/withdrawal orders)
- Add initial migration for planting-service (planting_orders, fund_allocations, positions, batches, events)
- Both services now have migrations that will be automatically applied on container startup via `prisma migrate deploy`
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-09 20:30:23 -08:00