Commit Graph

1867 Commits

Author SHA1 Message Date
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 4b1855f57a fix(mining-app): use public API for asset page to avoid JWT mismatch
Changed from myAssetProvider (requires JWT) to accountAssetProvider
(public API) to avoid 401 errors when trading-service JWT_SECRET
doesn't match auth-service.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 06:34:19 -08:00
hailin 4cef31b1d1 fix(api-gateway): correct mining-admin-service upstream URL to /api/v2
The service uses 'api/v2' as global prefix, not 'api/v1'.
Request flow: /api/v2/mining-admin/auth/login -> strip path -> /auth/login -> upstream /api/v2/auth/login

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 06:29:10 -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 d12bbb17be feat(mining-app): add share pool balance display on contribution page
Display real-time share pool balance (积分股池实时余量) in the total
contribution card on the contribution page.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 04:27:48 -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 183b2bef59 style(mining-app): hide accountSequence and rename phone to ID on profile page
- Remove accountSequence (ID: xxxx) display from profile page
- Rename "手机:" label to "ID:" for phone number display

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 03:39:18 -08:00
hailin 1bdb9bb336 style(mining-admin-web): display all numbers with 8 decimal places
Update all formatDecimal, formatNumber, formatPercent, formatCompactNumber
and formatShareAmount calls to use 8 decimal precision for consistent display
across all pages (dashboard, users, reports, system-accounts).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 02:55:23 -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 420dfbfd9f fix(mining-admin-web): display theoretical network contribution instead of effective
Changed "全网算力" card to show theoretical total (totalTrees * 22617) instead
of effective contribution. Added effective contribution to subValue for reference.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 02:04:08 -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 8ae9e217ff fix(mining-app): fix mining records data parsing from mining-service
Map miningMinute->distributionMinute, minedAmount->shareAmount,
secondDistribution->priceSnapshot to match entity fields

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 00:02:30 -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 debc8605df fix(mining-app): rename MiningRecordsPage widget to avoid name conflict
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 23:33:38 -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 546c0060da feat(mining-app): add mining records and planting records pages
- Add mining records page showing distribution history with share amounts
- Add planting records page with adoption summary and detailed records
- Remove 推广奖励 and 收益明细 from profile page
- Add planting-ledger API endpoint and data models

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 23:23:31 -08:00
hailin b81ae634a6 fix(mining-app): hardcode team bonus tiers display to 15
- Profile page: 团队上级 shows '15' instead of actual unlockedBonusTiers
- Contribution page: 已解锁上级 shows '15级' instead of actual value

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 20:28:02 -08:00
hailin 0cccc0e2cd refactor(mining-app): rename VIP等级 to 团队上级 and 直推人数 to 引荐人数
- Changed "VIP等级" label to "团队上级" in profile stats row
- Changed display value from vipLevel (V3 format) to unlockedBonusTiers (raw number)
- Changed "直推人数" label to "引荐人数" for consistency

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 20:07:52 -08:00
hailin cd938f4a34 refactor(mining-app): rename team contribution labels
Update contribution page labels:
- "团队层级" → "团队下级"
- "团队奖励" → "团队上级"
- "直推人数" → "引荐人数"
- "已解锁奖励" → "已解锁上级" (with unit "档" → "级")
- "已解锁层级" → "已解锁下级"
- "直推及间推" → "引荐及间推" in subtitle

