@pisell/pisellos 2.3.172 → 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.
Files changed (84) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.js +0 -1
  3. package/dist/modules/BookingContext/utils/productExtend.d.ts +5 -0
  4. package/dist/modules/BookingContext/utils/productExtend.js +61 -23
  5. package/dist/modules/Discount/index.js +0 -1
  6. package/dist/modules/OpenData/index.d.ts +1 -0
  7. package/dist/modules/OpenData/index.js +1 -0
  8. package/dist/modules/OpenData/salesSettings.d.ts +32 -0
  9. package/dist/modules/OpenData/salesSettings.js +80 -0
  10. package/dist/modules/OpenData/types.d.ts +13 -0
  11. package/dist/modules/Order/index.d.ts +3 -25
  12. package/dist/modules/Order/index.js +1313 -1772
  13. package/dist/modules/Order/types.d.ts +0 -7
  14. package/dist/modules/Order/utils/discountProductLineIdentity.js +2 -2
  15. package/dist/modules/Product/index.d.ts +1 -1
  16. package/dist/modules/ProductList/index.js +12 -33
  17. package/dist/modules/Rules/index.d.ts +0 -2
  18. package/dist/modules/Rules/index.js +21 -29
  19. package/dist/solution/BaseSales/index.d.ts +1 -16
  20. package/dist/solution/BaseSales/index.js +1325 -1511
  21. package/dist/solution/BookingByStep/index.d.ts +2 -2
  22. package/dist/solution/BookingTicket/index.d.ts +2 -2
  23. package/dist/solution/BookingTicket/index.js +108 -200
  24. package/dist/solution/BookingTicket/types.d.ts +2 -14
  25. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +1 -1
  26. package/dist/solution/BookingTicket/utils/addProductDecision.js +3 -4
  27. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +58 -94
  28. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +0 -1
  29. package/dist/solution/BookingTicket/utils/scan/handleScan.js +1 -2
  30. package/dist/solution/UnifiedBookingSales/index.d.ts +23 -2
  31. package/dist/solution/UnifiedBookingSales/index.js +923 -683
  32. package/dist/solution/UnifiedBookingSales/salesSettings.d.ts +16 -0
  33. package/dist/solution/UnifiedBookingSales/salesSettings.js +81 -0
  34. package/dist/utils/platform.d.ts +0 -2
  35. package/dist/utils/platform.js +0 -6
  36. package/lib/index.d.ts +0 -1
  37. package/lib/index.js +0 -12
  38. package/lib/model/strategy/adapter/promotion/index.js +46 -1
  39. package/lib/modules/BookingContext/utils/productExtend.d.ts +5 -0
  40. package/lib/modules/BookingContext/utils/productExtend.js +36 -3
  41. package/lib/modules/Discount/index.js +0 -1
  42. package/lib/modules/OpenData/index.d.ts +1 -0
  43. package/lib/modules/OpenData/index.js +12 -0
  44. package/lib/modules/OpenData/salesSettings.d.ts +32 -0
  45. package/lib/modules/OpenData/salesSettings.js +70 -0
  46. package/lib/modules/OpenData/types.d.ts +13 -0
  47. package/lib/modules/Order/index.d.ts +3 -25
  48. package/lib/modules/Order/index.js +38 -192
  49. package/lib/modules/Order/types.d.ts +0 -7
  50. package/lib/modules/Order/utils/discountProductLineIdentity.js +1 -1
  51. package/lib/modules/Product/index.d.ts +1 -1
  52. package/lib/modules/ProductList/index.js +0 -15
  53. package/lib/modules/Rules/index.d.ts +0 -2
  54. package/lib/modules/Rules/index.js +0 -6
  55. package/lib/solution/BaseSales/index.d.ts +1 -16
  56. package/lib/solution/BaseSales/index.js +9 -89
  57. package/lib/solution/BookingByStep/index.d.ts +2 -2
  58. package/lib/solution/BookingTicket/index.d.ts +2 -2
  59. package/lib/solution/BookingTicket/index.js +2 -38
  60. package/lib/solution/BookingTicket/types.d.ts +2 -14
  61. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +1 -1
  62. package/lib/solution/BookingTicket/utils/addProductDecision.js +3 -4
  63. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +2 -14
  64. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +0 -1
  65. package/lib/solution/BookingTicket/utils/scan/handleScan.js +1 -2
  66. package/lib/solution/UnifiedBookingSales/index.d.ts +23 -2
  67. package/lib/solution/UnifiedBookingSales/index.js +131 -15
  68. package/lib/solution/UnifiedBookingSales/salesSettings.d.ts +16 -0
  69. package/lib/solution/UnifiedBookingSales/salesSettings.js +72 -0
  70. package/lib/utils/platform.d.ts +0 -2
  71. package/lib/utils/platform.js +0 -7
  72. package/package.json +1 -1
  73. package/dist/inventory/index.d.ts +0 -92
  74. package/dist/inventory/index.js +0 -509
  75. package/dist/modules/Order/utils/productVoucherGroups.d.ts +0 -15
  76. package/dist/modules/Order/utils/productVoucherGroups.js +0 -115
  77. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +0 -10
  78. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +0 -117
  79. package/lib/inventory/index.d.ts +0 -92
  80. package/lib/inventory/index.js +0 -287
  81. package/lib/modules/Order/utils/productVoucherGroups.d.ts +0 -15
  82. package/lib/modules/Order/utils/productVoucherGroups.js +0 -64
  83. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +0 -10
  84. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +0 -71
