hailin
6900905475
fix(mining-admin): APK下载URL指向localhost导致手机无法下载
...
问题:FileStorageService 默认 UPLOAD_BASE_URL 为 http://localhost:3020/downloads ,
手机端无法访问服务器的 localhost。
修复:
- docker-compose.2.0.yml: 添加 UPLOAD_BASE_URL=https://rwaapi.szaiai.com/mining-admin/downloads
- 添加 mining-admin-uploads volume 持久化上传的 APK 文件
- 修正默认端口 3020→3023(mining-admin-service 实际端口)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 12:56:40 -08:00
hailin
dc51c19dfd
fix(mining-admin): 修复 APK 解析 adbkit-apkreader 导入方式
...
adbkit-apkreader 是 CJS 模块,直接导出 class(module.exports = ApkReader),
不存在 .default 属性。将 dynamic import 改为 require 直接调用 ApkReader.open()。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 13:45:25 -08:00
hailin
b4afc4615c
fix(mining-admin-service): 修复 APK 解析和添加 AppVersion migration
...
1. 修复 package-parser.service.ts:
- ApkReader.open 需要文件路径,改为先写入临时文件再解析
- 添加 fs/path/os 模块导入
- 完成后自动清理临时文件
2. 添加 AppVersion 表 migration:
- 创建 Platform 枚举类型 (ANDROID, IOS)
- 创建 app_versions 表
- 添加必要索引
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 22:24:45 -08:00
hailin
76d566d145
feat: 集成 mining-app 升级和遥测功能,扩展 mobile-upgrade 支持多应用
...
## mining-app (Flutter)
- 新增 updater 模块: 版本检查、APK下载(断点续传+SHA256校验)、安装
- 新增 telemetry 模块: 事件上报、会话追踪、心跳检测(DAU统计)
- 集成原生 MethodChannel 实现 APK 安装
- 在关于页面添加"检查更新"功能入口
## mining-admin-service (NestJS)
- 新增版本管理 API (/api/v2/versions)
- 实现 DDD 架构: Entity, Value Objects, Repository
- 支持 APK/IPA 解析 (需安装 adbkit-apkreader, jszip, plist)
- 支持文件上传和静态文件服务
## mobile-upgrade (Next.js)
- 扩展支持多后端: 榴莲 App (admin-service) + 股行 App (mining-admin-service)
- 添加应用选择器 UI
- 配置独立的 API 端点
## 修复
- 移除未使用的 _apiBaseUrl 字段 (Flutter)
- 替换废弃的 WillPopScope 为 PopScope (Flutter)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 20:03:26 -08:00
hailin
e7260be219
feat(contribution): 添加系统账户算力来源类型字段
...
- 添加 sourceType 字段区分算力来源类型:
- FIXED_RATE: 固定比例分配(OPERATION 12%、PROVINCE 1%、CITY 2%)
- LEVEL_OVERFLOW: 层级溢出归总部(上线未解锁该级别)
- LEVEL_NO_ANCESTOR: 无上线归总部(该级无上线)
- BONUS_TIER_1/2/3: 团队奖励未解锁归总部
- 添加 levelDepth 字段记录层级深度(1-15级)
- 更新前端表格显示来源类型列
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 04:23:50 -08:00
hailin
946978f624
fix(mining-admin): 修复 PostgreSQL NULL 唯一约束导致系统账户数据重复问题
...
- 修改 synced_system_contributions 唯一索引使用 COALESCE 处理 NULL 值
- 修改 handleSystemAccountSynced 和 handleSystemContributionUpdated 方法
使用 findMany 替代 findFirst,自动清理重复记录
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 03:29:24 -08:00
hailin
6de365e707
fix(mining-admin): 修复 SystemContributionRecordCreated 事件字段映射
...
contribution-service 使用 systemAccountType 字段发布事件,
mining-admin-service 需要正确映射到 accountType 和 regionCode
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 01:09:44 -08:00
hailin
86c8ede198
fix(mining-admin): 修复 CDC 事件 eventId 解析问题
...
mining-wallet-service 发布的事件使用 eventId 字段而不是 id,
导致 normalizeServiceEvent 返回的对象没有 id 属性。
修复:在驼峰格式事件处理中,优先使用 data.id,回退到 data.eventId
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 22:41:55 -08:00
hailin
0a199ae3b5
Revert "fix(mining-admin): 修复 CDC 事件缺少 eventId 的问题"
...
This reverts commit fff56e8baa .
2026-01-20 22:38:42 -08:00
hailin
fff56e8baa
fix(mining-admin): 修复 CDC 事件缺少 eventId 的问题
...
- 在 normalizeServiceEvent 中添加对多种 id 字段的支持
- 当事件缺少 id 时,使用 aggregateId + timestamp 生成备用 ID
- 在 withIdempotency 中添加 event.id 验证,避免创建无效记录
- 修复驼峰格式事件可能没有 id 字段的问题
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 22:09:34 -08:00
hailin
7e61ac7ff2
fix(system-accounts): 修复 Prisma nullable regionCode 复合唯一键查询问题
...
- 将所有使用 accountType_regionCode 复合键的 findUnique 改为 findFirst
- 将所有 upsert 改为 findFirst + create/update 模式
- 原因:Prisma 复合唯一键不支持 nullable 字段的 findUnique 查询
影响的服务:
- mining-service: admin.controller.ts, system-mining-account.repository.ts
- mining-admin-service: cdc-sync.service.ts, system-accounts.service.ts
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 21:45:13 -08:00
hailin
9062346650
refactor(system-accounts): 移除 baseType 字段,使用 accountType+regionCode 复合唯一键
...
## 主要变更
### 数据模型简化
- 移除冗余的 baseType 字段,accountType 已包含类型信息
- 使用 accountType (OPERATION/PROVINCE/CITY/HEADQUARTERS) + regionCode (省市代码) 作为复合唯一键
- 所有查询改用 accountType+regionCode,100% 弃用数据库自增 ID
### contribution-service
- SystemAccount 表移除 baseType,改用 accountType+regionCode 唯一约束
- 修改算力分配逻辑,省市账户使用对应 regionCode
- 事件发布增加 regionCode 字段
### mining-service
- SystemMiningAccount 表使用 accountType+regionCode 唯一约束
- API 改为 /system-accounts/:accountType/records?regionCode=xxx 格式
- 挖矿分配逻辑支持按省市细分
### mining-admin-service
- SyncedSystemContribution 表使用 accountType+regionCode 唯一约束
- CDC 同步处理器适配新格式
- API 统一使用 accountType+regionCode 查询
## API 示例
- 运营账户: GET /admin/system-accounts/OPERATION/records
- 广东省: GET /admin/system-accounts/PROVINCE/records?regionCode=440000
- 广州市: GET /admin/system-accounts/CITY/records?regionCode=440100
- 总部: GET /admin/system-accounts/HEADQUARTERS/records
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 21:29:01 -08:00
hailin
09b0bc077e
feat(system-accounts): 实现系统账户按省市细分算力和挖矿分配
...
## 核心功能
### 1. 算力按省市细分分配
- accountType 从枚举改为组合键字符串:PROVINCE_440000, CITY_440100
- 新增 baseType (基础类型) 和 regionCode (区域代码) 字段
- 认种时根据 selectedProvince/selectedCity 分配到具体省市账户
- 无省市信息时归入汇总账户
### 2. 系统账户参与挖矿
- 运营、省、市账户按各自 totalContribution 参与挖矿
- 总部账户(HEADQUARTERS)不直接参与,接收待解锁算力收益
- 待解锁算力 100% 参与挖矿,收益归总部
### 3. 算力来源明细追溯
- 新增 SystemContributionRecord 记录每笔算力来源
- 新增 SystemContributionRecordCreatedEvent 事件同步明细
- 前端新增"算力来源"标签页展示明细
## 修改的服务
### contribution-service
- schema: SystemAccount 新增 baseType, regionCode
- contribution-calculator: 按省市生成组合键
- system-account.repository: 支持动态创建省市账户
- 新增 SystemContributionRecordCreatedEvent 事件
### mining-service
- schema: SystemMiningAccount 从枚举改为字符串
- network-sync: 处理带 baseType/regionCode 的同步事件
- mining-distribution: 系统账户和待解锁算力参与挖矿
### mining-admin-service
- schema: 新增 SyncedSystemContributionRecord 表
- cdc-sync: 处理 SystemContributionRecordCreated 事件
- system-accounts.service: 新增算力来源明细和统计 API
### mining-admin-web
- 新增 ContributionRecordsTable 组件
- 系统账户详情页新增"算力来源"标签页
- 显示来源认种ID、用户、分配比例、金额
## 数据库迁移
- contribution-service: 20250120000001_add_region_to_system_accounts
- mining-service: 20250120000001_add_region_to_system_mining_accounts
- mining-admin-service: 20250120000001, 20250120000002
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 19:55:14 -08:00
hailin
d957e5a841
feat(admin): 系统账户添加已挖积分股显示和分类账功能
...
## 后端改动
### mining-service
- 新增 GET /admin/system-accounts/:accountType/records - 获取系统账户挖矿记录(分钟级)
- 新增 GET /admin/system-accounts/:accountType/transactions - 获取系统账户交易记录
### mining-admin-service
- 添加 @nestjs/axios 依赖用于 HTTP 调用
- 修改 SystemAccountsService,通过 HTTP 调用 mining-service 获取挖矿数据(totalMined, availableBalance)
- 新增挖矿记录和交易记录的代理 API
## 前端改动
### 类型定义
- SystemAccount 新增 totalMined, availableBalance, miningContribution, miningLastSyncedAt 字段
### API 层
- 新增 getMiningRecords 和 getTransactions API 方法
- 新增 SystemMiningRecord, SystemTransaction 等类型定义
### Hooks
- 新增 useSystemAccountMiningRecords 和 useSystemAccountTransactions
### 组件
- AccountsTable 新增"已挖积分股"列,显示每个系统账户累计挖到的积分股
- AccountsTable 新增"分类账"按钮,可跳转到账户详情页
### 新页面
- 新建 /system-accounts/[accountType] 详情页面
- 账户概览卡片:当前算力、已挖积分股、可用余额、挖矿记录数
- 挖矿记录 Tab:分钟级挖矿明细(时间、算力占比、全网算力、每秒分配量、挖得数量)
- 交易记录 Tab:所有交易流水(时间、类型、金额、交易前后余额、备注)
- 支持分页浏览
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 05:53:03 -08:00
hailin
8319fe5e9a
fix(mining-admin): 修复 MiningConfigUpdated 事件缺少 minuteDistribution 字段
...
mining-service 发布的事件中只有 secondDistribution,CDC 同步时需要
计算 minuteDistribution = secondDistribution * 60
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 04:08:04 -08:00
hailin
b645621c81
fix(admin): add SystemAccountSynced event handler for system contribution sync
...
The mining-admin-service was only listening for SystemContributionUpdated
events, but contribution-service publishes SystemAccountSynced events.
Added the missing handler to properly sync system account contribution data.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 09:22:59 -08:00
hailin
839feab97d
fix(mining-admin): handle CONTRIBUTION_CREDITED event for wallet sync
...
Add handler for CONTRIBUTION_CREDITED events from mining-wallet-service
to sync user wallet data to synced_user_wallets table.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 06:11:49 -08:00
hailin
5e16adc1ec
fix(mining-admin): use outbox_id for event idempotency key
...
The outbox_events table uses outbox_id as the primary key column name
(mapped from id in Prisma). When Debezium captures changes, the message
contains outbox_id field, not id. This caused all events to have
undefined eventId, resulting in duplicate detection treating all events
as duplicates after the first one.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 21:41:54 -08:00
hailin
70135938c4
feat(mining-admin): implement transactional idempotent consumer for 100% exactly-once semantics
...
- Use Prisma $transaction with Serializable isolation level
- Insert idempotency record FIRST, then execute business logic
- Unique constraint violation (P2002) indicates duplicate event
- All operations atomic - either fully commit or fully rollback
- Modified all handlers to accept transaction client parameter
- Removed old non-atomic isEventProcessed/recordProcessedEvent methods
This ensures 100% data consistency for CDC synchronization, which is
critical for financial data where any error is catastrophic.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 19:11:30 -08:00
hailin
577f626972
fix(cdc): implement idempotent consumer pattern for reliable CDC sync
...
- Use (sourceTopic, eventId) as composite unique key in processed_events
- Add sourceTopic to ServiceEvent for globally unique idempotency key
- Wrap all handlers with withIdempotency() for duplicate event detection
- Fix ID collision issue between different service outbox tables
This implements the industry-standard CDC exactly-once semantics pattern.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 13:31:10 -08:00
hailin
bf5a16939f
fix(mining-admin-service): ignore Debezium heartbeat messages
...
- Add isHeartbeatMessage to detect heartbeat messages (only have ts_ms field)
- Skip processing for heartbeat messages to avoid unnecessary warnings
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 07:44:27 -08:00
hailin
30e1867eb0
fix(mining-admin-service): properly handle Debezium outbox CDC events
...
- Add isDebeziumOutboxEvent to detect outbox table CDC messages
- Add handleDebeziumOutboxEvent to extract service event from payload.after
- Fix CDC consumer not recognizing events from contribution-service outbox
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 07:39:27 -08:00
hailin
dbe9ab223f
feat(contribution): fix pending fields update and add network progress tracking
...
- Fix updateContribution to properly update levelXPending and bonusTierXPending fields
- Add NetworkAdoptionProgress and DailyContributionRate tables for tracking contribution coefficient
- Create ContributionRateService for dynamic rate calculation (base 22617, +0.3% per 100 trees after 1000)
- Add ContributionRecordSynced and NetworkProgressUpdated events for CDC sync
- Add admin endpoints for network progress query and contribution records publishing
- Update mining-admin-service to sync contribution records and network progress
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 07:26:32 -08:00
hailin
180e5ad057
feat(mining-admin): 重构算力构成展示,添加解锁状态
...
- 后端添加 unlockedBonusTiers 字段同步
- 前端算力构成卡片展示层级解锁(L1-15)和团队奖励解锁(3档)状态
- 移除无用的系统运营/省级/市级字段
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 04:59:51 -08:00
hailin
30b04c6376
feat(sync): 完善 CDC 数据同步 - 添加推荐关系、认种记录和昵称字段
...
- auth-service:
- SyncedLegacyUser 表添加 nickname 字段
- LegacyUserMigratedEvent 添加 nickname 参数
- CDC consumer 同步 nickname 字段
- SyncedLegacyUserData 接口添加 nickname
- contribution-service:
- 新增 ReferralSyncedEvent 事件类
- 新增 AdoptionSyncedEvent 事件类
- admin.controller 添加 publish-all APIs:
- POST /admin/referrals/publish-all
- POST /admin/adoptions/publish-all
- mining-admin-service:
- SyncedUser 表添加 nickname 字段
- 新增 SyncedReferral 表 (推荐关系)
- 新增 SyncedAdoption 表 (认种记录)
- handleReferralSynced 处理器
- handleAdoptionSynced 处理器
- handleLegacyUserMigrated 处理 nickname
- deploy-mining.sh:
- full_reset 更新为 14 步
- Step 13: 发布推荐关系
- Step 14: 发布认种记录
解决 mining-admin-web 缺少昵称、推荐人、认种数据的问题
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 02:48:15 -08:00
hailin
40745ca580
feat(cdc): 完善 2.0 服务数据聚合到 mining-admin-service
...
1. deploy-mining.sh:
- 添加 outbox connectors 配置数组 (auth, contribution, mining, trading, wallet)
- 添加 register_outbox_connectors() 函数自动注册 Debezium 连接器
- 添加 outbox-register, outbox-status, outbox-delete 命令
- full-reset 更新为 12 步,包含注册 outbox connectors 和初始数据发布
2. contribution-service:
- 添加 ContributionAccountSyncedEvent 事件
- 添加 POST /admin/contribution-accounts/publish-all API 用于初始全量同步
3. mining-admin-service:
- 添加 ContributionAccountSynced 事件处理(复用 ContributionAccountUpdated 处理器)
- 添加 ContributionCalculated 事件处理
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 01:41:46 -08:00
hailin
0d06080760
fix(mining-admin): 兼容 Debezium outbox 消息格式
...
问题:Debezium 产生的 outbox 消息使用下划线命名(event_type,
aggregate_type),而代码期望驼峰格式(eventType, aggregateType)
解决方案:
- isServiceEvent() 同时检查两种命名格式
- 新增 normalizeServiceEvent() 转换 Debezium 格式到驼峰格式
- 解析 payload JSON 字符串
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 01:10:24 -08:00
hailin
63d73af135
refactor(cdc): 统一使用 Debezium CDC 进行数据同步
...
1. contribution-service:
- 添加 identity topic 订阅,全量同步 1.0 用户数据
- 修改 fromBeginning 为 true,首次启动全量同步
2. mining-admin-service:
- 将 Outbox 事件改为 Debezium CDC 监听 outbox_events 表
- 修改 fromBeginning 为 true,首次启动全量同步
3. 新增 5 个 2.0 服务的 Debezium connector 配置:
- auth-outbox-connector.json
- contribution-outbox-connector.json
- mining-outbox-connector.json
- trading-outbox-connector.json
- mining-wallet-outbox-connector.json
4. 更新 register-connectors.sh 脚本
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 23:19:34 -08:00
hailin
582beb4f81
feat(cdc): 添加 legacy 用户批量同步功能
...
auth-service:
- 添加 AdminController 和 AdminSyncService
- POST /admin/legacy-users/publish-all: 为所有 legacy 用户发布事件
- GET /admin/users/sync: 获取所有用户数据供同步
mining-admin-service:
- 添加 user.legacy.migrated 事件处理器
- 添加 sync-users 和 sync-contribution-accounts API
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 20:17:46 -08:00
hailin
49b1571bba
fix(cdc): 修复 auth-service 与 mining-admin-service 的 CDC 事件同步
...
- auth-service: 将 outbox topic 从 auth.events 改为 mining-admin.auth.users
- mining-admin-service: 添加 user.registered 和 user.kyc_verified 事件处理器
- 确保 auth-service 发布的事件能被 mining-admin-service 正确接收和处理
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 19:51:01 -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
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
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
a17f408653
feat(mining-ecosystem): 添加挖矿生态系统完整微服务与前端
...
## 概述
为榴莲生态2.0添加完整的挖矿系统,包含3个后端微服务、1个管理后台和1个用户端App。
---
## 后端微服务
### 1. mining-service (挖矿服务) - Port 3021
**核心功能:**
- 积分股每日分配(基于算力快照)
- 每分钟定时销毁(进入黑洞)
- 价格计算:价格 = 积分股池 ÷ (100.02亿 - 黑洞 - 流通池)
- 全局状态管理(黑洞量、流通池、价格)
**关键文件:**
- src/application/services/mining-distribution.service.ts - 挖矿分配核心逻辑
- src/application/schedulers/mining.scheduler.ts - 定时任务调度
- src/domain/services/mining-calculator.service.ts - 分配计算
- src/infrastructure/persistence/repositories/black-hole.repository.ts - 黑洞管理
### 2. trading-service (交易服务) - Port 3022
**核心功能:**
- 积分股买卖撮合
- K线数据生成
- 手续费处理(10%买入/卖出)
- 流通池管理
- 卖出倍数计算:倍数 = (100亿 - 销毁量) ÷ (200万 - 流通池量)
**关键文件:**
- src/domain/services/matching-engine.service.ts - 撮合引擎
- src/application/services/order.service.ts - 订单处理
- src/application/services/transfer.service.ts - 划转服务
- src/domain/aggregates/order.aggregate.ts - 订单聚合根
### 3. mining-admin-service (挖矿管理服务) - Port 3023
**核心功能:**
- 系统配置管理(分配参数、手续费率等)
- 老用户数据初始化
- 系统监控仪表盘
- 审计日志
**关键文件:**
- src/application/services/config.service.ts - 配置管理
- src/application/services/initialization.service.ts - 数据初始化
- src/application/services/dashboard.service.ts - 仪表盘数据
---
## 前端应用
### 1. mining-admin-web (管理后台) - Next.js 14
**技术栈:**
- Next.js 14 + React 18
- TailwindCSS + Radix UI
- React Query + Zustand
- ECharts 图表
**功能模块:**
- 登录认证
- 仪表盘(实时数据、价格走势)
- 用户查询(算力详情、挖矿记录、交易订单)
- 系统配置管理
- 数据初始化任务
- 审计日志查看
### 2. mining-app (用户端App) - Flutter 3.x
**技术栈:**
- Flutter 3.x + Dart
- Riverpod 状态管理
- GoRouter 路由
- Clean Architecture (3层)
**功能模块:**
- 首页资产总览
- 实时收益显示(每秒更新)
- 贡献值展示(个人/团队)
- 积分股买卖交易
- K线图与价格显示
- 个人中心
---
## 架构文档
- docs/mining-ecosystem-architecture.md - 系统架构总览
- 服务职责与端口分配
- 数据流向图
- Kafka Topics 定义
- 跨服务关联(account_sequence)
- 配置参数说明
- 开发顺序建议
---
## .gitignore 更新
- 添加 Flutter/Dart 构建文件忽略
- 添加 iOS/Android 构建产物忽略
- 添加 Next.js 构建目录忽略
- 添加 TypeScript 缓存文件忽略
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 17:45:46 -08:00