|
...
|
...
|
@@ -220,17 +220,24 @@ class VideoTask extends Command |
|
|
|
if (count($productIds)<7){
|
|
|
|
$product_all_id = Product::where("project_id", $project_id)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
|
|
|
|
$number = 40;
|
|
|
|
$product_id = array_rand($product_all_id, min($product_all_id, $number-count($productIds)));
|
|
|
|
$randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
|
|
|
|
$products = $productsQuery->merge($randomData);
|
|
|
|
$array_count = count($product_all_id);
|
|
|
|
if ($array_count > 0) {
|
|
|
|
$product_id = array_rand($product_all_id, min($array_count, $number - count($productIds)));
|
|
|
|
$randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
|
|
|
|
$products = $productsQuery->merge($randomData);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$products = $productsQuery;
|
|
|
|
}
|
|
|
|
}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 = [];
|
|
...
|
...
|
@@ -242,10 +249,11 @@ class VideoTask extends Command |
|
|
|
if(count($data) > 13){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (strpos($item->keyword_id, ','.$productKeyword->id.',') === false) {
|
|
|
|
$keyword_id = implode(',',$item->keyword_id);
|
|
|
|
if (strpos(','.$keyword_id.',', ','.$productKeyword->id.',') === false) {
|
|
|
|
//不包含
|
|
|
|
$productModel = new Product();
|
|
|
|
$keyword_id = $item->keyword_id . $productKeyword->id.',';
|
|
|
|
$keyword_id = $keyword_id . $productKeyword->id.',';
|
|
|
|
$productModel->edit(['keyword_id'=>$keyword_id],['id'=>$item->id]);
|
|
|
|
}
|
|
|
|
$data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title];
|
...
|
...
|
|