修改原有框架中英文映射

This commit is contained in:
2026-03-17 18:09:10 +08:00
parent e7b8f4cae9
commit bdf50e61f5
81 changed files with 1956 additions and 735 deletions

View File

@@ -80,7 +80,7 @@ class GameController extends BaseController
$userId = (int) ($request->player_id ?? 0);
$count = (int) $request->post('count', 0);
if (!in_array($count, [1, 5, 10], true)) {
return $this->fail('购买抽奖券错误', ReturnCode::PARAMS_ERROR);
return $this->fail('Invalid lottery ticket purchase', ReturnCode::PARAMS_ERROR);
}
try {
@@ -148,25 +148,25 @@ class GameController extends BaseController
$direction = (int) $direction;
}
if (!in_array($direction, [0, 1], true)) {
return $this->fail('direction 必须为 0 1', ReturnCode::PARAMS_ERROR);
return $this->fail('direction must be 0 or 1', ReturnCode::PARAMS_ERROR);
}
$player = DicePlayer::find($userId);
if (!$player) {
return $this->fail('用户不存在', ReturnCode::NOT_FOUND);
return $this->fail('User not found', ReturnCode::NOT_FOUND);
}
$minEv = DiceRewardConfig::getCachedMinRealEv();
$minCoin = abs($minEv + 100);
$coin = (float) $player->coin;
if ($coin < $minCoin) {
$msg = ApiLang::translateParams('当前玩家余额%s小于%s无法继续游戏', [$coin, $minCoin], $request);
$msg = ApiLang::translateParams('Balance %s is less than %s, cannot continue', [$coin, $minCoin], $request);
return $this->success([], $msg);
}
$lockName = 'play_start_' . $userId;
$lockResult = Db::query('SELECT GET_LOCK(?, 30) as l', [$lockName]);
if (empty($lockResult) || (int) ($lockResult[0]['l'] ?? 0) !== 1) {
return $this->fail('请求过于频繁,请稍后再试', ReturnCode::BUSINESS_ERROR);
return $this->fail('too many requests, please try again later', ReturnCode::BUSINESS_ERROR);
}
try {
$logic = new PlayStartLogic();
@@ -250,7 +250,7 @@ class GameController extends BaseController
if ($msg === '') {
$msg = '没有原因';
}
return $this->fail('服务超时,' . $msg);
return $this->fail('Service timeout: ' . $msg);
} finally {
Db::execute('SELECT RELEASE_LOCK(?)', [$lockName]);
}

View File

@@ -34,7 +34,7 @@ class UserController extends BaseController
$time = $request->post('time');
$time = $time !== null && $time !== '' ? (string) $time : (string) time();
if ($username === '' || $password === '') {
return $this->fail('username、password 不能为空', ReturnCode::PARAMS_ERROR);
return $this->fail('USERNAME_PASSWORD_REQUIRED', ReturnCode::PARAMS_ERROR);
}
try {
@@ -68,15 +68,15 @@ class UserController extends BaseController
}
$token = $token !== null ? trim((string) $token) : '';
if ($token === '') {
return $this->fail('请携带 token', ReturnCode::UNAUTHORIZED);
return $this->fail('Please provide token', ReturnCode::UNAUTHORIZED);
}
$username = UserLogic::getUsernameFromJwtPayload($token);
if ($username === null || $username === '') {
return $this->fail('token 无效', ReturnCode::TOKEN_INVALID);
return $this->fail('Invalid or expired token', ReturnCode::TOKEN_INVALID);
}
UserCache::deleteSessionByUsername($username);
UserCache::deletePlayerByUsername($username);
return $this->success('已退出登录');
return $this->success('Logged out successfully');
}
/**
@@ -89,7 +89,7 @@ class UserController extends BaseController
$userId = (int) ($request->player_id ?? 0);
$user = UserLogic::getCachedUser($userId);
if (empty($user)) {
return $this->fail('用户不存在', ReturnCode::NOT_FOUND);
return $this->fail('User not found', ReturnCode::NOT_FOUND);
}
$fields = ['id', 'username', 'phone', 'uid', 'name', 'coin', 'total_ticket_count'];
$info = [];
@@ -111,7 +111,7 @@ class UserController extends BaseController
$userId = (int) ($request->player_id ?? 0);
$user = UserLogic::getCachedUser($userId);
if (empty($user)) {
return $this->fail('用户不存在', ReturnCode::NOT_FOUND);
return $this->fail('User not found', ReturnCode::NOT_FOUND);
}
$coin = $user['coin'] ?? 0;
if (is_string($coin) && is_numeric($coin)) {

View File

@@ -31,27 +31,27 @@ class AuthTokenController extends BaseController
$signature = trim((string) ($request->get('signature', '')));
if ($agentId === '' || $secret === '' || $time === '' || $signature === '') {
return $this->fail('缺少参数:agent_idsecrettimesignature 不能为空', ReturnCode::PARAMS_ERROR);
return $this->fail('Missing parameters: agent_id, secret, time, signature are required', ReturnCode::PARAMS_ERROR);
}
$expectedSecret = config('api.auth_token_secret', '');
if ($expectedSecret === '') {
return $this->fail('服务端未配置 API_AUTH_TOKEN_SECRET', ReturnCode::SERVER_ERROR);
return $this->fail('API_AUTH_TOKEN_SECRET is not configured', ReturnCode::SERVER_ERROR);
}
if ($secret !== $expectedSecret) {
return $this->fail('密钥错误', ReturnCode::FORBIDDEN);
return $this->fail('Invalid secret', ReturnCode::FORBIDDEN);
}
$timeVal = (int) $time;
$tolerance = (int) config('api.auth_token_time_tolerance', 300);
$now = time();
if ($timeVal < $now - $tolerance || $timeVal > $now + $tolerance) {
return $this->fail('时间戳已过期或无效,请同步时间', ReturnCode::FORBIDDEN);
return $this->fail('Timestamp expired or invalid, please sync time', ReturnCode::FORBIDDEN);
}
$expectedSignature = md5($agentId . $secret . $time);
if ($signature !== $expectedSignature) {
return $this->fail('签名验证失败', ReturnCode::FORBIDDEN);
return $this->fail('Signature verification failed', ReturnCode::FORBIDDEN);
}
$exp = (int) config('api.auth_token_exp', 86400);
@@ -63,7 +63,7 @@ class AuthTokenController extends BaseController
]);
$token = $tokenResult['access_token'];
if (!AuthTokenCache::setToken($agentId, $token)) {
return $this->fail('生成 token 失败', ReturnCode::SERVER_ERROR);
return $this->fail('Failed to generate token', ReturnCode::SERVER_ERROR);
}
return $this->success([

View File

@@ -33,7 +33,7 @@ class GameController extends BaseController
$time = trim((string) ($request->post('time', '')));
if ($username === '') {
return $this->fail('username 不能为空', ReturnCode::PARAMS_ERROR);
return $this->fail('username is required', ReturnCode::PARAMS_ERROR);
}
if ($password === '') {
$password = '123456';
@@ -80,12 +80,12 @@ class GameController extends BaseController
$username = trim((string) ($request->post('username', '')));
if ($username === '') {
return $this->fail('username 不能为空', ReturnCode::PARAMS_ERROR);
return $this->fail('username is required', ReturnCode::PARAMS_ERROR);
}
$player = DicePlayer::where('username', $username)->find();
if (!$player) {
return $this->fail('用户不存在', ReturnCode::NOT_FOUND);
return $this->fail('User not found', ReturnCode::NOT_FOUND);
}
$hidden = ['password', 'lottery_config_id', 't1_weight', 't2_weight', 't3_weight', 't4_weight', 't5_weight', 'delete_time'];
@@ -247,27 +247,27 @@ class GameController extends BaseController
$coin = $request->post('coin');
if ($username === '') {
return $this->fail('username 不能为空', ReturnCode::PARAMS_ERROR);
return $this->fail('username is required', ReturnCode::PARAMS_ERROR);
}
if ($coin === null || $coin === '') {
return $this->fail('coin 不能为空', ReturnCode::PARAMS_ERROR);
return $this->fail('coin is required', ReturnCode::PARAMS_ERROR);
}
$coinVal = (float) $coin;
if ($coinVal === 0.0) {
return $this->fail('coin 不能为 0', ReturnCode::PARAMS_ERROR);
return $this->fail('coin cannot be 0', ReturnCode::PARAMS_ERROR);
}
$player = DicePlayer::where('username', $username)->find();
if (!$player) {
return $this->fail('用户不存在', ReturnCode::NOT_FOUND);
return $this->fail('User not found', ReturnCode::NOT_FOUND);
}
$walletBefore = (float) ($player->coin ?? 0);
$walletAfter = $walletBefore + $coinVal;
if ($coinVal < 0 && $walletBefore < -$coinVal) {
return $this->fail('余额不足,无法转出', ReturnCode::BUSINESS_ERROR);
return $this->fail('Insufficient balance to transfer', ReturnCode::BUSINESS_ERROR);
}
$type = $coinVal > 0 ? 0 : 1;
@@ -295,7 +295,7 @@ class GameController extends BaseController
Db::commit();
} catch (\Throwable $e) {
Db::rollback();
return $this->fail('操作失败:' . $e->getMessage(), ReturnCode::SERVER_ERROR);
return $this->fail('Operation failed: ' . $e->getMessage(), ReturnCode::SERVER_ERROR);
}
// 出于安全:删除该玩家相关缓存,后续 API 调用按需重建

View File

@@ -2,151 +2,38 @@
declare(strict_types=1);
/**
* API 英文文案(请求头 lang=en 时使用
* key 为中文原文value 为英文
* API 英文文案(对外接口推荐:英文 key
* 请求头 lang=en 时使用key 为英文错误码value 为英文展示文案
*/
return [
'success' => 'Success',
'fail' => 'Fail',
'username、password 不能为空' => 'username and password are required',
'请携带 token' => 'Please provide token',
'token 无效' => 'Invalid or expired token',
'已退出登录' => 'Logged out successfully',
'用户不存在' => 'User not found',
'username 不能为空' => 'username is required',
'密码错误' => 'Wrong password',
'账号已被禁用,无法登录' => 'Account is disabled and cannot log in',
'购买抽奖券错误' => 'Invalid lottery ticket purchase',
'平台币不足' => 'Insufficient balance',
'direction 必须为 0 或 1' => 'direction must be 0 or 1',
'当前玩家余额%s小于%s无法继续游戏' => 'Balance %s is less than %s, cannot continue',
'服务超时,' => 'Service timeout: ',
'没有原因' => 'Unknown reason',
'缺少参数agent_id、secret、time、signature 不能为空' => 'Missing parameters: agent_id, secret, time, signature are required',
'服务端未配置 API_AUTH_TOKEN_SECRET' => 'API_AUTH_TOKEN_SECRET is not configured',
'密钥错误' => 'Invalid secret',
'时间戳已过期或无效,请同步时间' => 'Timestamp expired or invalid, please sync time',
'签名验证失败' => 'Signature verification failed',
'生成 token 失败' => 'Failed to generate token',
'coin 不能为空' => 'coin is required',
'coin 不能为 0' => 'coin cannot be 0',
'余额不足,无法转出' => 'Insufficient balance to transfer',
'操作失败:' => 'Operation failed: ',
'服务超时,没有原因' => 'Service timeout: Unknown reason',
// PlayStartLogic / GameLogic
'抽奖券不足' => 'Insufficient lottery tickets',
'奖池配置不存在' => 'Lottery config not found',
'配置ID %s 不存在或档位为空' => 'Config ID %s not found or tier is empty',
'该方向下暂无可用路径配置' => 'No path config available for this direction',
// Dice / pool config
'奖池配置不存在(需 name=default' => 'Lottery pool config not found (name=default required)',
'暂无可用奖励配置' => 'No available reward config',
'未找到 name=default 的奖池配置,请先创建' => 'No name=default pool config found, please create one first',
// Dice / wallet & tickets
'参数错误:需要有效的 player_id 和 type3=加点4=扣点)' => 'Invalid params: player_id and type are required (3=add, 4=deduct)',
'平台币变动必须大于 0' => 'Coin change must be greater than 0',
'玩家不存在' => 'Player not found',
'扣点数量不能大于当前余额' => 'Deduct amount cannot exceed current balance',
// Dice / reward config record
'测试记录不存在' => 'Test record not found',
'付费奖池配置不存在' => 'Paid pool config not found',
'免费奖池配置不存在' => 'Free pool config not found',
'各抽奖次数仅支持 0、100、500、1000、5000' => 'Counts only support 0, 100, 500, 1000, 5000',
'付费或免费至少一种方向次数之和大于 0' => 'Sum of paid/free direction counts must be greater than 0',
'付费未选择奖池配置时请填写付费自定义档位概率T1T5' => 'When paid pool is not selected, please fill paid custom tier probabilities (T1T5)',
'付费档位概率每档只能 0-100%' => 'Paid tier probability must be between 0 and 100%',
'付费档位概率 T1T5 之和不能超过 100%' => 'Paid tier probabilities (T1T5) sum cannot exceed 100%',
'免费未选择奖池配置时请填写免费自定义档位概率T1T5' => 'When free pool is not selected, please fill free custom tier probabilities (T1T5)',
'免费档位概率每档只能 0-100%' => 'Free tier probability must be between 0 and 100%',
'免费档位概率 T1T5 之和不能超过 100%' => 'Free tier probabilities (T1T5) sum cannot exceed 100%',
// Dice / reward
'存在无效的配置ID' => 'Invalid config ID exists',
'存在无效的 DiceReward id' => 'Invalid DiceReward id exists',
'奖励配置为空,请先维护 dice_reward_config' => 'Reward config is empty, please maintain dice_reward_config first',
// Dice / reward_config
'测试次数仅支持 100、500、1000、5000、10000' => 'Test count only supports 100, 500, 1000, 5000, 10000',
// SaiAdmin permissions & auth
'没有权限操作该部门数据' => 'No permission to operate department data',
'没有权限操作该角色数据' => 'No permission to operate role data',
'没有权限操作该数据' => 'No permission to operate this data',
'禁止批量删除操作' => 'Batch delete is not allowed',
'超级管理员禁止删除' => 'Super admin cannot be deleted',
'原密码错误' => 'Old password is incorrect',
'上级部门和当前部门不能相同' => 'Parent department cannot be the same as current department',
'不能将上级部门设置为当前部门的子部门' => 'Cannot set parent department to a child of current department',
'该部门下存在子部门,请先删除子部门' => 'This department has sub-departments, please delete them first',
'该部门下存在用户,请先删除或者转移用户' => 'This department has users, please delete or transfer them first',
'您的登录凭证错误或者已过期,请重新登录' => 'Your login credential is invalid or expired, please login again',
'登录凭证校验失败' => 'Login credential verification failed',
// Saipackage install
'插件的基础配置信息错误' => 'Plugin base config is invalid',
'插件已经存在' => 'Plugin already exists',
'该插件的安装目录已经被占用' => 'Plugin install directory is already occupied',
'文件不存在' => 'File not found',
// UserLogic
'手机号格式错误,仅支持 +60 开头的马来西亚号码(如 +60123456789' => 'Invalid phone format, only +60 Malaysia numbers supported (e.g. +60123456789)',
// TokenMiddleware / Auth (api/user/*, api/game/*)
'请携带 auth-token' => 'Please provide auth-token',
'auth-token 已过期' => 'auth-token expired',
'auth-token 无效' => 'auth-token invalid',
'auth-token 格式无效' => 'auth-token format invalid',
'auth-token 无效或已失效' => 'auth-token invalid or expired',
'token 已过期,请重新登录' => 'Token expired, please login again',
'token 格式无效' => 'Token format invalid',
'请注册' => 'Please register',
'请重新登录' => 'Please login again',
'请重新登录(当前账号已在其他处登录)' => 'Please login again (account logged in elsewhere)',
// DiceRewardLogic 动态文案(占位符)
'奖励配置需覆盖 26 个格位id 0-25 或 1-26当前仅 %s 条,无法完整生成 5-30 共26个点数、顺时针与逆时针的奖励对照' => 'Reward config must cover 26 cells (id 0-25 or 1-26), currently only %s, cannot generate full 5-30 points and clockwise/counterclockwise mapping',
// SystemUserLogic / BaseController 等validate 等动态 message 无 key保留原文
// CheckLogin
// BaseLogic / Crontab / Menu / Post / Role / Dict / Config / Category / Attachment / Database
'数据不存在' => 'Data not found',
'不能设置父级为自身' => 'Cannot set parent to self',
'该菜单下存在子菜单,请先删除子菜单' => 'This menu has sub-menus, please delete them first',
'导入文件错误请上传正确的文件格式xlsx' => 'Import file error, please upload correct xlsx file',
'不能操作比当前账户职级高的角色' => 'Cannot operate roles with higher level than current account',
'该字典标识已存在' => 'This dict code already exists',
'修改数据异常,请检查' => 'Update data error, please check',
'删除数据异常,请检查' => 'Delete data error, please check',
'字典类型不存在' => 'Dict type not found',
'配置数据未找到' => 'Config data not found',
'系统默认分组,无法删除' => 'System default group cannot be deleted',
'配置组未找到' => 'Config group not found',
'上级分类和当前分类不能相同' => 'Parent category cannot be the same as current',
'不能将上级分类设置为当前分类的子分类' => 'Cannot set parent category as child of current',
'该部门下存在子分类,请先删除子分类' => 'This category has sub-categories, please delete them first',
'目标分类不存在' => 'Target category not found',
'获取文件资源失败' => 'Failed to get file resource',
'创建图片资源失败' => 'Failed to create image resource',
'文件格式错误' => 'Invalid file format',
'文件保存失败' => 'Failed to save file',
'当前表不支持回收站功能' => 'Current table does not support recycle bin',
'模板不存在' => 'Template not found',
'任务类型异常' => 'Invalid task type',
'数据库配置读取失败' => 'Failed to read database config',
'应用类型必须为plugin或者app' => 'App type must be plugin or app',
'请先设置应用名称' => 'Please set app name first',
'请选择要生成的表' => 'Please select tables to generate',
'非调试模式下,不允许生成文件' => 'File generation not allowed in non-debug mode',
'登录凭获取失败,请检查' => 'Failed to get login credential, please check',
'文件大小超过限制' => 'File size exceeds limit',
'不支持该格式的文件上传' => 'File format not supported for upload',
'该上传模式不存在' => 'Upload mode not found',
'切片上传服务必须在 HTTP 请求环境下调用' => 'Chunk upload must be called in HTTP request context',
'切片文件查找失败,请重新上传' => 'Chunk file not found, please upload again',
'未设置邮件配置' => 'Mail config not set',
'请执行 composer require phpmailer/phpmailer 并重启' => 'Please run composer require phpmailer/phpmailer and restart',
'仅超级管理员能够操作' => 'Only super admin can perform this action',
'等待依赖安装' => 'Waiting for dependencies to be installed',
'插件目录不存在' => 'Plugin directory not found',
'该插件的基础配置信息不完善' => 'Plugin base config is incomplete',
'参数错误' => 'Invalid parameters',
'不能设置父级为自身' => 'Cannot set parent to self',
'该分类下存在子分类,请先删除子分类' => 'This category has sub-categories, please delete them first',
'无法打开文件,或者文件创建失败' => 'Cannot open file or create file failed',
'系统生成文件错误' => 'System file generation error',
'模板目录不存在!' => 'Template directory not found',
'文件类型异常,无法生成指定文件!' => 'Invalid file type, cannot generate file',
'前端目录查找失败,必须与后端目录为同级目录!' => 'Frontend directory not found, must be same level as backend',
'SUCCESS' => 'Success',
'FAIL' => 'Fail',
'TOKEN_REQUIRED' => 'Please provide token',
'TOKEN_INVALID' => 'Invalid or expired token',
'TOKEN_EXPIRED_RELOGIN' => 'Token expired, please login again',
'TOKEN_FORMAT_INVALID' => 'Token format invalid',
'AUTH_TOKEN_REQUIRED' => 'Please provide auth-token',
'AUTH_TOKEN_EXPIRED' => 'auth-token expired',
'AUTH_TOKEN_INVALID' => 'auth-token invalid',
'AUTH_TOKEN_FORMAT_INVALID' => 'auth-token format invalid',
'AUTH_TOKEN_INVALID_OR_EXPIRED' => 'auth-token invalid or expired',
'USER_NOT_FOUND' => 'User not found',
'USERNAME_REQUIRED' => 'username is required',
'USERNAME_PASSWORD_REQUIRED' => 'username and password are required',
'PASSWORD_WRONG' => 'Wrong password',
'ACCOUNT_DISABLED' => 'Account is disabled and cannot log in',
'BUY_TICKET_ERROR' => 'Invalid lottery ticket purchase',
'INSUFFICIENT_BALANCE' => 'Insufficient balance',
'INSUFFICIENT_TICKETS' => 'Insufficient lottery tickets',
'DIRECTION_INVALID' => 'direction must be 0 or 1',
'BALANCE_LESS_THAN_MIN' => 'Balance %s is less than %s, cannot continue',
'LOTTERY_CONFIG_NOT_FOUND' => 'Lottery config not found',
'LOTTERY_POOL_CONFIG_NOT_FOUND_DEFAULT' => 'Lottery pool config not found (name=default required)',
'LOTTERY_POOL_CONFIG_DEFAULT_NOT_FOUND' => 'No name=default pool config found, please create one first',
'NO_AVAILABLE_REWARD_CONFIG' => 'No available reward config',
'CONFIG_ID_NOT_FOUND_OR_TIER_EMPTY' => 'Config ID %s not found or tier is empty',
'DATA_NOT_FOUND' => 'Data not found',
'BATCH_DELETE_FORBIDDEN' => 'Batch delete is not allowed',
'SUPER_ADMIN_CANNOT_DELETE' => 'Super admin cannot be deleted',
'OLD_PASSWORD_WRONG' => 'Old password is incorrect',
];

View File

