|
|
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api\WashConfig;
|
|
|
use App\Http\Controllers\Api\Api;
|
|
|
use App\Http\Requests\Manager\WashConfig\LowPriceGoods as Request;
|
|
|
use App\Models\Manager\WashConfig\LowPriceGoods as LowPriceGoodsModel;
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -50,8 +51,11 @@ class LowPriceGoods extends Api
|
|
|
$result = $LowPriceGoodsModel->query()
|
|
|
->where($map)
|
|
|
->orderByDesc('id')
|
|
|
- ->select(['id','product_name'])
|
|
|
- ->distinct('product_name')
|
|
|
+ ->select([
|
|
|
+ DB::raw('MAX(id) as id'), // 使用 MAX 聚合函数获取最新的 id
|
|
|
+ 'product_name'
|
|
|
+ ])
|
|
|
+ ->groupBy('product_name')
|
|
|
->paginate($limit);
|
|
|
// 分配数据
|
|
|
if (!$result) return json_send(['code' => 'error', 'msg' => '暂无数据']);
|
|
|
@@ -94,8 +98,11 @@ class LowPriceGoods extends Api
|
|
|
$result = $LowPriceGoodsModel->query()
|
|
|
->where($map)
|
|
|
->orderByDesc('id')
|
|
|
- ->select(['id','product_specs'])
|
|
|
- ->distinct('product_specs')
|
|
|
+ ->select([
|
|
|
+ DB::raw('MAX(id) as id'), // 使用 MAX 聚合函数获取最新的 id
|
|
|
+ 'product_specs'
|
|
|
+ ])
|
|
|
+ ->groupBy('product_specs')
|
|
|
->paginate($limit);
|
|
|
// 分配数据
|
|
|
if (!$result) return json_send(['code' => 'error', 'msg' => '暂无数据']);
|