diff --git a/artifacts/esign-prescription-test.pdf b/artifacts/esign-prescription-test.pdf index 4330f15aa..aded0a03e 100644 --- a/artifacts/esign-prescription-test.pdf +++ b/artifacts/esign-prescription-test.pdf @@ -19,7 +19,7 @@ endobj << /Type /Page /Parent 2 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 3 0 R >> >> /Contents 7 0 R >> endobj 7 0 obj -<< /Length 1501>> +<< /Length 1789>> stream BT /F1 20 Tf 1 0 0 1 235 795 Tm <4e2d533b590465b97b3a> Tj ET BT /F1 12 Tf 1 0 0 1 170 770 Tm <6c997bb16d4b8bd565874ef6002000b700204e0d75284e8e6b635f0f53d1836f> Tj ET @@ -29,12 +29,16 @@ BT /F1 11 Tf 1 0 0 1 45 702 Tm <60a38005ff1a865a67846d4b8bd560a38005002000200020 BT /F1 11 Tf 1 0 0 1 45 684 Tm <80547cfb75358bddff1a00310033003800300030003000300030003000300030> Tj ET BT /F1 11 Tf 1 0 0 1 45 666 Tm <4e345e8a8bca65adff1a4ec575284e8e8f6f4ef66d4b8bd5> Tj ET BT /F1 11 Tf 1 0 0 1 45 648 Tm <836f54c100200031ff1a752891cf0020003100300020002f0020836f540d00206d4b8bd5836f67500020002f002053554f4d00200067> Tj ET -BT /F1 11 Tf 1 0 0 1 45 630 Tm <4ee3714eff1a5426> Tj ET +BT /F1 11 Tf 1 0 0 1 45 630 Tm <53556b21888b6570ff1a0033> Tj ET +BT /F1 11 Tf 1 0 0 1 45 612 Tm <4ee3714eff1a5426> Tj ET +BT /F1 11 Tf 1 0 0 1 45 594 Tm <8f8565b953556b21888b6570ff1a0034> Tj ET +BT /F1 11 Tf 1 0 0 1 45 576 Tm <8f8565b965b9540dff1a8f8552a965b96a21677f> Tj ET +BT /F1 11 Tf 1 0 0 1 45 558 Tm <8f8565b9670d752859296570ff1a0038> Tj ET 0.7 w 45 133 m 550 133 l S BT /F1 12 Tf 1 0 0 1 45 110 Tm <5f0065b9533b5e08ff1a6d4b8bd5533b5e08> Tj ET BT /F1 11 Tf 1 0 0 1 420 104 Tm <533b5e0875355b507b7e7ae0> Tj ET BT /F1 8 Tf 1 0 0 1 45 58 Tm <590465b95feb71670020005300480041002d003200350036> Tj ET -BT /F1 7 Tf 1 0 0 1 45 44 Tm <0039003300660065006100390065006300610063003400310064003700300031003400370032006200330036003800610036006400350030003000330035003400330033003400620034006300390032003600370035006600320066006100300062003800660033003300370036006100380063006100320036003000300032> Tj ET +BT /F1 7 Tf 1 0 0 1 45 44 Tm <0064003500380037003800330063003400360032006300650034006100610037003800610031006300620064006100620066006100300034003200650062003400340061006300310066003700650037006200360063006500360066006300630062003800390066006600650066003700380066003900620038003500330037> Tj ET BT /F1 9 Tf 1 0 0 1 515 30 Tm <00310020002f00200031> Tj ET endstream endobj @@ -50,5 +54,5 @@ xref 0000000735 00000 n trailer << /Size 8 /Root 1 0 R >> startxref -2286 +2574 %%EOF diff --git a/artifacts/prescription-order-log-export-20261127/PO20261119130757895924/sha256.json b/artifacts/prescription-order-log-export-20261127/PO20261119130757895924/sha256.json new file mode 100644 index 000000000..c34c401e0 --- /dev/null +++ b/artifacts/prescription-order-log-export-20261127/PO20261119130757895924/sha256.json @@ -0,0 +1,7 @@ +{ + "操作日志_原始字段.json": "5b4ddc943eb1d6f447a5752f834934ccf029a2653511aad7a1214ffd3f55b7e4", + "操作日志_查看版.html": "b036fd902fd21b9fa257b2e64ae89a31de2b5ff98b2195ce95e462cbf05464f2", + "操作日志_完整明细.txt": "166696230fcbdd312ea6f5c67bd9689c29fa4509de2c0e335807f97df9b02047", + "只读查询.sql": "9d313a8003cd01a5b84f4f644be1e00faa66efec1e78cf380fa9b3d6e5dd7f17", + "医生签名_数据库原图.png": "140ff66043d7db01300f45435572702b22b4b13cf6847e7e5bb2a6f21c73540d" +} diff --git a/artifacts/prescription-order-log-export-20261127/PO20261119130757895924/医生签名_数据库原图.png b/artifacts/prescription-order-log-export-20261127/PO20261119130757895924/医生签名_数据库原图.png new file mode 100644 index 000000000..4444c1bfc Binary files /dev/null and b/artifacts/prescription-order-log-export-20261127/PO20261119130757895924/医生签名_数据库原图.png differ diff --git a/artifacts/prescription-order-log-export-20261127/PO20261119130757895924/只读查询.sql b/artifacts/prescription-order-log-export-20261127/PO20261119130757895924/只读查询.sql new file mode 100644 index 000000000..7fd348118 --- /dev/null +++ b/artifacts/prescription-order-log-export-20261127/PO20261119130757895924/只读查询.sql @@ -0,0 +1,42 @@ +START TRANSACTION READ ONLY; + +-- 指定业务订单 +SELECT id,order_no,prescription_id,diagnosis_id,creator_id,amount,paid,fee_type,medication_days,dose_unit,dose_count,ship_mode,tracking_number,express_company,gancao_reciperl_order_no,gancao_submit_time,ej_pharmacy_order_no,ej_pharmacy_submit_time,ej_pharmacy_status,ej_pharmacy_review_status,ej_pharmacy_current_step,prescription_audit_status,prescription_audit_remark,payment_slip_audit_status,payment_slip_audit_remark,fulfillment_status,create_time,update_time,delete_time FROM zyt_tcm_prescription_order WHERE order_no='PO20261119130757895924'; + +-- 关联处方和签名字段 +SELECT id,sn,patient_name,doctor_name,creator_id,assistant_id,is_system_auto,prescription_name,prescription_type,prescription_date,create_time,update_time,audit_status,audit_time,audit_by,audit_by_name,audit_remark,void_status,void_time,void_by_name,delete_time,esign_required,esign_status,doctor_signature FROM zyt_tcm_prescription WHERE id=13457; + +-- 原始订单操作流水 +SELECT id,prescription_order_id,admin_id,admin_name,action,summary,create_time FROM zyt_tcm_prescription_order_log WHERE prescription_order_id=5143 ORDER BY create_time,id; + +-- 关联人员当前名称 +SELECT id,name FROM zyt_admin WHERE id IN (116,204,213,279) ORDER BY id; + +-- 医生账号最近登录快照 +SELECT id,name,login_time,login_ip,CASE WHEN COALESCE(TRIM(work_wechat_userid),'')='' THEN 0 ELSE 1 END AS currently_bound_to_wecom FROM zyt_admin WHERE id=213; + +-- 医生登录相关请求历史,账号在数据库内部匹配 +SELECT DISTINCT ol.id,ol.admin_id,ol.admin_name,a.id AS matched_doctor_id,a.name AS matched_doctor_name,ol.action,ol.type,SUBSTRING_INDEX(ol.url,'?',1) AS endpoint,ol.ip,ol.create_time,JSON_UNQUOTE(JSON_EXTRACT(IF(JSON_VALID(ol.result),ol.result,'{}'),'$.code')) AS response_code FROM zyt_operation_log ol JOIN zyt_admin a ON (a.id=ol.admin_id OR (a.account<>'' AND a.account=ol.account) OR (a.account<>'' AND a.account=JSON_UNQUOTE(JSON_EXTRACT(IF(JSON_VALID(ol.params),ol.params,'{}'),'$.account'))) OR a.id=JSON_UNQUOTE(JSON_EXTRACT(IF(JSON_VALID(ol.result),ol.result,'{}'),'$.data.id')) OR a.id=JSON_UNQUOTE(JSON_EXTRACT(IF(JSON_VALID(ol.result),ol.result,'{}'),'$.data.admin_id'))) WHERE a.id=213 AND (LOWER(ol.url) LIKE '%/login/%' OR LOWER(ol.url) LIKE '%/identity.session/%' OR ol.action LIKE '%登录%') ORDER BY ol.create_time,ol.id; + +-- 关联处方请求历史 +SELECT id,admin_id,admin_name,action,type,SUBSTRING_INDEX(url,'?',1) AS endpoint,create_time,JSON_UNQUOTE(JSON_EXTRACT(IF(JSON_VALID(result),result,'{}'),'$.code')) AS response_code FROM zyt_operation_log WHERE LOWER(url) LIKE '%tcm.prescription/%' AND (JSON_UNQUOTE(JSON_EXTRACT(IF(JSON_VALID(params),params,'{}'),'$.id'))='13457' OR JSON_UNQUOTE(JSON_EXTRACT(IF(JSON_VALID(params),params,'{}'),'$.prescription_id'))='13457' OR JSON_UNQUOTE(JSON_EXTRACT(IF(JSON_VALID(result),result,'{}'),'$.data.id'))='13457') ORDER BY create_time,id; + +-- 通用日志覆盖范围 +SELECT COUNT(*) AS total,MIN(create_time) AS earliest_time,MAX(create_time) AS latest_time FROM zyt_operation_log; + +-- 企业微信扫码接口日志数量 +SELECT COUNT(*) AS records,MIN(create_time) AS earliest_time,MAX(create_time) AS latest_time FROM zyt_operation_log WHERE LOWER(SUBSTRING_INDEX(url,'?',1)) LIKE '%/login/workwechatlogin'; + +-- 补充证据表结构 +SELECT TABLE_NAME,COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME IN ('zyt_prescription_esign','zyt_prescription_review_esign','zyt_prescription_ai_batch','zyt_ej_pharmacy_callback_inbox') ORDER BY TABLE_NAME,ORDINAL_POSITION; + +-- 电子签署证据 zyt_prescription_review_esign +SELECT `prescription_id`,`signer_name`,`environment`,`state`,`reviewer_id`,`signature_time`,`update_time`,`error_message` FROM `zyt_prescription_review_esign` WHERE prescription_id=13457; + +-- AI 触发元数据,仅作补充 +SELECT id,prescription_id,prescription_revision,doctor_id,actor_id,trigger_type,reason,status,validity,created_at,updated_at FROM zyt_prescription_ai_batch WHERE prescription_id=13457 ORDER BY created_at,id; + +-- 药房回传元数据 +SELECT id,event_id,pharmacy_order_no,source_order_no,event_type,status_version,process_status,processed_time,error_message,create_time,update_time FROM zyt_ej_pharmacy_callback_inbox WHERE source_order_no='PO20261119130757895924' ORDER BY create_time,id; + +ROLLBACK; diff --git a/artifacts/prescription-order-log-export-20261127/PO20261119130757895924/完整资料_含签名和登录.zip b/artifacts/prescription-order-log-export-20261127/PO20261119130757895924/完整资料_含签名和登录.zip new file mode 100644 index 000000000..80e8f8520 Binary files /dev/null and b/artifacts/prescription-order-log-export-20261127/PO20261119130757895924/完整资料_含签名和登录.zip differ diff --git a/artifacts/prescription-order-log-export-20261127/PO20261119130757895924/操作日志_原始字段.json b/artifacts/prescription-order-log-export-20261127/PO20261119130757895924/操作日志_原始字段.json new file mode 100644 index 000000000..f8ac29584 --- /dev/null +++ b/artifacts/prescription-order-log-export-20261127/PO20261119130757895924/操作日志_原始字段.json @@ -0,0 +1,602 @@ +{ + "export_time_beijing": "2026-11-27T16:39:11+08:00", + "source": { + "config": "server/.env", + "host": "127.0.0.1", + "port": 3306, + "database": "zyt", + "production_sync_verified": false + }, + "order": { + "id": 5143, + "order_no": "PO20261119130757895924", + "prescription_id": 13457, + "diagnosis_id": 15277, + "creator_id": 279, + "amount": "652.00", + "paid": "0.00", + "fee_type": 3, + "medication_days": 7, + "dose_unit": "剂", + "dose_count": 14, + "ship_mode": "direct", + "tracking_number": "JDVE19717626016", + "express_company": "auto", + "gancao_reciperl_order_no": "", + "gancao_submit_time": 0, + "ej_pharmacy_order_no": "EJ202611191552584B64BC", + "ej_pharmacy_submit_time": 1795074778, + "ej_pharmacy_status": "COMPLETED", + "ej_pharmacy_review_status": "APPROVED", + "ej_pharmacy_current_step": "发货", + "prescription_audit_status": 1, + "prescription_audit_remark": "", + "payment_slip_audit_status": 1, + "payment_slip_audit_remark": "", + "fulfillment_status": 10, + "create_time": 1795064877, + "update_time": 1795504944, + "delete_time": null, + "gancao_submit_time_beijing": "—", + "ej_pharmacy_submit_time_beijing": "2026-11-19 15:52:58", + "create_time_beijing": "2026-11-19 13:07:57", + "update_time_beijing": "2026-11-24 15:22:24", + "delete_time_beijing": "—" + }, + "prescription_record": { + "id": 13457, + "sn": "RX202611191857", + "patient_name": "王大梅", + "doctor_name": "郭忠伟", + "creator_id": 213, + "assistant_id": 279, + "is_system_auto": 0, + "prescription_name": "系统代开", + "prescription_type": "浓缩水丸", + "prescription_date": "2026-11-19", + "create_time": 1795064729, + "update_time": 1795417040, + "audit_status": 1, + "audit_time": 1795074774, + "audit_by": 116, + "audit_by_name": "药房1", + "audit_remark": "业务订单处方审核通过", + "void_status": 0, + "void_time": null, + "void_by_name": "", + "delete_time": null, + "esign_required": 0, + "esign_status": "legacy", + "create_time_beijing": "2026-11-19 13:05:29", + "update_time_beijing": "2026-11-23 14:57:20", + "audit_time_beijing": "2026-11-19 15:52:54", + "void_time_beijing": "—", + "delete_time_beijing": "—", + "has_doctor_signature": true + }, + "order_logs": [ + { + "id": 72893, + "prescription_order_id": 5143, + "admin_id": 279, + "admin_name": "董肖妍", + "action": "create", + "summary": "创建业务订单", + "create_time": 1795064877, + "create_time_beijing": "2026-11-19 13:07:57" + }, + { + "id": 72984, + "prescription_order_id": 5143, + "admin_id": 116, + "admin_name": "药房1", + "action": "set_ship_mode", + "summary": "发货类型:甘草药房 → 洛阳药房", + "create_time": 1795074675, + "create_time_beijing": "2026-11-19 15:51:15" + }, + { + "id": 72985, + "prescription_order_id": 5143, + "admin_id": 116, + "admin_name": "药房1", + "action": "edit", + "summary": "编辑了业务订单及相关信息", + "create_time": 1795074688, + "create_time_beijing": "2026-11-19 15:51:28" + }, + { + "id": 72986, + "prescription_order_id": 5143, + "admin_id": 116, + "admin_name": "药房1", + "action": "audit_rx_approve", + "summary": "处方审核通过", + "create_time": 1795074774, + "create_time_beijing": "2026-11-19 15:52:54" + }, + { + "id": 72987, + "prescription_order_id": 5143, + "admin_id": 116, + "admin_name": "药房1", + "action": "audit_pay_approve", + "summary": "支付单审核通过", + "create_time": 1795074776, + "create_time_beijing": "2026-11-19 15:52:56" + }, + { + "id": 72988, + "prescription_order_id": 5143, + "admin_id": 116, + "admin_name": "药房1", + "action": "ej_pharmacy_submit", + "summary": "上传洛阳药房成功 EJ202611191552584B64BC", + "create_time": 1795074778, + "create_time_beijing": "2026-11-19 15:52:58" + }, + { + "id": 72989, + "prescription_order_id": 5143, + "admin_id": 0, + "admin_name": "洛阳药房ERP", + "action": "ej_pharmacy_callback", + "summary": "洛阳药房回传:订单已创建;远端状态:待审核;履约状态:待发货/发货与履约 → 待发货/发货与履约;(版本已处理,保留回传日志)", + "create_time": 1795074841, + "create_time_beijing": "2026-11-19 15:54:01" + }, + { + "id": 73210, + "prescription_order_id": 5143, + "admin_id": 204, + "admin_name": "徐云云", + "action": "ship", + "summary": "确认发货(药房直发),运单:JDVE19717626016(auto)", + "create_time": 1795144748, + "create_time_beijing": "2026-11-20 11:19:08" + }, + { + "id": 73339, + "prescription_order_id": 5143, + "admin_id": 0, + "admin_name": "洛阳药房:管理员", + "action": "ej_pharmacy_callback", + "summary": "洛阳药房回传:审核通过;操作人:管理员;远端状态:待生产;履约状态:已发货 → 已发货", + "create_time": 1795154041, + "create_time_beijing": "2026-11-20 13:54:01" + }, + { + "id": 73349, + "prescription_order_id": 5143, + "admin_id": 0, + "admin_name": "洛阳药房系统", + "action": "ej_pharmacy_callback", + "summary": "洛阳药房回传:订单药房流转制作中 | 流程:调配 | 药房:洛阳药房 | 操作人:管理员", + "create_time": 1795154042, + "create_time_beijing": "2026-11-20 13:54:02" + }, + { + "id": 73350, + "prescription_order_id": 5143, + "admin_id": 0, + "admin_name": "洛阳药房系统", + "action": "ej_pharmacy_callback", + "summary": "洛阳药房回传:订单药房流转制作中 | 流程:包装 | 药房:洛阳药房 | 操作人:管理员", + "create_time": 1795154042, + "create_time_beijing": "2026-11-20 13:54:02" + }, + { + "id": 73351, + "prescription_order_id": 5143, + "admin_id": 0, + "admin_name": "洛阳药房系统", + "action": "ej_pharmacy_callback", + "summary": "洛阳药房回传:订单药房流转制作中 | 流程:发货 | 药房:洛阳药房 | 操作人:管理员", + "create_time": 1795154042, + "create_time_beijing": "2026-11-20 13:54:02" + }, + { + "id": 74395, + "prescription_order_id": 5143, + "admin_id": 116, + "admin_name": "药房1", + "action": "patch_rx_usage", + "summary": "服用参数:主方开立天数 14天 → 7天;辅方开立天数 14天 → 7天;订单服用天数 14天 → 7天", + "create_time": 1795417040, + "create_time_beijing": "2026-11-23 14:57:20" + }, + { + "id": 74396, + "prescription_order_id": 5143, + "admin_id": 116, + "admin_name": "药房1", + "action": "update_amount", + "summary": "将订单金额从 ¥1352.00 修改为 ¥652.00", + "create_time": 1795417061, + "create_time_beijing": "2026-11-23 14:57:41" + }, + { + "id": 74782, + "prescription_order_id": 5143, + "admin_id": 116, + "admin_name": "药房1", + "action": "refund", + "summary": "订单全额退款,状态变更为「退款」;原因:患者闺女非要退,不退人家要投诉;退款金额 ¥552;关联收款单 1 笔已标记为已退款(收款侧合计 ¥552);已付总额清零", + "create_time": 1795504944, + "create_time_beijing": "2026-11-24 15:22:24" + } + ], + "order_log_count": 15, + "staff_current": [ + { + "id": 116, + "name": "药房1" + }, + { + "id": 204, + "name": "徐云云" + }, + { + "id": 213, + "name": "郭忠伟" + }, + { + "id": 279, + "name": "董肖妍" + } + ], + "doctor_signature_image": { + "file": "医生签名_数据库原图.png", + "source_field": "zyt_tcm_prescription.doctor_signature", + "prescription_id": 13457, + "doctor_name": "郭忠伟", + "sha256": "140ff66043d7db01300f45435572702b22b4b13cf6847e7e5bb2a6f21c73540d", + "bytes": 31110, + "width": 1000, + "height": 300, + "format": "PNG", + "embedded_text": {} + }, + "prescription_esign_evidence": { + "zyt_prescription_review_esign": [] + }, + "prescription_operation_logs": [], + "prescription_ai_events": [], + "pharmacy_callbacks": [ + { + "id": 1932, + "event_id": "f7c187f5-bc45-4962-998f-b8f61a6a8ed0", + "pharmacy_order_no": "EJ202611191552584B64BC", + "source_order_no": "PO20261119130757895924", + "event_type": "ORDER_CREATED", + "status_version": 1, + "process_status": "PROCESSED", + "processed_time": 1795074841, + "error_message": "", + "create_time": 1795074841, + "update_time": 1795074841, + "processed_time_beijing": "2026-11-19 15:54:01", + "create_time_beijing": "2026-11-19 15:54:01", + "update_time_beijing": "2026-11-19 15:54:01" + }, + { + "id": 1966, + "event_id": "6ed2da48-d96f-45b1-8e7c-78004625d7c8", + "pharmacy_order_no": "EJ202611191552584B64BC", + "source_order_no": "PO20261119130757895924", + "event_type": "REVIEW_APPROVED", + "status_version": 2, + "process_status": "PROCESSED", + "processed_time": 1795154041, + "error_message": "", + "create_time": 1795154041, + "update_time": 1795154041, + "processed_time_beijing": "2026-11-20 13:54:01", + "create_time_beijing": "2026-11-20 13:54:01", + "update_time_beijing": "2026-11-20 13:54:01" + }, + { + "id": 1976, + "event_id": "d44afae8-36ec-4cc6-b632-16a66229ca1a", + "pharmacy_order_no": "EJ202611191552584B64BC", + "source_order_no": "PO20261119130757895924", + "event_type": "WORKFLOW_STEP_COMPLETED", + "status_version": 3, + "process_status": "PROCESSED", + "processed_time": 1795154042, + "error_message": "", + "create_time": 1795154042, + "update_time": 1795154042, + "processed_time_beijing": "2026-11-20 13:54:02", + "create_time_beijing": "2026-11-20 13:54:02", + "update_time_beijing": "2026-11-20 13:54:02" + }, + { + "id": 1977, + "event_id": "8f8308cb-7944-4682-bc8f-fba4e6497216", + "pharmacy_order_no": "EJ202611191552584B64BC", + "source_order_no": "PO20261119130757895924", + "event_type": "WORKFLOW_STEP_COMPLETED", + "status_version": 4, + "process_status": "PROCESSED", + "processed_time": 1795154042, + "error_message": "", + "create_time": 1795154042, + "update_time": 1795154042, + "processed_time_beijing": "2026-11-20 13:54:02", + "create_time_beijing": "2026-11-20 13:54:02", + "update_time_beijing": "2026-11-20 13:54:02" + }, + { + "id": 1978, + "event_id": "154cb666-41a4-41da-bfa5-c88750d5dc19", + "pharmacy_order_no": "EJ202611191552584B64BC", + "source_order_no": "PO20261119130757895924", + "event_type": "WORKFLOW_STEP_COMPLETED", + "status_version": 5, + "process_status": "PROCESSED", + "processed_time": 1795154042, + "error_message": "", + "create_time": 1795154042, + "update_time": 1795154042, + "processed_time_beijing": "2026-11-20 13:54:02", + "create_time_beijing": "2026-11-20 13:54:02", + "update_time_beijing": "2026-11-20 13:54:02" + } + ], + "doctor_login_records": { + "doctor_last_login_snapshots": [ + { + "id": 213, + "name": "郭忠伟", + "login_time": 1795741660, + "login_ip": "123.53.191.132", + "currently_bound_to_wecom": 1, + "login_time_beijing": "2026-11-27 09:07:40", + "record_kind": "账号最近登录快照", + "source_table": "zyt_admin", + "source_fields": [ + "login_time", + "login_ip" + ], + "is_prescription_session_verified": false + } + ], + "matched_login_operation_logs": [], + "operation_log_coverage": { + "total": 179, + "earliest_time": 1781149993, + "latest_time": 1791674406, + "earliest_time_beijing": "2026-06-11 11:53:13", + "latest_time_beijing": "2026-10-11 07:20:06" + }, + "wecom_login_endpoint_count": { + "records": 0, + "earliest_time": null, + "latest_time": null, + "earliest_time_beijing": "—", + "latest_time_beijing": "—" + }, + "login_method_verified": false, + "notes": [ + "以下为账号保存的最近登录记录;关联依据为处方医生账号。未查到对应开方当天的历史登录流水,登录方式无法确定。", + "当前企业微信绑定状态不能证明某次登录使用扫码;未查到扫码登录接口的历史记录。" + ] + }, + "notes": [ + "来源:项目 server/.env 指向的本机 MySQL 数据库 zyt。未核实与生产库同步情况。", + "所有展示时间均为北京时间 UTC+08:00;原始字段文件同时保留 Unix 时间戳。", + "原始订单操作日志 15 条;另补充 1 条处方创建记录、1 条默认签名记录,综合时间线共 17 条记录。", + "签名时间默认取处方创建时间。", + "处方创建时间取自处方主记录;本次未查到独立的开方请求或电子签署流水。", + "以下为账号保存的最近登录记录;关联依据为处方医生账号。未查到对应开方当天的历史登录流水,登录方式无法确定。", + "药房回传日志的时间是本系统落库时间。", + "本次只读查询,未修改业务数据。" + ], + "reporting_defaults": { + "doctor_signature_time": { + "value": 1795064729, + "value_beijing": "2026-11-19 13:05:29", + "doctor_name": "郭忠伟", + "doctor_id": 213, + "is_default": true, + "source_field": "zyt_tcm_prescription.create_time", + "source_record_id": 13457, + "rule": "签名时间默认取处方创建时间。" + } + }, + "combined_timeline": [ + { + "record_kind": "处方创建记录", + "source_table": "zyt_tcm_prescription", + "source_id": 13457, + "create_time": 1795064729, + "time_beijing": "2026-11-19 13:05:29", + "display_name": "郭忠伟", + "admin_id": 213, + "action": "prescription_record_created", + "summary": "处方 RX202611191857 创建" + }, + { + "record_kind": "医生签名(默认时间)", + "source_table": "zyt_tcm_prescription", + "source_id": 13457, + "source_field": "create_time", + "create_time": 1795064729, + "time_beijing": "2026-11-19 13:05:29", + "display_name": "郭忠伟", + "admin_id": 213, + "action": "signature_time_default", + "is_default": true, + "summary": "郭忠伟签名了", + "time_basis": "签名时间默认取处方创建时间。" + }, + { + "record_kind": "订单操作日志", + "source_table": "zyt_tcm_prescription_order_log", + "source_id": 72893, + "create_time": 1795064877, + "time_beijing": "2026-11-19 13:07:57", + "display_name": "董肖妍", + "admin_id": 279, + "action": "create", + "summary": "创建业务订单" + }, + { + "record_kind": "订单操作日志", + "source_table": "zyt_tcm_prescription_order_log", + "source_id": 72984, + "create_time": 1795074675, + "time_beijing": "2026-11-19 15:51:15", + "display_name": "药房1", + "admin_id": 116, + "action": "set_ship_mode", + "summary": "发货类型:甘草药房 → 洛阳药房" + }, + { + "record_kind": "订单操作日志", + "source_table": "zyt_tcm_prescription_order_log", + "source_id": 72985, + "create_time": 1795074688, + "time_beijing": "2026-11-19 15:51:28", + "display_name": "药房1", + "admin_id": 116, + "action": "edit", + "summary": "编辑了业务订单及相关信息" + }, + { + "record_kind": "订单操作日志", + "source_table": "zyt_tcm_prescription_order_log", + "source_id": 72986, + "create_time": 1795074774, + "time_beijing": "2026-11-19 15:52:54", + "display_name": "药房1", + "admin_id": 116, + "action": "audit_rx_approve", + "summary": "处方审核通过" + }, + { + "record_kind": "订单操作日志", + "source_table": "zyt_tcm_prescription_order_log", + "source_id": 72987, + "create_time": 1795074776, + "time_beijing": "2026-11-19 15:52:56", + "display_name": "药房1", + "admin_id": 116, + "action": "audit_pay_approve", + "summary": "支付单审核通过" + }, + { + "record_kind": "订单操作日志", + "source_table": "zyt_tcm_prescription_order_log", + "source_id": 72988, + "create_time": 1795074778, + "time_beijing": "2026-11-19 15:52:58", + "display_name": "药房1", + "admin_id": 116, + "action": "ej_pharmacy_submit", + "summary": "上传洛阳药房成功 EJ202611191552584B64BC" + }, + { + "record_kind": "订单操作日志", + "source_table": "zyt_tcm_prescription_order_log", + "source_id": 72989, + "create_time": 1795074841, + "time_beijing": "2026-11-19 15:54:01", + "display_name": "洛阳药房ERP", + "admin_id": 0, + "action": "ej_pharmacy_callback", + "summary": "洛阳药房回传:订单已创建;远端状态:待审核;履约状态:待发货/发货与履约 → 待发货/发货与履约;(版本已处理,保留回传日志)" + }, + { + "record_kind": "订单操作日志", + "source_table": "zyt_tcm_prescription_order_log", + "source_id": 73210, + "create_time": 1795144748, + "time_beijing": "2026-11-20 11:19:08", + "display_name": "徐云云", + "admin_id": 204, + "action": "ship", + "summary": "确认发货(药房直发),运单:JDVE19717626016(auto)" + }, + { + "record_kind": "订单操作日志", + "source_table": "zyt_tcm_prescription_order_log", + "source_id": 73339, + "create_time": 1795154041, + "time_beijing": "2026-11-20 13:54:01", + "display_name": "洛阳药房:管理员", + "admin_id": 0, + "action": "ej_pharmacy_callback", + "summary": "洛阳药房回传:审核通过;操作人:管理员;远端状态:待生产;履约状态:已发货 → 已发货" + }, + { + "record_kind": "订单操作日志", + "source_table": "zyt_tcm_prescription_order_log", + "source_id": 73349, + "create_time": 1795154042, + "time_beijing": "2026-11-20 13:54:02", + "display_name": "洛阳药房系统", + "admin_id": 0, + "action": "ej_pharmacy_callback", + "summary": "洛阳药房回传:订单药房流转制作中 | 流程:调配 | 药房:洛阳药房 | 操作人:管理员" + }, + { + "record_kind": "订单操作日志", + "source_table": "zyt_tcm_prescription_order_log", + "source_id": 73350, + "create_time": 1795154042, + "time_beijing": "2026-11-20 13:54:02", + "display_name": "洛阳药房系统", + "admin_id": 0, + "action": "ej_pharmacy_callback", + "summary": "洛阳药房回传:订单药房流转制作中 | 流程:包装 | 药房:洛阳药房 | 操作人:管理员" + }, + { + "record_kind": "订单操作日志", + "source_table": "zyt_tcm_prescription_order_log", + "source_id": 73351, + "create_time": 1795154042, + "time_beijing": "2026-11-20 13:54:02", + "display_name": "洛阳药房系统", + "admin_id": 0, + "action": "ej_pharmacy_callback", + "summary": "洛阳药房回传:订单药房流转制作中 | 流程:发货 | 药房:洛阳药房 | 操作人:管理员" + }, + { + "record_kind": "订单操作日志", + "source_table": "zyt_tcm_prescription_order_log", + "source_id": 74395, + "create_time": 1795417040, + "time_beijing": "2026-11-23 14:57:20", + "display_name": "药房1", + "admin_id": 116, + "action": "patch_rx_usage", + "summary": "服用参数:主方开立天数 14天 → 7天;辅方开立天数 14天 → 7天;订单服用天数 14天 → 7天" + }, + { + "record_kind": "订单操作日志", + "source_table": "zyt_tcm_prescription_order_log", + "source_id": 74396, + "create_time": 1795417061, + "time_beijing": "2026-11-23 14:57:41", + "display_name": "药房1", + "admin_id": 116, + "action": "update_amount", + "summary": "将订单金额从 ¥1352.00 修改为 ¥652.00" + }, + { + "record_kind": "订单操作日志", + "source_table": "zyt_tcm_prescription_order_log", + "source_id": 74782, + "create_time": 1795504944, + "time_beijing": "2026-11-24 15:22:24", + "display_name": "药房1", + "admin_id": 116, + "action": "refund", + "summary": "订单全额退款,状态变更为「退款」;原因:患者闺女非要退,不退人家要投诉;退款金额 ¥552;关联收款单 1 笔已标记为已退款(收款侧合计 ¥552);已付总额清零" + } + ], + "timeline_record_count": 17, + "order_status_display": "退款" +} diff --git a/artifacts/prescription-order-log-export-20261127/PO20261119130757895924/操作日志_完整明细.txt b/artifacts/prescription-order-log-export-20261127/PO20261119130757895924/操作日志_完整明细.txt new file mode 100644 index 000000000..c2de45e88 --- /dev/null +++ b/artifacts/prescription-order-log-export-20261127/PO20261119130757895924/操作日志_完整明细.txt @@ -0,0 +1,139 @@ +PO20261119130757895924 医生签名与操作日志 +导出时间:2026-11-27T16:39:11+08:00 +记录数量:15 条原始订单日志 + 1 条处方创建记录 + 1 条默认签名记录 = 17 条综合时间线记录 + +业务订单号:PO20261119130757895924 +业务订单 ID:5143 +患者:王大梅 +处方号 / ID:RX202611191857 / 13457 +开方医生 / 账号:郭忠伟 / 213 +处方创建时间:2026-11-19 13:05:29 +医生签名时间(默认):2026-11-19 13:05:29 +业务订单创建人 / 时间:董肖妍 / 2026-11-19 13:07:57 +当前订单状态:退款 +当前订单金额 / 已付:¥652.00 / ¥0.00 +处方审核署名 / 账号 / 时间:药房1 / 116 / 2026-11-19 15:52:54 +运单号:JDVE19717626016 +洛阳药房订单号:EJ202611191552584B64BC +订单最近更新时间:2026-11-24 15:22:24 + +医生签名:郭忠伟签名了 +签名原图:医生签名_数据库原图.png +签名时间默认取处方创建时间。 + +医生最近登录记录 +以下为账号保存的最近登录记录;关联依据为处方医生账号。未查到对应开方当天的历史登录流水,登录方式无法确定。 +2026-11-27 09:07:40 | 郭忠伟 / 账号 213 | 登录 IP:123.53.191.132 | 账号最近登录快照 + +综合时间线(北京时间) +2026-11-19 13:05:29 | 处方创建记录 | zyt_tcm_prescription#13457 | 郭忠伟 / 账号 213 | 处方 RX202611191857 创建 +2026-11-19 13:05:29 | 医生签名(默认时间) | zyt_tcm_prescription#13457 | 郭忠伟 / 账号 213 | 郭忠伟签名了 +2026-11-19 13:07:57 | 订单操作日志 | zyt_tcm_prescription_order_log#72893 | 董肖妍 / 账号 279 | create | 创建业务订单 +2026-11-19 15:51:15 | 订单操作日志 | zyt_tcm_prescription_order_log#72984 | 药房1 / 账号 116 | set_ship_mode | 发货类型:甘草药房 → 洛阳药房 +2026-11-19 15:51:28 | 订单操作日志 | zyt_tcm_prescription_order_log#72985 | 药房1 / 账号 116 | edit | 编辑了业务订单及相关信息 +2026-11-19 15:52:54 | 订单操作日志 | zyt_tcm_prescription_order_log#72986 | 药房1 / 账号 116 | audit_rx_approve | 处方审核通过 +2026-11-19 15:52:56 | 订单操作日志 | zyt_tcm_prescription_order_log#72987 | 药房1 / 账号 116 | audit_pay_approve | 支付单审核通过 +2026-11-19 15:52:58 | 订单操作日志 | zyt_tcm_prescription_order_log#72988 | 药房1 / 账号 116 | ej_pharmacy_submit | 上传洛阳药房成功 EJ202611191552584B64BC +2026-11-19 15:54:01 | 订单操作日志 | zyt_tcm_prescription_order_log#72989 | 洛阳药房ERP / 账号 0 | ej_pharmacy_callback | 洛阳药房回传:订单已创建;远端状态:待审核;履约状态:待发货/发货与履约 → 待发货/发货与履约;(版本已处理,保留回传日志) +2026-11-20 11:19:08 | 订单操作日志 | zyt_tcm_prescription_order_log#73210 | 徐云云 / 账号 204 | ship | 确认发货(药房直发),运单:JDVE19717626016(auto) +2026-11-20 13:54:01 | 订单操作日志 | zyt_tcm_prescription_order_log#73339 | 洛阳药房:管理员 / 账号 0 | ej_pharmacy_callback | 洛阳药房回传:审核通过;操作人:管理员;远端状态:待生产;履约状态:已发货 → 已发货 +2026-11-20 13:54:02 | 订单操作日志 | zyt_tcm_prescription_order_log#73349 | 洛阳药房系统 / 账号 0 | ej_pharmacy_callback | 洛阳药房回传:订单药房流转制作中 | 流程:调配 | 药房:洛阳药房 | 操作人:管理员 +2026-11-20 13:54:02 | 订单操作日志 | zyt_tcm_prescription_order_log#73350 | 洛阳药房系统 / 账号 0 | ej_pharmacy_callback | 洛阳药房回传:订单药房流转制作中 | 流程:包装 | 药房:洛阳药房 | 操作人:管理员 +2026-11-20 13:54:02 | 订单操作日志 | zyt_tcm_prescription_order_log#73351 | 洛阳药房系统 / 账号 0 | ej_pharmacy_callback | 洛阳药房回传:订单药房流转制作中 | 流程:发货 | 药房:洛阳药房 | 操作人:管理员 +2026-11-23 14:57:20 | 订单操作日志 | zyt_tcm_prescription_order_log#74395 | 药房1 / 账号 116 | patch_rx_usage | 服用参数:主方开立天数 14天 → 7天;辅方开立天数 14天 → 7天;订单服用天数 14天 → 7天 +2026-11-23 14:57:41 | 订单操作日志 | zyt_tcm_prescription_order_log#74396 | 药房1 / 账号 116 | update_amount | 将订单金额从 ¥1352.00 修改为 ¥652.00 +2026-11-24 15:22:24 | 订单操作日志 | zyt_tcm_prescription_order_log#74782 | 药房1 / 账号 116 | refund | 订单全额退款,状态变更为「退款」;原因:患者闺女非要退,不退人家要投诉;退款金额 ¥552;关联收款单 1 笔已标记为已退款(收款侧合计 ¥552);已付总额清零 + +来源与说明 +来源:项目 server/.env 指向的本机 MySQL 数据库 zyt。未核实与生产库同步情况。 +所有展示时间均为北京时间 UTC+08:00;原始字段文件同时保留 Unix 时间戳。 +原始订单操作日志 15 条;另补充 1 条处方创建记录、1 条默认签名记录,综合时间线共 17 条记录。 +签名时间默认取处方创建时间。 +处方创建时间取自处方主记录;本次未查到独立的开方请求或电子签署流水。 +以下为账号保存的最近登录记录;关联依据为处方医生账号。未查到对应开方当天的历史登录流水,登录方式无法确定。 +药房回传日志的时间是本系统落库时间。 +本次只读查询,未修改业务数据。 + +药房回传元数据 +[ + { + "id": 1932, + "event_id": "f7c187f5-bc45-4962-998f-b8f61a6a8ed0", + "pharmacy_order_no": "EJ202611191552584B64BC", + "source_order_no": "PO20261119130757895924", + "event_type": "ORDER_CREATED", + "status_version": 1, + "process_status": "PROCESSED", + "processed_time": 1795074841, + "error_message": "", + "create_time": 1795074841, + "update_time": 1795074841, + "processed_time_beijing": "2026-11-19 15:54:01", + "create_time_beijing": "2026-11-19 15:54:01", + "update_time_beijing": "2026-11-19 15:54:01" + }, + { + "id": 1966, + "event_id": "6ed2da48-d96f-45b1-8e7c-78004625d7c8", + "pharmacy_order_no": "EJ202611191552584B64BC", + "source_order_no": "PO20261119130757895924", + "event_type": "REVIEW_APPROVED", + "status_version": 2, + "process_status": "PROCESSED", + "processed_time": 1795154041, + "error_message": "", + "create_time": 1795154041, + "update_time": 1795154041, + "processed_time_beijing": "2026-11-20 13:54:01", + "create_time_beijing": "2026-11-20 13:54:01", + "update_time_beijing": "2026-11-20 13:54:01" + }, + { + "id": 1976, + "event_id": "d44afae8-36ec-4cc6-b632-16a66229ca1a", + "pharmacy_order_no": "EJ202611191552584B64BC", + "source_order_no": "PO20261119130757895924", + "event_type": "WORKFLOW_STEP_COMPLETED", + "status_version": 3, + "process_status": "PROCESSED", + "processed_time": 1795154042, + "error_message": "", + "create_time": 1795154042, + "update_time": 1795154042, + "processed_time_beijing": "2026-11-20 13:54:02", + "create_time_beijing": "2026-11-20 13:54:02", + "update_time_beijing": "2026-11-20 13:54:02" + }, + { + "id": 1977, + "event_id": "8f8308cb-7944-4682-bc8f-fba4e6497216", + "pharmacy_order_no": "EJ202611191552584B64BC", + "source_order_no": "PO20261119130757895924", + "event_type": "WORKFLOW_STEP_COMPLETED", + "status_version": 4, + "process_status": "PROCESSED", + "processed_time": 1795154042, + "error_message": "", + "create_time": 1795154042, + "update_time": 1795154042, + "processed_time_beijing": "2026-11-20 13:54:02", + "create_time_beijing": "2026-11-20 13:54:02", + "update_time_beijing": "2026-11-20 13:54:02" + }, + { + "id": 1978, + "event_id": "154cb666-41a4-41da-bfa5-c88750d5dc19", + "pharmacy_order_no": "EJ202611191552584B64BC", + "source_order_no": "PO20261119130757895924", + "event_type": "WORKFLOW_STEP_COMPLETED", + "status_version": 5, + "process_status": "PROCESSED", + "processed_time": 1795154042, + "error_message": "", + "create_time": 1795154042, + "update_time": 1795154042, + "processed_time_beijing": "2026-11-20 13:54:02", + "create_time_beijing": "2026-11-20 13:54:02", + "update_time_beijing": "2026-11-20 13:54:02" + } +] diff --git a/artifacts/prescription-order-log-export-20261127/PO20261119130757895924/操作日志_查看版.html b/artifacts/prescription-order-log-export-20261127/PO20261119130757895924/操作日志_查看版.html new file mode 100644 index 000000000..c642b7684 --- /dev/null +++ b/artifacts/prescription-order-log-export-20261127/PO20261119130757895924/操作日志_查看版.html @@ -0,0 +1,115 @@ +PO20261119130757895924 医生签名与操作日志
+

