feat: 备货单 detail 接口车辆列表补充返回 attachment

prepareVehicleListData 组装每辆车时带上 attachment(模型 array cast
取出即 [{url, original_name}]);同款车按 unique_id 合并的行,
各车附件按 url+文件名并集去重后拼接。show 接口本就带,不动。

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
mzl
2026-08-26 11:43:01 +08:00
parent 6fa80336a6
commit 2e2188d6e5
+13
View File
@@ -884,6 +884,18 @@ class StockOrdersService
$vehList[$v->unique_id]['remark'] = $v->remark; $vehList[$v->unique_id]['remark'] = $v->remark;
} }
} }
// 拼接附件(并集去重,按 url+文件名)
$currAttach = is_array($v->attachment) ? $v->attachment : [];
if (!empty($currAttach)) {
$union = [];
foreach (array_merge($vehList[$v->unique_id]['attachment'], $currAttach) as $a) {
$key = ($a['url'] ?? '') . '|' . ($a['original_name'] ?? '');
if (!isset($union[$key])) {
$union[$key] = $a;
}
}
$vehList[$v->unique_id]['attachment'] = array_values($union);
}
continue; continue;
} }
$index++; $index++;
@@ -899,6 +911,7 @@ class StockOrdersService
'mileage' => $v->mileage, 'mileage' => $v->mileage,
'remark' => $v->remark, 'remark' => $v->remark,
'vin' => $v->vin, 'vin' => $v->vin,
'attachment' => is_array($v->attachment) ? $v->attachment : [],
] + $moneyValues; ] + $moneyValues;
} }
return ['list' => $vehList]; return ['list' => $vehList];