Commit Graph

2092 Commits

Author SHA1 Message Date
hailin e56c86545c docs: 添加 RWADurian 2.0 部署与运维成本方案
- 方案一:高可用架构(3台服务器,100Mbps,月成本 ¥20,950)
- 方案二:标准架构(1台服务器,10Mbps,月成本 ¥5,150)
- 包含数据存储与带宽需求分析
- 包含架构设计与服务器配置说明

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 03:29:51 -08:00
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 f3d460ba09 fix(mining-app): 修复批量补发记录解析字段名
API 返回 records 字段,而非 data 或 items

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 02:11:10 -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 623e695353 fix(mining-app): 修正批量补发记录 API 路径
添加 /admin 前缀以匹配 mining-service 的 AdminController 路由

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 01:45:41 -08:00
hailin b6d723333c fix(mining-app): 修复 BatchMiningRecordsPage 类名冲突
将页面类重命名为 BatchMiningRecordsListPage 以避免与实体类冲突

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 01:42:46 -08:00
hailin d5dc248a16 feat(mining-app): 添加补发记录功能
- 添加批量补发记录 API endpoint
- 创建 BatchMiningRecord 实体和模型
- 添加批量补发记录 provider 和页面
- 在"我的"页面动态显示补发记录入口(仅当用户有记录时显示)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 01:35:53 -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 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 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 390cc3131d fix(contribution): 修复T2/T3补发记录缺少treeCount和baseContribution
补发奖励时从SyncedAdoption查询原始认种数据,
确保补发记录包含正确的棵数和基础贡献值。

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 19:38:18 -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 7a5faad665 feat(mining-app): UI调整 - 隐藏部分功能和文案修改
- 兑换页面:将"挖矿账户"改为"分配账户"
- 我的页面:隐藏"账户设置"栏目(2.0版本暂不需要)
- 贡献值页面:隐藏"今日预估收益"栏目
- 贡献值明细页:同伴上贡献值不显示用户ID
- 参与记录页:将"算力"改为"贡献值"

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 06:34:36 -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 cb9831f2fc feat(mining-admin-web): 前端实现区域代码到中文名称转换
系统账户列表现在显示中文省市名称(如"广州市公司")而不是区域代码(如"440100账户")

- 新增 region-codes.ts 包含完整的省市行政区划代码映射
- 修改 accounts-table.tsx 使用 getRegionDisplayName() 转换名称
- 修改 account-card.tsx 使用区域代码映射
- 修改账户详情页使用区域代码映射显示标题

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 05:20:50 -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 f7dbe2f62b refactor(contribution): 合并所有迁移到 0001_init
- 将 0002_add_soft_delete 的 deleted_at 字段合并到 0001_init
- 删除 0002_add_soft_delete_to_system_contribution_records 目录
- 现在只保留一个初始化迁移文件

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 04:31:52 -08:00
hailin 21c6c25f7c refactor(contribution): 合并 source_type 迁移到 0001_init
将 0003_add_source_type 迁移合并到 0001_init/migration.sql

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 04:28:14 -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 e89c3166bf feat(mining-admin-web): 系统账户算力明细显示更多信息
- 显示认种订单:日期、树数
- 显示认种用户:姓名/手机号
- 更新类型定义匹配后端新字段

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 03:36:02 -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 eeaa43e044 feat(contribution): 系统账户明细记录改为软删除
- 在 SystemContributionRecord 模型添加 deleted_at 字段
- 修改 deleteContributionRecordsByAdoption 方法为软删除(设置 deleted_at)
- 修改 findContributionRecords 方法过滤已删除记录(deletedAt: null)
- 添加数据库迁移文件

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 03:09:41 -08:00
hailin e0eb734196 fix(contribution): 用户领取奖励时从 HEADQUARTERS 减少算力并删除明细
- 添加 subtractContribution 方法减少系统账户算力
- 添加 deleteContributionRecordsByAdoption 方法删除明细记录
- 在 BonusClaimService 中领取奖励时同步更新 HEADQUARTERS
2026-01-21 02:56:58 -08:00
hailin fda022d29c fix(frontend): 添加 regionCode 到 SystemAccount 类型 2026-01-21 02:23:35 -08:00
hailin 974b45554d feat(contribution): 为 HEADQUARTERS 未分配算力创建明细记录
- 每笔未分配算力都创建 HEADQUARTERS 的明细记录
- 发布 SystemContributionRecordCreatedEvent 事件同步到 mining-admin-service
- 明细记录包含来源用户ID (sourceAccountSequence)
2026-01-21 02:20:36 -08:00
hailin 97e974b6da fix(frontend): 添加 regionCode 参数到算力来源 API 调用 2026-01-21 02:13:41 -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 27a045e082 fix(contribution): 在算力明细事件中添加 regionCode 字段
修改 SystemContributionRecordCreatedEvent 事件,将 systemAccountType
拆分为 accountType 和 regionCode 两个独立字段,以便 mining-admin-service
正确同步按省市细分的算力明细记录

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 01:25:46 -08:00