@pisell/pisellos 2.3.172 → 2.3.174

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 (83) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.js +0 -1
  3. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
  4. package/dist/model/strategy/adapter/promotion/evaluator.js +14 -8
  5. package/dist/modules/BookingContext/utils/productExtend.d.ts +5 -0
  6. package/dist/modules/BookingContext/utils/productExtend.js +61 -23
  7. package/dist/modules/Discount/index.js +0 -1
  8. package/dist/modules/OpenData/index.d.ts +1 -0
  9. package/dist/modules/OpenData/index.js +1 -0
  10. package/dist/modules/OpenData/salesSettings.d.ts +32 -0
  11. package/dist/modules/OpenData/salesSettings.js +80 -0
  12. package/dist/modules/OpenData/types.d.ts +13 -0
  13. package/dist/modules/Order/index.d.ts +3 -25
  14. package/dist/modules/Order/index.js +1313 -1772
  15. package/dist/modules/Order/types.d.ts +0 -7
  16. package/dist/modules/Order/utils/discountProductLineIdentity.js +2 -2
  17. package/dist/modules/ProductList/index.js +12 -33
  18. package/dist/modules/Rules/index.d.ts +0 -2
  19. package/dist/modules/Rules/index.js +21 -29
  20. package/dist/solution/BaseSales/index.d.ts +1 -16
  21. package/dist/solution/BaseSales/index.js +1325 -1511
  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/evaluator.d.ts +2 -1
  39. package/lib/model/strategy/adapter/promotion/evaluator.js +13 -7
  40. package/lib/modules/BookingContext/utils/productExtend.d.ts +5 -0
  41. package/lib/modules/BookingContext/utils/productExtend.js +36 -3
  42. package/lib/modules/Discount/index.js +0 -1
  43. package/lib/modules/OpenData/index.d.ts +1 -0
  44. package/lib/modules/OpenData/index.js +12 -0
  45. package/lib/modules/OpenData/salesSettings.d.ts +32 -0
  46. package/lib/modules/OpenData/salesSettings.js +70 -0
  47. package/lib/modules/OpenData/types.d.ts +13 -0
  48. package/lib/modules/Order/index.d.ts +3 -25
  49. package/lib/modules/Order/index.js +38 -192
  50. package/lib/modules/Order/types.d.ts +0 -7
  51. package/lib/modules/Order/utils/discountProductLineIdentity.js +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/BookingTicket/index.d.ts +2 -2
  58. package/lib/solution/BookingTicket/index.js +2 -38
  59. package/lib/solution/BookingTicket/types.d.ts +2 -14
  60. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +1 -1
  61. package/lib/solution/BookingTicket/utils/addProductDecision.js +3 -4
  62. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +2 -14
  63. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +0 -1
  64. package/lib/solution/BookingTicket/utils/scan/handleScan.js +1 -2
  65. package/lib/solution/UnifiedBookingSales/index.d.ts +23 -2
  66. package/lib/solution/UnifiedBookingSales/index.js +131 -15
  67. package/lib/solution/UnifiedBookingSales/salesSettings.d.ts +16 -0
  68. package/lib/solution/UnifiedBookingSales/salesSettings.js +72 -0
  69. package/lib/utils/platform.d.ts +0 -2
  70. package/lib/utils/platform.js +0 -7
  71. package/package.json +1 -1
  72. package/dist/inventory/index.d.ts +0 -92
  73. package/dist/inventory/index.js +0 -509
  74. package/dist/modules/Order/utils/productVoucherGroups.d.ts +0 -15
  75. package/dist/modules/Order/utils/productVoucherGroups.js +0 -115
  76. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +0 -10
  77. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +0 -117
  78. package/lib/inventory/index.d.ts +0 -92
  79. package/lib/inventory/index.js +0 -287
  80. package/lib/modules/Order/utils/productVoucherGroups.d.ts +0 -15
  81. package/lib/modules/Order/utils/productVoucherGroups.js +0 -64
  82. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +0 -10
  83. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +0 -71
