@pisell/pisellos 0.10.70 → 0.10.72
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/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/Order/index.d.ts +13 -4
- package/dist/modules/Order/index.js +1401 -764
- package/dist/modules/Order/types.d.ts +24 -1
- package/dist/modules/Order/types.js +4 -0
- package/dist/server/index.js +5 -2
- package/dist/solution/BaseSales/index.d.ts +2 -2
- package/dist/solution/BaseSales/index.js +8 -8
- package/dist/solution/BookingTicket/index.d.ts +2 -2
- package/dist/solution/UnifiedBookingSales/index.d.ts +36 -1
- package/dist/solution/UnifiedBookingSales/index.js +1434 -709
- package/dist/solution/UnifiedBookingSales/salesSettings.d.ts +16 -0
- package/dist/solution/UnifiedBookingSales/salesSettings.js +81 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +17 -1
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- 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/Order/index.d.ts +13 -4
- package/lib/modules/Order/index.js +284 -24
- package/lib/modules/Order/types.d.ts +24 -1
- package/lib/modules/Order/types.js +2 -0
- package/lib/server/index.js +5 -1
- package/lib/solution/BaseSales/index.d.ts +2 -2
- package/lib/solution/BaseSales/index.js +2 -2
- package/lib/solution/BookingTicket/index.d.ts +2 -2
- package/lib/solution/UnifiedBookingSales/index.d.ts +36 -1
- package/lib/solution/UnifiedBookingSales/index.js +463 -45
- package/lib/solution/UnifiedBookingSales/salesSettings.d.ts +16 -0
- package/lib/solution/UnifiedBookingSales/salesSettings.js +72 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +17 -1
- package/package.json +1 -1
|
@@ -17,6 +17,10 @@ export interface BookingCalcContext {
|
|
|
17
17
|
date?: any;
|
|
18
18
|
/** 上一个服务行(getServiceStartTimeAndEndTime 拼接续接 start_time 用)。可缺省。 */
|
|
19
19
|
previousService?: any;
|
|
20
|
+
/** UBS-only default-time policy. Other solutions retain their existing Board behavior. */
|
|
21
|
+
resolveDefaultBookingStart?: (cacheItem: any, fallback: string) => string | undefined;
|
|
22
|
+
/** Explicit holder context supplied before the cache item has received its holder snapshot. */
|
|
23
|
+
holderIds?: unknown;
|
|
20
24
|
/** 日历选中的资源 id(替代 info2 sessionStorage.serviceParams.resource_id)。 */
|
|
21
25
|
resourceIdFromCalendar?: number;
|
|
22
26
|
/** 资源自动分派开关(替代 info2 localStorage 'resource-auto-allocation');默认全开。 */
|
|
@@ -51,6 +55,7 @@ export declare function getServiceStartTimeAndEndTime(params: {
|
|
|
51
55
|
cacheItem: any;
|
|
52
56
|
timeObj: TimeSlicesResult;
|
|
53
57
|
ctx: BookingCalcContext;
|
|
58
|
+
defaultBookingStartFallback?: string;
|
|
54
59
|
}): any;
|
|
55
60
|
/**
|
|
56
61
|
* 综合:把 cacheItem 拼装出完整的 _extend / _data(资源 / 容量 / timeObj),并标记 autoClose。
|
|
@@ -96,6 +96,12 @@ export function getTimeObj(params) {
|
|
|
96
96
|
durationSlicesBasedOnTime: durationSlicesBasedOnTime
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
+
function getDefaultBookingStartFallback(cacheItem, ctx) {
|
|
100
|
+
var _ref, _cacheItem$_extend$st, _cacheItem$_extend3;
|
|
101
|
+
var date = dayjs((_ref = (_cacheItem$_extend$st = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend3 = cacheItem._extend) === null || _cacheItem$_extend3 === void 0 ? void 0 : _cacheItem$_extend3.start_date) !== null && _cacheItem$_extend$st !== void 0 ? _cacheItem$_extend$st : ctx.date) !== null && _ref !== void 0 ? _ref : dayjs()).format('YYYY-MM-DD');
|
|
102
|
+
var time = ctx.presetStartTime || cacheItem.currentDefaultTime || dayjs().format('HH:mm');
|
|
103
|
+
return "".concat(date, "T").concat(time);
|
|
104
|
+
}
|
|
99
105
|
|
|
100
106
|
/**
|
|
101
107
|
* 计算商品行 _extend(包含 start_time / endDate / duration / start_date / end_date / sub_type 等)。
|
|
@@ -105,7 +111,7 @@ export function getTimeObj(params) {
|
|
|
105
111
|
* - cacheItem.isCustomItem → 直接返回 `{ duration: null }`。
|
|
106
112
|
*/
|
|
107
113
|
export function getServiceStartTimeAndEndTime(params) {
|
|
108
|
-
var _cacheItem$
|
|
114
|
+
var _cacheItem$_extend4, _cacheItem$_extend5, _cacheItem$_extend7;
|
|
109
115
|
var cacheItem = params.cacheItem,
|
|
110
116
|
timeObj = params.timeObj,
|
|
111
117
|
ctx = params.ctx;
|
|
@@ -114,7 +120,7 @@ export function getServiceStartTimeAndEndTime(params) {
|
|
|
114
120
|
duration: null
|
|
115
121
|
};
|
|
116
122
|
}
|
|
117
|
-
var appointmentTimingPreference = getAppointmentTimingPreference(ctx);
|
|
123
|
+
var appointmentTimingPreference = ctx.resolveDefaultBookingStart ? undefined : getAppointmentTimingPreference(ctx);
|
|
118
124
|
var lastServer = ctx.previousService || null;
|
|
119
125
|
var resolveDuration = function resolveDuration() {
|
|
120
126
|
var _cacheItem$duration;
|
|
@@ -124,7 +130,15 @@ export function getServiceStartTimeAndEndTime(params) {
|
|
|
124
130
|
var _extend = {
|
|
125
131
|
duration: resolveDuration()
|
|
126
132
|
};
|
|
127
|
-
if (
|
|
133
|
+
if (ctx.resolveDefaultBookingStart && !((_cacheItem$_extend4 = cacheItem._extend) !== null && _cacheItem$_extend4 !== void 0 && _cacheItem$_extend4.start_time) && !isSessionProduct(cacheItem)) {
|
|
134
|
+
var _params$defaultBookin;
|
|
135
|
+
var _fallback = (_params$defaultBookin = params.defaultBookingStartFallback) !== null && _params$defaultBookin !== void 0 ? _params$defaultBookin : getDefaultBookingStartFallback(cacheItem, ctx);
|
|
136
|
+
var start = ctx.resolveDefaultBookingStart(cacheItem, _fallback);
|
|
137
|
+
if (start) {
|
|
138
|
+
_extend.start_date = start.slice(0, 10);
|
|
139
|
+
_extend.start_time = start.slice(11);
|
|
140
|
+
}
|
|
141
|
+
} else if (lastServer) {
|
|
128
142
|
var _lastServer$_extend, _lastServer$_extend2;
|
|
129
143
|
var lastStart = (_lastServer$_extend = lastServer._extend) === null || _lastServer$_extend === void 0 ? void 0 : _lastServer$_extend.startDate;
|
|
130
144
|
var lastEnd = (_lastServer$_extend2 = lastServer._extend) === null || _lastServer$_extend2 === void 0 ? void 0 : _lastServer$_extend2.endDate;
|
|
@@ -148,7 +162,20 @@ export function getServiceStartTimeAndEndTime(params) {
|
|
|
148
162
|
_extend.start_time = dayjs().format('HH:mm');
|
|
149
163
|
}
|
|
150
164
|
}
|
|
165
|
+
var defaultStartDate = _extend.start_date;
|
|
151
166
|
_extend = _objectSpread(_objectSpread({}, _extend), cacheItem._extend);
|
|
167
|
+
// start_date on a new cache item is a calendar anchor, not a manually selected time.
|
|
168
|
+
// Preserve the complete default after a previous booking crossed midnight.
|
|
169
|
+
if (defaultStartDate && !((_cacheItem$_extend5 = cacheItem._extend) !== null && _cacheItem$_extend5 !== void 0 && _cacheItem$_extend5.start_time)) {
|
|
170
|
+
var _cacheItem$_extend6;
|
|
171
|
+
_extend.start_date = defaultStartDate;
|
|
172
|
+
if (isMultiDayProduct(cacheItem) && (_cacheItem$_extend6 = cacheItem._extend) !== null && _cacheItem$_extend6 !== void 0 && _cacheItem$_extend6.end_date) {
|
|
173
|
+
var _cacheItem$_extend$st2;
|
|
174
|
+
var originalDate = dayjs((_cacheItem$_extend$st2 = cacheItem._extend.start_date) !== null && _cacheItem$_extend$st2 !== void 0 ? _cacheItem$_extend$st2 : ctx.date).startOf('day');
|
|
175
|
+
var shiftDays = dayjs(defaultStartDate).diff(originalDate, 'day');
|
|
176
|
+
_extend.end_date = dayjs(cacheItem._extend.end_date).add(shiftDays, 'day').format('YYYY-MM-DD');
|
|
177
|
+
}
|
|
178
|
+
}
|
|
152
179
|
var _getServiceTimes = getServiceTimes(_objectSpread(_objectSpread({}, cacheItem), {}, {
|
|
153
180
|
_extend: _extend
|
|
154
181
|
})),
|
|
@@ -163,7 +190,7 @@ export function getServiceStartTimeAndEndTime(params) {
|
|
|
163
190
|
_extend.start_date = (_extend$start_date = _extend.start_date) !== null && _extend$start_date !== void 0 ? _extend$start_date : startDate;
|
|
164
191
|
_extend.end_date = (_extend$end_date = _extend.end_date) !== null && _extend$end_date !== void 0 ? _extend$end_date : endDate;
|
|
165
192
|
}
|
|
166
|
-
var session = cacheItem === null || cacheItem === void 0 || (_cacheItem$
|
|
193
|
+
var session = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend7 = cacheItem._extend) === null || _cacheItem$_extend7 === void 0 || (_cacheItem$_extend7 = _cacheItem$_extend7.other) === null || _cacheItem$_extend7 === void 0 ? void 0 : _cacheItem$_extend7.session;
|
|
167
194
|
if (isSessionProduct(cacheItem) && session) {
|
|
168
195
|
var baseDate = ctx.date ? dayjs(ctx.date) : dayjs();
|
|
169
196
|
var startAt = dayjs("".concat(baseDate.format('YYYY-MM-DD'), " ").concat(dayjs(session.start_at).format('HH:mm:ss')));
|
|
@@ -188,31 +215,42 @@ export function getServiceStartTimeAndEndTime(params) {
|
|
|
188
215
|
* 入参 ctx 必须至少给:bookingConfig / resourcesOriginMap / resourcesOrigin / date。
|
|
189
216
|
*/
|
|
190
217
|
export function getProductExtend(params) {
|
|
191
|
-
var _cacheItem$
|
|
218
|
+
var _cacheItem$_extend8;
|
|
192
219
|
var cacheItem = params.cacheItem,
|
|
193
220
|
ctx = params.ctx,
|
|
194
221
|
isDisabledTime = params.isDisabledTime;
|
|
195
|
-
var isNew = cacheItem.new || !((_cacheItem$
|
|
222
|
+
var isNew = cacheItem.new || !((_cacheItem$_extend8 = cacheItem._extend) !== null && _cacheItem$_extend8 !== void 0 && _cacheItem$_extend8.endDate);
|
|
196
223
|
var _cacheItem = _objectSpread({}, cacheItem);
|
|
197
224
|
var resourcesOriginMap = ctx.resourcesOriginMap || {};
|
|
198
225
|
_cacheItem._data = {};
|
|
199
226
|
if (isMultiDayProduct(cacheItem)) {
|
|
200
|
-
var _cacheItem$
|
|
227
|
+
var _cacheItem$_extend9;
|
|
201
228
|
_cacheItem._extend = _cacheItem._extend || {};
|
|
202
|
-
_cacheItem._extend.holder_id = (cacheItem === null || cacheItem === void 0 || (_cacheItem$
|
|
229
|
+
_cacheItem._extend.holder_id = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend9 = cacheItem._extend) === null || _cacheItem$_extend9 === void 0 ? void 0 : _cacheItem$_extend9.holder_id) || [];
|
|
203
230
|
_cacheItem._extend.sub_type = 'days';
|
|
204
231
|
}
|
|
205
232
|
if (isNew) {
|
|
206
|
-
var _ctx$bookingConfig3;
|
|
233
|
+
var _cacheItem$_data$sale, _cacheItem$_data, _ctx$bookingConfig3;
|
|
207
234
|
_cacheItem._data.timeObj = getTimeObj({
|
|
208
235
|
cacheItem: cacheItem,
|
|
209
236
|
ctx: ctx
|
|
210
237
|
});
|
|
238
|
+
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);
|
|
211
239
|
_cacheItem._extend = getServiceStartTimeAndEndTime({
|
|
212
240
|
cacheItem: cacheItem,
|
|
213
241
|
timeObj: _cacheItem._data.timeObj,
|
|
214
|
-
ctx: ctx
|
|
242
|
+
ctx: ctx,
|
|
243
|
+
defaultBookingStartFallback: defaultBookingStartFallback
|
|
215
244
|
});
|
|
245
|
+
if (ctx.resolveDefaultBookingStart && !isSessionProduct(cacheItem)) {
|
|
246
|
+
var _cacheItem$_data2, _cacheItem$_extend10;
|
|
247
|
+
var start = "".concat(dayjs(_cacheItem._extend.start_date).format('YYYY-MM-DD'), "T").concat(_cacheItem._extend.start_time);
|
|
248
|
+
var previousDefault = (_cacheItem$_data2 = cacheItem._data) === null || _cacheItem$_data2 === void 0 ? void 0 : _cacheItem$_data2.salesDefaultBookingStart;
|
|
249
|
+
if (!((_cacheItem$_extend10 = cacheItem._extend) !== null && _cacheItem$_extend10 !== void 0 && _cacheItem$_extend10.start_time) || previousDefault && dayjs(start).valueOf() === dayjs(previousDefault).valueOf()) {
|
|
250
|
+
_cacheItem._data.salesDefaultBookingStart = start;
|
|
251
|
+
_cacheItem._data.salesDefaultBookingFallback = defaultBookingStartFallback;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
216
254
|
_cacheItem._data.capacitys = cacheItem.capacity;
|
|
217
255
|
_cacheItem._data.resourcesOrigin = getResourceByIds(resourcesOriginMap, cacheItem, {
|
|
218
256
|
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,
|
|
@@ -260,14 +298,14 @@ export function getProductExtend(params) {
|
|
|
260
298
|
_cacheItem._time = new Date().getTime();
|
|
261
299
|
}
|
|
262
300
|
} else {
|
|
263
|
-
var _cacheItem$
|
|
301
|
+
var _cacheItem$_extend12;
|
|
264
302
|
if (!_cacheItem._data.capacitys) {
|
|
265
303
|
_cacheItem._data.capacitys = cacheItem.capacity;
|
|
266
304
|
}
|
|
267
305
|
if (!_cacheItem._data.resourcesOrigin) {
|
|
268
|
-
var _cacheItem$
|
|
306
|
+
var _cacheItem$_extend11, _ctx$bookingConfig4;
|
|
269
307
|
var extraResources = [];
|
|
270
|
-
if (Array.isArray((_cacheItem$
|
|
308
|
+
if (Array.isArray((_cacheItem$_extend11 = _cacheItem._extend) === null || _cacheItem$_extend11 === void 0 ? void 0 : _cacheItem$_extend11.event_resources)) {
|
|
271
309
|
_cacheItem._extend.event_resources.forEach(function (er) {
|
|
272
310
|
extraResources.push({
|
|
273
311
|
form_id: er.form_id,
|
|
@@ -293,7 +331,7 @@ export function getProductExtend(params) {
|
|
|
293
331
|
}
|
|
294
332
|
_cacheItem._data.timeObj = getTimeObj({
|
|
295
333
|
cacheItem: _cacheItem,
|
|
296
|
-
useStartTime: (_cacheItem$
|
|
334
|
+
useStartTime: (_cacheItem$_extend12 = _cacheItem._extend) === null || _cacheItem$_extend12 === void 0 ? void 0 : _cacheItem$_extend12.start_time,
|
|
297
335
|
ctx: ctx
|
|
298
336
|
});
|
|
299
337
|
}
|
|
@@ -306,13 +344,13 @@ export function getProductExtend(params) {
|
|
|
306
344
|
* `getAutoAllocationStorage` 抽象为入参 `isAutoAllocationOn(formId)`。
|
|
307
345
|
*/
|
|
308
346
|
export function getIsAutoClose(cacheItem, isAutoAllocationOn) {
|
|
309
|
-
var _cacheItem$
|
|
347
|
+
var _cacheItem$_data3, _cacheItem$_extend13;
|
|
310
348
|
if (productNeedsResourceExtend(cacheItem) && !hasActualResourceSelection(cacheItem)) {
|
|
311
349
|
return false;
|
|
312
350
|
}
|
|
313
|
-
if (((_cacheItem$
|
|
314
|
-
var _cacheItem$
|
|
315
|
-
var resources = (cacheItem === null || cacheItem === void 0 || (_cacheItem$
|
|
351
|
+
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') {
|
|
352
|
+
var _cacheItem$_data4;
|
|
353
|
+
var resources = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_data4 = cacheItem._data) === null || _cacheItem$_data4 === void 0 ? void 0 : _cacheItem$_data4.resources) || [];
|
|
316
354
|
if (resources.length === 1) {
|
|
317
355
|
var _first$select_type;
|
|
318
356
|
var first = resources[0];
|
|
@@ -321,14 +359,14 @@ export function getIsAutoClose(cacheItem, isAutoAllocationOn) {
|
|
|
321
359
|
}
|
|
322
360
|
}
|
|
323
361
|
}
|
|
324
|
-
var entries = Object.entries(((_cacheItem$
|
|
362
|
+
var entries = Object.entries(((_cacheItem$_extend13 = cacheItem._extend) === null || _cacheItem$_extend13 === void 0 ? void 0 : _cacheItem$_extend13.resource) || {});
|
|
325
363
|
if (entries.length === 0) {
|
|
326
364
|
return !productNeedsResourceExtend(cacheItem);
|
|
327
365
|
}
|
|
328
|
-
return entries.every(function (
|
|
329
|
-
var
|
|
330
|
-
key =
|
|
331
|
-
value =
|
|
366
|
+
return entries.every(function (_ref2) {
|
|
367
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
368
|
+
key = _ref3[0],
|
|
369
|
+
value = _ref3[1];
|
|
332
370
|
return isAutoAllocationOn(key) && Array.isArray(value) && value.length > 0;
|
|
333
371
|
});
|
|
334
372
|
}
|
|
@@ -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;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, CancelOrderParams, ChangeBookingStatusParams, CheckoutOrderParams } from './types';
|
|
3
|
+
import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductsOptions, UpdateOrderProductQuantityParams, CancelOrderParams, ChangeBookingStatusParams, CheckoutOrderParams } from './types';
|
|
4
4
|
import { CartItem } from '../Cart/types';
|
|
5
5
|
import { type SubmitPayloadEnhancer } from './utils';
|
|
6
6
|
import { type PickupTimingBooking, type PickupTimingBookingInput } from './pickupTiming';
|
|
7
7
|
import { type ProductVoucherGroup } from './utils/productVoucherGroups';
|
|
8
|
-
import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, OrderHooksConfig, OrderCartIntentCommitContext, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, PointCardSnapshotMergeContext, PointCardSnapshotItem, ShopServiceData, ShopServiceType } from './types';
|
|
8
|
+
import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, ReplaceBookingProductWithRelatedRetailParams, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, OrderHooksConfig, OrderCartIntentCommitContext, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, PointCardSnapshotMergeContext, PointCardSnapshotItem, ShopServiceData, ShopServiceType } from './types';
|
|
9
9
|
import type { ICustomer } from '../AccountList/types';
|
|
10
10
|
import type { Discount } from '../Discount/types';
|
|
11
11
|
import { UnavailableReason } from '../Rules/types';
|
|
@@ -347,6 +347,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
347
347
|
private applyOrderProductsDepositSummary;
|
|
348
348
|
recalculateSummary(options?: {
|
|
349
349
|
createIfMissing?: boolean;
|
|
350
|
+
isCurrentOrder?: () => boolean;
|
|
350
351
|
}): Promise<OrderSummary | null>;
|
|
351
352
|
getOrderSummary(): Promise<OrderSummary>;
|
|
352
353
|
updateTempOrderNote(note: string): string;
|
|
@@ -497,6 +498,13 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
497
498
|
*/
|
|
498
499
|
addProductToOrder(product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput, options?: AddProductToOrderOptions): Promise<OrderProduct[]>;
|
|
499
500
|
private addProductToOrderDraft;
|
|
501
|
+
/**
|
|
502
|
+
* Replaces one local Party booking and its confirmed children on a detached draft.
|
|
503
|
+
* All fallible preparation precedes a guarded synchronous publication; never rolls
|
|
504
|
+
* an old whole-order snapshot over concurrent edits or a newly selected order.
|
|
505
|
+
*/
|
|
506
|
+
replaceBookingProductWithRelatedRetail(params: ReplaceBookingProductWithRelatedRetailParams): Promise<OrderProduct[]>;
|
|
507
|
+
private replaceBookingProductWithRelatedRetailDraft;
|
|
500
508
|
/**
|
|
501
509
|
* 批量添加商品行,所有行追加完成后只触发一次促销、折扣、summary 重算与持久化。
|
|
502
510
|
*
|
|
@@ -525,8 +533,9 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
525
533
|
private applyOrderProductUpdateToTempOrder;
|
|
526
534
|
updateOrderProduct(params: UpdateOrderProductParams): Promise<OrderProduct[]>;
|
|
527
535
|
private updateOrderProductDraft;
|
|
528
|
-
updateOrderProducts(paramsList: UpdateOrderProductParams[]): Promise<OrderProduct[]>;
|
|
536
|
+
updateOrderProducts(paramsList: UpdateOrderProductParams[], options?: UpdateOrderProductsOptions): Promise<OrderProduct[]>;
|
|
529
537
|
private updateOrderProductsDraft;
|
|
538
|
+
private updateOrderProductsGuarded;
|
|
530
539
|
updateOrderProductQuantity(params: UpdateOrderProductQuantityParams): Promise<OrderProduct[]>;
|
|
531
540
|
private updateOrderProductQuantityDraft;
|
|
532
541
|
updateOrderBooking(params: UpdateOrderBookingParams): any[];
|
|
@@ -692,6 +701,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
692
701
|
getOrderInfo(order_id: number): Promise<any>;
|
|
693
702
|
getVouchers(): any[];
|
|
694
703
|
}
|
|
695
|
-
export type { OrderHolderRelation, AddProductToOrderOptions, OrderMetaList, PointCardSnapshotItem, VirtualCurrencySnapshotItem, RemoveProductsFromOrderOptions, SalesNote, SalesNoteDraftInput, SalesNoteLocalizedSelection, SalesNoteLocalizedText, SalesNoteRelation, SalesNoteTextInput, SetSalesNoteInput, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';
|
|
704
|
+
export type { OrderHolderRelation, AddProductToOrderOptions, OrderMetaList, PointCardSnapshotItem, VirtualCurrencySnapshotItem, RemoveProductsFromOrderOptions, SalesNote, SalesNoteDraftInput, SalesNoteLocalizedSelection, SalesNoteLocalizedText, SalesNoteRelation, SalesNoteTextInput, SetSalesNoteInput, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductsOptions, UpdateOrderProductQuantityParams, } from './types';
|
|
696
705
|
export { isFulfillmentTimingBooking } from './pickupTiming';
|
|
697
706
|
export type { PickupTimingBooking, PickupTimingBookingInput, PickupTimingBookingMetadata, PickupTimingSelectionMode, PickupTimingSource, } from './pickupTiming';
|