feat: 添加货币格式化功能,更新多个控制器以支持金额和余额的格式化显示,增强 API 响应的可读性

This commit is contained in:
2026-05-13 11:59:50 +08:00
parent 805847954d
commit d8e9fa5f4c
8 changed files with 60 additions and 22 deletions

View File

@@ -6,6 +6,7 @@ use App\Models\JackpotPool;
use App\Support\ApiResponse;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use App\Support\CurrencyFormatter;
use App\Http\Controllers\Controller;
/**
@@ -25,10 +26,13 @@ final class JackpotSummaryController extends Controller
->where('status', 1)
->first();
$amountMinor = $pool !== null ? (int) $pool->current_amount : 0;
return ApiResponse::success([
'currency_code' => $currency,
'enabled' => $pool !== null,
'current_amount_minor' => $pool !== null ? (int) $pool->current_amount : 0,
'current_amount_minor' => $amountMinor,
'current_amount_formatted' => CurrencyFormatter::fromMinor($amountMinor),
]);
}
}