hailin
e9dea69ee9
feat(batch-mining): 动态获取批量补发计算起始日期
...
重构批量补发功能,将硬编码的起始日期(2025-11-08)改为从 Excel 数据中
动态获取,提高计算的准确性和灵活性。
后端改动 (mining-service):
- 新增 DEFAULT_MINING_START_DATE 常量作为找不到有效数据时的默认值
- 新增 getCalculatedStartDate() 方法:从批次1用户的 miningStartDate 中
获取最早日期
- 新增 parseDate() 方法:支持解析 2025.11.8、2025-11-08、2025/11/8 格式
- 修改 buildMiningPhases() 方法:新增 startDateStr 参数,不再硬编码日期
- 修改 preview/execute 方法:在返回结果中包含 calculatedStartDate 字段
前端改动 (mining-admin-web):
- 更新 BatchPreviewResult 接口,新增 calculatedStartDate 字段
- 预览结果描述中显示计算起始日期(蓝色高亮)
- 确认对话框中新增"计算起始日期"行
降级策略:
- 若批次1用户不存在或日期均无效,自动使用默认日期 2025-11-08
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 02:01:40 -08:00
hailin
ab320083f7
fix(mining-service): 修复批量补发记录分页参数类型问题
...
Query 参数是字符串类型,需要显式转换为数字
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 02:05:16 -08:00
hailin
c7f7c10d59
fix(mining-service): 修正 AdminController 路由前缀
...
将 AdminController 路由从 /admin 改为 /mining/admin,
以匹配 Kong 网关路由 /api/v2/mining
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 01:51:11 -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
f44af3a2ed
fix(batch-mining): 修正grandTotalAmount重复累加问题
...
用户可能在多个批次中出现,之前按批次累加batchTotalAmount会导致
同一用户的收益被重复计算。改为直接累加所有用户的amount(去重)。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 00:04:35 -08:00
hailin
18e9749ad8
fix(batch-mining): 修正总天数计算逻辑
...
- 总挖矿天数 = 从2025-11-08到今天的自然天数
- 最后阶段天数 = 总天数 - 前面各阶段天数之和
- 不再累加preMineDays作为总天数
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 23:46:27 -08:00
hailin
d47276a460
fix(batch-mining): 添加详细日志追踪阶段划分和总天数计算
...
- 添加更清晰的阶段划分注释说明
- 添加日志打印最后批次preMineDays=0时改为1天的情况
- 添加预期总金额日志用于验证计算正确性
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 23:44:10 -08:00
hailin
0adc4c8c26
fix(batch-mining): 最后批次preMineDays=0时改为1天
...
最后一个批次即使 preMineDays=0,也要算1天(所有人一起挖1天生成收益)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 23:37:35 -08:00
hailin
d98e22f151
fix(batch-mining): 移除多余的最后阶段
...
根据需求:总天数 = 所有批次的 preMineDays 之和
- 阶段1: 只有第一批,分配第一批的 preMineDays 天
- 阶段2: 第一批+第二批,分配第二批的 preMineDays 天
- 依次类推...
没有额外的"最后阶段",不再使用 maxTotalMiningDays
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 23:35:50 -08:00
hailin
c90d88a047
Revert "fix(batch-mining): 修正阶段划分逻辑"
...
This reverts commit 9e9c791283 .
2026-01-21 23:34:12 -08:00
hailin
9e9c791283
fix(batch-mining): 修正阶段划分逻辑
...
preMineDays 表示该批次比最后批次提前多少天开始挖矿
阶段天数 = 当前批次的preMineDays - 下一批次的preMineDays(差值)
例如:批次1(3天)、批次2(2天)、批次3(1天)、批次4(0天)
- 阶段1:只有批次1,持续 3-2=1 天
- 阶段2:批次1+2,持续 2-1=1 天
- 阶段3:批次1+2+3,持续 1-0=1 天
- 最后阶段:所有批次一起挖剩余天数
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 23:33:58 -08:00
hailin
2358b3ea17
fix(batch-mining): 修复重复用户计算问题
...
- 添加 userBatchContributions 按用户-批次跟踪算力
- 修复阶段计算时同一用户被重复计算的问题
- 修复输出结果时同一用户金额被重复累加的问题
- 使用 processedInPhase Set 避免同一阶段重复处理同一用户
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 23:24:03 -08:00
hailin
f14ad0b7ad
fix(batch-mining): 修正补发计算逻辑
...
- 去掉虚构的'全网算力'概念
- 每天固定分配70%产出给参与用户
- 用户收益 = 每日产出 × 70% × 天数 × (用户算力/当前参与总算力)
- 总补发金额固定为: 日产出 × 70% × 总天数
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 23:08:55 -08:00
hailin
702fa937e8
fix(batch-mining): 修正阶段划分逻辑
...
- preMineDays 是该批次加入后挖矿的天数,不是差值
- 批次1的preMineDays=3 → 批次1先独挖3天
- 批次2的preMineDays=2 → 批次1+2一起挖2天
- 批次3的preMineDays=1 → 批次1+2+3一起挖1天
- 最后所有批次一起挖剩余天数
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 21:29:34 -08:00
hailin
8b8d1f7d16
Revert "fix(batch-mining): 简化计算逻辑"
...
This reverts commit 4dcbe38309 .
2026-01-21 21:17:00 -08:00
hailin
4dcbe38309
fix(batch-mining): 简化计算逻辑
...
- 移除分阶段计算,改用简单公式
- 用户收益 = (用户算力/全网算力) × 每日产出 × 天数
- 全网算力 = 用户算力 / 0.7
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 21:16:14 -08:00
hailin
97b3a20a7c
fix(batch-mining): 修正70%比例计算逻辑
...
- 移除 PERSONAL_RATE,避免70%被乘两次
- 用户算力 = 棵数 × 22617(不再乘70%)
- 全网算力 = 用户算力 / 0.7(70%体现在这里)
- 预期结果:(1000000/365/2)*70%*74 = 70958.90411
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 21:07:35 -08:00
hailin
e79d42db61
fix(batch-mining): 修复计算逻辑,批量补发用户只占全网70%
...
- 添加 BATCH_USERS_NETWORK_RATIO 常量(0.70)
- 计算全网算力时:实际全网算力 = 用户算力 / 0.7
- 修正预期结果约为 70,958 而非 104,656
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 20:58:42 -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
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
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
5fa0fd5d1a
fix(mining): 为 HEADQUARTERS 账户添加每分钟挖矿记录
...
HEADQUARTERS 的挖矿收益来自待解锁算力,之前只更新了账户余额,
但没有写入 system_mining_records 表的每分钟汇总记录。
现在在两个分发路径中都为 HEADQUARTERS 调用 accumulateSystemMinuteData,
确保前端能正确显示总部账户的挖矿记录。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 17:25:07 -08:00
hailin
1c787a22a3
fix(mining): 修复 mining-service 订阅错误的 Kafka topic
...
问题:mining-service 订阅的是 cdc.contribution.outbox (Debezium CDC topic),
但 contribution-service 使用 Outbox Pattern 直接发送到 contribution.{eventType} topic。
修复:
- mining-service 订阅正确的 topic 列表
- 修复消息解析逻辑支持 Outbox Pattern 消息格式
- contribution-service 添加 GET /admin/unallocated-contributions 端点(调试用)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 03:03:17 -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
dcf413fb72
fix(mining): perSecondEarning只在挖矿激活时返回非零值
...
- GetMiningAccountQuery 检查 config.isActive 状态
- 挖矿未激活时 perSecondEarning 返回 0
- 前端资产页面定时器会因此停止增长
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 08:32:54 -08:00
hailin
2154d5752f
fix: 修复K线图NaN错误并添加mining-service划转端点
...
- 修复K线图当价格范围为0时导致的NaN Offset错误
- 在mining-service添加transfer-out和transfer-in端点
- 划转操作会在mining_transactions表中记录明细
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 07:12:32 -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
4eb466230e
fix(mining): 修复 ShareAmount 类型调用方式
...
使用 .value.toNumber() 而非 .toNumber()
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 22:59:44 -08:00
hailin
4f1f1f9eaf
feat(mining): 添加 perSecondEarning 到挖矿账户 API
...
- 后端:计算每秒收益 = (用户贡献 / 全网贡献) × 每秒分配量
- 前端:修正字段映射以匹配后端返回格式
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 22:56:19 -08:00
hailin
416495a398
fix(mining): correctly parse network-progress API response
...
The API returns {success: true, data: {...}} but code was accessing
progressResult.currentContributionPerTree directly instead of
progressResult.data.currentContributionPerTree.
This caused:
- totalTreeCount to be 0 (undefined → 0)
- networkTotalContribution to be 0
- No mining distributions happening
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 09:46:25 -08:00
hailin
11ff3cc9bd
fix: correct totalShares and distributionPool values
...
- totalShares: 100020000000 → 10002000000 (100.02亿 = 100亿 + 200万)
- distributionPool: 200000000 → 2000000 (200万)
Fixed in:
- trading-service/prisma/schema.prisma
- trading-service/prisma/migrations/0002_add_trading_burn_system/migration.sql
- mining-service/.env.example
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 09:01:17 -08:00
hailin
6043d2fec8
fix(mining): calculate remainingDistribution from actual distributed amount
...
- Changed from reading config.remainingDistribution to calculating:
remainingDistribution = distributionPool - totalDistributed
- Ensures data consistency: remaining + distributed = total pool
- Added Math.max(0, ...) to prevent negative values
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 08:19:05 -08:00
hailin
3e536115eb
fix(mining): add defensive checks for network sync undefined values
...
- Handle missing currentContributionPerTree with default value
- Add null checks for all network progress fields
- Prevent DecimalError when contribution service returns incomplete data
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 01:19:18 -08:00
hailin
68a583508b
fix(mining): correct progress calculation to use totalDistributed/distributionPool
...
Previously used (pool - remaining) / pool which was incorrect.
Now uses actual distributed amount / total pool for accurate percentage.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 01:10:54 -08:00
hailin
1e33ab178d
fix(mining): move progress endpoint to MiningController for correct Kong routing
...
- Add /api/v2/mining/progress endpoint in MiningController
- Update frontend API to call /progress instead of /admin/mining/status
- Kong routes /api/v2/mining/* with strip_path=false, so endpoint must
be under /mining controller path
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 00:55:58 -08:00
hailin
49949ff979
fix(mining): use unified transaction to prevent timeout errors
...
- Wrap all database operations in executeSecondDistribution with
UnitOfWork.executeInTransaction
- Pass transaction client to repository save methods
- Use longer transaction timeout (60s) for batch operations
- Move Redis operations outside transaction (non-ACID)
- Add distributeToSystemAndPendingInTx method that accepts tx client
This resolves the "Unable to start a transaction in the given time"
error caused by multiple concurrent transactions competing for
database connections.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 00:31:20 -08:00
hailin
725fb80f80
refactor(frontend): 删除我的页面中的支付密码功能
...
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 00:28:30 -08:00
hailin
aee64d9be8
fix(mining): add null safety to MiningConfigUpdated event payload
...
Prevent TypeError when config properties are undefined by using
optional chaining and default values in publishMiningConfigUpdated.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 00:10:28 -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
e80e672ffe
feat(mining-admin): add mining progress dashboard component
...
Add real-time mining progress statistics similar to burn progress:
- Backend: new /admin/mining/status endpoint in mining-service
- Frontend: MiningProgress component with progress bar and stats
- Shows: total distributed, remaining pool, minutes left, per-minute rate
- Auto-refresh every 60 seconds via React Query
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 00:00:20 -08:00
hailin
9deffe2565
fix(mining): resolve transaction timeout by using single transaction for system accounts
...
Problem:
- Multiple concurrent transactions updating system_mining_accounts caused row lock contention
- 16+ transactions waiting for tuple/transactionid locks led to timeout errors
- This prevented writeMinuteRecords() from executing, leaving mining_records empty
Solution:
- Modified SystemMiningAccountRepository.mine() to accept optional external transaction client
- Created new distributeToSystemAndPending() method that processes all system accounts
and pending contributions in a single transaction
- Pre-calculate all rewards before transaction, then execute updates sequentially
- Aggregate all pending contribution rewards into single HEADQUARTERS update
- Move Redis accumulation outside transaction to avoid blocking
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 18:53:53 -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
7852b9d673
feat(mining): publish CDC events for mining-admin-service sync
...
Add event publishing to enable mining-admin-service to sync data via
Debezium CDC instead of direct API calls:
- MiningConfigUpdated: Published every minute with distribution status
- DailyMiningStatCreated: Published when daily stats are generated
- MiningAccountUpdated: Method added for future per-account sync
These events will be captured by Debezium monitoring the outbox_events
table and forwarded to mining-admin-service via Kafka.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 08:33:02 -08:00
hailin
2534068f70
fix(mining): remove duplicate burn mechanism from mining-service
...
Mining-service incorrectly implemented its own burn mechanism (10-year
cycle) which was not in the requirements. Per requirements, only
trading-service should handle per-minute burn (4756.47/minute).
Removed:
- BlackHoleRepository and all burn-related methods
- executeBurn() from mining distribution service
- Burn stats from admin API and queries
- Burn progress UI from mining admin web
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 07:31:13 -08:00