chore: prepare release build

This commit is contained in:
wushumin
2026-05-16 16:32:56 +08:00
parent dd56e0861b
commit deecb5d33e
28 changed files with 4396 additions and 361 deletions

View File

@@ -5,6 +5,8 @@ namespace app\controller\admin;
use app\support\AppraisalEvidenceService;
use app\support\ContentService;
use app\support\EnterpriseWebhookService;
use app\support\FulfillmentFlowService;
use app\support\MaterialTagService;
use app\support\MessageDispatcher;
use support\Request;
use support\think\Db;
@@ -24,6 +26,7 @@ class ReportsController
->alias('r')
->leftJoin('orders o', 'o.id = r.order_id')
->leftJoin('order_products p', 'p.order_id = r.order_id')
->leftJoin('material_tag_codes mt', 'mt.report_id = r.id')
->field([
'r.id',
'r.report_no',
@@ -42,6 +45,9 @@ class ReportsController
'p.product_name',
'p.category_name',
'p.brand_name',
'mt.id as material_tag_id',
'mt.verify_code as material_tag_verify_code',
'mt.bind_status as material_tag_bind_status',
])
->order('r.id', 'desc');
@@ -80,6 +86,9 @@ class ReportsController
'product_name' => $item['product_name'] ?: (string)($productSnapshot['product_name'] ?? ''),
'category_name' => $item['category_name'] ?: (string)($productSnapshot['category_name'] ?? ''),
'brand_name' => $item['brand_name'] ?: (string)($productSnapshot['brand_name'] ?? ''),
'material_tag_bound' => (int)($item['material_tag_id'] ?? 0) > 0,
'material_tag_verify_code' => (string)($item['material_tag_verify_code'] ?? ''),
'material_tag_bind_status' => (string)($item['material_tag_bind_status'] ?? ''),
];
if ($keyword !== '' && !$this->matchKeyword($mapped, $keyword)) {
@@ -125,21 +134,21 @@ class ReportsController
$zhongjianReportFiles = $this->evidenceService()->normalize($content['zhongjian_report_files_json'] ?? null, $request);
$appraisalSnapshot = $this->enrichAppraisalSnapshot($report, $appraisalSnapshot);
$evidenceAttachments = $this->evidenceService()->normalize($content['evidence_attachments_json'] ?? null, $request);
$materialTag = (new MaterialTagService())->findBoundTagForReport($id);
$usesPlatformVerify = (string)($report['service_provider'] ?? '') !== 'zhongjian';
$verify = $usesPlatformVerify ? (Db::name('report_verifies')->where('report_id', $id)->find() ?: []) : [];
if ($usesPlatformVerify && ($report['report_status'] ?? '') === 'published') {
$verify = Db::name('report_verifies')->where('report_id', $id)->find() ?: [];
if (($report['report_status'] ?? '') === 'published') {
$verify = $this->createOrUpdateVerifyRecord($report, date('Y-m-d H:i:s'));
}
$reportPageUrl = $usesPlatformVerify ? $this->buildPublicPageUrl('/pages/report/detail', ['report_no' => $report['report_no']]) : '';
$verifyUrl = $usesPlatformVerify ? $this->buildPublicPageUrl('/pages/verify/result', ['report_no' => $report['report_no']]) : '';
$reportPageUrl = $this->buildPublicPageUrl('/pages/report/detail', ['report_no' => $report['report_no']]);
$verifyUrl = $this->buildPublicPageUrl('/pages/verify/result', ['report_no' => $report['report_no']]);
if (!$verify) {
$verify = [];
}
$verify['report_page_url'] = $usesPlatformVerify ? ($verify['report_page_url'] ?? $reportPageUrl) : '';
$verify['verify_qrcode_url'] = $usesPlatformVerify ? ($verify['verify_qrcode_url'] ?? $reportPageUrl) : '';
$verify['verify_url'] = $usesPlatformVerify ? ($verify['verify_url'] ?? $verifyUrl) : '';
$verify['report_page_url'] = $verify['report_page_url'] ?? $reportPageUrl;
$verify['verify_qrcode_url'] = $verify['verify_qrcode_url'] ?? $reportPageUrl;
$verify['verify_url'] = $verify['verify_url'] ?? $verifyUrl;
$defaultRiskNotice = (new ContentService())->getReportRiskNotice((string)($report['report_type'] ?? 'appraisal'));
return api_success([
@@ -167,6 +176,7 @@ class ReportsController
'valuation_info' => $valuationSnapshot,
'evidence_attachments' => $evidenceAttachments,
'zhongjian_report_files' => $zhongjianReportFiles,
'material_tag' => $materialTag,
'risk_notice_text' => ($content['risk_notice_text'] ?? '') !== '' ? $content['risk_notice_text'] : $defaultRiskNotice,
'verify_info' => [
'verify_status' => $verify['verify_status'] ?? (($report['report_status'] ?? '') === 'published' ? 'valid' : 'pending'),
@@ -333,11 +343,9 @@ class ReportsController
'verify_url' => '',
'report_page_url' => '',
];
$usesPlatformVerify = $serviceProvider !== 'zhongjian';
if ($reportStatus === 'published' && $reportRecord && $usesPlatformVerify) {
if ($reportStatus === 'published' && $reportRecord) {
$verifyInfo = $this->createOrUpdateVerifyRecord($reportRecord, $now);
} else {
} elseif ($reportStatus !== 'published') {
Db::name('report_verifies')->where('report_id', $reportId)->delete();
}
@@ -361,6 +369,7 @@ class ReportsController
public function publish(Request $request)
{
$id = (int)$request->input('id', 0);
$qrInput = trim((string)$request->input('qr_input', ''));
if (!$id) {
return api_error('报告 ID 不能为空', 422);
}
@@ -381,7 +390,29 @@ class ReportsController
}
$effectivePublishTime = $report['publish_time'] ?: $now;
$usesPlatformVerify = (string)($report['service_provider'] ?? '') !== 'zhongjian';
$isOrderAppraisalReport = ($report['report_type'] ?? 'appraisal') === 'appraisal' && (int)($report['order_id'] ?? 0) > 0;
$materialTag = null;
if ($isOrderAppraisalReport) {
$materialTag = (new MaterialTagService())->findBoundTagForReport($id);
if (!$materialTag) {
if ($qrInput === '') {
Db::rollback();
return api_error('请扫描验真吊牌二维码后再发布报告', 422);
}
$task = Db::name('appraisal_tasks')
->where('order_id', (int)$report['order_id'])
->order('id', 'desc')
->find();
if (!$task) {
Db::rollback();
return api_error('报告未关联鉴定任务,不能绑定吊牌发布', 422);
}
$materialTag = (new MaterialTagService())->bindTagToReportByTask((int)$task['id'], $qrInput, $request);
}
}
if ($report['report_status'] !== 'published') {
Db::name('reports')->where('id', $id)->update([
'report_status' => 'published',
@@ -392,18 +423,13 @@ class ReportsController
$report['publish_time'] = $effectivePublishTime;
}
if (($report['report_type'] ?? 'appraisal') === 'appraisal' && (int)($report['order_id'] ?? 0) > 0) {
if ($isOrderAppraisalReport) {
$this->refreshAppraisalSnapshot((int)$report['id'], (int)$report['order_id'], $report['service_provider'], $now);
}
$verify = [];
if ($usesPlatformVerify) {
$verify = $this->createOrUpdateVerifyRecord($report, $now);
} else {
Db::name('report_verifies')->where('report_id', $id)->delete();
}
$verify = $this->createOrUpdateVerifyRecord($report, $now);
if (($report['report_type'] ?? 'appraisal') === 'appraisal' && (int)($report['order_id'] ?? 0) > 0) {
if ($isOrderAppraisalReport) {
Db::name('orders')->where('id', $report['order_id'])->update([
'order_status' => 'report_published',
'display_status' => '报告已出具',
@@ -424,7 +450,7 @@ class ReportsController
'order_id' => $report['order_id'],
'node_code' => 'report_published',
'node_text' => '报告已出具',
'node_desc' => $usesPlatformVerify ? '正式报告已发布,用户可查看报告并进行验真。' : '中检报告已发布,用户可查看报告。',
'node_desc' => '正式报告已发布,用户可查看报告并进行验真。',
'operator_type' => 'admin',
'operator_id' => (int)$request->header('x-admin-id', 0) ?: null,
'occurred_at' => $now,
@@ -440,22 +466,24 @@ class ReportsController
'report_title' => $report['report_title'],
'product_name' => $product['product_name'] ?? '',
'publish_time' => $report['publish_time'] ?: $now,
'verify_url' => $usesPlatformVerify ? (string)($verify['verify_url'] ?? '') : '',
'verify_url' => (string)($verify['verify_url'] ?? ''),
'fallback_title' => '报告已出具',
'fallback_content' => $usesPlatformVerify ? '您的正式报告已生成,可前往报告中心查看并完成验真。' : '您的中检报告已生成,可前往报告中心查看。',
'fallback_content' => '您的正式报告已生成,可前往报告中心查看并完成验真。',
]);
(new FulfillmentFlowService())->markReportPublished((int)$report['order_id'], $request);
}
Db::commit();
if (($report['report_type'] ?? 'appraisal') === 'appraisal' && (int)($report['order_id'] ?? 0) > 0) {
if ($isOrderAppraisalReport) {
(new EnterpriseWebhookService())->recordOrderEvent((int)$report['order_id'], 'report_published', [
'report_id' => $id,
'report_no' => (string)$report['report_no'],
'report_title' => (string)$report['report_title'],
'publish_time' => $effectivePublishTime,
'verify_url' => $usesPlatformVerify ? (string)($verify['verify_url'] ?? '') : '',
'report_page_url' => $usesPlatformVerify ? (string)($verify['report_page_url'] ?? '') : '',
'verify_url' => (string)($verify['verify_url'] ?? ''),
'report_page_url' => (string)($verify['report_page_url'] ?? ''),
]);
}
@@ -463,8 +491,9 @@ class ReportsController
'id' => $id,
'report_status' => 'published',
'publish_time' => $effectivePublishTime,
'verify_url' => $usesPlatformVerify ? (string)($verify['verify_url'] ?? '') : '',
'report_page_url' => $usesPlatformVerify ? (string)($verify['report_page_url'] ?? '') : '',
'verify_url' => (string)($verify['verify_url'] ?? ''),
'report_page_url' => (string)($verify['report_page_url'] ?? ''),
'material_tag' => $materialTag,
], '报告已发布');
} catch (\Throwable $e) {
Db::rollback();