|
...
|
...
|
@@ -196,24 +196,24 @@ class VideoTask extends Command |
|
|
|
/**
|
|
|
|
* 关键词聚合页-推荐&热门产品
|
|
|
|
*/
|
|
|
|
public function getRecommendAndHotProducts($project,$route): ?array
|
|
|
|
public function getRecommendAndHotProducts($project_id,$route): ?array
|
|
|
|
{
|
|
|
|
$productIds = [];
|
|
|
|
$productKeyword = Keyword::where("project_id",$project->id)->where("route",$route)->first();
|
|
|
|
$productKeyword = Keyword::where("project_id",$project_id)->where("route",$route)->first();
|
|
|
|
if (!empty($productKeyword)){
|
|
|
|
$productsQuery = Product::where("project_id", $project->id)->where("status",1)->where("keyword_id","like","%,".$productKeyword->id.",%")->limit(7)->get();
|
|
|
|
$productsQuery = Product::where("project_id", $project_id)->where("status",1)->where("keyword_id","like","%,".$productKeyword->id.",%")->limit(7)->get();
|
|
|
|
if (!empty($productsQuery)){
|
|
|
|
foreach ($productsQuery as $item){
|
|
|
|
$productIds[] = $item->id;
|
|
|
|
}
|
|
|
|
if (count($productIds)<7){
|
|
|
|
$randomData = Product::where("project_id", $project->id)->where("status",1)->whereNotIn('id', $productIds)->inRandomOrder()->take(13-count($productIds))->get();
|
|
|
|
$randomData = Product::where("project_id", $project_id)->where("status",1)->whereNotIn('id', $productIds)->inRandomOrder()->take(13-count($productIds))->get();
|
|
|
|
$products = $productsQuery->merge($randomData);
|
|
|
|
}else{
|
|
|
|
$products = $productsQuery;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$products = Product::where("project_id", $project->id)->where("status",1)->inRandomOrder()->take(13)->get();
|
|
|
|
$products = Product::where("project_id", $project_id)->where("status",1)->inRandomOrder()->take(13)->get();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$data = [];
|
...
|
...
|
|