hailin
b17bf82443
feat(pre-planting): 新增 GET /merges/:mergeNo 合并详情接口
...
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 10:07:53 -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
20b8d41212
feat(pre-planting): 支持省市名称存储,参照正常认种处理方式
...
- PurchasePrePlantingDto 添加可选字段 provinceName/cityName,
与 SelectProvinceCityDto 保持一致,解决 NestJS forbidNonWhitelisted 400 错误
- pre_planting_positions 表新增 province_name/city_name 列(迁移)
- PrePlantingPosition aggregate 增加 provinceName/cityName 字段
- addPortions() 接受并存储省市名称
- getPosition() 返回 provinceName/cityName 供续购时显示
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 07:48:47 -08:00
hailin
5aa17b05c5
fix(pre-planting): 代码审查修复 2 处小问题
...
1. handler: 删除冗余三元表达式(两边相同),改用 new Date(raw) 直接解析
2. service: swapContributionForMerge 增加源订单数量不足时的 warn 日志(不阻断执行)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 07:28:30 -08:00
hailin
4c6fd424b5
feat(pre-planting): 合成树后算力切换(预种 5 份合同签署触发)
...
当用户购买满5份预种后合成1棵树并签署合同时,自动执行算力切换:
1. 作废5份份额的算力记录(is_expired=true,remark 标注合成原因,已挖积分不受影响)
2. 从认种人账户扣减旧个人算力(保持账户余额准确)
3. 以1棵完整树的算力单价创建新算力记录(remark 标注来源订单)
4. 写入 pre_planting_synced_merges 幂等标记
== 实现方式 ==
- 触发节点:Debezium CDC on pre_planting_merges.mining_enabled_at(null → 非null)
- 新增 Debezium table:public.pre_planting_merges
- 新增 Kafka topic 订阅:cdc.pre-planting.public.pre_planting_merges
- 新增 handler:PrePlantingMergeSyncedHandler(解析 CDC 事件)
- 新增 service 方法:swapContributionForMerge(核心算力切换逻辑)
- 新增常量:PRE_PLANTING_MERGE_SOURCE_ID_OFFSET = 20B(区别于份额的 10B 偏移)
- 新增 DB 表:pre_planting_synced_merges(幂等标记,migration 已包含)
== 幂等保证 ==
- CDC 层:processedCdcEvent 表(sourceTopic + offset 唯一)
- 业务层:contribution_records WHERE sourceAdoptionId=20B+mergeId 存在性检查
- 标记层:pre_planting_synced_merges(best-effort,事务提交后写入)
== 对现有系统的影响 ==
- 零修改现有 contribution 调度器 / freeze scheduler
- 团队分润账户净效果≈0(旧5份=1棵树,切换后金额一致)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 07:22:09 -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
hailin
606d3c0b22
fix(pre-planting): 修复购买失败时 List<dynamic> 类型转换错误和续购省市缺失
...
1. api_client.dart: NestJS validation error 返回 message 为数组时,
用 join(', ') 转为字符串,避免直接传给 ApiException(String) 崩溃
2. pre_planting_purchase_page.dart: 续购时传 _position 中已保存的
provinceCode/cityCode,满足后端 DTO 必填校验
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 06:56:49 -08:00
hailin
2d7b02aa96
fix(pre-planting): 修复预种页面 5 个 UI 问题(纯前端,零后端改动)
...
=== 问题 1:流水明细合同按钮 500 错误 ===
文件: ledger_detail_page.dart
原因: 预种订单(PPL 前缀)无合同,但流水详情弹窗显示「查看合同/下载合同」按钮
修复: _showTransactionDetail 检测 refOrderId.startsWith('PPL'),
预种订单传 showContractButtons: false,弹窗不渲染合同按钮区
=== 问题 2:流水备注显示英文 ===
文件: ledger_detail_page.dart
原因: 备注字段存储的是 'Plant payment (from frozen)'(后端写入,不改后端)
修复: _TransactionDetailSheet 展示备注时,若订单号以 PPL 开头则显示「预种」
=== 问题 3:预种明细订单金额单位错误 ===
文件: pre_planting_position_page.dart
修复: '${order.totalAmount.toInt()} USDT' → '${order.totalAmount.toInt()} 绿积分'
=== 问题 4:省市显示数字代码(如 44 · 4401)===
文件: pre_planting_position_page.dart / pre_planting_purchase_page.dart
原因: provinceName/cityName 为 null 时回退显示 provinceCode/cityCode
修复:
- position 页:条件改为 provinceName != null && cityName != null,无中文名则不显示省市行
- purchase 页:加载时不再 fallback 到代码;锁定显示无名称时显示「已锁定」;
购买确认弹窗省市行无名称时显示「-」
=== 问题 5:「合并进度」改为「合成进度」===
文件: pre_planting_position_page.dart / pre_planting_purchase_page.dart
修复: 两处 Text('合并进度') → Text('合成进度')
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 06:25:38 -08:00
hailin
f4c9535e12
feat(capability): 补齐全部后端 API 能力拦截
...
## 背景
审计发现 13 项用户能力中,部分后端 API 端点缺少 @RequireCapability
拦截,用户可绕过前端 UI 限制直接调用 API。本次逐服务补齐。
## Phase 1: 高优先级 — 操作端点
### auth-service
- POST /auth/password/change → @RequireCapability('PROFILE_EDIT')
修改登录密码需要 PROFILE_EDIT 能力
- POST /auth/trade-password/set → @RequireCapability('PROFILE_EDIT')
设置交易密码需要 PROFILE_EDIT 能力
- POST /auth/trade-password/change → @RequireCapability('PROFILE_EDIT')
修改交易密码需要 PROFILE_EDIT 能力
- POST /auth/trade-password/verify → @RequireCapability('TRADING')
验证交易密码是交易前置步骤,需要 TRADING 能力
### trading-service
- POST /c2c/orders/:orderNo/cancel → @RequireCapability('C2C')
C2C 取消订单是唯一缺失 C2C 能力检查的操作端点
## Phase 2: 低优先级 — 查看端点
### trading-service
- GET /trading/orders → VIEW_RECORDS (用户订单列表)
- GET /trading/trades → VIEW_RECORDS (成交记录)
- GET /transfers/history → VIEW_RECORDS (划转历史)
- GET /p2p/transfers/:accountSequence → VIEW_RECORDS (P2P转账历史)
- GET /c2c/orders/my → VIEW_RECORDS (我的C2C订单)
### contribution-service
- GET /contribution/accounts/:accountSequence/active → VIEW_ASSET
- GET /contribution/accounts/:accountSequence/planting-ledger → VIEW_RECORDS
## 能力覆盖总览 (补齐后)
| 能力 | 端点数 | 状态 |
|------|--------|------|
| LOGIN | 全局 | ✅ JwtAuthGuard 拦截 |
| TRADING | 3 | ✅ createOrder, cancelOrder, verifyTradePassword |
| C2C | 6 | ✅ create, take, cancel, confirmPayment, confirmReceived, uploadProof |
| TRANSFER_IN | 1 | ✅ transferIn |
| TRANSFER_OUT | 1 | ✅ transferOut |
| P2P_SEND | 1 | ✅ transfer |
| KYC | 1 | ✅ submitKyc |
| PROFILE_EDIT | 3 | ✅ changePassword, setTradePassword, changeTradePassword |
| VIEW_ASSET | 2 | ✅ getMyAsset, getActiveContribution |
| VIEW_TEAM | 2 | ✅ getMyTeamInfo, getDirectReferrals |
| VIEW_RECORDS | 6 | ✅ 各服务历史记录端点 |
| P2P_RECEIVE | 0 | 仅前端展示控制(无后端操作端点) |
| MINING_CLAIM | 0 | mining-service 需后续重构(@Public 类级别) |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 05:22:37 -08:00
hailin
97f8b7339f
fix(auth): LOGIN 能力禁用后强制下线已登录用户
...
## 问题
管理员在后台禁用用户的 LOGIN 能力后,该用户仍然可以正常使用 mining-app。
原因是 LOGIN 检查只在登录/刷新 token 时执行,已持有有效 JWT(7天有效期)
的用户不会被影响,直到 token 过期才会被拦截。
## 修复
### 后端 - JwtAuthGuard (auth-service)
- 在 JWT 验证通过后,增加 LOGIN 能力实时检查
- 调用 CapabilityService.isCapabilityEnabled() 查询 Redis 缓存
- LOGIN 被禁用时返回 403 ForbiddenException("您的账户已被限制登录")
- 采用 fail-open 策略:Redis/DB 查询失败时放行,不影响正常用户
- 每次认证请求多一次 Redis GET(<1ms),对当前用户规模无性能影响
### 前端 - mining-app API Client
- 新增 onLoginDisabled 全局回调(类似现有的 onUnauthorized)
- Dio 拦截器检测 403 响应中包含"限制登录"关键词时触发回调
- 回调执行:清除用户状态 + 跳转登录页(与 401 处理一致)
## 影响范围
- 所有使用 @UseGuards(JwtAuthGuard) 的端点都会实时检查 LOGIN 能力
- 管理员禁用 LOGIN 后,用户下一次 API 请求即被拦截并强制下线
- 不影响公开端点(登录、注册等不经过 JwtAuthGuard 的接口)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 05:01:37 -08:00
hailin
a7f2008bc2
feat(pre-planting): 添加算力补偿调度器,修复 transfer_order_no schema 一致性
...
问题:CDC 后置回调失败(如迁移未就绪)后,pre_planting_synced_orders 记录
status=PAID 但 contributionDistributed=false,没有机制重新触发算力计算。
修复:
1. 新增 PrePlantingContributionScheduler(每 5 分钟):
- 扫描未分配算力的 PAID 预种订单
- 调用 processUndistributedOrders() 补偿分配
- Redis 分布式锁防并发
2. 注册到 PrePlantingCdcModule 的 providers
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 03:08:06 -08:00
hailin
b747555927
fix(contribution-service): 补充缺失的 transfer_order_no 迁移文件
...
schema.prisma 中 ContributionRecord / SystemContributionRecord /
UnallocatedContribution 三个模型均新增了 transferOrderNo 字段,
但历史上只有 0001_init 一个迁移文件,导致生产数据库中缺少该列。
新增迁移 20260228000001_add_transfer_order_no:
- ALTER TABLE contribution_records ADD COLUMN transfer_order_no
- ALTER TABLE system_contribution_records ADD COLUMN transfer_order_no
- ALTER TABLE unallocated_contributions ADD COLUMN transfer_order_no
- 对应 3 个索引(与 schema @@index 一致)
- 使用 IF NOT EXISTS 保证幂等性
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 03:00:40 -08:00
hailin
390e5ccb19
fix(pre-planting): 用 orderNo 替代 BigInt 自增 ID 作为 CDC 关联键
...
问题:Debezium CDC 事件中 Prisma @map("order_id") 字段以 DB 列名
order_id 发送,而代码访问 data.id 导致 undefined → BigInt 转换失败。
修复方案(遵循"用 orderNo 业务键关联"原则):
- pre-planting-order-synced.handler.ts:
* PrePlantingOrderSyncResult 改为 { orderNo: string }
* handleCreateOrSnapshot/handleUpdate 均用 order_no 字段
* syncToTrackingTable upsert where 改为 { orderNo }
* ensureAdoptionMarker 入参从 orderId bigint 改为 orderNo string
- markerAdoptionId = PRE_PLANTING_SOURCE_ID_OFFSET + hash(orderNo)
* isAlreadyDistributed 改为 findUnique({ where: { orderNo } })
* calculateAfterCommit 传 result.orderNo
- pre-planting-contribution.service.ts:
* calculateForPrePlantingOrder 入参从 bigint 改为 string(orderNo)
* findUnique({ where: { orderNo } }) 查询,用存储的 originalOrderId 计算偏移
* 所有日志/update 中 originalOrderId 替换为 orderNo
* processUndistributedOrders 改为传 order.orderNo,orderBy 改为 createdAt
- schema.prisma:orderNo 字段新增 @unique 约束
- migration SQL:CREATE UNIQUE INDEX on order_no 列
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 02:31:04 -08:00
hailin
560674f2e9
fix(pre-planting): 无推荐关系用户购买预种时 404 导致整笔交易失败
...
问题:PrePlantingReferralClient.getReferralChain() 生产环境遇到 404
(用户无推荐人)时直接 throw error,导致整个购买事务回滚,
无推荐关系的用户(测试账号、直接注册用户)完全无法购买预种份额。
修复:AxiosError status === 404 时返回 { directReferrer: null },
与"直接注册、无推荐人"的正常业务场景对齐,不阻断购买流程。
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 02:13:29 -08:00
hailin
fe9a30df85
feat(mining-app): 接入 capabilitiesProvider 实现 UI 层能力适配
...
Phase 5 补充:在 mining-app Flutter 前端关键页面接入 capability 检查,
被禁用的功能按钮置灰并显示 SnackBar 提示,后端 403 拦截作为兜底。
修改的页面及对应能力:
- send_shares_page: P2P_SEND → "确认发送"按钮
- receive_shares_page: P2P_RECEIVE → 顶部限制提示横幅
- c2c_market_page: C2C → "发布"按钮 + "接单"弹窗入口
- c2c_publish_page: C2C → "发布买入/卖出"按钮
- trading_page: TRADING → "确认交易"按钮
- edit_profile_page: PROFILE_EDIT → "保存"操作
- team_page: VIEW_TEAM → 页面数据加载前检查
设计原则:
- 不阻断页面浏览,只阻断操作
- fail-open: 能力获取失败时默认全部开启
- 禁用时点击按钮弹出 SnackBar 提示"您的XX功能已被限制"
- 沿用现有 disabled 按钮样式(.withOpacity(0.4))
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 01:36:24 -08:00
hailin
21fc55fb01
fix(capability): auth-service CapabilityGuard 类型修复 string → Capability
...
isCapabilityEnabled 参数需要 Capability 枚举类型,添加 as Capability 类型断言
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 22:29:20 -08:00
hailin
55cfc96464
feat(capability): 实现用户能力权限控制系统(Capability-based Permission)
...
借鉴 Stripe Capability 模型,实现 13 项细粒度用户功能权限控制:
LOGIN, TRADING, C2C, TRANSFER_IN/OUT, P2P_SEND/RECEIVE,
MINING_CLAIM, KYC, PROFILE_EDIT, VIEW_ASSET/TEAM/RECORDS
## 架构设计
- auth-service 为能力数据唯一写入点(DB + Redis DB14 缓存)
- 下游服务通过独立 ioredis 客户端直连 Redis DB14 检查能力(~1ms)
- 默认全部开启(fail-open):无缓存/Redis 故障 = 允许通行
- Guard 执行顺序:JwtAuthGuard → CapabilityGuard
## Phase 1: auth-service 核心
- Prisma Schema: UserCapability + CapabilityLog 两张表
- Domain: Capability 枚举, CapabilityMap 类型, Repository 接口
- Infrastructure: PrismaCapabilityRepository(含 $transaction 原子操作)
- Application: CapabilityService(Redis 缓存优先 → DB fallback → 写回 Redis TTL 1h)
- Scheduler: 每 60 秒扫描到期限制自动恢复(Redis 分布式锁防重复)
- API: GET /auth/user/capabilities (JWT), Internal CRUD API (服务间)
- 登录/refreshToken 均增加 LOGIN 能力检查
## Phase 2: 下游 CapabilityGuard
- trading-service: 14 个端点标注(TRADING/C2C/TRANSFER/P2P_SEND/VIEW_ASSET)
- contribution-service: 3 个端点标注(VIEW_RECORDS/VIEW_TEAM)
- mining-service: Guard 注册 + JwtAuthGuard accountSequence 兼容修复
- auth-service: KYC 端点标注(controller 级别 UseGuards)
## Phase 3: mining-admin-service
- CapabilityAdminService: 代理 auth-service internal API + 本地 AuditLog
- CapabilityController: Admin CRUD + 批量设置 + 变更日志查询
## Phase 4: mining-admin-web
- capability-management.tsx: 分组 Switch 开关 + 禁用 Dialog(原因+到期时间)+ 变更日志分页
- React Query hooks: useCapabilities/useSetCapability/useCapabilityLogs
- 用户详情页新增"权限管理"Tab
## Phase 5: mining-app (Flutter)
- CapabilityMap 数据模型 + ForbiddenException 异常类
- api_client.dart: 403 响应适配 ExceptionFilter 包装格式
- capabilitiesProvider: 登录后获取能力列表,fail-open 降级
## 审计修复
- CRITICAL: users.api.ts capability 方法移入 usersApi 对象内部
- P0: Flutter 403 解析路径适配 {error:{code,message}} 实际格式
- P0: 批量接口 operatorId 提升到 body 顶层匹配 auth-service 契约
- P1: mining-service JwtAuthGuard accountSequence fallback payload.sub
- P1: refreshCache 加 try/catch 防止 Redis 故障导致 500
- P1: processExpiredRestrictions 改用 upsertWithLog 事务方法
- P1: C2C upload-proof 补加 @RequireCapability('C2C')
- HIGH: internal.controller.ts 新增 capability 枚举校验
- HIGH: admin capability.controller.ts adminId fallback + query params 类型修复
- MEDIUM: setCapability 改用 $transaction 保证 upsert+log 原子性
## 部署注意
- 需运行: cd auth-service && npx prisma migrate dev --name add_user_capabilities
- 需配置: mining-admin-service .env AUTH_SERVICE_URL=http://auth-service:3010
## 待后续处理(P2)
- P2P_RECEIVE 需在业务逻辑层检查(收款方无主动请求)
- MINING_CLAIM/PROFILE_EDIT 待对应端点实现后标注
- getCapabilities 返回 Map 转 Array 丢失 reason/expiresAt 详细字段
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 22:19:56 -08:00
hailin
1d1c60e2a2
feat(notification): 新增强制阅读弹窗功能(管理员可配置 requiresForceRead)
...
## 功能概述
在不影响任何现有业务的前提下,新增"强制阅读弹窗"功能:
- 管理员创建通知时可勾选「需要强制弹窗阅读」
- App 冷启动进入主页 或 从后台切回前台时自动触发检查
- 存在未读且标记 requiresForceRead=true 的通知时,依次逐条弹窗
- 用户无法通过点击背景或返回键关闭弹窗(强制阅读)
- 最后一条通知弹窗底部显示 checkbox「我已经阅读并知晓」
- 未勾选时"确定"按钮置灰禁用
- 勾选后"确定"变为金色可点击,点击后所有弹窗消失
- 全部看完后仅对已展示的强制阅读通知按 ID 逐一标记已读
(不影响普通未读通知的 badge 计数)
## 涉及改动
### 后端 admin-service
- `prisma/schema.prisma`
- Notification 模型新增字段 `requiresForceRead Boolean @default(false)`
- `prisma/migrations/20260227100000_add_requires_force_read_to_notifications/migration.sql`
- 手动创建 SQL migration(本地无 DATABASE_URL 环境)
- 部署时需在服务器执行 `npx prisma migrate deploy`
- `src/domain/entities/notification.entity.ts`
- 实体类构造器新增 `requiresForceRead`
- create() / update() 方法均支持该字段,默认值 false
- `src/infrastructure/persistence/mappers/notification.mapper.ts`
- toDomain() 从 Prisma 记录读取 requiresForceRead
- toPersistence() 写入 requiresForceRead
- `src/api/dto/request/notification.dto.ts`
- CreateNotificationDto / UpdateNotificationDto 各新增可选字段 requiresForceRead
- `src/api/dto/response/notification.dto.ts`
- NotificationResponseDto(管理端)新增 requiresForceRead
- UserNotificationResponseDto(移动端)新增 requiresForceRead
- `src/api/controllers/notification.controller.ts`
- create() / update() 透传 requiresForceRead 到 entity
### 前端 admin-web
- `src/services/notificationService.ts`
- NotificationItem / CreateNotificationRequest / UpdateNotificationRequest 新增 requiresForceRead
- `src/app/(dashboard)/notifications/page.tsx`
- 通知列表:requiresForceRead=true 时显示红色「强制阅读」标签
- 创建/编辑表单:新增 checkbox「需要强制弹窗阅读」及说明文字
- form state / submit payload / edit 初始化均包含 requiresForceRead
### 移动端 mobile-app
- `lib/core/services/notification_service.dart`
- NotificationItem 新增字段 requiresForceRead(默认 false,fromJson 安全读取)
- `lib/features/notification/presentation/pages/notification_inbox_page.dart`
- markAsRead / markAllAsRead 重建 NotificationItem 时保留 requiresForceRead
- `lib/features/notification/presentation/widgets/force_read_notification_dialog.dart`(新建)
- 单条强制阅读弹窗组件
- 顶部显示通知类型图标 + 进度「1/3」
- 可滚动内容区展示完整通知
- 非最后条:「下一条 ▶」按钮(始终可点)
- 最后一条:checkbox + 「确定」(勾选后才可点)
- barrierDismissible: false + PopScope(canPop: false),无法逃出
- `lib/features/home/presentation/pages/home_shell_page.dart`
- 新增状态:_isShowingForceReadDialog(实例,防重入)
_lastForceReadDialogShownAt(静态,60秒冷却)
- 新增方法 _checkAndShowForceReadDialog():
Guard 1: 防重入锁
Guard 2: 60秒冷却(防回前台闪弹)
Guard 3: 检查用户已登录
Guard 4: 检查无其他弹窗在显示
弹窗期间同时设置 _isShowingDialog=true,阻止后台合同/KYC检查并发
全部看完后仅标记 forceReadList 中的通知为已读,再 refresh() 刷新 badge
- initState addPostFrameCallback 中新增调用
- didChangeAppLifecycleState resumed 分支中新增调用
- resetContractCheckState() 中重置 _lastForceReadDialogShownAt(账号切换隔离)
## 安全与兼容性
- API 调用失败时静默返回,不阻断用户进入 App
- 仅对 requiresForceRead=true 的通知弹窗,普通通知完全不受影响
- 与现有合同弹窗、KYC弹窗、维护弹窗、更新弹窗无冲突
- 静态冷却变量在账号切换时重置,避免新账号被旧账号冷却影响
- badge 准确:仅标记已展示的强制通知,不动其他未读通知计数
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 19:33:51 -08:00
hailin
2684a81383
fix(pre-planting): getEligibility 返回 canPurchase 字段修复"待开启"问题
...
后端 getEligibility() 原先只返回 hasPrePlanting/canTrade 等内部字段,
缺少前端购买页期望的 canPurchase/maxAdditional/message 字段。
由于 json['canPurchase'] ?? false 默认为 false,导致购买页始终显示"待开启"。
修复:getEligibility() 现在先查询 admin config 的 isActive 状态,
结合用户持仓计算出 canPurchase/maxAdditional/message,同时保留原有字段。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 23:36:08 -08:00
hailin
ef68b7b9c0
fix(pre-planting): 预种开关关闭时隐藏"我的"页面预种按钮
...
- profile_page: 加载预种配置,根据 isActive 控制预种按钮显隐
- 开关关闭时不显示「预种购买」「预种明细」按钮
- 默认不显示(_isPrePlantingActive = false),加载成功后更新
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 23:11:53 -08:00
hailin
e328c75fc1
fix(pre-planting): 修复前后端 API 路径不匹配导致预种页面打不开
...
后端 PrePlantingController 缺少 eligibility 端点,前端请求 404 导致
Future.wait 整体失败,页面显示"加载数据失败"。
修复:
1. 后端: 在 PrePlantingController 添加 GET eligibility 端点
2. 前端: createOrder 路径从 /orders 改为 /purchase(匹配后端)
3. 前端: signMergeContract 路径从 /merges/:no/sign 改为 /sign-contract
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 23:07:47 -08:00
hailin
20a73a8d43
feat(planting-service): 添加 transfer_locked_count 列的数据库迁移
...
Prisma schema 中已定义 transferLockedCount 字段但缺少对应 migration,
导致运行时 PrismaClientKnownRequestError:
The column planting_orders.transfer_locked_count does not exist
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 22:57:15 -08:00
hailin
7c95d1d425
fix(admin-service): admin config 端点也返回 agreementText
...
planting-service 调用的是 admin 控制器的 getConfig()(非 public 控制器),
因为 public 控制器有双重 api/v1 前缀。确保 admin getConfig 也包含协议文本。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 22:01:03 -08:00
hailin
5131728835
fix(planting-service): 添加 ADMIN_SERVICE_URL 环境变量
...
planting-service 的 PrePlantingPublicController 需要调用 admin-service
获取预种配置(含协议文本),但 docker-compose 中缺少 ADMIN_SERVICE_URL
环境变量,导致默认使用 localhost:3010 连接失败。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 21:58:42 -08:00
hailin
c0ac63d40a
feat(pre-planting): 重命名预种持仓→预种明细 + 购买协议弹窗
...
- mobile-app: "预种持仓"按钮和页面标题改为"预种明细"
- admin-service: 新增预种协议文本 API (GET/PUT agreement),存储于 system_configs 表
- admin-service: 公开 config API 响应增加 agreementText 字段
- planting-service: 新建 PrePlantingPublicController (无需 JWT),暴露 GET /pre-planting/config
- admin-web: 预种管理页面新增协议文本编辑器(textarea + 保存按钮)
- mobile-app: 购买流程增加协议弹窗,用户需勾选同意后才能继续
- mobile-app: 协议文本优先使用后台配置,未配置时使用默认文本
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 21:14:24 -08:00
hailin
92054e776e
fix(contribution): 复制预种Prisma生成客户端到dist目录修复运行时MODULE_NOT_FOUND
...
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 20:35:26 -08:00
hailin
30a2f739cb
fix(contribution): Dockerfile添加预种Prisma Client生成和migration
...
- builder和runner阶段均添加 prisma generate --schema=prisma/pre-planting/schema.prisma
- start.sh添加预种migration部署步骤
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 20:33:04 -08:00
hailin
8d7fd68509
fix(admin): 预种开关DTO添加class-validator装饰器,修复400错误
...
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 20:26:42 -08:00
hailin
37a5610d74
feat(admin): 实现预种管理页面完整API端点
...
planting-service: InternalPrePlantingController 新增4个管理员查询端点
- GET /internal/pre-planting/admin/orders (分页订单列表)
- GET /internal/pre-planting/admin/positions (分页持仓列表)
- GET /internal/pre-planting/admin/merges (分页合并记录)
- GET /internal/pre-planting/admin/stats (统计汇总)
admin-service: HTTP代理层新增5个端点
- PUT config/toggle (开关切换)
- GET orders/positions/merges/stats (代理转发到planting-service)
- 新建 PrePlantingProxyService (复用ContractService的axios代理模式)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 20:21:31 -08:00
hailin
63a169abb0
fix(cdc): deploy-mining.sh 添加预种CDC connector管理
...
更新 CDC_POSTGRES_CONNECTORS 数组和所有 case 映射(resnapshot、
full-reset topic清理、Step9重注册),确保2.0部署脚本能正确
管理预种CDC connector的生命周期。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 18:58:49 -08:00
hailin
f270b7cc27
fix(cdc): 添加3171预种计划Debezium CDC connector配置
...
预种CDC消费端(contribution-service)代码已就绪,但缺少Debezium
connector配置,导致pre_planting_orders和pre_planting_positions
表变更无法捕获到Kafka,算力无法同步。
新增:
- pre-planting-connector.json: 监听rwa_planting库的pre_planting_*表
独立slot/publication/topic前缀(cdc.pre-planting)
- register-connectors.sh: 注册pre-planting-postgres-connector
- deploy.sh: infra-status显示所有1.0 connector状态
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 18:56:42 -08:00
hailin
843f817976
fix(kong): 添加3171预种计划API网关路由
...
预种控制器 @Controller('pre-planting') 的路由 /api/v1/pre-planting
未在 Kong 网关中配置,导致所有预种API请求返回 "no Route matched"。
新增 pre-planting-api 路由指向 planting-service (192.168.1.111:3003)。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 18:24:49 -08:00
hailin
8bafb0a8d4
fix(mobile-app): 增加切换账号全局防护,彻底解决切换期间自动退出登录
...
根因:切换账号时 saveCurrentAccountData() 耗时 ~7 秒,期间定时器仍在发 API 请求,
clear 阶段 token 被删除后 in-flight 请求收到 401 → 触发 tokenExpired →
logoutCurrentAccount() 把刚恢复的新账号数据全部擦除。
修复(两层防护):
1. 全局锁 isSwitchingAccount:MultiAccountService 在 switchToAccount 整个过程中
设为 true,app.dart _handleTokenExpired 检测到该标志直接 return,不执行 logout
2. 定时器提前停止:将定时器停止从 onBeforeRestore(save 之后)移到 switchToAccount
调用之前,确保 save 期间无新 API 请求
3. try/finally 保证标志位必定清除,异常情况不会锁死后续 tokenExpired 事件
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 12:41:45 -08:00
hailin
a5cc3fdc5b
fix(mobile-app): 修复切换账号时 token 过期导致自动退出登录
...
根因:switchToAccount() 流程中,定时器在 _clearCurrentAccountData()
之后才停止。clear 阶段会删除 token,但此时定时器仍在运行,
in-flight 的 API 请求收到 401 → 触发 _handleTokenExpired()
→ 调用 logoutCurrentAccount() 把正在恢复的新账号数据全部清掉
→ 用户被自动踢到登录页面。
修复:将 onBeforeRestore 回调(停止定时器)移到 _clearCurrentAccountData()
之前执行,确保所有 API 请求停止后再清除 token。
修改前: save → clear(删token) → 停定时器 → restore
修改后: save → 停定时器 → clear(删token) → restore
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 12:21:57 -08:00
hailin
cfc03fe523
fix(pricing): 手动调价支持负数降价对冲
...
之前手动调价只允许非负整数,无法用负数对冲降价。
前端 (admin-web settings/page.tsx):
- 移除 input min="0" 限制,允许输入负数
- 验证改为:只校验 isNaN 和总价不低于 0(15831 + amount >= 0)
- 文案:"加价金额" → "调价金额",placeholder 改为"正数涨价,负数降价"
- 实时预览条件从 amount >= 0 改为总价 >= 0
- 提示文案更新为"正数涨价,负数降价对冲"
后端 (admin-service tree-pricing.service.ts):
- 移除 newSupplement < 0 的硬性拒绝
- 改为校验 BASE_PRICE(15831) + newSupplement >= 0,防止总价为负
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 11:58:11 -08:00
hailin
12004d1c2e
fix(mobile-app): 修复账号切换后自动退出登录的问题
...
根因:ref.invalidate(authProvider) 销毁旧 AuthNotifier 后,新实例的构造函数
仅设置 AuthState(status: AuthStatus.initial),从不自动调用 checkAuthStatus()
从 SecureStorage 重新加载认证数据。导致 auth 状态停留在 initial(未认证),
依赖 auth 状态的组件误判为"未登录",触发页面跳转到登录页。
修复:
- account_switch_page: invalidate 后立即调用 loadAuthState() 从 storage
读取新账号数据,确保 auth 状态为 authenticated 后再导航
- account_switch_page: 切换后重置 ApiClient 的 tokenExpired 标记,防止
旧会话的 401 状态阻塞新账号的请求
- app.dart: _handleTokenExpired() 增加醒目日志和调用栈打印,便于排查
切换期间是否有 token 过期事件被误触发
切换流程更新为 6 步:
[1/6] switchToAccount() - 保存旧账号、清空、恢复新账号 storage
[2/6] onBeforeRestore - 停止所有定时器
[3/6] invalidate Provider - 销毁旧 Provider 实例
[4/6] loadAuthState() - 从 storage 加载新账号 auth 状态 ← 新增关键步骤
[5/6] 恢复遥测上传
[6/6] 导航到 ranking 页面
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 11:39:31 -08:00
hailin
83ba9b7d54
fix(admin-service): 定价DTO添加class-validator装饰器,修复400错误
...
与auth-service支付密码DTO同样的问题:ValidationPipe的
forbidNonWhitelisted:true 导致无装饰器的DTO属性被拒绝。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:50:45 -08:00
hailin
81ea35b712
fix(admin-service): 修复预种价格计算公式,3566不是15831/5
...
totalPortionPrice 之前用 Math.floor(totalPrice/5) = 3166,但预种
价格 3566 是各权益项 floor(amount/5) 之和 + 总部吸收余额,不是
简单的整棵价格除以5。
修正为: BASE_PORTION_PRICE(3566) + floor(currentSupplement/5)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:48:07 -08:00
hailin
3a307b5db7
fix(planting): 修复认种页面动态定价不生效 + 添加涨价倒计时
...
- 修复 admin-service PublicTreePricingController 路由双重前缀问题
(@Controller('api/v1/tree-pricing') → @Controller('tree-pricing'))
- Kong 网关新增 /api/v1/tree-pricing 路由到 admin-service
- mobile-app 认种页面添加涨价倒计时功能:
显示"距下次涨价还有 X天 X小时 X分钟"及涨价后价格
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:22:27 -08:00
hailin
19f350b8e3
fix(mining-app): 全网兑换销毁量改为保留8位小数
...
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 09:54:53 -08:00
hailin
c293309bdf
fix(mining-app): 全网兑换销毁量保留4位小数
...
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 09:53:47 -08:00
hailin
a39af93063
fix(mining-app): 全网兑换销毁量改用circulationPool+保留小数格式
...
根据业务需求,"全网兑换销毁量"应显示流通池总数量(全网卖出量),
而非SELL_BURN销毁总量。同时将formatIntWithCommas改为formatWithCommas
以保留小数位,避免小数值被截断显示为0。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 09:53:14 -08:00
hailin
edc81cc55d
fix(trading+mining-app): 修复"全网兑换销毁量"显示为0的问题
...
根因:前端"全网兑换销毁量"读取的是circulationPool(流通池积分股),
但实际应该显示burn_records中source_type=SELL_BURN的销毁总量。
这是两个不同的概念:circulationPool是卖出交易进入流通的积分股,
而兑换销毁量是卖出时被销毁(进入黑洞)的积分股。
修复:
- 后端: BlackHoleRepository添加getTotalSellBurned()聚合查询
- 后端: asset.service.ts市场概览API新增totalSellBurned字段
- 前端: MarketOverview实体/Model新增totalSellBurned字段
- 前端: trading_page销毁明细弹窗改用totalSellBurned显示
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 09:52:10 -08:00
hailin
74f061cfeb
fix(auth-service): 修复支付密码DTO缺少class-validator装饰器导致请求被ValidationPipe拒绝
...
根因:ValidationPipe配置了whitelist+forbidNonWhitelisted,但DTO类的属性
没有任何class-validator装饰器,导致所有请求体属性被当作非白名单属性直接
返回Bad Request,请求根本未到达业务逻辑层。
修复:为SetTradePasswordDto、ChangeTradePasswordDto、VerifyTradePasswordDto
添加@IsString()和@IsNotEmpty()装饰器。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 09:39:14 -08:00
hailin
16da1d20f0
fix(auth): 修复设置支付密码时报错的问题
...
支付密码是6位纯数字,但 setTradePassword 调用了 Password.create()
走了登录密码的格式验证(要求≥8位+字母+数字),导致必然抛出异常。
新增 Password.createWithoutValidation() 方法,仅做 bcrypt hash
不走格式验证。支付密码的格式验证由 trade-password.service.ts 独立处理。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 09:01:33 -08:00
hailin
4a1bf3aafe
fix(trading): 修复已分配积分股显示为0的问题
...
mining-service 返回格式为 { success: true, data: { totalDistributed: "..." } }
但 getTotalMinedFromMiningService() 直接取 result.totalDistributed,
应该取 result.data.totalDistributed。
同时兼容两种格式,优先取 result.data.totalDistributed。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 08:36:38 -08:00
hailin
acf55b26a7
feat(pricing): 预种每份价格从 3171 调整为 3566 绿积分
...
分配规则:按 reward-service RIGHT_AMOUNTS(15831 整棵树)各项 /5 取整,
余额全归总部社区(HQ_BASE_FEE)。5 份合成一棵树 = 17830。
10 类分配金额变更:
- COST_FEE: 576 (不变, floor(2880/5))
- OPERATION_FEE: 420 (不变, floor(2100/5))
- HQ_BASE_FEE: 29.4 → 427 (3566 - 3139, 吸收全部余额)
- RWAD_POOL: 1152 (不变, floor(5760/5))
- SHARE_RIGHT: 720 (不变, floor(3600/5))
- PROVINCE_AREA: 21.6 → 21 (floor(108/5))
- PROVINCE_TEAM: 28.8 → 28 (floor(144/5))
- CITY_AREA: 50.4 → 50 (floor(252/5))
- CITY_TEAM: 57.6 → 57 (floor(288/5))
- COMMUNITY: 115.2 → 115 (floor(576/5))
- 合计: 3171 → 3566 ✓
涉及服务:planting-service, admin-service, contribution-service
涉及前端:admin-web, mobile-app (Flutter)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 08:02:17 -08:00