@@ -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
+ }
@@ -6,5 +6,3 @@ export declare function normalizeRuntimePlatform(platform: unknown): string;
6
6
  * PC and H5 are authenticated-customer clients rather than staff terminals.
7
7
  */
8
8
  export declare function isCustomerUserPlatform(platform: unknown): boolean;
9
- /** Kiosk and vending retain distinct channels but share self-service checkout behavior. */
10
- export declare function isSelfServicePlatform(platform: unknown): boolean;
@@ -1,5 +1,4 @@
1
1
  var CUSTOMER_USER_PLATFORMS = new Set(['pc', 'h5']);
2
- var SELF_SERVICE_PLATFORMS = new Set(['kiosk', 'vending']);
3
2
 
4
3
  /**
5
4
  * Normalize the runtime platform passed through solution/module otherParams.
@@ -13,9 +12,4 @@ export function normalizeRuntimePlatform(platform) {
13
12
  */
14
13
  export function isCustomerUserPlatform(platform) {
15
14
  return CUSTOMER_USER_PLATFORMS.has(normalizeRuntimePlatform(platform));
16
- }
17
-
18
- /** Kiosk and vending retain distinct channels but share self-service checkout behavior. */
19
- export function isSelfServicePlatform(platform) {
20
- return SELF_SERVICE_PLATFORMS.has(normalizeRuntimePlatform(platform));
21
15
  }
package/lib/index.d.ts CHANGED
@@ -7,7 +7,6 @@ export * from './modules';
7
7
  export * from './plugins';
8
8
  export * from './solution';
9
9
  export * from './model';
10
- export * from './inventory';
11
10
  export { PisellOSCore } from './core';
12
11
  import PisellOSCore from './core';
13
12
  export default PisellOSCore;
package/lib/index.js CHANGED
@@ -80,18 +80,6 @@ Object.keys(_model).forEach(function (key) {
80
80
  }
81
81
  });
82
82
  });
83
- var _inventory = require("./inventory");
84
- Object.keys(_inventory).forEach(function (key) {
85
- if (key === "default" || key === "__esModule") return;
86
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
87
- if (key in exports && exports[key] === _inventory[key]) return;
88
- Object.defineProperty(exports, key, {
89
- enumerable: true,
90
- get: function () {
91
- return _inventory[key];
92
- }
93
- });
94
- });
95
83
  var _core = _interopRequireWildcard(require("./core"));
96
84
  var _smallTicket = require("./shared/receipt/small-ticket");
