平台订单详情:对账/退款异常时禁用同步订阅并给治理提示块
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
<?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 AdminPlatformOrderShowActivateSubscriptionButtonDisabledWhenGovernanceMismatchTest 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_activate_subscription_button_should_be_disabled_and_show_governance_block_when_reconcile_mismatch(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
$merchant = Merchant::query()->firstOrFail();
|
||||
$plan = Plan::query()->create([
|
||||
'code' => 'po_show_disable_sync_reconcile_mismatch_plan',
|
||||
'name' => '同步订阅禁用-对账不一致测试套餐',
|
||||
'billing_cycle' => 'monthly',
|
||||
'price' => 10,
|
||||
'list_price' => 10,
|
||||
'status' => 'active',
|
||||
'sort' => 10,
|
||||
'published_at' => now(),
|
||||
]);
|
||||
|
||||
// 已支付+已生效,但回执总额=9,paid_amount=10 => reconcile_mismatch=true
|
||||
$order = PlatformOrder::query()->create([
|
||||
'merchant_id' => $merchant->id,
|
||||
'plan_id' => $plan->id,
|
||||
'order_no' => 'PO_SHOW_DISABLE_SYNC_RECON_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' => 9,
|
||||
],
|
||||
'payment_receipts' => [
|
||||
[
|
||||
'type' => 'bank_transfer',
|
||||
'channel' => 'offline',
|
||||
'amount' => 9,
|
||||
'paid_at' => now()->toDateTimeString(),
|
||||
'created_at' => now()->toDateTimeString(),
|
||||
'admin_id' => 1,
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$res = $this->get('/admin/platform-orders/' . $order->id);
|
||||
$res->assertOk();
|
||||
|
||||
$res->assertSee('同步订阅治理提示', false);
|
||||
$res->assertSee('去补回执', false);
|
||||
$res->assertSee('href="/admin/platform-orders/' . $order->id, false); // should include a link back to this page + anchor
|
||||
$res->assertSee('disabled', false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user