@pisell/pisellos 2.3.190 → 2.3.192
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 +0 -9
- 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.d.ts +13 -5
- package/dist/modules/Order/index.js +1053 -554
- package/dist/modules/Order/types.d.ts +20 -1
- package/dist/modules/Order/types.js +4 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ProductList/clientDataVariants.js +6 -2
- package/dist/modules/ProductList/index.d.ts +2 -0
- package/dist/modules/ProductList/index.js +125 -39
- package/dist/modules/ResourcePlanner/planner.js +5 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +1105 -976
- package/dist/shared/receipt/small-ticket.js +33 -5
- package/dist/solution/BaseSales/index.d.ts +14 -3
- package/dist/solution/BaseSales/index.js +285 -195
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/UnifiedBookingSales/catalogQueryBatch.d.ts +21 -0
- package/dist/solution/UnifiedBookingSales/catalogQueryBatch.js +202 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +49 -1
- package/dist/solution/UnifiedBookingSales/index.js +2276 -902
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +4 -0
- package/dist/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
- package/dist/solution/UnifiedBookingSales/sessionResourceCache.js +271 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +64 -1
- package/dist/solution/UnifiedBookingSales/types.js +7 -1
- package/dist/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
- package/dist/solution/UnifiedBookingSales/venueCatalogSession.js +277 -0
- 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.d.ts +13 -5
- package/lib/modules/Order/index.js +208 -7
- package/lib/modules/Order/types.d.ts +20 -1
- package/lib/modules/Order/types.js +2 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ProductList/clientDataVariants.js +6 -2
- package/lib/modules/ProductList/index.d.ts +2 -0
- package/lib/modules/ProductList/index.js +56 -0
- package/lib/modules/ResourcePlanner/planner.js +4 -0
- package/lib/server/index.d.ts +3 -0
- package/lib/server/index.js +86 -5
- package/lib/shared/receipt/small-ticket.js +30 -5
- package/lib/solution/BaseSales/index.d.ts +14 -3
- package/lib/solution/BaseSales/index.js +67 -2
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/UnifiedBookingSales/catalogQueryBatch.d.ts +21 -0
- package/lib/solution/UnifiedBookingSales/catalogQueryBatch.js +109 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +49 -1
- package/lib/solution/UnifiedBookingSales/index.js +872 -55
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +2 -0
- package/lib/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
- package/lib/solution/UnifiedBookingSales/sessionResourceCache.js +199 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +64 -1
- package/lib/solution/UnifiedBookingSales/types.js +4 -1
- package/lib/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
- package/lib/solution/UnifiedBookingSales/venueCatalogSession.js +151 -0
- package/package.json +1 -1
|
@@ -85,6 +85,7 @@ const LABELS = {
|
|
|
85
85
|
cashReceived: 'Cash received',
|
|
86
86
|
changeDue: 'Change due',
|
|
87
87
|
eftpos: 'Eftpos',
|
|
88
|
+
creditCard: 'Credit card',
|
|
88
89
|
wallet: 'Wallet',
|
|
89
90
|
giftCard: 'Gift card',
|
|
90
91
|
pointCard: 'Point card',
|
|
@@ -131,6 +132,7 @@ const LABELS = {
|
|
|
131
132
|
cashReceived: '收取现金',
|
|
132
133
|
changeDue: '找零',
|
|
133
134
|
eftpos: '刷卡支付',
|
|
135
|
+
creditCard: '信用卡',
|
|
134
136
|
wallet: '钱包支付',
|
|
135
137
|
giftCard: '礼品卡',
|
|
136
138
|
pointCard: '积分卡',
|
|
@@ -177,6 +179,7 @@ const LABELS = {
|
|
|
177
179
|
cashReceived: '收取現金',
|
|
178
180
|
changeDue: '找零',
|
|
179
181
|
eftpos: '刷卡支付',
|
|
182
|
+
creditCard: '信用卡',
|
|
180
183
|
wallet: '錢包支付',
|
|
181
184
|
giftCard: '禮品卡',
|
|
182
185
|
pointCard: '積分卡',
|
|
@@ -221,6 +224,7 @@ const LABELS = {
|
|
|
221
224
|
asap: 'できるだけ早く',
|
|
222
225
|
cash: '現金',
|
|
223
226
|
eftpos: 'カード',
|
|
227
|
+
creditCard: 'クレジットカード',
|
|
224
228
|
wallet: 'ウォレット',
|
|
225
229
|
giftCard: 'ギフトカード',
|
|
226
230
|
pointCard: 'ポイントカード',
|
|
@@ -266,6 +270,7 @@ const LABELS = {
|
|
|
266
270
|
asap: 'Assim que possível',
|
|
267
271
|
cash: 'Dinheiro',
|
|
268
272
|
eftpos: 'Cartão',
|
|
273
|
+
creditCard: 'Cartão de crédito',
|
|
269
274
|
wallet: 'Carteira',
|
|
270
275
|
giftCard: 'Cartão-presente',
|
|
271
276
|
pointCard: 'Cartão de pontos',
|
|
@@ -2438,12 +2443,30 @@ function appendMaskedCardCode(name, code) {
|
|
|
2438
2443
|
function trimDecimal(value) {
|
|
2439
2444
|
return value.toDecimalPlaces(2).toFixed(2).replace(/\.?0+$/, '');
|
|
2440
2445
|
}
|
|
2446
|
+
function getLocalizedPaymentName(value, locale) {
|
|
2447
|
+
if (typeof value === 'string') return value.trim();
|
|
2448
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return '';
|
|
2449
|
+
const candidates = [value[locale], value[locale.replace('_', '-')], value[locale.replace('-', '_')], value.original, value.auto, value.default, value.en];
|
|
2450
|
+
for (const candidate of candidates) {
|
|
2451
|
+
if (typeof candidate === 'string' && candidate.trim()) return candidate.trim();
|
|
2452
|
+
}
|
|
2453
|
+
return '';
|
|
2454
|
+
}
|
|
2455
|
+
function getExplicitPaymentName(payment, locale) {
|
|
2456
|
+
// Cloud order snapshots retain the localized name in metadata after reload.
|
|
2457
|
+
const candidates = [payment.name, payment.title, payment.payment_method_name, payment.method_name, payment.metadata?.custom_payment_name];
|
|
2458
|
+
for (const candidate of candidates) {
|
|
2459
|
+
const name = getLocalizedPaymentName(candidate, locale);
|
|
2460
|
+
if (name) return name;
|
|
2461
|
+
}
|
|
2462
|
+
return '';
|
|
2463
|
+
}
|
|
2441
2464
|
function getFundRecordPaymentName(payment, locale) {
|
|
2442
2465
|
const fundRecord = getFundRecord(payment);
|
|
2443
2466
|
if (!fundRecord) return '';
|
|
2444
|
-
const name =
|
|
2467
|
+
const name = getLocalizedPaymentName(fundRecord.wallet_pass_name, locale);
|
|
2445
2468
|
if (!name && !maskMachineCode(fundRecord.code)) return '';
|
|
2446
|
-
const fallbackName =
|
|
2469
|
+
const fallbackName = getExplicitPaymentName(payment, locale) || getLocalizedPaymentName(payment.code, locale);
|
|
2447
2470
|
return appendMaskedCardCode(name || fallbackName, fundRecord.code);
|
|
2448
2471
|
}
|
|
2449
2472
|
function appendMachineCodeToName(name, payment) {
|
|
@@ -2453,13 +2476,15 @@ function appendMachineCodeToName(name, payment) {
|
|
|
2453
2476
|
function paymentMethodName(payment, locale) {
|
|
2454
2477
|
const fundRecordName = getFundRecordPaymentName(payment, locale);
|
|
2455
2478
|
if (fundRecordName) return fundRecordName;
|
|
2456
|
-
const
|
|
2457
|
-
if (
|
|
2479
|
+
const name = getExplicitPaymentName(payment, locale);
|
|
2480
|
+
if (name) return appendMachineCodeToName(name, payment);
|
|
2458
2481
|
const code = stringify(payment.code || payment.type || payment.payment_method || payment.method).toLowerCase();
|
|
2459
2482
|
if (code.includes('cash')) return label(locale, 'cash');
|
|
2460
|
-
if (code.includes('eftpos')
|
|
2483
|
+
if (code.includes('eftpos')) return label(locale, 'eftpos');
|
|
2461
2484
|
if (code.includes('wallet')) return label(locale, 'wallet');
|
|
2462
2485
|
if (code.includes('gift')) return label(locale, 'giftCard');
|
|
2486
|
+
if (code === 'credit_card' || code.startsWith('credit_card_')) return label(locale, 'creditCard');
|
|
2487
|
+
if (code.includes('card')) return label(locale, 'eftpos');
|
|
2463
2488
|
return stringify(payment.code || payment.type || payment.payment_method || payment.method);
|
|
2464
2489
|
}
|
|
2465
2490
|
function getSummary(order) {
|
|
@@ -7,7 +7,7 @@ import { OrderModule } from '../../modules/Order';
|
|
|
7
7
|
import { type PickupTimingBookingInput } from '../../modules/Order/pickupTiming';
|
|
8
8
|
import type { PickupTimingAvailability, PickupTimingSelection, PickupTimingValidationResult } from '../../modules/FulfillmentTiming';
|
|
9
9
|
import { type ContactInfoConfig } from '../../modules/OpenData/contactInfo';
|
|
10
|
-
import type { AddProductBookingInput, AddProductToOrderOptions, LoadSalesDetailParams, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, OrderTempOrder, OrderSummary, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, ReplaceTempOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, ShopServiceData, ShopServiceType } from '../../modules/Order/types';
|
|
10
|
+
import type { AddProductBookingInput, AddProductToOrderOptions, LoadSalesDetailParams, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductsOptions, OrderTempOrder, OrderSummary, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, ReplaceTempOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, ShopServiceData, ShopServiceType } from '../../modules/Order/types';
|
|
11
11
|
import type { SubmitPayloadEnhancer } from '../../modules/Order/utils';
|
|
12
12
|
import type { Discount, VirtualCurrencyAsset } from '../../modules/Discount/types';
|
|
13
13
|
import { RequestPlugin, WindowPlugin } from '../../plugins';
|
|
@@ -135,7 +135,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
135
135
|
* /product/query 的智能定价评估只读取 strategy_context;
|
|
136
136
|
* application_code 仅作为接口兼容字段,不能替代 channel / business_code。
|
|
137
137
|
*/
|
|
138
|
-
|
|
138
|
+
protected getPriceQueryStrategyContext(channel?: string): Record<string, any>;
|
|
139
139
|
/**
|
|
140
140
|
* 子类可在商品重报价前准备客户维度的策略上下文,例如等待 Wallet/优惠资产加载。
|
|
141
141
|
*/
|
|
@@ -162,6 +162,12 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
162
162
|
private prepareRawProductForPriceQuery;
|
|
163
163
|
private resolveLocalProductForPriceQuery;
|
|
164
164
|
private loadProductsForPriceQuery;
|
|
165
|
+
/** Opt-in subclasses may supply page-owned raw pools; ordinary sales keep remote fallback. */
|
|
166
|
+
protected isVenueCatalogLocalPricingActive(): boolean;
|
|
167
|
+
protected getVenueCatalogLocalPriceSource(_productId: number, _selectedProduct?: Record<string, any>): {
|
|
168
|
+
product: Record<string, any>;
|
|
169
|
+
menuList: Record<string, any>[];
|
|
170
|
+
} | undefined;
|
|
165
171
|
private resolveProductsForPriceQuery;
|
|
166
172
|
private getAuthoritativeBundleItems;
|
|
167
173
|
private findAuthoritativeBundleItem;
|
|
@@ -535,6 +541,11 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
535
541
|
submitBeforeSend?: boolean;
|
|
536
542
|
}): Promise<T>;
|
|
537
543
|
transformBaseProductToOrderProduct(params: TransformBaseProductToOrderProductParams): import("./utils/transformBaseProductToOrderProduct").BaseProductOrderProductInput | null;
|
|
544
|
+
/** Explicit pool source avoids races between two simultaneous Venue pricing contexts. */
|
|
545
|
+
protected calculateVenueCatalogProductBookingPrice(params: BaseSalesCalculateProductBookingPriceParams, source: {
|
|
546
|
+
product: Record<string, any>;
|
|
547
|
+
menuList: Record<string, any>[];
|
|
548
|
+
}): Promise<BaseSalesProductBookingPriceResult>;
|
|
538
549
|
calculateProductBookingPrice(params: BaseSalesCalculateProductBookingPriceParams): Promise<BaseSalesProductBookingPriceResult>;
|
|
539
550
|
getQuotationCustomerScopeInfo(): BaseSalesQuotationCustomerScopeInfo;
|
|
540
551
|
private hasSmartPricingStrategies;
|
|
@@ -548,7 +559,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
548
559
|
validateProductVoucherSelection(): void;
|
|
549
560
|
addProductToOrder(product: Partial<BaseSalesOrderProduct> & BaseSalesOrderProductIdentity, booking?: AddProductBookingInput, options?: AddProductToOrderOptions): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
550
561
|
updateOrderProduct(params: UpdateOrderProductParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
551
|
-
updateOrderProducts(paramsList: UpdateOrderProductParams[]): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
562
|
+
updateOrderProducts(paramsList: UpdateOrderProductParams[], options?: UpdateOrderProductsOptions): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
552
563
|
updateOrderProductQuantity(params: BaseSalesUpdateOrderProductQuantityParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
553
564
|
updateOrderBooking(params: UpdateOrderBookingParams): any[];
|
|
554
565
|
/**
|
|
@@ -1058,6 +1058,9 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
1058
1058
|
products: [preparedProduct],
|
|
1059
1059
|
queryPayload: params.queryPayload,
|
|
1060
1060
|
handledByOsServer: false,
|
|
1061
|
+
...(params.menuList ? {
|
|
1062
|
+
menuList: params.menuList
|
|
1063
|
+
} : {}),
|
|
1061
1064
|
...(scheduleList ? {
|
|
1062
1065
|
scheduleList
|
|
1063
1066
|
} : {})
|
|
@@ -1113,6 +1116,14 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
1113
1116
|
return productsById;
|
|
1114
1117
|
}
|
|
1115
1118
|
}
|
|
1119
|
+
|
|
1120
|
+
/** Opt-in subclasses may supply page-owned raw pools; ordinary sales keep remote fallback. */
|
|
1121
|
+
isVenueCatalogLocalPricingActive() {
|
|
1122
|
+
return false;
|
|
1123
|
+
}
|
|
1124
|
+
getVenueCatalogLocalPriceSource(_productId, _selectedProduct) {
|
|
1125
|
+
return undefined;
|
|
1126
|
+
}
|
|
1116
1127
|
async resolveProductsForPriceQuery(params) {
|
|
1117
1128
|
const selectedProducts = params.priceQueries.map(item => item.product || {});
|
|
1118
1129
|
const productIds = selectedProducts.map(product => this.getPriceQueryProductId(product));
|
|
@@ -1120,6 +1131,30 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
1120
1131
|
if (!ids.length) {
|
|
1121
1132
|
return selectedProducts.map(() => null);
|
|
1122
1133
|
}
|
|
1134
|
+
|
|
1135
|
+
// An explicitly active Venue pool owns all its product reads. Missing raw data
|
|
1136
|
+
// or rules must fail visibly; never silently spend a second list/detail request.
|
|
1137
|
+
if (this.isVenueCatalogLocalPricingActive()) {
|
|
1138
|
+
const queryPayload = this.buildPriceQueryPayload({
|
|
1139
|
+
ids,
|
|
1140
|
+
schedule: params.schedule,
|
|
1141
|
+
customerId: params.customerId,
|
|
1142
|
+
channel: params.channel
|
|
1143
|
+
});
|
|
1144
|
+
return selectedProducts.map((selectedProduct, index) => {
|
|
1145
|
+
const source = productIds[index] == null ? undefined : this.getVenueCatalogLocalPriceSource(productIds[index], selectedProduct);
|
|
1146
|
+
const resolved = source && this.resolveLocalProductForPriceQuery({
|
|
1147
|
+
selectedProduct,
|
|
1148
|
+
rawProduct: source.product,
|
|
1149
|
+
menuList: source.menuList,
|
|
1150
|
+
queryPayload
|
|
1151
|
+
});
|
|
1152
|
+
if (!resolved) throw Object.assign(new Error('The complete venue product or pricing rules are not ready. Reload the catalog before continuing.'), {
|
|
1153
|
+
code: 'VENUE_LOCAL_PRICE_UNAVAILABLE'
|
|
1154
|
+
});
|
|
1155
|
+
return resolved;
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1123
1158
|
const handledByOsServer = this.request ? (0, _clientDataVariants.isProductQueryHandledByOsServer)(this.core, this.request) : false;
|
|
1124
1159
|
const canUseLocalFastPath = this.isCustomerUserPriceQuery() && !handledByOsServer;
|
|
1125
1160
|
if (!canUseLocalFastPath) {
|
|
@@ -4224,6 +4259,36 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
4224
4259
|
transformBaseProductToOrderProduct(params) {
|
|
4225
4260
|
return (0, _transformBaseProductToOrderProduct.transformBaseProductToOrderProduct)(params);
|
|
4226
4261
|
}
|
|
4262
|
+
|
|
4263
|
+
/** Explicit pool source avoids races between two simultaneous Venue pricing contexts. */
|
|
4264
|
+
async calculateVenueCatalogProductBookingPrice(params, source) {
|
|
4265
|
+
const customerId = params.customer_id ?? this.getCurrentOrderCustomerId();
|
|
4266
|
+
await this.prepareProductPriceQueryContext(customerId);
|
|
4267
|
+
const channel = this.getPriceQueryChannel(params.channel);
|
|
4268
|
+
const queryPayload = this.buildPriceQueryPayload({
|
|
4269
|
+
ids: [Number(source.product.id)],
|
|
4270
|
+
schedule: this.getPriceQuerySchedule(params),
|
|
4271
|
+
customerId,
|
|
4272
|
+
channel
|
|
4273
|
+
});
|
|
4274
|
+
const authoritativeProduct = this.resolveLocalProductForPriceQuery({
|
|
4275
|
+
selectedProduct: params.product,
|
|
4276
|
+
rawProduct: source.product,
|
|
4277
|
+
menuList: source.menuList,
|
|
4278
|
+
queryPayload
|
|
4279
|
+
});
|
|
4280
|
+
if (!authoritativeProduct) throw Object.assign(new Error('Complete product pricing rules are not ready. Please retry.'), {
|
|
4281
|
+
code: 'VENUE_LOCAL_PRICE_UNAVAILABLE'
|
|
4282
|
+
});
|
|
4283
|
+
return (0, _quotationPrice.calculateBaseSalesProductBookingPrice)({
|
|
4284
|
+
...params,
|
|
4285
|
+
channel,
|
|
4286
|
+
customer_id: customerId,
|
|
4287
|
+
product: this.mergeProductForPriceQuery(params.product, authoritativeProduct),
|
|
4288
|
+
fallback_price: undefined,
|
|
4289
|
+
quotation: undefined
|
|
4290
|
+
});
|
|
4291
|
+
}
|
|
4227
4292
|
async calculateProductBookingPrice(params) {
|
|
4228
4293
|
const [result] = await this.calculateProductBookingPrices([params]);
|
|
4229
4294
|
return result;
|
|
@@ -4471,10 +4536,10 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
4471
4536
|
throw error;
|
|
4472
4537
|
}
|
|
4473
4538
|
}
|
|
4474
|
-
async updateOrderProducts(paramsList) {
|
|
4539
|
+
async updateOrderProducts(paramsList, options) {
|
|
4475
4540
|
try {
|
|
4476
4541
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
4477
|
-
const products = await this.store.order.updateOrderProducts(paramsList);
|
|
4542
|
+
const products = await this.store.order.updateOrderProducts(paramsList, options);
|
|
4478
4543
|
return products;
|
|
4479
4544
|
} catch (error) {
|
|
4480
4545
|
throw error;
|
|
@@ -328,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
328
328
|
date: string;
|
|
329
329
|
status: string;
|
|
330
330
|
week: string;
|
|
331
|
-
weekNum: 0 |
|
|
331
|
+
weekNum: 0 | 1 | 2 | 3 | 5 | 4 | 6;
|
|
332
332
|
}[]>;
|
|
333
333
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
334
334
|
private getScheduleDataByIds;
|
|
@@ -375,7 +375,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
375
375
|
};
|
|
376
376
|
setOtherData(key: string, value: any): void;
|
|
377
377
|
getOtherData(key: string): any;
|
|
378
|
-
getProductTypeById(id: number): Promise<"
|
|
378
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
379
379
|
/**
|
|
380
380
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
381
381
|
*
|
|
@@ -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, UnifiedBookingSalesVenueCatalogSession, UnifiedBookingSalesVenueCatalogSessionParams, 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 { BaseSalesSubmitSalesOrderParams } from '../BaseSales/types';
|
|
@@ -72,8 +72,13 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
72
72
|
private runtimeOpenDataModule;
|
|
73
73
|
private runtimeOpenDataCore;
|
|
74
74
|
private runtimeOpenDataGeneration;
|
|
75
|
+
private runtimeInitializationGeneration;
|
|
75
76
|
private runtimeOpenDataDestroyed;
|
|
76
77
|
private unifiedProductCatalog;
|
|
78
|
+
private venueCatalogSessions;
|
|
79
|
+
private venueCatalogSessionKey?;
|
|
80
|
+
private venueCatalogMenus?;
|
|
81
|
+
private venueVariantDetails;
|
|
77
82
|
private availabilityRuntimeOffsetMinutes;
|
|
78
83
|
private availabilityScheduleCatalog;
|
|
79
84
|
private availabilityProjectionSequence;
|
|
@@ -84,6 +89,7 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
84
89
|
private availabilityPrepareInFlight;
|
|
85
90
|
private availabilityProjectionRefreshInFlight;
|
|
86
91
|
private availabilityRemoteOccupancyCache;
|
|
92
|
+
private availabilitySessionResourceCache;
|
|
87
93
|
private availabilityRemoteResourceQueryInFlight;
|
|
88
94
|
private availabilityRemoteResourceQuerySequence;
|
|
89
95
|
private availabilityRemoteResourceEpoch;
|
|
@@ -231,6 +237,42 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
231
237
|
callback?: (result: any) => void;
|
|
232
238
|
subscriberId?: string;
|
|
233
239
|
}): Promise<ProductData[]>;
|
|
240
|
+
/**
|
|
241
|
+
* Queries one explicitly configured menu scope without publishing the sales catalog.
|
|
242
|
+
* The returned graph is detached from ProductList's shared ID cache. Callers own its
|
|
243
|
+
* membership and must requery/reprice with the service datetime after a context change.
|
|
244
|
+
* Missing/invalid menu configuration fails closed instead of querying every product.
|
|
245
|
+
*/
|
|
246
|
+
queryCatalogSnapshot(params: ProductListLoadProductsParams): Promise<ProductData[]>;
|
|
247
|
+
/** Full SKU/bundle detail, after verifying membership in the explicit day/menu scope. */
|
|
248
|
+
queryCatalogProductDetail(params: ProductListLoadProductsParams & {
|
|
249
|
+
product_id: number;
|
|
250
|
+
}): Promise<ProductData | undefined>;
|
|
251
|
+
protected isVenueCatalogLocalPricingActive(): boolean;
|
|
252
|
+
protected getVenueCatalogLocalPriceSource(productId: number, selectedProduct?: Record<string, any>): {
|
|
253
|
+
product: Record<string, any>;
|
|
254
|
+
menuList: Record<string, any>[];
|
|
255
|
+
} | undefined;
|
|
256
|
+
getProductByIds(ids: number[], options?: {
|
|
257
|
+
loadMissing?: boolean;
|
|
258
|
+
}): Promise<ProductData[]>;
|
|
259
|
+
private getVenueCatalogHydratedProduct;
|
|
260
|
+
/** Explicit user opening for legacy promotion/gift SKU hosts. Pure readers never call this. */
|
|
261
|
+
prepareVenueCatalogProductDetail(params: {
|
|
262
|
+
product_id: number;
|
|
263
|
+
retry?: boolean;
|
|
264
|
+
}): Promise<ProductData | undefined>;
|
|
265
|
+
private hydrateVenueVariantDetail;
|
|
266
|
+
/** One complete raw product query per explicitly configured pool for this page lifetime. */
|
|
267
|
+
createVenueCatalogSession(params: UnifiedBookingSalesVenueCatalogSessionParams): UnifiedBookingSalesVenueCatalogSession;
|
|
268
|
+
/**
|
|
269
|
+
* Opt-in calendar/card preview batching. Results expire after sixty seconds or a
|
|
270
|
+
* runtime change; the next read starts a fresh clock/cache. Selection and submit
|
|
271
|
+
* must keep using the ordinary fresh query methods. Call dispose on owner cleanup.
|
|
272
|
+
*/
|
|
273
|
+
createCatalogQueryBatch(): UnifiedBookingSalesCatalogQueryBatch;
|
|
274
|
+
private loadCatalogProductDetail;
|
|
275
|
+
private loadCatalogProducts;
|
|
234
276
|
queryProducts(params?: ProductListStoreQueryParams): Promise<ProductData[]>;
|
|
235
277
|
/** Date-first entry point. It delegates protocol details and cache ownership to ScheduleModule. */
|
|
236
278
|
loadScheduleAvailableDate(params: LoadScheduleAvailableDateParams): Promise<import("../../modules/Date/types").ITime[]>;
|
|
@@ -263,6 +305,8 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
263
305
|
* Its staged lines have separate ownership so planner and retail skins can coexist safely.
|
|
264
306
|
*/
|
|
265
307
|
stageRetailProducts(params: UnifiedBookingSalesStageRetailProductsParams): Promise<Record<string, any> | null>;
|
|
308
|
+
/** Explicit capability: order-scoped Tickets extras use guarded writes without implicit SKU merging. */
|
|
309
|
+
supportsVenueTicketExtras(): boolean;
|
|
266
310
|
/**
|
|
267
311
|
* Adds one retail line without replacing the cart's existing retail selection.
|
|
268
312
|
* This is intentionally separate from stageRetailProducts(), whose contract is
|
|
@@ -282,6 +326,8 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
282
326
|
* resource dates endpoint.
|
|
283
327
|
*/
|
|
284
328
|
private fetchAvailabilityResourcesV2;
|
|
329
|
+
/** Fresh read-only metadata for confirmation forms/policies; does not create a projection or mutate BookingContext. */
|
|
330
|
+
queryBookingResourceDetails(params: UnifiedBookingSalesQueryBookingResourceDetailsParams): Promise<UnifiedBookingSalesResourceDetail[]>;
|
|
285
331
|
private fetchAndPublishAvailabilityResourcesV2;
|
|
286
332
|
private refreshAvailabilityRemoteResourceQuery;
|
|
287
333
|
private loadAvailabilityResources;
|
|
@@ -308,6 +354,8 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
308
354
|
getProductTimeRanges(contextId: string, request?: GetProductTimeRangesRequest): Promise<ContextualProductTimeRangeGroup[]>;
|
|
309
355
|
/** Thin facade: auto-refresh on cart drift, then delegate to the pure projection query. */
|
|
310
356
|
queryBookingAvailability(contextId: string, request: ContextualAvailabilityQuery): Promise<ContextualAvailabilityQueryResult>;
|
|
357
|
+
/** Reads detached resource metadata from the current context; never refreshes or performs I/O. */
|
|
358
|
+
getAvailabilityResources(contextId: string, expectedVersion?: number): AvailabilityResource[];
|
|
311
359
|
releaseAvailabilityContext(contextId: string): void;
|
|
312
360
|
private assertAvailabilityCommitWriteCAS;
|
|
313
361
|
private findProductLineByUid;
|