option('app-id'); $targetUserId = (int) $this->option('target-user-id'); $amount = (float) $this->option('amount'); $orderId = (int) $this->option('order-id'); $transferType = (string) $this->option('transfer-type'); $this->info("开始测试手续费转移功能"); $this->info("应用ID: {$appId}"); $this->info("目标用户ID: {$targetUserId}"); $this->info("转移金额: {$amount}"); $this->info("订单ID: {$orderId}"); $this->info("转移类型: {$transferType}"); $this->line(''); // 检查应用是否存在 $app = TransferApp::find($appId); if (!$app) { $this->error("应用ID {$appId} 不存在"); return 1; } $this->info("应用信息:"); $this->info(" - 名称: {$app->title}"); $this->info(" - 标识: {$app->keyname}"); $this->info(" - 手续费账户UID: {$app->getFeeAccountUid()}"); $this->info(" - 资金类型ID: {$app->fund_id}"); $this->line(''); // 检查目标用户是否存在 $targetUser = User::find($targetUserId); if (!$targetUser) { $this->error("目标用户ID {$targetUserId} 不存在"); return 1; } $this->info("目标用户信息:"); $this->info(" - 用户名: {$targetUser->username}"); $this->info(" - 邮箱: {$targetUser->email}"); $this->line(''); // 检查账户余额 $feeAccountUid = $app->getFeeAccountUid(); $feeAccount = FundModel::getAccount($feeAccountUid, $app->fund_id); $targetAccount = FundModel::getAccount($targetUserId, $app->fund_id); $this->info("转移前余额:"); $this->info(" - 手续费账户(UID {$feeAccountUid}): " . ($feeAccount ? $feeAccount->balance : '账户不存在')); $this->info(" - 目标用户账户: " . ($targetAccount ? $targetAccount->balance : '账户不存在')); $this->line(''); // 执行转移 $this->info("执行手续费转移..."); try { DB::beginTransaction(); $result = FeeService::transfer($appId, $targetUserId, $amount, $orderId, $transferType); if ($result === true) { DB::commit(); $this->info("✅ 手续费转移成功!"); // 重新查询余额 $feeAccount = FundModel::getAccount($feeAccountUid, $app->fund_id); $targetAccount = FundModel::getAccount($targetUserId, $app->fund_id); $this->line(''); $this->info("转移后余额:"); $this->info(" - 手续费账户(UID {$feeAccountUid}): " . ($feeAccount ? $feeAccount->balance : '账户不存在')); $this->info(" - 目标用户账户: " . ($targetAccount ? $targetAccount->balance : '账户不存在')); } else { DB::rollBack(); $this->error("❌ 手续费转移失败: {$result}"); return 1; } } catch (\Exception $e) { DB::rollBack(); $this->error("❌ 转移过程中发生异常: " . $e->getMessage()); $this->error("异常堆栈: " . $e->getTraceAsString()); return 1; } $this->line(''); $this->info("测试完成!"); return 0; } }