Commit Graph

1834 Commits

Author SHA1 Message Date
hailin a539b33dff fix(contribution-service): 优化账户查询API返回有意义的业务状态
- 新增 ContributionAccountStatus 枚举区分三种状态:
  - ACTIVE: 账户正常,有算力数据
  - INACTIVE: 用户存在但暂无认种记录
  - USER_NOT_FOUND: 账户不存在
- 移除 404 错误响应,统一返回 200 并通过 status 和 message 字段描述状态
- 为不同状态提供友好的中文提示信息

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 17:13:38 -08:00
hailin 5ee6caa190 fix(contribution-service): 修复Kafka消息BigInt序列化错误
JSON.stringify无法序列化BigInt,添加自定义replacer将BigInt转换为字符串

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 09:57:21 -08:00
hailin a40e314c94 fix(contribution-service): 修复adoption handler事务嵌套问题
将upsertSyncedAdoption和calculateForAdoption分离为两个独立操作,
避免嵌套事务导致内层事务看不到外层事务尚未提交的数据

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 09:52:00 -08:00
hailin 5006a5a170 fix(contribution-service): 修复synced_adoptions.status字段长度
1.0 planting_orders.status是VARCHAR(30),2.0需要匹配以避免数据截断错误

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 09:45:08 -08:00
hailin 5f76108579 fix(contribution-service): 修复CDC消息解析以支持Debezium扁平化格式
Debezium配置了ExtractNewRecordState转换,消息格式是扁平化的:
- 元数据字段使用__前缀(__op, __table, __source_ts_ms, __deleted)
- 业务数据字段直接在根级别
- 修改handleMessage方法正确解析扁平化格式
- 更新CDCEvent接口以匹配实际消息结构

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 09:39:09 -08:00
hailin 4b55c63e71 fix(contribution-service): 修复CDC同步字段映射,支持完整同步referral数据
主要更改:
1. synced_referrals表增加referrer_user_id和original_user_id字段
   - 1.0的referral_relationships表只有referrer_id(user_id),没有referrer_account_sequence
   - 保存原始user_id以便后续解析推荐人的account_sequence

2. 修复referral-synced.handler字段映射
   - 正确处理1.0的user_id、referrer_id、ancestor_path字段
   - ancestor_path从BigInt[]数组转换为逗号分隔的字符串

3. 修复cdc-event-dispatcher表名注册
   - 使用正确的表名: referral_relationships, planting_orders
   - 移除不需要的user_accounts注册

4. 更新docker-compose.2.0.yml
   - 添加CDC_TOPIC_REFERRALS配置
   - 移除未使用的CDC_TOPIC_PAYMENTS

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 09:27:01 -08:00
hailin 05a8168a31 fix(contribution-service): 修复CDC同步配置,使用正确的planting-service topic
- 修改CDC topic为cdc.planting.public.planting_orders
- 更新healthcheck使用api/v2
- 更新handler适配planting_orders表字段

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 09:18:37 -08:00
hailin a14daae222 fix: update mining-service package-lock.json
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 09:12:48 -08:00
hailin 0e05139c01 fix(contribution-service): 统一使用api/v2前缀
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 09:05:42 -08:00
hailin 73381a4376 fix: 修复contribution-service路由映射
- Kong: /api/v2/contribution -> /api/v1/contributions (strip_path)
- mining-app: 添加/accounts前缀匹配controller路径

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 09:04:21 -08:00
hailin 1256bc2fdd fix(mining-app): 修复auth API路径,移除多余的/auth层
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 08:58:25 -08:00
hailin 849fa77df0 fix(auth-service): 允许synced_legacy_users的phone和password_hash为空
- 修改schema让phone和passwordHash字段可为空
- 添加migration: 20260111083500_allow_nullable_phone_password
- CDC consumer使用null替代空字符串
- 支持同步没有手机号/密码的系统账户

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 08:37:02 -08:00
hailin 6caae7c860 fix(auth-service): 跳过无手机号/密码的系统账户CDC同步
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 08:33:39 -08:00
hailin a749a3b9e1 fix: 修复auth-service CDC配置和API路由
- 修复docker-compose.2.0.yml中CDC_TOPIC_USERS为正确的topic名称
- 添加CDC_ENABLED环境变量
- 更新Kong配置auth-service路由使用strip_path
- 更新mining-app API端点匹配v2服务路由
- 更新mining-app baseUrl指向Kong网关根路径

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 08:29:16 -08:00
hailin dd77dc65d1 fix(mining-app): 添加assets/images目录
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 08:12:29 -08:00
hailin 8e2073bc5a feat(mining-app): 添加Android/iOS平台配置和编译支持
- 添加Android平台文件(包名: com.rwadurian.mining_app)
- 添加iOS平台文件
- 配置应用名称为"榴莲挖矿"
- 添加网络权限和明文流量支持
- 配置minSdk为24,启用multidex
- 添加debug/release构建类型
- 创建proguard混淆规则
- 添加环境配置文件

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 08:06:53 -08:00
hailin 5727192719 feat(mining-app): 重新设计四个主要导航页面UI
- 贡献值页面: 新增贡献值卡片、算力排行榜、收益统计等模块
- 兑换页面: 添加K线图、市场数据、买卖面板等交易界面
- 资产页面: 实现总资产卡片、快捷操作、资产列表、收益统计
- 我的页面: 添加用户头部信息、邀请码、账户设置、记录入口等
- 更新底部导航为: 贡献值、兑换、资产、我的
- 登录/注册后跳转到贡献值页面

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 07:56:23 -08:00
hailin 26dce24e75 feat(mining-app): 添加找回密码和修改密码功能
- 添加 /password/reset 和 /password/change API 端点
- 在 auth_remote_datasource 中实现 resetPassword 和 changePassword 方法
- 在 user_providers 中添加状态管理方法
- 创建找回密码页面 (forgot_password_page.dart)
- 创建修改密码页面 (change_password_page.dart)
- 添加路由配置
- 在登录页面添加"忘记密码"链接
- 在个人资料页面添加"修改密码"入口

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 07:36:56 -08:00
hailin 36d7b7ebfe fix(docker-compose.2.0): 修复healthcheck路径为/api/v1/health并增加start_period到60s
docker-compose.yml里的healthcheck配置会覆盖Dockerfile里的配置

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 07:25:30 -08:00
hailin 1b425e09c9 fix(contribution-service): 添加@Public装饰器到HealthController以绕过JWT认证
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 07:02:17 -08:00
hailin 673e5ff772 fix(dockerfiles): 修复2.0服务健康检查路径
- 修正健康检查URL从 /health 到 /api/v1/health(因为设置了全局前缀)
- 增加 start-period 从 10s 到 60s,给服务更多启动时间

