hailin
ac3adfc90a
feat(pre-planting): 新增预种积分股卖出限制(方案B纯新增)
...
限制仅有预种份数(未合并成棵)的用户卖出积分股,
直到用户完成首次预种合并后方可卖出。
=== 改动范围(全部 2.0 系统,纯新增)===
contribution-service:
- prisma/pre-planting/schema.prisma: 新增 PrePlantingSellRestrictionOverride 模型
- migrations/20260304000000: 对应建表 SQL
- src/pre-planting/application/services/sell-restriction.service.ts: 核心判断逻辑
isRestricted = has_pre_planting_marker AND !has_real_tree AND !admin_override
- src/api/controllers/pre-planting-restriction.controller.ts: 暴露内部接口
GET /api/v2/pre-planting/sell-restriction/:accountSequence (@Public)
POST /api/v2/pre-planting/sell-restriction/:accountSequence/unlock (@Public)
- src/api/api.module.ts: 注册新 controller 和 SellRestrictionService
trading-service:
- src/application/services/sell-restriction.service.ts: HTTP + Redis 缓存(TTL 60s)
fail-open:contribution-service 不可用时允许卖出,保障业务连续性
- src/application/services/order.service.ts: 卖单前增加限制检查(4行)
- src/application/application.module.ts: 注册 TradingSellRestrictionService
mining-admin-service:
- src/application/services/pre-planting-restriction.service.ts: 代理接口 + 审计日志
每次管理员解除操作均写入 AuditLog,保证严格可追溯性
- src/api/controllers/pre-planting-restriction.controller.ts:
GET /pre-planting-restriction/:accountSequence
POST /pre-planting-restriction/:accountSequence/unlock
- api.module.ts / application.module.ts: 注册新服务和接口
mining-admin-web:
- users.api.ts: 新增 getPrePlantingRestriction / unlockPrePlantingRestriction
- use-users.ts: 新增 usePrePlantingRestriction / useUnlockPrePlantingRestriction hooks
- users/[accountSequence]/page.tsx: 受限时在基本信息卡显示红色警告 + 解除按钮
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 05:04:57 -08:00
hailin
8fcfec9b65
fix(contribution): backfill 强制重算 unlock status,修复预种用户层级卡在5级的问题
...
问题根因:直推用户先买预种导致 directReferralAdoptedCount 已累加到正确值(如5),
但 markAsAdopted() 随后被调用时硬编码 level=5/bonus=1,覆盖了正确的解锁状态。
之后 backfill 因 count 未变(5>5=false)永远不触发重算,level 永久卡死。
修复:updateAccountUnlockStatus 改用 setDirectReferralAdoptedCount() 替代
incrementDirectReferralAdoptedCount 循环,无论 count 是否变化都强制调用
updateUnlockStatus() 重算 unlockedLevelDepth 和 unlockedBonusTiers。
同时为 getDirectReferralAdoptedCount 补充注释,说明常规认种和预种均按人头计。
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 23:16:47 -08:00
hailin
728728bee3
fix(admin-service): 个人/团队认种数量改为统计棵数而非订单数
...
【问题】
getUserList 及推荐树节点中「个人认种」「团队认种」显示的是订单条数
(_count: { id }),而非实际认种棵数。一笔订单可认种多棵,导致多棵
合并下单的用户数量严重偏低。
【修复】
将以下方法中的所有 count(orders) 改为 sum(treeCount):
- getPersonalAdoptionCount — 用户详情页个人认种数
- getTeamStats — 用户详情页团队认种数
- getBatchUserStats — 用户列表批量统计(个人/团队/省/市认种数)
- getAncestors — 推荐树祖先节点认种数
- getDirectReferrals — 推荐树直推节点认种数
【影响范围】
仅影响 admin-web 管理后台的展示数据,不涉及业务逻辑和数据存储。
省市认种百分比计算基准同步修正(teamAdoptions 也改为棵数),
比例结果不变,但基数更准确。
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 22:29:32 -08:00
hailin
3f4b22b013
docs(contribution): add detailed comments for backfill task and findAccountsWithIncompleteUnlock
...
Explain the starvation root cause, unlock rules, pre-planting user scenario,
and future scalability considerations (cursor-based pagination).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 21:58:52 -08:00
hailin
2565fa8259
fix(contribution): process all incomplete-unlock accounts in backfill (remove 100-limit)
...
Previous 100-account batch caused starvation: accounts at positions 101+
(including recent pre-planting users) were never processed. Remove limit
to process all eligible accounts in each 10-minute run.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 21:55:46 -08:00
hailin
551723fe82
fix(contribution): remove redundant snapshotDate from GetBatchRatiosRequest query DTO
...
The date is already read from URL path param @Param('date'), not query string.
Having it as required in the query DTO caused 400 Bad Request on ratios endpoint.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 09:06:53 -08:00
hailin
fb4e52c0de
fix(contribution): add @Public() to getBatchRatios endpoint for service-to-service calls
...
mining-service calls this endpoint without JWT token during DailySnapshot
full sync, causing 401 Unauthorized. Mark it as public since it's internal data.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 08:35:55 -08:00
hailin
a392f708a7
fix(mining): 修复 DailySnapshot API 路径 v1→v2 + deploy-mining.sh 默认 standalone
...
- fetchContributionRatios URL 从 /api/v1/ 改为 /api/v2/ 与 contribution-service 的 globalPrefix 匹配
- deploy-mining.sh 默认部署模式从 shared 改为 standalone
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 08:27:57 -08:00
hailin
2b2e1efc7a
fix(mining): 修复挖矿分配并发覆盖贡献值同步的 Lost Update 问题
...
挖矿分配每秒运行的 save() 无条件写回所有字段(含 totalContribution),
导致贡献值同步刚更新的正确值被立即覆盖回旧值。
同时修复 DailySnapshot 全量同步一直 synced 0 accounts 的安全网失效问题。
- repository save() 增加 skipContributionUpdate 选项
- 挖矿分配路径传入 skipContributionUpdate: true
- contribution-service DailySnapshot 事件 payload 补全字段
- mining-service 适配字段名差异并修复 API 解析 bug
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 07:24:52 -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
a8e06e2eda
fix(pre-planting): 合并逻辑改为按份数累计,支持多份订单合并
...
问题:用户一笔订单可购买多份(portionCount>1),但 performMerge
按订单条数校验是否够 10 条,导致 6 笔订单共 10 份却报错
"不足 10 笔已支付订单进行合并"。
修复:
- performMerge: 遍历 PAID 订单累加 portionCount 直到凑满 10 份
- findPaidOrdersByUserId: 去掉 limit 参数,获取所有 PAID 订单
- PrePlantingMerge.create: 去掉 sourceOrderNos.length === 10 校验
改为 length > 0(份数校验已在 performMerge 完成)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 02:44:35 -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
a801a46e76
fix(admin): 修复授权照片代理未解包全局响应拦截器的问题
...
authorization-service 全局拦截器将响应包装为 {success, data, timestamp},
代理服务需要从 response.data.data 取实际数据,而非 response.data。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 22:50:52 -08:00
hailin
1621b75a47
feat(admin): 引荐关系树节点增加个人/团队预种份数展示
...
后端:
- ReferralNodeDto 新增 selfPrePlantingPortions, teamPrePlantingPortions
- user-detail.controller: getReferralTree 中并行调用
ReferralProxyService 批量获取所有节点的预种统计
(当前用户用 getPrePlantingStats,祖先+下级用 batchGetPrePlantingStats)
前端:
- ReferralNode 类型新增两个预种字段
- 引荐关系树节点(祖先链 + 递归展开节点)在"本人认种/团队认种"
下方新增一行"个人预种: X份 / 团队预种: Y份"
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 19:16:02 -08:00
hailin
eb425b0f92
fix(referral): 团队预种总量排除自己的预种份数
...
TeamStatistics.teamPrePlantingPortions 包含用户自身的预种量,
但"团队预种"应只统计伞下成员。返回时减去 selfPrePlantingPortions。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 19:03:08 -08:00
hailin
5e05e336f7
fix(mining-admin): add @map for targetType column in Notification schema
...
Missing @map("target_type") caused Prisma to look for camelCase column
name instead of the snake_case column created in migration SQL.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 08:55:00 -08:00
hailin
e68b5aa3d9
feat(mining-admin): add Prisma migration for notification tables
...
Create notifications, notification_reads, notification_user_targets
tables with indexes and unique constraints.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 08:48:17 -08:00
hailin
5ee94b3672
fix(notifications): NotificationPriority 类型从 string 改为 Prisma 枚举
...
修复后端编译错误: priority 字段类型应使用 @prisma/client 的
NotificationPriority 枚举而非 string。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 08:38:25 -08:00
hailin
7c781c7d62
feat(notifications): 2.0系统通知弹窗功能(后端+管理端+APP端)
...
复制1.0通知系统架构到2.0系统,实现完整的通知推送功能:
后端 (mining-admin-service):
- Prisma Schema: 添加 Notification/NotificationRead/NotificationUserTarget 表
- NotificationService: 完整 CRUD + 移动端通知查询/已读标记
- AdminNotificationController: 管理端通知 CRUD API
- MobileNotificationController: 移动端通知列表/未读数/标记已读 API
管理端 (mining-admin-web):
- 通知管理页面: 列表/筛选/新建/编辑/删除 Dialog
- 支持类型/优先级/目标用户/强制弹窗/发布时间等完整配置
- 侧边栏添加"通知管理"入口
APP端 (mining-app):
- NotificationService: 通知API服务(经Kong网关路由)
- NotificationBadgeProvider: 30秒轮询未读数量+生命周期监听
- ForceReadNotificationDialog: 强制阅读弹窗(橙色主题,逐条查看+确认)
- NotificationInboxPage: 通知收件箱(支持dark/light主题)
- MainShell: 添加强制弹窗检查(启动+前台恢复,60秒冷却)
- ProfilePage: 用户头部添加通知图标+未读角标
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 08:35:16 -08:00
hailin
59f7bdc137
feat(admin): 功能8修正 — 自助申请照片独立展示页(纯新增方案)
...
用户在 App 自助申请社区/市团队/省团队授权时上传的办公室照片,
之前错误放在授权管理页且因 CDC 未同步导致全显示"-"。
本次采用纯新增方案:绕过 CDC,通过内部 HTTP API 直连
authorization-service 源头数据库读取照片,保证数据 100% 准确。
=== 数据流 ===
admin-web 新页面 → admin-service 新 Controller
→ authorization-service 新 Internal API
→ authorization_roles 表 (源头, officePhotoUrls 字段)
=== 后端 — authorization-service ===
- 新建 internal-self-apply-photos.controller.ts
GET /authorization/self-apply-photos?page=1&limit=20&roleType=COMMUNITY
使用 $queryRaw 查询 office_photo_urls != '{}' 的记录
支持 roleType 筛选 + 分页
- index.ts 新增 export, app.module.ts 注册 controller
=== 后端 — admin-service ===
- 新建 authorization/authorization-proxy.service.ts
axios 代理调用 authorization-service 内部 API
批量查 user_query_view 补充 nickname + avatarUrl
- 新建 api/controllers/authorization-photos.controller.ts
GET /admin/authorization-photos (admin-web 调用)
- app.module.ts 注册 controller + provider
- docker-compose.yml 追加 AUTHORIZATION_SERVICE_URL 环境变量
=== 前端 — admin-web ===
- 新建 authorization-photos/ 页面 (page.tsx + SCSS)
表格展示:头像、昵称、账户序列号、授权类型、地区、照片数、申请时间
点击照片弹出 Modal 网格 → 点击单张弹出全屏 Lightbox
支持 roleType 筛选 + 分页
- Sidebar.tsx 追加"申请照片"菜单项 (紧随"授权管理"之后)
- endpoints.ts 追加 SELF_APPLY_PHOTOS 端点
- authorization/page.tsx 移除"申请照片"列、photo modal、lightbox
- authorization.module.scss 清理照片相关样式
=== 风险 ===
- CDC 链路: 零修改
- 现有 API: 零冲突 (新 controller 独立文件)
- 2.0 系统: 零影响
- 所有操作均为只读查询
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 08:08:32 -08:00
hailin
41818eb8e2
feat(mining-admin-web): 添加全局兑换记录页面
...
后端(trading-service):
- OrderRepository 新增 findAllOrders/findAllTrades 全局查询方法
- AdminController 新增 GET /admin/orders 和 GET /admin/trades 端点
支持 type/status/source/search/日期范围筛选 + 分页
前端(mining-admin-web):
- 新增 /exchange-records 页面,包含「订单记录」和「成交明细」两个 Tab
- 订单 Tab: 支持按类型/状态/来源筛选,显示订单号/账号/价格/数量等
- 成交 Tab: 支持按来源筛选,显示买卖双方/价格/数量/销毁量/手续费等
- 侧边栏添加「兑换记录」菜单项
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 07:38:46 -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
d3969710be
fix(wallet): 系统账户划转前自动结算 settleableUsdt,解决全额划转余额不足
...
## 问题
省/市区域和团队账户收到的奖励进入 settleableUsdt,
但划转验证只检查 usdtAvailable,导致全额划转报"余额不足"。
## 修复
在 requestSystemWithdrawal 事务中,划转前自动执行结算:
1. 检测账户是否为区域/团队账户(6/7/8/9开头)
2. 若 settleableUsdt > 0,自动结算到 usdtAvailable
3. 记录 REWARD_SETTLED 流水明细(含 trigger=SYSTEM_WITHDRAWAL_AUTO_SETTLE)
4. 结算和划转在同一事务中,保证原子性
## 审计流水
每次自动结算会产生一条独立的 REWARD_SETTLED 流水:
- memo: "系统账户自动结算: 待结算 X 绿积分转入可用余额(划转前自动执行)"
- payloadJson: { settledAmount, previousAvailable, newAvailable, trigger }
## 其他
- 划转白名单扩展支持 6xxx(市团队)、7xxx(省团队)
- getSystemAccountName 添加省团队/市团队名称映射
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 06:30:34 -08:00
hailin
17df9b6df1
feat(admin): 预种管理页添加"待合并总量"统计项
...
- planting-service stats 端点新增 pendingMergePortions 字段
从 PrePlantingPosition 表聚合 SUM(available_portions)
- admin-web 统计卡片区新增"待合并总量(份)"显示
- 网格布局从 4 列调整为 5 列
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 04:17:38 -08:00
hailin
24fe10ee36
fix(authorization): 修复 queryAuthorizations 返回类型缺少 officePhotoUrls
...
application service 的 queryAuthorizations 方法返回类型声明中
缺少 officePhotoUrls 字段,导致 TypeScript 编译报错。
实际数据映射已正确包含该字段,只是类型注解遗漏。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 03:24:47 -08:00
hailin
ac15d6682a
feat(admin): 用户预种数量展示 & 授权申请照片查看
...
## 功能7:用户管理展示预种数量
### 需求
在用户管理(列表+详情页)展示个人及团队预种份数,
并支持跳转预种管理页查看团队中哪些ID购买了预种。
### 后端变更
referral-service — 新增内部 API:
- GET /internal/referral/pre-planting-stats/:accountSequence
- POST /internal/referral/pre-planting-stats/batch
从 TeamStatistics 表查询 selfPrePlantingPortions/teamPrePlantingPortions
admin-service:
- 新建 ReferralProxyService (src/referral/) 代理 referral-service 内部 API
- UserFullDetailDto 新增 selfPrePlantingPortions, teamPrePlantingPortions
- user-detail.controller 并行调用获取预种统计
- user.controller 批量获取用户列表预种统计
- UserListItemDto 新增 selfPrePlantingPortions, teamPrePlantingPortions
- pre-planting-config.controller 新增 teamOf 查询参数
→ 先从 referralQueryView 获取团队成员列表
→ 将 accountSequences 传递给 planting-service 过滤
planting-service:
- internal-pre-planting.controller 的 admin orders/positions 端点
新增 accountSequences 查询参数,支持按用户列表过滤
### 前端变更
admin-web:
- 用户列表页表格新增"个人预种(份)"、"团队预种(份)"两列
- 用户详情页新增预种统计卡片(个人/团队预种份数)
- 团队预种数字可点击,跳转 /pre-planting?teamOf={accountSequence}
- 预种管理页支持 teamOf URL 参数,团队过滤模式下显示提示条+返回链接
---
## 功能8:授权管理查看申请照片
### 需求
管理后台无法查看社区/市公司/省公司申请时提供的办公室照片。
原因:authorization-service 收到 officePhotoUrls 后只验证未持久化。
照片文件本身已存储在 MinIO,只需持久化 URL 到数据库。
### 后端变更
authorization-service:
- schema.prisma: AuthorizationRole 新增 officePhotoUrls String[] 字段
- authorization-role.aggregate: props/字段/getter/构造/toPersistence/所有工厂方法
- repository: save() create/update 块 + toDomain() 映射
- application service: 3个 self-apply 方法传递 officePhotoUrls 到 aggregate
- admin controller: queryAuthorizations 响应包含 officePhotoUrls
admin-service:
- schema.prisma: AuthorizationRoleQueryView 新增 officePhotoUrls 字段
- user-detail-query.repository 接口 + impl: 包含 officePhotoUrls
- user-detail.dto: AuthorizationRoleDto 新增 officePhotoUrls
### 前端变更
admin-web:
- 授权管理页表格新增"申请照片"列,点击弹出照片网格 Modal
- 照片支持点击放大(全屏 lightbox 覆盖层)
- 用户详情页授权信息 Tab 同样支持查看照片
- authorization.types.ts / userDetail.types.ts 类型更新
---
## 部署注意事项
1. authorization-service 需运行: npx prisma migrate dev --name add-office-photo-urls
2. admin-service 需运行: npx prisma migrate dev --name add-auth-role-office-photos
3. 需部署: authorization-service, admin-service, referral-service, planting-service, admin-web
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 03:09:17 -08:00
hailin
0cd0bd5694
fix(transfer): Outbox 配置值 Number() 转型,修复 Prisma take 参数类型错误
...
环境变量读取的值始终是 string,ConfigService.get<number> 不会自动转型,
导致 Prisma findMany({ take: "100" }) 报 String 类型错误。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:55:51 -08:00
hailin
5110915aa8
feat(transfer): 添加 transfer-service 初始数据库 migration
...
基于 schema.prisma 创建初始 migration SQL,包含:
- transfer_orders: 转让订单表(Saga 聚合根)
- transfer_status_logs: 状态变更审计日志
- outbox_events: Outbox Pattern 事件表
- processed_events: 幂等性保证表
容器启动时 Dockerfile 会自动执行 prisma migrate deploy 建表。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:16:28 -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
28cf0b7769
fix(wallet): settleUserPendingRewards 补创建 REWARD_TO_SETTLEABLE 流水
...
转换 PENDING→SETTLEABLE 时,为每笔奖励创建带来源信息的
REWARD_TO_SETTLEABLE 流水,解决"分享收益"筛选缺失问题。
统计排除逻辑同步更新,通过 convertedFromPending 标记避免双重计算。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 11:15:19 -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
eba125901c
fix(wallet): 统计排除 REWARD_SETTLED 避免三重计入
...
奖励流水三阶段 REWARD_PENDING → REWARD_TO_SETTLEABLE → REWARD_SETTLED
是同一笔钱的状态转换,只在 REWARD_PENDING 阶段计入收入。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 10:07:22 -08:00
hailin
b905e8cb23
fix(wallet): 统计概览排除 REWARD_TO_SETTLEABLE 避免重复计入
...
REWARD_PENDING(入账) 和 REWARD_TO_SETTLEABLE(状态转换) 是同一笔收入
的两个阶段,统计时只应计入 REWARD_PENDING,排除 REWARD_TO_SETTLEABLE。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 10:01:36 -08:00
hailin
ecaaf68a27
fix(wallet): settle 时清除 pending_expire_at 避免残留倒计时
...
settleUserPendingRewards 全量结算后 pendingUsdt=0,
但 pendingExpireAt 未清除导致 API 仍返回过期时间。
与 expirePendingReward/claimRewards 行为保持一致。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 09:52:19 -08:00
hailin
d849ca7bc2
fix(wallet): getPendingRewards 只返回 PENDING 状态记录
...
之前 getPendingRewards 没有传 status 过滤参数,返回了所有状态
(包括 SETTLED 和 EXPIRED)的记录,导致前端误将已结算的预种条目
显示在待领取列表中。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 09:07:31 -08:00
hailin
718e70e61a
fix(pre-planting): 修复 settleAfterPrePlanting 响应解包(TransformInterceptor)
...
wallet-service 的 TransformInterceptor 会将响应包装为 { data: {...} },
需要从 response.data.data 中提取实际数据,与 allocatePrePlantingFunds 一致。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 08:57:45 -08:00
hailin
722c124cc9
feat(pre-planting): 预种购买后自动触发待领取→可结算转换
...
购买预种份额后,planting-service 调用 wallet-service 新增的内部 API,
将用户标记为 hasPlanted=true 并结算所有 PENDING 奖励为 SETTLED。
纯新增代码,不修改任何现有方法逻辑,两步均幂等,失败不阻塞购买流程。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 08:51:03 -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
1157760d4d
fix(pre-planting): 补充社区/省团队/市团队 API 缺失的 treeCount 参数
...
三个接口调用时未传 treeCount,导致 authorization-service 收到
Number(undefined)=NaN,addMonthlyTrees(NaN) 使字段变为 NaN,
Prisma upsert 报 PrismaClientValidationError。
修复:全部传 treeCount=0(预种不计入月度考核),
省团队补充 provinceCode,市团队补充 cityCode,
同时修正社区/团队接口返回格式为 distributions 数组。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 02:30:35 -08:00
hailin
e32658fc5e
fix(pre-planting): 修复 authorization-service 响应包装格式解析
...
authorization-service 全局 TransformInterceptor 将响应包装为
{ success, data: T, timestamp },预种客户端需读取 response.data.data
而非 response.data。此前因解析失败静默 fallback 到系统账户。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 02:22:01 -08:00
hailin
a15a4a97b1
fix(docker): 为 planting-service 添加 AUTHORIZATION_SERVICE_URL 环境变量
...
planting-service 缺少 AUTHORIZATION_SERVICE_URL 配置,
默认回退到 http://localhost:3006,在容器内无法访问 authorization-service,
导致所有授权分配请求失败走 fallback。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 02:15:23 -08:00
hailin
d880242807
fix(pre-planting): 修复 authorization-service API 路径错误
...
预种 client 使用 /internal/authorization/... 但 authorization-service
全局前缀为 api/v1,实际路由是 /api/v1/authorization/...。
路径不对导致所有请求 404 → catch → fallback → 全部进系统账户。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 02:04:09 -08:00
hailin
530aeb2a6f
feat(authorization): 新增行政区划代码↔中文名映射表,修复省市公司查询不到的问题
...
authorization_roles表的regionCode存储格式不一致(有中文名"北京"、"广东省"也有数字代码"110100"),
但查询时统一传入6位数字代码,导致findProvinceCompanyByRegion/findCityCompanyByRegion永远返回null。
新增 RegionCodeResolver 静态映射表(34个省+333个地级市),
将精确匹配 regionCode = provinceCode 改为多形式匹配 regionCode IN (所有可能形式)。
此修复同时影响正常认种和预种的省区域/市区域/省团队/市团队权益分配。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 01:41:48 -08:00
hailin
b9ddda2532
fix(pre-planting): 修复省市代码格式不一致导致授权分配失败
...
预种DTO接收2位省代码(如"44")和4位市代码(如"4401"),
但authorization-service需要6位标准格式(如"440000"/"440100")。
- resolveAllocations中新增padEnd(6,'0')标准化转换
- fallback系统账户生成从padStart改为padEnd(右补零)
- 正常认种不受影响(SelectProvinceCityDto直接接收6位格式)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 01:23:55 -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
f32748c1d5
fix(pre-planting): 修复推荐链 API 调用的 URL 路径和返回格式解析
...
1. URL: /referrals/:id/chain → /referral/chain/:id(与正常认种对齐)
2. 返回格式: 正确解析 { ancestors: [{accountSequence, hasPlanted}] }
之前错误期望 { directReferrer: {...} },导致有推荐人也被当成无推荐人
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 21:39:07 -08:00