@pisell/pisellos 2.3.195 → 2.3.197

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 (59) hide show
  1. package/dist/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
  2. package/dist/modules/BookingContext/utils/calendarBooking.js +207 -0
  3. package/dist/modules/BookingContext/utils/index.d.ts +1 -0
  4. package/dist/modules/BookingContext/utils/index.js +1 -0
  5. package/dist/modules/BookingContext/utils/productExtend.d.ts +6 -0
  6. package/dist/modules/BookingContext/utils/productExtend.js +21 -0
  7. package/dist/modules/Order/index.d.ts +3 -0
  8. package/dist/modules/Order/index.js +127 -46
  9. package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
  10. package/dist/modules/Order/unpaidAmountGap.js +72 -0
  11. package/dist/modules/Product/index.d.ts +1 -1
  12. package/dist/modules/ResourcePlanner/planner.js +24 -0
  13. package/dist/modules/ResourcePlanner/types.d.ts +7 -0
  14. package/dist/server/index.js +207 -193
  15. package/dist/server/modules/order/index.js +2 -1
  16. package/dist/shared/receipt/small-ticket.d.ts +3 -0
  17. package/dist/shared/receipt/small-ticket.js +26 -3
  18. package/dist/solution/BookingByStep/index.d.ts +2 -2
  19. package/dist/solution/BookingTicket/index.d.ts +2 -14
  20. package/dist/solution/BookingTicket/index.js +8 -4
  21. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -0
  22. package/dist/solution/BookingTicket/utils/addProductDecision.js +35 -8
  23. package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
  24. package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
  25. package/dist/solution/OrderInvoicePreview/index.js +13 -8
  26. package/dist/solution/UnifiedBookingSales/index.d.ts +16 -2
  27. package/dist/solution/UnifiedBookingSales/index.js +1670 -1377
  28. package/dist/solution/UnifiedBookingSales/types.d.ts +1 -0
  29. package/dist/solution/UnifiedBookingSales/venueCatalogSession.js +11 -5
  30. package/lib/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
  31. package/lib/modules/BookingContext/utils/calendarBooking.js +156 -0
  32. package/lib/modules/BookingContext/utils/index.d.ts +1 -0
  33. package/lib/modules/BookingContext/utils/index.js +11 -0
  34. package/lib/modules/BookingContext/utils/productExtend.d.ts +6 -0
  35. package/lib/modules/BookingContext/utils/productExtend.js +23 -0
  36. package/lib/modules/Order/index.d.ts +3 -0
  37. package/lib/modules/Order/index.js +85 -16
  38. package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
  39. package/lib/modules/Order/unpaidAmountGap.js +60 -0
  40. package/lib/modules/Product/index.d.ts +1 -1
  41. package/lib/modules/ResourcePlanner/planner.js +23 -0
  42. package/lib/modules/ResourcePlanner/types.d.ts +7 -0
  43. package/lib/server/index.js +21 -5
  44. package/lib/server/modules/order/index.js +2 -1
  45. package/lib/shared/receipt/small-ticket.d.ts +3 -0
  46. package/lib/shared/receipt/small-ticket.js +24 -1
  47. package/lib/solution/BookingByStep/index.d.ts +2 -2
  48. package/lib/solution/BookingTicket/index.d.ts +2 -14
  49. package/lib/solution/BookingTicket/index.js +4 -2
  50. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -0
  51. package/lib/solution/BookingTicket/utils/addProductDecision.js +33 -3
  52. package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
  53. package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
  54. package/lib/solution/OrderInvoicePreview/index.js +6 -1
  55. package/lib/solution/UnifiedBookingSales/index.d.ts +16 -2
  56. package/lib/solution/UnifiedBookingSales/index.js +176 -36
  57. package/lib/solution/UnifiedBookingSales/types.d.ts +1 -0
  58. package/lib/solution/UnifiedBookingSales/venueCatalogSession.js +9 -5
  59. package/package.json +1 -1
