@pisell/pisellos 2.3.180 → 2.3.181
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/Product/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts +4 -0
- package/dist/solution/UnifiedBookingSales/index.js +719 -554
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +4 -0
- package/lib/solution/UnifiedBookingSales/index.js +76 -0
- package/package.json +1 -1
|
@@ -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" | "normal" | "session";
|
|
53
53
|
}
|
|
@@ -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 | 2 | 1 | 3 | 4 | 5 | 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<"duration" | "normal" | "session">;
|
|
379
379
|
/**
|
|
380
380
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
381
381
|
*
|
|
@@ -366,7 +366,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
366
366
|
* 获取当前的客户搜索条件
|
|
367
367
|
* @returns 当前搜索条件
|
|
368
368
|
*/
|
|
369
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
369
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
370
370
|
/**
|
|
371
371
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
372
372
|
* @returns 客户状态
|
|
@@ -9,6 +9,7 @@ import type { AvailabilityDateRange, AvailabilityOccupancy, AvailabilityProduct,
|
|
|
9
9
|
import type { AvailabilityContextRef, ContextualAvailabilityQuery, ContextualAvailabilityQueryResult, ContextualCommitAvailabilitySelectionParams, ContextualProductTimeRangeGroup, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesCommitAvailabilitySelectionResult, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesPrepareAvailabilityProjectionParams, UnifiedBookingSalesPolicyResponse, UnifiedBookingSalesResolveProductAllergyRequirementParams, UnifiedBookingSalesStageRetailProductsParams, UnifiedBookingSalesState } from './types';
|
|
10
10
|
import type { BusinessAvailability } from '../../modules/BusinessAvailability';
|
|
11
11
|
import { BookingTicket } from '../BookingTicket';
|
|
12
|
+
import type { BaseSalesSubmitSalesOrderParams } from '../BaseSales/types';
|
|
12
13
|
import type { AllergyRequirement } from '../../model/strategy/adapter/itemRule';
|
|
13
14
|
export * from './types';
|
|
14
15
|
export * from './salesSettings';
|
|
@@ -202,6 +203,9 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
202
203
|
protected loadPickupTimingOpenData(_force: boolean): Promise<Record<string, unknown>>;
|
|
203
204
|
private resetAllergyItemRuleState;
|
|
204
205
|
private fetchAllergyItemRuleConfigs;
|
|
206
|
+
/** Required products currently apply only to the online venue-ticket entry. */
|
|
207
|
+
validateRequiredProducts(): Promise<void>;
|
|
208
|
+
submitSalesOrder<T = any>(params?: BaseSalesSubmitSalesOrderParams): Promise<T>;
|
|
205
209
|
private ensureAllergyItemRuleConfigsLoaded;
|
|
206
210
|
/**
|
|
207
211
|
* 评估当前渠道与商品是否命中 ALLERGY_CHECK。
|
|
@@ -2203,6 +2203,82 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
2203
2203
|
throw error;
|
|
2204
2204
|
}
|
|
2205
2205
|
}
|
|
2206
|
+
|
|
2207
|
+
/** Required products currently apply only to the online venue-ticket entry. */
|
|
2208
|
+
async validateRequiredProducts() {
|
|
2209
|
+
const businessCode = String(this.otherParams?.businessCode ?? this.otherParams?.business_code ?? '').trim();
|
|
2210
|
+
const channel = String(this.otherParams?.channel ?? '').trim();
|
|
2211
|
+
if (businessCode !== 'venue_ticket' || channel !== 'online_ordering') return;
|
|
2212
|
+
const scope = this.getPickupTimingScope();
|
|
2213
|
+
const order = this.getTempOrder();
|
|
2214
|
+
const runtimeConfig = this.otherParams?.itemRule || {};
|
|
2215
|
+
let configs = normalizeItemRuleStrategyConfigs(runtimeConfig.strategyConfigs);
|
|
2216
|
+
if (!configs.length) {
|
|
2217
|
+
const openData = await this.getOpenData();
|
|
2218
|
+
if (!toConfiguredBoolean(openData?.['sale.enable_item_rules'])) return;
|
|
2219
|
+
const ids = normalizePositiveIntegerList(openData?.['sale.enabled_item_rules']);
|
|
2220
|
+
if (!ids.length) return;
|
|
2221
|
+
|
|
2222
|
+
// Checkout must not use the allergy loader's fail-open fallback.
|
|
2223
|
+
const response = await this.request.get('/promotion', {
|
|
2224
|
+
skip: 1,
|
|
2225
|
+
num: 99,
|
|
2226
|
+
status: 'active',
|
|
2227
|
+
ids
|
|
2228
|
+
});
|
|
2229
|
+
if (response?.code !== 200 || !Array.isArray(response?.data?.list)) {
|
|
2230
|
+
throw new Error('Unable to load required product rules. Please try again.');
|
|
2231
|
+
}
|
|
2232
|
+
// Configured IDs can include disabled or deleted rules; only active results participate.
|
|
2233
|
+
configs = normalizeItemRuleStrategyConfigs(response.data.list.filter(item => ids.includes(Number(item?.id))).map(item => item?.metadata));
|
|
2234
|
+
}
|
|
2235
|
+
if (scope !== this.getPickupTimingScope() || order !== this.getTempOrder()) {
|
|
2236
|
+
throw new Error('The order changed. Please try again.');
|
|
2237
|
+
}
|
|
2238
|
+
const strategyConfigs = configs.filter(config => Array.isArray(config.actions)).map(config => ({
|
|
2239
|
+
...config,
|
|
2240
|
+
actions: config.actions.filter(action => {
|
|
2241
|
+
const rules = action.config?.quantityRules;
|
|
2242
|
+
return action.type === 'QUANTITY_CHECK' && action.config?.targetType === 'product' && Array.isArray(rules) && rules.length > 0 && rules.every(rule => rule.source === 'fixed' && (rule.comparison === 'minimum' || rule.comparison === 'must_include'));
|
|
2243
|
+
})
|
|
2244
|
+
})).filter(config => config.actions.length > 0);
|
|
2245
|
+
if (!strategyConfigs.length) return;
|
|
2246
|
+
const cartItems = this.getOrderProducts().map(item => ({
|
|
2247
|
+
product_id: Number(item.product_id),
|
|
2248
|
+
quantity: Number(item.num)
|
|
2249
|
+
})).filter(item => Number.isFinite(item.product_id) && item.product_id > 0 && Number.isFinite(item.quantity) && item.quantity > 0);
|
|
2250
|
+
const result = new _itemRule.ItemRuleEvaluator().evaluate({
|
|
2251
|
+
strategyConfigs,
|
|
2252
|
+
cartItems,
|
|
2253
|
+
// Fixed-quantity rules do not consume pax; no customer headcount is collected.
|
|
2254
|
+
pax: {
|
|
2255
|
+
total: 0,
|
|
2256
|
+
adult: 0,
|
|
2257
|
+
child: 0
|
|
2258
|
+
},
|
|
2259
|
+
channel,
|
|
2260
|
+
submissionIndex: 0,
|
|
2261
|
+
custom: {
|
|
2262
|
+
...runtimeConfig.custom,
|
|
2263
|
+
businessCode
|
|
2264
|
+
}
|
|
2265
|
+
});
|
|
2266
|
+
if (result.rawResults.some(evaluation => !evaluation.success)) {
|
|
2267
|
+
throw new Error('Unable to validate required product rules. Please try again.');
|
|
2268
|
+
}
|
|
2269
|
+
if (!result.allPassed) {
|
|
2270
|
+
const error = new Error(result.failedChecks[0]?.validationMessage || 'Please select the required product before checkout.');
|
|
2271
|
+
Object.assign(error, {
|
|
2272
|
+
code: 'REQUIRED_PRODUCT_MISSING',
|
|
2273
|
+
failures: result.failedChecks
|
|
2274
|
+
});
|
|
2275
|
+
throw error;
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
async submitSalesOrder(params) {
|
|
2279
|
+
await this.validateRequiredProducts();
|
|
2280
|
+
return super.submitSalesOrder(params);
|
|
2281
|
+
}
|
|
2206
2282
|
async ensureAllergyItemRuleConfigsLoaded() {
|
|
2207
2283
|
if (this.allergyItemRuleConfigs.length > 0) {
|
|
2208
2284
|
return this.allergyItemRuleConfigs;
|