@pisell/pisellos 2.2.294 → 2.2.296
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/itemRule/adapter.d.ts +1 -4
- package/dist/model/strategy/adapter/itemRule/adapter.js +35 -135
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +1 -8
- package/dist/model/strategy/adapter/itemRule/evaluator.js +1 -25
- package/dist/model/strategy/adapter/itemRule/type.d.ts +0 -44
- package/dist/model/strategy/adapter/itemRule/type.js +1 -19
- package/dist/modules/Order/index.d.ts +3 -18
- package/dist/modules/Order/index.js +485 -885
- package/dist/modules/Order/types.d.ts +5 -91
- package/dist/modules/Order/types.js +0 -5
- package/dist/modules/Order/utils.js +10 -22
- package/dist/modules/ProductList/index.d.ts +1 -2
- package/dist/modules/ProductList/index.js +20 -100
- package/dist/modules/ProductList/types.d.ts +0 -10
- package/dist/server/index.d.ts +0 -6
- package/dist/server/index.js +3 -43
- package/dist/server/utils/small-ticket.js +49 -1
- package/dist/solution/BaseSales/index.d.ts +1 -9
- package/dist/solution/BaseSales/index.js +706 -894
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/utils/orderCustomer.js +2 -3
- package/dist/solution/RegisterAndLogin/config.d.ts +3 -9
- package/dist/solution/RegisterAndLogin/config.js +40 -95
- package/dist/solution/RegisterAndLogin/index.js +1 -4
- package/dist/solution/ScanOrder/index.d.ts +0 -1
- package/dist/solution/ScanOrder/index.js +27 -31
- package/dist/solution/ScanOrder/utils.d.ts +0 -1
- package/dist/solution/ScanOrder/utils.js +0 -2
- package/dist/solution/UnifiedBookingSales/index.d.ts +2 -15
- package/dist/solution/UnifiedBookingSales/index.js +484 -752
- package/dist/solution/UnifiedBookingSales/types.d.ts +1 -14
- package/dist/solution/VenueBooking/index.d.ts +0 -1
- package/dist/solution/VenueBooking/index.js +4 -8
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +1 -4
- package/lib/model/strategy/adapter/itemRule/adapter.js +4 -73
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +1 -8
- package/lib/model/strategy/adapter/itemRule/evaluator.js +1 -23
- package/lib/model/strategy/adapter/itemRule/type.d.ts +0 -44
- package/lib/model/strategy/adapter/itemRule/type.js +1 -19
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/Order/index.d.ts +3 -18
- package/lib/modules/Order/index.js +28 -325
- package/lib/modules/Order/types.d.ts +5 -91
- package/lib/modules/Order/types.js +0 -4
- package/lib/modules/Order/utils.js +1 -13
- package/lib/modules/ProductList/index.d.ts +1 -2
- package/lib/modules/ProductList/index.js +2 -47
- package/lib/modules/ProductList/types.d.ts +0 -10
- package/lib/server/index.d.ts +0 -6
- package/lib/server/index.js +3 -37
- package/lib/server/utils/small-ticket.js +50 -1
- package/lib/solution/BaseSales/index.d.ts +1 -9
- package/lib/solution/BaseSales/index.js +1 -105
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/utils/orderCustomer.js +1 -2
- package/lib/solution/RegisterAndLogin/config.d.ts +3 -9
- package/lib/solution/RegisterAndLogin/config.js +8 -49
- package/lib/solution/RegisterAndLogin/index.js +1 -4
- package/lib/solution/ScanOrder/index.d.ts +0 -1
- package/lib/solution/ScanOrder/index.js +1 -5
- package/lib/solution/ScanOrder/utils.d.ts +0 -1
- package/lib/solution/ScanOrder/utils.js +0 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +2 -15
- package/lib/solution/UnifiedBookingSales/index.js +1 -125
- package/lib/solution/UnifiedBookingSales/types.d.ts +1 -14
- package/lib/solution/VenueBooking/index.d.ts +0 -1
- package/lib/solution/VenueBooking/index.js +1 -5
- package/package.json +1 -1
- package/dist/modules/Order/salesNotes.d.ts +0 -31
- package/dist/modules/Order/salesNotes.js +0 -492
- package/lib/modules/Order/salesNotes.d.ts +0 -31
- package/lib/modules/Order/salesNotes.js +0 -382
|
@@ -15,8 +15,6 @@ exports.getChannelConfig = getChannelConfig;
|
|
|
15
15
|
* API 配置接口
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
const h5CustomerAuthApiNames = new Set(['sendEmailVerificationCode', 'sendEmailLoginCode', 'sendSmsRegisterCode', 'sendEmailRegisterLink', 'verifyEmailRegistrationLink', 'emailPasswordLogin', 'emailCodeRegister', 'phoneCodeRegister', 'resendEmailRegisterLink', 'checkEmailLinkCode', 'sendSmsLoginCode', 'phoneCodeLogin', 'guestLogin', 'checkEmailExists', 'checkEmailCode', 'checkMobileCode', 'phonePasswordLogin', 'sendPasswordResetEmail', 'sendPasswordResetSms', 'sendResetPasswordLink', 'checkResetPasswordCode', 'resetPasswordByCode', 'resetPasswordByEmail', 'resetPasswordByPhone', 'verifyCode', 'register', 'login', 'oauthLogin', 'facebookLogin', 'appleLogin']);
|
|
19
|
-
|
|
20
18
|
/**
|
|
21
19
|
* 渠道配置接口
|
|
22
20
|
*/
|
|
@@ -280,31 +278,6 @@ const onlineStoreConfig = {
|
|
|
280
278
|
})
|
|
281
279
|
}
|
|
282
280
|
};
|
|
283
|
-
function withH5AuthPrefix(config) {
|
|
284
|
-
const nextConfig = {};
|
|
285
|
-
Object.entries(config).forEach(([key, apiConfig]) => {
|
|
286
|
-
if (!apiConfig.url.startsWith('/auth/')) {
|
|
287
|
-
nextConfig[key] = apiConfig;
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
nextConfig[key] = {
|
|
291
|
-
...apiConfig,
|
|
292
|
-
url: apiConfig.url.startsWith('/h5/') ? apiConfig.url : `/h5${apiConfig.url}`,
|
|
293
|
-
options: params => {
|
|
294
|
-
const {
|
|
295
|
-
withCredentials,
|
|
296
|
-
...baseOptions
|
|
297
|
-
} = (typeof apiConfig.options === 'function' ? apiConfig.options(params) : apiConfig.options) || {};
|
|
298
|
-
return {
|
|
299
|
-
...baseOptions,
|
|
300
|
-
prefix: false
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
};
|
|
304
|
-
});
|
|
305
|
-
return nextConfig;
|
|
306
|
-
}
|
|
307
|
-
const h5OnlineStoreConfig = withH5AuthPrefix(onlineStoreConfig);
|
|
308
281
|
|
|
309
282
|
/**
|
|
310
283
|
* 默认配置(通用配置)
|
|
@@ -1093,7 +1066,6 @@ const shopWebposConfig = {
|
|
|
1093
1066
|
*/
|
|
1094
1067
|
const channelConfigMap = exports.channelConfigMap = {
|
|
1095
1068
|
'online-store': onlineStoreConfig,
|
|
1096
|
-
'online-store-h5': h5OnlineStoreConfig,
|
|
1097
1069
|
'default': defaultConfig,
|
|
1098
1070
|
'webpos': webposConfig,
|
|
1099
1071
|
'shop.webpos': shopWebposConfig
|
|
@@ -1111,16 +1083,9 @@ function getChannelConfig(channel) {
|
|
|
1111
1083
|
* 负责根据配置执行 API 调用
|
|
1112
1084
|
*/
|
|
1113
1085
|
class ApiCaller {
|
|
1114
|
-
constructor(request, config
|
|
1086
|
+
constructor(request, config) {
|
|
1115
1087
|
this.request = request;
|
|
1116
1088
|
this.config = config;
|
|
1117
|
-
this.options = options;
|
|
1118
|
-
}
|
|
1119
|
-
resolveUrl(url) {
|
|
1120
|
-
if (!this.options.baseUrl || !url.startsWith('/h5/auth/')) {
|
|
1121
|
-
return url;
|
|
1122
|
-
}
|
|
1123
|
-
return `${this.options.baseUrl.replace(/\/$/, '')}${url}`;
|
|
1124
1089
|
}
|
|
1125
1090
|
|
|
1126
1091
|
/**
|
|
@@ -1146,12 +1111,6 @@ class ApiCaller {
|
|
|
1146
1111
|
...options,
|
|
1147
1112
|
...additionalOptions
|
|
1148
1113
|
};
|
|
1149
|
-
if (apiConfig.url.startsWith('/h5/auth/') && h5CustomerAuthApiNames.has(apiName)) {
|
|
1150
|
-
requestOptions.h5CustomerAuth = true;
|
|
1151
|
-
if (this.options.shopDomain) {
|
|
1152
|
-
requestOptions.h5AuthShopDomain = this.options.shopDomain;
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
1114
|
|
|
1156
1115
|
// 处理动态 headers
|
|
1157
1116
|
if (requestOptions.headers && typeof requestOptions.headers === 'function') {
|
|
@@ -1164,19 +1123,19 @@ class ApiCaller {
|
|
|
1164
1123
|
switch (apiConfig.method) {
|
|
1165
1124
|
case 'GET':
|
|
1166
1125
|
if (transformedParams && Object.keys(transformedParams).length > 0) {
|
|
1167
|
-
response = await this.request.get(
|
|
1126
|
+
response = await this.request.get(apiConfig.url, transformedParams, requestOptions);
|
|
1168
1127
|
} else {
|
|
1169
|
-
response = await this.request.get(
|
|
1128
|
+
response = await this.request.get(apiConfig.url, undefined, requestOptions);
|
|
1170
1129
|
}
|
|
1171
1130
|
break;
|
|
1172
1131
|
case 'POST':
|
|
1173
|
-
response = await this.request.post(
|
|
1132
|
+
response = await this.request.post(apiConfig.url, transformedParams, requestOptions);
|
|
1174
1133
|
break;
|
|
1175
1134
|
case 'PUT':
|
|
1176
|
-
response = await this.request.put(
|
|
1135
|
+
response = await this.request.put(apiConfig.url, transformedParams, requestOptions);
|
|
1177
1136
|
break;
|
|
1178
1137
|
case 'DELETE':
|
|
1179
|
-
response = await this.request.delete(
|
|
1138
|
+
response = await this.request.delete(apiConfig.url, requestOptions);
|
|
1180
1139
|
break;
|
|
1181
1140
|
default:
|
|
1182
1141
|
throw new Error(`不支持的 HTTP 方法: ${apiConfig.method}`);
|
|
@@ -1191,7 +1150,7 @@ class ApiCaller {
|
|
|
1191
1150
|
* 创建 API 调用器
|
|
1192
1151
|
*/
|
|
1193
1152
|
exports.ApiCaller = ApiCaller;
|
|
1194
|
-
function createApiCaller(request, channel
|
|
1153
|
+
function createApiCaller(request, channel) {
|
|
1195
1154
|
const config = getChannelConfig(channel);
|
|
1196
|
-
return new ApiCaller(request, config
|
|
1155
|
+
return new ApiCaller(request, config);
|
|
1197
1156
|
}
|
|
@@ -227,10 +227,7 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
|
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
// 创建 API 调用器
|
|
230
|
-
this.apiCaller = (0, _config.createApiCaller)(this.request, this.channel
|
|
231
|
-
baseUrl: this.otherParams.h5AuthBaseUrl,
|
|
232
|
-
shopDomain: this.otherParams.h5AuthShopDomain
|
|
233
|
-
});
|
|
230
|
+
this.apiCaller = (0, _config.createApiCaller)(this.request, this.channel);
|
|
234
231
|
|
|
235
232
|
// 尝试从本地存储恢复登录状态
|
|
236
233
|
await this.restoreLoginState();
|
|
@@ -1200,11 +1200,7 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1200
1200
|
return sourceMap;
|
|
1201
1201
|
}
|
|
1202
1202
|
getItemRuleRuntimeConfig() {
|
|
1203
|
-
|
|
1204
|
-
return {
|
|
1205
|
-
...runtimeConfig,
|
|
1206
|
-
channel: runtimeConfig.channel ?? runtimeConfig.custom?.channel ?? this.otherParams?.channel
|
|
1207
|
-
};
|
|
1203
|
+
return this.itemRuleRuntimeConfig || {};
|
|
1208
1204
|
}
|
|
1209
1205
|
async ensureItemRuleConfigsLoaded() {
|
|
1210
1206
|
if (this.itemRuleConfigs.length > 0) return this.itemRuleConfigs;
|
|
@@ -333,7 +333,6 @@ function buildItemRuleBusinessData(params) {
|
|
|
333
333
|
cartItems,
|
|
334
334
|
historicalItems,
|
|
335
335
|
serviceType: runtimeConfig.serviceType || 'dine-in',
|
|
336
|
-
channel: runtimeConfig.channel ?? runtimeConfig.custom?.channel,
|
|
337
336
|
submissionIndex: typeof runtimeConfig.submissionIndex === 'number' ? toNonNegativeInt(runtimeConfig.submissionIndex) : tempOrder.order_id ? 1 : 0,
|
|
338
337
|
custom: runtimeConfig.custom || {},
|
|
339
338
|
strategyConfigs: itemRuleConfigs
|
|
@@ -2,11 +2,10 @@ import type { Module, ModuleOptions, PisellCore } from '../../types';
|
|
|
2
2
|
import type { ProductData } from '../../modules';
|
|
3
3
|
import type { OpenDataConfig } from '../../modules/OpenData';
|
|
4
4
|
import type { LoadScheduleAvailableDateParams, ScheduleItem } from '../../modules/Schedule/types';
|
|
5
|
-
import type { ProductListLoadProductsParams
|
|
5
|
+
import type { ProductListLoadProductsParams } from '../../modules/ProductList';
|
|
6
6
|
import type { AvailabilityDateRange, AvailabilityOccupancy, AvailabilityProduct, AvailabilityResource, GetProductTimeRangesRequest } from '../../modules/ResourcePlanner';
|
|
7
|
-
import type { AvailabilityContextRef, ContextualAvailabilityQuery, ContextualAvailabilityQueryResult, ContextualCommitAvailabilitySelectionParams, ContextualProductTimeRangeGroup, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesCommitAvailabilitySelectionResult, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesPrepareAvailabilityProjectionParams, UnifiedBookingSalesPolicyResponse,
|
|
7
|
+
import type { AvailabilityContextRef, ContextualAvailabilityQuery, ContextualAvailabilityQueryResult, ContextualCommitAvailabilitySelectionParams, ContextualProductTimeRangeGroup, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesCommitAvailabilitySelectionResult, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesPrepareAvailabilityProjectionParams, UnifiedBookingSalesPolicyResponse, UnifiedBookingSalesStageRetailProductsParams, UnifiedBookingSalesState } from './types';
|
|
8
8
|
import { BookingTicket } from '../BookingTicket';
|
|
9
|
-
import type { AllergyRequirement } from '../../model/strategy/adapter/itemRule';
|
|
10
9
|
export * from './types';
|
|
11
10
|
export { AvailabilityError } from '../../modules/ResourcePlanner';
|
|
12
11
|
/**
|
|
@@ -77,9 +76,6 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
77
76
|
private availabilityRemoteResourceQuerySequence;
|
|
78
77
|
private availabilityRemoteResourceEpoch;
|
|
79
78
|
private availabilityCommitLocks;
|
|
80
|
-
private allergyItemRuleEvaluator;
|
|
81
|
-
private allergyItemRuleConfigs;
|
|
82
|
-
private allergyItemRuleConfigsPromise;
|
|
83
79
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
84
80
|
protected getSubmitOrderSalesChannel(): string;
|
|
85
81
|
private createAvailabilityFacadeError;
|
|
@@ -151,14 +147,6 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
151
147
|
*/
|
|
152
148
|
loadOpenData(params: UnifiedBookingSalesLoadOpenDataParams): Promise<OpenDataConfig>;
|
|
153
149
|
getOpenData(): Promise<OpenDataConfig | null>;
|
|
154
|
-
private resetAllergyItemRuleState;
|
|
155
|
-
private fetchAllergyItemRuleConfigs;
|
|
156
|
-
private ensureAllergyItemRuleConfigsLoaded;
|
|
157
|
-
/**
|
|
158
|
-
* 评估当前渠道与商品是否命中 ALLERGY_CHECK。
|
|
159
|
-
* 只返回优先级最高 Action 中当前商品 Target 的 dataSource,不跨商品或 Action 合并。
|
|
160
|
-
*/
|
|
161
|
-
resolveProductAllergyRequirement(params: UnifiedBookingSalesResolveProductAllergyRequirementParams): Promise<AllergyRequirement | null>;
|
|
162
150
|
/**
|
|
163
151
|
* Load a resource policy without depending on the legacy appointmentBooking solution.
|
|
164
152
|
*/
|
|
@@ -171,7 +159,6 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
171
159
|
callback?: (result: any) => void;
|
|
172
160
|
subscriberId?: string;
|
|
173
161
|
}): Promise<ProductData[]>;
|
|
174
|
-
queryProducts(params?: ProductListStoreQueryParams): Promise<ProductData[]>;
|
|
175
162
|
/** Date-first entry point. It delegates protocol details and cache ownership to ScheduleModule. */
|
|
176
163
|
loadScheduleAvailableDate(params: LoadScheduleAvailableDateParams): Promise<import("../../modules/Date/types").ITime[]>;
|
|
177
164
|
/**
|
|
@@ -51,7 +51,6 @@ var _remoteOccupancyCache = require("./remoteOccupancyCache");
|
|
|
51
51
|
var _BookingTicket = require("../BookingTicket");
|
|
52
52
|
var _localClock = require("../../modules/ResourcePlanner/localClock");
|
|
53
53
|
var _platform = require("../../utils/platform");
|
|
54
|
-
var _itemRule = require("../../model/strategy/adapter/itemRule");
|
|
55
54
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
56
55
|
const OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow', 'basic', 'checkout', 'availability'];
|
|
57
56
|
const OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
|
|
@@ -84,22 +83,6 @@ function getCandidateStartTime(candidate) {
|
|
|
84
83
|
return undefined;
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
|
-
function normalizePositiveIntegerList(value) {
|
|
88
|
-
if (!Array.isArray(value)) return [];
|
|
89
|
-
return Array.from(new Set(value.map(item => normalizePositiveInteger(item)).filter(item => item !== undefined)));
|
|
90
|
-
}
|
|
91
|
-
function toConfiguredBoolean(value) {
|
|
92
|
-
if (typeof value === 'boolean') return value;
|
|
93
|
-
if (typeof value === 'number') return value !== 0;
|
|
94
|
-
if (typeof value === 'string') {
|
|
95
|
-
return ['1', 'true', 'yes', 'y', 'on'].includes(value.trim().toLowerCase());
|
|
96
|
-
}
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
function normalizeItemRuleStrategyConfigs(value) {
|
|
100
|
-
if (!Array.isArray(value)) return [];
|
|
101
|
-
return value.filter(config => Boolean(config && typeof config === 'object' && config.metadata?.type === 'item_rule'));
|
|
102
|
-
}
|
|
103
86
|
function isRecord(value) {
|
|
104
87
|
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
105
88
|
}
|
|
@@ -1181,15 +1164,11 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
1181
1164
|
availabilityRemoteResourceQuerySequence = 0;
|
|
1182
1165
|
availabilityRemoteResourceEpoch = 0;
|
|
1183
1166
|
availabilityCommitLocks = new Set();
|
|
1184
|
-
allergyItemRuleEvaluator = new _itemRule.ItemRuleEvaluator();
|
|
1185
|
-
allergyItemRuleConfigs = [];
|
|
1186
|
-
allergyItemRuleConfigsPromise = null;
|
|
1187
1167
|
async initialize(core, options = {}) {
|
|
1188
1168
|
this.availabilityScheduleCatalog = null;
|
|
1189
1169
|
this.openDataTarget = null;
|
|
1190
1170
|
this.availabilityRuntimeOffsetMinutes = (0, _localClock.captureRuntimeOffsetMinutes)();
|
|
1191
1171
|
this.clearAvailabilityRemoteResourceState();
|
|
1192
|
-
this.resetAllergyItemRuleState();
|
|
1193
1172
|
await super.initialize(core, options);
|
|
1194
1173
|
const openDataBusinessCode = String(this.otherParams?.businessCode ?? this.otherParams?.business_code ?? '').trim();
|
|
1195
1174
|
const openDataChannel = String(this.otherParams?.channel ?? '').trim();
|
|
@@ -1334,7 +1313,6 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
1334
1313
|
cover = false
|
|
1335
1314
|
} = {}) {
|
|
1336
1315
|
const previousScope = this.getAvailabilityScopeDescriptor(this.otherParams || {});
|
|
1337
|
-
const previousItemRuleConfig = this.otherParams?.itemRule;
|
|
1338
1316
|
const explicitlySetsOpenData = Object.prototype.hasOwnProperty.call(params, 'openData');
|
|
1339
1317
|
await super.setOtherParams(params, {
|
|
1340
1318
|
cover
|
|
@@ -1347,15 +1325,11 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
1347
1325
|
if (shouldResetAvailabilityState) {
|
|
1348
1326
|
await this.resetAvailabilityProjectionState('set_other_params_reset');
|
|
1349
1327
|
}
|
|
1350
|
-
if (shouldResetAvailabilityState || explicitlySetsOpenData || previousItemRuleConfig !== this.otherParams?.itemRule) {
|
|
1351
|
-
this.resetAllergyItemRuleState();
|
|
1352
|
-
}
|
|
1353
1328
|
}
|
|
1354
1329
|
async destroy() {
|
|
1355
1330
|
this.availabilityScheduleCatalog = null;
|
|
1356
1331
|
this.availabilityRuntimeOffsetMinutes = null;
|
|
1357
1332
|
await this.resetAvailabilityProjectionState('destroy');
|
|
1358
|
-
this.resetAllergyItemRuleState();
|
|
1359
1333
|
await super.destroy();
|
|
1360
1334
|
}
|
|
1361
1335
|
createAvailabilityContextId() {
|
|
@@ -1709,98 +1683,6 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
1709
1683
|
channel
|
|
1710
1684
|
});
|
|
1711
1685
|
}
|
|
1712
|
-
resetAllergyItemRuleState() {
|
|
1713
|
-
this.allergyItemRuleConfigs = [];
|
|
1714
|
-
this.allergyItemRuleConfigsPromise = null;
|
|
1715
|
-
this.allergyItemRuleEvaluator.setStrategyConfigs([]);
|
|
1716
|
-
}
|
|
1717
|
-
async fetchAllergyItemRuleConfigs(strategyModelIds) {
|
|
1718
|
-
if (!strategyModelIds.length) return [];
|
|
1719
|
-
try {
|
|
1720
|
-
const response = await this.request.get('/promotion', {
|
|
1721
|
-
skip: 1,
|
|
1722
|
-
num: 99,
|
|
1723
|
-
status: 'active',
|
|
1724
|
-
ids: strategyModelIds
|
|
1725
|
-
});
|
|
1726
|
-
if (response?.code !== 200 || !Array.isArray(response?.data?.list)) {
|
|
1727
|
-
throw new Error('[UnifiedBookingSales] 商品过敏策略加载失败');
|
|
1728
|
-
}
|
|
1729
|
-
const list = response.data.list;
|
|
1730
|
-
return normalizeItemRuleStrategyConfigs(list.map(item => item?.metadata));
|
|
1731
|
-
} catch (error) {
|
|
1732
|
-
// this.logMethodError('fetchAllergyItemRuleConfigs', error, {
|
|
1733
|
-
// strategyModelIds,
|
|
1734
|
-
// });
|
|
1735
|
-
throw error;
|
|
1736
|
-
}
|
|
1737
|
-
}
|
|
1738
|
-
async ensureAllergyItemRuleConfigsLoaded() {
|
|
1739
|
-
if (this.allergyItemRuleConfigs.length > 0) {
|
|
1740
|
-
return this.allergyItemRuleConfigs;
|
|
1741
|
-
}
|
|
1742
|
-
if (this.allergyItemRuleConfigsPromise) {
|
|
1743
|
-
return this.allergyItemRuleConfigsPromise;
|
|
1744
|
-
}
|
|
1745
|
-
this.allergyItemRuleConfigsPromise = (async () => {
|
|
1746
|
-
const staticConfigs = normalizeItemRuleStrategyConfigs(this.otherParams?.itemRule?.strategyConfigs);
|
|
1747
|
-
if (staticConfigs.length > 0) {
|
|
1748
|
-
this.allergyItemRuleConfigs = staticConfigs;
|
|
1749
|
-
this.allergyItemRuleEvaluator.setStrategyConfigs(staticConfigs);
|
|
1750
|
-
return staticConfigs;
|
|
1751
|
-
}
|
|
1752
|
-
const openData = await this.getOpenData();
|
|
1753
|
-
const enabled = toConfiguredBoolean(openData?.['sale.enable_item_rules']);
|
|
1754
|
-
const strategyModelIds = normalizePositiveIntegerList(openData?.['sale.enabled_item_rules']);
|
|
1755
|
-
if (!enabled || !strategyModelIds.length) {
|
|
1756
|
-
this.allergyItemRuleEvaluator.setStrategyConfigs([]);
|
|
1757
|
-
return [];
|
|
1758
|
-
}
|
|
1759
|
-
const loaded = await this.fetchAllergyItemRuleConfigs(strategyModelIds);
|
|
1760
|
-
this.allergyItemRuleConfigs = loaded;
|
|
1761
|
-
this.allergyItemRuleEvaluator.setStrategyConfigs(loaded);
|
|
1762
|
-
return loaded;
|
|
1763
|
-
})();
|
|
1764
|
-
return this.allergyItemRuleConfigsPromise;
|
|
1765
|
-
}
|
|
1766
|
-
|
|
1767
|
-
/**
|
|
1768
|
-
* 评估当前渠道与商品是否命中 ALLERGY_CHECK。
|
|
1769
|
-
* 只返回优先级最高 Action 中当前商品 Target 的 dataSource,不跨商品或 Action 合并。
|
|
1770
|
-
*/
|
|
1771
|
-
async resolveProductAllergyRequirement(params) {
|
|
1772
|
-
const productId = normalizePositiveInteger(params.productId);
|
|
1773
|
-
if (!productId) return null;
|
|
1774
|
-
const strategyConfigs = await this.ensureAllergyItemRuleConfigsLoaded();
|
|
1775
|
-
if (!strategyConfigs.length) return null;
|
|
1776
|
-
const productVariantId = normalizePositiveInteger(params.productVariantId);
|
|
1777
|
-
const runtimeConfig = this.otherParams?.itemRule || {};
|
|
1778
|
-
const runtimePax = runtimeConfig.pax || {};
|
|
1779
|
-
const cartItems = (this.getOrderProducts?.() || []).map(item => ({
|
|
1780
|
-
product_id: Number(item?.product_id ?? item?.id),
|
|
1781
|
-
product_variant_id: Number(item?.product_variant_id ?? 0) || undefined,
|
|
1782
|
-
quantity: Number(item?.num ?? item?.quantity ?? 0)
|
|
1783
|
-
})).filter(item => Number.isFinite(item.product_id) && item.product_id > 0 && Number.isFinite(item.quantity) && item.quantity > 0);
|
|
1784
|
-
return this.allergyItemRuleEvaluator.getAllergyRequirement({
|
|
1785
|
-
pax: {
|
|
1786
|
-
total: Number(runtimePax.total ?? 0) || 0,
|
|
1787
|
-
adult: Number(runtimePax.adult ?? 0) || 0,
|
|
1788
|
-
child: Number(runtimePax.child ?? 0) || 0
|
|
1789
|
-
},
|
|
1790
|
-
cartItems,
|
|
1791
|
-
serviceType: String(runtimeConfig.serviceType ?? this.otherParams?.serviceType ?? ''),
|
|
1792
|
-
channel: String(params.channel ?? this.otherParams?.channel ?? this.otherParams?.platform ?? ''),
|
|
1793
|
-
currentProduct: {
|
|
1794
|
-
product_id: productId,
|
|
1795
|
-
...(productVariantId ? {
|
|
1796
|
-
product_variant_id: productVariantId
|
|
1797
|
-
} : {})
|
|
1798
|
-
},
|
|
1799
|
-
submissionIndex: Number(runtimeConfig.submissionIndex ?? 0) || 0,
|
|
1800
|
-
strategyConfigs,
|
|
1801
|
-
custom: runtimeConfig.custom
|
|
1802
|
-
});
|
|
1803
|
-
}
|
|
1804
1686
|
|
|
1805
1687
|
/**
|
|
1806
1688
|
* Load a resource policy without depending on the legacy appointmentBooking solution.
|
|
@@ -1837,10 +1719,6 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
1837
1719
|
await this.core.effects.emit(`${this.name}:onProductsLoaded`, result);
|
|
1838
1720
|
return result;
|
|
1839
1721
|
}
|
|
1840
|
-
async queryProducts(params = {}) {
|
|
1841
|
-
if (!this.store.products) throw new Error('[UnifiedBookingSales] products 模块未初始化');
|
|
1842
|
-
return this.store.products.queryProducts(params);
|
|
1843
|
-
}
|
|
1844
1722
|
|
|
1845
1723
|
/** Date-first entry point. It delegates protocol details and cache ownership to ScheduleModule. */
|
|
1846
1724
|
async loadScheduleAvailableDate(params) {
|
|
@@ -3356,9 +3234,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3356
3234
|
} else {
|
|
3357
3235
|
const beforeProductLineUids = new Set((this.getTempOrder()?.products || []).map(line => getProductLineUid(line)).filter(Boolean));
|
|
3358
3236
|
const beforeBookingUids = new Set((this.getTempOrder()?.bookings || []).map(item => getBookingUid(item)).filter(Boolean));
|
|
3359
|
-
const products = await this.addProductToOrder(transformed, booking
|
|
3360
|
-
salesNotes: params.salesNotes
|
|
3361
|
-
} : undefined);
|
|
3237
|
+
const products = await this.addProductToOrder(transformed, booking);
|
|
3362
3238
|
const addedLines = products.filter(line => sameAvailabilityId(line.product_id ?? line.id, refreshedCandidate.productId) && line.metadata?.availability_candidate_key === refreshedCandidate.key && !beforeProductLineUids.has(getProductLineUid(line)));
|
|
3363
3239
|
productLineUids = addedLines.map(line => getProductLineUid(line)).filter(Boolean);
|
|
3364
3240
|
const addedBookings = (this.getTempOrder()?.bookings || []).filter(item => item.metadata?.availability_candidate_key === refreshedCandidate.key && !beforeBookingUids.has(getBookingUid(item)));
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import type { OpenDataConfig } from '../../modules/OpenData';
|
|
2
|
-
import type { ProductListLoadProductsParams
|
|
3
|
-
import type { ProductData } from '../../modules/Product/types';
|
|
2
|
+
import type { ProductListLoadProductsParams } from '../../modules/ProductList';
|
|
4
3
|
import type { LoadScheduleAvailableDateParams } from '../../modules/Schedule/types';
|
|
5
4
|
import type { AvailabilityDateRange, AvailabilityErrorCode, AvailabilityId, AvailabilityOccupancy, AvailabilityProduct, AvailabilityProjection, AvailabilityQuery, AvailabilityRequirementSelection, AvailabilityResource, AvailabilitySelectionValidationResult, DateAvailabilityQueryResult, GetProductTimeRangesRequest, ProductAvailabilityQueryResult, ProductTimeRange, ProductTimeRangeGroup, ResourceAvailabilityGroup, ResourceAvailabilityRangeGroup, TimeAvailabilityGroup, TimeAvailabilityItem } from '../../modules/ResourcePlanner';
|
|
6
5
|
import type { BookingTicketState } from '../BookingTicket/types';
|
|
7
|
-
import type { AllergyRequirement } from '../../model/strategy/adapter/itemRule';
|
|
8
|
-
import type { SalesNoteDraftInput } from '../../modules/Order/types';
|
|
9
|
-
export type { ProductListStoreQueryParams } from '../../modules/ProductList';
|
|
10
6
|
export type { AvailabilityAbsoluteRange, AvailabilityAssignment, AvailabilityCell, AvailabilityDateRange, AvailabilityDisplayRange, AvailabilityErrorCode, AvailabilityId, AvailabilityMode, AvailabilityOccupancy, AvailabilityProduct, AvailabilityProductKind, AvailabilityProjection, AvailabilityProjectionInput, AvailabilityProjectionMeta, AvailabilityQuery, AvailabilityQueryResult, AvailabilityRequirementGroup, AvailabilityRequirementGroupResult, AvailabilityRequirementSelection, AvailabilityResource, AvailabilityResourceOption, AvailabilityResourceType, AvailabilityResourceWindow, AvailabilityScheduleMode, AvailabilityScheduleRef, AvailabilityScheduleRule, AvailabilitySelectionValidationParams, AvailabilitySelectionValidationResult, AvailabilitySessionRange, AvailabilityStatus, DateAvailabilityGroup, DateAvailabilityItem, DateAvailabilityQuery, DateAvailabilityQueryResult, GetProductTimeRangesRequest, ProductAvailabilityGroup, ProductAvailabilityItem, ProductAvailabilityQuery, ProductAvailabilityQueryResult, ProductTimeRange, ProductTimeRangeGroup, QueryAvailabilityBaseRequest, ResourceAvailabilityGroup, ResourceAvailabilityQuery, ResourceAvailabilityQueryResult, ResourceAvailabilityRangeGroup, TimeAvailabilityGroup, TimeAvailabilityItem, TimeAvailabilityQuery, TimeAvailabilityQueryResult, } from '../../modules/ResourcePlanner';
|
|
11
7
|
export interface UnifiedBookingSalesState extends BookingTicketState {
|
|
12
8
|
}
|
|
@@ -28,12 +24,6 @@ export declare enum UnifiedBookingSalesHooks {
|
|
|
28
24
|
export interface UnifiedBookingSalesOtherParams extends Record<string, any> {
|
|
29
25
|
enableSessionStoragePersist?: boolean;
|
|
30
26
|
}
|
|
31
|
-
export type UnifiedBookingSalesAllergyRequirement = AllergyRequirement;
|
|
32
|
-
export interface UnifiedBookingSalesResolveProductAllergyRequirementParams {
|
|
33
|
-
productId: number | string;
|
|
34
|
-
productVariantId?: number | string;
|
|
35
|
-
channel?: string;
|
|
36
|
-
}
|
|
37
27
|
export interface UnifiedBookingSalesLoadOpenDataParams {
|
|
38
28
|
businessCode: string;
|
|
39
29
|
channel: string;
|
|
@@ -161,8 +151,6 @@ export interface ContextualCommitAvailabilitySelectionParams {
|
|
|
161
151
|
requirementSelections: AvailabilityRequirementSelection[];
|
|
162
152
|
partySize: number;
|
|
163
153
|
bookingCount?: number;
|
|
164
|
-
/** 新增商品行时与商品、预约在同一次 Order mutation 内写入的 Sales Notes。 */
|
|
165
|
-
salesNotes?: SalesNoteDraftInput[];
|
|
166
154
|
/** 编辑预约时,允许本次显式报价覆盖已落库订单行的历史价格。 */
|
|
167
155
|
allowBookingReprice?: boolean;
|
|
168
156
|
/** 编辑预约重报价后,允许订单模块重新应用已选编辑态折扣。 */
|
|
@@ -220,7 +208,6 @@ export interface UnifiedBookingSalesApi {
|
|
|
220
208
|
getOpenData: () => Promise<OpenDataConfig | null>;
|
|
221
209
|
loadScheduleAvailableDate: (params: LoadScheduleAvailableDateParams) => Promise<unknown>;
|
|
222
210
|
loadProductsByScheduleDate: (params: UnifiedBookingSalesLoadProductsByScheduleDateParams) => Promise<unknown[]>;
|
|
223
|
-
queryProducts: (params?: ProductListStoreQueryParams) => Promise<ProductData[]>;
|
|
224
211
|
stageRetailProducts: (params: UnifiedBookingSalesStageRetailProductsParams) => Promise<Record<string, any> | null>;
|
|
225
212
|
addRetailProduct: (params: UnifiedBookingSalesAddRetailProductParams) => Promise<Record<string, any>[]>;
|
|
226
213
|
prepareAvailabilityProjection: (params: UnifiedBookingSalesPrepareAvailabilityProjectionParams) => Promise<AvailabilityContextRef>;
|
|
@@ -1758,11 +1758,7 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1758
1758
|
return sourceMap;
|
|
1759
1759
|
}
|
|
1760
1760
|
getItemRuleRuntimeConfig() {
|
|
1761
|
-
|
|
1762
|
-
return {
|
|
1763
|
-
...runtimeConfig,
|
|
1764
|
-
channel: runtimeConfig.channel ?? runtimeConfig.custom?.channel ?? this.otherParams?.channel
|
|
1765
|
-
};
|
|
1761
|
+
return this.itemRuleRuntimeConfig || {};
|
|
1766
1762
|
}
|
|
1767
1763
|
async ensureItemRuleConfigsLoaded() {
|
|
1768
1764
|
if (this.itemRuleConfigs.length > 0) return this.itemRuleConfigs;
|
package/package.json
CHANGED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { SalesNote, SalesNoteProtocol, SalesNoteTextInput } from './types';
|
|
2
|
-
export interface SalesNotePolicy {
|
|
3
|
-
note_type: string;
|
|
4
|
-
importance: string;
|
|
5
|
-
uniquePerPrimaryTarget: boolean;
|
|
6
|
-
primary_relation_type: 'about';
|
|
7
|
-
secondary_order_relation_type: 'related_to';
|
|
8
|
-
}
|
|
9
|
-
export declare function getSalesNotePolicy(note_type: string): SalesNotePolicy | null;
|
|
10
|
-
export declare function buildSalesNoteText(input: SalesNoteTextInput): Record<string, string>;
|
|
11
|
-
export interface SalesNoteValidationOptions {
|
|
12
|
-
allowUnresolvedOrderTarget?: boolean;
|
|
13
|
-
expectedOrderTargetUuid?: string;
|
|
14
|
-
productTargetUuids?: ReadonlySet<string>;
|
|
15
|
-
}
|
|
16
|
-
export type EncodeSalesNotesOptions = SalesNoteValidationOptions;
|
|
17
|
-
export declare function encodeSalesNotes(notes: SalesNote[], options?: EncodeSalesNotesOptions): SalesNoteProtocol[];
|
|
18
|
-
export interface DecodedSalesNotesSnapshot {
|
|
19
|
-
notes: SalesNote[];
|
|
20
|
-
complete: boolean;
|
|
21
|
-
}
|
|
22
|
-
export interface DecodeSalesNotesOptions {
|
|
23
|
-
allowUnresolvedOrderTarget?: boolean;
|
|
24
|
-
}
|
|
25
|
-
export declare function decodeSalesNotesSnapshot(value: unknown, options?: DecodeSalesNotesOptions): DecodedSalesNotesSnapshot;
|
|
26
|
-
export declare function decodeSalesNotes(value: unknown, options?: DecodeSalesNotesOptions): SalesNote[];
|
|
27
|
-
export declare function finalizeSalesNotesForCheckout(params: {
|
|
28
|
-
notes: unknown;
|
|
29
|
-
shopOrderNumber: unknown;
|
|
30
|
-
productTargetUuids: string[];
|
|
31
|
-
}): SalesNoteProtocol[];
|