From 7c3670dd22add5471082bbb927ffb657dad544dc Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Fri, 23 Dec 2022 14:55:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E7=85=A7=E8=BE=93=E5=85=A5=E4=BA=A7?= =?UTF-8?q?=E5=93=81ID=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- beike/Repositories/ProductRepo.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/beike/Repositories/ProductRepo.php b/beike/Repositories/ProductRepo.php index 8cafb9b9..a542eaad 100644 --- a/beike/Repositories/ProductRepo.php +++ b/beike/Repositories/ProductRepo.php @@ -86,8 +86,11 @@ class ProductRepo }); } - if (isset($data['product_ids'])) { - $builder->whereIn('id', $data['product_ids']); + $productIds = $data['product_ids'] ?? []; + if ($productIds) { + $builder->whereIn('id', $productIds); + $productIds = implode(',', $productIds); + $builder->orderByRaw("FIELD(products.id, {$productIds})"); } if (isset($data['sku']) || isset($data['model'])) {