Commit Graph

68 Commits

Author SHA1 Message Date
hailin 856354690d fix(mobile/profile): fix HoldingsSummaryModel import path
Was importing from profile/data/models/ (nonexistent),
should be coupons/data/models/.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 20:22:56 -08:00
hailin 4065d586a9 feat(mobile/coupons): complete coupon holdings feature
- wallet_coupons_page: pass full CouponModel to detail route (was coupon.id)
- wallet_coupons_page: fix status filters (in_circulation=可使用, listed=挂售中)
- my_coupon_detail_page: full rewrite — StatefulWidget, accept CouponModel or String ID,
  real QR code via qr_flutter, barcode toggle, real data (faceValue/price/expiry/orderNo/resale),
  conditional action buttons per isTransferable + resaleCount, grey gradient for expired coupons
- profile_page: convert to StatefulWidget, load holdingsSummary on init, show real hold
  count & totalSaved in quick stats (tappable → /wallet/coupons), add "我的持仓" menu entry
- i18n: add myCoupon.switchQr + common.notFound to all 4 locales

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 20:09:31 -08:00
hailin af7fdfd428 fix(mobile/share): fix referral code overflow, remove team stats & team reward section
- Fix RIGHT OVERFLOWED BY 17 PIXELS: use Flexible on code Text,
  reduce letterSpacing 4→2, reduce horizontal padding
- Remove stats card (direct/team count) from page layout
- Remove 团队层级收益 reward item from reward plan card

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 11:46:13 -08:00
hailin 13ab4ba1f3 fix(mobile/telemetry): add NativeAdapter to heartbeat & uploader, fix 2xx status check
- HeartbeatService: add NativeAdapter on Android to fix DNS via Java stack;
  fix status check from == 200 to >= 200 && < 300
- TelemetryUploader: same two fixes (refactor to _buildDio static method)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 11:29:36 -08:00
hailin 9e368cbf37 fix(mobile+backend): fix notification DNS, message page API bugs, add read-all
Android DNS fix (native_dio_adapter):
- Dart's getaddrinfo() fails on some Android 12+ devices when browser works
  fine — root cause is Dart native socket using different DNS path than
  Android Java stack; fix by using NativeAdapter (OkHttp) on Android
- Add native_dio_adapter ^1.5.1 to pubspec; enable in ApiClient for Android

Message page bugs (5 fixes):
- Fix offset->page: Flutter sent ?offset=0 but backend NotificationQueryDto
  uses page/limit (1-based); now sends ?page=1&limit=50
- Fix announcement tab API: Tab 2 now calls /api/v1/announcements (separate
  resource) instead of /api/v1/notifications?type=ANNOUNCEMENT
- Fix markAllAsRead routing: calls correct API based on active tab
- Fix markAsRead routing: announcement items use announcements API
- Fix detail navigation: passes NotificationItem as route argument

Backend notification-service:
- Add PUT /api/v1/notifications/read-all endpoint
- Add markAllReadByUserId() to repository interface + TypeORM implementation
- Add markAllRead() to NotificationService

i18n (4 languages): add time.justNow/minutesAgo/hoursAgo/daysAgo keys

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 11:15:03 -08:00
hailin 918489e4e5 fix(mobile/telemetry): buffer pre-init events instead of dropping them
Root cause: TelemetryService.initialize() is async (device info collection,
SharedPreferences I/O, remote config sync), taking several hundred ms to
complete. RouteObserver page_view events and auth events fire synchronously
during the initial navigation before initialization finishes, causing the
"TelemetryService not initialized, event ignored" drops seen in logs.

Fix: add _preInitBuffer (max 50 events). logEvent() now enqueues events
instead of dropping when _isInitialized=false. After initialization
completes, all buffered events are replayed in order via logEvent(),
ensuring no startup events are lost.

The network errors ("Failed host lookup: api.gogenex.com") are unrelated —
they are expected in offline test environments and handled gracefully.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 10:42:53 -08:00
hailin 9bcb1f864d feat(mobile): implement invite friends share page with APK QR code & referral marketing
- SharePage: QR code now encodes actual APK download URL from admin-service
  (GET /api/v1/app/version/download/{id} via Kong), referral code shown
  separately below QR for manual entry on registration
- Add referral reward marketing section: direct bonus / team levels (50
  layers) / new user welcome package — drives viral growth
- Show referrer info card when current user was invited via referral code
- Share text updated to marketing copy with APK link + referral code
- VersionChecker.getLatestApkUrl(): fetches latest APK URL regardless of
  needUpdate (passes version=0.0.0 to force server response)
- UpdateService.getLatestApkUrl(): exposes APK URL fetch for UI layer
- i18n (zh-CN/zh-TW/en/ja): add 14 new keys for marketing content,
  APK download hints, reward program descriptions, and referrer info

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 10:17:59 -08:00
hailin 192bc476c4 fix(mobile): move _startDownload to didChangeDependencies to avoid initState context crash
context.t() (Localizations) cannot be called during initState() — inherited
widgets are not yet mounted. When download fails instantly (e.g. no network),
setState with context.t() inside _startDownload fired synchronously within
initState, causing:
  dependOnInheritedWidgetOfExactType called before initState() completed

