正在显示
1 个修改的文件
包含
2 行增加
和
2 行删除
| @@ -253,14 +253,14 @@ class VideoTask extends Command | @@ -253,14 +253,14 @@ class VideoTask extends Command | ||
| 253 | } | 253 | } |
| 254 | if (count($productIds) < 13){ | 254 | if (count($productIds) < 13){ |
| 255 | $product_all_id = Product::where('thumb','!=',null)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20 - count($productIds))->pluck('id')->toArray(); | 255 | $product_all_id = Product::where('thumb','!=',null)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20 - count($productIds))->pluck('id')->toArray(); |
| 256 | - $randomData = Product::whereIn("id", $product_all_id)->get(); | 256 | + $randomData = Product::whereIn("id", $product_all_id)->orderByRaw(DB::raw("FIELD(id, " . implode(',', $product_all_id) . ")"))->get(); |
| 257 | $products = $productsQuery->merge($randomData); | 257 | $products = $productsQuery->merge($randomData); |
| 258 | }else{ | 258 | }else{ |
| 259 | $products = $productsQuery; | 259 | $products = $productsQuery; |
| 260 | } | 260 | } |
| 261 | }else{ | 261 | }else{ |
| 262 | $product_all_id = Product::where('thumb','!=',null)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20)->pluck('id')->toArray(); | 262 | $product_all_id = Product::where('thumb','!=',null)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20)->pluck('id')->toArray(); |
| 263 | - $products = Product::whereIn("id", $product_all_id)->get(); | 263 | + $products = Product::whereIn("id", $product_all_id)->orderByRaw(DB::raw("FIELD(id, " . implode(',', $product_all_id) . ")"))->get(); |
| 264 | } | 264 | } |
| 265 | $data = []; | 265 | $data = []; |
| 266 | if (!empty($products)){ | 266 | if (!empty($products)){ |
-
请 注册 或 登录 后发表评论