@pisell/pisellos 2.2.163 → 2.2.164

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 (117) hide show
  1. package/dist/modules/BookingContext/index.d.ts +37 -0
  2. package/dist/modules/BookingContext/index.js +436 -0
  3. package/dist/modules/BookingContext/types.d.ts +102 -0
  4. package/dist/modules/BookingContext/types.js +51 -0
  5. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  6. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +157 -0
  7. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  8. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +107 -0
  9. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +65 -0
  10. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +191 -0
  11. package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
  12. package/dist/modules/BookingContext/utils/flexible.js +56 -0
  13. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  14. package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
  15. package/dist/modules/BookingContext/utils/index.d.ts +11 -0
  16. package/dist/modules/BookingContext/utils/index.js +11 -0
  17. package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
  18. package/dist/modules/BookingContext/utils/noResource.js +77 -0
  19. package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
  20. package/dist/modules/BookingContext/utils/productExtend.js +339 -0
  21. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  22. package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
  23. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  24. package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
  25. package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
  26. package/dist/modules/BookingContext/utils/resources.js +486 -0
  27. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  28. package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
  29. package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  30. package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
  31. package/dist/modules/Customer/index.js +23 -22
  32. package/dist/modules/Discount/index.js +4 -3
  33. package/dist/modules/Order/index.d.ts +18 -7
  34. package/dist/modules/Order/index.js +474 -287
  35. package/dist/modules/Order/types.d.ts +32 -12
  36. package/dist/modules/Order/utils.js +9 -8
  37. package/dist/modules/SalesSummary/index.js +4 -2
  38. package/dist/modules/index.d.ts +1 -0
  39. package/dist/modules/index.js +2 -1
  40. package/dist/server/index.js +0 -1
  41. package/dist/solution/BaseSales/index.d.ts +38 -7
  42. package/dist/solution/BaseSales/index.js +797 -310
  43. package/dist/solution/BaseSales/types.d.ts +48 -1
  44. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  45. package/dist/solution/BaseSales/utils/quotationPrice.js +159 -0
  46. package/dist/solution/BookingByStep/index.d.ts +1 -1
  47. package/dist/solution/BookingTicket/index.d.ts +121 -1
  48. package/dist/solution/BookingTicket/index.js +401 -72
  49. package/dist/solution/BookingTicket/types.d.ts +2 -0
  50. package/dist/solution/BookingTicket/types.js +3 -0
  51. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +111 -0
  52. package/dist/solution/BookingTicket/utils/addProductDecision.js +326 -0
  53. package/dist/solution/ScanOrder/index.d.ts +9 -3
  54. package/dist/solution/ScanOrder/index.js +231 -128
  55. package/dist/solution/VenueBooking/index.d.ts +4 -2
  56. package/dist/solution/VenueBooking/index.js +103 -55
  57. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  58. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
  59. package/lib/modules/BookingContext/index.d.ts +37 -0
  60. package/lib/modules/BookingContext/index.js +297 -0
  61. package/lib/modules/BookingContext/types.d.ts +102 -0
  62. package/lib/modules/BookingContext/types.js +34 -0
  63. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  64. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +174 -0
  65. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  66. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +115 -0
  67. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +65 -0
  68. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +177 -0
  69. package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
  70. package/lib/modules/BookingContext/utils/flexible.js +80 -0
  71. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  72. package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
  73. package/lib/modules/BookingContext/utils/index.d.ts +11 -0
  74. package/lib/modules/BookingContext/utils/index.js +43 -0
  75. package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
  76. package/lib/modules/BookingContext/utils/noResource.js +90 -0
  77. package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
  78. package/lib/modules/BookingContext/utils/productExtend.js +283 -0
  79. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  80. package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
  81. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  82. package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
  83. package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
  84. package/lib/modules/BookingContext/utils/resources.js +377 -0
  85. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  86. package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
  87. package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  88. package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
  89. package/lib/modules/Customer/index.js +8 -8
  90. package/lib/modules/Discount/index.js +5 -1
  91. package/lib/modules/Order/index.d.ts +18 -7
  92. package/lib/modules/Order/index.js +164 -68
  93. package/lib/modules/Order/types.d.ts +32 -12
  94. package/lib/modules/Order/utils.js +8 -6
  95. package/lib/modules/SalesSummary/index.js +4 -2
  96. package/lib/modules/index.d.ts +1 -0
  97. package/lib/modules/index.js +3 -1
  98. package/lib/server/index.js +0 -1
  99. package/lib/solution/BaseSales/index.d.ts +38 -7
  100. package/lib/solution/BaseSales/index.js +304 -14
  101. package/lib/solution/BaseSales/types.d.ts +48 -1
  102. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  103. package/lib/solution/BaseSales/utils/quotationPrice.js +201 -0
  104. package/lib/solution/BookingByStep/index.d.ts +1 -1
  105. package/lib/solution/BookingTicket/index.d.ts +121 -1
  106. package/lib/solution/BookingTicket/index.js +207 -2
  107. package/lib/solution/BookingTicket/types.d.ts +2 -0
  108. package/lib/solution/BookingTicket/types.js +6 -0
  109. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +111 -0
  110. package/lib/solution/BookingTicket/utils/addProductDecision.js +300 -0
  111. package/lib/solution/ScanOrder/index.d.ts +9 -3
  112. package/lib/solution/ScanOrder/index.js +147 -66
  113. package/lib/solution/VenueBooking/index.d.ts +4 -2
  114. package/lib/solution/VenueBooking/index.js +50 -14
  115. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  116. package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
  117. package/package.json +1 -1
