Commit Graph

763 Commits

Author SHA1 Message Date
hailin 05040b3495 feat(mobile): integrate community hierarchy API in profile page
- Call getMyCommunityHierarchy() to get parent/child community info
- Display parent community name (defaults to 总部社区 if none)
- Display child communities count and first name

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 20:13:52 -08:00
hailin 9cf8b5305b feat(authorization): add community hierarchy API
- Add internal referral-chain API in referral-service for getting ancestor path and team members
- Extend ReferralServiceClient to call referral-chain API
- Add findActiveCommunityByAccountSequences repository method
- Add getCommunityHierarchy application service method
- Add GET /authorizations/my/community-hierarchy endpoint
- Update frontend with CommunityHierarchy model and getMyCommunityHierarchy method

API returns:
- myCommunity: user's own community authorization (if any)
- parentCommunity: nearest parent community (defaults to 总部社区 if none)
- childCommunities: nearest child communities in user's team

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 18:18:49 -08:00
hailin c1d30b0a65 fix(mobile): correct community benefit description
Changed from "有资格获得 3% 的社区福利" to "每新增认种 1 棵可获得 80 USDT"
which accurately reflects the actual community benefit rule.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 17:49:19 -08:00
hailin eae6293b4a fix(mobile): fix authorization API response parsing
The API returns {"success": true, "data": [...]} format but the code
was checking if response.data is List directly. Now properly extracts
the data field before parsing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 17:40:04 -08:00
hailin f8cfb5e597 feat(authorization): add admin API for community authorization
Add new endpoint POST /api/v1/admin/authorizations/community
that allows administrators to directly authorize users as community
managers without requiring the user to self-apply first.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 17:03:34 -08:00
hailin 003bef1c76 fix(reward): add REFERRAL_SERVICE_URL and AUTHORIZATION_SERVICE_URL
reward-service was trying to connect to localhost instead of Docker
network service names, causing connection refused errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 16:48:47 -08:00
hailin b1e6cb5041 chore(authorization): add axios dependency for referral-service HTTP client
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 16:37:01 -08:00
hailin ccef23f5b0 feat(authorization): integrate with referral-service for team statistics
- Add InternalTeamStatisticsController in referral-service for service-to-service API
- Create ReferralServiceClient in authorization-service to fetch real team statistics
- Replace MockTeamStatisticsRepository with real HTTP client implementation
- Configure docker-compose with REFERRAL_SERVICE_URL for authorization-service

This enables authorization-service to get real team planting counts from
referral-service for authorization assessment and activation logic.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 16:30:35 -08:00
hailin 05545dea59 fix(authorization): add missing findByAccountSequence to MockTeamStatisticsRepository
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 16:18:12 -08:00
hailin b6bc10d680 debug(backup-service): log allowed services on init
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 16:00:29 -08:00
hailin 5ecb13974f fix(backup-service): add mpc-service to allowed services
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 15:42:40 -08:00
hailin 660e5ea3a0 fix(mpc-service): add backup service environment variables
Add BACKUP_SERVICE_URL, BACKUP_SERVICE_ENABLED, and SERVICE_JWT_SECRET
to mpc-service configuration to enable backup share storage.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 15:39:52 -08:00
hailin 41af5ef3a3 fix(mpc/backup): add accountSequence to backup share storage
- mpc-service: add accountSequence param to StoreBackupShareParams
- mpc-service: pass accountSequence when calling backup-service
- backup-service: add logging for store request success/failure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 15:06:00 -08:00
hailin 300fe211c8 fix: add accountSequence to all services and fix compilation errors
- reward-service: add accountSequence to aggregates, services, tests
- authorization-service: fix UserId/AdminUserId to accept accountSequence, add findByAccountSequence to repositories
- referral-service: fix test files for accountSequence changes
- Add migration files for reward-service and authorization-service

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 14:14:06 -08:00
hailin 034fb53674 refactor: use accountSequence as unified user identifier across all services
- planting-service: extract accountSequence from JWT, pass to referral-service
- referral-service: query by accountSequence instead of userId
- reward-service: add accountSequence field to schema and all layers
- wallet-service: prioritize accountSequence lookup over userId
- authorization-service: change userId from String to BigInt, add accountSequence

This change ensures consistent cross-service user identification using
accountSequence (8-digit unique business ID) instead of internal database IDs.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 13:55:03 -08:00
hailin 62a21b73a5 fix(referral): use accountSequence instead of userId for user registration events
identity-service sends userId=0 in events (temp value before DB save),
use accountSequence as the unique identifier instead
2025-12-10 13:29:36 -08:00
hailin 31c3c24a12 fix(reward-service): correct healthcheck endpoint path to /api/v1/health 2025-12-10 12:48:26 -08:00
hailin 8532bf6945 fix(blockchain): use amountFormatted to rebuild TokenAmount from DB
Previously used amount (raw) with hardcoded 18 decimals, which caused
incorrect formatting for USDT (6 decimals). Now uses amountFormatted
which is already correctly formatted during deposit detection.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 12:22:32 -08:00
hailin db3e0ba1bd fix(blockchain): fix deposit stuck in CONFIRMING status
The updateConfirmations logic only checked for DETECTED status
when confirming, so deposits that transitioned to CONFIRMING
would never be confirmed even with enough confirmations.

