feat: 重构注单控制器以复用共享筛选逻辑
新增 TicketItemListFilters trait,用于封装注单列表的通用筛选逻辑。 更新 AdminPlayerTicketItemsIndexController、AdminTicketItemIndexController 与 TicketItemsIndexController,统一使用新的注单编号搜索与订单日期范围筛选方法,提升代码复用性与可读性。 增强 AdminRiskPoolManualStatusController:支持发布手动停售状态变更通知。 优化 RiskPoolService 与 TicketWalletService:钱包资金变动后实时通知余额更新。 更新测试用例,确保重构后功能行为保持一致。
This commit is contained in:
51
app/Services/Wallet/WalletBalanceRealtimeNotifier.php
Normal file
51
app/Services/Wallet/WalletBalanceRealtimeNotifier.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Wallet;
|
||||
|
||||
use App\Models\PlayerWallet;
|
||||
use App\Services\PlayerRealtimeBroadcaster;
|
||||
|
||||
/**
|
||||
* 钱包余额变动后推送 `balance.update`(频道 `player.{id}`)。
|
||||
*/
|
||||
final class WalletBalanceRealtimeNotifier
|
||||
{
|
||||
public function __construct(
|
||||
private readonly PlayerRealtimeBroadcaster $playerRealtime,
|
||||
) {}
|
||||
|
||||
public function notifyAfterMovement(
|
||||
PlayerWallet $wallet,
|
||||
int $changeMinor,
|
||||
string $bizType,
|
||||
): void {
|
||||
if ($changeMinor === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$reason = $this->mapBizTypeToReason($bizType);
|
||||
if ($reason === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->playerRealtime->notifyBalanceUpdate(
|
||||
(int) $wallet->player_id,
|
||||
(string) $wallet->currency_code,
|
||||
(int) $wallet->balance,
|
||||
$changeMinor,
|
||||
$reason,
|
||||
);
|
||||
}
|
||||
|
||||
private function mapBizTypeToReason(string $bizType): ?string
|
||||
{
|
||||
return match ($bizType) {
|
||||
'transfer_in' => 'transfer_in',
|
||||
'transfer_out' => 'transfer_out',
|
||||
'transfer_out_refund', 'bet_reverse', 'reversal' => 'refund',
|
||||
'bet_deduct' => 'bet',
|
||||
'settle_payout', 'jackpot_manual_payout' => 'prize',
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user