Commit Graph

488 Commits

Author SHA1 Message Date
hailin 34603aac8e fix(security): 修复修改登录密码页面加载失败时静默降级的 bug
与 change_payment_password_page 同款问题:加载失败时原本默默设为
hasPassword=true(注册时必须设置的假设),改为显示错误状态+重试按钮。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 09:17:53 -08:00
hailin 5df9c97794 fix(account): 修复 verifyLoginPassword/verifyPaymentPassword 未读取 TransformInterceptor 包装层的 bug
后端 TransformInterceptor 将所有响应包装为 { success, data: <实际数据> },
但两个 verify 方法直接读 response.data['valid'],导致始终得到 null == true → false,
用户输入正确密码也显示"密码错误"。修复为读取 response.data['data']['valid']。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 08:47:17 -08:00
hailin 405e7e407e fix(security): 修复支付密码页面加载失败时静默降级为设置模式的 bug
加载状态失败时改为显示错误提示和重试按钮,避免误导用户认为未设置支付密码。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 08:19:44 -08:00
hailin a1d284b6b5 fix(password): 统一登录密码和支付密码状态查询为服务端 API
问题:
- isPasswordSet() 读 SecureStorage,重装/换设备后丢失 → 页面误判未设密码
- isPaymentPasswordSet() 读 response.data['isSet'],但实际格式为
  { success, data: { isSet } },取到 null → 始终返回 false

修复:
- 后端新增 GET /user/password-status 接口(isLoginPasswordSet 方法)
- 前端 isPasswordSet() 改为调用服务端 API
- 两个方法均使用正确的 response.data['data']['isSet'] 解包

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 08:14:24 -08:00
hailin 728b11c2aa fix(payment-password): 修复 isPaymentPasswordSet 响应解析错误
API 返回 { success: true, data: { isSet: true } },
但代码读的是 response.data['isSet'](顶层),
实际应该读 response.data['data']['isSet'](嵌套在 data 下)。
导致 isSet 永远为 null == true → false,
支付密码页面始终显示「设置」模式而非「修改」模式。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 08:12:46 -08:00
hailin 5752f7b545 fix(telemetry): 冷启动会话恢复时注入 access token 到 TelemetryService
checkAuthStatus() 从 SecureStorage 读取 token 后,只设置了 userId
而未调用 setAccessToken,导致 App 冷启动后心跳一直返回 401。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 07:43:19 -08:00
hailin 37b11a3db6 feat(telemetry): 接通心跳服务的 JWT 认证,启用实时在线统计
- TelemetryService: 添加 _accessToken 缓存字段,实现 setAccessToken/clearAccessToken
- _getAuthHeaders(): 返回 Bearer token(原为空 {},导致心跳 401)
- AccountService: 3 处登录成功后同步调用 setAccessToken(response.accessToken)
- MultiAccountService: 账号切换后从 SecureStorage 读取恢复的 token 并注入;
  账号删除时同步调用 clearAccessToken()

presence-service 后端待部署后,心跳将开始正常工作,实时在线数和 DAU 数据可用。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 07:20:05 -08:00
hailin 6f912b1232 feat(payment-password): 添加忘记支付密码功能(全栈)
后端(identity-service,纯新增):
- user-application.service 添加 2 个方法:
  sendResetPaymentPasswordSmsCode(userId) —— 发送验证码到已绑定手机(Redis key 独立)
  resetPaymentPassword(userId, smsCode, newPassword) —— 验证码校验 + 格式校验 + bcrypt 更新
- user-account.controller 新增 2 个端点(均为 @ApiBearerAuth):
  POST /user/send-reset-payment-password-sms
  POST /user/reset-payment-password

前端(mobile-app,纯新增):
- account_service 新增 sendResetPaymentPasswordSmsCode / resetPaymentPassword 两个方法
- 新建 reset_payment_password_page.dart:验证码 + 新6位PIN,重置成功后自动返回
- 路由:RoutePaths / RouteNames / AppRouter 各新增 resetPaymentPassword 条目
- change_payment_password_page:旧密码输入框下方添加「忘记支付密码?」入口链接

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 07:04:20 -08:00
hailin 71774f301d fix(payment-password): 优化未设置支付密码时的错误提示
- 识别后端"尚未设置支付密码"异常,显示明确引导语
  "请先前往「我的」→「支付密码」完成设置",替代误导性的"请检查网络"
