正在显示
1 个修改的文件
包含
2 行增加
和
3 行删除
| @@ -245,7 +245,6 @@ class VideoTask extends Command | @@ -245,7 +245,6 @@ class VideoTask extends Command | ||
| 245 | public function getRecommendAndHotProducts($keyword_id,$project_id): ?array | 245 | public function getRecommendAndHotProducts($keyword_id,$project_id): ?array |
| 246 | { | 246 | { |
| 247 | $productIds = []; | 247 | $productIds = []; |
| 248 | - $productKeyword = Keyword::where("id",$keyword_id)->first(); | ||
| 249 | $productsQuery = Product::where("status",1)->where("keyword_id","like","%,".$keyword_id.",%")->limit(7)->get(); | 248 | $productsQuery = Product::where("status",1)->where("keyword_id","like","%,".$keyword_id.",%")->limit(7)->get(); |
| 250 | if (!empty($productsQuery)){ | 249 | if (!empty($productsQuery)){ |
| 251 | foreach ($productsQuery as $item){ | 250 | foreach ($productsQuery as $item){ |
| @@ -258,7 +257,7 @@ class VideoTask extends Command | @@ -258,7 +257,7 @@ class VideoTask extends Command | ||
| 258 | if ($array_count > 0) { | 257 | if ($array_count > 0) { |
| 259 | $product_id_key = array_rand($product_all_id, min($array_count, $number - count($productIds))); | 258 | $product_id_key = array_rand($product_all_id, min($array_count, $number - count($productIds))); |
| 260 | foreach ($product_id_key as $value_key){ | 259 | foreach ($product_id_key as $value_key){ |
| 261 | - $project_id_arr = $product_all_id[$value_key]; | 260 | + $project_id_arr[] = $product_all_id[$value_key]; |
| 262 | } | 261 | } |
| 263 | $randomData = Product::whereIn("id", $project_id_arr)->get(); | 262 | $randomData = Product::whereIn("id", $project_id_arr)->get(); |
| 264 | $products = $productsQuery->merge($randomData); | 263 | $products = $productsQuery->merge($randomData); |
| @@ -276,7 +275,7 @@ class VideoTask extends Command | @@ -276,7 +275,7 @@ class VideoTask extends Command | ||
| 276 | $project_id_arr = []; | 275 | $project_id_arr = []; |
| 277 | $product_id_key = array_rand($product_all_id, min($array_count, $number-count($productIds))); | 276 | $product_id_key = array_rand($product_all_id, min($array_count, $number-count($productIds))); |
| 278 | foreach ($product_id_key as $value_key){ | 277 | foreach ($product_id_key as $value_key){ |
| 279 | - $project_id_arr = $product_all_id[$value_key]; | 278 | + $project_id_arr[] = $product_all_id[$value_key]; |
| 280 | } | 279 | } |
| 281 | $products = Product::where("project_id", $project_id)->whereIn("id", $project_id_arr)->get(); | 280 | $products = Product::where("project_id", $project_id)->whereIn("id", $project_id_arr)->get(); |
| 282 | } | 281 | } |
-
请 注册 或 登录 后发表评论