正在显示
1 个修改的文件
包含
6 行增加
和
3 行删除
| @@ -220,9 +220,12 @@ class VideoTask extends Command | @@ -220,9 +220,12 @@ class VideoTask extends Command | ||
| 220 | if (count($productIds)<7){ | 220 | if (count($productIds)<7){ |
| 221 | $product_all_id = Product::where("project_id", $project_id)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->pluck('id')->toArray(); | 221 | $product_all_id = Product::where("project_id", $project_id)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->pluck('id')->toArray(); |
| 222 | $number = 40; | 222 | $number = 40; |
| 223 | - $product_id = array_rand($product_all_id, min($product_all_id, $number-count($productIds))); | ||
| 224 | - $randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get(); | ||
| 225 | - $products = $productsQuery->merge($randomData); | 223 | + $array_count = count($product_all_id); |
| 224 | + if ($array_count > 0) { | ||
| 225 | + $product_id = array_rand($product_all_id, min($array_count, $number - count($productIds))); | ||
| 226 | + $randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get(); | ||
| 227 | + $products = $productsQuery->merge($randomData); | ||
| 228 | + } | ||
| 226 | }else{ | 229 | }else{ |
| 227 | $products = $productsQuery; | 230 | $products = $productsQuery; |
| 228 | } | 231 | } |
-
请 注册 或 登录 后发表评论