feat(billing): 平台订单创建页展示订阅关联提示并加测试
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Models\Merchant;
|
||||
use App\Models\Plan;
|
||||
use App\Models\PlatformOrder;
|
||||
use App\Models\SiteSubscription;
|
||||
use App\Support\SubscriptionActivationService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@@ -39,9 +40,16 @@ class PlatformOrderController extends Controller
|
||||
'remark' => (string) $request->query('remark', ''),
|
||||
];
|
||||
|
||||
$siteSubscription = null;
|
||||
$siteSubscriptionId = (int) ($defaults['site_subscription_id'] ?? 0);
|
||||
if ($siteSubscriptionId > 0) {
|
||||
$siteSubscription = SiteSubscription::query()->with(['merchant', 'plan'])->find($siteSubscriptionId);
|
||||
}
|
||||
|
||||
return view('admin.platform_orders.form', [
|
||||
'merchants' => $merchants,
|
||||
'plans' => $plans,
|
||||
'siteSubscription' => $siteSubscription,
|
||||
'billingCycleLabels' => $this->billingCycleLabels(),
|
||||
'orderTypeLabels' => $this->orderTypeLabels(),
|
||||
'defaults' => $defaults,
|
||||
|
||||
@@ -7,6 +7,16 @@
|
||||
<div class="card mb-20">
|
||||
<p class="muted muted-tight">用于总台运营手工创建一笔平台订单(演示/补单/线下收款录入)。</p>
|
||||
<p class="muted">创建后可在「平台订单」列表中继续推进:标记支付并生效 → 同步订阅(形成最小收费闭环)。</p>
|
||||
|
||||
@if(($siteSubscription ?? null) && $siteSubscription->id)
|
||||
<div class="mt-10">
|
||||
<div class="muted">本订单将关联订阅:</div>
|
||||
<div>
|
||||
<a class="link" href="/admin/site-subscriptions/{{ $siteSubscription->id }}">{{ $siteSubscription->subscription_no }}</a>
|
||||
<span class="muted">(订阅ID:{{ $siteSubscription->id }})</span>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<form method="post" action="/admin/platform-orders" class="card form-grid">
|
||||
|
||||
@@ -47,6 +47,46 @@ class AdminPlatformOrderCreateTest extends TestCase
|
||||
$res->assertSee('创建订单');
|
||||
}
|
||||
|
||||
public function test_platform_admin_can_open_create_platform_order_form_with_site_subscription_hint(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
$merchant = Merchant::query()->firstOrFail();
|
||||
|
||||
$plan = Plan::query()->create([
|
||||
'code' => 'create_order_plan_01b',
|
||||
'name' => '创建订单测试套餐(订阅联动)',
|
||||
'billing_cycle' => 'monthly',
|
||||
'price' => 100,
|
||||
'list_price' => 100,
|
||||
'status' => 'active',
|
||||
'sort' => 10,
|
||||
'published_at' => now(),
|
||||
]);
|
||||
|
||||
$sub = \App\Models\SiteSubscription::query()->create([
|
||||
'merchant_id' => $merchant->id,
|
||||
'plan_id' => $plan->id,
|
||||
'status' => 'activated',
|
||||
'source' => 'manual',
|
||||
'subscription_no' => 'SUB_CREATE_ORDER_HINT_0001',
|
||||
'plan_name' => $plan->name,
|
||||
'billing_cycle' => 'monthly',
|
||||
'period_months' => 1,
|
||||
'amount' => 88,
|
||||
'starts_at' => now()->subDays(2),
|
||||
'ends_at' => now()->addDays(20),
|
||||
'activated_at' => now()->subDays(2),
|
||||
]);
|
||||
|
||||
$res = $this->get('/admin/platform-orders/create?site_subscription_id=' . $sub->id);
|
||||
|
||||
$res->assertOk();
|
||||
$res->assertSee('本订单将关联订阅:');
|
||||
$res->assertSee('SUB_CREATE_ORDER_HINT_0001');
|
||||
$res->assertSee('/admin/site-subscriptions/' . $sub->id);
|
||||
}
|
||||
|
||||
public function test_platform_admin_can_create_platform_order_and_see_it_in_show_page(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
Reference in New Issue
Block a user