Changed condition to accept both DETECTED and CONFIRMING status.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 12:19:29 -08:00
hailin 5e670e64b3 fix(blockchain): read token decimals from contract for deposit detection
Previously decimals were hardcoded to 18, causing incorrect amount parsing
for USDT which uses 6 decimals. Now reads decimals() from ERC20 contract
when processing deposits.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 11:57:34 -08:00
hailin 8cea0e7998 fix(reward): change sourceOrderId to sourceOrderNo string type
Fixes BigInt conversion error when consuming planting.order.paid events.
The orderId from planting-service is a string format like PLT1765391584505Q0Q6QD,
not a numeric value.

Changes:
- reward-source.vo.ts: sourceOrderId (bigint) → sourceOrderNo (string)
- reward-calculation.service.ts: updated all method signatures
- reward-application.service.ts: updated distributeRewards params
- event-consumer.controller.ts: removed BigInt() conversion
- prisma schema: changed column type to VarChar(50)
- mapper/repository: updated field names accordingly
- Removed incompatible prisma.config.ts (Prisma 7.x format)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 11:12:58 -08:00
hailin 6b10b15492 chore(identity): temporarily disable device registration check
Allow same device to create multiple accounts for testing purposes.
Original validation code is commented out and can be restored later.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 11:07:21 -08:00
hailin 176a4b1493 fix(guide): change referral code input text color to black for visibility
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 10:44:39 -08:00
hailin 9e6fc04344 fix(reward): register EventConsumerController to enable Kafka consumption
EventConsumerController was not registered in KafkaModule, causing
@MessagePattern('planting.order.paid') to never be subscribed.
This resulted in reward-service having empty memberAssignment.

Also added forwardRef to resolve circular dependency between
ApplicationModule and InfrastructureModule.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 10:36:55 -08:00
hailin 4972e56ad2 fix(reward): correct health check path to /api/v1/health
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 10:16:57 -08:00
hailin adc063eb7a fix(authorization): add Kafka microservice for @EventPattern to work
authorization-service uses @EventPattern('planting-events') to consume
planting events but was missing connectMicroservice() configuration.
Without this, the service could not receive planting events, causing:
- Province team benefits (20 USDT) not distributed
- City team benefits (40 USDT) not distributed
- Community benefits (80 USDT) not distributed
- Monthly assessment data not updated

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 10:08:55 -08:00
hailin f36fc0e8b7 fix(services): add Kafka microservice for @MessagePattern to work
The @MessagePattern decorator requires connectMicroservice() to work.
Without this configuration, services could not consume Kafka messages
via @MessagePattern, causing events to be lost.

Fixed services:
- planting-service: ACK consumption
- identity-service: event consumption
- reward-service: event consumption

blockchain-service already had this configured.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 09:57:07 -08:00
hailin 70d1a8bfb8 fix(referral): add idempotency check for Kafka event processing
- Add processed_events table to track handled events
- Check eventId before processing planting.created events
- Skip duplicate events and still send ACK to stop retries

This prevents data accumulation when Kafka events are redelivered
due to ACK failures or consumer timeouts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 09:38:13 -08:00
hailin 1b2211d641 feat(mobile): add personal planting count to profile page
Added "个人种植数" stat between direct referral count and team planting
count in the profile page team stats section.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 09:13:20 -08:00
hailin 317ea1234d fix(mobile): use wallet-service for balance queries
- Planting page: fetch USDT balance from wallet-service instead of blockchain-service
- Deposit page: fetch USDT balance from wallet-service instead of blockchain-service

This ensures balance reflects internal wallet state, not on-chain balance.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 09:07:15 -08:00
hailin 3714edb30b feat(wallet): add detailed logging for freeze-for-planting API
Added comprehensive logging to track:
- Request parameters (userId, amount, orderId)
- Wallet balance information
- Balance check results
- Freeze operation status

