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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
bfafd6d34c
refactor(prisma): consolidate migrations into single init files
...
Merge multiple incremental migrations into single init migration for each service:
- auth-service: 3 migrations → 1 (user auth, SMS, KYC)
- contribution-service: 4 migrations → 1 (contribution accounts, 15-level hierarchy, 3-tier bonus)
- mining-admin-service: 6 migrations → 1 (admin, CDC sync tables, prisma relation mode)
- mining-service: 1 migration (no change needed, renamed for consistency)
- mining-wallet-service: 3 migrations → 1 (wallet system, removed blockchain tables)
- trading-service: 1 migration (no change needed, renamed for consistency)
All migrations renamed from timestamp format (20260111000000_*) to sequential format (0001_init)
for cleaner migration history.
Note: Requires clearing _prisma_migrations table before applying to existing databases.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 11:04:24 -08:00
hailin
f790d2bbe5
refactor(api): 升级 trading-service API 前缀至 v2
...
将 trading-service 的 API 版本从 v1 升级到 v2,统一 2.0 系统架构:
**trading-service:**
- main.ts: 全局前缀 api/v1 → api/v2
- Dockerfile: 健康检查路径 /api/v1/health → /api/v2/health
- transfer.service.ts: 更新调用 mining-service 的 API 路径
- /api/v1/mining/accounts/.../transfer-out → /api/v2/...
- /api/v1/mining/accounts/.../transfer-in → /api/v2/...
此变更使 trading-service 正式成为 2.0 系统的一部分,
与 auth-service、contribution-service、mining-service、
mining-admin-service、mining-wallet-service 保持一致。
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 22:37:17 -08:00
hailin
05f98def6d
fix(sync): 修复数据同步 API 认证和响应解析
...
- 为 contribution/mining/trading 服务的 AdminController 添加 @Public 装饰器
- 修复 initialization.service.ts 中响应格式解析,支持 { data: { ... } } 格式
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 21:47:32 -08:00
hailin
6fedebf020
fix(trading-service): 更新 package-lock.json
...
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 21:35:33 -08:00
hailin
3fe6bdbbf0
feat(sync): 添加批量同步 API 端点
...
- 为 contribution-service、mining-service、trading-service 添加 AdminController
- 提供 /admin/accounts/sync 端点用于批量获取账户数据
- 在 mining-admin-service 添加同步 mining/trading 账户的初始化端点
- 添加 sync-all 端点支持一键同步所有数据
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 21:27:35 -08:00
hailin
673e5ff772
fix(dockerfiles): 修复2.0服务健康检查路径
...
- 修正健康检查URL从 /health 到 /api/v1/health(因为设置了全局前缀)
- 增加 start-period 从 10s 到 60s,给服务更多启动时间
受影响服务:
- contribution-service
- mining-service
- mining-admin-service
- trading-service
- mining-wallet-service
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 06:45:44 -08:00
hailin
51456373a9
feat(2.0-services): 添加所有服务的初始Prisma migrations
...
使用 prisma migrate diff 生成初始数据库迁移脚本:
- mining-admin-service: 管理后台相关表及CDC同步表
- auth-service: 用户认证相关表
- trading-service: 交易相关表
- mining-wallet-service: 钱包相关表
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 00:06:46 -08:00
hailin
319a787c43
fix(2.0-dockerfiles): 添加openssl解决Prisma兼容性问题
...
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:46:14 -08:00
hailin
c1de1daea8
fix(2.0-dockerfiles): 使用printf替代echo解决alpine兼容性问题
...
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:37:29 -08:00
hailin
d3fecc42c1
fix(2.0-services): 优化所有Dockerfile使用--chown避免chown -R
...
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:23:57 -08:00
hailin
ca55a81263
feat(mining-wallet-service): 添加独立钱包管理微服务
...
- 新增 mining-wallet-service 完整实现,100% 与 1.0 系统隔离
- 支持系统账户:总部、运营、省公司、市公司、手续费、热钱包、冷钱包
- 支持池账户:份额池、黑洞池、流通池
- 支持用户钱包:算力钱包、代币存储钱包、绿积分钱包
- 实现用户-区域映射(独立于 1.0)
- 集成 KAVA 区块链:提现、充值、DEX Swap
- 所有交易记录包含交易对手信息(counterparty)
- 使用 Outbox 模式确保事件可靠发布
feat(mining-admin-service): 添加 mining-wallet-service CDC 同步
- 新增 13 个 Synced 同步表接收钱包服务数据
- 新增 wallet-sync.handlers.ts 处理钱包服务事件
- 更新 cdc-sync.service.ts 注册钱包服务事件处理器
chore(mining-service, trading-service): 为池账户添加 counterparty 跟踪字段
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 22:21:08 -08:00
hailin
ee5f841034
fix(outbox): 实现指数退避重试策略,最大延迟3小时
...
修复Outbox事件发布的重试机制:
1. 更新Prisma Schema (mining-service, trading-service):
- 添加OutboxStatus枚举 (PENDING, PUBLISHED, FAILED)
- 添加topic、key、status、retryCount、maxRetries、lastError等字段
- 添加publishedAt、nextRetryAt时间戳
- 优化索引 (status, nextRetryAt, createdAt)
2. 更新OutboxRepository (mining-service, trading-service):
- findPendingEvents(): 查询待处理且到达重试时间的事件
- markAsPublished(): 标记事件已发布
- markAsFailed(): 实现指数退避算法 (30s基础, 最大3小时)
- deletePublished(): 清理已发布的旧事件
3. 更新OutboxScheduler (auth/mining/trading-service):
- 使用指数退避: 30s, 60s, 120s, 240s, ... 最大10800s (3小时)
- 记录重试次数和错误信息
- 达到最大重试次数后标记为FAILED
指数退避公式: delay = min(30s * 2^(retryCount-1), 3h)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 21:08:57 -08:00
hailin
28ad8c2e2f
feat(2.0-services): 为auth/mining/trading服务添加Outbox事件发布机制
...
- auth-service:
- 添加Kafka生产者模块和服务
- 添加Redis服务用于分布式锁
- 添加OutboxScheduler定时发布Outbox事件到Kafka
- 更新InfrastructureModule为全局模块
- mining-service:
- 添加Kafka生产者服务
- 添加OutboxRepository用于管理Outbox事件
- 添加OutboxScheduler定时发布事件
- trading-service:
- 添加Kafka生产者服务
- 添加OutboxRepository用于管理Outbox事件
- 添加OutboxScheduler定时发布事件
所有服务的Outbox调度器:
- 每30秒发布待处理的事件到Kafka
- 每天凌晨3点清理7天前已处理的事件
- 使用Redis分布式锁确保多实例部署时只有一个实例处理
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 20:54:37 -08:00