'use strict'; const {createHash}=require('node:crypto'); // 加列后旧申请的快照没有内部备注。只兼容迁移补出的空值;真实备注仍参与过期和结果校验。 module.exports=function orderSnapshotHash(value,saved){ const original=saved?.data?.order||saved?.order,legacy=original&&!Object.hasOwn(original,'internal_note'); const json=JSON.stringify(value,legacy?(key,item)=>{ if(item&&Array.isArray(item.lines)&&Object.hasOwn(item,'customer')&&Object.hasOwn(item,'salesperson')&&item.internal_note===''){ const {internal_note,...order}=item;return order; } return item; }:undefined); return createHash('sha256').update(json).digest('hex'); };