@pisell/pisellos 2.2.162 → 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 (116) 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 +17 -6
  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/solution/BaseSales/index.d.ts +38 -7
  41. package/dist/solution/BaseSales/index.js +797 -310
  42. package/dist/solution/BaseSales/types.d.ts +48 -1
  43. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  44. package/dist/solution/BaseSales/utils/quotationPrice.js +159 -0
  45. package/dist/solution/BookingByStep/index.d.ts +2 -2
  46. package/dist/solution/BookingTicket/index.d.ts +121 -1
  47. package/dist/solution/BookingTicket/index.js +401 -72
  48. package/dist/solution/BookingTicket/types.d.ts +2 -0
  49. package/dist/solution/BookingTicket/types.js +3 -0
  50. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +111 -0
  51. package/dist/solution/BookingTicket/utils/addProductDecision.js +326 -0
  52. package/dist/solution/ScanOrder/index.d.ts +9 -3
  53. package/dist/solution/ScanOrder/index.js +231 -128
  54. package/dist/solution/VenueBooking/index.d.ts +4 -2
  55. package/dist/solution/VenueBooking/index.js +103 -55
  56. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  57. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
  58. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  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 +17 -6
  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/solution/BaseSales/index.d.ts +38 -7
  99. package/lib/solution/BaseSales/index.js +304 -14
  100. package/lib/solution/BaseSales/types.d.ts +48 -1
  101. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  102. package/lib/solution/BaseSales/utils/quotationPrice.js +201 -0
  103. package/lib/solution/BookingByStep/index.d.ts +2 -2
  104. package/lib/solution/BookingTicket/index.d.ts +121 -1
  105. package/lib/solution/BookingTicket/index.js +207 -2
  106. package/lib/solution/BookingTicket/types.d.ts +2 -0
  107. package/lib/solution/BookingTicket/types.js +6 -0
  108. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +111 -0
  109. package/lib/solution/BookingTicket/utils/addProductDecision.js +300 -0
  110. package/lib/solution/ScanOrder/index.d.ts +9 -3
  111. package/lib/solution/ScanOrder/index.js +147 -66
  112. package/lib/solution/VenueBooking/index.d.ts +4 -2
  113. package/lib/solution/VenueBooking/index.js +50 -14
  114. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  115. package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
  116. package/package.json +1 -1
