fix: close order intake five minutes before scheduled mail
This commit is contained in:
1 parent
5fe461c77d
commit
4d8f393895
17 files changed
+137
-24
No files matched your search
@@ -25,7 +25,8 @@ function windowForCutoff(cutoff,schedule,overrides=[]){
|
||||
}
|
||||
}
|
||||
const fmt=value=>new Intl.DateTimeFormat('zh-CN',{timeZone:'Asia/Shanghai',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hour12:false}).format(new Date(value));
|
||||
return {start,end,label:fmt(start)+' 至 '+fmt(end)+'(北京时间,含起点、不含终点)',startInclusive:true,endInclusive:false};
|
||||
const collectionStart=new Date(Date.parse(start)-300000).toISOString(),collectionEnd=new Date(Date.parse(end)-300000).toISOString();
|
||||
return {start,end,collectionStart,collectionEnd,collectionLeadMinutes:5,policyVersion:2,label:fmt(collectionStart)+' 至 '+fmt(collectionEnd)+' 到达 · '+fmt(end)+' 发送(北京时间,含起点、不含终点)',startInclusive:true,endInclusive:false};
|
||||
}
|
||||
function upcomingWindow(now,schedule,overrides=[]){
|
||||
const times=timesOf(schedule),day=dayOf(now);
|
||||
@@ -34,5 +35,6 @@ function upcomingWindow(now,schedule,overrides=[]){
|
||||
if(!cutoff)return null;
|
||||
return {...windowForCutoff(cutoff,schedule,overrides),available:Boolean(due&&cutoff===due)};
|
||||
}
|
||||
function inWindow(receivedAt,window){const value=Date.parse(receivedAt);return Number.isFinite(value)&&value>=Date.parse(window.start)&&value<Date.parse(window.end);}
|
||||
module.exports={windowForCutoff,upcomingWindow,inWindow};
|
||||
function collectionBounds(window){return {start:window.collectionStart||window.start,end:window.collectionEnd||window.end};}
|
||||
function inWindow(receivedAt,window){const value=Date.parse(receivedAt),bounds=collectionBounds(window);return Number.isFinite(value)&&value>=Date.parse(bounds.start)&&value<Date.parse(bounds.end);}
|
||||
module.exports={windowForCutoff,upcomingWindow,inWindow,collectionBounds};
|
||||
Reference in new issue
Block a user