fix: 修复特殊扣减API路径和批量创建用户ID解析问题

1. mobile-app: 修复特殊扣减API路径重复问题
   - 将 /api/v1/wallets/special-deduction/execute 改为 /wallets/special-deduction/execute
   - 因为 ApiClient baseURL 已包含 /api/v1 前缀

2. admin-web: 批量创建待办操作支持中文逗号分隔
   - 正则表达式从 /[\n,]/ 改为 /[\n,,]/
   - 同时支持换行、英文逗号、中文逗号作为分隔符

3. identity-service: 添加用户查找调试日志
   - 在 findUserByIdOrSequence 方法中添加日志
   - 便于排查用户ID查找失败的问题

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-03 17:54:27 -08:00
parent d5fee8d8c6
commit dcd6f2ce18
4 changed files with 15 additions and 7 deletions

View File

@ -576,7 +576,9 @@
"Bash(npm run type-check:*)",
"Bash(git commit -m \"$\\(cat <<''EOF''\nfeat\\(settlement\\): implement settle-to-balance with detailed source tracking\n\nAdd complete settlement-to-balance feature that transfers settleable\nearnings directly to wallet USDT balance \\(no currency swap\\). Key changes:\n\nBackend \\(wallet-service\\):\n- Add SettleToBalanceCommand for settlement operations\n- Add settleToBalance method to WalletAccountAggregate\n- Add settleToBalance application service with ledger recording\n- Add internal API endpoint POST /api/v1/wallets/settle-to-balance\n\nBackend \\(reward-service\\):\n- Add settleToBalance client method for wallet-service communication\n- Add settleRewardsToBalance application service method\n- Add user-facing API endpoint POST /rewards/settle-to-balance\n- Build detailed settlement memo with source user tracking per reward\n\nFrontend \\(mobile-app\\):\n- Add SettleToBalanceResult model class\n- Add settleToBalance\\(\\) method to RewardService\n- Update pending_actions_page to handle SETTLE_REWARDS action\n- Add completion detection via settleableUsdt balance check\n\nSettlement memo now includes detailed breakdown by right type with\nsource user accountSequence for each reward entry, e.g.:\n 结算 1000.00 绿积分到钱包余额\n 涉及 5 笔奖励\n - SHARE_RIGHT: 500.00 绿积分\n 来自 D2512120001: 288.00 绿积分\n 来自 D2512120002: 212.00 绿积分\n\n🤖 Generated with [Claude Code]\\(https://claude.com/claude-code\\)\n\nCo-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>\nEOF\n\\)\")",
"Bash(git commit -m \"$\\(cat <<''EOF''\nfeat\\(withdrawal\\): implement fiat withdrawal with bank/alipay/wechat\n\nAdd complete fiat withdrawal feature that allows users to withdraw\ngreen credits \\(绿积分\\) to their bank card, Alipay, or WeChat account\nwith 1:1 CNY conversion. Key changes:\n\nBackend \\(wallet-service\\):\n- Update Prisma schema with fiat withdrawal fields \\(paymentMethod,\n bankName, bankCardNo, cardHolderName, alipay*, wechat*, review fields\\)\n- Rewrite withdrawal status enum for fiat flow: PENDING → FROZEN →\n REVIEWING → APPROVED → PAYING → COMPLETED \\(or REJECTED/FAILED\\)\n- Add PaymentMethod enum: BANK_CARD, ALIPAY, WECHAT\n- Update WithdrawalOrderAggregate with new fiat withdrawal methods\n- Add review/payment workflow methods in WalletApplicationService\n- Add internal API endpoints for admin withdrawal management\n- Remove blockchain withdrawal event handler \\(no longer needed\\)\n\nFrontend \\(admin-web\\):\n- Add withdrawal review management page at /withdrawals\n- Add tabs for reviewing/approved/paying order states\n- Add withdrawal service and React Query hooks\n- Add types for withdrawal orders and payment methods\n- Add sidebar menu item for withdrawal review\n\nFrontend \\(mobile-app\\):\n- Add withdrawFiat\\(\\) method to WalletService\n- Add PaymentMethod enum with BANK_CARD/ALIPAY/WECHAT\n- Create new WithdrawFiatPage for fiat withdrawal input\n- Create WithdrawFiatConfirmPage with SMS + password verification\n- Add routes for /withdraw/fiat and /withdraw/fiat/confirm\n- Keep existing withdraw/usdt \\(划转\\) pages unchanged\n\nNote: The existing withdraw_usdt_page.dart is for point-to-point\ntransfer \\(划转\\), which is a different feature from fiat withdrawal.\n\n🤖 Generated with [Claude Code]\\(https://claude.com/claude-code\\)\n\nCo-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>\nEOF\n\\)\")",
"Bash(git grep:*)"
"Bash(git grep:*)",
"Bash(git commit -m \"$\\(cat <<''EOF''\nfeat\\(fiat-withdrawal\\): add complete fiat withdrawal system\n\n实现完整的法币提现功能支持银行卡、支付宝、微信三种收款方式。\n此功能与现有的区块链划转功能完全独立互不影响。\n\n## 后端 \\(wallet-service\\)\n\n### 数据库\n- 新增 `fiat_withdrawal_orders` 表存储法币提现订单\n- 与现有 `withdrawal_orders` 表\\(区块链划转\\)完全分离\n- 添加完整索引支持高效查询\n\n### 领域层\n- 新增 `FiatWithdrawalStatus` 枚举(与 WithdrawalStatus 独立)\n - 流程: PENDING -> FROZEN -> REVIEWING -> APPROVED -> PAYING -> COMPLETED\n - 或 REJECTED / FAILED / CANCELLED\n- 新增 `PaymentMethod` 枚举: BANK_CARD / ALIPAY / WECHAT\n- 新增 `FiatWithdrawalOrder` 聚合根\n- 新增 `IFiatWithdrawalOrderRepository` 仓储接口\n- 新增 `FIAT_WITHDRAWAL` 账本流水类型\n\n### 应用层\n- 新增 `FiatWithdrawalApplicationService` 处理业务逻辑\n - 发送短信验证码\n - 申请法币提现(冻结余额)\n - 提交审核\n - 审核通过/驳回\n - 开始打款\n - 完成打款\n\n### API层\n- 新增 `FiatWithdrawalController` 提供用户端API\n - POST /wallet/fiat-withdrawal/send-sms - 发送验证码\n - POST /wallet/fiat-withdrawal - 申请提现\n - GET /wallet/fiat-withdrawal - 获取提现记录\n- 新增内部API供管理端调用\n - GET /api/v1/wallets/fiat-withdrawals - 查询订单\n - POST /api/v1/wallets/fiat-withdrawals/:orderNo/review - 审核\n - POST /api/v1/wallets/fiat-withdrawals/:orderNo/start-payment - 开始打款\n - POST /api/v1/wallets/fiat-withdrawals/:orderNo/complete-payment - 完成打款\n\n## 前端 \\(admin-web\\)\n\n- 新增法币提现审核管理页面 `/withdrawals`\n- 支持按状态分 Tab 查看订单\n- 支持审核通过/驳回\n- 支持打款操作\n- 支持查看订单详情\n\n## 前端 \\(mobile-app\\)\n\n- 新增 `WithdrawFiatPage` 法币提现页面\n - 支持选择银行卡/支付宝/微信\n - 输入收款账户信息\n- 新增 `WithdrawFiatConfirmPage` 确认页面\n - 短信验证码验证\n - 密码验证\n- 在 `WalletService` 中添加法币提现相关方法和模型\n\n## 重要说明\n\n此功能与现有的区块链划转功能 \\(withdraw_usdt_page.dart\\) 完全独立:\n- 独立的数据库表\n- 独立的聚合根\n- 独立的状态枚举\n- 独立的API端点\n- 独立的前端页面\n\n原有的区块链划转功能保持不变不受任何影响。\n\n🤖 Generated with [Claude Code]\\(https://claude.com/claude-code\\)\n\nCo-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>\nEOF\n\\)\")",
"Bash(git commit -m \"$\\(cat <<''EOF''\nfeat\\(pending-actions\\): add special deduction feature for admin-created user actions\n\n实现特殊扣减功能允许管理员为用户创建扣减待办操作由用户在移动端确认执行。\n\n## 后端 \\(wallet-service\\)\n\n### 领域层\n- 新增 `SPECIAL_DEDUCTION` 到 LedgerEntryType 枚举\n 用于记录特殊扣减的账本流水类型\n\n### 应用层\n- 新增 `executeSpecialDeduction` 方法\n - 验证用户钱包存在性\n - 检查余额是否充足\n - 乐观锁控制并发\n - 扣减余额并记录账本流水\n - 返回操作结果和新余额\n\n### API层\n- 新增内部API: POST /api/v1/wallets/special-deduction/execute\n 供移动端调用执行特殊扣减操作\n\n## 前端 \\(admin-web\\)\n\n### 类型定义\n- 新增 `SPECIAL_DEDUCTION` 到 ACTION_CODES\n- 新增 `SpecialDeductionParams` 接口定义扣减参数\n - amount: 扣减金额\n - reason: 扣减原因\n\n### 页面\n- 更新待办操作管理页面\n - 当选择 SPECIAL_DEDUCTION 时显示扣减金额和原因输入框\n - 验证扣减金额必须大于0\n - 验证扣减原因不能为空\n\n### 样式\n- 新增特殊扣减表单区域样式\n\n## 前端 \\(mobile-app\\)\n\n### 服务层\n- 新增 `executeSpecialDeduction` 方法到 WalletService\n- 新增 `SpecialDeductionResult` 结果类\n- 新增 `specialDeduction` 到 PendingActionCode 枚举\n\n### 页面\n- 新增 `SpecialDeductionPage` 特殊扣减确认页面\n - 显示扣减金额和管理员备注\n - 显示当前余额和扣减后余额\n - 余额不足时禁用确认按钮\n - 温馨提示说明操作性质\n\n- 更新 `PendingActionsPage`\n - 处理 SPECIAL_DEDUCTION 类型的待办操作\n - 从 actionParams 解析 amount 和 reason\n - 导航到特殊扣减确认页面\n\n## 工作流程\n\n1. 管理员在 admin-web 创建 SPECIAL_DEDUCTION 待办操作\n - 选择目标用户\n - 输入扣减金额\n - 输入扣减原因\n\n2. 用户在 mobile-app 待办操作列表看到该操作\n\n3. 用户点击后进入特殊扣减确认页面\n - 查看扣减详情\n - 确认余额充足\n - 点击确认执行扣减\n\n4. 后端执行扣减并记录账本流水\n\n🤖 Generated with [Claude Code]\\(https://claude.com/claude-code\\)\n\nCo-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>\nEOF\n\\)\")"
],
"deny": [],
"ask": []

