Compare commits

...

10 Commits

11 changed files with 952 additions and 5 deletions

View File

@@ -140,6 +140,20 @@
$spotPickNextUrl = \App\Support\BackUrl::withBack($spotPickNextUrl, $safeBackForLinks);
@endphp
<a class="link muted-xs" data-role="batch-spot-check-next" href="{{ $spotPickNextUrl }}">换一单</a>
@php
$spotAfterId = (int) request()->query('spot_after_id', 0);
@endphp
@if($spotAfterId > 0)
@php
$spotPickResetUrl = '/admin/platform-batches/show?' . \Illuminate\Support\Arr::query([
'type' => $type,
'run_id' => $runId,
]);
$spotPickResetUrl = \App\Support\BackUrl::withBack($spotPickResetUrl, $safeBackForLinks);
@endphp
<span class="muted muted-xs"></span>
<a class="link muted-xs" data-role="batch-spot-check-reset" href="{{ $spotPickResetUrl }}">回到最新</a>
@endif
@endif
</div>
@else

View File

@@ -1529,7 +1529,7 @@
<div class="muted muted-xs">治理:<a class="link" href="{!! $bmpaGoFailedUrl !!}">进入 BMPA 失败集合</a></div>
@endif
@else
<a class="link text-danger" href="{!! $safeFullUrlWithQuery(['bmpa_error_keyword' => $bmpaErrMsg, 'page' => null]) !!}">{{ mb_substr($bmpaErrMsg, 0, $SYNC_FAILED_REASON_TRUNCATE_LEN) }}</a>
<a class="link text-danger" href="{!! $safeFullUrlWithQuery(['bmpa_failed_only' => '1', 'bmpa_error_keyword' => $bmpaErrMsg, 'page' => null]) !!}">{{ mb_substr($bmpaErrMsg, 0, $SYNC_FAILED_REASON_TRUNCATE_LEN) }}</a>
@if($bmpaGoBatchReasonUrl !== '')
<div class="muted muted-xs">治理:<a class="link" href="{!! $bmpaGoBatchReasonUrl !!}">本批次按原因筛选</a></div>
@@ -1765,7 +1765,8 @@
@endphp
@if($receiptCount > 0)
@php
$receiptCountShowUrl = \App\Support\BackUrl::withBackAndFragment('/admin/platform-orders/' . $order->id, $selfWithoutBack, 'add-payment-receipt');
// spot-check有回执时优先直达“回执列表区”#payment-receipts而非“新增回执表单”。
$receiptCountShowUrl = \App\Support\BackUrl::withBackAndFragment('/admin/platform-orders/' . $order->id, $selfWithoutBack, 'payment-receipts');
@endphp
<a href="{!! $receiptCountShowUrl !!}" class="muted">{{ $receiptCount }}</a>
@else
@@ -1780,7 +1781,8 @@
@endphp
@if($refundCount > 0)
@php
$refundCountShowUrl = \App\Support\BackUrl::withBackAndFragment('/admin/platform-orders/' . $order->id, $selfWithoutBack, 'add-refund-receipt');
// spot-check有退款记录时优先直达“退款记录区”#refund-receipts而非“新增退款表单”。
$refundCountShowUrl = \App\Support\BackUrl::withBackAndFragment('/admin/platform-orders/' . $order->id, $selfWithoutBack, 'refund-receipts');
@endphp
<a href="{!! $refundCountShowUrl !!}" class="muted">{{ $refundCount }}</a>
@else

View File