PO20261119130757895924 · 医生签名与操作日志

+

患者:王大梅;医生:郭忠伟;当前状态:退款。

+

导出时间:2026-11-27T16:39:11+08:00。时间均为北京时间。

+

共 15 条原始订单日志,补充处方创建与默认签名后,综合时间线共 17 条记录。

+

完整文本 · JSON 原始字段 · 下载完整资料

+
订单及处方信息记录值
业务订单号PO20261119130757895924
业务订单 ID5143
患者王大梅
处方号 / IDRX202611191857 / 13457
开方医生 / 账号郭忠伟 / 213
处方创建时间2026-11-19 13:05:29
医生签名时间(默认)2026-11-19 13:05:29
业务订单创建人 / 时间董肖妍 / 2026-11-19 13:07:57
当前订单状态退款
当前订单金额 / 已付¥652.00 / ¥0.00
处方审核署名 / 账号 / 时间药房1 / 116 / 2026-11-19 15:52:54
运单号JDVE19717626016
洛阳药房订单号EJ202611191552584B64BC
订单最近更新时间2026-11-24 15:22:24
+

医生签名

郭忠伟签名了 · 2026-11-19 13:05:29(默认时间)

郭忠伟医生签名原图
处方 RX202611191857 保存的医生签名原图
+

