@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
|
@@ -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
|
+
}
|
|
@@ -59,6 +59,12 @@ export interface UnifiedBookingSalesPrepareAvailabilityProjectionParams {
|
|
|
59
59
|
dateRange?: Partial<AvailabilityDateRange>;
|
|
60
60
|
catalogScope?: UnifiedBookingSalesCatalogScope;
|
|
61
61
|
rawProducts?: Record<string, any>[];
|
|
62
|
+
/** Keep an independent catalog/projection without replacing the public sales catalog. Defaults to true. */
|
|
63
|
+
publishCatalog?: boolean;
|
|
64
|
+
/** Await remote occupancy refresh instead of stale-while-revalidate. Ignores rawResources; does not lock resources. */
|
|
65
|
+
refreshOccupancies?: boolean;
|
|
66
|
+
/** Enforce configured sale cutoffs and disable manual POS availability overrides for this context. Defaults to false. */
|
|
67
|
+
strictAvailability?: boolean;
|
|
62
68
|
rawResources?: Record<string, any>[];
|
|
63
69
|
rawOccupancies?: AvailabilityOccupancy[];
|
|
64
70
|
editingProductLineUids?: string[];
|
|
@@ -152,10 +158,20 @@ export interface UnifiedBookingSalesAddRetailProductParams {
|
|
|
152
158
|
productId?: number | string;
|
|
153
159
|
quantity?: number;
|
|
154
160
|
productLoadParams?: ProductListLoadProductsParams;
|
|
161
|
+
salesNotes?: SalesNoteDraftInput[];
|
|
162
|
+
availabilityCommitGuard?: () => void;
|
|
155
163
|
}
|
|
156
164
|
export interface ContextualCommitAvailabilitySelectionParams {
|
|
157
|
-
mode: 'add' | 'edit';
|
|
165
|
+
mode: 'add' | 'edit' | 'replace';
|
|
166
|
+
/** Local UI intent guard, checked again immediately before the Order mutation. */
|
|
167
|
+
availabilityCommitGuard?: () => void;
|
|
158
168
|
productLineUid?: string;
|
|
169
|
+
/**
|
|
170
|
+
* Confirmed complete Party extras set (configured, service-datetime-repriced retail source products).
|
|
171
|
+
* Required for replace; edit opts into the same atomic path. Existing extras keep their own
|
|
172
|
+
* metadata.unique_identification_number; new extras omit it. [] explicitly removes all owned extras.
|
|
173
|
+
*/
|
|
174
|
+
relatedRetailProducts?: Record<string, any>[];
|
|
159
175
|
orderProduct: Record<string, any>;
|
|
160
176
|
candidate: ContextualProductTimeRange;
|
|
161
177
|
requirementSelections: AvailabilityRequirementSelection[];
|
|
@@ -1,46 +1 @@
|
|
|
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; }
|
|
1
|
+
"use strict";
|
|
@@ -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。
|
|
@@ -100,6 +100,11 @@ function getTimeObj(params) {
|
|
|
100
100
|
durationSlicesBasedOnTime
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
+
function getDefaultBookingStartFallback(cacheItem, ctx) {
|
|
104
|
+
const date = (0, _dayjs.default)(cacheItem?._extend?.start_date ?? ctx.date ?? (0, _dayjs.default)()).format('YYYY-MM-DD');
|
|
105
|
+
const time = ctx.presetStartTime || cacheItem.currentDefaultTime || (0, _dayjs.default)().format('HH:mm');
|
|
106
|
+
return `${date}T${time}`;
|
|
107
|
+
}
|
|
103
108
|
|
|
104
109
|
/**
|
|
105
110
|
* 计算商品行 _extend(包含 start_time / endDate / duration / start_date / end_date / sub_type 等)。
|
|
@@ -119,7 +124,7 @@ function getServiceStartTimeAndEndTime(params) {
|
|
|
119
124
|
duration: null
|
|
120
125
|
};
|
|
121
126
|
}
|
|
122
|
-
const appointmentTimingPreference = getAppointmentTimingPreference(ctx);
|
|
127
|
+
const appointmentTimingPreference = ctx.resolveDefaultBookingStart ? undefined : getAppointmentTimingPreference(ctx);
|
|
123
128
|
const lastServer = ctx.previousService || null;
|
|
124
129
|
const resolveDuration = () => {
|
|
125
130
|
if ((0, _serviceTimes.isMultiDayProduct)(cacheItem)) return (0, _serviceTimes.getDays)(cacheItem, 'days');
|
|
@@ -128,7 +133,14 @@ function getServiceStartTimeAndEndTime(params) {
|
|
|
128
133
|
let _extend = {
|
|
129
134
|
duration: resolveDuration()
|
|
130
135
|
};
|
|
131
|
-
if (
|
|
136
|
+
if (ctx.resolveDefaultBookingStart && !cacheItem._extend?.start_time && !(0, _serviceTimes.isSessionProduct)(cacheItem)) {
|
|
137
|
+
const fallback = params.defaultBookingStartFallback ?? getDefaultBookingStartFallback(cacheItem, ctx);
|
|
138
|
+
const start = ctx.resolveDefaultBookingStart(cacheItem, fallback);
|
|
139
|
+
if (start) {
|
|
140
|
+
_extend.start_date = start.slice(0, 10);
|
|
141
|
+
_extend.start_time = start.slice(11);
|
|
142
|
+
}
|
|
143
|
+
} else if (lastServer) {
|
|
132
144
|
const lastStart = lastServer._extend?.startDate;
|
|
133
145
|
const lastEnd = lastServer._extend?.endDate;
|
|
134
146
|
if (appointmentTimingPreference === 'parallel') {
|
|
@@ -150,10 +162,21 @@ function getServiceStartTimeAndEndTime(params) {
|
|
|
150
162
|
_extend.start_time = (0, _dayjs.default)().format('HH:mm');
|
|
151
163
|
}
|
|
152
164
|
}
|
|
165
|
+
const defaultStartDate = _extend.start_date;
|
|
153
166
|
_extend = {
|
|
154
167
|
..._extend,
|
|
155
168
|
...cacheItem._extend
|
|
156
169
|
};
|
|
170
|
+
// start_date on a new cache item is a calendar anchor, not a manually selected time.
|
|
171
|
+
// Preserve the complete default after a previous booking crossed midnight.
|
|
172
|
+
if (defaultStartDate && !cacheItem._extend?.start_time) {
|
|
173
|
+
_extend.start_date = defaultStartDate;
|
|
174
|
+
if ((0, _serviceTimes.isMultiDayProduct)(cacheItem) && cacheItem._extend?.end_date) {
|
|
175
|
+
const originalDate = (0, _dayjs.default)(cacheItem._extend.start_date ?? ctx.date).startOf('day');
|
|
176
|
+
const shiftDays = (0, _dayjs.default)(defaultStartDate).diff(originalDate, 'day');
|
|
177
|
+
_extend.end_date = (0, _dayjs.default)(cacheItem._extend.end_date).add(shiftDays, 'day').format('YYYY-MM-DD');
|
|
178
|
+
}
|
|
179
|
+
}
|
|
157
180
|
const {
|
|
158
181
|
startDate,
|
|
159
182
|
endDate
|
|
@@ -215,11 +238,21 @@ function getProductExtend(params) {
|
|
|
215
238
|
cacheItem,
|
|
216
239
|
ctx
|
|
217
240
|
});
|
|
241
|
+
const defaultBookingStartFallback = cacheItem._data?.salesDefaultBookingFallback ?? getDefaultBookingStartFallback(cacheItem, ctx);
|
|
218
242
|
_cacheItem._extend = getServiceStartTimeAndEndTime({
|
|
219
243
|
cacheItem,
|
|
220
244
|
timeObj: _cacheItem._data.timeObj,
|
|
221
|
-
ctx
|
|
245
|
+
ctx,
|
|
246
|
+
defaultBookingStartFallback
|
|
222
247
|
});
|
|
248
|
+
if (ctx.resolveDefaultBookingStart && !(0, _serviceTimes.isSessionProduct)(cacheItem)) {
|
|
249
|
+
const start = `${(0, _dayjs.default)(_cacheItem._extend.start_date).format('YYYY-MM-DD')}T${_cacheItem._extend.start_time}`;
|
|
250
|
+
const previousDefault = cacheItem._data?.salesDefaultBookingStart;
|
|
251
|
+
if (!cacheItem._extend?.start_time || previousDefault && (0, _dayjs.default)(start).valueOf() === (0, _dayjs.default)(previousDefault).valueOf()) {
|
|
252
|
+
_cacheItem._data.salesDefaultBookingStart = start;
|
|
253
|
+
_cacheItem._data.salesDefaultBookingFallback = defaultBookingStartFallback;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
223
256
|
_cacheItem._data.capacitys = cacheItem.capacity;
|
|
224
257
|
_cacheItem._data.resourcesOrigin = (0, _resources.getResourceByIds)(resourcesOriginMap, cacheItem, {
|
|
225
258
|
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;
|
|
@@ -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';
|