fix(settlement): 操作记录分页、流水动作与坏账幂等加固
- 新增 settlement-operations 合并列表 API,收付/调账接口改为标准分页 - actionable_only 流水在内存过滤后正确分页 - 已结账单流水不再展示补差/冲正快捷动作 - 坏账核销支持 idempotency_key 并写入 result_bill_id - 补充操作记录、流水与坏账幂等相关测试
This commit is contained in:
@@ -2,10 +2,12 @@
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\E2E;
|
||||
|
||||
use App\Services\AdminCaptchaService;
|
||||
use App\Lottery\ErrorCode;
|
||||
use App\Support\ApiResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\AdminCaptchaService;
|
||||
|
||||
/**
|
||||
* E2E 辅助:peek captcha bypass 码。
|
||||
@@ -14,14 +16,15 @@ use Illuminate\Http\Request;
|
||||
* 改用 e2e 约定:captcha_code == "LOTTERY_E2E_BYPASS" 在 LOTTERY_E2E=true 时视为通过。
|
||||
* 本端点不返回任何"答案",仅返回约定码提示。
|
||||
*/
|
||||
final class E2ECaptchaPeekController extends \App\Http\Controllers\Controller
|
||||
final class E2ECaptchaPeekController extends Controller
|
||||
{
|
||||
public function player(Request $request): JsonResponse
|
||||
{
|
||||
$key = (string) $request->input('captcha_key', '');
|
||||
if ($key === '') {
|
||||
return ApiResponse::error('captcha_key required', 'e2e_invalid_input', null, 422);
|
||||
return ApiResponse::error('captcha_key required', ErrorCode::ValidationFailed->value, null, 422);
|
||||
}
|
||||
|
||||
return $this->peek($key, AdminCaptchaService::SCOPE_PLAYER);
|
||||
}
|
||||
|
||||
@@ -29,8 +32,9 @@ final class E2ECaptchaPeekController extends \App\Http\Controllers\Controller
|
||||
{
|
||||
$key = (string) $request->input('captcha_key', '');
|
||||
if ($key === '') {
|
||||
return ApiResponse::error('captcha_key required', 'e2e_invalid_input', null, 422);
|
||||
return ApiResponse::error('captcha_key required', ErrorCode::ValidationFailed->value, null, 422);
|
||||
}
|
||||
|
||||
return $this->peek($key, AdminCaptchaService::SCOPE_ADMIN);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\E2E;
|
||||
|
||||
use App\Lottery\ErrorCode;
|
||||
use App\Lottery\DrawStatus;
|
||||
use App\Support\ApiResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
/**
|
||||
* E2E 辅助:期号时间/状态快进。
|
||||
@@ -19,13 +22,13 @@ use Illuminate\Support\Facades\DB;
|
||||
*
|
||||
* 严格仅在 LOTTERY_E2E=true 时由 E2EServiceProvider 注册。
|
||||
*/
|
||||
final class E2EDrawController extends \App\Http\Controllers\Controller
|
||||
final class E2EDrawController extends Controller
|
||||
{
|
||||
public function closeNow(Request $request, string $drawNo): JsonResponse
|
||||
{
|
||||
$draw = DB::table('draws')->where('draw_no', $drawNo)->first();
|
||||
if (! $draw) {
|
||||
return ApiResponse::error('draw not found', 'e2e_draw_missing', null, 404);
|
||||
return ApiResponse::error('draw not found', ErrorCode::NotFound->value, null, 404);
|
||||
}
|
||||
|
||||
DB::table('draws')
|
||||
@@ -44,7 +47,7 @@ final class E2EDrawController extends \App\Http\Controllers\Controller
|
||||
{
|
||||
$draw = DB::table('draws')->where('draw_no', $drawNo)->first();
|
||||
if (! $draw) {
|
||||
return ApiResponse::error('draw not found', 'e2e_draw_missing', null, 404);
|
||||
return ApiResponse::error('draw not found', ErrorCode::NotFound->value, null, 404);
|
||||
}
|
||||
|
||||
DB::table('draws')
|
||||
@@ -62,7 +65,7 @@ final class E2EDrawController extends \App\Http\Controllers\Controller
|
||||
{
|
||||
$draw = DB::table('draws')->where('draw_no', $drawNo)->first();
|
||||
if (! $draw) {
|
||||
return ApiResponse::error('draw not found', 'e2e_draw_missing', null, 404);
|
||||
return ApiResponse::error('draw not found', ErrorCode::NotFound->value, null, 404);
|
||||
}
|
||||
|
||||
DB::table('draws')
|
||||
@@ -82,8 +85,9 @@ final class E2EDrawController extends \App\Http\Controllers\Controller
|
||||
{
|
||||
$draw = DB::table('draws')->where('draw_no', $drawNo)->first();
|
||||
if (! $draw) {
|
||||
return ApiResponse::error('draw not found', 'e2e_draw_missing', null, 404);
|
||||
return ApiResponse::error('draw not found', ErrorCode::NotFound->value, null, 404);
|
||||
}
|
||||
|
||||
return $this->inspectById((int) $draw->id);
|
||||
}
|
||||
|
||||
@@ -91,11 +95,11 @@ final class E2EDrawController extends \App\Http\Controllers\Controller
|
||||
public function tick(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$exit = \Illuminate\Support\Facades\Artisan::call('lottery:draw-tick');
|
||||
$exit = Artisan::call('lottery:draw-tick');
|
||||
} catch (\Throwable $e) {
|
||||
return ApiResponse::error(
|
||||
'draw-tick failed: '.$e->getMessage(),
|
||||
'e2e_tick_failed',
|
||||
ErrorCode::InternalError->value,
|
||||
['trace' => array_slice(explode("\n", $e->getTraceAsString()), 0, 5)],
|
||||
500,
|
||||
);
|
||||
@@ -103,13 +107,14 @@ final class E2EDrawController extends \App\Http\Controllers\Controller
|
||||
|
||||
return ApiResponse::success([
|
||||
'exit_code' => $exit,
|
||||
'output' => \Illuminate\Support\Facades\Artisan::output(),
|
||||
'output' => Artisan::output(),
|
||||
]);
|
||||
}
|
||||
|
||||
private function inspectById(int $id): JsonResponse
|
||||
{
|
||||
$d = DB::table('draws')->where('id', $id)->first();
|
||||
|
||||
return ApiResponse::success([
|
||||
'id' => (int) $d->id,
|
||||
'draw_no' => $d->draw_no,
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\E2E;
|
||||
|
||||
use App\Lottery\ErrorCode;
|
||||
use App\Support\ApiResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
/**
|
||||
* E2E 辅助:重置/查询玩家状态。
|
||||
@@ -17,7 +19,7 @@ use Illuminate\Support\Facades\DB;
|
||||
*
|
||||
* 严格仅在 LOTTERY_E2E=true 时由 E2EServiceProvider 注册。
|
||||
*/
|
||||
final class E2EPlayerStateController extends \App\Http\Controllers\Controller
|
||||
final class E2EPlayerStateController extends Controller
|
||||
{
|
||||
public function reset(Request $request): JsonResponse
|
||||
{
|
||||
@@ -32,7 +34,7 @@ final class E2EPlayerStateController extends \App\Http\Controllers\Controller
|
||||
->value('id');
|
||||
|
||||
if (! $playerId) {
|
||||
return ApiResponse::error('e2e player not found', 'e2e_player_missing', null, 404);
|
||||
return ApiResponse::error('e2e player not found', ErrorCode::NotFound->value, null, 404);
|
||||
}
|
||||
|
||||
DB::transaction(function () use ($playerId, $balance, $currency) {
|
||||
@@ -70,7 +72,7 @@ final class E2EPlayerStateController extends \App\Http\Controllers\Controller
|
||||
$balance = (int) $request->input('balance', -1);
|
||||
|
||||
if ($balance < 0) {
|
||||
return ApiResponse::error('balance must be >= 0', 'e2e_invalid_input', null, 422);
|
||||
return ApiResponse::error('balance must be >= 0', ErrorCode::ValidationFailed->value, null, 422);
|
||||
}
|
||||
|
||||
$playerId = DB::table('players')
|
||||
@@ -79,7 +81,7 @@ final class E2EPlayerStateController extends \App\Http\Controllers\Controller
|
||||
->value('id');
|
||||
|
||||
if (! $playerId) {
|
||||
return ApiResponse::error('e2e player not found', 'e2e_player_missing', null, 404);
|
||||
return ApiResponse::error('e2e player not found', ErrorCode::NotFound->value, null, 404);
|
||||
}
|
||||
|
||||
DB::table('player_wallets')
|
||||
@@ -130,7 +132,7 @@ final class E2EPlayerStateController extends \App\Http\Controllers\Controller
|
||||
->first();
|
||||
|
||||
if (! $player) {
|
||||
return ApiResponse::error('e2e player not found', 'e2e_player_missing', null, 404);
|
||||
return ApiResponse::error('e2e player not found', ErrorCode::NotFound->value, null, 404);
|
||||
}
|
||||
|
||||
$wallets = DB::table('player_wallets')
|
||||
|
||||
@@ -2,27 +2,29 @@
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\E2E;
|
||||
|
||||
use Firebase\JWT\JWT;
|
||||
use App\Models\Player;
|
||||
use App\Models\AdminSite;
|
||||
use App\Models\AdminUser;
|
||||
use App\Models\AgentNode;
|
||||
use App\Models\Player;
|
||||
use App\Lottery\ErrorCode;
|
||||
use App\Models\PlayerWallet;
|
||||
use App\Support\ApiResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Support\PlayerAuthSource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Support\SiteOperatorRoles;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Support\PlatformSystemRoles;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Services\Agent\AgentNodeService;
|
||||
use App\Services\Integration\PartnerSiteConfigResolver;
|
||||
use App\Support\ApiResponse;
|
||||
use App\Support\PlatformSystemRoles;
|
||||
use App\Support\PlayerAuthSource;
|
||||
use App\Support\SiteOperatorRoles;
|
||||
use Firebase\JWT\JWT;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
/**
|
||||
* E2E 辅助:信用玩家 / SSO JWT / 主站钱包 mock 配置。
|
||||
*/
|
||||
final class E2EProvisionController extends \App\Http\Controllers\Controller
|
||||
final class E2EProvisionController extends Controller
|
||||
{
|
||||
public function setupCreditPlayer(Request $request): JsonResponse
|
||||
{
|
||||
@@ -34,7 +36,7 @@ final class E2EProvisionController extends \App\Http\Controllers\Controller
|
||||
|
||||
$site = AdminSite::query()->where('code', $siteCode)->first();
|
||||
if ($site === null) {
|
||||
return ApiResponse::error('site not found', 'e2e_site_missing', null, 404);
|
||||
return ApiResponse::error('site not found', ErrorCode::NotFound->value, null, 404);
|
||||
}
|
||||
|
||||
$extra = $site->extra_json ?? [];
|
||||
@@ -54,7 +56,7 @@ final class E2EProvisionController extends \App\Http\Controllers\Controller
|
||||
->value('id');
|
||||
|
||||
if ($rootId <= 0) {
|
||||
return ApiResponse::error('root agent missing', 'e2e_agent_missing', null, 500);
|
||||
return ApiResponse::error('root agent missing', ErrorCode::InternalError->value, null, 500);
|
||||
}
|
||||
|
||||
$leafCode = (string) $request->input('agent_code', 'e2e_leaf');
|
||||
@@ -64,9 +66,9 @@ final class E2EProvisionController extends \App\Http\Controllers\Controller
|
||||
->first();
|
||||
|
||||
if ($leaf === null) {
|
||||
$super = \App\Models\AdminUser::query()->where('username', 'admin')->first();
|
||||
$super = AdminUser::query()->where('username', 'admin')->first();
|
||||
if ($super === null) {
|
||||
return ApiResponse::error('admin user missing', 'e2e_admin_missing', null, 500);
|
||||
return ApiResponse::error('admin user missing', ErrorCode::InternalError->value, null, 500);
|
||||
}
|
||||
$leaf = app(AgentNodeService::class)->createChild($super, [
|
||||
'parent_id' => $rootId,
|
||||
@@ -153,12 +155,12 @@ final class E2EProvisionController extends \App\Http\Controllers\Controller
|
||||
|
||||
$site = AdminSite::query()->where('code', $siteCode)->first();
|
||||
if ($site === null) {
|
||||
return ApiResponse::error('site not found', 'e2e_site_missing', null, 404);
|
||||
return ApiResponse::error('site not found', ErrorCode::NotFound->value, null, 404);
|
||||
}
|
||||
|
||||
$roleId = (int) DB::table('admin_roles')->where('slug', $roleSlug)->value('id');
|
||||
if ($roleId <= 0) {
|
||||
return ApiResponse::error('role not found', 'e2e_role_missing', null, 500);
|
||||
return ApiResponse::error('role not found', ErrorCode::InternalError->value, null, 500);
|
||||
}
|
||||
|
||||
/** @var AdminUser $user */
|
||||
@@ -192,7 +194,7 @@ final class E2EProvisionController extends \App\Http\Controllers\Controller
|
||||
$siteCode = (string) ($request->input('site_code') ?: env('E2E_PLAYER_SITE_CODE', 'demo'));
|
||||
$site = AdminSite::query()->where('code', $siteCode)->first();
|
||||
if ($site === null) {
|
||||
return ApiResponse::error('site not found', 'e2e_site_missing', null, 404);
|
||||
return ApiResponse::error('site not found', ErrorCode::NotFound->value, null, 404);
|
||||
}
|
||||
|
||||
$siteId = (int) $site->id;
|
||||
@@ -230,12 +232,12 @@ final class E2EProvisionController extends \App\Http\Controllers\Controller
|
||||
|
||||
$site = AdminSite::query()->where('code', $siteCode)->first();
|
||||
if ($site === null) {
|
||||
return ApiResponse::error('site not found', 'e2e_site_missing', null, 404);
|
||||
return ApiResponse::error('site not found', ErrorCode::NotFound->value, null, 404);
|
||||
}
|
||||
|
||||
$secret = $site->decryptedSsoJwtSecret();
|
||||
if (! is_string($secret) || $secret === '') {
|
||||
return ApiResponse::error('sso secret missing on site', 'e2e_sso_secret_missing', null, 500);
|
||||
return ApiResponse::error('sso secret missing on site', ErrorCode::InternalError->value, null, 500);
|
||||
}
|
||||
|
||||
$now = time();
|
||||
@@ -258,12 +260,12 @@ final class E2EProvisionController extends \App\Http\Controllers\Controller
|
||||
$siteCode = (string) ($request->input('site_code') ?: env('E2E_PLAYER_SITE_CODE', 'demo'));
|
||||
$baseUrl = rtrim((string) $request->input('base_url', ''), '/');
|
||||
if ($baseUrl === '') {
|
||||
return ApiResponse::error('base_url required', 'e2e_invalid_input', null, 422);
|
||||
return ApiResponse::error('base_url required', ErrorCode::ValidationFailed->value, null, 422);
|
||||
}
|
||||
|
||||
$site = AdminSite::query()->where('code', $siteCode)->first();
|
||||
if ($site === null) {
|
||||
return ApiResponse::error('site not found', 'e2e_site_missing', null, 404);
|
||||
return ApiResponse::error('site not found', ErrorCode::NotFound->value, null, 404);
|
||||
}
|
||||
|
||||
$site->wallet_api_url = $baseUrl;
|
||||
@@ -286,7 +288,7 @@ final class E2EProvisionController extends \App\Http\Controllers\Controller
|
||||
|
||||
$site = AdminSite::query()->where('code', $siteCode)->first();
|
||||
if ($site === null) {
|
||||
return ApiResponse::error('site not found', 'e2e_site_missing', null, 404);
|
||||
return ApiResponse::error('site not found', ErrorCode::NotFound->value, null, 404);
|
||||
}
|
||||
|
||||
$site->wallet_api_url = null;
|
||||
|
||||
Reference in New Issue
Block a user