Browse Source

报表打开错误

doge 1 ngày trước cách đây
mục cha
commit
17f90e413a

+ 5 - 1
app/Services/Reporting/ReportReader.php

@@ -267,7 +267,11 @@ class ReportReader
             foreach (DB::table('agent_rebate_records')->cursor() as $row) {
             foreach (DB::table('agent_rebate_records')->cursor() as $row) {
                 if (!empty($agents[$row->agent_id]['is_test'])) continue;
                 if (!empty($agents[$row->agent_id]['is_test'])) continue;
                 if (!empty($p['agent_account']) && !str_contains($agents[$row->agent_id]['username'] ?? '', $p['agent_account'])) continue;
                 if (!empty($p['agent_account']) && !str_contains($agents[$row->agent_id]['username'] ?? '', $p['agent_account'])) continue;
-                foreach (['flow', 'profit'] as $part) if ($row->{$part . '_status'} === 'pending') $result['agent_unpaid'] = bcadd($result['agent_unpaid'], (string) $row->{$part . '_commission'}, 10);
+                // 合营后流水佣金列已删除;缺列按 0,避免未定义属性中断整张报表。
+                foreach (['flow', 'profit'] as $part) {
+                    if (($row->{$part . '_status'} ?? null) !== 'pending') continue;
+                    $result['agent_unpaid'] = bcadd($result['agent_unpaid'], (string) ($row->{$part . '_commission'} ?? '0'), 10);
+                }
             }
             }
         }
         }
         if (Schema::hasTable('share_accounts')) {
         if (Schema::hasTable('share_accounts')) {

+ 18 - 0
tests/Integration/ReportingTest.php

@@ -718,11 +718,29 @@ class ReportingTest extends TestCase
             $this->assertNotContains('unallocated', array_column($details['data'], 'group_id'));
             $this->assertNotContains('unallocated', array_column($details['data'], 'group_id'));
             $this->assertSame(2, $details['total']);
             $this->assertSame(2, $details['total']);
         }
         }
+        $this->assertSame('2.0000000000', $this->reader->summary($this->today())['commission_balances']['agent_unpaid']);
         $this->assertSame('7.0000000000', $this->reader->summary($this->today())['summary']['agent_commission']);
         $this->assertSame('7.0000000000', $this->reader->summary($this->today())['summary']['agent_commission']);
         $this->assertSame('28.0000000000', $this->reader->summary($this->today())['summary']['company_profit']);
         $this->assertSame('28.0000000000', $this->reader->summary($this->today())['summary']['company_profit']);
         $this->assertSame('5.0000000000', $this->reader->summary(['report_type' => 'sharing'])['summary']['share_commission']);
         $this->assertSame('5.0000000000', $this->reader->summary(['report_type' => 'sharing'])['summary']['share_commission']);
     }
     }
 
 
+    public function test_business_summary_survives_rebate_records_without_flow_columns(): void
+    {
+        DB::table('agent_rebate_records')->insert(['id' => 1, 'agent_id' => 10, 'platform' => 'self:lottery', 'game_type' => 8,
+            'settlement_date' => '2026-10-26', 'profit_commission' => '4.5', 'profit_status' => 'pending', 'created_at' => '2026-10-26 10:00:00']);
+        DB::statement('ALTER TABLE bot_agent_rebate_records DROP COLUMN flow_commission');
+        DB::statement('ALTER TABLE bot_agent_rebate_records DROP COLUMN flow_status');
+        set_error_handler(static function (int $severity, string $message): bool {
+            throw new \ErrorException($message, 0, $severity);
+        });
+        try {
+            $balances = $this->reader->summary([])['commission_balances'];
+        } finally {
+            restore_error_handler();
+        }
+        $this->assertSame('4.5000000000', $balances['agent_unpaid']);
+    }
+
     public function test_daily_total_is_for_all_pages_and_source_errors_are_visible_until_fixed(): void
     public function test_daily_total_is_for_all_pages_and_source_errors_are_visible_until_fixed(): void
     {
     {
         $this->bet(1, ['created_at' => '2026-10-25 09:00:00']);
         $this->bet(1, ['created_at' => '2026-10-25 09:00:00']);