test(platform-orders): 清理失败标记 filtered 范围补充 refund_status 口径测试护栏
This commit is contained in:
@@ -84,10 +84,38 @@ class AdminPlatformOrderClearSyncErrorsFilteredTest extends TestCase
|
||||
],
|
||||
]);
|
||||
|
||||
// 仅清理“status=pending”范围内的失败标记:应该只清掉 failedA
|
||||
$failedRefunded = PlatformOrder::query()->create([
|
||||
'merchant_id' => $merchant->id,
|
||||
'plan_id' => $plan->id,
|
||||
'order_no' => 'PO_CLEAR_ERR_F_REFUNDED',
|
||||
'order_type' => 'new_purchase',
|
||||
'status' => 'pending',
|
||||
'payment_status' => 'paid',
|
||||
'plan_name' => $plan->name,
|
||||
'billing_cycle' => $plan->billing_cycle,
|
||||
'period_months' => 1,
|
||||
'quantity' => 1,
|
||||
'payable_amount' => 1,
|
||||
'paid_amount' => 1,
|
||||
'placed_at' => now(),
|
||||
'meta' => [
|
||||
'refund_summary' => [
|
||||
'count' => 1,
|
||||
'total_amount' => 0.50,
|
||||
],
|
||||
'subscription_activation_error' => [
|
||||
'message' => '模拟失败REFUNDED',
|
||||
'at' => now()->toDateTimeString(),
|
||||
'admin_id' => 1,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
// 仅清理“status=pending + refund_status=none”范围内的失败标记:应该只清掉 failedA(不应清掉 failedRefunded)
|
||||
$this->post('/admin/platform-orders/clear-sync-errors', [
|
||||
'scope' => 'filtered',
|
||||
'status' => 'pending',
|
||||
'refund_status' => 'none',
|
||||
])->assertRedirect();
|
||||
|
||||
// 增加一条带 subscription_id 的失败订单,用于验证 site_subscription_id 精确过滤生效
|
||||
@@ -141,11 +169,15 @@ class AdminPlatformOrderClearSyncErrorsFilteredTest extends TestCase
|
||||
|
||||
$failedA->refresh();
|
||||
$failedB->refresh();
|
||||
$failedRefunded->refresh();
|
||||
|
||||
$this->assertEmpty(data_get($failedA->meta, 'subscription_activation_error'));
|
||||
$this->assertNotEmpty(data_get($failedA->meta, 'audit.0.action'));
|
||||
$this->assertSame('clear_sync_error', data_get($failedA->meta, 'audit.0.action'));
|
||||
|
||||
$this->assertNotEmpty(data_get($failedB->meta, 'subscription_activation_error.message'));
|
||||
|
||||
// 有退款的失败订单不应被 refund_status=none 的清理动作误命中
|
||||
$this->assertNotEmpty(data_get($failedRefunded->meta, 'subscription_activation_error.message'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user