@pisell/pisellos 2.3.205 → 2.3.207
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 +9 -0
- package/dist/modules/ResourcePlanner/planner.js +1 -1
- package/dist/server/index.js +26 -13
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +6 -5
- package/dist/solution/UnifiedBookingSales/index.d.ts +3 -1
- package/dist/solution/UnifiedBookingSales/index.js +309 -181
- 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/server/index.js +9 -4
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +2 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +3 -1
- package/lib/solution/UnifiedBookingSales/index.js +101 -19
- 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);
|
package/lib/server/index.js
CHANGED
|
@@ -3833,10 +3833,15 @@ class Server {
|
|
|
3833
3833
|
biz: next.business_code || 'ticket'
|
|
3834
3834
|
});
|
|
3835
3835
|
}
|
|
3836
|
-
if (needsShopFullOrderNumber
|
|
3837
|
-
next.
|
|
3838
|
-
|
|
3839
|
-
|
|
3836
|
+
if (needsShopFullOrderNumber) {
|
|
3837
|
+
const biz = next.business_code || 'ticket';
|
|
3838
|
+
if (idGenerator.getConfig?.(biz)?.enableShortNumber === false) {
|
|
3839
|
+
next.shop_full_order_number = next.shop_order_number;
|
|
3840
|
+
} else if (idGenerator.generateReceiptId) {
|
|
3841
|
+
next.shop_full_order_number = await idGenerator.generateReceiptId({
|
|
3842
|
+
biz
|
|
3843
|
+
});
|
|
3844
|
+
}
|
|
3840
3845
|
}
|
|
3841
3846
|
this.logInfo(`${title}: checkout 订单号已准备`, {
|
|
3842
3847
|
shop_order_number: next.shop_order_number,
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
date: string;
|
|
343
343
|
status: string;
|
|
344
344
|
week: string;
|
|
345
|
-
weekNum: 0 |
|
|
345
|
+
weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
|
|
346
346
|
}[]>;
|
|
347
347
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
348
348
|
private getScheduleDataByIds;
|
|
@@ -366,7 +366,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
366
366
|
* 获取当前的客户搜索条件
|
|
367
367
|
* @returns 当前搜索条件
|
|
368
368
|
*/
|
|
369
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
369
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
370
370
|
/**
|
|
371
371
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
372
372
|
* @returns 客户状态
|
|
@@ -385,6 +385,7 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
385
385
|
await idGenerator.configure({
|
|
386
386
|
biz: businessCode,
|
|
387
387
|
config: {
|
|
388
|
+
enableShortNumber: openDataConfig?.['sale.enable_short_number'] !== false,
|
|
388
389
|
prefix,
|
|
389
390
|
deviceCode: deviceId,
|
|
390
391
|
padReceiptSequence: openDataConfig?.['sale.pad_with_leading_zeros'] === true,
|
|
@@ -2077,7 +2078,7 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
2077
2078
|
if (invoiceContextChanged) {
|
|
2078
2079
|
await this.prepareInvoiceTemplateAtSolutionReady(Object.prototype.hasOwnProperty.call(params, 'openData') ? this.getInjectedOpenDataConfig() : undefined);
|
|
2079
2080
|
}
|
|
2080
|
-
if (params?.businessCode !== undefined || params?.business_code !== undefined) {
|
|
2081
|
+
if (params?.businessCode !== undefined || params?.business_code !== undefined || Object.prototype.hasOwnProperty.call(params ?? {}, 'openData')) {
|
|
2081
2082
|
await this.configureIdGeneratorFromOpenData();
|
|
2082
2083
|
}
|
|
2083
2084
|
}
|
|
@@ -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';
|
|
@@ -1956,7 +2001,8 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
1956
2001
|
const biz = this.getBookingTicketBusinessCode();
|
|
1957
2002
|
if (!biz) throw new Error('当前订单缺少业务类型,无法生成订单编号');
|
|
1958
2003
|
const idGenerator = this.appPlugin?.getApp?.()?.getPlugin?.('idGenerator');
|
|
1959
|
-
|
|
2004
|
+
const useLongNumber = idGenerator?.getConfig?.(biz)?.enableShortNumber === false;
|
|
2005
|
+
if (!tempOrder.shop_order_number && typeof idGenerator?.generateShopOrderNumber !== 'function' || !tempOrder.shop_full_order_number && !useLongNumber && typeof idGenerator?.generateReceiptId !== 'function') {
|
|
1960
2006
|
throw new Error('订单编号生成器不可用,请重启应用后重试');
|
|
1961
2007
|
}
|
|
1962
2008
|
try {
|
|
@@ -1966,7 +2012,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
1966
2012
|
});
|
|
1967
2013
|
}
|
|
1968
2014
|
if (!tempOrder.shop_full_order_number) {
|
|
1969
|
-
tempOrder.shop_full_order_number = await idGenerator.generateReceiptId({
|
|
2015
|
+
tempOrder.shop_full_order_number = useLongNumber ? tempOrder.shop_order_number : await idGenerator.generateReceiptId({
|
|
1970
2016
|
biz
|
|
1971
2017
|
});
|
|
1972
2018
|
}
|
|
@@ -4346,6 +4392,18 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4346
4392
|
}
|
|
4347
4393
|
}
|
|
4348
4394
|
}
|
|
4395
|
+
|
|
4396
|
+
/** Read an existing customer selection without refreshing its clock or occupancy snapshot. */
|
|
4397
|
+
getCustomerSelectionProjection(contextId) {
|
|
4398
|
+
const context = this.getAvailabilityContextEntry(contextId);
|
|
4399
|
+
const projectionEntry = this.getActiveAvailabilityProjectionEntry(context);
|
|
4400
|
+
if (!projectionEntry) throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', '所选商品上下文已关闭,请重新打开商品');
|
|
4401
|
+
return {
|
|
4402
|
+
context,
|
|
4403
|
+
projectionEntry,
|
|
4404
|
+
refreshed: false
|
|
4405
|
+
};
|
|
4406
|
+
}
|
|
4349
4407
|
async ensureAvailabilityContextProjection(contextId, reason) {
|
|
4350
4408
|
let retries = 0;
|
|
4351
4409
|
while (retries < 3) {
|
|
@@ -4554,11 +4612,12 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4554
4612
|
|
|
4555
4613
|
/** Thin facade: auto-refresh on cart drift, then delegate to the pure projection query. */
|
|
4556
4614
|
async queryBookingAvailability(contextId, request) {
|
|
4615
|
+
const customerSelectionSnapshot = request.target === 'resource' && request.customerSelectionSnapshot === true && (0, _platform.isCustomerUserPlatform)(this.otherParams?.platform);
|
|
4557
4616
|
const {
|
|
4558
4617
|
context,
|
|
4559
4618
|
projectionEntry,
|
|
4560
4619
|
refreshed
|
|
4561
|
-
} = await this.ensureAvailabilityContextProjection(contextId, 'query_booking_availability');
|
|
4620
|
+
} = customerSelectionSnapshot ? this.getCustomerSelectionProjection(contextId) : await this.ensureAvailabilityContextProjection(contextId, 'query_booking_availability');
|
|
4562
4621
|
this.assertContextualQueryFreshness(context, request);
|
|
4563
4622
|
const strictAvailability = context.prepareParams.strictAvailability === true;
|
|
4564
4623
|
const isPosAvailabilityRequest = String(this.otherParams?.platform ?? '').trim().toLowerCase() === 'pos';
|
|
@@ -4568,6 +4627,9 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4568
4627
|
dateRange: request.dateRange || this.getAvailabilityBusinessDateRange(projectionEntry.projection)
|
|
4569
4628
|
} : request;
|
|
4570
4629
|
const result = (0, _ResourcePlanner.queryAvailabilityProjection)(projectionEntry.projection, queryRequest, {
|
|
4630
|
+
...(customerSelectionSnapshot ? {
|
|
4631
|
+
evaluatedAt: projectionEntry.projection.meta.now
|
|
4632
|
+
} : {}),
|
|
4571
4633
|
useDurationTimeGrid: this.usesDurationTimeGrid(projectionEntry.projection),
|
|
4572
4634
|
enforceSaleCutoff: strictAvailability || isPosAvailabilityRequest && !context.prepareParams.editingProductLineUids?.length && request.selectionIntent === 'remembered',
|
|
4573
4635
|
rememberedTimeByProductId,
|
|
@@ -4683,7 +4745,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4683
4745
|
return identities.length ? this.removeProductsFromOrder(identities) : products;
|
|
4684
4746
|
}
|
|
4685
4747
|
|
|
4686
|
-
/**
|
|
4748
|
+
/** Customer snapshot writes defer availability to checkout; other callers retain cache revalidation. */
|
|
4687
4749
|
async commitAvailabilitySelection(contextId, params) {
|
|
4688
4750
|
const normalizedContextId = String(contextId || '').trim();
|
|
4689
4751
|
if (!normalizedContextId) {
|
|
@@ -4714,8 +4776,9 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4714
4776
|
if (isRememberedSelection && (String(this.otherParams?.platform ?? '').trim().toLowerCase() !== 'pos' || params.mode !== 'add')) {
|
|
4715
4777
|
throw new _ResourcePlanner.AvailabilityError('INVALID_TARGET_FILTER', '记忆时间自动提交仅支持 POS 新增 duration 商品');
|
|
4716
4778
|
}
|
|
4779
|
+
const customerSelectionSnapshot = params.customerSelectionSnapshot === true && (0, _platform.isCustomerUserPlatform)(this.otherParams?.platform);
|
|
4717
4780
|
const strictAvailability = this.availabilityContextRegistry.get(normalizedContextId)?.prepareParams.strictAvailability === true;
|
|
4718
|
-
const hasCommitGuard = strictAvailability || isRememberedSelection || isPartyReplacement || Boolean(params.availabilityCommitGuard);
|
|
4781
|
+
const hasCommitGuard = customerSelectionSnapshot || strictAvailability || isRememberedSelection || isPartyReplacement || Boolean(params.availabilityCommitGuard);
|
|
4719
4782
|
params.availabilityCommitGuard?.();
|
|
4720
4783
|
// Stabilize the locally generated sale identity before taking the guard snapshot.
|
|
4721
4784
|
if (hasCommitGuard) this.store.order?.ensureTempOrder?.();
|
|
@@ -4765,7 +4828,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4765
4828
|
context,
|
|
4766
4829
|
projectionEntry,
|
|
4767
4830
|
refreshed
|
|
4768
|
-
} = await this.ensureAvailabilityContextProjection(normalizedContextId, 'commit_precheck');
|
|
4831
|
+
} = customerSelectionSnapshot ? this.getCustomerSelectionProjection(normalizedContextId) : await this.ensureAvailabilityContextProjection(normalizedContextId, 'commit_precheck');
|
|
4769
4832
|
if (refreshed) {
|
|
4770
4833
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
|
|
4771
4834
|
contextId: normalizedContextId,
|
|
@@ -4795,7 +4858,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4795
4858
|
projectionContextVersion: projectionEntry.contextVersion
|
|
4796
4859
|
});
|
|
4797
4860
|
}
|
|
4798
|
-
if (projectionEntry.orderRevision !== this.getCurrentOrderRevision()) {
|
|
4861
|
+
if (!customerSelectionSnapshot && projectionEntry.orderRevision !== this.getCurrentOrderRevision()) {
|
|
4799
4862
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '购物车已变化,请重新获取候选', {
|
|
4800
4863
|
contextId: normalizedContextId,
|
|
4801
4864
|
currentContextVersion: context.activeVersion,
|
|
@@ -4849,18 +4912,22 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4849
4912
|
expectedVersion: context.activeVersion,
|
|
4850
4913
|
expectedRefreshNonce: context.refreshNonce,
|
|
4851
4914
|
expectedLifecycleGeneration: this.availabilityLifecycleGeneration,
|
|
4852
|
-
expectedOrderRevision: String(baseProjection.meta.orderRevision ?? '')
|
|
4915
|
+
expectedOrderRevision: customerSelectionSnapshot ? this.getCurrentOrderRevision() : String(baseProjection.meta.orderRevision ?? '')
|
|
4853
4916
|
};
|
|
4854
4917
|
const prepareParams = baseProjection.meta.prepareParams;
|
|
4855
4918
|
if (!prepareParams) {
|
|
4856
4919
|
throw new _ResourcePlanner.AvailabilityError('REVALIDATION_FAILED', 'projection 缺少 prepareParams,无法执行缓存重校验');
|
|
4857
4920
|
}
|
|
4858
|
-
const fallbackResources = {
|
|
4921
|
+
const fallbackResources = customerSelectionSnapshot ? undefined : {
|
|
4859
4922
|
resources: (0, _lodashEs.cloneDeep)([...(baseProjection.resources || [])]),
|
|
4860
4923
|
resourceOccupancies: (0, _lodashEs.cloneDeep)([...(baseProjection.resourceOccupancies || [])].filter(occupancy => occupancy.source !== 'cart')),
|
|
4861
4924
|
includesInjectedRawOccupancies: true
|
|
4862
4925
|
};
|
|
4863
|
-
const commitSnapshot =
|
|
4926
|
+
const commitSnapshot = customerSelectionSnapshot ? {
|
|
4927
|
+
projection: baseProjection,
|
|
4928
|
+
prepareParams,
|
|
4929
|
+
orderRevision: commitWriteGuard.expectedOrderRevision
|
|
4930
|
+
} : await this.buildAvailabilityProjectionSnapshot({
|
|
4864
4931
|
...this.cloneAvailabilityPrepareParams(prepareParams),
|
|
4865
4932
|
editingProductLineUids: isEditingSelection && params.productLineUid ? [params.productLineUid] : []
|
|
4866
4933
|
}, {
|
|
@@ -4869,7 +4936,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4869
4936
|
durationCandidateAnchorAt: this.getAvailabilityDurationCandidateAnchorAt(baseProjection) || context.durationCandidateAnchorAt
|
|
4870
4937
|
});
|
|
4871
4938
|
const refreshedProjection = commitSnapshot.projection;
|
|
4872
|
-
if (String(refreshedProjection.meta.orderRevision ?? '') !== String(baseProjection.meta.orderRevision ?? '')) {
|
|
4939
|
+
if (!customerSelectionSnapshot && String(refreshedProjection.meta.orderRevision ?? '') !== String(baseProjection.meta.orderRevision ?? '')) {
|
|
4873
4940
|
await this.refreshAvailabilityContextProjection({
|
|
4874
4941
|
contextId: normalizedContextId,
|
|
4875
4942
|
reason: 'commit_order_revision_changed',
|
|
@@ -4897,7 +4964,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4897
4964
|
endAt: params.candidate.bookingEndAt
|
|
4898
4965
|
}
|
|
4899
4966
|
}, params.orderSessionId) : undefined;
|
|
4900
|
-
const refreshedRanges = (0, _ResourcePlanner.getProductTimeRanges)(refreshedProjection, {
|
|
4967
|
+
const refreshedRanges = customerSelectionSnapshot ? [params.candidate] : (0, _ResourcePlanner.getProductTimeRanges)(refreshedProjection, {
|
|
4901
4968
|
productIds: [params.candidate.productId],
|
|
4902
4969
|
dateRange: {
|
|
4903
4970
|
startDate: candidateBusinessDate,
|
|
@@ -4964,7 +5031,13 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
4964
5031
|
productId: refreshedCandidateBase.productId
|
|
4965
5032
|
});
|
|
4966
5033
|
}
|
|
4967
|
-
let validation =
|
|
5034
|
+
let validation = customerSelectionSnapshot ? acceptCustomerSelectionSnapshot({
|
|
5035
|
+
candidate: params.candidate,
|
|
5036
|
+
product,
|
|
5037
|
+
resources: baseProjection.resources,
|
|
5038
|
+
requirementSelections: params.requirementSelections,
|
|
5039
|
+
partySize
|
|
5040
|
+
}) : (0, _ResourcePlanner.validateAvailabilitySelection)(refreshedProjection, {
|
|
4968
5041
|
candidate: refreshedCandidateBase,
|
|
4969
5042
|
requirementSelections: params.requirementSelections,
|
|
4970
5043
|
partySize,
|
|
@@ -5006,7 +5079,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
5006
5079
|
// Revalidation failure must leave the caller's candidate reusable. Only publish the
|
|
5007
5080
|
// refreshed projection/version after candidate and resource validation has passed;
|
|
5008
5081
|
// otherwise a second Confirm from the still-open modal would incorrectly become stale.
|
|
5009
|
-
const revalidationEntry = this.storeAvailabilityProjectionEntry({
|
|
5082
|
+
const revalidationEntry = customerSelectionSnapshot ? projectionEntry : this.storeAvailabilityProjectionEntry({
|
|
5010
5083
|
contextId: normalizedContextId,
|
|
5011
5084
|
prepareParams: commitSnapshot.prepareParams,
|
|
5012
5085
|
prepareKey: context.prepareKey,
|
|
@@ -5015,7 +5088,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
5015
5088
|
incrementVersion: true
|
|
5016
5089
|
});
|
|
5017
5090
|
const revalidatedContext = this.getAvailabilityContextEntry(normalizedContextId);
|
|
5018
|
-
await this.emitAvailabilityDiagnostic({
|
|
5091
|
+
if (!customerSelectionSnapshot) await this.emitAvailabilityDiagnostic({
|
|
5019
5092
|
action: 'refresh',
|
|
5020
5093
|
contextId: normalizedContextId,
|
|
5021
5094
|
contextVersion: revalidatedContext.activeVersion,
|
|
@@ -5030,7 +5103,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
5030
5103
|
expectedVersion: revalidatedContext.activeVersion,
|
|
5031
5104
|
expectedRefreshNonce: revalidatedContext.refreshNonce,
|
|
5032
5105
|
expectedLifecycleGeneration: this.availabilityLifecycleGeneration,
|
|
5033
|
-
expectedOrderRevision: revalidationEntry.orderRevision
|
|
5106
|
+
expectedOrderRevision: customerSelectionSnapshot ? commitWriteGuard.expectedOrderRevision : revalidationEntry.orderRevision
|
|
5034
5107
|
};
|
|
5035
5108
|
const refreshedCandidate = this.decorateAvailabilityCandidate(normalizedContextId, revalidatedContext.activeVersion, refreshedCandidateBase);
|
|
5036
5109
|
// Order may await line/runtime setup. Its guarded transaction invokes this
|
|
@@ -5044,7 +5117,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
5044
5117
|
// Same-order immutable snapshots and generated sale IDs preserve the session.
|
|
5045
5118
|
// Capture the actual object Order is about to publish, not an earlier snapshot.
|
|
5046
5119
|
if (isOrderRememberedSelection) rememberedOrder = this.getTempOrder();
|
|
5047
|
-
if (!isRememberedSelection && !strictAvailability) return;
|
|
5120
|
+
if (customerSelectionSnapshot || !isRememberedSelection && !strictAvailability) return;
|
|
5048
5121
|
const currentValidation = (0, _ResourcePlanner.validateAvailabilitySelection)(refreshedProjection, {
|
|
5049
5122
|
candidate: refreshedCandidateBase,
|
|
5050
5123
|
requirementSelections: params.requirementSelections,
|
|
@@ -5162,7 +5235,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
5162
5235
|
unique_identification_number: params.productLineUid,
|
|
5163
5236
|
booking_uid: existingBookingUid
|
|
5164
5237
|
};
|
|
5165
|
-
|
|
5238
|
+
const editParams = {
|
|
5166
5239
|
product_id: transformed.product_id ?? editingLine.product_id,
|
|
5167
5240
|
product_variant_id: transformed.product_variant_id ?? editingLine.product_variant_id ?? 0,
|
|
5168
5241
|
unique_identification_number: params.productLineUid,
|
|
@@ -5174,7 +5247,16 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
5174
5247
|
...(params.allowBookingDiscountReapply !== undefined ? {
|
|
5175
5248
|
allow_booking_discount_reapply: params.allowBookingDiscountReapply
|
|
5176
5249
|
} : {})
|
|
5177
|
-
}
|
|
5250
|
+
};
|
|
5251
|
+
if (customerSelectionSnapshot) {
|
|
5252
|
+
await this.updateOrderProducts([editParams], {
|
|
5253
|
+
beforeApply: availabilityCommitGuard,
|
|
5254
|
+
isCurrentOrder: availabilityCommitTargetGuard
|
|
5255
|
+
});
|
|
5256
|
+
guardedCommitPublished = true;
|
|
5257
|
+
} else {
|
|
5258
|
+
await this.updateOrderProduct(editParams);
|
|
5259
|
+
}
|
|
5178
5260
|
await this.removeBookingProductsOutsideStartDate(booking.start_date);
|
|
5179
5261
|
productLineUid = params.productLineUid;
|
|
5180
5262
|
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. */
|