修改原有框架中英文映射

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

@@ -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;
}