platform orders: add batch bmpa 24h filter

This commit is contained in:
萝卜
2026-03-13 14:13:02 +00:00
parent 96e9b67f64
commit 2e05adf801
3 changed files with 117 additions and 0 deletions

View File

@@ -151,6 +151,8 @@ class PlatformOrderController extends Controller
'syncable_only' => (string) $request->query('syncable_only', ''),
// 只看最近 24 小时批量同步过的订单(可治理追踪)
'batch_synced_24h' => (string) $request->query('batch_synced_24h', ''),
// 只看最近 24 小时批量“标记支付并生效(BMPA)”过的订单(可治理追踪)
'batch_mark_paid_and_activate_24h' => (string) $request->query('batch_mark_paid_and_activate_24h', ''),
// 只看最近 24 小时批量“仅标记为已生效”过的订单(可治理追踪)
'batch_mark_activated_24h' => (string) $request->query('batch_mark_activated_24h', ''),
// 只看“对账不一致”的订单粗版meta.payment_summary.total_amount 与 paid_amount 不一致
@@ -852,6 +854,8 @@ class PlatformOrderController extends Controller
'syncable_only' => (string) $request->query('syncable_only', ''),
// 只看最近 24 小时批量同步过的订单(可治理追踪)
'batch_synced_24h' => (string) $request->query('batch_synced_24h', ''),
// 只看最近 24 小时批量“标记支付并生效(BMPA)”过的订单(可治理追踪)
'batch_mark_paid_and_activate_24h' => (string) $request->query('batch_mark_paid_and_activate_24h', ''),
// 只看最近 24 小时批量“仅标记为已生效”过的订单(可治理追踪)
'batch_mark_activated_24h' => (string) $request->query('batch_mark_activated_24h', ''),
// 只看“对账不一致”的订单粗版meta.payment_summary.total_amount 与 paid_amount 不一致
@@ -1744,6 +1748,19 @@ class PlatformOrderController extends Controller
$builder->whereRaw("JSON_UNQUOTE(JSON_EXTRACT(meta, '$.batch_activation.at')) >= ?", [$since]);
}
})
->when(($filters['batch_mark_paid_and_activate_24h'] ?? '') !== '', function (Builder $builder) {
// 只看最近 24 小时批量“标记支付并生效(BMPA)”过的订单(基于 meta.batch_mark_paid_and_activate.at
$since = now()->subHours(24)->format('Y-m-d H:i:s');
$builder->whereRaw("JSON_EXTRACT(meta, '$.batch_mark_paid_and_activate.at') IS NOT NULL");
$driver = $builder->getQuery()->getConnection()->getDriverName();
if ($driver === 'sqlite') {
$builder->whereRaw("JSON_EXTRACT(meta, '$.batch_mark_paid_and_activate.at') >= ?", [$since]);
} else {
$builder->whereRaw("JSON_UNQUOTE(JSON_EXTRACT(meta, '$.batch_mark_paid_and_activate.at')) >= ?", [$since]);
}
})
->when(($filters['batch_mark_activated_24h'] ?? '') !== '', function (Builder $builder) {
// 只看最近 24 小时批量“仅标记为已生效”过的订单(基于 meta.batch_mark_activated.at
$since = now()->subHours(24)->format('Y-m-d H:i:s');