@pisell/pisellos 2.3.194 → 2.3.196

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 (38) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
  3. package/dist/modules/BookingContext/utils/calendarBooking.js +207 -0
  4. package/dist/modules/BookingContext/utils/index.d.ts +1 -0
  5. package/dist/modules/BookingContext/utils/index.js +1 -0
  6. package/dist/modules/BookingContext/utils/productExtend.d.ts +6 -0
  7. package/dist/modules/BookingContext/utils/productExtend.js +21 -0
  8. package/dist/modules/Product/index.d.ts +1 -1
  9. package/dist/modules/ResourcePlanner/planner.js +24 -0
  10. package/dist/modules/ResourcePlanner/types.d.ts +7 -0
  11. package/dist/server/index.js +27 -17
  12. package/dist/solution/BookingByStep/index.d.ts +2 -2
  13. package/dist/solution/BookingTicket/index.js +8 -4
  14. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -0
  15. package/dist/solution/BookingTicket/utils/addProductDecision.js +35 -8
  16. package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
  17. package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
  18. package/dist/solution/UnifiedBookingSales/index.d.ts +14 -2
  19. package/dist/solution/UnifiedBookingSales/index.js +1619 -1335
  20. package/lib/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
  21. package/lib/modules/BookingContext/utils/calendarBooking.js +156 -0
  22. package/lib/modules/BookingContext/utils/index.d.ts +1 -0
  23. package/lib/modules/BookingContext/utils/index.js +11 -0
  24. package/lib/modules/BookingContext/utils/productExtend.d.ts +6 -0
  25. package/lib/modules/BookingContext/utils/productExtend.js +23 -0
  26. package/lib/modules/Product/index.d.ts +1 -1
  27. package/lib/modules/ResourcePlanner/planner.js +23 -0
  28. package/lib/modules/ResourcePlanner/types.d.ts +7 -0
  29. package/lib/server/index.js +5 -1
  30. package/lib/solution/BookingByStep/index.d.ts +2 -2
  31. package/lib/solution/BookingTicket/index.js +4 -2
  32. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -0
  33. package/lib/solution/BookingTicket/utils/addProductDecision.js +33 -3
  34. package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
  35. package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
  36. package/lib/solution/UnifiedBookingSales/index.d.ts +14 -2
  37. package/lib/solution/UnifiedBookingSales/index.js +139 -3
  38. package/package.json +1 -1
@@ -5,7 +5,8 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  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); }
7
7
  import dayjs from 'dayjs';
8
- import { cacheItemToBookingInput, derivePresetStartTimeFromDate, getProductExtend, getIsAutoClose, isSessionProduct, isBookingProduct, applySessionTimesToExtend, hasActualResourceSelection, productNeedsResourceExtend } from "../../../modules/BookingContext";
8
+ import { cacheItemToBookingInput, derivePresetStartTimeFromDate, getProductExtend, getIsAutoClose, isSessionProduct, isBookingProduct, applySessionTimesToExtend, hasActualResourceSelection, productNeedsResourceExtend, getCalendarBookingRange, calendarBookingNeedsInput, calendarBookingPreparationKey } from "../../../modules/BookingContext";
9
+ import { resolveUniqueCartDetailValue } from "./resolveUniqueCartDetail";
9
10
  import { transformBaseProductToOrderProduct } from "../../BaseSales/utils/transformBaseProductToOrderProduct";
10
11
  import { buildProductSkuFromCacheItem } from "./weighingProductSku";
11
12
  import { isSelfServicePlatform } from "../../../utils/platform";
