hailin
8b459dd33f
fix(trading-service): 修复P2P转账AUTH_SERVICE_URL默认值
...
默认值从localhost改为内网IP,解决Docker环境中调用auth-service失败的问题
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 08:49:54 -08:00
hailin
40389fcfc7
feat(trading-service, mining-admin-web): 支持在管理后台配置做市商钱包地址
...
- 后端: 在 UpdateConfigDto 和 updateConfig 方法中添加 kavaWalletAddress 字段
- 前端: 在充值对话框中添加钱包地址配置输入框
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 07:53:04 -08:00
hailin
7a8a3a8fd1
feat(trading-service): 初始化做市商时自动读取环境变量配置钱包地址
...
- 从 FUSDT_MARKET_MAKER_ADDRESS 环境变量读取做市商钱包地址
- 初始化时自动设置 kavaWalletAddress
- 如果做市商已存在但钱包地址为空,也会从环境变量更新
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 07:31:16 -08:00
hailin
812b127ace
fix(trading-service): 添加缺失的数据库字段迁移
...
Schema 中有但 migration 中缺失的字段:
- market_maker_configs: kava_wallet_address, mpc_username
- c2c_orders: seller_kava_address, bot_purchased, payment_tx_hash
这些字段缺失导致 500 错误:
"The column `market_maker_configs.kava_wallet_address` does not exist"
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 07:20:21 -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
fd64903841
fix(mining-admin-service): 添加 adbkit-apkreader 类型声明
...
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 22:21:18 -08:00
hailin
8314dda670
fix(mining-admin-service): 更新 package-lock.json
...
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 22:17:01 -08:00
hailin
4ce43c20cc
fix(mining-admin-service): 添加 APK/IPA 解析依赖包
...
添加版本管理所需的包解析依赖:
- adbkit-apkreader: 解析 Android APK 文件
- jszip: 解压 iOS IPA 文件
- plist: 解析 iOS Info.plist 文件
- @types/plist: TypeScript 类型声明
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 22:15:43 -08:00
hailin
edc0ea46c9
fix: 修复 mining-blockchain-service Kafka consumer group 冲突
...
- mining-blockchain-service 使用独立的 consumer group ID,避免与 blockchain-service 冲突
- withdrawal-event-consumer: blockchain-service-withdrawal-events -> mining-blockchain-service-withdrawal-events
- mpc-event-consumer: blockchain-service-mpc-events -> mining-blockchain-service-mpc-events
- deposit-ack-consumer: blockchain-service-deposit-acks -> mining-blockchain-service-deposit-acks
- 更新 docker-compose.yml 和 kafka.config.ts 的默认配置
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 22:05:55 -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
219fb7bb69
fix(mining-blockchain): 移除旧的 MARKET_MAKER_* 变量名引用
...
- main.ts: 使用 EUSDT/FUSDT_MARKET_MAKER_* 验证配置
- blockchain.config.ts: 使用 eusdtMarketMaker/fusdtMarketMaker 配置
- market-maker-deposit-detection.service.ts: 每种代币使用独立的做市商钱包地址
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 19:20:48 -08:00
hailin
3b95a8a332
feat(mining-blockchain): 支持 eUSDT 和 fUSDT 独立做市商钱包
...
- 新增 EUSDT_MARKET_MAKER_USERNAME/ADDRESS 配置
- 新增 FUSDT_MARKET_MAKER_USERNAME/ADDRESS 配置
- mpc-signing.client.ts: 分离 eUSDT 和 fUSDT 做市商签名方法
- erc20-transfer.service.ts: 根据代币类型选择对应钱包转账
- transfer.controller.ts: 更新余额查询和状态接口
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 19:05:15 -08:00
hailin
aa33803d08
fix(mining-blockchain): 修正做市商钱包配置项顺序
...
统一 USERNAME 在前,ADDRESS 在后的格式,与 HOT_WALLET 保持一致
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 18:33:16 -08:00
hailin
cfdcd9352a
feat(mining-blockchain-service): 支持做市商独立MPC钱包签名
...
- MpcSigningClient 支持两个钱包: C2C Bot 和做市商
- HOT_WALLET_USERNAME/ADDRESS: C2C Bot 热钱包
- MARKET_MAKER_MPC_USERNAME/WALLET_ADDRESS: 做市商钱包
- Erc20TransferService 新增 transferTokenAsMarketMaker() 方法
- eUSDT/fUSDT 转账使用做市商钱包签名和转账
- 新增 /transfer/market-maker/status 状态检查接口
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 18:27:09 -08:00
hailin
4283a369ae
fix(mining-blockchain-service): 修复Redis DB配置超出范围问题
...
- 将 REDIS_DB 从 16 改为 8(Redis 仅支持 0-15)
- 更新 .env.example 添加做市商钱包配置说明
- 添加 eUSDT/fUSDT 合约地址配置
- 添加区块扫描配置项
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 18:16:38 -08:00
hailin
58feec255d
feat(market-maker): 实现做市商区块链充提功能
...
- 扩展 mining-blockchain-service 支持 eUSDT/fUSDT 转账
- 添加 trading-service 区块链提现 API(自动回滚失败交易)
- 前端支持中心化和区块链充提两种模式(Tab切换)
- 区块链充值显示钱包地址和二维码
- 区块链提现支持输入目标地址直接转账
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 17:56:15 -08:00
hailin
94f9e7d5b5
fix(trading-service): 使用事务确保成交时账户余额更新的原子性
...
## 问题描述
用户 D25122700015 的卖单成交后,订单状态变为 FILLED,成交记录存在,
但 frozenShares 未释放,cashBalance 未增加,交易流水缺少 SELL 记录。
## 根本原因
`tryMatch` 方法中的数据库操作没有使用事务:
1. trade.create - 单独提交
2. orderRepository.save - 单独提交
3. accountRepository.save(buyerAccount) - 单独提交
4. accountRepository.save(sellerAccount) - 可能因前面异常而跳过
如果步骤 1-3 成功但步骤 4 失败,会导致:
- 成交记录存在 ✓
- 订单状态 FILLED ✓
- 买方账户正常 ✓
- 卖方账户未更新 ✗
## 修复方案
使用 Prisma 事务包装所有关键操作,确保原子性:
1. 创建成交记录
2. 更新买单状态
3. 更新卖单状态(含销毁信息)
4. 更新买方账户(扣除冻结现金,增加积分股)
5. 更新卖方账户(扣除冻结积分股,增加现金)
6. 记录交易流水
任何一步失败,整个事务回滚。
## 受影响用户
- D25122700015: 订单 OMKXYTXS6KKC3A6
- 成交记录: TMKXYTXXH8CYQZ7
- 需要手动修复现有数据
## 回滚方法
git revert <此commit>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 17:20:31 -08:00
hailin
1974c43eba
feat(market-maker): 实现做市商区块链充值监控功能
...
- mining-blockchain-service:
- 添加 MarketMakerDeposit 和 MarketMakerBlockCheckpoint 表
- 添加 eUSDT/fUSDT 代币合约配置
- 实现做市商钱包充值检测服务
- 添加启动时配置验证和错误日志
- 发布充值确认事件到 Kafka
- trading-service:
- 添加做市商充提记录表 (MarketMakerDeposit, MarketMakerWithdraw)
- 添加 Kafka 消费者监听充值确认事件
- 实现充值自动入账和流水记录
- 部署配置:
- 更新 docker-compose 添加新环境变量
- 更新 deploy-mining.sh 添加 blockchain 服务
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 17:13:41 -08:00
hailin
042a52550b
feat(c2c): 实现C2C Bot自动交易系统
...
- 创建独立的 mining-blockchain-service 服务 (基于 blockchain-service)
- 添加 dUSDT 转账接口供 C2C Bot 调用
- 实现 C2cBotService 自动购买卖单
- 实现 C2cBotScheduler 每10秒扫描待处理卖单
- 添加 BlockchainClient 和 IdentityClient 客户端
- 更新 C2cOrder 模型添加 Bot 购买相关字段
- 使用 MPC 热钱包签名交易
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 07:10:25 -08:00
hailin
cec98e9d3e
feat(contribution): 添加定时任务补发未完全解锁的贡献值
...
每10分钟扫描已认种但解锁状态不完整的账户,检查其直推用户认种情况,
若满足新的解锁条件则自动补发层级贡献值和奖励档位。
- 添加 findAccountsWithIncompleteUnlock 查询方法
- 添加 findPendingLevelByAccountSequence 和 claimLevelRecords 方法
- 实现 processBackfillForAccount 和 claimLevelContributions 补发逻辑
- 添加 processContributionBackfill 定时任务(每10分钟执行)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 06:25:57 -08:00
hailin
2597d0ef46
feat: 实现P2P转账功能及前端资产页面优化
...
- trading-service: 添加P2pTransfer模型和P2P转账API
- auth-service: 添加用户手机号查询接口用于转账验证
- frontend: 修复资产页面冻结份额显示和转账页面余额字段
- frontend: 添加P2P转账记录页面
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 06:25:42 -08:00
hailin
37d3300b17
fix(contribution-service): CDC planting_orders 阶段按 order_id 排序处理
...
## 问题背景
用户 D25122700018 的层级已解锁(unlocked_level_depth=5),但缺少 TEAM_LEVEL 算力记录。
其下级用户 D25122700019 的团队算力被错误地分配给了 D25122700015(level 2)而非 D25122700018(level 1)。
## 根本原因分析
1. 源系统数据顺序正确:
- D25122700018: order_id=55, created_at=2026-01-09 11:57:01 (先认种)
- D25122700019: order_id=57, created_at=2026-01-09 12:00:38 (后认种)
2. Kafka 消息顺序错误:
- D25122700019: offset=732, synced_at=10:15:32 (先处理)
- D25122700018: offset=798, synced_at=10:15:41 (后处理)
3. 原因:Debezium snapshot 按 PostgreSQL 物理存储顺序(heap order)读取数据,
而非按主键顺序。即使 topic 只有 1 个分区,消息顺序仍然错误。
4. 后果:当处理 D25122700019 的认种时,D25122700018 的 unlocked_level_depth 还是 0,
导致 D25122700019 的 TEAM_LEVEL 算力跳过 level 1 直接分配给 level 2。
## 解决方案
对 planting_orders 阶段实现"收集-排序-处理"模式:
1. 先收集所有消息到内存数组(不立即处理)
2. 按 order_id(源系统主键)升序排序
3. 再按排序后的顺序逐条处理
这确保上游用户的认种记录先于下游用户处理,避免算力分配错误。
## 受影响用户案例
- 上游用户: D25122700018 (order_id=55)
- 下游用户: D25122700019 (order_id=57, 58, 59)
- 错误分配: D25122700019 的 TEAM_LEVEL 给了 D25122700015 而非 D25122700018
## 回滚方法
如需回滚此修改,将 consumePhaseToEnd 方法中的判断条件改为 false:
```typescript
const needsSorting = false; // 原: phase.tableName === 'planting_orders'
```
或直接 revert 此 commit。
## 风险评估
- 业务逻辑完全不变,只改变处理顺序
- user_accounts 和 referral_relationships 阶段保持原有逻辑
- 内存开销可控(10000 条记录约 5MB)
- 排序开销可忽略(O(n log n))
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 03:41:14 -08:00
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
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
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
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
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
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
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
974b45554d
feat(contribution): 为 HEADQUARTERS 未分配算力创建明细记录
...
- 每笔未分配算力都创建 HEADQUARTERS 的明细记录
- 发布 SystemContributionRecordCreatedEvent 事件同步到 mining-admin-service
- 明细记录包含来源用户ID (sourceAccountSequence)
2026-01-21 02:20:36 -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
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
96da7518bf
fix(system-accounts): 修复省市系统账户自动创建的数据流问题
...
1. contribution-service: 修复 CITY 类型账户的 provinceCode 映射
- 之前 CITY 的 provinceCode 被错误设为 cityCode
- 现在正确传递 provinceCode 用于创建省份
2. mining-wallet-service: 修复系统账户创建事件的 topic
- 之前发布到 mining-wallet.system-account.created
- 现在发布到 cdc.mining-wallet.outbox 供 mining-admin-service 同步
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 00:28:48 -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
40ac037c03
fix(contribution): 修复系统账户查询中 nullable regionCode 的 TypeScript 类型错误
...
## 问题
- Prisma 生成的类型不允许在 unique where 条件中传递 null
- addContribution 方法被传入多余参数
- findByType 返回数组被当作单个对象使用
## 修复
- findByTypeAndRegion: 使用 findFirst 替代 findUnique
- ensureSystemAccountsExist: 使用 findFirst + create 替代 upsert
- addContribution: 使用 findFirst + create/update 替代 upsert
- 修正 HEADQUARTERS 账户同步事件调用参数
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 21:37:44 -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
5f2f223f7b
fix(contribution): 修复 SystemAccountSyncedEvent 缺少 baseType/regionCode 参数
...
问题:
- admin.controller.ts 中 republishSystemAccounts 端点调用 SystemAccountSyncedEvent 时
只传递了 4 个参数,但构造函数需要 6 个参数
- 缺少 baseType(基础类型)和 regionCode(区域代码)参数
修复:
- 添加 account.baseType 和 account.regionCode 参数
- 与 contribution-calculation.service.ts 中的调用保持一致
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 20:12:49 -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
1d5e3ebff2
fix(contribution): 使用 upsert 替代 update 避免记录不存在错误
...
将 addContribution 方法改为 upsert,当系统账户不存在时自动创建,
存在时增加算力余额。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 08:43:37 -08:00
hailin
5ec310124d
fix(contribution): 确保 HEADQUARTERS 账户存在后再更新算力
...
修复 Record to update not found 错误,在调用 addContribution 前
先调用 ensureSystemAccountsExist 确保系统账户记录已创建。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 08:42:02 -08:00
hailin
d844228711
fix(contribution): 将未分配算力汇总到总部账户(HEADQUARTERS)
...
之前 HEADQUARTERS 账户在算力分配时被遗漏,未获得未分配算力的汇总。
现在在保存未分配算力时,同时更新 HEADQUARTERS 账户的 contributionBalance,
并发布同步事件用于 mining-admin-service 同步。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 08:26:53 -08:00
hailin
e8e1193387
fix(trading): 添加 original_quantity 数据库迁移文件
...
修复服务器上缺少 trades.original_quantity 列的问题
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 08:21:29 -08:00
hailin
6c77828944
fix(deploy): 完善 cdc-resnapshot 自动从配置文件创建连接器
...
- 修复 database.hostname: postgres -> rwa-postgres
- cdc-resnapshot 现在会自动检查连接器是否存在
- 如果连接器不存在,自动从配置文件创建(使用 snapshot.mode=always)
- 修复连接器映射到配置文件的逻辑
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 07:55:19 -08:00
hailin
60f2c29ad8
fix(deploy): 修复 CDC 全量同步问题
...
问题:
- CDC_CONSUMER_GROUPS 缺少阶段性消费者组,导致 full-reset 时
未重置 contribution-service-cdc-phase-* 消费者组
- 当 Kafka topic 数据丢失时,无法触发 Debezium 重新快照
修复:
- 添加阶段性消费者组到 CDC_CONSUMER_GROUPS
- 添加 CDC_POSTGRES_CONNECTORS 列表
- 新增 cdc-resnapshot 命令,用于强制 Debezium 重新快照
使用方法:
- ./deploy-mining.sh full-reset # 完整重置
- ./deploy-mining.sh cdc-resnapshot # Kafka 数据丢失时触发重新快照
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 07:38:21 -08:00
hailin
995dfa898e
feat(trading): 添加涨跌幅显示及修复成交明细数据
...
1. 后端:
- 添加 getFirstSnapshot() 获取上线首日价格
- PriceInfo 接口增加 priceChangePercent 和 initialPrice 字段
- 计算涨跌幅 = (当前价格 - 首日价格) / 首日价格 × 100%
- 修复 originalQuantity 为0时的数据计算逻辑
2. 前端:
- 交易页面涨跌幅移到价格下方单独显示
- 添加"较上线首日"说明文字
- 根据涨跌正负显示不同颜色和图标
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 05:24:23 -08:00
hailin
8728fdce4c
feat(trading): 成交明细显示完整卖出信息(销毁倍数、有效积分股、手续费等)
...
- 后端Trade表新增originalQuantity字段存储原始卖出数量
- quantity字段改为存储有效积分股(含销毁倍数)
- API返回完整明细:销毁倍数、有效积分股、交易总额、进入积分股池
- 前端成交明细页面显示完整卖出信息,类似确认卖出弹窗样式
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 04:07:52 -08:00
hailin
7da98c248b
feat(trading): 交易记录页面添加成交明细Tab,显示手续费
...
后端:
- trading-service 添加 GET /trading/trades API 获取成交记录
- 成交记录包含: 交易总额、手续费(10%)、实际收到金额
前端:
- 新增 TradeRecord 实体和 TradesPageModel
- 交易记录页面添加 Tab: "订单记录" 和 "成交明细"
- 成交明细显示: 价格、数量、交易总额、手续费、实际收到
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 03:15:25 -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
13f1b687ee
feat(kline): add dynamic history loading on pan
...
Add support for loading more K-line history data when user pans to the
left edge. Backend API now accepts 'before' parameter for pagination.
Frontend uses KlinesNotifier to manage accumulated data with proper
deduplication.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 22:21:39 -08:00
hailin
d8df50a68f
fix(c2c): 修复分页参数类型转换问题导致的500错误
...
- 为 QueryC2cOrdersDto 和 QueryMyC2cOrdersDto 的 page/pageSize 字段添加 @Type(() => Number) 装饰器
- Query参数从URL获取时默认为字符串,需要显式转换为数字类型
- 添加 @IsInt() 验证确保参数为整数
- 修复 Prisma findMany take 参数期望 Int 但收到 String 的错误
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 18:32:38 -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
8326f8c35c
fix(cdc): 添加 Debezium heartbeat 机制防止 WAL 堆积
...
问题背景:
- PostgreSQL pg_wal 目录从 80MB 膨胀到 60.4GB,导致磁盘使用率达到 96%
- 根因: wallet/planting/referral 三个数据库的业务表长期无写入
- 虽然 Debezium 有 heartbeat 配置,但未配置 heartbeat.action.query
- 导致 replication slot 的 restart_lsn 无法推进,WAL 文件无法被清理
解决方案:
1. 在 wallet/planting/referral 三个服务中添加 debezium_heartbeat 表
2. 配置 Debezium connector 的 heartbeat.action.query
3. 每 60 秒自动执行 UPDATE 语句推进 restart_lsn
修改内容:
- wallet-service/prisma/schema.prisma: 添加 DebeziumHeartbeat model
- planting-service/prisma/schema.prisma: 添加 DebeziumHeartbeat model
- referral-service/prisma/schema.prisma: 添加 DebeziumHeartbeat model
- scripts/debezium/wallet-connector.json: 添加 heartbeat.action.query 配置
- scripts/debezium/planting-connector.json: 添加 heartbeat.action.query 配置
- scripts/debezium/referral-connector.json: 添加 heartbeat.action.query 配置
- 新增三个服务的 Prisma migration 文件
效果:
- pg_wal 从 60.4GB 降至 80.2MB
- 磁盘使用率从 96% 降至 40%
- replication slot lag 从 51-60GB 降至 KB 级别
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 17:42:41 -08:00
hailin
af339b19b9
feat(c2c): 完善C2C场外交易功能 - 收款信息与订单超时处理
...
## 后端更新
### Prisma Schema (0008_add_c2c_orders migration)
- 新增 C2cPaymentMethod 枚举 (ALIPAY/WECHAT/BANK)
- C2cOrder 模型新增字段:
- 收款信息:paymentMethod, paymentAccount, paymentQrCode, paymentRealName
- 超时配置:paymentTimeoutMinutes (默认15分钟), confirmTimeoutMinutes (默认60分钟)
- 截止时间:paymentDeadline, confirmDeadline
- 新增索引优化超时查询
### API层
- c2c.dto.ts: 新增收款信息和超时配置字段
- c2c.controller.ts: 新增C2C控制器,支持完整的订单生命周期管理
### 业务层
- c2c.service.ts:
- createOrder: 卖单必须提供收款信息验证
- takeOrder: 接单时自动设置付款截止时间
- confirmPayment: 确认付款时设置确认收款截止时间
- processExpiredOrders/expireOrder: 处理超时订单(释放冻结资产)
- c2c-expiry.scheduler.ts: 每分钟执行超时订单检查(带分布式锁)
### 数据层
- c2c-order.repository.ts: 新增 findExpiredOrders 方法
- trading-account.repository.ts: 新增 unfreezeShares/unfreezeCash 方法
## 前端更新
### 数据模型
- c2c_order_model.dart:
- 新增 C2cPaymentMethod 枚举
- 新增收款信息和超时相关字段
- 新增辅助方法:paymentMethodText, hasPaymentInfo, paymentRemainingSeconds, confirmRemainingSeconds
### API层
- trading_remote_datasource.dart: createC2cOrder/takeC2cOrder 支持收款信息参数
### 状态管理
- c2c_providers.dart: createOrder/takeOrder 方法支持收款信息参数
### UI层
- c2c_publish_page.dart:
- 新增收款方式选择器 (支付宝/微信/银行卡)
- 新增收款账号和收款人姓名输入框
- 卖单发布时验证收款信息必填
- 确认对话框显示收款信息摘要
- c2c_order_detail_page.dart:
- 新增收款信息卡片展示(买家视角/卖家视角区分)
- 新增倒计时进度条显示(付款/确认收款截止时间)
- 剩余时间<5分钟时高亮警告
- 支持复制收款账号
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 07:17: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
07498271d3
feat(blockchain): 部署 eUSDT 和 fUSDT 代币合约
...
新增两个 ERC-20 代币合约,部署在 KAVA 主网:
## eUSDT (Energy USDT)
- 合约地址: 0x7C3275D808eFbAE90C06C7E3A9AfDdcAa8563931
- 总供应量: 100.02亿 (10,002,000,000)
- 交易哈希: 0x5bebaa4a35378438ba5c891972024a1766935d2e01397a33502aa99e956a6b19
## fUSDT (Future USDT)
- 合约地址: 0x14dc4f7d3E4197438d058C3D156dd9826A161134
- 总供应量: 1万亿 (1,000,000,000,000)
- 交易哈希: 0x071f535971bc3a134dd26c182b6f05c53f0c3783e91fe6ef471d6c914e4cdb06
## 共同特性
- 固定供应量,不可增发
- 6位小数精度(与USDT一致)
- 标准ERC-20接口
- 部署者: 0x4F7E78d6B7C5FC502Ec7039848690f08c8970F1E
## 文件结构
- eUSDT/: 合约源码、编译脚本、部署脚本、README
- fUSDT/: 合约源码、编译脚本、部署脚本、README
- contracts/README.md: 补充dUSDT说明文档
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 05:30:25 -08:00
hailin
c05bcc9a76
feat(trading): 实现10%交易手续费进入积分股池
...
- 在成交时从卖方收益中扣除10%手续费
- 手续费流入积分股池(greenPoints/200万账户)
- 添加详细分类账记录,包含买卖双方账户和来源标注
- Trade表新增fee字段记录每笔交易的手续费
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 21:33:40 -08:00
hailin
192e2551bf
feat(trading): 资产页面实时价格 WebSocket 推送
...
## 后端变更
- 添加 @nestjs/websockets, @nestjs/platform-socket.io, socket.io 依赖
- 新增 PriceGateway (price.gateway.ts): WebSocket 网关,namespace /price
- 新增 PriceBroadcastScheduler: 每秒广播价格更新到所有连接的客户端
- 更新 ApiModule 和 ApplicationModule 注册新模块
## Kong API Gateway
- 添加 WebSocket 路由: /ws/price -> trading-service:3022/price
- 支持 ws/wss 协议
## 前端变更
- 添加 socket_io_client 依赖
- 新增 PriceWebSocketService: 带自动断线重连机制的 WebSocket 服务
- 指数退避重连策略 (1s -> 30s)
- 最大重连次数 10 次
- 连接状态流监听
- 资产页面集成 WebSocket:
- initState 时连接,dispose 时断开
- 实时更新价格和销毁倍数
- 保持原有的每秒积分股增长计算
## 调试日志
- 前后端都添加了详细的调试日志方便排查问题
- 日志前缀: [PriceWS], [AssetPage], [PriceGateway], [PriceBroadcastScheduler]
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 21:18:34 -08:00
hailin
f6458dd12e
fix(trading): 做市商吃单间隔从1-4秒改为固定1秒
...
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 21:00:21 -08:00
hailin
07247fe05f
fix: 将划转最小限制从5改为0.01积分股
...
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 19:29:05 -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
b7c8cdd249
fix(trading): 销毁和快照只在交易系统激活时执行
...
- BurnScheduler 检查 trading_configs.isActive 状态
- 交易系统未激活时跳过每分钟销毁和价格快照
- 交易系统未激活时跳过每小时状态日志
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 08:28:48 -08:00
hailin
096d87e2a8
fix(trading): 区分买方支付和卖方收款金额
...
问题:executeBuy使用含销毁倍数的tradeAmount,但买方冻结的是原始金额
原因:买方支付=原始数量×价格,卖方收款=有效数量×价格(含销毁)
修复:
- buyerPayAmount = tradeQuantity × price(买方实际支付)
- sellerReceiveAmount = effectiveQuantity × price(卖方实际收款)
- executeBuy 使用 buyerPayAmount
- executeSell 使用 sellerReceiveAmount
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 08:08:58 -08:00