@pisell/pisellos 2.3.187 → 2.3.189
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/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/BookingContext/utils/productExtend.d.ts +9 -1
- package/dist/modules/BookingContext/utils/productExtend.js +47 -13
- package/dist/modules/Order/index.d.ts +15 -5
- package/dist/modules/Order/index.js +1161 -921
- package/dist/modules/Order/types.d.ts +16 -4
- package/dist/modules/Order/utils.d.ts +1 -3
- package/dist/modules/Order/utils.js +2 -5
- package/dist/modules/ResourcePlanner/planner.js +29 -2
- package/dist/modules/ResourcePlanner/types.d.ts +6 -0
- package/dist/modules/Rules/index.js +19 -30
- package/dist/solution/BaseSales/index.d.ts +4 -0
- package/dist/solution/BaseSales/index.js +204 -176
- package/dist/solution/BaseSales/types.d.ts +1 -0
- package/dist/solution/BaseSales/types.js +1 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +52 -31
- package/dist/solution/UnifiedBookingSales/index.d.ts +3 -0
- package/dist/solution/UnifiedBookingSales/index.js +279 -204
- package/dist/solution/UnifiedBookingSales/types.d.ts +6 -1
- package/lib/modules/BookingContext/utils/productExtend.d.ts +9 -1
- package/lib/modules/BookingContext/utils/productExtend.js +38 -5
- package/lib/modules/Order/index.d.ts +15 -5
- package/lib/modules/Order/index.js +167 -21
- package/lib/modules/Order/types.d.ts +16 -4
- package/lib/modules/Order/utils.d.ts +1 -3
- package/lib/modules/Order/utils.js +2 -5
- package/lib/modules/ResourcePlanner/planner.js +25 -1
- package/lib/modules/ResourcePlanner/types.d.ts +6 -0
- package/lib/modules/Rules/index.js +9 -19
- package/lib/solution/BaseSales/index.d.ts +4 -0
- package/lib/solution/BaseSales/index.js +14 -0
- package/lib/solution/BaseSales/types.d.ts +1 -0
- package/lib/solution/BaseSales/types.js +1 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +8 -2
- package/lib/solution/UnifiedBookingSales/index.d.ts +3 -0
- package/lib/solution/UnifiedBookingSales/index.js +80 -15
- package/lib/solution/UnifiedBookingSales/types.d.ts +6 -1
- package/package.json +1 -1
|
@@ -74,8 +74,9 @@ export interface AvailabilityContextRef {
|
|
|
74
74
|
contextId: string;
|
|
75
75
|
/** POS/Kiosk duration protocol capability and business-day default. */
|
|
76
76
|
durationTimeSelection?: {
|
|
77
|
-
version:
|
|
77
|
+
version: 2;
|
|
78
78
|
currentBusinessDate: string;
|
|
79
|
+
orderSessionId: string | null;
|
|
79
80
|
};
|
|
80
81
|
}
|
|
81
82
|
export interface ContextualProductTimeRange extends ProductTimeRange {
|
|
@@ -100,6 +101,8 @@ export type ContextualAvailabilityQuery = (Omit<Extract<AvailabilityQuery, {
|
|
|
100
101
|
})) & {
|
|
101
102
|
/** Automatic remembered selection must not inherit POS manual exceptions. */
|
|
102
103
|
selectionIntent?: 'remembered' | 'manual';
|
|
104
|
+
rememberedTimeByProductId?: GetProductTimeRangesRequest['rememberedTimeByProductId'];
|
|
105
|
+
orderSessionId?: string;
|
|
103
106
|
};
|
|
104
107
|
export type ContextualTimeAvailabilityItem = Omit<TimeAvailabilityItem, keyof ProductTimeRange> & ContextualProductTimeRange;
|
|
105
108
|
export interface ContextualTimeAvailabilityGroup extends Omit<TimeAvailabilityGroup, 'times'> {
|
|
@@ -165,6 +168,8 @@ export interface ContextualCommitAvailabilitySelectionParams {
|
|
|
165
168
|
mode: 'add' | 'edit';
|
|
166
169
|
/** Only POS duration add supports automatic remembered-time commits. */
|
|
167
170
|
selectionIntent?: 'remembered' | 'manual';
|
|
171
|
+
/** v2 remembered commits must still belong to the order that saved the interval. */
|
|
172
|
+
orderSessionId?: string;
|
|
168
173
|
/** Local UI intent guard, checked again immediately before the Order mutation. */
|
|
169
174
|
availabilityCommitGuard?: () => void;
|
|
170
175
|
productLineUid?: string;
|
|
@@ -9,11 +9,19 @@ import { TimeSlicesResult, TimeSlice, DurationSlice } from './timeSlices';
|
|
|
9
9
|
export interface BookingCalcContext {
|
|
10
10
|
/** Sales channel; remembered duration starts are accepted only by POS. */
|
|
11
11
|
channel?: string;
|
|
12
|
-
/**
|
|
12
|
+
/** Current in-memory order session, supplied by the owning Order module. */
|
|
13
|
+
orderSessionId?: string;
|
|
14
|
+
/** Rejects a session while an order replacement or hydration is pending. */
|
|
15
|
+
isOrderSessionCurrent?: (sessionId: string) => boolean;
|
|
16
|
+
/** Legacy start-only preference, or an exact interval owned by the current order session. */
|
|
13
17
|
rememberedTime?: {
|
|
14
18
|
businessDate: string;
|
|
15
19
|
startAt: string;
|
|
20
|
+
endAt?: string;
|
|
21
|
+
orderSessionId?: string;
|
|
16
22
|
};
|
|
23
|
+
/** An expired memory restarts from the current entry time, without following cart bookings. */
|
|
24
|
+
useCurrentTimeAfterRememberedExpiry?: boolean;
|
|
17
25
|
/** 来自 `/core/board/management/config` 的整套配置;常用路径见 sliceTimeSlices / appointmentTimingPreference。 */
|
|
18
26
|
bookingConfig?: any;
|
|
19
27
|
/** 资源 origin map(id → resource origin)。 */
|
|
@@ -31,7 +31,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
31
31
|
/** Rebuild only the derived booking fields; SKU, quantity, notes and Holder stay intact. */
|
|
32
32
|
function seedRememberedBookingStart(cacheItem, ctx) {
|
|
33
33
|
const remembered = ctx.rememberedTime;
|
|
34
|
-
const invalid = () => Object.assign(new Error('Remembered time requires a valid POS duration
|
|
34
|
+
const invalid = () => Object.assign(new Error('Remembered time requires a valid POS duration interval in the current order.'), {
|
|
35
35
|
code: 'INVALID_REMEMBERED_TIME'
|
|
36
36
|
});
|
|
37
37
|
const duration = cacheItem?.duration;
|
|
@@ -43,12 +43,29 @@ function seedRememberedBookingStart(cacheItem, ctx) {
|
|
|
43
43
|
const date = new Date(`${value}T00:00:00.000Z`);
|
|
44
44
|
return Number.isFinite(date.getTime()) && date.toISOString().slice(0, 10) === value;
|
|
45
45
|
};
|
|
46
|
-
const
|
|
47
|
-
|
|
46
|
+
const isDateTime = value => {
|
|
47
|
+
const parts = typeof value === 'string' ? /^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,3})?)?(?:Z|[+-](\d{2}):(\d{2}))?$/.exec(value) : null;
|
|
48
|
+
return Boolean(parts && isCalendarDate(parts[1]) && Number(parts[2]) <= 23 && Number(parts[3]) <= 59 && Number(parts[4] || 0) <= 59 && Number(parts[5] || 0) <= 23 && Number(parts[6] || 0) <= 59);
|
|
49
|
+
};
|
|
50
|
+
if (String(ctx.channel || '').trim().toLowerCase() !== 'pos' || !isDuration || (0, _serviceTimes.isMultiDayProduct)(cacheItem) || (0, _serviceTimes.isSessionProduct)(cacheItem) || cacheItem?.cartDetailValue?.session || cacheItem?._extend?.other?.session || !isCalendarDate(remembered?.businessDate) || !isDateTime(remembered?.startAt)) throw invalid();
|
|
48
51
|
// Parse the actual instant with the same runtime clock used by the legacy booking helpers.
|
|
49
52
|
// The business-day label must not replace the calendar date of an overnight start.
|
|
50
53
|
const start = (0, _dayjs.default)(remembered.startAt);
|
|
51
54
|
if (!start.isValid()) throw invalid();
|
|
55
|
+
const hasRememberedInterval = remembered.endAt !== undefined || remembered.orderSessionId !== undefined;
|
|
56
|
+
let end;
|
|
57
|
+
let rememberedDuration;
|
|
58
|
+
if (hasRememberedInterval) {
|
|
59
|
+
if (!isDateTime(remembered.endAt) || typeof remembered.orderSessionId !== 'string' || !remembered.orderSessionId.trim() || remembered.orderSessionId !== ctx.orderSessionId || ctx.isOrderSessionCurrent && !ctx.isOrderSessionCurrent(remembered.orderSessionId)) throw invalid();
|
|
60
|
+
end = (0, _dayjs.default)(remembered.endAt);
|
|
61
|
+
const durationMinutes = (end.valueOf() - start.valueOf()) / 60000;
|
|
62
|
+
if (!end.isValid() || !Number.isFinite(durationMinutes) || durationMinutes <= 0) throw invalid();
|
|
63
|
+
const flexible = (0, _flexible.isProductFlexibleDuration)(duration);
|
|
64
|
+
const configuredDurationMinutes = Number(durationValue) * (['hour', 'hours'].includes(durationType) ? 60 : 1);
|
|
65
|
+
if (!flexible && durationMinutes !== configuredDurationMinutes) throw invalid();
|
|
66
|
+
rememberedDuration = flexible ? _flexible.flexibleObj.create(durationMinutes) : durationMinutes;
|
|
67
|
+
}
|
|
68
|
+
const clockFormat = value => value.format(value.millisecond() ? 'HH:mm:ss.SSS' : value.second() ? 'HH:mm:ss' : 'HH:mm');
|
|
52
69
|
const extend = {
|
|
53
70
|
...(cacheItem?._extend || {})
|
|
54
71
|
};
|
|
@@ -61,7 +78,13 @@ function seedRememberedBookingStart(cacheItem, ctx) {
|
|
|
61
78
|
_extend: {
|
|
62
79
|
...extend,
|
|
63
80
|
start_date: start.format('YYYY-MM-DD'),
|
|
64
|
-
start_time:
|
|
81
|
+
start_time: clockFormat(start),
|
|
82
|
+
...(end ? {
|
|
83
|
+
end_date: end.format('YYYY-MM-DD'),
|
|
84
|
+
end_time: clockFormat(end),
|
|
85
|
+
endDate: end,
|
|
86
|
+
duration: rememberedDuration
|
|
87
|
+
} : {})
|
|
65
88
|
}
|
|
66
89
|
};
|
|
67
90
|
}
|
|
@@ -94,6 +117,15 @@ function getFlexibleOption(params) {
|
|
|
94
117
|
const duration = (0, _flexible.getDurationValue)(cacheItem?.duration);
|
|
95
118
|
if (duration !== 'flexible') return null;
|
|
96
119
|
const startDate = (0, _dayjs.default)(`${(0, _dayjs.default)(cacheItem?._extend?.start_date).format('YYYY-MM-DD')} ${useStartTime || cacheItem?._extend?.start_time || '00:00'}`);
|
|
120
|
+
// The current-order interval was validated before rebuilding the cache item.
|
|
121
|
+
// Resource defaults may change, but must never extend its saved end.
|
|
122
|
+
if (params.ctx.rememberedTime?.endAt !== undefined) {
|
|
123
|
+
const timeValue = ((0, _dayjs.default)(params.ctx.rememberedTime.endAt).valueOf() - startDate.valueOf()) / 60000;
|
|
124
|
+
return {
|
|
125
|
+
label: String(timeValue),
|
|
126
|
+
value: _flexible.flexibleObj.create(timeValue)
|
|
127
|
+
};
|
|
128
|
+
}
|
|
97
129
|
const usable = (0, _resources.getUsableTime)(cacheItem);
|
|
98
130
|
const usableEndAt = usable?._extend?.usableTime?.end_at ? (0, _dayjs.default)(usable._extend.usableTime.end_at) : null;
|
|
99
131
|
const endDate = (0, _timeSlices.getEndDate)(startDate, 'flexible', usableEndAt, params.ctx?.shopOpeningHours);
|
|
@@ -139,6 +171,7 @@ function getTimeObj(params) {
|
|
|
139
171
|
};
|
|
140
172
|
}
|
|
141
173
|
function getDefaultBookingStartFallback(cacheItem, ctx) {
|
|
174
|
+
if (ctx.useCurrentTimeAfterRememberedExpiry) return (0, _dayjs.default)(ctx.date ?? (0, _dayjs.default)()).format('YYYY-MM-DDTHH:mm');
|
|
142
175
|
const date = (0, _dayjs.default)(cacheItem?._extend?.start_date ?? ctx.date ?? (0, _dayjs.default)()).format('YYYY-MM-DD');
|
|
143
176
|
const time = ctx.presetStartTime || cacheItem.currentDefaultTime || (0, _dayjs.default)().format('HH:mm');
|
|
144
177
|
return `${date}T${time}`;
|
|
@@ -281,7 +314,7 @@ function getProductExtend(params) {
|
|
|
281
314
|
cacheItem,
|
|
282
315
|
ctx
|
|
283
316
|
});
|
|
284
|
-
const defaultBookingStartFallback = cacheItem._data?.salesDefaultBookingFallback ?? getDefaultBookingStartFallback(cacheItem, ctx);
|
|
317
|
+
const defaultBookingStartFallback = (!ctx.useCurrentTimeAfterRememberedExpiry ? cacheItem._data?.salesDefaultBookingFallback : undefined) ?? getDefaultBookingStartFallback(cacheItem, ctx);
|
|
285
318
|
_cacheItem._extend = getServiceStartTimeAndEndTime({
|
|
286
319
|
cacheItem,
|
|
287
320
|
timeObj: _cacheItem._data.timeObj,
|
|
@@ -5,7 +5,7 @@ import { CartItem } from '../Cart/types';
|
|
|
5
5
|
import { type SubmitPayloadEnhancer } from './utils';
|
|
6
6
|
import { type PickupTimingBooking, type PickupTimingBookingInput } from './pickupTiming';
|
|
7
7
|
import { type ProductVoucherGroup } from './utils/productVoucherGroups';
|
|
8
|
-
import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, OrderHooksConfig, OrderCartIntentCommitContext, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, PointCardSnapshotMergeContext, PointCardSnapshotItem, ShopServiceData, ShopServiceType } from './types';
|
|
8
|
+
import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, OrderHooksConfig, OrderCartIntentCommitContext, ReplaceTempOrderOptions, HydrateTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, PointCardSnapshotMergeContext, PointCardSnapshotItem, ShopServiceData, ShopServiceType } from './types';
|
|
9
9
|
import type { ICustomer } from '../AccountList/types';
|
|
10
10
|
import type { Discount } from '../Discount/types';
|
|
11
11
|
import { UnavailableReason } from '../Rules/types';
|
|
@@ -22,6 +22,10 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
22
22
|
private openCache;
|
|
23
23
|
private sessionStoragePersistEnabled;
|
|
24
24
|
private sessionStorageRestoreRecord;
|
|
25
|
+
private orderSessionId;
|
|
26
|
+
private orderSessionDestroyed;
|
|
27
|
+
private orderSessionAliases;
|
|
28
|
+
private orderReplacement;
|
|
25
29
|
/** 只允许当前订单最新的 prepare/config 请求回写客户资产态。 */
|
|
26
30
|
private customerWalletPrepareConfigEpoch;
|
|
27
31
|
/** Payment 可能早于 prepare/config 返回;先按实例 ID 暂存卡号等待 Snapshot。 */
|
|
@@ -205,6 +209,14 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
205
209
|
clearSessionStoragePersistedTempOrder(): void;
|
|
206
210
|
consumeSessionStorageRestore(): Record<string, any> | null;
|
|
207
211
|
notifyTempOrderChanged(): void;
|
|
212
|
+
private getOrderSessionAliases;
|
|
213
|
+
private publishOrderSession;
|
|
214
|
+
getOrderSessionId(): string | null;
|
|
215
|
+
isOrderSessionCurrent(sessionId: string): boolean;
|
|
216
|
+
private beginOrderReplacement;
|
|
217
|
+
private assertOrderReplacementCurrent;
|
|
218
|
+
private completeOrderReplacement;
|
|
219
|
+
private rollbackOrderReplacement;
|
|
208
220
|
private createDefaultTempOrderInstance;
|
|
209
221
|
private clearTempOrderCustomerWalletSnapshots;
|
|
210
222
|
private clearCustomerWalletState;
|
|
@@ -666,10 +678,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
666
678
|
* 数据源应尽量返回 tempOrder 所需结构;这里仅做 SDK 运行必须字段兜底,
|
|
667
679
|
* 例如数组字段、商品行唯一值、价格 metadata、summary 派生状态和 _extend。
|
|
668
680
|
*/
|
|
669
|
-
hydrateTempOrderFromRecord(record: Record<string, any>, options?:
|
|
670
|
-
|
|
671
|
-
source?: 'salesDetail' | 'mergedSalesDetail' | 'sessionStorage';
|
|
672
|
-
}): Promise<OrderTempOrder>;
|
|
681
|
+
hydrateTempOrderFromRecord(record: Record<string, any>, options?: HydrateTempOrderOptions): Promise<OrderTempOrder>;
|
|
682
|
+
private prepareHydratedTempOrder;
|
|
673
683
|
/**
|
|
674
684
|
* 兼容后端详情将 holder 放在 metadata.holder 的历史形态,统一补到运行时展示路径。
|
|
675
685
|
*
|
|
@@ -140,6 +140,10 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
140
140
|
openCache = false;
|
|
141
141
|
sessionStoragePersistEnabled = false;
|
|
142
142
|
sessionStorageRestoreRecord = null;
|
|
143
|
+
orderSessionId = null;
|
|
144
|
+
orderSessionDestroyed = false;
|
|
145
|
+
orderSessionAliases = new Set();
|
|
146
|
+
orderReplacement = null;
|
|
143
147
|
/** 只允许当前订单最新的 prepare/config 请求回写客户资产态。 */
|
|
144
148
|
customerWalletPrepareConfigEpoch = 0;
|
|
145
149
|
/** Payment 可能早于 prepare/config 返回;先按实例 ID 暂存卡号等待 Snapshot。 */
|
|
@@ -425,6 +429,10 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
425
429
|
async initialize(core, options) {
|
|
426
430
|
this.core = core;
|
|
427
431
|
this.store = options.store;
|
|
432
|
+
this.orderReplacement = null;
|
|
433
|
+
this.orderSessionId = null;
|
|
434
|
+
this.orderSessionDestroyed = false;
|
|
435
|
+
this.orderSessionAliases.clear();
|
|
428
436
|
const otherParams = options.otherParams || {};
|
|
429
437
|
this.syncSessionStorageOptions(otherParams);
|
|
430
438
|
if (this.sessionStoragePersistEnabled) {
|
|
@@ -464,10 +472,14 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
464
472
|
this.orderHooks = this.moduleHooksOverride || otherParams.order?.hooks || otherParams.hooks?.order;
|
|
465
473
|
this.otherParams = otherParams;
|
|
466
474
|
this.registerDiscountModules(options);
|
|
475
|
+
this.publishOrderSession(this.store.tempOrder);
|
|
467
476
|
this.logInfo('OrderModule initialized successfully');
|
|
468
477
|
}
|
|
469
478
|
async destroy() {
|
|
470
479
|
this.sessionStorageRestoreRecord = null;
|
|
480
|
+
this.orderReplacement = null;
|
|
481
|
+
this.orderSessionDestroyed = true;
|
|
482
|
+
this.publishOrderSession(null);
|
|
471
483
|
const childModules = [this.store?.discount, this.store?.rules];
|
|
472
484
|
for (const childModule of childModules) {
|
|
473
485
|
if (!childModule || typeof childModule.destroy !== 'function') continue;
|
|
@@ -1292,6 +1304,111 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
1292
1304
|
|
|
1293
1305
|
// ─── TempOrder: 创建 & 获取 ───
|
|
1294
1306
|
|
|
1307
|
+
getOrderSessionAliases(order) {
|
|
1308
|
+
const aliases = new Set();
|
|
1309
|
+
if (!order) return aliases;
|
|
1310
|
+
for (const key of ['external_sale_number', 'order_id']) {
|
|
1311
|
+
const value = order[key];
|
|
1312
|
+
if (value !== null && value !== undefined && String(value).trim() !== '' && (key !== 'order_id' || String(value) !== '0')) {
|
|
1313
|
+
aliases.add(`${key}:${String(value).trim()}`);
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
return aliases;
|
|
1317
|
+
}
|
|
1318
|
+
publishOrderSession(order, fresh = false) {
|
|
1319
|
+
const previousSessionId = this.orderSessionId;
|
|
1320
|
+
if (!order) {
|
|
1321
|
+
this.orderSessionId = null;
|
|
1322
|
+
this.orderSessionAliases.clear();
|
|
1323
|
+
} else {
|
|
1324
|
+
if (fresh || !this.orderSessionId) {
|
|
1325
|
+
this.orderSessionId = (0, _utils.createUuidV4)();
|
|
1326
|
+
this.orderSessionAliases = new Set();
|
|
1327
|
+
}
|
|
1328
|
+
this.getOrderSessionAliases(order).forEach(alias => this.orderSessionAliases.add(alias));
|
|
1329
|
+
}
|
|
1330
|
+
if (previousSessionId === this.orderSessionId || !this.core?.effects) return;
|
|
1331
|
+
// The session is already published. A listener failure must not turn a successful
|
|
1332
|
+
// reset into a failed reset or roll the active order back.
|
|
1333
|
+
const reportError = error => this.logWarning('Order session listener failed', {
|
|
1334
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1335
|
+
});
|
|
1336
|
+
try {
|
|
1337
|
+
void Promise.resolve(this.effectsEmit('onOrderSessionChanged', {
|
|
1338
|
+
sessionId: this.orderSessionId,
|
|
1339
|
+
previousSessionId
|
|
1340
|
+
})).catch(reportError);
|
|
1341
|
+
} catch (error) {
|
|
1342
|
+
reportError(error);
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
getOrderSessionId() {
|
|
1346
|
+
if (this.orderSessionDestroyed) return null;
|
|
1347
|
+
if (this.orderReplacement) return this.orderReplacement.sessionId;
|
|
1348
|
+
// Existing in-memory orders can be adopted during initialization. Adding a
|
|
1349
|
+
// remote ID later only extends the aliases; it does not create a new order.
|
|
1350
|
+
this.publishOrderSession(this.store?.tempOrder || null);
|
|
1351
|
+
return this.orderSessionId;
|
|
1352
|
+
}
|
|
1353
|
+
isOrderSessionCurrent(sessionId) {
|
|
1354
|
+
return !this.orderReplacement && Boolean(sessionId) && this.getOrderSessionId() === sessionId;
|
|
1355
|
+
}
|
|
1356
|
+
beginOrderReplacement(preserveOrderSessionId) {
|
|
1357
|
+
if (this.orderReplacement) {
|
|
1358
|
+
throw Object.assign(new Error('An order replacement is already pending'), {
|
|
1359
|
+
code: 'ORDER_SESSION_TRANSITION_PENDING'
|
|
1360
|
+
});
|
|
1361
|
+
}
|
|
1362
|
+
const sessionId = this.getOrderSessionId();
|
|
1363
|
+
if (preserveOrderSessionId && preserveOrderSessionId !== sessionId) {
|
|
1364
|
+
throw Object.assign(new Error('The order session has changed'), {
|
|
1365
|
+
code: 'ORDER_SESSION_CHANGED'
|
|
1366
|
+
});
|
|
1367
|
+
}
|
|
1368
|
+
const discount = this.store.discount;
|
|
1369
|
+
const replacement = {
|
|
1370
|
+
state: {
|
|
1371
|
+
...this.store
|
|
1372
|
+
},
|
|
1373
|
+
sessionId,
|
|
1374
|
+
aliases: new Set(this.orderSessionAliases),
|
|
1375
|
+
originalDiscounts: (0, _lodashEs.cloneDeep)(discount?.getOriginalDiscountList?.() || []),
|
|
1376
|
+
discounts: (0, _lodashEs.cloneDeep)(discount?.getDiscountList?.() || []),
|
|
1377
|
+
walletEpoch: this.customerWalletPrepareConfigEpoch,
|
|
1378
|
+
pointCardCandidates: new Map(this.pointCardSnapshotCodeCandidates),
|
|
1379
|
+
sessionStorageRestoreRecord: this.sessionStorageRestoreRecord
|
|
1380
|
+
};
|
|
1381
|
+
this.orderReplacement = replacement;
|
|
1382
|
+
return replacement;
|
|
1383
|
+
}
|
|
1384
|
+
assertOrderReplacementCurrent(replacement) {
|
|
1385
|
+
if (this.orderReplacement !== replacement) {
|
|
1386
|
+
throw Object.assign(new Error('The order changed while its replacement was pending'), {
|
|
1387
|
+
code: 'ORDER_SESSION_CHANGED'
|
|
1388
|
+
});
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
completeOrderReplacement(replacement, nextOrder, preserveOrderSessionId) {
|
|
1392
|
+
this.assertOrderReplacementCurrent(replacement);
|
|
1393
|
+
const aliases = this.getOrderSessionAliases(nextOrder);
|
|
1394
|
+
const sameOrder = Boolean(replacement.sessionId) && (preserveOrderSessionId === replacement.sessionId || [...aliases].some(alias => replacement.aliases.has(alias)));
|
|
1395
|
+
this.orderReplacement = null;
|
|
1396
|
+
this.publishOrderSession(nextOrder, !sameOrder);
|
|
1397
|
+
}
|
|
1398
|
+
async rollbackOrderReplacement(replacement) {
|
|
1399
|
+
// An explicit reset wins over the pending result, including its rollback.
|
|
1400
|
+
if (this.orderReplacement !== replacement) return;
|
|
1401
|
+
Object.assign(this.store, replacement.state);
|
|
1402
|
+
this.customerWalletPrepareConfigEpoch = replacement.walletEpoch;
|
|
1403
|
+
this.pointCardSnapshotCodeCandidates = replacement.pointCardCandidates;
|
|
1404
|
+
this.sessionStorageRestoreRecord = replacement.sessionStorageRestoreRecord;
|
|
1405
|
+
const discount = this.store.discount;
|
|
1406
|
+
const restore = await Promise.allSettled([discount?.setOriginalDiscountList(replacement.originalDiscounts), discount?.setDiscountList(replacement.discounts)]);
|
|
1407
|
+
if (restore.some(result => result.status === 'rejected')) {
|
|
1408
|
+
this.logWarning('Order replacement discount rollback listener failed');
|
|
1409
|
+
}
|
|
1410
|
+
if (this.orderReplacement === replacement) this.orderReplacement = null;
|
|
1411
|
+
}
|
|
1295
1412
|
createDefaultTempOrderInstance() {
|
|
1296
1413
|
return (0, _utils.createDefaultTempOrder)({
|
|
1297
1414
|
now: (0, _utils.formatDateTime)(new Date())
|
|
@@ -2171,16 +2288,19 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2171
2288
|
ensureTempOrder() {
|
|
2172
2289
|
if (this.store.tempOrder) {
|
|
2173
2290
|
this.ensureExternalSaleNumber(this.store.tempOrder);
|
|
2291
|
+
if (!this.orderReplacement) this.publishOrderSession(this.store.tempOrder);
|
|
2174
2292
|
return this.store.tempOrder;
|
|
2175
2293
|
}
|
|
2176
2294
|
const newOrder = this.createDefaultTempOrderInstance();
|
|
2177
2295
|
this.ensureExternalSaleNumber(newOrder);
|
|
2178
2296
|
this.store.tempOrder = newOrder;
|
|
2297
|
+
this.publishOrderSession(newOrder, true);
|
|
2179
2298
|
this.persistTempOrder();
|
|
2180
2299
|
return newOrder;
|
|
2181
2300
|
}
|
|
2182
2301
|
restoreOrder() {
|
|
2183
2302
|
this.logInfo('restoreOrder start', {});
|
|
2303
|
+
this.orderReplacement = null;
|
|
2184
2304
|
this.sessionStorageRestoreRecord = null;
|
|
2185
2305
|
const freshTempOrder = this.createDefaultTempOrderInstance();
|
|
2186
2306
|
this.ensureExternalSaleNumber(freshTempOrder);
|
|
@@ -2191,36 +2311,45 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2191
2311
|
this.store.syncState = undefined;
|
|
2192
2312
|
void this.store.discount?.setOriginalDiscountList([]);
|
|
2193
2313
|
void this.store.discount?.setDiscountList([]);
|
|
2314
|
+
this.publishOrderSession(freshTempOrder, true);
|
|
2194
2315
|
this.persistTempOrder();
|
|
2195
2316
|
return freshTempOrder;
|
|
2196
2317
|
}
|
|
2197
2318
|
getTempOrder() {
|
|
2198
|
-
return this.store.tempOrder;
|
|
2319
|
+
return this.orderReplacement ? this.orderReplacement.state.tempOrder : this.store.tempOrder;
|
|
2199
2320
|
}
|
|
2200
2321
|
async replaceTempOrder(tempOrder, options) {
|
|
2201
2322
|
if (!(0, _utils.isTempOrder)(tempOrder)) {
|
|
2202
2323
|
throw new Error('无效的 tempOrder 数据');
|
|
2203
2324
|
}
|
|
2204
|
-
this.sessionStorageRestoreRecord = null;
|
|
2205
2325
|
const nextTempOrder = this.normalizeTempOrderForRuntime((0, _lodashEs.cloneDeep)(tempOrder), {
|
|
2206
2326
|
ensureIdentity: false
|
|
2207
2327
|
});
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2328
|
+
const replacement = this.beginOrderReplacement(options?.preserveOrderSessionId);
|
|
2329
|
+
try {
|
|
2330
|
+
this.sessionStorageRestoreRecord = null;
|
|
2331
|
+
this.store.tempOrder = nextTempOrder;
|
|
2332
|
+
this.clearCustomerWalletRuntimeState();
|
|
2333
|
+
if (options?.recalculateSummary !== false) {
|
|
2334
|
+
await this.recalculateSummary({
|
|
2335
|
+
createIfMissing: false,
|
|
2336
|
+
isCurrentOrder: () => this.orderReplacement === replacement
|
|
2337
|
+
});
|
|
2338
|
+
} else {
|
|
2339
|
+
this.store.summary = (0, _utils.createEmptySummary)();
|
|
2340
|
+
}
|
|
2341
|
+
this.assertOrderReplacementCurrent(replacement);
|
|
2342
|
+
if (options?.saveDraft) {
|
|
2343
|
+
await this.saveDraft();
|
|
2344
|
+
this.assertOrderReplacementCurrent(replacement);
|
|
2345
|
+
}
|
|
2346
|
+
if (options?.persist !== false) this.persistTempOrder();
|
|
2347
|
+
this.completeOrderReplacement(replacement, nextTempOrder, options?.preserveOrderSessionId);
|
|
2348
|
+
return nextTempOrder;
|
|
2349
|
+
} catch (error) {
|
|
2350
|
+
await this.rollbackOrderReplacement(replacement);
|
|
2351
|
+
throw error;
|
|
2222
2352
|
}
|
|
2223
|
-
return nextTempOrder;
|
|
2224
2353
|
}
|
|
2225
2354
|
getOrderIdentity() {
|
|
2226
2355
|
const tempOrder = this.store.tempOrder;
|
|
@@ -5462,6 +5591,19 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5462
5591
|
* 例如数组字段、商品行唯一值、价格 metadata、summary 派生状态和 _extend。
|
|
5463
5592
|
*/
|
|
5464
5593
|
async hydrateTempOrderFromRecord(record, options) {
|
|
5594
|
+
const replacement = this.beginOrderReplacement(options?.preserveOrderSessionId);
|
|
5595
|
+
try {
|
|
5596
|
+
const nextTempOrder = await this.prepareHydratedTempOrder(record, options, replacement);
|
|
5597
|
+
this.assertOrderReplacementCurrent(replacement);
|
|
5598
|
+
this.persistTempOrder();
|
|
5599
|
+
this.completeOrderReplacement(replacement, nextTempOrder, options?.preserveOrderSessionId);
|
|
5600
|
+
return nextTempOrder;
|
|
5601
|
+
} catch (error) {
|
|
5602
|
+
await this.rollbackOrderReplacement(replacement);
|
|
5603
|
+
throw error;
|
|
5604
|
+
}
|
|
5605
|
+
}
|
|
5606
|
+
async prepareHydratedTempOrder(record, options, replacement) {
|
|
5465
5607
|
const sourceRaw = record && typeof record === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
5466
5608
|
const duplicateProductIdentityRepair = (0, _orderCollectionIdentity.repairDuplicateProductLineIdentities)(Array.isArray(sourceRaw.products) ? sourceRaw.products : [], sourceRaw._extend?.productsByUid);
|
|
5467
5609
|
const duplicateIdentityReadySource = duplicateProductIdentityRepair.repairs.length ? {
|
|
@@ -5517,13 +5659,15 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5517
5659
|
this.store.summary = (0, _utils.createEmptySummary)();
|
|
5518
5660
|
this.store.lastOrderInfo = undefined;
|
|
5519
5661
|
await this.store.discount?.setOriginalDiscountList((0, _lodashEs.cloneDeep)(restoredSessionDiscounts));
|
|
5662
|
+
this.assertOrderReplacementCurrent(replacement);
|
|
5520
5663
|
await this.store.discount?.setDiscountList((0, _lodashEs.cloneDeep)(restoredSessionDiscounts));
|
|
5664
|
+
this.assertOrderReplacementCurrent(replacement);
|
|
5521
5665
|
if (options?.recalcOnHydrate) {
|
|
5522
5666
|
await this.recalculateSummary({
|
|
5523
|
-
createIfMissing: false
|
|
5667
|
+
createIfMissing: false,
|
|
5668
|
+
isCurrentOrder: () => this.orderReplacement === replacement
|
|
5524
5669
|
});
|
|
5525
5670
|
}
|
|
5526
|
-
this.persistTempOrder();
|
|
5527
5671
|
return nextTempOrder;
|
|
5528
5672
|
}
|
|
5529
5673
|
|
|
@@ -5580,14 +5724,16 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5580
5724
|
if (!shouldSkipEmptyDiscountSync) {
|
|
5581
5725
|
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
5582
5726
|
await this.store.discount?.setOriginalDiscountList(nextDiscounts);
|
|
5727
|
+
this.assertOrderReplacementCurrent(replacement);
|
|
5583
5728
|
await this.store.discount?.setDiscountList(nextDiscounts);
|
|
5729
|
+
this.assertOrderReplacementCurrent(replacement);
|
|
5584
5730
|
}
|
|
5585
5731
|
if (options?.recalcOnHydrate) {
|
|
5586
5732
|
await this.recalculateSummary({
|
|
5587
|
-
createIfMissing: false
|
|
5733
|
+
createIfMissing: false,
|
|
5734
|
+
isCurrentOrder: () => this.orderReplacement === replacement
|
|
5588
5735
|
});
|
|
5589
5736
|
}
|
|
5590
|
-
this.persistTempOrder();
|
|
5591
5737
|
return nextTempOrder;
|
|
5592
5738
|
}
|
|
5593
5739
|
|
|
@@ -449,6 +449,17 @@ export interface ReplaceTempOrderOptions {
|
|
|
449
449
|
recalculateSummary?: boolean;
|
|
450
450
|
persist?: boolean;
|
|
451
451
|
saveDraft?: boolean;
|
|
452
|
+
/** Internal same-order updates may explicitly retain an anonymous order's session. */
|
|
453
|
+
preserveOrderSessionId?: string;
|
|
454
|
+
}
|
|
455
|
+
export interface OrderSessionChangedPayload {
|
|
456
|
+
sessionId: string | null;
|
|
457
|
+
previousSessionId: string | null;
|
|
458
|
+
}
|
|
459
|
+
export interface HydrateTempOrderOptions {
|
|
460
|
+
recalcOnHydrate?: boolean;
|
|
461
|
+
source?: 'salesDetail' | 'mergedSalesDetail' | 'sessionStorage';
|
|
462
|
+
preserveOrderSessionId?: string;
|
|
452
463
|
}
|
|
453
464
|
export type AddProductBookingInput = Record<string, any>;
|
|
454
465
|
/**
|
|
@@ -869,6 +880,10 @@ export interface OrderModuleAPI {
|
|
|
869
880
|
salesSummaryModuleName?: string;
|
|
870
881
|
}) => void;
|
|
871
882
|
getTempOrder: () => OrderTempOrder | null;
|
|
883
|
+
/** Runtime-only identity; never part of an order or a persisted draft. */
|
|
884
|
+
getOrderSessionId: () => string | null;
|
|
885
|
+
/** Also rejects a session while an asynchronous order replacement is pending. */
|
|
886
|
+
isOrderSessionCurrent: (sessionId: string) => boolean;
|
|
872
887
|
ensureTempOrder: () => OrderTempOrder;
|
|
873
888
|
replaceTempOrder: (tempOrder: OrderTempOrder, options?: ReplaceTempOrderOptions) => Promise<OrderTempOrder>;
|
|
874
889
|
addNewOrder: () => Promise<OrderTempOrder>;
|
|
@@ -999,10 +1014,7 @@ export interface OrderModuleAPI {
|
|
|
999
1014
|
}) => OrderPaymentData[];
|
|
1000
1015
|
sendCustomerPayLink: <T = any>(params: SendCustomerPayLinkParams) => Promise<T>;
|
|
1001
1016
|
saveDraft: () => Promise<void>;
|
|
1002
|
-
hydrateTempOrderFromRecord: (record: Record<string, any>, options?:
|
|
1003
|
-
recalcOnHydrate?: boolean;
|
|
1004
|
-
source?: 'salesDetail' | 'mergedSalesDetail' | 'sessionStorage';
|
|
1005
|
-
}) => Promise<OrderTempOrder>;
|
|
1017
|
+
hydrateTempOrderFromRecord: (record: Record<string, any>, options?: HydrateTempOrderOptions) => Promise<OrderTempOrder>;
|
|
1006
1018
|
syncPaymentsToOrder: <T = any>(params: SyncPaymentsToOrderParams) => Promise<SyncPaymentsToOrderResult<T>>;
|
|
1007
1019
|
getSalesOrderByLookup: (params: SalesOrderLookupParams) => Promise<any>;
|
|
1008
1020
|
getLastOrderInfo: () => Record<string, any> | undefined;
|
|
@@ -128,9 +128,7 @@ export declare function getBundleSellingMagnitude(bundle: Record<string, any> |
|
|
|
128
128
|
*
|
|
129
129
|
* Rules 钩子契约(hook_adapt 方案,Rules 内部保持不变):
|
|
130
130
|
* - `getProduct.price` / `getProduct.original_price` 回传 **source-level 主价**
|
|
131
|
-
* (`metadata.source_product_price
|
|
132
|
-
* 赠品基础价已被赠送优惠抵扣,只有收费 option / bundle 继续按卡券规则计算。
|
|
133
|
-
* Rules 内部 `getProductTotalPrice` /
|
|
131
|
+
* (`metadata.source_product_price`)。Rules 内部 `getProductTotalPrice` /
|
|
134
132
|
* `getProductOriginTotalPrice` 会自行叠加 option + bundle,喂 source 可避免 option 双加。
|
|
135
133
|
* - `getProduct.total` = `selling_price × num`(行 composite × num),与 Rules 内部产出的
|
|
136
134
|
* total(source + option + bundle)对齐。
|
|
@@ -651,9 +651,7 @@ function getBundleSellingMagnitude(bundle) {
|
|
|
651
651
|
*
|
|
652
652
|
* Rules 钩子契约(hook_adapt 方案,Rules 内部保持不变):
|
|
653
653
|
* - `getProduct.price` / `getProduct.original_price` 回传 **source-level 主价**
|
|
654
|
-
* (`metadata.source_product_price
|
|
655
|
-
* 赠品基础价已被赠送优惠抵扣,只有收费 option / bundle 继续按卡券规则计算。
|
|
656
|
-
* Rules 内部 `getProductTotalPrice` /
|
|
654
|
+
* (`metadata.source_product_price`)。Rules 内部 `getProductTotalPrice` /
|
|
657
655
|
* `getProductOriginTotalPrice` 会自行叠加 option + bundle,喂 source 可避免 option 双加。
|
|
658
656
|
* - `getProduct.total` = `selling_price × num`(行 composite × num),与 Rules 内部产出的
|
|
659
657
|
* total(source + option + bundle)对齐。
|
|
@@ -936,8 +934,7 @@ function createDefaultOrderRulesHooks(getBookings, getHolderRelations) {
|
|
|
936
934
|
_id: product.metadata?.unique_identification_number ? `${product.product_id}_${product.product_variant_id}_${product.metadata.unique_identification_number}` : `${product.product_id}_${product.product_variant_id}_${(0, _utils2.buildProductLineFingerprint)(getProductSkuOptions(product), product.product_bundle)}`,
|
|
937
935
|
// Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
|
|
938
936
|
// 所以这里必须喂 source-level(不含 option、不含 bundle、不含折扣)单价,避免双加 option。
|
|
939
|
-
|
|
940
|
-
price: metadataAny._giftInfo ? '0.00' : sourcePrice,
|
|
937
|
+
price: sourcePrice,
|
|
941
938
|
// total / origin_total 使用 composite × num,跟 Rules 内部产出的 total 对齐(含 option + bundle)。
|
|
942
939
|
total: new _decimal.default(product.selling_price || 0).times(product.num || 1).toNumber(),
|
|
943
940
|
origin_total: new _decimal.default(product.original_price || product.selling_price || 0).times(product.num || 1).toNumber(),
|
|
@@ -225,6 +225,16 @@ function isCandidateFromExcludedScheduleDate(params) {
|
|
|
225
225
|
}
|
|
226
226
|
return getSessionRangesForProduct(projection, product, candidateDateRange, true).some(range => getProductTimeRangeIdentity(range) === candidateIdentity);
|
|
227
227
|
}
|
|
228
|
+
function resolveRememberedDurationRange(product, value, timezoneName) {
|
|
229
|
+
if (value === undefined) return null;
|
|
230
|
+
const range = normalizeAbsoluteRange(value, timezoneName);
|
|
231
|
+
if (!range || range.end <= range.start) {
|
|
232
|
+
throw availabilityError('INVALID_TARGET_FILTER', '记忆时间必须包含有效且递增的开始和结束时间');
|
|
233
|
+
}
|
|
234
|
+
if (product.kind !== 'duration') return null;
|
|
235
|
+
if (!product.isFlexibleDuration && (!Number.isFinite(product.durationMinutes) || range.end - range.start !== Number(product.durationMinutes) * 60000)) return null;
|
|
236
|
+
return range;
|
|
237
|
+
}
|
|
228
238
|
function evaluateCandidateTimeGate(params) {
|
|
229
239
|
const {
|
|
230
240
|
projection,
|
|
@@ -298,6 +308,10 @@ function evaluateCandidateTimeGate(params) {
|
|
|
298
308
|
};
|
|
299
309
|
}
|
|
300
310
|
if (policy.type === 'before_start') {
|
|
311
|
+
const rememberedRange = resolveRememberedDurationRange(product, evaluationContext.rememberedTimeByProductId?.[String(product.id)], timezoneName);
|
|
312
|
+
// Only the exact order-scoped interval may retain its start after this
|
|
313
|
+
// cutoff. The end/past and operating-window gates above still apply.
|
|
314
|
+
if (rememberedRange?.start === candidateRange.start && rememberedRange.end === candidateRange.end) return null;
|
|
301
315
|
// POS fixed-duration candidates use the context's stable opening-minute
|
|
302
316
|
// anchor. Keep that anchored range selectable while it is still active;
|
|
303
317
|
// otherwise a minute refresh turns it into 0 capacity and incorrectly
|
|
@@ -1143,6 +1157,12 @@ function getAlignedDurationRanges(params) {
|
|
|
1143
1157
|
addRange(start, start + duration * 60000);
|
|
1144
1158
|
}
|
|
1145
1159
|
}
|
|
1160
|
+
const rememberedRange = resolveRememberedDurationRange(product, request.rememberedTimeByProductId?.[String(product.id)], projection.meta.timezone);
|
|
1161
|
+
if (rememberedRange && baseRanges.some(range => contains(range, rememberedRange))) {
|
|
1162
|
+
// Never extend a remembered flexible interval when the resource now has a
|
|
1163
|
+
// later closing time, or rebuild a fixed interval after its duration changed.
|
|
1164
|
+
addRange(rememberedRange.start, rememberedRange.end);
|
|
1165
|
+
}
|
|
1146
1166
|
const editingAt = request.editingStartAtByProductId?.[String(product.id)];
|
|
1147
1167
|
if (editingAt !== undefined) {
|
|
1148
1168
|
const start = toDateTime(editingAt);
|
|
@@ -1476,7 +1496,8 @@ function buildEvaluationContext(params) {
|
|
|
1476
1496
|
durationCandidateAnchorAtMs: Number.isFinite(durationCandidateAnchorAt) ? floorToMinute(durationCandidateAnchorAt) : null,
|
|
1477
1497
|
allowExcludedScheduleDateOverride: params.allowExcludedScheduleDateOverride === true,
|
|
1478
1498
|
useDurationTimeGrid: params.useDurationTimeGrid === true,
|
|
1479
|
-
enforceSaleCutoff: params.enforceSaleCutoff === true
|
|
1499
|
+
enforceSaleCutoff: params.enforceSaleCutoff === true,
|
|
1500
|
+
rememberedTimeByProductId: params.rememberedTimeByProductId
|
|
1480
1501
|
};
|
|
1481
1502
|
}
|
|
1482
1503
|
function summarizeStatuses(statuses) {
|
|
@@ -1885,6 +1906,7 @@ function queryAvailabilityProjection(projection, request, runtimeOptions = {}) {
|
|
|
1885
1906
|
resourceIds: request.resourceIds,
|
|
1886
1907
|
useDurationTimeGrid: runtimeOptions.useDurationTimeGrid,
|
|
1887
1908
|
enforceSaleCutoff: runtimeOptions.enforceSaleCutoff,
|
|
1909
|
+
rememberedTimeByProductId: runtimeOptions.rememberedTimeByProductId,
|
|
1888
1910
|
useExactDurationCandidateMinute: runtimeOptions.useExactDurationCandidateMinute,
|
|
1889
1911
|
allowExcludedScheduleDateOverride: runtimeOptions.allowExcludedScheduleDateOverride
|
|
1890
1912
|
});
|
|
@@ -1963,6 +1985,7 @@ function queryAvailabilityProjection(projection, request, runtimeOptions = {}) {
|
|
|
1963
1985
|
evaluatedAt,
|
|
1964
1986
|
useDurationTimeGrid: runtimeOptions.useDurationTimeGrid,
|
|
1965
1987
|
enforceSaleCutoff: runtimeOptions.enforceSaleCutoff,
|
|
1988
|
+
rememberedTimeByProductId: runtimeOptions.rememberedTimeByProductId,
|
|
1966
1989
|
useExactDurationCandidateMinute: runtimeOptions.useExactDurationCandidateMinute,
|
|
1967
1990
|
allowExcludedScheduleDateOverride: runtimeOptions.allowExcludedScheduleDateOverride
|
|
1968
1991
|
});
|
|
@@ -2165,6 +2188,7 @@ function validateAvailabilitySelection(projection, params, runtimeOptions = {})
|
|
|
2165
2188
|
requirementSelections: params.requirementSelections,
|
|
2166
2189
|
useDurationTimeGrid: runtimeOptions.useDurationTimeGrid,
|
|
2167
2190
|
enforceSaleCutoff: runtimeOptions.enforceSaleCutoff,
|
|
2191
|
+
rememberedTimeByProductId: runtimeOptions.rememberedTimeByProductId,
|
|
2168
2192
|
useExactDurationCandidateMinute: runtimeOptions.useExactDurationCandidateMinute,
|
|
2169
2193
|
allowExcludedScheduleDateOverride: runtimeOptions.allowExcludedScheduleDateOverride
|
|
2170
2194
|
})
|
|
@@ -265,6 +265,10 @@ export interface GetProductTimeRangesRequest {
|
|
|
265
265
|
durationStartTimesByProductId?: Record<string, string[]>;
|
|
266
266
|
/** Restore only the exact remembered start; recompute the end from current product/windows. */
|
|
267
267
|
rememberedStartAtByProductId?: Record<string, string>;
|
|
268
|
+
/** Order-scoped v2 memory preserves the complete actual booking interval. */
|
|
269
|
+
rememberedTimeByProductId?: Record<string, AvailabilityAbsoluteRange>;
|
|
270
|
+
/** Required by the POS facade before accepting v2 remembered intervals. */
|
|
271
|
+
orderSessionId?: string;
|
|
268
272
|
/** Edit only: preserve the full actual start plus an explicit durationMinutesByProductId. */
|
|
269
273
|
editingStartAtByProductId?: Record<string, string>;
|
|
270
274
|
/**
|
|
@@ -279,6 +283,8 @@ export interface GetProductTimeRangesRuntimeOptions {
|
|
|
279
283
|
useDurationTimeGrid?: boolean;
|
|
280
284
|
/** Automatic remembered selection must not use POS opening-minute cutoff exceptions. */
|
|
281
285
|
enforceSaleCutoff?: boolean;
|
|
286
|
+
/** Internal POS capability, validated against the current order session by the facade. */
|
|
287
|
+
rememberedTimeByProductId?: Record<string, AvailabilityAbsoluteRange>;
|
|
282
288
|
/**
|
|
283
289
|
* Internal POS capability: fixed-duration candidates start from the stable
|
|
284
290
|
* context anchor's current minute instead of rounding up to ten minutes, and
|