- 转入 main_site_timeout 等不可冲正场景直接拒绝,避免假结案 - payment_records / settlement_adjustments 增加 partial unique 索引 - 坏账核销行锁 + meta 幂等回放;补差单记录 result_bill_id - 新增 FundOperationsHardeningTest 覆盖关键路径
26 lines
702 B
PHP
26 lines
702 B
PHP
<?php
|
||
|
||
namespace App\Support;
|
||
|
||
use Illuminate\Database\QueryException;
|
||
|
||
/** 识别数据库唯一约束冲突(PostgreSQL / SQLite / MySQL)。 */
|
||
final class DatabaseUniqueViolation
|
||
{
|
||
public static function matches(QueryException $e): bool
|
||
{
|
||
$sqlState = (string) $e->getCode();
|
||
$errorInfo = $e->errorInfo ?? null;
|
||
$driverCode = is_array($errorInfo) ? (int) ($errorInfo[1] ?? 0) : 0;
|
||
|
||
if ($sqlState === '23505' || $sqlState === '23000' || $sqlState === '19') {
|
||
return true;
|
||
}
|
||
|
||
if ($driverCode === 19 || $driverCode === 1062) {
|
||
return true;
|
||
}
|
||
|
||
return stripos($e->getMessage(), 'unique') !== false;
|
||
}
|
||
} |