@pisell/pisellos 2.2.178 → 2.2.179

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 (182) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  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 +18 -88
  9. package/dist/modules/Order/index.js +501 -1357
  10. package/dist/modules/Order/types.d.ts +19 -198
  11. package/dist/modules/Order/types.js +0 -31
  12. package/dist/modules/Order/utils.d.ts +1 -50
  13. package/dist/modules/Order/utils.js +32 -261
  14. package/dist/modules/Quotation/index.d.ts +1 -0
  15. package/dist/modules/Quotation/index.js +21 -23
  16. package/dist/modules/Rules/index.d.ts +0 -4
  17. package/dist/modules/Rules/index.js +10 -26
  18. package/dist/modules/SalesSummary/index.js +2 -4
  19. package/dist/modules/SalesSummary/utils.js +7 -21
  20. package/dist/modules/Schedule/index.js +2 -6
  21. package/dist/modules/index.d.ts +0 -1
  22. package/dist/modules/index.js +1 -2
  23. package/dist/server/index.js +29 -87
  24. package/dist/server/modules/order/index.d.ts +0 -23
  25. package/dist/server/modules/order/index.js +46 -123
  26. package/dist/server/modules/order/types.d.ts +2 -0
  27. package/dist/server/modules/order/utils/filterOrders.js +6 -20
  28. package/dist/server/modules/products/index.d.ts +1 -1
  29. package/dist/server/modules/products/index.js +113 -130
  30. package/dist/server/modules/schedule/index.js +6 -13
  31. package/dist/solution/BaseSales/index.d.ts +7 -89
  32. package/dist/solution/BaseSales/index.js +375 -1494
  33. package/dist/solution/BaseSales/types.d.ts +1 -67
  34. package/dist/solution/BaseSales/types.js +1 -3
  35. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
  36. package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
  37. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -68
  38. package/dist/solution/BaseSales/utils.js +8 -46
  39. package/dist/solution/BookingByStep/index.d.ts +1 -1
  40. package/dist/solution/BookingTicket/index.d.ts +1 -133
  41. package/dist/solution/BookingTicket/index.js +175 -780
  42. package/dist/solution/BookingTicket/types.d.ts +0 -2
  43. package/dist/solution/BookingTicket/types.js +0 -3
  44. package/dist/solution/BookingTicket/utils/cartView.js +2 -4
  45. package/dist/solution/ScanOrder/index.d.ts +3 -9
  46. package/dist/solution/ScanOrder/index.js +128 -231
  47. package/dist/solution/ScanOrder/utils.js +8 -46
  48. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  49. package/dist/solution/ShopDiscount/index.js +23 -18
  50. package/dist/solution/VenueBooking/index.d.ts +9 -5
  51. package/dist/solution/VenueBooking/index.js +55 -103
  52. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  53. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
  54. package/lib/modules/Customer/index.d.ts +0 -6
  55. package/lib/modules/Customer/index.js +11 -26
  56. package/lib/modules/Customer/types.d.ts +0 -2
  57. package/lib/modules/Discount/index.d.ts +4 -2
  58. package/lib/modules/Discount/index.js +63 -8
  59. package/lib/modules/Discount/types.d.ts +7 -1
  60. package/lib/modules/Order/index.d.ts +18 -88
  61. package/lib/modules/Order/index.js +149 -677
  62. package/lib/modules/Order/types.d.ts +19 -198
  63. package/lib/modules/Order/types.js +0 -1
  64. package/lib/modules/Order/utils.d.ts +1 -50
  65. package/lib/modules/Order/utils.js +22 -229
  66. package/lib/modules/Quotation/index.d.ts +1 -0
  67. package/lib/modules/Quotation/index.js +15 -18
  68. package/lib/modules/Rules/index.d.ts +0 -4
  69. package/lib/modules/Rules/index.js +14 -22
  70. package/lib/modules/SalesSummary/index.js +2 -4
  71. package/lib/modules/SalesSummary/utils.js +7 -21
  72. package/lib/modules/Schedule/index.js +1 -3
  73. package/lib/modules/index.d.ts +0 -1
  74. package/lib/modules/index.js +1 -3
  75. package/lib/server/index.js +4 -41
  76. package/lib/server/modules/order/index.d.ts +0 -23
  77. package/lib/server/modules/order/index.js +14 -46
  78. package/lib/server/modules/order/types.d.ts +2 -0
  79. package/lib/server/modules/order/utils/filterOrders.js +4 -12
  80. package/lib/server/modules/products/index.d.ts +1 -1
  81. package/lib/server/modules/products/index.js +20 -30
  82. package/lib/server/modules/schedule/index.js +1 -2
  83. package/lib/solution/BaseSales/index.d.ts +7 -89
  84. package/lib/solution/BaseSales/index.js +22 -736
  85. package/lib/solution/BaseSales/types.d.ts +1 -67
  86. package/lib/solution/BaseSales/types.js +1 -3
  87. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
  88. package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -0
  89. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +12 -71
  90. package/lib/solution/BaseSales/utils.js +6 -46
  91. package/lib/solution/BookingByStep/index.d.ts +1 -1
  92. package/lib/solution/BookingTicket/index.d.ts +1 -133
  93. package/lib/solution/BookingTicket/index.js +8 -352
  94. package/lib/solution/BookingTicket/types.d.ts +0 -2
  95. package/lib/solution/BookingTicket/types.js +0 -6
  96. package/lib/solution/BookingTicket/utils/cartView.js +2 -4
  97. package/lib/solution/ScanOrder/index.d.ts +3 -9
  98. package/lib/solution/ScanOrder/index.js +66 -147
  99. package/lib/solution/ScanOrder/utils.js +6 -46
  100. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  101. package/lib/solution/ShopDiscount/index.js +4 -2
  102. package/lib/solution/VenueBooking/index.d.ts +9 -5
  103. package/lib/solution/VenueBooking/index.js +14 -50
  104. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  105. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
  106. package/package.json +2 -2
  107. package/dist/modules/BookingContext/index.d.ts +0 -37
  108. package/dist/modules/BookingContext/index.js +0 -436
  109. package/dist/modules/BookingContext/types.d.ts +0 -102
  110. package/dist/modules/BookingContext/types.js +0 -51
  111. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  112. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -193
  113. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  114. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -137
  115. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  116. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -215
  117. package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
  118. package/dist/modules/BookingContext/utils/flexible.js +0 -56
  119. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  120. package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
  121. package/dist/modules/BookingContext/utils/index.d.ts +0 -11
  122. package/dist/modules/BookingContext/utils/index.js +0 -11
  123. package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
  124. package/dist/modules/BookingContext/utils/noResource.js +0 -77
  125. package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
  126. package/dist/modules/BookingContext/utils/productExtend.js +0 -339
  127. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  128. package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
  129. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  130. package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
  131. package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
  132. package/dist/modules/BookingContext/utils/resources.js +0 -486
  133. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  134. package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
  135. package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  136. package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
  137. package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  138. package/dist/modules/Order/utils/manualProductDiscount.js +0 -212
  139. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +0 -275
  140. package/dist/solution/BaseSales/utils/cartPromotion.js +0 -1258
  141. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  142. package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
  143. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  144. package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
  145. package/lib/modules/BookingContext/index.d.ts +0 -37
  146. package/lib/modules/BookingContext/index.js +0 -297
  147. package/lib/modules/BookingContext/types.d.ts +0 -102
  148. package/lib/modules/BookingContext/types.js +0 -34
  149. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  150. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -207
  151. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  152. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -141
  153. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  154. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -198
  155. package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
  156. package/lib/modules/BookingContext/utils/flexible.js +0 -80
  157. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  158. package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
  159. package/lib/modules/BookingContext/utils/index.d.ts +0 -11
  160. package/lib/modules/BookingContext/utils/index.js +0 -43
  161. package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
  162. package/lib/modules/BookingContext/utils/noResource.js +0 -90
  163. package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
  164. package/lib/modules/BookingContext/utils/productExtend.js +0 -283
  165. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  166. package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
  167. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  168. package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
  169. package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
  170. package/lib/modules/BookingContext/utils/resources.js +0 -377
  171. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  172. package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
  173. package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  174. package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
  175. package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  176. package/lib/modules/Order/utils/manualProductDiscount.js +0 -207
  177. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +0 -275
  178. package/lib/solution/BaseSales/utils/cartPromotion.js +0 -836
  179. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  180. package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
  181. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  182. package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
@@ -1,7 +0,0 @@
1
- import type { QuotationModule } from '../../../modules/Quotation';
2
- import type { BaseSalesCalculateProductBookingPriceParams, BaseSalesProductBookingPriceResult } from '../types';
3
- interface BuildBaseSalesQuotationPriceParams extends BaseSalesCalculateProductBookingPriceParams {
4
- quotation?: Pick<QuotationModule, 'getPriceForProduct' | 'getQuotationShelfId'> | null;
5
- }
6
- export declare function calculateBaseSalesProductBookingPrice(params: BuildBaseSalesQuotationPriceParams): BaseSalesProductBookingPriceResult;
7
- export {};
@@ -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
- };