@pisell/pisellos 2.2.173 → 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 (159) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/Customer/index.d.ts +0 -6
  3. package/dist/modules/Customer/index.js +83 -129
  4. package/dist/modules/Customer/types.d.ts +0 -2
  5. package/dist/modules/Discount/index.d.ts +4 -2
  6. package/dist/modules/Discount/index.js +93 -8
  7. package/dist/modules/Discount/types.d.ts +7 -1
  8. package/dist/modules/Order/index.d.ts +17 -33
  9. package/dist/modules/Order/index.js +395 -757
  10. package/dist/modules/Order/types.d.ts +17 -58
  11. package/dist/modules/Order/types.js +0 -2
  12. package/dist/modules/Order/utils.d.ts +1 -39
  13. package/dist/modules/Order/utils.js +31 -219
  14. package/dist/modules/Quotation/index.js +5 -16
  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.js +94 -113
  24. package/dist/server/modules/schedule/index.js +6 -13
  25. package/dist/solution/BaseSales/index.d.ts +7 -53
  26. package/dist/solution/BaseSales/index.js +339 -1160
  27. package/dist/solution/BaseSales/types.d.ts +1 -67
  28. package/dist/solution/BaseSales/types.js +1 -3
  29. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +15 -65
  30. package/dist/solution/BaseSales/utils.js +8 -46
  31. package/dist/solution/BookingByStep/index.d.ts +1 -1
  32. package/dist/solution/BookingTicket/index.d.ts +1 -133
  33. package/dist/solution/BookingTicket/index.js +175 -776
  34. package/dist/solution/BookingTicket/types.d.ts +0 -2
  35. package/dist/solution/BookingTicket/types.js +0 -3
  36. package/dist/solution/ScanOrder/index.d.ts +3 -9
  37. package/dist/solution/ScanOrder/index.js +128 -231
  38. package/dist/solution/ScanOrder/utils.js +8 -46
  39. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  40. package/dist/solution/ShopDiscount/index.js +23 -18
  41. package/dist/solution/VenueBooking/index.d.ts +9 -5
  42. package/dist/solution/VenueBooking/index.js +55 -103
  43. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  44. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
  45. package/lib/modules/Customer/index.d.ts +0 -6
  46. package/lib/modules/Customer/index.js +11 -26
  47. package/lib/modules/Customer/types.d.ts +0 -2
  48. package/lib/modules/Discount/index.d.ts +4 -2
  49. package/lib/modules/Discount/index.js +63 -8
  50. package/lib/modules/Discount/types.d.ts +7 -1
  51. package/lib/modules/Order/index.d.ts +17 -33
  52. package/lib/modules/Order/index.js +148 -402
  53. package/lib/modules/Order/types.d.ts +17 -58
  54. package/lib/modules/Order/utils.d.ts +1 -39
  55. package/lib/modules/Order/utils.js +22 -197
  56. package/lib/modules/Quotation/index.js +6 -17
  57. package/lib/modules/Rules/index.d.ts +0 -4
  58. package/lib/modules/Rules/index.js +14 -22
  59. package/lib/modules/SalesSummary/index.js +2 -4
  60. package/lib/modules/Schedule/index.js +1 -3
  61. package/lib/modules/index.d.ts +0 -1
  62. package/lib/modules/index.js +1 -3
  63. package/lib/server/index.js +0 -2
  64. package/lib/server/modules/order/utils/filterOrders.js +4 -12
  65. package/lib/server/modules/products/index.js +12 -23
  66. package/lib/server/modules/schedule/index.js +1 -2
  67. package/lib/solution/BaseSales/index.d.ts +7 -53
  68. package/lib/solution/BaseSales/index.js +20 -527
  69. package/lib/solution/BaseSales/types.d.ts +1 -67
  70. package/lib/solution/BaseSales/types.js +1 -3
  71. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +11 -70
  72. package/lib/solution/BaseSales/utils.js +6 -46
  73. package/lib/solution/BookingByStep/index.d.ts +1 -1
  74. package/lib/solution/BookingTicket/index.d.ts +1 -133
  75. package/lib/solution/BookingTicket/index.js +8 -349
  76. package/lib/solution/BookingTicket/types.d.ts +0 -2
  77. package/lib/solution/BookingTicket/types.js +0 -6
  78. package/lib/solution/ScanOrder/index.d.ts +3 -9
  79. package/lib/solution/ScanOrder/index.js +66 -147
  80. package/lib/solution/ScanOrder/utils.js +6 -46
  81. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  82. package/lib/solution/ShopDiscount/index.js +4 -2
  83. package/lib/solution/VenueBooking/index.d.ts +9 -5
  84. package/lib/solution/VenueBooking/index.js +14 -50
  85. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  86. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
  87. package/package.json +2 -2
  88. package/dist/modules/BookingContext/index.d.ts +0 -37
  89. package/dist/modules/BookingContext/index.js +0 -436
  90. package/dist/modules/BookingContext/types.d.ts +0 -102
  91. package/dist/modules/BookingContext/types.js +0 -51
  92. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  93. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -193
  94. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  95. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -137
  96. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  97. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -215
  98. package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
  99. package/dist/modules/BookingContext/utils/flexible.js +0 -56
  100. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  101. package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
  102. package/dist/modules/BookingContext/utils/index.d.ts +0 -11
  103. package/dist/modules/BookingContext/utils/index.js +0 -11
  104. package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
  105. package/dist/modules/BookingContext/utils/noResource.js +0 -77
  106. package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
  107. package/dist/modules/BookingContext/utils/productExtend.js +0 -339
  108. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  109. package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
  110. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  111. package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
  112. package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
  113. package/dist/modules/BookingContext/utils/resources.js +0 -486
  114. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  115. package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
  116. package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  117. package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
  118. package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  119. package/dist/modules/Order/utils/manualProductDiscount.js +0 -212
  120. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  121. package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
  122. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  123. package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
  124. package/lib/modules/BookingContext/index.d.ts +0 -37
  125. package/lib/modules/BookingContext/index.js +0 -297
  126. package/lib/modules/BookingContext/types.d.ts +0 -102
  127. package/lib/modules/BookingContext/types.js +0 -34
  128. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  129. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -207
  130. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  131. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -141
  132. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  133. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -198
  134. package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
  135. package/lib/modules/BookingContext/utils/flexible.js +0 -80
  136. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  137. package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
  138. package/lib/modules/BookingContext/utils/index.d.ts +0 -11
  139. package/lib/modules/BookingContext/utils/index.js +0 -43
  140. package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
  141. package/lib/modules/BookingContext/utils/noResource.js +0 -90
  142. package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
  143. package/lib/modules/BookingContext/utils/productExtend.js +0 -283
  144. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  145. package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
  146. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  147. package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
  148. package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
  149. package/lib/modules/BookingContext/utils/resources.js +0 -377
  150. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  151. package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
  152. package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  153. package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
  154. package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  155. package/lib/modules/Order/utils/manualProductDiscount.js +0 -207
  156. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  157. package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
  158. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  159. package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