- 简化空输入提示逻辑(直接使用 widget.hint)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 06:21:25 -08:00
hailin cad7ebe832 feat(payment-password): 添加支付密码功能(全栈)
后端(identity-service):
- Prisma schema 新增 paymentPasswordHash 字段及手动迁移脚本
- user-application.service 添加 4 个方法:isPaymentPasswordSet / setPaymentPassword /
  changePaymentPassword / verifyPaymentPassword(纯新增,不修改已有逻辑)
- user-account.controller 新增 4 个端点:
  GET /user/payment-password-status
  POST /user/set-payment-password
  POST /user/change-payment-password
  POST /user/verify-payment-password → { valid: bool }

前端(mobile-app):
- account_service 新增 4 个方法对应后端 4 个接口
- 新建 change_payment_password_page.dart:6 位数字支付密码设置/修改页面
- 路由:RoutePaths / RouteNames / AppRouter 注册 /security/payment-password
- profile_page:'修改登录密码' 改为 '修改密码',下方新增 '支付密码' 入口
- PasswordVerifyDialog:新增 title / subtitle / hint 可选参数,支持登录/支付双模式
- planting_location_page:认种确认改为验证支付密码(verifyPaymentPassword)
- pre_planting_purchase_page:预种确认后追加支付密码验证步骤

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 06:18:40 -08:00
hailin d91ff7b83a docs(mobile-app): 完善认种密码校验相关代码注释
- PasswordVerifyDialog: 补充类级文档、onVerify 字段说明、_handleConfirm 流程注释
- account_service.verifyLoginPassword: 补充参数、响应格式、行为说明
- planting_location_page._verifyPasswordThenSubmit: 说明在认种流程中的插入位置与作用

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 05:55:07 -08:00
hailin 3a84315b64 fix(mobile-app): verifyLoginPassword 读取响应体 valid 字段
后端 POST /user/verify-password 返回 { valid: bool },不用 HTTP 状态码区分,
修正响应解析逻辑。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 05:53:16 -08:00
hailin 41fa6349bd feat(mobile-app): 认种确认前新增登录密码校验弹窗
- 新增 PasswordVerifyDialog 弹窗,风格与主体 App 一致
- account_service 新增 verifyLoginPassword() 调用 POST /user/verify-password
- planting_location_page 在 PlantingConfirmDialog 确认后插入密码校验步骤

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 05:51:47 -08:00
hailin b67dfa0f4c fix(planting-service+app): 合并列表补充 totalPortions,前端显示实际份数而非订单数
- getMerges 批量查来源订单 portionCount,按合并分组求和后返回 totalPortions
- 预种明细合并卡片改用 totalPortions 显示份数,fallback 才用订单数

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 08:58:45 -08:00
hailin 59097203ae fix(app): 预种计划入口移至自助申请授权页市团队下方
## 问题
上一版错误将「申请预种计划」入口放在「我」页面主区域,
实际需求是放在「自助申请授权」页的「申请市团队」卡片下方。

## 改动内容

### authorization_apply_page.dart
- import route_paths.dart
- `_buildAuthorizationTypes()` 将 `.map()` 展开为 for 循环,
  在 AuthorizationType.cityTeam item 渲染完后插入 `_buildPrePlantingEntry()`
- 新增 `_buildPrePlantingEntry()` 方法:
  · 样式:金色(0xFFD4AF37)卡片,左侧图标圆角背景 + 右侧箭头,
    副标题「购买预种份额 · 查看明细 · 团队预种统计」
  · 点击跳转 RoutePaths.prePlantingHub(预种计划 Hub 页)

### profile_page.dart(撤销上一版在主页的改动)
- 移除 `bool _isPrePlantingActive` 状态变量
- 移除 `_loadPrePlantingConfig()` 方法及 initState 调用
- 移除布局中的预种入口按钮区块
- 移除 `_buildPrePlantingEntryButton()` 方法

Hub 页面(pre_planting_hub_page.dart)和路由定义保持不变,
入口位置从「我」主页改为自助申请授权页的市团队下方。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 07:03:59 -08:00
hailin 8b48d80cd4 feat(app): 预种计划三按钮合并为单入口 Hub 页面
## 背景
「我」页面原有三个并排的预种按钮(预种购买 / 预种明细 / 团队预种),
三等分宽度导致文字拥挤,视觉层级也不清晰。