@@ -0,0 +1,127 @@
<?php
namespace Tests\Feature;
use App\Models\Merchant;
use App\Models\Plan;
use App\Models\PlatformOrder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformBatchShowPageSpotCheckLinkBackShouldIncludeSpotAfterIdWhenPresentForBasTest extends TestCase
{
use RefreshDatabase;
protected function loginAsPlatformAdmin(): void
{
$this->seed();
$this->post('/admin/login', [
'email' => 'platform.admin@demo.local',
'password' => 'Platform@123456',
])->assertRedirect('/admin');
}
public function test_batch_show_page_spot_check_link_back_should_include_spot_after_id_when_present_for_bas(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'plan_bas_spot_back_after_id_0001',
'name' => 'BAS 批次页抽样复核 back 包含 spot_after_id 护栏测试套餐',
'billing_cycle' => 'monthly',
'price' => 10,
'list_price' => 10,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
$runId = 'BAS_SPOT_BACK_AFTER_ID_0001';
$orderA = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_BAS_SPOT_BACK_AFTER_ID_A',
'order_type' => 'new_purchase',
'status' => 'activated',
'payment_status' => 'paid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 10,
'paid_amount' => 10,
'placed_at' => now()->subMinutes(11),
'paid_at' => now()->subMinutes(10),
'activated_at' => now()->subMinutes(9),
'meta' => [
'batch_activation' => [
'run_id' => $runId,
'last_result' => [
'run_id' => $runId,
'success' => 2,
'failed' => 0,
'matched' => 2,
'processed' => 2,
'top_reasons' => [],
'at' => now()->toDateTimeString(),
],
],
'subscription_activation' => [
'subscription_id' => 201,
'synced_at' => now()->toDateTimeString(),
],
],
]);
$orderB = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_BAS_SPOT_BACK_AFTER_ID_B',
'order_type' => 'new_purchase',
'status' => 'activated',
'payment_status' => 'paid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 10,
'paid_amount' => 10,
'placed_at' => now()->subMinutes(8),
'paid_at' => now()->subMinutes(7),
'activated_at' => now()->subMinutes(6),
'meta' => [
'batch_activation' => [
'run_id' => $runId,
'last_result' => [
'run_id' => $runId,
'success' => 2,
'failed' => 0,
'matched' => 2,
'processed' => 2,
'top_reasons' => [],
'at' => now()->toDateTimeString(),
],
],
'subscription_activation' => [
'subscription_id' => 202,
'synced_at' => now()->toDateTimeString(),
],
],
]);
// spot_after_id=orderB 将抽样切换到更早的 orderA
$html = $this->get('/admin/platform-batches/show?type=bas&run_id=' . $runId . '&spot_after_id=' . $orderB->id)
->assertOk()
->getContent();
$expectedBack = '/admin/platform-batches/show?type=bas&run_id=' . $runId . '&spot_after_id=' . $orderB->id;
$this->assertStringContainsString('data-role="batch-spot-check-link"', $html);
$this->assertStringContainsString('/admin/platform-orders/' . $orderA->id, $html);
$this->assertStringContainsString('#subscription-sync', $html);
$this->assertStringContainsString('back=' . urlencode($expectedBack), $html);
}
}

View File

@@ -0,0 +1,118 @@
<?php
namespace Tests\Feature;
use App\Models\Merchant;
use App\Models\Plan;
use App\Models\PlatformOrder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformBatchShowPageSpotCheckLinkBackShouldIncludeSpotAfterIdWhenPresentTest extends TestCase
{
use RefreshDatabase;
protected function loginAsPlatformAdmin(): void
{
$this->seed();
$this->post('/admin/login', [
'email' => 'platform.admin@demo.local',
'password' => 'Platform@123456',
])->assertRedirect('/admin');
}
public function test_batch_show_page_spot_check_link_back_should_include_spot_after_id_when_present(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'plan_batch_spot_back_after_id_0001',
'name' => '批次页抽样复核 back 包含 spot_after_id 护栏测试套餐',
'billing_cycle' => 'monthly',
'price' => 10,
'list_price' => 10,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
$runId = 'BMPA_SPOT_BACK_AFTER_ID_0001';
$orderA = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_BMPA_SPOT_BACK_AFTER_ID_A',
'order_type' => 'new_purchase',
'status' => 'activated',
'payment_status' => 'paid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 10,
'paid_amount' => 10,
'placed_at' => now()->subMinutes(11),
'paid_at' => now()->subMinutes(10),
'activated_at' => now()->subMinutes(9),
'meta' => [
'batch_mark_paid_and_activate' => [
'run_id' => $runId,
'last_result' => [
'run_id' => $runId,
'success' => 2,
'failed' => 0,
'matched' => 2,
'processed' => 2,
'top_reasons' => [],
'at' => now()->toDateTimeString(),
],
],
],
]);
$orderB = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_BMPA_SPOT_BACK_AFTER_ID_B',
'order_type' => 'new_purchase',
'status' => 'activated',
'payment_status' => 'paid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 10,
'paid_amount' => 10,
'placed_at' => now()->subMinutes(8),
'paid_at' => now()->subMinutes(7),
'activated_at' => now()->subMinutes(6),
'meta' => [
'batch_mark_paid_and_activate' => [
'run_id' => $runId,
'last_result' => [
'run_id' => $runId,
'success' => 2,
'failed' => 0,
'matched' => 2,
'processed' => 2,
'top_reasons' => [],
'at' => now()->toDateTimeString(),
],
],
],
]);
// spot_after_id=orderB 将抽样切换到更早的 orderA
$html = $this->get('/admin/platform-batches/show?type=bmpa&run_id=' . $runId . '&spot_after_id=' . $orderB->id)
->assertOk()
->getContent();
$expectedBack = '/admin/platform-batches/show?type=bmpa&run_id=' . $runId . '&spot_after_id=' . $orderB->id;
$this->assertStringContainsString('data-role="batch-spot-check-link"', $html);
$this->assertStringContainsString('/admin/platform-orders/' . $orderA->id, $html);
$this->assertStringContainsString('back=' . urlencode($expectedBack), $html);
}
}

