引入 CurrencyResolver,用于在 DrawCurrentController、DrawResultShowController 与 DrawResultsIndexController 中统一处理币种代码解析。 更新 DrawHallSnapshotBuilder 与 DrawResultViewService 的构建方法,新增币种代码参数支持,确保开奖相关功能中的币种处理一致性。 增强 SettingIndexController:新增允许访问的 KV 配置分组校验。 在 OddsStreamService、PlayConfigStreamService 与 RiskCapStreamService 中新增广播功能,用于在玩法目录变更时推送更新通知。 新增测试用例,验证风险限额发布的广播行为。
68 lines
2.4 KiB
PHP
68 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\V1\Draw;
|
|
|
|
use App\Models\Draw;
|
|
use App\Support\ApiResponse;
|
|
use Illuminate\Http\Request;
|
|
use App\Support\CurrencyResolver;
|
|
use App\Models\DrawResultBatch;
|
|
use App\Support\PaginationTrait;
|
|
use Illuminate\Http\JsonResponse;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Lottery\DrawResultBatchStatus;
|
|
use App\Services\Draw\DrawResultViewService;
|
|
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
|
|
|
/**
|
|
* `GET /api/v1/draw/results` — 已发布开奖往期(公开;对齐 PRD `/api/v1/results`)。
|
|
*/
|
|
final class DrawResultsIndexController extends Controller
|
|
{
|
|
use PaginationTrait;
|
|
|
|
public function __construct(
|
|
private readonly DrawResultViewService $viewer,
|
|
) {}
|
|
|
|
public function __invoke(Request $request): JsonResponse
|
|
{
|
|
$perPage = $this->perPage($request, 'size', 15, 50);
|
|
$page = $this->page($request);
|
|
/** @var string|null $bizDate query `business_date` 或旧的 `date` */
|
|
$bizDate = $request->query('business_date') ?? $request->query('date');
|
|
|
|
$query = Draw::query()
|
|
->whereIn('status', DrawResultViewService::publishedDrawStatuses())
|
|
->where('current_result_version', '>', 0)
|
|
->whereNotNull('draw_time')
|
|
->whereExists(function ($sub): void {
|
|
$sub->selectRaw('1')
|
|
->from((new DrawResultBatch)->getTable())
|
|
->whereColumn('draw_id', 'draws.id')
|
|
->whereColumn('result_version', 'draws.current_result_version')
|
|
->where('status', DrawResultBatchStatus::Published->value);
|
|
});
|
|
|
|
if (is_string($bizDate) && preg_match('/^\d{4}-\d{2}-\d{2}$/', $bizDate)) {
|
|
$query->whereDate('business_date', $bizDate);
|
|
}
|
|
|
|
/** @var LengthAwarePaginator<int, Draw> $paginator */
|
|
$paginator = $query
|
|
->orderByDesc('draw_time')
|
|
->paginate(perPage: $perPage, columns: ['*'], pageName: 'page', page: $page);
|
|
|
|
$currencyCode = CurrencyResolver::resolve($request, $request->lotteryPlayer());
|
|
$decorated = $this->viewer->decoratePaginator($paginator, $currencyCode);
|
|
|
|
return ApiResponse::success([
|
|
'items' => $decorated->items(),
|
|
'total' => $decorated->total(),
|
|
'page' => $decorated->currentPage(),
|
|
'per_page' => $decorated->perPage(),
|
|
'last_page' => $decorated->lastPage(),
|
|
]);
|
|
}
|
|
}
|