Fix: add _downloadStarted guard flag; call _startDownload() from
didChangeDependencies() instead of initState(), where context is fully ready.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 09:57:38 -08:00
hailin d79b7cf500 fix(mobile): fix telemetry import path in self_hosted_updater
../../../ → ../../ (channels/ → updater/ → core/, not lib/)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 09:45:20 -08:00
hailin 9519e29b8f feat(mobile/telemetry): collect real network type via connectivity_plus
- Add connectivity_plus: ^6.0.3 to pubspec.yaml
- DeviceInfoCollector._getNetworkType() calls Connectivity().checkConnectivity()
  and maps ConnectivityResult → wifi / mobile / ethernet / vpn / bluetooth / none / unknown
- networkType field in DeviceContext is now populated on every cold start
- All page_view and session events carry the accurate network type in device props

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 09:43:04 -08:00
hailin 9b760c56ee feat(mobile/telemetry): add comprehensive event tracking for DAU, real-time presence & funnels
## 架构设计(亿级用户规模)
- 客户端:本地队列(500条) + 批量上传(20条/30s) + 10% 采样率
- 心跳:前台每60s发送,后端3分钟滑动窗口 → 实时在线率
- DAU:app_session_start 事件 + installId 去重
- 后端接入:Kafka → ClickHouse 消费落盘

## 新增 TelemetryRouteObserver (NEW FILE)
- 继承 RouteObserver<PageRoute>,注册到 MaterialApp.navigatorObservers
- 自动记录所有页面 page_view(push/pop/replace),零侵入业务页面
- 属性:page_name, previous_page, nav_action
- 覆盖全部 37 个已注册路由,无需逐页埋点

## main.dart
- 接入 TelemetryRouteObserver.instance
- 新增 FlutterError.onError 全局钩子 → logError 上报 Widget build 异常

## auth_service.dart — 认证漏斗
| 事件 | 触发时机 | method 属性 |
|------|---------|------------|
| register_success | 注册成功 | phone_sms / email_code |
| login_success    | 登录成功 | password / phone_sms / email_code / wechat / alipay / google / apple |
| user_logout      | 主动登出 | — |

## self_hosted_updater.dart — 升级漏斗
update_prompted → update_accepted / update_dismissed
→ update_download_started → update_download_completed / update_download_failed / update_download_cancelled
→ update_install_triggered / update_install_failed

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 09:39:48 -08:00
hailin cc966fb022 feat(mobile): check for update on app resume from background
- Mix in WidgetsBindingObserver to detect foreground/background transitions
- On resumed: run a silent version check (no dialog) and only show the
  update dialog if a new version is actually available
- Throttle resume checks to once per 2 minutes to avoid excessive API calls
- Once the update dialog has been shown, skip further checks for the rest
  of the session; user won't be re-prompted until next cold start

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 09:29:46 -08:00
hailin d174b74764 debug(mobile): 下载失败诊断日志
添加详细 debugPrint,覆盖:
- URL 检查失败原因
- 实际下载 URL 和保存路径
- HTTP 响应状态码和 content-length/content-range
- DioException 类型、消息、HTTP 状态码
- SHA-256 校验结果(预期值 vs 实际值)
- 文件大小

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 08:53:05 -08:00
hailin 9e07efc54c fix(mobile): remove back button on MarketPage and fix transfer row overflow
- MarketPage: add automaticallyImplyLeading: false (tab-level page)
- TransferPage: wrap maskedContact in Flexible to prevent RIGHT OVERFLOW

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 03:07:50 -08:00
hailin 0c3ef3b598 fix(mobile): fix version check API and platform detection in both apps
genex-mobile/lib/core/updater/version_checker.dart
- platform 从写死 'android' 改为运行时检测 Platform.isIOS ? 'IOS' : 'ANDROID'

admin-app/lib/core/updater/version_checker.dart
- API 路径修正: /api/app/version/check → /api/v1/app/version/check
- 新增 app_type: 'ADMIN_APP'(原缺失,后端默认返回 GENEX_MOBILE 版本)
- platform 从写死 'android' 改为运行时检测
- 响应解析修正: 原逻辑把外层 {code,data} 当版本数据用,
  改为正确取 response.data['data'] 内层对象
- 新增 downloadUrl 相对路径修复(向下兼容旧记录)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 00:50:42 -08:00
hailin 4369aecf60 fix: 修复上传版本500错误 + 优化App冷启动通知请求
- fix(admin-service): versionCode 兜底从 Date.now() 改为 1,避免超出 PostgreSQL integer 范围
- fix(genex-mobile): NotificationBadgeManager 加登录检查,未登录跳过API请求
- fix(genex-mobile): 将通知徽章初始化移至首帧后执行,消除冷启动DNS竞争

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 08:48:09 -08:00
hailin ce9cc5b72e feat(telemetry): 完整实现 presence-service 迁移 + Flutter 遥测接入
## 后端 (backend/services/telemetry-service)

