This commit is contained in:
Your Name
2026-12-04 10:01:42 +08:00
parent 91e35cb905
commit 63e52f6273
8 changed files with 128 additions and 27 deletions
@@ -3230,7 +3230,8 @@ class PrescriptionOrderLogic
$logSummary = $summary;
if ($changeParts !== []) {
$logSummary .= '(' . implode(';', $changeParts) . ')';
$changeSummary = '(' . implode(';', $changeParts) . ')';
$logSummary = mb_substr($summary, 0, 500 - mb_strlen($changeSummary)) . $changeSummary;
}
self::writeLog($id, $adminId, $adminInfo, 'manual_log', $logSummary);
@@ -4795,26 +4796,35 @@ class PrescriptionOrderLogic
}
}
$paymentAuditActions = ['audit_pay_approve', 'audit_pay_reject'];
$paymentAuditResetActions = [
'revoke_pay_audit', 'audit_rx_reject', 'revoke_rx_audit', 'add_pay_order', 'link_pay_order', 'completion_request',
];
$logRows = PrescriptionOrderLog::whereIn('prescription_order_id', $poIds)
->whereIn('action', ['audit_rx_approve', 'audit_rx_reject', 'revoke_rx_audit'])
->field(['prescription_order_id', 'id', 'action', 'admin_name', 'create_time'])
->whereIn('action', [...$paymentAuditActions, ...$paymentAuditResetActions, 'manual_log'])
->field(['prescription_order_id', 'action', 'admin_name', 'create_time', 'summary'])
->order('id', 'asc')
->select()
->toArray();
$auditEffectiveByPo = [];
$paymentAuditByPo = [];
foreach ($logRows as $lg) {
$pid = (int) ($lg['prescription_order_id'] ?? 0);
if ($pid <= 0) {
$pid = (int) $lg['prescription_order_id'];
$action = $lg['action'];
if (in_array($action, $paymentAuditActions, true)) {
$paymentAuditByPo[$pid] = $lg;
continue;
}
$act = (string) ($lg['action'] ?? '');
if ($act === 'revoke_rx_audit') {
$auditEffectiveByPo[$pid] = null;
$summary = (string) $lg['summary'];
// 补录已支付收款也记为 link_pay_order,但只有发起新审核的关联操作会重置状态。
if ($action === 'link_pay_order' && !str_starts_with($summary, '关联支付单 ')) {
continue;
}
if ($act === 'audit_rx_approve' || $act === 'audit_rx_reject') {
$auditEffectiveByPo[$pid] = $lg;
// 手工调整支付审核状态会追加固定格式的变更说明,普通备注不影响已有审核记录。
if ($action === 'manual_log'
&& !preg_match('/[(;]支付单审核:(待审核|已通过|已驳回) → (待审核|已通过|已驳回))$/u', $summary)) {
continue;
}
unset($paymentAuditByPo[$pid]);
}
// 服务套餐字典:与前端 formatServicePackage 同口径(dict_data type_value=server_order;只取启用项做兜底取原值)
@@ -5016,16 +5026,18 @@ class PrescriptionOrderLogic
$item['export_center_label'] = '一中心';
}
$paSt = (int) ($item['prescription_audit_status'] ?? 0);
$aud = $auditEffectiveByPo[$poId] ?? null;
if (($paSt === 1 || $paSt === 2) && \is_array($aud)) {
$at = (int) ($aud['create_time'] ?? 0);
$item['export_rx_audit_time'] = $at > 0 ? date('Y-m-d H:i:s', $at) : '';
$item['export_rx_auditor'] = (string) ($aud['admin_name'] ?? '');
} else {
$item['export_rx_audit_time'] = '';
$item['export_rx_auditor'] = '';
$paymentAudit = $paymentAuditByPo[$poId] ?? [];
$expectedAction = match ((int) ($item['payment_slip_audit_status'] ?? 0)) {
1 => 'audit_pay_approve',
2 => 'audit_pay_reject',
default => null,
};
if ($expectedAction === null || ($paymentAudit['action'] ?? null) !== $expectedAction) {
$paymentAudit = [];
}
$auditTime = (int) ($paymentAudit['create_time'] ?? 0);
$item['export_payment_audit_time'] = $auditTime > 0 ? date('Y-m-d H:i:s', $auditTime) : '';
$item['export_payment_auditor'] = (string) ($paymentAudit['admin_name'] ?? '');
}
unset($item);
}