feat: add report review publish flow
This commit is contained in:
@@ -179,7 +179,11 @@ class EnterpriseOrderService
|
||||
$timeline = Db::name('order_timelines')->where('order_id', (int)$order['id'])->order('occurred_at', 'asc')->select()->toArray();
|
||||
$sendLogistics = Db::name('order_logistics')->where('order_id', (int)$order['id'])->where('logistics_type', 'send_to_center')->order('id', 'desc')->find();
|
||||
$returnLogistics = Db::name('order_logistics')->where('order_id', (int)$order['id'])->where('logistics_type', 'return_to_user')->order('id', 'desc')->find();
|
||||
$report = Db::name('reports')->where('order_id', (int)$order['id'])->order('id', 'desc')->find();
|
||||
$report = Db::name('reports')
|
||||
->where('order_id', (int)$order['id'])
|
||||
->where('report_status', 'published')
|
||||
->order('id', 'desc')
|
||||
->find();
|
||||
$verify = $report ? (Db::name('report_verifies')->where('report_id', (int)$report['id'])->find() ?: null) : null;
|
||||
|
||||
return [
|
||||
|
||||
@@ -269,7 +269,7 @@ class FulfillmentFlowService
|
||||
$context = $this->formatOrderContext((int)$flow['order_id'], $request);
|
||||
$report = $context['report_info'] ?? null;
|
||||
if (!$report || ($report['report_status'] ?? '') !== 'published') {
|
||||
throw new \InvalidArgumentException('订单报告未发布,不能进入寄回流程');
|
||||
throw new \InvalidArgumentException('该报告未发布,不符合寄回条件');
|
||||
}
|
||||
|
||||
return $context + [
|
||||
@@ -289,7 +289,7 @@ class FulfillmentFlowService
|
||||
}
|
||||
$report = $this->latestReport((int)$flow['order_id']);
|
||||
if (!$report || ($report['report_status'] ?? '') !== 'published') {
|
||||
throw new \InvalidArgumentException('订单报告未发布,不能确认寄回');
|
||||
throw new \InvalidArgumentException('该报告未发布,不符合寄回条件');
|
||||
}
|
||||
|
||||
$tag = (new MaterialTagService())->findTagByInput($qrInput);
|
||||
@@ -320,7 +320,10 @@ class FulfillmentFlowService
|
||||
$report = $this->latestReport((int)$flow['order_id']);
|
||||
$content = $report ? Db::name('report_contents')->where('report_id', (int)$report['id'])->find() : null;
|
||||
$files = $this->decodeJsonArray($content['zhongjian_report_files_json'] ?? null);
|
||||
if (!$report || ($report['report_status'] ?? '') !== 'published' || trim((string)($report['zhongjian_report_no'] ?? '')) === '' || !$files) {
|
||||
if (!$report || ($report['report_status'] ?? '') !== 'published') {
|
||||
throw new \InvalidArgumentException('该报告未发布,不符合寄回条件');
|
||||
}
|
||||
if (trim((string)($report['zhongjian_report_no'] ?? '')) === '' || !$files) {
|
||||
throw new \InvalidArgumentException('中检报告未完整录入,不能确认寄回');
|
||||
}
|
||||
|
||||
@@ -337,7 +340,7 @@ class FulfillmentFlowService
|
||||
|
||||
$report = $this->latestReport((int)$flow['order_id']);
|
||||
if (!$report || ($report['report_status'] ?? '') !== 'published') {
|
||||
throw new \InvalidArgumentException('订单报告未发布,不能确认寄回');
|
||||
throw new \InvalidArgumentException('该报告未发布,不符合寄回条件');
|
||||
}
|
||||
if ((int)$report['id'] !== $reportId) {
|
||||
throw new \InvalidArgumentException('确认的报告与当前订单报告不匹配');
|
||||
@@ -371,6 +374,10 @@ class FulfillmentFlowService
|
||||
if (!$flow) {
|
||||
throw new \RuntimeException('未找到可用的内部流转挂牌', 404);
|
||||
}
|
||||
$report = $this->latestReport((int)$flow['order_id']);
|
||||
if (!$report || ($report['report_status'] ?? '') !== 'published') {
|
||||
throw new \InvalidArgumentException('该报告未发布,不符合寄回条件');
|
||||
}
|
||||
if ((string)($flow['current_stage'] ?? '') !== 'return_confirmed') {
|
||||
throw new \InvalidArgumentException('请先完成报告确认,再登记回寄运单');
|
||||
}
|
||||
|
||||
@@ -344,10 +344,6 @@ class MaterialTagService
|
||||
if ($batch && ($batch['status'] ?? 'active') === 'invalid') {
|
||||
throw new \InvalidArgumentException('该吊牌所属批次已失效,不能绑定报告');
|
||||
}
|
||||
if (($tag['bind_status'] ?? '') === 'bound' || (int)($tag['report_id'] ?? 0) > 0) {
|
||||
throw new \InvalidArgumentException('该吊牌已绑定报告,不能重复绑定');
|
||||
}
|
||||
|
||||
$task = Db::name('appraisal_tasks')->where('id', $taskId)->find();
|
||||
if (!$task) {
|
||||
throw new \RuntimeException('任务不存在', 404);
|
||||
@@ -364,6 +360,21 @@ class MaterialTagService
|
||||
throw new \InvalidArgumentException('报告已发布,不能再绑定或更换吊牌');
|
||||
}
|
||||
|
||||
if (($tag['bind_status'] ?? '') === 'bound' || (int)($tag['report_id'] ?? 0) > 0) {
|
||||
if (
|
||||
(int)($tag['report_id'] ?? 0) === (int)$report['id']
|
||||
&& in_array((string)($report['report_status'] ?? ''), ['draft', 'pending_publish', 'updated', 'rejected'], true)
|
||||
) {
|
||||
return $this->formatTagCode($tag, [
|
||||
'id' => (int)$report['id'],
|
||||
'report_no' => (string)$report['report_no'],
|
||||
'report_status' => (string)$report['report_status'],
|
||||
]);
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('该吊牌已绑定报告,不能重复绑定');
|
||||
}
|
||||
|
||||
$existing = Db::name('material_tag_codes')->where('report_id', (int)$report['id'])->find();
|
||||
if ($existing) {
|
||||
throw new \InvalidArgumentException('当前报告已绑定吊牌,不能重复绑定');
|
||||
@@ -530,18 +541,13 @@ class MaterialTagService
|
||||
if (($report['report_status'] ?? '') !== 'published') {
|
||||
return [
|
||||
'tag_status' => 'pending_report',
|
||||
'status_text' => '报告生成中',
|
||||
'status_text' => '报告未发布',
|
||||
'message' => '该吊牌已关联报告,正式报告发布后可查看完整内容。',
|
||||
'qr_token' => (string)$tag['qr_token'],
|
||||
'qr_url' => (string)$tag['qr_url'],
|
||||
'scan_count' => (int)$tag['scan_count'],
|
||||
'verify_count' => (int)$tag['verify_count'],
|
||||
'report_summary' => [
|
||||
'report_no' => (string)$report['report_no'],
|
||||
'report_title' => (string)$report['report_title'],
|
||||
'institution_name' => (string)$report['institution_name'],
|
||||
'publish_time' => (string)($report['publish_time'] ?? ''),
|
||||
],
|
||||
'report_summary' => null,
|
||||
'product_summary' => [],
|
||||
'result_summary' => [],
|
||||
'verify_passed' => false,
|
||||
|
||||
Reference in New Issue
Block a user