受影响服务:
- contribution-service
- mining-service
- mining-admin-service
- trading-service
- mining-wallet-service

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 06:45:44 -08:00
hailin f26a796244 fix(contribution-service): 修复migration为完整初始化脚本
将增量migration改为完整的初始化migration,包含所有表的CREATE TABLE语句。
原migration使用ALTER TABLE假设表已存在,但这是服务的第一个migration文件。

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 06:31:24 -08:00
hailin 6261679f5a feat(contribution-service, mining-service): 添加18级待解锁算力字段和挖矿收益分配表
contribution-service:
- 添加15级层级待解锁字段 (level1-15Pending)
- 添加3档加成待解锁字段 (bonusTier1-3Pending)
- 添加解锁状态追踪字段 (hasAdopted, directReferralAdoptedCount等)
- 重构ContributionAccountAggregate支持新字段结构
- 更新repository和query处理effectiveContribution

mining-service:
- 添加MiningRewardAllocation表追踪每日挖矿收益分配明细
- 添加DailyMiningRewardSummary表汇总账户每日收益
- 添加HeadquartersPendingReward表记录未解锁算力收益归总部明细
- 创建初始migration文件

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 06:16:15 -08:00
hailin 4bb995f2c2 feat(auth-service,mining-app): 实现完整认证流程和CDC用户同步
auth-service:
- 添加DTO验证装饰器(IsString, IsNotEmpty, Matches, MinLength)
- 添加短信验证码登录(loginBySms)方法
- 修复CDC Consumer字段映射匹配1.0 user_accounts表
- 更新CDC topic为cdc.identity.public.user_accounts