@@ -34,6 +35,7 @@ function needsSpecDetailModal(item) {
34
35
  * 第二段:预约商品是否仍需打开资源 / 时间编辑(自助终端强制打开,其他渠道与 info2 `cacheItem.autoClose` 等价)。
35
36
  */
36
37
  function needsBookingEdit(cacheItem, ctx) {
38
+ if (getCalendarBookingRange(cacheItem, ctx)) return calendarBookingNeedsInput(cacheItem);
37
39
  if (isNormalBookingProduct(cacheItem)) return false;
38
40
  if (isSelfServicePlatform(ctx === null || ctx === void 0 ? void 0 : ctx.channel)) return true;
39
41
  var isAutoAllocationOn = (ctx === null || ctx === void 0 ? void 0 : ctx.isAutoAllocationOn) || function () {
@@ -54,13 +56,22 @@ function buildRequiresBookingEditPayload(cacheItem, ctx) {
54
56
  */
55
57
  export function decideAddProduct(item, ctx) {
56
58
  var derivedCtx = withDerivedBookingCtx(ctx);
57
- if (needsSpecDetailModal(item)) {
59
+ var calendarRange = getCalendarBookingRange(item, derivedCtx);
60
+ var uniqueValue = calendarRange ? resolveUniqueCartDetailValue(item) : null;
61
+ var selectedItem = uniqueValue ? _objectSpread(_objectSpread({}, item), {}, {
62
+ cartDetailValue: uniqueValue,
63
+ isOpenDetailModal: false
64
+ }) : item;
65
+ if (needsSpecDetailModal(selectedItem)) {
66
+ var preparedCacheItem = calendarRange ? prepareBookingCacheItem(buildCacheItemFromCartDetail(item, derivedCtx), derivedCtx) : undefined;
58
67
  return {
59
68
  action: 'requiresDetail',
60
- payload: buildRequiresDetailPayload(item, derivedCtx)
69
+ payload: _objectSpread(_objectSpread({}, buildRequiresDetailPayload(item, derivedCtx)), preparedCacheItem ? {
70
+ preparedCacheItem: preparedCacheItem
71
+ } : {})
61
72
  };
62
73
  }
63
- var cacheItem = prepareBookingCacheItem(buildCacheItemFromCartDetail(item, derivedCtx), derivedCtx);
74
+ var cacheItem = prepareBookingCacheItem(buildCacheItemFromCartDetail(selectedItem, derivedCtx), derivedCtx);
64
75
  if (needsBookingEdit(cacheItem, derivedCtx)) {
65
76
  return {
66
77
  action: 'requiresBookingEdit',
@@ -142,7 +153,23 @@ function isMultiDayLike(cacheItem) {
142
153
  * `_extend.resource / capacity / startDate / endDate` 等后续 booking mapper 需要的字段。
143
154
  */
144
155
  export function prepareBookingCacheItem(cacheItem, ctx) {
145
- if ((ctx === null || ctx === void 0 ? void 0 : ctx.rememberedTime) === undefined && (isNormalBookingProduct(cacheItem) || hasPreparedBookingExtend(cacheItem))) {
156
+ var _ctx, _cacheItem$duration2, _cacheItem$_extend, _ctx2;
157
+ if (getCalendarBookingRange(cacheItem, ctx)) {
158
+ var _cacheItem$_data;
159
+ if (((_cacheItem$_data = cacheItem._data) === null || _cacheItem$_data === void 0 ? void 0 : _cacheItem$_data.calendarBookingPreparationKey) === calendarBookingPreparationKey(cacheItem, ctx)) return cacheItem;
160
+ return getProductExtend({
161
+ cacheItem: cacheItem,
162
+ ctx: ctx,
163
+ isDisabledTime: true
164
+ });
165
+ }
166
+ if ((_ctx = ctx) !== null && _ctx !== void 0 && _ctx.bookingTimeRangeFromCalendar && (((_cacheItem$duration2 = cacheItem.duration) === null || _cacheItem$duration2 === void 0 ? void 0 : _cacheItem$duration2.type) === 'days' || cacheItem.duration_type === 'days' || ((_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.sub_type) === 'days')) {
167
+ ctx = _objectSpread(_objectSpread({}, ctx), {}, {
168
+ bookingTimeRangeFromCalendar: undefined,
169
+ resourceIdFromCalendar: undefined
170
+ });
171
+ }
172
+ if (((_ctx2 = ctx) === null || _ctx2 === void 0 ? void 0 : _ctx2.rememberedTime) === undefined && (isNormalBookingProduct(cacheItem) || hasPreparedBookingExtend(cacheItem))) {
146
173
  return cacheItem;
147
174
  }
148
175
  return getProductExtend({
@@ -320,9 +347,9 @@ export function transformDetailToProductAndBooking(cacheItem, ctx) {
320
347
  * 把 cacheItem._extend.other 中的字段 + 顶层运行态拼成 `BaseProductDetailPayload`。
321
348
  */
322
349
  function buildBasePayloadFromCacheItem(cacheItem, ctx) {
323
- var _cacheItem$_extend, _cacheItem$_extend$qu, _cacheItem$_extend2, _cacheItem$product_id, _cacheItem$id, _ref5, _other$product_varian, _other$production_cod, _extend$skuValue, _extend$_skuValue, _extend$price, _extend$price2, _cacheItem$metadata$s, _cacheItem$metadata, _extend$metadata;
324
- var other = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.other) || {};
325
- var quantity = (ctx === null || ctx === void 0 ? void 0 : ctx.quantity) != null && ctx.quantity > 0 ? ctx.quantity : (_cacheItem$_extend$qu = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.quantity) !== null && _cacheItem$_extend$qu !== void 0 ? _cacheItem$_extend$qu : 1;
350
+ var _cacheItem$_extend2, _cacheItem$_extend$qu, _cacheItem$_extend3, _cacheItem$product_id, _cacheItem$id, _ref5, _other$product_varian, _other$production_cod, _extend$skuValue, _extend$_skuValue, _extend$price, _extend$price2, _cacheItem$metadata$s, _cacheItem$metadata, _extend$metadata;
351
+ var other = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.other) || {};
352
+ var quantity = (ctx === null || ctx === void 0 ? void 0 : ctx.quantity) != null && ctx.quantity > 0 ? ctx.quantity : (_cacheItem$_extend$qu = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend3 = cacheItem._extend) === null || _cacheItem$_extend3 === void 0 ? void 0 : _cacheItem$_extend3.quantity) !== null && _cacheItem$_extend$qu !== void 0 ? _cacheItem$_extend$qu : 1;
326
353
  var resolvedPid = (_cacheItem$product_id = cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.product_id) !== null && _cacheItem$product_id !== void 0 ? _cacheItem$product_id : cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.id;
327
354
  var extend = (cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem._extend) || {};
328
355
  var productSku = buildProductSkuFromCacheItem(cacheItem);
@@ -0,0 +1,8 @@
1
+ type RecordValue = Record<string, any>;
2
+ /**
3
+ * Resolve a whole SKU only when the original configuration proves one legal
4
+ * result. A default, a stock-filtered remainder, or missing detail is not proof
5
+ * of uniqueness. The input product and its existing selections stay untouched.
6
+ */
7
+ export declare function resolveUniqueCartDetailValue(product: RecordValue): RecordValue | null;
8
+ export {};
@@ -0,0 +1,188 @@
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 _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; } } }; }
3
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
+ 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."); }
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
+ 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; }
8
+ 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; }
9
+ 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; }
10
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
11
+ 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); }
12
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
13
+ 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."); }
14
+ 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); }
15
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
16
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
17
+ 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; }
18
+ var flag = function flag(value) {
19
+ return value === true || value === 1 || value === '1';
20
+ };
21
+ var cleared = function cleared(value) {
22
+ return value === false || value === 0 || value === '0';
23
+ };
24
+ var enabled = function enabled(item) {
25
+ return item && !flag(item.disabled) && !cleared(item.is_enabled) && item.deleted_at == null;
26
+ };
27
+ var sellable = function sellable(item) {
28
+ return enabled(item) && (!flag(item.is_track) || flag(item.over_sold) || Number(item.stock_quantity) > 0);
29
+ };
30
+ var bound = function bound(value) {
31
+ var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
32
+ if (value == null || value === '') return fallback;
33
+ if (typeof value !== 'number' && typeof value !== 'string') return null;
34
+ var number = Number(value);
35
+ return Number.isInteger(number) && number >= 0 ? number : null;
36
+ };
37
+ var validId = function validId(value) {
38
+ return (typeof value === 'number' || typeof value === 'string') && Number.isSafeInteger(Number(value)) && Number(value) > 0;
39
+ };
40
+
41
+ /** A choice is unique only if its complete allowed quantity interval is one value. */
42
+ function fixedQuantity(minimums, maximums) {
43
+ var min = Math.max.apply(Math, [1].concat(_toConsumableArray(minimums)));
44
+ var max = Math.min.apply(Math, _toConsumableArray(maximums.filter(function (value) {
45
+ return value > 0;
46
+ })).concat([Infinity]));
47
+ return min === max ? min : null;
48
+ }
49
+ function configuredGroups(product, key, countKey) {
50
+ var groups = product[key];
51
+ if (groups == null && product[countKey] == null) return null;
52
+ var count = bound(product[countKey]);
53
+ if (count == null || groups != null && !Array.isArray(groups)) return null;
54
+ if (count > 0 && (!Array.isArray(groups) || groups.length !== count)) return null;
55
+ return groups || [];
56
+ }
57
+
58
+ /**
59
+ * Resolve a whole SKU only when the original configuration proves one legal
60
+ * result. A default, a stock-filtered remainder, or missing detail is not proof
61
+ * of uniqueness. The input product and its existing selections stay untouched.
62
+ */
63
+ export function resolveUniqueCartDetailValue(product) {
64
+ var _product$id, _product$id2, _product$option_group, _product$bundle_group, _product$bundle_group2, _product$variant_grou, _existing$option, _existing$bundle, _ref2, _value$session$key;
65
+ if (!product || !validId((_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : product.product_id) || flag(product.open_sold_weight)) return null;
66
+ var productId = (_product$id2 = product.id) !== null && _product$id2 !== void 0 ? _product$id2 : product.product_id;
67
+ var existing = product.cartDetailValue;
68
+ var hasConfiguredSku = flag(product.is_variant) || Number(product.variant_count) > 0 || Number(product.option_group_count) > 0 || Number(product.bundle_group_count) > 0 || ((_product$option_group = product.option_group) === null || _product$option_group === void 0 ? void 0 : _product$option_group.length) > 0 || ((_product$bundle_group = product.bundle_group) === null || _product$bundle_group === void 0 ? void 0 : _product$bundle_group.length) > 0 || ((_product$bundle_group2 = product.bundle_groups) === null || _product$bundle_group2 === void 0 ? void 0 : _product$bundle_group2.length) > 0 || ((_product$variant_grou = product.variant_group) === null || _product$variant_grou === void 0 ? void 0 : _product$variant_grou.length) > 0;
69
+ if (existing && !hasConfiguredSku && !((_existing$option = existing.option) !== null && _existing$option !== void 0 && _existing$option.length || (_existing$bundle = existing.bundle) !== null && _existing$bundle !== void 0 && _existing$bundle.length)) {
70
+ return _objectSpread(_objectSpread({}, existing), {}, {
71
+ product_id: productId,
72
+ quantity: 1
73
+ });
74
+ }
75
+ var knowsVariantShape = cleared(product.is_variant) || product.variant_count === 0 || product.variant_count === '0' || Array.isArray(product.variant) || Array.isArray(product.variant_group);
76
+ if (!knowsVariantShape) return null;
77
+ var optionGroups = configuredGroups(product, 'option_group', 'option_group_count');
78
+ var bundleKey = product.bundle_group != null ? 'bundle_group' : 'bundle_groups';
79
+ var bundleGroups = configuredGroups(product, bundleKey, 'bundle_group_count');
80
+ if (!optionGroups || !bundleGroups) return null;
81
+ var value = _objectSpread(_objectSpread({}, product.cartDetailValue || {}), {}, {
82
+ product_id: productId,
83
+ product_variant_id: 0,
84
+ option: [],
85
+ bundle: [],
86
+ quantity: 1
87
+ });
88
+ var hasVariant = flag(product.is_variant) || Number(product.variant_count) > 0 || Array.isArray(product.variant_group) && product.variant_group.length > 0 || Array.isArray(product.variant) && product.variant.length > 0;
89
+ if (hasVariant) {
90
+ var _ref, _variant$production_c;
91
+ if (!Array.isArray(product.variant) || product.variant.length !== 1 || Number(product.variant_count) > 0 && Number(product.variant_count) !== 1) return null;
92
+ var _product$variant = _slicedToArray(product.variant, 1),
93
+ variant = _product$variant[0];
94
+ if (!validId(variant === null || variant === void 0 ? void 0 : variant.id) || !sellable(variant)) return null;
95
+ value.product_variant_id = variant.id;
96
+ if (variant.price == null || variant.price === '' || !Number.isFinite(Number(variant.price)) || Number(variant.price) < 0) return null;
97
+ value.price = variant.price;
98
+ value.production_code = (_ref = (_variant$production_c = variant.production_code) !== null && _variant$production_c !== void 0 ? _variant$production_c : variant.code) !== null && _ref !== void 0 ? _ref : '';
99
+ }
100
+ var _iterator = _createForOfIteratorHelper(optionGroups),
101
+ _step;
102
+ try {
103
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
104
+ var _group$metadata, _group$metadata2, _group$metadata3, _ref3, _item$price;
105
+ var group = _step.value;
106
+ // Do not silently remove configured alternatives that are disabled or out of stock.
107
+ if (!validId(group === null || group === void 0 ? void 0 : group.id) || !enabled(group) || !Array.isArray(group.option_item) || group.option_item.length !== 1) return null;
108
+ var _group$option_item = _slicedToArray(group.option_item, 1),
109
+ item = _group$option_item[0];
110
+ if (!validId(item === null || item === void 0 ? void 0 : item.id) || !sellable(item)) return null;
111
+ var multiple = flag(group.is_multiple);
112
+ var groupMin = bound(group.min_quantity);
113
+ var groupMax = bound(group.max_quantity);
114
+ var itemMin = bound(item.min_quantity);
115
+ var itemMax = bound(item.max_quantity, 1);
116
+ if ([groupMin, groupMax, itemMin, itemMax].some(function (value) {
117
+ return value == null;
118
+ })) return null;
119
+ var advanced = multiple && flag((_group$metadata = group.metadata) === null || _group$metadata === void 0 ? void 0 : _group$metadata.advanced_settings_enabled);
120
+ var minTypes = advanced ? bound((_group$metadata2 = group.metadata) === null || _group$metadata2 === void 0 || (_group$metadata2 = _group$metadata2.option_types_config) === null || _group$metadata2 === void 0 ? void 0 : _group$metadata2.min) : 0;
121
+ var maxTypes = advanced ? bound((_group$metadata3 = group.metadata) === null || _group$metadata3 === void 0 || (_group$metadata3 = _group$metadata3.option_types_config) === null || _group$metadata3 === void 0 ? void 0 : _group$metadata3.max) : 0;
122
+ if (minTypes == null || maxTypes == null || minTypes > 1 || maxTypes > 0 && maxTypes < minTypes) return null;
123
+ var required = multiple ? groupMin > 0 || minTypes > 0 : flag(group.required);
124
+ if (!required) return null;
125
+ var quantity = fixedQuantity([itemMin].concat(_toConsumableArray(multiple ? [groupMin] : [])), [itemMax].concat(_toConsumableArray(multiple ? [groupMax] : [])));
126
+ if (!quantity) return null;
127
+ var price = (_ref3 = (_item$price = item.price) !== null && _item$price !== void 0 ? _item$price : item.add_price) !== null && _ref3 !== void 0 ? _ref3 : 0;
128
+ value.option.push(_objectSpread(_objectSpread({}, item), {}, {
129
+ id: item.id,
130
+ product_option_item_id: item.id,
131
+ option_group_item_id: item.id,
132
+ option_group_id: group.id,
133
+ product_id: productId,
134
+ quantity: quantity,
135
+ num: quantity,
136
+ price: price,
137
+ original_price: price
138
+ }));
139
+ }
140
+ } catch (err) {
141
+ _iterator.e(err);
142
+ } finally {
143
+ _iterator.f();
144
+ }
145
+ var _iterator2 = _createForOfIteratorHelper(bundleGroups),
146
+ _step2;
147
+ try {
148
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
149
+ var _item$option_group, _item$variant_group, _item$variant, _item$bundle_group, _item$bundle_groups;
150
+ var _group = _step2.value;
151
+ if (!validId(_group === null || _group === void 0 ? void 0 : _group.id) || !enabled(_group) || !Array.isArray(_group.bundle_item) || _group.bundle_item.length !== 1) return null;
152
+ var _group$bundle_item = _slicedToArray(_group.bundle_item, 1),
153
+ _item = _group$bundle_item[0];
154
+ if (!validId(_item === null || _item === void 0 ? void 0 : _item.id) || !validId(_item === null || _item === void 0 ? void 0 : _item.bundle_product_id) || !sellable(_item) || (_item$option_group = _item.option_group) !== null && _item$option_group !== void 0 && _item$option_group.length || (_item$variant_group = _item.variant_group) !== null && _item$variant_group !== void 0 && _item$variant_group.length || (_item$variant = _item.variant) !== null && _item$variant !== void 0 && _item$variant.length || (_item$bundle_group = _item.bundle_group) !== null && _item$bundle_group !== void 0 && _item$bundle_group.length || (_item$bundle_groups = _item.bundle_groups) !== null && _item$bundle_groups !== void 0 && _item$bundle_groups.length || flag(_item.is_variant) || flag(_item.open_sold_weight) || Number(_item.variant_count) > 0 || Number(_item.option_group_count) > 0 || Number(_item.bundle_group_count) > 0) return null;
155
+ var _groupMin = bound(_group.min_quantity);
156
+ var _groupMax = bound(_group.max_quantity);
157
+ var _itemMin = bound(_item.min_quantity);
158
+ var _itemMax = bound(_item.max_quantity);
159
+ if ([_groupMin, _groupMax, _itemMin, _itemMax].some(function (value) {
160
+ return value == null;
161
+ }) || _groupMin <= 0) return null;
162
+ var _quantity = fixedQuantity([_groupMin, _itemMin], [_groupMax, _itemMax]);
163
+ if (!_quantity) return null;
164
+ value.bundle.push(_objectSpread(_objectSpread({}, _item), {}, {
165
+ id: _item.id,
166
+ group_id: _group.id,
167
+ bundle_group_id: _group.id,
168
+ _bundle_product_id: _item.bundle_product_id,
169
+ quantity: _quantity,
170
+ num: _quantity,
171
+ option: []
172
+ }));
173
+ }
174
+ } catch (err) {
175
+ _iterator2.e(err);
176
+ } finally {
177
+ _iterator2.f();
178
+ }
179
+ var key = [productId, value.product_variant_id].concat(_toConsumableArray(value.option.map(function (item) {
180
+ return "o".concat(item.option_group_id, ":").concat(item.id, ":").concat(item.quantity);
181
+ })), _toConsumableArray(value.bundle.map(function (item) {
182
+ return "b".concat(item.group_id, ":").concat(item.id, ":").concat(item.quantity);
183
+ })), _toConsumableArray(value.session ? ["s".concat((_ref2 = (_value$session$key = value.session.key) !== null && _value$session$key !== void 0 ? _value$session$key : value.session.id) !== null && _ref2 !== void 0 ? _ref2 : '')] : [])).join('_');
184
+ return _objectSpread(_objectSpread({}, value), {}, {
185
+ key: key,
186
+ rowKey: key
187
+ });
188
+ }
@@ -5,8 +5,8 @@ import type { AddProductDecideContext } from '../BookingTicket/utils/addProductD
5
5
  import { type InvoiceLayoutConfig, type InvoiceTemplateSettings, type OpenDataConfig, type ResolvedSalesSettings } from '../../modules/OpenData';
