@pisell/pisellos 2.2.174 → 2.2.175

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 (162) 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 +17 -33
  8. package/dist/modules/Order/index.js +395 -757
  9. package/dist/modules/Order/types.d.ts +17 -58
  10. package/dist/modules/Order/types.js +0 -2
  11. package/dist/modules/Order/utils.d.ts +1 -39
  12. package/dist/modules/Order/utils.js +31 -220
  13. package/dist/modules/Quotation/index.d.ts +1 -0
  14. package/dist/modules/Quotation/index.js +21 -23
  15. package/dist/modules/Rules/index.d.ts +0 -4
  16. package/dist/modules/Rules/index.js +10 -26
  17. package/dist/modules/SalesSummary/index.js +2 -4
  18. package/dist/modules/Schedule/index.js +2 -6
  19. package/dist/modules/index.d.ts +0 -1
  20. package/dist/modules/index.js +1 -2
  21. package/dist/server/index.js +6 -10
  22. package/dist/server/modules/order/utils/filterOrders.js +6 -20
  23. package/dist/server/modules/products/index.d.ts +1 -1
  24. package/dist/server/modules/products/index.js +113 -130
  25. package/dist/server/modules/schedule/index.js +6 -13
  26. package/dist/solution/BaseSales/index.d.ts +7 -53
  27. package/dist/solution/BaseSales/index.js +340 -1165
  28. package/dist/solution/BaseSales/types.d.ts +1 -67
  29. package/dist/solution/BaseSales/types.js +1 -3
  30. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -68
  31. package/dist/solution/BaseSales/utils.js +8 -46
  32. package/dist/solution/BookingByStep/index.d.ts +1 -1
  33. package/dist/solution/BookingTicket/index.d.ts +1 -133
  34. package/dist/solution/BookingTicket/index.js +175 -776
  35. package/dist/solution/BookingTicket/types.d.ts +0 -2
  36. package/dist/solution/BookingTicket/types.js +0 -3
  37. package/dist/solution/ScanOrder/index.d.ts +3 -9
  38. package/dist/solution/ScanOrder/index.js +128 -231
  39. package/dist/solution/ScanOrder/utils.js +8 -46
  40. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  41. package/dist/solution/ShopDiscount/index.js +23 -18
  42. package/dist/solution/VenueBooking/index.d.ts +9 -5
  43. package/dist/solution/VenueBooking/index.js +55 -103
  44. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  45. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
  46. package/lib/modules/Customer/index.d.ts +0 -6
  47. package/lib/modules/Customer/index.js +11 -26
  48. package/lib/modules/Customer/types.d.ts +0 -2
  49. package/lib/modules/Discount/index.d.ts +4 -2
  50. package/lib/modules/Discount/index.js +63 -8
  51. package/lib/modules/Discount/types.d.ts +7 -1
  52. package/lib/modules/Order/index.d.ts +17 -33
  53. package/lib/modules/Order/index.js +148 -402
  54. package/lib/modules/Order/types.d.ts +17 -58
  55. package/lib/modules/Order/utils.d.ts +1 -39
  56. package/lib/modules/Order/utils.js +22 -198
  57. package/lib/modules/Quotation/index.d.ts +1 -0
  58. package/lib/modules/Quotation/index.js +15 -18
  59. package/lib/modules/Rules/index.d.ts +0 -4
  60. package/lib/modules/Rules/index.js +14 -22
  61. package/lib/modules/SalesSummary/index.js +2 -4
  62. package/lib/modules/Schedule/index.js +1 -3
  63. package/lib/modules/index.d.ts +0 -1
  64. package/lib/modules/index.js +1 -3
  65. package/lib/server/index.js +0 -2
  66. package/lib/server/modules/order/utils/filterOrders.js +4 -12
  67. package/lib/server/modules/products/index.d.ts +1 -1
  68. package/lib/server/modules/products/index.js +20 -30
  69. package/lib/server/modules/schedule/index.js +1 -2
  70. package/lib/solution/BaseSales/index.d.ts +7 -53
  71. package/lib/solution/BaseSales/index.js +22 -530
  72. package/lib/solution/BaseSales/types.d.ts +1 -67
  73. package/lib/solution/BaseSales/types.js +1 -3
  74. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +12 -71
  75. package/lib/solution/BaseSales/utils.js +6 -46
  76. package/lib/solution/BookingByStep/index.d.ts +1 -1
  77. package/lib/solution/BookingTicket/index.d.ts +1 -133
  78. package/lib/solution/BookingTicket/index.js +8 -349
  79. package/lib/solution/BookingTicket/types.d.ts +0 -2
  80. package/lib/solution/BookingTicket/types.js +0 -6
  81. package/lib/solution/ScanOrder/index.d.ts +3 -9
  82. package/lib/solution/ScanOrder/index.js +66 -147
  83. package/lib/solution/ScanOrder/utils.js +6 -46
  84. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  85. package/lib/solution/ShopDiscount/index.js +4 -2
  86. package/lib/solution/VenueBooking/index.d.ts +9 -5
  87. package/lib/solution/VenueBooking/index.js +14 -50
  88. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  89. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
  90. package/package.json +2 -2
  91. package/dist/modules/BookingContext/index.d.ts +0 -37
  92. package/dist/modules/BookingContext/index.js +0 -436
  93. package/dist/modules/BookingContext/types.d.ts +0 -102
  94. package/dist/modules/BookingContext/types.js +0 -51
  95. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  96. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -193
  97. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  98. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -137
  99. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  100. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -215
  101. package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
  102. package/dist/modules/BookingContext/utils/flexible.js +0 -56
  103. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  104. package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
  105. package/dist/modules/BookingContext/utils/index.d.ts +0 -11
  106. package/dist/modules/BookingContext/utils/index.js +0 -11
  107. package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
  108. package/dist/modules/BookingContext/utils/noResource.js +0 -77
  109. package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
  110. package/dist/modules/BookingContext/utils/productExtend.js +0 -339
  111. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  112. package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
  113. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  114. package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
  115. package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
  116. package/dist/modules/BookingContext/utils/resources.js +0 -486
  117. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  118. package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
  119. package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  120. package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
  121. package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  122. package/dist/modules/Order/utils/manualProductDiscount.js +0 -212
  123. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  124. package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
  125. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  126. package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
  127. package/lib/modules/BookingContext/index.d.ts +0 -37
  128. package/lib/modules/BookingContext/index.js +0 -297
  129. package/lib/modules/BookingContext/types.d.ts +0 -102
  130. package/lib/modules/BookingContext/types.js +0 -34
  131. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  132. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -207
  133. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  134. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -141
  135. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  136. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -198
  137. package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
  138. package/lib/modules/BookingContext/utils/flexible.js +0 -80
  139. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  140. package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
  141. package/lib/modules/BookingContext/utils/index.d.ts +0 -11
  142. package/lib/modules/BookingContext/utils/index.js +0 -43
  143. package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
  144. package/lib/modules/BookingContext/utils/noResource.js +0 -90
  145. package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
  146. package/lib/modules/BookingContext/utils/productExtend.js +0 -283
  147. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  148. package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
  149. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  150. package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
  151. package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
  152. package/lib/modules/BookingContext/utils/resources.js +0 -377
  153. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  154. package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
  155. package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  156. package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
  157. package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  158. package/lib/modules/Order/utils/manualProductDiscount.js +0 -207
  159. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  160. package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
  161. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  162. package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