View File

@@ -0,0 +1,84 @@
<?php
namespace Tests\Feature;
use App\Models\Merchant;
use App\Models\Plan;
use App\Models\PlatformOrder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformBatchShowPageSpotCheckLinkBackShouldReturnToBatchPageTest extends TestCase
{
use RefreshDatabase;
protected function loginAsPlatformAdmin(): void
{
$this->seed();
$this->post('/admin/login', [
'email' => 'platform.admin@demo.local',
'password' => 'Platform@123456',
])->assertRedirect('/admin');
}
public function test_batch_show_page_spot_check_link_should_have_back_to_current_batch_page(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'plan_batch_spot_back_0001',
'name' => '批次页抽样复核 back 回批次页护栏测试套餐',
'billing_cycle' => 'monthly',
'price' => 10,
'list_price' => 10,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
$runId = 'BMPA_SPOT_BACK_0001';
PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_BMPA_SPOT_BACK_0001',
'order_type' => 'new_purchase',
'status' => 'activated',
'payment_status' => 'paid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 10,
'paid_amount' => 10,
'placed_at' => now()->subMinutes(10),
'paid_at' => now()->subMinutes(9),
'activated_at' => now()->subMinutes(8),
'meta' => [
'batch_mark_paid_and_activate' => [
'run_id' => $runId,
'last_result' => [
'run_id' => $runId,
'success' => 1,
'failed' => 0,
'matched' => 1,
'processed' => 1,
'top_reasons' => [],
'at' => now()->toDateTimeString(),
],
],
],
]);
$html = $this->get('/admin/platform-batches/show?type=bmpa&run_id=' . $runId)
->assertOk()
->getContent();
$expectedBack = '/admin/platform-batches/show?type=bmpa&run_id=' . $runId;
$this->assertStringContainsString('data-role="batch-spot-check-link"', $html);
$this->assertStringContainsString('back=' . urlencode($expectedBack), $html);
}
}

View File

@@ -0,0 +1,124 @@
<?php
namespace Tests\Feature;
use App\Models\Merchant;
use App\Models\Plan;
use App\Models\PlatformOrder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformBatchShowPageSpotCheckNextLinkShouldKeepBackForBasTest extends TestCase
{
use RefreshDatabase;
protected function loginAsPlatformAdmin(): void
{
$this->seed();
$this->post('/admin/login', [
'email' => 'platform.admin@demo.local',
'password' => 'Platform@123456',
])->assertRedirect('/admin');
}
public function test_batch_show_page_spot_check_next_link_should_keep_incoming_back_for_bas(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'plan_bas_spot_next_keep_back_0001',
'name' => 'BAS 批次页换一单入口保留 back 护栏测试套餐',
'billing_cycle' => 'monthly',
'price' => 10,
'list_price' => 10,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
$runId = 'BAS_SPOT_NEXT_KEEP_BACK_0001';
PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_BAS_SPOT_NEXT_KEEP_BACK_A',
'order_type' => 'new_purchase',
'status' => 'activated',
'payment_status' => 'paid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 10,
'paid_amount' => 10,
'placed_at' => now()->subMinutes(11),
'paid_at' => now()->subMinutes(10),
'activated_at' => now()->subMinutes(9),
'meta' => [
'batch_activation' => [
'run_id' => $runId,
'last_result' => [
'run_id' => $runId,
'success' => 2,
'failed' => 0,
'matched' => 2,
'processed' => 2,
'top_reasons' => [],
'at' => now()->toDateTimeString(),
],
],
'subscription_activation' => [
'subscription_id' => 101,
'synced_at' => now()->toDateTimeString(),
],
],
]);
PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_BAS_SPOT_NEXT_KEEP_BACK_B',
'order_type' => 'new_purchase',
'status' => 'activated',
'payment_status' => 'paid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 10,
'paid_amount' => 10,
'placed_at' => now()->subMinutes(8),
'paid_at' => now()->subMinutes(7),
'activated_at' => now()->subMinutes(6),
'meta' => [
'batch_activation' => [
'run_id' => $runId,
'last_result' => [
'run_id' => $runId,
'success' => 2,
'failed' => 0,
'matched' => 2,
'processed' => 2,
'top_reasons' => [],
'at' => now()->toDateTimeString(),
],
],
'subscription_activation' => [
'subscription_id' => 102,
'synced_at' => now()->toDateTimeString(),
],
],
]);
$incomingBack = '/admin/platform-orders?batch_activation_run_id=' . $runId;
$html = $this->get('/admin/platform-batches/show?type=bas&run_id=' . $runId . '&back=' . urlencode($incomingBack))
->assertOk()
->getContent();
$this->assertStringContainsString('data-role="batch-spot-check-next"', $html);
$this->assertStringContainsString('back=' . urlencode($incomingBack), $html);
}
}