@@ -0,0 +1,157 @@
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ 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."); }
4
+ 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); }
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
+ 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; }
8
+ 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; }
9
+ 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; }
10
+ 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; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
+ 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); }
13
+ import dayjs from 'dayjs';
14
+ function safeFormat(value, fmt) {
15
+ if (value === undefined || value === null) return undefined;
16
+ var d = dayjs(value);
17
+ if (!d.isValid()) return undefined;
18
+ return d.format(fmt);
19
+ }
20
+ function normalizeTimeString(value) {
21
+ if (value === undefined || value === null) return undefined;
22
+ if (typeof value === 'string') {
23
+ var t = value.trim();
24
+ var hhmmFromHhmmss = t.match(/^(\d{1,2}:\d{2}):\d{2}$/);
25
+ if (hhmmFromHhmmss) return hhmmFromHhmmss[1];
26
+ if (/^\d{1,2}:\d{2}$/.test(t)) return t;
27
+ }
28
+ var d = dayjs(value);
29
+ if (d.isValid()) return d.format('HH:mm');
30
+ return undefined;
31
+ }
32
+
33
+ /**
34
+ * bookings[].resources[] → cacheItem._extend.resource(与 cacheItemToBookingInput.flattenResources 互逆)。
35
+ */
36
+ function unflattenResourceMap(resources) {
37
+ var map = {};
38
+ if (!Array.isArray(resources)) return map;
39
+ resources.forEach(function (r) {
40
+ var formId = r === null || r === void 0 ? void 0 : r.form_id;
41
+ if (formId === undefined || formId === null) return;
42
+ var key = String(formId);
43
+ if (!map[key]) map[key] = [];
44
+ map[key].push({
45
+ form_id: formId,
46
+ relation_id: r.relation_id,
47
+ relation_type: r.relation_type || 'form',
48
+ like_status: r.like_status || 'common',
49
+ metadata: r.metadata ? _objectSpread({}, r.metadata) : undefined,
50
+ children: r.children
51
+ });
52
+ });
53
+ return map;
54
+ }
55
+ function buildCapacityFromBooking(resources) {
56
+ if (!Array.isArray(resources)) return [];
57
+ return resources.filter(function (r) {
58
+ return (r === null || r === void 0 ? void 0 : r.relation_id) !== undefined && (r === null || r === void 0 ? void 0 : r.relation_id) !== null && r.capacity !== undefined;
59
+ }).map(function (r) {
60
+ return {
61
+ id: r.relation_id,
62
+ value: Number(r.capacity || 0)
63
+ };
64
+ });
65
+ }
66
+ function resolveDurationForExtend(booking) {
67
+ var duration = booking.duration;
68
+ if (booking.sub_type === 'days' || booking.is_all === 1) {
69
+ return duration;
70
+ }
71
+ if (typeof duration === 'number' && Number.isFinite(duration)) {
72
+ return duration;
73
+ }
74
+ return duration;
75
+ }
76
+
77
+ /**
78
+ * 从已加车的 order line + booking 反查 editService 所需的 cacheItem。
79
+ *
80
+ * 与 `buildCacheItemFromCartDetail` / `buildCacheItemFromDetail` 正向拼装互逆(在 getProductExtend 之前调用)。
81
+ * 调用方须传入与该行关联的 booking(通常 bookings[].product_uid === product.metadata.unique_identification_number)。
82
+ */
83
+ export function buildCacheItemFromOrderLine(input) {
84
+ var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata, _product$product_vari, _product$num, _ref, _ref2, _title, _booking$product, _booking$detail, _ref3, _product$note, _booking$detail2, _ref4, _extension_type, _booking$product2, _title2, _booking$product3, _price, _product$order_detail, _ref5, _booking$id;
85
+ var product = input.product,
86
+ booking = input.booking,
87
+ sourceProduct = input.sourceProduct;
88
+ var resolvedId = (_product$product_id = product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.id;
89
+ var selling = Number((_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : 0);
90
+ var original = Number((_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : selling);
91
+ var startDate = safeFormat(booking.start_date, 'YYYY-MM-DD');
92
+ var endDate = safeFormat(booking.end_date, 'YYYY-MM-DD');
93
+ var startTime = normalizeTimeString(booking.start_time);
94
+ var endTime = normalizeTimeString(booking.end_time);
95
+ var resource = unflattenResourceMap(booking.resources);
96
+ var capacity = buildCapacityFromBooking(booking.resources);
97
+ var holderId = (_booking$metadata$hol = (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.holder_id) !== null && _booking$metadata$hol !== void 0 ? _booking$metadata$hol : booking.holder_id;
98
+ var other = {
99
+ product_variant_id: (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : 0,
100
+ option: Array.isArray(product.product_option_item) ? _toConsumableArray(product.product_option_item) : [],
101
+ bundle: Array.isArray(product.product_bundle) ? _toConsumableArray(product.product_bundle) : []
102
+ };
103
+ var extend = {
104
+ start_date: startDate ? dayjs(startDate) : undefined,
105
+ end_date: endDate ? dayjs(endDate) : undefined,
106
+ startDate: startDate ? dayjs(startDate) : undefined,
107
+ endDate: endDate ? dayjs(endDate) : undefined,
108
+ start_time: startTime,
109
+ end_time: endTime,
110
+ duration: resolveDurationForExtend(booking),
111
+ sub_type: booking.sub_type,
112
+ quantity: (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : 1,
113
+ product_name: (_ref = (_ref2 = (_title = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) !== null && _title !== void 0 ? _title : booking === null || booking === void 0 || (_booking$product = booking.product) === null || _booking$product === void 0 ? void 0 : _booking$product.title) !== null && _ref2 !== void 0 ? _ref2 : booking === null || booking === void 0 || (_booking$detail = booking.detail) === null || _booking$detail === void 0 ? void 0 : _booking$detail.product_title) !== null && _ref !== void 0 ? _ref : '',
114
+ note: (_ref3 = (_product$note = product.note) !== null && _product$note !== void 0 ? _product$note : booking === null || booking === void 0 || (_booking$detail2 = booking.detail) === null || _booking$detail2 === void 0 ? void 0 : _booking$detail2.note) !== null && _ref3 !== void 0 ? _ref3 : '',
115
+ price: selling,
116
+ total: selling,
117
+ origin_total: original,
118
+ resource: resource,
119
+ capacity: capacity,
120
+ holder_id: holderId,
121
+ other: other,
122
+ like_status: booking.like_status || 'common'
123
+ };
124
+ if (booking.holder !== undefined) {
125
+ extend.holder = booking.holder;
126
+ }
127
+ if (Array.isArray(booking.relation_forms)) {
128
+ extend.relation_forms = booking.relation_forms;
129
+ }
130
+ var base = _objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
131
+ id: resolvedId,
132
+ product_id: resolvedId,
133
+ extension_type: (_ref4 = (_extension_type = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type) !== null && _extension_type !== void 0 ? _extension_type : booking === null || booking === void 0 || (_booking$product2 = booking.product) === null || _booking$product2 === void 0 ? void 0 : _booking$product2.extension_type) !== null && _ref4 !== void 0 ? _ref4 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type,
134
+ title: (_title2 = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) !== null && _title2 !== void 0 ? _title2 : booking === null || booking === void 0 || (_booking$product3 = booking.product) === null || _booking$product3 === void 0 ? void 0 : _booking$product3.title,
135
+ price: (_price = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price !== void 0 ? _price : selling,
136
+ selling_price: product.selling_price,
137
+ original_price: product.original_price,
138
+ _extend: extend,
139
+ new: 0,
140
+ autoClose: false,
141
+ order_detail_id: (_product$order_detail = product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : null,
142
+ booking_id: (_ref5 = (_booking$id = booking.id) !== null && _booking$id !== void 0 ? _booking$id : booking.booking_id) !== null && _ref5 !== void 0 ? _ref5 : 0
143
+ });
144
+ if ((sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.capacity) !== undefined) {
145
+ base.capacity = sourceProduct.capacity;
146
+ }
147
+ if ((sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.duration) !== undefined) {
148
+ base.duration = sourceProduct.duration;
149
+ }
150
+ if ((sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.product_resource) !== undefined) {
151
+ base.product_resource = sourceProduct.product_resource;
152
+ }
153
+ if (booking.schedule_event_id !== undefined) {
154
+ base.schedule_event_id = booking.schedule_event_id;
155
+ }
156
+ return base;
157
+ }
@@ -0,0 +1,8 @@
1
+ import type { OrderProduct } from '../../Order/types';
2
+ export interface BuildNormalProductCacheItemFromOrderLineInput {
3
+ /** tempOrder.products 中的一行(普通商品,无关联 booking) */
4
+ product: OrderProduct;
5
+ /** 商品 catalog / 详情,用于 variant / option / bundle 模板字段 */
6
+ sourceProduct?: Record<string, any> | null;
7
+ }
8
+ export declare function buildNormalProductCacheItemFromOrderLine(input: BuildNormalProductCacheItemFromOrderLineInput): Record<string, any>;
@@ -0,0 +1,107 @@
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 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; }
3
+ 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; }
4
+ 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; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
+ 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."); }
9
+ 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); }
10
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
11
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
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
+ /**
14
+ * 从已加车的普通商品 order line 反查 SkuDetailModal edit 所需的 cacheItem。
15
+ *
16
+ * 与 `buildCacheItemFromOrderLine`(预约行 + booking)并列;不含 resource / duration / holder 等预约字段。
17
+ */
18
+ /**
19
+ * 解析 v2 主商品 source 价(不含 option、不含 bundle),供 SkuDetailModal / transform 使用。
20
+ */
21
+ function resolveSourceProductPrice(product, sourceProduct) {
22
+ var _price, _price2, _metadata$origin2, _metadata$origin3, _product$selling_pric;
23
+ var metadata = product.metadata || {};
24
+ if (metadata.source_product_price !== undefined && metadata.source_product_price !== null) {
25
+ var parsed = Number(metadata.source_product_price);
26
+ if (Number.isFinite(parsed)) return parsed;
27
+ }
28
+ var variantId = Number(product.product_variant_id || 0);
29
+ if (variantId > 0) {
30
+ var _variant, _metadata$origin;
31
+ var variantList = (_variant = (_metadata$origin = metadata.origin) === null || _metadata$origin === void 0 ? void 0 : _metadata$origin.variant) !== null && _variant !== void 0 ? _variant : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.variant;
32
+ if (Array.isArray(variantList)) {
33
+ var _matched$price;
34
+ var matched = variantList.find(function (v) {
35
+ return Number(v === null || v === void 0 ? void 0 : v.id) === variantId;
36
+ });
37
+ var variantPrice = (_matched$price = matched === null || matched === void 0 ? void 0 : matched.price) !== null && _matched$price !== void 0 ? _matched$price : matched === null || matched === void 0 ? void 0 : matched.base_price;
38
+ if (variantPrice !== undefined && variantPrice !== null) {
39
+ var _parsed = Number(variantPrice);
40
+ if (Number.isFinite(_parsed)) return _parsed;
41
+ }
42
+ }
43
+ }
44
+ var catalogPrice = (_price = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price !== void 0 ? _price : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price;
45
+ if (catalogPrice !== undefined && catalogPrice !== null) {
46
+ var _parsed2 = Number(catalogPrice);
47
+ if (Number.isFinite(_parsed2)) return _parsed2;
48
+ }
49
+ var originPrice = (_price2 = (_metadata$origin2 = metadata.origin) === null || _metadata$origin2 === void 0 ? void 0 : _metadata$origin2.price) !== null && _price2 !== void 0 ? _price2 : (_metadata$origin3 = metadata.origin) === null || _metadata$origin3 === void 0 ? void 0 : _metadata$origin3.base_price;
50
+ if (originPrice !== undefined && originPrice !== null) {
51
+ var _parsed3 = Number(originPrice);
52
+ if (Number.isFinite(_parsed3)) return _parsed3;
53
+ }
54
+ return Number((_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : 0);
55
+ }
56
+ export function buildNormalProductCacheItemFromOrderLine(input) {
57
+ var _product$product_id, _product$selling_pric2, _product$original_pri, _product$metadata, _product$product_vari, _product$num, _product$product_vari2, _product$num2, _title, _product$note, _price3, _product$order_detail;
58
+ var product = input.product,
59
+ sourceProduct = input.sourceProduct;
60
+ var resolvedId = (_product$product_id = product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.id;
61
+ var sourcePrice = resolveSourceProductPrice(product, sourceProduct);
62
+ var selling = Number((_product$selling_pric2 = product.selling_price) !== null && _product$selling_pric2 !== void 0 ? _product$selling_pric2 : 0);
63
+ var original = Number((_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : selling);
64
+ var uid = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.unique_identification_number;
65
+ var option = Array.isArray(product.product_option_item) ? _toConsumableArray(product.product_option_item) : [];
66
+ var bundle = Array.isArray(product.product_bundle) ? _toConsumableArray(product.product_bundle) : [];
67
+ var other = {
68
+ product_id: resolvedId,
69
+ product_variant_id: (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : 0,
70
+ option: option,
71
+ bundle: bundle,
72
+ quantity: (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : 1
73
+ };
74
+ var skuValue = {
75
+ product_id: resolvedId,
76
+ product_variant_id: (_product$product_vari2 = product.product_variant_id) !== null && _product$product_vari2 !== void 0 ? _product$product_vari2 : 0,
77
+ option: option,
78
+ bundle: bundle
79
+ };
80
+ var extend = {
81
+ quantity: (_product$num2 = product.num) !== null && _product$num2 !== void 0 ? _product$num2 : 1,
82
+ product_name: (_title = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) !== null && _title !== void 0 ? _title : '',
83
+ note: (_product$note = product.note) !== null && _product$note !== void 0 ? _product$note : '',
84
+ // v2:_extend.price 为主商品 source 价;行 composite 用 total / origin_total 展示
85
+ price: sourcePrice,
86
+ total: selling,
87
+ origin_total: original,
88
+ other: other,
89
+ skuValue: JSON.parse(JSON.stringify(skuValue)),
90
+ _skuValue: JSON.parse(JSON.stringify(skuValue)),
91
+ isNormalProduct: true
92
+ };
93
+ return _objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
94
+ id: resolvedId,
95
+ product_id: resolvedId,
96
+ _id: uid,
97
+ title: sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title,
98
+ price: (_price3 = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price3 !== void 0 ? _price3 : sourcePrice,
99
+ selling_price: product.selling_price,
100
+ original_price: product.original_price,
101
+ note: product.note,
102
+ order_detail_id: (_product$order_detail = product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : null,
103
+ new: 0,
104
+ autoClose: true,
105
+ _extend: extend
106
+ });
107
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * 把 info2 `cacheItem` 转换为 OS `addProductToOrder(product, booking)` 所需的 booking 入参。
3
+ *
4
+ * 协议严格对齐 `pisell_os/src/modules/Order/TEMP_ORDER_FIELDS_SUMMARY.md` 的 Bookings 章节:
5
+ * - 顶层只允许出现:schedule_event_id / appointment_status / start_date / start_time / end_date /
6
+ * end_time / select_date / duration / sub_type / like_status / number / resources / relation_forms /
7
+ * holder / metadata / is_all / schedule_id / relation_id / form_id / relation_type / product_uid
8
+ * - bookings[] 不允许出现 `_extend`
9
+ * - bookings[].metadata 走白名单:unique_identification_number / collect_pax / capacity / holder_id / resource_select_type
10
+ * - bookings[].resources[] 只接受协议白名单:form_id / relation_type / relation_id / capacity / like_status / metadata / children
11
+ *
12
+ * `product_uid` / `metadata.unique_identification_number` 不在这里生成:
13
+ * OS `addProductToOrder` 内的 `createLinkedProductAndBooking` 会在最终一步统一改写,
14
+ * 保证商品行 uid 与 booking root 唯一值始终对齐。
15
+ *
16
+ * 复杂 multi-day 展开(createBookingItemsByGroup / concatBookings)首版**不支持**,
17
+ * 由 UI 在 `cart.confirmDetail` 之外通过辅助 API 处理。
18
+ */
19
+ export interface CacheItemToBookingInputOptions {
20
+ /** booking config,用于推导 metadata.resource_select_type(默认从 cacheItem.\_data.resources[0].select_type.type 推断)。 */
21
+ bookingConfig?: any;
22
+ }
23
+ export interface BookingInput {
24
+ schedule_event_id?: number | string;
25
+ start_date?: string;
26
+ start_time?: string;
27
+ end_date?: string;
28
+ end_time?: string;
29
+ select_date?: string;
30
+ duration?: number;
31
+ sub_type?: 'days' | 'minutes' | string;
32
+ is_all?: 0 | 1;
33
+ number?: number;
34
+ holder?: any;
35
+ like_status?: string;
36
+ relation_forms?: any[];
37
+ resources?: BookingResourceInput[];
38
+ metadata?: BookingMetadataInput;
39
+ schedule_id?: number | string;
40
+ relation_id?: number | string;
41
+ form_id?: number | string;
42
+ relation_type?: string;
43
+ }
44
+ export interface BookingResourceInput {
45
+ form_id?: number | string;
46
+ relation_type?: string;
47
+ relation_id?: number | string;
48
+ capacity?: number;
49
+ like_status?: string;
50
+ metadata?: Record<string, any>;
51
+ children?: any[];
52
+ }
53
+ export interface BookingMetadataInput {
54
+ /** 由 OS createLinkedProductAndBooking 统一改写,这里不生成。 */
55
+ unique_identification_number?: string;
56
+ collect_pax?: number;
57
+ capacity?: number;
58
+ /** 协议要求始终提交(即使为 null)。 */
59
+ holder_id: any;
60
+ resource_select_type?: 'single' | 'multiple' | string;
61
+ }
62
+ /**
63
+ * 主入口。
64
+ */
65
+ export declare function cacheItemToBookingInput(cacheItem: any, options?: CacheItemToBookingInputOptions): BookingInput;
@@ -0,0 +1,191 @@
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 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; }
3
+ 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; }
4
+ 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; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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
+ import dayjs from 'dayjs';
8
+ import { isMultiDayProduct, isSessionProduct, getDays } from "./serviceTimes";
9
+ import { getSumCapacity } from "./resources";
10
+ import { flexibleObj } from "./flexible";
11
+
12
+ /**
13
+ * 把 info2 `cacheItem` 转换为 OS `addProductToOrder(product, booking)` 所需的 booking 入参。
14
+ *
15
+ * 协议严格对齐 `pisell_os/src/modules/Order/TEMP_ORDER_FIELDS_SUMMARY.md` 的 Bookings 章节:
16
+ * - 顶层只允许出现:schedule_event_id / appointment_status / start_date / start_time / end_date /
17
+ * end_time / select_date / duration / sub_type / like_status / number / resources / relation_forms /
18
+ * holder / metadata / is_all / schedule_id / relation_id / form_id / relation_type / product_uid
19
+ * - bookings[] 不允许出现 `_extend`
20
+ * - bookings[].metadata 走白名单:unique_identification_number / collect_pax / capacity / holder_id / resource_select_type
21
+ * - bookings[].resources[] 只接受协议白名单:form_id / relation_type / relation_id / capacity / like_status / metadata / children
22
+ *
23
+ * `product_uid` / `metadata.unique_identification_number` 不在这里生成:
24
+ * OS `addProductToOrder` 内的 `createLinkedProductAndBooking` 会在最终一步统一改写,
25
+ * 保证商品行 uid 与 booking root 唯一值始终对齐。
26
+ *
27
+ * 复杂 multi-day 展开(createBookingItemsByGroup / concatBookings)首版**不支持**,
28
+ * 由 UI 在 `cart.confirmDetail` 之外通过辅助 API 处理。
29
+ */
30
+
31
+ function safeFormat(value, fmt) {
32
+ if (value === undefined || value === null) return undefined;
33
+ var d = dayjs(value);
34
+ if (!d.isValid()) return undefined;
35
+ return d.format(fmt);
36
+ }
37
+
38
+ /** booking 协议 start_time / end_time:统一 HH:mm(不带秒)。 */
39
+ function normalizeTimeString(value) {
40
+ if (value === undefined || value === null) return undefined;
41
+ if (typeof value === 'string') {
42
+ var t = value.trim();
43
+ var hhmmFromHhmmss = t.match(/^(\d{1,2}:\d{2}):\d{2}$/);
44
+ if (hhmmFromHhmmss) return hhmmFromHhmmss[1];
45
+ if (/^\d{1,2}:\d{2}$/.test(t)) return t;
46
+ }
47
+ var d = dayjs(value);
48
+ if (d.isValid()) return d.format('HH:mm');
49
+ return undefined;
50
+ }
51
+ function resolveDurationMinutes(value) {
52
+ if (typeof value === 'number' && Number.isFinite(value)) return value;
53
+ if (typeof value !== 'string') return undefined;
54
+ if (flexibleObj.isFlexible(value)) return flexibleObj.getValue(value);
55
+ var n = Number(value);
56
+ return Number.isNaN(n) ? undefined : n;
57
+ }
58
+
59
+ /**
60
+ * cacheItem._extend.resource 形如 `{ [form_id]: [{ relation_id, form_id, like_status, metadata, children }] }`。
61
+ * 这里扁平化为符合协议的 resources[] 数组;id=0 的「无资源」占位行**保留**(与 info2 业务等价;协议 `relation_id=0` 合法)。
62
+ *
63
+ * 顶层 resources[].capacity 与 info2 `checkResourcesFormat` 一致:Σ capacity[].value(不含 quantity)。
64
+ */
65
+ function flattenResources(cacheItem) {
66
+ var _cacheItem$_extend;
67
+ var resourceMap = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.resource) || {};
68
+ var topLevelCapacity = getSumCapacity(cacheItem, false);
69
+ var result = [];
70
+ Object.values(resourceMap).forEach(function (arr) {
71
+ if (!Array.isArray(arr)) return;
72
+ arr.forEach(function (r) {
73
+ var item = {
74
+ form_id: r === null || r === void 0 ? void 0 : r.form_id,
75
+ relation_type: (r === null || r === void 0 ? void 0 : r.relation_type) || 'form',
76
+ relation_id: r === null || r === void 0 ? void 0 : r.relation_id,
77
+ capacity: topLevelCapacity
78
+ };
79
+ item.like_status = (r === null || r === void 0 ? void 0 : r.like_status) || 'common';
80
+ if ((r === null || r === void 0 ? void 0 : r.metadata) !== undefined) {
81
+ // 协议允许 metadata 自由透传;为了与 info2 行为等价,把 form_name / resource_name / combined_resource 一并保留。
82
+ item.metadata = _objectSpread({}, r.metadata);
83
+ }
84
+ if ((r === null || r === void 0 ? void 0 : r.children) !== undefined) item.children = r.children;
85
+ result.push(item);
86
+ });
87
+ });
88
+ return result;
89
+ }
90
+
91
+ /**
92
+ * 从 cacheItem 中派生 metadata.resource_select_type;优先级:
93
+ * 1. cacheItem._data.resources[0].select_type.type
94
+ * 2. cacheItem.product_resource.resources[0].select_type.type
95
+ * 3. 默认 undefined(由 OS / 后端兜底)。
96
+ */
97
+ function deriveResourceSelectType(cacheItem) {
98
+ var _cacheItem$_data, _cacheItem$product_re;
99
+ var localFirst = cacheItem === null || cacheItem === void 0 || (_cacheItem$_data = cacheItem._data) === null || _cacheItem$_data === void 0 || (_cacheItem$_data = _cacheItem$_data.resources) === null || _cacheItem$_data === void 0 || (_cacheItem$_data = _cacheItem$_data[0]) === null || _cacheItem$_data === void 0 || (_cacheItem$_data = _cacheItem$_data.select_type) === null || _cacheItem$_data === void 0 ? void 0 : _cacheItem$_data.type;
100
+ if (localFirst) return localFirst;
101
+ var productFirst = cacheItem === null || cacheItem === void 0 || (_cacheItem$product_re = cacheItem.product_resource) === null || _cacheItem$product_re === void 0 || (_cacheItem$product_re = _cacheItem$product_re.resources) === null || _cacheItem$product_re === void 0 || (_cacheItem$product_re = _cacheItem$product_re[0]) === null || _cacheItem$product_re === void 0 || (_cacheItem$product_re = _cacheItem$product_re.select_type) === null || _cacheItem$product_re === void 0 ? void 0 : _cacheItem$product_re.type;
102
+ if (productFirst) return productFirst;
103
+ return undefined;
104
+ }
105
+
106
+ /**
107
+ * 主入口。
108
+ */
109
+ export function cacheItemToBookingInput(cacheItem, options) {
110
+ var _ext$other, _options$bookingConfi;
111
+ if (!cacheItem) return {
112
+ metadata: {
113
+ holder_id: null
114
+ }
115
+ };
116
+ var ext = cacheItem._extend || {};
117
+ var isMultiDay = isMultiDayProduct(cacheItem) || ext.is_all === 1 || ext.sub_type === 'days';
118
+ var isSession = isSessionProduct(cacheItem);
119
+ var result = {};
120
+
121
+ // ──── 日期 / 时间 ───────────────────────────────────────────────
122
+ if (isSession && ext !== null && ext !== void 0 && (_ext$other = ext.other) !== null && _ext$other !== void 0 && _ext$other.session) {
123
+ var session = ext.other.session;
124
+ // 优先 _extend 上已按顶部 date 对齐过的起止(catalog cartDetailValue.session → applySessionTimesToExtend)
125
+ result.start_date = safeFormat(ext.start_date || ext.startDate || session.start_at, 'YYYY-MM-DD');
126
+ result.start_time = normalizeTimeString(ext.start_time) || normalizeTimeString(session.start_time) || safeFormat(session.start_at, 'HH:mm');
127
+ result.end_date = safeFormat(ext.end_date || ext.endDate || session.end_at, 'YYYY-MM-DD');
128
+ result.end_time = normalizeTimeString(ext.end_time) || normalizeTimeString(session.end_time) || safeFormat(session.end_at, 'HH:mm');
129
+ } else {
130
+ result.start_date = safeFormat(ext.start_date || ext.startDate, 'YYYY-MM-DD');
131
+ result.start_time = normalizeTimeString(ext.start_time) || safeFormat(ext.startDate, 'HH:mm');
132
+ result.end_date = safeFormat(ext.end_date || ext.endDate, 'YYYY-MM-DD');
133
+ result.end_time = normalizeTimeString(ext.end_time) || safeFormat(ext.endDate, 'HH:mm');
134
+ }
135
+
136
+ // ──── duration / sub_type / is_all ──────────────────────────────
137
+ if (isMultiDay) {
138
+ result.is_all = 1;
139
+ result.sub_type = 'days';
140
+ result.duration = Number(ext.duration) || getDays(cacheItem, 'days');
141
+ // 全天选择日期 = 起始日
142
+ if (result.start_date) result.select_date = result.start_date;
143
+ // 跨日结束时刻与开始一致(如 11:24),避免 endDate 仅日期落为 00:00
144
+ if (result.start_time && (!result.end_time || result.end_time === '00:00')) {
145
+ result.end_time = result.start_time;
146
+ }
147
+ } else {
148
+ result.is_all = 0;
149
+ result.sub_type = ext.sub_type || 'minutes';
150
+ var duration = resolveDurationMinutes(ext.duration);
151
+ if (duration !== undefined) result.duration = duration;
152
+ }
153
+
154
+ // ──── number(人数/容量占用) ───────────────────────────────────
155
+ result.number = getSumCapacity(cacheItem, true);
156
+
157
+ // ──── resources ─────────────────────────────────────────────────
158
+ result.resources = flattenResources(cacheItem);
159
+
160
+ // ──── holder / relation_forms / like_status / schedule_event_id ──
161
+ if (ext.holder !== undefined) result.holder = ext.holder;
162
+ if (Array.isArray(ext.relation_forms)) result.relation_forms = ext.relation_forms;
163
+ // 与 info2 booking/components/footer/utils formatBooking 一致:默认 common
164
+ result.like_status = ext.like_status || 'common';
165
+ if (cacheItem.schedule_event_id !== undefined) {
166
+ result.schedule_event_id = cacheItem.schedule_event_id;
167
+ }
168
+
169
+ // ──── metadata(严格白名单) ────────────────────────────────────
170
+ var metadata = {
171
+ holder_id: null
172
+ };
173
+ if (ext.holder_id !== undefined && ext.holder_id !== null) {
174
+ metadata.holder_id = ext.holder_id;
175
+ }
176
+ if (ext.collect_pax !== undefined) metadata.collect_pax = ext.collect_pax;
177
+ if (ext.capacity_snapshot !== undefined) {
178
+ metadata.capacity = ext.capacity_snapshot;
179
+ }
180
+ var selectType = deriveResourceSelectType(cacheItem) || (options === null || options === void 0 || (_options$bookingConfi = options.bookingConfig) === null || _options$bookingConfi === void 0 ? void 0 : _options$bookingConfi.resource_select_type);
181
+ if (selectType) metadata.resource_select_type = selectType;
182
+ // unique_identification_number 不在这里生成(由 OS createLinkedProductAndBooking 统一写)。
183
+ result.metadata = metadata;
184
+
185
+ // ──── booking root 占位字段(与 TEMP_ORDER_FIELDS_SUMMARY 一致) ──
186
+ result.schedule_id = 0;
187
+ result.relation_id = 0;
188
+ result.form_id = 0;
189
+ result.relation_type = '';
190
+ return result;
191
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * 灵活时长(flexible duration)协议工具。
3
+ *
4
+ * info2 用 `flexible_<minutes>` 字符串前缀标记"灵活时长",对外用同名 API 暴露 create / getValue / isFlexible / add。
5
+ * OS 这边一比一搬运,无外部依赖。
6
+ */
7
+ export declare const flexibleObj: {
8
+ create(num: number): string;
9
+ getValue(str: string | number): number;
10
+ isFlexible(str: string | number | undefined | null): boolean;
11
+ add(current: number | string, duration: number): string | number;
12
+ };
13
+ /**
14
+ * 取 duration 数值(兼容 number / { type, value } / 灵活时长字符串)。
15
+ * 与 info2 `getDuration` 行为等价。
16
+ */
17
+ /**
18
+ * 商品定义是否为「灵活时长」类型(仅看 product.duration 对象,不把 flexible_423 字符串当类型)。
19
+ * 与 info2 `getDuration({ type: 'flexible' }) === 'flexible'` 判定对齐。
20
+ */
21
+ export declare function isProductFlexibleDuration(duration: number | string | {
22
+ type: string;
23
+ value: number;
24
+ } | undefined | null): boolean;
25
+ export declare function getDurationValue(duration: number | string | {
26
+ type: string;
27
+ value: number;
28
+ } | undefined | null): number | 'flexible' | undefined;
@@ -0,0 +1,56 @@
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
+ /**
3
+ * 灵活时长(flexible duration)协议工具。
4
+ *
5
+ * info2 用 `flexible_<minutes>` 字符串前缀标记"灵活时长",对外用同名 API 暴露 create / getValue / isFlexible / add。
6
+ * OS 这边一比一搬运,无外部依赖。
7
+ */
8
+
9
+ var PREFIX = 'flexible_';
10
+ export var flexibleObj = {
11
+ create: function create(num) {
12
+ return "".concat(PREFIX).concat(num);
13
+ },
14
+ getValue: function getValue(str) {
15
+ if (typeof str === 'string' && flexibleObj.isFlexible(str)) {
16
+ return Number(str.replace(PREFIX, ''));
17
+ }
18
+ return Number(str);
19
+ },
20
+ isFlexible: function isFlexible(str) {
21
+ if (typeof str !== 'string') return false;
22
+ return str.indexOf(PREFIX) > -1;
23
+ },
24
+ add: function add(current, duration) {
25
+ if (flexibleObj.isFlexible(current)) {
26
+ return flexibleObj.create(flexibleObj.getValue(current) + duration);
27
+ }
28
+ return Number(current) + duration;
29
+ }
30
+ };
31
+
32
+ /**
33
+ * 取 duration 数值(兼容 number / { type, value } / 灵活时长字符串)。
34
+ * 与 info2 `getDuration` 行为等价。
35
+ */
36
+ /**
37
+ * 商品定义是否为「灵活时长」类型(仅看 product.duration 对象,不把 flexible_423 字符串当类型)。
38
+ * 与 info2 `getDuration({ type: 'flexible' }) === 'flexible'` 判定对齐。
39
+ */
40
+ export function isProductFlexibleDuration(duration) {
41
+ return Boolean(duration && _typeof(duration) === 'object' && duration.type === 'flexible');
42
+ }
43
+ export function getDurationValue(duration) {
44
+ if (duration === undefined || duration === null) return undefined;
45
+ if (typeof duration === 'number') return duration;
46
+ if (typeof duration === 'string') {
47
+ if (flexibleObj.isFlexible(duration)) return 'flexible';
48
+ return Number(duration);
49
+ }
50
+ if (_typeof(duration) === 'object') {
51
+ if (duration.type === 'minutes') return duration.value;
52
+ if (duration.type === 'flexible') return 'flexible';
53
+ if (duration.type === 'days') return duration.value;
54
+ }
55
+ return undefined;
56
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 将 `/schedule/resource/list` 原始数组格式化为 `list + listMap`。
3
+ * 逻辑与 info2 [`getFormatResourceListAndMap`] 对齐:追加无资源占位行、按 id 建 map。
4
+ */
5
+ export declare function formatResourceListAndMap(data: any[] | null | undefined, _bookingIds?: number[]): {
6
+ list: any[];
7
+ listMap: Record<string, any>;
8
+ };