@@ -1,277 +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/solution/BaseSales/utils/quotationPrice.ts
30
- var quotationPrice_exports = {};
31
- __export(quotationPrice_exports, {
32
- calculateBaseSalesProductBookingPrice: () => calculateBaseSalesProductBookingPrice
33
- });
34
- module.exports = __toCommonJS(quotationPrice_exports);
35
- var import_dayjs = __toESM(require("dayjs"));
36
- var import_decimal = __toESM(require("decimal.js"));
37
- function toFiniteNumber(value, fallback = 0) {
38
- const parsedValue = Number(value);
39
- if (!Number.isFinite(parsedValue))
40
- return fallback;
41
- return parsedValue;
42
- }
43
- function toPositiveInt(value, fallback = 1) {
44
- const parsedValue = Math.floor(Number(value));
45
- if (!Number.isFinite(parsedValue) || parsedValue < 1)
46
- return fallback;
47
- return parsedValue;
48
- }
49
- function toPriceString(value) {
50
- return new import_decimal.default(Number(value) || 0).toDecimalPlaces(2).toFixed(2);
51
- }
52
- function normalizeDateTime(value) {
53
- if (typeof value !== "string" || !value.trim())
54
- return null;
55
- const normalized = value.includes(":") ? value : `${value} 00:00:00`;
56
- const datetime = (0, import_dayjs.default)(normalized);
57
- if (!datetime.isValid())
58
- return null;
59
- return datetime;
60
- }
61
- function buildBookingDateTime(date, time) {
62
- if (typeof date !== "string" || !date.trim())
63
- return null;
64
- const timeText = typeof time === "string" && time.trim() ? time.trim() : "00:00";
65
- const datetime = (0, import_dayjs.default)(`${date.trim()} ${timeText}`);
66
- if (!datetime.isValid())
67
- return null;
68
- return datetime;
69
- }
70
- function getDurationUnit(type) {
71
- const normalizedType = String(type || "").toLowerCase();
72
- if (normalizedType === "day" || normalizedType === "days")
73
- return "day";
74
- if (normalizedType === "minute" || normalizedType === "minutes")
75
- return "minute";
76
- return null;
77
- }
78
- function getProductId(product) {
79
- const productId = toFiniteNumber(product.product_id ?? product.id, NaN);
80
- if (!Number.isFinite(productId))
81
- return null;
82
- return productId;
83
- }
84
- function getProductVariantId(product) {
85
- const variantId = toFiniteNumber(
86
- product.product_variant_id ?? product.variant_id,
87
- 0
88
- );
89
- if (!Number.isFinite(variantId) || variantId <= 0)
90
- return void 0;
91
- return variantId;
92
- }
93
- function getFallbackPrice(params) {
94
- const product = params.product || {};
95
- return toPriceString(
96
- params.fallback_price ?? product.price ?? product.selling_price ?? product.original_price ?? 0
97
- );
98
- }
99
- function getProductQuantity(product) {
100
- return toPositiveInt(product.num ?? product.quantity, 1);
101
- }
102
- function getBundleProductId(bundle) {
103
- const productId = toFiniteNumber(
104
- bundle.bundle_product_id ?? bundle._bundle_product_id,
105
- NaN
106
- );
107
- if (!Number.isFinite(productId))
108
- return null;
109
- return productId;
110
- }
111
- function getBundleVariantId(bundle) {
112
- const variantId = toFiniteNumber(
113
- bundle.bundle_variant_id ?? bundle.variant_id,
114
- 0
115
- );
116
- if (!Number.isFinite(variantId) || variantId <= 0)
117
- return void 0;
118
- return variantId;
119
- }
120
- function getBundleFallbackPrice(bundle) {
121
- return toPriceString(
122
- bundle.bundle_selling_price ?? bundle.price ?? bundle.original_price ?? bundle.base_price ?? 0
123
- );
124
- }
125
- function shouldSplitByDuration(duration, start, end) {
126
- if (!duration)
127
- return false;
128
- if (!start || !end || !end.isAfter(start))
129
- return false;
130
- const unit = getDurationUnit(duration.type);
131
- const value = toFiniteNumber(duration.value);
132
- return !!unit && value > 0;
133
- }
134
- function buildTimeSegments(params) {
135
- const booking = params.booking || {};
136
- const explicitDatetime = normalizeDateTime(params.datetime);
137
- const bookingStart = buildBookingDateTime(booking.start_date, booking.start_time);
138
- const start = bookingStart || explicitDatetime || (0, import_dayjs.default)();
139
- const bookingEnd = buildBookingDateTime(booking.end_date, booking.end_time);
140
- if (!shouldSplitByDuration(params.duration, start, bookingEnd)) {
141
- return [{ start }];
142
- }
143
- const unit = getDurationUnit(params.duration.type);
144
- const value = toFiniteNumber(params.duration.value);
145
- const segments = [];
146
- let cursor = start;
147
- let guard = 0;
148
- while (cursor.isBefore(bookingEnd) && guard < 1e4) {
149
- const next = cursor.add(value, unit);
150
- segments.push({
151
- start: cursor,
152
- end: next.isBefore(bookingEnd) ? next : bookingEnd ?? void 0
153
- });
154
- cursor = next;
155
- guard += 1;
156
- }
157
- return segments.length ? segments : [{ start }];
158
- }
159
- function formatTimePoint(datetime) {
160
- return datetime.format("YYYY-MM-DD HH:mm:ss");
161
- }
162
- function buildPriceSegment(params) {
163
- const timePoint = formatTimePoint(params.segment.start);
164
- const quotedPrice = params.quotation && params.productId !== null ? params.quotation.getPriceForProduct({
165
- productId: params.productId,
166
- variantId: params.variantId,
167
- datetime: timePoint,
168
- customer_id: params.customerId
169
- }) : null;
170
- const unitPrice = toPriceString(quotedPrice ?? params.fallbackPrice);
171
- const quotationShelfId = quotedPrice !== null && params.quotation && params.productId !== null ? params.quotation.getQuotationShelfId({
172
- productId: params.productId,
173
- variantId: params.variantId,
174
- datetime: timePoint,
175
- customer_id: params.customerId
176
- }) : 0;
177
- return {
178
- start_datetime: timePoint,
179
- end_datetime: params.segment.end ? formatTimePoint(params.segment.end) : void 0,
180
- time_point: timePoint,
181
- unit_price: unitPrice,
182
- quantity: 1,
183
- total_price: unitPrice,
184
- quotation_shelf_id: quotationShelfId,
185
- source: quotedPrice !== null ? "quotation" : "fallback"
186
- };
187
- }
188
- function calculatePriceForProduct(params) {
189
- var _a;
190
- const segments = params.segments.map((segment) => buildPriceSegment({
191
- quotation: params.quotation,
192
- productId: params.productId,
193
- variantId: params.variantId,
194
- customerId: params.customerId,
195
- fallbackPrice: params.fallbackPrice,
196
- segment
197
- }));
198
- const unitPrice = segments.reduce(
199
- (total, segment) => total.plus(segment.total_price),
200
- new import_decimal.default(0)
201
- );
202
- const totalPrice = unitPrice.times(params.quantity);
203
- const quotationShelfId = ((_a = segments.find((segment) => segment.quotation_shelf_id)) == null ? void 0 : _a.quotation_shelf_id) || 0;
204
- return {
205
- unitPrice,
206
- totalPrice,
207
- quotationShelfId,
208
- segments
209
- };
210
- }
211
- function calculateBundlePrices(params, segments) {
212
- var _a;
213
- const bundleList = ((_a = params.product) == null ? void 0 : _a.product_bundle) || [];
214
- if (!bundleList.length)
215
- return void 0;
216
- return bundleList.map((bundle) => {
217
- const productId = getBundleProductId(bundle);
218
- const variantId = getBundleVariantId(bundle);
219
- const quantity = getProductQuantity(bundle);
220
- const price = calculatePriceForProduct({
221
- quotation: params.quotation,
222
- productId,
223
- variantId,
224
- customerId: params.customer_id,
225
- quantity,
226
- fallbackPrice: getBundleFallbackPrice(bundle),
227
- segments
228
- });
229
- return {
230
- bundle_id: bundle.bundle_id ?? bundle.id,
231
- group_id: bundle.group_id,
232
- bundle_group_id: bundle.bundle_group_id,
233
- bundle_product_id: productId,
234
- bundle_variant_id: variantId ?? 0,
235
- unit_price: price.unitPrice.toDecimalPlaces(2).toFixed(2),
236
- total_price: price.totalPrice.toDecimalPlaces(2).toFixed(2),
237
- quantity,
238
- quotation_shelf_id: price.quotationShelfId,
239
- source: price.segments.some((segment) => segment.source === "quotation") ? "quotation" : "fallback",
240
- segments: price.segments
241
- };
242
- });
243
- }
244
- function calculateBaseSalesProductBookingPrice(params) {
245
- const product = params.product || {};
246
- const productId = getProductId(product);
247
- const variantId = getProductVariantId(product);
248
- const productQuantity = getProductQuantity(product);
249
- const fallbackPrice = getFallbackPrice(params);
250
- const timeSegments = buildTimeSegments(params);
251
- const price = calculatePriceForProduct({
252
- quotation: params.quotation,
253
- productId,
254
- variantId,
255
- customerId: params.customer_id,
256
- quantity: productQuantity,
257
- fallbackPrice,
258
- segments: timeSegments
259
- });
260
- const bundlePrices = calculateBundlePrices(params, timeSegments);
261
- return {
262
- product_id: productId,
263
- product_variant_id: variantId ?? 0,
264
- customer_id: params.customer_id,
265
- unit_price: price.unitPrice.toDecimalPlaces(2).toFixed(2),
266
- total_price: price.totalPrice.toDecimalPlaces(2).toFixed(2),
267
- quantity: productQuantity,
268
- duration: params.duration,
269
- quotation_shelf_id: price.quotationShelfId,
270
- segments: price.segments,
271
- ...bundlePrices ? { product_bundle: bundlePrices } : {}
272
- };
273
- }
274
- // Annotate the CommonJS export names for ESM import in node:
275
- 0 && (module.exports = {
276
- calculateBaseSalesProductBookingPrice
277
- });
@@ -1,113 +0,0 @@
1
- import { BookingCalcContext } from '../../../modules/BookingContext';
2
- import type { ProductData } from '../../../modules/Product/types';
3
- import type { OrderProduct, OrderProductIdentity, AddProductBookingInput } from '../../../modules/Order/types';
4
- /**
5
- * cart.addProduct 两阶段决策(与 ticketBooking `handleSelectProduct` 对齐):
6
- *
7
- * 1. `requiresDetail`:规格 / SKU / 套餐 / Session / 称重弹窗(门禁:`isOpenDetailModal` / `cartDetailValue` / `open_sold_weight`)
8
- * 2. `requiresBookingEdit`:资源 / 时间编辑抽屉(门禁:`getIsAutoClose` on prepared cacheItem)
9
- * 3. `add`:两关均通过,直接 transform + 加车
10
- */
11
- export type AddProductDecision = {
12
- action: 'add';
13
- cacheItem: any;
14
- } | {
15
- action: 'requiresDetail';
16
- payload: AddProductRequiresDetailPayload;
17
- } | {
18
- action: 'requiresBookingEdit';
19
- cacheItem: any;
20
- payload: AddProductRequiresBookingEditPayload;
21
- };
22
- /** 资源 / 时间编辑抽屉所需的最小 payload。 */
23
- export interface AddProductRequiresBookingEditPayload {
24
- cacheItem: any;
25
- customerId?: number | string;
26
- date: string | null;
27
- }
28
- /**
29
- * 加车主决策:对齐 `handleSelectProduct` 两段分支。
30
- */
31
- export declare function decideAddProduct(item: any, ctx?: AddProductDecideContext): AddProductDecision;
32
- /**
33
- * 规格弹窗 callback 后的第二段决策(对齐 `handleBooking4Service` 内 `cacheItem.autoClose` 分支)。
34
- */
35
- export declare function decideAfterDetail(cacheItem: any, ctx?: AddProductDecideContext): AddProductDecision;
36
- /**
37
- * @deprecated 请用 `decideAddProduct`;保留兼容:autoClose=true 仅表示可直接加车(action=add)。
38
- */
39
- export interface AddProductRequiresDetailPayload {
40
- item: ProductData | Record<string, any>;
41
- /** UI 需展示的子弹窗开关。 */
42
- showConfig: {
43
- option: boolean;
44
- session: boolean;
45
- variant: boolean;
46
- package: boolean;
47
- number: boolean;
48
- };
49
- /** 仅 session 商品(且无 variant/option/package)→ true,UI 可只渲染 session 选择。 */
50
- isOnlySession: boolean;
51
- /** 0/1,与 info2 `getIsEject` 等价含义。 */
52
- isEject: 0 | 1;
53
- /** 当前选中客户 id(透传给 detail 弹窗用)。 */
54
- customerId?: number | string;
55
- /** 当前选择的日期。 */
56
- date: string | null;
57
- /** 透传完整商品数据,UI 渲染时直接用。 */
58
- productData: ProductData | Record<string, any>;
59
- }
60
- export interface AddProductDecideContext extends BookingCalcContext {
61
- type?: 'select' | 'detail';
62
- quantity?: number;
63
- customerId?: number | string;
64
- }
65
- /**
66
- * 统一补齐预约商品的运行态字段。
67
- *
68
- * 新链路不再让决策和提交各自重建 cacheItem;这里作为唯一入口补齐
69
- * `_extend.resource / capacity / startDate / endDate` 等后续 booking mapper 需要的字段。
70
- */
71
- export declare function prepareBookingCacheItem(cacheItem: any, ctx?: AddProductDecideContext): any;
72
- export declare function decideAutoClose(item: any, ctx?: AddProductDecideContext): {
73
- autoClose: boolean;
74
- cacheItem?: any;
75
- };
76
- /**
77
- * 替代 info2 `getIsEject`:商品是否需要弹窗(含 type='detail' / option_group / bundle_group / variant / session / sold_by_weight)。
78
- */
79
- export declare function getIsEject(item: any, type?: 'select' | 'detail'): 0 | 1;
80
- /** 仅 session 商品(且没有 variant/option/package)。 */
81
- export declare function getIsOnlySession(item: any): boolean;
82
- /**
83
- * 拼装 requiresDetail payload;showConfig 与 info2 弹窗内部判断一致。
84
- */
85
- export declare function buildRequiresDetailPayload(item: any, ctx?: AddProductDecideContext): AddProductRequiresDetailPayload;
86
- /**
87
- * 用 item.cartDetailValue 拼装一个 cacheItem 雏形(与 info2 `handleDirectAddService` 等价路径)。
88
- * 这里只补 `_extend.start_date / quantity / other` 等运行态字段;后续走 getProductExtend 才会补齐资源 / 时间。
89
- */
90
- export declare function buildCacheItemFromCartDetail(item: any, ctx?: AddProductDecideContext): any;
91
- /**
92
- * 用 Info2 callback 的 (e, extension_type, detail) 拼装 cacheItem。
93
- *
94
- * 保留 detail._extend 中的 pricing / note(规格弹窗改价、备注等),
95
- * 再叠加 session 时间、ctx.quantity 等运行态字段;other 以 callback `e` 为准。
96
- */
97
- export declare function buildCacheItemFromDetail(item: any, detailResult: {
98
- e: any;
99
- extension_type?: any;
100
- detail?: any;
101
- }, ctx?: AddProductDecideContext): any;
102
- /**
103
- * `transformDetailToProductAndBooking`:把 cacheItem 拆成 OS `addProductToOrder` 所需的 `(product, booking)`。
104
- *
105
- * - `product` 走 `transformBaseProductToOrderProduct`(沿用 BaseSales 现有 mapper)。
106
- * - `booking` 走 `cacheItemToBookingInput`(严格按 TEMP_ORDER_FIELDS_SUMMARY.md 协议)。
107
- * - 普通商品(无 duration / 无 schedules)不产 booking,与 info2 一致。
108
- */
109
- export declare function transformDetailToProductAndBooking(cacheItem: any, ctx?: AddProductDecideContext): {
110
- product: Partial<OrderProduct> & OrderProductIdentity;
111
- booking?: AddProductBookingInput;
112
- cacheItem: any;
113
- };