@@ -0,0 +1,15 @@
1
+ import dayjs from 'dayjs';
2
+ import type { BookingCalcContext } from './productExtend';
3
+ export declare function isManualBookingProduct(product: any): boolean;
4
+ export declare function getCalendarBookingRange(product: any, ctx?: BookingCalcContext): {
5
+ startAt: string;
6
+ endAt: string;
7
+ duration: number;
8
+ startDate: dayjs.Dayjs;
9
+ endDate: dayjs.Dayjs;
10
+ } | undefined;
11
+ /** A prepared calendar cache is reused after SKU input; no availability-driven replacement is allowed. */
12
+ export declare function prepareCalendarBookingCacheItem(cacheItem: any, ctx: BookingCalcContext): any;
13
+ export declare function calendarBookingEntryKey(ctx: BookingCalcContext): string;
14
+ export declare function calendarBookingNeedsInput(cacheItem: any): boolean;
15
+ export declare function calendarBookingPreparationKey(cacheItem: any, ctx: BookingCalcContext): string;
@@ -0,0 +1,207 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ 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."); }
4
+ 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; } }
5
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
6
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
7
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
9
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
11
+ 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); }
12
+ 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; }
13
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
17
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
+ import dayjs from 'dayjs';
19
+ import { captureRuntimeOffsetMinutes, extractFixedOffsetMinutes, formatLocalDateTime, localDateTimeToScalar, parseLocalDateTime } from "../../ResourcePlanner/localClock";
20
+ import { isBookingProduct, isMultiDayProduct } from "./serviceTimes";
21
+ export function isManualBookingProduct(product) {
22
+ var _product$product_reso, _product$capacity;
23
+ return !isBookingProduct(product) && Boolean((product === null || product === void 0 ? void 0 : product.extension_type) === 'product_appointment' || (product === null || product === void 0 || (_product$product_reso = product.product_resource) === null || _product$product_reso === void 0 || (_product$product_reso = _product$product_reso.resources) === null || _product$product_reso === void 0 ? void 0 : _product$product_reso.some(function (group) {
24
+ return Number(group.status) === 1;
25
+ })) || ['custom', 'package'].includes(product === null || product === void 0 || (_product$capacity = product.capacity) === null || _product$capacity === void 0 ? void 0 : _product$capacity.type));
26
+ }
27
+ export function getCalendarBookingRange(product, ctx) {
28
+ var _product$flexible, _product$_extend;
29
+ var range = ctx === null || ctx === void 0 ? void 0 : ctx.bookingTimeRangeFromCalendar;
30
+ if (!range || (ctx === null || ctx === void 0 ? void 0 : ctx.platform) !== 'pos' || isMultiDayProduct(product) || (product === null || product === void 0 ? void 0 : product.duration_type) === 'days' || (product === null || product === void 0 || (_product$flexible = product.flexible) === null || _product$flexible === void 0 || (_product$flexible = _product$flexible.duration) === null || _product$flexible === void 0 ? void 0 : _product$flexible.type) === 'days' || (product === null || product === void 0 || (_product$_extend = product._extend) === null || _product$_extend === void 0 ? void 0 : _product$_extend.sub_type) === 'days' || !isBookingProduct(product) && !isManualBookingProduct(product)) return undefined;
31
+ try {
32
+ var offset = captureRuntimeOffsetMinutes();
33
+ var normalize = function normalize(text) {
34
+ var _extractFixedOffsetMi;
35
+ var scalar = localDateTimeToScalar(parseLocalDateTime(text));
36
+ var inputOffset = (_extractFixedOffsetMi = extractFixedOffsetMinutes(text)) !== null && _extractFixedOffsetMi !== void 0 ? _extractFixedOffsetMi : offset;
37
+ return formatLocalDateTime(scalar + (offset - inputOffset) * 60000, offset);
38
+ };
39
+ var startAt = normalize(range.startAt);
40
+ var endAt = normalize(range.endAt);
41
+ var start = localDateTimeToScalar(parseLocalDateTime(startAt));
42
+ var end = localDateTimeToScalar(parseLocalDateTime(endAt));
43
+ var duration = (end - start) / 60000;
44
+ if (!Number.isInteger(duration) || duration <= 0 || start % 60000 || end % 60000) throw new Error();
45
+ return {
46
+ startAt: startAt,
47
+ endAt: endAt,
48
+ duration: duration,
49
+ startDate: dayjs(startAt.slice(0, 19)),
50
+ endDate: dayjs(endAt.slice(0, 19))
51
+ };
52
+ } catch (_unused) {
53
+ throw Object.assign(new Error('Calendar booking requires valid complete start/end times.'), {
54
+ code: 'INVALID_TARGET_FILTER'
55
+ });
56
+ }
57
+ }
58
+
59
+ /** A prepared calendar cache is reused after SKU input; no availability-driven replacement is allowed. */
60
+ export function prepareCalendarBookingCacheItem(cacheItem, ctx) {
61
+ var _cacheItem$product_re, _cacheItem$_data;
62
+ var range = getCalendarBookingRange(cacheItem, ctx);
63
+ if (!range) return cacheItem;
64
+ var resource = {};
65
+ var forms = (((_cacheItem$product_re = cacheItem.product_resource) === null || _cacheItem$product_re === void 0 ? void 0 : _cacheItem$product_re.resources) || []).filter(function (group) {
66
+ return Number(group.status) === 1;
67
+ });
68
+ var entry = Number(ctx.resourceIdFromCalendar);
69
+ var preserveInput = ((_cacheItem$_data = cacheItem._data) === null || _cacheItem$_data === void 0 ? void 0 : _cacheItem$_data.calendarBookingEntryKey) === calendarBookingEntryKey(ctx);
70
+ var inputInvalid = false;
71
+ if (preserveInput) {
72
+ var ext = cacheItem._extend || {};
73
+ try {
74
+ var _ext$start_date, _ext$end_date, _ext$start_date2, _ext$end_date2;
75
+ if (!((_ext$start_date = ext.start_date) !== null && _ext$start_date !== void 0 ? _ext$start_date : ext.startDate) || !((_ext$end_date = ext.end_date) !== null && _ext$end_date !== void 0 ? _ext$end_date : ext.endDate) || !ext.start_time || !ext.end_time) throw new Error('Incomplete calendar input.');
76
+ range = getCalendarBookingRange(cacheItem, _objectSpread(_objectSpread({}, ctx), {}, {
77
+ bookingTimeRangeFromCalendar: {
78
+ startAt: "".concat(dayjs((_ext$start_date2 = ext.start_date) !== null && _ext$start_date2 !== void 0 ? _ext$start_date2 : ext.startDate).format('YYYY-MM-DD'), "T").concat(ext.start_time, ":00"),
79
+ endAt: "".concat(dayjs((_ext$end_date2 = ext.end_date) !== null && _ext$end_date2 !== void 0 ? _ext$end_date2 : ext.endDate).format('YYYY-MM-DD'), "T").concat(ext.end_time, ":00")
80
+ }
81
+ }));
82
+ } catch (_unused2) {
83
+ range = undefined;
84
+ inputInvalid = true;
85
+ }
86
+ }
87
+ var _iterator = _createForOfIteratorHelper(forms),
88
+ _step;
89
+ try {
90
+ var _loop = function _loop() {
91
+ var _ctx$resourcesOriginM, _cacheItem$_extend;
92
+ var form = _step.value;
93
+ var ids = [].concat(_toConsumableArray(form.optional_resource || []), _toConsumableArray(form.default_resource || []));
94
+ var linked = ids.some(function (id) {
95
+ return String(id) === String(entry);
96
+ });
97
+ var origin = (_ctx$resourcesOriginM = ctx.resourcesOriginMap) === null || _ctx$resourcesOriginM === void 0 ? void 0 : _ctx$resourcesOriginM[entry];
98
+ var chosen = (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 || (_cacheItem$_extend = _cacheItem$_extend.resource) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend[String(form.id)];
99
+ var hasChosen = preserveInput && chosen !== undefined;
100
+ var validChosen = hasChosen && Array.isArray(chosen) && new Set(chosen.map(function (row) {
101
+ return String(row.relation_id);
102
+ })).size === chosen.length && chosen.every(function (row) {
103
+ var _ctx$resourcesOriginM2;
104
+ return (row.form_id == null || String(row.form_id) === String(form.id)) && (Number(row.relation_id) === 0 || ids.some(function (id) {
105
+ return String(id) === String(row.relation_id);
106
+ }) && ((_ctx$resourcesOriginM2 = ctx.resourcesOriginMap) === null || _ctx$resourcesOriginM2 === void 0 ? void 0 : _ctx$resourcesOriginM2[row.relation_id]) && (ctx.resourcesOriginMap[row.relation_id].form_id == null || String(ctx.resourcesOriginMap[row.relation_id].form_id) === String(form.id)));
107
+ });
108
+ if (hasChosen && !validChosen) inputInvalid = true;
109
+ if (hasChosen) {
110
+ resource[String(form.id)] = validChosen ? chosen : [];
111
+ } else if (linked && origin && (origin.form_id == null || String(origin.form_id) === String(form.id))) {
112
+ resource[String(form.id)] = [{
113
+ relation_type: origin.relation_type || 'form',
114
+ form_id: form.id,
115
+ relation_id: entry,
116
+ like_status: 'common',
117
+ metadata: {
118
+ form_name: form.title,
119
+ resource_name: origin.main_field
120
+ }
121
+ }];
122
+ } else {
123
+ resource[String(form.id)] = [];
124
+ }
125
+ };
126
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
127
+ _loop();
128
+ }
129
+ } catch (err) {
130
+ _iterator.e(err);
131
+ } finally {
132
+ _iterator.f();
133
+ }
134
+ return _objectSpread(_objectSpread(_objectSpread({}, cacheItem), isManualBookingProduct(cacheItem) && range ? {
135
+ duration: {
136
+ type: 'minutes',
137
+ value: range.duration
138
+ }
139
+ } : {}), {}, {
140
+ _data: _objectSpread(_objectSpread({}, cacheItem._data), {}, {
141
+ calendarBookingInputInvalid: inputInvalid
142
+ }),
143
+ _extend: _objectSpread(_objectSpread(_objectSpread({}, cacheItem._extend), range ? {
144
+ startDate: range.startDate,
145
+ start_date: range.startDate,
146
+ start_time: range.startAt.slice(11, 16),
147
+ endDate: range.endDate,
148
+ end_date: range.endDate,
149
+ end_time: range.endAt.slice(11, 16),
150
+ duration: range.duration
151
+ } : {}), {}, {
152
+ resource: resource
153
+ })
154
+ });
155
+ }
156
+ export function calendarBookingEntryKey(ctx) {
157
+ return JSON.stringify([ctx.bookingTimeRangeFromCalendar, ctx.resourceIdFromCalendar]);
158
+ }
159
+ export function calendarBookingNeedsInput(cacheItem) {
160
+ var _cacheItem$_data2, _cacheItem$product_re2;
161
+ if ((_cacheItem$_data2 = cacheItem._data) !== null && _cacheItem$_data2 !== void 0 && _cacheItem$_data2.calendarBookingInputInvalid) return true;
162
+ var capacity = cacheItem.capacity;
163
+ if ((capacity === null || capacity === void 0 ? void 0 : capacity.type) === 'custom' && (!Array.isArray(capacity.custom) || !capacity.custom.length || capacity.custom.some(function (item) {
164
+ return !Number.isFinite(Number(item.min)) || item.max == null || Number(item.min) !== Number(item.max);
165
+ }))) return true;
166
+ var groups = (_cacheItem$product_re2 = cacheItem.product_resource) === null || _cacheItem$product_re2 === void 0 ? void 0 : _cacheItem$product_re2.resources;
167
+ if (groups != null && !Array.isArray(groups)) return true;
168
+ var seen = new Set();
169
+ return (groups || []).some(function (group) {
170
+ var _rule$min, _rule$max, _cacheItem$_extend2, _group$required;
171
+ if (Number(group.status) === 0) return false;
172
+ if (group.id == null || seen.has(String(group.id))) return true;
173
+ seen.add(String(group.id));
174
+ var rule = group.select_type;
175
+ if (Number(group.status) !== 1 || !rule || !['single', 'multiple'].includes(rule.type)) return true;
176
+ var min = Number((_rule$min = rule.min) !== null && _rule$min !== void 0 ? _rule$min : rule.type === 'single' ? 1 : NaN);
177
+ var max = Number((_rule$max = rule.max) !== null && _rule$max !== void 0 ? _rule$max : rule.type === 'single' ? 1 : NaN);
178
+ var rows = (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 || (_cacheItem$_extend2 = _cacheItem$_extend2.resource) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2[String(group.id)];
179
+ var required = (_group$required = group.required) !== null && _group$required !== void 0 ? _group$required : true;
180
+ var minimum = Math.max(required ? 1 : 0, min);
181
+ return !Number.isInteger(min) || !Number.isInteger(max) || min < 0 || max < minimum || !Array.isArray(rows) || rows.length < minimum || rows.length > max;
182
+ });
183
+ }
184
+ export function calendarBookingPreparationKey(cacheItem, ctx) {
185
+ var _cacheItem$_extend3, _sku$product_variant_, _ext$start_date3, _ext$end_date3;
186
+ var identities = function identities(rows) {
187
+ return (rows || []).map(function (row) {
188
+ var _ref, _row$group_id, _ref2, _row$product_option_i, _row$_bundle_product_, _row$product_variant_, _ref3, _row$quantity;
189
+ return [(_ref = (_row$group_id = row.group_id) !== null && _row$group_id !== void 0 ? _row$group_id : row.option_group_id) !== null && _ref !== void 0 ? _ref : row.bundle_group_id, (_ref2 = (_row$product_option_i = row.product_option_item_id) !== null && _row$product_option_i !== void 0 ? _row$product_option_i : row.option_group_item_id) !== null && _ref2 !== void 0 ? _ref2 : row.id, (_row$_bundle_product_ = row._bundle_product_id) !== null && _row$_bundle_product_ !== void 0 ? _row$_bundle_product_ : row.bundle_product_id, (_row$product_variant_ = row.product_variant_id) !== null && _row$product_variant_ !== void 0 ? _row$product_variant_ : row.bundle_variant_id, (_ref3 = (_row$quantity = row.quantity) !== null && _row$quantity !== void 0 ? _row$quantity : row.num) !== null && _ref3 !== void 0 ? _ref3 : 1, identities(row.option)];
190
+ }).sort(function (left, right) {
191
+ return JSON.stringify(left).localeCompare(JSON.stringify(right));
192
+ });
193
+ };
194
+ var sku = ((_cacheItem$_extend3 = cacheItem._extend) === null || _cacheItem$_extend3 === void 0 ? void 0 : _cacheItem$_extend3.other) || {};
195
+ var ext = cacheItem._extend || {};
196
+ var dateKey = function dateKey(value) {
197
+ return value == null || value === '' ? null : dayjs(value).format('YYYY-MM-DD');
198
+ };
199
+ return JSON.stringify([ctx.bookingTimeRangeFromCalendar, ctx.resourceIdFromCalendar, cacheItem.capacity, cacheItem.product_resource, (_sku$product_variant_ = sku.product_variant_id) !== null && _sku$product_variant_ !== void 0 ? _sku$product_variant_ : sku.variant_id, identities(sku.option), identities(sku.bundle), dateKey((_ext$start_date3 = ext.start_date) !== null && _ext$start_date3 !== void 0 ? _ext$start_date3 : ext.startDate), ext.start_time, dateKey((_ext$end_date3 = ext.end_date) !== null && _ext$end_date3 !== void 0 ? _ext$end_date3 : ext.endDate), ext.end_time, Object.entries(ext.resource || {}).map(function (_ref4) {
200
+ var _ref5 = _slicedToArray(_ref4, 2),
201
+ formId = _ref5[0],
202
+ rows = _ref5[1];
203
+ return [formId, Array.isArray(rows) ? rows.map(function (row) {
204
+ return [row.form_id, row.relation_id];
205
+ }) : null];
206
+ })]);
207
+ }
@@ -6,6 +6,7 @@ export * from './resources';
6
6
  export * from './resourceSelection';
7
7
  export * from './resourceErrors';
8
8
  export * from './productExtend';
9
+ export * from './calendarBooking';
9
10
  export * from './cacheItemToBookingInput';
10
11
  export * from './buildCacheItemFromOrderLine';
11
12
  export * from './buildNormalProductCacheItemFromOrderLine';
@@ -6,6 +6,7 @@ export * from "./resources";
6
6
  export * from "./resourceSelection";
7
7
  export * from "./resourceErrors";
8
8
  export * from "./productExtend";
9
+ export * from "./calendarBooking";
9
10
  export * from "./cacheItemToBookingInput";
10
11
  export * from "./buildCacheItemFromOrderLine";
11
12
  export * from "./buildNormalProductCacheItemFromOrderLine";
@@ -7,6 +7,12 @@ import { TimeSlicesResult, TimeSlice, DurationSlice } from './timeSlices';
7
7
  * 让 OS 这层完全可在 Node 单测下运行(dayjs 在 Node 也是纯函数)。
8
8
  */
9
9
  export interface BookingCalcContext {
10
+ /** Real runtime platform, injected by BookingTicket rather than inferred from sales channel. */
11
+ platform?: string;
12
+ bookingTimeRangeFromCalendar?: {
13
+ startAt: string;
14
+ endAt: string;
15
+ };
10
16
  /** Sales channel; remembered duration starts are accepted only by POS. */
11
17
  channel?: string;
12
18
  /** Current in-memory order session, supplied by the owning Order module. */
@@ -16,6 +16,7 @@ import { hasActualResourceSelection, productNeedsResourceExtend } from "./resour
16
16
  import { isMultiDayProduct, isSessionProduct, getDays, getServiceTimes } from "./serviceTimes";
17
17
  import { sliceDayIntoFiveMinutes, findNextDuration, getEndDate } from "./timeSlices";
18
18
  import { flexibleObj, getDurationValue, isProductFlexibleDuration } from "./flexible";
19
+ import { getCalendarBookingRange, prepareCalendarBookingCacheItem, calendarBookingNeedsInput, calendarBookingPreparationKey, calendarBookingEntryKey, isManualBookingProduct } from "./calendarBooking";
19
20
 
20
21
  /**
21
22
  * 上下文(与 info2 state.bookingConfig / state.service / state.date 一一对应)。
@@ -291,6 +292,26 @@ export function getServiceStartTimeAndEndTime(params) {
291
292
  export function getProductExtend(params) {
292
293
  var _cacheItem$_extend9;
293
294
  var isDisabledTime = params.isDisabledTime;
295
+ if (getCalendarBookingRange(params.cacheItem, params.ctx)) {
296
+ var _params$cacheItem$_da;
297
+ var prepared = prepareCalendarBookingCacheItem(params.cacheItem, params.ctx);
298
+ var capacity = setDefaultCapacitys({
299
+ capacitys: prepared.capacity,
300
+ cacheItem: prepared
301
+ });
302
+ return _objectSpread(_objectSpread({}, prepared), {}, {
303
+ _extend: _objectSpread(_objectSpread({}, prepared._extend), {}, {
304
+ capacity: capacity
305
+ }),
306
+ _data: _objectSpread(_objectSpread({}, prepared._data), {}, {
307
+ capacitys: prepared.capacity,
308
+ calendarManualBooking: ((_params$cacheItem$_da = params.cacheItem._data) === null || _params$cacheItem$_da === void 0 ? void 0 : _params$cacheItem$_da.calendarManualBooking) === true || isManualBookingProduct(params.cacheItem),
309
+ calendarBookingEntryKey: calendarBookingEntryKey(params.ctx),
310
+ calendarBookingPreparationKey: calendarBookingPreparationKey(prepared, params.ctx)
311
+ }),
312
+ autoClose: !calendarBookingNeedsInput(prepared)
313
+ });
314
+ }
294
315
  var hasRememberedTime = params.ctx.rememberedTime !== undefined;
295
316
  var cacheItem = hasRememberedTime ? seedRememberedBookingStart(params.cacheItem, params.ctx) : params.cacheItem;
296
317
  var ctx = hasRememberedTime ? _objectSpread(_objectSpread({}, params.ctx), {}, {
@@ -243,6 +243,9 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
243
243
  private calculatePaymentTotal;
244
244
  private calculateOrderPaidPaymentTotal;
245
245
  private getDepositAmount;
246
+ private isDepositSelectionDisabled;
247
+ /** Cap only the active target; product rules, manual intent and saved snapshots stay raw. */
248
+ private applyEffectiveDepositSummary;
246
249
  private normalizeDepositAmount;
247
250
  private normalizeDepositFlag;
248
251
  private getHistoricalDepositSnapshot;