@pisell/pisellos 0.10.73 → 0.10.75
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/Order/index.js +8 -7
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ProductList/clientDataVariants.js +6 -2
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.d.ts +1 -13
- package/dist/solution/UnifiedBookingSales/catalogQueryBatch.d.ts +21 -0
- package/dist/solution/UnifiedBookingSales/catalogQueryBatch.js +202 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +13 -1
- package/dist/solution/UnifiedBookingSales/index.js +875 -570
- package/dist/solution/UnifiedBookingSales/types.d.ts +25 -1
- package/dist/solution/UnifiedBookingSales/types.js +5 -1
- package/lib/modules/Order/index.js +4 -3
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ProductList/clientDataVariants.js +6 -2
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.d.ts +1 -13
- package/lib/solution/UnifiedBookingSales/catalogQueryBatch.d.ts +21 -0
- package/lib/solution/UnifiedBookingSales/catalogQueryBatch.js +109 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +13 -1
- package/lib/solution/UnifiedBookingSales/index.js +219 -7
- package/lib/solution/UnifiedBookingSales/types.d.ts +25 -1
- package/lib/solution/UnifiedBookingSales/types.js +3 -1
- package/package.json +1 -1
|
@@ -10,6 +10,15 @@ export type { ProductListStoreQueryParams } from '../../modules/ProductList';
|
|
|
10
10
|
export type { AvailabilityAbsoluteRange, AvailabilityAssignment, AvailabilityCell, AvailabilityDateRange, AvailabilityDisplayRange, AvailabilityErrorCode, AvailabilityId, AvailabilityMode, AvailabilityOccupancy, AvailabilityProduct, AvailabilityProductKind, AvailabilityProjection, AvailabilityProjectionInput, AvailabilityProjectionMeta, AvailabilityQuery, AvailabilityQueryResult, AvailabilityRequirementGroup, AvailabilityRequirementGroupResult, AvailabilityRequirementSelection, AvailabilityResource, AvailabilityResourceOption, AvailabilityResourceType, AvailabilityResourceWindow, AvailabilityScheduleMode, AvailabilityScheduleRef, AvailabilityScheduleRule, AvailabilitySelectionValidationParams, AvailabilitySelectionValidationResult, AvailabilitySessionRange, AvailabilityStatus, DateAvailabilityGroup, DateAvailabilityItem, DateAvailabilityQuery, DateAvailabilityQueryResult, GetProductTimeRangesRequest, ProductAvailabilityGroup, ProductAvailabilityItem, ProductAvailabilityQuery, ProductAvailabilityQueryResult, ProductTimeRange, ProductTimeRangeGroup, QueryAvailabilityBaseRequest, ResourceAvailabilityGroup, ResourceAvailabilityQuery, ResourceAvailabilityQueryResult, ResourceAvailabilityRangeGroup, TimeAvailabilityGroup, TimeAvailabilityItem, TimeAvailabilityQuery, TimeAvailabilityQueryResult, } from '../../modules/ResourcePlanner';
|
|
11
11
|
export interface UnifiedBookingSalesState extends BookingTicketState {
|
|
12
12
|
}
|
|
13
|
+
/** Read-only preview scope; existing solution queries remain fresh for selection and submission. */
|
|
14
|
+
export interface UnifiedBookingSalesCatalogQueryBatch {
|
|
15
|
+
queryCatalogSnapshot(params: ProductListLoadProductsParams): Promise<ProductData[]>;
|
|
16
|
+
queryCatalogProductDetail(params: ProductListLoadProductsParams & {
|
|
17
|
+
product_id: number;
|
|
18
|
+
}): Promise<ProductData | undefined>;
|
|
19
|
+
/** Releases retained results. A disposed batch cannot be reused. */
|
|
20
|
+
dispose(): void;
|
|
21
|
+
}
|
|
13
22
|
export interface UnifiedBookingSalesPolicy {
|
|
14
23
|
id?: AvailabilityId;
|
|
15
24
|
title?: unknown;
|
|
@@ -39,6 +48,19 @@ export interface UnifiedBookingSalesLoadOpenDataParams {
|
|
|
39
48
|
channel: string;
|
|
40
49
|
force?: boolean;
|
|
41
50
|
}
|
|
51
|
+
export interface UnifiedBookingSalesQueryBookingResourceDetailsParams {
|
|
52
|
+
/** Explicit booking date, YYYY-MM-DD. No implicit current-date fallback. */
|
|
53
|
+
date: string;
|
|
54
|
+
resourceIds: AvailabilityId[];
|
|
55
|
+
}
|
|
56
|
+
/** Original resource metadata. form_id is its resource type, not an associated customer form. */
|
|
57
|
+
export interface UnifiedBookingSalesResourceDetail extends Record<string, any> {
|
|
58
|
+
id: AvailabilityId;
|
|
59
|
+
resource_form_id?: number | string | null;
|
|
60
|
+
policy_id?: number | string | null;
|
|
61
|
+
form_id?: AvailabilityId;
|
|
62
|
+
main_field?: unknown;
|
|
63
|
+
}
|
|
42
64
|
export interface UnifiedBookingSalesLoadProductsByScheduleDateParams extends Omit<ProductListLoadProductsParams, 'schedule_date' | 'product_ids'> {
|
|
43
65
|
date: string;
|
|
44
66
|
product_ids?: number[];
|
|
@@ -167,7 +189,9 @@ export interface ContextualCommitAvailabilitySelectionParams {
|
|
|
167
189
|
availabilityCommitGuard?: () => void;
|
|
168
190
|
productLineUid?: string;
|
|
169
191
|
/**
|
|
170
|
-
* Confirmed complete Party extras set (configured,
|
|
192
|
+
* Confirmed complete Party extras set (configured, purchase-time-repriced retail source products).
|
|
193
|
+
* Their legacy venue_booking_service_datetime metadata stores the venue-local quote time,
|
|
194
|
+
* independently of the main product's appointment time.
|
|
171
195
|
* Required for replace; edit opts into the same atomic path. Existing extras keep their own
|
|
172
196
|
* metadata.unique_identification_number; new extras omit it. [] explicitly removes all owned extras.
|
|
173
197
|
*/
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
/** Read-only preview scope; existing solution queries remain fresh for selection and submission. */
|
|
2
|
+
|
|
1
3
|
export var UnifiedBookingSalesHooks = /*#__PURE__*/function (UnifiedBookingSalesHooks) {
|
|
2
4
|
UnifiedBookingSalesHooks["onAvailabilityProjectionPrepared"] = "unifiedBookingSales:onAvailabilityProjectionPrepared";
|
|
3
5
|
UnifiedBookingSalesHooks["onAvailabilitySelectionCommitted"] = "unifiedBookingSales:onAvailabilitySelectionCommitted";
|
|
4
6
|
UnifiedBookingSalesHooks["onAvailabilityProjectionDiagnostic"] = "unifiedBookingSales:onAvailabilityProjectionDiagnostic";
|
|
5
7
|
return UnifiedBookingSalesHooks;
|
|
6
|
-
}({});
|
|
8
|
+
}({});
|
|
9
|
+
|
|
10
|
+
/** Original resource metadata. form_id is its resource type, not an associated customer form. */
|
|
@@ -4040,9 +4040,10 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4040
4040
|
const nextChildren = (0, _lodashEs.cloneDeep)(params.relatedRetailProducts);
|
|
4041
4041
|
for (const child of nextChildren) {
|
|
4042
4042
|
const childUid = getUid(child);
|
|
4043
|
-
const
|
|
4044
|
-
|
|
4045
|
-
|
|
4043
|
+
const purchaseDatetime = String(child.metadata?.venue_booking_service_datetime || '');
|
|
4044
|
+
const normalizedPurchaseDatetime = purchaseDatetime.length === 16 ? `${purchaseDatetime}:00` : purchaseDatetime;
|
|
4045
|
+
if (child.metadata?.venue_booking_role !== 'party_extra' || String(child.metadata?.venue_booking_parent_uid || '') !== uid || child.metadata?.venue_booking_scope_key !== scopeKey || !/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(:\d{2})?$/.test(purchaseDatetime) || !(0, _dayjs.default)(purchaseDatetime).isValid() || (0, _dayjs.default)(purchaseDatetime).format('YYYY-MM-DD HH:mm:ss') !== normalizedPurchaseDatetime || this.hasLinkedBookingUid(child) || child.order_detail_id != null || childUid && (nextUids.has(childUid) || live.products.some(line => getUid(line) === childUid && !ownedUids.has(childUid)))) {
|
|
4046
|
+
throw new Error('[Order] Invalid Party extra ownership, identity, or purchase quote datetime');
|
|
4046
4047
|
}
|
|
4047
4048
|
if (childUid) nextUids.add(childUid);
|
|
4048
4049
|
const previous = children.find(line => getUid(line) === childUid);
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "duration" | "session" | "normal";
|
|
53
53
|
}
|
|
@@ -37,7 +37,9 @@ function collectReferencedRuleIds(products) {
|
|
|
37
37
|
if (!Array.isArray(variants)) return;
|
|
38
38
|
variants.forEach(variant => {
|
|
39
39
|
const id = String(variant?.data_variant_rule_id ?? '').trim();
|
|
40
|
-
|
|
40
|
+
// Rule 0 is the default-variant sentinel, not a strategy to load.
|
|
41
|
+
// Keep the evaluator responsible for its pricing/settlement semantics.
|
|
42
|
+
if (id && Number(id) !== 0) ids.add(id);
|
|
41
43
|
});
|
|
42
44
|
};
|
|
43
45
|
products.forEach(product => {
|
|
@@ -56,10 +58,12 @@ function isEvaluatorReady(evaluator, products) {
|
|
|
56
58
|
// A referenced Data Variant cannot be evaluated authoritatively until those
|
|
57
59
|
// configs have arrived. Evaluators without this capability remain compatible.
|
|
58
60
|
if (typeof evaluator.getStrategyConfigs === 'function') {
|
|
61
|
+
const referencedRuleIds = collectReferencedRuleIds(products);
|
|
62
|
+
if (referencedRuleIds.size === 0) return true;
|
|
59
63
|
const configs = evaluator.getStrategyConfigs();
|
|
60
64
|
if (!Array.isArray(configs) || configs.length === 0) return false;
|
|
61
65
|
const availableRuleIds = new Set(configs.map(config => String(config?.metadata?.id ?? '').trim()).filter(Boolean));
|
|
62
|
-
return Array.from(
|
|
66
|
+
return Array.from(referencedRuleIds).every(id => availableRuleIds.has(id));
|
|
63
67
|
}
|
|
64
68
|
return true;
|
|
65
69
|
}
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
date: string;
|
|
327
327
|
status: string;
|
|
328
328
|
week: string;
|
|
329
|
-
weekNum: 0 | 2 | 1 | 3 |
|
|
329
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -373,7 +373,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
373
373
|
};
|
|
374
374
|
setOtherData(key: string, value: any): void;
|
|
375
375
|
getOtherData(key: string): any;
|
|
376
|
-
getProductTypeById(id: number): Promise<"
|
|
376
|
+
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
377
377
|
/**
|
|
378
378
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
379
379
|
*
|
|
@@ -479,19 +479,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
479
479
|
* 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
|
|
480
480
|
* 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
|
|
481
481
|
*/
|
|
482
|
-
decideAddProduct(item: any, options?: Partial<AddProductDecideContext>):
|
|
483
|
-
action: "reloadCatalog";
|
|
484
|
-
} | {
|
|
485
|
-
action: "add";
|
|
486
|
-
cacheItem: any;
|
|
487
|
-
} | {
|
|
488
|
-
action: "requiresDetail";
|
|
489
|
-
payload: AddProductRequiresDetailPayload;
|
|
490
|
-
} | {
|
|
491
|
-
action: "requiresBookingEdit";
|
|
492
|
-
cacheItem: any;
|
|
493
|
-
payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
|
|
494
|
-
};
|
|
482
|
+
decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
|
|
495
483
|
/** 规格弹窗 callback 后的第二段决策。 */
|
|
496
484
|
decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
|
|
497
485
|
/**
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ProductListLoadProductsParams } from '../../modules/ProductList';
|
|
2
|
+
import type { ProductData } from '../../modules/Product/types';
|
|
3
|
+
import type { UnifiedBookingSalesCatalogQueryBatch } from './types';
|
|
4
|
+
type DetailParams = ProductListLoadProductsParams & {
|
|
5
|
+
product_id: number;
|
|
6
|
+
};
|
|
7
|
+
export interface CatalogQueryRuntime {
|
|
8
|
+
references: unknown[];
|
|
9
|
+
values: unknown;
|
|
10
|
+
/** Late-loaded pricing/schedule data may refresh within the same owner. */
|
|
11
|
+
refreshValues?: unknown;
|
|
12
|
+
}
|
|
13
|
+
/** Internal adapter: membership loaders are never accepted from public callers. */
|
|
14
|
+
export declare function createCatalogQueryBatchAdapter(options: {
|
|
15
|
+
runtime(): CatalogQueryRuntime;
|
|
16
|
+
normalize(params: ProductListLoadProductsParams, now: number): ProductListLoadProductsParams;
|
|
17
|
+
key(params: ProductListLoadProductsParams): string;
|
|
18
|
+
snapshot(params: ProductListLoadProductsParams): Promise<ProductData[]>;
|
|
19
|
+
detail(params: DetailParams, snapshot: UnifiedBookingSalesCatalogQueryBatch['queryCatalogSnapshot']): Promise<ProductData | undefined>;
|
|
20
|
+
}): UnifiedBookingSalesCatalogQueryBatch;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createCatalogQueryBatchAdapter = createCatalogQueryBatchAdapter;
|
|
7
|
+
var _lodashEs = require("lodash-es");
|
|
8
|
+
const BATCH_MAX_AGE_MS = 60 * 1000;
|
|
9
|
+
// Enough for a 42-day calendar with several product details per day, but bounded.
|
|
10
|
+
const BATCH_MAX_ENTRIES = 512;
|
|
11
|
+
|
|
12
|
+
/** Internal adapter: membership loaders are never accepted from public callers. */
|
|
13
|
+
function createCatalogQueryBatchAdapter(options) {
|
|
14
|
+
let disposed = false;
|
|
15
|
+
let epoch;
|
|
16
|
+
const sameOwner = (left, right) => left.references.length === right.references.length && left.references.every((ref, index) => ref === right.references[index]) && (0, _lodashEs.isEqual)(left.values, right.values);
|
|
17
|
+
const fail = code => Object.assign(new Error(code === 'CATALOG_QUERY_BATCH_DISPOSED' ? 'The catalog query batch is closed. Create a new batch before querying.' : 'The catalog context changed while loading. Please retry.'), {
|
|
18
|
+
code
|
|
19
|
+
});
|
|
20
|
+
const current = () => {
|
|
21
|
+
if (disposed) throw fail('CATALOG_QUERY_BATCH_DISPOSED');
|
|
22
|
+
const now = Date.now();
|
|
23
|
+
const runtime = options.runtime();
|
|
24
|
+
if (!epoch || now < epoch.startedAt || now - epoch.startedAt >= BATCH_MAX_AGE_MS || !sameOwner(runtime, epoch.runtime) || !(0, _lodashEs.isEqual)(runtime.refreshValues, epoch.runtime.refreshValues)) {
|
|
25
|
+
epoch?.entries.clear();
|
|
26
|
+
epoch = {
|
|
27
|
+
runtime: {
|
|
28
|
+
references: [...runtime.references],
|
|
29
|
+
values: (0, _lodashEs.cloneDeep)(runtime.values),
|
|
30
|
+
refreshValues: (0, _lodashEs.cloneDeep)(runtime.refreshValues)
|
|
31
|
+
},
|
|
32
|
+
startedAt: now,
|
|
33
|
+
entries: new Map()
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return epoch;
|
|
37
|
+
};
|
|
38
|
+
const assertEpoch = owner => {
|
|
39
|
+
const next = current();
|
|
40
|
+
if (next !== owner) throw Object.assign(fail('CATALOG_QUERY_BATCH_STALE'), {
|
|
41
|
+
retryable: sameOwner(owner.runtime, next.runtime)
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const run = async load => {
|
|
45
|
+
for (let attempt = 0;; attempt++) {
|
|
46
|
+
try {
|
|
47
|
+
return await load(current());
|
|
48
|
+
} catch (error) {
|
|
49
|
+
const failure = error;
|
|
50
|
+
// Drop the old result and reread under the new configuration. Never replay
|
|
51
|
+
// a network error, disposed batch or a request belonging to a different user/store.
|
|
52
|
+
if (attempt >= 2 || failure?.code !== 'CATALOG_QUERY_BATCH_STALE' || !failure.retryable) throw error;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const read = async (owner, key, load) => {
|
|
57
|
+
assertEpoch(owner);
|
|
58
|
+
let promise = owner.entries.get(key);
|
|
59
|
+
if (promise) {
|
|
60
|
+
owner.entries.delete(key);
|
|
61
|
+
owner.entries.set(key, promise);
|
|
62
|
+
} else {
|
|
63
|
+
promise = Promise.resolve().then(() => {
|
|
64
|
+
assertEpoch(owner);
|
|
65
|
+
return load();
|
|
66
|
+
}).then(value => (0, _lodashEs.cloneDeep)(value));
|
|
67
|
+
owner.entries.set(key, promise);
|
|
68
|
+
while (owner.entries.size > BATCH_MAX_ENTRIES) owner.entries.delete(owner.entries.keys().next().value);
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
const result = await promise;
|
|
72
|
+
assertEpoch(owner);
|
|
73
|
+
return (0, _lodashEs.cloneDeep)(result);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
if (owner.entries.get(key) === promise) owner.entries.delete(key);
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const snapshotFor = async (owner, input) => {
|
|
80
|
+
assertEpoch(owner);
|
|
81
|
+
const {
|
|
82
|
+
product_ids,
|
|
83
|
+
...scope
|
|
84
|
+
} = options.normalize((0, _lodashEs.cloneDeep)(input), owner.startedAt);
|
|
85
|
+
// The membership scope is always the whole menu; ID filtering is only a detached view.
|
|
86
|
+
const products = await read(owner, `list:${options.key(scope)}`, () => options.snapshot(scope));
|
|
87
|
+
return product_ids?.length ? products.filter(product => product_ids.some(id => Number(id) === Number(product.id))) : products;
|
|
88
|
+
};
|
|
89
|
+
return {
|
|
90
|
+
queryCatalogSnapshot: params => run(owner => snapshotFor(owner, params)),
|
|
91
|
+
queryCatalogProductDetail: input => run(owner => {
|
|
92
|
+
const {
|
|
93
|
+
product_id,
|
|
94
|
+
product_ids: _ignored,
|
|
95
|
+
...scope
|
|
96
|
+
} = (0, _lodashEs.cloneDeep)(input);
|
|
97
|
+
const params = {
|
|
98
|
+
...options.normalize(scope, owner.startedAt),
|
|
99
|
+
product_id
|
|
100
|
+
};
|
|
101
|
+
return read(owner, `detail:${options.key(params)}`, () => options.detail(params, query => snapshotFor(owner, query)));
|
|
102
|
+
}),
|
|
103
|
+
dispose: () => {
|
|
104
|
+
disposed = true;
|
|
105
|
+
epoch?.entries.clear();
|
|
106
|
+
epoch = undefined;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
@@ -6,7 +6,7 @@ import { type InvoiceLayoutConfig, type InvoiceTemplateSettings, type OpenDataCo
|
|
|
6
6
|
import type { LoadScheduleAvailableDateParams, ScheduleItem } from '../../modules/Schedule/types';
|
|
7
7
|
import type { ProductListLoadProductsParams, ProductListStoreQueryParams } from '../../modules/ProductList';
|
|
8
8
|
import type { AvailabilityDateRange, AvailabilityOccupancy, AvailabilityProduct, AvailabilityResource, GetProductTimeRangesRequest } from '../../modules/ResourcePlanner';
|
|
9
|
-
import type { AvailabilityContextRef, ContextualAvailabilityQuery, ContextualAvailabilityQueryResult, ContextualCommitAvailabilitySelectionParams, ContextualProductTimeRangeGroup, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesCommitAvailabilitySelectionResult, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesPrepareAvailabilityProjectionParams, UnifiedBookingSalesPolicyResponse, UnifiedBookingSalesResolveProductAllergyRequirementParams, UnifiedBookingSalesStageRetailProductsParams, UnifiedBookingSalesState } from './types';
|
|
9
|
+
import type { AvailabilityContextRef, ContextualAvailabilityQuery, ContextualAvailabilityQueryResult, ContextualCommitAvailabilitySelectionParams, ContextualProductTimeRangeGroup, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesCatalogQueryBatch, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesCommitAvailabilitySelectionResult, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesPrepareAvailabilityProjectionParams, UnifiedBookingSalesPolicyResponse, UnifiedBookingSalesQueryBookingResourceDetailsParams, UnifiedBookingSalesResourceDetail, UnifiedBookingSalesResolveProductAllergyRequirementParams, UnifiedBookingSalesStageRetailProductsParams, UnifiedBookingSalesState } from './types';
|
|
10
10
|
import type { BusinessAvailability } from '../../modules/BusinessAvailability';
|
|
11
11
|
import { BookingTicket } from '../BookingTicket';
|
|
12
12
|
import type { AllergyRequirement } from '../../model/strategy/adapter/itemRule';
|
|
@@ -71,6 +71,7 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
71
71
|
private runtimeOpenDataModule;
|
|
72
72
|
private runtimeOpenDataCore;
|
|
73
73
|
private runtimeOpenDataGeneration;
|
|
74
|
+
private runtimeInitializationGeneration;
|
|
74
75
|
private runtimeOpenDataDestroyed;
|
|
75
76
|
private unifiedProductCatalog;
|
|
76
77
|
private availabilityRuntimeOffsetMinutes;
|
|
@@ -224,6 +225,13 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
224
225
|
queryCatalogProductDetail(params: ProductListLoadProductsParams & {
|
|
225
226
|
product_id: number;
|
|
226
227
|
}): Promise<ProductData | undefined>;
|
|
228
|
+
/**
|
|
229
|
+
* Opt-in calendar/card preview batching. Results expire after sixty seconds or a
|
|
230
|
+
* runtime change; the next read starts a fresh clock/cache. Selection and submit
|
|
231
|
+
* must keep using the ordinary fresh query methods. Call dispose on owner cleanup.
|
|
232
|
+
*/
|
|
233
|
+
createCatalogQueryBatch(): UnifiedBookingSalesCatalogQueryBatch;
|
|
234
|
+
private loadCatalogProductDetail;
|
|
227
235
|
private loadCatalogProducts;
|
|
228
236
|
queryProducts(params?: ProductListStoreQueryParams): Promise<ProductData[]>;
|
|
229
237
|
/** Date-first entry point. It delegates protocol details and cache ownership to ScheduleModule. */
|
|
@@ -257,6 +265,8 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
257
265
|
* Its staged lines have separate ownership so planner and retail skins can coexist safely.
|
|
258
266
|
*/
|
|
259
267
|
stageRetailProducts(params: UnifiedBookingSalesStageRetailProductsParams): Promise<Record<string, any> | null>;
|
|
268
|
+
/** Explicit capability: order-scoped Tickets extras use guarded writes without implicit SKU merging. */
|
|
269
|
+
supportsVenueTicketExtras(): boolean;
|
|
260
270
|
/**
|
|
261
271
|
* Adds one retail line without replacing the cart's existing retail selection.
|
|
262
272
|
* This is intentionally separate from stageRetailProducts(), whose contract is
|
|
@@ -276,6 +286,8 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
276
286
|
* resource dates endpoint.
|
|
277
287
|
*/
|
|
278
288
|
private fetchAvailabilityResourcesV2;
|
|
289
|
+
/** Fresh read-only metadata for confirmation forms/policies; does not create a projection or mutate BookingContext. */
|
|
290
|
+
queryBookingResourceDetails(params: UnifiedBookingSalesQueryBookingResourceDetailsParams): Promise<UnifiedBookingSalesResourceDetail[]>;
|
|
279
291
|
private fetchAndPublishAvailabilityResourcesV2;
|
|
280
292
|
private refreshAvailabilityRemoteResourceQuery;
|
|
281
293
|
private loadAvailabilityResources;
|
|
@@ -64,6 +64,7 @@ Object.keys(_types).forEach(function (key) {
|
|
|
64
64
|
});
|
|
65
65
|
var _remoteOccupancyCache = require("./remoteOccupancyCache");
|
|
66
66
|
var _businessAvailability = require("./businessAvailability");
|
|
67
|
+
var _catalogQueryBatch = require("./catalogQueryBatch");
|
|
67
68
|
var _BookingTicket = require("../BookingTicket");
|
|
68
69
|
var _localClock = require("../../modules/ResourcePlanner/localClock");
|
|
69
70
|
var _platform = require("../../utils/platform");
|
|
@@ -1224,6 +1225,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
1224
1225
|
runtimeOpenDataModule = null;
|
|
1225
1226
|
runtimeOpenDataCore;
|
|
1226
1227
|
runtimeOpenDataGeneration = 0;
|
|
1228
|
+
runtimeInitializationGeneration = 0;
|
|
1227
1229
|
runtimeOpenDataDestroyed = false;
|
|
1228
1230
|
unifiedProductCatalog = [];
|
|
1229
1231
|
availabilityRuntimeOffsetMinutes = null;
|
|
@@ -1244,15 +1246,24 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
1244
1246
|
allergyItemRuleConfigs = [];
|
|
1245
1247
|
allergyItemRuleConfigsPromise = null;
|
|
1246
1248
|
async initialize(core, options = {}) {
|
|
1249
|
+
const initializationGeneration = ++this.runtimeInitializationGeneration;
|
|
1247
1250
|
this.resetRuntimeOpenData();
|
|
1248
1251
|
this.runtimeOpenDataDestroyed = false;
|
|
1249
|
-
const openDataGeneration = this.runtimeOpenDataGeneration;
|
|
1250
1252
|
this.availabilityScheduleCatalog = null;
|
|
1251
1253
|
this.availabilityRuntimeOffsetMinutes = (0, _localClock.captureRuntimeOffsetMinutes)();
|
|
1252
1254
|
this.clearAvailabilityRemoteResourceState();
|
|
1253
1255
|
this.resetAllergyItemRuleState();
|
|
1254
|
-
await
|
|
1255
|
-
|
|
1256
|
+
// BaseSales synchronously installs this runtime before its first await. Cache
|
|
1257
|
+
// refreshes during that await are valid; they are not a new initialization.
|
|
1258
|
+
const initialization = super.initialize(core, options);
|
|
1259
|
+
const scope = this.getRuntimeOpenDataScope();
|
|
1260
|
+
const openDataModule = this.store.openData;
|
|
1261
|
+
await initialization;
|
|
1262
|
+
if (this.runtimeOpenDataDestroyed || initializationGeneration !== this.runtimeInitializationGeneration) {
|
|
1263
|
+
// A destroyed/reinitialized instance must not publish a ready snapshot.
|
|
1264
|
+
return;
|
|
1265
|
+
}
|
|
1266
|
+
if (core !== this.core || openDataModule !== this.store.openData || scope !== this.getRuntimeOpenDataScope()) {
|
|
1256
1267
|
throw new Error('Store settings changed. Please try again.');
|
|
1257
1268
|
}
|
|
1258
1269
|
this.captureAvailabilityScheduleCatalog();
|
|
@@ -1474,6 +1485,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
1474
1485
|
}
|
|
1475
1486
|
}
|
|
1476
1487
|
async destroy() {
|
|
1488
|
+
this.runtimeInitializationGeneration += 1;
|
|
1477
1489
|
this.runtimeOpenDataDestroyed = true;
|
|
1478
1490
|
this.clearOpenDataCache();
|
|
1479
1491
|
this.availabilityScheduleCatalog = null;
|
|
@@ -2200,6 +2212,100 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
2200
2212
|
|
|
2201
2213
|
/** Full SKU/bundle detail, after verifying membership in the explicit day/menu scope. */
|
|
2202
2214
|
async queryCatalogProductDetail(params) {
|
|
2215
|
+
return this.loadCatalogProductDetail(params, query => this.queryCatalogSnapshot(query));
|
|
2216
|
+
}
|
|
2217
|
+
|
|
2218
|
+
/**
|
|
2219
|
+
* Opt-in calendar/card preview batching. Results expire after sixty seconds or a
|
|
2220
|
+
* runtime change; the next read starts a fresh clock/cache. Selection and submit
|
|
2221
|
+
* must keep using the ordinary fresh query methods. Call dispose on owner cleanup.
|
|
2222
|
+
*/
|
|
2223
|
+
createCatalogQueryBatch() {
|
|
2224
|
+
return (0, _catalogQueryBatch.createCatalogQueryBatchAdapter)({
|
|
2225
|
+
runtime: () => {
|
|
2226
|
+
if (this.runtimeOpenDataDestroyed) throw new Error('The booking service is closed.');
|
|
2227
|
+
const user = this.core.getPlugin?.('user');
|
|
2228
|
+
const productParams = this.store.products?.otherParams || this.otherParams || {};
|
|
2229
|
+
const fatherModule = String(productParams.fatherModule || '').trim();
|
|
2230
|
+
const schedule = (fatherModule ? this.core.getModule?.(`${fatherModule}_schedule`) : null) || this.core.getModule?.('schedule');
|
|
2231
|
+
const evaluator = this.core.context?.dataVariantEvaluator;
|
|
2232
|
+
// OpenData hydration is not a catalog input. Its temporary null/reload cycle
|
|
2233
|
+
// must not expire a batch while a parallel preview reads sales settings.
|
|
2234
|
+
const {
|
|
2235
|
+
openData: _openData,
|
|
2236
|
+
...otherParams
|
|
2237
|
+
} = this.otherParams || {};
|
|
2238
|
+
const {
|
|
2239
|
+
openData: _productOpenData,
|
|
2240
|
+
...productOtherParams
|
|
2241
|
+
} = productParams;
|
|
2242
|
+
return {
|
|
2243
|
+
references: [this.core, this.request, this.store.products, this.core.server, user, this.appPlugin, this.core.getPlugin?.('request'), this.core.getPlugin?.('app'), schedule, evaluator],
|
|
2244
|
+
values: {
|
|
2245
|
+
initialization: this.runtimeInitializationGeneration,
|
|
2246
|
+
scope: this.getRuntimeOpenDataScope(),
|
|
2247
|
+
requestBaseUrl: this.request.baseUrl,
|
|
2248
|
+
customerId: user?.get?.()?.id,
|
|
2249
|
+
otherParams,
|
|
2250
|
+
productOtherParams
|
|
2251
|
+
},
|
|
2252
|
+
refreshValues: {
|
|
2253
|
+
scheduleList: schedule?.getScheduleList?.(),
|
|
2254
|
+
contextScheduleList: this.core.context?.scheduleList,
|
|
2255
|
+
contextMenuList: this.core.context?.menuList,
|
|
2256
|
+
strategyConfigs: evaluator?.getStrategyConfigs?.()
|
|
2257
|
+
}
|
|
2258
|
+
};
|
|
2259
|
+
},
|
|
2260
|
+
normalize: (params, now) => {
|
|
2261
|
+
const date = params.schedule_date || (0, _dayjs.default)(now).format('YYYY-MM-DD');
|
|
2262
|
+
const user = this.core.getPlugin?.('user');
|
|
2263
|
+
const explicitCustomer = params.customer_id;
|
|
2264
|
+
if (explicitCustomer != null && (!Number.isSafeInteger(Number(explicitCustomer)) || Number(explicitCustomer) <= 0)) {
|
|
2265
|
+
throw new Error('Catalog query customer_id must be a positive integer.');
|
|
2266
|
+
}
|
|
2267
|
+
const fallbackCustomer = user?.get?.()?.id;
|
|
2268
|
+
const customer = explicitCustomer ?? (Number.isSafeInteger(Number(fallbackCustomer)) && Number(fallbackCustomer) > 0 ? Number(fallbackCustomer) : undefined);
|
|
2269
|
+
const productParams = this.store.products?.otherParams || this.otherParams || {};
|
|
2270
|
+
const channelMap = {
|
|
2271
|
+
online_store: 'online-store',
|
|
2272
|
+
scan_to_order: 'online-store',
|
|
2273
|
+
'scan-to-order': 'online-store',
|
|
2274
|
+
scan_to_order_2: 'online-store',
|
|
2275
|
+
scan_to_order_3: 'scantoorder3'
|
|
2276
|
+
};
|
|
2277
|
+
const channel = channelMap[productParams.channel] || productParams.channel;
|
|
2278
|
+
const businessCode = productParams.businessCode ?? productParams.business_code;
|
|
2279
|
+
const sorted = items => [...new Set(items)].sort((a, b) => String(a).localeCompare(String(b)));
|
|
2280
|
+
return {
|
|
2281
|
+
...params,
|
|
2282
|
+
menu_list_ids: Array.isArray(params.menu_list_ids) ? sorted(params.menu_list_ids) : params.menu_list_ids,
|
|
2283
|
+
category_ids: sorted(params.category_ids || []),
|
|
2284
|
+
collection: Array.isArray(params.collection) ? sorted(params.collection) : params.collection,
|
|
2285
|
+
extension_type: params.extension_type ? sorted(params.extension_type) : undefined,
|
|
2286
|
+
with_count: sorted(params.with_count ?? ['bundleGroup', 'optionGroup']),
|
|
2287
|
+
with_schedule: params.with_schedule ?? 1,
|
|
2288
|
+
status: params.status ?? 'published',
|
|
2289
|
+
schedule_date: date,
|
|
2290
|
+
schedule_datetime: params.schedule_datetime || `${date} ${(0, _dayjs.default)(now).format('HH:mm:ss')}`,
|
|
2291
|
+
customer_id: customer == null ? undefined : Number(customer),
|
|
2292
|
+
strategy_context: {
|
|
2293
|
+
...(channel ? {
|
|
2294
|
+
channel
|
|
2295
|
+
} : {}),
|
|
2296
|
+
...(businessCode ? {
|
|
2297
|
+
business_code: businessCode
|
|
2298
|
+
} : {}),
|
|
2299
|
+
...(params.strategy_context || {})
|
|
2300
|
+
}
|
|
2301
|
+
};
|
|
2302
|
+
},
|
|
2303
|
+
key: params => JSON.stringify(stableValue(params)),
|
|
2304
|
+
snapshot: params => this.queryCatalogSnapshot(params),
|
|
2305
|
+
detail: (params, snapshot) => this.loadCatalogProductDetail(params, snapshot)
|
|
2306
|
+
});
|
|
2307
|
+
}
|
|
2308
|
+
async loadCatalogProductDetail(params, loadSnapshot) {
|
|
2203
2309
|
const {
|
|
2204
2310
|
product_id,
|
|
2205
2311
|
product_ids: _ignoredIds,
|
|
@@ -2213,7 +2319,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
2213
2319
|
schedule_date,
|
|
2214
2320
|
schedule_datetime
|
|
2215
2321
|
};
|
|
2216
|
-
const member = (await
|
|
2322
|
+
const member = (await loadSnapshot(scopedParams)).find(item => Number(item.id) === product_id);
|
|
2217
2323
|
if (!member) return undefined;
|
|
2218
2324
|
const baseUrl = String(this.request.baseUrl || ((0, _platform.isCustomerUserPlatform)(this.otherParams?.platform) ? '/h5' : '/shop')).replace(/\/+$/, '');
|
|
2219
2325
|
const localPath = `/product/query/${product_id}`;
|
|
@@ -2548,6 +2654,11 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
2548
2654
|
return this.stageProducts(params, 'unified_booking_sales_retail');
|
|
2549
2655
|
}
|
|
2550
2656
|
|
|
2657
|
+
/** Explicit capability: order-scoped Tickets extras use guarded writes without implicit SKU merging. */
|
|
2658
|
+
supportsVenueTicketExtras() {
|
|
2659
|
+
return true;
|
|
2660
|
+
}
|
|
2661
|
+
|
|
2551
2662
|
/**
|
|
2552
2663
|
* Adds one retail line without replacing the cart's existing retail selection.
|
|
2553
2664
|
* This is intentionally separate from stageRetailProducts(), whose contract is
|
|
@@ -2580,23 +2691,66 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
2580
2691
|
if (!orderProduct) {
|
|
2581
2692
|
throw new Error('[UnifiedBookingSales] 无法生成零售商品订单行');
|
|
2582
2693
|
}
|
|
2694
|
+
if (orderProduct.metadata?.venue_booking_role === 'tickets_extra') {
|
|
2695
|
+
const order = this.getTempOrder();
|
|
2696
|
+
const meta = orderProduct.metadata;
|
|
2697
|
+
const scopeKey = String(meta.venue_booking_scope_key || '');
|
|
2698
|
+
const purchaseDatetime = String(meta.venue_booking_service_datetime || '');
|
|
2699
|
+
const identity = [order?.order_id, order?.external_sale_number, order?.customer_id];
|
|
2700
|
+
const isCurrentOrder = () => this.getTempOrder() === order && order?.order_id === identity[0] && order?.external_sale_number === identity[1] && order?.customer_id === identity[2];
|
|
2701
|
+
const guard = () => {
|
|
2702
|
+
params.availabilityCommitGuard?.();
|
|
2703
|
+
if (!isCurrentOrder() || !order || order.order_id || !scopeKey || meta.venue_booking_parent_uid || orderProduct.booking_uid || meta.booking_uid || !/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(:\d{2})?$/.test(purchaseDatetime) || !(0, _dayjs.default)(purchaseDatetime).isValid() || !(order.products || []).some(line => line.metadata?.venue_booking_role === 'tickets' && line.metadata?.venue_booking_scope_key === scopeKey)) {
|
|
2704
|
+
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '门票订单或购买时间已变化,请重新确认附加商品');
|
|
2705
|
+
}
|
|
2706
|
+
};
|
|
2707
|
+
guard();
|
|
2708
|
+
// Retail extras are order-owned, with their own UID and no Holder/booking.
|
|
2709
|
+
delete orderProduct.unique_identification_number;
|
|
2710
|
+
delete meta.unique_identification_number;
|
|
2711
|
+
delete meta.venue_booking_parent_uid;
|
|
2712
|
+
orderProduct.holder_config = {
|
|
2713
|
+
status: 'disable',
|
|
2714
|
+
required: 0
|
|
2715
|
+
};
|
|
2716
|
+
meta.holder_config = {
|
|
2717
|
+
status: 'disable',
|
|
2718
|
+
required: 0
|
|
2719
|
+
};
|
|
2720
|
+
return this.addProductToOrder(orderProduct, undefined, {
|
|
2721
|
+
disableMerge: true,
|
|
2722
|
+
availabilityCommitGuard: guard,
|
|
2723
|
+
availabilityCommitTargetGuard: isCurrentOrder,
|
|
2724
|
+
salesNotes: params.salesNotes
|
|
2725
|
+
});
|
|
2726
|
+
}
|
|
2583
2727
|
if (orderProduct.metadata?.venue_booking_role === 'party_extra') {
|
|
2584
2728
|
const order = this.getTempOrder();
|
|
2585
2729
|
const meta = orderProduct.metadata;
|
|
2586
2730
|
const parentUid = String(meta.venue_booking_parent_uid || '');
|
|
2587
2731
|
const scopeKey = String(meta.venue_booking_scope_key || '');
|
|
2588
|
-
|
|
2732
|
+
// The persisted legacy key holds this retail extra's venue-local purchase quote time.
|
|
2733
|
+
// Its parent UID owns the extra; the parent's appointment time does not price it.
|
|
2734
|
+
const purchaseDatetime = String(meta.venue_booking_service_datetime || '');
|
|
2735
|
+
const normalizedPurchaseDatetime = purchaseDatetime.length === 16 ? `${purchaseDatetime}:00` : purchaseDatetime;
|
|
2589
2736
|
const identity = [order?.order_id, order?.external_sale_number];
|
|
2590
2737
|
const isCurrentOrder = () => this.getTempOrder() === order && order?.order_id === identity[0] && order?.external_sale_number === identity[1];
|
|
2591
2738
|
const guard = () => {
|
|
2592
2739
|
params.availabilityCommitGuard?.();
|
|
2593
2740
|
const parent = (order?.products || []).find(line => getProductLineUid(line) === parentUid);
|
|
2594
|
-
|
|
2595
|
-
if (!isCurrentOrder() || !order || order.order_id || !parentUid || !scopeKey || parent?.metadata?.venue_booking_role !== 'party_main' || parent?.metadata?.venue_booking_scope_key !== scopeKey || !service || !parentService || !(0, _dayjs.default)(service).isValid() || !(0, _dayjs.default)(parentService).isValid() || (0, _dayjs.default)(service).format('YYYY-MM-DD HH:mm:ss') !== (0, _dayjs.default)(parentService).format('YYYY-MM-DD HH:mm:ss')) throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'Party 主商品或服务时间已变化,请重新确认附加商品');
|
|
2741
|
+
if (!isCurrentOrder() || !order || order.order_id || !parentUid || !scopeKey || parent?.metadata?.venue_booking_role !== 'party_main' || parent?.metadata?.venue_booking_scope_key !== scopeKey || !/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(:\d{2})?$/.test(purchaseDatetime) || !(0, _dayjs.default)(purchaseDatetime).isValid() || (0, _dayjs.default)(purchaseDatetime).format('YYYY-MM-DD HH:mm:ss') !== normalizedPurchaseDatetime) throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'Party 主商品或附加商品报价上下文已变化,请重新确认附加商品');
|
|
2596
2742
|
};
|
|
2597
2743
|
guard();
|
|
2598
2744
|
delete orderProduct.unique_identification_number;
|
|
2599
2745
|
delete orderProduct.metadata.unique_identification_number;
|
|
2746
|
+
orderProduct.holder_config = {
|
|
2747
|
+
status: 'disable',
|
|
2748
|
+
required: 0
|
|
2749
|
+
};
|
|
2750
|
+
orderProduct.metadata.holder_config = {
|
|
2751
|
+
status: 'disable',
|
|
2752
|
+
required: 0
|
|
2753
|
+
};
|
|
2600
2754
|
return this.addProductToOrder(orderProduct, undefined, {
|
|
2601
2755
|
disableMerge: true,
|
|
2602
2756
|
availabilityCommitGuard: guard,
|
|
@@ -2830,10 +2984,58 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
2830
2984
|
useCache: false
|
|
2831
2985
|
});
|
|
2832
2986
|
const data = response?.data;
|
|
2987
|
+
if (params.strictResponse && response?.status === false) {
|
|
2988
|
+
const message = response?.message;
|
|
2989
|
+
throw Object.assign(new Error(typeof message === 'string' && message.trim() ? message : 'Unable to load booking resource details.'), {
|
|
2990
|
+
code: response?.code
|
|
2991
|
+
});
|
|
2992
|
+
}
|
|
2833
2993
|
if (Array.isArray(data)) return data;
|
|
2834
2994
|
if (Array.isArray(data?.list)) return data.list;
|
|
2995
|
+
if (params.strictResponse) {
|
|
2996
|
+
throw new Error('Booking resource details returned an invalid response.');
|
|
2997
|
+
}
|
|
2835
2998
|
return [];
|
|
2836
2999
|
}
|
|
3000
|
+
|
|
3001
|
+
/** Fresh read-only metadata for confirmation forms/policies; does not create a projection or mutate BookingContext. */
|
|
3002
|
+
async queryBookingResourceDetails(params) {
|
|
3003
|
+
const date = params?.date;
|
|
3004
|
+
try {
|
|
3005
|
+
if (typeof date !== 'string' || !/^\d{4}-\d{2}-\d{2}$/.test(date)) throw new Error('date');
|
|
3006
|
+
(0, _localClock.parseLocalDate)(date);
|
|
3007
|
+
} catch {
|
|
3008
|
+
throw this.createAvailabilityFacadeError('INVALID_DATE_RANGE', 'A valid booking date is required to load resource details.');
|
|
3009
|
+
}
|
|
3010
|
+
if (!Array.isArray(params?.resourceIds) || !params.resourceIds.length || params.resourceIds.some(id => !['number', 'string'].includes(typeof id) || !/^\d+$/.test(String(id)) || !Number.isSafeInteger(Number(id)) || Number(id) <= 0)) {
|
|
3011
|
+
throw this.createAvailabilityFacadeError('INVALID_TARGET_FILTER', 'Selected resource IDs are required to load resource details.');
|
|
3012
|
+
}
|
|
3013
|
+
const resourceIds = [...new Set(params.resourceIds.map(id => String(Number(id))))];
|
|
3014
|
+
const core = this.core;
|
|
3015
|
+
const request = this.request;
|
|
3016
|
+
const generation = this.runtimeInitializationGeneration;
|
|
3017
|
+
const scope = this.getRuntimeOpenDataScope();
|
|
3018
|
+
const assertCurrent = () => {
|
|
3019
|
+
if (this.runtimeOpenDataDestroyed || !request || core !== this.core || request !== this.request || generation !== this.runtimeInitializationGeneration || scope !== this.getRuntimeOpenDataScope()) {
|
|
3020
|
+
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'Booking settings changed. Please reload the resource details.');
|
|
3021
|
+
}
|
|
3022
|
+
};
|
|
3023
|
+
assertCurrent();
|
|
3024
|
+
const resources = await this.fetchAvailabilityResourcesV2({
|
|
3025
|
+
dateRange: {
|
|
3026
|
+
startDate: date,
|
|
3027
|
+
endDate: date
|
|
3028
|
+
},
|
|
3029
|
+
resourceIds,
|
|
3030
|
+
strictResponse: true
|
|
3031
|
+
});
|
|
3032
|
+
assertCurrent();
|
|
3033
|
+
const byId = new Map(resources.filter(isRecord).map(resource => [String(resource.id), resource]));
|
|
3034
|
+
if (resourceIds.some(id => !byId.has(id))) {
|
|
3035
|
+
throw this.createAvailabilityFacadeError('INVALID_TARGET_FILTER', 'A selected booking resource is no longer available.');
|
|
3036
|
+
}
|
|
3037
|
+
return (0, _lodashEs.cloneDeep)(resourceIds.map(id => byId.get(id)));
|
|
3038
|
+
}
|
|
2837
3039
|
async fetchAndPublishAvailabilityResourcesV2(params) {
|
|
2838
3040
|
const normalizedResourceIds = this.normalizeAvailabilityIdList(params.resourceIds) || [];
|
|
2839
3041
|
if (normalizedResourceIds.length === 0) return [];
|
|
@@ -3943,6 +4145,16 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3943
4145
|
const relatedRetailProducts = params.relatedRetailProducts.map(source => {
|
|
3944
4146
|
const line = this.buildUnifiedOrderProduct(source, 'unified_booking_sales_retail');
|
|
3945
4147
|
if (!line) throw new _ResourcePlanner.AvailabilityError('INVALID_TARGET_FILTER', '无法生成附加商品订单行');
|
|
4148
|
+
if (line.metadata?.venue_booking_role === 'party_extra') {
|
|
4149
|
+
line.holder_config = {
|
|
4150
|
+
status: 'disable',
|
|
4151
|
+
required: 0
|
|
4152
|
+
};
|
|
4153
|
+
line.metadata.holder_config = {
|
|
4154
|
+
status: 'disable',
|
|
4155
|
+
required: 0
|
|
4156
|
+
};
|
|
4157
|
+
}
|
|
3946
4158
|
// This is the only replacement-specific UID restore. Order checks ownership/collisions.
|
|
3947
4159
|
const sourceUid = getProductLineUid(source);
|
|
3948
4160
|
if (sourceUid) {
|