platform orders: add bmpa_failed_only filter for governance
This commit is contained in:
@@ -138,6 +138,8 @@ class PlatformOrderController extends Controller
|
||||
// 精确过滤:订阅ID(用于从订阅详情页跳转到平台订单列表时锁定范围)
|
||||
'site_subscription_id' => trim((string) $request->query('site_subscription_id', '')),
|
||||
'fail_only' => (string) $request->query('fail_only', ''),
|
||||
// 只看批量“标记支付并生效”失败:meta.batch_mark_paid_and_activate_error.message 存在
|
||||
'bmpa_failed_only' => (string) $request->query('bmpa_failed_only', ''),
|
||||
'synced_only' => (string) $request->query('synced_only', ''),
|
||||
'sync_status' => trim((string) $request->query('sync_status', '')),
|
||||
'keyword' => trim((string) $request->query('keyword', '')),
|
||||
@@ -819,6 +821,8 @@ class PlatformOrderController extends Controller
|
||||
// 精确过滤:订阅ID(用于从订阅详情页跳转到平台订单列表时锁定范围)
|
||||
'site_subscription_id' => trim((string) $request->query('site_subscription_id', '')),
|
||||
'fail_only' => (string) $request->query('fail_only', ''),
|
||||
// 只看批量“标记支付并生效”失败:meta.batch_mark_paid_and_activate_error.message 存在
|
||||
'bmpa_failed_only' => (string) $request->query('bmpa_failed_only', ''),
|
||||
'synced_only' => (string) $request->query('synced_only', ''),
|
||||
'sync_status' => trim((string) $request->query('sync_status', '')),
|
||||
'keyword' => trim((string) $request->query('keyword', '')),
|
||||
@@ -1533,6 +1537,10 @@ class PlatformOrderController extends Controller
|
||||
// 只看同步失败:meta.subscription_activation_error.message 存在即视为失败
|
||||
$builder->whereRaw("JSON_EXTRACT(meta, '$.subscription_activation_error.message') IS NOT NULL");
|
||||
})
|
||||
->when(($filters['bmpa_failed_only'] ?? '') !== '', function (Builder $builder) {
|
||||
// 只看批量“标记支付并生效”失败:meta.batch_mark_paid_and_activate_error.message 存在即视为失败
|
||||
$builder->whereRaw("JSON_EXTRACT(meta, '$.batch_mark_paid_and_activate_error.message') IS NOT NULL");
|
||||
})
|
||||
->when(($filters['synced_only'] ?? '') !== '', function (Builder $builder) {
|
||||
// 只看已同步:meta.subscription_activation.subscription_id 存在即视为已同步
|
||||
$builder->whereRaw("JSON_EXTRACT(meta, '$.subscription_activation.subscription_id') IS NOT NULL");
|
||||
|
||||
@@ -93,6 +93,10 @@
|
||||
<input type="checkbox" name="fail_only" value="1" @checked(($filters['fail_only'] ?? '') === '1')>
|
||||
<span>只看同步失败</span>
|
||||
</label>
|
||||
<label class="form-inline-row">
|
||||
<input type="checkbox" name="bmpa_failed_only" value="1" @checked(($filters['bmpa_failed_only'] ?? '') === '1')>
|
||||
<span>只看批量标记支付失败</span>
|
||||
</label>
|
||||
<label class="form-inline-row">
|
||||
<input type="checkbox" name="synced_only" value="1" @checked(($filters['synced_only'] ?? '') === '1')>
|
||||
<span>只看已同步</span>
|
||||
|
||||
94
tests/Feature/AdminPlatformOrderBmpaFailedOnlyFilterTest.php
Normal file
94
tests/Feature/AdminPlatformOrderBmpaFailedOnlyFilterTest.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?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 AdminPlatformOrderBmpaFailedOnlyFilterTest 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_bmpa_failed_only(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
$merchant = Merchant::query()->firstOrFail();
|
||||
$plan = Plan::query()->create([
|
||||
'code' => 'bmpa_failed_only_plan',
|
||||
'name' => 'BMPA failed_only 筛选测试套餐',
|
||||
'billing_cycle' => 'monthly',
|
||||
'price' => 10,
|
||||
'list_price' => 10,
|
||||
'status' => 'active',
|
||||
'sort' => 10,
|
||||
'published_at' => now(),
|
||||
]);
|
||||
|
||||
$hit = PlatformOrder::query()->create([
|
||||
'merchant_id' => $merchant->id,
|
||||
'plan_id' => $plan->id,
|
||||
'order_no' => 'PO_BMPA_FAILED_ONLY_HIT',
|
||||
'order_type' => 'new_purchase',
|
||||
'status' => 'pending',
|
||||
'payment_status' => 'unpaid',
|
||||
'plan_name' => $plan->name,
|
||||
'billing_cycle' => $plan->billing_cycle,
|
||||
'period_months' => 1,
|
||||
'quantity' => 1,
|
||||
'payable_amount' => 10,
|
||||
'paid_amount' => 0,
|
||||
'placed_at' => now(),
|
||||
'meta' => [
|
||||
'batch_mark_paid_and_activate_error' => [
|
||||
'message' => '回执总额与应付金额不一致',
|
||||
'at' => now()->toDateTimeString(),
|
||||
'admin_id' => 1,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
PlatformOrder::query()->create([
|
||||
'merchant_id' => $merchant->id,
|
||||
'plan_id' => $plan->id,
|
||||
'order_no' => 'PO_BMPA_FAILED_ONLY_MISS',
|
||||
'order_type' => 'new_purchase',
|
||||
'status' => 'pending',
|
||||
'payment_status' => 'unpaid',
|
||||
'plan_name' => $plan->name,
|
||||
'billing_cycle' => $plan->billing_cycle,
|
||||
'period_months' => 1,
|
||||
'quantity' => 1,
|
||||
'payable_amount' => 10,
|
||||
'paid_amount' => 0,
|
||||
'placed_at' => now(),
|
||||
'meta' => [
|
||||
'subscription_activation_error' => [
|
||||
'message' => '订阅同步失败',
|
||||
'at' => now()->toDateTimeString(),
|
||||
'admin_id' => 1,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$res = $this->get('/admin/platform-orders?bmpa_failed_only=1');
|
||||
$res->assertOk();
|
||||
|
||||
$res->assertSee('批量标记支付并生效失败原因 TOP5');
|
||||
$res->assertSee($hit->order_no);
|
||||
$res->assertDontSee('PO_BMPA_FAILED_ONLY_MISS');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user