作者 lyh

gx

... ... @@ -232,8 +232,12 @@ class VideoTask extends Command
}else{
$product_all_id = Product::where("project_id", $project_id)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
$number = 40;
$product_id = array_rand($product_all_id, min($product_all_id, $number-count($productIds)));
$products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
$array_count = count($product_all_id);
if ($array_count > 0)
{
$product_id = array_rand($product_all_id, min($array_count, $number-count($productIds)));
$products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
}
}
}
$data = [];
... ...