97
85
  Object.keys(_smallTicket).forEach(function (key) {
@@ -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 (lastServer) {
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,
@@ -141,7 +141,6 @@ class DiscountModule extends _BaseModule.BaseModule {
141
141
  } = options || {};
142
142
  const result = await this.request.get(`/machinecode/batch-search`, {
143
143
  code,
144
- resolve_ticket_order: 1,
145
144
  translate_flag: 1,
146
145
  tags: ['entitlement_pass', 'good_pass', 'product_discount_card'],
147
146
  // available: 1,
@@ -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;
@@ -4,8 +4,7 @@ import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrde
4
4
  import { CartItem } from '../Cart/types';
5
5
  import { type SubmitPayloadEnhancer } from './utils';
6
6
  import { type PickupTimingBooking, type PickupTimingBookingInput } from './pickupTiming';
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';
7
+ import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, OrderCartIntentCommitContext, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, PointCardSnapshotMergeContext, PointCardSnapshotItem, ShopServiceData, ShopServiceType } from './types';
9
8
  import type { ICustomer } from '../AccountList/types';
10
9
  import type { Discount } from '../Discount/types';
11
10
  import { UnavailableReason } from '../Rules/types';
@@ -30,12 +29,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
30
29
  private rulesHooksOverride?;
31
30
  private moduleHooksOverride?;
32
31
  private orderHooks?;
33
- private cartCommandQueue;
34
- private queueCartCommand;
35
- /** Use the exact Order normalizers/merge rules on a private draft, not a second projection. */
36
- private beginCartMutation;
37
- /** Serializes checkout preparation with local cart commands; hydration remains outside this guard. */
38
- prepareCheckout<T>(prepare: (items: OrderProduct[]) => Promise<T>): Promise<T>;
39
32
  private otherParams?;
40
33
  /** 评估器引用;由 SalesSdkProvider 注入,未注入时 applyPromotion 静默跳过 */
41
34
  private promotionEvaluator;
@@ -73,11 +66,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
73
66
  * @example
74
67
  * orderModule.updateOtherParams({ cacheId: 'cache-2', channel: 'pos' });
75
68
  */
76
- updateOtherParams(params: Record<string, any>, options?: {
77
- hooks?: OrderHooksConfig;
78
- changedParams?: Record<string, any>;
79
- cover?: boolean;
80
- }): void;
69
+ updateOtherParams(params: Record<string, any>): void;
81
70
  /** Internal intent boundary shared with asynchronous scanner/detail flows. */
82
71
  createCartIntentCommitGuard(action: OrderCartIntentCommitContext['action'], tempOrder?: OrderTempOrder | null): () => void;
83
72
  /** PC/H5 属于在线店铺;其它或缺失平台统一沿用 POS 行为。 */
@@ -95,8 +84,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
95
84
  */
96
85
  private logError;
97
86
  private registerDiscountModules;
98
- setProductVoucherGroups(groups: ProductVoucherGroup[]): void;
99
- validateProductVoucherSelection(): void;
100
87
  private createDefaultRulesHooks;
101
88
  /**
102
89
  * Stable across notifyTempOrderChanged's immutable copy, but changes when a
@@ -115,9 +102,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
115
102
  getCustomerWalletPrepareConfigEpoch(): number;
116
103
  private syncScannedDiscountsToOriginalDiscountList;
117
104
  private ensureEditDiscountConfigForProductChange;
118
- scanCode(code: string, customerId?: number, options?: {
119
- productVouchersOnly?: boolean;
120
- }): Promise<{
105
+ scanCode(code: string, customerId?: number): Promise<{
121
106
  isAvailable: boolean;
122
107
  isAccepted?: boolean;
123
108
  discountList: Discount[];
@@ -497,7 +482,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
497
482
  * // → tempOrder.products 新增 3 行,每行 num=1,bookings 3 条
498
483
  */
499
484
  addProductToOrder(product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput, options?: AddProductToOrderOptions): Promise<OrderProduct[]>;
500
- private addProductToOrderDraft;
501
485
  /**
502
486
  * 批量添加商品行,所有行追加完成后只触发一次促销、折扣、summary 重算与持久化。
503
487
  *
@@ -513,7 +497,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
513
497
  }>, options?: {
514
498
  skipEditDiscountConfigRefresh?: boolean;
515
499
  }): Promise<OrderProduct[]>;
516
- private addProductsToOrderDraft;
517
500
  private getFullCoveragePassDiscounts;
518
501
  private hasEntitlementPassDiscount;
519
502
  private hasGoodPassDiscount;
@@ -525,13 +508,10 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
525
508
  private isRestrictedCartProductUpdate;
526
509
  private applyOrderProductUpdateToTempOrder;
527
510
  updateOrderProduct(params: UpdateOrderProductParams): Promise<OrderProduct[]>;
528
- private updateOrderProductDraft;
529
511
  updateOrderProducts(paramsList: UpdateOrderProductParams[]): Promise<OrderProduct[]>;
530
- private updateOrderProductsDraft;
531
512
  updateOrderProductQuantity(params: UpdateOrderProductQuantityParams, options?: {
532
513
  isCurrentOrder?: () => boolean;
533
514
  }): Promise<OrderProduct[]>;
534
- private updateOrderProductQuantityDraft;
535
515
  updateOrderBooking(params: UpdateOrderBookingParams): any[];
536
516
  /**
537
517
  * 商品行写路径收尾:促销 → 折扣 → 清洗 → summary → 持久化。
@@ -548,14 +528,12 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
548
528
  * await order.removeProductsFromOrder([identityA, identityB]);
549
529
  */
550
530
  removeProductsFromOrder(identities: OrderProductIdentity[], options?: RemoveProductsFromOrderOptions): Promise<OrderProduct[]>;
551
- private removeProductsFromOrderDraft;
552
531
  removeProductFromOrder(identity: OrderProductIdentity, options?: RemoveProductsFromOrderOptions): Promise<OrderProduct[]>;
553
532
  /**
554
533
  * 仅清空购物车行(products / bookings),不重置整单。
555
534
  * 普通整单 note 保持不变;以商品行为主体的 Sales Notes 同步删除。
556
535
  */
557
536
  clearOrderCartLines(): Promise<OrderTempOrder>;
558
- private clearOrderCartLinesDraft;
559
537
  /**
560
538
  * 切换购物车结算单位时清理所有会影响新币种的订单状态,但保留当前客户。
561
539
  */