feat: 增强玩家 API,新增 locale 和时间字段,更新钱包 API 以支持可用余额计算,添加错误码与多语言支持
This commit is contained in:
@@ -9,16 +9,35 @@ use Illuminate\Http\Request;
|
||||
* 【业务文案翻译辅助类】
|
||||
*
|
||||
* 从 lang/{locale}/sso.php 等语言包取字符串,供 JSON 里「msg」字段使用。
|
||||
* `App\Lottery\ErrorCode` 中玩家 SSO 段(8001–8004)的各语言 `msg`。
|
||||
* `App\Lottery\ErrorCode` 中玩家 SSO 段(8001–8005)的各语言 `msg`。
|
||||
*
|
||||
* 依赖 NegotiateLotteryLocale 已写入 lottery_locale;若未写则使用 fallback 语言包。
|
||||
*/
|
||||
final class LotteryMessage
|
||||
{
|
||||
/**
|
||||
* 取钱包划转类错误的用户可见文案(lang/{locale}/wallet.php 键名为数字错误码)。
|
||||
*
|
||||
* @param int $code {@see ErrorCode} 钱包段(1001–1010 等与钱包相关的业务码)
|
||||
*/
|
||||
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 段(8001–8004)
|
||||
* @param int $code {@see ErrorCode} 玩家 SSO 段(8001–8005)
|
||||
*/
|
||||
public static function sso(Request $request, int $code): string
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user