@@ -0,0 +1,115 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.ts
20
+ var buildNormalProductCacheItemFromOrderLine_exports = {};
21
+ __export(buildNormalProductCacheItemFromOrderLine_exports, {
22
+ buildNormalProductCacheItemFromOrderLine: () => buildNormalProductCacheItemFromOrderLine
23
+ });
24
+ module.exports = __toCommonJS(buildNormalProductCacheItemFromOrderLine_exports);
25
+ function resolveSourceProductPrice(product, sourceProduct) {
26
+ var _a, _b, _c;
27
+ const metadata = product.metadata || {};
28
+ if (metadata.source_product_price !== void 0 && metadata.source_product_price !== null) {
29
+ const parsed = Number(metadata.source_product_price);
30
+ if (Number.isFinite(parsed))
31
+ return parsed;
32
+ }
33
+ const variantId = Number(product.product_variant_id || 0);
34
+ if (variantId > 0) {
35
+ const variantList = ((_a = metadata.origin) == null ? void 0 : _a.variant) ?? (sourceProduct == null ? void 0 : sourceProduct.variant);
36
+ if (Array.isArray(variantList)) {
37
+ const matched = variantList.find((v) => Number(v == null ? void 0 : v.id) === variantId);
38
+ const variantPrice = (matched == null ? void 0 : matched.price) ?? (matched == null ? void 0 : matched.base_price);
39
+ if (variantPrice !== void 0 && variantPrice !== null) {
40
+ const parsed = Number(variantPrice);
41
+ if (Number.isFinite(parsed))
42
+ return parsed;
43
+ }
44
+ }
45
+ }
46
+ const catalogPrice = (sourceProduct == null ? void 0 : sourceProduct.price) ?? (sourceProduct == null ? void 0 : sourceProduct.base_price);
47
+ if (catalogPrice !== void 0 && catalogPrice !== null) {
48
+ const parsed = Number(catalogPrice);
49
+ if (Number.isFinite(parsed))
50
+ return parsed;
51
+ }
52
+ const originPrice = ((_b = metadata.origin) == null ? void 0 : _b.price) ?? ((_c = metadata.origin) == null ? void 0 : _c.base_price);
53
+ if (originPrice !== void 0 && originPrice !== null) {
54
+ const parsed = Number(originPrice);
55
+ if (Number.isFinite(parsed))
56
+ return parsed;
57
+ }
58
+ return Number(product.selling_price ?? 0);
59
+ }
60
+ function buildNormalProductCacheItemFromOrderLine(input) {
61
+ var _a;
62
+ const { product, sourceProduct } = input;
63
+ const resolvedId = product.product_id ?? (sourceProduct == null ? void 0 : sourceProduct.id);
64
+ const sourcePrice = resolveSourceProductPrice(product, sourceProduct);
65
+ const selling = Number(product.selling_price ?? 0);
66
+ const original = Number(product.original_price ?? selling);
67
+ const uid = (_a = product.metadata) == null ? void 0 : _a.unique_identification_number;
68
+ const option = Array.isArray(product.product_option_item) ? [...product.product_option_item] : [];
69
+ const bundle = Array.isArray(product.product_bundle) ? [...product.product_bundle] : [];
70
+ const other = {
71
+ product_id: resolvedId,
72
+ product_variant_id: product.product_variant_id ?? 0,
73
+ option,
74
+ bundle,
75
+ quantity: product.num ?? 1
76
+ };
77
+ const skuValue = {
78
+ product_id: resolvedId,
79
+ product_variant_id: product.product_variant_id ?? 0,
80
+ option,
81
+ bundle
82
+ };
83
+ const extend = {
84
+ quantity: product.num ?? 1,
85
+ product_name: (sourceProduct == null ? void 0 : sourceProduct.title) ?? "",
86
+ note: product.note ?? "",
87
+ // v2:_extend.price 为主商品 source 价;行 composite 用 total / origin_total 展示
88
+ price: sourcePrice,
89
+ total: selling,
90
+ origin_total: original,
91
+ other,
92
+ skuValue: JSON.parse(JSON.stringify(skuValue)),
93
+ _skuValue: JSON.parse(JSON.stringify(skuValue)),
94
+ isNormalProduct: true
95
+ };
96
+ return {
97
+ ...sourceProduct || {},
98
+ id: resolvedId,
99
+ product_id: resolvedId,
100
+ _id: uid,
101
+ title: sourceProduct == null ? void 0 : sourceProduct.title,
102
+ price: (sourceProduct == null ? void 0 : sourceProduct.price) ?? sourcePrice,
103
+ selling_price: product.selling_price,
104
+ original_price: product.original_price,
105
+ note: product.note,
106
+ order_detail_id: product.order_detail_id ?? null,
107
+ new: 0,
108
+ autoClose: true,
109
+ _extend: extend
110
+ };
111
+ }
112
+ // Annotate the CommonJS export names for ESM import in node:
113
+ 0 && (module.exports = {
114
+ buildNormalProductCacheItemFromOrderLine
115
+ });
@@ -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,177 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/modules/BookingContext/utils/cacheItemToBookingInput.ts
30
+ var cacheItemToBookingInput_exports = {};
31
+ __export(cacheItemToBookingInput_exports, {
32
+ cacheItemToBookingInput: () => cacheItemToBookingInput
33
+ });
34
+ module.exports = __toCommonJS(cacheItemToBookingInput_exports);
35
+ var import_dayjs = __toESM(require("dayjs"));
36
+ var import_serviceTimes = require("./serviceTimes");
37
+ var import_resources = require("./resources");
38
+ var import_flexible = require("./flexible");
39
+ function safeFormat(value, fmt) {
40
+ if (value === void 0 || value === null)
41
+ return void 0;
42
+ const d = (0, import_dayjs.default)(value);
43
+ if (!d.isValid())
44
+ return void 0;
45
+ return d.format(fmt);
46
+ }
47
+ function normalizeTimeString(value) {
48
+ if (value === void 0 || value === null)
49
+ return void 0;
50
+ if (typeof value === "string") {
51
+ const t = value.trim();
52
+ const hhmmFromHhmmss = t.match(/^(\d{1,2}:\d{2}):\d{2}$/);
53
+ if (hhmmFromHhmmss)
54
+ return hhmmFromHhmmss[1];
55
+ if (/^\d{1,2}:\d{2}$/.test(t))
56
+ return t;
57
+ }
58
+ const d = (0, import_dayjs.default)(value);
59
+ if (d.isValid())
60
+ return d.format("HH:mm");
61
+ return void 0;
62
+ }
63
+ function resolveDurationMinutes(value) {
64
+ if (typeof value === "number" && Number.isFinite(value))
65
+ return value;
66
+ if (typeof value !== "string")
67
+ return void 0;
68
+ if (import_flexible.flexibleObj.isFlexible(value))
69
+ return import_flexible.flexibleObj.getValue(value);
70
+ const n = Number(value);
71
+ return Number.isNaN(n) ? void 0 : n;
72
+ }
73
+ function flattenResources(cacheItem) {
74
+ var _a;
75
+ const resourceMap = ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.resource) || {};
76
+ const topLevelCapacity = (0, import_resources.getSumCapacity)(cacheItem, false);
77
+ const result = [];
78
+ Object.values(resourceMap).forEach((arr) => {
79
+ if (!Array.isArray(arr))
80
+ return;
81
+ arr.forEach((r) => {
82
+ const item = {
83
+ form_id: r == null ? void 0 : r.form_id,
84
+ relation_type: (r == null ? void 0 : r.relation_type) || "form",
85
+ relation_id: r == null ? void 0 : r.relation_id,
86
+ capacity: topLevelCapacity
87
+ };
88
+ item.like_status = (r == null ? void 0 : r.like_status) || "common";
89
+ if ((r == null ? void 0 : r.metadata) !== void 0) {
90
+ item.metadata = { ...r.metadata };
91
+ }
92
+ if ((r == null ? void 0 : r.children) !== void 0)
93
+ item.children = r.children;
94
+ result.push(item);
95
+ });
96
+ });
97
+ return result;
98
+ }
99
+ function deriveResourceSelectType(cacheItem) {
100
+ var _a, _b, _c, _d, _e, _f, _g, _h;
101
+ const localFirst = (_d = (_c = (_b = (_a = cacheItem == null ? void 0 : cacheItem._data) == null ? void 0 : _a.resources) == null ? void 0 : _b[0]) == null ? void 0 : _c.select_type) == null ? void 0 : _d.type;
102
+ if (localFirst)
103
+ return localFirst;
104
+ const productFirst = (_h = (_g = (_f = (_e = cacheItem == null ? void 0 : cacheItem.product_resource) == null ? void 0 : _e.resources) == null ? void 0 : _f[0]) == null ? void 0 : _g.select_type) == null ? void 0 : _h.type;
105
+ if (productFirst)
106
+ return productFirst;
107
+ return void 0;
108
+ }
109
+ function cacheItemToBookingInput(cacheItem, options) {
110
+ var _a, _b;
111
+ if (!cacheItem)
112
+ return { metadata: { holder_id: null } };
113
+ const ext = cacheItem._extend || {};
114
+ const isMultiDay = (0, import_serviceTimes.isMultiDayProduct)(cacheItem) || ext.is_all === 1 || ext.sub_type === "days";
115
+ const isSession = (0, import_serviceTimes.isSessionProduct)(cacheItem);
116
+ const result = {};
117
+ if (isSession && ((_a = ext == null ? void 0 : ext.other) == null ? void 0 : _a.session)) {
118
+ const session = ext.other.session;
119
+ result.start_date = safeFormat(ext.start_date || ext.startDate || session.start_at, "YYYY-MM-DD");
120
+ result.start_time = normalizeTimeString(ext.start_time) || normalizeTimeString(session.start_time) || safeFormat(session.start_at, "HH:mm");
121
+ result.end_date = safeFormat(ext.end_date || ext.endDate || session.end_at, "YYYY-MM-DD");
122
+ result.end_time = normalizeTimeString(ext.end_time) || normalizeTimeString(session.end_time) || safeFormat(session.end_at, "HH:mm");
123
+ } else {
124
+ result.start_date = safeFormat(ext.start_date || ext.startDate, "YYYY-MM-DD");
125
+ result.start_time = normalizeTimeString(ext.start_time) || safeFormat(ext.startDate, "HH:mm");
126
+ result.end_date = safeFormat(ext.end_date || ext.endDate, "YYYY-MM-DD");
127
+ result.end_time = normalizeTimeString(ext.end_time) || safeFormat(ext.endDate, "HH:mm");
128
+ }
129
+ if (isMultiDay) {
130
+ result.is_all = 1;
131
+ result.sub_type = "days";
132
+ result.duration = Number(ext.duration) || (0, import_serviceTimes.getDays)(cacheItem, "days");
133
+ if (result.start_date)
134
+ result.select_date = result.start_date;
135
+ if (result.start_time && (!result.end_time || result.end_time === "00:00")) {
136
+ result.end_time = result.start_time;
137
+ }
138
+ } else {
139
+ result.is_all = 0;
140
+ result.sub_type = ext.sub_type || "minutes";
141
+ const duration = resolveDurationMinutes(ext.duration);
142
+ if (duration !== void 0)
143
+ result.duration = duration;
144
+ }
145
+ result.number = (0, import_resources.getSumCapacity)(cacheItem, true);
146
+ result.resources = flattenResources(cacheItem);
147
+ if (ext.holder !== void 0)
148
+ result.holder = ext.holder;
149
+ if (Array.isArray(ext.relation_forms))
150
+ result.relation_forms = ext.relation_forms;
151
+ result.like_status = ext.like_status || "common";
152
+ if (cacheItem.schedule_event_id !== void 0) {
153
+ result.schedule_event_id = cacheItem.schedule_event_id;
154
+ }
155
+ const metadata = { holder_id: null };
156
+ if (ext.holder_id !== void 0 && ext.holder_id !== null) {
157
+ metadata.holder_id = ext.holder_id;
158
+ }
159
+ if (ext.collect_pax !== void 0)
160
+ metadata.collect_pax = ext.collect_pax;
161
+ if (ext.capacity_snapshot !== void 0) {
162
+ metadata.capacity = ext.capacity_snapshot;
163
+ }
164
+ const selectType = deriveResourceSelectType(cacheItem) || ((_b = options == null ? void 0 : options.bookingConfig) == null ? void 0 : _b.resource_select_type);
165
+ if (selectType)
166
+ metadata.resource_select_type = selectType;
167
+ result.metadata = metadata;
168
+ result.schedule_id = 0;
169
+ result.relation_id = 0;
170
+ result.form_id = 0;
171
+ result.relation_type = "";
172
+ return result;
173
+ }
174
+ // Annotate the CommonJS export names for ESM import in node:
175
+ 0 && (module.exports = {
176
+ cacheItemToBookingInput
177
+ });
@@ -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,80 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/modules/BookingContext/utils/flexible.ts
20
+ var flexible_exports = {};
21
+ __export(flexible_exports, {
22
+ flexibleObj: () => flexibleObj,
23
+ getDurationValue: () => getDurationValue,
24
+ isProductFlexibleDuration: () => isProductFlexibleDuration
25
+ });
26
+ module.exports = __toCommonJS(flexible_exports);
27
+ var PREFIX = "flexible_";
28
+ var flexibleObj = {
29
+ create(num) {
30
+ return `${PREFIX}${num}`;
31
+ },
32
+ getValue(str) {
33
+ if (typeof str === "string" && flexibleObj.isFlexible(str)) {
34
+ return Number(str.replace(PREFIX, ""));
35
+ }
36
+ return Number(str);
37
+ },
38
+ isFlexible(str) {
39
+ if (typeof str !== "string")
40
+ return false;
41
+ return str.indexOf(PREFIX) > -1;
42
+ },
43
+ add(current, duration) {
44
+ if (flexibleObj.isFlexible(current)) {
45
+ return flexibleObj.create(flexibleObj.getValue(current) + duration);
46
+ }
47
+ return Number(current) + duration;
48
+ }
49
+ };
50
+ function isProductFlexibleDuration(duration) {
51
+ return Boolean(
52
+ duration && typeof duration === "object" && duration.type === "flexible"
53
+ );
54
+ }
55
+ function getDurationValue(duration) {
56
+ if (duration === void 0 || duration === null)
57
+ return void 0;
58
+ if (typeof duration === "number")
59
+ return duration;
60
+ if (typeof duration === "string") {
61
+ if (flexibleObj.isFlexible(duration))
62
+ return "flexible";
63
+ return Number(duration);
64
+ }
65
+ if (typeof duration === "object") {
66
+ if (duration.type === "minutes")
67
+ return duration.value;
68
+ if (duration.type === "flexible")
69
+ return "flexible";
70
+ if (duration.type === "days")
71
+ return duration.value;
72
+ }
73
+ return void 0;
74
+ }
75
+ // Annotate the CommonJS export names for ESM import in node:
76
+ 0 && (module.exports = {
77
+ flexibleObj,
78
+ getDurationValue,
79
+ isProductFlexibleDuration
80
+ });
@@ -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
+ };
@@ -0,0 +1,50 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/modules/BookingContext/utils/formatResourceList.ts
20
+ var formatResourceList_exports = {};
21
+ __export(formatResourceList_exports, {
22
+ formatResourceListAndMap: () => formatResourceListAndMap
23
+ });
24
+ module.exports = __toCommonJS(formatResourceList_exports);
25
+ var import_noResource = require("./noResource");
26
+ function formatResourceListAndMap(data, _bookingIds = []) {
27
+ const resourceList = (Array.isArray(data) ? data : []).concat([(0, import_noResource.getNoResource2)({})]);
28
+ const map = resourceList.reduce((prev, item) => {
29
+ if ((item == null ? void 0 : item.id) !== void 0 && (item == null ? void 0 : item.id) !== null) {
30
+ prev[String(item.id)] = item;
31
+ }
32
+ return prev;
33
+ }, {});
34
+ const getCapacity = (item) => item.capacity;
35
+ const list = resourceList.map((item) => {
36
+ const newItem = {
37
+ ...item,
38
+ capacity: getCapacity(item)
39
+ };
40
+ if (newItem.id !== void 0 && newItem.id !== null) {
41
+ map[String(newItem.id)] = newItem;
42
+ }
43
+ return newItem;
44
+ });
45
+ return { list, listMap: map };
46
+ }
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ formatResourceListAndMap
50
+ });
@@ -0,0 +1,11 @@
1
+ export * from './flexible';
2
+ export * from './serviceTimes';
3
+ export * from './timeSlices';
4
+ export * from './noResource';
5
+ export * from './resources';
6
+ export * from './resourceSelection';
7
+ export * from './resourceErrors';
8
+ export * from './productExtend';
9
+ export * from './cacheItemToBookingInput';
10
+ export * from './buildCacheItemFromOrderLine';
11
+ export * from './buildNormalProductCacheItemFromOrderLine';
@@ -0,0 +1,43 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/modules/BookingContext/utils/index.ts
17
+ var utils_exports = {};
18
+ module.exports = __toCommonJS(utils_exports);
19
+ __reExport(utils_exports, require("./flexible"), module.exports);
20
+ __reExport(utils_exports, require("./serviceTimes"), module.exports);
21
+ __reExport(utils_exports, require("./timeSlices"), module.exports);
22
+ __reExport(utils_exports, require("./noResource"), module.exports);
23
+ __reExport(utils_exports, require("./resources"), module.exports);
24
+ __reExport(utils_exports, require("./resourceSelection"), module.exports);
25
+ __reExport(utils_exports, require("./resourceErrors"), module.exports);
26
+ __reExport(utils_exports, require("./productExtend"), module.exports);
27
+ __reExport(utils_exports, require("./cacheItemToBookingInput"), module.exports);
28
+ __reExport(utils_exports, require("./buildCacheItemFromOrderLine"), module.exports);
29
+ __reExport(utils_exports, require("./buildNormalProductCacheItemFromOrderLine"), module.exports);
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ ...require("./flexible"),
33
+ ...require("./serviceTimes"),
34
+ ...require("./timeSlices"),
35
+ ...require("./noResource"),
36
+ ...require("./resources"),
37
+ ...require("./resourceSelection"),
38
+ ...require("./resourceErrors"),
39
+ ...require("./productExtend"),
40
+ ...require("./cacheItemToBookingInput"),
41
+ ...require("./buildCacheItemFromOrderLine"),
42
+ ...require("./buildNormalProductCacheItemFromOrderLine")
43
+ });
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 「无资源」占位资源行的数据骨架。
3
+ *
4
+ * 与 info2 [`booking/mock.ts#getNoResource2`] 一比一对齐,区别仅在于:
5
+ * - `main_field / room_name / labelText` 三个 i18n 文案字段在 OS 这边**置空**,
6
+ * 调用方(UI)在 `id === 0` 时自行渲染本地化的「无资源 / No resource」。
7
+ *
8
+ * 用途:`getResourceByIds` 在拼装 `optional_resource` 列表时,会在末尾 concat 一行此占位,
9
+ * 让用户能选择「不指定资源」。
10
+ */
11
+ export declare function getNoResource2(other?: {
12
+ form_id?: number | string;
13
+ } & Record<string, any>): any;