feat: refactor super admin to use is_super_admin flag and enhance site deletion logic
- Changed super admin detection from role-based to `is_super_admin` flag in AdminUser model
- Added `requireDefaultAdminSiteId()` method to throw validation error when no integration site exists
- Enhanced site deletion to migrate platform role bindings to fallback site and auto-delete site-specific admin accounts
- Made agent line code optional with auto-generation fallback using `{site_code}-agent-{counter}` format
This commit is contained in:
@@ -31,12 +31,14 @@ final class PlayerLedgerLogsService
|
||||
'prize' => ['settle_payout', 'prize', 'jackpot_manual_payout'],
|
||||
];
|
||||
|
||||
/** PRD 对外类型 → credit_ledger.reason */
|
||||
/** PRD 对外类型 → credit_ledger.reason(信用盘不用钱包「派彩」口径) */
|
||||
private const CREDIT_TYPE_TO_REASON = [
|
||||
'bet' => ['bet_hold', 'game_settlement_loss'],
|
||||
'reversal' => ['bet_hold_release'],
|
||||
'refund' => ['settlement_confirm'],
|
||||
'prize' => ['game_settlement_win', 'settlement_payout'],
|
||||
'win_credit' => ['game_settlement_win'],
|
||||
'credit_release' => ['game_settlement_win', 'settlement_confirm', 'bet_hold_release'],
|
||||
'bill_settlement' => ['settlement_payout'],
|
||||
'transfer_in' => [],
|
||||
'transfer_out' => [],
|
||||
];
|
||||
@@ -413,8 +415,18 @@ final class PlayerLedgerLogsService
|
||||
$items = $paginator->getCollection()
|
||||
->map(function (object $row) use (&$runningMinor, $player, $currency): array {
|
||||
$amount = (int) $row->amount;
|
||||
$formatted = $this->formatPlayerCreditRow($row, $player, $currency, $runningMinor);
|
||||
$runningMinor -= $amount;
|
||||
$reason = (string) $row->reason;
|
||||
$affectsBalance = $this->creditReasonAffectsAvailableBalance($reason);
|
||||
$formatted = $this->formatPlayerCreditRow(
|
||||
$row,
|
||||
$player,
|
||||
$currency,
|
||||
$affectsBalance ? $runningMinor : null,
|
||||
$affectsBalance,
|
||||
);
|
||||
if ($affectsBalance) {
|
||||
$runningMinor -= $amount;
|
||||
}
|
||||
|
||||
return $formatted;
|
||||
})
|
||||
@@ -530,24 +542,30 @@ final class PlayerLedgerLogsService
|
||||
object $row,
|
||||
Player $player,
|
||||
string $currency,
|
||||
int $balanceAfterMinor,
|
||||
?int $balanceAfterMinor,
|
||||
?bool $affectsAvailableBalance = null,
|
||||
): array {
|
||||
$amount = (int) $row->amount;
|
||||
$amountAbs = abs($amount);
|
||||
$publicType = $this->creditReasonToPublicType((string) $row->reason);
|
||||
$reason = (string) $row->reason;
|
||||
$publicType = $this->creditReasonToPublicType($reason);
|
||||
$affectsBalance = $affectsAvailableBalance ?? $this->creditReasonAffectsAvailableBalance($reason);
|
||||
|
||||
return [
|
||||
'log_id' => 'CL-'.$row->id,
|
||||
'type' => $publicType,
|
||||
'biz_type' => (string) $row->reason,
|
||||
'biz_type' => $reason,
|
||||
'amount' => $amount,
|
||||
'amount_formatted' => CurrencyFormatter::fromMinor($amountAbs),
|
||||
'amount_abs' => $amountAbs,
|
||||
'amount_abs_formatted' => CurrencyFormatter::fromMinor($amountAbs),
|
||||
'direction' => $amount >= 0 ? 'in' : 'out',
|
||||
'currency_code' => $currency,
|
||||
'balance_after' => $balanceAfterMinor,
|
||||
'balance_after_formatted' => CurrencyFormatter::fromMinor($balanceAfterMinor),
|
||||
'balance_after' => $affectsBalance ? $balanceAfterMinor : null,
|
||||
'balance_after_formatted' => $affectsBalance && $balanceAfterMinor !== null
|
||||
? CurrencyFormatter::fromMinor($balanceAfterMinor)
|
||||
: null,
|
||||
'affects_available_credit' => $affectsBalance,
|
||||
'ref_id' => $this->creditRefLabel($row),
|
||||
'idempotent_key' => null,
|
||||
'external_ref_no' => null,
|
||||
@@ -560,6 +578,12 @@ final class PlayerLedgerLogsService
|
||||
];
|
||||
}
|
||||
|
||||
/** 账期收付记账不改变 player_credit_accounts,不参与可用信用倒推。 */
|
||||
private function creditReasonAffectsAvailableBalance(string $reason): bool
|
||||
{
|
||||
return $reason !== 'settlement_payout';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
@@ -611,7 +635,8 @@ final class PlayerLedgerLogsService
|
||||
'bet_hold', 'game_settlement_loss' => 'bet',
|
||||
'bet_hold_release' => 'reversal',
|
||||
'settlement_confirm' => 'refund',
|
||||
'game_settlement_win', 'settlement_payout' => 'prize',
|
||||
'game_settlement_win' => 'win_credit',
|
||||
'settlement_payout' => 'bill_settlement',
|
||||
default => $reason,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user