作者 lyh

gxvideo脚本

@@ -275,8 +275,12 @@ class VideoTask extends Command @@ -275,8 +275,12 @@ class VideoTask extends Command
275 } 275 }
276 }else{ 276 }else{
277 $product_all_id = Product::where('thumb','!=',null)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20)->pluck('id')->toArray(); 277 $product_all_id = Product::where('thumb','!=',null)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20)->pluck('id')->toArray();
  278 + if(empty($product_all_id)){
  279 + $products = [];
  280 + }else{
278 $products = Product::whereIn("id", $product_all_id)->orderByRaw(DB::raw("FIELD(id, " . implode(',', $product_all_id) . ")"))->get(); 281 $products = Product::whereIn("id", $product_all_id)->orderByRaw(DB::raw("FIELD(id, " . implode(',', $product_all_id) . ")"))->get();
279 } 282 }
  283 + }
280 $data = []; 284 $data = [];
281 if (!empty($products)){ 285 if (!empty($products)){
282 foreach ($products as $item){ 286 foreach ($products as $item){