修改原有框架中英文映射
This commit is contained in:
@@ -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 调用按需重建
|
||||
|
||||
Reference in New Issue
Block a user