hailin
9adef67bb8
feat(admin-web): P2P划转记录管理页面 + 手续费汇总
...
## 后端 — mining-admin-service
- users.controller: 新增 GET /users/p2p-transfers 端点(搜索+分页)
- 放在 :accountSequence 路由之前避免被 catch-all 拦截
- users.service: 新增 getP2pTransfers() 代理方法
- 调用 trading-service 的 /api/v2/p2p/internal/all-transfers
- 返回划转记录列表 + 汇总统计 + 分页信息
## 前端 — mining-admin-web
- 新增 /p2p-transfers 页面:
- 三个汇总卡片:累计手续费收入、累计划转金额、成功划转笔数
- 搜索框支持账号、手机号、转账单号搜索
- 记录表格:转账单号、发送方、接收方、转账金额、手续费、备注、时间
- 分页控件
- sidebar: 新增"P2P划转"导航项(位于"交易管理"下方)
- users.api: 新增 getP2pTransfers API + P2pTransferRecord 类型
- use-users: 新增 useP2pTransfers hook
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 10:41:55 -08:00
hailin
9f94344e8b
feat: 算力记录排序 + P2P转账管理后台查询端点
...
## 算力记录排序(全栈)
- mining-admin-service controller: 新增 sortBy/sortOrder 查询参数
- users.service: 动态构建 orderBy(支持 sourceType, levelDepth, amount, createdAt)
- levelDepth 排序特殊处理:先按 sourceType 分组,再按 levelDepth/bonusTier 排序,null 值排末尾
- admin-web contribution-records-list: 可点击排序表头(来源、获得算力、层级/等级、生效日期)
- 三态切换:升序 → 降序 → 取消排序
- 排序图标指示当前状态
## P2P转账管理后台查询端点(后端准备)
- trading-service P2pTransferService: 新增 getAllTransfers() 方法
- 列出全部已完成 P2P 转账记录(分页 + 搜索)
- 返回汇总统计:总手续费、总转账金额、总笔数
- trading-service controller: 新增 GET /p2p/internal/all-transfers(@Public 内部端点)
- P2pTransferHistoryItem 接口扩展 fromPhone/fromNickname/toNickname 字段
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 10:37:22 -08:00
hailin
b1607666a0
fix(contribution): LEVEL_OVERFLOW 回收任务,修复已解锁层级的溢出记录无法被回收的 bug
...
当下级认种时上级 unlocked_level_depth 不足,层级奖励进入 LEVEL_OVERFLOW(PENDING)。
上级后续解锁到足够层级后,现有 backfill 因条件 expectedLevel > currentLevel 为 false
而跳过,导致 PENDING 记录永远无法被回收。新增独立调度任务每10分钟扫描并回收。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 10:12:48 -08:00
hailin
ca4e5393be
feat(p2p-transfer): 实现P2P划转手续费功能(全栈)
...
## 功能概述
- P2P转账(积分值)支持手续费收取,手续费存入系统成本费账户 S0000000002
- 发送方实际扣除 = 转账金额 + 手续费,接收方全额收到转账金额
- 手续费金额和最小划转金额可在管理后台动态配置(默认: 手续费5, 最小划转6)
## 后端 — mining-admin-service
- GET /configs/p2p-transfer-fee: 管理端获取手续费配置(需鉴权)
- POST /configs/p2p-transfer-fee: 管理端设置手续费配置,校验最小划转 > 手续费
- GET /configs/internal/p2p-transfer-fee: 内部调用端点(@Public 无鉴权)
## 后端 — trading-service
- Prisma schema: P2pTransfer model 新增 fee Decimal(30,8) 字段
- docker-compose: 新增 MINING_ADMIN_SERVICE_URL 环境变量
- p2p-transfer.service: 动态获取手续费配置,余额校验含手续费,
事务内分别记录转账流水和手续费流水(P2P_TRANSFER_FEE),
手续费存入系统成本费账户 S0000000002
- p2p-transfer.controller: 新增 GET /p2p/transfer-fee-config 代理端点
- 转账结果和历史记录新增 fee 字段返回
## 前端 — mining-admin-web
- configs.api.ts: 新增 getP2pTransferFee / setP2pTransferFee API
- use-configs.ts: 新增 useP2pTransferFee / useSetP2pTransferFee hooks
- configs/page.tsx: 新增"P2P划转手续费设置"卡片(手续费 + 最小划转金额)
## 前端 — mining-app (Flutter)
- api_endpoints.dart: 新增 p2pTransferFeeConfig 端点常量
- p2p_transfer_fee_config_model.dart: 新增手续费配置 Model
- trading_remote_datasource.dart: 新增 getP2pTransferFeeConfig 方法
- transfer_providers.dart: 新增 p2pTransferFeeConfigProvider
- send_shares_page.dart: 发送页面显示手续费信息、最小划转金额提示、
实际扣除金额计算、"全部"按钮扣除手续费、确认弹窗展示手续费明细
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 06:44:19 -08:00
hailin
817b7d3a9f
fix(contribution): 算力分配时序保证 + bonus补发stale-read修复
...
4处改动确保部署清库重新同步后100%可靠:
1. contribution.scheduler.ts - CDC就绪门控
注入CDCConsumerService,processUnprocessedAdoptions/publishRecentlyUpdatedAccounts/
processContributionBackfill三个调度方法开头加isCdcReady()检查,
确保用户+推荐+认种三阶段CDC同步全部完成后才开始处理。
2. contribution-calculation.service.ts - 推荐数据防护
calculateForAdoption()中,userReferral为null时warn并return,
不标记distributed,调度器下次重试。覆盖continuous mode下
认种事件先于推荐事件到达的竞态场景。
3. bonus-claim.service.ts - bonus补发stale-read修复
processBackfillForAccount()中,level事务的updateAccountUnlockStatus
通过incrementDirectReferralAdoptedCount()同时修改unlockedLevelDepth
和unlockedBonusTiers,导致bonus分支条件永远为false。
修复:保存originalDirectReferralAdoptedCount和originalUnlockedBonusTiers,
bonus分支使用原始值判断和传参。
4. config.controller.ts - mining-admin同步检查增强
isSynced新增allAdoptionsProcessed条件(unprocessedAdoptions===0),
确保所有认种分配+补发完成后才允许激活挖矿。
修复data变量作用域问题(原在if块内声明,外部引用会报错)。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 05:54:02 -08:00
hailin
83384acdac
fix(mining-service): Redis DB 11 冲突修复,迁移至 DB 16
...
问题:
mining-service (2.0) 与 blockchain-service (1.0) 共用 Redis DB 11,
存在数据污染和资源抢占风险。虽然当前 Key 前缀不同
(mining:* vs blockchain:*),但缺乏结构性隔离保障。
方案:
- 将 mining-service Redis DB 从 11 迁移到 16 (超出默认 0-15 范围)
- Redis 基础设施配置增加 --databases 20,支持 DB 16+
- 同步修正 .env.example 与代码默认值不一致的问题 (原 .env=1, 代码=11)
修改清单:
- mining-service/infrastructure.module.ts: 代码默认值 11 → 16
- mining-service/redis.service.ts: fallback 默认值 1 → 16
- mining-service/.env.example: REDIS_DB=1 → REDIS_DB=16
- docker-compose.2.0.yml: mining-service REDIS_DB 11 → 16 + 注释
- docker-compose.yml: Redis 添加 --databases 20
- docker-compose.infra.yml: Redis 添加 --databases 20
- docker-compose.windows.yml: Redis 添加 --databases 20
部署注意:
1. 需重启 Redis 容器使 --databases 20 生效
2. 需重启 mining-service 使新 DB 16 生效
3. 旧 DB 11 中 mining-service 的残留数据可手动清理:
redis-cli -n 11 KEYS "mining:*" | xargs redis-cli -n 11 DEL
Redis DB 分配表 (修改后):
1.0: DB 0-11 (identity=0, wallet=1, ..., blockchain=11)
2.0: DB 8,10,12-16 (blockchain=8, contribution=10, trading=12,
admin=13, auth=14, wallet=15, mining=16)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 02:22:20 -08:00
hailin
454b379f6c
feat(mining-blockchain-service): mining_ 前缀隔离,与 blockchain-service 100% 资源分离
...
mining-blockchain-service 的所有共享资源全部加上 mining_ 前缀,
确保与 1.0 blockchain-service 完全隔离,互不干扰。
## Kafka Topic 隔离 — 生产者 (event-publisher.service.ts)
- source header: 'blockchain-service' → 'mining-blockchain-service'
- topic 映射全部加 mining_ 前缀:
- blockchain.deposits → mining_blockchain.deposits
- blockchain.wallets → mining_blockchain.wallets
- blockchain.transactions → mining_blockchain.transactions
- mpc.SigningRequested → mining_mpc.SigningRequested
- blockchain.market_maker.deposits → mining_blockchain.market_maker.deposits
- 默认 fallback: blockchain.events → mining_blockchain.events
## Domain Event eventType 隔离 (5 个事件类)
- deposit-detected.event.ts: mining_blockchain.deposit.detected
- deposit-confirmed.event.ts: mining_blockchain.deposit.confirmed
- wallet-address-created.event.ts: mining_blockchain.wallet.address.created
- transaction-broadcasted.event.ts: mining_blockchain.transaction.broadcasted
- market-maker-deposit-confirmed.event.ts: mining_blockchain.market_maker.deposit.confirmed
## Kafka Topic 隔离 — 消费者 (3 个 consumer)
- mpc-event-consumer: mining_mpc.KeygenCompleted / SigningCompleted / SessionFailed
- withdrawal-event-consumer: mining_wallet.withdrawals / mining_wallet.system-withdrawals
- 事件类型检查: mining_wallet.withdrawal.requested / mining_wallet.system-withdrawal.requested
- deposit-ack-consumer: mining_wallet.acks
- 事件类型检查: mining_wallet.deposit.credited
- outbox ACK 匹配: mining_blockchain.deposit.confirmed
## Kafka 事件类型 — Event Handlers
- mpc-signing.client.ts:
- MPC_SIGNING_TOPIC → mining_mpc.SigningRequested
- eventType → mining_blockchain.mpc.signing.requested
- withdrawal-requested.handler.ts:
- mining_blockchain.withdrawal.confirmed / failed / status
- system-withdrawal-requested.handler.ts:
- mining_blockchain.system-withdrawal.confirmed / failed
## Redis Key 前缀隔离
- address-cache: blockchain:monitored_addresses: → mining_blockchain:monitored_addresses:
- hot-wallet-balance: hot_wallet:dusdt_balance: → mining_hot_wallet:dusdt_balance:
- hot-wallet-balance: hot_wallet:native_balance: → mining_hot_wallet:native_balance:
## 数据库名称隔离
- docker-compose.yml: rwa_blockchain → rwa_mining_blockchain
- docker-compose.2.0.yml: rwa_blockchain → rwa_mining_blockchain
- deploy-mining.sh: MINING_DATABASES + SERVICE_DB 映射 → rwa_mining_blockchain
## 下游服务需配套更新 (不在本次修改范围)
- mpc-service: 消费 mining_mpc.SigningRequested, 发布 mining_mpc.* 结果
- mining-wallet-service: 发布 mining_wallet.*, 消费 mining_blockchain.*
- trading-service: 消费 mining_blockchain.market_maker.deposits
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 01:58:45 -08:00
hailin
08cf4681f2
fix: migration 使用 IF NOT EXISTS 防止重复创建 + clean 去掉 --remove-orphans
...
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 00:37:29 -08:00
hailin
4a803ea008
feat(deploy): 添加 clean 命令清除 2.0 所有 Docker 资源
...
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 23:36:35 -08:00
hailin
6b92ab0dd8
Revert "fix(2.0): 所有 Kafka consumer 改为 fromBeginning: true 确保 full-reset 全量同步"
...
This reverts commit 534d4ce70c .
2026-01-29 22:41:40 -08:00
hailin
a41feb841f
fix(mining-service): 添加 ManualMiningRecord 缺失的 migration 0004
...
schema 中定义的 manual_mining_records 表缺少对应的 migration 文件,
导致 schema 与 migration 不一致。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 22:30:04 -08:00
hailin
534d4ce70c
fix(2.0): 所有 Kafka consumer 改为 fromBeginning: true 确保 full-reset 全量同步
...
- mining-blockchain-service: withdrawal/mpc/deposit-ack consumer 改为 fromBeginning: true
- trading-service: cdc-consumer/market-maker-deposit consumer 改为 fromBeginning: true
- mining-service: contribution-event handler 改为 fromBeginning: true
- deploy-mining.sh: CDC_CONSUMER_GROUPS 补充所有 2.0 服务的 consumer group ID
确保 ./deploy-mining.sh full-reset 可以 100% 从 0 开始同步所有 1.0 数据。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 22:20:23 -08:00
hailin
5dc37e24d2
fix(deploy): cdc_resnapshot 清空 rwa_auth 的 processed_cdc_events
...
cdc_resnapshot 之前只清空 rwa_contribution 的幂等表,遗漏了 rwa_auth,
导致 wallet address CDC 重新快照后消息被幂等检查跳过,KAVA 地址无法重新同步。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 14:24:59 -08:00
hailin
f2b83650b5
fix(deploy): full-reset 添加 wallet CDC consumer group 和修复 cdc-resnapshot
...
- CDC_CONSUMER_GROUPS 添加 auth-service-cdc-group-wallet
- cdc_resnapshot 同时停止 auth-service(之前只停了 contribution-service)
- cdc_resnapshot 完成后同时启动 auth-service
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 14:12:45 -08:00
hailin
6f01892945
fix(debezium): identity connector 添加 wallet_addresses 表
...
Debezium identity-connector 之前只捕获 user_accounts 表,
导致 auth-service 的 WalletAddressCdcConsumer 收不到任何事件。
添加 public.wallet_addresses 到 table.include.list。
需要重新注册 connector 才能生效。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 14:06:42 -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
3ff38ca9c2
fix(mining-admin): 添加 buildNumber 到版本检查返回结果
...
mining-app VersionInfo.fromJson 要求 buildNumber 字段,
CheckUpdateResult 接口和 checkUpdate 方法之前未包含该字段。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 13:29:53 -08:00
hailin
96e1fa4534
fix(mining-admin): 适配 mining-app 版本检查 API 格式
...
- CheckUpdateDto: current_version_code 改为 versionCode 匹配 mining-app 请求参数
- MobileVersionController: 响应格式改为 { hasUpdate, latestVersion: {...} } 匹配 mining-app 解析
- TransformInterceptor: 添加 @SkipTransform() 装饰器,移动端版本检查接口跳过响应包装
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 13:26:13 -08:00
hailin
f595c6f26d
fix(mining-admin): 将 upload DTO 的 changelog 改为可选
...
前端 upload-modal 在用户未填写更新日志时不发送 changelog 字段,
导致 DTO 校验失败返回 400。将 changelog 改为 @IsOptional(),
与前端行为一致。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 13:13:57 -08:00
hailin
4112b45b9e
feat(mining-admin): 新建公开版本管理接口供 mobile-upgrade 前端使用
...
mining-admin-service 有全局 AdminAuthGuard,导致 mobile-upgrade 前端
调用版本接口返回 401。新建 UpgradeVersionController (@Public) 作为
独立的公开接口,路径为 /api/v2/upgrade-versions,不影响现有需认证的
/api/v2/versions 接口。前端 apiPrefix 同步更新。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 12:53:29 -08:00
hailin
7e289430ae
feat(auth-service): CDC 同步 wallet_addresses 并提供内部 API
...
- auth-service: 新增 SyncedWalletAddress Prisma model 和 migration
- auth-service: 新增 WalletAddressCdcConsumer 消费 1.0 钱包地址变更
- auth-service: 新增 InternalController 提供 kava 地址查询 API
- trading-service: IdentityClient 改调 auth-service 内部 API
- docker-compose.2.0.yml: 添加 CDC_TOPIC_WALLET_ADDRESSES 和 AUTH_SERVICE_URL
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 12:20:23 -08:00
hailin
83fa6bec74
feat(c2c): 支持绿积分(GREEN_POINTS)作为默认支付方式
...
- 后端 paymentMethod 字段从 PostgreSQL 枚举改为 String,支持逗号分隔多种支付方式
- 添加数据库迁移将 C2cPaymentMethod 枚举列转为 TEXT 类型
- DTO 验证改为 @IsString() 接受 GREEN_POINTS 及其组合
- 前端保持发送完整的支付方式列表(含 GREEN_POINTS)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 11:39:00 -08:00
hailin
263f1ecf8e
feat(c2c): 卖单自动获取账户ID和Kava地址,移除手动输入
...
后端创建卖单时自动从 identity-service 获取卖家 Kava 地址并存入订单,
前端发布页面自动展示 accountSequence(只读),不再需要手动输入1.0系统ID。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 11:08:56 -08:00
hailin
776d181ef3
fix(trading-service): 修复P2P转账API响应双重包装问题
...
- 移除controller中的手动包装,由TransformInterceptor统一处理
- 前端增加类型检查防止解析错误
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 09:11:59 -08:00
hailin
28c73136a8
fix(trading-service): 修复P2P转账历史查询参数解析
...
确保 page 和 pageSize 是有效数字,避免 skip: NaN 错误
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 09:00:28 -08:00
hailin
dcc83b9f79
fix(trading-service): 使用Docker容器名调用auth-service
...
改为使用 auth-service:3024 替代 IP 地址
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 08:56:24 -08:00
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
hailin
64b9dcb6c7
fix(trading): 修复订单撮合时buyOrderId为null的问题
...
问题:在createOrder中调用tryMatch时,传入的order对象没有id
原因:orderRepository.save()返回orderId但没有更新到order对象
解决:保存后重新从数据库获取订单,确保有id再进行撮合
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 07:44:44 -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
1760f9b82c
fix(trading): 为所有 DTO 添加 class-validator 装饰器
...
修复 trading.controller、admin.controller、transfer.controller
的 DTO 验证问题,解决 App 下单时 400 错误。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 06:14:06 -08:00
hailin
edd6ced2a3
fix(trading): 为做市商 DTO 添加 class-validator 装饰器
...
修复做市商初始化失败问题。由于 ValidationPipe 配置了
forbidNonWhitelisted: true,没有装饰器的属性会被拒绝。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 05:47: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
5a719eef61
fix(trading): 合并销毁和快照任务确保K线价格正确
...
将 executeMinuteBurn 和 createPriceSnapshot 合并为单个 cron 任务,
确保快照在销毁完成后创建,避免K线出现价格不变的间隔
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 23:26:04 -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
b1fedd417f
fix(trading): 修复 migration 执行顺序问题
...
将 0003_add_market_maker_depth 重命名为 0006_add_market_maker_depth,
确保在 0005_add_market_maker_and_order_source 创建 market_maker_configs 表
之后再执行添加深度字段的 migration。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:59:06 -08:00
hailin
3265ee2506
feat(trading): 将初始绿积分从5760调整为57.6亿
...
## 变更说明
将积分股池的初始绿积分从 5760 调整为 5,760,000,000 (57.6亿)
### 价格影响
- 初始价格:5760 / 100.02亿 ≈ 5.76×10⁻⁷ → 57.6亿 / 100.02亿 ≈ 0.576
- 价格从极小数值变为正常交易数值
- 更符合实际交易习惯
### 技术评估
- 数据库精度 Decimal(30,8) 完全足够
- 价格公式线性放大,逻辑不变
- 销毁倍数公式不涉及 greenPoints,不受影响
- "越卖越涨"机制保持不变
### 修改文件
- prisma/seed.ts: 初始化种子数据
- burn.service.ts: 运行时初始化逻辑
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:50:43 -08:00
hailin
8c78f26e6d
feat(trading): 实现做市商吃单/挂单模式互斥机制
...
## 后端 - trading-service
### MarketMakerService
- 新增 MarketMakerMode 类型:'idle' | 'taker' | 'maker'
- 新增 getCurrentMode() 和 getRunningStatus() 方法获取当前运行状态
- start() (吃单模式): 启动前自动停止挂单模式
- startMaker() (挂单模式): 启动前自动停止吃单模式
- 两种模式互斥,同一时间只能运行一种
### MarketMakerController
- getConfig 接口返回 runningStatus 运行状态
- 新增 GET /status 接口获取做市商运行状态
## 前端 - mining-admin-web
### 做市商管理页面
- 新增运行模式状态卡片,显示当前模式(空闲/吃单/挂单)
- 吃单模式和挂单模式使用 runningStatus 判断状态
- 添加互斥提示:启动一个模式会自动停止另一个
- 挂单模式添加警告提示:卖单被吃会触发销毁导致价格上涨
### API 更新
- 新增 RunningStatus 接口类型
- getConfig 返回类型增加 runningStatus
- 新增 getRunningStatus API
## 设计说明
- 吃单模式(推荐):做市商只作为买方,不触发额外销毁
- 挂单模式(谨慎使用):做市商挂卖单会触发销毁机制
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:41:39 -08:00
hailin
3b6bd29283
feat(trading): 实现完整的CEX做市商双边深度系统
...
## 后端 - trading-service
### 数据库模型扩展 (Prisma Schema)
- TradingConfig: 新增 depthEnabled 字段控制深度显示开关
- MarketMakerConfig: 新增双边挂单配置
- makerEnabled: 做市商挂单模式开关
- bidEnabled/askEnabled: 买/卖方向独立开关
- bidLevels/askLevels: 买/卖档位数量
- bidSpread/askSpread: 买/卖价差比例
- bidLevelSpacing/askLevelSpacing: 档位间距
- bidQuantityPerLevel/askQuantityPerLevel: 每档数量
- refreshIntervalMs: 刷新间隔
- MarketMakerOrder: 新增做市商订单追踪模型
- MarketMakerLedger: 新增做市商账户流水模型
### 做市商服务 (MarketMakerService)
- depositShares/withdrawShares: 积分股充值/提现
- startMaker/stopMaker: 做市商挂单模式启停
- refreshMakerOrders: 核心双边挂单逻辑
- 根据当前价格计算买卖各档位价格和数量
- 自动撤销旧订单并创建新订单
- 记录做市商订单关联
- cancelAllMakerOrders: 撤销所有做市商订单
- getDepth: 获取订单簿深度数据
- updateMakerConfig/getMakerOrders: 配置和订单查询
### API 端点
- MarketMakerController:
- POST /deposit-shares: 积分股充值
- POST /withdraw-shares: 积分股提现
- POST /start-maker: 启动挂单模式
- POST /stop-maker: 停止挂单模式
- POST /refresh-orders: 手动刷新订单
- POST /cancel-all-orders: 撤销所有订单
- PUT /maker-config: 更新挂单配置
- GET /maker-orders: 查询做市商订单
- GET /depth: 获取深度数据
- AdminController:
- GET/POST /trading/depth-enabled: 深度显示开关
- PriceController:
- GET /depth: 公开深度接口 (受 depthEnabled 控制)
### 领域层扩展
- TradingAccountAggregate: 新增 depositShares/withdrawShares 方法
- OrderAggregate: 支持 source 字段标识订单来源
## 前端 - mining-admin-web
### 做市商管理页面 (/market-maker)
- 账户余额展示: 积分值和积分股余额
- 资金管理: 积分值/积分股的充值和提现对话框
- 吃单模式: 启动/停止/手动吃单控制
- 挂单模式: 启动/停止/刷新订单/撤销所有
- 深度开关: 控制公开 API 是否返回深度数据
- 深度展示: 实时显示买卖盘深度数据表格
### 前端架构
- market-maker.api.ts: 完整的 API 客户端
- use-market-maker.ts: React Query hooks 封装
- sidebar.tsx: 新增"做市商管理"导航菜单
## 数据库迁移
- 0003_add_market_maker_depth: 双边深度相关字段
- 0005_add_market_maker_and_order_source: 订单来源追踪
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:11:23 -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
481a355d72
feat(trading): add buy function control switch with admin management
...
- Add buyEnabled field to TradingConfig in trading-service with migration
- Add API endpoints for get/set buy enabled status in admin controller
- Add buy function switch card in mining-admin-web trading page
- Implement buyEnabledProvider in mining-app with 2-minute cache
- Show "待开启" when buy function is disabled in trading page
- Add real-time asset value refresh in asset page (1-second updates)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 08:56:35 -08:00
hailin
e8f3c34723
fix(contribution): 认种记录总贡献值显示用户实际有效算力
...
后端:
- get-planting-ledger.query.ts: 添加effectiveContribution字段
- 从contributionAccount获取用户实际的个人算力(personalContribution)
前端:
- planting_record.dart: PlantingSummary添加effectiveContribution字段
- planting_record_model.dart: 解析effectiveContribution字段
- planting_records_page.dart: 总贡献值显示effectiveContribution而非totalAmount
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 08:29:14 -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
d5f3f3b868
feat(frontend): 实现我的页面其他设置4项功能
...
- 消息通知: 添加开关控制,状态持久化到SharedPreferences
- 深色模式: 添加开关控制,状态持久化到SharedPreferences
- 帮助中心: 新建页面,包含常见问题FAQ和联系方式
- 关于我们: 新建页面,包含应用简介、功能特点、联系方式和法律条款
新增文件:
- settings_providers.dart: 设置状态管理
- help_center_page.dart: 帮助中心页面
- about_page.dart: 关于我们页面
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 01:08:21 -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
d424f2a18e
refactor: rename '算力占比' to '贡献值占比' in mining records
...
- Update label in Flutter mining records page
- Update table header in admin web mining records list
- Update memo strings in mining-wallet-service
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 00:33:02 -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
0ebb0ad076
fix(contribution): use Symbol token for SYNCED_DATA_REPOSITORY injection
...
The GetTeamTreeQuery was importing SYNCED_DATA_REPOSITORY as a Symbol from
the domain interface, but InfrastructureModule defined its own string token.
This caused NestJS dependency resolution to fail.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 09:33:21 -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
4ec6c9f48b
feat(contribution/mining-app): add team tree API using contribution-service 2.0
...
Add team info and direct referrals endpoints to contribution-service,
using SyncedReferral data synced via CDC. Update mining-app to use the
new v2 contribution API instead of legacy referral-service.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 09:17:18 -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
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
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
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
hailin
f22c3efb11
fix: use correct property name 'type' for unallocated contribution
...
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 05:40:40 -08:00
hailin
0241930011
feat(contribution/mining): sync unallocated contributions to mining-service
...
- Add UnallocatedContributionSyncedEvent in contribution-service
- Add event handler in mining-service's contribution-event.handler.ts
- Add handleUnallocatedContributionSynced in network-sync.service.ts
- Add admin endpoint to publish all unallocated contributions
- Sync pending/unallocated contributions to PendingContributionMining table
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 05:29:28 -08:00
hailin
130bf57842
fix(contribution): 处理认种时发布系统账户同步事件
...
- 在保存系统账户算力后,发布 SystemAccountSyncedEvent
- 使 mining-service 能够同步运营/省/市公司的算力
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 05:24:04 -08:00
hailin
962e7874c8
fix(contribution): 修复全网理论算力未同步问题
...
- 在 calculateForAdoption 中调用 updateNetworkProgress 更新 NetworkAdoptionProgress 表
- 之前 publishNetworkProgressEvent 读取的 totalTreeCount 始终为 0,因为表未被更新
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 04:55:30 -08:00
hailin
bb75ff19a4
feat(contribution): 认种处理后自动发布全网进度事件
...
- 每次认种分配完成后发布 NetworkProgressUpdatedEvent
- mining-service 通过 Kafka 实时接收全网理论算力更新
- 定时同步改为每5分钟一次,作为兜底方案
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 04:46:12 -08:00
hailin
23bb8baa9c
feat(mining): 自动同步全网理论算力
...
- 启动时自动从 contribution-service 同步全网数据
- 每分钟定时同步全网理论算力和系统账户算力
- 使用分布式锁防止并发同步
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 04:44:27 -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
72b3b44d37
feat(trading): 实现K线图真实数据展示与Y轴自适应
...
后端 (trading-service):
- 新增 GET /api/v2/price/klines API 端点
- 支持多周期K线聚合 (1m/5m/15m/30m/1h/4h/1d)
- 将 PriceSnapshot 数据聚合为 OHLC 格式
前端 (mining-app):
- 添加 klinesProvider 获取K线数据
- 重写 _CandlestickPainter 使用真实数据
- 实现 Y轴自适应显示,放大价格变化
- 周期选择器联动数据刷新
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 23:57:12 -08:00
hailin
8ab11c8f50
feat(wallet): sync burn events from trading-service to deduct SHARE_POOL_A
...
Add Kafka consumer to listen for burn events (minute burn and sell burn)
from trading-service and deduct from SHARE_POOL_A (100B pool), updating
BLACK_HOLE_POOL balance accordingly.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 23:24:43 -08:00
hailin
88368d1705
fix(wallet): 统一使用 accountSequence 查询钱包,修复转账余额不足问题
...
背景:幽灵钱包 D26010800000 (user_id=133, 余额=0) 导致真实用户
D26010900000 (user_id=0, 余额=200465) 转账失败
原因:
- D26010800000 是 2026-01-08 16:23 通过未知方式创建的脏数据
- 真实用户 D26010900000 在 18:40 注册时,user_id=133 已被占用
- getMyWallet 用 accountSequence 查询显示余额正确
- requestWithdrawal 用 userId 查询找到错误的空钱包
修复:
- Controller: 传 user.accountSequence 而非 user.userId
- Service: 移除 findByUserId fallback,仅用 findByAccountSequence
- 从钱包记录获取 userId 用于订单、流水、事件关联
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 23:00:40 -08:00
hailin
974d660544
feat(mining): sync pool balance via Kafka when mining distributes
...
- mining-service: publish MINING_MINUTE_DISTRIBUTED event to Kafka after
each minute's mining distribution is completed
- mining-wallet-service: add MiningDistributionConsumer to consume the
event and deduct from SHARE_POOL_B
- Add deductFromSharePoolB method in PoolAccountService
- This ensures the share pool balance displayed in mining-app reflects
the actual remaining balance after mining distributions
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 21:30:35 -08:00
hailin
8018fa5110
feat(admin): add trading system management UI and API
...
- Add trading system activate/deactivate endpoints to trading-service
- Add trading management page to mining-admin-web with:
- Trading system status display and control
- Market overview (price, green points, circulation pool)
- Burn progress visualization
- Burn records list with filtering
- Add trading-service proxy configuration to next.config.js
- Add trading menu item to sidebar navigation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 20:37:52 -08:00
hailin
1e2d8d1df7
feat(asset): aggregate mining and trading account balances in asset display
...
- Modify AssetService to fetch mining account balance from mining-service
- Sum mining balance + trading balance for total share display
- Add miningShareBalance and tradingShareBalance fields to AssetDisplay
- Update frontend entity and model to support new fields
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 19:53:31 -08:00
hailin
ed715111ae
fix(trading): auto-initialize SharePool and CirculationPool on startup
...
- Add SharePool and CirculationPool initialization in BurnService.initialize()
- Initialize SharePool with 5760 green points (fixes price showing as 0)
- Remove misleading "= 5,760 积分值" display from trading page
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 19:32:46 -08:00
hailin
e611894b55
fix(trading-service): use payload.sub as accountSequence in JWT guard
...
auth-service puts accountSequence in payload.sub, not payload.accountSequence.
This mismatch caused 401 errors when accessing trading endpoints.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 17:54:28 -08:00
hailin
83b05ac146
fix(docker): add JWT_SECRET to mining-service and trading-service
...
Both services were missing JWT_SECRET environment variable, causing
401 Unauthorized errors when validating JWT tokens from auth-service.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 17:25:55 -08:00
hailin
01bd638dbb
fix(contribution-service): add parent .env path for shared config
...
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 07:00:02 -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
0420b0acab
fix(trading,auth): add parent .env path for shared JWT_SECRET
...
Both services need to read JWT_SECRET from the shared .env file
in the parent directory (backend/services/.env).
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 06:57:57 -08:00
hailin
4440f40fba
fix(mining-wallet-service): use upsert in seed for 100% overwrite
...
Remove existence check, directly upsert pool accounts to ensure
consistent state on every seed run.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 06:42:34 -08:00
hailin
fdff3a3119
feat(mining-wallet-service): add migration for SHARE_POOL_A and SHARE_POOL_B
...
Split the share pool into two accounts:
- SHARE_POOL_A: 100亿 for burning
- SHARE_POOL_B: 200万 for mining distribution
Total: 100.02亿
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 06:40:56 -08:00
hailin
109986ba49
fix(mining-wallet-service): move share-pool-balance route before :type param route
...
NestJS routes are matched in order, so the parameterized :type route
was capturing 'share-pool-balance' before it could reach the public
endpoint, causing 401 errors.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 06:22:30 -08:00
hailin
b5899497ea
fix(mining-wallet-service): use SHARE_POOL_A instead of SHARE_POOL for mining rewards
2026-01-15 06:05:17 -08:00
hailin
40869ef00f
feat: split share pool into A (100亿) and B (200万) accounts
...
Backend changes:
- mining-wallet-service: Split SHARE_POOL into SHARE_POOL_A (100亿, for burning)
and SHARE_POOL_B (200万, for mining distribution)
- Add /pool-accounts/share-pool-balance API endpoint to get total balance
- Update pool initialization logic and seed data
- Fix Kong routing for mining-wallet-service (strip_path: true)
- Fix Kong routing for trading-service (strip_path: true)
Constant updates (100.02亿 = 10,002,000,000):
- mining-service: TOTAL_SHARES
- trading-service: TOTAL_SHARES, trading config defaults
- trading-service seed: initial green points = 5760
Frontend changes:
- Add sharePoolBalanceProvider to fetch pool balance from mining-wallet-service
- Update contribution page to display real-time share pool balance (A + B)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 05:55:52 -08:00
hailin
a1508b208e
fix(api-gateway): correct Kong routing for trading-service
...
- Change strip_path to true to strip /api/v2/trading prefix
- Add /api/v2 to upstream URL so requests route correctly
- Revert accidental main.ts change
Request flow: /api/v2/trading/asset/market -> strip /api/v2/trading -> /asset/market -> upstream /api/v2/asset/market
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 05:27:46 -08:00
hailin
c60d3b2f26
fix(trading-service): correct global prefix to match Kong routing
...
Change prefix from 'api/v2' to 'api/v2/trading' to match Kong gateway
configuration with strip_path: false.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 05:26:11 -08:00
hailin
bb4143d75b
fix(trading-service): exclude prisma from tsconfig to fix build output path
2026-01-15 04:46:01 -08:00
hailin
19428a8cb7
feat(trading-service): sync trading account creation with wallet service
...
- Add CDC consumer to listen for UserWalletCreated events from mining-wallet-service
- Create trading accounts when user contribution wallets are created (lazy creation)
- Add WalletSystemAccountCreated handler for province/city system accounts
- Add seed script for core system accounts (HQ, operation, cost, pool)
- Keep auth.user.registered listener for V2 new user registration
This ensures trading accounts are created in sync with wallet accounts,
supporting both V2 new users and V1 migrated users.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 04:27:14 -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
1f15daa6c5
fix(planting-records): filter only MINING_ENABLED records and fix UI overflow
...
- Backend: Add status filter to getPlantingLedger and getPlantingSummary
- Frontend: Change Row to Wrap for info items to prevent width overflow
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 00:12:07 -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
81a58edaca
fix(contribution-service): calculate totalContribution correctly in CDC event
...
Previously, totalContribution was incorrectly set to effectiveContribution.
Now correctly calculated as: personal + teamLevel + teamBonus
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 23:40:50 -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
141db46356
fix(contribution-service): use real contributionPerTree from rate service
...
Previously, adoptions were synced with hardcoded contributionPerTree=1,
resulting in contribution values like 0.7 instead of the expected 15831.9.
Now the handler fetches the actual contribution rate from ContributionRateService
based on the adoption date, storing values like:
- Personal (70%): 22617 × 70% = 15831.9
- Team Level (0.5%): 22617 × 0.5% = 113.085
- Team Bonus (2.5%): 22617 × 2.5% = 565.425
Note: Historical data may need migration to apply the correct multiplier.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 18:01:30 -08:00
hailin
c852f24a72
fix(auth-service): add 'auth/' prefix to controller routes for Kong compatibility
...
Kong routes /api/v2/auth/* to auth-service without stripping the path,
so controllers need 'auth/' prefix to match frontend requests:
- SmsController: 'sms' -> 'auth/sms'
- PasswordController: 'password' -> 'auth/password'
- UserController: 'user' -> 'auth/user'
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 08:53:48 -08:00
hailin
f2692a50ed
fix(contribution-service): fix toRecordDto using wrong property name
...
- Changed `record.finalContribution` to `record.amount` for getting final contribution value
- Added optional chaining to prevent undefined errors
- Added default values for safety
The ContributionRecordAggregate uses `amount` property, not `finalContribution`.
This was causing "Cannot read properties of undefined (reading 'value')" errors.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 08:43:14 -08:00
hailin
106a287260
fix(mining-service): make health endpoints public
2026-01-14 07:35:42 -08:00
hailin
30dc2f6665
fix(trading-service): make health endpoints public
2026-01-14 07:28:24 -08:00
hailin
e1fb70e2ee
feat(trading-service): add burn system, Kafka events, and idempotency
...
- Add trading burn system with black hole, share pool, and price calculation
- Implement per-minute auto burn and sell burn with multiplier
- Add Kafka event publishing via outbox pattern (order, trade, burn events)
- Add user.registered consumer to auto-create trading accounts
- Implement Redis + DB dual idempotency for event processing
- Add price, burn, and asset API controllers
- Add migrations for burn tables and processed events
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 07:15:41 -08:00
hailin
f3d4799efc
feat(mining-wallet): add UserWalletCreated/Updated events for CDC sync
...
- Publish UserWalletCreated when a new wallet is created
- Publish UserWalletUpdated when wallet balance changes
- Events sent to cdc.mining-wallet.outbox topic for mining-admin-service
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 06:13:34 -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
c6c875849a
fix(mining-service): make mining API public for service-to-service calls
...
Add @Public() decorator to MiningController to allow mining-admin-service
to fetch mining records without authentication.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 05:46:11 -08:00
hailin
ce95c40c84
fix(mining-service): listen to correct CDC topic for contribution sync
...
Changed event handler to:
- Listen to 'cdc.contribution.outbox' topic (CDC/Debezium format)
- Handle 'ContributionAccountUpdated' events instead of 'ContributionCalculated'
- Use effectiveContribution for mining power calculation
This fixes the issue where mining accounts had zero totalContribution
because they weren't receiving contribution sync events.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 05:30:38 -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
hailin
e99b5347da
feat(mining-admin-service): add transfer-enabled API endpoints
...
Add GET and POST /configs/transfer-enabled endpoints to control
the transfer switch. Routes are placed before :category/:key to
avoid being matched as path parameters.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 04:22:11 -08:00
hailin
a15dcafc03
fix(mining-admin-service): 解包mining-service返回的data字段
2026-01-14 04:09:02 -08:00
hailin
d404521841
fix(mining-admin-service): 修复mining-service API路径为v2
2026-01-14 03:58:02 -08:00
hailin
09b15da3cb
fix(mining-service): Redis锁使用毫秒PX代替秒EX支持小数TTL
2026-01-14 03:52:22 -08:00
hailin
901247366d
fix(mining-service): 添加tsconfig include/exclude配置修复构建
2026-01-14 03:48:18 -08:00
hailin
0abc04b9cb
fix(mining-service): 添加Dockerfile构建验证步骤
2026-01-14 03:45:51 -08:00
hailin
2b083991d0
feat(mining-service): 添加migration将minuteDistribution改为secondDistribution
...
支持每秒挖矿分配功能
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 03:40:41 -08:00
hailin
8f616dd45b
fix(mining-service): 修复Dockerfile支持prisma seed
...
- 添加ts-node/typescript到生产环境以支持seed执行
- 启动脚本中添加prisma db seed执行
- 复制tsconfig.json到生产环境
参考mining-wallet-service的Dockerfile配置
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 03:35:34 -08:00
hailin
1008672af9
Revert "fix(mining-service): 修复Docker构建问题"
...
This reverts commit f4380604d9 .
2026-01-14 03:34:58 -08:00
hailin
f4380604d9
fix(mining-service): 修复Docker构建问题
...
- tsconfig.json 添加 include/exclude 排除 prisma 文件夹
- 添加 .dockerignore 排除 seed.ts
- Dockerfile 添加构建验证
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 03:34:04 -08:00
hailin
3b61f2e095
feat(mining): 实现每秒挖矿分配系统
...
核心改动:
- 调度器从每分钟改为每秒执行,用户每秒看到挖矿收益
- 每秒更新账户余额,但MiningRecord每分钟汇总写入一次(减少数据量)
- seed自动执行(prisma.seed配置),初始化后isActive=false
- 只有一个手动操作:管理员在后台点击"启动挖矿"
技术细节:
- 每秒分配量:100万/63,072,000秒 ≈ 0.01585 shares/秒
- Redis累积器:每秒挖矿数据累积到Redis,每分钟末写入数据库
- 分布式锁:0.9秒锁定时间,支持多实例部署
- 后台管理界面:添加挖矿状态卡片和激活/停用按钮
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 03:25:47 -08:00
hailin
25608babd6
feat(mining-service): add initialization APIs and seed script
...
Add admin endpoints:
- GET /admin/status - Get mining system status
- POST /admin/initialize - Initialize mining config (one-time)
- POST /admin/activate - Activate mining distribution
Add prisma seed script for database initialization:
- MiningConfig: 100.02B total shares, 200万 distribution pool
- BlackHole: 100亿 burn target
- MiningEra: First era with 100万 distribution
- PoolAccounts: SHARE_POOL, BLACK_HOLE_POOL, CIRCULATION_POOL
Based on requirements:
- 第一个两年分配100万积分股
- 第二个两年分配50万积分股(减半)
- 100亿通过10年销毁到黑洞
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 02:36:52 -08:00
hailin
a2adddbf3d
fix(mining-admin): transform dashboard API response to match frontend expected format
...
Frontend expects flat DashboardStats and RealtimeData interfaces.
Transform backend nested response to:
- totalUsers, adoptedUsers, networkEffectiveContribution, etc.
- currentMinuteDistribution, activeOrders, pendingTrades, etc.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 02:23:54 -08:00
hailin
d6064294d7
refactor(mining-admin): remove initialization feature
...
System initialization is now handled by seed scripts and CDC sync,
so the manual initialization UI is no longer needed.
Removed:
- Frontend: initialization page and sidebar menu item
- Backend: InitializationController and InitializationService
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 02:22:23 -08:00
hailin
36c3ada6a6
fix(mining-admin): fix audit logs API path and response format
...
- Change controller path from /audit-logs to /audit to match frontend
- Transform response to frontend expected format (items, totalPages, etc.)
- Map admin.username to adminUsername field
- Add keyword query parameter support
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 02:18:53 -08:00
hailin
13e94db450
feat(mining-admin): add /reports/daily endpoint for frontend reports page
...
Add ReportsController with /reports/daily endpoint that maps the
dashboard service data to the format expected by the frontend.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 02:10:47 -08:00
hailin
feb871bcf1
feat(mining-admin): add daily report generation service
...
Add DailyReportService that:
- Generates daily reports on startup
- Updates reports every hour
- Collects stats from synced tables (users, adoptions, contributions, mining, trading)
- Supports historical report generation for backfilling
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 02:03:21 -08:00
hailin
fa6826dde3
fix(mining-admin): use CDC synced tables for system accounts API
...
Change SystemAccountsService to read from syncedWalletSystemAccount and
syncedWalletPoolAccount tables instead of local tables. This fixes the
issue where the frontend shows "暂无数据" despite data being synced.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 01:44:22 -08:00
hailin
eff71a6b22
feat(mining-wallet): publish outbox events for system/pool accounts
...
Add WalletSystemAccountCreated and WalletPoolAccountCreated events:
- seed.ts: publish events when creating HQ/OP/FEE and pool accounts
- contribution-wallet.service.ts: publish events when auto-creating
province/city system accounts
This enables mining-admin-service to sync system accounts via CDC.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 01:28:48 -08:00
hailin
0bbb52284c
fix(contribution): avoid nested transaction timeout in BonusClaimService
...
Use unitOfWork.isInTransaction() to detect if already in a transaction
context (called from ContributionCalculationService). If so, reuse the
existing transaction instead of opening a new one, preventing Prisma
interactive transaction timeout errors.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 01:02:08 -08:00
hailin
7588d18fff
fix(mining-wallet): fix province/city creation and add seed on startup
...
- Use provinceCode directly instead of inferring from cityCode
- Use code as name for province/city records
- Add ts-node to production for seed execution
- Run prisma db seed on container startup
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 00:40:49 -08:00
hailin
e6e44d9a43
Revert "fix(mining-wallet): auto-create HEADQUARTERS account, skip DEFAULT province/city"
...
This reverts commit bf004bab52 .
2026-01-14 00:19:12 -08:00
hailin
bf004bab52
fix(mining-wallet): auto-create HEADQUARTERS account, skip DEFAULT province/city
2026-01-14 00:18:53 -08:00
hailin
a03b883350
fix(mining-wallet): exclude prisma directory from TypeScript compilation
2026-01-14 00:07:58 -08:00
hailin
2a79c83715
feat(contribution): implement TEAM_BONUS backfill when unlock conditions met
...
When a user's direct referral count reaches 2 or 4, the system now automatically
backfills previously pending TEAM_BONUS (T2/T3) contributions that were allocated
to headquarters while waiting for unlock conditions.
- Add BonusClaimService for handling bonus backfill logic
- Add findPendingBonusByAccountSequence and claimBonusRecords to repository
- Integrate bonus claim into updateReferrerUnlockStatus flow
- Add BonusClaimed event consumer in mining-wallet-service
- Generate ledger records for backfilled contributions
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 23:58:54 -08:00
hailin
ef330a2687
feat(mining-wallet): add seed and auto-create province/city accounts
...
- Add prisma seed to initialize core system accounts (HQ, OP, FEE) and pool accounts
- Auto-create province/city system accounts on-demand during contribution distribution
- Province/city regions are also auto-created if not exist
This ensures:
1. Core accounts exist after deployment (via seed)
2. Province/city accounts are created dynamically as orders come in
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 23:36:31 -08:00
hailin
6594845d4c
fix(mining-wallet): fix Kafka consumers not subscribing to topics
...
- Change consumers from @Injectable to @Controller for @EventPattern to work
- Move consumers from providers to controllers array in module
- Add subscribe.fromBeginning config to Kafka microservice
The consumers were not receiving messages because NestJS microservices
require @EventPattern handlers to be in @Controller classes, not just
@Injectable services.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 23:31:31 -08:00
hailin
77b682c8a8
feat(mining-wallet): make initialize endpoints public for internal network calls
...
Changed system-accounts/initialize and pool-accounts/initialize endpoints from
@AdminOnly to @Public to allow deploy scripts to call them without authentication.
These endpoints are only accessible from internal network.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 23:22:17 -08:00
hailin
6ec79a6672
fix(deploy): correct CDC sync API URL path
...
Change from /health/cdc-sync to /api/v2/health/cdc-sync
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 22:26:32 -08:00
hailin
631fe2bf31
fix(contribution-service): reset consumer group offsets to earliest on startup
...
Use admin.resetOffsets({ earliest: true }) before connecting consumer
to ensure CDC sync always starts from the beginning of Kafka topics,
regardless of previously committed offsets.
This fixes the infinite loop issue where existing consumer groups
had committed offsets at high watermark, causing eachMessage to
never be called.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 22:14:51 -08:00
hailin
d968efcad4
fix(contribution): run CDC sync in background to allow API access during sync
...
Change CDC consumer startup from blocking await to non-blocking .then()
so HTTP server starts immediately and /health/cdc-sync API is accessible
for deploy script to poll sync status.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 21:50:59 -08:00
hailin
5a4970d7d9
Revert "fix(contribution): run CDC sync in background to avoid blocking service startup"
...
This reverts commit 703c12e9f6 .
2026-01-13 21:44:18 -08:00
hailin
703c12e9f6
fix(contribution): run CDC sync in background to avoid blocking service startup
...
- Change await to .then() for cdcConsumer.start()
- Allows HTTP endpoints to be accessible during CDC sync
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 21:44:00 -08:00
hailin
8199bc4d66
feat(contribution): add CDC sync status API and fix deploy script timing
...
- Add initialSyncCompleted flag to track CDC sequential sync completion
- Add getSyncStatus() method to CDCConsumerService
- Add /health/cdc-sync endpoint to expose sync status
- Update deploy-mining.sh to wait for CDC sync completion before calling publish APIs
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 21:34:58 -08:00
hailin
aef6feb2cd
fix(contribution): use unique consumer group id for each phase
...
Previous consumer group had already consumed messages, so fromBeginning
had no effect. Now using timestamp-based unique group id to ensure
fresh consumption from beginning each time.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 21:11:40 -08:00