作者 lyh

gx

@@ -232,10 +232,14 @@ class VideoTask extends Command @@ -232,10 +232,14 @@ class VideoTask extends Command
232 }else{ 232 }else{
233 $product_all_id = Product::where("project_id", $project_id)->where("status",Product::STATUS_ON)->pluck('id')->toArray(); 233 $product_all_id = Product::where("project_id", $project_id)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
234 $number = 40; 234 $number = 40;
235 - $product_id = array_rand($product_all_id, min($product_all_id, $number-count($productIds))); 235 + $array_count = count($product_all_id);
  236 + if ($array_count > 0)
  237 + {
  238 + $product_id = array_rand($product_all_id, min($array_count, $number-count($productIds)));
236 $products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get(); 239 $products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
237 } 240 }
238 } 241 }
  242 + }
239 $data = []; 243 $data = [];
240 if (!empty($products)){ 244 if (!empty($products)){
241 foreach ($products as $item){ 245 foreach ($products as $item){