feat: 增强玩家 API,新增 locale 和时间字段,更新钱包 API 以支持可用余额计算,添加错误码与多语言支持

This commit is contained in:
2026-05-09 15:05:46 +08:00
parent f1b38ef421
commit a0f86a4e36
36 changed files with 2523 additions and 34 deletions

View File

@@ -9,16 +9,35 @@ use Illuminate\Http\Request;
* 【业务文案翻译辅助类】
*
* lang/{locale}/sso.php 等语言包取字符串,供 JSON 里「msg」字段使用。
* `App\Lottery\ErrorCode` 中玩家 SSO 80018004)的各语言 `msg`
* `App\Lottery\ErrorCode` 中玩家 SSO 80018005)的各语言 `msg`
*
* 依赖 NegotiateLotteryLocale 已写入 lottery_locale若未写则使用 fallback 语言包。
*/
final class LotteryMessage
{
/**
* 取钱包划转类错误的用户可见文案lang/{locale}/wallet.php 键名为数字错误码)。
*
* @param int $code {@see ErrorCode} 钱包段10011010 等与钱包相关的业务码)
*/
public static function wallet(Request $request, int $code): string
{
$fallback = (string) config('lottery.locales.fallback', 'en');
$locale = (string) ($request->attributes->get('lottery_locale') ?? LotteryLocale::resolve($request));
$key = 'wallet.'.$code;
$msg = trans($key, [], $locale);
if ($msg !== $key) {
return $msg;
}
return trans($key, [], $fallback);
}
/**
* SSO 鉴权类错误的用户可见文案(与 ApiResponse msg 对应)。
*
* @param int $code {@see ErrorCode} 玩家 SSO 80018004
* @param int $code {@see ErrorCode} 玩家 SSO 80018005
*/
public static function sso(Request $request, int $code): string
{