## 改动内容

### 新增文件
- `pre_planting_hub_page.dart`
  预种计划 Hub 汇总页,竖排展示三个功能入口卡片:
  · 预种购买(金色)→ /pre-planting/purchase
  · 预种明细(棕色)→ /pre-planting/position
  · 团队预种(绿色)→ /pre-planting/team
  页面为纯导航页,无需加载数据;风格与 pre_planting_purchase_page
  一致(渐变背景、金色「← 返回」Header、Inter 字体)。

### 修改文件
- `route_paths.dart` / `route_names.dart`
  新增路由常量 prePlantingHub = '/pre-planting/hub'

- `app_router.dart`
  注册 GoRoute(path: prePlantingHub) → PrePlantingHubPage
  新增对应 import

- `profile_page.dart`
  · 删除 `_buildPrePlantingButtons()`(三按钮并排 Widget)
  · 删除已无用的三个导航方法:
    _goToPrePlantingPurchase / _goToPrePlantingPosition / _goToTeamPrePlanting
  · 新增 `_buildPrePlantingEntryButton()`:
    满宽 48px 按钮,文字「申请预种计划」,点击跳转 Hub 页
  · 布局调用处改为 _buildPrePlantingEntryButton()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 06:42:50 -08:00
hailin 92c305c749 fix(mobile-app): 待签署合同页文案改为"10份预种份额已合并为1棵树"
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 03:40:49 -08:00
hailin 2f78899ceb fix(mobile-app): 修复待签署合同页和持仓页硬编码"5份"的问题
预种方案已从5份/棵调整为10份/棵,但以下两处文案仍硬编码为5:

1. 待签署合同页 (pending_contracts_page.dart)
   - 原: "5 份预种份额已合并,请签署合同以开启挖矿"
   - 改: "{订单数} 笔预种订单已合并为 {树数} 棵树,请签署合同以开启挖矿"
   - 使用 merge.sourceOrderNos.length 和 merge.treeCount 动态显示

2. 持仓页空状态 (pre_planting_position_page.dart)
   - 原: "累计 5 份后将自动合成 1 棵树"
   - 改: "累计 $_portionsPerTree 份后将自动合成 1 棵树"
   - 使用已有常量 _portionsPerTree=10

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 03:30:42 -08:00
hailin 55f81ff329 fix(mobile-app): 修复多个页面时间显示为UTC而非北京时间的问题
后端数据库统一存储UTC时间,前端展示时需调用 .toLocal() 转换为
设备本地时区(中国地区即 UTC+8 北京时间)。

以下5个页面的 _formatDateTime() 方法缺少 .toLocal() 转换,
导致页面显示的时间比北京时间慢8小时:

- 预种合并详情页 (pre_planting_merge_detail_page.dart)
  → 合并时间、签署时间、挖矿开启时间
- 预种持仓页 (pre_planting_position_page.dart)
  → 购买时间、合并时间
- 合同签署页 (contract_signing_page.dart)
  → 合同签署时间
- 转让列表页 (transfer_list_page.dart)
  → 转让创建时间
- 转让详情页 (transfer_detail_page.dart)
  → 转让各状态时间

修复方式:在格式化前统一调用 dt.toLocal() 将UTC转为本地时区。
后端和数据库保持UTC不变,仅前端展示层做时区转换。

注:ledger_detail_page.dart 已使用 DateTimeUtils.formatDateTime()
(内含 .toLocal()),无需修改。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 03:11:48 -08:00
hailin 532be9a561 fix(pre-planting): 合并详情显示实际份数和金额,不再硬编码
问题:合并详情页"合并份数"显示订单条数(7)而非实际份数(10),
"总价值"硬编码 订单数×1887,每笔订单金额也硬编码 1,887。

修复:
后端 getMergeDetail:
  - 新增 sourceOrders[] 含每笔订单的 portionCount + totalAmount
  - 新增 totalPortions(总份数)和 totalAmount(总金额)

前端 PrePlantingMerge model:
  - 新增 MergeSourceOrder 类
  - 新增 sourceOrders/totalPortions/totalAmount 字段

