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:
@@ -884,6 +884,18 @@ class StockOrdersService
|
||||
$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;
|
||||
}
|
||||
$index++;
|
||||
@@ -899,6 +911,7 @@ class StockOrdersService
|
||||
'mileage' => $v->mileage,
|
||||
'remark' => $v->remark,
|
||||
'vin' => $v->vin,
|
||||
'attachment' => is_array($v->attachment) ? $v->attachment : [],
|
||||
] + $moneyValues;
|
||||
}
|
||||
return ['list' => $vehList];
|
||||
|
||||
Reference in New Issue
Block a user