feat(platform-orders): 增加对账不一致筛选(回执总额≠已付金额)
This commit is contained in:
102
tests/Feature/AdminPlatformOrderReconcileMismatchFilterTest.php
Normal file
102
tests/Feature/AdminPlatformOrderReconcileMismatchFilterTest.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?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 AdminPlatformOrderReconcileMismatchFilterTest 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_reconcile_mismatch(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
$merchant = Merchant::query()->firstOrFail();
|
||||
$plan = Plan::query()->create([
|
||||
'code' => 'reconcile_mismatch_test',
|
||||
'name' => '对账不一致筛选测试套餐',
|
||||
'billing_cycle' => 'monthly',
|
||||
'price' => 10,
|
||||
'list_price' => 10,
|
||||
'status' => 'active',
|
||||
'sort' => 10,
|
||||
'published_at' => now(),
|
||||
]);
|
||||
|
||||
// 不一致:paid_amount=10,但 payment_summary.total_amount=9.99
|
||||
PlatformOrder::query()->create([
|
||||
'merchant_id' => $merchant->id,
|
||||
'plan_id' => $plan->id,
|
||||
'order_no' => 'PO_RECON_MISMATCH_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.99,
|
||||
'last_at' => now()->toDateTimeString(),
|
||||
'last_amount' => 9.99,
|
||||
'last_channel' => 'bank',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
// 一致:paid_amount=10,payment_summary.total_amount=10
|
||||
PlatformOrder::query()->create([
|
||||
'merchant_id' => $merchant->id,
|
||||
'plan_id' => $plan->id,
|
||||
'order_no' => 'PO_RECON_MATCH_0002',
|
||||
'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.00,
|
||||
'last_at' => now()->toDateTimeString(),
|
||||
'last_amount' => 10.00,
|
||||
'last_channel' => 'bank',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->get('/admin/platform-orders?reconcile_mismatch=1')
|
||||
->assertOk()
|
||||
->assertSee('PO_RECON_MISMATCH_0001')
|
||||
->assertDontSee('PO_RECON_MATCH_0002');
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ class AdminPlatformOrderTest extends TestCase
|
||||
->assertSee('退款总额')
|
||||
->assertSee('有回执订单 / 回执总额')
|
||||
->assertSee('对账差额')
|
||||
->assertSee('只看对账不一致')
|
||||
->assertSee('快捷筛选')
|
||||
->assertSee('待支付')
|
||||
->assertSee('待生效')
|
||||
|
||||
Reference in New Issue
Block a user