feat: 增强玩家 API,新增 locale 和时间字段,更新钱包 API 以支持可用余额计算,添加错误码与多语言支持
This commit is contained in:
65
app/Services/Wallet/StubMainSiteWalletGateway.php
Normal file
65
app/Services/Wallet/StubMainSiteWalletGateway.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Wallet;
|
||||
|
||||
use App\Models\Player;
|
||||
|
||||
/**
|
||||
* 未配置 `MAIN_SITE_WALLET_API_URL` 或仅本地联调时使用:主站永远返回成功。
|
||||
*/
|
||||
final class StubMainSiteWalletGateway implements MainSiteWalletGateway
|
||||
{
|
||||
public function debitMainForLotteryDeposit(
|
||||
Player $player,
|
||||
string $currencyCode,
|
||||
int $amountMinor,
|
||||
string $idempotentKey,
|
||||
): MainSiteWalletResult {
|
||||
$req = self::requestSnapshot($player, $currencyCode, $amountMinor, $idempotentKey, 'stub_debit');
|
||||
|
||||
return MainSiteWalletResult::success('stub-debit:'.$idempotentKey, [
|
||||
'stub' => true,
|
||||
'currency' => $currencyCode,
|
||||
'amount_minor' => $amountMinor,
|
||||
], $req);
|
||||
}
|
||||
|
||||
public function creditMainForLotteryWithdraw(
|
||||
Player $player,
|
||||
string $currencyCode,
|
||||
int $amountMinor,
|
||||
string $idempotentKey,
|
||||
): MainSiteWalletResult {
|
||||
$req = self::requestSnapshot($player, $currencyCode, $amountMinor, $idempotentKey, 'stub_credit');
|
||||
|
||||
return MainSiteWalletResult::success('stub-credit:'.$idempotentKey, [
|
||||
'stub' => true,
|
||||
'currency' => $currencyCode,
|
||||
'amount_minor' => $amountMinor,
|
||||
], $req);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private static function requestSnapshot(
|
||||
Player $player,
|
||||
string $currencyCode,
|
||||
int $amountMinor,
|
||||
string $idempotentKey,
|
||||
string $stubOp,
|
||||
): array {
|
||||
return [
|
||||
'site_code' => $player->site_code,
|
||||
'site_player_id' => $player->site_player_id,
|
||||
'player_id' => $player->id,
|
||||
'currency_code' => $currencyCode,
|
||||
'amount_minor' => $amountMinor,
|
||||
'idempotent_key' => $idempotentKey,
|
||||
'_meta' => [
|
||||
'stub' => true,
|
||||
'operation' => $stubOp,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user