@@ -36,6 +36,18 @@ var _pickupTiming = require("../../modules/Order/pickupTiming");
36
36
  var _cacheItemToBookingInput = require("../../modules/BookingContext/utils/cacheItemToBookingInput");
37
37
  var _utils = require("../../modules/BookingContext/utils");
38
38
  var _OpenData = require("../../modules/OpenData");
39
+ var _salesSettings = require("./salesSettings");
40
+ Object.keys(_salesSettings).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
43
+ if (key in exports && exports[key] === _salesSettings[key]) return;
44
+ Object.defineProperty(exports, key, {
45
+ enumerable: true,
46
+ get: function () {
47
+ return _salesSettings[key];
48
+ }
49
+ });
50
+ });
39
51
  var _getDateIsInSchedule = require("../../modules/Schedule/getDateIsInSchedule");
40
52
  var _ResourcePlanner = require("../../modules/ResourcePlanner");
41
53
  var _types = require("./types");
@@ -57,7 +69,7 @@ var _localClock = require("../../modules/ResourcePlanner/localClock");
57
69
  var _platform = require("../../utils/platform");
58
70
  var _itemRule = require("../../model/strategy/adapter/itemRule");
59
71
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
60
- const OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow', 'documents', 'basic', 'checkout', 'availability'];
72
+ const OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow', 'documents', 'basic', 'checkout', 'availability', 'interface'];
61
73
  function normalizePositiveInteger(value) {
62
74
  const normalized = Number(value);
63
75
  if (!Number.isInteger(normalized) || normalized <= 0) return undefined;
@@ -1546,7 +1558,6 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1546
1558
  cover = false
1547
1559
  } = {}) {
1548
1560
  const previousScope = this.getAvailabilityScopeDescriptor(this.otherParams || {});
1549
- const previousCatalogScope = this.otherParams?.catalogScopeKey;
1550
1561
  const previousItemRuleConfig = this.otherParams?.itemRule;
1551
1562
  const explicitlySetsOpenData = Object.prototype.hasOwnProperty.call(params, 'openData');
1552
1563
  const nextParams = cover ? params : {
@@ -1559,10 +1570,6 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1559
1570
  await super.setOtherParams(params, {
1560
1571
  cover
1561
1572
  });
1562
- if (previousCatalogScope !== this.otherParams?.catalogScopeKey && (previousCatalogScope || this.otherParams?.catalogScopeKey)) {
1563
- this.unifiedProductCatalog = [];
1564
- await this.core.effects.emit(`${this.name}:onProductsLoaded`, []);
1565
- }
1566
1573
  const nextScope = this.getAvailabilityScopeDescriptor(this.otherParams || {});
1567
1574
  if (explicitlySetsOpenData) {
1568
1575
  this.openDataTarget = this.otherParams?.openData && nextScope.businessCode && nextScope.channel ? `${nextScope.businessCode}+${nextScope.channel}` : null;
@@ -1817,14 +1824,14 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1817
1824
  }
1818
1825
 
1819
1826
  /**
1820
- * PC/H5 及自助终端结账默认直接等待云端 checkout;POS/WebPOS 仍保持本地待同步。
1827
+ * PC/H5/Kiosk 结账默认直接等待云端 checkout;POS/WebPOS 仍保持本地待同步。
1821
1828
  * 显式传 checkoutSyncTaskEnabled: true 时仍可回退到本地同步模式。
1822
1829
  */
1823
1830
  shouldUseCheckoutSyncTask() {
1824
1831
  const configured = this.otherParams?.checkoutSyncTaskEnabled;
1825
1832
  if (configured === true) return true;
1826
1833
  const platform = (0, _platform.normalizeRuntimePlatform)(this.otherParams?.platform);
1827
- return !(0, _platform.isCustomerUserPlatform)(platform) && !(0, _platform.isSelfServicePlatform)(platform);
1834
+ return !(0, _platform.isCustomerUserPlatform)(platform) && platform !== 'kiosk';
1828
1835
  }
1829
1836
 
1830
1837
  /** UnifiedBookingSales 的真实结账默认请求收据数据,供云端确认后再本地打印。 */
@@ -2043,6 +2050,121 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2043
2050
  async getOpenData() {
2044
2051
  return this.loadOpenDataConfig();
2045
2052
  }
2053
+
2054
+ /** One policy snapshot for all Sales 2.0 consumers. Network errors must reach the caller. */
2055
+ async getSalesSettings() {
2056
+ const config = await this.getOpenData();
2057
+ if (!config) throw new Error('Sales settings are unavailable without a business context.');
2058
+ return (0, _OpenData.normalizeSalesSettings)(config, this.otherParams?.platform);
2059
+ }
2060
+ getLoadedSalesSettings() {
2061
+ if (!this.runtimeOpenDataSnapshot) {
2062
+ throw new Error('Sales settings are not loaded. Call getSalesSettings before preparing a booking.');
2063
+ }
2064
+ return (0, _OpenData.normalizeSalesSettings)(this.runtimeOpenDataSnapshot, this.otherParams?.platform);
2065
+ }
2066
+ getProductBookingsForScheduling() {
2067
+ const seen = new Set();
2068
+ return (this.getTempOrder()?.products || []).flatMap(product => {
2069
+ if (product.metadata?.product_add_schedule_time != null || product.deleted_at) return [];
2070
+ const booking = this.findLinkedBooking(product);
2071
+ if (!booking || (0, _pickupTiming.isFulfillmentTimingBooking)(booking) || seen.has(booking)) return [];
2072
+ seen.add(booking);
2073
+ return [booking];
2074
+ });
2075
+ }
2076
+ shouldApplyMultipleBookingScheduling() {
2077
+ const platform = (0, _platform.normalizeRuntimePlatform)(this.otherParams?.platform);
2078
+ return platform === 'pos' || platform === 'webpos';
2079
+ }
2080
+ resolveLoadedDefaultBookingStart(holderIds, fallback) {
2081
+ // Customer channels keep their entry default instead of following cart bookings.
2082
+ // Keep this callback installed so BookingContext cannot fall back to Board.
2083
+ if (!this.shouldApplyMultipleBookingScheduling()) return (0, _salesSettings.normalizeBookingDateTime)(fallback);
2084
+ const settings = this.getLoadedSalesSettings();
2085
+ return (0, _salesSettings.resolveDefaultBookingStart)({
2086
+ bookings: this.getProductBookingsForScheduling(),
2087
+ holderIds,
2088
+ mode: settings.reservation.multipleBookingScheduling,
2089
+ fallback
2090
+ });
2091
+ }
2092
+
2093
+ /** Used by the SKU flow after Holder changes, without changing an explicit user-selected time. */
2094
+ async resolveDefaultBookingStart(params) {
2095
+ if (!this.shouldApplyMultipleBookingScheduling()) return (0, _salesSettings.normalizeBookingDateTime)(params.fallback);
2096
+ await this.getSalesSettings();
2097
+ return this.resolveLoadedDefaultBookingStart(params.holderIds, params.fallback);
2098
+ }
2099
+ buildBookingCalcContext(extra) {
2100
+ return {
2101
+ ...super.buildBookingCalcContext(extra),
2102
+ resolveDefaultBookingStart: (cacheItem, fallback) => this.resolveLoadedDefaultBookingStart(extra?.holderIds ?? (0, _salesSettings.getBookingHolderIds)(cacheItem), fallback)
2103
+ };
2104
+ }
2105
+ buildAddProductCtx(extra) {
2106
+ return {
2107
+ ...super.buildAddProductCtx(extra),
2108
+ resolveDefaultBookingStart: (cacheItem, fallback) => this.resolveLoadedDefaultBookingStart(extra?.holderIds ?? (0, _salesSettings.getBookingHolderIds)(cacheItem), fallback)
2109
+ };
2110
+ }
2111
+
2112
+ /** Re-evaluate an automatic default after Holder enrichment, or restore a known explicit TimeBar start. */
2113
+ async applyDefaultBookingStart(cacheItem, options = {}) {
2114
+ if (!this.shouldApplyMultipleBookingScheduling()) return cacheItem;
2115
+ if (!cacheItem?.new || !(0, _utils.isBookingProduct)(cacheItem) || (0, _utils.isSessionProduct)(cacheItem) || cacheItem?._extend?.other?.session) return cacheItem;
2116
+ const extend = cacheItem._extend || {};
2117
+ const currentStart = (0, _salesSettings.getBookingBoundary)(extend, 'start');
2118
+ const automaticStart = (0, _salesSettings.normalizeBookingDateTime)(cacheItem._data?.salesDefaultBookingStart);
2119
+ if (extend.start_time && (!automaticStart || !currentStart || (0, _dayjs.default)(currentStart).valueOf() !== (0, _dayjs.default)(automaticStart).valueOf())) return cacheItem;
2120
+ const explicitStart = (0, _salesSettings.normalizeBookingDateTime)(options.explicitStart);
2121
+ if (options.explicitStart !== undefined && !explicitStart) {
2122
+ throw new Error('The explicit booking start must be a valid date and time.');
2123
+ }
2124
+ const holderIds = options.holderIds ?? (0, _salesSettings.getBookingHolderIds)(cacheItem);
2125
+ const fallback = (0, _salesSettings.normalizeBookingDateTime)(cacheItem._data?.salesDefaultBookingFallback) ?? currentStart ?? (0, _salesSettings.normalizeBookingDateTime)(String(this.getBookingDate() || ''));
2126
+ const nextStart = explicitStart ?? (await this.resolveDefaultBookingStart({
2127
+ holderIds,
2128
+ fallback
2129
+ }));
2130
+ if (!nextStart) return cacheItem;
2131
+ if (currentStart && (0, _dayjs.default)(nextStart).valueOf() === (0, _dayjs.default)(currentStart).valueOf()) {
2132
+ if (!explicitStart) return cacheItem;
2133
+ const data = {
2134
+ ...cacheItem._data
2135
+ };
2136
+ delete data.salesDefaultBookingStart;
2137
+ delete data.salesDefaultBookingFallback;
2138
+ return {
2139
+ ...cacheItem,
2140
+ _data: data
2141
+ };
2142
+ }
2143
+ const nextExtend = {
2144
+ ...extend,
2145
+ start_date: nextStart.slice(0, 10),
2146
+ start_time: nextStart.slice(11)
2147
+ };
2148
+ for (const key of ['startDate', 'endDate', 'end_time', 'resource', 'resources', 'availabilitySelection']) {
2149
+ delete nextExtend[key];
2150
+ }
2151
+ if ((0, _utils.isMultiDayProduct)(cacheItem) && currentStart && extend.end_date) {
2152
+ const shiftDays = (0, _dayjs.default)(nextStart.slice(0, 10)).diff((0, _dayjs.default)(currentStart.slice(0, 10)), 'day');
2153
+ nextExtend.end_date = (0, _dayjs.default)(extend.end_date).add(shiftDays, 'day').format('YYYY-MM-DD');
2154
+ } else {
2155
+ delete nextExtend.end_date;
2156
+ }
2157
+ return this.getProductExtend({
2158
+ ...cacheItem,
2159
+ _extend: nextExtend,
2160
+ _data: explicitStart ? {} : {
2161
+ salesDefaultBookingStart: nextStart,
2162
+ salesDefaultBookingFallback: fallback
2163
+ }
2164
+ }, {
2165
+ holderIds
2166
+ });
2167
+ }
2046
2168
  async loadPickupTimingOpenData(_force) {
2047
2169
  const scope = this.getPickupTimingScope();
2048
2170
  const businessCode = String(this.otherParams?.businessCode ?? this.otherParams?.business_code ?? '').trim();
@@ -2181,7 +2303,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2181
2303
  throw new Error('[UnifiedBookingSales] getProtocol 需要 policyId');
2182
2304
  }
2183
2305
  let policyUrl = 'shop-policy';
2184
- if ((0, _platform.isSelfServicePlatform)(this.otherParams.platform) || this.otherParams.platform === 'pos' || this.otherParams.platform === 'shop') {
2306
+ if (this.otherParams.platform === 'kiosk' || this.otherParams.platform === 'pos' || this.otherParams.platform === 'shop') {
2185
2307
  policyUrl = 'policy';
2186
2308
  }
2187
2309
  return this.request.get(`/${policyUrl}/${encodeURIComponent(normalizedPolicyId)}`);
@@ -2193,7 +2315,6 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2193
2315
  */
2194
2316
  async loadProducts(params = {}, options) {
2195
2317
  if (!this.store.products) throw new Error('[UnifiedBookingSales] products 模块未初始化');
2196
- const catalogScope = this.otherParams.catalogScopeKey;
2197
2318
  const schedule_date = params.schedule_date || (0, _dayjs.default)().format('YYYY-MM-DD');
2198
2319
  const schedule_datetime = params.schedule_datetime || `${schedule_date} ${(0, _dayjs.default)().format('HH:mm:ss')}`;
2199
2320
  const result = await this.store.products.loadProducts({
@@ -2204,11 +2325,6 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2204
2325
  schedule_datetime,
2205
2326
  cacheId: this.cacheId
2206
2327
  }, options);
2207
- if (catalogScope !== this.otherParams.catalogScopeKey) {
2208
- throw Object.assign(new Error('Product scope changed'), {
2209
- name: 'AbortError'
2210
- });
2211
- }
2212
2328
  this.unifiedProductCatalog = Array.isArray(result) ? [...result] : [];
2213
2329
  await this.core.effects.emit(`${this.name}:onProductsLoaded`, result);
2214
2330
  return result;
@@ -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,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getBookingBoundary = getBookingBoundary;
7
+ exports.getBookingHolderIds = getBookingHolderIds;
8
+ exports.normalizeBookingDateTime = normalizeBookingDateTime;
9
+ exports.normalizeBookingHolderIds = normalizeBookingHolderIds;
10
+ exports.resolveDefaultBookingStart = resolveDefaultBookingStart;
11
+ var _dayjs = _interopRequireDefault(require("dayjs"));
12
+ var _pickupTiming = require("../../modules/Order/pickupTiming");
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ /** Normalize scalar/array holder identities without merging the no-holder group with real holders. */
15
+ function normalizeBookingHolderIds(value) {
16
+ const values = Array.isArray(value) ? value : value == null ? [] : [value];
17
+ return Array.from(new Set(values.flatMap(id => {
18
+ if (typeof id !== 'string' && typeof id !== 'number') return [];
19
+ const text = String(id).trim();
20
+ return text && text !== '0' ? [text] : [];
21
+ })));
22
+ }
23
+ function getBookingHolderIds(booking) {
24
+ return normalizeBookingHolderIds(booking.holder_id ?? booking.metadata?.holder_id ?? booking.holder?.form_record ?? booking.metadata?.holder?.form_record ?? booking._extend?.holder_id ?? booking._extend?.holder?.form_record);
25
+ }
26
+
27
+ /** Validate input and convert absolute ISO values to the runtime-local date/time used by booking fields. */
28
+ function normalizeBookingDateTime(value) {
29
+ if (typeof value !== 'string') return undefined;
30
+ const text = value.trim().replace(' ', 'T');
31
+ const match = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,3})?)?(Z|[+-]\d{2}:\d{2})?$/.exec(text);
32
+ if (!match) return undefined;
33
+ const [, y, m, d, h, minute, second = '0', zone] = match;
34
+ const calendar = new Date(`${y}-${m}-${d}T00:00:00.000Z`);
35
+ if (!Number.isFinite(calendar.getTime()) || calendar.toISOString().slice(0, 10) !== `${y}-${m}-${d}` || Number(h) > 23 || Number(minute) > 59 || Number(second) > 59 || !(0, _dayjs.default)(text).isValid()) return undefined;
36
+ return zone ? (0, _dayjs.default)(text).format('YYYY-MM-DDTHH:mm:ss') : text;
37
+ }
38
+ function getBookingBoundary(booking, edge) {
39
+ const direct = booking[`${edge}At`] ?? booking[`${edge}_at`];
40
+ const directTime = normalizeBookingDateTime(direct);
41
+ if (directTime) return directTime;
42
+ const date = booking[`${edge}_date`];
43
+ const time = booking[`${edge}_time`];
44
+ if (typeof date !== 'string') return undefined;
45
+ return typeof time === 'string' ? normalizeBookingDateTime(`${date.slice(0, 10)}T${time}`) : normalizeBookingDateTime(date);
46
+ }
47
+
48
+ /** Select a default only; availability and resource occupancy remain the commit path's authority. */
49
+ function resolveDefaultBookingStart({
50
+ bookings,
51
+ holderIds,
52
+ mode = 'one_after_another',
53
+ fallback
54
+ }) {
55
+ const holders = new Set(normalizeBookingHolderIds(holderIds));
56
+ const related = bookings.flatMap(booking => {
57
+ if (!booking || (0, _pickupTiming.isFulfillmentTimingBooking)(booking) || booking.deleted_at) return [];
58
+ const previousHolders = getBookingHolderIds(booking);
59
+ const matches = holders.size === 0 ? previousHolders.length === 0 : previousHolders.some(holder => holders.has(holder));
60
+ if (!matches) return [];
61
+ const start = getBookingBoundary(booking, 'start');
62
+ const end = getBookingBoundary(booking, 'end');
63
+ if (!start || !end || !(0, _dayjs.default)(end).isAfter((0, _dayjs.default)(start))) return [];
64
+ return [{
65
+ start,
66
+ end
67
+ }];
68
+ });
69
+ if (!related.length) return normalizeBookingDateTime(fallback);
70
+ if (mode === 'same_start_time') return related[related.length - 1].start;
71
+ return related.reduce((latest, booking) => (0, _dayjs.default)(booking.end).isAfter((0, _dayjs.default)(latest)) ? booking.end : latest, related[0].end);
72
+ }
@@ -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;
@@ -4,10 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.isCustomerUserPlatform = isCustomerUserPlatform;
7
- exports.isSelfServicePlatform = isSelfServicePlatform;
8
7
  exports.normalizeRuntimePlatform = normalizeRuntimePlatform;
9
8
  const CUSTOMER_USER_PLATFORMS = new Set(['pc', 'h5']);
10
- const SELF_SERVICE_PLATFORMS = new Set(['kiosk', 'vending']);
11
9
 
12
10
  /**
13
11
  * Normalize the runtime platform passed through solution/module otherParams.
@@ -21,9 +19,4 @@ function normalizeRuntimePlatform(platform) {
21
19
  */
22
20
  function isCustomerUserPlatform(platform) {
23
21
  return CUSTOMER_USER_PLATFORMS.has(normalizeRuntimePlatform(platform));
24
- }
25
-
26
- /** Kiosk and vending retain distinct channels but share self-service checkout behavior. */
27
- function isSelfServicePlatform(platform) {
28
- return SELF_SERVICE_PLATFORMS.has(normalizeRuntimePlatform(platform));
29
22
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.172",
4
+ "version": "2.3.174",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -1,92 +0,0 @@
1
- /** Optional, instance-scoped sales inventory. Never stored in ProductData or order payloads. */
2
- export type InventoryRecord = Record<string, any>;
3
- export type InventoryRefreshReason = 'catalog-entry' | 'detail-open' | 'checkout' | 'manual';
4
- export interface InventoryAvailability {
5
- status: 'ready' | 'loading' | 'stale' | 'error' | 'unmapped';
6
- quantity?: number;
7
- message?: string;
8
- }
9
- export interface InventorySelectionAvailability {
10
- availability: InventoryAvailability;
11
- /** Stock remaining after other cart lines using the same inventory key. */
12
- availableQuantity: number;
13
- /** The existing line can still be reduced when stock is unavailable. */
14
- retainedQuantity: number;
15
- maxQuantity: number;
16
- }
17
- export interface InventorySource {
18
- readonly scopeKey: string;
19
- assertCurrent(): void;
20
- keyOf(product: InventoryRecord, variant?: InventoryRecord): string | undefined;
21
- read(context: {
22
- reason: InventoryRefreshReason;
23
- signal: AbortSignal;
24
- }): Promise<ReadonlyMap<string, {
25
- quantity: number | null;
26
- message?: string;
27
- }>>;
28
- message(reason: 'unavailable' | 'unmapped' | 'insufficient', values?: {
29
- key: string;
30
- quantity: number;
31
- }): string;
32
- }
33
- export interface CheckoutInventoryLine {
34
- readonly lineId: string;
35
- readonly productId: string | number;
36
- readonly variantId: string | number;
37
- readonly quantity: number;
38
- readonly inventoryKey: string;
39
- }
40
- export interface CheckoutRuntimeSnapshot {
41
- readonly scopeKey: string;
42
- readonly revision: number;
43
- readonly lines: readonly CheckoutInventoryLine[];
44
- }
45
- export interface SalesCheckoutHooks {
46
- beforeCheckout?(context: {
47
- items: readonly InventoryRecord[];
48
- signal?: AbortSignal;
49
- }): Promise<void>;
50
- }
51
- export declare const salesGuardError: (message: string) => Error & {
52
- code: string;
53
- };
54
- export declare class InventoryController {
55
- private readonly source;
56
- readonly identity: symbol;
57
- readonly scopeKey: string;
58
- private entries;
59
- private lastQuantities;
60
- private products;
61
- private keys;
62
- private catalogProducts;
63
- private listeners;
64
- private revision;
65
- private state;
66
- private pending?;
67
- private disposed;
68
- constructor(source: InventorySource);
69
- getRevision: () => number;
70
- subscribe: (listener: () => void) => () => void;
71
- private publish;
72
- private assertCurrent;
73
- activate(): void;
74
- dispose(): void;
75
- invalidate(): void;
76
- /** Catalog replaces identities; partial detail only merges its variants, never its prices. */
77
- registerProducts(products: readonly InventoryRecord[], complete?: boolean): void;
78
- /** Consumers share I/O; cancelling one detail does not cancel another consumer. */
79
- refresh(context: {
80
- reason: InventoryRefreshReason;
81
- signal?: AbortSignal;
82
- force?: boolean;
83
- }): Promise<void>;
84
- availabilityForKey(key?: string): InventoryAvailability;
85
- availability(product: InventoryRecord, variantId?: string | number): InventoryAvailability;
86
- private keyForLine;
87
- /** Advisory UI limit only. The serialized cart guard remains authoritative. */
88
- selectionAvailability(product: InventoryRecord, variantId: string | number, items: readonly InventoryRecord[], editingItem?: InventoryRecord): InventorySelectionAvailability;
89
- private totals;
90
- validate(proposed: readonly InventoryRecord[], current?: readonly InventoryRecord[], allowReductions?: boolean): void;
91
- freezeCheckout(items: readonly InventoryRecord[]): CheckoutRuntimeSnapshot;
92
- }