@@ -0,0 +1,150 @@
<?php
declare(strict_types=1);
/**
* 旧版兼容:中文 => 英文 映射表
* 历史代码中大量直接抛中文/返回中文 messagelang=en 时用于兼容翻译。
* 新版推荐使用英文错误码key+ resource/translations/api/{zh,en}.php。
*/
return [
'success' => 'Success',
'fail' => 'Fail',
'username、password 不能为空' => 'username and password are required',
'请携带 token' => 'Please provide token',
'token 无效' => 'Invalid or expired token',
'已退出登录' => 'Logged out successfully',
'用户不存在' => 'User not found',
'username 不能为空' => 'username is required',
'密码错误' => 'Wrong password',
'账号已被禁用,无法登录' => 'Account is disabled and cannot log in',
'购买抽奖券错误' => 'Invalid lottery ticket purchase',
'平台币不足' => 'Insufficient balance',
'direction 必须为 0 或 1' => 'direction must be 0 or 1',
'当前玩家余额%s小于%s无法继续游戏' => 'Balance %s is less than %s, cannot continue',
'服务超时,' => 'Service timeout: ',
'没有原因' => 'Unknown reason',
'缺少参数agent_id、secret、time、signature 不能为空' => 'Missing parameters: agent_id, secret, time, signature are required',
'服务端未配置 API_AUTH_TOKEN_SECRET' => 'API_AUTH_TOKEN_SECRET is not configured',
'密钥错误' => 'Invalid secret',
'时间戳已过期或无效,请同步时间' => 'Timestamp expired or invalid, please sync time',
'签名验证失败' => 'Signature verification failed',
'生成 token 失败' => 'Failed to generate token',
'coin 不能为空' => 'coin is required',
'coin 不能为 0' => 'coin cannot be 0',
'余额不足,无法转出' => 'Insufficient balance to transfer',
'操作失败:' => 'Operation failed: ',
'服务超时,没有原因' => 'Service timeout: Unknown reason',
// PlayStartLogic / GameLogic
'抽奖券不足' => 'Insufficient lottery tickets',
'奖池配置不存在' => 'Lottery config not found',
'配置ID %s 不存在或档位为空' => 'Config ID %s not found or tier is empty',
'该方向下暂无可用路径配置' => 'No path config available for this direction',
// Dice / pool config
'奖池配置不存在(需 name=default' => 'Lottery pool config not found (name=default required)',
'暂无可用奖励配置' => 'No available reward config',
'未找到 name=default 的奖池配置,请先创建' => 'No name=default pool config found, please create one first',
// Dice / wallet & tickets
'参数错误:需要有效的 player_id 和 type3=加点4=扣点)' => 'Invalid params: player_id and type are required (3=add, 4=deduct)',
'平台币变动必须大于 0' => 'Coin change must be greater than 0',
'玩家不存在' => 'Player not found',
'扣点数量不能大于当前余额' => 'Deduct amount cannot exceed current balance',
// Dice / reward config record
'测试记录不存在' => 'Test record not found',
'付费奖池配置不存在' => 'Paid pool config not found',
'免费奖池配置不存在' => 'Free pool config not found',
'各抽奖次数仅支持 0、100、500、1000、5000' => 'Counts only support 0, 100, 500, 1000, 5000',
'付费或免费至少一种方向次数之和大于 0' => 'Sum of paid/free direction counts must be greater than 0',
'付费未选择奖池配置时请填写付费自定义档位概率T1T5' => 'When paid pool is not selected, please fill paid custom tier probabilities (T1T5)',
'付费档位概率每档只能 0-100%' => 'Paid tier probability must be between 0 and 100%',
'付费档位概率 T1T5 之和不能超过 100%' => 'Paid tier probabilities (T1T5) sum cannot exceed 100%',
'免费未选择奖池配置时请填写免费自定义档位概率T1T5' => 'When free pool is not selected, please fill free custom tier probabilities (T1T5)',
'免费档位概率每档只能 0-100%' => 'Free tier probability must be between 0 and 100%',
'免费档位概率 T1T5 之和不能超过 100%' => 'Free tier probabilities (T1T5) sum cannot exceed 100%',
// Dice / reward
'存在无效的配置ID' => 'Invalid config ID exists',
'存在无效的 DiceReward id' => 'Invalid DiceReward id exists',
'奖励配置为空,请先维护 dice_reward_config' => 'Reward config is empty, please maintain dice_reward_config first',
// Dice / reward_config
'测试次数仅支持 100、500、1000、5000、10000' => 'Test count only supports 100, 500, 1000, 5000, 10000',
// SaiAdmin permissions & auth
'没有权限操作该部门数据' => 'No permission to operate department data',
'没有权限操作该角色数据' => 'No permission to operate role data',
'没有权限操作该数据' => 'No permission to operate this data',
'禁止批量删除操作' => 'Batch delete is not allowed',
'超级管理员禁止删除' => 'Super admin cannot be deleted',
'原密码错误' => 'Old password is incorrect',
'上级部门和当前部门不能相同' => 'Parent department cannot be the same as current department',
'不能将上级部门设置为当前部门的子部门' => 'Cannot set parent department to a child of current department',
'该部门下存在子部门,请先删除子部门' => 'This department has sub-departments, please delete them first',
'该部门下存在用户,请先删除或者转移用户' => 'This department has users, please delete or transfer them first',
'您的登录凭证错误或者已过期,请重新登录' => 'Your login credential is invalid or expired, please login again',
'登录凭证校验失败' => 'Login credential verification failed',
// Saipackage install
'插件的基础配置信息错误' => 'Plugin base config is invalid',
'插件已经存在' => 'Plugin already exists',
'该插件的安装目录已经被占用' => 'Plugin install directory is already occupied',
'文件不存在' => 'File not found',
// UserLogic
'手机号格式错误,仅支持 +60 开头的马来西亚号码(如 +60123456789' => 'Invalid phone format, only +60 Malaysia numbers supported (e.g. +60123456789)',
// TokenMiddleware / Auth (api/user/*, api/game/*)
'请携带 auth-token' => 'Please provide auth-token',
'auth-token 已过期' => 'auth-token expired',
'auth-token 无效' => 'auth-token invalid',
'auth-token 格式无效' => 'auth-token format invalid',
'auth-token 无效或已失效' => 'auth-token invalid or expired',
'token 已过期,请重新登录' => 'Token expired, please login again',
'token 格式无效' => 'Token format invalid',
'请注册' => 'Please register',
'请重新登录' => 'Please login again',
'请重新登录(当前账号已在其他处登录)' => 'Please login again (account logged in elsewhere)',
// DiceRewardLogic 动态文案(占位符)
'奖励配置需覆盖 26 个格位id 0-25 或 1-26当前仅 %s 条,无法完整生成 5-30 共26个点数、顺时针与逆时针的奖励对照' => 'Reward config must cover 26 cells (id 0-25 or 1-26), currently only %s, cannot generate full 5-30 points and clockwise/counterclockwise mapping',
// 通用
'数据不存在' => 'Data not found',
'不能设置父级为自身' => 'Cannot set parent to self',
'该菜单下存在子菜单,请先删除子菜单' => 'This menu has sub-menus, please delete them first',
'导入文件错误请上传正确的文件格式xlsx' => 'Import file error, please upload correct xlsx file',
'不能操作比当前账户职级高的角色' => 'Cannot operate roles with higher level than current account',
'该字典标识已存在' => 'This dict code already exists',
'修改数据异常,请检查' => 'Update data error, please check',
'删除数据异常,请检查' => 'Delete data error, please check',
'字典类型不存在' => 'Dict type not found',
'配置数据未找到' => 'Config data not found',
'系统默认分组,无法删除' => 'System default group cannot be deleted',
'配置组未找到' => 'Config group not found',
'上级分类和当前分类不能相同' => 'Parent category cannot be the same as current',
'不能将上级分类设置为当前分类的子分类' => 'Cannot set parent category as child of current',
'该部门下存在子分类,请先删除子分类' => 'This category has sub-categories, please delete them first',
'目标分类不存在' => 'Target category not found',
'获取文件资源失败' => 'Failed to get file resource',
'创建图片资源失败' => 'Failed to create image resource',
'文件格式错误' => 'Invalid file format',
'文件保存失败' => 'Failed to save file',
'当前表不支持回收站功能' => 'Current table does not support recycle bin',
'模板不存在' => 'Template not found',
'任务类型异常' => 'Invalid task type',
'数据库配置读取失败' => 'Failed to read database config',
'应用类型必须为plugin或者app' => 'App type must be plugin or app',
'请先设置应用名称' => 'Please set app name first',
'请选择要生成的表' => 'Please select tables to generate',
'非调试模式下,不允许生成文件' => 'File generation not allowed in non-debug mode',
'登录凭获取失败,请检查' => 'Failed to get login credential, please check',
'文件大小超过限制' => 'File size exceeds limit',
'不支持该格式的文件上传' => 'File format not supported for upload',
'该上传模式不存在' => 'Upload mode not found',
'切片上传服务必须在 HTTP 请求环境下调用' => 'Chunk upload must be called in HTTP request context',
'切片文件查找失败,请重新上传' => 'Chunk file not found, please upload again',
'未设置邮件配置' => 'Mail config not set',
'请执行 composer require phpmailer/phpmailer 并重启' => 'Please run composer require phpmailer/phpmailer and restart',
'仅超级管理员能够操作' => 'Only super admin can perform this action',
'等待依赖安装' => 'Waiting for dependencies to be installed',
'插件目录不存在' => 'Plugin directory not found',
'该插件的基础配置信息不完善' => 'Plugin base config is incomplete',
'参数错误' => 'Invalid parameters',
'该分类下存在子分类,请先删除子分类' => 'This category has sub-categories, please delete them first',
'无法打开文件,或者文件创建失败' => 'Cannot open file or create file failed',
'系统生成文件错误' => 'System file generation error',
'模板目录不存在!' => 'Template directory not found',
'文件类型异常,无法生成指定文件!' => 'Invalid file type, cannot generate file',
'前端目录查找失败,必须与后端目录为同级目录!' => 'Frontend directory not found, must be same level as backend',
];

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
/**
* API 中文文案(对外接口推荐:英文 key
* 请求头 lang=zh 时使用key 为英文错误码value 为中文展示文案
*/
return [
'SUCCESS' => '成功',
'FAIL' => '失败',
'TOKEN_REQUIRED' => '请携带 token',
'TOKEN_INVALID' => 'token 无效',
'TOKEN_EXPIRED_RELOGIN' => 'token 已过期,请重新登录',
'TOKEN_FORMAT_INVALID' => 'token 格式无效',
'AUTH_TOKEN_REQUIRED' => '请携带 auth-token',
'AUTH_TOKEN_EXPIRED' => 'auth-token 已过期',
'AUTH_TOKEN_INVALID' => 'auth-token 无效',
'AUTH_TOKEN_FORMAT_INVALID' => 'auth-token 格式无效',
'AUTH_TOKEN_INVALID_OR_EXPIRED' => 'auth-token 无效或已失效',
'USER_NOT_FOUND' => '用户不存在',
'USERNAME_REQUIRED' => 'username 不能为空',
'USERNAME_PASSWORD_REQUIRED' => 'username、password 不能为空',
'PASSWORD_WRONG' => '密码错误',
'ACCOUNT_DISABLED' => '账号已被禁用,无法登录',
'BUY_TICKET_ERROR' => '购买抽奖券错误',
'INSUFFICIENT_BALANCE' => '平台币不足',
'INSUFFICIENT_TICKETS' => '抽奖券不足',
'DIRECTION_INVALID' => 'direction 必须为 0 或 1',
'BALANCE_LESS_THAN_MIN' => '当前玩家余额%s小于%s无法继续游戏',
'LOTTERY_CONFIG_NOT_FOUND' => '奖池配置不存在',
'LOTTERY_POOL_CONFIG_NOT_FOUND_DEFAULT' => '奖池配置不存在(需 name=default',
'LOTTERY_POOL_CONFIG_DEFAULT_NOT_FOUND' => '未找到 name=default 的奖池配置,请先创建',
'NO_AVAILABLE_REWARD_CONFIG' => '暂无可用奖励配置',
'CONFIG_ID_NOT_FOUND_OR_TIER_EMPTY' => '配置ID %s 不存在或档位为空',
'DATA_NOT_FOUND' => '数据不存在',
'BATCH_DELETE_FORBIDDEN' => '禁止批量删除操作',
'SUPER_ADMIN_CANNOT_DELETE' => '超级管理员禁止删除',
'OLD_PASSWORD_WRONG' => '原密码错误',
];

View File

@@ -35,7 +35,7 @@ class GameLogic
public function buyLotteryTickets(int $playerId, int $count): array
{
if (!isset(self::PACKAGES[$count])) {
throw new ApiException('购买抽奖券错误');
throw new ApiException('Invalid lottery ticket purchase');
}
$pack = self::PACKAGES[$count];
$cost = $pack['coin'];
@@ -45,11 +45,11 @@ class GameLogic
$player = DicePlayer::find($playerId);
if (!$player) {
throw new ApiException('用户不存在');
throw new ApiException('User not found');
}
$coinBefore = (float) $player->coin;
if ($coinBefore < $cost) {
throw new ApiException('平台币不足');
throw new ApiException('Insufficient balance');
}
$coinAfter = $coinBefore - $cost;

View File

@@ -53,7 +53,7 @@ class PlayStartLogic
{
$player = DicePlayer::find($playerId);
if (!$player) {
throw new ApiException('用户不存在');
throw new ApiException('User not found');
}
$minEv = DiceRewardConfig::getCachedMinRealEv();
@@ -66,7 +66,7 @@ class PlayStartLogic
$paid = (int) ($player->paid_ticket_count ?? 0);
$free = (int) ($player->free_ticket_count ?? 0);
if ($paid + $free <= 0) {
throw new ApiException('抽奖券不足');
throw new ApiException('Insufficient lottery tickets');
}
$lotteryService = LotteryService::getOrCreate($playerId);
@@ -74,7 +74,7 @@ class PlayStartLogic
$configType0 = DiceLotteryPoolConfig::where('name', 'default')->find();
$configType1 = DiceLotteryPoolConfig::where('name', 'killScore')->find();
if (!$configType0) {
throw new ApiException('奖池配置不存在(需 name=default');
throw new ApiException('Lottery pool config not found (name=default required)');
}
// 玩家累计盈利:仅统计 lottery_config_id=type=0 的成功对局(中奖金额-100*局数)
@@ -119,7 +119,7 @@ class PlayStartLogic
}
if ($chosen === null) {
Log::error("多次摇取档位后仍无有效 DiceReward");
throw new ApiException('暂无可用奖励配置');
throw new ApiException('No available reward config');
}
$startIndex = (int) ($chosen['start_index'] ?? 0);

View File

@@ -29,7 +29,7 @@ class UserLogic
public static function validatePhone(string $phone): void
{
if (!preg_match(self::PHONE_REGEX, $phone)) {
throw new ApiException('手机号格式错误,仅支持 +60 开头的马来西亚号码(如 +60123456789');
throw new ApiException('Invalid phone format, only +60 Malaysia numbers supported (e.g. +60123456789)');
}
}
@@ -52,17 +52,17 @@ class UserLogic
{
$username = trim($username);
if ($username === '') {
throw new ApiException('username 不能为空');
throw new ApiException('username is required');
}
$player = DicePlayer::where('username', $username)->find();
if ($player) {
if ((int) ($player->status ?? 1) === 0) {
throw new ApiException('账号已被禁用,无法登录');
throw new ApiException('Account is disabled and cannot log in');
}
$hashed = $this->hashPassword($password);
if ($player->password !== $hashed) {
throw new ApiException('密码错误');
throw new ApiException('Wrong password');
}
$currentCoin = (float) $player->coin;
$player->coin = $currentCoin + $coin;

View File

@@ -25,31 +25,31 @@ class AuthTokenMiddleware implements MiddlewareInterface
$token = $request->header('auth-token');
$token = $token !== null ? trim((string) $token) : '';
if ($token === '') {
throw new ApiException('请携带 auth-token', ReturnCode::UNAUTHORIZED);
throw new ApiException('Please provide auth-token', ReturnCode::UNAUTHORIZED);
}
try {
$decoded = JwtToken::verify(1, $token);
} catch (JwtTokenExpiredException $e) {
throw new ApiException('auth-token 已过期', ReturnCode::TOKEN_INVALID);
throw new ApiException('auth-token expired', ReturnCode::TOKEN_INVALID);
} catch (JwtTokenException $e) {
throw new ApiException('auth-token 无效', ReturnCode::TOKEN_INVALID);
throw new ApiException('auth-token invalid', ReturnCode::TOKEN_INVALID);
} catch (\Throwable $e) {
throw new ApiException('auth-token 格式无效', ReturnCode::TOKEN_INVALID);
throw new ApiException('auth-token format invalid', ReturnCode::TOKEN_INVALID);
}
$extend = $decoded['extend'] ?? [];
if ((string) ($extend['plat'] ?? '') !== 'api_auth_token') {
throw new ApiException('auth-token 无效', ReturnCode::TOKEN_INVALID);
throw new ApiException('auth-token invalid', ReturnCode::TOKEN_INVALID);
}
$agentId = trim((string) ($extend['agent_id'] ?? ''));
if ($agentId === '') {
throw new ApiException('auth-token 无效', ReturnCode::TOKEN_INVALID);
throw new ApiException('auth-token invalid', ReturnCode::TOKEN_INVALID);
}
$currentToken = AuthTokenCache::getTokenByAgentId($agentId);
if ($currentToken === null || $currentToken !== $token) {
throw new ApiException('auth-token 无效或已失效', ReturnCode::TOKEN_INVALID);
throw new ApiException('auth-token invalid or expired', ReturnCode::TOKEN_INVALID);
}
$request->agent_id = $agentId;

View File

@@ -32,38 +32,38 @@ class TokenMiddleware implements MiddlewareInterface
}
$token = $token !== null ? trim((string) $token) : '';
if ($token === '') {
throw new ApiException('请携带 token', ReturnCode::UNAUTHORIZED);
throw new ApiException('Please provide token', ReturnCode::UNAUTHORIZED);
}
try {
$decoded = JwtToken::verify(1, $token);
} catch (JwtTokenExpiredException $e) {
throw new ApiException('token 已过期,请重新登录', ReturnCode::TOKEN_INVALID);
throw new ApiException('Token expired, please login again', ReturnCode::TOKEN_INVALID);
} catch (JwtTokenException $e) {
throw new ApiException('token 无效', ReturnCode::TOKEN_INVALID);
throw new ApiException('Invalid or expired token', ReturnCode::TOKEN_INVALID);
} catch (\Throwable $e) {
throw new ApiException('token 格式无效', ReturnCode::TOKEN_INVALID);
throw new ApiException('Token format invalid', ReturnCode::TOKEN_INVALID);
}
$extend = $decoded['extend'] ?? [];
if ((string) ($extend['plat'] ?? '') !== 'api_login') {
throw new ApiException('token 无效', ReturnCode::TOKEN_INVALID);
throw new ApiException('Invalid or expired token', ReturnCode::TOKEN_INVALID);
}
$username = trim((string) ($extend['username'] ?? ''));
if ($username === '') {
throw new ApiException('token 无效', ReturnCode::TOKEN_INVALID);
throw new ApiException('Invalid or expired token', ReturnCode::TOKEN_INVALID);
}
$currentToken = UserCache::getSessionTokenByUsername($username);
if ($currentToken === null || $currentToken === '') {
$player = DicePlayer::where('username', $username)->find();
if (!$player) {
throw new ApiException('请注册', ReturnCode::TOKEN_INVALID);
throw new ApiException('Please register', ReturnCode::TOKEN_INVALID);
}
throw new ApiException('请重新登录', ReturnCode::TOKEN_INVALID);
throw new ApiException('Please login again', ReturnCode::TOKEN_INVALID);
}
if ($currentToken !== $token) {
throw new ApiException('请重新登录(当前账号已在其他处登录)', ReturnCode::TOKEN_INVALID);
throw new ApiException('Please login again (account logged in elsewhere)', ReturnCode::TOKEN_INVALID);
}
// 优先从 Redis 缓存取玩家,避免每次请求都查库
@@ -76,7 +76,7 @@ class TokenMiddleware implements MiddlewareInterface
$player = DicePlayer::where('username', $username)->find();
if (!$player) {
UserCache::deleteSessionByUsername($username);
throw new ApiException('请重新登录', ReturnCode::TOKEN_INVALID);
throw new ApiException('Please login again', ReturnCode::TOKEN_INVALID);
}
UserCache::setPlayerByUsername($username, $player->hidden(['password'])->toArray());
}

View File

@@ -16,7 +16,7 @@ class ApiLang
private const LANG_EN = 'en';
private const LANG_ZH = 'zh';
/** @var array<string, array<string, string>> locale => [ 中文 => 译文 ] */
/** @var array<string, array<string, string>> lang => [ key => message ] */
private static array $messages = [];
/**
@@ -42,21 +42,31 @@ class ApiLang
}
/**
* 翻译文案lang=zh 返回原文中文lang=en 返回英文映射
* 语言文件优先从 Webman resource/translations/api/{locale}.php 加载,否则从 app/api/lang 加载
* 翻译文案(对外接口 message
* - 推荐:抛英文 key如 USER_NOT_FOUND根据 lang 返回对应语言
* - 兼容仍抛中文原文时lang=en 按旧映射翻译,否则原样返回
*
* 语言文件优先从 Webman config('translation.path')/api/{lang}.php 加载
*/
public static function translate(string $message, ?Request $request = null): string
{
$lang = self::getLang($request);
if ($lang !== self::LANG_EN) {
return $message;
$map = self::loadMessages($lang);
if (isset($map[$message])) {
return (string) $map[$message];
}
$map = self::loadMessages(self::LANG_EN);
return $map[$message] ?? $message;
// 若传入的是中文/原文,则按固定规则生成英文 keyMSG_XXXXXXXX再翻译
$key = self::toMsgKey($message);
if ($key !== null && isset($map[$key])) {
return (string) $map[$key];
}
return $message;
}
/**
* 加载某语言的 API 文案key=value=译文
* 加载某语言的 API 文案(推荐:key=value=对应语言文案
*/
private static function loadMessages(string $locale): array
{
@@ -70,13 +80,34 @@ class ApiLang
$path = $base . DIRECTORY_SEPARATOR . 'api' . DIRECTORY_SEPARATOR . $locale . '.php';
}
}
if (($path === null || !is_file($path)) && $locale === self::LANG_EN) {
$path = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . 'en.php';
if ($path !== null && is_file($path)) {
self::$messages[$locale] = require $path;
return self::$messages[$locale];
}
self::$messages[$locale] = ($path !== null && is_file($path)) ? (require $path) : [];
// 回退到 app/api/lang/{lang}.php同样使用英文 key
$fallback = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . $locale . '.php';
self::$messages[$locale] = is_file($fallback) ? (require $fallback) : [];
return self::$messages[$locale];
}
/**
* 将原文转换为英文 key只包含英文字符/数字/下划线MSG_XXXXXXXXcrc32
* 若入参已经是英文 key则返回 null表示无需转换
*/
private static function toMsgKey(string $message): ?string
{
$trim = trim($message);
if ($trim === '') {
return null;
}
// 已经是英文错误码 key只允许 A-Z/0-9/_且至少 3 位)
if (preg_match('/^[A-Z0-9_]{3,}$/', $trim) === 1) {
return null;
}
return 'MSG_' . strtoupper(sprintf('%08X', crc32($trim)));
}
/**
* 带占位符的翻译,如 translateParams('当前玩家余额%s小于%s无法继续游戏', [$coin, $minCoin])
* 先翻译再替换en 文案使用 %s 占位)

View File

@@ -60,7 +60,7 @@ class DiceConfigController extends BaseController
$data = is_array($model) ? $model : $model->toArray();
return $this->success($data);
} else {
return $this->fail('未查找到信息');
return $this->fail('not found');
}
}
@@ -76,9 +76,9 @@ class DiceConfigController extends BaseController
$this->validate('save', $data);
$result = $this->logic->add($data);
if ($result) {
return $this->success('添加成功');
return $this->success('add success');
} else {
return $this->fail('添加失败');
return $this->fail('add failed');
}
}
@@ -94,9 +94,9 @@ class DiceConfigController extends BaseController
$this->validate('update', $data);
$result = $this->logic->edit($data['id'], $data);
if ($result) {
return $this->success('修改成功');
return $this->success('update success');
} else {
return $this->fail('修改失败');
return $this->fail('update failed');
}
}
@@ -110,13 +110,13 @@ class DiceConfigController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$result = $this->logic->destroy($ids);
if ($result) {
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}

View File

@@ -85,7 +85,7 @@ class DiceLotteryPoolConfigController extends BaseController
$data = is_array($model) ? $model : $model->toArray();
return $this->success($data);
} else {
return $this->fail('未查找到信息');
return $this->fail('not found');
}
}
@@ -101,9 +101,9 @@ class DiceLotteryPoolConfigController extends BaseController
$this->validate('save', $data);
$result = $this->logic->add($data);
if ($result) {
return $this->success('添加成功');
return $this->success('add success');
} else {
return $this->fail('添加失败');
return $this->fail('add failed');
}
}
@@ -119,9 +119,9 @@ class DiceLotteryPoolConfigController extends BaseController
$this->validate('update', $data);
$result = $this->logic->edit($data['id'], $data);
if ($result) {
return $this->success('修改成功');
return $this->success('update success');
} else {
return $this->fail('修改失败');
return $this->fail('update failed');
}
}
@@ -135,13 +135,13 @@ class DiceLotteryPoolConfigController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$result = $this->logic->destroy($ids);
if ($result) {
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}
@@ -149,7 +149,7 @@ class DiceLotteryPoolConfigController extends BaseController
* 获取当前彩金池Redis 实例化,无则按 type=0 创建)
* 返回含玩家累计盈利 profit_amount 实时值,供前端轮询展示
*/
#[Permission('色子奖池配置列表', 'dice:lottery_pool_config:index:index')]
#[Permission('色子奖池配置列表', 'dice:lottery_pool_config:index:getCurrentPool')]
public function getCurrentPool(Request $request): Response
{
$data = $this->logic->getCurrentPool();
@@ -159,21 +159,21 @@ class DiceLotteryPoolConfigController extends BaseController
/**
* 更新当前彩金池:仅可修改 safety_line、t1_weightt5_weight不可修改 profit_amount
*/
#[Permission('色子奖池配置修改', 'dice:lottery_pool_config:index:update')]
#[Permission('色子奖池配置修改', 'dice:lottery_pool_config:index:updateCurrentPool')]
public function updateCurrentPool(Request $request): Response
{
$data = $request->post();
$this->logic->updateCurrentPool($data);
return $this->success('保存成功');
return $this->success('save success');
}
/**
* 重置当前彩金池的玩家累计盈利:将 profit_amount 置为 0
*/
#[Permission('色子奖池配置修改', 'dice:lottery_pool_config:index:update')]
#[Permission('色子奖池配置修改', 'dice:lottery_pool_config:index:resetProfitAmount')]
public function resetProfitAmount(Request $request): Response
{
$this->logic->resetProfitAmount();
return $this->success('重置成功');
return $this->success('reset success');
}
}

View File

@@ -120,11 +120,11 @@ class DicePlayRecordController extends BaseController
$id = $request->input('id', '');
$model = $this->logic->read($id);
if (!$model) {
return $this->fail('未查找到信息');
return $this->fail('not found');
}
$allowedIds = AdminScopeHelper::getAllowedAdminIds($this->adminInfo ?? null);
if ($allowedIds !== null && !in_array((int) ($model->admin_id ?? 0), $allowedIds, true)) {
return $this->fail('无权限查看该记录');
return $this->fail('no permission to view this record');
}
$data = is_array($model) ? $model : $model->toArray();
return $this->success($data);
@@ -142,9 +142,9 @@ class DicePlayRecordController extends BaseController
$this->validate('save', $data);
$result = $this->logic->add($data);
if ($result) {
return $this->success('添加成功');
return $this->success('add success');
} else {
return $this->fail('添加失败');
return $this->fail('add failed');
}
}
@@ -160,9 +160,9 @@ class DicePlayRecordController extends BaseController
$this->validate('update', $data);
$result = $this->logic->edit($data['id'], $data);
if ($result) {
return $this->success('修改成功');
return $this->success('update success');
} else {
return $this->fail('修改失败');
return $this->fail('update failed');
}
}
@@ -176,13 +176,13 @@ class DicePlayRecordController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$result = $this->logic->destroy($ids);
if ($result) {
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}