View File

@@ -0,0 +1,116 @@
<?php
namespace Tests\Feature;
use App\Models\Merchant;
use App\Models\Plan;
use App\Models\PlatformOrder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformBatchShowPageSpotCheckNextLinkShouldKeepBackTest extends TestCase
{
use RefreshDatabase;
protected function loginAsPlatformAdmin(): void
{
$this->seed();
$this->post('/admin/login', [
'email' => 'platform.admin@demo.local',
'password' => 'Platform@123456',
])->assertRedirect('/admin');
}
public function test_batch_show_page_spot_check_next_link_should_keep_incoming_back(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'plan_batch_spot_next_keep_back_0001',
'name' => '批次页换一单入口保留 back 护栏测试套餐',
'billing_cycle' => 'monthly',
'price' => 10,
'list_price' => 10,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
$runId = 'BMPA_SPOT_NEXT_KEEP_BACK_0001';
PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_BMPA_SPOT_NEXT_KEEP_BACK_A',
'order_type' => 'new_purchase',
'status' => 'activated',
'payment_status' => 'paid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 10,
'paid_amount' => 10,
'placed_at' => now()->subMinutes(11),
'paid_at' => now()->subMinutes(10),
'activated_at' => now()->subMinutes(9),
'meta' => [
'batch_mark_paid_and_activate' => [
'run_id' => $runId,
'last_result' => [
'run_id' => $runId,
'success' => 2,
'failed' => 0,
'matched' => 2,
'processed' => 2,
'top_reasons' => [],
'at' => now()->toDateTimeString(),
],
],
],
]);
PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_BMPA_SPOT_NEXT_KEEP_BACK_B',
'order_type' => 'new_purchase',
'status' => 'activated',
'payment_status' => 'paid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 10,
'paid_amount' => 10,
'placed_at' => now()->subMinutes(8),
'paid_at' => now()->subMinutes(7),
'activated_at' => now()->subMinutes(6),
'meta' => [
'batch_mark_paid_and_activate' => [
'run_id' => $runId,
'last_result' => [
'run_id' => $runId,
'success' => 2,
'failed' => 0,
'matched' => 2,
'processed' => 2,
'top_reasons' => [],
'at' => now()->toDateTimeString(),
],
],
],
]);
$incomingBack = '/admin/platform-orders?batch_bmpa_run_id=' . $runId;
$html = $this->get('/admin/platform-batches/show?type=bmpa&run_id=' . $runId . '&back=' . urlencode($incomingBack))
->assertOk()
->getContent();
$this->assertStringContainsString('data-role="batch-spot-check-next"', $html);
$this->assertStringContainsString('back=' . urlencode($incomingBack), $html);
}
}

View File

