## 实际改动 - 招商银行账户即使数据来源为“手动”,也保持原有自动银企直连判定。 - 在编辑弹窗明确选择“非银企直连”时保存独立覆盖值,不会被自动直连规则覆盖。 - 同时让旧列设置自动升级,默认显示“连接方式”列。 ## 验证证据 - `FinanceLedgerManualEditTest`、`NonStoreAccountMonitorTest`:招商自动直连和明确非直连专项通过。 - 招商银行“手动”数据来源场景已纳入回归测试。 ## 风险检查 - 不涉及数据库迁移、生产配置、数据修复或权限变更。 - 仅调整连接方式判定与页面默认列。 Reviewed-on: #1577
69 lines
2.5 KiB
PHP
69 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Utilities;
|
|
|
|
use Illuminate\Database\ConnectionInterface;
|
|
|
|
final class FinanceLedgerBankDirectAccounts
|
|
{
|
|
/** @return array<string,true> */
|
|
public static function map(ConnectionInterface $connection): array
|
|
{
|
|
$accounts = $connection->table('fin_accounts')
|
|
->whereNotNull('account_short')
|
|
->where('account_short', '<>', '')
|
|
->orderBy('id')
|
|
->get(['account_short', 'account_type', 'bank_name']);
|
|
if ($accounts->isEmpty()) {
|
|
return [];
|
|
}
|
|
|
|
$accountShorts = $accounts->pluck('account_short')->unique()->values()->all();
|
|
$typeOverrides = $connection->getSchemaBuilder()->hasTable('fin_account_type_overrides')
|
|
? $connection->table('fin_account_type_overrides')
|
|
->whereIn('account_short', $accountShorts)
|
|
->pluck('account_type', 'account_short')
|
|
: collect();
|
|
$sources = $connection->getSchemaBuilder()->hasTable('fin_flow_summary_account_sources')
|
|
? $connection->table('fin_flow_summary_account_sources')
|
|
->whereIn('account_short', $accountShorts)
|
|
->pluck('data_source', 'account_short')
|
|
: collect();
|
|
|
|
$direct = [];
|
|
foreach ($accounts as $account) {
|
|
$accountShort = trim((string) $account->account_short);
|
|
$accountType = trim((string) (
|
|
$typeOverrides[$accountShort]
|
|
?? $account->account_type
|
|
?? ''
|
|
));
|
|
if ($accountShort === '' || $accountType === '个人卡') {
|
|
continue;
|
|
}
|
|
|
|
$dataSource = FinanceLedgerFlowSummaryDataSource::stored($sources[$accountShort] ?? null);
|
|
if ($dataSource === FinanceLedgerFlowSummaryDataSource::DIRECT) {
|
|
$direct[$accountShort] = true;
|
|
continue;
|
|
}
|
|
if ($dataSource === FinanceLedgerFlowSummaryDataSource::NON_DIRECT) {
|
|
continue;
|
|
}
|
|
|
|
$bank = trim((string) ($account->bank_name ?? ''));
|
|
if (str_contains($accountShort, '招商')
|
|
|| str_contains($accountShort, '招行')
|
|
|| str_contains($bank, '招商')
|
|
|| str_contains($bank, '招行')
|
|
|| $accountType === '网商银行'
|
|
|| str_contains($accountShort, '网商')
|
|
|| str_contains($bank, '网商')) {
|
|
$direct[$accountShort] = true;
|
|
}
|
|
}
|
|
|
|
return $direct;
|
|
}
|
|
}
|