Commit Graph

119 Commits

Author SHA1 Message Date
hailin 0009a9358d fix(mining-admin-service): 修正调用 mining-service admin API 路径
mining-service 的 AdminController 路由前缀改为 mining/admin 后,
mining-admin-service 中调用的路径也需要相应修改

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 02:15:12 -08:00
hailin 134e45e0bf fix(mining-admin-service): 审计日志失败不影响批量补发返回结果
批量补发实际操作完成后,即使审计日志创建失败也应返回成功响应。

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 00:57:00 -08:00
hailin 8a47659c47 feat(batch-mining): 按阶段创建补发记录并添加用户查询功能
- 修改BatchMiningRecord表结构,添加phase和daysInPhase字段
- 修改execute函数,按阶段为每个用户创建记录
- 添加用户批量补发记录查询API
- mining-admin-web用户详情页添加"批量补发"Tab

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 00:30:06 -08:00
hailin 16daa7403c fix(mining-admin): 修正Excel列索引
Excel实际格式是:
- 索引0: 序号
- 索引1: 注册ID
- 索引2: 认种量(棵)
- 索引3: 挖矿开始时间
- 索引4: 批次
- 索引5: 授权提前挖的天数
- 索引6: 备注

之前代码从索引0读取用户ID是错误的,现在修正为从索引1开始读取。

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 19:58:17 -08:00
hailin ca5de3add1 debug: 添加原始Excel数据日志 2026-01-21 19:46:31 -08:00
hailin e4c320970f fix(batch-mining): 重构分阶段挖矿计算逻辑
核心修改:
1. 正确理解 preMineDays 的含义:该批次比下一批次提前的天数
2. 新增 totalMiningDays:从挖矿开始日期到今天的总天数
3. 分阶段计算收益:
   - 阶段1: 批次1独挖 (preMineDays1 - preMineDays2) 天
   - 阶段2: 批次1+2共挖 (preMineDays2 - preMineDays3) 天
   - 阶段3: 批次1+2+3共挖 (preMineDays3 - 0) 天
   - 最终阶段: 所有批次共挖 (totalMiningDays - 已用天数) 天
4. 每个阶段按当时的全网算力比例分配收益

示例:
- 批次1 preMineDays=3,批次2 preMineDays=2,批次3 preMineDays=1
- totalMiningDays=74(从11.8到1.21)
- 阶段1: 批次1独挖1天 (3-2=1)
- 阶段2: 批次1+2共挖1天 (2-1=1)
- 阶段3: 批次1+2+3共挖1天 (1-0=1)
- 阶段4: 所有批次共挖71天 (74-3=71)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 18:56:45 -08:00
hailin af95f8da0c fix(mining-admin): 根据挖矿开始时间自动计算挖矿天数
之前错误地从Excel第6列读取preMineDays,但该列为空。
现在根据"挖矿开始时间"到今天自动计算实际挖矿天数。

修改内容:
- 修正Excel列索引(用户ID在第1列,不是第2列)
- 解析日期支持多种格式(2025.11.8, 2025-11-08, 2025/11/8)
- 自动计算从挖矿开始日期到今天的天数作为preMineDays

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 18:50:46 -08:00
hailin 30a82f09f3 fix(mining-admin): 解包 mining-service 响应的 TransformInterceptor 包装
mining-service 使用 TransformInterceptor 将所有响应包装为 { success, data, timestamp } 结构,
mining-admin-service 需要从 result.data 中提取实际数据。

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 06:26:56 -08:00
hailin a02813a8ea fix(batch-mining): 修复 mining-admin-service 调用 mining-service API 路径
mining-service 的路由是 /api/v2/admin/batch-mining/...
但 mining-admin-service 调用时缺少 /api/v2 前缀导致 404

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 06:12:32 -08:00
hailin 7a4f5591b7 feat(batch-mining): 添加详细的调试日志
- mining-service batch-mining.service.ts: 添加所有方法的详细日志
- mining-admin-service batch-mining.service.ts: 添加 HTTP 请求和响应日志
- mining-admin-service batch-mining.controller.ts: 添加控制器层日志
- frontend batch-mining page.tsx: 添加前端 console.log 日志

