格式化:Prettier统一代码风格(仅格式,无逻辑变化)
仅为 npm run format 的输出;黄金对照、旧库兼容、浏览器流程与单元测试全部通过且零差异。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3743d687e7
commit
28c64814f0
221 files changed
+116943
-26708
No files matched your search
+34
-11
@@ -1,15 +1,38 @@
|
||||
'use strict';
|
||||
const {createHash}=require('node:crypto');
|
||||
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 legacyCustomerType=original&&!Object.hasOwn(original,'customer_type');
|
||||
const json=JSON.stringify(value,legacy||legacyCustomerType?(key,item)=>{
|
||||
if(legacyCustomerType&&item&&Array.isArray(item.lines)&&Object.hasOwn(item,'customer')&&item.customer_type==='unknown'){const {customer_type,...rest}=item;item=rest;}
|
||||
if(legacy&&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);
|
||||
module.exports = function orderSnapshotHash(value, saved) {
|
||||
const original = saved?.data?.order || saved?.order,
|
||||
legacy = original && !Object.hasOwn(original, 'internal_note');
|
||||
const legacyCustomerType = original && !Object.hasOwn(original, 'customer_type');
|
||||
const json = JSON.stringify(
|
||||
value,
|
||||
legacy || legacyCustomerType
|
||||
? (key, item) => {
|
||||
if (
|
||||
legacyCustomerType &&
|
||||
item &&
|
||||
Array.isArray(item.lines) &&
|
||||
Object.hasOwn(item, 'customer') &&
|
||||
item.customer_type === 'unknown'
|
||||
) {
|
||||
const { customer_type, ...rest } = item;
|
||||
item = rest;
|
||||
}
|
||||
if (
|
||||
legacy &&
|
||||
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');
|
||||
};
|
||||
Reference in new issue
Block a user