### 修复骨架中的关键缺陷
- 创建本地 JwtAuthGuard / AdminGuard,替换不存在的 @genex/common 包
- 修复 req.user.sub → req.user.id(与 JwtStrategy.validate() 返回值对齐)
- 重写 Dockerfile,移除对不存在的 packages/common 目录的引用
- 更新 telemetry.module.ts,将 JwtAuthGuard / AdminGuard 注册为 providers
- admin-telemetry.controller.ts 改用本地 AdminGuard(检查 role === 'admin')

### 新增功能
- GET /api/v1/telemetry/config:公开配置下发接口
  Flutter TelemetryConfig.syncFromRemote() 每小时拉取,返回全局开关、采样率、
  心跳间隔等配置,所有字段支持环境变量覆盖(TELEMETRY_GLOBAL_ENABLED 等)
- 设备字段(deviceBrand/deviceModel/deviceOs/appVersion/locale)提升为顶层列
  BatchEventsDto / TelemetryEvent 实体 / recordEvents() 全链路补齐
  原因:JSONB 内字段无法走 B-tree 索引,千万级数据分组查询需独立列

### DB 迁移
- 050_add_device_fields_to_telemetry_events.sql:为已有 telemetry_events 表
  新增 5 个设备字段列和 device_brand / app_version 索引

### docker-compose 环境变量
- telemetry-service 新增 TELEMETRY_GLOBAL_ENABLED / SAMPLING_RATE /
  HEARTBEAT_INTERVAL / CONFIG_VERSION 环境变量,支持生产环境热调整

## 前端

### genex-mobile (Flutter 消费者端)
- 复制 lib/core/telemetry/ 模块(11个文件):TelemetryService、
  HeartbeatService、SessionManager、TelemetryUploader、TelemetryStorage 等
- 修正 API 路径:presence/heartbeat → telemetry/heartbeat,
  analytics/events → telemetry/events
- pubspec.yaml 新增依赖:uuid ^4.3.3、equatable ^2.0.5、device_info_plus ^10.1.0
- main.dart:initState 首帧回调初始化 TelemetryService(需 BuildContext 采集设备信息)
  已登录时自动注入 accessToken
- auth_service.dart:_setAuth() 登录成功后注入 userId + accessToken;
  _clearAuth() 退出时清除(同时覆盖 Token 过期自动清除场景)

### admin-app (Flutter 发行方控制台)
- 复制 lib/core/telemetry/ 模块(同上)
- pubspec.yaml 新增依赖:uuid、equatable、device_info_plus、shared_preferences
- IssuerLoginPage:initState 首帧初始化 + 登录成功后注入 userId/token
  使用 api.gogenex.cn(与 UpdateService 域名一致)
- settings_page.dart:退出登录时调用 clearUserId() + clearAccessToken()

## 架构说明
- 在线人数:Redis Sorted Set (genex:presence:online),心跳 60s/次,180s 窗口判定在线
- DAU:app_session_start 事件写入 telemetry_events,每天凌晨 1 点聚合到
  daily_active_stats 表,同时每小时滚动更新当日 DAU
- 设备字段采用 Amplitude 风格:前端本地队列存 properties 内,
  toServerJson() 上传时自动提升为顶层字段,后端写入独立索引列
- 心跳需要 JWT 认证(未登录用户自动跳过,不报错)
- 遥测完全异步,任何失败只打 debug 日志,不影响主流程

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 23:33:13 -08:00
hailin 8f3d0f5d17 fix: comprehensive API compatibility fixes across issuer/user/ai services and Flutter
Backend:
- issuer-service: fix credit-metric entity column names to match DB schema
  (breakage_ratio, market_tenure_months, user_satisfaction, computed_score, etc.)
- issuer-service: add page/limit to ListStoresQueryDto and ListEmployeesQueryDto
- issuer-service: add period field to ReconciliationQueryDto
- issuer-service: fix IssuerStatsController to use req.user.id→issuerId lookup
- issuer-service: add analytics stubs (users/demographics/repurchase/ai-insights)
- issuer-service: add issuers/me/coupons endpoint
- user-service: add GET /users/payment-methods stub before /:id route
- ai-service: add GET /ai/sessions/current/messages stub endpoint