View File

@@ -75,7 +75,7 @@ class DicePlayRecordTestController extends BaseController
$data = is_array($model) ? $model : $model->toArray();
return $this->success($data);
} else {
return $this->fail('未查找到信息');
return $this->fail('not found');
}
}
@@ -91,9 +91,9 @@ class DicePlayRecordTestController extends BaseController
$this->validate('save', $data);
$result = $this->logic->add($data);
if ($result) {
return $this->success('添加成功');
return $this->success('add success');
} else {
return $this->fail('添加失败');
return $this->fail('add failed');
}
}
@@ -109,9 +109,9 @@ class DicePlayRecordTestController extends BaseController
$this->validate('update', $data);
$result = $this->logic->edit($data['id'], $data);
if ($result) {
return $this->success('修改成功');
return $this->success('update success');
} else {
return $this->fail('修改失败');
return $this->fail('update failed');
}
}
@@ -125,13 +125,13 @@ class DicePlayRecordTestController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$result = $this->logic->destroy($ids);
if ($result) {
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}
@@ -146,9 +146,9 @@ class DicePlayRecordTestController extends BaseController
try {
$table = (new \app\dice\model\play_record_test\DicePlayRecordTest())->getTable();
Db::execute('TRUNCATE TABLE `' . $table . '`');
return $this->success('已清空所有测试数据');
return $this->success('all test data cleared');
} catch (\Throwable $e) {
return $this->fail('清空失败:' . $e->getMessage());
return $this->fail('clear failed: ' . $e->getMessage());
}
}
}

View File

