feat: 增强信用问题检查,动态调整检查项以适应数据库结构变化

This commit is contained in:
2026-06-09 15:13:23 +08:00
parent 6860c0cd6e
commit a0c3b8a1ff

View File

@@ -4,6 +4,7 @@ namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
final class AuditFinancialChainCommand extends Command
{
@@ -88,7 +89,7 @@ final class AuditFinancialChainCommand extends Command
*/
private function creditIssues(): array
{
return $this->countIssues([
$checks = [
'credit_account_negative' => [
'message' => '玩家授信账户额度、已用或冻结为负数',
'sql' => 'select count(*) as cnt from player_credit_accounts where credit_limit < 0 or used_credit < 0 or frozen_credit < 0',
@@ -113,7 +114,13 @@ final class AuditFinancialChainCommand extends Command
'message' => '信用流水引用了不存在的结算账单',
'sql' => "select count(*) as cnt from credit_ledger cl where cl.ref_type = 'settlement_bill' and not exists (select 1 from settlement_bills sb where sb.id = cl.ref_id)",
],
]);
];
if (! Schema::hasColumn('players', 'funding_mode')) {
unset($checks['credit_players_without_account']);
}
return $this->countIssues($checks);
}
/**