@pisell/pisellos 2.2.169 → 2.2.171

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 (146) hide show
  1. package/dist/modules/Customer/index.d.ts +0 -6
  2. package/dist/modules/Customer/index.js +83 -129
  3. package/dist/modules/Customer/types.d.ts +0 -2
  4. package/dist/modules/Discount/index.d.ts +4 -2
  5. package/dist/modules/Discount/index.js +93 -8
  6. package/dist/modules/Discount/types.d.ts +7 -1
  7. package/dist/modules/Order/index.d.ts +16 -28
  8. package/dist/modules/Order/index.js +322 -695
  9. package/dist/modules/Order/types.d.ts +14 -49
  10. package/dist/modules/Order/types.js +0 -2
  11. package/dist/modules/Order/utils.d.ts +0 -17
  12. package/dist/modules/Order/utils.js +26 -96
  13. package/dist/modules/Rules/index.d.ts +0 -4
  14. package/dist/modules/Rules/index.js +10 -26
  15. package/dist/modules/SalesSummary/index.js +2 -4
  16. package/dist/modules/index.d.ts +0 -1
  17. package/dist/modules/index.js +1 -2
  18. package/dist/server/modules/order/utils/filterOrders.js +6 -20
  19. package/dist/solution/BaseSales/index.d.ts +7 -46
  20. package/dist/solution/BaseSales/index.js +315 -1009
  21. package/dist/solution/BaseSales/types.d.ts +1 -53
  22. package/dist/solution/BaseSales/types.js +1 -3
  23. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +15 -65
  24. package/dist/solution/BaseSales/utils.js +8 -46
  25. package/dist/solution/BookingTicket/index.d.ts +2 -134
  26. package/dist/solution/BookingTicket/index.js +175 -768
  27. package/dist/solution/BookingTicket/types.d.ts +0 -2
  28. package/dist/solution/BookingTicket/types.js +0 -3
  29. package/dist/solution/ScanOrder/index.d.ts +3 -9
  30. package/dist/solution/ScanOrder/index.js +128 -231
  31. package/dist/solution/ScanOrder/utils.js +8 -46
  32. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  33. package/dist/solution/ShopDiscount/index.js +23 -18
  34. package/dist/solution/VenueBooking/index.d.ts +9 -5
  35. package/dist/solution/VenueBooking/index.js +55 -103
  36. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  37. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
  38. package/lib/modules/Customer/index.d.ts +0 -6
  39. package/lib/modules/Customer/index.js +11 -26
  40. package/lib/modules/Customer/types.d.ts +0 -2
  41. package/lib/modules/Discount/index.d.ts +4 -2
  42. package/lib/modules/Discount/index.js +63 -8
  43. package/lib/modules/Discount/types.d.ts +7 -1
  44. package/lib/modules/Order/index.d.ts +16 -28
  45. package/lib/modules/Order/index.js +84 -336
  46. package/lib/modules/Order/types.d.ts +14 -49
  47. package/lib/modules/Order/utils.d.ts +0 -17
  48. package/lib/modules/Order/utils.js +18 -104
  49. package/lib/modules/Rules/index.d.ts +0 -4
  50. package/lib/modules/Rules/index.js +14 -22
  51. package/lib/modules/SalesSummary/index.js +2 -4
  52. package/lib/modules/index.d.ts +0 -1
  53. package/lib/modules/index.js +1 -3
  54. package/lib/server/modules/order/utils/filterOrders.js +4 -12
  55. package/lib/solution/BaseSales/index.d.ts +7 -46
  56. package/lib/solution/BaseSales/index.js +20 -434
  57. package/lib/solution/BaseSales/types.d.ts +1 -53
  58. package/lib/solution/BaseSales/types.js +1 -3
  59. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +11 -70
  60. package/lib/solution/BaseSales/utils.js +6 -46
  61. package/lib/solution/BookingTicket/index.d.ts +2 -134
  62. package/lib/solution/BookingTicket/index.js +8 -341
  63. package/lib/solution/BookingTicket/types.d.ts +0 -2
  64. package/lib/solution/BookingTicket/types.js +0 -6
  65. package/lib/solution/ScanOrder/index.d.ts +3 -9
  66. package/lib/solution/ScanOrder/index.js +66 -147
  67. package/lib/solution/ScanOrder/utils.js +6 -46
  68. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  69. package/lib/solution/ShopDiscount/index.js +4 -2
  70. package/lib/solution/VenueBooking/index.d.ts +9 -5
  71. package/lib/solution/VenueBooking/index.js +14 -50
  72. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  73. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
  74. package/package.json +2 -2
  75. package/dist/modules/BookingContext/index.d.ts +0 -37
  76. package/dist/modules/BookingContext/index.js +0 -436
  77. package/dist/modules/BookingContext/types.d.ts +0 -102
  78. package/dist/modules/BookingContext/types.js +0 -51
  79. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  80. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -193
  81. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  82. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -137
  83. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  84. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -215
  85. package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
  86. package/dist/modules/BookingContext/utils/flexible.js +0 -56
  87. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  88. package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
  89. package/dist/modules/BookingContext/utils/index.d.ts +0 -11
  90. package/dist/modules/BookingContext/utils/index.js +0 -11
  91. package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
  92. package/dist/modules/BookingContext/utils/noResource.js +0 -77
  93. package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
  94. package/dist/modules/BookingContext/utils/productExtend.js +0 -339
  95. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  96. package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
  97. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  98. package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
  99. package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
  100. package/dist/modules/BookingContext/utils/resources.js +0 -486
  101. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  102. package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
  103. package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  104. package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
  105. package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  106. package/dist/modules/Order/utils/manualProductDiscount.js +0 -212
  107. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  108. package/dist/solution/BaseSales/utils/quotationPrice.js +0 -159
  109. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  110. package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
  111. package/lib/modules/BookingContext/index.d.ts +0 -37
  112. package/lib/modules/BookingContext/index.js +0 -297
  113. package/lib/modules/BookingContext/types.d.ts +0 -102
  114. package/lib/modules/BookingContext/types.js +0 -34
  115. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  116. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -207
  117. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  118. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -141
  119. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  120. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -198
  121. package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
  122. package/lib/modules/BookingContext/utils/flexible.js +0 -80
  123. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  124. package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
  125. package/lib/modules/BookingContext/utils/index.d.ts +0 -11
  126. package/lib/modules/BookingContext/utils/index.js +0 -43
  127. package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
  128. package/lib/modules/BookingContext/utils/noResource.js +0 -90
  129. package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
  130. package/lib/modules/BookingContext/utils/productExtend.js +0 -283
  131. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  132. package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
  133. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  134. package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
  135. package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
  136. package/lib/modules/BookingContext/utils/resources.js +0 -377
  137. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  138. package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
  139. package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  140. package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
  141. package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  142. package/lib/modules/Order/utils/manualProductDiscount.js +0 -207
  143. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  144. package/lib/solution/BaseSales/utils/quotationPrice.js +0 -201
  145. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  146. package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
