chore: sync release updates

This commit is contained in:
wushumin
2026-05-22 15:47:23 +08:00
parent be64b8e5b7
commit baef2fb64c
23 changed files with 879 additions and 131 deletions

View File

@@ -1045,7 +1045,11 @@ class AppraisalTasksController
}
try {
$asset = $this->evidenceService()->upload($request);
$scene = (string)$request->input('upload_scene', 'appraisal_evidence');
if (!in_array($scene, ['appraisal_evidence', 'zhongjian_report'], true)) {
$scene = 'appraisal_evidence';
}
$asset = $this->evidenceService()->upload($request, 'file', $scene);
return api_success($asset);
} catch (\Throwable $e) {
return api_error($e->getMessage(), 422);
@@ -1859,11 +1863,13 @@ class AppraisalTasksController
'brand_name' => $product['brand_name'] ?? '',
'color' => $product['color'] ?? '',
'size_spec' => $product['size_spec'] ?? '',
'serial_no' => $product['serial_no'] ?? '',
], JSON_UNESCAPED_UNICODE),
'result_snapshot_json' => json_encode([
'result_status' => $resultPayload['result_status'],
'result_text' => $resultPayload['result_text'],
'result_desc' => $resultPayload['result_desc'],
'external_remark' => $resultPayload['external_remark'] ?? '',
'key_points' => $this->loadLatestOrderKeyPoints($orderId),
], JSON_UNESCAPED_UNICODE),
'appraisal_snapshot_json' => json_encode($appraisalSnapshot, JSON_UNESCAPED_UNICODE),

View File

@@ -0,0 +1,24 @@
<?php
namespace app\controller\admin;
use app\support\FileUploadService;
use support\Request;
class FileUploadController
{
public function directPolicy(Request $request)
{
try {
return api_success((new FileUploadService())->createOssDirectUploadPolicy(
$request,
(string)$request->input('upload_scene', ''),
(string)$request->input('original_name', ''),
(int)$request->input('file_size', 0),
(string)$request->input('mime_type', '')
));
} catch (\Throwable $e) {
return api_error($e->getMessage(), 422);
}
}
}

View File

@@ -275,7 +275,16 @@ class SystemConfigsController
'title' => 'OSS Endpoint',
'field_type' => 'text',
'placeholder' => '例如 oss-cn-shenzhen.aliyuncs.com',
'remark' => '填写 Bucket 所在地域的公网 Endpoint。',
'remark' => '后台服务端 SDK 使用的 Endpoint。可填公网 Endpoint如服务器在同地域内网也可填内网 Endpoint。',
'is_secret' => false,
'visible_when' => ['config_key' => 'driver', 'equals' => 'oss'],
],
[
'config_key' => 'oss_upload_endpoint',
'title' => 'OSS 直传 Endpoint',
'field_type' => 'text',
'placeholder' => '例如 oss-cn-shenzhen.aliyuncs.com',
'remark' => '前端直传 OSS 使用的公网 Endpoint。为空时沿用 OSS Endpoint如 OSS Endpoint 填了内网地址,这里必须填写公网地址。',
'is_secret' => false,
'visible_when' => ['config_key' => 'driver', 'equals' => 'oss'],
],
@@ -324,6 +333,16 @@ class SystemConfigsController
'is_secret' => false,
'visible_when' => ['config_key' => 'driver', 'equals' => 'oss'],
],
[
'config_key' => 'direct_upload_max_size_mb',
'title' => '直传文件大小上限 MB',
'field_type' => 'text',
'placeholder' => '默认 200',
'remark' => '前端直传 OSS 的单文件最大大小,单位 MB。建议按业务网络环境设置允许范围 1-2048。',
'is_secret' => false,
'default_value' => '200',
'visible_when' => ['config_key' => 'driver', 'equals' => 'oss'],
],
[
'config_key' => 'qiniu_bucket',
'title' => '七牛 Bucket',
@@ -452,6 +471,11 @@ class SystemConfigsController
}
}
$directUploadMaxSizeMb = trim((string)($configValueMap['file_storage.direct_upload_max_size_mb'] ?? '200'));
if ($directUploadMaxSizeMb !== '' && (!ctype_digit($directUploadMaxSizeMb) || (int)$directUploadMaxSizeMb < 1 || (int)$directUploadMaxSizeMb > 2048)) {
throw new \RuntimeException('直传文件大小上限需填写 1-2048 之间的整数');
}
return;
}

View File

