@pisell/pisellos 0.10.72 → 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/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/BookingContext/index.d.ts +2 -2
- package/dist/modules/BookingContext/index.js +55 -25
- package/dist/modules/BookingContext/types.d.ts +2 -0
- 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/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/BookingContext/index.d.ts +2 -2
- package/lib/modules/BookingContext/index.js +42 -10
- package/lib/modules/BookingContext/types.d.ts +2 -0
- 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. */
|
|
@@ -1 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
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; }
|
|
@@ -12,7 +12,7 @@ export * from './utils';
|
|
|
12
12
|
export declare function __clearBookingContextSharedCacheForTest(): void;
|
|
13
13
|
/** 稳定序列化 config 查询参数,用于判断是否与上次 loadBookingConfig 一致。 */
|
|
14
14
|
export declare function buildBookingConfigQueryKey(params?: LoadBookingConfigParams): string;
|
|
15
|
-
/** 稳定序列化资源列表查询(date + bookingIds
|
|
15
|
+
/** 稳定序列化资源列表查询(date + bookingIds + resourceIds)。 */
|
|
16
16
|
export declare function buildBookingResourcesQueryKey(params?: LoadBookingResourcesParams): string;
|
|
17
17
|
export declare class BookingContextModule extends BaseModule implements Module, BookingContextModuleAPI {
|
|
18
18
|
protected defaultName: string;
|
|
@@ -22,7 +22,7 @@ export declare class BookingContextModule extends BaseModule implements Module,
|
|
|
22
22
|
private otherParams;
|
|
23
23
|
/** 上次成功 loadBookingConfig 的 query key;命中则不再请求。 */
|
|
24
24
|
private lastConfigQueryKey;
|
|
25
|
-
/** 上次成功 loadResources 的 query key
|
|
25
|
+
/** 上次成功 loadResources 的 query key(接口合同 + 日期/预约/资源范围)。 */
|
|
26
26
|
private lastResourcesQueryKey;
|
|
27
27
|
constructor(name?: string, version?: string);
|
|
28
28
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
@@ -190,12 +190,38 @@ function resolveBookingConfigRequest(platform, params = {}) {
|
|
|
190
190
|
key: `${endpoint}:${JSON.stringify(sortedQuery)}`
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
|
+
function normalizeBookingResourceIds(ids) {
|
|
194
|
+
return [...new Set((ids || []).map(id => String(id).trim()).filter(Boolean))].sort();
|
|
195
|
+
}
|
|
193
196
|
|
|
194
|
-
/** 稳定序列化资源列表查询(date + bookingIds
|
|
197
|
+
/** 稳定序列化资源列表查询(date + bookingIds + resourceIds)。 */
|
|
195
198
|
function buildBookingResourcesQueryKey(params = {}) {
|
|
196
199
|
const date = toScheduleQueryDate(params.date);
|
|
197
200
|
const ids = (params.bookingIds || []).filter(id => typeof id === 'number' && Number.isFinite(id)).sort((a, b) => a - b);
|
|
198
|
-
|
|
201
|
+
const resourceIds = normalizeBookingResourceIds(params.resourceIds);
|
|
202
|
+
return `${date}|${ids.join(',')}${resourceIds.length ? `|resources:${JSON.stringify(resourceIds)}` : ''}`;
|
|
203
|
+
}
|
|
204
|
+
function resolveBookingResourcesRequest(platform, params) {
|
|
205
|
+
const date = toScheduleQueryDate(params.date);
|
|
206
|
+
const isCustomerPlatform = (0, _platform.isCustomerUserPlatform)(platform);
|
|
207
|
+
const resourceIds = normalizeBookingResourceIds(params.resourceIds);
|
|
208
|
+
return {
|
|
209
|
+
// The customer endpoint uses the same inclusive date range as DateModule.
|
|
210
|
+
// Keep the public date contract and the staff endpoint's existing query.
|
|
211
|
+
query: isCustomerPlatform ? {
|
|
212
|
+
start_date: date,
|
|
213
|
+
end_date: date,
|
|
214
|
+
...(resourceIds.length ? {
|
|
215
|
+
resource_ids: resourceIds
|
|
216
|
+
} : {})
|
|
217
|
+
} : {
|
|
218
|
+
date
|
|
219
|
+
},
|
|
220
|
+
key: `${isCustomerPlatform ? 'customer' : 'staff'}:${buildBookingResourcesQueryKey({
|
|
221
|
+
...params,
|
|
222
|
+
date
|
|
223
|
+
})}`
|
|
224
|
+
};
|
|
199
225
|
}
|
|
200
226
|
class BookingContextModule extends _BaseModule.BaseModule {
|
|
201
227
|
defaultName = 'bookingContext';
|
|
@@ -207,7 +233,7 @@ class BookingContextModule extends _BaseModule.BaseModule {
|
|
|
207
233
|
otherParams = {};
|
|
208
234
|
/** 上次成功 loadBookingConfig 的 query key;命中则不再请求。 */
|
|
209
235
|
lastConfigQueryKey = null;
|
|
210
|
-
/** 上次成功 loadResources 的 query key
|
|
236
|
+
/** 上次成功 loadResources 的 query key(接口合同 + 日期/预约/资源范围)。 */
|
|
211
237
|
lastResourcesQueryKey = null;
|
|
212
238
|
constructor(name, version) {
|
|
213
239
|
super(name, version);
|
|
@@ -277,9 +303,13 @@ class BookingContextModule extends _BaseModule.BaseModule {
|
|
|
277
303
|
}
|
|
278
304
|
async loadResources(params = {}, options = {}) {
|
|
279
305
|
const date = toScheduleQueryDate(params.date ?? this.store.date);
|
|
280
|
-
const
|
|
306
|
+
const {
|
|
307
|
+
query,
|
|
308
|
+
key: resourcesKey
|
|
309
|
+
} = resolveBookingResourcesRequest(this.otherParams?.platform, {
|
|
281
310
|
date,
|
|
282
|
-
bookingIds: params.bookingIds
|
|
311
|
+
bookingIds: params.bookingIds,
|
|
312
|
+
resourceIds: params.resourceIds
|
|
283
313
|
});
|
|
284
314
|
if (!options.forceRefresh && this.lastResourcesQueryKey === resourcesKey) {
|
|
285
315
|
return this.getResourcesOrigin();
|
|
@@ -295,9 +325,7 @@ class BookingContextModule extends _BaseModule.BaseModule {
|
|
|
295
325
|
if (!pending) {
|
|
296
326
|
const requestPromise = (async () => {
|
|
297
327
|
try {
|
|
298
|
-
const res = await this.request.get('/schedule/resource/list',
|
|
299
|
-
date
|
|
300
|
-
}, RESOURCE_LIST_CACHE);
|
|
328
|
+
const res = await this.request.get('/schedule/resource/list', query, RESOURCE_LIST_CACHE);
|
|
301
329
|
const {
|
|
302
330
|
list
|
|
303
331
|
} = (0, _formatResourceList.formatResourceListAndMap)(res?.data, params.bookingIds || []);
|
|
@@ -323,7 +351,9 @@ class BookingContextModule extends _BaseModule.BaseModule {
|
|
|
323
351
|
const configKey = resolveBookingConfigRequest(this.otherParams?.platform, params.bookingConfigParams).key;
|
|
324
352
|
const dateInput = params.date ?? this.store.date ?? (0, _dayjs.default)();
|
|
325
353
|
const queryDate = toScheduleQueryDate(dateInput);
|
|
326
|
-
const
|
|
354
|
+
const {
|
|
355
|
+
key: resourcesKey
|
|
356
|
+
} = resolveBookingResourcesRequest(this.otherParams?.platform, {
|
|
327
357
|
date: queryDate,
|
|
328
358
|
bookingIds: params.bookingIds
|
|
329
359
|
});
|
|
@@ -339,7 +369,9 @@ class BookingContextModule extends _BaseModule.BaseModule {
|
|
|
339
369
|
return this.getState();
|
|
340
370
|
}
|
|
341
371
|
const configKey = resolveBookingConfigRequest(this.otherParams?.platform, params.bookingConfigParams).key;
|
|
342
|
-
const
|
|
372
|
+
const {
|
|
373
|
+
key: resourcesKey
|
|
374
|
+
} = resolveBookingResourcesRequest(this.otherParams?.platform, {
|
|
343
375
|
date: queryDate,
|
|
344
376
|
bookingIds: params.bookingIds
|
|
345
377
|
});
|
|
@@ -22,6 +22,8 @@ export interface LoadBookingConfigParams {
|
|
|
22
22
|
export interface LoadBookingResourcesParams {
|
|
23
23
|
/** 查询日期,`YYYY-MM-DD`;缺省用 store 内已 set 的 date,再缺省为当天。 */
|
|
24
24
|
date?: string;
|
|
25
|
+
/** 用户端查询的资源 ID;PC/H5 资源接口需要显式范围才会返回对应实体。 */
|
|
26
|
+
resourceIds?: Array<number | string>;
|
|
25
27
|
/** 编辑态排除容量占用用的 booking id 列表。 */
|
|
26
28
|
bookingIds?: number[];
|
|
27
29
|
}
|
|
@@ -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 |
|
|
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. */
|