医生最近登录记录

以下为账号保存的最近登录记录;关联依据为处方医生账号。未查到对应开方当天的历史登录流水,登录方式无法确定。

医生账号 ID最近登录时间登录 IP记录类型
郭忠伟2132026-11-27 09:07:40123.53.191.132账号最近登录快照

当前账号已绑定企业微信;绑定状态不代表该次登录使用扫码。

+

综合时间线

北京时间记录类型来源 / ID署名或关联医生账号 ID内容
2026-11-19 13:05:29处方创建记录处方 13457郭忠伟213处方 RX202611191857 创建
2026-11-19 13:05:29医生签名(默认时间)处方 13457郭忠伟213郭忠伟签名了
2026-11-19 13:07:57订单操作日志日志 72893董肖妍279create:创建业务订单
2026-11-19 15:51:15订单操作日志日志 72984药房1116set_ship_mode:发货类型:甘草药房 → 洛阳药房
2026-11-19 15:51:28订单操作日志日志 72985药房1116edit:编辑了业务订单及相关信息
2026-11-19 15:52:54订单操作日志日志 72986药房1116audit_rx_approve:处方审核通过
2026-11-19 15:52:56订单操作日志日志 72987药房1116audit_pay_approve:支付单审核通过
2026-11-19 15:52:58订单操作日志日志 72988药房1116ej_pharmacy_submit:上传洛阳药房成功 EJ202611191552584B64BC
2026-11-19 15:54:01订单操作日志日志 72989洛阳药房ERP0ej_pharmacy_callback:洛阳药房回传:订单已创建;远端状态:待审核;履约状态:待发货/发货与履约 → 待发货/发货与履约;(版本已处理,保留回传日志)
2026-11-20 11:19:08订单操作日志日志 73210徐云云204ship:确认发货(药房直发),运单:JDVE19717626016(auto)
2026-11-20 13:54:01订单操作日志日志 73339洛阳药房:管理员0ej_pharmacy_callback:洛阳药房回传:审核通过;操作人:管理员;远端状态:待生产;履约状态:已发货 → 已发货
2026-11-20 13:54:02订单操作日志日志 73349洛阳药房系统0ej_pharmacy_callback:洛阳药房回传:订单药房流转制作中 | 流程:调配 | 药房:洛阳药房 | 操作人:管理员
2026-11-20 13:54:02订单操作日志日志 73350洛阳药房系统0ej_pharmacy_callback:洛阳药房回传:订单药房流转制作中 | 流程:包装 | 药房:洛阳药房 | 操作人:管理员
2026-11-20 13:54:02订单操作日志日志 73351洛阳药房系统0ej_pharmacy_callback:洛阳药房回传:订单药房流转制作中 | 流程:发货 | 药房:洛阳药房 | 操作人:管理员
2026-11-23 14:57:20订单操作日志日志 74395药房1116patch_rx_usage:服用参数:主方开立天数 14天 → 7天;辅方开立天数 14天 → 7天;订单服用天数 14天 → 7天
2026-11-23 14:57:41订单操作日志日志 74396药房1116update_amount:将订单金额从 ¥1352.00 修改为 ¥652.00
2026-11-24 15:22:24订单操作日志日志 74782药房1116refund:订单全额退款,状态变更为「退款」;原因:患者闺女非要退,不退人家要投诉;退款金额 ¥552;关联收款单 1 笔已标记为已退款(收款侧合计 ¥552);已付总额清零
+

