@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
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { MultipleBookingScheduling } from '../../modules/OpenData';
|
|
2
|
+
export interface ResolveDefaultBookingStartParams {
|
|
3
|
+
/** Product bookings in cart insertion order; unrelated order-level bookings are excluded by the facade. */
|
|
4
|
+
bookings: readonly Record<string, any>[];
|
|
5
|
+
holderIds?: unknown;
|
|
6
|
+
mode?: MultipleBookingScheduling;
|
|
7
|
+
fallback?: string;
|
|
8
|
+
}
|
|
9
|
+
/** Normalize scalar/array holder identities without merging the no-holder group with real holders. */
|
|
10
|
+
export declare function normalizeBookingHolderIds(value: unknown): string[];
|
|
11
|
+
export declare function getBookingHolderIds(booking: Record<string, any>): string[];
|
|
12
|
+
/** Validate input and convert absolute ISO values to the runtime-local date/time used by booking fields. */
|
|
13
|
+
export declare function normalizeBookingDateTime(value: unknown): string | undefined;
|
|
14
|
+
export declare function getBookingBoundary(booking: Record<string, any>, edge: 'start' | 'end'): string | undefined;
|
|
15
|
+
/** Select a default only; availability and resource occupancy remain the commit path's authority. */
|
|
16
|
+
export declare function resolveDefaultBookingStart({ bookings, holderIds, mode, fallback, }: ResolveDefaultBookingStartParams): string | undefined;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
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; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import dayjs from 'dayjs';
|
|
8
|
+
import { isFulfillmentTimingBooking } from "../../modules/Order/pickupTiming";
|
|
9
|
+
/** Normalize scalar/array holder identities without merging the no-holder group with real holders. */
|
|
10
|
+
export function normalizeBookingHolderIds(value) {
|
|
11
|
+
var values = Array.isArray(value) ? value : value == null ? [] : [value];
|
|
12
|
+
return Array.from(new Set(values.flatMap(function (id) {
|
|
13
|
+
if (typeof id !== 'string' && typeof id !== 'number') return [];
|
|
14
|
+
var text = String(id).trim();
|
|
15
|
+
return text && text !== '0' ? [text] : [];
|
|
16
|
+
})));
|
|
17
|
+
}
|
|
18
|
+
export function getBookingHolderIds(booking) {
|
|
19
|
+
var _ref, _ref2, _ref3, _ref4, _booking$holder_id, _booking$metadata, _booking$holder, _booking$metadata2, _booking$_extend, _booking$_extend2;
|
|
20
|
+
return normalizeBookingHolderIds((_ref = (_ref2 = (_ref3 = (_ref4 = (_booking$holder_id = booking.holder_id) !== null && _booking$holder_id !== void 0 ? _booking$holder_id : (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.holder_id) !== null && _ref4 !== void 0 ? _ref4 : (_booking$holder = booking.holder) === null || _booking$holder === void 0 ? void 0 : _booking$holder.form_record) !== null && _ref3 !== void 0 ? _ref3 : (_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 || (_booking$metadata2 = _booking$metadata2.holder) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.form_record) !== null && _ref2 !== void 0 ? _ref2 : (_booking$_extend = booking._extend) === null || _booking$_extend === void 0 ? void 0 : _booking$_extend.holder_id) !== null && _ref !== void 0 ? _ref : (_booking$_extend2 = booking._extend) === null || _booking$_extend2 === void 0 || (_booking$_extend2 = _booking$_extend2.holder) === null || _booking$_extend2 === void 0 ? void 0 : _booking$_extend2.form_record);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Validate input and convert absolute ISO values to the runtime-local date/time used by booking fields. */
|
|
24
|
+
export function normalizeBookingDateTime(value) {
|
|
25
|
+
if (typeof value !== 'string') return undefined;
|
|
26
|
+
var text = value.trim().replace(' ', 'T');
|
|
27
|
+
var match = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,3})?)?(Z|[+-]\d{2}:\d{2})?$/.exec(text);
|
|
28
|
+
if (!match) return undefined;
|
|
29
|
+
var _match = _slicedToArray(match, 8),
|
|
30
|
+
y = _match[1],
|
|
31
|
+
m = _match[2],
|
|
32
|
+
d = _match[3],
|
|
33
|
+
h = _match[4],
|
|
34
|
+
minute = _match[5],
|
|
35
|
+
_match$ = _match[6],
|
|
36
|
+
second = _match$ === void 0 ? '0' : _match$,
|
|
37
|
+
zone = _match[7];
|
|
38
|
+
var calendar = new Date("".concat(y, "-").concat(m, "-").concat(d, "T00:00:00.000Z"));
|
|
39
|
+
if (!Number.isFinite(calendar.getTime()) || calendar.toISOString().slice(0, 10) !== "".concat(y, "-").concat(m, "-").concat(d) || Number(h) > 23 || Number(minute) > 59 || Number(second) > 59 || !dayjs(text).isValid()) return undefined;
|
|
40
|
+
return zone ? dayjs(text).format('YYYY-MM-DDTHH:mm:ss') : text;
|
|
41
|
+
}
|
|
42
|
+
export function getBookingBoundary(booking, edge) {
|
|
43
|
+
var _booking;
|
|
44
|
+
var direct = (_booking = booking["".concat(edge, "At")]) !== null && _booking !== void 0 ? _booking : booking["".concat(edge, "_at")];
|
|
45
|
+
var directTime = normalizeBookingDateTime(direct);
|
|
46
|
+
if (directTime) return directTime;
|
|
47
|
+
var date = booking["".concat(edge, "_date")];
|
|
48
|
+
var time = booking["".concat(edge, "_time")];
|
|
49
|
+
if (typeof date !== 'string') return undefined;
|
|
50
|
+
return typeof time === 'string' ? normalizeBookingDateTime("".concat(date.slice(0, 10), "T").concat(time)) : normalizeBookingDateTime(date);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Select a default only; availability and resource occupancy remain the commit path's authority. */
|
|
54
|
+
export function resolveDefaultBookingStart(_ref5) {
|
|
55
|
+
var bookings = _ref5.bookings,
|
|
56
|
+
holderIds = _ref5.holderIds,
|
|
57
|
+
_ref5$mode = _ref5.mode,
|
|
58
|
+
mode = _ref5$mode === void 0 ? 'one_after_another' : _ref5$mode,
|
|
59
|
+
fallback = _ref5.fallback;
|
|
60
|
+
var holders = new Set(normalizeBookingHolderIds(holderIds));
|
|
61
|
+
var related = bookings.flatMap(function (booking) {
|
|
62
|
+
if (!booking || isFulfillmentTimingBooking(booking) || booking.deleted_at) return [];
|
|
63
|
+
var previousHolders = getBookingHolderIds(booking);
|
|
64
|
+
var matches = holders.size === 0 ? previousHolders.length === 0 : previousHolders.some(function (holder) {
|
|
65
|
+
return holders.has(holder);
|
|
66
|
+
});
|
|
67
|
+
if (!matches) return [];
|
|
68
|
+
var start = getBookingBoundary(booking, 'start');
|
|
69
|
+
var end = getBookingBoundary(booking, 'end');
|
|
70
|
+
if (!start || !end || !dayjs(end).isAfter(dayjs(start))) return [];
|
|
71
|
+
return [{
|
|
72
|
+
start: start,
|
|
73
|
+
end: end
|
|
74
|
+
}];
|
|
75
|
+
});
|
|
76
|
+
if (!related.length) return normalizeBookingDateTime(fallback);
|
|
77
|
+
if (mode === 'same_start_time') return related[related.length - 1].start;
|
|
78
|
+
return related.reduce(function (latest, booking) {
|
|
79
|
+
return dayjs(booking.end).isAfter(dayjs(latest)) ? booking.end : latest;
|
|
80
|
+
}, related[0].end);
|
|
81
|
+
}
|
|
@@ -1 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _examples.BUY_X_GET_Y_FREE_STRATEGY;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _examples.ITEM_REWARD_STRATEGY;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "PromotionAdapter", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _adapter.PromotionAdapter;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "PromotionEvaluator", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _evaluator.PromotionEvaluator;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "default", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _adapter.default;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
var _evaluator = require("./evaluator");
|
|
43
|
+
var _adapter = _interopRequireWildcard(require("./adapter"));
|
|
44
|
+
var _examples = require("./examples");
|
|
45
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -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。
|
|
@@ -138,6 +138,11 @@ function getTimeObj(params) {
|
|
|
138
138
|
durationSlicesBasedOnTime
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
|
+
function getDefaultBookingStartFallback(cacheItem, ctx) {
|
|
142
|
+
const date = (0, _dayjs.default)(cacheItem?._extend?.start_date ?? ctx.date ?? (0, _dayjs.default)()).format('YYYY-MM-DD');
|
|
143
|
+
const time = ctx.presetStartTime || cacheItem.currentDefaultTime || (0, _dayjs.default)().format('HH:mm');
|
|
144
|
+
return `${date}T${time}`;
|
|
145
|
+
}
|
|
141
146
|
|
|
142
147
|
/**
|
|
143
148
|
* 计算商品行 _extend(包含 start_time / endDate / duration / start_date / end_date / sub_type 等)。
|
|
@@ -157,7 +162,7 @@ function getServiceStartTimeAndEndTime(params) {
|
|
|
157
162
|
duration: null
|
|
158
163
|
};
|
|
159
164
|
}
|
|
160
|
-
const appointmentTimingPreference = getAppointmentTimingPreference(ctx);
|
|
165
|
+
const appointmentTimingPreference = ctx.resolveDefaultBookingStart ? undefined : getAppointmentTimingPreference(ctx);
|
|
161
166
|
const lastServer = ctx.previousService || null;
|
|
162
167
|
const resolveDuration = () => {
|
|
163
168
|
if ((0, _serviceTimes.isMultiDayProduct)(cacheItem)) return (0, _serviceTimes.getDays)(cacheItem, 'days');
|
|
@@ -166,7 +171,14 @@ function getServiceStartTimeAndEndTime(params) {
|
|
|
166
171
|
let _extend = {
|
|
167
172
|
duration: resolveDuration()
|
|
168
173
|
};
|
|
169
|
-
if (
|
|
174
|
+
if (ctx.resolveDefaultBookingStart && !ctx.rememberedTime && !cacheItem._extend?.start_time && !(0, _serviceTimes.isSessionProduct)(cacheItem)) {
|
|
175
|
+
const fallback = params.defaultBookingStartFallback ?? getDefaultBookingStartFallback(cacheItem, ctx);
|
|
176
|
+
const 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) {
|
|
170
182
|
const lastStart = lastServer._extend?.startDate;
|
|
171
183
|
const lastEnd = lastServer._extend?.endDate;
|
|
172
184
|
if (appointmentTimingPreference === 'parallel') {
|
|
@@ -188,10 +200,21 @@ function getServiceStartTimeAndEndTime(params) {
|
|
|
188
200
|
_extend.start_time = (0, _dayjs.default)().format('HH:mm');
|
|
189
201
|
}
|
|
190
202
|
}
|
|
203
|
+
const defaultStartDate = _extend.start_date;
|
|
191
204
|
_extend = {
|
|
192
205
|
..._extend,
|
|
193
206
|
...cacheItem._extend
|
|
194
207
|
};
|
|
208
|
+
// start_date on a new cache item is a calendar anchor, not a manually selected time.
|
|
209
|
+
// Preserve the complete default after a previous booking crossed midnight.
|
|
210
|
+
if (defaultStartDate && !cacheItem._extend?.start_time) {
|
|
211
|
+
_extend.start_date = defaultStartDate;
|
|
212
|
+
if ((0, _serviceTimes.isMultiDayProduct)(cacheItem) && cacheItem._extend?.end_date) {
|
|
213
|
+
const originalDate = (0, _dayjs.default)(cacheItem._extend.start_date ?? ctx.date).startOf('day');
|
|
214
|
+
const shiftDays = (0, _dayjs.default)(defaultStartDate).diff(originalDate, 'day');
|
|
215
|
+
_extend.end_date = (0, _dayjs.default)(cacheItem._extend.end_date).add(shiftDays, 'day').format('YYYY-MM-DD');
|
|
216
|
+
}
|
|
217
|
+
}
|
|
195
218
|
const {
|
|
196
219
|
startDate,
|
|
197
220
|
endDate
|
|
@@ -258,11 +281,21 @@ function getProductExtend(params) {
|
|
|
258
281
|
cacheItem,
|
|
259
282
|
ctx
|
|
260
283
|
});
|
|
284
|
+
const defaultBookingStartFallback = cacheItem._data?.salesDefaultBookingFallback ?? getDefaultBookingStartFallback(cacheItem, ctx);
|
|
261
285
|
_cacheItem._extend = getServiceStartTimeAndEndTime({
|
|
262
286
|
cacheItem,
|
|
263
287
|
timeObj: _cacheItem._data.timeObj,
|
|
264
|
-
ctx
|
|
288
|
+
ctx,
|
|
289
|
+
defaultBookingStartFallback
|
|
265
290
|
});
|
|
291
|
+
if (ctx.resolveDefaultBookingStart && !hasRememberedTime && !(0, _serviceTimes.isSessionProduct)(cacheItem)) {
|
|
292
|
+
const start = `${(0, _dayjs.default)(_cacheItem._extend.start_date).format('YYYY-MM-DD')}T${_cacheItem._extend.start_time}`;
|
|
293
|
+
const previousDefault = cacheItem._data?.salesDefaultBookingStart;
|
|
294
|
+
if (!cacheItem._extend?.start_time || previousDefault && (0, _dayjs.default)(start).valueOf() === (0, _dayjs.default)(previousDefault).valueOf()) {
|
|
295
|
+
_cacheItem._data.salesDefaultBookingStart = start;
|
|
296
|
+
_cacheItem._data.salesDefaultBookingFallback = defaultBookingStartFallback;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
266
299
|
_cacheItem._data.capacitys = cacheItem.capacity;
|
|
267
300
|
_cacheItem._data.resourcesOrigin = (0, _resources.getResourceByIds)(resourcesOriginMap, cacheItem, {
|
|
268
301
|
resourceTab: ctx?.bookingConfig?.config?.resource_tab,
|
|
@@ -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;
|
|
@@ -89,6 +89,18 @@ Object.keys(_contactInfo).forEach(function (key) {
|
|
|
89
89
|
}
|
|
90
90
|
});
|
|
91
91
|
});
|
|
92
|
+
var _salesSettings = require("./salesSettings");
|
|
93
|
+
Object.keys(_salesSettings).forEach(function (key) {
|
|
94
|
+
if (key === "default" || key === "__esModule") return;
|
|
95
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
96
|
+
if (key in exports && exports[key] === _salesSettings[key]) return;
|
|
97
|
+
Object.defineProperty(exports, key, {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
get: function () {
|
|
100
|
+
return _salesSettings[key];
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
});
|
|
92
104
|
function isRecord(value) {
|
|
93
105
|
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
94
106
|
}
|
|
@@ -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,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DEFAULT_SALES_RESOURCE_SETTING = void 0;
|
|
7
|
+
exports.normalizeSalesResourceSettings = normalizeSalesResourceSettings;
|
|
8
|
+
exports.normalizeSalesSettings = normalizeSalesSettings;
|
|
9
|
+
var _platform = require("../../utils/platform");
|
|
10
|
+
const DEFAULT_SALES_RESOURCE_SETTING = exports.DEFAULT_SALES_RESOURCE_SETTING = Object.freeze({
|
|
11
|
+
resourceSelectionMode: 'customer_optional',
|
|
12
|
+
skipResourceSelectionIfSingle: true,
|
|
13
|
+
autoAssignmentRule: 'optimal_idle_time'
|
|
14
|
+
});
|
|
15
|
+
function isRecord(value) {
|
|
16
|
+
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
17
|
+
}
|
|
18
|
+
function booleanOr(value, fallback) {
|
|
19
|
+
return typeof value === 'boolean' ? value : fallback;
|
|
20
|
+
}
|
|
21
|
+
function normalizeResourceName(value) {
|
|
22
|
+
if (typeof value === 'string') return value.trim() ? value : undefined;
|
|
23
|
+
if (!isRecord(value)) return undefined;
|
|
24
|
+
const entries = Object.entries(value).filter(([, text]) => typeof text === 'string' && text.trim());
|
|
25
|
+
return entries.length ? Object.fromEntries(entries) : undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** PiCoding stores this field as a form-ID map despite its administration schema's array declaration. */
|
|
29
|
+
function normalizeSalesResourceSettings(value) {
|
|
30
|
+
if (!isRecord(value)) return {};
|
|
31
|
+
const entries = Object.entries(value).flatMap(([formId, setting]) => {
|
|
32
|
+
if (!/^[1-9]\d*$/.test(formId) || !isRecord(setting)) return [];
|
|
33
|
+
const name = normalizeResourceName(setting.name);
|
|
34
|
+
const mode = setting.resourceSelectionMode;
|
|
35
|
+
return [[formId, {
|
|
36
|
+
...(name === undefined ? {} : {
|
|
37
|
+
name
|
|
38
|
+
}),
|
|
39
|
+
resourceSelectionMode: mode === 'customer_required' || mode === 'automatic' ? mode : 'customer_optional',
|
|
40
|
+
skipResourceSelectionIfSingle: booleanOr(setting.skipResourceSelectionIfSingle, true),
|
|
41
|
+
// No new allocation algorithm is introduced by this migration.
|
|
42
|
+
autoAssignmentRule: 'optimal_idle_time'
|
|
43
|
+
}]];
|
|
44
|
+
});
|
|
45
|
+
return Object.fromEntries(entries);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Normalize a successfully loaded OpenData snapshot; callers must propagate loading failures. */
|
|
49
|
+
function normalizeSalesSettings(raw, platform) {
|
|
50
|
+
const runtimePlatform = (0, _platform.normalizeRuntimePlatform)(platform);
|
|
51
|
+
const isPos = runtimePlatform === 'pos' || runtimePlatform === 'webpos';
|
|
52
|
+
return {
|
|
53
|
+
cart: {
|
|
54
|
+
showProductImage: booleanOr(raw?.['interface.show_product_image'], true),
|
|
55
|
+
showRemoveButton: isPos || booleanOr(raw?.['interface.show_remove_button'], true)
|
|
56
|
+
},
|
|
57
|
+
product: {
|
|
58
|
+
checkRequiredOptions: booleanOr(raw?.['sale.check_required_options'], true)
|
|
59
|
+
},
|
|
60
|
+
stock: {
|
|
61
|
+
checkStock: !isPos || booleanOr(raw?.['sale.stock_settings'], true),
|
|
62
|
+
allowInsufficientStock: isPos && booleanOr(raw?.['sale.allow_adding_insufficient_stock'], false),
|
|
63
|
+
showDontRemindAgainToday: isPos && booleanOr(raw?.['sale.show_option'], false)
|
|
64
|
+
},
|
|
65
|
+
reservation: {
|
|
66
|
+
multipleBookingScheduling: raw?.['reservation.multiple_booking_scheduling'] === 'same_start_time' ? 'same_start_time' : 'one_after_another',
|
|
67
|
+
resourceSettings: normalizeSalesResourceSettings(raw?.['reservation.resource_setting'])
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -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;
|
|
@@ -1146,7 +1146,10 @@ class WalletPassPaymentImpl {
|
|
|
1146
1146
|
if (paymentAssets.length > 0) {
|
|
1147
1147
|
this.searchResults = mergeWalletAssets(this.searchResults, paymentAssets);
|
|
1148
1148
|
}
|
|
1149
|
-
const
|
|
1149
|
+
const matchedAsset = paymentAssets.find(item => String(item?.code || '') === normalizedCode);
|
|
1150
|
+
// 精确命中券码时仅处理该券;未命中时处理接口返回的全部结果。
|
|
1151
|
+
const assetsToApply = matchedAsset ? [matchedAsset] : paymentAssets;
|
|
1152
|
+
const asset = assetsToApply[0];
|
|
1150
1153
|
if (!asset) {
|
|
1151
1154
|
return {
|
|
1152
1155
|
type: 'normalCode',
|
|
@@ -1155,6 +1158,25 @@ class WalletPassPaymentImpl {
|
|
|
1155
1158
|
state: this.getWalletAssetsState()
|
|
1156
1159
|
};
|
|
1157
1160
|
}
|
|
1161
|
+
|
|
1162
|
+
// 根据 code 找不到结果时,则使用接口返回的所有券数据(扫手环)
|
|
1163
|
+
if (!matchedAsset && assetsToApply.length > 1) {
|
|
1164
|
+
const items = mergeWalletAssets(this.walletAssetsState.items, assetsToApply);
|
|
1165
|
+
const assetIds = assetsToApply.map(item => getWalletAssetId(item)).filter(id => id !== undefined && id !== null);
|
|
1166
|
+
const selectionSources = {
|
|
1167
|
+
...this.walletAssetsState.selectionSources
|
|
1168
|
+
};
|
|
1169
|
+
assetIds.forEach(id => {
|
|
1170
|
+
selectionSources[String(id)] = 'scan';
|
|
1171
|
+
});
|
|
1172
|
+
const selected = this.walletAssetsBehavior.autoSelectAfterSearch ? this.recalculateWalletAssets(items, Array.from(new Set([...this.walletAssetsState.selectedIds, ...assetIds])), selectionSources) : this.recalculateWalletAssets(items, this.walletAssetsState.selectedIds, this.walletAssetsState.selectionSources);
|
|
1173
|
+
return {
|
|
1174
|
+
type: result.type,
|
|
1175
|
+
asset,
|
|
1176
|
+
selected: assetIds.some(id => selected.selectedIds.includes(id)),
|
|
1177
|
+
state: selected
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1158
1180
|
const items = mergeWalletAssets(this.walletAssetsState.items, [asset]);
|
|
1159
1181
|
const recalculatedState = this.recalculateWalletAssets(items, this.walletAssetsState.selectedIds, this.walletAssetsState.selectionSources);
|
|
1160
1182
|
const assetId = getWalletAssetId(asset);
|
|
@@ -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;
|