@@ -0,0 +1,127 @@
<?php
namespace Tests\Feature;
use App\Models\Merchant;
use App\Models\Plan;
use App\Models\PlatformOrder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformBatchShowPageSpotCheckResetLinkShouldKeepBackForBasTest extends TestCase
{
use RefreshDatabase;
protected function loginAsPlatformAdmin(): void
{
$this->seed();
$this->post('/admin/login', [
'email' => 'platform.admin@demo.local',
'password' => 'Platform@123456',
])->assertRedirect('/admin');
}
public function test_batch_show_page_spot_check_reset_link_should_keep_incoming_back_for_bas(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'plan_bas_spot_reset_keep_back_0001',
'name' => 'BAS 批次页回到最新入口保留 back 护栏测试套餐',
'billing_cycle' => 'monthly',
'price' => 10,
'list_price' => 10,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
$runId = 'BAS_SPOT_RESET_KEEP_BACK_0001';
PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_BAS_SPOT_RESET_KEEP_BACK_A',
'order_type' => 'new_purchase',
'status' => 'activated',
'payment_status' => 'paid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 10,
'paid_amount' => 10,
'placed_at' => now()->subMinutes(11),
'paid_at' => now()->subMinutes(10),
'activated_at' => now()->subMinutes(9),
'meta' => [
'batch_activation' => [
'run_id' => $runId,
'last_result' => [
'run_id' => $runId,
'success' => 2,
'failed' => 0,
'matched' => 2,
'processed' => 2,
'top_reasons' => [],
'at' => now()->toDateTimeString(),
],
],
'subscription_activation' => [
'subscription_id' => 301,
'synced_at' => now()->toDateTimeString(),
],
],
]);
$orderB = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_BAS_SPOT_RESET_KEEP_BACK_B',
'order_type' => 'new_purchase',
'status' => 'activated',
'payment_status' => 'paid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 10,
'paid_amount' => 10,
'placed_at' => now()->subMinutes(8),
'paid_at' => now()->subMinutes(7),
'activated_at' => now()->subMinutes(6),
'meta' => [
'batch_activation' => [
'run_id' => $runId,
'last_result' => [
'run_id' => $runId,
'success' => 2,
'failed' => 0,
'matched' => 2,
'processed' => 2,
'top_reasons' => [],
'at' => now()->toDateTimeString(),
],
],
'subscription_activation' => [
'subscription_id' => 302,
'synced_at' => now()->toDateTimeString(),
],
],
]);
$incomingBack = '/admin/platform-orders?batch_activation_run_id=' . $runId;
$html = $this->get('/admin/platform-batches/show?type=bas&run_id=' . $runId . '&spot_after_id=' . $orderB->id . '&back=' . urlencode($incomingBack))
->assertOk()
->getContent();
$this->assertStringContainsString('data-role="batch-spot-check-reset"', $html);
$this->assertStringContainsString('back=' . urlencode($incomingBack), $html);
// reset 链接应回到不带 spot_after_id 的 batch page
$this->assertStringNotContainsString('data-role="batch-spot-check-reset" href="/admin/platform-batches/show?type=bas&amp;run_id=' . $runId . '&amp;spot_after_id=', $html);
}
}

View File

@@ -0,0 +1,116 @@
<?php
namespace Tests\Feature;
use App\Models\Merchant;
use App\Models\Plan;
use App\Models\PlatformOrder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformBatchShowPageSpotCheckResetLinkShouldKeepBackTest extends TestCase
{
use RefreshDatabase;
protected function loginAsPlatformAdmin(): void
{
$this->seed();
$this->post('/admin/login', [
'email' => 'platform.admin@demo.local',
'password' => 'Platform@123456',
])->assertRedirect('/admin');
}
public function test_batch_show_page_spot_check_reset_link_should_keep_incoming_back(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'plan_batch_spot_reset_keep_back_0001',
'name' => '批次页回到最新入口保留 back 护栏测试套餐',
'billing_cycle' => 'monthly',
'price' => 10,
'list_price' => 10,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
$runId = 'BMPA_SPOT_RESET_KEEP_BACK_0001';
PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_BMPA_SPOT_RESET_KEEP_BACK_A',
'order_type' => 'new_purchase',
'status' => 'activated',
'payment_status' => 'paid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 10,
'paid_amount' => 10,
'placed_at' => now()->subMinutes(11),
'paid_at' => now()->subMinutes(10),
'activated_at' => now()->subMinutes(9),
'meta' => [
'batch_mark_paid_and_activate' => [
'run_id' => $runId,
'last_result' => [
'run_id' => $runId,
'success' => 2,
'failed' => 0,
'matched' => 2,
'processed' => 2,
'top_reasons' => [],
'at' => now()->toDateTimeString(),
],
],
],
]);
$orderB = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_BMPA_SPOT_RESET_KEEP_BACK_B',
'order_type' => 'new_purchase',
'status' => 'activated',
'payment_status' => 'paid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 10,
'paid_amount' => 10,
'placed_at' => now()->subMinutes(8),
'paid_at' => now()->subMinutes(7),
'activated_at' => now()->subMinutes(6),
'meta' => [
'batch_mark_paid_and_activate' => [
'run_id' => $runId,
'last_result' => [
'run_id' => $runId,
'success' => 2,
'failed' => 0,
'matched' => 2,
'processed' => 2,
'top_reasons' => [],
'at' => now()->toDateTimeString(),
],
],
],
]);
$incomingBack = '/admin/platform-orders?batch_bmpa_run_id=' . $runId;
$html = $this->get('/admin/platform-batches/show?type=bmpa&run_id=' . $runId . '&spot_after_id=' . $orderB->id . '&back=' . urlencode($incomingBack))
->assertOk()
->getContent();
$this->assertStringContainsString('data-role="batch-spot-check-reset"', $html);
$this->assertStringContainsString('back=' . urlencode($incomingBack), $html);
}
}

