admin: subscription show bmpa summary add success/failed links

This commit is contained in:
萝卜
2026-03-18 04:41:15 +08:00
parent 59910e05aa
commit 8fcf880a92
3 changed files with 17 additions and 6 deletions

View File

@@ -94,11 +94,18 @@ class SiteSubscriptionController extends Controller
} }
} }
// 订阅维度BMPA批量标记支付并生效失败订单数(与平台订单列表 bmpa_failed_only 口径一致) // 订阅维度BMPA批量标记支付并生效成功/失败订单数
// - 失败口径与平台订单列表 bmpa_failed_only 一致error.message 存在
// - 成功口径与 bmpa_success_only 一致:存在 run_id 且 error.message 为空
$bmpaFailedOrders = (clone $baseOrdersQuery) $bmpaFailedOrders = (clone $baseOrdersQuery)
->whereRaw("JSON_EXTRACT(meta, '$.batch_mark_paid_and_activate_error.message') IS NOT NULL") ->whereRaw("JSON_EXTRACT(meta, '$.batch_mark_paid_and_activate_error.message') IS NOT NULL")
->count(); ->count();
$bmpaSuccessOrders = (clone $baseOrdersQuery)
->whereRaw("JSON_EXTRACT(meta, '$.batch_mark_paid_and_activate.run_id') IS NOT NULL")
->whereRaw("JSON_EXTRACT(meta, '$.batch_mark_paid_and_activate_error.message') IS NULL")
->count();
$summaryStats = $summaryStats + [ $summaryStats = $summaryStats + [
'receipt_orders' => $receiptOrders, 'receipt_orders' => $receiptOrders,
'no_receipt_orders' => $noReceiptOrders, 'no_receipt_orders' => $noReceiptOrders,
@@ -110,7 +117,8 @@ class SiteSubscriptionController extends Controller
'refund_inconsistent_orders' => (int) $refundInconsistentOrders, 'refund_inconsistent_orders' => (int) $refundInconsistentOrders,
// 对账不一致订单(订阅维度) // 对账不一致订单(订阅维度)
'reconcile_mismatch_orders' => (int) $reconcileMismatchOrders, 'reconcile_mismatch_orders' => (int) $reconcileMismatchOrders,
// BMPA 失败订单(订阅维度) // BMPA 成功/失败订单(订阅维度)
'bmpa_success_orders' => (int) $bmpaSuccessOrders,
'bmpa_failed_orders' => (int) $bmpaFailedOrders, 'bmpa_failed_orders' => (int) $bmpaFailedOrders,
// 对账差额:回执总额 - 已付总额(订阅维度) // 对账差额:回执总额 - 已付总额(订阅维度)
'reconciliation_delta' => (float) ($totalReceiptAmount - (float) $metaOrders->sum('paid_amount')), 'reconciliation_delta' => (float) ($totalReceiptAmount - (float) $metaOrders->sum('paid_amount')),

View File

@@ -328,11 +328,13 @@
</div> </div>
<div class="card"> <div class="card">
<h3>BMPA 失败</h3> <h3>BMPA 成功 / 失败</h3>
<div class="num-md"> <div class="num-md">
<a class="link" href="{!! $makePlatformOrderUrl(['site_subscription_id' => $subscription->id, 'bmpa_success_only' => '1']) !!}">{{ $summaryStats['bmpa_success_orders'] ?? 0 }}</a>
<span class="muted"> / </span>
<a class="link" href="{!! $makePlatformOrderUrl(['site_subscription_id' => $subscription->id, 'bmpa_failed_only' => '1']) !!}">{{ $summaryStats['bmpa_failed_orders'] ?? 0 }}</a> <a class="link" href="{!! $makePlatformOrderUrl(['site_subscription_id' => $subscription->id, 'bmpa_failed_only' => '1']) !!}">{{ $summaryStats['bmpa_failed_orders'] ?? 0 }}</a>
</div> </div>
<div class="muted muted-xs">点击跳转:该订阅下「批量标记支付并生效失败」订单</div> <div class="muted muted-xs">点击跳转:该订阅下「BMPA成功 / BMPA失败」订单集合</div>
</div> </div>
<div class="card"> <div class="card">

View File

@@ -23,7 +23,7 @@ class AdminSiteSubscriptionBmpaFailedSummaryCardTest extends TestCase
])->assertRedirect('/admin'); ])->assertRedirect('/admin');
} }
public function test_subscription_show_page_has_bmpa_failed_summary_card_and_link(): void public function test_subscription_show_page_has_bmpa_summary_card_and_links(): void
{ {
$this->loginAsPlatformAdmin(); $this->loginAsPlatformAdmin();
@@ -81,8 +81,9 @@ class AdminSiteSubscriptionBmpaFailedSummaryCardTest extends TestCase
$this->get('/admin/site-subscriptions/' . $sub->id) $this->get('/admin/site-subscriptions/' . $sub->id)
->assertOk() ->assertOk()
->assertSee('BMPA 失败') ->assertSee('BMPA 成功 / 失败')
->assertSee('/admin/platform-orders?site_subscription_id=' . $sub->id . '&bmpa_failed_only=1', false) ->assertSee('/admin/platform-orders?site_subscription_id=' . $sub->id . '&bmpa_failed_only=1', false)
->assertSee('/admin/platform-orders?site_subscription_id=' . $sub->id . '&bmpa_success_only=1', false)
->assertSee('1'); ->assertSee('1');
} }
} }