统一规范状态码
This commit is contained in:
@@ -7,6 +7,7 @@ use support\Request;
|
||||
use support\Response;
|
||||
use app\api\logic\UserLogic;
|
||||
use app\api\logic\GameLogic;
|
||||
use app\api\util\ReturnCode;
|
||||
use app\dice\model\reward_config\DiceRewardConfig;
|
||||
use plugin\saiadmin\basic\OpenController;
|
||||
|
||||
@@ -32,16 +33,16 @@ class GameController extends OpenController
|
||||
}
|
||||
}
|
||||
if (empty($token)) {
|
||||
return $this->fail('请携带 user-token');
|
||||
return $this->fail('请携带 user-token', ReturnCode::MISSING_TOKEN);
|
||||
}
|
||||
$userId = UserLogic::getUserIdFromToken($token);
|
||||
if ($userId === null) {
|
||||
return $this->fail('user-token 无效或已过期');
|
||||
return $this->fail('user-token 无效或已过期', ReturnCode::TOKEN_TIMEOUT);
|
||||
}
|
||||
|
||||
$count = (int) $request->post('count', 0);
|
||||
if (!in_array($count, [1, 5, 10], true)) {
|
||||
return $this->fail('购买抽奖券错误');
|
||||
return $this->fail('购买抽奖券错误', ReturnCode::EMPTY_PARAMS);
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -49,7 +50,7 @@ class GameController extends OpenController
|
||||
$data = $logic->buyLotteryTickets($userId, $count);
|
||||
return $this->success($data);
|
||||
} catch (\plugin\saiadmin\exception\ApiException $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
return $this->fail($e->getMessage(), ReturnCode::EMPTY_PARAMS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user