@@ -110,11 +110,11 @@ class DicePlayerController extends BaseController
$id = $request->input('id', '');
$model = $this->logic->read($id);
if (!$model) {
return $this->fail('未查找到信息');
return $this->fail('not found');
}
$allowedIds = AdminScopeHelper::getAllowedAdminIds($this->adminInfo ?? null);
if ($allowedIds !== null && !in_array((int) ($model->admin_id ?? 0), $allowedIds, true)) {
return $this->fail('无权限查看该记录');
return $this->fail('no permission to view this record');
}
$data = is_array($model) ? $model : $model->toArray();
return $this->success($data);
@@ -142,9 +142,9 @@ class DicePlayerController extends BaseController
if ($player && $player->username !== '') {
UserCache::deletePlayerByUsername($player->username);
}
return $this->success('添加成功');
return $this->success('add success');
}
return $this->fail('添加失败');
return $this->fail('add failed');
}
/**
@@ -161,7 +161,7 @@ class DicePlayerController extends BaseController
if ($model) {
$allowedIds = AdminScopeHelper::getAllowedAdminIds($this->adminInfo ?? null);
if ($allowedIds !== null && !in_array((int) ($model->admin_id ?? 0), $allowedIds, true)) {
return $this->fail('无权限修改该记录');
return $this->fail('no permission to update this record');
}
}
$result = $this->logic->edit($data['id'], $data);
@@ -172,9 +172,9 @@ class DicePlayerController extends BaseController
if ($player && $player->username !== '') {
UserCache::deletePlayerByUsername($player->username);
}
return $this->success('修改成功');
return $this->success('update success');
}
return $this->fail('修改失败');
return $this->fail('update failed');
}
/**
@@ -188,16 +188,16 @@ class DicePlayerController extends BaseController
$id = $request->input('id');
$status = $request->input('status');
if ($id === null || $id === '') {
return $this->fail('缺少参数 id');
return $this->fail('missing parameter id');
}
if ($status === null || $status === '') {
return $this->fail('缺少参数 status');
return $this->fail('missing parameter status');
}
$model = $this->logic->read($id);
if ($model) {
$allowedIds = AdminScopeHelper::getAllowedAdminIds($this->adminInfo ?? null);
if ($allowedIds !== null && !in_array((int) ($model->admin_id ?? 0), $allowedIds, true)) {
return $this->fail('无权限修改该记录');
return $this->fail('no permission to update this record');
}
}
$this->logic->edit($id, ['status' => (int) $status]);
@@ -207,7 +207,7 @@ class DicePlayerController extends BaseController
if ($player && $player->username !== '') {
UserCache::deletePlayerByUsername($player->username);
}
return $this->success('修改成功');
return $this->success('update success');
}
/**
@@ -220,7 +220,7 @@ class DicePlayerController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$ids = is_array($ids) ? $ids : explode(',', (string) $ids);
$allowedIds = AdminScopeHelper::getAllowedAdminIds($this->adminInfo ?? null);
@@ -235,7 +235,7 @@ class DicePlayerController extends BaseController
}
$ids = $validIds;
if (empty($ids)) {
return $this->fail('无权限删除所选数据');
return $this->fail('no permission to delete selected data');
}
}
$result = $this->logic->destroy($ids);
@@ -248,9 +248,9 @@ class DicePlayerController extends BaseController
UserCache::deletePlayerByUsername($player->username);
}
}
return $this->success('删除成功');
return $this->success('delete success');
}
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}

View File

@@ -88,11 +88,11 @@ class DicePlayerTicketRecordController extends BaseController
$id = $request->input('id', '');
$model = $this->logic->read($id);
if (!$model) {
return $this->fail('未查找到信息');
return $this->fail('not found');
}
$allowedIds = AdminScopeHelper::getAllowedAdminIds($this->adminInfo ?? null);
if ($allowedIds !== null && !in_array((int) ($model->admin_id ?? 0), $allowedIds, true)) {
return $this->fail('无权限查看该记录');
return $this->fail('no permission to view this record');
}
$data = is_array($model) ? $model : $model->toArray();
return $this->success($data);
@@ -110,9 +110,9 @@ class DicePlayerTicketRecordController extends BaseController
$this->validate('save', $data);
$result = $this->logic->add($data);
if ($result) {
return $this->success('添加成功');
return $this->success('add success');
} else {
return $this->fail('添加失败');
return $this->fail('add failed');
}
}
@@ -128,9 +128,9 @@ class DicePlayerTicketRecordController extends BaseController
$this->validate('update', $data);
$result = $this->logic->edit($data['id'], $data);
if ($result) {
return $this->success('修改成功');
return $this->success('update success');
} else {
return $this->fail('修改失败');
return $this->fail('update failed');
}
}
@@ -144,13 +144,13 @@ class DicePlayerTicketRecordController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$result = $this->logic->destroy($ids);
if ($result) {
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}

View File

@@ -85,15 +85,15 @@ class DicePlayerWalletRecordController extends BaseController
{
$playerId = $request->input('player_id');
if ($playerId === null || $playerId === '') {
return $this->fail('缺少 player_id');
return $this->fail('missing player_id');
}
$player = DicePlayer::field('coin,admin_id')->where('id', $playerId)->find();
if (!$player) {
return $this->fail('玩家不存在');
return $this->fail('Player not found');
}
$allowedIds = AdminScopeHelper::getAllowedAdminIds($this->adminInfo ?? null);
if ($allowedIds !== null && !in_array((int) ($player->admin_id ?? 0), $allowedIds, true)) {
return $this->fail('无权限操作该玩家');
return $this->fail('no permission to operate this player');
}
return $this->success(['wallet_before' => (float) $player['coin']]);
}
@@ -109,11 +109,11 @@ class DicePlayerWalletRecordController extends BaseController
$id = $request->input('id', '');
$model = $this->logic->read($id);
if (!$model) {
return $this->fail('未查找到信息');
return $this->fail('not found');
}
$allowedIds = AdminScopeHelper::getAllowedAdminIds($this->adminInfo ?? null);
if ($allowedIds !== null && !in_array((int) ($model->admin_id ?? 0), $allowedIds, true)) {
return $this->fail('无权限查看该记录');
return $this->fail('no permission to view this record');
}
$data = is_array($model) ? $model : $model->toArray();
return $this->success($data);
@@ -133,13 +133,13 @@ class DicePlayerWalletRecordController extends BaseController
$coin = isset($data['coin']) ? (float) $data['coin'] : null;
if ($playerId === null || $playerId === '') {
return $this->fail('请选择玩家');
return $this->fail('please select player');
}
if (!in_array($type, [3, 4], true)) {
return $this->fail('操作类型必须为 3=加点 或 4=扣点');
return $this->fail('operation type must be 3 (add) or 4 (deduct)');
}
if ($coin === null || $coin <= 0) {
return $this->fail('平台币变动必须大于 0');
return $this->fail('Coin change must be greater than 0');
}
$data['player_id'] = $playerId;
@@ -163,20 +163,20 @@ class DicePlayerWalletRecordController extends BaseController
}
}
if ($adminId === null || $adminId <= 0) {
return $this->fail('请先登录');
return $this->fail('please login first');
}
$player = DicePlayer::field('admin_id')->where('id', $playerId)->find();
if ($player) {
$allowedIds = AdminScopeHelper::getAllowedAdminIds($this->adminInfo ?? null);
if ($allowedIds !== null && !in_array((int) ($player->admin_id ?? 0), $allowedIds, true)) {
return $this->fail('无权限操作该玩家');
return $this->fail('no permission to operate this player');
}
}
try {
$this->logic->adminOperate($data, $adminId);
return $this->success('操作成功');
return $this->success('operation success');
} catch (\Throwable $e) {
return $this->fail($e->getMessage());
}
@@ -194,9 +194,9 @@ class DicePlayerWalletRecordController extends BaseController
$this->validate('save', $data);
$result = $this->logic->add($data);
if ($result) {
return $this->success('添加成功');
return $this->success('add success');
} else {
return $this->fail('添加失败');
return $this->fail('add failed');
}
}
@@ -212,9 +212,9 @@ class DicePlayerWalletRecordController extends BaseController
$this->validate('update', $data);
$result = $this->logic->edit($data['id'], $data);
if ($result) {
return $this->success('修改成功');
return $this->success('update success');
} else {
return $this->fail('修改失败');
return $this->fail('update failed');
}
}
@@ -228,13 +228,13 @@ class DicePlayerWalletRecordController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$result = $this->logic->destroy($ids);
if ($result) {
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}

View File

@@ -29,11 +29,11 @@ class DiceRewardController extends BaseController
{
$direction = $request->input('direction', null);
if ($direction === null || $direction === '') {
return $this->fail('请传入 direction0=顺时针 1=逆时针)');
return $this->fail('please provide direction (0=clockwise, 1=counterclockwise)');
}
$direction = (int) $direction;
if (!in_array($direction, [DiceReward::DIRECTION_CLOCKWISE, DiceReward::DIRECTION_COUNTERCLOCKWISE], true)) {
return $this->fail('direction 必须为 0顺时针或 1逆时针');
return $this->fail('direction must be 0 (clockwise) or 1 (counterclockwise)');
}
$tier = $request->input('tier', '');
$page = (int) $request->input('page', 1);
@@ -120,11 +120,11 @@ class DiceRewardController extends BaseController
{
$recordId = (int) $request->input('record_id', 0);
if ($recordId <= 0) {
return $this->fail('请传入 record_id');
return $this->fail('please provide record_id');
}
$record = DiceRewardConfigRecord::find($recordId);
if (!$record) {
return $this->fail('记录不存在');
return $this->fail('record not found');
}
$arr = $record->toArray();
$data = [
@@ -147,9 +147,9 @@ class DiceRewardController extends BaseController
try {
$table = (new DicePlayRecordTest())->getTable();
Db::execute('TRUNCATE TABLE `' . $table . '`');
return $this->success('已清空测试数据');
return $this->success('test data cleared');
} catch (\Throwable $e) {
return $this->fail('清空失败:' . $e->getMessage());
return $this->fail('clear failed: ' . $e->getMessage());
}
}
@@ -162,12 +162,12 @@ class DiceRewardController extends BaseController
{
$items = $request->post('items', []);
if (!is_array($items)) {
return $this->fail('参数 items 必须为数组');
return $this->fail('parameter items must be an array');
}
try {
$logic = new DiceRewardLogic();
$logic->batchUpdateWeights($items);
return $this->success('保存成功');
return $this->success('save success');
} catch (\plugin\saiadmin\exception\ApiException $e) {
return $this->fail($e->getMessage());
}
@@ -182,16 +182,16 @@ class DiceRewardController extends BaseController
{
$direction = (int) $request->post('direction', 0);
if (!in_array($direction, [DiceReward::DIRECTION_CLOCKWISE, DiceReward::DIRECTION_COUNTERCLOCKWISE], true)) {
return $this->fail('direction 必须为 0顺时针或 1逆时针');
return $this->fail('direction must be 0 (clockwise) or 1 (counterclockwise)');
}
$items = $request->post('items', []);
if (!is_array($items)) {
return $this->fail('参数 items 必须为数组');
return $this->fail('parameter items must be an array');
}
try {
$logic = new DiceRewardLogic();
$logic->batchUpdateWeightsByDirection($direction, $items);
return $this->success('保存成功');
return $this->success('save success');
} catch (\plugin\saiadmin\exception\ApiException $e) {
return $this->fail($e->getMessage());
}

View File

@@ -64,7 +64,7 @@ class DiceRewardConfigController extends BaseController
$data = is_array($model) ? $model : $model->toArray();
return $this->success($data);
} else {
return $this->fail('未查找到信息');
return $this->fail('not found');
}
}
@@ -80,9 +80,9 @@ class DiceRewardConfigController extends BaseController
$this->validate('save', $data);
$result = $this->logic->add($data);
if ($result) {
return $this->success('添加成功');
return $this->success('add success');
} else {
return $this->fail('添加失败');
return $this->fail('add failed');
}
}
@@ -98,9 +98,9 @@ class DiceRewardConfigController extends BaseController
$this->validate('update', $data);
$result = $this->logic->edit($data['id'], $data);
if ($result) {
return $this->success('修改成功');
return $this->success('update success');
} else {
return $this->fail('修改失败');
return $this->fail('update failed');
}
}
@@ -114,7 +114,7 @@ class DiceRewardConfigController extends BaseController
{
$items = $request->post('items', []);
if (! is_array($items)) {
return $this->fail('参数 items 必须为数组');
return $this->fail('parameter items must be an array');
}
$err = $this->logic->validateBatchUpdateItems($items);
if ($err !== null) {
@@ -124,7 +124,7 @@ class DiceRewardConfigController extends BaseController
$this->validate('batch_update', array_merge($item, ['id' => $item['id']]));
}
$this->logic->batchUpdate($items);
return $this->success('保存成功');
return $this->success('save success');
}
/**
@@ -137,13 +137,13 @@ class DiceRewardConfigController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$result = $this->logic->destroy($ids);
if ($result) {
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}
@@ -171,12 +171,12 @@ class DiceRewardConfigController extends BaseController
{
$items = $request->post('items', []);
if (!is_array($items)) {
return $this->fail('参数 items 必须为数组');
return $this->fail('parameter items must be an array');
}
try {
$rewardLogic = new DiceRewardLogic();
$rewardLogic->batchUpdateWeights($items);
return $this->success('保存成功');
return $this->success('save success');
} catch (\plugin\saiadmin\exception\ApiException $e) {
return $this->fail($e->getMessage());
}
@@ -193,14 +193,14 @@ class DiceRewardConfigController extends BaseController
{
$items = $request->post('items', []);
if (! is_array($items)) {
return $this->fail('参数 items 必须为数组');
return $this->fail('parameter items must be an array');
}
$err = $this->logic->validateBigwinWeightItems($items);
if ($err !== null) {
return $this->fail($err);
}
$this->logic->batchUpdateBigwinWeight($items);
return $this->success('保存成功');
return $this->success('save success');
}
/**
@@ -215,7 +215,7 @@ class DiceRewardConfigController extends BaseController
try {
$rewardLogic = new DiceRewardLogic();
$result = $rewardLogic->createRewardReferenceFromConfig();
return $this->success($result, '创建奖励对照成功');
return $this->success($result, 'create reward mapping success');
} catch (\plugin\saiadmin\exception\ApiException $e) {
return $this->fail($e->getMessage());
}

View File

@@ -59,7 +59,7 @@ class DiceRewardConfigRecordController extends BaseController
$data['admin_name'] = $this->getAdminName((int) ($data['admin_id'] ?? 0));
return $this->success($data);
} else {
return $this->fail('未查找到信息');
return $this->fail('not found');
}
}
@@ -96,9 +96,9 @@ class DiceRewardConfigRecordController extends BaseController
$this->validate('save', $data);
$result = $this->logic->add($data);
if ($result) {
return $this->success('添加成功');
return $this->success('add success');
} else {
return $this->fail('添加失败');
return $this->fail('add failed');
}
}
@@ -114,9 +114,9 @@ class DiceRewardConfigRecordController extends BaseController
$this->validate('update', $data);
$result = $this->logic->edit($data['id'], $data);
if ($result) {
return $this->success('修改成功');
return $this->success('update success');
} else {
return $this->fail('修改失败');
return $this->fail('update failed');
}
}
@@ -130,13 +130,13 @@ class DiceRewardConfigRecordController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$result = $this->logic->destroy($ids);
if ($result) {
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}
@@ -149,7 +149,7 @@ class DiceRewardConfigRecordController extends BaseController
{
$recordId = (int) $request->post('record_id', 0);
if ($recordId <= 0) {
return $this->fail('请指定测试记录');
return $this->fail('please specify test record');
}
$paidId = $request->post('paid_lottery_config_id', null);
$freeId = $request->post('free_lottery_config_id', null);
@@ -159,7 +159,7 @@ class DiceRewardConfigRecordController extends BaseController
$lotteryConfigId = $legacyId !== null && $legacyId !== '' ? (int) $legacyId : null;
try {
$this->logic->importFromRecord($recordId, $paidLotteryConfigId, $freeLotteryConfigId, $lotteryConfigId);
return $this->success('导入成功,已刷新 DiceRewardDiceRewardConfig(BIGWIN)、奖池配置');
return $this->success('import success, refreshed DiceReward, DiceRewardConfig(BIGWIN), and pool config');
} catch (\plugin\saiadmin\exception\ApiException $e) {
return $this->fail($e->getMessage());
}

View File

@@ -40,7 +40,7 @@ class DiceLotteryPoolConfigLogic extends BaseLogic
{
$configType0 = DiceLotteryPoolConfig::where('name', 'default')->find();
if (!$configType0) {
throw new ApiException('未找到 name=default 的奖池配置,请先创建');
throw new ApiException('No name=default pool config found, please create one first');
}
$configType1 = DiceLotteryPoolConfig::where('name', 'killScore')->find();
$row0 = $configType0->toArray();

View File

@@ -50,20 +50,20 @@ class DicePlayerWalletRecordLogic extends BaseLogic
$coin = (float) ($data['coin'] ?? 0);
if ($playerId <= 0 || !in_array($type, [3, 4], true)) {
throw new ApiException('参数错误:需要有效的 player_id type3=加点4=扣点)');
throw new ApiException('Invalid params: player_id and type are required (3=add, 4=deduct)');
}
if ($coin <= 0) {
throw new ApiException('平台币变动必须大于 0');
throw new ApiException('Coin change must be greater than 0');
}
$player = DicePlayer::where('id', $playerId)->find();
if (!$player) {
throw new ApiException('玩家不存在');
throw new ApiException('Player not found');
}
$walletBefore = (float) ($player['coin'] ?? 0);
if ($type === 4 && $walletBefore < $coin) {
throw new ApiException('扣点数量不能大于当前余额');
throw new ApiException('Deduct amount cannot exceed current balance');
}
$walletAfter = $type === 3 ? $walletBefore + $coin : $walletBefore - $coin;

View File

@@ -86,7 +86,7 @@ class DiceRewardLogic
$id = isset($item['id']) ? (int) $item['id'] : 0;
$weight = isset($item['weight']) ? (int) $item['weight'] : self::WEIGHT_MIN;
if ($id <= 0) {
throw new ApiException('存在无效的配置ID');
throw new ApiException('Invalid config ID exists');
}
$weight = max(self::WEIGHT_MIN, min(self::WEIGHT_MAX, $weight));
@@ -199,7 +199,7 @@ class DiceRewardLogic
$id = isset($item['reward_id']) ? (int) $item['reward_id'] : 0;
}
if ($id <= 0) {
throw new ApiException('存在无效的 DiceReward id');
throw new ApiException('Invalid DiceReward id exists');
}
$weight = isset($item['weight']) ? (int) $item['weight'] : self::WEIGHT_MIN;
$weight = max(self::WEIGHT_MIN, min(self::WEIGHT_MAX, $weight));
@@ -313,7 +313,7 @@ class DiceRewardLogic
{
$list = DiceRewardConfig::order('id', 'asc')->select()->toArray();
if (empty($list)) {
throw new ApiException('奖励配置为空,请先维护 dice_reward_config');
throw new ApiException('Reward config is empty, please maintain dice_reward_config first');
}
$configCount = count($list);
if ($configCount < self::BOARD_SIZE) {

View File

@@ -319,7 +319,7 @@ class DiceRewardConfigLogic extends BaseLogic
{
$allowedCounts = [100, 500, 1000, 5000, 10000];
if (!in_array($testCount, $allowedCounts, true)) {
throw new ApiException('测试次数仅支持 1005001000500010000');
throw new ApiException('Test count only supports 100, 500, 1000, 5000, 10000');
}
$grouped = [];

View File

@@ -81,7 +81,7 @@ class DiceRewardConfigRecordLogic extends BaseLogic
{
$record = $this->model->find($recordId);
if (!$record) {
throw new ApiException('测试记录不存在');
throw new ApiException('Test record not found');
}
$record = is_array($record) ? $record : $record->toArray();
@@ -195,7 +195,7 @@ class DiceRewardConfigRecordLogic extends BaseLogic
if (is_array($paidData) && $paidTargetId > 0) {
$pool = DiceLotteryPoolConfig::find($paidTargetId);
if (!$pool) {
throw new ApiException('付费奖池配置不存在');
throw new ApiException('Paid pool config not found');
}
$update = [
't1_weight' => (int) ($paidData['T1'] ?? $paidData['t1'] ?? 0),
@@ -209,7 +209,7 @@ class DiceRewardConfigRecordLogic extends BaseLogic
if (is_array($freeData) && $freeTargetId > 0) {
$pool = DiceLotteryPoolConfig::find($freeTargetId);
if (!$pool) {
throw new ApiException('免费奖池配置不存在');
throw new ApiException('Free pool config not found');
}
$update = [
't1_weight' => (int) ($freeData['T1'] ?? $freeData['t1'] ?? 0),
@@ -264,12 +264,12 @@ class DiceRewardConfigRecordLogic extends BaseLogic
foreach ([$paidS, $paidN, $freeS, $freeN] as $c) {
if ($c !== 0 && !in_array($c, $allowed, true)) {
throw new ApiException('各抽奖次数仅支持 0、10050010005000');
throw new ApiException('Counts only support 0, 100, 500, 1000, 5000');
}
}
$total = $paidS + $paidN + $freeS + $freeN;
if ($total <= 0) {
throw new ApiException('付费或免费至少一种方向次数之和大于 0');
throw new ApiException('Sum of paid/free direction counts must be greater than 0');
}
$snapshot = [];
@@ -314,7 +314,7 @@ class DiceRewardConfigRecordLogic extends BaseLogic
if ($paidConfigId > 0) {
$config = DiceLotteryPoolConfig::find($paidConfigId);
if (!$config) {
throw new ApiException('付费奖池配置不存在');
throw new ApiException('Paid pool config not found');
}
$tierWeightsSnapshot['paid'] = [
'T1' => (int) ($config->t1_weight ?? 0),
@@ -326,19 +326,19 @@ class DiceRewardConfigRecordLogic extends BaseLogic
} else {
$paidTierWeights = $params['paid_tier_weights'] ?? null;
if (!is_array($paidTierWeights)) {
throw new ApiException('付费未选择奖池配置时,请填写付费自定义档位概率(T1T5');
throw new ApiException('When paid pool is not selected, please fill paid custom tier probabilities (T1T5)');
}
$tiers = ['T1', 'T2', 'T3', 'T4', 'T5'];
foreach ($tiers as $t) {
$v = (int) ($paidTierWeights[$t] ?? 0);
if ($v < 0 || $v > 100) {
throw new ApiException('付费档位概率每档只能 0-100%');
throw new ApiException('Paid tier probability must be between 0 and 100%');
}
$paidTierWeights[$t] = $v;
}
$paidSum = array_sum(array_intersect_key($paidTierWeights, array_flip($tiers)));
if ($paidSum > 100) {
throw new ApiException('付费档位概率 T1T5 之和不能超过 100%');
throw new ApiException('Paid tier probabilities (T1T5) sum cannot exceed 100%');
}
$tierWeightsSnapshot['paid'] = $paidTierWeights;
}
@@ -346,7 +346,7 @@ class DiceRewardConfigRecordLogic extends BaseLogic
if ($freeConfigId > 0) {
$config = DiceLotteryPoolConfig::find($freeConfigId);
if (!$config) {
throw new ApiException('免费奖池配置不存在');
throw new ApiException('Free pool config not found');
}
$tierWeightsSnapshot['free'] = [
'T1' => (int) ($config->t1_weight ?? 0),
@@ -358,19 +358,19 @@ class DiceRewardConfigRecordLogic extends BaseLogic
} else {
$freeTierWeights = $params['free_tier_weights'] ?? null;
if (!is_array($freeTierWeights)) {
throw new ApiException('免费未选择奖池配置时,请填写免费自定义档位概率(T1T5');
throw new ApiException('When free pool is not selected, please fill free custom tier probabilities (T1T5)');
}
$tiers = ['T1', 'T2', 'T3', 'T4', 'T5'];
foreach ($tiers as $t) {
$v = (int) ($freeTierWeights[$t] ?? 0);
if ($v < 0 || $v > 100) {
throw new ApiException('免费档位概率每档只能 0-100%');
throw new ApiException('Free tier probability must be between 0 and 100%');
}
$freeTierWeights[$t] = $v;
}
$freeSum = array_sum(array_intersect_key($freeTierWeights, array_flip($tiers)));
if ($freeSum > 100) {
throw new ApiException('免费档位概率 T1T5 之和不能超过 100%');
throw new ApiException('Free tier probabilities (T1T5) sum cannot exceed 100%');
}
$tierWeightsSnapshot['free'] = $freeTierWeights;
}

View File

@@ -63,7 +63,7 @@ class InstallController extends OpenController
clearstatcache();
if (is_file($env)) {
return $this->fail('管理后台已经安装如需重新安装请删除根目录env配置文件并重启');
return $this->fail('admin already installed, to reinstall please delete env file and restart');
}
$user = $request->post('username');
@@ -82,13 +82,13 @@ class InstallController extends OpenController
} catch (\Throwable $e) {
$message = $e->getMessage();
if (stripos($message, 'Access denied for user')) {
return $this->fail('数据库用户名或密码错误');
return $this->fail('database username or password is incorrect');
}
if (stripos($message, 'Connection refused')) {
return $this->fail('Connection refused. 请确认数据库IP端口是否正确数据库已经启动');
return $this->fail('connection refused, please check database ip/port and ensure database is running');
}
if (stripos($message, 'timed out')) {
return $this->fail('数据库连接超时请确认数据库IP端口是否正确安全组及防火墙已经放行端口');
return $this->fail('database connection timeout, please check ip/port and firewall/security group rules');
}
throw $e;
}
@@ -98,7 +98,7 @@ class InstallController extends OpenController
$smt = $db->query("show tables like 'sa_system_menu';");
$tables = $smt->fetchAll();
if (count($tables) > 0) {
return $this->fail('数据库已经安装,请勿重复安装');
return $this->fail('database already installed, please do not install again');
}
if ($dataType == 'demo') {
@@ -108,7 +108,7 @@ class InstallController extends OpenController
}
if (!is_file($sql_file)) {
return $this->fail('数据库SQL文件不存在');
return $this->fail('database SQL file not found');
}
$sql_query = file_get_contents($sql_file);
@@ -151,7 +151,7 @@ EOF;
restore_error_handler();
}
return $this->success('安装成功');
return $this->success('install success');
}
/**

View File

@@ -53,7 +53,7 @@ class LoginController extends BaseController
if ($captchaEnabled) {
$captcha = new Captcha();
if (!$captcha->checkCaptcha($uuid, $code)) {
return $this->fail('验证码错误');
return $this->fail('captcha error');
}
}
$logic = new SystemUserLogic();

View File

@@ -37,14 +37,14 @@ class SystemController extends BaseController
if ($adminInfo === null || !is_array($adminInfo) || !isset($adminInfo['id'])) {
$token = getCurrentInfo();
if (!is_array($token) || empty($token['id'])) {
return $this->fail('登录已过期或用户信息无效,请重新登录', 401);
return $this->fail('login expired or invalid, please login again', 401);
}
$adminInfo = UserInfoCache::getUserInfo($token['id']);
if (empty($adminInfo) || !isset($adminInfo['id'])) {
$adminInfo = UserInfoCache::setUserInfo($token['id']);
}
if (empty($adminInfo) || !isset($adminInfo['id'])) {
return $this->fail('登录已过期或用户信息无效,请重新登录', 401);
return $this->fail('login expired or invalid, please login again', 401);
}
$this->adminInfo = $adminInfo;
}
@@ -86,7 +86,7 @@ class SystemController extends BaseController
public function menu(): Response
{
if (!$this->ensureAdminInfo()) {
return $this->fail('登录已过期或用户信息无效,请重新登录', 401);
return $this->fail('login expired or invalid, please login again', 401);
}
$data = UserMenuCache::getUserMenu($this->adminInfo['id']);
return $this->success($data);
@@ -151,7 +151,7 @@ class SystemController extends BaseController
$config = Storage::getConfig('local');
$logic = new SystemAttachmentLogic();
$data = $logic->saveNetworkImage($url, $config);
return $this->success($data, '操作成功');
return $this->success($data, 'operation success');
}
/**
@@ -228,7 +228,7 @@ class SystemController extends BaseController
UserInfoCache::clearUserInfo($this->adminId);
UserAuthCache::clearUserAuth($this->adminId);
UserMenuCache::clearUserMenu($this->adminId);
return $this->success([], '清除缓存成功!');
return $this->success([], 'clear cache success');
}
/**

View File

@@ -78,11 +78,11 @@ class DataBaseController extends BaseController
if (!empty($ids)) {
$result = $this->logic->delete($table, $ids);
if (!$result) {
return $this->fail('操作失败');
return $this->fail('operation failed');
}
return $this->success('操作成功');
return $this->success('operation success');
} else {
return $this->fail('参数错误,请检查');
return $this->fail('invalid parameters, please check');
}
}
@@ -99,11 +99,11 @@ class DataBaseController extends BaseController
if (!empty($ids)) {
$result = $this->logic->recovery($table, $ids);
if (!$result) {
return $this->fail('操作失败');
return $this->fail('operation failed');
}
return $this->success('操作成功');
return $this->success('operation success');
} else {
return $this->fail('参数错误,请检查');
return $this->fail('invalid parameters, please check');
}
}
@@ -130,7 +130,7 @@ class DataBaseController extends BaseController
{
$tables = $request->input('tables', []);
$this->logic->optimizeTable($tables);
return $this->success('优化成功');
return $this->success('optimize success');
}
/**
@@ -141,7 +141,7 @@ class DataBaseController extends BaseController
{
$tables = $request->input('tables', []);
$this->logic->fragmentTable($tables);
return $this->success('清理成功');
return $this->success('clean success');
}
}

View File

@@ -57,9 +57,9 @@ class SystemAttachmentController extends BaseController
$data = $request->post();
$result = $this->logic->edit($data['id'], ['origin_name' => $data['origin_name']]);
if ($result) {
return $this->success('修改成功');
return $this->success('update success');
} else {
return $this->fail('修改失败');
return $this->fail('update failed');
}
}
@@ -73,13 +73,13 @@ class SystemAttachmentController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$result = $this->logic->destroy($ids);
if ($result) {
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}
@@ -94,13 +94,13 @@ class SystemAttachmentController extends BaseController
$category_id = $request->post('category_id', '');
$ids = $request->post('ids', '');
if (empty($ids) || empty($category_id)) {
return $this->fail('参数错误,请检查参数');
return $this->fail('invalid parameters, please check');
}
$result = $this->logic->move($category_id, $ids);
if ($result) {
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}

View File

@@ -57,7 +57,7 @@ class SystemCategoryController extends BaseController
$data = is_array($model) ? $model : $model->toArray();
return $this->success($data);
} else {
return $this->fail('未查找到信息');
return $this->fail('not found');
}
}
@@ -73,9 +73,9 @@ class SystemCategoryController extends BaseController
$this->validate('save', $data);
$result = $this->logic->add($data);
if ($result) {
return $this->success('添加成功');
return $this->success('add success');
} else {
return $this->fail('添加失败');
return $this->fail('add failed');
}
}
@@ -91,9 +91,9 @@ class SystemCategoryController extends BaseController
$this->validate('update', $data);
$result = $this->logic->edit($data['id'], $data);
if ($result) {
return $this->success('修改成功');
return $this->success('update success');
} else {
return $this->fail('修改失败');
return $this->fail('update failed');
}
}
@@ -107,13 +107,13 @@ class SystemCategoryController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$result = $this->logic->destroy($ids);
if ($result) {
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}

View File

@@ -62,9 +62,9 @@ class SystemConfigController extends BaseController
$this->validate('save', $data);
$result = $this->logic->add($data);
if ($result) {
return $this->success('添加成功');
return $this->success('add success');
} else {
return $this->fail('添加失败');
return $this->fail('add failed');
}
}
@@ -80,9 +80,9 @@ class SystemConfigController extends BaseController
$this->validate('update', $data);
$result = $this->logic->edit($data['id'], $data);
if ($result) {
return $this->success('修改成功');
return $this->success('update success');
} else {
return $this->fail('修改失败');
return $this->fail('update failed');
}
}
@@ -96,13 +96,13 @@ class SystemConfigController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$result = $this->logic->destroy($ids);
if ($result) {
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}
@@ -117,10 +117,10 @@ class SystemConfigController extends BaseController
$group_id = $request->post('group_id');
$config = $request->post('config');
if (empty($group_id) || empty($config)) {
return $this->fail('参数错误');
return $this->fail('Invalid parameters');
}
$this->logic->batchUpdate($group_id, $config);
return $this->success('操作成功');
return $this->success('operation success');
}
}

View File

@@ -61,9 +61,9 @@ class SystemConfigGroupController extends BaseController
$this->validate('save', $data);
$result = $this->logic->add($data);
if ($result) {
return $this->success('添加成功');
return $this->success('add success');
} else {
return $this->fail('添加失败');
return $this->fail('add failed');
}
}
@@ -80,9 +80,9 @@ class SystemConfigGroupController extends BaseController
$result = $this->logic->edit($data['id'], $data);
if ($result) {
ConfigCache::clearConfig($data['code']);
return $this->success('修改成功');
return $this->success('update success');
} else {
return $this->fail('修改失败');
return $this->fail('update failed');
}
}
@@ -96,13 +96,13 @@ class SystemConfigGroupController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$result = $this->logic->destroy($ids);
if ($result) {
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}
@@ -116,7 +116,7 @@ class SystemConfigGroupController extends BaseController
{
$email = $request->input('email', '');
if (empty($email)) {
return $this->fail('请输入邮箱');
return $this->fail('please input email');
}
$subject = "测试邮件";
$code = "9527";
@@ -137,11 +137,11 @@ class SystemConfigGroupController extends BaseController
$model->status = 'failure';
$model->response = $result;
$model->save();
return $this->fail('发送失败,请查看日志');
return $this->fail('send failed, please check logs');
} else {
$model->status = 'success';
$model->save();
return $this->success([], '发送成功');
return $this->success([], 'send success');
}
} catch (\Exception $e) {
$model->status = 'failure';

View File

@@ -59,7 +59,7 @@ class SystemDeptController extends BaseController
$data = is_array($model) ? $model : $model->toArray();
return $this->success($data);
} else {
return $this->fail('未查找到信息');
return $this->fail('not found');
}
}
@@ -75,9 +75,9 @@ class SystemDeptController extends BaseController
$this->validate('save', $data);
$result = $this->logic->add($data);
if ($result) {
return $this->success('添加成功');
return $this->success('add success');
} else {
return $this->fail('添加失败');
return $this->fail('add failed');
}
}
@@ -93,9 +93,9 @@ class SystemDeptController extends BaseController
$this->validate('update', $data);
$result = $this->logic->edit($data['id'], $data);
if ($result) {
return $this->success('修改成功');
return $this->success('update success');
} else {
return $this->fail('修改失败');
return $this->fail('update failed');
}
}
@@ -109,13 +109,13 @@ class SystemDeptController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$result = $this->logic->destroy($ids);
if ($result) {
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}

View File

@@ -63,9 +63,9 @@ class SystemDictDataController extends BaseController
$result = $this->logic->add($data);
if ($result) {
DictCache::clear();
return $this->success('添加成功');
return $this->success('add success');
} else {
return $this->fail('添加失败');
return $this->fail('add failed');
}
}
@@ -82,9 +82,9 @@ class SystemDictDataController extends BaseController
$result = $this->logic->edit($data['id'], $data);
if ($result) {
DictCache::clear();
return $this->success('修改成功');
return $this->success('update success');
} else {
return $this->fail('修改失败');
return $this->fail('update failed');
}
}
@@ -98,14 +98,14 @@ class SystemDictDataController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$result = $this->logic->destroy($ids);
if ($result) {
DictCache::clear();
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}

View File

@@ -61,9 +61,9 @@ class SystemDictTypeController extends BaseController
$result = $this->logic->add($data);
if ($result) {
DictCache::clear();
return $this->success('添加成功');
return $this->success('add success');
} else {
return $this->fail('添加失败');
return $this->fail('add failed');
}
}
@@ -80,9 +80,9 @@ class SystemDictTypeController extends BaseController
$result = $this->logic->edit($data['id'], $data);
if ($result) {
DictCache::clear();
return $this->success('修改成功');
return $this->success('update success');
} else {
return $this->fail('修改失败');
return $this->fail('update failed');
}
}
@@ -96,14 +96,14 @@ class SystemDictTypeController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$result = $this->logic->destroy($ids);
if ($result) {
DictCache::clear();
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}

View File

@@ -51,9 +51,9 @@ class SystemLogController extends BaseController
$logic = new SystemLoginLogLogic();
if (!empty($ids)) {
$logic->destroy($ids);
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('参数错误,请检查');
return $this->fail('invalid parameters, please check');
}
}
@@ -91,9 +91,9 @@ class SystemLogController extends BaseController
$logic = new SystemOperLogLogic();
if (!empty($ids)) {
$logic->destroy($ids);
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('参数错误,请检查');
return $this->fail('invalid parameters, please check');
}
}

View File

@@ -59,13 +59,13 @@ class SystemMailController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$result = $this->logic->destroy($ids);
if ($result) {
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}

View File

@@ -61,7 +61,7 @@ class SystemMenuController extends BaseController
$data = is_array($model) ? $model : $model->toArray();
return $this->success($data);
} else {
return $this->fail('未查找到信息');
return $this->fail('not found');
}
}
@@ -78,9 +78,9 @@ class SystemMenuController extends BaseController
$result = $this->logic->add($data);
if ($result) {
UserMenuCache::clearMenuCache();
return $this->success('添加成功');
return $this->success('add success');
} else {
return $this->fail('添加失败');
return $this->fail('add failed');
}
}
@@ -97,9 +97,9 @@ class SystemMenuController extends BaseController
$result = $this->logic->edit($data['id'], $data);
if ($result) {
UserMenuCache::clearMenuCache();
return $this->success('修改成功');
return $this->success('update success');
} else {
return $this->fail('修改失败');
return $this->fail('update failed');
}
}
@@ -113,14 +113,14 @@ class SystemMenuController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$result = $this->logic->destroy($ids);
if ($result) {
UserMenuCache::clearMenuCache();
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}

View File

@@ -60,7 +60,7 @@ class SystemPostController extends BaseController
$data = is_array($model) ? $model : $model->toArray();
return $this->success($data);
} else {
return $this->fail('未查找到信息');
return $this->fail('not found');
}
}
@@ -76,9 +76,9 @@ class SystemPostController extends BaseController
$this->validate('save', $data);
$result = $this->logic->add($data);
if ($result) {
return $this->success('添加成功');
return $this->success('add success');
} else {
return $this->fail('添加失败');
return $this->fail('add failed');
}
}
@@ -94,9 +94,9 @@ class SystemPostController extends BaseController
$this->validate('update', $data);
$result = $this->logic->edit($data['id'], $data);
if ($result) {
return $this->success('修改成功');
return $this->success('update success');
} else {
return $this->fail('修改失败');
return $this->fail('update failed');
}
}
@@ -110,13 +110,13 @@ class SystemPostController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$result = $this->logic->destroy($ids);
if ($result) {
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}
@@ -130,10 +130,10 @@ class SystemPostController extends BaseController
{
$file = current($request->file());
if (!$file || !$file->isValid()) {
return $this->fail('未找到上传文件');
return $this->fail('uploaded file not found');
}
$this->logic->import($file);
return $this->success('导入成功');
return $this->success('import success');
}
/**

View File

@@ -66,7 +66,7 @@ class SystemRoleController extends BaseController
$data = is_array($model) ? $model : $model->toArray();
return $this->success($data);
} else {
return $this->fail('未查找到信息');
return $this->fail('not found');
}
}
@@ -82,9 +82,9 @@ class SystemRoleController extends BaseController
$this->validate('save', $data);
$result = $this->logic->add($data);
if ($result) {
return $this->success('添加成功');
return $this->success('add success');
} else {
return $this->fail('添加失败');
return $this->fail('add failed');
}
}
@@ -100,9 +100,9 @@ class SystemRoleController extends BaseController
$this->validate('update', $data);
$result = $this->logic->edit($data['id'], $data);
if ($result) {
return $this->success('修改成功');
return $this->success('update success');
} else {
return $this->fail('修改失败');
return $this->fail('update failed');
}
}
@@ -116,13 +116,13 @@ class SystemRoleController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$result = $this->logic->destroy($ids);
if ($result) {
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}
@@ -150,7 +150,7 @@ class SystemRoleController extends BaseController
$id = $request->post('id');
$menu_ids = $request->post('menu_ids');
$this->logic->saveMenuPermission($id, $menu_ids);
return $this->success('操作成功');
return $this->success('operation success');
}
/**

View File

@@ -75,11 +75,11 @@ class SystemServerController extends BaseController
{
$tag = $request->input('tag', '');
if (empty($tag)) {
return $this->fail('请选择要删除的缓存');
return $this->fail('please select cache to delete');
}
Cache::tag($tag)->clear();
Cache::delete($tag);
return $this->success('删除成功');
return $this->success('delete success');
}
}

View File

@@ -65,7 +65,7 @@ class SystemUserController extends BaseController
$data = is_array($model) ? $model : $model->toArray();
return $this->success($data);
} else {
return $this->fail('未查找到信息');
return $this->fail('not found');
}
}
@@ -81,9 +81,9 @@ class SystemUserController extends BaseController
$this->validate('save', $data);
$result = $this->logic->add($data);
if ($result) {
return $this->success('添加成功');
return $this->success('add success');
} else {
return $this->fail('添加失败');
return $this->fail('add failed');
}
}
@@ -99,9 +99,9 @@ class SystemUserController extends BaseController
$this->validate('update', $data);
$result = $this->logic->edit($data['id'], $data);
if ($result) {
return $this->success('修改成功');
return $this->success('update success');
} else {
return $this->fail('修改失败');
return $this->fail('update failed');
}
}
@@ -116,9 +116,9 @@ class SystemUserController extends BaseController
$ids = $request->input('ids', '');
if (!empty($ids)) {
$this->logic->destroy($ids);
return $this->success('操作成功');
return $this->success('operation success');
} else {
return $this->fail('参数错误,请检查');
return $this->fail('invalid parameters, please check');
}
}
@@ -134,7 +134,7 @@ class SystemUserController extends BaseController
UserInfoCache::clearUserInfo($id);
UserAuthCache::clearUserAuth($id);
UserMenuCache::clearUserMenu($id);
return $this->success('操作成功');
return $this->success('operation success');
}
/**
@@ -148,12 +148,12 @@ class SystemUserController extends BaseController
$id = $request->post('id', '');
$password = $request->post('password', '');
if ($id == 1) {
return $this->fail('超级管理员不允许重置密码');
return $this->fail('super admin cannot reset password');
}
$data = ['password' => password_hash($password, PASSWORD_DEFAULT)];
$this->logic->authEdit($id, $data);
UserInfoCache::clearUserInfo($id);
return $this->success('操作成功');
return $this->success('operation success');
}
/**
@@ -169,7 +169,7 @@ class SystemUserController extends BaseController
$data = ['dashboard' => $dashboard];
$this->logic->authEdit($id, $data);
UserInfoCache::clearUserInfo($id);
return $this->success('操作成功');
return $this->success('operation success');
}
/**
@@ -187,9 +187,9 @@ class SystemUserController extends BaseController
$result = $this->logic->updateInfo($this->adminId, $data);
if ($result) {
UserInfoCache::clearUserInfo($this->adminId);
return $this->success('操作成功');
return $this->success('operation success');
} else {
return $this->fail('操作失败');
return $this->fail('operation failed');
}
}
@@ -205,6 +205,6 @@ class SystemUserController extends BaseController
$newPassword = $request->input('newPassword');
$this->logic->modifyPassword($this->adminId, $oldPassword, $newPassword);
UserInfoCache::clearUserInfo($this->adminId);
return $this->success('修改成功');
return $this->success('update success');
}
}

View File

@@ -61,9 +61,9 @@ class CrontabController extends BaseController
$this->validate('save', $data);
$result = $this->logic->add($data);
if ($result) {
return $this->success('添加成功');
return $this->success('add success');
} else {
return $this->fail('添加失败');
return $this->fail('add failed');
}
}
@@ -79,9 +79,9 @@ class CrontabController extends BaseController
$this->validate('update', $data);
$result = $this->logic->edit($data['id'], $data);
if ($result) {
return $this->success('修改成功');
return $this->success('update success');
} else {
return $this->fail('修改失败');
return $this->fail('update failed');
}
}
@@ -95,13 +95,13 @@ class CrontabController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$result = $this->logic->destroy($ids);
if ($result) {
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}
@@ -116,13 +116,13 @@ class CrontabController extends BaseController
$id = $request->input('id', '');
$status = $request->input('status', 1);
if (empty($id)) {
return $this->fail('参数错误,请检查');
return $this->fail('invalid parameters, please check');
}
$result = $this->logic->changeStatus($id, $status);
if ($result) {
return $this->success('操作成功');
return $this->success('operation success');
} else {
return $this->fail('操作失败');
return $this->fail('operation failed');
}
}
@@ -137,9 +137,9 @@ class CrontabController extends BaseController
$id = $request->input('id', '');
$result = $this->logic->run($id);
if ($result) {
return $this->success('执行成功');
return $this->success('execute success');
} else {
return $this->fail('执行失败');
return $this->fail('execution failed');
}
}
@@ -173,9 +173,9 @@ class CrontabController extends BaseController
if (!empty($ids)) {
$logic = new CrontabLogLogic();
$logic->destroy($ids);
return $this->success('操作成功');
return $this->success('operation success');
} else {
return $this->fail('参数错误,请检查');
return $this->fail('invalid parameters, please check');
}
}
}

View File

@@ -59,7 +59,7 @@ class GenerateTablesController extends BaseController
$data = is_array($model) ? $model : $model->toArray();
return $this->success($data);
} else {
return $this->fail('未查找到信息');
return $this->fail('not found');
}
}
@@ -75,9 +75,9 @@ class GenerateTablesController extends BaseController
$this->validate('update', $data);
$result = $this->logic->edit($data['id'], $data);
if ($result) {
return $this->success('修改成功');
return $this->success('update success');
} else {
return $this->fail('修改失败');
return $this->fail('update failed');
}
}
@@ -91,13 +91,13 @@ class GenerateTablesController extends BaseController
{
$ids = $request->post('ids', '');
if (empty($ids)) {
return $this->fail('请选择要删除的数据');
return $this->fail('please select data to delete');
}
$result = $this->logic->destroy($ids);
if ($result) {
return $this->success('删除成功');
return $this->success('delete success');
} else {
return $this->fail('删除失败');
return $this->fail('delete failed');
}
}
@@ -112,7 +112,7 @@ class GenerateTablesController extends BaseController
$names = $request->input('names', []);
$source = $request->input('source', '');
$this->logic->loadTable($names, $source);
return $this->success('操作成功');
return $this->success('operation success');
}
/**
@@ -125,7 +125,7 @@ class GenerateTablesController extends BaseController
{
$id = $request->input('id', '');
$this->logic->sync($id);
return $this->success('操作成功');
return $this->success('operation success');
}
/**
@@ -159,7 +159,7 @@ class GenerateTablesController extends BaseController
$id = $request->input('id', '');
$this->logic->generateFile($id);
UserMenuCache::clearMenuCache();
return $this->success('操作成功');
return $this->success('operation success');
}
/**

View File

@@ -68,7 +68,7 @@ if (!function_exists('downloadFile')) {
if (file_exists($base_dir . DIRECTORY_SEPARATOR . $file_name)) {
return response()->download($base_dir . DIRECTORY_SEPARATOR . $file_name, urlencode($file_name));
} else {
throw new ApiException('模板不存在');
throw new ApiException('Template not found');
}
}
}

View File

@@ -158,7 +158,7 @@ class DatabaseLogic extends BaseLogic
$isDeleteTime = true;
}
if (!$isDeleteTime) {
throw new ApiException('当前表不支持回收站功能');
throw new ApiException('Current table does not support recycle bin');
}
// 查询软删除数据
$request = request();

View File

@@ -38,7 +38,7 @@ class SystemAttachmentLogic extends BaseLogic
{
$category = SystemCategory::where('id', $category_id)->findOrEmpty();
if ($category->isEmpty()) {
throw new ApiException('目标分类不存在');
throw new ApiException('Target category not found');
}
return $this->model->whereIn('id', $ids)->update(['category_id' => $category_id]);
}
@@ -54,11 +54,11 @@ class SystemAttachmentLogic extends BaseLogic
{
$image_data = file_get_contents($url);
if ($image_data === false) {
throw new ApiException('获取文件资源失败');
throw new ApiException('Failed to get file resource');
}
$image_resource = imagecreatefromstring($image_data);
if (!$image_resource) {
throw new ApiException('创建图片资源失败');
throw new ApiException('Failed to create image resource');
}
$filename = basename($url);
$file_extension = pathinfo($filename, PATHINFO_EXTENSION);
@@ -84,11 +84,11 @@ class SystemAttachmentLogic extends BaseLogic
break;
default:
imagedestroy($image_resource);
throw new ApiException('文件格式错误');
throw new ApiException('Invalid file format');
}
imagedestroy($image_resource);
if (!$result) {
throw new ApiException('文件保存失败');
throw new ApiException('Failed to save file');
}
$hash = md5_file($save_path);

View File

@@ -41,14 +41,14 @@ class SystemCategoryLogic extends BaseLogic
{
$data = $this->handleData($data);
if ($data['parent_id'] == $id) {
throw new ApiException('上级分类和当前分类不能相同');
throw new ApiException('Parent category cannot be the same as current');
}
if (in_array($id, explode(',', $data['level']))) {
throw new ApiException('不能将上级分类设置为当前分类的子分类');
throw new ApiException('Cannot set parent category as child of current');
}
$model = $this->model->findOrEmpty($id);
if ($model->isEmpty()) {
throw new ApiException('数据不存在');
throw new ApiException('Data not found');
}
return $model->save($data);
}
@@ -60,7 +60,7 @@ class SystemCategoryLogic extends BaseLogic
{
$num = $this->model->where('parent_id', 'in', $ids)->count();
if ($num > 0) {
throw new ApiException('该部门下存在子分类,请先删除子分类');
throw new ApiException('This category has sub-categories, please delete them first');
} else {
return $this->model->destroy($ids);
}

View File

@@ -34,10 +34,10 @@ class SystemConfigGroupLogic extends BaseLogic
$id = $ids[0];
$model = $this->model->where('id', $id)->findOrEmpty();
if ($model->isEmpty()) {
throw new ApiException('配置数据未找到');
throw new ApiException('Config data not found');
}
if (in_array(intval($id), [1, 2, 3])) {
throw new ApiException('系统默认分组,无法删除');
throw new ApiException('System default group cannot be deleted');
}
Db::startTrans();
try {
@@ -51,7 +51,7 @@ class SystemConfigGroupLogic extends BaseLogic
return true;
} catch (\Exception $e) {
Db::rollback();
throw new ApiException('删除数据异常,请检查');
throw new ApiException('Delete data error, please check');
}
}
}

View File

@@ -63,7 +63,7 @@ class SystemConfigLogic extends BaseLogic
{
$group = SystemConfigGroup::find($group_id);
if (!$group) {
throw new ApiException('配置组未找到');
throw new ApiException('Config group not found');
}
$saveData = [];
foreach ($config as $key => $value) {

View File

@@ -44,10 +44,10 @@ class SystemDeptLogic extends BaseLogic
$oldLevel = $data['level'] . $id . ',';
$data = $this->handleData($data);
if ($data['parent_id'] == $id) {
throw new ApiException('上级部门和当前部门不能相同');
throw new ApiException('Parent department cannot be the same as current department');
}
if (in_array($id, explode(',', $data['level']))) {
throw new ApiException('不能将上级部门设置为当前部门的子部门');
throw new ApiException('Cannot set parent department to a child of current department');
}
$newLevel = $data['level'] . $id . ',';
$deptIds = $this->model->where('level', 'like', $oldLevel . '%')->column('id');
@@ -65,11 +65,11 @@ class SystemDeptLogic extends BaseLogic
{
$num = $this->model->where('parent_id', 'in', $ids)->count();
if ($num > 0) {
throw new ApiException('该部门下存在子部门,请先删除子部门');
throw new ApiException('This department has sub-departments, please delete them first');
} else {
$count = SystemUser::where('dept_id', 'in', $ids)->count();
if ($count > 0) {
throw new ApiException('该部门下存在用户,请先删除或者转移用户');
throw new ApiException('This department has users, please delete or transfer them first');
}
return $this->model->destroy($ids);
}

View File

@@ -35,7 +35,7 @@ class SystemDictDataLogic extends BaseLogic
{
$type = SystemDictType::where('id', $data['type_id'])->findOrEmpty();
if ($type->isEmpty()) {
throw new ApiException('字典类型不存在');
throw new ApiException('Dict type not found');
}
$data['code'] = $type->code;
$model = $this->model->create($data);

View File

@@ -32,7 +32,7 @@ class SystemDictTypeLogic extends BaseLogic
{
$model = $this->model->where('code', $data['code'])->findOrEmpty();
if (!$model->isEmpty()) {
throw new ApiException('该字典标识已存在');
throw new ApiException('This dict code already exists');
}
return $this->model->save($data);
}
@@ -52,7 +52,7 @@ class SystemDictTypeLogic extends BaseLogic
return $result;
} catch (\Exception $e) {
Db::rollback();
throw new ApiException('修改数据异常,请检查');
throw new ApiException('Update data error, please check');
}
}
@@ -72,7 +72,7 @@ class SystemDictTypeLogic extends BaseLogic
return $result;
} catch (\Exception $e) {
Db::rollback();
throw new ApiException('删除数据异常,请检查');
throw new ApiException('Delete data error, please check');
}
}

View File

@@ -43,7 +43,7 @@ class SystemMenuLogic extends BaseLogic
{
$data = $this->handleData($data);
if ($data['parent_id'] == $id) {
throw new ApiException('不能设置父级为自身');
throw new ApiException('Cannot set parent to self');
}
return $this->model->update($data, ['id' => $id]);
}
@@ -55,7 +55,7 @@ class SystemMenuLogic extends BaseLogic
{
$num = $this->model->where('parent_id', 'in', $ids)->count();
if ($num > 0) {
throw new ApiException('该菜单下存在子菜单,请先删除子菜单');
throw new ApiException('This menu has sub-menus, please delete them first');
} else {
return $this->model->destroy($ids);
}

View File

@@ -65,7 +65,7 @@ class SystemPostLogic extends BaseLogic
}
$this->saveAll($data);
} catch (\Exception $e) {
throw new ApiException('导入文件错误请上传正确的文件格式xlsx');
throw new ApiException('Import file error, please upload correct xlsx file');
}
}

View File

@@ -43,7 +43,7 @@ class SystemRoleLogic extends BaseLogic
{
$model = $this->model->findOrEmpty($id);
if ($model->isEmpty()) {
throw new ApiException('数据不存在');
throw new ApiException('Data not found');
}
$data = $this->handleData($data);
return $model->save($data);
@@ -60,7 +60,7 @@ class SystemRoleLogic extends BaseLogic
$num = SystemRole::where('level', '>=', $maxLevel)->whereIn('id', $ids)->count();
if ($num > 0) {
throw new ApiException('不能操作比当前账户职级高的角色');
throw new ApiException('Cannot operate roles with higher level than current account');
} else {
return $this->model->destroy($ids);
}
@@ -75,7 +75,7 @@ class SystemRoleLogic extends BaseLogic
$levelArr = array_column($this->adminInfo['roleList'], 'level');
$maxLevel = max($levelArr);
if ($data['level'] >= $maxLevel) {
throw new ApiException('不能操作比当前账户职级高的角色');
throw new ApiException('Cannot operate roles with higher level than current account');
}
return $data;
}

View File

@@ -85,7 +85,7 @@ class SystemUserLogic extends BaseLogic
if ($this->adminInfo['id'] > 1) {
// 部门保护
if (!$this->deptProtect($this->adminInfo['deptList'], $data['dept_id'])) {
throw new ApiException('没有权限操作该部门数据');
throw new ApiException('No permission to operate department data');
}
}
return $data;
@@ -105,11 +105,11 @@ class SystemUserLogic extends BaseLogic
if ($this->adminInfo['id'] > 1) {
// 部门保护
if (!$this->deptProtect($this->adminInfo['deptList'], $data['dept_id'])) {
throw new ApiException('没有权限操作该部门数据');
throw new ApiException('No permission to operate department data');
}
// 越权保护
if (!$this->roleProtect($this->adminInfo['roleList'], $role_ids)) {
throw new ApiException('没有权限操作该角色数据');
throw new ApiException('No permission to operate role data');
}
}
$user = SystemUser::create($data);
@@ -142,16 +142,16 @@ class SystemUserLogic extends BaseLogic
}
$user = $query->findOrEmpty();
if ($user->isEmpty()) {
throw new ApiException('没有权限操作该数据');
throw new ApiException('No permission to operate this data');
}
if ($this->adminInfo['id'] > 1) {
// 部门保护
if (!$this->deptProtect($this->adminInfo['deptList'], $data['dept_id'])) {
throw new ApiException('没有权限操作该部门数据');
throw new ApiException('No permission to operate department data');
}
// 越权保护
if (!$this->roleProtect($this->adminInfo['roleList'], $role_ids)) {
throw new ApiException('没有权限操作该角色数据');
throw new ApiException('No permission to operate role data');
}
}
$result = parent::edit($id, $data);
@@ -179,12 +179,12 @@ class SystemUserLogic extends BaseLogic
{
if (is_array($ids)) {
if (count($ids) > 1) {
throw new ApiException('禁止批量删除操作');
throw new ApiException('Batch delete is not allowed');
}
$ids = $ids[0];
}
if ($ids == 1) {
throw new ApiException('超级管理员禁止删除');
throw new ApiException('Super admin cannot be deleted');
}
$query = $this->model->where('id', $ids);
// 超级管理员可删除任意用户,普通管理员仅可删除当前部门和子部门的用户
@@ -193,14 +193,14 @@ class SystemUserLogic extends BaseLogic
}
$user = $query->findOrEmpty();
if ($user->isEmpty()) {
throw new ApiException('没有权限操作该数据');
throw new ApiException('No permission to operate this data');
}
if ($this->adminInfo['id'] > 1) {
$role_ids = $user->roles->toArray() ?: [];
if (!empty($role_ids)) {
// 越权保护
if (!$this->roleProtect($this->adminInfo['roleList'], array_column($role_ids, 'id'))) {
throw new ApiException('没有权限操作该角色数据');
throw new ApiException('No permission to operate role data');
}
}
}
@@ -283,7 +283,7 @@ class SystemUserLogic extends BaseLogic
$model->password = password_hash($newPassword, PASSWORD_DEFAULT);
return $model->save();
} else {
throw new ApiException('原密码错误');
throw new ApiException('Old password is incorrect');
}
}
@@ -298,7 +298,7 @@ class SystemUserLogic extends BaseLogic
$query->auth($this->adminInfo['deptList']);
$user = $query->findOrEmpty();
if ($user->isEmpty()) {
throw new ApiException('没有权限操作该数据');
throw new ApiException('No permission to operate this data');
}
}
parent::edit($id, $data);

View File

@@ -50,7 +50,7 @@ class CrontabLogic extends BaseLogic
6 => "0 {$minute} {$hour} * * {$week}",
7 => "0 {$minute} {$hour} {$day} * *",
8 => "0 {$minute} {$hour} {$day} {$month} *",
default => throw new ApiException("任务类型异常"),
default => throw new ApiException('Invalid task type'),
};
// 定时任务模型新增
@@ -95,13 +95,13 @@ class CrontabLogic extends BaseLogic
6 => "0 {$minute} {$hour} * * {$week}",
7 => "0 {$minute} {$hour} {$day} * *",
8 => "0 {$minute} {$hour} {$day} {$month} *",
default => throw new ApiException("任务类型异常"),
default => throw new ApiException('Invalid task type'),
};
// 查询任务数据
$model = $this->model->findOrEmpty($id);
if ($model->isEmpty()) {
throw new ApiException('数据不存在');
throw new ApiException('Data not found');
}
$result = $model->save([
@@ -134,7 +134,7 @@ class CrontabLogic extends BaseLogic
{
if (is_array($ids)) {
if (count($ids) > 1) {
throw new ApiException('禁止批量删除操作');
throw new ApiException('Batch delete is not allowed');
}
$ids = $ids[0];
}
@@ -157,7 +157,7 @@ class CrontabLogic extends BaseLogic
{
$model = $this->model->findOrEmpty($id);
if ($model->isEmpty()) {
throw new ApiException('数据不存在');
throw new ApiException('Data not found');
}
$result = $model->save(['status' => $status]);
if ($result) {

View File

@@ -63,7 +63,7 @@ class GenerateTablesLogic extends BaseLogic
$data = config('think-orm.connections');
$config = $data[$source];
if (!$config) {
throw new ApiException('数据库配置读取失败');
throw new ApiException('Failed to read database config');
}
$prefix = $config['prefix'] ?? '';
@@ -262,10 +262,10 @@ class GenerateTablesLogic extends BaseLogic
{
$table = $this->model->findOrEmpty($id);
if (!in_array($table['template'], ["plugin", "app"])) {
throw new ApiException('应用类型必须为plugin或者app');
throw new ApiException('App type must be plugin or app');
}
if (empty($table['namespace'])) {
throw new ApiException('请先设置应用名称');
throw new ApiException('Please set app name first');
}
$columns = $this->columnLogic->where('table_id', $id)
@@ -320,11 +320,11 @@ class GenerateTablesLogic extends BaseLogic
{
$table = $this->model->where('id', $id)->findOrEmpty();
if ($table->isEmpty()) {
throw new ApiException('请选择要生成的表');
throw new ApiException('Please select tables to generate');
}
$debug = config('app.debug', true);
if (!$debug) {
throw new ApiException('非调试模式下,不允许生成文件');
throw new ApiException('File generation not allowed in non-debug mode');
}
$this->updateMenu($table);
$this->genModule($id);

View File

@@ -27,10 +27,10 @@ class CheckLogin implements MiddlewareInterface
try {
$token = JwtToken::getExtend();
} catch (\Throwable $e) {
throw new ApiException('您的登录凭证错误或者已过期,请重新登录', 401);
throw new ApiException('Your login credential is invalid or expired, please login again', 401);
}
if ($token['plat'] !== 'saiadmin') {
throw new ApiException('登录凭证校验失败');
throw new ApiException('Login credential verification failed');
}
// 一次合并设置,避免 setHeader 覆盖导致只保留最后一个
$request->setHeader(array_merge($request->header() ?: [], [

View File

@@ -30,7 +30,7 @@ class SystemLog implements MiddlewareInterface
// 记录日志
Event::emit('user.operateLog', true);
} catch (\Throwable $e) {
throw new ApiException('登录凭获取失败,请检查');
throw new ApiException('Failed to get login credential, please check');
}
}
return $handler($request);

View File

@@ -47,7 +47,7 @@ class BaseLogic extends AbstractLogic
{
$model = $this->model->find($id);
if (!$model) {
throw new ApiException('数据不存在');
throw new ApiException('Data not found');
}
return $model->update($data);
}
@@ -61,7 +61,7 @@ class BaseLogic extends AbstractLogic
{
$model = $this->model->find($id);
if (!$model) {
throw new ApiException('数据不存在');
throw new ApiException('Data not found');
}
return $model;
}

View File

@@ -47,7 +47,7 @@ class BaseLogic extends AbstractLogic
{
$model = $this->model->findOrEmpty($id);
if ($model->isEmpty()) {
throw new ApiException('数据不存在');
throw new ApiException('Data not found');
}
return $model->save($data);
}
@@ -61,7 +61,7 @@ class BaseLogic extends AbstractLogic
{
$model = $this->model->findOrEmpty($id);
if ($model->isEmpty()) {
throw new ApiException('数据不存在');
throw new ApiException('Data not found');
}
return $model;
}

View File

@@ -26,7 +26,7 @@ class EmailService
$logic = new SystemConfigLogic();
$config = $logic->getGroup('email_config');
if (!$config) {
throw new ApiException('未设置邮件配置');
throw new ApiException('Mail config not set');
}
return $config;
}
@@ -38,7 +38,7 @@ class EmailService
public static function getMailer(): PHPMailer
{
if (!class_exists(PHPMailer::class)) {
throw new ApiException('请执行 composer require phpmailer/phpmailer 并重启');
throw new ApiException('Please run composer require phpmailer/phpmailer and restart');
}
$config = static::getConfig();
$mailer = new PHPMailer();

View File

@@ -54,7 +54,7 @@ class ChunkUploadService
{
$allow_file = Arr::getConfigValue($this->config, 'upload_allow_file');
if (!in_array($data['ext'], explode(',', $allow_file))) {
throw new ApiException('不支持该格式的文件上传');
throw new ApiException('File format not supported for upload');
}
// 检查已经上传的分片文件
for ($i = 0; $i < $data['total']; ++$i) {
@@ -80,11 +80,11 @@ class ChunkUploadService
{
$allow_file = Arr::getConfigValue($this->config, 'upload_allow_file');
if (!in_array($data['ext'], explode(',', $allow_file))) {
throw new ApiException('不支持该格式的文件上传');
throw new ApiException('File format not supported for upload');
}
$request = request();
if (!$request) {
throw new ApiException('切片上传服务必须在 HTTP 请求环境下调用');
throw new ApiException('Chunk upload must be called in HTTP request context');
}
$uploadFile = current($request->file());
$chunkName = $this->path . "{$data['hash']}_{$data['total']}_{$data['index']}.chunk";
@@ -107,7 +107,7 @@ class ChunkUploadService
for ($i = 0; $i < $data['total']; ++$i) {
$chunkFile = $this->path . "{$data['hash']}_{$data['total']}_{$i}.chunk";
if (!file_exists($chunkFile)) {
throw new ApiException('切片文件查找失败,请重新上传');
throw new ApiException('Chunk file not found, please upload again');
}
fwrite($fileHandle, file_get_contents($chunkFile));
unlink($chunkFile);

View File

@@ -34,17 +34,17 @@ class UploadService
$ext = $file->getUploadExtension() ?: null;
$file_size = $file->getSize();
if ($file_size > Arr::getConfigValue($uploadConfig, 'upload_size')) {
throw new ApiException('文件大小超过限制');
throw new ApiException('File size exceeds limit');
}
$allow_file = Arr::getConfigValue($uploadConfig, 'upload_allow_file');
$allow_image = Arr::getConfigValue($uploadConfig, 'upload_allow_image');
if ($upload == 'image') {
if (!in_array($ext, explode(',', $allow_image))) {
throw new ApiException('不支持该格式的文件上传');
throw new ApiException('File format not supported for upload');
}
} else {
if (!in_array($ext, explode(',', $allow_file))) {
throw new ApiException('不支持该格式的文件上传');
throw new ApiException('File format not supported for upload');
}
}
switch ($type) {
@@ -115,7 +115,7 @@ class UploadService
];
break;
default:
throw new ApiException('该上传模式不存在');
throw new ApiException('Upload mode not found');
}
return new $config['adapter'](array_merge(
$config,

View File

@@ -53,7 +53,7 @@ class CodeEngine
// 判断模板是否存在
if (!is_dir($config['template_path'])) {
throw new ApiException('模板目录不存在!');
throw new ApiException('Template directory not found');
}
// 判断文件生成目录是否存在
if (!is_dir($config['generate_path'])) {
@@ -160,7 +160,7 @@ class CodeEngine
}
if (empty($outPath)) {
throw new ApiException('文件类型异常,无法生成指定文件!');
throw new ApiException('Invalid file type, cannot generate file');
}
if (!is_dir(dirname($outPath))) {
mkdir(dirname($outPath), 0777, true);
@@ -176,7 +176,7 @@ class CodeEngine
{
$rootPath = dirname(base_path()) . DS . $this->value['generate_path'];
if (!is_dir($rootPath)) {
throw new ApiException('前端目录查找失败,必须与后端目录为同级目录!');
throw new ApiException('Frontend directory not found, must be same level as backend');
}
$rootPath = $rootPath . DS . 'src' . DS . 'views' . DS . 'plugin' . DS . $this->value['namespace'];
@@ -199,7 +199,7 @@ class CodeEngine
}
if (empty($outPath)) {
throw new ApiException('文件类型异常,无法生成指定文件!');
throw new ApiException('Invalid file type, cannot generate file');
}
if (!is_dir(dirname($outPath))) {
mkdir(dirname($outPath), 0777, true);

View File

@@ -57,7 +57,7 @@ class CodeZip
$zipName = $config['generate_path'].'.zip';
$dirPath = $config['generate_path'];
if ($zipArc->open($zipName, \ZipArchive::OVERWRITE | \ZipArchive::CREATE) !== true) {
throw new ApiException('无法打开文件,或者文件创建失败');
throw new ApiException('Cannot open file or create file failed');
}
$this->addFileToZip($dirPath, $zipArc);
$zipArc->close();
@@ -158,7 +158,7 @@ class CodeZip
@readfile($fileName);
@unlink($fileName);
} catch (\Throwable $th) {
throw new ApiException('系统生成文件错误');
throw new ApiException('System file generation error');
}
}
}

View File

@@ -25,7 +25,7 @@ class InstallController extends BaseController
{
parent::__construct();
if ($this->adminId > 1) {
throw new ApiException('仅超级管理员能够操作');
throw new ApiException('Only super admin can perform this action');
}
}
@@ -105,17 +105,17 @@ class InstallController extends BaseController
{
$spl_file = current($request->file());
if (!$spl_file->isValid()) {
return $this->fail('上传文件校验失败');
return $this->fail('upload file validation failed');
}
$config = config('plugin.saipackage.upload', [
'size' => 1024 * 1024 * 5,
'type' => ['zip']
]);
if (!in_array($spl_file->getUploadExtension(), $config['type'])) {
return $this->fail('文件格式上传失败,请选择zip格式文件上传');
return $this->fail('upload failed, please upload zip file');
}
if ($spl_file->getSize() > $config['size']) {
return $this->fail('文件大小不能超过5M');
return $this->fail('file size cannot exceed 5M');
}
$install = new InstallLogic();
$info = $install->upload($spl_file);
@@ -132,7 +132,7 @@ class InstallController extends BaseController
{
$appName = $request->post("appName", '');
if (empty($appName)) {
return $this->fail('参数错误');
return $this->fail('Invalid parameters');
}
$install = new InstallLogic($appName);
$info = $install->install();
@@ -150,12 +150,12 @@ class InstallController extends BaseController
{
$appName = $request->post("appName", '');
if (empty($appName)) {
return $this->fail('参数错误');
return $this->fail('Invalid parameters');
}
$install = new InstallLogic($appName);
$install->uninstall();
UserMenuCache::clearMenuCache();
return $this->success('卸载插件成功');
return $this->success('uninstall plugin success');
}
/**
@@ -167,7 +167,7 @@ class InstallController extends BaseController
{
Server::restart();
return $this->success('重载成功');
return $this->success('reload success');
}
// ========== 商店代理接口 ==========
@@ -278,7 +278,7 @@ class InstallController extends BaseController
{
$token = $request->input('token');
if (empty($token)) {
return $this->fail('未登录');
return $this->fail('not logged in');
}
$result = $this->proxyRequest(
@@ -299,7 +299,7 @@ class InstallController extends BaseController
{
$token = $request->input('token');
if (empty($token)) {
return $this->fail('未登录');
return $this->fail('not logged in');
}
$result = $this->proxyRequest(
@@ -322,7 +322,7 @@ class InstallController extends BaseController
$appId = $request->input('app_id');
if (empty($token)) {
return $this->fail('未登录');
return $this->fail('not logged in');
}
$result = $this->proxyRequest(
@@ -345,11 +345,11 @@ class InstallController extends BaseController
$versionId = $request->input('id');
if (empty($token)) {
return $this->fail('未登录');
return $this->fail('not logged in');
}
if (empty($versionId)) {
return $this->fail('版本ID不能为空');
return $this->fail('version id is required');
}
$result = $this->proxyRequest(
@@ -365,7 +365,7 @@ class InstallController extends BaseController
}
if (!isset($result['raw'])) {
return $this->fail('下载失败');
return $this->fail('download failed');
}
// 保存临时 zip 文件
@@ -380,7 +380,7 @@ class InstallController extends BaseController
$install = new InstallLogic();
$info = $install->uploadFromPath($tempZip);
return $this->success($info, '下载成功,请在插件列表中安装');
return $this->success($info, 'download success, please install in plugin list');
} catch (Throwable $e) {
@unlink($tempZip);
return $this->fail($e->getMessage());

View File

@@ -108,7 +108,7 @@ class InstallLogic
if (empty($info['app'])) {
Filesystem::delDir($copyToDir);
// 基本配置不完整
throw new ApiException('插件的基础配置信息错误');
throw new ApiException('Plugin base config is invalid');
}
@@ -127,14 +127,14 @@ class InstallLogic
$upgrade = Version::compare($nextVersion, $info['version']);
if (!$upgrade) {
Filesystem::delDir($copyToDir);
throw new ApiException('插件已经存在');
throw new ApiException('Plugin already exists');
}
}
if (Filesystem::dirIsEmpty($this->appDir) || (!Filesystem::dirIsEmpty($this->appDir) && !$upgrade)) {
Filesystem::delDir($copyToDir);
// 模块目录被占
throw new ApiException('该插件的安装目录已经被占用');
throw new ApiException('Plugin install directory is already occupied');
}
}
@@ -167,7 +167,7 @@ class InstallLogic
public function uploadFromPath(string $zipPath): array
{
if (!is_file($zipPath)) {
throw new ApiException('文件不存在');
throw new ApiException('File not found');
}
// 解压
@@ -181,7 +181,7 @@ class InstallLogic
$info = Server::getIni($copyToDir);
if (empty($info['app'])) {
Filesystem::delDir($copyToDir);
throw new ApiException('插件的基础配置信息错误');
throw new ApiException('Plugin base config is invalid');
}
$this->appName = $info['app'];
@@ -199,13 +199,13 @@ class InstallLogic
$upgrade = Version::compare($nextVersion, $info['version']);
if (!$upgrade) {
Filesystem::delDir($copyToDir);
throw new ApiException('插件已经存在');
throw new ApiException('Plugin already exists');
}
}
if (Filesystem::dirIsEmpty($this->appDir) || (!Filesystem::dirIsEmpty($this->appDir) && !$upgrade)) {
Filesystem::delDir($copyToDir);
throw new ApiException('该插件的安装目录已经被占用');
throw new ApiException('Plugin install directory is already occupied');
}
}
@@ -237,11 +237,11 @@ class InstallLogic
{
$state = $this->getInstallState();
if ($state == self::INSTALLED || $state == self::DIRECTORY_OCCUPIED) {
throw new ApiException('插件已经存在');
throw new ApiException('Plugin already exists');
}
if ($state == self::DEPENDENT_WAIT_INSTALL) {
throw new ApiException('等待依赖安装');
throw new ApiException('Waiting for dependencies to be installed');
}
echo '开始安装[' . $this->appName . ']' . PHP_EOL;
@@ -351,14 +351,14 @@ class InstallLogic
public function checkPackage(): bool
{
if (!is_dir($this->appDir)) {
throw new ApiException('插件目录不存在');
throw new ApiException('Plugin directory not found');
}
$info = $this->getInfo();
$infoKeys = ['app', 'title', 'about', 'author', 'version', 'state'];
foreach ($infoKeys as $value) {
if (!array_key_exists($value, $info)) {
Filesystem::delDir($this->appDir);
throw new ApiException('该插件的基础配置信息不完善');
throw new ApiException('Plugin base config is incomplete');
}
}
return true;
@@ -527,6 +527,6 @@ class InstallLogic
} elseif ($arr) {
return Server::setIni($this->appDir, $arr);
}
throw new ApiException('参数错误');
throw new ApiException('Invalid parameters');
}
}

View File

@@ -1,136 +1,346 @@
<?php
declare(strict_types=1);
/**
* API 英文文案Webman 多语言路径config translation.path / api / en.php
* 请求头 lang=en 时使用key 为中文原文value 为英文
*/
return [
'success' => 'Success',
'fail' => 'Fail',
'username、password 不能为空' => 'username and password are required',
'请携带 token' => 'Please provide token',
'token 无效' => 'Invalid or expired token',
'已退出登录' => 'Logged out successfully',
'用户不存在' => 'User not found',
'username 不能为空' => 'username is required',
'密码错误' => 'Wrong password',
'账号已被禁用,无法登录' => 'Account is disabled and cannot log in',
'购买抽奖券错误' => 'Invalid lottery ticket purchase',
'平台币不足' => 'Insufficient balance',
'direction 必须为 0 或 1' => 'direction must be 0 or 1',
'当前玩家余额%s小于%s无法继续游戏' => 'Balance %s is less than %s, cannot continue',
'服务超时,' => 'Service timeout: ',
'没有原因' => 'Unknown reason',
'缺少参数agent_id、secret、time、signature 不能为空' => 'Missing parameters: agent_id, secret, time, signature are required',
'服务端未配置 API_AUTH_TOKEN_SECRET' => 'API_AUTH_TOKEN_SECRET is not configured',
'密钥错误' => 'Invalid secret',
'时间戳已过期或无效,请同步时间' => 'Timestamp expired or invalid, please sync time',
'签名验证失败' => 'Signature verification failed',
'生成 token 失败' => 'Failed to generate token',
'coin 不能为空' => 'coin is required',
'coin 不能为 0' => 'coin cannot be 0',
'余额不足,无法转出' => 'Insufficient balance to transfer',
'操作失败:' => 'Operation failed: ',
'服务超时,没有原因' => 'Service timeout: Unknown reason',
'抽奖券不足' => 'Insufficient lottery tickets',
'奖池配置不存在' => 'Lottery config not found',
'配置ID %s 不存在或档位为空' => 'Config ID %s not found or tier is empty',
'该方向下暂无可用路径配置' => 'No path config available for this direction',
'奖池配置不存在(需 name=default' => 'Lottery pool config not found (name=default required)',
'暂无可用奖励配置' => 'No available reward config',
'未找到 name=default 的奖池配置,请先创建' => 'No name=default pool config found, please create one first',
'参数错误:需要有效的 player_id 和 type3=加点4=扣点)' => 'Invalid params: player_id and type are required (3=add, 4=deduct)',
'平台币变动必须大于 0' => 'Coin change must be greater than 0',
'玩家不存在' => 'Player not found',
'扣点数量不能大于当前余额' => 'Deduct amount cannot exceed current balance',
'测试记录不存在' => 'Test record not found',
'付费奖池配置不存在' => 'Paid pool config not found',
'免费奖池配置不存在' => 'Free pool config not found',
'各抽奖次数仅支持 0、100、500、1000、5000' => 'Counts only support 0, 100, 500, 1000, 5000',
'付费或免费至少一种方向次数之和大于 0' => 'Sum of paid/free direction counts must be greater than 0',
'付费未选择奖池配置时请填写付费自定义档位概率T1T5' => 'When paid pool is not selected, please fill paid custom tier probabilities (T1T5)',
'付费档位概率每档只能 0-100%' => 'Paid tier probability must be between 0 and 100%',
'付费档位概率 T1T5 之和不能超过 100%' => 'Paid tier probabilities (T1T5) sum cannot exceed 100%',
'免费未选择奖池配置时请填写免费自定义档位概率T1T5' => 'When free pool is not selected, please fill free custom tier probabilities (T1T5)',
'免费档位概率每档只能 0-100%' => 'Free tier probability must be between 0 and 100%',
'免费档位概率 T1T5 之和不能超过 100%' => 'Free tier probabilities (T1T5) sum cannot exceed 100%',
'存在无效的配置ID' => 'Invalid config ID exists',
'存在无效的 DiceReward id' => 'Invalid DiceReward id exists',
'奖励配置为空,请先维护 dice_reward_config' => 'Reward config is empty, please maintain dice_reward_config first',
'奖励配置需覆盖 26 个格位id 0-25 或 1-26当前仅 %s 条,无法完整生成 5-30 共26个点数、顺时针与逆时针的奖励对照' => 'Reward config must cover 26 cells (id 0-25 or 1-26), currently only %s, cannot generate full 5-30 points and clockwise/counterclockwise mapping',
'测试次数仅支持 100、500、1000、5000、10000' => 'Test count only supports 100, 500, 1000, 5000, 10000',
'没有权限操作该部门数据' => 'No permission to operate department data',
'没有权限操作该角色数据' => 'No permission to operate role data',
'没有权限操作该数据' => 'No permission to operate this data',
'禁止批量删除操作' => 'Batch delete is not allowed',
'超级管理员禁止删除' => 'Super admin cannot be deleted',
'原密码错误' => 'Old password is incorrect',
'上级部门和当前部门不能相同' => 'Parent department cannot be the same as current department',
'不能将上级部门设置为当前部门的子部门' => 'Cannot set parent department to a child of current department',
'该部门下存在子部门,请先删除子部门' => 'This department has sub-departments, please delete them first',
'该部门下存在用户,请先删除或者转移用户' => 'This department has users, please delete or transfer them first',
'您的登录凭证错误或者已过期,请重新登录' => 'Your login credential is invalid or expired, please login again',
'登录凭证校验失败' => 'Login credential verification failed',
'插件的基础配置信息错误' => 'Plugin base config is invalid',
'插件已经存在' => 'Plugin already exists',
'该插件的安装目录已经被占用' => 'Plugin install directory is already occupied',
'文件不存在' => 'File not found',
'手机号格式错误,仅支持 +60 开头的马来西亚号码(如 +60123456789' => 'Invalid phone format, only +60 Malaysia numbers supported (e.g. +60123456789)',
'请携带 auth-token' => 'Please provide auth-token',
'auth-token 已过期' => 'auth-token expired',
'auth-token 无效' => 'auth-token invalid',
'auth-token 格式无效' => 'auth-token format invalid',
'auth-token 无效或已失效' => 'auth-token invalid or expired',
'token 已过期,请重新登录' => 'Token expired, please login again',
'token 格式无效' => 'Token format invalid',
'请注册' => 'Please register',
'请重新登录' => 'Please login again',
'请重新登录(当前账号已在其他处登录)' => 'Please login again (account logged in elsewhere)',
'数据不存在' => 'Data not found',
'不能设置父级为自身' => 'Cannot set parent to self',
'该菜单下存在子菜单,请先删除子菜单' => 'This menu has sub-menus, please delete them first',
'导入文件错误请上传正确的文件格式xlsx' => 'Import file error, please upload correct xlsx file',
'不能操作比当前账户职级高的角色' => 'Cannot operate roles with higher level than current account',
'该字典标识已存在' => 'This dict code already exists',
'修改数据异常,请检查' => 'Update data error, please check',
'删除数据异常,请检查' => 'Delete data error, please check',
'字典类型不存在' => 'Dict type not found',
'配置数据未找到' => 'Config data not found',
'系统默认分组,无法删除' => 'System default group cannot be deleted',
'配置组未找到' => 'Config group not found',
'上级分类和当前分类不能相同' => 'Parent category cannot be the same as current',
'不能将上级分类设置为当前分类的子分类' => 'Cannot set parent category as child of current',
'该部门下存在子分类,请先删除子分类' => 'This category has sub-categories, please delete them first',
'目标分类不存在' => 'Target category not found',
'获取文件资源失败' => 'Failed to get file resource',
'创建图片资源失败' => 'Failed to create image resource',
'文件格式错误' => 'Invalid file format',
'文件保存失败' => 'Failed to save file',
'当前表不支持回收站功能' => 'Current table does not support recycle bin',
'模板不存在' => 'Template not found',
'任务类型异常' => 'Invalid task type',
'数据库配置读取失败' => 'Failed to read database config',
'应用类型必须为plugin或者app' => 'App type must be plugin or app',
'请先设置应用名称' => 'Please set app name first',
'请选择要生成的表' => 'Please select tables to generate',
'非调试模式下,不允许生成文件' => 'File generation not allowed in non-debug mode',
'登录凭获取失败,请检查' => 'Failed to get login credential, please check',
'文件大小超过限制' => 'File size exceeds limit',
'不支持该格式的文件上传' => 'File format not supported for upload',
'该上传模式不存在' => 'Upload mode not found',
'切片上传服务必须在 HTTP 请求环境下调用' => 'Chunk upload must be called in HTTP request context',
'切片文件查找失败,请重新上传' => 'Chunk file not found, please upload again',
'未设置邮件配置' => 'Mail config not set',
'请执行 composer require phpmailer/phpmailer 并重启' => 'Please run composer require phpmailer/phpmailer and restart',
'仅超级管理员能够操作' => 'Only super admin can perform this action',
'等待依赖安装' => 'Waiting for dependencies to be installed',
'插件目录不存在' => 'Plugin directory not found',
'该插件的基础配置信息不完善' => 'Plugin base config is incomplete',
'参数错误' => 'Invalid parameters',
'无法打开文件,或者文件创建失败' => 'Cannot open file or create file failed',
'系统生成文件错误' => 'System file generation error',
'模板目录不存在!' => 'Template directory not found',
'文件类型异常,无法生成指定文件!' => 'Invalid file type, cannot generate file',
'前端目录查找失败,必须与后端目录为同级目录!' => 'Frontend directory not found, must be same level as backend',
'ACCOUNT_DISABLED' => 'Account is disabled and cannot log in',
'API_AUTH_TOKEN_SECRET is not configured' => 'API_AUTH_TOKEN_SECRET is not configured',
'AUTH_TOKEN_EXPIRED' => 'auth-token expired',
'AUTH_TOKEN_FORMAT_INVALID' => 'auth-token format invalid',
'AUTH_TOKEN_INVALID' => 'auth-token invalid',
'AUTH_TOKEN_INVALID_OR_EXPIRED' => 'auth-token invalid or expired',
'AUTH_TOKEN_REQUIRED' => 'Please provide auth-token',
'Account is disabled and cannot log in' => 'Account is disabled and cannot log in',
'App type must be plugin or app' => 'App type must be plugin or app',
'BALANCE_LESS_THAN_MIN' => 'Balance %s is less than %s, cannot continue',
'BATCH_DELETE_FORBIDDEN' => 'Batch delete is not allowed',
'BUY_TICKET_ERROR' => 'Invalid lottery ticket purchase',
'Balance %s is less than %s, cannot continue' => 'Balance %s is less than %s, cannot continue',
'Batch delete is not allowed' => 'Batch delete is not allowed',
'CONFIG_ID_NOT_FOUND_OR_TIER_EMPTY' => 'Config ID %s not found or tier is empty',
'Cannot open file or create file failed' => 'Cannot open file or create file failed',
'Cannot operate roles with higher level than current account' => 'Cannot operate roles with higher level than current account',
'Cannot set parent category as child of current' => 'Cannot set parent category as child of current',
'Cannot set parent department to a child of current department' => 'Cannot set parent department to a child of current department',
'Cannot set parent to self' => 'Cannot set parent to self',
'Chunk file not found, please upload again' => 'Chunk file not found, please upload again',
'Chunk upload must be called in HTTP request context' => 'Chunk upload must be called in HTTP request context',
'Coin change must be greater than 0' => 'Coin change must be greater than 0',
'Config data not found' => 'Config data not found',
'Config group not found' => 'Config group not found',
'Counts only support 0, 100, 500, 1000, 5000' => 'Counts only support 0, 100, 500, 1000, 5000',
'Current table does not support recycle bin' => 'Current table does not support recycle bin',
'DATA_NOT_FOUND' => 'Data not found',
'DIRECTION_INVALID' => 'direction must be 0 or 1',
'Data not found' => 'Data not found',
'Deduct amount cannot exceed current balance' => 'Deduct amount cannot exceed current balance',
'Delete data error, please check' => 'Delete data error, please check',
'Dict type not found' => 'Dict type not found',
'FAIL' => 'Fail',
'Failed to create image resource' => 'Failed to create image resource',
'Failed to generate token' => 'Failed to generate token',
'Failed to get file resource' => 'Failed to get file resource',
'Failed to get login credential, please check' => 'Failed to get login credential, please check',
'Failed to read database config' => 'Failed to read database config',
'Failed to save file' => 'Failed to save file',
'File format not supported for upload' => 'File format not supported for upload',
'File generation not allowed in non-debug mode' => 'File generation not allowed in non-debug mode',
'File not found' => 'File not found',
'File size exceeds limit' => 'File size exceeds limit',
'Free pool config not found' => 'Free pool config not found',
'Free tier probabilities (T1T5) sum cannot exceed 100%' => 'Free tier probabilities (T1T5) sum cannot exceed 100%',
'Free tier probability must be between 0 and 100%' => 'Free tier probability must be between 0 and 100%',
'Frontend directory not found, must be same level as backend' => 'Frontend directory not found, must be same level as backend',
'INSUFFICIENT_BALANCE' => 'Insufficient balance',
'INSUFFICIENT_TICKETS' => 'Insufficient lottery tickets',
'Import file error, please upload correct xlsx file' => 'Import file error, please upload correct xlsx file',
'Insufficient balance' => 'Insufficient balance',
'Insufficient balance to transfer' => 'Insufficient balance to transfer',
'Insufficient lottery tickets' => 'Insufficient lottery tickets',
'Invalid DiceReward id exists' => 'Invalid DiceReward id exists',
'Invalid config ID exists' => 'Invalid config ID exists',
'Invalid file format' => 'Invalid file format',
'Invalid file type, cannot generate file' => 'Invalid file type, cannot generate file',
'Invalid lottery ticket purchase' => 'Invalid lottery ticket purchase',
'Invalid or expired token' => 'Invalid or expired token',
'Invalid parameters' => 'Invalid parameters',
'Invalid params: player_id and type are required (3=add, 4=deduct)' => 'Invalid params: player_id and type are required (3=add, 4=deduct)',
'Invalid phone format, only +60 Malaysia numbers supported (e.g. +60123456789)' => 'Invalid phone format, only +60 Malaysia numbers supported (e.g. +60123456789)',
'Invalid secret' => 'Invalid secret',
'Invalid task type' => 'Invalid task type',
'LOTTERY_CONFIG_NOT_FOUND' => 'Lottery config not found',
'LOTTERY_POOL_CONFIG_DEFAULT_NOT_FOUND' => 'No name=default pool config found, please create one first',
'LOTTERY_POOL_CONFIG_NOT_FOUND_DEFAULT' => 'Lottery pool config not found (name=default required)',
'Logged out successfully' => 'Logged out successfully',
'Login credential verification failed' => 'Login credential verification failed',
'Lottery pool config not found (name=default required)' => 'Lottery pool config not found (name=default required)',
'MSG_022FA411' => 'App type must be plugin or app',
'MSG_04BF8179' => 'Data not found',
'MSG_06F06DA6' => 'Invalid or expired token',
'MSG_0A17D195' => 'Paid tier probability must be between 0 and 100%',
'MSG_0A9A3E28' => 'Batch delete is not allowed',
'MSG_0BCF9CBC' => 'Test count only supports 100, 500, 1000, 5000, 10000',
'MSG_0CBB8FF6' => 'Service timeout: ',
'MSG_0D49B785' => 'Old password is incorrect',
'MSG_0FE75E2C' => 'Chunk upload must be called in HTTP request context',
'MSG_146A3F0D' => 'Dict type not found',
'MSG_17740DB3' => 'Token format invalid',
'MSG_1798E4D4' => 'Template not found',
'MSG_19E651B8' => 'coin is required',
'MSG_1A499109' => 'File not found',
'MSG_1BB27051' => 'auth-token expired',
'MSG_1C1718A6' => 'Plugin already exists',
'MSG_2240AD6D' => 'auth-token invalid',
'MSG_2273437E' => 'Balance %s is less than %s, cannot continue',
'MSG_22C6787F' => 'Chunk file not found, please upload again',
'MSG_25BF8A8D' => 'Deduct amount cannot exceed current balance',
'MSG_2830AE01' => 'Service timeout: Unknown reason',
'MSG_2ED0C7A8' => 'Plugin base config is invalid',
'MSG_2EE75A5E' => 'System file generation error',
'MSG_2EFE74EE' => 'File generation not allowed in non-debug mode',
'MSG_2F100DB4' => 'Cannot operate roles with higher level than current account',
'MSG_334CE26A' => 'No permission to operate this data',
'MSG_35FB9BA0' => 'File format not supported for upload',
'MSG_381A19AE' => 'Upload mode not found',
'MSG_3A4A6DE6' => 'username is required',
'MSG_3A4FF81F' => 'No permission to operate department data',
'MSG_3C99F7F7' => 'Reward config is empty, please maintain dice_reward_config first',
'MSG_3DBFEA33' => 'Invalid file format',
'MSG_43C4D703' => 'This department has users, please delete or transfer them first',
'MSG_47FDBDD0' => 'Config group not found',
'MSG_4CA58C61' => 'Update data error, please check',
'MSG_4F1D271A' => 'Invalid DiceReward id exists',
'MSG_521593FB' => 'Please set app name first',
'MSG_557E5109' => 'Failed to get file resource',
'MSG_559AAE0E' => 'No permission to operate role data',
'MSG_560E6D91' => 'No path config available for this direction',
'MSG_5643EE10' => 'Failed to generate token',
'MSG_569EC863' => 'Current table does not support recycle bin',
'MSG_56B44907' => 'Target category not found',
'MSG_5CE17D6B' => 'auth-token invalid or expired',
'MSG_5FF3A2BE' => 'Failed to read database config',
'MSG_609A300B' => 'Insufficient balance',
'MSG_60B9FC38' => 'Failed to get login credential, please check',
'MSG_64A3C830' => 'User not found',
'MSG_67C66962' => 'No name=default pool config found, please create one first',
'MSG_6C16260B' => 'When free pool is not selected, please fill free custom tier probabilities (T1T5)',
'MSG_6CA924A1' => 'Lottery pool config not found (name=default required)',
'MSG_6F00DFB2' => 'Success',
'MSG_7310FDB8' => 'Frontend directory not found, must be same level as backend',
'MSG_74E3CB84' => 'No available reward config',
'MSG_75C6A69F' => 'Please provide auth-token',
'MSG_7845F2E9' => 'Delete data error, please check',
'MSG_86272B49' => 'Fail',
'MSG_8865D363' => 'coin cannot be 0',
'MSG_8B6AA32A' => 'Cannot set parent category as child of current',
'MSG_8C2E3CE6' => 'Please login again (account logged in elsewhere)',
'MSG_8FDBA3F1' => 'This dict code already exists',
'MSG_91272513' => 'Invalid lottery ticket purchase',
'MSG_94EE6593' => 'Plugin install directory is already occupied',
'MSG_9501E2EF' => 'Insufficient balance to transfer',
'MSG_950B6072' => 'Config data not found',
'MSG_9A01DFBF' => 'Plugin base config is incomplete',
'MSG_9D195F25' => 'Account is disabled and cannot log in',
'MSG_9EE0801C' => 'Cannot open file or create file failed',
'MSG_9F6B51C8' => 'Invalid file type, cannot generate file',
'MSG_A049A679' => 'This category has sub-categories, please delete them first',
'MSG_A3165463' => 'Only super admin can perform this action',
'MSG_A4FB6212' => 'Failed to save file',
'MSG_A6A8EA8F' => 'Plugin directory not found',
'MSG_A72A7DC6' => 'This department has sub-departments, please delete them first',
'MSG_A778ABB9' => 'auth-token format invalid',
'MSG_ADA80442' => 'Please login again',
'MSG_AE73E6F3' => 'API_AUTH_TOKEN_SECRET is not configured',
'MSG_B387239D' => 'Paid tier probabilities (T1T5) sum cannot exceed 100%',
'MSG_B5C2F2F6' => 'Counts only support 0, 100, 500, 1000, 5000',
'MSG_B5CD5C51' => 'Test record not found',
'MSG_B720629D' => 'username and password are required',
'MSG_BA173F12' => 'Sum of paid/free direction counts must be greater than 0',
'MSG_BAC2EFB0' => 'Parent department cannot be the same as current department',
'MSG_BB3C5A3F' => 'direction must be 0 or 1',
'MSG_BBD3198A' => 'Invalid params: player_id and type are required (3=add, 4=deduct)',
'MSG_BD8AD1D3' => 'Invalid phone format, only +60 Malaysia numbers supported (e.g. +60123456789)',
'MSG_BEB15D55' => 'Invalid parameters',
'MSG_C2E4B3DC' => 'Invalid task type',
'MSG_C2F02095' => 'Insufficient lottery tickets',
'MSG_C3CB20DC' => 'Free tier probability must be between 0 and 100%',
'MSG_C43809BC' => 'Operation failed: ',
'MSG_C548E557' => 'Missing parameters: agent_id, secret, time, signature are required',
'MSG_C5D5D5E1' => 'Cannot set parent department to a child of current department',
'MSG_C803EA6F' => 'Please register',
'MSG_C80C5EF5' => 'Failed to create image resource',
'MSG_C9BFC7E9' => 'Lottery config not found',
'MSG_CDEA9DD8' => 'Your login credential is invalid or expired, please login again',
'MSG_D15C0759' => 'Invalid secret',
'MSG_D1D1C0A0' => 'Template directory not found',
'MSG_D1E7769C' => 'Parent category cannot be the same as current',
'MSG_D224020F' => 'Free pool config not found',
'MSG_D75845B2' => 'Free tier probabilities (T1T5) sum cannot exceed 100%',
'MSG_DB560C68' => 'Please run composer require phpmailer/phpmailer and restart',
'MSG_DEE31D19' => 'Timestamp expired or invalid, please sync time',
'MSG_DF93D5F9' => 'Token expired, please login again',
'MSG_E12FF883' => 'File size exceeds limit',
'MSG_E15B47C6' => 'Super admin cannot be deleted',
'MSG_E1BFE655' => 'Mail config not set',
'MSG_E5849544' => 'Wrong password',
'MSG_E66BC216' => 'This menu has sub-menus, please delete them first',
'MSG_E6E6288B' => 'System default group cannot be deleted',
'MSG_E84B2B0A' => 'Logged out successfully',
'MSG_E8C8EC80' => 'Invalid config ID exists',
'MSG_E96B26B9' => 'Coin change must be greater than 0',
'MSG_EEDAAC44' => 'Waiting for dependencies to be installed',
'MSG_F0F5F561' => 'Config ID %s not found or tier is empty',
'MSG_F12E5DBA' => 'Reward config must cover 26 cells (id 0-25 or 1-26), currently only %s, cannot generate full 5-30 points and clockwise/counterclockwise mapping',
'MSG_F2643E83' => 'Login credential verification failed',
'MSG_F58CB5C8' => 'This category has sub-categories, please delete them first',
'MSG_F5F9FF11' => 'Paid pool config not found',
'MSG_F7BBA776' => 'Unknown reason',
'MSG_F8EB5084' => 'Signature verification failed',
'MSG_FA5FF202' => 'Cannot set parent to self',
'MSG_FB4C0ADF' => 'Please select tables to generate',
'MSG_FBC50B18' => 'Player not found',
'MSG_FC1E3345' => 'Import file error, please upload correct xlsx file',
'MSG_FDADA275' => 'When paid pool is not selected, please fill paid custom tier probabilities (T1T5)',
'MSG_FE1B67CA' => 'Please provide token',
'Mail config not set' => 'Mail config not set',
'Missing parameters: agent_id, secret, time, signature are required' => 'Missing parameters: agent_id, secret, time, signature are required',
'NO_AVAILABLE_REWARD_CONFIG' => 'No available reward config',
'No available reward config' => 'No available reward config',
'No name=default pool config found, please create one first' => 'No name=default pool config found, please create one first',
'No permission to operate department data' => 'No permission to operate department data',
'No permission to operate role data' => 'No permission to operate role data',
'No permission to operate this data' => 'No permission to operate this data',
'OLD_PASSWORD_WRONG' => 'Old password is incorrect',
'Old password is incorrect' => 'Old password is incorrect',
'Only super admin can perform this action' => 'Only super admin can perform this action',
'Operation failed: ' => 'Operation failed: ',
'PASSWORD_WRONG' => 'Wrong password',
'Paid pool config not found' => 'Paid pool config not found',
'Paid tier probabilities (T1T5) sum cannot exceed 100%' => 'Paid tier probabilities (T1T5) sum cannot exceed 100%',
'Paid tier probability must be between 0 and 100%' => 'Paid tier probability must be between 0 and 100%',
'Parent category cannot be the same as current' => 'Parent category cannot be the same as current',
'Parent department cannot be the same as current department' => 'Parent department cannot be the same as current department',
'Player not found' => 'Player not found',
'Please login again' => 'Please login again',
'Please login again (account logged in elsewhere)' => 'Please login again (account logged in elsewhere)',
'Please provide auth-token' => 'Please provide auth-token',
'Please provide token' => 'Please provide token',
'Please register' => 'Please register',
'Please run composer require phpmailer/phpmailer and restart' => 'Please run composer require phpmailer/phpmailer and restart',
'Please select tables to generate' => 'Please select tables to generate',
'Please set app name first' => 'Please set app name first',
'Plugin already exists' => 'Plugin already exists',
'Plugin base config is incomplete' => 'Plugin base config is incomplete',
'Plugin base config is invalid' => 'Plugin base config is invalid',
'Plugin directory not found' => 'Plugin directory not found',
'Plugin install directory is already occupied' => 'Plugin install directory is already occupied',
'Reward config is empty, please maintain dice_reward_config first' => 'Reward config is empty, please maintain dice_reward_config first',
'SUCCESS' => 'Success',
'SUPER_ADMIN_CANNOT_DELETE' => 'Super admin cannot be deleted',
'Service timeout: ' => 'Service timeout: ',
'Signature verification failed' => 'Signature verification failed',
'Sum of paid/free direction counts must be greater than 0' => 'Sum of paid/free direction counts must be greater than 0',
'Super admin cannot be deleted' => 'Super admin cannot be deleted',
'System default group cannot be deleted' => 'System default group cannot be deleted',
'System file generation error' => 'System file generation error',
'TOKEN_EXPIRED_RELOGIN' => 'Token expired, please login again',
'TOKEN_FORMAT_INVALID' => 'Token format invalid',
'TOKEN_INVALID' => 'Invalid or expired token',
'TOKEN_REQUIRED' => 'Please provide token',
'Target category not found' => 'Target category not found',
'Template directory not found' => 'Template directory not found',
'Template not found' => 'Template not found',
'Test count only supports 100, 500, 1000, 5000, 10000' => 'Test count only supports 100, 500, 1000, 5000, 10000',
'Test record not found' => 'Test record not found',
'This category has sub-categories, please delete them first' => 'This category has sub-categories, please delete them first',
'This department has sub-departments, please delete them first' => 'This department has sub-departments, please delete them first',
'This department has users, please delete or transfer them first' => 'This department has users, please delete or transfer them first',
'This dict code already exists' => 'This dict code already exists',
'This menu has sub-menus, please delete them first' => 'This menu has sub-menus, please delete them first',
'Timestamp expired or invalid, please sync time' => 'Timestamp expired or invalid, please sync time',
'Token expired, please login again' => 'Token expired, please login again',
'Token format invalid' => 'Token format invalid',
'USERNAME_PASSWORD_REQUIRED' => 'username and password are required',
'USERNAME_REQUIRED' => 'username is required',
'USER_NOT_FOUND' => 'User not found',
'Update data error, please check' => 'Update data error, please check',
'Upload mode not found' => 'Upload mode not found',
'User not found' => 'User not found',
'Waiting for dependencies to be installed' => 'Waiting for dependencies to be installed',
'When free pool is not selected, please fill free custom tier probabilities (T1T5)' => 'When free pool is not selected, please fill free custom tier probabilities (T1T5)',
'When paid pool is not selected, please fill paid custom tier probabilities (T1T5)' => 'When paid pool is not selected, please fill paid custom tier probabilities (T1T5)',
'Wrong password' => 'Wrong password',
'Your login credential is invalid or expired, please login again' => 'Your login credential is invalid or expired, please login again',
'add failed' => 'add failed',
'add success' => 'add success',
'admin already installed, to reinstall please delete env file and restart' => 'admin already installed, to reinstall please delete env file and restart',
'all test data cleared' => 'all test data cleared',
'auth-token expired' => 'auth-token expired',
'auth-token format invalid' => 'auth-token format invalid',
'auth-token invalid' => 'auth-token invalid',
'auth-token invalid or expired' => 'auth-token invalid or expired',
'captcha error' => 'captcha error',
'clean success' => 'clean success',
'clear cache success' => 'clear cache success',
'clear failed: ' => 'clear failed: ',
'coin cannot be 0' => 'coin cannot be 0',
'coin is required' => 'coin is required',
'connection refused, please check database ip/port and ensure database is running' => 'connection refused, please check database ip/port and ensure database is running',
'create reward mapping success' => 'create reward mapping success',
'database SQL file not found' => 'database SQL file not found',
'database already installed, please do not install again' => 'database already installed, please do not install again',
'database connection timeout, please check ip/port and firewall/security group rules' => 'database connection timeout, please check ip/port and firewall/security group rules',
'database username or password is incorrect' => 'database username or password is incorrect',
'delete failed' => 'delete failed',
'delete success' => 'delete success',
'direction must be 0 (clockwise) or 1 (counterclockwise)' => 'direction must be 0 (clockwise) or 1 (counterclockwise)',
'direction must be 0 or 1' => 'direction must be 0 or 1',
'download failed' => 'download failed',
'download success, please install in plugin list' => 'download success, please install in plugin list',
'execute success' => 'execute success',
'execution failed' => 'execution failed',
'file size cannot exceed 5M' => 'file size cannot exceed 5M',
'import success' => 'import success',
'import success, refreshed DiceReward, DiceRewardConfig(BIGWIN), and pool config' => 'import success, refreshed DiceReward, DiceRewardConfig(BIGWIN), and pool config',
'install success' => 'install success',
'invalid parameters, please check' => 'invalid parameters, please check',
'login expired or invalid, please login again' => 'login expired or invalid, please login again',
'missing parameter id' => 'missing parameter id',
'missing parameter status' => 'missing parameter status',
'missing player_id' => 'missing player_id',
'no permission to delete selected data' => 'no permission to delete selected data',
'no permission to operate this player' => 'no permission to operate this player',
'no permission to update this record' => 'no permission to update this record',
'no permission to view this record' => 'no permission to view this record',
'not found' => 'not found',
'not logged in' => 'not logged in',
'operation failed' => 'operation failed',
'operation success' => 'operation success',
'operation type must be 3 (add) or 4 (deduct)' => 'operation type must be 3 (add) or 4 (deduct)',
'optimize success' => 'optimize success',
'parameter items must be an array' => 'parameter items must be an array',
'please input email' => 'please input email',
'please login first' => 'please login first',
'please provide direction (0=clockwise, 1=counterclockwise)' => 'please provide direction (0=clockwise, 1=counterclockwise)',
'please provide record_id' => 'please provide record_id',
'please select cache to delete' => 'please select cache to delete',
'please select data to delete' => 'please select data to delete',
'please select player' => 'please select player',
'please specify test record' => 'please specify test record',
'record not found' => 'record not found',
'reload success' => 'reload success',
'reset success' => 'reset success',
'save success' => 'save success',
'send failed, please check logs' => 'send failed, please check logs',
'send success' => 'send success',
'super admin cannot reset password' => 'super admin cannot reset password',
'test data cleared' => 'test data cleared',
'too many requests, please try again later' => 'too many requests, please try again later',
'uninstall plugin success' => 'uninstall plugin success',
'update failed' => 'update failed',
'update success' => 'update success',
'upload failed, please upload zip file' => 'upload failed, please upload zip file',
'upload file validation failed' => 'upload file validation failed',
'uploaded file not found' => 'uploaded file not found',
'username is required' => 'username is required',
'version id is required' => 'version id is required',
];

