草稿附件

This commit is contained in:
2025-05-15 13:25:17 +08:00
parent 3b6a1ecd01
commit ff07c5bcd9
2 changed files with 148 additions and 0 deletions
@@ -43,6 +43,66 @@ class DraftsDataController extends BaseController
if ($scene === 'default') {
}
if ($scene === 'show') {
if ($item['cover']) {
$item['cover_full'] = (new \app\mzl\modules\upload\service\OssService())->generatePrivateUrl($item['cover']);
}
$arr = [];
if (isset($item['album'])) {
$albumFields = \app\console\model\DraftsAlbumModel::VEHICLE_ALBUM_FIELDS;
$arr = [];
foreach ($albumFields as $field) {
$arr[] = [
'field' => $field,
'name' => trans($field),
'value_full' => $item['album'][$field]
? (new \app\mzl\modules\upload\service\OssService())->generatePrivateUrl($item['album'][$field])
: '',
'value' => $item['album'][$field]
];
}
}
$result = [
'id' => $item['id'],
'vin' => $item['vin'],
'user_nickname' => isset($item['user']) ? $item['user']['nickname'] : '',
'price' => $item['price'],
'brand_name' => is_array($item['brand']) ? $item['brand']['translation']['name'] : '',
'energy_name' => is_array($item['energy']) ? $item['energy']['translation']['name'] : '',
'type_name' => isset($item['types']) ? $item['types']['translation']['name'] : '',
'model_name' => isset($item['models']) ? $item['models']['translation']['name'] : '',
'mileage' => $item['mileage'],
'vehicle_age' => $item['vehicle_age'],
'views' => $item['views'],
'is_hot' => $item['is_hot'],
'store_status' => $item['store_status'],
'store_status_name' => trans(\app\apis\model\VehicleDataModel::STORE_STATUS_VALUE[$item['store_status']]),
'name' => isset($item['translation']) ? $item['translation']['name'] : '',
'condition_desc' => isset($item['translation']) ? $item['translation']['condition_desc'] : '',
'cover' => isset($item['cover']) ? $item['cover'] : '',
'cover_full' => isset($item['cover']) ? $item['cover_full'] : '',
'albums' => $arr,
'created_at' => date('Y-m-d H:i:s', $item['created_at']),
'updated_at' => date('Y-m-d H:i:s', $item['updated_at']),
'brand' => is_array($item['brand']) ? $item['brand']['translation']['brand_id'] : $item['brand'],
'energy' => is_array($item['energy']) ? $item['energy']['translation']['energy_id'] : $item['energy'],
'type' => isset($item['types']) ? $item['types']['translation']['type_id'] : $item['type'],
'model' => isset($item['models']) ? $item['models']['translation']['model_id'] : $item['model'],
'location_name' => $item['location'] ? $item['location']['translation']['name'] : '',
'location' => is_array($item['location']) ? $item['location']['translation']['location_id'] : $item['location'],
];
foreach ($arr as $album){
$result[$album['field']] = $album['value'];
$result[$album['field'].'_full'] = $album['value_full'];
}
return $result;
}
return $item;
}