feat: 新增玩家管理与转账对账相关功能
1. 新增完整的后台玩家管理CRUD接口,包括列表、创建、详情、更新、删除 2. 新增转账订单冲正和人工处理功能,支持待对账订单状态变更 3. 扩展钱包流水和转账订单的状态支持,新增reversed、manually_processed等状态 4. 新增玩家API数据统一输出类,标准化玩家信息返回格式
This commit is contained in:
40
app/Support/PlayerApiPresenter.php
Normal file
40
app/Support/PlayerApiPresenter.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use App\Models\Player;
|
||||
use App\Models\PlayerWallet;
|
||||
|
||||
/** 玩家 API 统一 JSON 形状(列表行 / 详情)。 */
|
||||
final class PlayerApiPresenter
|
||||
{
|
||||
/** @return array<string, mixed> */
|
||||
public static function listItem(Player $player): array
|
||||
{
|
||||
$wallets = $player->relationLoaded('wallets')
|
||||
? $player->wallets
|
||||
: $player->wallets()->get();
|
||||
|
||||
$walletRows = $wallets->map(static fn (PlayerWallet $w): array => [
|
||||
'wallet_type' => $w->wallet_type,
|
||||
'currency_code' => $w->currency_code,
|
||||
'balance' => (int) $w->balance,
|
||||
'frozen_balance' => (int) $w->frozen_balance,
|
||||
'available_balance' => max(0, (int) $w->balance - (int) $w->frozen_balance),
|
||||
'status' => (int) $w->status,
|
||||
])->values()->all();
|
||||
|
||||
return [
|
||||
'id' => (int) $player->id,
|
||||
'site_code' => $player->site_code,
|
||||
'site_player_id' => $player->site_player_id,
|
||||
'username' => $player->username,
|
||||
'nickname' => $player->nickname,
|
||||
'default_currency' => $player->default_currency,
|
||||
'status' => (int) $player->status,
|
||||
'last_login_at' => $player->last_login_at?->toIso8601String(),
|
||||
'created_at' => $player->created_at?->toIso8601String(),
|
||||
'wallets' => $walletRows,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user