Update contribution records page labels:
- "团队层级" → "团队下级"
- "团队奖励" → "团队上级"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 19:58:41 -08:00
hailin 84fa3e5e19 refactor(mining-app): rename 绿积分 to 积分值 across all pages
Replace all occurrences of "绿积分" with "积分值" in:
- trading_page.dart (price display, pool name, input field)
- asset_page.dart (account labels)
- trading_account.dart (entity comment)
- price_info.dart (entity comment)
- market_overview.dart (entity comment)
- DEVELOPMENT_GUIDE.md (documentation)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 19:57:17 -08:00
hailin adeeadb495 fix(mining-app): update profile page - hide items and rename label
- Rename "团队层级" to "团队下级" in stats row
- Hide "实名认证" option from account settings
- Hide "我的邀请码" card section entirely
- Remove unused _buildInvitationCard and _buildActionButton methods

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 19:47:14 -08:00
hailin 42a28efe74 fix(mining-app): remove operator account note from expiration card
Remove the "运营账号贡献值永不失效" note from the contribution
expiration countdown card.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 19:28:31 -08:00
hailin 91b8cca41c feat(mining-app): implement hide/show amounts toggle
- Add hideAmountsProvider to control amount visibility
- Add tap handler to eye icon in total contribution card
- Toggle icon between visibility_outlined and visibility_off_outlined
- Hide amounts with **** when toggled in:
  - Total contribution value
  - Three column stats (personal, team level, team bonus)
  - Today's estimated earnings
  - Contribution detail summary rows

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 19:22:03 -08:00
hailin 02cc79d67a fix(mining-app): reduce bottom padding on navigation pages
Reduce bottom SizedBox from 100 to 24 on all four main navigation
pages (contribution, trading, asset, profile) to eliminate excessive
whitespace when scrolling to bottom.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 19:17:59 -08:00
hailin 7bc8547a96 fix(mining-app): rename ContributionRecordsListPage to avoid name conflict
- Rename page class from ContributionRecordsPage to ContributionRecordsListPage
- Add typedef RecordsPageData for ContributionRecordsPage data model
- Fix import statements and unused variable

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 19:08:09 -08:00
hailin caffb124d2 feat(mining-app): add contribution records page with category summary
- Create contribution_records_page.dart with full list view
  - Pagination support with page navigation
  - Filter by source type (personal, team level, team bonus)
  - Show detailed info: tree count, base contribution, rate, amount
  - Display effective/expire dates and status badges

- Update contribution_page.dart detail card
  - Show category summary instead of record list
  - Display three categories with icons: personal, team level, team bonus
  - Add navigation to full records page via "查看全部"

- Add route configuration for /contribution-records

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 19:02:30 -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 f57b0f9c26 chore(mining-app): configure release build
- Add kDebugMode check to LoggingInterceptor to suppress logs in release
- Remove debug print statements from contribution_providers
- Add Play Core proguard rules to fix R8 missing classes error

Build command: flutter build apk --release --split-per-abi --target-platform android-arm,android-arm64
Output:
- app-arm64-v8a-release.apk: 18MB
- app-armeabi-v7a-release.apk: 16MB

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 17:24:42 -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 cb3c7623dc fix(mining-app): fix Riverpod ref usage in router redirect callback
Use cached auth state from AuthNotifier instead of ref.read() to avoid
"Cannot use ref functions after provider changed" exception during rebuild.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 08:49:52 -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 ed9f817fae feat(mining-app): add estimated earnings and contribution stats API
- Add ContributionStats entity and model for network-wide statistics
- Add /api/v2/contribution/stats endpoint
- Implement estimatedEarningsProvider to calculate daily earnings
- Formula: (user contribution / total contribution) × daily allocation
- Update contribution page to display real estimated earnings
- Add debug logs for contribution records API

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 08:37:30 -08:00
hailin 6bcb4af028 feat(mining-app): integrate real APIs for Asset and Profile pages
- Asset page now uses trading-service /asset/my endpoint
- Profile page integrates auth-service /user/profile and contribution-service
- Add new entities: AssetDisplay, PriceInfo, MarketOverview, TradingAccount
- Add corresponding models with JSON parsing
- Create asset_providers and profile_providers for state management
- Update trading_providers with real API integration
- Extend UserState and UserInfo with additional profile fields
- Remove obsolete buy_shares and sell_shares use cases
- Fix compilation errors in get_current_price and trading_page

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 08:22:40 -08:00