补齐套餐详情页与订阅无回执治理入口测试

This commit is contained in:
萝卜
2026-03-20 07:45:29 +08:00
parent 50f73d2222
commit 7bd40a5527
7 changed files with 536 additions and 0 deletions

View File

@@ -162,6 +162,64 @@ class PlanController extends Controller
]);
}
public function show(Request $request, Plan $plan): View
{
$this->ensurePlatformAdmin($request);
$plan->loadCount(['subscriptions', 'platformOrders']);
$summaryStats = [
'subscriptions_count' => (int) SiteSubscription::query()->where('plan_id', $plan->id)->count(),
'activated_subscriptions_count' => (int) SiteSubscription::query()->where('plan_id', $plan->id)->where('status', 'activated')->count(),
'expiring_7d_subscriptions_count' => (int) SiteSubscription::query()
->where('plan_id', $plan->id)
->whereNotNull('ends_at')
->whereBetween('ends_at', [now(), now()->copy()->addDays(7)])
->count(),
'platform_orders_count' => (int) PlatformOrder::query()->where('plan_id', $plan->id)->count(),
'paid_orders_count' => (int) PlatformOrder::query()->where('plan_id', $plan->id)->where('payment_status', 'paid')->count(),
'paid_amount_total' => (float) (PlatformOrder::query()->where('plan_id', $plan->id)->where('payment_status', 'paid')->sum('paid_amount') ?? 0),
'paid_no_receipt_orders_count' => (int) PlatformOrder::query()
->where('plan_id', $plan->id)
->where('payment_status', 'paid')
->whereRaw("JSON_EXTRACT(meta, '$.payment_summary.total_amount') IS NULL")
->whereRaw("JSON_EXTRACT(meta, '$.payment_receipts[0].amount') IS NULL")
->count(),
'sync_failed_orders_count' => (int) PlatformOrder::query()
->where('plan_id', $plan->id)
->whereRaw("JSON_EXTRACT(meta, '$.subscription_activation_error.message') IS NOT NULL")
->count(),
'renewal_missing_subscription_orders_count' => (int) PlatformOrder::query()
->where('plan_id', $plan->id)
->where('order_type', 'renewal')
->whereNull('site_subscription_id')
->count(),
];
$recentOrders = PlatformOrder::query()
->with(['merchant', 'siteSubscription'])
->where('plan_id', $plan->id)
->orderByDesc('id')
->limit(10)
->get();
$recentSubscriptions = SiteSubscription::query()
->with('merchant')
->where('plan_id', $plan->id)
->orderByDesc('id')
->limit(10)
->get();
return view('admin.plans.show', [
'plan' => $plan,
'summaryStats' => $summaryStats,
'recentOrders' => $recentOrders,
'recentSubscriptions' => $recentSubscriptions,
'statusLabels' => $this->statusLabels(),
'billingCycleLabels' => $this->billingCycleLabels(),
]);
}
public function store(Request $request): RedirectResponse
{
$this->ensurePlatformAdmin($request);