platform orders: add batch bmpa 24h filter
This commit is contained in:
@@ -151,6 +151,8 @@ class PlatformOrderController extends Controller
|
|||||||
'syncable_only' => (string) $request->query('syncable_only', ''),
|
'syncable_only' => (string) $request->query('syncable_only', ''),
|
||||||
// 只看最近 24 小时批量同步过的订单(可治理追踪)
|
// 只看最近 24 小时批量同步过的订单(可治理追踪)
|
||||||
'batch_synced_24h' => (string) $request->query('batch_synced_24h', ''),
|
'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 小时批量“仅标记为已生效”过的订单(可治理追踪)
|
// 只看最近 24 小时批量“仅标记为已生效”过的订单(可治理追踪)
|
||||||
'batch_mark_activated_24h' => (string) $request->query('batch_mark_activated_24h', ''),
|
'batch_mark_activated_24h' => (string) $request->query('batch_mark_activated_24h', ''),
|
||||||
// 只看“对账不一致”的订单(粗版):meta.payment_summary.total_amount 与 paid_amount 不一致
|
// 只看“对账不一致”的订单(粗版):meta.payment_summary.total_amount 与 paid_amount 不一致
|
||||||
@@ -852,6 +854,8 @@ class PlatformOrderController extends Controller
|
|||||||
'syncable_only' => (string) $request->query('syncable_only', ''),
|
'syncable_only' => (string) $request->query('syncable_only', ''),
|
||||||
// 只看最近 24 小时批量同步过的订单(可治理追踪)
|
// 只看最近 24 小时批量同步过的订单(可治理追踪)
|
||||||
'batch_synced_24h' => (string) $request->query('batch_synced_24h', ''),
|
'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 小时批量“仅标记为已生效”过的订单(可治理追踪)
|
// 只看最近 24 小时批量“仅标记为已生效”过的订单(可治理追踪)
|
||||||
'batch_mark_activated_24h' => (string) $request->query('batch_mark_activated_24h', ''),
|
'batch_mark_activated_24h' => (string) $request->query('batch_mark_activated_24h', ''),
|
||||||
// 只看“对账不一致”的订单(粗版):meta.payment_summary.total_amount 与 paid_amount 不一致
|
// 只看“对账不一致”的订单(粗版):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]);
|
$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) {
|
->when(($filters['batch_mark_activated_24h'] ?? '') !== '', function (Builder $builder) {
|
||||||
// 只看最近 24 小时批量“仅标记为已生效”过的订单(基于 meta.batch_mark_activated.at)
|
// 只看最近 24 小时批量“仅标记为已生效”过的订单(基于 meta.batch_mark_activated.at)
|
||||||
$since = now()->subHours(24)->format('Y-m-d H:i:s');
|
$since = now()->subHours(24)->format('Y-m-d H:i:s');
|
||||||
|
|||||||
@@ -113,6 +113,10 @@
|
|||||||
<input type="checkbox" name="batch_synced_24h" value="1" @checked(($filters['batch_synced_24h'] ?? '') === '1')>
|
<input type="checkbox" name="batch_synced_24h" value="1" @checked(($filters['batch_synced_24h'] ?? '') === '1')>
|
||||||
<span>最近24小时批量同步过</span>
|
<span>最近24小时批量同步过</span>
|
||||||
</label>
|
</label>
|
||||||
|
<label class="form-inline-row">
|
||||||
|
<input type="checkbox" name="batch_mark_paid_and_activate_24h" value="1" @checked(($filters['batch_mark_paid_and_activate_24h'] ?? '') === '1')>
|
||||||
|
<span>最近24小时批量BMPA过</span>
|
||||||
|
</label>
|
||||||
<label class="form-inline-row">
|
<label class="form-inline-row">
|
||||||
<input type="checkbox" name="batch_mark_activated_24h" value="1" @checked(($filters['batch_mark_activated_24h'] ?? '') === '1')>
|
<input type="checkbox" name="batch_mark_activated_24h" value="1" @checked(($filters['batch_mark_activated_24h'] ?? '') === '1')>
|
||||||
<span>最近24小时批量生效过</span>
|
<span>最近24小时批量生效过</span>
|
||||||
|
|||||||
@@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Models\Merchant;
|
||||||
|
use App\Models\Plan;
|
||||||
|
use App\Models\PlatformOrder;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminPlatformOrderBatchMarkPaidAndActivate24hFilterTest 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_platform_orders_page_can_filter_by_batch_mark_paid_and_activate_24h(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$merchant = Merchant::query()->firstOrFail();
|
||||||
|
$plan = Plan::query()->create([
|
||||||
|
'code' => 'batch_bmpa_24h_filter_plan',
|
||||||
|
'name' => '批量BMPA24h筛选测试套餐',
|
||||||
|
'billing_cycle' => 'monthly',
|
||||||
|
'price' => 10,
|
||||||
|
'list_price' => 10,
|
||||||
|
'status' => 'active',
|
||||||
|
'sort' => 10,
|
||||||
|
'published_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
PlatformOrder::query()->create([
|
||||||
|
'merchant_id' => $merchant->id,
|
||||||
|
'plan_id' => $plan->id,
|
||||||
|
'order_no' => 'PO_BMPA24H_FILTER_RECENT',
|
||||||
|
'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()->subMinutes(20),
|
||||||
|
'paid_at' => now()->subMinutes(18),
|
||||||
|
'activated_at' => now()->subMinutes(10),
|
||||||
|
'meta' => [
|
||||||
|
'batch_mark_paid_and_activate' => [
|
||||||
|
'at' => now()->toDateTimeString(),
|
||||||
|
'admin_id' => 1,
|
||||||
|
'scope' => 'filtered',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
PlatformOrder::query()->create([
|
||||||
|
'merchant_id' => $merchant->id,
|
||||||
|
'plan_id' => $plan->id,
|
||||||
|
'order_no' => 'PO_BMPA24H_FILTER_OLD',
|
||||||
|
'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()->subHours(30),
|
||||||
|
'paid_at' => now()->subHours(30),
|
||||||
|
'activated_at' => now()->subHours(30),
|
||||||
|
'meta' => [
|
||||||
|
'batch_mark_paid_and_activate' => [
|
||||||
|
'at' => now()->subHours(30)->toDateTimeString(),
|
||||||
|
'admin_id' => 1,
|
||||||
|
'scope' => 'filtered',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$res = $this->get('/admin/platform-orders?batch_mark_paid_and_activate_24h=1');
|
||||||
|
$res->assertOk();
|
||||||
|
$res->assertSee('PO_BMPA24H_FILTER_RECENT');
|
||||||
|
$res->assertDontSee('PO_BMPA24H_FILTER_OLD');
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user