功能性

This commit is contained in:
Your Name
2026-11-27 17:25:53 +08:00
parent 954e6f00d0
commit 82a91858f9
7 changed files with 217 additions and 29 deletions
@@ -64,6 +64,7 @@ try {
id INT PRIMARY KEY AUTO_INCREMENT, diagnosis_id INT DEFAULT 1, gender INT DEFAULT 0,
creator_id INT DEFAULT 1, assistant_id INT DEFAULT 0, is_shared INT DEFAULT 0,
herbs TEXT, audit_status INT DEFAULT 1, void_status INT DEFAULT 0, visible_role_ids VARCHAR(100) DEFAULT "",
audit_by INT NULL, audit_by_name VARCHAR(100), audit_time INT NULL, audit_remark VARCHAR(500),
create_time INT DEFAULT 0, update_time INT DEFAULT 0, delete_time INT NULL
) ENGINE=InnoDB');
$pdo->exec('CREATE TABLE zyt_tcm_diagnosis (id INT PRIMARY KEY, assistant_id INT DEFAULT 0, delete_time INT NULL)');
@@ -171,7 +172,7 @@ try {
'Final pending audit must reject changed tracking and roll back all form changes');
}
// New orders always start pending, even if clients submit fake audit flags or the source prescription is approved.
// Creation trusts recorded approvals, never audit flags supplied by the client or set by a column default.
$createParams = static fn (int $rxId): array => [
'prescription_id' => $rxId, 'diagnosis_id' => 1, 'recipient_name' => '测试患者',
'recipient_phone' => '13000000000', 'shipping_address' => '测试地址', 'fee_type' => 3, 'amount' => 100,
@@ -188,6 +189,20 @@ try {
&& (int) $out['prescription_audit_status'] === 0 && (int) $out['payment_slip_audit_status'] === 0,
'Normal creation must store empty tracking and pending audits');
}
$rxId = $newRx();
$auditTime = time() - 90;
Db::name('tcm_prescription')->where('id', $rxId)->update([
'herbs' => '[{"name":"测试药材"}]', 'audit_by' => 2, 'audit_by_name' => '实际审核人',
'audit_time' => $auditTime, 'audit_remark' => '已开处方审核意见',
]);
$out = PrescriptionOrderLogic::create($createParams($rxId), 1, $admin);
$expect(is_array($out) && (int) $out['prescription_audit_status'] === 1
&& (int) $out['payment_slip_audit_status'] === 0 && (int) $out['fulfillment_status'] === 1,
'An order created after prescription approval inherits the approval and still needs payment review');
$approvalLog = $logs((int) $out['id'])[1];
$expect($approvalLog['action'] === 'audit_rx_approve' && (int) $approvalLog['admin_id'] === 2
&& (int) $approvalLog['create_time'] === $auditTime,
'Inherited approval records the original approver and approval time');
// Audit revocation must be observed on the next request; historical fulfillment/snapshot data grants no exemption.
foreach ([1, 2, 3, 4, 5, 6, 9, 10] as $status) {