mining-app (Flutter):
- 新增auth_remote_datasource实现真实API调用
- 新增登录页面(密码/短信切换)和注册页面
- 替换splash_page中的mock登录为真实状态检查
- 添加token自动注入拦截器到ApiClient
- 配置生产环境API指向Kong网关

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 05:29:48 -08:00
hailin 9fca17e7ed fix(mining-admin-web): 修复auth API类型定义
更新 TypeScript 类型以匹配后端响应格式:
- ApiResponse<T> 包装器
- LoginData 和 ProfileData 接口

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 01:10:05 -08:00
hailin e28fe56489 fix(mining-admin-web): 适配后端API响应格式
后端返回格式为 { success, data: {...} },
修改 login 和 getProfile 解析 response.data.data

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 01:05:55 -08:00
hailin 25ad627377 feat(mining-admin-service): 添加/auth/profile接口
前端dashboard layout需要获取当前用户信息,添加GET /auth/profile接口

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 01:01:49 -08:00
hailin 86f2c85f8d fix(mining-admin-service): 修复LoginDto验证装饰器缺失
添加 @IsString() 和 @IsNotEmpty() 装饰器到 LoginDto,
修复 ValidationPipe forbidNonWhitelisted 导致的400错误

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 00:54:37 -08:00
hailin fe7dda396f fix(kong): 修复mining-admin-service路由映射
使用strip_path:true并将url设为/api/v1,
使Kong路由 /api/v2/mining-admin/* -> 服务 /api/v1/*

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 00:50:29 -08:00
hailin 341e319fd3 feat(mining-admin-web): 配置生产环境API指向Kong网关
修改:
1. frontend/mining-admin-web/src/lib/api/client.ts
   - 使用环境变量 NEXT_PUBLIC_API_URL 配置 API baseURL
   - 开发环境默认使用 /api 代理

2. frontend/mining-admin-web/.env.production (新增)
   - NEXT_PUBLIC_API_URL=https://rwaapi.szaiai.com/api/v2/mining-admin

3. backend/api-gateway/kong.yml
   - CORS origins 添加 https://madmin.szaiai.com
   - CORS origins 添加 http://localhost:3100

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 00:28:17 -08:00
hailin 42e6b5c27c feat(gateway): 添加2.0服务路由到Kong和nginx配置
Kong网关:
- 添加contribution-service-v2 (3020)
- 添加mining-service-v2 (3021)
- 添加trading-service-v2 (3022)
- 添加mining-admin-service (3023)
- 添加auth-service-v2 (3024)
- 添加mining-wallet-service (3025)

Nginx (madmin.szaiai.com):
- 添加/api/代理到mining-admin-service:3023
- 支持CORS预检请求

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 00:22:23 -08:00
hailin 51456373a9 feat(2.0-services): 添加所有服务的初始Prisma migrations
使用 prisma migrate diff 生成初始数据库迁移脚本:
- mining-admin-service: 管理后台相关表及CDC同步表
- auth-service: 用户认证相关表
- trading-service: 交易相关表
- mining-wallet-service: 钱包相关表

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 00:06:46 -08:00
hailin 7f72c1e1ec fix(2.0-services): 修复InfrastructureModule导出PrismaService问题
NestJS不允许模块导出未在providers中声明的服务。
将exports中的PrismaService改为PrismaModule(因为PrismaModule已导出PrismaService)。

修复服务:
- mining-admin-service
- auth-service

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 00:00:50 -08:00
hailin c4ee8ed6a9 fix(2.0-services): 更新package-lock.json并添加bcrypt编译支持
- mining-admin-service: 更新package-lock.json以包含bcrypt依赖
- auth-service: Dockerfile添加python3 make g++用于编译bcrypt

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:53:11 -08:00
hailin c032f30f7b fix(mining-admin-service): 添加bcrypt依赖和编译工具
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:49:26 -08:00
hailin 319a787c43 fix(2.0-dockerfiles): 添加openssl解决Prisma兼容性问题
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:46:14 -08:00
hailin 576aad8691 fix(deploy-mining): rebuild默认不使用--no-cache,需显式指定
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:40:08 -08:00
hailin c1de1daea8 fix(2.0-dockerfiles): 使用printf替代echo解决alpine兼容性问题
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:37:29 -08:00
hailin 1c3e7809ad fix(docker-compose.2.0): 使用external连接1.0网络services_rwa-network
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:31:53 -08:00
hailin 86091097a6 fix(docker-compose.2.0): 使用bridge驱动自建网络而非external
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:28:41 -08:00
hailin d3fecc42c1 fix(2.0-services): 优化所有Dockerfile使用--chown避免chown -R
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:23:57 -08:00
hailin 81f8422758 fix(mining-admin-service): 优化Dockerfile使用--chown避免chown -R
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:22:34 -08:00
hailin 0467e17032 fix(docker-compose.2.0): 移除对外部基础设施服务的depends_on
2.0服务使用external network连接1.0的基础设施,不需要depends_on

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:18:20 -08:00
hailin 0a433eca40 . 2026-01-11 15:14:25 +08:00
hailin a36bdcdda5 fix(deploy-mining): 使用docker compose替代npm进行构建和部署
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:11:42 -08:00
hailin ca55a81263 feat(mining-wallet-service): 添加独立钱包管理微服务
- 新增 mining-wallet-service 完整实现,100% 与 1.0 系统隔离
- 支持系统账户:总部、运营、省公司、市公司、手续费、热钱包、冷钱包
- 支持池账户:份额池、黑洞池、流通池
- 支持用户钱包:算力钱包、代币存储钱包、绿积分钱包
- 实现用户-区域映射(独立于 1.0)
- 集成 KAVA 区块链:提现、充值、DEX Swap
- 所有交易记录包含交易对手信息(counterparty)
- 使用 Outbox 模式确保事件可靠发布

feat(mining-admin-service): 添加 mining-wallet-service CDC 同步

- 新增 13 个 Synced 同步表接收钱包服务数据
- 新增 wallet-sync.handlers.ts 处理钱包服务事件
- 更新 cdc-sync.service.ts 注册钱包服务事件处理器

chore(mining-service, trading-service): 为池账户添加 counterparty 跟踪字段

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 22:21:08 -08:00
hailin ee5f841034 fix(outbox): 实现指数退避重试策略,最大延迟3小时
修复Outbox事件发布的重试机制:

1. 更新Prisma Schema (mining-service, trading-service):
   - 添加OutboxStatus枚举 (PENDING, PUBLISHED, FAILED)
   - 添加topic、key、status、retryCount、maxRetries、lastError等字段
   - 添加publishedAt、nextRetryAt时间戳
   - 优化索引 (status, nextRetryAt, createdAt)

2. 更新OutboxRepository (mining-service, trading-service):
   - findPendingEvents(): 查询待处理且到达重试时间的事件
   - markAsPublished(): 标记事件已发布
   - markAsFailed(): 实现指数退避算法 (30s基础, 最大3小时)
   - deletePublished(): 清理已发布的旧事件

3. 更新OutboxScheduler (auth/mining/trading-service):
   - 使用指数退避: 30s, 60s, 120s, 240s, ... 最大10800s (3小时)
   - 记录重试次数和错误信息
   - 达到最大重试次数后标记为FAILED

指数退避公式: delay = min(30s * 2^(retryCount-1), 3h)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 21:08:57 -08:00
hailin 28ad8c2e2f feat(2.0-services): 为auth/mining/trading服务添加Outbox事件发布机制
- auth-service:
  - 添加Kafka生产者模块和服务
  - 添加Redis服务用于分布式锁
  - 添加OutboxScheduler定时发布Outbox事件到Kafka
  - 更新InfrastructureModule为全局模块

- mining-service:
  - 添加Kafka生产者服务
  - 添加OutboxRepository用于管理Outbox事件
  - 添加OutboxScheduler定时发布事件

- trading-service:
  - 添加Kafka生产者服务
  - 添加OutboxRepository用于管理Outbox事件
  - 添加OutboxScheduler定时发布事件

所有服务的Outbox调度器:
- 每30秒发布待处理的事件到Kafka
- 每天凌晨3点清理7天前已处理的事件
- 使用Redis分布式锁确保多实例部署时只有一个实例处理

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 20:54:37 -08:00
hailin 15a5fb6c14 feat(mining-admin-service): 添加CDC同步和完整用户管理API
## Prisma Schema 更新
- 添加 CDC 同步表:SyncedUser, SyncedContributionAccount, SyncedMiningAccount, SyncedTradingAccount
- 添加系统数据同步表:SyncedMiningConfig, SyncedDailyMiningStat, SyncedDayKLine, SyncedCirculationPool
- 添加 CDC 进度跟踪:CdcSyncProgress, ProcessedEvent

## CDC 消费者模块
- CdcConsumerService: Kafka 消费者,支持 Debezium CDC 和服务间事件
- CdcSyncService: 同步处理器,从 auth/contribution/mining/trading 服务同步数据

## 新增 API 端点
### 用户管理 (/api/v1/users)
- GET /users - 用户列表(分页、搜索、过滤)
- GET /users/:accountSequence - 用户详情
- GET /users/:accountSequence/contributions - 算力记录
- GET /users/:accountSequence/mining-records - 挖矿记录
- GET /users/:accountSequence/orders - 交易订单

### 系统账户 (/api/v1/system-accounts)
- GET /system-accounts - 系统账户列表
- GET /system-accounts/summary - 系统账户汇总

### 仪表盘增强 (/api/v1/dashboard)
- GET /dashboard - 统计数据(新增用户/算力/挖矿/交易统计)
- GET /dashboard/realtime - 实时数据
- GET /dashboard/stats - 统计数据(别名)

## Docker Compose 更新
- 添加 Kafka 依赖和 CDC topic 配置
- 添加与 auth-service 的依赖关系

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 20:36:21 -08:00
hailin 2a09fca728 chore(mining-admin-web): 添加.gitignore文件
忽略以下自动生成的文件:
- node_modules/
- .next/
- next-env.d.ts
- *.tsbuildinfo
- .env*.local

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 20:18:35 -08:00