前端合并详情页:
  - "合并份数"用 totalPortions 替代 sourceOrderNos.length
  - "总价值"用 totalAmount 替代硬编码计算
  - 来源订单列表显示每笔实际金额和份数(多份时显示"N份"前缀)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 02:58:34 -08:00
hailin d7f7d7082d fix(pricing): 预种定价API常量同步 — 3566→1887, /5→/10, 正式认种15831不变
admin-service tree-pricing.service.ts:
  - BASE_PORTION_PRICE: 3566 → 1887
  - supplement 除数: /5 → /PORTIONS_PER_TREE(10)
  - BASE_PRICE 保持 15831(正式认种价格不变)
  - 移除 updateSupplement 中重复声明的 BASE_PRICE 局部变量

planting-service tree-pricing-admin.client.ts:
  - fallback basePortionPrice/totalPortionPrice: 3566 → 1887

mobile-app tree_pricing_service.dart:
  - 修正上次commit误改的 basePrice/totalPrice fallback: 18870 → 15831
  - basePortionPrice/totalPortionPrice 保持 1887

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 01:56:21 -08:00
hailin a55201b3b3 feat(referral+mobile): 功能6 — App 团队预种数量展示
纯新增实现,不修改任何现有业务逻辑,对现有系统零风险。

## 后端 — referral-service

新建 TeamPrePlantingController(JWT 认证),2 个公开端点:

1. GET /referral/me/team-pre-planting
   - 返回当前用户的个人预种份数、团队预种总量
   - 返回直推成员列表及每人的预种份数
   - 从 TeamStatistics 表读取(CDC 事件维护的数据)

2. GET /referral/me/team-pre-planting/members?limit=20&offset=0
   - 分页返回全部团队成员的预种明细(仅有预种份数 > 0 的成员)
   - 使用 ancestor_path 数组查询所有下级用户
   - JOIN team_statistics 获取每人的 selfPrePlantingPortions