便于调试部署后的 404 等问题

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 05:49:04 -08:00
hailin 71151eaabf feat(mining): 添加批量补发挖矿功能
- 新增批量补发服务和API (mining-service)
  - 支持按批次累积计算全网算力
  - 用户算力 = 认种棵数 × 22617 × 70%
  - 补发金额 = (用户算力/全网算力) × 每秒分配量 × 天数 × 86400
  - 防重复执行机制(只能执行一次)

- 新增文件上传和批量补发API (mining-admin-service)
  - 支持上传 Excel 文件解析
  - 预览和执行两步操作
  - 审计日志记录

- 新增批量补发页面 (mining-admin-web)
  - Excel 文件上传
  - 按批次预览计算结果
  - 执行确认对话框

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 04:59:13 -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 7c8ea7a9d7 feat(mining-admin): 增强系统账户算力明细信息
- 关联认种订单信息:树数、认种日期、状态、单价
- 关联用户信息:手机号(脱敏)、姓名
- 方便追溯每笔算力的来源

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 03:32:27 -08:00
hailin 63aba087b6 feat(mining-admin): 系统账户显示具体省市名称
- 根据 regionCode 从 SyncedProvince/SyncedCity 表查找名称
- PROVINCE + 440000 显示为 "广东省公司"
- CITY + 440100 显示为 "广州市公司"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 03:31:05 -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 495a1445fd fix(mining-admin): 修复 Prisma 查询 null 值的语法
Prisma 查询 null 值需要使用 { equals: null } 而不是直接 null

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 01:58:08 -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 cded4b2134 fix(mining-admin): 以算力账户为主显示系统账户列表
修改 getSystemAccounts 方法:
- 以 synced_system_contributions 为主要数据源
- 关联钱包数据和挖矿数据
- 显示所有省市算力账户(而不仅是有钱包的账户)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 23:06:46 -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 81b2e7a4c2 refactor(migrations): 合并各服务的 migration 文件为单个 0001_init
将各服务的多个 migration 文件合并到单一的初始化 migration 中:
- contribution-service: 3→1 (含 region 支持)
- mining-service: 4→1 (含 second 分配和 region 支持)
- mining-admin-service: 4→1 (含 region 和算力明细同步)
- auth-service: 2→1 (含 CDC 幂等)
- trading-service: 9→1 (含销毁系统/做市商/C2C)
- mining-wallet-service: 2→1 (含 SHARE_POOL 拆分)

所有迁移统一使用 TEXT 类型(非 VARCHAR)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 20:34:56 -08:00
hailin 9c816266ac fix(schema): 统一使用 TEXT 类型替代 VARCHAR
问题:
- 之前 schema 和 migration 中使用了 VARCHAR(n) 限制字段长度
- Prisma 的 String 类型默认映射到 PostgreSQL TEXT
- VARCHAR 和 TEXT 在 PostgreSQL 中性能相同,VARCHAR 限制反而增加风险

修复:
1. contribution-service:
   - schema: 移除 accountType/baseType/regionCode/name 的 @db.VarChar
   - migration: VARCHAR -> TEXT

2. mining-service:
   - schema: 移除 accountType/baseType/regionCode/name 的 @db.VarChar
   - migration: VARCHAR -> TEXT

3. mining-admin-service:
   - migration: VARCHAR -> TEXT (schema 已使用 TEXT)

原则:Prisma String 直接使用,不加 @db.VarChar()

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 20:24: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 63c192e90d feat(pending-contributions): 添加待解锁算力分类账功能
功能说明:
- 待解锁算力是因用户未满足解锁条件(如直推数不足)而暂存的层级/奖励算力
- 这部分算力参与挖矿,但收益归入总部账户(HEADQUARTERS)

后端变更:
- mining-service: 添加4个待解锁算力相关API
  - GET /admin/pending-contributions - 获取待解锁算力列表(支持分页和类型筛选)
  - GET /admin/pending-contributions/summary - 获取汇总统计(按类型统计、总挖矿收益)
  - GET /admin/pending-contributions/:id/records - 获取单条记录的挖矿明细
  - GET /admin/pending-contributions/mining-records - 获取所有挖矿记录汇总视图