@@ -1,237 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
- import dayjs from 'dayjs';
8
- import Decimal from 'decimal.js';
9
- function toFiniteNumber(value) {
10
- var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
11
- var parsedValue = Number(value);
12
- if (!Number.isFinite(parsedValue)) return fallback;
13
- return parsedValue;
14
- }
15
- function toPositiveInt(value) {
16
- var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
17
- var parsedValue = Math.floor(Number(value));
18
- if (!Number.isFinite(parsedValue) || parsedValue < 1) return fallback;
19
- return parsedValue;
20
- }
21
- function toPriceString(value) {
22
- return new Decimal(Number(value) || 0).toDecimalPlaces(2).toFixed(2);
23
- }
24
- function normalizeDateTime(value) {
25
- if (typeof value !== 'string' || !value.trim()) return null;
26
- var normalized = value.includes(':') ? value : "".concat(value, " 00:00:00");
27
- var datetime = dayjs(normalized);
28
- if (!datetime.isValid()) return null;
29
- return datetime;
30
- }
31
- function buildBookingDateTime(date, time) {
32
- if (typeof date !== 'string' || !date.trim()) return null;
33
- var timeText = typeof time === 'string' && time.trim() ? time.trim() : '00:00';
34
- var datetime = dayjs("".concat(date.trim(), " ").concat(timeText));
35
- if (!datetime.isValid()) return null;
36
- return datetime;
37
- }
38
- function getDurationUnit(type) {
39
- var normalizedType = String(type || '').toLowerCase();
40
- if (normalizedType === 'day' || normalizedType === 'days') return 'day';
41
- if (normalizedType === 'minute' || normalizedType === 'minutes') return 'minute';
42
- return null;
43
- }
44
- function getProductId(product) {
45
- var _product$product_id;
46
- var productId = toFiniteNumber((_product$product_id = product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product.id, NaN);
47
- if (!Number.isFinite(productId)) return null;
48
- return productId;
49
- }
50
- function getProductVariantId(product) {
51
- var _product$product_vari;
52
- var variantId = toFiniteNumber((_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : product.variant_id, 0);
53
- if (!Number.isFinite(variantId) || variantId <= 0) return undefined;
54
- return variantId;
55
- }
56
- function getFallbackPrice(params) {
57
- var _ref, _ref2, _ref3, _params$fallback_pric;
58
- var product = params.product || {};
59
- return toPriceString((_ref = (_ref2 = (_ref3 = (_params$fallback_pric = params.fallback_price) !== null && _params$fallback_pric !== void 0 ? _params$fallback_pric : product.price) !== null && _ref3 !== void 0 ? _ref3 : product.selling_price) !== null && _ref2 !== void 0 ? _ref2 : product.original_price) !== null && _ref !== void 0 ? _ref : 0);
60
- }
61
- function getProductQuantity(product) {
62
- var _product$num;
63
- return toPositiveInt((_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity, 1);
64
- }
65
- function getBundleProductId(bundle) {
66
- var _bundle$bundle_produc;
67
- var productId = toFiniteNumber((_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id, NaN);
68
- if (!Number.isFinite(productId)) return null;
69
- return productId;
70
- }
71
- function getBundleVariantId(bundle) {
72
- var _bundle$bundle_varian;
73
- var variantId = toFiniteNumber((_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle.variant_id, 0);
74
- if (!Number.isFinite(variantId) || variantId <= 0) return undefined;
75
- return variantId;
76
- }
77
- function getBundleFallbackPrice(bundle) {
78
- var _ref4, _ref5, _ref6, _bundle$bundle_sellin;
79
- return toPriceString((_ref4 = (_ref5 = (_ref6 = (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.price) !== null && _ref6 !== void 0 ? _ref6 : bundle.original_price) !== null && _ref5 !== void 0 ? _ref5 : bundle.base_price) !== null && _ref4 !== void 0 ? _ref4 : 0);
80
- }
81
- function shouldSplitByDuration(duration, start, end) {
82
- if (!duration) return false;
83
- if (!start || !end || !end.isAfter(start)) return false;
84
- var unit = getDurationUnit(duration.type);
85
- var value = toFiniteNumber(duration.value);
86
- return !!unit && value > 0;
87
- }
88
- function buildTimeSegments(params) {
89
- var booking = params.booking || {};
90
- var explicitDatetime = normalizeDateTime(params.datetime);
91
- var bookingStart = buildBookingDateTime(booking.start_date, booking.start_time);
92
- var start = bookingStart || explicitDatetime || dayjs();
93
- var bookingEnd = buildBookingDateTime(booking.end_date, booking.end_time);
94
- if (!shouldSplitByDuration(params.duration, start, bookingEnd)) {
95
- return [{
96
- start: start
97
- }];
98
- }
99
- var unit = getDurationUnit(params.duration.type);
100
- var value = toFiniteNumber(params.duration.value);
101
- var segments = [];
102
- var cursor = start;
103
- var guard = 0;
104
- while (cursor.isBefore(bookingEnd) && guard < 10000) {
105
- var next = cursor.add(value, unit);
106
- segments.push({
107
- start: cursor,
108
- end: next.isBefore(bookingEnd) ? next : bookingEnd !== null && bookingEnd !== void 0 ? bookingEnd : undefined
109
- });
110
- cursor = next;
111
- guard += 1;
112
- }
113
- return segments.length ? segments : [{
114
- start: start
115
- }];
116
- }
117
- function formatTimePoint(datetime) {
118
- return datetime.format('YYYY-MM-DD HH:mm:ss');
119
- }
120
- function buildPriceSegment(params) {
121
- var timePoint = formatTimePoint(params.segment.start);
122
- var quotedPrice = params.quotation && params.productId !== null ? params.quotation.getPriceForProduct({
123
- productId: params.productId,
124
- variantId: params.variantId,
125
- datetime: timePoint,
126
- customer_id: params.customerId
127
- }) : null;
128
- var unitPrice = toPriceString(quotedPrice !== null && quotedPrice !== void 0 ? quotedPrice : params.fallbackPrice);
129
- var quotationShelfId = quotedPrice !== null && params.quotation && params.productId !== null ? params.quotation.getQuotationShelfId({
130
- productId: params.productId,
131
- variantId: params.variantId,
132
- datetime: timePoint,
133
- customer_id: params.customerId
134
- }) : 0;
135
- return {
136
- start_datetime: timePoint,
137
- end_datetime: params.segment.end ? formatTimePoint(params.segment.end) : undefined,
138
- time_point: timePoint,
139
- unit_price: unitPrice,
140
- quantity: 1,
141
- total_price: unitPrice,
142
- quotation_shelf_id: quotationShelfId,
143
- source: quotedPrice !== null ? 'quotation' : 'fallback'
144
- };
145
- }
146
- function calculatePriceForProduct(params) {
147
- var _segments$find;
148
- var segments = params.segments.map(function (segment) {
149
- return buildPriceSegment({
150
- quotation: params.quotation,
151
- productId: params.productId,
152
- variantId: params.variantId,
153
- customerId: params.customerId,
154
- fallbackPrice: params.fallbackPrice,
155
- segment: segment
156
- });
157
- });
158
- var unitPrice = segments.reduce(function (total, segment) {
159
- return total.plus(segment.total_price);
160
- }, new Decimal(0));
161
- var totalPrice = unitPrice.times(params.quantity);
162
- var quotationShelfId = ((_segments$find = segments.find(function (segment) {
163
- return segment.quotation_shelf_id;
164
- })) === null || _segments$find === void 0 ? void 0 : _segments$find.quotation_shelf_id) || 0;
165
- return {
166
- unitPrice: unitPrice,
167
- totalPrice: totalPrice,
168
- quotationShelfId: quotationShelfId,
169
- segments: segments
170
- };
171
- }
172
- function calculateBundlePrices(params, segments) {
173
- var _params$product;
174
- var bundleList = ((_params$product = params.product) === null || _params$product === void 0 ? void 0 : _params$product.product_bundle) || [];
175
- if (!bundleList.length) return undefined;
176
- return bundleList.map(function (bundle) {
177
- var _bundle$bundle_id;
178
- var productId = getBundleProductId(bundle);
179
- var variantId = getBundleVariantId(bundle);
180
- var quantity = getProductQuantity(bundle);
181
- var price = calculatePriceForProduct({
182
- quotation: params.quotation,
183
- productId: productId,
184
- variantId: variantId,
185
- customerId: params.customer_id,
186
- quantity: quantity,
187
- fallbackPrice: getBundleFallbackPrice(bundle),
188
- segments: segments
189
- });
190
- return {
191
- bundle_id: (_bundle$bundle_id = bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle.id,
192
- group_id: bundle.group_id,
193
- bundle_group_id: bundle.bundle_group_id,
194
- bundle_product_id: productId,
195
- bundle_variant_id: variantId !== null && variantId !== void 0 ? variantId : 0,
196
- unit_price: price.unitPrice.toDecimalPlaces(2).toFixed(2),
197
- total_price: price.totalPrice.toDecimalPlaces(2).toFixed(2),
198
- quantity: quantity,
199
- quotation_shelf_id: price.quotationShelfId,
200
- source: price.segments.some(function (segment) {
201
- return segment.source === 'quotation';
202
- }) ? 'quotation' : 'fallback',
203
- segments: price.segments
204
- };
205
- });
206
- }
207
- export function calculateBaseSalesProductBookingPrice(params) {
208
- var product = params.product || {};
209
- var productId = getProductId(product);
210
- var variantId = getProductVariantId(product);
211
- var productQuantity = getProductQuantity(product);
212
- var fallbackPrice = getFallbackPrice(params);
213
- var timeSegments = buildTimeSegments(params);
214
- var price = calculatePriceForProduct({
215
- quotation: params.quotation,
216
- productId: productId,
217
- variantId: variantId,
218
- customerId: params.customer_id,
219
- quantity: productQuantity,
220
- fallbackPrice: fallbackPrice,
221
- segments: timeSegments
222
- });
223
- var bundlePrices = calculateBundlePrices(params, timeSegments);
224
- return _objectSpread({
225
- product_id: productId,
226
- product_variant_id: variantId !== null && variantId !== void 0 ? variantId : 0,
227
- customer_id: params.customer_id,
228
- unit_price: price.unitPrice.toDecimalPlaces(2).toFixed(2),
229
- total_price: price.totalPrice.toDecimalPlaces(2).toFixed(2),
230
- quantity: productQuantity,
231
- duration: params.duration,
232
- quotation_shelf_id: price.quotationShelfId,
233
- segments: price.segments
234
- }, bundlePrices ? {
235
- product_bundle: bundlePrices
236
- } : {});
237
- }
@@ -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
- };