@pisell/pisellos 0.10.73 → 0.10.74
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/index.d.ts +6 -1
- package/dist/solution/UnifiedBookingSales/index.js +498 -316
- package/dist/solution/UnifiedBookingSales/types.d.ts +16 -1
- package/dist/solution/UnifiedBookingSales/types.js +3 -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/index.d.ts +6 -1
- package/lib/solution/UnifiedBookingSales/index.js +123 -6
- package/lib/solution/UnifiedBookingSales/types.d.ts +16 -1
- package/lib/solution/UnifiedBookingSales/types.js +2 -1
- package/package.json +1 -1
|
@@ -39,6 +39,19 @@ export interface UnifiedBookingSalesLoadOpenDataParams {
|
|
|
39
39
|
channel: string;
|
|
40
40
|
force?: boolean;
|
|
41
41
|
}
|
|
42
|
+
export interface UnifiedBookingSalesQueryBookingResourceDetailsParams {
|
|
43
|
+
/** Explicit booking date, YYYY-MM-DD. No implicit current-date fallback. */
|
|
44
|
+
date: string;
|
|
45
|
+
resourceIds: AvailabilityId[];
|
|
46
|
+
}
|
|
47
|
+
/** Original resource metadata. form_id is its resource type, not an associated customer form. */
|
|
48
|
+
export interface UnifiedBookingSalesResourceDetail extends Record<string, any> {
|
|
49
|
+
id: AvailabilityId;
|
|
50
|
+
resource_form_id?: number | string | null;
|
|
51
|
+
policy_id?: number | string | null;
|
|
52
|
+
form_id?: AvailabilityId;
|
|
53
|
+
main_field?: unknown;
|
|
54
|
+
}
|
|
42
55
|
export interface UnifiedBookingSalesLoadProductsByScheduleDateParams extends Omit<ProductListLoadProductsParams, 'schedule_date' | 'product_ids'> {
|
|
43
56
|
date: string;
|
|
44
57
|
product_ids?: number[];
|
|
@@ -167,7 +180,9 @@ export interface ContextualCommitAvailabilitySelectionParams {
|
|
|
167
180
|
availabilityCommitGuard?: () => void;
|
|
168
181
|
productLineUid?: string;
|
|
169
182
|
/**
|
|
170
|
-
* Confirmed complete Party extras set (configured,
|
|
183
|
+
* Confirmed complete Party extras set (configured, purchase-time-repriced retail source products).
|
|
184
|
+
* Their legacy venue_booking_service_datetime metadata stores the venue-local quote time,
|
|
185
|
+
* independently of the main product's appointment time.
|
|
171
186
|
* Required for replace; edit opts into the same atomic path. Existing extras keep their own
|
|
172
187
|
* metadata.unique_identification_number; new extras omit it. [] explicitly removes all owned extras.
|
|
173
188
|
*/
|
|
@@ -3,4 +3,6 @@ export var UnifiedBookingSalesHooks = /*#__PURE__*/function (UnifiedBookingSales
|
|
|
3
3
|
UnifiedBookingSalesHooks["onAvailabilitySelectionCommitted"] = "unifiedBookingSales:onAvailabilitySelectionCommitted";
|
|
4
4
|
UnifiedBookingSalesHooks["onAvailabilityProjectionDiagnostic"] = "unifiedBookingSales:onAvailabilityProjectionDiagnostic";
|
|
5
5
|
return UnifiedBookingSalesHooks;
|
|
6
|
-
}({});
|
|
6
|
+
}({});
|
|
7
|
+
|
|
8
|
+
/** 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
|
/**
|
|
@@ -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, 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;
|
|
@@ -257,6 +258,8 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
257
258
|
* Its staged lines have separate ownership so planner and retail skins can coexist safely.
|
|
258
259
|
*/
|
|
259
260
|
stageRetailProducts(params: UnifiedBookingSalesStageRetailProductsParams): Promise<Record<string, any> | null>;
|
|
261
|
+
/** Explicit capability: order-scoped Tickets extras use guarded writes without implicit SKU merging. */
|
|
262
|
+
supportsVenueTicketExtras(): boolean;
|
|
260
263
|
/**
|
|
261
264
|
* Adds one retail line without replacing the cart's existing retail selection.
|
|
262
265
|
* This is intentionally separate from stageRetailProducts(), whose contract is
|
|
@@ -276,6 +279,8 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
276
279
|
* resource dates endpoint.
|
|
277
280
|
*/
|
|
278
281
|
private fetchAvailabilityResourcesV2;
|
|
282
|
+
/** Fresh read-only metadata for confirmation forms/policies; does not create a projection or mutate BookingContext. */
|
|
283
|
+
queryBookingResourceDetails(params: UnifiedBookingSalesQueryBookingResourceDetailsParams): Promise<UnifiedBookingSalesResourceDetail[]>;
|
|
279
284
|
private fetchAndPublishAvailabilityResourcesV2;
|
|
280
285
|
private refreshAvailabilityRemoteResourceQuery;
|
|
281
286
|
private loadAvailabilityResources;
|
|
@@ -1224,6 +1224,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
1224
1224
|
runtimeOpenDataModule = null;
|
|
1225
1225
|
runtimeOpenDataCore;
|
|
1226
1226
|
runtimeOpenDataGeneration = 0;
|
|
1227
|
+
runtimeInitializationGeneration = 0;
|
|
1227
1228
|
runtimeOpenDataDestroyed = false;
|
|
1228
1229
|
unifiedProductCatalog = [];
|
|
1229
1230
|
availabilityRuntimeOffsetMinutes = null;
|
|
@@ -1244,15 +1245,24 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
1244
1245
|
allergyItemRuleConfigs = [];
|
|
1245
1246
|
allergyItemRuleConfigsPromise = null;
|
|
1246
1247
|
async initialize(core, options = {}) {
|
|
1248
|
+
const initializationGeneration = ++this.runtimeInitializationGeneration;
|
|
1247
1249
|
this.resetRuntimeOpenData();
|
|
1248
1250
|
this.runtimeOpenDataDestroyed = false;
|
|
1249
|
-
const openDataGeneration = this.runtimeOpenDataGeneration;
|
|
1250
1251
|
this.availabilityScheduleCatalog = null;
|
|
1251
1252
|
this.availabilityRuntimeOffsetMinutes = (0, _localClock.captureRuntimeOffsetMinutes)();
|
|
1252
1253
|
this.clearAvailabilityRemoteResourceState();
|
|
1253
1254
|
this.resetAllergyItemRuleState();
|
|
1254
|
-
await
|
|
1255
|
-
|
|
1255
|
+
// BaseSales synchronously installs this runtime before its first await. Cache
|
|
1256
|
+
// refreshes during that await are valid; they are not a new initialization.
|
|
1257
|
+
const initialization = super.initialize(core, options);
|
|
1258
|
+
const scope = this.getRuntimeOpenDataScope();
|
|
1259
|
+
const openDataModule = this.store.openData;
|
|
1260
|
+
await initialization;
|
|
1261
|
+
if (this.runtimeOpenDataDestroyed || initializationGeneration !== this.runtimeInitializationGeneration) {
|
|
1262
|
+
// A destroyed/reinitialized instance must not publish a ready snapshot.
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
if (core !== this.core || openDataModule !== this.store.openData || scope !== this.getRuntimeOpenDataScope()) {
|
|
1256
1266
|
throw new Error('Store settings changed. Please try again.');
|
|
1257
1267
|
}
|
|
1258
1268
|
this.captureAvailabilityScheduleCatalog();
|
|
@@ -1474,6 +1484,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
1474
1484
|
}
|
|
1475
1485
|
}
|
|
1476
1486
|
async destroy() {
|
|
1487
|
+
this.runtimeInitializationGeneration += 1;
|
|
1477
1488
|
this.runtimeOpenDataDestroyed = true;
|
|
1478
1489
|
this.clearOpenDataCache();
|
|
1479
1490
|
this.availabilityScheduleCatalog = null;
|
|
@@ -2548,6 +2559,11 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
2548
2559
|
return this.stageProducts(params, 'unified_booking_sales_retail');
|
|
2549
2560
|
}
|
|
2550
2561
|
|
|
2562
|
+
/** Explicit capability: order-scoped Tickets extras use guarded writes without implicit SKU merging. */
|
|
2563
|
+
supportsVenueTicketExtras() {
|
|
2564
|
+
return true;
|
|
2565
|
+
}
|
|
2566
|
+
|
|
2551
2567
|
/**
|
|
2552
2568
|
* Adds one retail line without replacing the cart's existing retail selection.
|
|
2553
2569
|
* This is intentionally separate from stageRetailProducts(), whose contract is
|
|
@@ -2580,23 +2596,66 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
2580
2596
|
if (!orderProduct) {
|
|
2581
2597
|
throw new Error('[UnifiedBookingSales] 无法生成零售商品订单行');
|
|
2582
2598
|
}
|
|
2599
|
+
if (orderProduct.metadata?.venue_booking_role === 'tickets_extra') {
|
|
2600
|
+
const order = this.getTempOrder();
|
|
2601
|
+
const meta = orderProduct.metadata;
|
|
2602
|
+
const scopeKey = String(meta.venue_booking_scope_key || '');
|
|
2603
|
+
const purchaseDatetime = String(meta.venue_booking_service_datetime || '');
|
|
2604
|
+
const identity = [order?.order_id, order?.external_sale_number, order?.customer_id];
|
|
2605
|
+
const isCurrentOrder = () => this.getTempOrder() === order && order?.order_id === identity[0] && order?.external_sale_number === identity[1] && order?.customer_id === identity[2];
|
|
2606
|
+
const guard = () => {
|
|
2607
|
+
params.availabilityCommitGuard?.();
|
|
2608
|
+
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)) {
|
|
2609
|
+
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '门票订单或购买时间已变化,请重新确认附加商品');
|
|
2610
|
+
}
|
|
2611
|
+
};
|
|
2612
|
+
guard();
|
|
2613
|
+
// Retail extras are order-owned, with their own UID and no Holder/booking.
|
|
2614
|
+
delete orderProduct.unique_identification_number;
|
|
2615
|
+
delete meta.unique_identification_number;
|
|
2616
|
+
delete meta.venue_booking_parent_uid;
|
|
2617
|
+
orderProduct.holder_config = {
|
|
2618
|
+
status: 'disable',
|
|
2619
|
+
required: 0
|
|
2620
|
+
};
|
|
2621
|
+
meta.holder_config = {
|
|
2622
|
+
status: 'disable',
|
|
2623
|
+
required: 0
|
|
2624
|
+
};
|
|
2625
|
+
return this.addProductToOrder(orderProduct, undefined, {
|
|
2626
|
+
disableMerge: true,
|
|
2627
|
+
availabilityCommitGuard: guard,
|
|
2628
|
+
availabilityCommitTargetGuard: isCurrentOrder,
|
|
2629
|
+
salesNotes: params.salesNotes
|
|
2630
|
+
});
|
|
2631
|
+
}
|
|
2583
2632
|
if (orderProduct.metadata?.venue_booking_role === 'party_extra') {
|
|
2584
2633
|
const order = this.getTempOrder();
|
|
2585
2634
|
const meta = orderProduct.metadata;
|
|
2586
2635
|
const parentUid = String(meta.venue_booking_parent_uid || '');
|
|
2587
2636
|
const scopeKey = String(meta.venue_booking_scope_key || '');
|
|
2588
|
-
|
|
2637
|
+
// The persisted legacy key holds this retail extra's venue-local purchase quote time.
|
|
2638
|
+
// Its parent UID owns the extra; the parent's appointment time does not price it.
|
|
2639
|
+
const purchaseDatetime = String(meta.venue_booking_service_datetime || '');
|
|
2640
|
+
const normalizedPurchaseDatetime = purchaseDatetime.length === 16 ? `${purchaseDatetime}:00` : purchaseDatetime;
|
|
2589
2641
|
const identity = [order?.order_id, order?.external_sale_number];
|
|
2590
2642
|
const isCurrentOrder = () => this.getTempOrder() === order && order?.order_id === identity[0] && order?.external_sale_number === identity[1];
|
|
2591
2643
|
const guard = () => {
|
|
2592
2644
|
params.availabilityCommitGuard?.();
|
|
2593
2645
|
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 主商品或服务时间已变化,请重新确认附加商品');
|
|
2646
|
+
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
2647
|
};
|
|
2597
2648
|
guard();
|
|
2598
2649
|
delete orderProduct.unique_identification_number;
|
|
2599
2650
|
delete orderProduct.metadata.unique_identification_number;
|
|
2651
|
+
orderProduct.holder_config = {
|
|
2652
|
+
status: 'disable',
|
|
2653
|
+
required: 0
|
|
2654
|
+
};
|
|
2655
|
+
orderProduct.metadata.holder_config = {
|
|
2656
|
+
status: 'disable',
|
|
2657
|
+
required: 0
|
|
2658
|
+
};
|
|
2600
2659
|
return this.addProductToOrder(orderProduct, undefined, {
|
|
2601
2660
|
disableMerge: true,
|
|
2602
2661
|
availabilityCommitGuard: guard,
|
|
@@ -2830,10 +2889,58 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
2830
2889
|
useCache: false
|
|
2831
2890
|
});
|
|
2832
2891
|
const data = response?.data;
|
|
2892
|
+
if (params.strictResponse && response?.status === false) {
|
|
2893
|
+
const message = response?.message;
|
|
2894
|
+
throw Object.assign(new Error(typeof message === 'string' && message.trim() ? message : 'Unable to load booking resource details.'), {
|
|
2895
|
+
code: response?.code
|
|
2896
|
+
});
|
|
2897
|
+
}
|
|
2833
2898
|
if (Array.isArray(data)) return data;
|
|
2834
2899
|
if (Array.isArray(data?.list)) return data.list;
|
|
2900
|
+
if (params.strictResponse) {
|
|
2901
|
+
throw new Error('Booking resource details returned an invalid response.');
|
|
2902
|
+
}
|
|
2835
2903
|
return [];
|
|
2836
2904
|
}
|
|
2905
|
+
|
|
2906
|
+
/** Fresh read-only metadata for confirmation forms/policies; does not create a projection or mutate BookingContext. */
|
|
2907
|
+
async queryBookingResourceDetails(params) {
|
|
2908
|
+
const date = params?.date;
|
|
2909
|
+
try {
|
|
2910
|
+
if (typeof date !== 'string' || !/^\d{4}-\d{2}-\d{2}$/.test(date)) throw new Error('date');
|
|
2911
|
+
(0, _localClock.parseLocalDate)(date);
|
|
2912
|
+
} catch {
|
|
2913
|
+
throw this.createAvailabilityFacadeError('INVALID_DATE_RANGE', 'A valid booking date is required to load resource details.');
|
|
2914
|
+
}
|
|
2915
|
+
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)) {
|
|
2916
|
+
throw this.createAvailabilityFacadeError('INVALID_TARGET_FILTER', 'Selected resource IDs are required to load resource details.');
|
|
2917
|
+
}
|
|
2918
|
+
const resourceIds = [...new Set(params.resourceIds.map(id => String(Number(id))))];
|
|
2919
|
+
const core = this.core;
|
|
2920
|
+
const request = this.request;
|
|
2921
|
+
const generation = this.runtimeInitializationGeneration;
|
|
2922
|
+
const scope = this.getRuntimeOpenDataScope();
|
|
2923
|
+
const assertCurrent = () => {
|
|
2924
|
+
if (this.runtimeOpenDataDestroyed || !request || core !== this.core || request !== this.request || generation !== this.runtimeInitializationGeneration || scope !== this.getRuntimeOpenDataScope()) {
|
|
2925
|
+
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'Booking settings changed. Please reload the resource details.');
|
|
2926
|
+
}
|
|
2927
|
+
};
|
|
2928
|
+
assertCurrent();
|
|
2929
|
+
const resources = await this.fetchAvailabilityResourcesV2({
|
|
2930
|
+
dateRange: {
|
|
2931
|
+
startDate: date,
|
|
2932
|
+
endDate: date
|
|
2933
|
+
},
|
|
2934
|
+
resourceIds,
|
|
2935
|
+
strictResponse: true
|
|
2936
|
+
});
|
|
2937
|
+
assertCurrent();
|
|
2938
|
+
const byId = new Map(resources.filter(isRecord).map(resource => [String(resource.id), resource]));
|
|
2939
|
+
if (resourceIds.some(id => !byId.has(id))) {
|
|
2940
|
+
throw this.createAvailabilityFacadeError('INVALID_TARGET_FILTER', 'A selected booking resource is no longer available.');
|
|
2941
|
+
}
|
|
2942
|
+
return (0, _lodashEs.cloneDeep)(resourceIds.map(id => byId.get(id)));
|
|
2943
|
+
}
|
|
2837
2944
|
async fetchAndPublishAvailabilityResourcesV2(params) {
|
|
2838
2945
|
const normalizedResourceIds = this.normalizeAvailabilityIdList(params.resourceIds) || [];
|
|
2839
2946
|
if (normalizedResourceIds.length === 0) return [];
|
|
@@ -3943,6 +4050,16 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3943
4050
|
const relatedRetailProducts = params.relatedRetailProducts.map(source => {
|
|
3944
4051
|
const line = this.buildUnifiedOrderProduct(source, 'unified_booking_sales_retail');
|
|
3945
4052
|
if (!line) throw new _ResourcePlanner.AvailabilityError('INVALID_TARGET_FILTER', '无法生成附加商品订单行');
|
|
4053
|
+
if (line.metadata?.venue_booking_role === 'party_extra') {
|
|
4054
|
+
line.holder_config = {
|
|
4055
|
+
status: 'disable',
|
|
4056
|
+
required: 0
|
|
4057
|
+
};
|
|
4058
|
+
line.metadata.holder_config = {
|
|
4059
|
+
status: 'disable',
|
|
4060
|
+
required: 0
|
|
4061
|
+
};
|
|
4062
|
+
}
|
|
3946
4063
|
// This is the only replacement-specific UID restore. Order checks ownership/collisions.
|
|
3947
4064
|
const sourceUid = getProductLineUid(source);
|
|
3948
4065
|
if (sourceUid) {
|
|
@@ -39,6 +39,19 @@ export interface UnifiedBookingSalesLoadOpenDataParams {
|
|
|
39
39
|
channel: string;
|
|
40
40
|
force?: boolean;
|
|
41
41
|
}
|
|
42
|
+
export interface UnifiedBookingSalesQueryBookingResourceDetailsParams {
|
|
43
|
+
/** Explicit booking date, YYYY-MM-DD. No implicit current-date fallback. */
|
|
44
|
+
date: string;
|
|
45
|
+
resourceIds: AvailabilityId[];
|
|
46
|
+
}
|
|
47
|
+
/** Original resource metadata. form_id is its resource type, not an associated customer form. */
|
|
48
|
+
export interface UnifiedBookingSalesResourceDetail extends Record<string, any> {
|
|
49
|
+
id: AvailabilityId;
|
|
50
|
+
resource_form_id?: number | string | null;
|
|
51
|
+
policy_id?: number | string | null;
|
|
52
|
+
form_id?: AvailabilityId;
|
|
53
|
+
main_field?: unknown;
|
|
54
|
+
}
|
|
42
55
|
export interface UnifiedBookingSalesLoadProductsByScheduleDateParams extends Omit<ProductListLoadProductsParams, 'schedule_date' | 'product_ids'> {
|
|
43
56
|
date: string;
|
|
44
57
|
product_ids?: number[];
|
|
@@ -167,7 +180,9 @@ export interface ContextualCommitAvailabilitySelectionParams {
|
|
|
167
180
|
availabilityCommitGuard?: () => void;
|
|
168
181
|
productLineUid?: string;
|
|
169
182
|
/**
|
|
170
|
-
* Confirmed complete Party extras set (configured,
|
|
183
|
+
* Confirmed complete Party extras set (configured, purchase-time-repriced retail source products).
|
|
184
|
+
* Their legacy venue_booking_service_datetime metadata stores the venue-local quote time,
|
|
185
|
+
* independently of the main product's appointment time.
|
|
171
186
|
* Required for replace; edit opts into the same atomic path. Existing extras keep their own
|
|
172
187
|
* metadata.unique_identification_number; new extras omit it. [] explicitly removes all owned extras.
|
|
173
188
|
*/
|
|
@@ -9,4 +9,5 @@ let UnifiedBookingSalesHooks = exports.UnifiedBookingSalesHooks = /*#__PURE__*/f
|
|
|
9
9
|
UnifiedBookingSalesHooks["onAvailabilitySelectionCommitted"] = "unifiedBookingSales:onAvailabilitySelectionCommitted";
|
|
10
10
|
UnifiedBookingSalesHooks["onAvailabilityProjectionDiagnostic"] = "unifiedBookingSales:onAvailabilityProjectionDiagnostic";
|
|
11
11
|
return UnifiedBookingSalesHooks;
|
|
12
|
-
}({});
|
|
12
|
+
}({});
|
|
13
|
+
/** Original resource metadata. form_id is its resource type, not an associated customer form. */
|