View File

@@ -0,0 +1,346 @@
<?php
declare(strict_types=1);
return [
'ACCOUNT_DISABLED' => '账号已被禁用,无法登录',
'API_AUTH_TOKEN_SECRET is not configured' => '服务端未配置 API_AUTH_TOKEN_SECRET',
'AUTH_TOKEN_EXPIRED' => 'auth-token 已过期',
'AUTH_TOKEN_FORMAT_INVALID' => 'auth-token 格式无效',
'AUTH_TOKEN_INVALID' => 'auth-token 无效',
'AUTH_TOKEN_INVALID_OR_EXPIRED' => 'auth-token 无效或已失效',
'AUTH_TOKEN_REQUIRED' => '请携带 auth-token',
'Account is disabled and cannot log in' => '账号已被禁用,无法登录',
'App type must be plugin or app' => '应用类型必须为plugin或者app',
'BALANCE_LESS_THAN_MIN' => '当前玩家余额%s小于%s无法继续游戏',
'BATCH_DELETE_FORBIDDEN' => '禁止批量删除操作',
'BUY_TICKET_ERROR' => '购买抽奖券错误',
'Balance %s is less than %s, cannot continue' => '当前玩家余额%s小于%s无法继续游戏',
'Batch delete is not allowed' => '禁止批量删除操作',
'CONFIG_ID_NOT_FOUND_OR_TIER_EMPTY' => '配置ID %s 不存在或档位为空',
'Cannot open file or create file failed' => '无法打开文件,或者文件创建失败',
'Cannot operate roles with higher level than current account' => '不能操作比当前账户职级高的角色',
'Cannot set parent category as child of current' => '不能将上级分类设置为当前分类的子分类',
'Cannot set parent department to a child of current department' => '不能将上级部门设置为当前部门的子部门',
'Cannot set parent to self' => '不能设置父级为自身',
'Chunk file not found, please upload again' => '切片文件查找失败,请重新上传',
'Chunk upload must be called in HTTP request context' => '切片上传服务必须在 HTTP 请求环境下调用',
'Coin change must be greater than 0' => '平台币变动必须大于 0',
'Config data not found' => '配置数据未找到',
'Config group not found' => '配置组未找到',
'Counts only support 0, 100, 500, 1000, 5000' => '各抽奖次数仅支持 0、100、500、1000、5000',
'Current table does not support recycle bin' => '当前表不支持回收站功能',
'DATA_NOT_FOUND' => '数据不存在',
'DIRECTION_INVALID' => 'direction 必须为 0 或 1',
'Data not found' => '数据不存在',
'Deduct amount cannot exceed current balance' => '扣点数量不能大于当前余额',
'Delete data error, please check' => '删除数据异常,请检查',
'Dict type not found' => '字典类型不存在',
'FAIL' => '失败',
'Failed to create image resource' => '创建图片资源失败',
'Failed to generate token' => '生成 token 失败',
'Failed to get file resource' => '获取文件资源失败',
'Failed to get login credential, please check' => '登录凭获取失败,请检查',
'Failed to read database config' => '数据库配置读取失败',
'Failed to save file' => '文件保存失败',
'File format not supported for upload' => '不支持该格式的文件上传',
'File generation not allowed in non-debug mode' => '非调试模式下,不允许生成文件',
'File not found' => '文件不存在',
'File size exceeds limit' => '文件大小超过限制',
'Free pool config not found' => '免费奖池配置不存在',
'Free tier probabilities (T1T5) sum cannot exceed 100%' => '免费档位概率 T1T5 之和不能超过 100%',
'Free tier probability must be between 0 and 100%' => '免费档位概率每档只能 0-100%',
'Frontend directory not found, must be same level as backend' => '前端目录查找失败,必须与后端目录为同级目录!',
'INSUFFICIENT_BALANCE' => '平台币不足',
'INSUFFICIENT_TICKETS' => '抽奖券不足',
'Import file error, please upload correct xlsx file' => '导入文件错误请上传正确的文件格式xlsx',
'Insufficient balance' => '平台币不足',
'Insufficient balance to transfer' => '余额不足,无法转出',
'Insufficient lottery tickets' => '抽奖券不足',
'Invalid DiceReward id exists' => '存在无效的 DiceReward id',
'Invalid config ID exists' => '存在无效的配置ID',
'Invalid file format' => '文件格式错误',
'Invalid file type, cannot generate file' => '文件类型异常,无法生成指定文件!',
'Invalid lottery ticket purchase' => '购买抽奖券错误',
'Invalid or expired token' => 'token 无效',
'Invalid parameters' => '参数错误',
'Invalid params: player_id and type are required (3=add, 4=deduct)' => '参数错误:需要有效的 player_id 和 type3=加点4=扣点)',
'Invalid phone format, only +60 Malaysia numbers supported (e.g. +60123456789)' => '手机号格式错误,仅支持 +60 开头的马来西亚号码(如 +60123456789',
'Invalid secret' => '密钥错误',
'Invalid task type' => '任务类型异常',
'LOTTERY_CONFIG_NOT_FOUND' => '奖池配置不存在',
'LOTTERY_POOL_CONFIG_DEFAULT_NOT_FOUND' => '未找到 name=default 的奖池配置,请先创建',
'LOTTERY_POOL_CONFIG_NOT_FOUND_DEFAULT' => '奖池配置不存在(需 name=default',
'Logged out successfully' => '已退出登录',
'Login credential verification failed' => '登录凭证校验失败',
'Lottery pool config not found (name=default required)' => '奖池配置不存在(需 name=default',
'MSG_022FA411' => '应用类型必须为plugin或者app',
'MSG_04BF8179' => '数据不存在',
'MSG_06F06DA6' => 'token 无效',
'MSG_0A17D195' => '付费档位概率每档只能 0-100%',
'MSG_0A9A3E28' => '禁止批量删除操作',
'MSG_0BCF9CBC' => '测试次数仅支持 100、500、1000、5000、10000',
'MSG_0CBB8FF6' => '服务超时,',
'MSG_0D49B785' => '原密码错误',
'MSG_0FE75E2C' => '切片上传服务必须在 HTTP 请求环境下调用',
'MSG_146A3F0D' => '字典类型不存在',
'MSG_17740DB3' => 'token 格式无效',
'MSG_1798E4D4' => '模板不存在',
'MSG_19E651B8' => 'coin 不能为空',
'MSG_1A499109' => '文件不存在',
'MSG_1BB27051' => 'auth-token 已过期',
'MSG_1C1718A6' => '插件已经存在',
'MSG_2240AD6D' => 'auth-token 无效',
'MSG_2273437E' => '当前玩家余额%s小于%s无法继续游戏',
'MSG_22C6787F' => '切片文件查找失败,请重新上传',
'MSG_25BF8A8D' => '扣点数量不能大于当前余额',
'MSG_2830AE01' => '服务超时,没有原因',
'MSG_2ED0C7A8' => '插件的基础配置信息错误',
'MSG_2EE75A5E' => '系统生成文件错误',
'MSG_2EFE74EE' => '非调试模式下,不允许生成文件',
'MSG_2F100DB4' => '不能操作比当前账户职级高的角色',
'MSG_334CE26A' => '没有权限操作该数据',
'MSG_35FB9BA0' => '不支持该格式的文件上传',
'MSG_381A19AE' => '该上传模式不存在',
'MSG_3A4A6DE6' => 'username 不能为空',
'MSG_3A4FF81F' => '没有权限操作该部门数据',
'MSG_3C99F7F7' => '奖励配置为空,请先维护 dice_reward_config',
'MSG_3DBFEA33' => '文件格式错误',
'MSG_43C4D703' => '该部门下存在用户,请先删除或者转移用户',
'MSG_47FDBDD0' => '配置组未找到',
'MSG_4CA58C61' => '修改数据异常,请检查',
'MSG_4F1D271A' => '存在无效的 DiceReward id',
'MSG_521593FB' => '请先设置应用名称',
'MSG_557E5109' => '获取文件资源失败',
'MSG_559AAE0E' => '没有权限操作该角色数据',
'MSG_560E6D91' => '该方向下暂无可用路径配置',
'MSG_5643EE10' => '生成 token 失败',
'MSG_569EC863' => '当前表不支持回收站功能',
'MSG_56B44907' => '目标分类不存在',
'MSG_5CE17D6B' => 'auth-token 无效或已失效',
'MSG_5FF3A2BE' => '数据库配置读取失败',
'MSG_609A300B' => '平台币不足',
'MSG_60B9FC38' => '登录凭获取失败,请检查',
'MSG_64A3C830' => '用户不存在',
'MSG_67C66962' => '未找到 name=default 的奖池配置,请先创建',
'MSG_6C16260B' => '免费未选择奖池配置时请填写免费自定义档位概率T1T5',
'MSG_6CA924A1' => '奖池配置不存在(需 name=default',
'MSG_6F00DFB2' => 'success',
'MSG_7310FDB8' => '前端目录查找失败,必须与后端目录为同级目录!',
'MSG_74E3CB84' => '暂无可用奖励配置',
'MSG_75C6A69F' => '请携带 auth-token',
'MSG_7845F2E9' => '删除数据异常,请检查',
'MSG_86272B49' => 'fail',
'MSG_8865D363' => 'coin 不能为 0',
'MSG_8B6AA32A' => '不能将上级分类设置为当前分类的子分类',
'MSG_8C2E3CE6' => '请重新登录(当前账号已在其他处登录)',
'MSG_8FDBA3F1' => '该字典标识已存在',
'MSG_91272513' => '购买抽奖券错误',
'MSG_94EE6593' => '该插件的安装目录已经被占用',
'MSG_9501E2EF' => '余额不足,无法转出',
'MSG_950B6072' => '配置数据未找到',
'MSG_9A01DFBF' => '该插件的基础配置信息不完善',
'MSG_9D195F25' => '账号已被禁用,无法登录',
'MSG_9EE0801C' => '无法打开文件,或者文件创建失败',
'MSG_9F6B51C8' => '文件类型异常,无法生成指定文件!',
'MSG_A049A679' => '该分类下存在子分类,请先删除子分类',
'MSG_A3165463' => '仅超级管理员能够操作',
'MSG_A4FB6212' => '文件保存失败',
'MSG_A6A8EA8F' => '插件目录不存在',
'MSG_A72A7DC6' => '该部门下存在子部门,请先删除子部门',
'MSG_A778ABB9' => 'auth-token 格式无效',
'MSG_ADA80442' => '请重新登录',
'MSG_AE73E6F3' => '服务端未配置 API_AUTH_TOKEN_SECRET',
'MSG_B387239D' => '付费档位概率 T1T5 之和不能超过 100%',
'MSG_B5C2F2F6' => '各抽奖次数仅支持 0、100、500、1000、5000',
'MSG_B5CD5C51' => '测试记录不存在',
'MSG_B720629D' => 'username、password 不能为空',
'MSG_BA173F12' => '付费或免费至少一种方向次数之和大于 0',
'MSG_BAC2EFB0' => '上级部门和当前部门不能相同',
'MSG_BB3C5A3F' => 'direction 必须为 0 或 1',
'MSG_BBD3198A' => '参数错误:需要有效的 player_id 和 type3=加点4=扣点)',
'MSG_BD8AD1D3' => '手机号格式错误,仅支持 +60 开头的马来西亚号码(如 +60123456789',
'MSG_BEB15D55' => '参数错误',
'MSG_C2E4B3DC' => '任务类型异常',
'MSG_C2F02095' => '抽奖券不足',
'MSG_C3CB20DC' => '免费档位概率每档只能 0-100%',
'MSG_C43809BC' => '操作失败:',
'MSG_C548E557' => '缺少参数agent_id、secret、time、signature 不能为空',
'MSG_C5D5D5E1' => '不能将上级部门设置为当前部门的子部门',
'MSG_C803EA6F' => '请注册',
'MSG_C80C5EF5' => '创建图片资源失败',
'MSG_C9BFC7E9' => '奖池配置不存在',
'MSG_CDEA9DD8' => '您的登录凭证错误或者已过期,请重新登录',
'MSG_D15C0759' => '密钥错误',
'MSG_D1D1C0A0' => '模板目录不存在!',
'MSG_D1E7769C' => '上级分类和当前分类不能相同',
'MSG_D224020F' => '免费奖池配置不存在',
'MSG_D75845B2' => '免费档位概率 T1T5 之和不能超过 100%',
'MSG_DB560C68' => '请执行 composer require phpmailer/phpmailer 并重启',
'MSG_DEE31D19' => '时间戳已过期或无效,请同步时间',
'MSG_DF93D5F9' => 'token 已过期,请重新登录',
'MSG_E12FF883' => '文件大小超过限制',
'MSG_E15B47C6' => '超级管理员禁止删除',
'MSG_E1BFE655' => '未设置邮件配置',
'MSG_E5849544' => '密码错误',
'MSG_E66BC216' => '该菜单下存在子菜单,请先删除子菜单',
'MSG_E6E6288B' => '系统默认分组,无法删除',
'MSG_E84B2B0A' => '已退出登录',
'MSG_E8C8EC80' => '存在无效的配置ID',
'MSG_E96B26B9' => '平台币变动必须大于 0',
'MSG_EEDAAC44' => '等待依赖安装',
'MSG_F0F5F561' => '配置ID %s 不存在或档位为空',
'MSG_F12E5DBA' => '奖励配置需覆盖 26 个格位id 0-25 或 1-26当前仅 %s 条,无法完整生成 5-30 共26个点数、顺时针与逆时针的奖励对照',
'MSG_F2643E83' => '登录凭证校验失败',
'MSG_F58CB5C8' => '该部门下存在子分类,请先删除子分类',
'MSG_F5F9FF11' => '付费奖池配置不存在',
'MSG_F7BBA776' => '没有原因',
'MSG_F8EB5084' => '签名验证失败',
'MSG_FA5FF202' => '不能设置父级为自身',
'MSG_FB4C0ADF' => '请选择要生成的表',
'MSG_FBC50B18' => '玩家不存在',
'MSG_FC1E3345' => '导入文件错误请上传正确的文件格式xlsx',
'MSG_FDADA275' => '付费未选择奖池配置时请填写付费自定义档位概率T1T5',
'MSG_FE1B67CA' => '请携带 token',
'Mail config not set' => '未设置邮件配置',
'Missing parameters: agent_id, secret, time, signature are required' => '缺少参数agent_id、secret、time、signature 不能为空',
'NO_AVAILABLE_REWARD_CONFIG' => '暂无可用奖励配置',
'No available reward config' => '暂无可用奖励配置',
'No name=default pool config found, please create one first' => '未找到 name=default 的奖池配置,请先创建',
'No permission to operate department data' => '没有权限操作该部门数据',
'No permission to operate role data' => '没有权限操作该角色数据',
'No permission to operate this data' => '没有权限操作该数据',
'OLD_PASSWORD_WRONG' => '原密码错误',
'Old password is incorrect' => '原密码错误',
'Only super admin can perform this action' => '仅超级管理员能够操作',
'Operation failed: ' => '操作失败:',
'PASSWORD_WRONG' => '密码错误',
'Paid pool config not found' => '付费奖池配置不存在',
'Paid tier probabilities (T1T5) sum cannot exceed 100%' => '付费档位概率 T1T5 之和不能超过 100%',
'Paid tier probability must be between 0 and 100%' => '付费档位概率每档只能 0-100%',
'Parent category cannot be the same as current' => '上级分类和当前分类不能相同',
'Parent department cannot be the same as current department' => '上级部门和当前部门不能相同',
'Player not found' => '玩家不存在',
'Please login again' => '请重新登录',
'Please login again (account logged in elsewhere)' => '请重新登录(当前账号已在其他处登录)',
'Please provide auth-token' => '请携带 auth-token',
'Please provide token' => '请携带 token',
'Please register' => '请注册',
'Please run composer require phpmailer/phpmailer and restart' => '请执行 composer require phpmailer/phpmailer 并重启',
'Please select tables to generate' => '请选择要生成的表',
'Please set app name first' => '请先设置应用名称',
'Plugin already exists' => '插件已经存在',
'Plugin base config is incomplete' => '该插件的基础配置信息不完善',
'Plugin base config is invalid' => '插件的基础配置信息错误',
'Plugin directory not found' => '插件目录不存在',
'Plugin install directory is already occupied' => '该插件的安装目录已经被占用',
'Reward config is empty, please maintain dice_reward_config first' => '奖励配置为空,请先维护 dice_reward_config',
'SUCCESS' => '成功',
'SUPER_ADMIN_CANNOT_DELETE' => '超级管理员禁止删除',
'Service timeout: ' => '服务超时,',
'Signature verification failed' => '签名验证失败',
'Sum of paid/free direction counts must be greater than 0' => '付费或免费至少一种方向次数之和大于 0',
'Super admin cannot be deleted' => '超级管理员禁止删除',
'System default group cannot be deleted' => '系统默认分组,无法删除',
'System file generation error' => '系统生成文件错误',
'TOKEN_EXPIRED_RELOGIN' => 'token 已过期,请重新登录',
'TOKEN_FORMAT_INVALID' => 'token 格式无效',
'TOKEN_INVALID' => 'token 无效',
'TOKEN_REQUIRED' => '请携带 token',
'Target category not found' => '目标分类不存在',
'Template directory not found' => '模板目录不存在!',
'Template not found' => '模板不存在',
'Test count only supports 100, 500, 1000, 5000, 10000' => '测试次数仅支持 100、500、1000、5000、10000',
'Test record not found' => '测试记录不存在',
'This category has sub-categories, please delete them first' => '该部门下存在子分类,请先删除子分类',
'This department has sub-departments, please delete them first' => '该部门下存在子部门,请先删除子部门',
'This department has users, please delete or transfer them first' => '该部门下存在用户,请先删除或者转移用户',
'This dict code already exists' => '该字典标识已存在',
'This menu has sub-menus, please delete them first' => '该菜单下存在子菜单,请先删除子菜单',
'Timestamp expired or invalid, please sync time' => '时间戳已过期或无效,请同步时间',
'Token expired, please login again' => 'token 已过期,请重新登录',
'Token format invalid' => 'token 格式无效',
'USERNAME_PASSWORD_REQUIRED' => 'username、password 不能为空',
'USERNAME_REQUIRED' => 'username 不能为空',
'USER_NOT_FOUND' => '用户不存在',
'Update data error, please check' => '修改数据异常,请检查',
'Upload mode not found' => '该上传模式不存在',
'User not found' => '用户不存在',
'Waiting for dependencies to be installed' => '等待依赖安装',
'When free pool is not selected, please fill free custom tier probabilities (T1T5)' => '免费未选择奖池配置时请填写免费自定义档位概率T1T5',
'When paid pool is not selected, please fill paid custom tier probabilities (T1T5)' => '付费未选择奖池配置时请填写付费自定义档位概率T1T5',
'Wrong password' => '密码错误',
'Your login credential is invalid or expired, please login again' => '您的登录凭证错误或者已过期,请重新登录',
'add failed' => '添加失败',
'add success' => '添加成功',
'admin already installed, to reinstall please delete env file and restart' => '管理后台已经安装如需重新安装请删除根目录env配置文件并重启',
'all test data cleared' => '已清空所有测试数据',
'auth-token expired' => 'auth-token 已过期',
'auth-token format invalid' => 'auth-token 格式无效',
'auth-token invalid' => 'auth-token 无效',
'auth-token invalid or expired' => 'auth-token 无效或已失效',
'captcha error' => '验证码错误',
'clean success' => '清理成功',
'clear cache success' => '清除缓存成功!',
'clear failed: ' => '清空失败:',
'coin cannot be 0' => 'coin 不能为 0',
'coin is required' => 'coin 不能为空',
'connection refused, please check database ip/port and ensure database is running' => 'Connection refused. 请确认数据库IP端口是否正确数据库已经启动',
'create reward mapping success' => '创建奖励对照成功',
'database SQL file not found' => '数据库SQL文件不存在',
'database already installed, please do not install again' => '数据库已经安装,请勿重复安装',
'database connection timeout, please check ip/port and firewall/security group rules' => '数据库连接超时请确认数据库IP端口是否正确安全组及防火墙已经放行端口',
'database username or password is incorrect' => '数据库用户名或密码错误',
'delete failed' => '删除失败',
'delete success' => '删除成功',
'direction must be 0 (clockwise) or 1 (counterclockwise)' => 'direction 必须为 0顺时针或 1逆时针',
'direction must be 0 or 1' => 'direction 必须为 0 或 1',
'download failed' => '下载失败',
'download success, please install in plugin list' => '下载成功,请在插件列表中安装',
'execute success' => '执行成功',
'execution failed' => '执行失败',
'file size cannot exceed 5M' => '文件大小不能超过5M',
'import success' => '导入成功',
'import success, refreshed DiceReward, DiceRewardConfig(BIGWIN), and pool config' => '导入成功,已刷新 DiceReward、DiceRewardConfig(BIGWIN)、奖池配置',
'install success' => '安装成功',
'invalid parameters, please check' => '参数错误,请检查',
'login expired or invalid, please login again' => '登录已过期或用户信息无效,请重新登录',
'missing parameter id' => '缺少参数 id',
'missing parameter status' => '缺少参数 status',
'missing player_id' => '缺少 player_id',
'no permission to delete selected data' => '无权限删除所选数据',
'no permission to operate this player' => '无权限操作该玩家',
'no permission to update this record' => '无权限修改该记录',
'no permission to view this record' => '无权限查看该记录',
'not found' => '未查找到信息',
'not logged in' => '未登录',
'operation failed' => '操作失败',
'operation success' => '操作成功',
'operation type must be 3 (add) or 4 (deduct)' => '操作类型必须为 3=加点 或 4=扣点',
'optimize success' => '优化成功',
'parameter items must be an array' => '参数 items 必须为数组',
'please input email' => '请输入邮箱',
'please login first' => '请先登录',
'please provide direction (0=clockwise, 1=counterclockwise)' => '请传入 direction0=顺时针 1=逆时针)',
'please provide record_id' => '请传入 record_id',
'please select cache to delete' => '请选择要删除的缓存',
'please select data to delete' => '请选择要删除的数据',
'please select player' => '请选择玩家',
'please specify test record' => '请指定测试记录',
'record not found' => '记录不存在',
'reload success' => '重载成功',
'reset success' => '重置成功',
'save success' => '保存成功',
'send failed, please check logs' => '发送失败,请查看日志',
'send success' => '发送成功',
'super admin cannot reset password' => '超级管理员不允许重置密码',
'test data cleared' => '已清空测试数据',
'too many requests, please try again later' => '请求过于频繁,请稍后再试',
'uninstall plugin success' => '卸载插件成功',
'update failed' => '修改失败',
'update success' => '修改成功',
'upload failed, please upload zip file' => '文件格式上传失败,请选择zip格式文件上传',
'upload file validation failed' => '上传文件校验失败',
'uploaded file not found' => '未找到上传文件',
'username is required' => 'username 不能为空',
'version id is required' => '版本ID不能为空',
];

