@pisell/pisellos 2.3.205 → 2.3.206
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/ResourcePlanner/planner.js +1 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts +3 -1
- package/dist/solution/UnifiedBookingSales/index.js +275 -158
- package/dist/solution/UnifiedBookingSales/types.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/ResourcePlanner/planner.js +1 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +3 -1
- package/lib/solution/UnifiedBookingSales/index.js +98 -17
- package/lib/solution/UnifiedBookingSales/types.d.ts +4 -0
- package/package.json +1 -1
|
@@ -151,6 +151,8 @@ export type ContextualAvailabilityQuery = (Omit<Extract<AvailabilityQuery, {
|
|
|
151
151
|
target: 'resource';
|
|
152
152
|
}>, 'selectedRanges'> & {
|
|
153
153
|
selectedRanges: ContextualProductTimeRange[];
|
|
154
|
+
/** PC/H5 only: retain the already-selected time while choosing resources in this snapshot. */
|
|
155
|
+
customerSelectionSnapshot?: boolean;
|
|
154
156
|
})) & {
|
|
155
157
|
/** Automatic remembered selection must not inherit POS manual exceptions. */
|
|
156
158
|
selectionIntent?: 'remembered' | 'manual';
|
|
@@ -221,6 +223,8 @@ export interface UnifiedBookingSalesAddRetailProductParams {
|
|
|
221
223
|
}
|
|
222
224
|
export interface ContextualCommitAvailabilitySelectionParams {
|
|
223
225
|
mode: 'add' | 'edit' | 'replace';
|
|
226
|
+
/** PC/H5 only: write the completed UI selection without re-querying availability; checkout is authoritative. */
|
|
227
|
+
customerSelectionSnapshot?: boolean;
|
|
224
228
|
/** Only POS duration add supports automatic remembered-time commits. */
|
|
225
229
|
selectionIntent?: 'remembered' | 'manual';
|
|
226
230
|
/** v2 remembered commits must still belong to the order that saved the interval. */
|
|
@@ -1,46 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _examples.BUY_X_GET_Y_FREE_STRATEGY;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _examples.ITEM_REWARD_STRATEGY;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "PromotionAdapter", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _adapter.PromotionAdapter;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "PromotionEvaluator", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _evaluator.PromotionEvaluator;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "default", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _adapter.default;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
var _evaluator = require("./evaluator");
|
|
43
|
-
var _adapter = _interopRequireWildcard(require("./adapter"));
|
|
44
|
-
var _examples = require("./examples");
|
|
45
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
1
|
+
"use strict";
|
|
@@ -1906,7 +1906,7 @@ function assertRangesWithinProjection(projection, ranges) {
|
|
|
1906
1906
|
}
|
|
1907
1907
|
function queryAvailabilityProjection(projection, request, runtimeOptions = {}) {
|
|
1908
1908
|
const normalizedPartySize = normalizePartySize(request.partySize);
|
|
1909
|
-
const evaluatedAt = formatDateTime((0, _localClock.localDateToScalar)(new Date()), projection.meta.timezone, (0, _localClock.extractFixedOffsetMinutes)(projection.meta.now) ?? (0, _localClock.captureRuntimeOffsetMinutes)());
|
|
1909
|
+
const evaluatedAt = runtimeOptions.evaluatedAt || formatDateTime((0, _localClock.localDateToScalar)(new Date()), projection.meta.timezone, (0, _localClock.extractFixedOffsetMinutes)(projection.meta.now) ?? (0, _localClock.captureRuntimeOffsetMinutes)());
|
|
1910
1910
|
if (request.target === 'time') {
|
|
1911
1911
|
assertTimeCandidates(request);
|
|
1912
1912
|
assertRangesWithinProjection(projection, request.candidates);
|
|
@@ -361,6 +361,8 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
361
361
|
private buildAvailabilityProjectionSnapshot;
|
|
362
362
|
private getSharedPreparedAvailabilitySnapshot;
|
|
363
363
|
private refreshAvailabilityContextProjection;
|
|
364
|
+
/** Read an existing customer selection without refreshing its clock or occupancy snapshot. */
|
|
365
|
+
private getCustomerSelectionProjection;
|
|
364
366
|
private ensureAvailabilityContextProjection;
|
|
365
367
|
private tryAcquireAvailabilityCommitLock;
|
|
366
368
|
private releaseAvailabilityCommitLock;
|
|
@@ -377,7 +379,7 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
377
379
|
private findProductLineByUid;
|
|
378
380
|
private findLinkedBooking;
|
|
379
381
|
removeBookingProductsOutsideStartDate(startDate: unknown): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
380
|
-
/**
|
|
382
|
+
/** Customer snapshot writes defer availability to checkout; other callers retain cache revalidation. */
|
|
381
383
|
commitAvailabilitySelection(contextId: string, params: ContextualCommitAvailabilitySelectionParams): Promise<UnifiedBookingSalesCommitAvailabilitySelectionResult>;
|
|
382
384
|
}
|
|
383
385
|
export declare const UnifiedBookingSales: typeof UnifiedBookingSalesImpl;
|
|
@@ -1187,6 +1187,12 @@ function buildPosForcedAvailabilityAssignments(params) {
|
|
|
1187
1187
|
}
|
|
1188
1188
|
selectedResourceIds.forEach(resourceId => {
|
|
1189
1189
|
if (sameAvailabilityId(resourceId, POS_NO_RESOURCE_ID)) {
|
|
1190
|
+
if (params.allowNoResource === false) {
|
|
1191
|
+
addConflict('resource_unavailable', '必须选择当前商品的有效资源', {
|
|
1192
|
+
resourceId
|
|
1193
|
+
});
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1190
1196
|
assignments.push({
|
|
1191
1197
|
productId: product.id,
|
|
1192
1198
|
resourceId: POS_NO_RESOURCE_ID,
|
|
@@ -1233,6 +1239,45 @@ function buildPosForcedAvailabilityAssignments(params) {
|
|
|
1233
1239
|
conflicts
|
|
1234
1240
|
};
|
|
1235
1241
|
}
|
|
1242
|
+
|
|
1243
|
+
/** Structural conversion only. The customer has already picked a time and resources in the UI. */
|
|
1244
|
+
function acceptCustomerSelectionSnapshot(params) {
|
|
1245
|
+
const {
|
|
1246
|
+
candidate
|
|
1247
|
+
} = params;
|
|
1248
|
+
try {
|
|
1249
|
+
const start = (0, _localClock.localDateTimeToScalar)((0, _localClock.parseLocalDateTime)(candidate.startAt));
|
|
1250
|
+
const end = (0, _localClock.localDateTimeToScalar)((0, _localClock.parseLocalDateTime)(candidate.endAt));
|
|
1251
|
+
const bookingStart = (0, _localClock.localDateTimeToScalar)((0, _localClock.parseLocalDateTime)(candidate.bookingStartAt));
|
|
1252
|
+
const bookingEnd = (0, _localClock.localDateTimeToScalar)((0, _localClock.parseLocalDateTime)(candidate.bookingEndAt));
|
|
1253
|
+
if (end <= start || bookingEnd <= bookingStart) throw new Error('invalid interval');
|
|
1254
|
+
} catch {
|
|
1255
|
+
throw new _ResourcePlanner.AvailabilityError('INVALID_TARGET_FILTER', '所选时间必须是有效且递增的区间');
|
|
1256
|
+
}
|
|
1257
|
+
const {
|
|
1258
|
+
assignments,
|
|
1259
|
+
conflicts
|
|
1260
|
+
} = buildPosForcedAvailabilityAssignments({
|
|
1261
|
+
...params,
|
|
1262
|
+
allowNoResource: false
|
|
1263
|
+
});
|
|
1264
|
+
// Preserve the original time-card snapshot for callers; do not query current availability here.
|
|
1265
|
+
const display = candidate;
|
|
1266
|
+
const availability = {
|
|
1267
|
+
...candidate,
|
|
1268
|
+
status: display.status || 'available',
|
|
1269
|
+
maxPartySize: display.maxPartySize ?? params.partySize,
|
|
1270
|
+
reasonCodes: display.reasonCodes || [],
|
|
1271
|
+
requirementGroups: display.requirementGroups || []
|
|
1272
|
+
};
|
|
1273
|
+
return {
|
|
1274
|
+
ok: conflicts.length === 0,
|
|
1275
|
+
status: availability.status,
|
|
1276
|
+
assignments,
|
|
1277
|
+
conflicts,
|
|
1278
|
+
availability
|
|
1279
|
+
};
|
|
1280
|
+
}
|
|
1236
1281
|
class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
1237
1282
|
defaultName = 'unifiedBookingSales';
|
|
1238
1283
|
defaultVersion = '1.0.0';
|
|
@@ -4346,6 +4391,18 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4346
4391
|
}
|
|
4347
4392
|
}
|
|
4348
4393
|
}
|
|
4394
|
+
|
|
4395
|
+
/** Read an existing customer selection without refreshing its clock or occupancy snapshot. */
|
|
4396
|
+
getCustomerSelectionProjection(contextId) {
|
|
4397
|
+
const context = this.getAvailabilityContextEntry(contextId);
|
|
4398
|
+
const projectionEntry = this.getActiveAvailabilityProjectionEntry(context);
|
|
4399
|
+
if (!projectionEntry) throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', '所选商品上下文已关闭,请重新打开商品');
|
|
4400
|
+
return {
|
|
4401
|
+
context,
|
|
4402
|
+
projectionEntry,
|
|
4403
|
+
refreshed: false
|
|
4404
|
+
};
|
|
4405
|
+
}
|
|
4349
4406
|
async ensureAvailabilityContextProjection(contextId, reason) {
|
|
4350
4407
|
let retries = 0;
|
|
4351
4408
|
while (retries < 3) {
|
|
@@ -4554,11 +4611,12 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4554
4611
|
|
|
4555
4612
|
/** Thin facade: auto-refresh on cart drift, then delegate to the pure projection query. */
|
|
4556
4613
|
async queryBookingAvailability(contextId, request) {
|
|
4614
|
+
const customerSelectionSnapshot = request.target === 'resource' && request.customerSelectionSnapshot === true && (0, _platform.isCustomerUserPlatform)(this.otherParams?.platform);
|
|
4557
4615
|
const {
|
|
4558
4616
|
context,
|
|
4559
4617
|
projectionEntry,
|
|
4560
4618
|
refreshed
|
|
4561
|
-
} = await this.ensureAvailabilityContextProjection(contextId, 'query_booking_availability');
|
|
4619
|
+
} = customerSelectionSnapshot ? this.getCustomerSelectionProjection(contextId) : await this.ensureAvailabilityContextProjection(contextId, 'query_booking_availability');
|
|
4562
4620
|
this.assertContextualQueryFreshness(context, request);
|
|
4563
4621
|
const strictAvailability = context.prepareParams.strictAvailability === true;
|
|
4564
4622
|
const isPosAvailabilityRequest = String(this.otherParams?.platform ?? '').trim().toLowerCase() === 'pos';
|
|
@@ -4568,6 +4626,9 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4568
4626
|
dateRange: request.dateRange || this.getAvailabilityBusinessDateRange(projectionEntry.projection)
|
|
4569
4627
|
} : request;
|
|
4570
4628
|
const result = (0, _ResourcePlanner.queryAvailabilityProjection)(projectionEntry.projection, queryRequest, {
|
|
4629
|
+
...(customerSelectionSnapshot ? {
|
|
4630
|
+
evaluatedAt: projectionEntry.projection.meta.now
|
|
4631
|
+
} : {}),
|
|
4571
4632
|
useDurationTimeGrid: this.usesDurationTimeGrid(projectionEntry.projection),
|
|
4572
4633
|
enforceSaleCutoff: strictAvailability || isPosAvailabilityRequest && !context.prepareParams.editingProductLineUids?.length && request.selectionIntent === 'remembered',
|
|
4573
4634
|
rememberedTimeByProductId,
|
|
@@ -4683,7 +4744,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4683
4744
|
return identities.length ? this.removeProductsFromOrder(identities) : products;
|
|
4684
4745
|
}
|
|
4685
4746
|
|
|
4686
|
-
/**
|
|
4747
|
+
/** Customer snapshot writes defer availability to checkout; other callers retain cache revalidation. */
|
|
4687
4748
|
async commitAvailabilitySelection(contextId, params) {
|
|
4688
4749
|
const normalizedContextId = String(contextId || '').trim();
|
|
4689
4750
|
if (!normalizedContextId) {
|
|
@@ -4714,8 +4775,9 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4714
4775
|
if (isRememberedSelection && (String(this.otherParams?.platform ?? '').trim().toLowerCase() !== 'pos' || params.mode !== 'add')) {
|
|
4715
4776
|
throw new _ResourcePlanner.AvailabilityError('INVALID_TARGET_FILTER', '记忆时间自动提交仅支持 POS 新增 duration 商品');
|
|
4716
4777
|
}
|
|
4778
|
+
const customerSelectionSnapshot = params.customerSelectionSnapshot === true && (0, _platform.isCustomerUserPlatform)(this.otherParams?.platform);
|
|
4717
4779
|
const strictAvailability = this.availabilityContextRegistry.get(normalizedContextId)?.prepareParams.strictAvailability === true;
|
|
4718
|
-
const hasCommitGuard = strictAvailability || isRememberedSelection || isPartyReplacement || Boolean(params.availabilityCommitGuard);
|
|
4780
|
+
const hasCommitGuard = customerSelectionSnapshot || strictAvailability || isRememberedSelection || isPartyReplacement || Boolean(params.availabilityCommitGuard);
|
|
4719
4781
|
params.availabilityCommitGuard?.();
|
|
4720
4782
|
// Stabilize the locally generated sale identity before taking the guard snapshot.
|
|
4721
4783
|
if (hasCommitGuard) this.store.order?.ensureTempOrder?.();
|
|
@@ -4765,7 +4827,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4765
4827
|
context,
|
|
4766
4828
|
projectionEntry,
|
|
4767
4829
|
refreshed
|
|
4768
|
-
} = await this.ensureAvailabilityContextProjection(normalizedContextId, 'commit_precheck');
|
|
4830
|
+
} = customerSelectionSnapshot ? this.getCustomerSelectionProjection(normalizedContextId) : await this.ensureAvailabilityContextProjection(normalizedContextId, 'commit_precheck');
|
|
4769
4831
|
if (refreshed) {
|
|
4770
4832
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
|
|
4771
4833
|
contextId: normalizedContextId,
|
|
@@ -4795,7 +4857,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4795
4857
|
projectionContextVersion: projectionEntry.contextVersion
|
|
4796
4858
|
});
|
|
4797
4859
|
}
|
|
4798
|
-
if (projectionEntry.orderRevision !== this.getCurrentOrderRevision()) {
|
|
4860
|
+
if (!customerSelectionSnapshot && projectionEntry.orderRevision !== this.getCurrentOrderRevision()) {
|
|
4799
4861
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '购物车已变化,请重新获取候选', {
|
|
4800
4862
|
contextId: normalizedContextId,
|
|
4801
4863
|
currentContextVersion: context.activeVersion,
|
|
@@ -4849,18 +4911,22 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4849
4911
|
expectedVersion: context.activeVersion,
|
|
4850
4912
|
expectedRefreshNonce: context.refreshNonce,
|
|
4851
4913
|
expectedLifecycleGeneration: this.availabilityLifecycleGeneration,
|
|
4852
|
-
expectedOrderRevision: String(baseProjection.meta.orderRevision ?? '')
|
|
4914
|
+
expectedOrderRevision: customerSelectionSnapshot ? this.getCurrentOrderRevision() : String(baseProjection.meta.orderRevision ?? '')
|
|
4853
4915
|
};
|
|
4854
4916
|
const prepareParams = baseProjection.meta.prepareParams;
|
|
4855
4917
|
if (!prepareParams) {
|
|
4856
4918
|
throw new _ResourcePlanner.AvailabilityError('REVALIDATION_FAILED', 'projection 缺少 prepareParams,无法执行缓存重校验');
|
|
4857
4919
|
}
|
|
4858
|
-
const fallbackResources = {
|
|
4920
|
+
const fallbackResources = customerSelectionSnapshot ? undefined : {
|
|
4859
4921
|
resources: (0, _lodashEs.cloneDeep)([...(baseProjection.resources || [])]),
|
|
4860
4922
|
resourceOccupancies: (0, _lodashEs.cloneDeep)([...(baseProjection.resourceOccupancies || [])].filter(occupancy => occupancy.source !== 'cart')),
|
|
4861
4923
|
includesInjectedRawOccupancies: true
|
|
4862
4924
|
};
|
|
4863
|
-
const commitSnapshot =
|
|
4925
|
+
const commitSnapshot = customerSelectionSnapshot ? {
|
|
4926
|
+
projection: baseProjection,
|
|
4927
|
+
prepareParams,
|
|
4928
|
+
orderRevision: commitWriteGuard.expectedOrderRevision
|
|
4929
|
+
} : await this.buildAvailabilityProjectionSnapshot({
|
|
4864
4930
|
...this.cloneAvailabilityPrepareParams(prepareParams),
|
|
4865
4931
|
editingProductLineUids: isEditingSelection && params.productLineUid ? [params.productLineUid] : []
|
|
4866
4932
|
}, {
|
|
@@ -4869,7 +4935,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4869
4935
|
durationCandidateAnchorAt: this.getAvailabilityDurationCandidateAnchorAt(baseProjection) || context.durationCandidateAnchorAt
|
|
4870
4936
|
});
|
|
4871
4937
|
const refreshedProjection = commitSnapshot.projection;
|
|
4872
|
-
if (String(refreshedProjection.meta.orderRevision ?? '') !== String(baseProjection.meta.orderRevision ?? '')) {
|
|
4938
|
+
if (!customerSelectionSnapshot && String(refreshedProjection.meta.orderRevision ?? '') !== String(baseProjection.meta.orderRevision ?? '')) {
|
|
4873
4939
|
await this.refreshAvailabilityContextProjection({
|
|
4874
4940
|
contextId: normalizedContextId,
|
|
4875
4941
|
reason: 'commit_order_revision_changed',
|
|
@@ -4897,7 +4963,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4897
4963
|
endAt: params.candidate.bookingEndAt
|
|
4898
4964
|
}
|
|
4899
4965
|
}, params.orderSessionId) : undefined;
|
|
4900
|
-
const refreshedRanges = (0, _ResourcePlanner.getProductTimeRanges)(refreshedProjection, {
|
|
4966
|
+
const refreshedRanges = customerSelectionSnapshot ? [params.candidate] : (0, _ResourcePlanner.getProductTimeRanges)(refreshedProjection, {
|
|
4901
4967
|
productIds: [params.candidate.productId],
|
|
4902
4968
|
dateRange: {
|
|
4903
4969
|
startDate: candidateBusinessDate,
|
|
@@ -4964,7 +5030,13 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4964
5030
|
productId: refreshedCandidateBase.productId
|
|
4965
5031
|
});
|
|
4966
5032
|
}
|
|
4967
|
-
let validation =
|
|
5033
|
+
let validation = customerSelectionSnapshot ? acceptCustomerSelectionSnapshot({
|
|
5034
|
+
candidate: params.candidate,
|
|
5035
|
+
product,
|
|
5036
|
+
resources: baseProjection.resources,
|
|
5037
|
+
requirementSelections: params.requirementSelections,
|
|
5038
|
+
partySize
|
|
5039
|
+
}) : (0, _ResourcePlanner.validateAvailabilitySelection)(refreshedProjection, {
|
|
4968
5040
|
candidate: refreshedCandidateBase,
|
|
4969
5041
|
requirementSelections: params.requirementSelections,
|
|
4970
5042
|
partySize,
|
|
@@ -5006,7 +5078,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
5006
5078
|
// Revalidation failure must leave the caller's candidate reusable. Only publish the
|
|
5007
5079
|
// refreshed projection/version after candidate and resource validation has passed;
|
|
5008
5080
|
// otherwise a second Confirm from the still-open modal would incorrectly become stale.
|
|
5009
|
-
const revalidationEntry = this.storeAvailabilityProjectionEntry({
|
|
5081
|
+
const revalidationEntry = customerSelectionSnapshot ? projectionEntry : this.storeAvailabilityProjectionEntry({
|
|
5010
5082
|
contextId: normalizedContextId,
|
|
5011
5083
|
prepareParams: commitSnapshot.prepareParams,
|
|
5012
5084
|
prepareKey: context.prepareKey,
|
|
@@ -5015,7 +5087,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
5015
5087
|
incrementVersion: true
|
|
5016
5088
|
});
|
|
5017
5089
|
const revalidatedContext = this.getAvailabilityContextEntry(normalizedContextId);
|
|
5018
|
-
await this.emitAvailabilityDiagnostic({
|
|
5090
|
+
if (!customerSelectionSnapshot) await this.emitAvailabilityDiagnostic({
|
|
5019
5091
|
action: 'refresh',
|
|
5020
5092
|
contextId: normalizedContextId,
|
|
5021
5093
|
contextVersion: revalidatedContext.activeVersion,
|
|
@@ -5030,7 +5102,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
5030
5102
|
expectedVersion: revalidatedContext.activeVersion,
|
|
5031
5103
|
expectedRefreshNonce: revalidatedContext.refreshNonce,
|
|
5032
5104
|
expectedLifecycleGeneration: this.availabilityLifecycleGeneration,
|
|
5033
|
-
expectedOrderRevision: revalidationEntry.orderRevision
|
|
5105
|
+
expectedOrderRevision: customerSelectionSnapshot ? commitWriteGuard.expectedOrderRevision : revalidationEntry.orderRevision
|
|
5034
5106
|
};
|
|
5035
5107
|
const refreshedCandidate = this.decorateAvailabilityCandidate(normalizedContextId, revalidatedContext.activeVersion, refreshedCandidateBase);
|
|
5036
5108
|
// Order may await line/runtime setup. Its guarded transaction invokes this
|
|
@@ -5044,7 +5116,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
5044
5116
|
// Same-order immutable snapshots and generated sale IDs preserve the session.
|
|
5045
5117
|
// Capture the actual object Order is about to publish, not an earlier snapshot.
|
|
5046
5118
|
if (isOrderRememberedSelection) rememberedOrder = this.getTempOrder();
|
|
5047
|
-
if (!isRememberedSelection && !strictAvailability) return;
|
|
5119
|
+
if (customerSelectionSnapshot || !isRememberedSelection && !strictAvailability) return;
|
|
5048
5120
|
const currentValidation = (0, _ResourcePlanner.validateAvailabilitySelection)(refreshedProjection, {
|
|
5049
5121
|
candidate: refreshedCandidateBase,
|
|
5050
5122
|
requirementSelections: params.requirementSelections,
|
|
@@ -5162,7 +5234,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
5162
5234
|
unique_identification_number: params.productLineUid,
|
|
5163
5235
|
booking_uid: existingBookingUid
|
|
5164
5236
|
};
|
|
5165
|
-
|
|
5237
|
+
const editParams = {
|
|
5166
5238
|
product_id: transformed.product_id ?? editingLine.product_id,
|
|
5167
5239
|
product_variant_id: transformed.product_variant_id ?? editingLine.product_variant_id ?? 0,
|
|
5168
5240
|
unique_identification_number: params.productLineUid,
|
|
@@ -5174,7 +5246,16 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
5174
5246
|
...(params.allowBookingDiscountReapply !== undefined ? {
|
|
5175
5247
|
allow_booking_discount_reapply: params.allowBookingDiscountReapply
|
|
5176
5248
|
} : {})
|
|
5177
|
-
}
|
|
5249
|
+
};
|
|
5250
|
+
if (customerSelectionSnapshot) {
|
|
5251
|
+
await this.updateOrderProducts([editParams], {
|
|
5252
|
+
beforeApply: availabilityCommitGuard,
|
|
5253
|
+
isCurrentOrder: availabilityCommitTargetGuard
|
|
5254
|
+
});
|
|
5255
|
+
guardedCommitPublished = true;
|
|
5256
|
+
} else {
|
|
5257
|
+
await this.updateOrderProduct(editParams);
|
|
5258
|
+
}
|
|
5178
5259
|
await this.removeBookingProductsOutsideStartDate(booking.start_date);
|
|
5179
5260
|
productLineUid = params.productLineUid;
|
|
5180
5261
|
bookingUid = existingBookingUid;
|
|
@@ -151,6 +151,8 @@ export type ContextualAvailabilityQuery = (Omit<Extract<AvailabilityQuery, {
|
|
|
151
151
|
target: 'resource';
|
|
152
152
|
}>, 'selectedRanges'> & {
|
|
153
153
|
selectedRanges: ContextualProductTimeRange[];
|
|
154
|
+
/** PC/H5 only: retain the already-selected time while choosing resources in this snapshot. */
|
|
155
|
+
customerSelectionSnapshot?: boolean;
|
|
154
156
|
})) & {
|
|
155
157
|
/** Automatic remembered selection must not inherit POS manual exceptions. */
|
|
156
158
|
selectionIntent?: 'remembered' | 'manual';
|
|
@@ -221,6 +223,8 @@ export interface UnifiedBookingSalesAddRetailProductParams {
|
|
|
221
223
|
}
|
|
222
224
|
export interface ContextualCommitAvailabilitySelectionParams {
|
|
223
225
|
mode: 'add' | 'edit' | 'replace';
|
|
226
|
+
/** PC/H5 only: write the completed UI selection without re-querying availability; checkout is authoritative. */
|
|
227
|
+
customerSelectionSnapshot?: boolean;
|
|
224
228
|
/** Only POS duration add supports automatic remembered-time commits. */
|
|
225
229
|
selectionIntent?: 'remembered' | 'manual';
|
|
226
230
|
/** v2 remembered commits must still belong to the order that saved the interval. */
|