@@ -43,7 +43,7 @@ class WarehouseWorkbenchController
{
$evidenceService = new AppraisalEvidenceService();
try {
$asset = $evidenceService->upload($request);
$asset = $evidenceService->upload($request, 'file', 'warehouse_inbound_evidence');
if (!in_array((string)($asset['file_type'] ?? ''), ['image', 'video'], true)) {
$evidenceService->delete((string)($asset['file_url'] ?? ''));
return api_error('拆包附件仅支持上传图片或视频', 422);
@@ -59,7 +59,7 @@ class WarehouseWorkbenchController
{
$evidenceService = new AppraisalEvidenceService();
try {
$asset = $evidenceService->upload($request);
$asset = $evidenceService->upload($request, 'file', 'warehouse_return_packing');
if (!in_array((string)($asset['file_type'] ?? ''), ['image', 'video'], true)) {
$evidenceService->delete((string)($asset['file_url'] ?? ''));
return api_error('打包装箱附件仅支持上传图片或视频', 422);

View File

@@ -104,7 +104,7 @@ class ReportsController
'valuation_snapshot' => $this->decodeJsonField($content['valuation_snapshot_json'] ?? null),
'risk_notice_text' => ($content['risk_notice_text'] ?? '') !== '' ? $content['risk_notice_text'] : $defaultRiskNotice,
];
$productDisplay = $this->buildProductDisplay($reportData, $payload['product_snapshot'], $payload['result_snapshot']);
$productDisplay = $this->buildProductDisplay($reportData, $payload['product_snapshot'], $payload['result_snapshot'], $payload['valuation_snapshot']);
$reportMedia = [
'images' => $this->filterAssetsByType($evidenceAttachments, 'image'),
];
@@ -261,7 +261,7 @@ class ReportsController
->find();
$publishTime = (string)($report['publish_time'] ?: date('Y-m-d H:i:s'));
$relativeDir = 'uploads/reports/' . date('Ymd', strtotime($publishTime));
$filename = $report['report_no'] . '-v2.pdf';
$filename = $report['report_no'] . '-v3.pdf';
$relativePath = $relativeDir . '/' . $filename;
if ($existingFile && !empty($existingFile['file_url'])) {
@@ -317,20 +317,26 @@ class ReportsController
return $this->storage()->publicUrl($request, $relativePath);
}
private function buildProductDisplay(array $report, array $productInfo, array $resultInfo): array
private function buildProductDisplay(array $report, array $productInfo, array $resultInfo, array $valuationInfo = []): array
{
$items = [
[
'label' => '检测结论',
'value' => $this->textValue($resultInfo['result_text'] ?? '') ?: '-',
'remark' => $this->textValue($resultInfo['result_desc'] ?? ''),
],
[
'label' => '品牌',
'value' => $this->textValue($productInfo['brand_name'] ?? '') ?: '-',
'remark' => '',
],
];
$items = [];
$this->appendDisplayItem(
$items,
'检测结论',
$this->textValue($resultInfo['result_text'] ?? '') ?: '-',
$this->textValue($resultInfo['result_desc'] ?? ''),
true
);
foreach ([
'品类' => $productInfo['category_name'] ?? '',
'品牌' => $productInfo['brand_name'] ?? '',
'颜色' => $productInfo['color'] ?? '',
'规格/尺寸' => $productInfo['size_spec'] ?? '',
'序列号/编码' => $productInfo['serial_no'] ?? '',
] as $label => $value) {
$this->appendDisplayItem($items, $label, $value);
}
foreach (($resultInfo['key_points'] ?? []) as $point) {
if (!is_array($point)) {
@@ -340,11 +346,30 @@ class ReportsController
if ($label === '') {
continue;
}
$items[] = [
'label' => $label,
'value' => $this->textValue($point['point_value'] ?? '') ?: '-',
'remark' => $this->textValue($point['point_remark'] ?? ''),
];
$this->appendDisplayItem(
$items,
$label,
$this->textValue($point['point_value'] ?? '') ?: '-',
$this->textValue($point['point_remark'] ?? ''),
true
);
}
$conditionGrade = $this->textValue($valuationInfo['condition_grade'] ?? '');
$conditionDesc = $this->textValue($valuationInfo['condition_desc'] ?? '');
if ($conditionGrade !== '' || $conditionDesc !== '') {
$this->appendDisplayItem($items, '成色评级', $conditionGrade ?: '-', $conditionDesc, true);
}
$valuationRange = $this->formatValuationRange($valuationInfo['valuation_min'] ?? 0, $valuationInfo['valuation_max'] ?? 0);
$valuationDesc = $this->textValue($valuationInfo['valuation_desc'] ?? '');
if ($valuationRange !== '' || $valuationDesc !== '') {
$this->appendDisplayItem($items, '估值区间', $valuationRange ?: '-', $valuationDesc, true);
}
$externalRemark = $this->textValue($resultInfo['external_remark'] ?? '');
if ($externalRemark !== '') {
$this->appendDisplayItem($items, '备注', $externalRemark);
}
return [
@@ -354,6 +379,42 @@ class ReportsController
];
}
private function appendDisplayItem(array &$items, string $label, mixed $value, mixed $remark = '', bool $keepEmpty = false): void
{
$valueText = $this->textValue($value);
$remarkText = $this->textValue($remark);
if (!$keepEmpty && $valueText === '' && $remarkText === '') {
return;
}
$items[] = [
'label' => $label,
'value' => $valueText !== '' ? $valueText : '-',
'remark' => $remarkText,
];
}
private function formatValuationRange(mixed $min, mixed $max): string
{
$minValue = (float)($min ?? 0);
$maxValue = (float)($max ?? 0);
if ($minValue <= 0 && $maxValue <= 0) {
return '';
}
if ($minValue > 0 && $maxValue > 0) {
return '¥' . $this->formatMoney($minValue) . ' - ¥' . $this->formatMoney($maxValue);
}
if ($minValue > 0) {
return '¥' . $this->formatMoney($minValue) . ' 起';
}
return '¥' . $this->formatMoney($maxValue) . ' 内';
}
private function formatMoney(float $value): string
{
return rtrim(rtrim(number_format($value, 2, '.', ''), '0'), '.');
}
private function buildTraceInfo(int $orderId, array $appraisalInfo, array $evidenceAttachments, Request $request): array
{
$logs = $orderId > 0