View File

@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
/**
* 将 “中文=>英文” 的历史映射(可临时放在 $legacy 变量里)转换为英文 key 映射:
* - resource/translations/api/en.php: key=MSG_XXXXXXXX, value=英文
* - resource/translations/api/zh.php: key=MSG_XXXXXXXX, value=中文
*
* 同时保留 resource/translations/api/{zh,en}.php 中已存在的显式英文错误码。
*/
$root = dirname(__DIR__);
$enPath = $root . '/resource/translations/api/en.php';
$zhPath = $root . '/resource/translations/api/zh.php';
$legacy = [];
$en = is_file($enPath) ? (require $enPath) : [];
$zh = is_file($zhPath) ? (require $zhPath) : [];
foreach ($legacy as $cn => $enVal) {
if (!is_string($cn) || $cn === '' || !is_string($enVal)) {
continue;
}
$key = 'MSG_' . strtoupper(sprintf('%08X', crc32($cn)));
if (!isset($en[$key])) {
$en[$key] = $enVal;
}
if (!isset($zh[$key])) {
$zh[$key] = $cn;
}
}
$dump = static function (array $arr): string {
ksort($arr);
$out = "<?php\ndeclare(strict_types=1);\n\nreturn [\n";
foreach ($arr as $k => $v) {
$k = str_replace("'", "\\'", (string) $k);
$v = str_replace("'", "\\'", (string) $v);
$out .= " '{$k}' => '{$v}',\n";
}
$out .= "];\n";
return $out;
};
file_put_contents($enPath, $dump($en));
file_put_contents($zhPath, $dump($zh));
echo "done\n";