View File

@ -360,17 +360,23 @@ export class PendingActionService {
): Promise<{ userId: bigint } | null> {
// 检查是否是纯数字 (userId)
if (/^\d+$/.test(userIdOrSequence)) {
return this.prisma.userAccount.findUnique({
this.logger.log(`[findUserByIdOrSequence] 按 userId 查找: ${userIdOrSequence}`);
const user = await this.prisma.userAccount.findUnique({
where: { userId: BigInt(userIdOrSequence) },
select: { userId: true },
});
this.logger.log(`[findUserByIdOrSequence] 查找结果: ${user ? '找到' : '未找到'}`);
return user;
}
// 否则尝试通过 accountSequence 查找
return this.prisma.userAccount.findUnique({
this.logger.log(`[findUserByIdOrSequence] 按 accountSequence 查找: ${userIdOrSequence}`);
const user = await this.prisma.userAccount.findUnique({
where: { accountSequence: userIdOrSequence },
select: { userId: true },
});
this.logger.log(`[findUserByIdOrSequence] 查找结果: ${user ? '找到' : '未找到'}`);
return user;
}
private toResponseDto(action: any, accountSequence?: string): PendingActionResponseDto {

View File

@ -350,7 +350,7 @@ export default function PendingActionsPage() {
// 提交批量创建
const handleBatchSubmit = async () => {
const userIds = batchFormData.userIds
.split(/[\n,]/)
.split(/[\n,]/) // 支持换行、英文逗号、中文逗号
.map((id) => id.trim())
.filter(Boolean);
@ -824,7 +824,7 @@ export default function PendingActionsPage() {
className={styles.pendingActions__userIdsInput}
/>
<span className={styles.pendingActions__formHint}>
{batchFormData.userIds.split(/[\n,]/).filter((s) => s.trim()).length}
{batchFormData.userIds.split(/[\n,]/).filter((s) => s.trim()).length}
</span>
</div>

View File

@ -827,7 +827,7 @@ class WalletService {
///
///
/// POST /api/v1/wallets/special-deduction/execute (wallet-service API)
/// POST /wallets/special-deduction/execute (wallet-service API)
///
Future<SpecialDeductionResult> executeSpecialDeduction({
required String accountSequence,
@ -843,7 +843,7 @@ class WalletService {
debugPrint('[WalletService] reason: $reason');
final response = await _apiClient.post(
'/api/v1/wallets/special-deduction/execute',
'/wallets/special-deduction/execute',
data: {
'accountSequence': accountSequence,
'pendingActionId': pendingActionId,