Explorar el Código

refactor(game): 优化日志收集命令和资金日志采集器

- 在 CollectUserLogsContinuousCommand 中添加了命令行执行提示
- 优化了 FundLogCollector 中的 buildUserFriendlyMessage 方法参数类型
- 调整了 CollectUserLogsContinuousCommand 中的代码格式和统计信息展示
AI Assistant hace 7 meses
padre
commit
b34d066b44

+ 12 - 11
app/Module/Game/Commands/CollectUserLogsContinuousCommand.php

@@ -10,6 +10,7 @@ use UCore\Command\Command;
  *
  * 持续运行的日志收集命令,循环100次后退出,间隔1秒
  * 复用CollectUserLogsCommand的核心逻辑
+ * php artisan game:collect-user-logs-continuous
  */
 class CollectUserLogsContinuousCommand extends Command
 {
@@ -77,7 +78,7 @@ class CollectUserLogsContinuousCommand extends Command
             $this->line("循环 {$i} ");
 
             $cycleStartTime = microtime(true);
-            
+
             try {
                 if ($detail) {
                     $this->line("🔄 第 {$i}/{$cycles} 次循环开始...");
@@ -85,10 +86,10 @@ class CollectUserLogsContinuousCommand extends Command
 
                 // 复用原有的收集逻辑
                 $result = $this->executeTimelineCollection($manager, $limit, $detail);
-                
+
                 $cycleEndTime = microtime(true);
                 $cycleExecutionTime = round(($cycleEndTime - $cycleStartTime) * 1000, 2);
-                
+
                 $totalProcessed += $result['processed_count'];
                 $totalExecutionTime += $cycleExecutionTime;
                 $successfulCycles++;
@@ -105,7 +106,7 @@ class CollectUserLogsContinuousCommand extends Command
             } catch (\Exception $e) {
                 $failedCycles++;
                 $this->error("❌ 第 {$i} 次循环失败: {$e->getMessage()}");
-                
+
                 if ($detail) {
                     $this->line("🚨 错误详情: " . $e->getTraceAsString());
                 }
@@ -189,32 +190,32 @@ class CollectUserLogsContinuousCommand extends Command
         $this->line("");
         $this->info("🎉 持续收集完成!");
         $this->line("");
-        
+
         $this->line("📊 <comment>执行统计</comment>:");
         $this->line("  🔄 总循环次数: <info>{$totalCycles}</info>");
         $this->line("  ✅ 成功次数: <info>{$successfulCycles}</info>");
-        
+
         if ($failedCycles > 0) {
             $this->line("  ❌ 失败次数: <error>{$failedCycles}</error>");
         }
-        
+
         $this->line("  📝 总处理记录: <info>{$totalProcessed}</info>");
         $this->line("  ⏱️  总执行时间: <info>{$totalExecutionTime}ms</info>");
         $this->line("  🕐 总运行时间: <info>{$totalRealTime}ms</info>");
-        
+
         if ($totalProcessed > 0) {
             $avgTimePerRecord = round($totalExecutionTime / $totalProcessed, 2);
             $this->line("  📈 平均处理时间: <info>{$avgTimePerRecord}ms/条</info>");
         }
-        
+
         if ($successfulCycles > 0) {
             $avgRecordsPerCycle = round($totalProcessed / $successfulCycles, 2);
             $this->line("  📊 平均每次处理: <info>{$avgRecordsPerCycle}条</info>");
         }
-        
+
         $successRate = round(($successfulCycles / $totalCycles) * 100, 2);
         $this->line("  🎯 成功率: <info>{$successRate}%</info>");
-        
+
         $this->line("");
     }
 }

+ 1 - 1
app/Module/Game/Logics/UserLogCollectors/FundLogCollector.php

@@ -158,7 +158,7 @@ class FundLogCollector extends BaseLogCollector
      * @param int $amount 金额
      * @return string
      */
-    private function buildUserFriendlyMessage(FundLogModel $record, string $fundName, string $action, int $amount): string
+    private function buildUserFriendlyMessage(FundLogModel $record, string $fundName, string $action, float $amount): string
     {
         // 解析备注信息
         $remarkInfo = $this->parseRemark($record->remark);