View File

@@ -0,0 +1,184 @@
<?php
declare(strict_types=1);
/**
* 批量把代码中的中文 message 替换为英文短句(显式英文,不是错误码):
* - return $this->success('中文...')
* - return $this->fail('中文...', ...)
* - throw new ApiException('中文...', ...)
*
* 英文短句来源resource/translations/api/en.php 与 zh.php 中的 MSG_ 对照crc32 中文生成 key
* 同时自动把“英文短句 => 英文/中文”写入 resource/translations/api/{en,zh}.phpWebman 标准路径)。
*
* 用法:
* php server/scripts/replace_cn_messages_with_en.php
*/
$root = dirname(__DIR__);
$serverDir = $root;
$enPath = $root . '/resource/translations/api/en.php';
$zhPath = $root . '/resource/translations/api/zh.php';
$enMap = is_file($enPath) ? (require $enPath) : [];
$zhMap = is_file($zhPath) ? (require $zhPath) : [];
/** @var array<string, string> $cnToEn */
$cnToEn = [];
foreach ($zhMap as $k => $cn) {
if (!is_string($k) || !is_string($cn)) {
continue;
}
if (strncmp($k, 'MSG_', 4) !== 0) {
continue;
}
$en = $enMap[$k] ?? null;
if (is_string($en) && $en !== '') {
$cnToEn[$cn] = $en;
}
}
$fallbackCn = [
'添加成功' => 'add success',
'修改成功' => 'update success',
'删除成功' => 'delete success',
'操作成功' => 'operation success',
'保存成功' => 'save success',
'执行成功' => 'execute success',
'安装成功' => 'install success',
'导入成功' => 'import success',
'发送成功' => 'send success',
'重载成功' => 'reload success',
'重置成功' => 'reset success',
'卸载插件成功' => 'uninstall plugin success',
'优化成功' => 'optimize success',
'清理成功' => 'clean success',
'清除缓存成功!' => 'clear cache success',
'已清空测试数据' => 'test data cleared',
'已清空所有测试数据' => 'all test data cleared',
'创建奖励对照成功' => 'create reward mapping success',
'导入成功,已刷新 DiceReward、DiceRewardConfig(BIGWIN)、奖池配置' => 'import success, refreshed DiceReward, DiceRewardConfig(BIGWIN), and pool config',
'下载成功,请在插件列表中安装' => 'download success, please install in plugin list',
];
$containsCn = static function (string $s): bool {
return preg_match('/[\x{4e00}-\x{9fff}]/u', $s) === 1;
};
$quote = static function (string $s): string {
return "'" . str_replace("'", "\\'", $s) . "'";
};
$dump = static function (array $arr): string {
ksort($arr);
$out = "<?php\ndeclare(strict_types=1);\n\nreturn [\n";
foreach ($arr as $k => $v) {
$k = str_replace("'", "\\'", (string) $k);
$v = str_replace("'", "\\'", (string) $v);
$out .= " '{$k}' => '{$v}',\n";
}
$out .= "];\n";
return $out;
};
$files = [];
$it = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($serverDir, FilesystemIterator::SKIP_DOTS)
);
foreach ($it as $file) {
/** @var SplFileInfo $file */
if (!$file->isFile()) {
continue;
}
$path = $file->getPathname();
if (substr($path, -4) !== '.php') {
continue;
}
// 跳过 translations 目录与 scripts 自己,避免自我替换
$norm = str_replace('\\', '/', $path);
if (str_contains($norm, '/resource/translations/')) {
continue;
}
if (str_contains($norm, '/scripts/replace_cn_messages_with_en.php')) {
continue;
}
$files[] = $path;
}
$totalReplaced = 0;
$touchedFiles = 0;
$addedKeys = 0;
foreach ($files as $path) {
$content = file_get_contents($path);
if (!is_string($content) || $content === '') {
continue;
}
$replacedInFile = 0;
$newContent = $content;
// 只处理单引号字符串:'...'
$patterns = [
// return $this->success('中文')
'/(\$this->success\(\s*)\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/' => 'success',
// return $this->success($data, '中文')
'/(\$this->success\([^\\)]*?,\s*)\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/' => 'success_msg',
// return $this->fail('中文', ...)
'/(\$this->fail\(\s*)\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/' => 'fail',
// throw new ApiException('中文', ...)
'/(throw\s+new\s+ApiException\(\s*)\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/' => 'exception',
];
foreach ($patterns as $regex => $type) {
$newContent = preg_replace_callback($regex, function (array $m) use (
$containsCn,
$quote,
&$cnToEn,
$fallbackCn,
&$enMap,
&$zhMap,
&$replacedInFile,
&$addedKeys,
$type
) {
$prefix = $m[1];
$raw = $m[2];
$cn = stripcslashes($raw);
if (!$containsCn($cn)) {
return $m[0];
}
$en = $cnToEn[$cn] ?? ($fallbackCn[$cn] ?? null);
if (!is_string($en) || $en === '') {
return $m[0];
}
// 写入翻译表:英文短句作为 key
if (!isset($enMap[$en])) {
$enMap[$en] = $en;
$addedKeys++;
}
if (!isset($zhMap[$en])) {
$zhMap[$en] = $cn;
$addedKeys++;
}
$replacedInFile++;
return $prefix . $quote($en);
}, $newContent) ?? $newContent;
}
if ($replacedInFile > 0 && $newContent !== $content) {
file_put_contents($path, $newContent);
$totalReplaced += $replacedInFile;
$touchedFiles++;
}
}
file_put_contents($enPath, $dump($enMap));
file_put_contents($zhPath, $dump($zhMap));
echo "touched_files={$touchedFiles}\n";
echo "replaced={$totalReplaced}\n";
echo "added_translation_pairs={$addedKeys}\n";

