415536c434
Закрыт хвост из billing-audit: webhook при зачислении пишет id строки ledger в saas_transactions.balance_transaction_id (жёсткая прослеживаемость). Колонка BIGINT nullable без FK (balance_transactions партиционирована). schema.sql v8.52 + миграция 2026_06_22_170000 (guarded) + CHANGELOG. Тест проверяет связку. 115/115.
46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Платёж SaaS (schema.sql table saas_transactions). RLS tenant_isolation.
|
|
* status ∈ {pending, success, failed, refunded}; type ∈ {topup, refund, manual_credit, manual_debit}.
|
|
*
|
|
* @mixin IdeHelperSaasTransaction
|
|
*/
|
|
class SaasTransaction extends Model
|
|
{
|
|
public const CREATED_AT = 'created_at';
|
|
|
|
public const UPDATED_AT = null;
|
|
|
|
public const STATUS_PENDING = 'pending';
|
|
|
|
public const STATUS_SUCCESS = 'success';
|
|
|
|
public const STATUS_FAILED = 'failed';
|
|
|
|
public const TYPE_TOPUP = 'topup';
|
|
|
|
protected $fillable = [
|
|
'tenant_id', 'type', 'amount_rub', 'balance_rub_after', 'leads_credited',
|
|
'gateway_id', 'gateway_code', 'gateway_payment_id', 'gateway_idempotence_key',
|
|
'payment_method', 'legal_entity_id', 'invoice_id', 'upd_id', 'status',
|
|
'description', 'failure_reason', 'balance_transaction_id', 'created_at', 'completed_at',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'amount_rub' => 'decimal:2',
|
|
'balance_rub_after' => 'decimal:2',
|
|
'created_at' => 'datetime',
|
|
'completed_at' => 'datetime',
|
|
];
|
|
}
|
|
}
|