6
6
  import type { LoadScheduleAvailableDateParams, ScheduleItem } from '../../modules/Schedule/types';
7
7
  import type { ProductListLoadProductsParams, ProductListStoreQueryParams } from '../../modules/ProductList';
8
- import type { AvailabilityDateRange, AvailabilityOccupancy, AvailabilityProduct, AvailabilityResource, GetProductTimeRangesRequest } from '../../modules/ResourcePlanner';
9
- import type { AvailabilityContextRef, ContextualAvailabilityQuery, ContextualAvailabilityQueryResult, ContextualCommitAvailabilitySelectionParams, ContextualProductTimeRangeGroup, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesCatalogQueryBatch, UnifiedBookingSalesVenueCatalogSession, UnifiedBookingSalesVenueCatalogSessionParams, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesCommitAvailabilitySelectionResult, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesPrepareAvailabilityProjectionParams, UnifiedBookingSalesPolicyResponse, UnifiedBookingSalesQueryBookingResourceDetailsParams, UnifiedBookingSalesResourceDetail, UnifiedBookingSalesResolveProductAllergyRequirementParams, UnifiedBookingSalesStageRetailProductsParams, UnifiedBookingSalesState } from './types';
8
+ import type { AvailabilityDateRange, AvailabilityOccupancy, AvailabilityProduct, AvailabilityRequirementSelection, AvailabilityResource, GetProductTimeRangesRequest } from '../../modules/ResourcePlanner';
9
+ import type { AvailabilityContextRef, ContextualAvailabilityQuery, ContextualAvailabilityQueryResult, ContextualCommitAvailabilitySelectionParams, ContextualProductTimeRange, ContextualProductTimeRangeGroup, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesCatalogQueryBatch, UnifiedBookingSalesVenueCatalogSession, UnifiedBookingSalesVenueCatalogSessionParams, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesCommitAvailabilitySelectionResult, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesPrepareAvailabilityProjectionParams, UnifiedBookingSalesPolicyResponse, UnifiedBookingSalesQueryBookingResourceDetailsParams, UnifiedBookingSalesResourceDetail, UnifiedBookingSalesResolveProductAllergyRequirementParams, UnifiedBookingSalesStageRetailProductsParams, UnifiedBookingSalesState } from './types';
10
10
  import type { BusinessAvailability } from '../../modules/BusinessAvailability';
11
11
  import { BookingTicket } from '../BookingTicket';
12
12
  import type { BaseSalesSubmitSalesOrderParams } from '../BaseSales/types';
@@ -122,6 +122,18 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
122
122
  * 仅供直加调用;手动时间选择和 availability candidate 不经过此方法。
123
123
  */
124
124
  prepareDirectAddFlexibleBooking(cacheItem: any): Promise<any>;
125
+ /** Reuse an approved calendar cache; only the final commit may mutate the order. */
126
+ prepareDirectAddCalendarBooking(cacheItem: any, options?: {
127
+ bookingCount?: number;
128
+ availabilityCommitGuard?: () => void;
129
+ }): Promise<{
130
+ cacheItem: any;
131
+ contextId: string;
132
+ candidate: ContextualProductTimeRange;
133
+ requirementSelections: AvailabilityRequirementSelection[];
134
+ partySize: number;
135
+ bookingCount: number;
136
+ } | null>;
125
137
  private resolveAvailabilityPrepareDefaults;
126
138
  private buildAvailabilityPrepareKey;
127
139
  private clearAvailabilityRemoteResourceState;