View File

@@ -0,0 +1,108 @@
<?php
declare(strict_types=1);
/**
* 修复替换结果:把代码里的 'E_XXXXXXXX'crc32 的十六进制)替换为真正英文短句。
* 英文短句来源resource/translations/api/en.php 的 MSG_XXXXXXXX。
*
* 同时确保 translations/api/{en,zh}.php 中包含:
* - key=英文短句, en=英文短句
* - key=英文短句, zh=对应中文
*/
$root = dirname(__DIR__);
$serverDir = $root;
$enPath = $root . '/resource/translations/api/en.php';
$zhPath = $root . '/resource/translations/api/zh.php';
$enMap = is_file($enPath) ? (require $enPath) : [];
$zhMap = is_file($zhPath) ? (require $zhPath) : [];
$dump = static function (array $arr): string {
ksort($arr);
$out = "<?php\ndeclare(strict_types=1);\n\nreturn [\n";
foreach ($arr as $k => $v) {
$k = str_replace("'", "\\'", (string) $k);
$v = str_replace("'", "\\'", (string) $v);
$out .= " '{$k}' => '{$v}',\n";
}
$out .= "];\n";
return $out;
};
$files = [];
$it = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($serverDir, FilesystemIterator::SKIP_DOTS)
);
foreach ($it as $file) {
/** @var SplFileInfo $file */
if (!$file->isFile()) {
continue;
}
$path = $file->getPathname();
if (substr($path, -4) !== '.php') {
continue;
}
$norm = str_replace('\\', '/', $path);
if (str_contains($norm, '/resource/translations/')) {
continue;
}
if (str_contains($norm, '/scripts/')) {
continue;
}
$files[] = $path;
}
$touchedFiles = 0;
$replaced = 0;
$added = 0;
foreach ($files as $path) {
$content = file_get_contents($path);
if (!is_string($content) || $content === '') {
continue;
}
$newContent = preg_replace_callback(
"/(['\"])E_([0-9A-Fa-f]{8})\\1/",
function (array $m) use (&$enMap, &$zhMap, &$replaced, &$added) {
$hex = strtoupper($m[2]);
$msgKey = 'MSG_' . $hex;
$en = $enMap[$msgKey] ?? null;
$zh = $zhMap[$msgKey] ?? null;
if (!is_string($en) || $en === '') {
return $m[0];
}
if (!is_string($zh) || $zh === '') {
$zh = $msgKey;
}
if (!isset($enMap[$en])) {
$enMap[$en] = $en;
$added++;
}
if (!isset($zhMap[$en])) {
$zhMap[$en] = $zh;
$added++;
}
$replaced++;
return "'" . str_replace("'", "\\'", $en) . "'";
},
$content
);
if (is_string($newContent) && $newContent !== $content) {
file_put_contents($path, $newContent);
$touchedFiles++;
}
}
file_put_contents($enPath, $dump($enMap));
file_put_contents($zhPath, $dump($zhMap));
echo "touched_files={$touchedFiles}\n";
echo "replaced={$replaced}\n";
echo "added_translation_pairs={$added}\n";

View File

@@ -0,0 +1,215 @@
<?php
declare(strict_types=1);
/**
* 通过 git diff 恢复 E_XXXXXXXX 对应的原中文,并替换为英文短句:
* - 在 server 下查找 "'E_XXXXXXXX'" 并替换为 "'<english phrase>'"
* - 同时写入 resource/translations/api/{en,zh}.phpenglish=>english / english=>中文
*
* 英文短句来源优先级:
* 1) resource/translations/api/en.php 与 zh.php 中的 MSG_ 对照(中文=>英文)
* 2) 内置常用中文短语翻译表
*/
$root = dirname(__DIR__);
$repoRoot = dirname($root);
$enPath = $root . '/resource/translations/api/en.php';
$zhPath = $root . '/resource/translations/api/zh.php';
$enMap = is_file($enPath) ? (require $enPath) : [];
$zhMap = is_file($zhPath) ? (require $zhPath) : [];
/** @var array<string, string> $cnToEn 基于 MSG_ 的中文=>英文 */
$cnToEn = [];
foreach ($zhMap as $k => $cn) {
if (!is_string($k) || !is_string($cn)) {
continue;
}
if (strncmp($k, 'MSG_', 4) !== 0) {
continue;
}
$en = $enMap[$k] ?? null;
if (is_string($en) && $en !== '') {
$cnToEn[$cn] = $en;
}
}
/** 常用中文短语翻译(兜底) */
$fallbackCn = [
'未查找到信息' => 'not found',
'记录不存在' => 'record not found',
'数据不存在' => 'data not found',
'添加失败' => 'add failed',
'修改失败' => 'update failed',
'删除失败' => 'delete failed',
'请选择要删除的数据' => 'please select data to delete',
'参数错误,请检查' => 'invalid parameters, please check',
'参数错误,请检查参数' => 'invalid parameters, please check',
'操作失败' => 'operation failed',
'执行失败' => 'execution failed',
'请先登录' => 'please login first',
'未登录' => 'not logged in',
'下载失败' => 'download failed',
'请求过于频繁,请稍后再试' => 'too many requests, please try again later',
'验证码错误' => 'captcha error',
'请选择要删除的缓存' => 'please select cache to delete',
'请选择要删除的数据' => 'please select data to delete',
'请选择要生成的表' => 'please select tables to generate',
'发送失败,请查看日志' => 'send failed, please check logs',
'请输入邮箱' => 'please input email',
'版本ID不能为空' => 'version id is required',
'上传文件校验失败' => 'upload file validation failed',
'文件大小不能超过5M' => 'file size cannot exceed 5M',
'文件格式上传失败,请选择zip格式文件上传' => 'upload failed, please upload zip file',
'登录已过期或用户信息无效,请重新登录' => 'login expired or invalid, please login again',
'超级管理员不允许重置密码' => 'super admin cannot reset password',
'未找到上传文件' => 'uploaded file not found',
'参数 items 必须为数组' => 'parameter items must be an array',
'缺少参数 id' => 'missing parameter id',
'缺少参数 status' => 'missing parameter status',
'缺少 player_id' => 'missing player_id',
'缺少参数agent_id、secret、time、signature 不能为空' => 'missing parameters: agent_id, secret, time, signature are required',
'无权限查看该记录' => 'no permission to view this record',
'无权限修改该记录' => 'no permission to update this record',
'无权限删除所选数据' => 'no permission to delete selected data',
'无权限操作该玩家' => 'no permission to operate this player',
'请选择玩家' => 'please select player',
'操作类型必须为 3=加点 或 4=扣点' => 'operation type must be 3 (add) or 4 (deduct)',
'请指定测试记录' => 'please specify test record',
'请传入 record_id' => 'please provide record_id',
'请传入 direction0=顺时针 1=逆时针)' => 'please provide direction (0=clockwise, 1=counterclockwise)',
'direction 必须为 0顺时针或 1逆时针' => 'direction must be 0 (clockwise) or 1 (counterclockwise)',
'清空失败:' => 'clear failed: ',
'管理后台已经安装如需重新安装请删除根目录env配置文件并重启' => 'admin already installed, to reinstall please delete env file and restart',
'数据库用户名或密码错误' => 'database username or password is incorrect',
'Connection refused. 请确认数据库IP端口是否正确数据库已经启动' => 'connection refused, please check database ip/port and ensure database is running',
'数据库连接超时请确认数据库IP端口是否正确安全组及防火墙已经放行端口' => 'database connection timeout, please check ip/port and firewall/security group rules',
'数据库已经安装,请勿重复安装' => 'database already installed, please do not install again',
'数据库SQL文件不存在' => 'database SQL file not found',
];
$dump = static function (array $arr): string {
ksort($arr);
$out = "<?php\ndeclare(strict_types=1);\n\nreturn [\n";
foreach ($arr as $k => $v) {
$k = str_replace("'", "\\'", (string) $k);
$v = str_replace("'", "\\'", (string) $v);
$out .= " '{$k}' => '{$v}',\n";
}
$out .= "];\n";
return $out;
};
$diff = shell_exec('git -C ' . escapeshellarg($repoRoot) . ' diff -U0 -- server');
if (!is_string($diff) || $diff === '') {
echo "no diff\n";
exit(0);
}
/** @var array<string, string> $hexToCn */
$hexToCn = [];
$lines = preg_split("/\r\n|\n|\r/", $diff) ?: [];
$prevCn = null;
foreach ($lines as $line) {
// - return $this->fail('未查找到信息');
if (preg_match("/^\\-.*'([^']*?)'.*$/u", $line, $m) === 1) {
$maybeCn = $m[1];
if (preg_match('/[\x{4e00}-\x{9fff}]/u', $maybeCn) === 1) {
$prevCn = $maybeCn;
continue;
}
}
// + return $this->fail('E_FC6490F8');
if ($prevCn !== null && preg_match("/^\\+.*'E_([0-9A-Fa-f]{8})'.*$/", $line, $m) === 1) {
$hexToCn[strtoupper($m[1])] = $prevCn;
$prevCn = null;
continue;
}
// reset when encountering unrelated added/removed line
if (strlen($line) > 0 && ($line[0] === '+' || $line[0] === '-')) {
$prevCn = null;
}
}
if ($hexToCn === []) {
echo "no E_ mappings found in diff\n";
exit(0);
}
// 替换代码中的 E_XXXXXXXX
$serverDir = $root;
$files = [];
$it = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($serverDir, FilesystemIterator::SKIP_DOTS)
);
foreach ($it as $file) {
/** @var SplFileInfo $file */
if (!$file->isFile()) {
continue;
}
$path = $file->getPathname();
if (substr($path, -4) !== '.php') {
continue;
}
$norm = str_replace('\\', '/', $path);
if (str_contains($norm, '/resource/translations/')) {
continue;
}
if (str_contains($norm, '/scripts/')) {
continue;
}
$files[] = $path;
}
$touched = 0;
$replaced = 0;
$addedPairs = 0;
foreach ($files as $path) {
$content = file_get_contents($path);
if (!is_string($content) || $content === '') {
continue;
}
$new = preg_replace_callback(
"/(['\"])E_([0-9A-Fa-f]{8})\\1/",
function (array $m) use (&$enMap, &$zhMap, &$replaced, &$addedPairs, $hexToCn, $cnToEn, $fallbackCn) {
$hex = strtoupper($m[2]);
$cn = $hexToCn[$hex] ?? null;
if (!is_string($cn) || $cn === '') {
return $m[0];
}
$en = $cnToEn[$cn] ?? ($fallbackCn[$cn] ?? null);
if (!is_string($en) || $en === '') {
return $m[0];
}
if (!isset($enMap[$en])) {
$enMap[$en] = $en;
$addedPairs++;
}
if (!isset($zhMap[$en])) {
$zhMap[$en] = $cn;
$addedPairs++;
}
$replaced++;
return "'" . str_replace("'", "\\'", $en) . "'";
},
$content
);
if (is_string($new) && $new !== $content) {
file_put_contents($path, $new);
$touched++;
}
}
file_put_contents($enPath, $dump($enMap));
file_put_contents($zhPath, $dump($zhMap));
echo "touched_files={$touched}\n";
echo "replaced={$replaced}\n";
echo "added_translation_pairs={$addedPairs}\n";