|
|
@@ -333,6 +333,37 @@ class AdminRealtimeSummaryTest extends TestCase
|
|
|
$this->assertSame(8, DB::table('payment_orders')->count(), '扫描只读业务表');
|
|
|
}
|
|
|
|
|
|
+ public function test_agent_withdrawal_badge_matches_http_and_pushes_when_the_pending_count_changes(): void
|
|
|
+ {
|
|
|
+ Schema::create('agent_withdrawals', function (Blueprint $table) {
|
|
|
+ $table->id();
|
|
|
+ $table->string('status');
|
|
|
+ $table->dateTime('created_at');
|
|
|
+ });
|
|
|
+ $channel = 'admin.stats.unprocessed';
|
|
|
+ $initial = collect($this->tick(0))->firstWhere('channel', $channel);
|
|
|
+ $this->assertSame(0, $initial['data']['agentWithdraw']);
|
|
|
+
|
|
|
+ $withdrawals = DB::table('agent_withdrawals');
|
|
|
+ $createdAt = $this->clock->copy()->subDays(3)->toDateTimeString();
|
|
|
+ foreach (['pending', 'pending', 'approved', 'processing', 'paid', 'rejected', 'failed'] as $status) {
|
|
|
+ $withdrawals->insert(['status' => $status, 'created_at' => $createdAt]);
|
|
|
+ }
|
|
|
+ $pending = collect($this->tick(6))->where('channel', $channel)->sole();
|
|
|
+ $this->assertSame('stats.updated', $pending['event']);
|
|
|
+ $this->assertSame(2, $pending['data']['agentWithdraw'], 'pending applications are counted even after 24 hours');
|
|
|
+ $this->assertSame(1, $pending['data']['usdtWithdraw'], 'agent withdrawals are counted separately');
|
|
|
+ $this->assertSame((new PaymentOrder())->unProcessed()->getData(true)['data'], $pending['data']);
|
|
|
+ $this->assertSame($pending['data'], AdminRealtimeFeed::replay($initial['seq'], [$channel])['events'][0]['data']);
|
|
|
+
|
|
|
+ (clone $withdrawals)->where('id', 1)->update(['status' => 'approved']);
|
|
|
+ (clone $withdrawals)->where('id', 2)->update(['status' => 'rejected']);
|
|
|
+ $reviewed = collect($this->tick(12))->where('channel', $channel)->sole();
|
|
|
+ $this->assertSame(0, $reviewed['data']['agentWithdraw']);
|
|
|
+ $this->assertSame((new PaymentOrder())->unProcessed()->getData(true)['data'], $reviewed['data']);
|
|
|
+ $this->assertSame([], $this->tick(18));
|
|
|
+ }
|
|
|
+
|
|
|
public function test_failed_outbox_registration_does_not_swallow_the_snapshot_change(): void
|
|
|
{
|
|
|
Schema::rename('admin_realtime_events', 'unavailable_realtime_events');
|