This helps debug the 400 error when planting-service calls wallet-service.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 08:38:36 -08:00
hailin d84fc9409b fix(mobile): add 5s delay before confirm-province-city API call
Backend requires 5 seconds wait time after selectProvinceCity before
confirmProvinceCity can be called. Added delay to comply with this rule.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 08:30:52 -08:00
hailin c887cf7ec6 fix(mobile): send all 4 fields for province/city selection API
API requires provinceCode, provinceName, cityCode, cityName (all strings).
Previous fix only sent 2 fields, now sending all 4 required fields.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 08:27:15 -08:00
hailin a44f6c7c35 fix(mobile): send provinceName/cityName instead of codes to API
API expects provinceName and cityName (strings) but frontend was
sending provinceCode and cityCode (numbers), causing 400 error.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 08:23:03 -08:00
hailin 4074281088 feat(mobile): allow manual input for planting quantity
- Replace static text with editable TextField for quantity
- Add warning when input exceeds max quantity based on balance
- Sync +/- buttons with input field value

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 08:16:23 -08:00
hailin 3dcf685715 feat(mobile): add close button to planting confirm dialog
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 08:07:27 -08:00
hailin 0b3ddd51bd feat(mobile): connect trading and mining pages to real APIs
- Trading page: fetch settleableUsdt and dstBalance from wallet-service
- Trading page: implement real settlement API call
- Mining page: fetch community/province/city from authorization-service
- Add loading states and error handling

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 08:02:43 -08:00
hailin 76377c3bb6 fix(mobile): fix wallet API response parsing
The wallet API returns wrapped format { success, data, timestamp }
but the parser was reading from the root object directly.
Now correctly unpacks the inner 'data' field before parsing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 06:55:30 -08:00
hailin 22c32031af feat(authorization): add community assessment progress to profile page
Backend:
- Add initialTargetTreeCount, currentTreeCount, monthlyTargetTreeCount
  fields to AuthorizationDTO and AuthorizationResponse
- Query TeamStatistics to populate current tree count in getUserAuthorizations

Frontend:
- Update AuthorizationResponse to parse new progress fields
- Replace hardcoded community assessment values with real API data
- Show authorization status: red (unauthorized), orange (pending), green (active)
- Display progress bar and target requirements based on benefit status

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 06:44:13 -08:00
hailin e5e2793337 feat(planting): add payment reliability improvements
## wallet-service
- Add freeze/confirm/unfreeze API endpoints for planting deduction
- Add deductFrozen method to wallet-account aggregate
- Add PLANT_FREEZE and PLANT_UNFREEZE ledger entry types
- Add idempotency check in deductForPlanting
- Fix test files to include accountSequence parameter

## planting-service
- Add PaymentCompensation model and migration
- Add payment-compensation.repository.ts
- Add payment-compensation.service.ts (background job for retry)
- Add HTTP retry mechanism with exponential backoff
- Refactor payOrder to use freeze → transaction → confirm flow
- Create compensation record on unfreeze failure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 06:31:54 -08:00
hailin 68182fd0a3 feat(referral): add personal/team planting counts to direct referral list
- Backend: batch query TeamStatistics to get each direct referral's
  personalPlantingCount and teamPlantingCount
- Updated DTO and query interfaces with new fields
- Frontend: parse and display "个人/团队" counts in profile page

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 05:57:46 -08:00
hailin e1017fff46 fix(mobile): reduce direct referral list item spacing
- Row gap: 8px → 4px
- Vertical padding: 12px → 8px

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 05:18:23 -08:00
hailin 13f670e9dd fix(referral): fix direct referral list display and count issues
1. Return accountSequence instead of userId for direct referral list display
2. Create missing team statistics record when referrer doesn't have one

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 04:58:16 -08:00
hailin b508d9b201 fix(mobile): change update check interval to 90-300s random
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 04:17:06 -08:00
hailin d6eda59d63 fix(mobile): change update check interval from 24h to 30-90s random
Allows faster detection of urgent updates while preventing excessive
API calls with random cooldown period.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 04:16:03 -08:00
hailin 88c59e92fd fix(mobile): use external storage for APK download and close app on install
- Change download path from getApplicationDocumentsDirectory to
  getExternalStorageDirectory for proper FileProvider support
- Add finishAffinity() after starting APK install intent

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 04:03:01 -08:00
hailin fea90b7616 fix(android): add app_flutter path for FileProvider
APK downloaded to getApplicationDocumentsDirectory() which maps to
files/app_flutter/ on Android. FileProvider needs this path configured
to grant URI permission for APK installation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 03:28:13 -08:00
hailin 908f50ab11 fix(mobile): move update check to HomeShellPage with valid context
- Move checkForAppUpdate from SplashPage to HomeShellPage
- Use WidgetsBindingObserver to check on app resume
- Add 24-hour interval check to avoid frequent API calls
- Fix: context.go() invalidates context, so check was never executed

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 03:05:19 -08:00
hailin 12116ff164 feat(blockchain): add deposit repair service and controller
Add internal APIs to diagnose and repair historical deposit issues:
- GET /internal/deposit-repair/diagnose - Query unnotified deposits
- POST /internal/deposit-repair/repair/:depositId - Repair single deposit
- POST /internal/deposit-repair/repair-all - Batch repair all pending deposits
- POST /internal/deposit-repair/reset-failed-outbox - Reset failed outbox events

The repair service creates new outbox events for CONFIRMED deposits
that were never notified to wallet-service.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 02:19:46 -08:00
hailin ba3103a7be fix(mobile): add missing orderNo parameter in router
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-09 22:34:28 -08:00