Subscription show: orders table links BAS/BMPA run_id to batch replay
This commit is contained in:
@@ -466,6 +466,8 @@
|
|||||||
<th>同步状态</th>
|
<th>同步状态</th>
|
||||||
<th>同步时间</th>
|
<th>同步时间</th>
|
||||||
<th>失败原因</th>
|
<th>失败原因</th>
|
||||||
|
<th>BAS run_id</th>
|
||||||
|
<th>BMPA run_id</th>
|
||||||
<th>操作</th>
|
<th>操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -486,6 +488,23 @@
|
|||||||
<td>{{ $order->id }}</td>
|
<td>{{ $order->id }}</td>
|
||||||
@php
|
@php
|
||||||
$orderShowUrl = \App\Support\BackUrl::withBack('/admin/platform-orders/' . $order->id, $selfWithoutBack);
|
$orderShowUrl = \App\Support\BackUrl::withBack('/admin/platform-orders/' . $order->id, $selfWithoutBack);
|
||||||
|
|
||||||
|
$basRunId = (string) (data_get($order->meta, 'batch_activation.run_id') ?? '');
|
||||||
|
$bmpaRunId = (string) (data_get($order->meta, 'batch_mark_paid_and_activate.run_id') ?? '');
|
||||||
|
|
||||||
|
$basBatchUrl = $basRunId !== ''
|
||||||
|
? \App\Support\BackUrl::withBack('/admin/platform-batches/show?' . \Illuminate\Support\Arr::query([
|
||||||
|
'type' => 'bas',
|
||||||
|
'run_id' => $basRunId,
|
||||||
|
]), $selfWithoutBack)
|
||||||
|
: '';
|
||||||
|
|
||||||
|
$bmpaBatchUrl = $bmpaRunId !== ''
|
||||||
|
? \App\Support\BackUrl::withBack('/admin/platform-batches/show?' . \Illuminate\Support\Arr::query([
|
||||||
|
'type' => 'bmpa',
|
||||||
|
'run_id' => $bmpaRunId,
|
||||||
|
]), $selfWithoutBack)
|
||||||
|
: '';
|
||||||
@endphp
|
@endphp
|
||||||
<td><a href="{!! $orderShowUrl !!}">{{ $order->order_no }}</a></td>
|
<td><a href="{!! $orderShowUrl !!}">{{ $order->order_no }}</a></td>
|
||||||
<td>{{ $order->status }}</td>
|
<td>{{ $order->status }}</td>
|
||||||
@@ -504,13 +523,27 @@
|
|||||||
<span class="muted">-</span>
|
<span class="muted">-</span>
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
@if($basBatchUrl !== '')
|
||||||
|
<a class="link" href="{!! $basBatchUrl !!}">{{ $basRunId }}</a>
|
||||||
|
@else
|
||||||
|
<span class="muted">-</span>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@if($bmpaBatchUrl !== '')
|
||||||
|
<a class="link" href="{!! $bmpaBatchUrl !!}">{{ $bmpaRunId }}</a>
|
||||||
|
@else
|
||||||
|
<span class="muted">-</span>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="{!! $orderShowUrl !!}">详情</a>
|
<a href="{!! $orderShowUrl !!}">详情</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@empty
|
@empty
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="11" class="muted table-empty">暂无关联平台订单。</td>
|
<td colspan="13" class="muted table-empty">暂无关联平台订单。</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforelse
|
@endforelse
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Models\Merchant;
|
||||||
|
use App\Models\Plan;
|
||||||
|
use App\Models\PlatformOrder;
|
||||||
|
use App\Models\SiteSubscription;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminSiteSubscriptionShowOrdersTableShouldRenderBatchRunIdColumnsTest 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_site_subscription_show_orders_table_should_render_batch_run_id_columns_and_links(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$merchant = Merchant::query()->firstOrFail();
|
||||||
|
$plan = Plan::query()->create([
|
||||||
|
'code' => 'sub_show_orders_batch_run_id_plan',
|
||||||
|
'name' => '订阅详情订单表批次run_id列测试套餐',
|
||||||
|
'billing_cycle' => 'monthly',
|
||||||
|
'price' => 10,
|
||||||
|
'list_price' => 10,
|
||||||
|
'status' => 'active',
|
||||||
|
'sort' => 10,
|
||||||
|
'published_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$sub = SiteSubscription::query()->create([
|
||||||
|
'merchant_id' => $merchant->id,
|
||||||
|
'plan_id' => $plan->id,
|
||||||
|
'status' => 'activated',
|
||||||
|
'source' => 'manual',
|
||||||
|
'subscription_no' => 'SUB_SHOW_ORDERS_BATCH_RUN_ID_0001',
|
||||||
|
'plan_name' => $plan->name,
|
||||||
|
'billing_cycle' => $plan->billing_cycle,
|
||||||
|
'period_months' => 1,
|
||||||
|
'amount' => 10,
|
||||||
|
'starts_at' => now()->subDay(),
|
||||||
|
'ends_at' => now()->addMonth(),
|
||||||
|
'activated_at' => now()->subDay(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$order = PlatformOrder::query()->create([
|
||||||
|
'merchant_id' => $merchant->id,
|
||||||
|
'plan_id' => $plan->id,
|
||||||
|
'site_subscription_id' => $sub->id,
|
||||||
|
'order_no' => 'PO_SUB_SHOW_ORDERS_BATCH_RUN_ID_0001',
|
||||||
|
'order_type' => 'renewal',
|
||||||
|
'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(),
|
||||||
|
'paid_at' => now(),
|
||||||
|
'activated_at' => now(),
|
||||||
|
'meta' => [
|
||||||
|
'batch_activation' => ['run_id' => 'RUN_BAS_SUB_0001'],
|
||||||
|
'batch_mark_paid_and_activate' => ['run_id' => 'RUN_BMPA_SUB_0001'],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$res = $this->get('/admin/site-subscriptions/' . $sub->id);
|
||||||
|
$res->assertOk();
|
||||||
|
|
||||||
|
// 表头列必须存在
|
||||||
|
$res->assertSee('BAS run_id', false);
|
||||||
|
$res->assertSee('BMPA run_id', false);
|
||||||
|
|
||||||
|
// run_id 值应可点击直达批次复盘页(带 back 回到订阅详情)
|
||||||
|
$expectedBack = urlencode('/admin/site-subscriptions/' . $sub->id);
|
||||||
|
|
||||||
|
$res->assertSee('/admin/platform-batches/show?type=bas&run_id=RUN_BAS_SUB_0001&back=' . $expectedBack, false);
|
||||||
|
$res->assertSee('/admin/platform-batches/show?type=bmpa&run_id=RUN_BMPA_SUB_0001&back=' . $expectedBack, false);
|
||||||
|
|
||||||
|
// 仍应保留订单详情 link
|
||||||
|
$res->assertSee('/admin/platform-orders/' . $order->id . '?back=' . $expectedBack, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user