@@ -1,141 +0,0 @@
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 mapOrderBundleToOtherBundle(bundle) {
61
- return bundle.map((item) => {
62
- const catalogOriginal = item.original_price ?? item.product_price ?? item.price ?? item.bundle_selling_price;
63
- const selling = item.bundle_selling_price ?? item.price ?? catalogOriginal;
64
- const { bundle_selling_price: _omitBundleSelling, ...rest } = item;
65
- return {
66
- ...rest,
67
- price: selling,
68
- original_price: catalogOriginal,
69
- original_total: item.original_total ?? catalogOriginal,
70
- num: item.num ?? item.quantity ?? 1,
71
- quantity: item.quantity ?? item.num ?? 1
72
- };
73
- });
74
- }
75
- function buildNormalProductCacheItemFromOrderLine(input) {
76
- var _a, _b, _c, _d;
77
- const { product, sourceProduct } = input;
78
- const resolvedId = product.product_id ?? (sourceProduct == null ? void 0 : sourceProduct.id);
79
- const sourcePrice = resolveSourceProductPrice(product, sourceProduct);
80
- const selling = Number(product.selling_price ?? 0);
81
- const original = Number(product.original_price ?? selling);
82
- const uid = (_a = product.metadata) == null ? void 0 : _a.unique_identification_number;
83
- const option = Array.isArray(product.product_option_item) ? [...product.product_option_item] : [];
84
- const bundle = mapOrderBundleToOtherBundle(
85
- Array.isArray(product.product_bundle) ? product.product_bundle : []
86
- );
87
- const originExtend = (_c = (_b = product.metadata) == null ? void 0 : _b.origin) == null ? void 0 : _c._extend;
88
- const other = {
89
- product_id: resolvedId,
90
- product_variant_id: product.product_variant_id ?? 0,
91
- option,
92
- bundle: ((_d = originExtend == null ? void 0 : originExtend.other) == null ? void 0 : _d.bundle) ? JSON.parse(JSON.stringify(originExtend.other.bundle)) : bundle,
93
- quantity: product.num ?? 1
94
- };
95
- const skuValue = {
96
- product_id: resolvedId,
97
- product_variant_id: product.product_variant_id ?? 0,
98
- option: other.option,
99
- bundle: other.bundle
100
- };
101
- const extend = {
102
- quantity: product.num ?? 1,
103
- product_name: (sourceProduct == null ? void 0 : sourceProduct.title) ?? "",
104
- note: product.note ?? "",
105
- // v2:_extend.price 为主商品 source 价;行 composite 用 total / origin_total 展示
106
- price: (originExtend == null ? void 0 : originExtend.price) ?? sourcePrice,
107
- total: (originExtend == null ? void 0 : originExtend.total) ?? selling,
108
- origin_total: (originExtend == null ? void 0 : originExtend.origin_total) ?? original,
109
- other,
110
- skuValue: JSON.parse(JSON.stringify(skuValue)),
111
- _skuValue: JSON.parse(JSON.stringify(skuValue)),
112
- isNormalProduct: true,
113
- ...(originExtend == null ? void 0 : originExtend.priceOverride) !== void 0 ? { priceOverride: originExtend.priceOverride } : {},
114
- ...(originExtend == null ? void 0 : originExtend.bundle_edit) !== void 0 ? { bundle_edit: originExtend.bundle_edit } : {}
115
- };
116
- if ((originExtend == null ? void 0 : originExtend.skuValue) || (originExtend == null ? void 0 : originExtend._skuValue)) {
117
- extend.skuValue = JSON.parse(
118
- JSON.stringify(originExtend.skuValue || originExtend._skuValue)
119
- );
120
- extend._skuValue = JSON.parse(JSON.stringify(extend.skuValue));
121
- }
122
- return {
123
- ...sourceProduct || {},
124
- id: resolvedId,
125
- product_id: resolvedId,
126
- _id: uid,
127
- title: sourceProduct == null ? void 0 : sourceProduct.title,
128
- price: (sourceProduct == null ? void 0 : sourceProduct.price) ?? sourcePrice,
129
- selling_price: product.selling_price,
130
- original_price: product.original_price,
131
- note: product.note,
132
- order_detail_id: product.order_detail_id ?? null,
133
- new: 0,
134
- autoClose: true,
135
- _extend: extend
136
- };
137
- }
138
- // Annotate the CommonJS export names for ESM import in node:
139
- 0 && (module.exports = {
140
- buildNormalProductCacheItemFromOrderLine
141
- });
@@ -1,75 +0,0 @@
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
- /** custom / package 人数维度快照,与 info2 `_extend.capacity` / `metadata.capacity` 对齐。 */
54
- export interface BookingCapacityMetadataItem {
55
- id: string | number;
56
- value: number;
57
- name?: Record<string, any> | string;
58
- }
59
- export interface BookingMetadataInput {
60
- /** 由 OS createLinkedProductAndBooking 统一改写,这里不生成。 */
61
- unique_identification_number?: string;
62
- collect_pax?: number;
63
- /**
64
- * 资源容量快照:custom 多维度时为 `{ id, value, name? }[]`;
65
- * 仅总和场景可为 number(capacity_snapshot 兼容)。
66
- */
67
- capacity?: number | BookingCapacityMetadataItem[];
68
- /** 协议要求始终提交(即使为 null)。 */
69
- holder_id: any;
70
- resource_select_type?: 'single' | 'multiple' | string;
71
- }
72
- /**
73
- * 主入口。
74
- */
75
- export declare function cacheItemToBookingInput(cacheItem: any, options?: CacheItemToBookingInputOptions): BookingInput;
@@ -1,198 +0,0 @@
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 normalizeExtendCapacityForMetadata(capacity) {
40
- if (!Array.isArray(capacity) || capacity.length === 0)
41
- return void 0;
42
- const normalized = capacity.map((item) => {
43
- if (!item || typeof item !== "object")
44
- return null;
45
- if (item.id === void 0 || item.id === null)
46
- return null;
47
- const row = {
48
- id: item.id,
49
- value: Number(item.value ?? 0)
50
- };
51
- if (item.name !== void 0)
52
- row.name = item.name;
53
- return row;
54
- }).filter((item) => item != null);
55
- return normalized.length > 0 ? normalized : void 0;
56
- }
57
- function safeFormat(value, fmt) {
58
- if (value === void 0 || value === null)
59
- return void 0;
60
- const d = (0, import_dayjs.default)(value);
61
- if (!d.isValid())
62
- return void 0;
63
- return d.format(fmt);
64
- }
65
- function normalizeTimeString(value) {
66
- if (value === void 0 || value === null)
67
- return void 0;
68
- if (typeof value === "string") {
69
- const t = value.trim();
70
- const hhmmFromHhmmss = t.match(/^(\d{1,2}:\d{2}):\d{2}$/);
71
- if (hhmmFromHhmmss)
72
- return hhmmFromHhmmss[1];
73
- if (/^\d{1,2}:\d{2}$/.test(t))
74
- return t;
75
- }
76
- const d = (0, import_dayjs.default)(value);
77
- if (d.isValid())
78
- return d.format("HH:mm");
79
- return void 0;
80
- }
81
- function resolveDurationMinutes(value) {
82
- if (typeof value === "number" && Number.isFinite(value))
83
- return value;
84
- if (typeof value !== "string")
85
- return void 0;
86
- if (import_flexible.flexibleObj.isFlexible(value))
87
- return import_flexible.flexibleObj.getValue(value);
88
- const n = Number(value);
89
- return Number.isNaN(n) ? void 0 : n;
90
- }
91
- function flattenResources(cacheItem) {
92
- var _a;
93
- const resourceMap = ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.resource) || {};
94
- const topLevelCapacity = (0, import_resources.getSumCapacity)(cacheItem, false);
95
- const result = [];
96
- Object.values(resourceMap).forEach((arr) => {
97
- if (!Array.isArray(arr))
98
- return;
99
- arr.forEach((r) => {
100
- const item = {
101
- form_id: r == null ? void 0 : r.form_id,
102
- relation_type: (r == null ? void 0 : r.relation_type) || "form",
103
- relation_id: r == null ? void 0 : r.relation_id,
104
- capacity: topLevelCapacity
105
- };
106
- item.like_status = (r == null ? void 0 : r.like_status) || "common";
107
- if ((r == null ? void 0 : r.metadata) !== void 0) {
108
- item.metadata = { ...r.metadata };
109
- }
110
- if ((r == null ? void 0 : r.children) !== void 0)
111
- item.children = r.children;
112
- result.push(item);
113
- });
114
- });
115
- return result;
116
- }
117
- function deriveResourceSelectType(cacheItem) {
118
- var _a, _b, _c, _d, _e, _f, _g, _h;
119
- 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;
120
- if (localFirst)
121
- return localFirst;
122
- 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;
123
- if (productFirst)
124
- return productFirst;
125
- return void 0;
126
- }
127
- function cacheItemToBookingInput(cacheItem, options) {
128
- var _a, _b;
129
- if (!cacheItem)
130
- return { metadata: { holder_id: null } };
131
- const ext = cacheItem._extend || {};
132
- const isMultiDay = (0, import_serviceTimes.isMultiDayProduct)(cacheItem) || ext.is_all === 1 || ext.sub_type === "days";
133
- const isSession = (0, import_serviceTimes.isSessionProduct)(cacheItem);
134
- const result = {};
135
- if (isSession && ((_a = ext == null ? void 0 : ext.other) == null ? void 0 : _a.session)) {
136
- const session = ext.other.session;
137
- result.start_date = safeFormat(ext.start_date || ext.startDate || session.start_at, "YYYY-MM-DD");
138
- result.start_time = normalizeTimeString(ext.start_time) || normalizeTimeString(session.start_time) || safeFormat(session.start_at, "HH:mm");
139
- result.end_date = safeFormat(ext.end_date || ext.endDate || session.end_at, "YYYY-MM-DD");
140
- result.end_time = normalizeTimeString(ext.end_time) || normalizeTimeString(session.end_time) || safeFormat(session.end_at, "HH:mm");
141
- } else {
142
- result.start_date = safeFormat(ext.start_date || ext.startDate, "YYYY-MM-DD");
143
- result.start_time = normalizeTimeString(ext.start_time) || safeFormat(ext.startDate, "HH:mm");
144
- result.end_date = safeFormat(ext.end_date || ext.endDate, "YYYY-MM-DD");
145
- result.end_time = normalizeTimeString(ext.end_time) || safeFormat(ext.endDate, "HH:mm");
146
- }
147
- if (isMultiDay) {
148
- result.is_all = 1;
149
- result.sub_type = "days";
150
- result.duration = Number(ext.duration) || (0, import_serviceTimes.getDays)(cacheItem, "days");
151
- if (result.start_date)
152
- result.select_date = result.start_date;
153
- if (result.start_time && (!result.end_time || result.end_time === "00:00")) {
154
- result.end_time = result.start_time;
155
- }
156
- } else {
157
- result.is_all = 0;
158
- result.sub_type = ext.sub_type || "minutes";
159
- const duration = resolveDurationMinutes(ext.duration);
160
- if (duration !== void 0)
161
- result.duration = duration;
162
- }
163
- result.number = (0, import_resources.getSumCapacity)(cacheItem, true);
164
- result.resources = flattenResources(cacheItem);
165
- if (ext.holder !== void 0)
166
- result.holder = ext.holder;
167
- if (Array.isArray(ext.relation_forms))
168
- result.relation_forms = ext.relation_forms;
169
- result.like_status = ext.like_status || "common";
170
- if (cacheItem.schedule_event_id !== void 0) {
171
- result.schedule_event_id = cacheItem.schedule_event_id;
172
- }
173
- const metadata = { holder_id: null };
174
- if (ext.holder_id !== void 0 && ext.holder_id !== null) {
175
- metadata.holder_id = ext.holder_id;
176
- }
177
- if (ext.collect_pax !== void 0)
178
- metadata.collect_pax = ext.collect_pax;
179
- const extendCapacity = normalizeExtendCapacityForMetadata(ext.capacity);
180
- if (extendCapacity) {
181
- metadata.capacity = extendCapacity;
182
- } else if (ext.capacity_snapshot !== void 0) {
183
- metadata.capacity = ext.capacity_snapshot;
184
- }
185
- const selectType = deriveResourceSelectType(cacheItem) || ((_b = options == null ? void 0 : options.bookingConfig) == null ? void 0 : _b.resource_select_type);
186
- if (selectType)
187
- metadata.resource_select_type = selectType;
188
- result.metadata = metadata;
189
- result.schedule_id = 0;
190
- result.relation_id = 0;
191
- result.form_id = 0;
192
- result.relation_type = "";
193
- return result;
194
- }
195
- // Annotate the CommonJS export names for ESM import in node:
196
- 0 && (module.exports = {
197
- cacheItemToBookingInput
198
- });
@@ -1,28 +0,0 @@
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;
@@ -1,80 +0,0 @@
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
- });
@@ -1,8 +0,0 @@
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
- };
@@ -1,50 +0,0 @@
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
- });
@@ -1,11 +0,0 @@
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';
@@ -1,43 +0,0 @@
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
- });
@@ -1,13 +0,0 @@
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;