- mining-admin-service: 添加代理层
  - 新建 PendingContributionsService 调用 mining-service API
  - 新建 PendingContributionsController 暴露 API 给前端

前端变更:
- 新建 pending-contributions feature 模块(API、hooks、类型定义)
- 新建 /pending-contributions 页面
  - 汇总统计卡片(总量、已归入总部积分股、挖矿记录数)
  - 按类型统计展示
  - 算力列表Tab(来源用户、归属用户、类型、算力、原因、创建时间)
  - 挖矿记录Tab(时间、类型、算力、占比、每秒分配量、挖得数量、归入)
- 在仪表盘的层级算力和团队奖励卡片添加"查看分类账"链接

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 18:13:22 -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 7bc911d4d7 feat(mining): 实现手工补发挖矿功能
为从1.0系统同步的用户提供手工补发历史挖矿收益功能:

- mining-service: 添加 ManualMiningRecord 表和计算/执行补发逻辑
- mining-wallet-service: 添加 MANUAL_MINING_REWARD 交易类型和 Kafka 消费者
- mining-admin-service: 添加补发 API 控制器和代理服务
- mining-admin-web: 添加手工补发页面和侧边栏菜单项

功能特点:
- 根据用户算力和当前挖矿配置计算补发金额
- 每个用户只能执行一次补发操作
- 通过 Kafka 事件确保跨服务数据一致性
- 完整的操作记录和钱包同步状态追踪

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 03:50:03 -08:00
hailin 22702e898b fix(mining-admin): 修复仪表板待解锁算力显示为0的问题
- mining-admin-service: 新增 fetchContributionServiceStats() 方法,
  从 contribution-service API 获取完整的 pending 数据
- mining-admin-service: 重构 getDetailedContributionStats(),优先
  使用 API 数据,失败时回退到本地数据
- mining-service: 修复 publishMiningConfigUpdated 中使用已废弃的
  minuteDistribution 字段导致的错误

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 00:09:40 -08:00
hailin c84341be37 fix(mining): return totalDistributed (sum of totalMined) in admin status
The dashboard was incorrectly calculating distributed shares using
distributionPool - remainingDistribution. The correct value is the sum
of all users' totalMined balances. Updated mining-service to return
totalDistributed directly, and mining-admin-service to use it.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 09:27:15 -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 64ccb8162a fix(admin): correct distributed shares calculation to use 2M pool
The dashboard was incorrectly using 5 billion as the distribution pool
default when calculating already distributed shares. The actual mining
distribution pool is 2 million shares, not 100 billion.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 08:59:46 -08:00
hailin 9d65eef1b1 fix(mining-admin): fetch dashboard data from remote services
Dashboard now fetches totalDistributed and totalBurned directly from
mining-service and trading-service APIs instead of relying solely on
CDC sync which may not have data.

- Add fetchRemoteServiceData() to get real-time data
- Use mining-service /admin/status for totalDistributed
- Use trading-service /asset/market for totalBurned and circulationPool
- Add 30-second cache to reduce API calls

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 08:25:07 -08:00
hailin 7909bcc3d1 fix(mining-admin): 修复同步状态判断逻辑
- 同步判断改为只检查全网理论算力是否同步
- 全网理论算力是挖矿分母,是判断同步完成的核心指标
- 使用相对误差(0.1%)而非绝对误差来判断同步

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 04:07:18 -08:00
hailin de5416aee6 feat(mining): 实现系统账户和待解锁算力参与挖矿
重大变更:
- 挖矿分母从用户有效算力改为全网理论算力(networkTotalContribution)
- 系统账户(运营12%/省1%/市2%)参与挖矿,有独立的挖矿记录
- 待解锁算力参与挖矿,收益归总部账户,记录包含完整来源信息

