fix: allow rejected report resubmission
This commit is contained in:
@@ -707,6 +707,8 @@ class AppraisalTasksController
|
||||
$order = Db::name('orders')->where('id', (int)$task['order_id'])->find() ?: [];
|
||||
$task['order_status'] = $order['order_status'] ?? '';
|
||||
$report = $this->findLatestAppraisalReport((int)$task['order_id']);
|
||||
$materialTagService = new MaterialTagService();
|
||||
$boundMaterialTag = $report ? $materialTagService->findBoundTagForReport((int)$report['id']) : null;
|
||||
$effectiveStatus = $this->effectiveTaskStatus($task, $report);
|
||||
if ($effectiveStatus !== $task['status']) {
|
||||
Db::name('appraisal_tasks')->where('id', $id)->update([
|
||||
@@ -729,7 +731,7 @@ class AppraisalTasksController
|
||||
if ($action !== 'save' && $resultText === '') {
|
||||
return api_error('鉴定结论不能为空', 422);
|
||||
}
|
||||
if ($action !== 'save' && $qrInput === '') {
|
||||
if ($action !== 'save' && $qrInput === '' && !$boundMaterialTag) {
|
||||
return api_error('请扫描验真吊牌二维码', 422);
|
||||
}
|
||||
$productInput = $request->input('product_info', null);
|
||||
@@ -836,8 +838,10 @@ class AppraisalTasksController
|
||||
Db::rollback();
|
||||
return api_error('报告草稿生成失败', 500);
|
||||
}
|
||||
$tag = (new MaterialTagService())->bindTagToReportByTask($id, $qrInput, $request);
|
||||
$freshReport = $this->findLatestAppraisalReport((int)$task['order_id']) ?: $report;
|
||||
$tag = $boundMaterialTag && $qrInput === ''
|
||||
? ($materialTagService->findBoundTagForReport((int)$freshReport['id']) ?: $boundMaterialTag)
|
||||
: $materialTagService->bindTagToReportByTask($id, $qrInput, $request);
|
||||
$this->insertReportLog((int)$freshReport['id'], $draftChange['action'], $draftChange['before'], $freshReport, $request, '报告已提交,待管理员发布');
|
||||
$this->insertReportLog((int)$freshReport['id'], 'submit', $draftChange['before'], $freshReport, $request, '鉴定师提交报告');
|
||||
|
||||
@@ -858,6 +862,12 @@ class AppraisalTasksController
|
||||
'report_page_url' => '',
|
||||
],
|
||||
], '报告已提交,待管理员发布');
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
Db::rollback();
|
||||
return api_error($e->getMessage(), 422);
|
||||
} catch (\RuntimeException $e) {
|
||||
Db::rollback();
|
||||
return api_error($e->getMessage(), $e->getCode() ?: 500);
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
return api_error('结论保存失败', 500, [
|
||||
|
||||
Reference in New Issue
Block a user