和你要的结果一样
$json = (new Filesystem())->get(public_path('1.json'));
$json = collect(json_decode($json, true))->groupBy('good.shop.id')->map(function (Collection $company) {
$data = Arr::get($company->first(), 'good.shop');
$data['goods'] = $company->map(function ($good) {
Arr::forget($good, 'good.shop');
$g = $good['good'];
Arr::forget($good, 'good');
return array_merge($g, $good);
})->toArray();
return $data;
});
dump($json->toArray());