Kong 网关无需修改(/api/v1/referral/* 已覆盖)。

## 前端 — Flutter mobile-app

新建 TeamPrePlantingPage 页面:
- 顶部统计卡片:个人预种 + 团队预种总量
- 直推预种明细列表(所有用户可见)
- 全部团队成员预种明细(仅市/省公司管理者可见,分页加载更多)
- 普通用户看到锁定提示"仅市公司/省公司管理者可查看"

入口:个人中心页预种按钮行新增绿色「团队预种」按钮。

## 文件清单

新建文件:
- backend/.../controllers/team-pre-planting.controller.ts(核心后端控制器)
- frontend/.../pages/team_pre_planting_page.dart(Flutter 团队预种页面)

微量修改(仅追加新行):
- controllers/index.ts: +1 行 export
- api.module.ts: +2 行 import/注册
- api_endpoints.dart: +2 行端点常量
- referral_service.dart: +4 模型类 +2 API 方法
- route_paths.dart, route_names.dart: +1 行路由定义
- app_router.dart: +1 import +1 GoRoute
- profile_page.dart: 预种按钮行追加第三个按钮

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 07:15:17 -08:00
hailin d5d61f4f68 fix(transfer): 修复转让记录 API 路径与参数不匹配
- API 路径: /transfers/my → /transfers(后端无 /my 子路由)
- 分页参数: page/pageSize → limit/offset(匹配后端 DTO)
- 转让记录页显示具体错误信息便于调试

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 23:35:09 -08:00
hailin 6efa74aded refactor(transfer): 移除发起转让页的售价字段 — 线下柜台签合同交易
APP 端树转让仅完成系统层面的所有权变更 + 算力调整(撤回旧用户算力、
新增至新用户及其团队),价格由用户线下到柜台签署合同确定。

变更详情:
- transfer_initiate_page.dart:
  · 移除 _priceController、_feeRate、费用相关 getter
  · 移除"每棵售价"输入框和费用计算卡片 UI
  · 移除 _feeRow 辅助方法
  · 更新说明文案:强调线下柜台签合同
  · 更新确认弹窗:仅显示买方账号和转让棵数
  · API 调用改用 treeCount 替代 pricePerTree
- transfer_service.dart:
  · createTransfer() 参数从 pricePerTree(double) 改为 treeCount(int)
  · 请求体字段同步调整

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 20:06:31 -08:00
hailin 0e34896d0b refactor(mobile-app): 树转让入口从"我"页面迁移至"实名认证"页面
将"发起转让"和"转让记录"按钮从 ProfilePage 顶部移除,
归类为"树服务"放入 KycEntryPage(实名认证入口页),
位于"其他操作 > 验证/更换手机号"的下方。

变更详情:
- profile_page.dart:
  · 移除 _buildTransferButtons() 方法及其调用
  · 移除 _goToTransferInitiate() / _goToTransferList() 导航方法
- kyc_entry_page.dart:
  · 在"验证/更换手机号"下方新增"树服务"分类标题
  · 新增"发起转让"操作卡片 → /transfer/initiate
  · 新增"转让记录"操作卡片 → /transfer/list
  · 复用页面已有的 _buildActionCard 样式,保持 UI 一致

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 19:47:39 -08:00
hailin b3984c861c feat(pre-planting): 预种方案调整 — 18870 USDT/棵,10份合1树
=== 方案变更 ===
- 全树基础价: 17830 → 18870 USDT
- 每份价格:   3566 → 1887 USDT
- 合并阈值:   5 份 → 10 份

=== 后端改动 (planting-service) ===
1. pre-planting-right-amounts.ts:
   - PRE_PLANTING_PRICE_PER_PORTION: 3566 → 1887
   - PRE_PLANTING_PORTIONS_PER_TREE: 5 → 10
   - 10类权益金额按 floor(整棵树/10) 重算,余数归 HQ_BASE_FEE(319)
2. pre-planting-merge.aggregate.ts:
   - 合并校验从硬编码 5 改为引用 PRE_PLANTING_PORTIONS_PER_TREE 常量
3. purchase-pre-planting.dto.ts:
   - portionCount @Max(5) → @Max(10)
4. pre-planting-application.service.ts:
   - 加价补贴计算 /5 → /PRE_PLANTING_PORTIONS_PER_TREE
   - 错误文案引用常量,消除硬编码

=== 前端改动 (mobile-app) ===
1. pre_planting_purchase_page.dart: 默认价格、份数、协议文本(1/10、4%)
2. pre_planting_position_page.dart: _portionsPerTree 5→10
3. pre_planting_merge_detail_page.dart: 总价值计算和单份显示金额
4. tree_pricing_service.dart: fallback 默认值
5. pre_planting_service.dart: JSON 解析 fallback 默认值
6. 各文件注释同步更新

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 18:32:32 -08:00
hailin fda79304c6 Revert "fix(ledger): 分享收益筛选支持多类型(REWARD_TO_SETTLEABLE + REWARD_PENDING)"
This reverts commit d223671db7.
2026-03-01 11:07:19 -08:00
hailin d223671db7 fix(ledger): 分享收益筛选支持多类型(REWARD_TO_SETTLEABLE + REWARD_PENDING)
后端 entryType 筛选支持逗号分隔多值,前端"分享收益"同时查询两种类型,
解决未认种时收到的 REWARD_PENDING 分享权益在筛选中丢失的问题。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 11:02:08 -08:00
hailin e4a2a0e37a feat(ledger): 流水明细显示来源用户ID + 统计兼容历史批量转换数据
- wallet_service.dart: LedgerEntry 新增 sourceAccountFromMemo 从 memo 提取来源用户
- ledger_detail_page.dart: 流水列表项显示"来自 Dxxx"金色文字
- ledger_detail_page.dart: 权益详情弹窗添加来源用户行和备注行
- wallet-application.service.ts: 统计/趋势保留 memo 兼容历史批量转换记录

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 10:41:11 -08:00
hailin d876dd1591 fix(wallet): 区分直接入账和批量转换的 REWARD_TO_SETTLEABLE
新增 REWARD_PENDING_CONVERTED 类型用于批量转换(待领取→可结算),
REWARD_TO_SETTLEABLE 保留给直接入账(hasPlanted=true时的新收入)。

统计排除:REWARD_PENDING_CONVERTED + REWARD_SETTLED(状态转换)
统计计入:REWARD_PENDING + REWARD_TO_SETTLEABLE(首次入账)

已迁移7条历史数据的 entry_type。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 10:30:47 -08:00
hailin 31e6f9e15a fix(mobile): 预种可结算列表以wallet实际金额为准,避免已结算条目残留
planting-service 的分配记录不跟踪 wallet 端的结算状态,
原来的反向排除法(排除PENDING+EXPIRED)无法处理:
1. 已结算到余额(SETTLED→余额)的条目
2. hasPlanted=true 后直接进可结算、不经 pending_rewards 的条目

改为以 walletInfo.rewards.settleableUsdt 为权威来源:
- settleableUsdt=0 时直接跳过(已全部结算到余额)
- settleableUsdt>0 时按金额截断,确保展示总额不超过实际可结算

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 10:19:31 -08:00
hailin 8e52535dd9 feat(mobile): 预种明细显示来源用户ID + 修复空待领取倒计时
1. 预种待领取/可结算明细的 memo 中追加来源用户(如"来自D26022600016的预种")
2. 修复 pendingUsdt=0 时倒计时仍然显示的问题(pending_expire_at 未清除时兜底)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 09:48:34 -08:00
hailin b13d873f64 feat(mobile): 流水明细中 REWARD_PENDING 标注"已转可结算"
用户购买预种后 hasPlanted=true,所有 PENDING 奖励转为 SETTLED,
此时流水中历史的 REWARD_PENDING 条目追加"(已转可结算)"标注,
避免用户误以为还有未领取的奖励。仅在 pendingUsdt=0 时显示。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 09:15:18 -08:00
hailin e9b9896317 fix(mobile): 修复预种可结算列表与金额不一致
问题:pre-planting/my-rewards 返回所有分配记录不区分状态,
导致 PENDING 状态的预种奖励也被错误地显示在可结算列表中,
而可结算金额(从 wallet-service 取值)正确为 0,造成列表和金额不一致。

修复:在合并预种可结算列表时,排除正在 PENDING 和 EXPIRED 状态的条目。
通过 wallet/pending-rewards 和 wallet/expired-rewards 获取实际状态,
用 sourceOrderId 交叉比对,只保留真正可结算的预种条目。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 08:24:03 -08:00
hailin 4996c1d110 feat(mobile): profile页待领取/可结算/已过期列表统一显示预种数据
变更概要:
- wallet_service.dart: 新增 WalletPendingRewardItem 模型和 getWalletPendingRewards() 方法
  调用 GET /wallet/pending-rewards 获取 wallet-service 的待领取奖励列表
- profile_page.dart: 合并预种待领取奖励到列表中
  从 wallet-service 待领取列表中筛选 PPL 前缀的预种条目,转换为 PendingRewardItem
  与 reward-service 的正常认种待领取统一展示
- profile_page.dart: 已过期列表标记预种条目
  wallet-service GET /wallet/expired-rewards 已包含预种过期记录,
  渲染时通过 sourceOrderId.startsWith('PPL') 动态添加 [预种] 前缀
- profile_page.dart: 所有汇总金额统一从 wallet-service 取值
  _pendingUsdt / _expiredUsdt / _remainingSeconds 改为从 walletInfo.rewards 读取,
  wallet_accounts 包含正常认种 + 预种,是唯一的 source of truth

技术说明:
- 后端零改动,仅前端变更(零风险)
- 预种条目通过订单号 PPL 前缀与正常认种区分,避免重复显示
- 所有预种条目在卡片上显示 [预种] 前缀,方便用户区分来源

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 07:52:02 -08:00
hailin 27cd72fe01 feat(pre-planting): 预种可结算收益结算 + 前端可结算金额修正
背景:
  预种奖励通过 planting-service → wallet-service allocateFunds 链路
  直接写入 wallet_accounts.settleable_usdt,不经过 reward-service。
  因此 reward-service 的一键结算(settleToBalance)无法覆盖预种部分,
  且 reward-service 的 summary.settleableUsdt 不包含预种金额。

改动:
1. wallet-service 新增 POST /wallet/settle-pre-planting 端点
   - 将 wallet 中剩余的 settleable_usdt 转入 available 余额
   - settleable_usdt=0 时幂等跳过,不创建空流水
   - 流水备注标注 [预种],payloadJson.source='pre-planting'

2. mobile-app 兑换页(trading_page):
   - 可结算金额改为从 wallet-service 的 wallet.rewards.settleableUsdt 取值
     (包含正常认种 + 预种的可结算部分,是唯一的 source of truth)
   - 一键结算流程改为两步串行:
     先调 reward-service settleToBalance(正常认种,不动现有逻辑),
     再调 wallet-service settle-pre-planting(预种部分,纯增量)

3. mobile-app 我的页(profile_page):
   - 并行加载新增 walletService.getMyWallet() 调用
   - _settleableUsdt 改为从 wallet.rewards.settleableUsdt 取值

不涉及的系统:
  - reward-service:零改动
  - planting-service:零改动
  - wallet-service 现有结算逻辑:零改动
  - admin-web:零改动

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 07:33:53 -08:00
hailin 05e590ef04 fix(pre-planting): 修复可结算收益重复计算
pre-planting getMyRewards API 错误地将所有分配记录金额算作
settleableUsdt(包括 PENDING 状态的待领取奖励)。
预种奖励的 PENDING/SETTLEABLE 状态由 wallet-service 管理,
reward-service 的 getMyRewardSummary 已包含预种可结算部分,
不应重复累加。

修复:
- 后端 getMyRewards 返回 settleableUsdt: 0
- 前端"我"页面和"兑换"页面不再额外加预种 settleableUsdt

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:34:22 -08:00
hailin cf07712a8c fix(mobile): 兑换页可结算收益聚合正常认种+预种金额
之前只显示正常认种的 settleableUsdt,未包含预种收益,
导致有预种收益但显示"暂无可结算收益"。
现在并行获取两者并累加,与"我"页面保持一致。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:11:13 -08:00
hailin 3be7b47678 feat(pre-planting+mobile): 预种奖励在"我"页面展示
## 问题
预种奖励直接走 planting-service → wallet-service,绕过 reward-service,
导致前端"我"页面读 reward-service 的 summary/settleable 数据时看不到预种奖励。

## 方案
前端同时读 reward-service(正常认种)和 planting-service(预种),合并展示。

## 后端(planting-service)
- PrePlantingRewardEntryRepository: 新增 findByRecipientAccountSequence() 方法,
  按收款方账户查询预种奖励记录(注入 PrismaService 替代事务 client)
- PrePlantingController: 新增 GET /pre-planting/my-rewards 端点,
  返回当前用户作为收款方收到的预种奖励汇总+明细列表
  格式与 reward-service 的 settleable 对齐(id, rightType, usdtAmount, sourceOrderNo 等)

## 前端(Flutter mobile-app)
- PrePlantingService: 新增 getMyRewards() 方法 + PrePlantingMyRewards/PrePlantingRewardItem 数据类
- profile_page.dart: 并行调用 prePlantingService.getMyRewards(),
  将预种奖励转为 SettleableRewardItem 合并到可结算列表,
  summary.settleableUsdt 也加上预种金额

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 22:03:53 -08:00
hailin 62bbbca609 Revert "fix(ledger): REWARD_EXPIRED条目显示权益类型+已过期标签"
This reverts commit 4bd40970d0.
2026-02-28 12:04:07 -08:00
hailin 4bd40970d0 fix(ledger): REWARD_EXPIRED条目显示权益类型+已过期标签
- 奖励过期条目显示具体权益名(分享权益/省团队权益等)+ 红色"已过期"标签
- 图标改为灰色 timer_off,金额文字改为灰色,背景微灰
- 与正常权益收入条目有明显视觉区分

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 12:01:36 -08:00
hailin a904c8bd42 feat(ledger): 预种份额在流水明细中显示合并合同下载按钮
- 移除硬编码"预种无合同"逻辑
- PPL 份额点击详情时,查找是否有对应的已签署合并记录
- 有签署合同则显示查看/下载按钮,调用预种合并合同 PDF 接口
- 同时新增 _viewMergeContractPdf / _downloadMergeContractPdf 方法

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 11:19:27 -08:00
hailin cd73b2dec4 fix(pre-planting): 签署合同前检查实名认证 + 修正合同金额
- getMergeContractPdf: KYC 为 null 时返回 400,不允许查看合同
- getMergeContractPdf: 从源订单汇总实际绿积分金额,CNY = 绿积分 × 1.1
- Flutter: KYC 错误时显示专用提示 + "去完成实名认证" 按钮

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 10:59:26 -08:00
hailin b1e5e6b29f feat(pre-planting): 合并合同走完整签署流程(PDF展示+手写签名)
- planting-service: 新增 GET /merges/:mergeNo/contract-pdf 接口,复用现有 PDF 模板
- planting-service: PrePlantingApplicationService 注入 PdfGeneratorService/IdentityServiceClient
- pre_planting_service.dart: 新增 downloadMergeContractPdf,signMergeContract 简化返回值
- 新建 PrePlantingMergeSigningPage:PDF展示→滚动到底→确认法律效力→手写签名→提交
- pending_contracts_page: 合并卡片点击跳签名页(prePlantingMergeSigning)
- pre_planting_merge_detail_page: 签署按钮跳签名页,移除直接调用逻辑
- 新增路由 /pre-planting/merge-signing/:mergeNo

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 10:35:22 -08:00
hailin 2ad1936126 fix(pre-planting): 合并详情页 USDT 改为绿积分
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 10:17:12 -08:00
hailin 7bad0a8935 fix(pre-planting): 修复编译错误(getMerges→getMyMerges、RoutePaths 缺失导入、Future.wait 类型)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 10:00:17 -08:00
hailin b9b23c36d7 feat(pre-planting): 合并后走正常签合同流程,购买第5份直接跳合并详情页
- pre_planting_service: CreatePrePlantingOrderResponse 增加 merged/mergeNo 字段
- pre_planting_purchase_page: 购买成功若触发合并,直接跳转合并详情签合同
- contract_check_service: 注入 PrePlantingService,checkAll 增加预种待签合并检查
- pending_contracts_page: 同时展示普通合同和预种合并待签卡片,复用现有签合同弹窗流程
- injection_container: contractCheckServiceProvider 注入 prePlantingService

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 09:51:21 -08:00
hailin 26dcd1d2de fix(pre-planting): 修复购买省市名称存储及多项购买失败问题
== 问题修复 ==

1. 购买失败:NestJS 返回数组 message 导致 Flutter 类型转换错误
   - 症状:List<dynamic> is not a subtype of String
   - 原因:ValidationPipe 校验失败时 message 字段为 List<String>(每条字段错误一条),
     Flutter _handleDioError 直接用 data['message'] 作为 String 参数导致运行时崩溃
   - 修复:api_client.dart 中对 rawMsg 判断是否 List,若是则 join(', ')

2. 续购省市为空导致 400 校验失败
   - 症状:续购时后端返回 "provinceCode should not be empty"
   - 原因:购买页面续购分支未传入省市,导致 provinceCode/cityCode 为 null
   - 修复:pre_planting_purchase_page.dart 中续购时使用 _position?.provinceCode

3. 购买请求携带 provinceName/cityName 被后端 forbidNonWhitelisted 拒绝
   - 症状:400 "property provinceName should not exist"
   - 原因:前端发送名称字段,但 PurchasePrePlantingDto 未声明这些字段
   - 修复:在 DTO 中添加 @IsOptional() 的 provinceName / cityName 字段

== 功能新增 ==

4. 预种持仓表新增省市名称存储(参照正式认种的处理方式)
   - 迁移:20260228000000_add_province_city_name_to_position
   - Prisma schema:PrePlantingPosition 新增 provinceName / cityName 可空字段
   - 聚合根:addPortions() 接受可选 provinceName/cityName,首购时写入,续购忽略
   - Repository:save/toDomain 同步处理名称字段
   - Application Service:purchasePortion 透传名称,getPosition 返回名称
   - Controller:purchase 端点透传 dto.provinceName / dto.cityName

5. 预种合并时算力精确回滚(contribution-service)
   - 新增 9a-team 步骤:事务内查询即将作废的 TEAM_LEVEL/TEAM_BONUS 算力记录
   - 新增 9c-team 步骤:按账户聚合后精确 decrement 上游推荐人的各档位 pending 和 effective
   - 目的:确保旧份额算力精确回滚,避免新树算力 9d 叠加后造成双倍计入

== UI 优化 ==
   - 购买页面将 "USDT" 改为 "绿积分"(单价、总价、成功提示)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 08:02:14 -08:00
hailin eea38b2b86 fix(pre-planting): 购买页面和弹窗中 USDT 改为绿积分
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 07:20:51 -08:00
hailin 9b6effe63d debug(pre-planting): 添加购买流程详细日志以排查 List cast 错误
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 07:19:35 -08:00