chore(admin-platform-order): disable batch sync button when governance blocks
This commit is contained in:
@@ -826,6 +826,20 @@
|
|||||||
|
|
||||||
<div class="tool-group focus-box">
|
<div class="tool-group focus-box">
|
||||||
<div class="tool-group-title">批量同步订阅</div>
|
<div class="tool-group-title">批量同步订阅</div>
|
||||||
|
@php
|
||||||
|
// 批量同步订阅:前端治理提示(后端仍有安全阀阻断,这里只做“减少误点/更可治理”)
|
||||||
|
$batchActivateBlockedReason = '';
|
||||||
|
if ((string) ($filters['syncable_only'] ?? '') !== '1') {
|
||||||
|
$batchActivateBlockedReason = '请先勾选「只看可同步」再执行批量同步。';
|
||||||
|
}
|
||||||
|
if ($batchActivateBlockedReason === '' && ((string) ($filters['receipt_status'] ?? '') === 'none')) {
|
||||||
|
$batchActivateBlockedReason = '当前集合为「无回执」:建议先补齐支付回执留痕后再批量同步。';
|
||||||
|
}
|
||||||
|
if ($batchActivateBlockedReason === '' && (((string) ($filters['reconcile_mismatch'] ?? '') === '1') || ((string) ($filters['refund_inconsistent'] ?? '') === '1'))) {
|
||||||
|
$batchActivateBlockedReason = '当前集合包含「对账不一致/退款不一致」:建议先完成金额/状态治理后再批量同步。';
|
||||||
|
}
|
||||||
|
$batchActivateBlocked = $batchActivateBlockedReason !== '';
|
||||||
|
@endphp
|
||||||
<form method="post" action="/admin/platform-orders/batch-activate-subscriptions" data-action="disable-on-submit" onsubmit="return confirm('确认批量同步当前筛选范围内“可同步”的订单?(仅处理:已支付+已生效+未同步)');" class="mb-10">
|
<form method="post" action="/admin/platform-orders/batch-activate-subscriptions" data-action="disable-on-submit" onsubmit="return confirm('确认批量同步当前筛选范围内“可同步”的订单?(仅处理:已支付+已生效+未同步)');" class="mb-10">
|
||||||
@csrf
|
@csrf
|
||||||
<input type="hidden" name="scope" value="filtered">
|
<input type="hidden" name="scope" value="filtered">
|
||||||
@@ -860,7 +874,10 @@
|
|||||||
|
|
||||||
<div class="muted mb-8">提示:建议先勾选筛选条件「只看可同步」,再执行批量同步。</div>
|
<div class="muted mb-8">提示:建议先勾选筛选条件「只看可同步」,再执行批量同步。</div>
|
||||||
<div class="mt-6">
|
<div class="mt-6">
|
||||||
<button class="btn btn-sm" type="submit">批量同步订阅(当前筛选范围)</button>
|
<button class="btn btn-sm" type="submit" @disabled($batchActivateBlocked) title="{{ $batchActivateBlockedReason }}">批量同步订阅(当前筛选范围)</button>
|
||||||
|
@if($batchActivateBlocked)
|
||||||
|
<div class="muted muted-xs text-danger mt-6" data-role="batch-activate-subscriptions-blocked-hint">提示:{{ $batchActivateBlockedReason }}</div>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,124 @@
|
|||||||
|
<?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 AdminPlatformOrderIndexBatchActivateButtonShouldDisableWhenNotSyncableOnlyOrReceiptNoneTest 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_activate_button_should_disable_when_syncable_only_not_checked(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$merchant = Merchant::query()->firstOrFail();
|
||||||
|
$plan = Plan::query()->create([
|
||||||
|
'code' => 'po_index_batch_sync_btn_disable_plan',
|
||||||
|
'name' => '批量同步按钮禁用测试套餐',
|
||||||
|
'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_IDX_BATCH_SYNC_BTN_DISABLE_0001',
|
||||||
|
'order_type' => 'new_purchase',
|
||||||
|
'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(),
|
||||||
|
'paid_at' => now(),
|
||||||
|
'activated_at' => now(),
|
||||||
|
'meta' => [
|
||||||
|
'payment_summary' => [
|
||||||
|
'count' => 1,
|
||||||
|
'total_amount' => 10,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 未勾选 syncable_only=1
|
||||||
|
$res = $this->get('/admin/platform-orders?payment_status=paid&status=activated');
|
||||||
|
$res->assertOk();
|
||||||
|
|
||||||
|
$html = (string) $res->getContent();
|
||||||
|
|
||||||
|
$this->assertStringContainsString('批量同步订阅(当前筛选范围)', $html);
|
||||||
|
$this->assertStringContainsString('disabled', $html);
|
||||||
|
$this->assertStringContainsString('data-role="batch-activate-subscriptions-blocked-hint"', $html);
|
||||||
|
$this->assertStringContainsString('只看可同步', $html);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_batch_activate_button_should_disable_when_receipt_status_none(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$merchant = Merchant::query()->firstOrFail();
|
||||||
|
$plan = Plan::query()->create([
|
||||||
|
'code' => 'po_index_batch_sync_btn_disable_receipt_none_plan',
|
||||||
|
'name' => '批量同步按钮禁用无回执测试套餐',
|
||||||
|
'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_IDX_BATCH_SYNC_BTN_DISABLE_RC_NONE_0001',
|
||||||
|
'order_type' => 'new_purchase',
|
||||||
|
'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(),
|
||||||
|
'paid_at' => now(),
|
||||||
|
'activated_at' => now(),
|
||||||
|
// meta 为空 => 无回执
|
||||||
|
'meta' => [],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 勾选 syncable_only=1 且 receipt_status=none
|
||||||
|
$res = $this->get('/admin/platform-orders?syncable_only=1&receipt_status=none');
|
||||||
|
$res->assertOk();
|
||||||
|
|
||||||
|
$html = (string) $res->getContent();
|
||||||
|
|
||||||
|
$this->assertStringContainsString('批量同步订阅(当前筛选范围)', $html);
|
||||||
|
$this->assertStringContainsString('disabled', $html);
|
||||||
|
$this->assertStringContainsString('无回执', $html);
|
||||||
|
$this->assertStringContainsString('data-role="batch-activate-subscriptions-blocked-hint"', $html);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user