@pisell/pisellos 2.3.171 → 2.3.173
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/utils/productExtend.d.ts +5 -0
- package/dist/modules/BookingContext/utils/productExtend.js +61 -23
- package/dist/modules/OpenData/index.d.ts +1 -0
- package/dist/modules/OpenData/index.js +1 -0
- package/dist/modules/OpenData/salesSettings.d.ts +32 -0
- package/dist/modules/OpenData/salesSettings.js +80 -0
- package/dist/modules/OpenData/types.d.ts +13 -0
- package/dist/modules/Payment/walletpass.js +32 -6
- 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 +2 -2
- package/dist/solution/UnifiedBookingSales/index.d.ts +22 -1
- package/dist/solution/UnifiedBookingSales/index.js +910 -650
- package/dist/solution/UnifiedBookingSales/salesSettings.d.ts +16 -0
- package/dist/solution/UnifiedBookingSales/salesSettings.js +81 -0
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/BookingContext/utils/productExtend.d.ts +5 -0
- package/lib/modules/BookingContext/utils/productExtend.js +36 -3
- package/lib/modules/OpenData/index.d.ts +1 -0
- package/lib/modules/OpenData/index.js +12 -0
- package/lib/modules/OpenData/salesSettings.d.ts +32 -0
- package/lib/modules/OpenData/salesSettings.js +70 -0
- package/lib/modules/OpenData/types.d.ts +13 -0
- package/lib/modules/Payment/walletpass.js +23 -1
- 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 +2 -2
- package/lib/solution/UnifiedBookingSales/index.d.ts +22 -1
- package/lib/solution/UnifiedBookingSales/index.js +128 -1
- package/lib/solution/UnifiedBookingSales/salesSettings.d.ts +16 -0
- package/lib/solution/UnifiedBookingSales/salesSettings.js +72 -0
- package/package.json +1 -1
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// 导出评估器
|
|
2
|
-
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
-
|
|
4
|
-
// 导出适配器
|
|
5
|
-
export { PromotionAdapter } from "./adapter";
|
|
6
|
-
export { default } from "./adapter";
|
|
7
|
-
|
|
8
|
-
// 导出策略配置示例常量
|
|
9
|
-
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
|
|
@@ -24,6 +24,10 @@ export interface BookingCalcContext {
|
|
|
24
24
|
date?: any;
|
|
25
25
|
/** 上一个服务行(getServiceStartTimeAndEndTime 拼接续接 start_time 用)。可缺省。 */
|
|
26
26
|
previousService?: any;
|
|
27
|
+
/** UBS-only default-time policy. Other solutions retain their existing Board behavior. */
|
|
28
|
+
resolveDefaultBookingStart?: (cacheItem: any, fallback: string) => string | undefined;
|
|
29
|
+
/** Explicit holder context supplied before the cache item has received its holder snapshot. */
|
|
30
|
+
holderIds?: unknown;
|
|
27
31
|
/** 日历选中的资源 id(替代 info2 sessionStorage.serviceParams.resource_id)。 */
|
|
28
32
|
resourceIdFromCalendar?: number;
|
|
29
33
|
/** 资源自动分派开关(替代 info2 localStorage 'resource-auto-allocation');默认全开。 */
|
|
@@ -58,6 +62,7 @@ export declare function getServiceStartTimeAndEndTime(params: {
|
|
|
58
62
|
cacheItem: any;
|
|
59
63
|
timeObj: TimeSlicesResult;
|
|
60
64
|
ctx: BookingCalcContext;
|
|
65
|
+
defaultBookingStartFallback?: string;
|
|
61
66
|
}): any;
|
|
62
67
|
/**
|
|
63
68
|
* 综合:把 cacheItem 拼装出完整的 _extend / _data(资源 / 容量 / timeObj),并标记 autoClose。
|
|
@@ -136,6 +136,12 @@ export function getTimeObj(params) {
|
|
|
136
136
|
durationSlicesBasedOnTime: durationSlicesBasedOnTime
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
|
+
function getDefaultBookingStartFallback(cacheItem, ctx) {
|
|
140
|
+
var _ref, _cacheItem$_extend$st, _cacheItem$_extend4;
|
|
141
|
+
var date = dayjs((_ref = (_cacheItem$_extend$st = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend4 = cacheItem._extend) === null || _cacheItem$_extend4 === void 0 ? void 0 : _cacheItem$_extend4.start_date) !== null && _cacheItem$_extend$st !== void 0 ? _cacheItem$_extend$st : ctx.date) !== null && _ref !== void 0 ? _ref : dayjs()).format('YYYY-MM-DD');
|
|
142
|
+
var time = ctx.presetStartTime || cacheItem.currentDefaultTime || dayjs().format('HH:mm');
|
|
143
|
+
return "".concat(date, "T").concat(time);
|
|
144
|
+
}
|
|
139
145
|
|
|
140
146
|
/**
|
|
141
147
|
* 计算商品行 _extend(包含 start_time / endDate / duration / start_date / end_date / sub_type 等)。
|
|
@@ -145,7 +151,7 @@ export function getTimeObj(params) {
|
|
|
145
151
|
* - cacheItem.isCustomItem → 直接返回 `{ duration: null }`。
|
|
146
152
|
*/
|
|
147
153
|
export function getServiceStartTimeAndEndTime(params) {
|
|
148
|
-
var _cacheItem$
|
|
154
|
+
var _cacheItem$_extend5, _cacheItem$_extend6, _cacheItem$_extend8;
|
|
149
155
|
var cacheItem = params.cacheItem,
|
|
150
156
|
timeObj = params.timeObj,
|
|
151
157
|
ctx = params.ctx;
|
|
@@ -154,7 +160,7 @@ export function getServiceStartTimeAndEndTime(params) {
|
|
|
154
160
|
duration: null
|
|
155
161
|
};
|
|
156
162
|
}
|
|
157
|
-
var appointmentTimingPreference = getAppointmentTimingPreference(ctx);
|
|
163
|
+
var appointmentTimingPreference = ctx.resolveDefaultBookingStart ? undefined : getAppointmentTimingPreference(ctx);
|
|
158
164
|
var lastServer = ctx.previousService || null;
|
|
159
165
|
var resolveDuration = function resolveDuration() {
|
|
160
166
|
var _cacheItem$duration;
|
|
@@ -164,7 +170,15 @@ export function getServiceStartTimeAndEndTime(params) {
|
|
|
164
170
|
var _extend = {
|
|
165
171
|
duration: resolveDuration()
|
|
166
172
|
};
|
|
167
|
-
if (
|
|
173
|
+
if (ctx.resolveDefaultBookingStart && !ctx.rememberedTime && !((_cacheItem$_extend5 = cacheItem._extend) !== null && _cacheItem$_extend5 !== void 0 && _cacheItem$_extend5.start_time) && !isSessionProduct(cacheItem)) {
|
|
174
|
+
var _params$defaultBookin;
|
|
175
|
+
var _fallback = (_params$defaultBookin = params.defaultBookingStartFallback) !== null && _params$defaultBookin !== void 0 ? _params$defaultBookin : getDefaultBookingStartFallback(cacheItem, ctx);
|
|
176
|
+
var start = ctx.resolveDefaultBookingStart(cacheItem, _fallback);
|
|
177
|
+
if (start) {
|
|
178
|
+
_extend.start_date = start.slice(0, 10);
|
|
179
|
+
_extend.start_time = start.slice(11);
|
|
180
|
+
}
|
|
181
|
+
} else if (lastServer) {
|
|
168
182
|
var _lastServer$_extend, _lastServer$_extend2;
|
|
169
183
|
var lastStart = (_lastServer$_extend = lastServer._extend) === null || _lastServer$_extend === void 0 ? void 0 : _lastServer$_extend.startDate;
|
|
170
184
|
var lastEnd = (_lastServer$_extend2 = lastServer._extend) === null || _lastServer$_extend2 === void 0 ? void 0 : _lastServer$_extend2.endDate;
|
|
@@ -188,7 +202,20 @@ export function getServiceStartTimeAndEndTime(params) {
|
|
|
188
202
|
_extend.start_time = dayjs().format('HH:mm');
|
|
189
203
|
}
|
|
190
204
|
}
|
|
205
|
+
var defaultStartDate = _extend.start_date;
|
|
191
206
|
_extend = _objectSpread(_objectSpread({}, _extend), cacheItem._extend);
|
|
207
|
+
// start_date on a new cache item is a calendar anchor, not a manually selected time.
|
|
208
|
+
// Preserve the complete default after a previous booking crossed midnight.
|
|
209
|
+
if (defaultStartDate && !((_cacheItem$_extend6 = cacheItem._extend) !== null && _cacheItem$_extend6 !== void 0 && _cacheItem$_extend6.start_time)) {
|
|
210
|
+
var _cacheItem$_extend7;
|
|
211
|
+
_extend.start_date = defaultStartDate;
|
|
212
|
+
if (isMultiDayProduct(cacheItem) && (_cacheItem$_extend7 = cacheItem._extend) !== null && _cacheItem$_extend7 !== void 0 && _cacheItem$_extend7.end_date) {
|
|
213
|
+
var _cacheItem$_extend$st2;
|
|
214
|
+
var originalDate = dayjs((_cacheItem$_extend$st2 = cacheItem._extend.start_date) !== null && _cacheItem$_extend$st2 !== void 0 ? _cacheItem$_extend$st2 : ctx.date).startOf('day');
|
|
215
|
+
var shiftDays = dayjs(defaultStartDate).diff(originalDate, 'day');
|
|
216
|
+
_extend.end_date = dayjs(cacheItem._extend.end_date).add(shiftDays, 'day').format('YYYY-MM-DD');
|
|
217
|
+
}
|
|
218
|
+
}
|
|
192
219
|
var _getServiceTimes = getServiceTimes(_objectSpread(_objectSpread({}, cacheItem), {}, {
|
|
193
220
|
_extend: _extend
|
|
194
221
|
})),
|
|
@@ -203,7 +230,7 @@ export function getServiceStartTimeAndEndTime(params) {
|
|
|
203
230
|
_extend.start_date = (_extend$start_date = _extend.start_date) !== null && _extend$start_date !== void 0 ? _extend$start_date : startDate;
|
|
204
231
|
_extend.end_date = (_extend$end_date = _extend.end_date) !== null && _extend$end_date !== void 0 ? _extend$end_date : endDate;
|
|
205
232
|
}
|
|
206
|
-
var session = cacheItem === null || cacheItem === void 0 || (_cacheItem$
|
|
233
|
+
var session = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend8 = cacheItem._extend) === null || _cacheItem$_extend8 === void 0 || (_cacheItem$_extend8 = _cacheItem$_extend8.other) === null || _cacheItem$_extend8 === void 0 ? void 0 : _cacheItem$_extend8.session;
|
|
207
234
|
if (isSessionProduct(cacheItem) && session) {
|
|
208
235
|
var baseDate = ctx.date ? dayjs(ctx.date) : dayjs();
|
|
209
236
|
var startAt = dayjs("".concat(baseDate.format('YYYY-MM-DD'), " ").concat(dayjs(session.start_at).format('HH:mm:ss')));
|
|
@@ -228,7 +255,7 @@ export function getServiceStartTimeAndEndTime(params) {
|
|
|
228
255
|
* 入参 ctx 必须至少给:bookingConfig / resourcesOriginMap / resourcesOrigin / date。
|
|
229
256
|
*/
|
|
230
257
|
export function getProductExtend(params) {
|
|
231
|
-
var _cacheItem$
|
|
258
|
+
var _cacheItem$_extend9;
|
|
232
259
|
var isDisabledTime = params.isDisabledTime;
|
|
233
260
|
var hasRememberedTime = params.ctx.rememberedTime !== undefined;
|
|
234
261
|
var cacheItem = hasRememberedTime ? seedRememberedBookingStart(params.cacheItem, params.ctx) : params.cacheItem;
|
|
@@ -236,27 +263,38 @@ export function getProductExtend(params) {
|
|
|
236
263
|
previousService: undefined,
|
|
237
264
|
presetStartTime: undefined
|
|
238
265
|
}) : params.ctx;
|
|
239
|
-
var isNew = cacheItem.new || !((_cacheItem$
|
|
266
|
+
var isNew = cacheItem.new || !((_cacheItem$_extend9 = cacheItem._extend) !== null && _cacheItem$_extend9 !== void 0 && _cacheItem$_extend9.endDate);
|
|
240
267
|
var _cacheItem = _objectSpread({}, cacheItem);
|
|
241
268
|
var resourcesOriginMap = ctx.resourcesOriginMap || {};
|
|
242
269
|
_cacheItem._data = {};
|
|
243
270
|
if (isMultiDayProduct(cacheItem)) {
|
|
244
|
-
var _cacheItem$
|
|
271
|
+
var _cacheItem$_extend10;
|
|
245
272
|
_cacheItem._extend = _cacheItem._extend || {};
|
|
246
|
-
_cacheItem._extend.holder_id = (cacheItem === null || cacheItem === void 0 || (_cacheItem$
|
|
273
|
+
_cacheItem._extend.holder_id = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend10 = cacheItem._extend) === null || _cacheItem$_extend10 === void 0 ? void 0 : _cacheItem$_extend10.holder_id) || [];
|
|
247
274
|
_cacheItem._extend.sub_type = 'days';
|
|
248
275
|
}
|
|
249
276
|
if (isNew) {
|
|
250
|
-
var _ctx$bookingConfig3;
|
|
277
|
+
var _cacheItem$_data$sale, _cacheItem$_data, _ctx$bookingConfig3;
|
|
251
278
|
_cacheItem._data.timeObj = getTimeObj({
|
|
252
279
|
cacheItem: cacheItem,
|
|
253
280
|
ctx: ctx
|
|
254
281
|
});
|
|
282
|
+
var defaultBookingStartFallback = (_cacheItem$_data$sale = (_cacheItem$_data = cacheItem._data) === null || _cacheItem$_data === void 0 ? void 0 : _cacheItem$_data.salesDefaultBookingFallback) !== null && _cacheItem$_data$sale !== void 0 ? _cacheItem$_data$sale : getDefaultBookingStartFallback(cacheItem, ctx);
|
|
255
283
|
_cacheItem._extend = getServiceStartTimeAndEndTime({
|
|
256
284
|
cacheItem: cacheItem,
|
|
257
285
|
timeObj: _cacheItem._data.timeObj,
|
|
258
|
-
ctx: ctx
|
|
286
|
+
ctx: ctx,
|
|
287
|
+
defaultBookingStartFallback: defaultBookingStartFallback
|
|
259
288
|
});
|
|
289
|
+
if (ctx.resolveDefaultBookingStart && !hasRememberedTime && !isSessionProduct(cacheItem)) {
|
|
290
|
+
var _cacheItem$_data2, _cacheItem$_extend11;
|
|
291
|
+
var start = "".concat(dayjs(_cacheItem._extend.start_date).format('YYYY-MM-DD'), "T").concat(_cacheItem._extend.start_time);
|
|
292
|
+
var previousDefault = (_cacheItem$_data2 = cacheItem._data) === null || _cacheItem$_data2 === void 0 ? void 0 : _cacheItem$_data2.salesDefaultBookingStart;
|
|
293
|
+
if (!((_cacheItem$_extend11 = cacheItem._extend) !== null && _cacheItem$_extend11 !== void 0 && _cacheItem$_extend11.start_time) || previousDefault && dayjs(start).valueOf() === dayjs(previousDefault).valueOf()) {
|
|
294
|
+
_cacheItem._data.salesDefaultBookingStart = start;
|
|
295
|
+
_cacheItem._data.salesDefaultBookingFallback = defaultBookingStartFallback;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
260
298
|
_cacheItem._data.capacitys = cacheItem.capacity;
|
|
261
299
|
_cacheItem._data.resourcesOrigin = getResourceByIds(resourcesOriginMap, cacheItem, {
|
|
262
300
|
resourceTab: ctx === null || ctx === void 0 || (_ctx$bookingConfig3 = ctx.bookingConfig) === null || _ctx$bookingConfig3 === void 0 || (_ctx$bookingConfig3 = _ctx$bookingConfig3.config) === null || _ctx$bookingConfig3 === void 0 ? void 0 : _ctx$bookingConfig3.resource_tab,
|
|
@@ -304,14 +342,14 @@ export function getProductExtend(params) {
|
|
|
304
342
|
_cacheItem._time = new Date().getTime();
|
|
305
343
|
}
|
|
306
344
|
} else {
|
|
307
|
-
var _cacheItem$
|
|
345
|
+
var _cacheItem$_extend13;
|
|
308
346
|
if (!_cacheItem._data.capacitys) {
|
|
309
347
|
_cacheItem._data.capacitys = cacheItem.capacity;
|
|
310
348
|
}
|
|
311
349
|
if (!_cacheItem._data.resourcesOrigin) {
|
|
312
|
-
var _cacheItem$
|
|
350
|
+
var _cacheItem$_extend12, _ctx$bookingConfig4;
|
|
313
351
|
var extraResources = [];
|
|
314
|
-
if (Array.isArray((_cacheItem$
|
|
352
|
+
if (Array.isArray((_cacheItem$_extend12 = _cacheItem._extend) === null || _cacheItem$_extend12 === void 0 ? void 0 : _cacheItem$_extend12.event_resources)) {
|
|
315
353
|
_cacheItem._extend.event_resources.forEach(function (er) {
|
|
316
354
|
extraResources.push({
|
|
317
355
|
form_id: er.form_id,
|
|
@@ -337,7 +375,7 @@ export function getProductExtend(params) {
|
|
|
337
375
|
}
|
|
338
376
|
_cacheItem._data.timeObj = getTimeObj({
|
|
339
377
|
cacheItem: _cacheItem,
|
|
340
|
-
useStartTime: (_cacheItem$
|
|
378
|
+
useStartTime: (_cacheItem$_extend13 = _cacheItem._extend) === null || _cacheItem$_extend13 === void 0 ? void 0 : _cacheItem$_extend13.start_time,
|
|
341
379
|
ctx: ctx
|
|
342
380
|
});
|
|
343
381
|
}
|
|
@@ -350,13 +388,13 @@ export function getProductExtend(params) {
|
|
|
350
388
|
* `getAutoAllocationStorage` 抽象为入参 `isAutoAllocationOn(formId)`。
|
|
351
389
|
*/
|
|
352
390
|
export function getIsAutoClose(cacheItem, isAutoAllocationOn) {
|
|
353
|
-
var _cacheItem$
|
|
391
|
+
var _cacheItem$_data3, _cacheItem$_extend14;
|
|
354
392
|
if (productNeedsResourceExtend(cacheItem) && !hasActualResourceSelection(cacheItem)) {
|
|
355
393
|
return false;
|
|
356
394
|
}
|
|
357
|
-
if (((_cacheItem$
|
|
358
|
-
var _cacheItem$
|
|
359
|
-
var resources = (cacheItem === null || cacheItem === void 0 || (_cacheItem$
|
|
395
|
+
if (((_cacheItem$_data3 = cacheItem._data) === null || _cacheItem$_data3 === void 0 || (_cacheItem$_data3 = _cacheItem$_data3.capacitys) === null || _cacheItem$_data3 === void 0 ? void 0 : _cacheItem$_data3.type) !== 'custom') {
|
|
396
|
+
var _cacheItem$_data4;
|
|
397
|
+
var resources = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_data4 = cacheItem._data) === null || _cacheItem$_data4 === void 0 ? void 0 : _cacheItem$_data4.resources) || [];
|
|
360
398
|
if (resources.length === 1) {
|
|
361
399
|
var _first$select_type;
|
|
362
400
|
var first = resources[0];
|
|
@@ -365,14 +403,14 @@ export function getIsAutoClose(cacheItem, isAutoAllocationOn) {
|
|
|
365
403
|
}
|
|
366
404
|
}
|
|
367
405
|
}
|
|
368
|
-
var entries = Object.entries(((_cacheItem$
|
|
406
|
+
var entries = Object.entries(((_cacheItem$_extend14 = cacheItem._extend) === null || _cacheItem$_extend14 === void 0 ? void 0 : _cacheItem$_extend14.resource) || {});
|
|
369
407
|
if (entries.length === 0) {
|
|
370
408
|
return !productNeedsResourceExtend(cacheItem);
|
|
371
409
|
}
|
|
372
|
-
return entries.every(function (
|
|
373
|
-
var
|
|
374
|
-
key =
|
|
375
|
-
value =
|
|
410
|
+
return entries.every(function (_ref2) {
|
|
411
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
412
|
+
key = _ref3[0],
|
|
413
|
+
value = _ref3[1];
|
|
376
414
|
return isAutoAllocationOn(key) && Array.isArray(value) && value.length > 0;
|
|
377
415
|
});
|
|
378
416
|
}
|
|
@@ -4,6 +4,7 @@ import type { ScheduleModule } from '../Schedule';
|
|
|
4
4
|
import type { OpenDataConfig, OpenDataFetchParams, OpenDataAvailabilityResult, InvoiceLayoutConfig, InvoiceTemplateSettings } from './types';
|
|
5
5
|
export * from './types';
|
|
6
6
|
export * from './contactInfo';
|
|
7
|
+
export * from './salesSettings';
|
|
7
8
|
export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceLayoutFromTemplateSettings, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, resolveInvoiceReceiptLocales, } from './utils';
|
|
8
9
|
export declare class OpenDataModule extends BaseModule implements Module {
|
|
9
10
|
protected defaultName: string;
|
|
@@ -19,6 +19,7 @@ import { BaseModule } from "../BaseModule";
|
|
|
19
19
|
import { computeAvailability, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutFromTemplateSettings, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings } from "./utils";
|
|
20
20
|
export * from "./types";
|
|
21
21
|
export * from "./contactInfo";
|
|
22
|
+
export * from "./salesSettings";
|
|
22
23
|
export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceLayoutFromTemplateSettings, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, resolveInvoiceReceiptLocales } from "./utils";
|
|
23
24
|
function isRecord(value) {
|
|
24
25
|
return !!value && _typeof(value) === 'object' && !Array.isArray(value);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { MultiLangObject, OpenDataConfig } from './types';
|
|
2
|
+
export type MultipleBookingScheduling = 'one_after_another' | 'same_start_time';
|
|
3
|
+
export type ResourceSelectionMode = 'customer_optional' | 'customer_required' | 'automatic';
|
|
4
|
+
export interface SalesResourceSetting {
|
|
5
|
+
name?: string | MultiLangObject;
|
|
6
|
+
resourceSelectionMode: ResourceSelectionMode;
|
|
7
|
+
skipResourceSelectionIfSingle: boolean;
|
|
8
|
+
autoAssignmentRule: 'optimal_idle_time';
|
|
9
|
+
}
|
|
10
|
+
export interface ResolvedSalesSettings {
|
|
11
|
+
cart: {
|
|
12
|
+
showProductImage: boolean;
|
|
13
|
+
showRemoveButton: boolean;
|
|
14
|
+
};
|
|
15
|
+
product: {
|
|
16
|
+
checkRequiredOptions: boolean;
|
|
17
|
+
};
|
|
18
|
+
stock: {
|
|
19
|
+
checkStock: boolean;
|
|
20
|
+
allowInsufficientStock: boolean;
|
|
21
|
+
showDontRemindAgainToday: boolean;
|
|
22
|
+
};
|
|
23
|
+
reservation: {
|
|
24
|
+
multipleBookingScheduling: MultipleBookingScheduling;
|
|
25
|
+
resourceSettings: Record<string, SalesResourceSetting>;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export declare const DEFAULT_SALES_RESOURCE_SETTING: Readonly<SalesResourceSetting>;
|
|
29
|
+
/** PiCoding stores this field as a form-ID map despite its administration schema's array declaration. */
|
|
30
|
+
export declare function normalizeSalesResourceSettings(value: unknown): Record<string, SalesResourceSetting>;
|
|
31
|
+
/** Normalize a successfully loaded OpenData snapshot; callers must propagate loading failures. */
|
|
32
|
+
export declare function normalizeSalesSettings(raw: OpenDataConfig | null | undefined, platform: unknown): ResolvedSalesSettings;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
7
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
9
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
10
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
13
|
+
import { normalizeRuntimePlatform } from "../../utils/platform";
|
|
14
|
+
export var DEFAULT_SALES_RESOURCE_SETTING = Object.freeze({
|
|
15
|
+
resourceSelectionMode: 'customer_optional',
|
|
16
|
+
skipResourceSelectionIfSingle: true,
|
|
17
|
+
autoAssignmentRule: 'optimal_idle_time'
|
|
18
|
+
});
|
|
19
|
+
function isRecord(value) {
|
|
20
|
+
return !!value && _typeof(value) === 'object' && !Array.isArray(value);
|
|
21
|
+
}
|
|
22
|
+
function booleanOr(value, fallback) {
|
|
23
|
+
return typeof value === 'boolean' ? value : fallback;
|
|
24
|
+
}
|
|
25
|
+
function normalizeResourceName(value) {
|
|
26
|
+
if (typeof value === 'string') return value.trim() ? value : undefined;
|
|
27
|
+
if (!isRecord(value)) return undefined;
|
|
28
|
+
var entries = Object.entries(value).filter(function (_ref) {
|
|
29
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
30
|
+
text = _ref2[1];
|
|
31
|
+
return typeof text === 'string' && text.trim();
|
|
32
|
+
});
|
|
33
|
+
return entries.length ? Object.fromEntries(entries) : undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** PiCoding stores this field as a form-ID map despite its administration schema's array declaration. */
|
|
37
|
+
export function normalizeSalesResourceSettings(value) {
|
|
38
|
+
if (!isRecord(value)) return {};
|
|
39
|
+
var entries = Object.entries(value).flatMap(function (_ref3) {
|
|
40
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
41
|
+
formId = _ref4[0],
|
|
42
|
+
setting = _ref4[1];
|
|
43
|
+
if (!/^[1-9]\d*$/.test(formId) || !isRecord(setting)) return [];
|
|
44
|
+
var name = normalizeResourceName(setting.name);
|
|
45
|
+
var mode = setting.resourceSelectionMode;
|
|
46
|
+
return [[formId, _objectSpread(_objectSpread({}, name === undefined ? {} : {
|
|
47
|
+
name: name
|
|
48
|
+
}), {}, {
|
|
49
|
+
resourceSelectionMode: mode === 'customer_required' || mode === 'automatic' ? mode : 'customer_optional',
|
|
50
|
+
skipResourceSelectionIfSingle: booleanOr(setting.skipResourceSelectionIfSingle, true),
|
|
51
|
+
// No new allocation algorithm is introduced by this migration.
|
|
52
|
+
autoAssignmentRule: 'optimal_idle_time'
|
|
53
|
+
})]];
|
|
54
|
+
});
|
|
55
|
+
return Object.fromEntries(entries);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Normalize a successfully loaded OpenData snapshot; callers must propagate loading failures. */
|
|
59
|
+
export function normalizeSalesSettings(raw, platform) {
|
|
60
|
+
var runtimePlatform = normalizeRuntimePlatform(platform);
|
|
61
|
+
var isPos = runtimePlatform === 'pos' || runtimePlatform === 'webpos';
|
|
62
|
+
return {
|
|
63
|
+
cart: {
|
|
64
|
+
showProductImage: booleanOr(raw === null || raw === void 0 ? void 0 : raw['interface.show_product_image'], true),
|
|
65
|
+
showRemoveButton: isPos || booleanOr(raw === null || raw === void 0 ? void 0 : raw['interface.show_remove_button'], true)
|
|
66
|
+
},
|
|
67
|
+
product: {
|
|
68
|
+
checkRequiredOptions: booleanOr(raw === null || raw === void 0 ? void 0 : raw['sale.check_required_options'], true)
|
|
69
|
+
},
|
|
70
|
+
stock: {
|
|
71
|
+
checkStock: !isPos || booleanOr(raw === null || raw === void 0 ? void 0 : raw['sale.stock_settings'], true),
|
|
72
|
+
allowInsufficientStock: isPos && booleanOr(raw === null || raw === void 0 ? void 0 : raw['sale.allow_adding_insufficient_stock'], false),
|
|
73
|
+
showDontRemindAgainToday: isPos && booleanOr(raw === null || raw === void 0 ? void 0 : raw['sale.show_option'], false)
|
|
74
|
+
},
|
|
75
|
+
reservation: {
|
|
76
|
+
multipleBookingScheduling: (raw === null || raw === void 0 ? void 0 : raw['reservation.multiple_booking_scheduling']) === 'same_start_time' ? 'same_start_time' : 'one_after_another',
|
|
77
|
+
resourceSettings: normalizeSalesResourceSettings(raw === null || raw === void 0 ? void 0 : raw['reservation.resource_setting'])
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -67,7 +67,20 @@ export interface OpenDataConfig {
|
|
|
67
67
|
'reservation.auto_confirm_mode'?: string;
|
|
68
68
|
'reservation.auto_confirm_delay_seconds'?: number;
|
|
69
69
|
'reservation.time_slice'?: number | string;
|
|
70
|
+
'reservation.multiple_booking_scheduling'?: 'one_after_another' | 'same_start_time';
|
|
71
|
+
'reservation.resource_setting'?: Record<string, {
|
|
72
|
+
name?: string | MultiLangObject;
|
|
73
|
+
resourceSelectionMode?: 'customer_optional' | 'customer_required' | 'automatic';
|
|
74
|
+
skipResourceSelectionIfSingle?: boolean;
|
|
75
|
+
autoAssignmentRule?: 'optimal_idle_time';
|
|
76
|
+
}>;
|
|
77
|
+
'interface.show_product_image'?: boolean;
|
|
78
|
+
'interface.show_remove_button'?: boolean;
|
|
70
79
|
'sale.allow_item_notes'?: boolean;
|
|
80
|
+
'sale.check_required_options'?: boolean;
|
|
81
|
+
'sale.stock_settings'?: boolean;
|
|
82
|
+
'sale.allow_adding_insufficient_stock'?: boolean;
|
|
83
|
+
'sale.show_option'?: boolean;
|
|
71
84
|
'sale.allow_order_notes'?: boolean;
|
|
72
85
|
'sale.enable_contact_info'?: boolean;
|
|
73
86
|
'sale.first_name.visible'?: boolean;
|
|
@@ -1525,7 +1525,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
1525
1525
|
key: "scanWalletAssetAsync",
|
|
1526
1526
|
value: function () {
|
|
1527
1527
|
var _scanWalletAssetAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(code) {
|
|
1528
|
-
var normalizedCode, selectedAsset, result, paymentAssets, asset, items, recalculatedState, assetId, recalculatedAsset, selected, isSelected, selectedStateAsset, resolvedAsset;
|
|
1528
|
+
var normalizedCode, selectedAsset, result, paymentAssets, matchedAsset, assetsToApply, asset, _items, assetIds, selectionSources, _selected, items, recalculatedState, assetId, recalculatedAsset, selected, isSelected, selectedStateAsset, resolvedAsset;
|
|
1529
1529
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
1530
1530
|
while (1) switch (_context9.prev = _context9.next) {
|
|
1531
1531
|
case 0:
|
|
@@ -1578,11 +1578,13 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
1578
1578
|
if (paymentAssets.length > 0) {
|
|
1579
1579
|
this.searchResults = mergeWalletAssets(this.searchResults, paymentAssets);
|
|
1580
1580
|
}
|
|
1581
|
-
|
|
1581
|
+
matchedAsset = paymentAssets.find(function (item) {
|
|
1582
1582
|
return String((item === null || item === void 0 ? void 0 : item.code) || '') === normalizedCode;
|
|
1583
|
-
})
|
|
1583
|
+
}); // 精确命中券码时仅处理该券;未命中时处理接口返回的全部结果。
|
|
1584
|
+
assetsToApply = matchedAsset ? [matchedAsset] : paymentAssets;
|
|
1585
|
+
asset = assetsToApply[0];
|
|
1584
1586
|
if (asset) {
|
|
1585
|
-
_context9.next =
|
|
1587
|
+
_context9.next = 19;
|
|
1586
1588
|
break;
|
|
1587
1589
|
}
|
|
1588
1590
|
return _context9.abrupt("return", {
|
|
@@ -1591,7 +1593,31 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
1591
1593
|
selected: false,
|
|
1592
1594
|
state: this.getWalletAssetsState()
|
|
1593
1595
|
});
|
|
1594
|
-
case
|
|
1596
|
+
case 19:
|
|
1597
|
+
if (!(!matchedAsset && assetsToApply.length > 1)) {
|
|
1598
|
+
_context9.next = 26;
|
|
1599
|
+
break;
|
|
1600
|
+
}
|
|
1601
|
+
_items = mergeWalletAssets(this.walletAssetsState.items, assetsToApply);
|
|
1602
|
+
assetIds = assetsToApply.map(function (item) {
|
|
1603
|
+
return getWalletAssetId(item);
|
|
1604
|
+
}).filter(function (id) {
|
|
1605
|
+
return id !== undefined && id !== null;
|
|
1606
|
+
});
|
|
1607
|
+
selectionSources = _objectSpread({}, this.walletAssetsState.selectionSources);
|
|
1608
|
+
assetIds.forEach(function (id) {
|
|
1609
|
+
selectionSources[String(id)] = 'scan';
|
|
1610
|
+
});
|
|
1611
|
+
_selected = this.walletAssetsBehavior.autoSelectAfterSearch ? this.recalculateWalletAssets(_items, Array.from(new Set([].concat(_toConsumableArray(this.walletAssetsState.selectedIds), _toConsumableArray(assetIds)))), selectionSources) : this.recalculateWalletAssets(_items, this.walletAssetsState.selectedIds, this.walletAssetsState.selectionSources);
|
|
1612
|
+
return _context9.abrupt("return", {
|
|
1613
|
+
type: result.type,
|
|
1614
|
+
asset: asset,
|
|
1615
|
+
selected: assetIds.some(function (id) {
|
|
1616
|
+
return _selected.selectedIds.includes(id);
|
|
1617
|
+
}),
|
|
1618
|
+
state: _selected
|
|
1619
|
+
});
|
|
1620
|
+
case 26:
|
|
1595
1621
|
items = mergeWalletAssets(this.walletAssetsState.items, [asset]);
|
|
1596
1622
|
recalculatedState = this.recalculateWalletAssets(items, this.walletAssetsState.selectedIds, this.walletAssetsState.selectionSources);
|
|
1597
1623
|
assetId = getWalletAssetId(asset);
|
|
@@ -1621,7 +1647,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
1621
1647
|
selected: isSelected,
|
|
1622
1648
|
state: selected
|
|
1623
1649
|
});
|
|
1624
|
-
case
|
|
1650
|
+
case 36:
|
|
1625
1651
|
case "end":
|
|
1626
1652
|
return _context9.stop();
|
|
1627
1653
|
}
|
|
@@ -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(): "normal" | "duration" | "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 | 2 |
|
|
331
|
+
weekNum: 0 | 1 | 2 | 6 | 3 | 4 | 5;
|
|
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
|
*
|
|
@@ -447,7 +447,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
447
447
|
/**
|
|
448
448
|
* 构造 BookingContext 计算上下文(供 getProductExtend / getResourceByIds 等读 API 复用)。
|
|
449
449
|
*/
|
|
450
|
-
|
|
450
|
+
protected buildBookingCalcContext(extra?: Partial<BookingCalcContext>): BookingCalcContext;
|
|
451
451
|
/**
|
|
452
452
|
* 取商品当前可选资源列表(透传 OS BookingContext utils#getResourceByIds)。
|
|
453
453
|
* `extraResources` 用于把拖入未绑定的资源也展示出来。
|
|
@@ -480,7 +480,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
480
480
|
/**
|
|
481
481
|
* 拼装 addProductDecision 通用上下文(从 store 自取)。
|
|
482
482
|
*/
|
|
483
|
-
|
|
483
|
+
protected buildAddProductCtx(extra?: Partial<AddProductDecideContext>): AddProductDecideContext;
|
|
484
484
|
/**
|
|
485
485
|
* 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
|
|
486
486
|
* 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
2
|
import type { ProductData } from '../../modules';
|
|
3
|
-
import
|
|
3
|
+
import type { BookingCalcContext } from '../../modules/BookingContext';
|
|
4
|
+
import type { AddProductDecideContext } from '../BookingTicket/utils/addProductDecision';
|
|
5
|
+
import { type InvoiceLayoutConfig, type InvoiceTemplateSettings, type OpenDataConfig, type ResolvedSalesSettings } from '../../modules/OpenData';
|
|
4
6
|
import type { LoadScheduleAvailableDateParams, ScheduleItem } from '../../modules/Schedule/types';
|
|
5
7
|
import type { ProductListLoadProductsParams, ProductListStoreQueryParams } from '../../modules/ProductList';
|
|
6
8
|
import type { AvailabilityDateRange, AvailabilityOccupancy, AvailabilityProduct, AvailabilityResource, GetProductTimeRangesRequest } from '../../modules/ResourcePlanner';
|
|
@@ -9,6 +11,7 @@ import type { BusinessAvailability } from '../../modules/BusinessAvailability';
|
|
|
9
11
|
import { BookingTicket } from '../BookingTicket';
|
|
10
12
|
import type { AllergyRequirement } from '../../model/strategy/adapter/itemRule';
|
|
11
13
|
export * from './types';
|
|
14
|
+
export * from './salesSettings';
|
|
12
15
|
export type { BusinessAvailability, BusinessClosedBehavior } from '../../modules/BusinessAvailability';
|
|
13
16
|
export { AvailabilityError } from '../../modules/ResourcePlanner';
|
|
14
17
|
/**
|
|
@@ -178,6 +181,24 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
178
181
|
/** A successful configuration belongs to this business runtime until an explicit refresh. */
|
|
179
182
|
loadOpenData(params: UnifiedBookingSalesLoadOpenDataParams): Promise<OpenDataConfig>;
|
|
180
183
|
getOpenData(): Promise<OpenDataConfig | null>;
|
|
184
|
+
/** One policy snapshot for all Sales 2.0 consumers. Network errors must reach the caller. */
|
|
185
|
+
getSalesSettings(): Promise<ResolvedSalesSettings>;
|
|
186
|
+
private getLoadedSalesSettings;
|
|
187
|
+
private getProductBookingsForScheduling;
|
|
188
|
+
private shouldApplyMultipleBookingScheduling;
|
|
189
|
+
private resolveLoadedDefaultBookingStart;
|
|
190
|
+
/** Used by the SKU flow after Holder changes, without changing an explicit user-selected time. */
|
|
191
|
+
resolveDefaultBookingStart(params: {
|
|
192
|
+
holderIds?: unknown;
|
|
193
|
+
fallback?: string;
|
|
194
|
+
}): Promise<string | undefined>;
|
|
195
|
+
protected buildBookingCalcContext(extra?: Partial<BookingCalcContext>): BookingCalcContext;
|
|
196
|
+
protected buildAddProductCtx(extra?: Partial<AddProductDecideContext>): AddProductDecideContext;
|
|
197
|
+
/** Re-evaluate an automatic default after Holder enrichment, or restore a known explicit TimeBar start. */
|
|
198
|
+
applyDefaultBookingStart(cacheItem: any, options?: {
|
|
199
|
+
holderIds?: unknown;
|
|
200
|
+
explicitStart?: string;
|
|
201
|
+
}): Promise<any>;
|
|
181
202
|
protected loadPickupTimingOpenData(_force: boolean): Promise<Record<string, unknown>>;
|
|
182
203
|
private resetAllergyItemRuleState;
|
|
183
204
|
private fetchAllergyItemRuleConfigs;
|