|
...
|
...
|
@@ -245,7 +245,6 @@ class VideoTask extends Command |
|
|
|
public function getRecommendAndHotProducts($keyword_id,$project_id): ?array
|
|
|
|
{
|
|
|
|
$productIds = [];
|
|
|
|
$productKeyword = Keyword::where("id",$keyword_id)->first();
|
|
|
|
$productsQuery = Product::where("status",1)->where("keyword_id","like","%,".$keyword_id.",%")->limit(7)->get();
|
|
|
|
if (!empty($productsQuery)){
|
|
|
|
foreach ($productsQuery as $item){
|
|
...
|
...
|
@@ -258,7 +257,7 @@ class VideoTask extends Command |
|
|
|
if ($array_count > 0) {
|
|
|
|
$product_id_key = array_rand($product_all_id, min($array_count, $number - count($productIds)));
|
|
|
|
foreach ($product_id_key as $value_key){
|
|
|
|
$project_id_arr = $product_all_id[$value_key];
|
|
|
|
$project_id_arr[] = $product_all_id[$value_key];
|
|
|
|
}
|
|
|
|
$randomData = Product::whereIn("id", $project_id_arr)->get();
|
|
|
|
$products = $productsQuery->merge($randomData);
|
|
...
|
...
|
@@ -276,7 +275,7 @@ class VideoTask extends Command |
|
|
|
$project_id_arr = [];
|
|
|
|
$product_id_key = array_rand($product_all_id, min($array_count, $number-count($productIds)));
|
|
|
|
foreach ($product_id_key as $value_key){
|
|
|
|
$project_id_arr = $product_all_id[$value_key];
|
|
|
|
$project_id_arr[] = $product_all_id[$value_key];
|
|
|
|
}
|
|
|
|
$products = Product::where("project_id", $project_id)->whereIn("id", $project_id_arr)->get();
|
|
|
|
}
|
...
|
...
|
|