View File

@@ -0,0 +1,118 @@
<?php
namespace Tests\Feature;
use App\Models\Merchant;
use App\Models\Plan;
use App\Models\PlatformOrder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformBatchShowPageSpotCheckResetLinkShouldRenderWhenSpotAfterIdPresentTest extends TestCase
{
use RefreshDatabase;
protected function loginAsPlatformAdmin(): void
{
$this->seed();
$this->post('/admin/login', [
'email' => 'platform.admin@demo.local',
'password' => 'Platform@123456',
])->assertRedirect('/admin');
}
public function test_batch_show_page_should_render_spot_check_reset_link_when_spot_after_id_present(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'plan_batch_spot_reset_0001',
'name' => '批次页抽样复核回到最新入口渲染测试套餐',
'billing_cycle' => 'monthly',
'price' => 10,
'list_price' => 10,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
$runId = 'BMPA_SPOT_RESET_0001';
PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_BMPA_SPOT_RESET_A',
'order_type' => 'new_purchase',
'status' => 'activated',
'payment_status' => 'paid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 10,
'paid_amount' => 10,
'placed_at' => now()->subMinutes(11),
'paid_at' => now()->subMinutes(10),
'activated_at' => now()->subMinutes(9),
'meta' => [
'batch_mark_paid_and_activate' => [
'run_id' => $runId,
'last_result' => [
'run_id' => $runId,
'success' => 2,
'failed' => 0,
'matched' => 2,
'processed' => 2,
'top_reasons' => [],
'at' => now()->toDateTimeString(),
],
],
],
]);
$orderB = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_BMPA_SPOT_RESET_B',
'order_type' => 'new_purchase',
'status' => 'activated',
'payment_status' => 'paid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 10,
'paid_amount' => 10,
'placed_at' => now()->subMinutes(8),
'paid_at' => now()->subMinutes(7),
'activated_at' => now()->subMinutes(6),
'meta' => [
'batch_mark_paid_and_activate' => [
'run_id' => $runId,
'last_result' => [
'run_id' => $runId,
'success' => 2,
'failed' => 0,
'matched' => 2,
'processed' => 2,
'top_reasons' => [],
'at' => now()->toDateTimeString(),
],
],
],
]);
$html = $this->get('/admin/platform-batches/show?type=bmpa&run_id=' . $runId . '&spot_after_id=' . $orderB->id)
->assertOk()
->getContent();
$this->assertStringContainsString('data-role="batch-spot-check-reset"', $html);
$this->assertStringContainsString('type=bmpa', $html);
$this->assertStringContainsString('run_id=' . $runId, $html);
$this->assertStringContainsString('data-role="batch-spot-check-reset"', $html);
$this->assertStringContainsString('href="/admin/platform-batches/show?type=bmpa&amp;run_id=' . $runId . '"', $html);
$this->assertStringNotContainsString('data-role="batch-spot-check-reset" href="/admin/platform-batches/show?type=bmpa&amp;run_id=' . $runId . '&amp;spot_after_id=', $html);
}
}

View File

@@ -71,13 +71,14 @@ class AdminPlatformOrderIndexReceiptRefundCountLinksContainBackTest extends Test
'status' => 'pending',
]);
// 有回执/退款记录时:列表点击应直达“记录区”(用于 spot-check 复核),而不是“新增表单”。
$receiptLink = '/admin/platform-orders/' . $order->id . '?' . Arr::query([
'back' => $indexSelfWithoutBack,
]) . '#add-payment-receipt';
]) . '#payment-receipts';
$refundLink = '/admin/platform-orders/' . $order->id . '?' . Arr::query([
'back' => $indexSelfWithoutBack,
]) . '#add-refund-receipt';
]) . '#refund-receipts';
$res->assertSee($receiptLink, false);
$res->assertSee($refundLink, false);