Commit Graph

1923 Commits

Author SHA1 Message Date
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 613fb33ff9 refactor(frontend): 删除兑换页面卖出功能中的销毁比例标签
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 08:24:26 -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 1aaf32cbb3 refactor(frontend): 认种记录汇总中总金额改为总贡献值
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 00:33:57 -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 76d6c30a20 refactor(frontend): 发送/接收积分股改名为积分值
- send_shares_page.dart: 标题改为发送积分值,提示信息同步更新
- receive_shares_page.dart: 标题改为接收积分值

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 00:26:44 -08:00
hailin 216394a44f refactor(trading): rename 卖出相关 黑洞 to 积分股池
- Update 10% 进入黑洞 to 10% 进入积分股池
- Update 销毁金额 to 进入积分股池 in sell confirmation
- Update 注意 text in sell confirmation
- Change color from red to green for 积分股池 text

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 00:15:38 -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 ea1e376939 chore(app): rename app to 股行
- Update Android app label in AndroidManifest.xml
- Update iOS CFBundleDisplayName and CFBundleName in Info.plist

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 23:50:23 -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 d5e5bf642c fix(kline-chart): prevent overflow in indicator selector and legend
- Wrap indicator selector Row in SingleChildScrollView for horizontal scrolling
- Add maxX boundary checks in _drawLegend to stop drawing when exceeding available space
- Prevents text overflow on narrow screens or when displaying many indicators

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 09:55:49 -08:00
hailin 27bf67e561 fix(kline-chart): improve pinch-to-zoom and fullscreen display
- Refactor to pixel-based scrolling system for smoother interaction
- Fix pinch-to-zoom to properly scale around focal point
- Adjust fullscreen layout to give more space to main chart (65%)
- Add candleWidth parameter to all painters for consistent rendering
- Detect multi-touch gestures using pointerCount

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 09:49:14 -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 1f0bd15946 feat(mining-app): add trading records page and remove withdrawal records
- Add TradingRecordsPage to display trade order history with status
- Connect trading records to profile page "交易记录" button
- Remove unused "提现记录" button from profile page
- Add route and navigation for trading records

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 09:22:15 -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 3d6b6ae405 feat(mining-app): connect my team page from profile
Link the "我的团队" menu item in profile page to the team tree page,
completing the integration of the team tree feature.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 09:03:06 -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 20a90fce4c feat(mining-app): add professional kline chart with technical indicators
- Add KlineChartWidget with pinch-to-zoom, fullscreen mode
- Implement MA, EMA, BOLL indicators for main chart
- Implement MACD, KDJ, RSI indicators for sub chart
- Add volume display with crossline info
- Add C2C trading feature with market/publish/detail pages
- Add P2P transfer functionality (send/receive shares)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 08:51:00 -08:00
hailin 3ce8bb0044 fix(mining-admin): parse burn records response correctly
The trading-service wraps all responses with { success, data, timestamp }.
Need to extract data.data for burn records endpoint.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 08:41:16 -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 3096297198 feat(mining-app): 资产页面优化及个人资料编辑功能
- 删除资产页面的"提现"按钮,将"划转"改为"C2C"
- 删除积分值卡片上的"可提现"标签
- 简化资产页面和兑换页面的标题栏,移除左右图标
- 统一资产页面背景色与兑换页面一致
- 新增个人资料编辑页面,支持头像颜色选择和昵称修改
- 头像和昵称支持本地存储

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 07:58:16 -08:00
hailin 854bb7a0ac fix(mining-admin): correct ContributionSyncStatus property names
Property names should match what's used in the UI component:
- miningNetworkTotal (was miningTotal)
- networkTotalContribution (was contributionTotal)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 07:41:59 -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 9e15fa4fd8 fix(admin-web): 修复全网算力同步状态显示
- 将显示内容从用户有效算力改为全网理论算力
- 显示 mining-service 和 contribution-service 的全网理论算力对比

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 04:02:29 -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