作者 lyh

gx

@@ -217,7 +217,7 @@ class VideoTask extends Command @@ -217,7 +217,7 @@ class VideoTask extends Command
217 } 217 }
218 if (count($productIds)<7){ 218 if (count($productIds)<7){
219 $product_all_id = Product::where("project_id", $project_id)->whereNotIn('id', $productIds)->where("status",1)->pluck('id')->toArray(); 219 $product_all_id = Product::where("project_id", $project_id)->whereNotIn('id', $productIds)->where("status",1)->pluck('id')->toArray();
220 - $product_id = array_rand($product_all_id, 13-count($productIds)); 220 + $product_id = array_rand($product_all_id, 30-count($productIds));
221 $randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get(); 221 $randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
222 $products = $productsQuery->merge($randomData); 222 $products = $productsQuery->merge($randomData);
223 }else{ 223 }else{
@@ -225,19 +225,23 @@ class VideoTask extends Command @@ -225,19 +225,23 @@ class VideoTask extends Command
225 } 225 }
226 }else{ 226 }else{
227 $product_all_id = Product::where("project_id", $project_id)->where("status",1)->pluck('id')->toArray(); 227 $product_all_id = Product::where("project_id", $project_id)->where("status",1)->pluck('id')->toArray();
228 - $product_id = array_rand($product_all_id, 13); 228 + $product_id = array_rand($product_all_id, 30);
229 $products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get(); 229 $products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
230 } 230 }
231 } 231 }
232 $data = []; 232 $data = [];
233 if (!empty($products)){ 233 if (!empty($products)){
234 foreach ($products as $item){ 234 foreach ($products as $item){
235 - $data[] = ['url'=>!empty($item->thumb) && $item->thumb['url'] != "" ? getImageUrl($item->thumb['url']) : "",'title'=>$item->title]; 235 + if(empty($item->thumb) || ($item->thumb['url'] == "")){
  236 + continue;
  237 + }
  238 + if(count($data) > 13){
  239 + break;
  240 + }
  241 + $data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title];
236 } 242 }
237 } 243 }
238 return $data; 244 return $data;
239 } 245 }
240 246
241 -  
242 -  
243 } 247 }