hailin
4ec6c9f48b
feat(contribution/mining-app): add team tree API using contribution-service 2.0
...
Add team info and direct referrals endpoints to contribution-service,
using SyncedReferral data synced via CDC. Update mining-app to use the
new v2 contribution API instead of legacy referral-service.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 09:17:18 -08:00
hailin
b5fca7bb04
fix(mining-admin): 修复算力同步状态检查的 API 路径
...
- contribution-service: 给 /contribution/stats 接口添加 @Public() 装饰器
- mining-admin-service: 修正 API 路径从 api/v1 改为 api/v2
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 03:09:05 -08:00
hailin
81a58edaca
fix(contribution-service): calculate totalContribution correctly in CDC event
...
Previously, totalContribution was incorrectly set to effectiveContribution.
Now correctly calculated as: personal + teamLevel + teamBonus
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 23:40:50 -08:00
hailin
849f346891
fix(contribution-service): 修复控制器路由路径与前端API不匹配
...
将控制器路由从 /contributions 改为 /contribution,
与前端 api_endpoints.dart 中定义的路径保持一致。
完整路径: /api/v2/contribution/accounts/{accountSequence}
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 17:42:10 -08:00
hailin
ace1e8673b
feat(deploy-mining): rebuild命令增加服务重启功能
...
rebuild命令现在会在构建完成后自动停止旧服务并启动新服务,
而不仅仅是编译镜像。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 17:18:25 -08:00
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
eaead7d4f3
feat(contribution-service): 添加算力管理微服务
...
## 概述
为榴莲生态2.0添加 contribution-service 微服务,负责算力计算、分配和快照管理。
## 架构设计
- 采用 DDD + Hexagonal Architecture (六边形架构)
- 使用 NestJS 框架 + Prisma ORM
- 通过 Kafka CDC (Debezium) 从 user-service 同步数据
- 使用 accountSequence (而非 userId) 进行跨服务关联
## 核心功能模块
### 1. Domain Layer (领域层)
- ContributionAccountAggregate: 算力账户聚合根
- ContributionRecordAggregate: 算力记录聚合根
- ContributionAmount: 算力金额值对象 (基于 Decimal.js)
- DistributionRate: 分配比例值对象
- ContributionSourceType: 算力来源类型枚举 (PERSONAL/TEAM_LEVEL/TEAM_BONUS)
### 2. Application Layer (应用层)
- ContributionCalculationService: 算力计算核心服务
- 个人算力: 认种金额 × 10
- 团队等级奖励: 基于直推有效认种人数
- 团队极差奖励: 多级分销算法
- SnapshotService: 每日算力快照服务
- CDC Event Handlers: 处理用户、认种、引荐关系同步事件
### 3. Infrastructure Layer (基础设施层)
- Prisma Repositories:
- ContributionAccountRepository
- ContributionRecordRepository
- SyncedDataRepository (同步数据)
- OutboxRepository (发件箱模式)
- SystemAccountRepository
- UnallocatedContributionRepository
- Kafka CDC Consumer: 消费 Debezium CDC 事件
- Redis: 缓存支持
- UnitOfWork: 事务管理
### 4. API Layer (接口层)
- ContributionController: 算力查询接口
- SnapshotController: 快照管理接口
- HealthController: 健康检查
## 数据模型 (Prisma Schema)
- ContributionAccount: 算力账户
- ContributionRecord: 算力记录 (支持过期)
- DailyContributionSnapshot: 每日快照
- SyncedUser/SyncedAdoption/SyncedReferral: CDC 同步数据
- OutboxEvent: 发件箱事件
- SystemContributionAccount: 系统账户
- UnallocatedContribution: 未分配算力
## TypeScript 类型修复
- 修复所有 Repository 接口与实现的类型不匹配
- 修复 ContributionAmount.multiply() 返回值类型
- 修复 isZero getter vs method 问题
- 修复 bigint vs string 类型转换
- 统一使用 items/total 返回格式
- 修复 Prisma schema 字段名映射 (unallocType, contributionBalance 等)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 17:39:25 -08:00