feat: freeze and recover independent Huizhou notifications
This commit is contained in:
1 parent
d903252807
commit
d8aa14d855
14 files changed
+294
-48
No files matched your search
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
function modeOf(batch){return batch?.notificationMode||'normal';}
|
||||
function delivery(order,mode='normal'){
|
||||
if(!order)return null;
|
||||
return mode==='normal'?{status:order.status,batchId:order.batchId||null,error:order.error||null}:order.notifications?.huizhou||null;
|
||||
}
|
||||
function updateDelivery(order,mode,patch){
|
||||
if(mode==='normal')Object.assign(order,patch);
|
||||
else {if(!order.notifications?.huizhou)throw Error('惠州通知没有独立预留记录。');Object.assign(order.notifications.huizhou,patch);}
|
||||
return order;
|
||||
}
|
||||
function notifications(order){
|
||||
if(!order)return undefined;
|
||||
const h=delivery(order,'huizhou');
|
||||
return {normal:delivery(order),huizhou:h?{status:h.status,batchId:h.batchId||null,error:h.error||null,orderNos:[...(h.orderNos||[])],issues:[...(h.issues||[])]}:{status:'not_applicable',batchId:null,error:null,orderNos:[],issues:[]}};
|
||||
}
|
||||
function needsRuntimeCheck(order){return !!order?.archive&&(['pending','batched'].includes(order.status)||['pending','batched'].includes(delivery(order,'huizhou')?.status));}
|
||||
function reserved(order){return !!order?.batchId||!!delivery(order,'huizhou')?.batchId;}
|
||||
module.exports={modeOf,delivery,updateDelivery,notifications,needsRuntimeCheck,reserved};
|
||||
Reference in new issue
Block a user