Преглед изворни кода

三方订单同步:限频时跳过不报错,失败原因写入日志

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
doge пре 1 дан
родитељ
комит
e3454baebd
2 измењених фајлова са 12 додато и 2 уклоњено
  1. 11 1
      app/Console/Commands/ThirdGameOrderSync.php
  2. 1 1
      app/Services/ThirdGameBalanceService.php

+ 11 - 1
app/Console/Commands/ThirdGameOrderSync.php

@@ -4,6 +4,7 @@ namespace App\Console\Commands;
 
 use App\Services\ThirdGameOrderService;
 use Illuminate\Console\Command;
+use Illuminate\Support\Facades\Log;
 
 class ThirdGameOrderSync extends Command
 {
@@ -20,12 +21,21 @@ class ThirdGameOrderSync extends Command
             try {
                 $result = $service->syncRealtime($page, 2000);
             } catch (\Throwable $e) {
+                Log::error('third_game_sync_orders_failed', ['page' => $page, 'exception' => $e]);
                 $this->error($e->getMessage());
                 return self::FAILURE;
             }
 
             if (empty($result['ok'])) {
-                $this->error((string) ($result['msg'] ?? '三方实时订单同步失败'));
+                $message = (string) ($result['msg'] ?? '三方实时订单同步失败');
+                // The provider allows one realtime query per minute and the admin list shares that quota. Each
+                // query covers the last 10 minutes, so a throttled run is skipped and the next run catches up.
+                if (!empty($result['throttled'])) {
+                    $this->warn("page={$page} skipped: {$message}");
+                    return self::SUCCESS;
+                }
+                Log::error('third_game_sync_orders_failed', ['page' => $page, 'message' => $message]);
+                $this->error($message);
                 return self::FAILURE;
             }
 

+ 1 - 1
app/Services/ThirdGameBalanceService.php

@@ -343,7 +343,7 @@ class ThirdGameBalanceService
 
         $rateError = $this->acquireRealtimeQuota($page, $limit);
         if ($rateError !== null) {
-            return ['ok' => false, 'msg' => $rateError];
+            return ['ok' => false, 'throttled' => true, 'msg' => $rateError];
         }
 
         $response = $this->request('/api/server/recordAll', [