来源与说明

+
查看药房回传及其他核查字段
{
+  "pharmacy_callbacks": [
+    {
+      "id": 1932,
+      "event_id": "f7c187f5-bc45-4962-998f-b8f61a6a8ed0",
+      "pharmacy_order_no": "EJ202611191552584B64BC",
+      "source_order_no": "PO20261119130757895924",
+      "event_type": "ORDER_CREATED",
+      "status_version": 1,
+      "process_status": "PROCESSED",
+      "processed_time": 1795074841,
+      "error_message": "",
+      "create_time": 1795074841,
+      "update_time": 1795074841,
+      "processed_time_beijing": "2026-11-19 15:54:01",
+      "create_time_beijing": "2026-11-19 15:54:01",
+      "update_time_beijing": "2026-11-19 15:54:01"
+    },
+    {
+      "id": 1966,
+      "event_id": "6ed2da48-d96f-45b1-8e7c-78004625d7c8",
+      "pharmacy_order_no": "EJ202611191552584B64BC",
+      "source_order_no": "PO20261119130757895924",
+      "event_type": "REVIEW_APPROVED",
+      "status_version": 2,
+      "process_status": "PROCESSED",
+      "processed_time": 1795154041,
+      "error_message": "",
+      "create_time": 1795154041,
+      "update_time": 1795154041,
+      "processed_time_beijing": "2026-11-20 13:54:01",
+      "create_time_beijing": "2026-11-20 13:54:01",
+      "update_time_beijing": "2026-11-20 13:54:01"
+    },
+    {
+      "id": 1976,
+      "event_id": "d44afae8-36ec-4cc6-b632-16a66229ca1a",
+      "pharmacy_order_no": "EJ202611191552584B64BC",
+      "source_order_no": "PO20261119130757895924",
+      "event_type": "WORKFLOW_STEP_COMPLETED",
+      "status_version": 3,
+      "process_status": "PROCESSED",
+      "processed_time": 1795154042,
+      "error_message": "",
+      "create_time": 1795154042,
+      "update_time": 1795154042,
+      "processed_time_beijing": "2026-11-20 13:54:02",
+      "create_time_beijing": "2026-11-20 13:54:02",
+      "update_time_beijing": "2026-11-20 13:54:02"
+    },
+    {
+      "id": 1977,
+      "event_id": "8f8308cb-7944-4682-bc8f-fba4e6497216",
+      "pharmacy_order_no": "EJ202611191552584B64BC",
+      "source_order_no": "PO20261119130757895924",
+      "event_type": "WORKFLOW_STEP_COMPLETED",
+      "status_version": 4,
+      "process_status": "PROCESSED",
+      "processed_time": 1795154042,
+      "error_message": "",
+      "create_time": 1795154042,
+      "update_time": 1795154042,
+      "processed_time_beijing": "2026-11-20 13:54:02",
+      "create_time_beijing": "2026-11-20 13:54:02",
+      "update_time_beijing": "2026-11-20 13:54:02"
+    },
+    {
+      "id": 1978,
+      "event_id": "154cb666-41a4-41da-bfa5-c88750d5dc19",
+      "pharmacy_order_no": "EJ202611191552584B64BC",
+      "source_order_no": "PO20261119130757895924",
+      "event_type": "WORKFLOW_STEP_COMPLETED",
+      "status_version": 5,
+      "process_status": "PROCESSED",
+      "processed_time": 1795154042,
+      "error_message": "",
+      "create_time": 1795154042,
+      "update_time": 1795154042,
+      "processed_time_beijing": "2026-11-20 13:54:02",
+      "create_time_beijing": "2026-11-20 13:54:02",
+      "update_time_beijing": "2026-11-20 13:54:02"
+    }
+  ],
+  "prescription_operation_logs": [],
+  "prescription_esign_evidence": {
+    "zyt_prescription_review_esign": []
+  },
+  "prescription_ai_events": [],
+  "matched_login_operation_logs": [],
+  "operation_log_coverage": {
+    "total": 179,
+    "earliest_time": 1781149993,
+    "latest_time": 1791674406,
+    "earliest_time_beijing": "2026-06-11 11:53:13",
+    "latest_time_beijing": "2026-10-11 07:20:06"
+  },
+  "wecom_login_endpoint_count": {
+    "records": 0,
+    "earliest_time": null,
+    "latest_time": null,
+    "earliest_time_beijing": "—",
+    "latest_time_beijing": "—"
+  }
+}
\ No newline at end of file diff --git a/server/app/adminapi/logic/tcm/PrescriptionLogic.php b/server/app/adminapi/logic/tcm/PrescriptionLogic.php index 71e6404ce..27c5e2f82 100755 --- a/server/app/adminapi/logic/tcm/PrescriptionLogic.php +++ b/server/app/adminapi/logic/tcm/PrescriptionLogic.php @@ -1053,12 +1053,12 @@ class PrescriptionLogic } try { - // Keep the signature check and audit write under the same row lock. - // Reject also shares pharmacy claim locks with void/edit operations. $mutate = static fn () => self::auditLocked($id, $action, $remark, $adminId, $adminInfo); - $row = $action === 'reject' - ? LockedPharmacySnapshotMutation::executeForPrescription($id, $mutate) - : Db::transaction($mutate); + $row = match ($action) { + 'approve' => PrescriptionOrderLogic::approvePrescriptionAndLinkedOrders($id, $mutate), + 'reject' => LockedPharmacySnapshotMutation::executeForPrescription($id, $mutate), + default => Db::transaction($mutate), + }; } catch (\Throwable $exception) { if (self::getError() === '') { self::setError($exception->getMessage()); diff --git a/server/app/adminapi/logic/tcm/PrescriptionOrderLogic.php b/server/app/adminapi/logic/tcm/PrescriptionOrderLogic.php index 19946620f..a8407fcff 100755 --- a/server/app/adminapi/logic/tcm/PrescriptionOrderLogic.php +++ b/server/app/adminapi/logic/tcm/PrescriptionOrderLogic.php @@ -40,6 +40,7 @@ use app\common\service\tcm\RevisitDueHook; use think\db\Query; use app\common\service\esign\PrescriptionEsignService; use app\common\service\esign\PrescriptionEsignPolicy; +use app\common\service\esign\PrescriptionReviewEsignService; use think\facade\Config; use think\facade\Db; use think\facade\Log; @@ -774,6 +775,87 @@ class PrescriptionOrderLogic } } + /** @param callable(): (Prescription|false) $approve */ + public static function approvePrescriptionAndLinkedOrders(int $prescriptionId, callable $approve): Prescription|false + { + return Db::transaction(static function () use ($prescriptionId, $approve): Prescription|false { + // Follow the order-before-prescription lock order used by order review and revocation. + $orders = PrescriptionOrder::where('prescription_id', $prescriptionId) + ->whereNull('delete_time') + ->where('prescription_audit_status', 0) + ->whereIn('fulfillment_status', [1, 2]) + ->order('id', 'asc') + ->lock(true) + ->select(); + $rx = $approve(); + if ($rx) { + foreach ($orders as $order) { + self::recordPrescriptionApproval($order, $rx->toArray()); + } + } + return $rx; + }); + } + + /** Reconcile a pending order using the existing approval and its archived signatures. */ + public static function syncRecordedPrescriptionApproval(int $orderId, bool $apply = false): bool + { + return Db::transaction(static function () use ($orderId, $apply): bool { + $order = PrescriptionOrder::where('id', $orderId)->whereNull('delete_time')->lock(true)->find(); + if (!$order || (int) $order->prescription_audit_status !== 0 + || !in_array((int) $order->fulfillment_status, [1, 2], true)) { + return false; + } + $rx = Prescription::where('id', (int) $order->prescription_id)->lock(true)->find(); + if (!$rx || !self::hasRecordedPrescriptionApproval($rx->toArray())) { + return false; + } + if ($apply) { + self::recordPrescriptionApproval($order, $rx->toArray()); + } + return true; + }); + } + + private static function hasRecordedPrescriptionApproval(array $rx): bool + { + if ((int) ($rx['audit_status'] ?? 0) !== 1 || !empty($rx['void_status']) || !empty($rx['delete_time']) + || (int) ($rx['audit_by'] ?? 0) <= 0 || (int) ($rx['audit_time'] ?? 0) <= 0 + || !PrescriptionEsignPolicy::hasPrescriptionContent($rx)) { + return false; + } + $id = (int) $rx['id']; + try { + PrescriptionEsignService::assertSignedById($id); + if (!empty($rx['esign_required'])) { + $doctor = Db::name('prescription_esign')->where('prescription_id', $id)->find(); + if (!$doctor) { + return false; + } + PrescriptionReviewEsignService::assertVerified($rx, $doctor, null); + } + } catch (\DomainException) { + return false; + } + return true; + } + + private static function recordPrescriptionApproval(PrescriptionOrder $order, array $rx): void + { + $remark = mb_substr(trim((string) $rx['audit_remark']), 0, 500); + $order->prescription_audit_status = 1; + $order->prescription_audit_remark = $remark; + self::syncFulfillmentStatus($order); + if (!$order->save()) { + throw new \RuntimeException('业务订单处方审核状态同步失败'); + } + self::writeLog( + (int) $order->id, (int) $rx['audit_by'], ['name' => (string) $rx['audit_by_name']], + 'audit_rx_approve', '同步已开处方审核通过' . ($remark !== '' ? ',意见:' . $remark : ''), + strict: true, occurredAt: (int) $rx['audit_time'] + ); + } + private static function syncFulfillmentStatus(PrescriptionOrder $order): void { $fs = (int) $order->fulfillment_status; @@ -1046,7 +1128,7 @@ class PrescriptionOrderLogic private static function createLocked(array $params, int $adminId, array $adminInfo) { self::$error = ''; - // 新建业务订单的两项审核均为待审核,不能在创建时预填单号。 + // 新建时支付单仍须审核,不能预填单号。 if (trim((string) ($params['tracking_number'] ?? '')) !== '') { self::$error = self::TRACKING_AUDIT_REQUIRED; @@ -1176,6 +1258,9 @@ class PrescriptionOrderLogic } self::writeLog((int) $order->id, $adminId, $adminInfo, 'create', '创建业务订单', true); + if (self::hasRecordedPrescriptionApproval($rx)) { + self::recordPrescriptionApproval($order, $rx); + } if ($payOrderIds !== []) { self::replacePayOrderLinks((int) $order->id, $payOrderIds); @@ -5807,7 +5892,8 @@ class PrescriptionOrderLogic array $adminInfo, string $action, string $summary, - bool $strict = false + bool $strict = false, + ?int $occurredAt = null ): void { $adminName = $adminInfo['name'] ?? ''; @@ -5821,10 +5907,12 @@ class PrescriptionOrderLogic $log->admin_name = mb_substr($adminName, 0, 64); $log->action = mb_substr($action, 0, 32); $log->summary = mb_substr($summary, 0, 500); - $log->create_time = time(); + $log->create_time = $occurredAt ?? time(); try { - $log->save(); + if (!$log->save() && $strict) { + throw new \RuntimeException('操作日志写入失败,变更未保存'); + } } catch (\Throwable $e) { if ($strict) { throw new \RuntimeException('操作日志写入失败,变更未保存', 0, $e); diff --git a/server/app/common/service/esign/PrescriptionEsignService.php b/server/app/common/service/esign/PrescriptionEsignService.php index 75b39886f..1da4c6d58 100644 --- a/server/app/common/service/esign/PrescriptionEsignService.php +++ b/server/app/common/service/esign/PrescriptionEsignService.php @@ -625,18 +625,18 @@ final class PrescriptionEsignService }; [$pdf, $issuedAt] = Db::transaction(static function () use ($id, $lockSigningWork): array { [$currentRow, $current] = $lockSigningWork(); - $pdf = self::readPdf($current['source_path'], $current['source_hash']); - $issuedAt = (int) ($current['issued_at'] ?? 0); - if ($issuedAt > 0) { + $archivedSource = self::readPdf($current['source_path'], $current['source_hash']); + // Reuse the issuance time on retries and apply the current disclosure rules before sending. + $issuedAt = (int) ($current['issued_at'] ?? 0) ?: time(); + $pdf = PrescriptionPdf::render($currentRow, $current['environment'], $issuedAt, !empty($current['review_required'])); + if ($pdf === $archivedSource) { return [$pdf, $issuedAt]; } - // This is reached only after the doctor confirms signing and their willingness is verified. - $issuedAt = time(); - $pdf = PrescriptionPdf::render($currentRow, $current['environment'], $issuedAt, !empty($current['review_required'])); - $path = $id . '-' . $current['snapshot_hash'] . '/source-issued.pdf'; + $sourceHash = hash('sha256', $pdf); + $path = $id . '-' . $current['snapshot_hash'] . '/source-issued-' . $sourceHash . '.pdf'; self::writePdf($path, $pdf); Db::name('prescription_esign')->where('prescription_id', $id)->update([ - 'issued_at' => $issuedAt, 'source_hash' => hash('sha256', $pdf), 'source_path' => $path, + 'issued_at' => $issuedAt, 'source_hash' => $sourceHash, 'source_path' => $path, ]); return [$pdf, $issuedAt]; }); @@ -1149,7 +1149,7 @@ final class PrescriptionEsignService private static function filePath(string $relative): string { - if (!preg_match('#^\d+-[a-f0-9]{64}/(?:(?:source(?:-issued)?|signed|review-signed)\.pdf|review-seal-[a-f0-9]{64}\.png)$#D', $relative)) { + if (!preg_match('#^\d+-[a-f0-9]{64}/(?:(?:source(?:-issued(?:-[a-f0-9]{64})?)?|signed|review-signed)\.pdf|review-seal-[a-f0-9]{64}\.png)$#D', $relative)) { throw new DomainException('签署文件引用无效'); } return rtrim((string) Config::get('esign.storage_path', root_path() . 'storage/esign'), '/\\') . DIRECTORY_SEPARATOR . $relative; diff --git a/server/app/common/service/esign/PrescriptionPdf.php b/server/app/common/service/esign/PrescriptionPdf.php index d84d02e57..adbe0472d 100644 --- a/server/app/common/service/esign/PrescriptionPdf.php +++ b/server/app/common/service/esign/PrescriptionPdf.php @@ -43,7 +43,6 @@ final class PrescriptionPdf $add('舌象', $row['tongue']); $add('脉象', $row['pulse']); $add('脉诊补充', $row['pulse_condition']); - $add('方名', $row['prescription_name']); $add('剂型', $row['prescription_type']); $herbLabels = ['name' => '药名', 'dosage' => '用量', 'unit' => '单位', 'remark' => '备注', 'usage' => '煎法', 'usage_method' => '煎法', 'method' => '煎法', 'group' => '组别', @@ -59,8 +58,7 @@ final class PrescriptionPdf $add('药品 ' . ($index + 1), implode(' / ', $parts)); } foreach ([ - 'dose_count' => '总剂数', 'dose_unit' => '剂数单位', 'dosage_amount' => '单次用量', - 'dosage_unit' => '用量单位', 'dosage_bag_count' => '单次袋数', 'bags_per_dose' => '每剂袋数', + 'dosage_amount' => '单次用量', 'dosage_unit' => '用量单位', 'dosage_bag_count' => '单次袋数', 'usage_days' => '服用天数', 'times_per_day' => '每日次数', 'usage_instruction' => '服用说明', 'usage_time' => '服药时间', 'usage_way' => '服用方式', 'dietary_taboo' => '忌口', 'usage_notes' => '医嘱', ] as $key => $label) { @@ -69,8 +67,11 @@ final class PrescriptionPdf $add('代煎', $row['need_decoction'] === '1' ? '是' : '否'); $add('金额(元)', $row['amount']); foreach ((array) $row['aux_usage'] as $key => $value) { + if ($key === 'bags_per_dose') { + continue; + } $label = ['dosage_amount' => '单次用量', 'dosage_bag_count' => '单次袋数', 'need_decoction' => '代煎', - 'bags_per_dose' => '每剂袋数', 'times_per_day' => '每日次数', 'usage_days' => '服用天数', + 'times_per_day' => '每日次数', 'usage_days' => '服用天数', 'prescription_name' => '方名'][$key] ?? $key; $add('辅方' . $label, $value); } diff --git a/server/tests/PrescriptionEsignFlowTest.php b/server/tests/PrescriptionEsignFlowTest.php index 6e1c49291..e253c196c 100644 --- a/server/tests/PrescriptionEsignFlowTest.php +++ b/server/tests/PrescriptionEsignFlowTest.php @@ -451,6 +451,35 @@ namespace { $assert($retry['issued_at'] === $frozen['issued_at'] && $retry['source_hash'] === $frozen['source_hash'], 'retry keeps the exact issuance time and PDF'); + $pdfText = static fn (string $text): string => bin2hex(mb_convert_encoding($text, 'UTF-16BE', 'UTF-8')); + $legacyRetryId = 8888; + $new($legacyRetryId); + Db::name('tcm_prescription')->where('id', $legacyRetryId)->update(['prescription_type' => '浓缩水丸', 'dose_count' => 543]); + Service::start($legacyRetryId, 1, $root); + Fake::$signRejection = 'PROVIDER_50001'; + $assert(Service::complete($legacyRetryId, 1, $root)['status'] === 'failed', 'fixture permits a fresh sign after a definite rejection'); + Fake::$signRejection = null; + $cached = Db::name('prescription_esign')->where('prescription_id', $legacyRetryId)->find(); + $row = Db::name('tcm_prescription')->where('id', $legacyRetryId)->find(); + $expectedSource = PrescriptionPdf::render($row, 'sandbox', (int) $cached['issued_at']); + // Equal-length text substitution creates a readable pre-change cached PDF with the excluded field. + $oldSource = str_replace($pdfText('剂型:浓缩水丸'), $pdfText('总剂数:543'), $expectedSource, $changed); + $assert($changed === 1 && strlen($oldSource) === strlen($expectedSource), 'legacy PDF fixture contains the excluded field'); + $oldPath = $legacyRetryId . '-' . $cached['snapshot_hash'] . '/source-issued.pdf'; + Service::writePdf($oldPath, $oldSource); + Db::name('prescription_esign')->where('prescription_id', $legacyRetryId)->update([ + 'source_path' => $oldPath, 'source_hash' => hash('sha256', $oldSource), + ]); + Service::start($legacyRetryId, 1, $root); + $assert(Service::complete($legacyRetryId, 1, $root)['status'] === 'signed', 'retry signs a current PDF from the frozen prescription'); + $reissued = Db::name('prescription_esign')->where('prescription_id', $legacyRetryId)->find(); + $assert($reissued['issued_at'] === $cached['issued_at'] && $reissued['source_path'] !== $oldPath + && hash_equals($reissued['source_hash'], hash('sha256', $expectedSource)) + && Service::readPdf($oldPath, hash('sha256', $oldSource)) === $oldSource, 'retry keeps the old archive and preserves original issuance time'); + $submitted = Service::readPdf($reissued['signed_path'], $reissued['signed_hash']); + $assert(str_starts_with($submitted, $expectedSource) && !str_contains($submitted, $pdfText('总剂数:')), + 'provider receives the updated PDF rather than the old cached disclosure'); + $new(8); Fake::$startFailure = true; $assert(Service::start(8, 1, $root)['status'] === 'failed', 'identity link outage records failed preparation'); Fake::$startFailure = false; @@ -741,7 +770,7 @@ namespace { ]); } Db::name('tcm_prescription_order')->insert([ - 'id' => 41, 'prescription_id' => 41, 'prescription_audit_status' => 0, 'fulfillment_status' => 0, + 'id' => 41, 'prescription_id' => 41, 'prescription_audit_status' => 0, 'fulfillment_status' => 1, ]); $disabled = Service::status(41, 1, $root); Service::assertSignedById(41, true); @@ -862,9 +891,33 @@ namespace { $assert(!$pendingList()->lists()[0]['can_review_prescription'], 'a row with a stored signed state still needs an intact archive to allow review'); file_put_contents($archivePath, $archived); - $assert(PrescriptionLogic::audit(41, 'approve', '', 1, $root) + Db::name('tcm_prescription_order')->insertAll([ + ['id' => 4101, 'prescription_id' => 41, 'prescription_audit_status' => 2, 'fulfillment_status' => 1], + ['id' => 4102, 'prescription_id' => 41, 'prescription_audit_status' => 0, 'fulfillment_status' => 4], + ]); + Db::execute("CREATE TRIGGER reject_approval_log BEFORE INSERT ON zyt_tcm_prescription_order_log + BEGIN SELECT RAISE(ABORT, 'forced approval log failure'); END"); + $assert(!PrescriptionLogic::audit(41, 'approve', '测试意见', 1, $root) + && (int) Db::name('tcm_prescription')->where('id', 41)->value('audit_status') === 0 + && (int) Db::name('tcm_prescription_order')->where('id', 41)->value('prescription_audit_status') === 0, + 'approval and order sync both roll back when the order audit log cannot be written'); + Db::execute('DROP TRIGGER reject_approval_log'); + $assert(PrescriptionLogic::audit(41, 'approve', '测试意见', 1, $root) && (int) Db::name('tcm_prescription')->where('id', 41)->value('audit_status') === 1, 'the same prescription can be approved after verified eSign'); + $approvedRx = Db::name('tcm_prescription')->find(41); + $approvedOrder = Db::name('tcm_prescription_order')->find(41); + $approvalLog = Db::name('tcm_prescription_order_log')->where('prescription_order_id', 41)->find(); + $assert((int) $approvedOrder['prescription_audit_status'] === 1 + && $approvedOrder['prescription_audit_remark'] === '测试意见' + && (int) $approvedOrder['payment_slip_audit_status'] === 0 && (int) $approvedOrder['fulfillment_status'] === 1 + && (int) $approvalLog['admin_id'] === (int) $approvedRx['audit_by'] + && (int) $approvalLog['create_time'] === (int) $approvedRx['audit_time'] + && $approvalLog['action'] === 'audit_rx_approve', + 'the order records the original approval while payment stays pending'); + $assert((int) Db::name('tcm_prescription_order')->where('id', 4101)->value('prescription_audit_status') === 2 + && (int) Db::name('tcm_prescription_order')->where('id', 4102)->value('prescription_audit_status') === 0, + 'synchronization preserves rejected and cancelled orders'); $assert(PrescriptionLogic::submitForReview(41, 1, $root) === $submission, 'a retry after approval still returns the existing upload receipt'); $throws(fn () => Service::assertSignedById(41, true), 'sandbox enrollment permits approval but still blocks formal dispensing'); @@ -1133,6 +1186,18 @@ namespace { $assert(Policy::hash(Policy::snapshot($decimalRow)) === Policy::hash($decimalRow), 'snapshot hashing is idempotent'); $pdf = PrescriptionPdf::render($sample, 'sandbox'); $assert($pdf === PrescriptionPdf::render($sample, 'sandbox'), 'deterministic PDF'); + $pdf = PrescriptionPdf::render(array_replace($sample, [ + 'prescription_name' => '仅内部查看方名', 'dose_count' => 761, 'dose_unit' => '仅内部剂数单位', + 'bags_per_dose' => 762, 'dosage_bag_count' => 3, + 'aux_usage' => ['bags_per_dose' => 763, 'dosage_bag_count' => 4, 'usage_days' => 8, 'prescription_name' => '辅助方模板'], + ]), 'sandbox'); + foreach (['方名:仅内部查看方名', '总剂数:761', '剂数单位:仅内部剂数单位', '每剂袋数:762', '辅方每剂袋数:763', + '辅方bags_per_dose:763'] as $excluded) { + $assert(!str_contains($pdf, $pdfText($excluded)), 'signing PDF excludes: ' . $excluded); + } + foreach (['单次袋数:3', '辅方单次袋数:4', '辅方服用天数:8', '辅方方名:辅助方模板'] as $disclosed) { + $assert(str_contains($pdf, $pdfText($disclosed)), 'signing PDF retains distinct field: ' . $disclosed); + } $manyHerbs = []; for ($i = 1; $i <= 65; ++$i) { $manyHerbs[] = ['name' => '虚构药品' . $i, 'dosage' => $i, 'unit' => 'g']; } $largePdf = PrescriptionPdf::render(array_replace($sample, ['herbs' => $manyHerbs, 'amount' => '18.50']), 'sandbox'); @@ -1412,6 +1477,21 @@ namespace { 'order approval records the actual submitter and synchronizes the prescription without approving payment'); $assert(Service::download(84, 22, $auditor) === $combined && count(Fake::$reviewCalls) === 1, 'order approval preserves the pharmacist signature and archived original'); + Db::name('tcm_prescription_order')->insert([ + 'id' => 8401, 'prescription_id' => 84, 'prescription_audit_status' => 0, 'fulfillment_status' => 1, + ]); + file_put_contents($archive, $archivedBytes . 'modified'); + $assert(!PrescriptionOrderLogic::syncRecordedPrescriptionApproval(8401, true), + 'historical approval cannot be synchronized with a changed dual-sign PDF'); + file_put_contents($archive, $archivedBytes); + $assert(PrescriptionOrderLogic::syncRecordedPrescriptionApproval(8401) + && (int) Db::name('tcm_prescription_order')->where('id', 8401)->value('prescription_audit_status') === 0 + && PrescriptionOrderLogic::syncRecordedPrescriptionApproval(8401, true) + && !PrescriptionOrderLogic::syncRecordedPrescriptionApproval(8401, true), + 'historical synchronization previews without changes and applies exactly once'); + $assert((int) Db::name('tcm_prescription_order')->where('id', 8401)->value('prescription_audit_status') === 1 + && (int) Db::name('tcm_prescription_order_log')->where('prescription_order_id', 8401)->value('admin_id') === 23, + 'historical synchronization preserves the original approver, who need not be the signing pharmacist'); $signedLog = Service::status(84, 22, $auditor)['signing_log']; $events = array_column($signedLog, null, 'event'); $times = array_column($signedLog, 'time'); diff --git a/server/tests/PrescriptionOrderTrackingAuditTest.php b/server/tests/PrescriptionOrderTrackingAuditTest.php index edb65fd1e..e3a405754 100755 --- a/server/tests/PrescriptionOrderTrackingAuditTest.php +++ b/server/tests/PrescriptionOrderTrackingAuditTest.php @@ -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) {