fix(platform-orders): 批量生效/清理失败标记过滤字段对齐列表筛选
This commit is contained in:
@@ -767,6 +767,10 @@ class PlatformOrderController extends Controller
|
|||||||
'keyword' => trim((string) $request->input('keyword', '')),
|
'keyword' => trim((string) $request->input('keyword', '')),
|
||||||
'syncable_only' => (string) $request->input('syncable_only', ''),
|
'syncable_only' => (string) $request->input('syncable_only', ''),
|
||||||
'batch_synced_24h' => (string) $request->input('batch_synced_24h', ''),
|
'batch_synced_24h' => (string) $request->input('batch_synced_24h', ''),
|
||||||
|
// 与列表页筛选保持一致(可治理):用于在批量操作后仍能回到同一口径
|
||||||
|
'batch_mark_activated_24h' => (string) $request->input('batch_mark_activated_24h', ''),
|
||||||
|
'reconcile_mismatch' => (string) $request->input('reconcile_mismatch', ''),
|
||||||
|
'receipt_status' => trim((string) $request->input('receipt_status', '')),
|
||||||
];
|
];
|
||||||
|
|
||||||
// 防误操作:批量同步默认要求先勾选“只看可同步”,避免无意识扩大处理范围
|
// 防误操作:批量同步默认要求先勾选“只看可同步”,避免无意识扩大处理范围
|
||||||
@@ -893,6 +897,10 @@ class PlatformOrderController extends Controller
|
|||||||
'keyword' => trim((string) $request->input('keyword', '')),
|
'keyword' => trim((string) $request->input('keyword', '')),
|
||||||
'syncable_only' => (string) $request->input('syncable_only', ''),
|
'syncable_only' => (string) $request->input('syncable_only', ''),
|
||||||
'batch_synced_24h' => (string) $request->input('batch_synced_24h', ''),
|
'batch_synced_24h' => (string) $request->input('batch_synced_24h', ''),
|
||||||
|
// 与列表页筛选保持一致(可治理):用于在批量操作后仍能回到同一口径
|
||||||
|
'batch_mark_activated_24h' => (string) $request->input('batch_mark_activated_24h', ''),
|
||||||
|
'reconcile_mismatch' => (string) $request->input('reconcile_mismatch', ''),
|
||||||
|
'receipt_status' => trim((string) $request->input('receipt_status', '')),
|
||||||
];
|
];
|
||||||
|
|
||||||
// 防误操作:批量“仅标记为已生效”默认要求当前筛选口径为「已支付 + 待处理(pending)」
|
// 防误操作:批量“仅标记为已生效”默认要求当前筛选口径为「已支付 + 待处理(pending)」
|
||||||
@@ -992,6 +1000,10 @@ class PlatformOrderController extends Controller
|
|||||||
'keyword' => trim((string) $request->input('keyword', '')),
|
'keyword' => trim((string) $request->input('keyword', '')),
|
||||||
'syncable_only' => (string) $request->input('syncable_only', ''),
|
'syncable_only' => (string) $request->input('syncable_only', ''),
|
||||||
'batch_synced_24h' => (string) $request->input('batch_synced_24h', ''),
|
'batch_synced_24h' => (string) $request->input('batch_synced_24h', ''),
|
||||||
|
// 与列表页筛选保持一致(可治理):用于在批量操作后仍能回到同一口径
|
||||||
|
'batch_mark_activated_24h' => (string) $request->input('batch_mark_activated_24h', ''),
|
||||||
|
'reconcile_mismatch' => (string) $request->input('reconcile_mismatch', ''),
|
||||||
|
'receipt_status' => trim((string) $request->input('receipt_status', '')),
|
||||||
];
|
];
|
||||||
|
|
||||||
$query = PlatformOrder::query()
|
$query = PlatformOrder::query()
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
<?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 AdminPlatformOrderBatchMarkActivatedFilterFieldsTest 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_batch_mark_activated_filtered_scope_respects_receipt_status_and_reconcile_mismatch_filters(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$merchant = Merchant::query()->firstOrFail();
|
||||||
|
$plan = Plan::query()->create([
|
||||||
|
'code' => 'batch_mark_activated_filter_fields_plan',
|
||||||
|
'name' => '批量生效(筛选字段)测试套餐',
|
||||||
|
'billing_cycle' => 'monthly',
|
||||||
|
'price' => 10,
|
||||||
|
'list_price' => 10,
|
||||||
|
'status' => 'active',
|
||||||
|
'sort' => 10,
|
||||||
|
'published_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// A:无回执 + 对账不一致(回执总额 0,但 paid_amount=10)=> reconcile_mismatch=1 命中
|
||||||
|
$a = PlatformOrder::query()->create([
|
||||||
|
'merchant_id' => $merchant->id,
|
||||||
|
'plan_id' => $plan->id,
|
||||||
|
'order_no' => 'PO_BMA_FILTER_A',
|
||||||
|
'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' => 10,
|
||||||
|
'paid_amount' => 10,
|
||||||
|
'placed_at' => now(),
|
||||||
|
'paid_at' => now(),
|
||||||
|
'meta' => [],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// B:有回执(summary=10)+ 对账一致 => reconcile_mismatch=1 不应命中
|
||||||
|
$b = PlatformOrder::query()->create([
|
||||||
|
'merchant_id' => $merchant->id,
|
||||||
|
'plan_id' => $plan->id,
|
||||||
|
'order_no' => 'PO_BMA_FILTER_B',
|
||||||
|
'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' => 10,
|
||||||
|
'paid_amount' => 10,
|
||||||
|
'placed_at' => now(),
|
||||||
|
'paid_at' => now(),
|
||||||
|
'meta' => [
|
||||||
|
'payment_summary' => [
|
||||||
|
'total_amount' => 10.00,
|
||||||
|
'count' => 1,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 批量生效:过滤条件=已支付+待处理 + 无回执 + 对账不一致,只应推进 A
|
||||||
|
$this->post('/admin/platform-orders/batch-mark-activated', [
|
||||||
|
'scope' => 'filtered',
|
||||||
|
'payment_status' => 'paid',
|
||||||
|
'status' => 'pending',
|
||||||
|
'receipt_status' => 'none',
|
||||||
|
'reconcile_mismatch' => '1',
|
||||||
|
'limit' => 50,
|
||||||
|
])->assertRedirect();
|
||||||
|
|
||||||
|
$a->refresh();
|
||||||
|
$b->refresh();
|
||||||
|
|
||||||
|
$this->assertSame('activated', $a->status);
|
||||||
|
$this->assertSame('pending', $b->status);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user