@pisell/pisellos 2.3.105 → 2.3.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Discount/index.js +4 -1
- package/dist/modules/Discount/types.d.ts +10 -0
- package/dist/modules/OpenData/index.d.ts +15 -2
- package/dist/modules/OpenData/index.js +307 -19
- package/dist/modules/OpenData/types.d.ts +55 -0
- package/dist/modules/OpenData/types.js +7 -1
- package/dist/modules/OpenData/utils.d.ts +21 -1
- package/dist/modules/OpenData/utils.js +138 -0
- package/dist/modules/Order/index.d.ts +3 -1
- package/dist/modules/Order/index.js +89 -16
- package/dist/modules/Order/types.d.ts +13 -0
- package/dist/modules/Order/utils.d.ts +4 -1
- package/dist/modules/Order/utils.js +57 -3
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -2
- package/dist/modules/ResourcePlanner/planner.js +172 -49
- package/dist/modules/ResourcePlanner/types.d.ts +19 -0
- package/dist/modules/Rules/index.js +1 -1
- package/dist/plugins/request.d.ts +2 -1
- package/dist/plugins/request.js +4 -2
- package/dist/server/index.d.ts +15 -0
- package/dist/server/index.js +1734 -1285
- package/dist/server/modules/order/types.d.ts +50 -0
- package/dist/server/modules/order/types.js +2 -0
- package/dist/server/utils/small-ticket.d.ts +4 -1
- package/dist/server/utils/small-ticket.js +461 -96
- package/dist/solution/BaseSales/index.d.ts +5 -1
- package/dist/solution/BaseSales/index.js +120 -45
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +8 -3
- package/dist/solution/BookingTicket/index.js +558 -443
- package/dist/solution/Sales/index.d.ts +16 -1
- package/dist/solution/Sales/index.js +338 -63
- package/dist/solution/Sales/types.d.ts +10 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/dist/solution/UnifiedBookingSales/index.js +614 -462
- package/dist/solution/UnifiedBookingSales/types.d.ts +7 -1
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/Discount/index.js +4 -1
- package/lib/modules/Discount/types.d.ts +10 -0
- package/lib/modules/OpenData/index.d.ts +15 -2
- package/lib/modules/OpenData/index.js +230 -3
- package/lib/modules/OpenData/types.d.ts +55 -0
- package/lib/modules/OpenData/types.js +9 -1
- package/lib/modules/OpenData/utils.d.ts +21 -1
- package/lib/modules/OpenData/utils.js +126 -0
- package/lib/modules/Order/index.d.ts +3 -1
- package/lib/modules/Order/index.js +69 -1
- package/lib/modules/Order/types.d.ts +13 -0
- package/lib/modules/Order/utils.d.ts +4 -1
- package/lib/modules/Order/utils.js +58 -1
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -2
- package/lib/modules/ResourcePlanner/planner.js +141 -35
- package/lib/modules/ResourcePlanner/types.d.ts +19 -0
- package/lib/modules/Rules/index.js +1 -1
- package/lib/plugins/request.d.ts +2 -1
- package/lib/plugins/request.js +3 -2
- package/lib/server/index.d.ts +15 -0
- package/lib/server/index.js +455 -105
- package/lib/server/modules/order/types.d.ts +50 -0
- package/lib/server/modules/order/types.js +1 -0
- package/lib/server/utils/small-ticket.d.ts +4 -1
- package/lib/server/utils/small-ticket.js +427 -72
- package/lib/solution/BaseSales/index.d.ts +5 -1
- package/lib/solution/BaseSales/index.js +84 -7
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +8 -3
- package/lib/solution/BookingTicket/index.js +60 -15
- package/lib/solution/Sales/index.d.ts +16 -1
- package/lib/solution/Sales/index.js +168 -1
- package/lib/solution/Sales/types.d.ts +10 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/lib/solution/UnifiedBookingSales/index.js +128 -35
- package/lib/solution/UnifiedBookingSales/types.d.ts +7 -1
- package/package.json +1 -1
|
@@ -166,9 +166,65 @@ function addLeadWindow(base, unit, unitType, _timezoneName) {
|
|
|
166
166
|
if (unitType === 'hours') return (0, _localClock.addLocalHours)(base, unit);
|
|
167
167
|
return (0, _localClock.addLocalMinutes)(base, unit);
|
|
168
168
|
}
|
|
169
|
+
function normalizedWindowContainsRange(windows, candidateRange, timezoneName) {
|
|
170
|
+
return windows.some(window => {
|
|
171
|
+
const normalized = normalizeAbsoluteRange(window, timezoneName);
|
|
172
|
+
return Boolean(normalized && contains(normalized, candidateRange));
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function normalizedWindowsContainDate(windows, date, timezoneName) {
|
|
176
|
+
return windows.some(window => {
|
|
177
|
+
const normalized = normalizeAbsoluteRange(window, timezoneName);
|
|
178
|
+
return Boolean(normalized && formatDate(normalized.start, timezoneName) === date);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
function isRangeFromExcludedWindows(params) {
|
|
182
|
+
const candidateDate = formatDate(params.candidateRange.start, params.timezoneName);
|
|
183
|
+
const hasNormalWindowOnDate = normalizedWindowsContainDate(params.normalWindows, candidateDate, params.timezoneName);
|
|
184
|
+
const hasExcludedWindowOnDate = normalizedWindowsContainDate(params.excludedWindows, candidateDate, params.timezoneName);
|
|
185
|
+
if (!hasNormalWindowOnDate && hasExcludedWindowOnDate) return true;
|
|
186
|
+
return !normalizedWindowContainsRange(params.normalWindows, params.candidateRange, params.timezoneName) && normalizedWindowContainsRange(params.excludedWindows, params.candidateRange, params.timezoneName);
|
|
187
|
+
}
|
|
188
|
+
function isCandidateFromExcludedScheduleDate(params) {
|
|
189
|
+
const {
|
|
190
|
+
projection,
|
|
191
|
+
product,
|
|
192
|
+
candidate,
|
|
193
|
+
candidateRange
|
|
194
|
+
} = params;
|
|
195
|
+
const operatingHours = projection.meta.defaults.operatingHours;
|
|
196
|
+
if (isRangeFromExcludedWindows({
|
|
197
|
+
normalWindows: operatingHours.windows,
|
|
198
|
+
excludedWindows: operatingHours.excludedWindows || [],
|
|
199
|
+
candidateRange,
|
|
200
|
+
timezoneName: projection.meta.timezone
|
|
201
|
+
})) {
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
if (product.kind !== 'session' && product.kind !== 'venue_slot') {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
if (candidate.source !== 'session_schedule') {
|
|
208
|
+
const hasNormalRule = (product.sessionRules || []).some(rule => matchesScheduleRuleDate(rule, candidate.date, projection.meta.timezone));
|
|
209
|
+
const hasExcludedOverrideRule = (product.sessionRules || []).some(rule => !matchesScheduleRuleDate(rule, candidate.date, projection.meta.timezone) && matchesScheduleRuleDate(rule, candidate.date, projection.meta.timezone, true));
|
|
210
|
+
return !hasNormalRule && hasExcludedOverrideRule;
|
|
211
|
+
}
|
|
212
|
+
const candidateDateRange = {
|
|
213
|
+
startDate: candidate.date,
|
|
214
|
+
endDate: candidate.date
|
|
215
|
+
};
|
|
216
|
+
const candidateIdentity = getProductTimeRangeIdentity(candidate);
|
|
217
|
+
const normalRanges = getSessionRangesForProduct(projection, product, candidateDateRange);
|
|
218
|
+
if (normalRanges.some(range => getProductTimeRangeIdentity(range) === candidateIdentity)) {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
return getSessionRangesForProduct(projection, product, candidateDateRange, true).some(range => getProductTimeRangeIdentity(range) === candidateIdentity);
|
|
222
|
+
}
|
|
169
223
|
function evaluateCandidateTimeGate(params) {
|
|
170
224
|
const {
|
|
225
|
+
projection,
|
|
171
226
|
product,
|
|
227
|
+
candidate,
|
|
172
228
|
candidateRange,
|
|
173
229
|
evaluationContext,
|
|
174
230
|
timezoneName
|
|
@@ -181,6 +237,18 @@ function evaluateCandidateTimeGate(params) {
|
|
|
181
237
|
conflictCode: 'past'
|
|
182
238
|
};
|
|
183
239
|
}
|
|
240
|
+
if (evaluationContext.allowExcludedScheduleDateOverride && isCandidateFromExcludedScheduleDate({
|
|
241
|
+
projection,
|
|
242
|
+
product,
|
|
243
|
+
candidate,
|
|
244
|
+
candidateRange
|
|
245
|
+
})) {
|
|
246
|
+
return {
|
|
247
|
+
status: 'unavailable',
|
|
248
|
+
reasonCodes: ['schedule_excluded_date'],
|
|
249
|
+
conflictCode: 'schedule_excluded_date'
|
|
250
|
+
};
|
|
251
|
+
}
|
|
184
252
|
const policy = product.cutOffPolicy;
|
|
185
253
|
if (!policy) return null;
|
|
186
254
|
if (resolveCutOffPolicyIssue(policy)) {
|
|
@@ -213,10 +281,12 @@ function evaluateCandidateTimeGate(params) {
|
|
|
213
281
|
};
|
|
214
282
|
}
|
|
215
283
|
if (policy.type === 'before_start') {
|
|
216
|
-
// Flexible-duration candidates
|
|
217
|
-
// minute
|
|
218
|
-
// already started because the query
|
|
219
|
-
|
|
284
|
+
// Flexible-duration candidates and POS fixed-duration anchors start at
|
|
285
|
+
// minute precision. Keep that current minute selectable instead of treating
|
|
286
|
+
// the freshly generated candidate as already started because the query
|
|
287
|
+
// clock still contains seconds.
|
|
288
|
+
const usesMinutePrecision = product.isFlexibleDuration || evaluationContext.useExactDurationCandidateMinute && product.kind === 'duration';
|
|
289
|
+
const hasNotReachedStart = usesMinutePrecision ? floorToMinute(now) <= candidateRange.start : now < candidateRange.start;
|
|
220
290
|
if (hasNotReachedStart) return null;
|
|
221
291
|
return {
|
|
222
292
|
status: 'unavailable',
|
|
@@ -324,8 +394,8 @@ function normalizeCoverage(input) {
|
|
|
324
394
|
}
|
|
325
395
|
};
|
|
326
396
|
}
|
|
327
|
-
function normalizeResourceWindow(resource, coverage, timezoneName) {
|
|
328
|
-
return mergeRanges((resource.windows || []).map(window => normalizeAbsoluteRange(window, timezoneName)).filter(window => Boolean(window)).map(window => clipRange(window, coverage)).filter(window => Boolean(window)));
|
|
397
|
+
function normalizeResourceWindow(resource, coverage, timezoneName, includeExcludedWindows = false) {
|
|
398
|
+
return mergeRanges([...(resource.windows || []), ...(includeExcludedWindows ? resource.excludedWindows || [] : [])].map(window => normalizeAbsoluteRange(window, timezoneName)).filter(window => Boolean(window)).map(window => clipRange(window, coverage)).filter(window => Boolean(window)));
|
|
329
399
|
}
|
|
330
400
|
function normalizeOccupancy(occupancy, coverage, timezoneName, fixedOffsetMinutes) {
|
|
331
401
|
const normalized = normalizeAbsoluteRange(occupancy, timezoneName);
|
|
@@ -389,6 +459,9 @@ function normalizeResources(resources) {
|
|
|
389
459
|
capacity: Math.max(1, Number(resource.capacity || 1) || 1),
|
|
390
460
|
windows: (resource.windows || []).map(window => ({
|
|
391
461
|
...window
|
|
462
|
+
})),
|
|
463
|
+
excludedWindows: (resource.excludedWindows || []).map(window => ({
|
|
464
|
+
...window
|
|
392
465
|
}))
|
|
393
466
|
}));
|
|
394
467
|
}
|
|
@@ -408,15 +481,20 @@ function normalizeOperatingHours(params) {
|
|
|
408
481
|
startAt: formatDateTime(range.start, params.timezoneName, params.fixedOffsetMinutes),
|
|
409
482
|
endAt: formatDateTime(range.end, params.timezoneName, params.fixedOffsetMinutes)
|
|
410
483
|
}));
|
|
411
|
-
const
|
|
484
|
+
const normalizeWindows = source => mergeRanges(source.map(window => normalizeAbsoluteRange(window, params.timezoneName)).filter(window => Boolean(window)).map(window => clipRange(window, params.coverage)).filter(window => Boolean(window))).map(range => ({
|
|
412
485
|
startAt: formatDateTime(range.start, params.timezoneName, params.fixedOffsetMinutes),
|
|
413
486
|
endAt: formatDateTime(range.end, params.timezoneName, params.fixedOffsetMinutes)
|
|
414
487
|
}));
|
|
488
|
+
const windows = normalizeWindows(sourceWindows);
|
|
489
|
+
const excludedWindows = normalizeWindows(params.input?.excludedWindows || []);
|
|
415
490
|
return {
|
|
416
491
|
source: params.input?.source || params.fallbackSource,
|
|
417
492
|
scheduleIds: uniqById(params.input?.scheduleIds || []),
|
|
418
493
|
missingScheduleIds: uniqById(params.input?.missingScheduleIds || []),
|
|
419
|
-
windows
|
|
494
|
+
windows,
|
|
495
|
+
...(excludedWindows.length > 0 ? {
|
|
496
|
+
excludedWindows
|
|
497
|
+
} : {})
|
|
420
498
|
};
|
|
421
499
|
}
|
|
422
500
|
function matchesRequirementGroup(requirementGroup, resource, product, partySize = 1) {
|
|
@@ -698,19 +776,19 @@ function resolveProjectionDateRange(projection, requestDateRange) {
|
|
|
698
776
|
endDate
|
|
699
777
|
};
|
|
700
778
|
}
|
|
701
|
-
function buildOperatingRanges(projection, dateRange) {
|
|
779
|
+
function buildOperatingRanges(projection, dateRange, includeExcludedWindows = false) {
|
|
702
780
|
const coverage = {
|
|
703
781
|
start: toDateStart(dateRange.startDate, projection.meta.timezone),
|
|
704
782
|
end: toDateEnd(nextDate(dateRange.endDate), projection.meta.timezone)
|
|
705
783
|
};
|
|
706
|
-
return mergeRanges(projection.meta.defaults.operatingHours.windows.map(window => normalizeAbsoluteRange(window, projection.meta.timezone)).filter(window => Boolean(window)).map(window => clipRange(window, coverage)).filter(window => Boolean(window)));
|
|
784
|
+
return mergeRanges([...projection.meta.defaults.operatingHours.windows, ...(includeExcludedWindows ? projection.meta.defaults.operatingHours.excludedWindows || [] : [])].map(window => normalizeAbsoluteRange(window, projection.meta.timezone)).filter(window => Boolean(window)).map(window => clipRange(window, coverage)).filter(window => Boolean(window)));
|
|
707
785
|
}
|
|
708
|
-
function buildResourceWindowIndex(projection) {
|
|
786
|
+
function buildResourceWindowIndex(projection, includeExcludedWindows = false) {
|
|
709
787
|
const coverage = {
|
|
710
788
|
start: toDateTime(projection.meta.coverage.startAt, projection.meta.timezone),
|
|
711
789
|
end: toDateTime(projection.meta.coverage.endAt, projection.meta.timezone)
|
|
712
790
|
};
|
|
713
|
-
return new Map(projection.resources.map(resource => [String(resource.id), normalizeResourceWindow(resource, coverage, projection.meta.timezone)]));
|
|
791
|
+
return new Map(projection.resources.map(resource => [String(resource.id), normalizeResourceWindow(resource, coverage, projection.meta.timezone, includeExcludedWindows)]));
|
|
714
792
|
}
|
|
715
793
|
function buildGroupWorkingRanges(params) {
|
|
716
794
|
const {
|
|
@@ -727,7 +805,7 @@ function buildGroupWorkingRanges(params) {
|
|
|
727
805
|
};
|
|
728
806
|
const filteredResourceIdSet = resourceIds?.length ? new Set(resourceIds.map(String)) : null;
|
|
729
807
|
const resourceWindows = projection.resources.filter(resource => matchesRequirementGroup(requirementGroup, resource, params.product, partySize)).filter(resource => !filteredResourceIdSet || filteredResourceIdSet.has(String(resource.id))).map(resource => {
|
|
730
|
-
const windows = params.resourceWindowIndex?.get(String(resource.id)) || normalizeResourceWindow(resource, coverage, projection.meta.timezone);
|
|
808
|
+
const windows = params.resourceWindowIndex?.get(String(resource.id)) || normalizeResourceWindow(resource, coverage, projection.meta.timezone, params.includeExcludedWindows === true);
|
|
731
809
|
return windows.map(window => clipRange(window, coverage)).filter(window => Boolean(window));
|
|
732
810
|
});
|
|
733
811
|
const requiredConcurrentResources = Math.max(requirementGroup.required === false ? 0 : 1, Number(requirementGroup.min ?? (requirementGroup.required === false ? 0 : 1)) || 0);
|
|
@@ -758,12 +836,12 @@ function buildGroupWorkingRanges(params) {
|
|
|
758
836
|
}
|
|
759
837
|
return mergeRanges(satisfiedRanges);
|
|
760
838
|
}
|
|
761
|
-
function materializeScheduleRules(rules, dateRange, timezoneName, fixedOffsetMinutes) {
|
|
839
|
+
function materializeScheduleRules(rules, dateRange, timezoneName, fixedOffsetMinutes, allowExcludedScheduleDates = false) {
|
|
762
840
|
const dates = enumerateDates(dateRange.startDate, dateRange.endDate);
|
|
763
841
|
const seen = new Map();
|
|
764
842
|
rules.forEach(rule => {
|
|
765
843
|
dates.forEach(date => {
|
|
766
|
-
if (!matchesScheduleRuleDate(rule, date, timezoneName)) return;
|
|
844
|
+
if (!matchesScheduleRuleDate(rule, date, timezoneName, allowExcludedScheduleDates)) return;
|
|
767
845
|
const start = toDateTimeInDate(date, rule.startTime, timezoneName);
|
|
768
846
|
let end = toDateTimeInDate(date, rule.endTime, timezoneName);
|
|
769
847
|
if (end <= start) end = toDateTimeInDate(nextDate(date, timezoneName), rule.endTime, timezoneName);
|
|
@@ -795,9 +873,9 @@ function materializeScheduleRules(rules, dateRange, timezoneName, fixedOffsetMin
|
|
|
795
873
|
});
|
|
796
874
|
return Array.from(seen.values());
|
|
797
875
|
}
|
|
798
|
-
function matchesScheduleRuleDate(rule, date, _timezoneName) {
|
|
876
|
+
function matchesScheduleRuleDate(rule, date, _timezoneName, allowExcludedScheduleDate = false) {
|
|
799
877
|
if (rule.includeDates?.includes(date)) return true;
|
|
800
|
-
if (rule.excludeDates?.includes(date)) return false;
|
|
878
|
+
if (!allowExcludedScheduleDate && rule.excludeDates?.includes(date)) return false;
|
|
801
879
|
if (rule.startDate && date < rule.startDate) return false;
|
|
802
880
|
if (rule.endDate && date > rule.endDate) return false;
|
|
803
881
|
if (rule.mode === 'designation') {
|
|
@@ -841,7 +919,7 @@ function buildGroupResourceIndex(params) {
|
|
|
841
919
|
});
|
|
842
920
|
return index;
|
|
843
921
|
}
|
|
844
|
-
function getSessionRangesForProduct(projection, product, dateRange) {
|
|
922
|
+
function getSessionRangesForProduct(projection, product, dateRange, allowExcludedScheduleDates = false) {
|
|
845
923
|
const fixedOffsetMinutes = (0, _localClock.extractFixedOffsetMinutes)(projection.meta.now) ?? (0, _localClock.captureRuntimeOffsetMinutes)();
|
|
846
924
|
const ranges = (product.sessionRanges || []).map(range => {
|
|
847
925
|
const normalized = normalizeAbsoluteRange(range, projection.meta.timezone);
|
|
@@ -866,7 +944,7 @@ function getSessionRangesForProduct(projection, product, dateRange) {
|
|
|
866
944
|
primaryScheduleRef: range.scheduleRefs?.[0]
|
|
867
945
|
};
|
|
868
946
|
}).filter(Boolean);
|
|
869
|
-
const ruleRanges = materializeScheduleRules(product.sessionRules || [], dateRange, projection.meta.timezone, fixedOffsetMinutes);
|
|
947
|
+
const ruleRanges = materializeScheduleRules(product.sessionRules || [], dateRange, projection.meta.timezone, fixedOffsetMinutes, allowExcludedScheduleDates);
|
|
870
948
|
return dedupeProductRanges([...ranges, ...ruleRanges.map(range => ({
|
|
871
949
|
...range,
|
|
872
950
|
key: `${String(product.id)}:${range.startAt}:${range.endAt}`,
|
|
@@ -916,7 +994,8 @@ function getProductTimeRanges(projection, request = {}, runtimeOptions = {}) {
|
|
|
916
994
|
const dateRange = resolveProjectionDateRange(projection, request.dateRange);
|
|
917
995
|
const slotStepMinutes = projection.meta.defaults.slotStepMinutes;
|
|
918
996
|
const fixedOffsetMinutes = (0, _localClock.extractFixedOffsetMinutes)(projection.meta.now) ?? (0, _localClock.captureRuntimeOffsetMinutes)();
|
|
919
|
-
const
|
|
997
|
+
const allowExcludedScheduleDateOverride = runtimeOptions.allowExcludedScheduleDateOverride === true;
|
|
998
|
+
const resourceWindowIndex = buildResourceWindowIndex(projection, allowExcludedScheduleDateOverride);
|
|
920
999
|
const filteredProductIdSet = request.productIds?.length ? new Set(request.productIds.map(String)) : null;
|
|
921
1000
|
return projection.products.filter(product => !filteredProductIdSet || filteredProductIdSet.has(String(product.id))).map(product => {
|
|
922
1001
|
if (product.kind === 'normal') {
|
|
@@ -929,7 +1008,7 @@ function getProductTimeRanges(projection, request = {}, runtimeOptions = {}) {
|
|
|
929
1008
|
};
|
|
930
1009
|
}
|
|
931
1010
|
if (product.kind === 'session' || product.kind === 'venue_slot') {
|
|
932
|
-
const fixedRanges = getSessionRangesForProduct(projection, product, dateRange);
|
|
1011
|
+
const fixedRanges = getSessionRangesForProduct(projection, product, dateRange, allowExcludedScheduleDateOverride);
|
|
933
1012
|
const customRanges = [];
|
|
934
1013
|
const customDurationMinutes = resolveRequestedSessionDurationMinutes(product, request, runtimeOptions.allowSessionCustomRanges === true);
|
|
935
1014
|
const requestedStartTimes = resolveRequestedDurationStartTimes(product, request, runtimeOptions.allowSessionCustomRanges === true);
|
|
@@ -949,7 +1028,8 @@ function getProductTimeRanges(projection, request = {}, runtimeOptions = {}) {
|
|
|
949
1028
|
};
|
|
950
1029
|
}
|
|
951
1030
|
const requiredGroups = (product.requirementGroups || []).filter(group => group.required !== false);
|
|
952
|
-
const operatingRanges = buildOperatingRanges(projection, dateRange);
|
|
1031
|
+
const operatingRanges = buildOperatingRanges(projection, dateRange, allowExcludedScheduleDateOverride);
|
|
1032
|
+
const operatingEndAt = dateRange.startDate === dateRange.endDate && operatingRanges.length > 0 ? formatDateTime(Math.max(...operatingRanges.map(range => range.end)), projection.meta.timezone, fixedOffsetMinutes) : undefined;
|
|
953
1033
|
const resourceRanges = requiredGroups.length ? requiredGroups.map(group => buildGroupWorkingRanges({
|
|
954
1034
|
projection,
|
|
955
1035
|
product,
|
|
@@ -957,7 +1037,8 @@ function getProductTimeRanges(projection, request = {}, runtimeOptions = {}) {
|
|
|
957
1037
|
dateRange,
|
|
958
1038
|
resourceIds: request.resourceIds,
|
|
959
1039
|
partySize: normalizedPartySize,
|
|
960
|
-
resourceWindowIndex
|
|
1040
|
+
resourceWindowIndex,
|
|
1041
|
+
includeExcludedWindows: allowExcludedScheduleDateOverride
|
|
961
1042
|
})).reduce((current, ranges) => current === null ? ranges : intersectRangeLists(current, ranges), null) || [] : null;
|
|
962
1043
|
const baseRanges = resourceRanges === null ? operatingRanges : intersectRangeLists(resourceRanges, operatingRanges);
|
|
963
1044
|
const durationMinutes = resolveRequestedDurationMinutes(product, request);
|
|
@@ -971,7 +1052,8 @@ function getProductTimeRanges(projection, request = {}, runtimeOptions = {}) {
|
|
|
971
1052
|
}
|
|
972
1053
|
return floorToMinute(evaluatedAt);
|
|
973
1054
|
})();
|
|
974
|
-
const
|
|
1055
|
+
const durationCandidateAnchor = toDateTime(projection.meta.durationCandidateAnchorAt, projection.meta.timezone);
|
|
1056
|
+
const durationAnchor = runtimeOptions.useExactDurationCandidateMinute ? floorToMinute(durationCandidateAnchor) : ceilToTenMinutes(durationCandidateAnchor, projection.meta.timezone);
|
|
975
1057
|
const requestedStartTimes = resolveRequestedDurationStartTimes(product, request);
|
|
976
1058
|
const ranges = [];
|
|
977
1059
|
baseRanges.forEach(range => {
|
|
@@ -1016,6 +1098,9 @@ function getProductTimeRanges(projection, request = {}, runtimeOptions = {}) {
|
|
|
1016
1098
|
title: product.title,
|
|
1017
1099
|
kind: product.kind,
|
|
1018
1100
|
slotStepMinutes,
|
|
1101
|
+
...(operatingEndAt ? {
|
|
1102
|
+
operatingEndAt
|
|
1103
|
+
} : {}),
|
|
1019
1104
|
ranges: dedupeProductRanges(ranges)
|
|
1020
1105
|
};
|
|
1021
1106
|
});
|
|
@@ -1173,7 +1258,9 @@ function buildEvaluationContext(params) {
|
|
|
1173
1258
|
evaluatedAt,
|
|
1174
1259
|
evaluatedAtMs: evaluatedAt,
|
|
1175
1260
|
resourceIdSet: params.resourceIds?.length ? new Set(params.resourceIds.map(String)) : null,
|
|
1176
|
-
selectionsByGroupKey
|
|
1261
|
+
selectionsByGroupKey,
|
|
1262
|
+
useExactDurationCandidateMinute: params.useExactDurationCandidateMinute === true,
|
|
1263
|
+
allowExcludedScheduleDateOverride: params.allowExcludedScheduleDateOverride === true
|
|
1177
1264
|
};
|
|
1178
1265
|
}
|
|
1179
1266
|
function summarizeStatuses(statuses) {
|
|
@@ -1323,7 +1410,8 @@ function evaluateCandidateSummary(projection, candidate, request) {
|
|
|
1323
1410
|
const evaluationContext = request.evaluationContext || buildEvaluationContext({
|
|
1324
1411
|
projection,
|
|
1325
1412
|
evaluatedAt: request.evaluatedAt,
|
|
1326
|
-
resourceIds: request.resourceIds
|
|
1413
|
+
resourceIds: request.resourceIds,
|
|
1414
|
+
allowExcludedScheduleDateOverride: request.allowExcludedScheduleDateOverride
|
|
1327
1415
|
});
|
|
1328
1416
|
const requestedPartySize = normalizePartySize(request.partySize);
|
|
1329
1417
|
const requiredGroups = (product.requirementGroups || []).filter(group => group.required !== false).map(requirementGroup => evaluateRequirementGroupSummary({
|
|
@@ -1337,7 +1425,9 @@ function evaluateCandidateSummary(projection, candidate, request) {
|
|
|
1337
1425
|
groupResourceIndex: request.groupResourceIndex
|
|
1338
1426
|
}));
|
|
1339
1427
|
const gate = evaluateCandidateTimeGate({
|
|
1428
|
+
projection,
|
|
1340
1429
|
product,
|
|
1430
|
+
candidate,
|
|
1341
1431
|
candidateRange,
|
|
1342
1432
|
evaluationContext,
|
|
1343
1433
|
timezoneName: projection.meta.timezone
|
|
@@ -1379,7 +1469,8 @@ function evaluateCandidate(projection, candidate, request) {
|
|
|
1379
1469
|
projection,
|
|
1380
1470
|
evaluatedAt: request.evaluatedAt,
|
|
1381
1471
|
resourceIds: request.resourceIds,
|
|
1382
|
-
requirementSelections: request.requirementSelections
|
|
1472
|
+
requirementSelections: request.requirementSelections,
|
|
1473
|
+
allowExcludedScheduleDateOverride: request.allowExcludedScheduleDateOverride
|
|
1383
1474
|
});
|
|
1384
1475
|
const requestedPartySize = normalizePartySize(request.partySize);
|
|
1385
1476
|
const partySize = requestedPartySize ?? 1;
|
|
@@ -1392,6 +1483,12 @@ function evaluateCandidate(projection, candidate, request) {
|
|
|
1392
1483
|
const matchedResources = (request.groupResourceIndex?.get([String(product.id), requirementGroup.id].join(':')) || projection.resources.filter(resource => matchesRequirementGroup(requirementGroup, resource, product, partySize)).filter(resource => !evaluationContext.resourceIdSet || evaluationContext.resourceIdSet.has(String(resource.id)))).filter(resource => !selection || selection.resourceIds.some(resourceId => sameId(resourceId, resource.id)));
|
|
1393
1484
|
const options = matchedResources.map(resource => {
|
|
1394
1485
|
const matchedCell = aggregateMatchedCells(product.id, requirementGroup.id, resource.id, candidateRange, request.cellIndex?.get([String(product.id), requirementGroup.id, String(resource.id)].join(':')) || []);
|
|
1486
|
+
const isExcludedScheduleDate = evaluationContext.allowExcludedScheduleDateOverride && isRangeFromExcludedWindows({
|
|
1487
|
+
normalWindows: resource.windows || [],
|
|
1488
|
+
excludedWindows: resource.excludedWindows || [],
|
|
1489
|
+
candidateRange,
|
|
1490
|
+
timezoneName: projection.meta.timezone
|
|
1491
|
+
});
|
|
1395
1492
|
if (!matchedCell) {
|
|
1396
1493
|
const isPast = candidateRange.endMs <= evaluationContext.evaluatedAtMs;
|
|
1397
1494
|
return {
|
|
@@ -1402,7 +1499,7 @@ function evaluateCandidate(projection, candidate, request) {
|
|
|
1402
1499
|
resourceType: resource.resourceType,
|
|
1403
1500
|
status: isPast ? 'past' : 'unavailable',
|
|
1404
1501
|
maxPartySize: 0,
|
|
1405
|
-
reasonCodes: isPast ? ['past'] : ['outside_resource_window']
|
|
1502
|
+
reasonCodes: isPast ? ['past'] : [...(isExcludedScheduleDate ? ['schedule_excluded_date'] : []), 'outside_resource_window']
|
|
1406
1503
|
};
|
|
1407
1504
|
}
|
|
1408
1505
|
const remainingCapacity = matchedCell.remainingCapacity;
|
|
@@ -1410,6 +1507,7 @@ function evaluateCandidate(projection, candidate, request) {
|
|
|
1410
1507
|
const isPast = candidateRange.endMs <= evaluationContext.evaluatedAtMs;
|
|
1411
1508
|
const maxPartySize = isPast ? 0 : Math.max(0, remainingCapacity || 0);
|
|
1412
1509
|
const requiredCapacity = resolveRequiredCapacity(requirementGroup, product, requestedPartySize);
|
|
1510
|
+
const reasonCodes = Array.from(new Set([...matchedCell.reasonCodes, ...(isExcludedScheduleDate ? ['schedule_excluded_date'] : [])]));
|
|
1413
1511
|
const status = (() => {
|
|
1414
1512
|
if (isPast) return 'past';
|
|
1415
1513
|
if (matchedCell.status === 'unavailable') return 'unavailable';
|
|
@@ -1427,7 +1525,7 @@ function evaluateCandidate(projection, candidate, request) {
|
|
|
1427
1525
|
remainingCapacity,
|
|
1428
1526
|
maxCapacity,
|
|
1429
1527
|
maxPartySize,
|
|
1430
|
-
reasonCodes: isPast ? Array.from(new Set([...
|
|
1528
|
+
reasonCodes: isPast ? Array.from(new Set([...reasonCodes, 'past'])) : reasonCodes,
|
|
1431
1529
|
matchedCell
|
|
1432
1530
|
};
|
|
1433
1531
|
});
|
|
@@ -1467,7 +1565,9 @@ function evaluateCandidate(projection, candidate, request) {
|
|
|
1467
1565
|
const requiredGroups = requirementGroups.filter(group => group.required);
|
|
1468
1566
|
const requiredStatuses = requiredGroups.map(group => group.status);
|
|
1469
1567
|
const gate = evaluateCandidateTimeGate({
|
|
1568
|
+
projection,
|
|
1470
1569
|
product,
|
|
1570
|
+
candidate,
|
|
1471
1571
|
candidateRange,
|
|
1472
1572
|
evaluationContext,
|
|
1473
1573
|
timezoneName: projection.meta.timezone
|
|
@@ -1543,7 +1643,7 @@ function assertRangesWithinProjection(projection, ranges) {
|
|
|
1543
1643
|
}
|
|
1544
1644
|
});
|
|
1545
1645
|
}
|
|
1546
|
-
function queryAvailabilityProjection(projection, request) {
|
|
1646
|
+
function queryAvailabilityProjection(projection, request, runtimeOptions = {}) {
|
|
1547
1647
|
const normalizedPartySize = normalizePartySize(request.partySize);
|
|
1548
1648
|
const evaluatedAt = formatDateTime((0, _localClock.localDateToScalar)(new Date()), projection.meta.timezone, (0, _localClock.extractFixedOffsetMinutes)(projection.meta.now) ?? (0, _localClock.captureRuntimeOffsetMinutes)());
|
|
1549
1649
|
if (request.target === 'time') {
|
|
@@ -1566,7 +1666,9 @@ function queryAvailabilityProjection(projection, request) {
|
|
|
1566
1666
|
const evaluationContext = buildEvaluationContext({
|
|
1567
1667
|
projection,
|
|
1568
1668
|
evaluatedAt,
|
|
1569
|
-
resourceIds: request.resourceIds
|
|
1669
|
+
resourceIds: request.resourceIds,
|
|
1670
|
+
useExactDurationCandidateMinute: runtimeOptions.useExactDurationCandidateMinute,
|
|
1671
|
+
allowExcludedScheduleDateOverride: runtimeOptions.allowExcludedScheduleDateOverride
|
|
1570
1672
|
});
|
|
1571
1673
|
if (request.target === 'time') {
|
|
1572
1674
|
const candidates = dedupeProductRanges(request.candidates);
|
|
@@ -1640,7 +1742,9 @@ function queryAvailabilityProjection(projection, request) {
|
|
|
1640
1742
|
resourceIds: request.resourceIds,
|
|
1641
1743
|
partySize: normalizedPartySize
|
|
1642
1744
|
}, {
|
|
1643
|
-
evaluatedAt
|
|
1745
|
+
evaluatedAt,
|
|
1746
|
+
useExactDurationCandidateMinute: runtimeOptions.useExactDurationCandidateMinute,
|
|
1747
|
+
allowExcludedScheduleDateOverride: runtimeOptions.allowExcludedScheduleDateOverride
|
|
1644
1748
|
});
|
|
1645
1749
|
const candidateGroupMap = new Map(candidateGroups.map(group => [String(group.productId), group]));
|
|
1646
1750
|
if (request.target === 'date') {
|
|
@@ -1790,7 +1894,7 @@ function summarizeProductStatus(statuses) {
|
|
|
1790
1894
|
if (statuses.every(status => status === 'past')) return 'past';
|
|
1791
1895
|
return 'unavailable';
|
|
1792
1896
|
}
|
|
1793
|
-
function validateAvailabilitySelection(projection, params) {
|
|
1897
|
+
function validateAvailabilitySelection(projection, params, runtimeOptions = {}) {
|
|
1794
1898
|
const normalizedPartySize = normalizePartySize(params.partySize);
|
|
1795
1899
|
const normalizedBookingCount = normalizeBookingCount(params.bookingCount);
|
|
1796
1900
|
assertRangesWithinProjection(projection, [params.candidate]);
|
|
@@ -1811,14 +1915,16 @@ function validateAvailabilitySelection(projection, params) {
|
|
|
1811
1915
|
evaluationContext: buildEvaluationContext({
|
|
1812
1916
|
projection,
|
|
1813
1917
|
evaluatedAt,
|
|
1814
|
-
requirementSelections: params.requirementSelections
|
|
1918
|
+
requirementSelections: params.requirementSelections,
|
|
1919
|
+
useExactDurationCandidateMinute: runtimeOptions.useExactDurationCandidateMinute,
|
|
1920
|
+
allowExcludedScheduleDateOverride: runtimeOptions.allowExcludedScheduleDateOverride
|
|
1815
1921
|
})
|
|
1816
1922
|
});
|
|
1817
1923
|
const conflicts = [];
|
|
1818
1924
|
if (evaluated.gate) {
|
|
1819
1925
|
conflicts.push({
|
|
1820
1926
|
code: evaluated.gate.conflictCode,
|
|
1821
|
-
message: evaluated.gate.
|
|
1927
|
+
message: evaluated.gate.conflictCode === 'past' ? '候选时间已过期' : evaluated.gate.conflictCode === 'schedule_excluded_date' ? '候选日期已被日程排除' : '候选时间不满足预订时间门禁',
|
|
1822
1928
|
reasonCodes: evaluated.gate.reasonCodes,
|
|
1823
1929
|
productId: params.candidate.productId,
|
|
1824
1930
|
candidateKey: params.candidate.key
|
|
@@ -101,6 +101,9 @@ export interface AvailabilityOperatingHoursSnapshot {
|
|
|
101
101
|
scheduleIds: AvailabilityId[];
|
|
102
102
|
missingScheduleIds: AvailabilityId[];
|
|
103
103
|
windows: AvailabilityResourceWindow[];
|
|
104
|
+
/** Schedule windows omitted only because their date is excluded. POS may use
|
|
105
|
+
* these to surface an unavailable, manually selectable candidate. */
|
|
106
|
+
excludedWindows?: AvailabilityResourceWindow[];
|
|
104
107
|
}
|
|
105
108
|
export interface AvailabilityResource {
|
|
106
109
|
id: AvailabilityId;
|
|
@@ -110,6 +113,8 @@ export interface AvailabilityResource {
|
|
|
110
113
|
resourceType: AvailabilityResourceType;
|
|
111
114
|
capacity: number;
|
|
112
115
|
windows: AvailabilityResourceWindow[];
|
|
116
|
+
/** Resource work windows omitted only by an excluded schedule date. */
|
|
117
|
+
excludedWindows?: AvailabilityResourceWindow[];
|
|
113
118
|
raw?: Record<string, any>;
|
|
114
119
|
}
|
|
115
120
|
export interface AvailabilityOccupancy extends AvailabilityAbsoluteRange {
|
|
@@ -213,6 +218,8 @@ export interface ProductTimeRangeGroup {
|
|
|
213
218
|
title?: string;
|
|
214
219
|
kind: AvailabilityProductKind;
|
|
215
220
|
slotStepMinutes?: number;
|
|
221
|
+
/** 单日查询对应营业窗口的最终结束时刻,不受资源排班是否为空影响。 */
|
|
222
|
+
operatingEndAt?: string;
|
|
216
223
|
ranges: ProductTimeRange[];
|
|
217
224
|
}
|
|
218
225
|
export interface AvailabilityAssignment extends AvailabilityAbsoluteRange {
|
|
@@ -243,6 +250,13 @@ export interface GetProductTimeRangesRequest {
|
|
|
243
250
|
}
|
|
244
251
|
export interface GetProductTimeRangesRuntimeOptions {
|
|
245
252
|
evaluatedAt?: string;
|
|
253
|
+
/**
|
|
254
|
+
* Internal POS capability: fixed-duration candidates start from the stable
|
|
255
|
+
* context anchor's current minute instead of rounding up to ten minutes, and
|
|
256
|
+
* that minute remains selectable during before-start cutoff evaluation.
|
|
257
|
+
* Other callers keep the legacy alignment and strict second-level cutoff.
|
|
258
|
+
*/
|
|
259
|
+
useExactDurationCandidateMinute?: boolean;
|
|
246
260
|
/**
|
|
247
261
|
* Internal POS capability: allow explicit duration/start overrides to append
|
|
248
262
|
* a custom duration candidate for Session products. Fixed Session ranges are
|
|
@@ -250,6 +264,11 @@ export interface GetProductTimeRangesRuntimeOptions {
|
|
|
250
264
|
* disabled.
|
|
251
265
|
*/
|
|
252
266
|
allowSessionCustomRanges?: boolean;
|
|
267
|
+
/**
|
|
268
|
+
* Internal POS capability: materialize candidates whose schedule date was
|
|
269
|
+
* explicitly excluded, while availability evaluation keeps them unavailable.
|
|
270
|
+
*/
|
|
271
|
+
allowExcludedScheduleDateOverride?: boolean;
|
|
253
272
|
}
|
|
254
273
|
export interface QueryAvailabilityBaseRequest {
|
|
255
274
|
productIds?: AvailabilityId[];
|
|
@@ -1128,7 +1128,7 @@ class RulesModule extends _BaseModule.BaseModule {
|
|
|
1128
1128
|
processedFlatItemsMap.set(flatItem._id, [{
|
|
1129
1129
|
...flatItem,
|
|
1130
1130
|
discount_list: isManualDiscount ? this.resolveDiscountListForManualOverride(flatItem.bundleItem?.discount_list || []) : this.filterDiscountListByType(flatItem.bundleItem?.discount_list || [], 'promotion'),
|
|
1131
|
-
price:
|
|
1131
|
+
price: flatItem.bundleItem.price,
|
|
1132
1132
|
bundle_selling_price: flatItem.bundleItem.bundle_selling_price ?? (isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price),
|
|
1133
1133
|
processed: true
|
|
1134
1134
|
}]);
|
package/lib/plugins/request.d.ts
CHANGED
|
@@ -70,6 +70,7 @@ export interface RequestOptions {
|
|
|
70
70
|
cache?: CacheProps;
|
|
71
71
|
cacheUpdateChange?: (data: any) => void;
|
|
72
72
|
osServer?: boolean;
|
|
73
|
+
isNocobase?: boolean;
|
|
73
74
|
prefix?: boolean;
|
|
74
75
|
callback?: (res: any) => void;
|
|
75
76
|
subscriberId?: string;
|
|
@@ -125,7 +126,7 @@ declare class RequestPluginImpl implements RequestPlugin {
|
|
|
125
126
|
/**
|
|
126
127
|
* GET 请求
|
|
127
128
|
*/
|
|
128
|
-
get<T = any>(url: string, options?: RequestOptions): Promise<T>;
|
|
129
|
+
get<T = any>(url: string, dataOrOptions?: any, options?: RequestOptions): Promise<T>;
|
|
129
130
|
/**
|
|
130
131
|
* POST 请求
|
|
131
132
|
*/
|
package/lib/plugins/request.js
CHANGED
|
@@ -99,9 +99,10 @@ class RequestPluginImpl {
|
|
|
99
99
|
/**
|
|
100
100
|
* GET 请求
|
|
101
101
|
*/
|
|
102
|
-
get(url,
|
|
102
|
+
get(url, dataOrOptions = {}, options) {
|
|
103
|
+
const requestOptions = options ?? dataOrOptions;
|
|
103
104
|
return this.request({
|
|
104
|
-
...
|
|
105
|
+
...requestOptions,
|
|
105
106
|
url,
|
|
106
107
|
method: 'GET'
|
|
107
108
|
});
|
package/lib/server/index.d.ts
CHANGED
|
@@ -421,6 +421,7 @@ declare class Server {
|
|
|
421
421
|
private shouldUseLocalOrderQuery;
|
|
422
422
|
/**
|
|
423
423
|
* 预约查询是否走本地:
|
|
424
|
+
* - 日历周/月/资源视图通过 compact_fields 显式标识,始终走远端;
|
|
424
425
|
* - 当 sales_time_between 的开始和结束都不是今天时,走远端;
|
|
425
426
|
* - 其余情况走本地。
|
|
426
427
|
*/
|
|
@@ -514,6 +515,10 @@ declare class Server {
|
|
|
514
515
|
private buildCheckoutTaskIdempotencyKey;
|
|
515
516
|
private isBlankCheckoutValue;
|
|
516
517
|
private isLocalCheckoutOrderId;
|
|
518
|
+
private normalizePrintInvoiceLayoutConfig;
|
|
519
|
+
private extractInvoiceLayoutConfig;
|
|
520
|
+
private normalizePrintInvoiceTemplateSettings;
|
|
521
|
+
private extractInvoiceTemplateSettings;
|
|
517
522
|
private applyCheckoutFulfillmentBuzzer;
|
|
518
523
|
private buildCheckoutResourceIdentifierBuzzer;
|
|
519
524
|
private getCheckoutResourceIdentifier;
|
|
@@ -533,7 +538,10 @@ declare class Server {
|
|
|
533
538
|
private dispatchLocalReceiptPrint;
|
|
534
539
|
private shouldLookupLocalPrintOrder;
|
|
535
540
|
private getLocalPrintOrderLookup;
|
|
541
|
+
private mergeLocalPrintOrderInput;
|
|
536
542
|
private handleLocalPrintOrder;
|
|
543
|
+
private normalizeRequestedReceiptLocales;
|
|
544
|
+
private handleLocalOrderReceiptSnapshot;
|
|
537
545
|
private handleMachinecodeBatchMeta;
|
|
538
546
|
private resolveMachinecodeBatchMetadataLookup;
|
|
539
547
|
private syncMachinecodeRedeemStatusToLocalOrder;
|
|
@@ -542,6 +550,11 @@ declare class Server {
|
|
|
542
550
|
private handleOrderDraftSubmit;
|
|
543
551
|
private handlePendingSyncCheckoutOrder;
|
|
544
552
|
private buildPendingSyncCheckoutOrder;
|
|
553
|
+
/**
|
|
554
|
+
* Checkout 与本地小票必须消费同一份规范化子项快照。
|
|
555
|
+
* 商品/预约只折叠持久化 ID 或协议 UID 相同的行;支付额外兼容 payment_number。
|
|
556
|
+
*/
|
|
557
|
+
private normalizeCheckoutCollections;
|
|
545
558
|
/**
|
|
546
559
|
* Android 结账自动小票由当前设备设置控制;其它平台保持原有行为。
|
|
547
560
|
*/
|
|
@@ -571,6 +584,8 @@ declare class Server {
|
|
|
571
584
|
private shouldLookupPaymentMethodNameByCode;
|
|
572
585
|
private enrichPaymentNamesByCode;
|
|
573
586
|
private withLocalSmallTicketData;
|
|
587
|
+
private normalizeRemoteSalesOrderErrorCode;
|
|
588
|
+
private fetchAndPersistSalesOrderByLookup;
|
|
574
589
|
private handleOrderSalesDetail;
|
|
575
590
|
/**
|
|
576
591
|
* 解析 order_ids 入参,兼容 url query / data 字段、字符串(csv) / 数组两种形态。
|