新增功能:
- mining-service: 系统挖矿账户表、待解锁算力表及相关挖矿记录表
- mining-service: NetworkSyncService 同步全网数据
- mining-service: /admin/sync-network 和 /admin/system-accounts 端点
- contribution-service: /admin/system-accounts 和发布系统账户事件端点
- mining-admin-service: 状态检查返回全网理论算力信息

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 03:39:56 -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 7c00c900a0 feat(mining-admin): 算力同步完成前禁用激活挖矿按钮
- 后端:getMiningStatus 接口并行获取 contribution-service 总算力,对比两边是否一致
- 前端:未同步时显示"全网算力同步中..."提示,禁用激活按钮
- 前端:同步中每 3 秒刷新状态,同步完成后恢复 30 秒刷新

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 03:00:40 -08:00
hailin 7a469be7cd fix(mining-*): add parent .env path for shared config
All mining services need to read shared environment variables
(JWT_SECRET, DATABASE_URL, etc.) from backend/services/.env

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 06:58:56 -08:00
hailin d7bbb19571 fix(mining-admin-service): correct effective contribution calculation
Effective contribution should equal theoretical total (totalTrees * 22617)
since it includes all parts: personal 70% + operation 12% + province 1% +
city 2% + level 7.5% + bonus 7.5% = 100%.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 02:20:45 -08:00
hailin cfbf1b21f3 feat(dashboard): add detailed contribution breakdown by category
Backend (contribution-service):
- Add getDetailedContributionStats() to repository
- Add getUnallocatedByLevelTier/BonusTier() to repository
- Extend stats API with level/bonus breakdown by tier
- Add getTotalTrees() to synced-data repository

Backend (mining-admin-service):
- Add detailed contribution stats calculation
- Calculate theoretical vs actual values per category
- Return level/bonus breakdown with unlocked/pending amounts

Frontend (mining-admin-web):
- Add ContributionBreakdown component showing:
  - Personal (70%), Operation (12%), Province (1%), City (2%)
  - Level contribution (7.5%) by tier: 1-5, 6-10, 11-15
  - Bonus contribution (7.5%) by tier: T1, T2, T3
- Update DashboardStats type definition
- Integrate breakdown component into dashboard page

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 01:43:37 -08:00
hailin 12f8fa67fc feat(mining-admin): add totalTrees, separate level/bonus pending display
- Add totalTrees field from syncedAdoption aggregate
- Rename fields: networkLevelPending, networkBonusPending
- Stats card: show level pending and bonus pending separately
- Add new stats card for total trees count
- Price overview: 2-row layout showing all contribution metrics

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 23:59:32 -08:00
hailin b310fde426 feat(mining-admin): show pending contribution in dashboard
- Add networkPendingContribution and networkBonusPendingContribution to API
- Display combined pending contribution (teamLevel + teamBonus) in stats card
- Replace 'total contribution' with 'pending contribution' in price overview

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 23:46:05 -08:00
hailin dee9c511e5 feat(mining-admin): add total contribution to dashboard stats
- Add networkTotalContribution field to dashboard API response
- Display total hashrate alongside effective hashrate in stats cards
- Update price overview to show both effective and total contribution
- Change grid from 3 to 4 columns in price overview

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 23:32:29 -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 465e398040 fix(mining-admin): fix wallet ledger API to match frontend expected format
- Return usdtAvailable, usdtFrozen, pendingUsdt, settleableUsdt,
  settledTotalUsdt, expiredTotalUsdt instead of old field names
- Query SyncedUserWallet table for GREEN_POINTS wallet data
- Use miningAccount.availableBalance for pendingUsdt

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 05:56:24 -08:00
hailin e6d966e89f fix(mining-admin): fetch mining records from mining-service
Update getUserMiningRecords to call mining-service API instead of
returning empty records. This enables the admin dashboard to display
actual user mining records.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 05:14:03 -08:00
hailin 270c17829e fix(mining-admin-service): move mining routes before :category/:key parameter route
NestJS matches routes in definition order. The :category/:key route was
matching mining/status before the specific mining routes. Moved mining
routes before the parameter routes to fix routing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 04:57:25 -08:00
hailin 289ac0190c fix(mining-admin-service): add logging and fix null data handling in getMiningStatus
- Add debug logging to trace mining service calls
- Return error object instead of null when data is missing
- Include error message in response for debugging

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 04:42:01 -08:00