Explorar el Código

[智价云] 统计查询优化

tangyuanwang hace 1 día
padre
commit
ae23e66bc0
Se han modificado 1 ficheros con 5 adiciones y 3 borrados
  1. 5 3
      app/Http/Controllers/Manager/Process/SubNotice.php

+ 5 - 3
app/Http/Controllers/Manager/Process/SubNotice.php

@@ -34,8 +34,9 @@ class SubNotice extends Controller
         $result = $CompanyModel->query()->get()->toArray();
         // 分配数据
         if (!$result)  return 5;
+        $key_index = 0;
         foreach ($result as $key => $item) {
-
+            $second = 300 * $key_index; // 每个商户延迟 300 秒
             //查询低价商品清洗清洗情况
             $action1 = $ExecuteLogModel->query()->where([['code', '=', 'LowPriceGoodsJobs'], ['company_id', '=', $item['id']], ['status', '=', '0'], ['insert_time', '>=', $todayStart], ['insert_time', '<=', $todayEnd]])->count();
             if ($action1 < 1) continue;
@@ -55,9 +56,10 @@ class SubNotice extends Controller
                 SendNoticeJobs::dispatch($message_data);
                 // SendNoticeJobs::dispatchSync($message_data);
             } else {
-                SubNoticeJobs::dispatch($message_data);
-                // SubNoticeJobs::dispatchSync($message_data);
+                SubNoticeJobs::dispatch($message_data)->delay($second);
+                // SubNoticeJobs::dispatchSync($message_data)->delay($second);;
             }
+            $key_index++;
         }
         // 告知结果
         return 6;