Flutter:
- genex-mobile: fix /users/kyc/status → /users/kyc
- genex-mobile: fix announcements offset→page param
- genex-mobile: fix trading paths (/trading/* → /trades/*)
- admin-app: fix announcements offset→page param

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 09:29:44 -08:00
hailin 3d0223d10a fix: add passport-jwt deps to 3 services + fix messages page UI
Backend:
- Add passport/passport-jwt/@types/passport-jwt to clearing-service,
  compliance-service, notification-service package.json (missing deps
  caused 'Cannot find module passport-jwt' build failure)

Flutter:
- MessagePage: automaticallyImplyLeading: false (no back btn on tab page)
- TabBar: isScrollable+tabAlignment.start to prevent 'Announcements' truncation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 23:15:00 -08:00
hailin 9a4c2c1c19 fix: add missing issuer-service JwtStrategy + fix home search bar overflow
- Add issuer-service/infrastructure/strategies/jwt.strategy.ts (was omitted
  from previous commit, causing build failure)
- Wrap search hint Text in Expanded to prevent Row overflow

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 23:11:10 -08:00
hailin 5113975c72 fix(genex-mobile): 首页移除返回键并修复搜索栏溢出
SliverAppBar 添加 automaticallyImplyLeading: false,
防止 Tab 导航进入时显示返回键,并修复返回键占位导致的搜索栏 overflow 6px。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 23:02:34 -08:00
hailin 75ed31cc04 fix: 全服务注册 JwtStrategy + 修复微信 WxApi 未配置 crash
**后端**
- packages/common: 新增并导出 JwtStrategy(共享 Passport JWT 策略)
- 6 个服务模块(user/issuer/clearing/compliance/notification/telemetry)
  均缺少 JwtStrategy provider,导致所有受保护接口返回 500
  "Unknown authentication strategy jwt"
- 统一修复:各模块 providers 添加 JwtStrategy

**Flutter**
- welcome_page: _onWechatTap() 的 isWeChatInstalled 调用未设 WECHAT_APP_ID
  时会抛出 PlatformException,catch 后降级为"未安装"提示

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 22:24:07 -08:00
hailin 4957b2ef85 feat(genex-mobile): 重构为 Clean Architecture + Riverpod
- 添加 flutter_riverpod ^2.5.1 依赖
- 搭建 core/error/failures.dart 和 core/usecases/usecase.dart 基础骨架
- auth feature 完整 3 层重构:
  - domain: AuthUser + AuthSession 实体, IAuthRepository 接口, 全套 UseCases
  - data: AuthRepositoryImpl(Strangler Fig,委托给 AuthService 保留 token 刷新逻辑)
  - presentation: AuthNotifier + authProvider + currentUserProvider + isAuthenticatedProvider
- 4 个 auth 页面升级为 ConsumerStatefulWidget,使用 ref.read(authProvider.notifier)
- main.dart: ProviderScope 包裹 GenexConsumerApp,改为 ConsumerStatefulWidget
  - 桥接 AuthService ValueNotifier → Riverpod authProvider(会话过期自动导航)
- 12 个 feature 全部创建 Riverpod providers(FutureProvider/NotifierProvider)
- 修复 my_coupons_page.dart 中 EmptyState/StatusTags 缺少 BuildContext 的预存在错误

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 20:12:50 -08:00
hailin 4878449f8c fix(genex-mobile): WXEntryActivity 完整转发微信回调 Intent
用 Intent(intent) 拷贝构造完整复制原始 Intent(action / data / extras),
再通过 setClass 重定向到 MainActivity,确保 fluwx 5.x 的
WXAPiHandler.handleIntent() 能读取到完整的微信授权回调内容。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 18:05:01 -08:00
hailin 5d72d9bd0b fix(genex-mobile): 修复 WXEntryActivity fluwx 5.x 编译错误
fluwx 5.x 将包名从 com.jarvanmo.fluwx 改为 com.jarvan.fluwx,
并移除了 WXEntryActivity 基类,导致编译报错:
  Unresolved reference 'jarvanmo'
  Cycle in supertypes detected

改为「中继(relay)」模式:
- WXEntryActivity 继承 Activity(不再继承 fluwx 基类)
- onCreate 时将微信回调 Intent extras 转发给 MainActivity
- fluwx 5.x 的 FluwxPlugin 实现了 PluginRegistry.NewIntentListener,
  MainActivity.onNewIntent() 会触发 FluwxPlugin 解析微信回调

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 18:03:16 -08:00
hailin 828770add8 fix(alipay): 适配 tobias 5.x 新 auth API,后端生成签名 authString
tobias 3.x+ 移除了顶层函数 aliPayAuth(appId, scope),
改为需要后端预签名的 Tobias().auth(authString)。

变更:
- alipay.provider.ts: 新增 generateMobileAuthString(scope) 方法,
  用 RSA2 私钥生成符合 Alipay SDK 格式的签名授权字符串
- auth.controller.ts: 新增 GET /auth/alipay/auth-string 接口
- pubspec.yaml: tobias ^3.0.0 → ^5.0.0
- auth_service.dart: 新增 getAlipayAuthString() 方法
- welcome_page.dart: 更新支付宝登录流程,先获取 authString 再调用 tobias

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 09:26:30 -08:00
hailin a27baa1181 docs: 完善 fluwx 5.x 迁移与 AdminLayout 跳转备注
- main.dart: 说明 fluwx 5.x 实例共享机制与迁移前后对比
- welcome_page.dart: 说明 addSubscriber/NormalAuth/WeChatAuthResponse 用法,
  以及 fluwx 3.x → 5.x API 对照
- AdminLayout.tsx: 说明 useEffect 跳转的原因(React #310 错误根因)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 09:00:18 -08:00
hailin 2e66db08ef fix(genex-mobile): 升级 fluwx 3.x → 5.x,适配新版 API
fluwx 3.x 不含 Android namespace,导致新版 AGP 构建失败。
升级至 5.x 并迁移 API:
- registerWxApi → Fluwx().registerApi()
- weChatResponseEventHandler → fluwx.addSubscriber()
- sendWeChatAuth → fluwx.authBy(NormalAuth)
- isWeChatInstalled → fluwx.isWeChatInstalled
- WXAuthResp → WeChatAuthResponse

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 08:42:56 -08:00
hailin 91f06890a5 docs(auth): 完善三方登录模块注释 — 含申请步骤与算法说明
AlipayProvider:
- callGateway: 补充完整请求参数结构说明
- sign: 详细说明 RSA2 签名5步骤(字典序→拼接→SHA256WithRSA→Base64)
- chunkBase64: 说明 PEM 格式每64字符换行要求

AppleProvider:
- verifyIdentityToken: 详细说明 claims 验证逻辑和签名验证原理
- getAppleJWKS: 说明 JWKS 缓存策略和 Apple 密钥轮换机制
- jwkToPublicKeyPem: 说明 JWK→SPKI PEM 转换过程
- base64urlDecode: 说明 Base64URL 与标准 Base64 的区别

GoogleProvider:
- verifyIdToken: 说明 tokeninfo vs JWKS 本地验证的权衡,补充响应字段说明

welcome_page.dart:
- 类头注释: 补充平台配置要求和各登录方式申请前提
- _onAlipayTap: 补充 tobias v3 API 结构、result 格式解析、scope 含义、iOS/Android 配置要求
- _parseParam: 说明 URI query 解析的原因
- _onGoogleTap: 补充 signIn 返回 null 的含义、idToken 说明、Android 配置
- _onAppleTap: 补充 Apple 3 项重要限制(姓名/邮箱只在首次授权时返回)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 04:56:11 -08:00
hailin 1fc0fcb95e feat(auth): 支付宝 + Google + Apple 三方登录
后端 (auth-service):
- 新增 AlipayProvider (RSA2签名) + AlipayService + POST /auth/alipay
- 新增 GoogleProvider (tokeninfo验证) + GoogleService + POST /auth/google
- 新增 AppleProvider (JWKS验证ES256 JWT) + AppleService + POST /auth/apple
- SocialProvider 枚举新增 ALIPAY
- .env.example 补充三方登录申请步骤文档

Flutter (genex-mobile):
- pubspec.yaml: 新增 tobias / google_sign_in / sign_in_with_apple
- auth_service.dart: loginByAlipay / loginByGoogle / loginByApple
- welcome_page.dart: Android=微信+支付宝+Google, iOS=+Apple
- AndroidManifest: 添加支付宝包名查询
- Info.plist: 支付宝 URL Scheme + alipay/alipays queries
- i18n: 4 语言补充失败提示文案

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 04:40:31 -08:00
hailin 2790d4c226 fix(genex-mobile): Apple 登录按钮仅在 iOS 上显示
Apple Sign In 是 iOS/macOS 生态专属功能,Android 用户不存在
Apple ID 账号体系,不应在 Android 上展示该入口。

使用 defaultTargetPlatform == TargetPlatform.iOS 条件渲染:
- Android: WeChat + Google(2个按钮)
- iOS:     WeChat + Google + Apple(3个按钮)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 04:21:34 -08:00
hailin 44de21a733 docs(auth): 完善微信登录模块注释 — 含申请移动应用完整步骤
wechat.provider.ts:
  - 补充微信开放平台申请移动应用的完整流程(企业资质、创建应用、
    获取 AppID/AppSecret、启用 unionid、获取 Android 签名 MD5)
  - 说明常见 errcode 含义(40029/42003/40163)
  - 安全注意事项(AppSecret 保密、服务端换 token、防重放建议)

wechat.service.ts:
  - 完整业务流程注释(6步,含新老用户分支逻辑)
  - unionid 优先策略原理(跨 App 唯一性,防重复注册)
  - 每次登录同步微信信息说明
  - 自动生成账号字段说明(nickname/email/phone/password/kycLevel)

.env.example:
  - 微信开放平台申请步骤(注册/认证/创建/获取/启用 unionid)
  - Android 签名 MD5 获取命令
  - Flutter --dart-define 构建参数说明
  - Universal Links 说明

WXEntryActivity.kt:
  - 包名路径规范说明(applicationId vs namespace 区别)
  - AndroidManifest 配置要求
  - 回调未触发的排查步骤(签名/包名/debug包名)
  - 获取 Android 签名 MD5 命令

main.dart:
  - registerWxApi 传参说明(--dart-define 用法)
  - 未配置 WECHAT_APP_ID 时的降级行为
  - Universal Links 配置说明

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 04:04:26 -08:00
hailin d68d48cb95 feat(auth): 微信登录 / 注册完整实现 — social_accounts + fluwx 全链路
后端:
- 新增 social_accounts 表 Entity/Repository/Migration (049)
- WechatProvider: code ↔ access_token / 获取用户信息 (native https)
- WechatService: unionid 优先查找 → 自动登录/注册 → 发布事件
- POST /auth/wechat 端点 (WechatLoginDto, referralCode 支持)
- auth.module.ts 注册 SocialAccount、WechatProvider、WechatService

Flutter (genex-mobile):
- pubspec.yaml: 添加 fluwx ^3.10.0
- main.dart: registerWxApi 初始化 (WECHAT_APP_ID via --dart-define)
- AuthService: loginByWechat(code, referralCode?, deviceInfo?)
- WelcomePage: 改为 StatefulWidget,监听 weChatResponseEventHandler
  微信按钮触发 sendWeChatAuth,授权成功后自动登录 → /main
  未安装微信 / 登录失败均有 SnackBar 提示
- 4语言 i18n: wechatNotInstalled / wechatLoginFailed

Android:
- AndroidManifest: WXEntryActivity + queries(com.tencent.mm)
- WXEntryActivity.kt: 继承 fluwx 提供的基类,无额外代码
- proguard-rules.pro: keep WeChat SDK 类

iOS:
- Info.plist: CFBundleURLTypes (wx${WECHAT_APP_ID}) + LSApplicationQueriesSchemes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 03:37:51 -08:00
hailin 9473512530 feat(auth): 邮箱注册完整实现 — Gmail SMTP + 邮件验证码全链路
后端 (auth-service):
- 新增 EmailVerification / EmailLog 实体 + TypeORM 映射
- Email 值对象:格式校验、小写归一化、脱敏展示
- Gmail SMTP Provider (nodemailer) + ConsoleEmailProvider (dev)
- EmailCodeService:Redis 缓存快速路径,与 SmsCodeService 对称
- EmailService:sendCode/verifyCode + 日限额 + 业务规则校验
- 新增端点:POST /auth/email/send / register-email / login-email / reset-password-email
- EMAIL_ENABLED 环境变量切换真实/控制台发送
- 数据库迁移:048_create_email_verifications.sql

前端 (genex-mobile):
- AuthService 新增 sendEmailCode / registerByEmail / loginByEmail / resetPasswordByEmail
- RegisterPage 根据 isEmail 参数自动切换 SMS/Email API 调用
- WelcomePage 邮箱注册按钮传递 isEmail:true 参数
- i18n 新增 register.errorEmailRequired(4语种)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 02:27:43 -08:00
hailin a893dbdb1b feat(genex-mobile): Token 持久化 — 登录状态跨重启保持
## 核心变更

### 新增 SessionStorage (lib/core/storage/session_storage.dart)
- flutter_secure_storage 封装层
- Android: EncryptedSharedPreferences(AES-256,Android Keystore 托管密钥)
- iOS: Keychain(AccessibilityFirstUnlock)
- 存储键: genex_access_token / genex_refresh_token / genex_user_json
- API: save() / load() / updateTokens() / getRefreshToken() / clear()

### 升级 ApiClient (lib/core/network/api_client.dart)
- 新增 Dio 错误拦截器(_buildAuthInterceptor)
- 401 自动触发 Token 静默刷新,成功后无感重试原始请求
- Completer 并发锁:多个 401 同时发生只执行一次刷新,其余等待结果
- 跳过重试的端点:/auth/refresh、/auth/login、/auth/register 等
- configureAuthCallbacks():注册 onTokenRefreshed / onSessionExpired 反向回调

### 升级 AuthService (lib/core/services/auth_service.dart)
- _setAuth():登录/注册后 await 写入 SecureStorage
- _clearAuth():登出/Token 过期后 await 清除 SecureStorage
- restoreSession():App 冷启动时从 SecureStorage 恢复 Token + 注册 ApiClient 回调
- refreshToken():主动刷新(正常由拦截器自动触发,无需手动调用)

### 升级 main.dart
- await AuthService.instance.restoreSession() 在 runApp 前执行
- initialRoute 动态判断:isLoggedIn → '/main',否则 '/'
- 全局 NavigatorKey(_navigatorKey)挂载到 MaterialApp
- 监听 authState ValueNotifier:Token 过期后自动导航回 '/'(pushNamedAndRemoveUntil)

## 用户体验
- 登录后关闭 App 再打开:直接进主界面,无需重新登录
- Access Token 过期:ApiClient 自动静默刷新,用户无感知
- Refresh Token 过期:清除本地会话,跳回欢迎页,提示重新登录
- 主动登出:清除 SecureStorage,跳回欢迎页

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 02:01:27 -08:00
hailin 1c36c849e2 docs(genex-mobile): 完善邀请分享模块注释与说明
SharePage:
  - 文件头注释:完整功能概述、支持的分享场景、数据来源、URL格式、依赖包说明
  - 类注释:生命周期描述、Widget 树结构图(ASCII)
  - 状态变量:详细说明 _info/_loading/_error/_baseInviteUrl
  - _inviteLink:注释已加载/未加载两种输出示例
  - _loadInfo:成功/失败两条路径说明
  - _showCopied:SnackBar 样式描述
  - _copyCode/_copyLink:示例复制内容
  - _shareNative:iOS/Android 行为说明 + 文案模板示例
  - _buildHeroCard:视觉层次注释 + QR 参数说明
  - _buildStatsCard:布局描述 + 数据来源注释
  - _buildShareActions:三项操作的点击行为说明

ReferralService:
  - 文件头:完整端点一览、推荐码格式、推荐链规则
  - ReferralInfo:字段含义 + 后端响应 JSON 示例
  - getMyInfo:登录要求说明
  - validateCode:用途说明 + 返回值降级策略
  - getDirectReferrals:分页参数范围 + 响应 JSON 示例

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 01:42:47 -08:00
hailin 46d2404d19 feat(genex-mobile): 邀请好友 — 分享二维码页面全链路实现
- 新增 SharePage:推荐码 QR 码 + 邀请进度 + 一键复制/原生分享
- ProfilePage 添加「邀请好友」渐变横幅入口
- 新增 ReferralService(getMyInfo / getDirectReferrals)
- pubspec.yaml 引入 qr_flutter ^4.1.0、share_plus ^10.0.2
- 路由 /share 注册
- i18n:4 语言新增 share.* 共 20 个翻译键(zh-CN / zh-TW / en / ja)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 01:28:22 -08:00
hailin 0ecf295c35 feat(referral): 推荐服务全链路实现
Backend:
- referral-service: 全新微服务 (NestJS + DDD + Clean Architecture)
  - ReferralProfile 聚合根 (TypeORM entity)
  - ReferralCode / ReferralChain 值对象
  - 仓储接口 + 实现
  - ReferralService 应用服务: 创建档案/验证码/查询直推
  - UserRegisteredHandler: 订阅 genex.user.registered Kafka 事件
  - REST: GET /referral/my, GET /referral/validate, GET /referral/direct
  - 内网: POST /internal/referral/profiles
  - 端口 3013 (外部 4013)
- auth-service: RegisterDto 增加 referralCode 字段
- auth-service: UserRegisteredEvent 携带 referralCode
- auth-service: EventPublisherService 实际接入 Kafka (之前是 stub)
- migrations: 047_create_referral_profiles.sql
- docker-compose: 新增 referral-service 服务块

Frontend (genex-mobile):
- 注册页添加推荐码输入框 (可选),输入时实时验证推荐码有效性
- AuthService.register() 增加 referralCode 参数
- AuthService.validateReferralCode() 新增方法
- i18n: zh_CN/zh_TW/en/ja 各新增 4 个推荐码相关 key

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 00:58:28 -08:00
hailin abb358100d fix(genex-mobile): 还原 api.gogenex.com + 增加更新检测日志
.cn 域名因未 ICP 备案被 ISP 拦截,继续使用 api.gogenex.com (HK IP)。
增加 [UpdateService] 和 [VersionChecker] 详细日志便于调试。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 23:17:12 -08:00
hailin 12a665f2ba fix(genex-mobile): 升级服务改用 api.gogenex.cn — 国内网络更稳定
.com 域名指向 HK IP 在中国大陆部分网络解析失败,
改用 .cn 国内域名确保升级检查能正常访问。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 22:55:04 -08:00
hailin 286e4d8886 fix(admin-service+mobile): 修复 OTA 下载三处 Bug
1. MinIO 内网 hostname 导致 redirect 失效
   → 改为 admin-service 直接流式代理传输文件(streamFile)
   → MinIO 仅绑 127.0.0.1:49000,不对外暴露

2. version_checker.dart 响应解析错误
   → API 返回 {"code":0,"data":{...}} 但代码误把外层 Map 当 VersionInfo
   → 现在正确提取 responseMap["data"] 内层对象

3. VersionInfo.fromJson 在 releaseDate=null 时崩溃
   → releaseDate 改为 nullable (DateTime?),null-safe 解析
   → 同步修复 version_checker.dart 拼接绝对 downloadUrl

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 22:19:10 -08:00
hailin c6c434a07a fix(update): 修复 app 版本更新检查路径 + 解决 MinIO presigned URL 24h 过期
Mobile 端:
- version_checker.dart: /api/app/... → /api/v1/app/... (与 Kong 路由匹配)

Backend (admin-service):
- AppVersion 实体新增 storage_key 字段(已执行 ALTER TABLE)
- FileStorageService: uploadFile 不再返回 presigned URL,只返回 objectName
- AdminVersionController: upload 后保存 storageKey,downloadUrl 设为
  /api/v1/app/version/download/{id}(稳定 API 地址,不过期)
- AppVersionController.downloadVersion: storageKey 存在时每次请求动态
  生成 presigned URL(1小时有效,只需够下载完成即可)
- AppVersionService.checkUpdate: 有 storageKey 的版本统一返回 API 下载地址

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 21:13:13 -08:00
hailin 50d6c77dfd fix(i18n): 补全 en.dart 注册页缺失的6个 key
register.hasAccount / loginNow / errorPhoneRequired /
errorCodeInvalid / errorPasswordWeak / errorTermsRequired
在英文环境下均有对应译文,不再回退显示中文

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 20:55:07 -08:00
hailin 04a55e3e12 fix(ui): 修复登录页中英混用 + 搜索栏溢出,更新品牌口号并支持后台配置
- admin-web 登录页底部 "Genex 券金融平台" → "Genex 管理后台",风格统一
- admin-web 顶部搜索栏改为弹性宽度(width:100%/maxWidth:320),修复窄屏溢出
- 全平台品牌口号统一更新为"让每一张券,自由流动"
  覆盖:genex-mobile(4语言) / miniapp(3语言) / portal(zh-CN/en-US)
- backend admin-system.service: getConfig() 新增 brandConfig 字段(4语言口号)
- admin-web 系统配置页新增品牌配置卡片:支持4语言口号在线编辑并保存

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 20:41:37 -08:00
hailin e7c1e33355 fix(genex-mobile): 语言偏好持久化 — 用户选择不再因重启丢失
修复 LocaleManager 仅用内存 ValueNotifier 存储语言选择的问题,
重启 App 后用户选的语言会丢失,回退到系统语言。

改动:
- pubspec.yaml: 添加 shared_preferences 依赖
- locale_manager.dart: 新增 init() 启动恢复 + setLocale() 写入持久化
  · null = 跟随系统语言(清除 SP 记录)
  · 非 null = 持久化到 SharedPreferences,重启后自动恢复
- main.dart: 启动时调用 await LocaleManager.init()
- settings_page.dart: 语言选择改用 LocaleManager.setLocale()

行为:首次安装跟随系统语言 → 用户选择后持久化 → 重启保持不变

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 19:39:07 -08:00
hailin 0cd5c58ecb feat(android): APK versionCode 自动递增 — 每次编译自增,各环境独立计数
参考 rwadurian mobile-app 的 version.properties 方案,为 genex-mobile
和 admin-app 添加 build 时 versionCode 自动 +1 逻辑:

- build.gradle.kts: calculateNextVersionCode() 读取 version.properties,
  自增后写回;versionName 格式 "pubspec版本.buildNumber"(如 1.0.0.42)
- .gitignore: 排除 /android/app/version.properties,每个构建环境
  (本机、CI、服务器)各自维护独立计数器,互不干扰
- 首次编译从 1 开始,后续跨日期持续递增,保证 APK 版本始终唯一

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 09:09:13 -08:00
hailin 535f53041f feat(deploy): Nginx反向代理 + SSL + 前端切换域名
部署架构:
- Nginx (跳板机 14.215.128.96) → Kong (192.168.1.222:48080)
- SSL: Let's Encrypt 证书已为 api.gogenex.com 签发
- HTTP 自动 301 → HTTPS

前端 API 地址:
- genex-mobile: https://api.gogenex.com (ApiClient + UpdateService)
- miniapp: https://api.gogenex.com (development config)
- 备案完成后切回 https://api.gogenex.cn

Namecheap DNS 新增:
- admin.gogenex.com → 154.84.135.121
- ws.gogenex.com → 154.84.135.121

备注:
- gogenex.cn 的 80/443 端口被世纪互联 ISP 拦截,需完成 ICP 备案
- admin/ws 子域名的 SSL 证书待 DNS 传播后申请

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 00:00:58 -08:00
hailin 8ed667bcf4 feat(联调): 前端指向远程API + 启用阿里云SMS
- genex-mobile ApiClient/UpdateService 指向 154.84.135.121:48080
- miniapp dev 环境指向 154.84.135.121:48080
- docker-compose 添加 ALIYUN SMS 环境变量透传
- auth-service 添加 @alicloud/dysmsapi20170525 等 SDK 依赖

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 00:18:05 -08:00
hailin 7d00cade2f fix(i18n): 清除前端页面中残留的硬编码中文
问题: 在英文/日文语言环境下,部分页面仍显示中文字符

修复内容:

## genex-mobile
- register_page.dart: `const TextSpan(text: ' 和 ')` → `context.t('register.and')`
- 4 语言文件新增 `register.and` key (和/和/and/および)

## miniapp
- login + h5-register: 移除 Toast fallback 中文 (`|| '验证码已发送'` 等)
- login + h5-register: 移除 JSX 中硬编码的《》书名号,改为 i18n 值内包含
  · zh-CN: `《用户协议》`、`《隐私政策》`
  · en-US: `User Agreement`、`Privacy Policy` (无括号)
  · ja-JP: `「利用規約」`、`「プライバシーポリシー」`
- ai-guide 组件: 4 个推荐标签从硬编码改为 `t('ai_recommend_N')`
  · 新增 12 个 i18n key (3 语言 × 4 标签)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 21:27:24 -08:00
hailin 4b1cdf9fb3 feat(genex-mobile): Flutter 前端对接 SMS 认证 API
Phase 6 — Flutter 前端完整对接后端 SMS 认证系统:

新增组件:
- OtpInput: 6位验证码输入框,支持自动跳转、粘贴、错误状态
- CountdownButton: 短信验证码倒计时按钮(60s),发送失败不启动倒计时

新增服务:
- AuthService: 单例认证服务,封装全部 auth API
  · sendSmsCode (REGISTER/LOGIN/RESET_PASSWORD/CHANGE_PHONE)
  · register / loginByPassword / loginByPhone
  · resetPassword / changePassword / changePhone
  · refreshToken / logout
  · ValueNotifier<AuthResult?> 状态管理

页面重写 (对接真实 API):
- LoginPage: 双 Tab (密码/验证码登录),错误提示 Banner,账户锁定展示
- RegisterPage: 三步注册流程,CountdownButton 集成,密码强度检查
- ForgotPasswordPage: 四步找回密码,验证码重发,密码一致性校验

i18n 补充 (4语言 × 13 新 key):
- login: noAccount, registerNow, networkError, errorPhoneRequired,
         errorPasswordMin, errorCodeInvalid
- register: hasAccount, loginNow, errorPhoneRequired, errorCodeInvalid,
            errorPasswordWeak, errorTermsRequired
- forgot: errorPasswordMismatch

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 19:23:25 -08:00