ソースを参照

超节损计算

unknown 2 週間 前
親
コミット
069f64c519

ファイルの差分が大きいため隠しています
+ 435 - 700
application/api/controller/OrderSuperLoss.php


+ 9 - 8
application/job/UnifiedCostCalculationJob.php

@@ -18,18 +18,17 @@ class UnifiedCostCalculationJob
     public function fire($job, $data)
     public function fire($job, $data)
     {
     {
         try {
         try {
-            Log::info('开始执行成本计算队列任务', $data);
-
-            // 获取任务ID
             $taskId = $data['task_id'] ?? 0;
             $taskId = $data['task_id'] ?? 0;
-            $month = $data['month'];
+            $month = $data['month'] ?? '';
 
 
-            // 更新任务状态为执行中
+            // 更新任务状态为执行中(须先于 Log,且勿用 Log::info($msg, $array) — TP5 第二参是 type 会触发 Illegal offset type)
             $this->updateTaskStatus($taskId, 'processing', [
             $this->updateTaskStatus($taskId, 'processing', [
                 'start_time' => date('Y-m-d H:i:s'),
                 'start_time' => date('Y-m-d H:i:s'),
                 'retry_count' => $job->attempts()
                 'retry_count' => $job->attempts()
             ]);
             ]);
 
 
+            Log::info('开始执行成本计算队列任务: ' . json_encode($data, JSON_UNESCAPED_UNICODE));
+
             // 执行成本计算
             // 执行成本计算
             $result = $this->executeCostCalculation($month, $data['sys_id'] ?? '');
             $result = $this->executeCostCalculation($month, $data['sys_id'] ?? '');
 
 
@@ -59,7 +58,7 @@ class UnifiedCostCalculationJob
                 }
                 }
             }
             }
 
 
-        } catch (\Exception $e) {
+        } catch (\Throwable $e) {
             Log::error('成本计算队列任务异常: ' . $e->getMessage());
             Log::error('成本计算队列任务异常: ' . $e->getMessage());
 
 
             if ($job->attempts() >= 3) {
             if ($job->attempts() >= 3) {
@@ -100,9 +99,11 @@ class UnifiedCostCalculationJob
     /**
     /**
      * 更新任务状态
      * 更新任务状态
      */
      */
-    protected function updateTaskStatus(int $taskId, string $status, array $data = []): void
+    protected function updateTaskStatus($taskId, string $status, array $data = []): void
     {
     {
-        if ($taskId <= 0) return;
+        if (empty($taskId)) {
+            return;
+        }
 
 
         $updateData = array_merge(['status' => $status, 'update_time' => date('Y-m-d H:i:s')], $data);
         $updateData = array_merge(['status' => $status, 'update_time' => date('Y-m-d H:i:s')], $data);
 
 

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません