|
|
@@ -21,6 +21,7 @@ use Illuminate\Validation\Rule;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use App\Rules\DecimalNumber;
|
|
|
use App\Constants\Util;
|
|
|
+use App\Services\ThirdGameBalanceService;
|
|
|
|
|
|
class Agent extends AgentApiController
|
|
|
{
|
|
|
@@ -114,22 +115,36 @@ class Agent extends AgentApiController
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- public function quota(Request $request)
|
|
|
+ public function quota(Request $request, ThirdGameBalanceService $thirdGame)
|
|
|
{
|
|
|
- return $this->execute(function () use ($request) {
|
|
|
- $data = $request->validate(['agent_id' => ['required', 'integer', 'exists:agents,id']]);
|
|
|
+ return $this->execute(function () use ($request, $thirdGame) {
|
|
|
+ $data = $request->validate([
|
|
|
+ 'agent_id' => ['required', 'integer', 'exists:agents,id'],
|
|
|
+ 'refresh' => ['nullable', 'boolean'],
|
|
|
+ ]);
|
|
|
$agent = AgentModel::query()->findOrFail($data['agent_id']);
|
|
|
+ $provider = $thirdGame->agentBalances((int) $agent->id, $request->boolean('refresh'));
|
|
|
+ if (empty($provider['ok'])) {
|
|
|
+ throw new \RuntimeException((string) ($provider['msg'] ?? '三方平台余额查询失败'));
|
|
|
+ }
|
|
|
+ $balances = is_array($provider['balances'] ?? null) ? $provider['balances'] : [];
|
|
|
$platforms = EgameItem::query()->where('item_type', EgameItem::TYPE_PLATFORM)->where('game_type', 0)
|
|
|
->where('status', EgameItem::STATUS_ENABLED)->orderByDesc('sort')->get(['plat_type', 'name', 'logo'])
|
|
|
- ->map(function (EgameItem $platform) {
|
|
|
+ ->map(function (EgameItem $platform) use ($balances) {
|
|
|
+ $key = strtolower((string) $platform->plat_type);
|
|
|
$platform->logo = Util::ensureUrl($platform->logo);
|
|
|
+ $platform->setAttribute('balance', $balances[$key] ?? '0.0000000000');
|
|
|
+ $platform->setAttribute('account_opened', array_key_exists($key, $balances) ? 1 : 0);
|
|
|
return $platform;
|
|
|
});
|
|
|
return [
|
|
|
+ 'agent_id' => (int) $agent->id,
|
|
|
+ 'player_id' => (string) $provider['player_id'],
|
|
|
+ 'currency' => (string) $provider['currency'],
|
|
|
'balance' => (string) $agent->balance,
|
|
|
'frozen_balance' => (string) $agent->frozen_balance,
|
|
|
- 'quota_mode' => 'internal',
|
|
|
- 'provider_wallet_supported' => false,
|
|
|
+ 'quota_mode' => 'provider',
|
|
|
+ 'provider_wallet_supported' => true,
|
|
|
'platforms' => $platforms,
|
|
|
];
|
|
|
});
|