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'])) {