| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace App\Http\Controllers\admin;
- use App\Constants\HttpStatus;
- use App\Http\Controllers\Controller;
- use App\Services\ThirdGameBalanceService;
- use Exception;
- use Illuminate\Http\JsonResponse;
- use Illuminate\Validation\ValidationException;
- class ThirdGameOrder extends Controller
- {
- public function index(ThirdGameBalanceService $service): JsonResponse
- {
- try {
- $params = request()->validate([
- 'start_time' => ['required', 'date_format:Y-m-d H:i:s'],
- 'end_time' => ['required', 'date_format:Y-m-d H:i:s', 'after_or_equal:start_time'],
- 'page' => ['nullable', 'integer', 'min:1'],
- 'limit' => ['nullable', 'integer', 'min:1', 'max:2000'],
- ]);
- $result = $service->historyOrders(
- (string) $params['start_time'],
- (string) $params['end_time'],
- (int) ($params['page'] ?? 1),
- (int) ($params['limit'] ?? 200)
- );
- if (!$result['ok']) {
- throw new Exception($result['msg'], HttpStatus::CUSTOM_ERROR);
- }
- unset($result['ok']);
- return $this->success($result);
- } catch (ValidationException $e) {
- return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());
- } catch (Exception $e) {
- return $this->error(HttpStatus::CUSTOM_ERROR, $e->getMessage());
- }
- }
- }
|