@pisell/pisellos 2.2.178 → 2.2.180

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/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 -87
  8. package/dist/modules/Order/index.js +501 -1357
  9. package/dist/modules/Order/types.d.ts +19 -198
  10. package/dist/modules/Order/types.js +0 -31
  11. package/dist/modules/Order/utils.d.ts +1 -50
  12. package/dist/modules/Order/utils.js +32 -261
  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/SalesSummary/utils.js +7 -21
  19. package/dist/modules/Schedule/index.js +2 -6
  20. package/dist/modules/index.d.ts +0 -1
  21. package/dist/modules/index.js +1 -2
  22. package/dist/server/index.js +29 -87
  23. package/dist/server/modules/order/index.d.ts +0 -23
  24. package/dist/server/modules/order/index.js +46 -123
  25. package/dist/server/modules/order/types.d.ts +2 -0
  26. package/dist/server/modules/order/utils/filterOrders.js +6 -20
  27. package/dist/server/modules/products/index.d.ts +1 -1
  28. package/dist/server/modules/products/index.js +113 -130
  29. package/dist/server/modules/schedule/index.js +6 -13
  30. package/dist/solution/BaseSales/index.d.ts +7 -89
  31. package/dist/solution/BaseSales/index.js +375 -1494
  32. package/dist/solution/BaseSales/types.d.ts +1 -67
  33. package/dist/solution/BaseSales/types.js +1 -3
  34. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
  35. package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
  36. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -68
  37. package/dist/solution/BaseSales/utils.js +8 -46
  38. package/dist/solution/BookingByStep/index.d.ts +1 -1
  39. package/dist/solution/BookingTicket/index.d.ts +1 -133
  40. package/dist/solution/BookingTicket/index.js +175 -780
  41. package/dist/solution/BookingTicket/types.d.ts +0 -2
  42. package/dist/solution/BookingTicket/types.js +0 -3
  43. package/dist/solution/BookingTicket/utils/cartView.js +2 -4
  44. package/dist/solution/ScanOrder/index.d.ts +3 -9
  45. package/dist/solution/ScanOrder/index.js +128 -231
  46. package/dist/solution/ScanOrder/utils.js +8 -46
  47. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  48. package/dist/solution/ShopDiscount/index.js +23 -18
  49. package/dist/solution/VenueBooking/index.d.ts +9 -5
  50. package/dist/solution/VenueBooking/index.js +55 -103
  51. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  52. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
  53. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  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 +17 -87
  61. package/lib/modules/Order/index.js +150 -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,318 +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/BookingTicket/utils/addProductDecision.ts
30
- var addProductDecision_exports = {};
31
- __export(addProductDecision_exports, {
32
- buildCacheItemFromCartDetail: () => buildCacheItemFromCartDetail,
33
- buildCacheItemFromDetail: () => buildCacheItemFromDetail,
34
- buildRequiresDetailPayload: () => buildRequiresDetailPayload,
35
- decideAddProduct: () => decideAddProduct,
36
- decideAfterDetail: () => decideAfterDetail,
37
- decideAutoClose: () => decideAutoClose,
38
- getIsEject: () => getIsEject,
39
- getIsOnlySession: () => getIsOnlySession,
40
- prepareBookingCacheItem: () => prepareBookingCacheItem,
41
- transformDetailToProductAndBooking: () => transformDetailToProductAndBooking
42
- });
43
- module.exports = __toCommonJS(addProductDecision_exports);
44
- var import_dayjs = __toESM(require("dayjs"));
45
- var import_BookingContext = require("../../../modules/BookingContext");
46
- var import_transformBaseProductToOrderProduct = require("../../BaseSales/utils/transformBaseProductToOrderProduct");
47
- function needsSpecDetailModal(item) {
48
- if (item == null ? void 0 : item.open_sold_weight)
49
- return true;
50
- if (item == null ? void 0 : item.isOpenDetailModal)
51
- return true;
52
- if (!(item == null ? void 0 : item.cartDetailValue))
53
- return true;
54
- return false;
55
- }
56
- function needsBookingEdit(cacheItem, ctx) {
57
- if (isNormalBookingProduct(cacheItem))
58
- return false;
59
- const isAutoAllocationOn = (ctx == null ? void 0 : ctx.isAutoAllocationOn) || (() => true);
60
- return !(0, import_BookingContext.getIsAutoClose)(cacheItem, isAutoAllocationOn);
61
- }
62
- function buildRequiresBookingEditPayload(cacheItem, ctx) {
63
- return {
64
- cacheItem,
65
- customerId: ctx == null ? void 0 : ctx.customerId,
66
- date: typeof (ctx == null ? void 0 : ctx.date) === "string" ? ctx.date : null
67
- };
68
- }
69
- function decideAddProduct(item, ctx) {
70
- const derivedCtx = withDerivedBookingCtx(ctx);
71
- if (needsSpecDetailModal(item)) {
72
- return {
73
- action: "requiresDetail",
74
- payload: buildRequiresDetailPayload(item, derivedCtx)
75
- };
76
- }
77
- const cacheItem = prepareBookingCacheItem(
78
- buildCacheItemFromCartDetail(item, derivedCtx),
79
- derivedCtx
80
- );
81
- if (needsBookingEdit(cacheItem, derivedCtx)) {
82
- return {
83
- action: "requiresBookingEdit",
84
- cacheItem,
85
- payload: buildRequiresBookingEditPayload(cacheItem, derivedCtx)
86
- };
87
- }
88
- return { action: "add", cacheItem };
89
- }
90
- function decideAfterDetail(cacheItem, ctx) {
91
- const derivedCtx = withDerivedBookingCtx(ctx);
92
- const extended = prepareBookingCacheItem(cacheItem, derivedCtx);
93
- if (needsBookingEdit(extended, derivedCtx)) {
94
- return {
95
- action: "requiresBookingEdit",
96
- cacheItem: extended,
97
- payload: buildRequiresBookingEditPayload(extended, derivedCtx)
98
- };
99
- }
100
- return { action: "add", cacheItem: extended };
101
- }
102
- function isNormalBookingProduct(item) {
103
- return !(0, import_BookingContext.isBookingProduct)(item);
104
- }
105
- function hasPreparedBookingExtend(cacheItem) {
106
- var _a;
107
- if ((0, import_BookingContext.productNeedsResourceExtend)(cacheItem) && !(0, import_BookingContext.hasActualResourceSelection)(cacheItem)) {
108
- return false;
109
- }
110
- const ext = (cacheItem == null ? void 0 : cacheItem._extend) || {};
111
- const hasResourceState = Boolean(
112
- (0, import_BookingContext.hasActualResourceSelection)(cacheItem) && ext.capacity && (ext.endDate || ext.end_date)
113
- );
114
- const hasSessionState = Boolean(
115
- (0, import_BookingContext.isSessionProduct)(cacheItem) && ((_a = ext.other) == null ? void 0 : _a.session) && ext.start_time && (ext.end_time || ext.endDate)
116
- );
117
- const hasMultiDayState = Boolean(isNormalBookingProduct(cacheItem) === false && isMultiDayLike(cacheItem));
118
- const hasExplicitTimeState = Boolean(
119
- ext.duration && (ext.start_date || ext.startDate) && ext.start_time && (ext.end_date && ext.end_time || ext.endDate)
120
- );
121
- return hasResourceState || hasSessionState || hasMultiDayState || hasExplicitTimeState;
122
- }
123
- function formatBookingDateForUI(date) {
124
- if (date == null || date === "")
125
- return null;
126
- const parsed = (0, import_dayjs.default)(date);
127
- return parsed.isValid() ? parsed.format("YYYY-MM-DD") : null;
128
- }
129
- function withDerivedBookingCtx(ctx) {
130
- if (!ctx)
131
- return {};
132
- return {
133
- ...ctx,
134
- presetStartTime: ctx.presetStartTime ?? (0, import_BookingContext.derivePresetStartTimeFromDate)(ctx.date)
135
- };
136
- }
137
- function isMultiDayLike(cacheItem) {
138
- var _a;
139
- const ext = (cacheItem == null ? void 0 : cacheItem._extend) || {};
140
- return Boolean(
141
- ((_a = cacheItem == null ? void 0 : cacheItem.duration) == null ? void 0 : _a.type) === "days" && ext.duration && ext.start_date && ext.end_date
142
- );
143
- }
144
- function prepareBookingCacheItem(cacheItem, ctx) {
145
- if (isNormalBookingProduct(cacheItem) || hasPreparedBookingExtend(cacheItem)) {
146
- return cacheItem;
147
- }
148
- return (0, import_BookingContext.getProductExtend)({
149
- cacheItem,
150
- ctx: withDerivedBookingCtx(ctx),
151
- isDisabledTime: true
152
- });
153
- }
154
- function decideAutoClose(item, ctx) {
155
- const decision = decideAddProduct(item, ctx);
156
- if (decision.action === "add") {
157
- return { autoClose: true, cacheItem: decision.cacheItem };
158
- }
159
- if (decision.action === "requiresBookingEdit") {
160
- return { autoClose: false, cacheItem: decision.cacheItem };
161
- }
162
- return { autoClose: false };
163
- }
164
- function getIsEject(item, type = "select") {
165
- const isSession = (0, import_BookingContext.isSessionProduct)(item);
166
- const isSoldByWeight = Boolean(item == null ? void 0 : item.open_sold_weight);
167
- const need = type === "detail" || ((item == null ? void 0 : item.bundle_group_count) || 0) > 0 || ((item == null ? void 0 : item.option_group_count) || 0) > 0 || ((item == null ? void 0 : item.is_variant) || 0) > 0 || isSession || isSoldByWeight;
168
- return need ? 1 : 0;
169
- }
170
- function getIsOnlySession(item) {
171
- const isSession = (0, import_BookingContext.isSessionProduct)(item);
172
- return !(((item == null ? void 0 : item.bundle_group_count) || 0) > 0 || ((item == null ? void 0 : item.option_group_count) || 0) > 0 || ((item == null ? void 0 : item.is_variant) || 0) > 0) && isSession;
173
- }
174
- function buildRequiresDetailPayload(item, ctx) {
175
- const isOnlySession = getIsOnlySession(item);
176
- const isEject = getIsEject(item, (ctx == null ? void 0 : ctx.type) || "select");
177
- return {
178
- item,
179
- showConfig: {
180
- option: ((item == null ? void 0 : item.option_group_count) || 0) > 0,
181
- session: (0, import_BookingContext.isSessionProduct)(item),
182
- variant: ((item == null ? void 0 : item.is_variant) || 0) > 0,
183
- package: ((item == null ? void 0 : item.bundle_group_count) || 0) > 0,
184
- number: Boolean(item == null ? void 0 : item.open_sold_weight)
185
- },
186
- isOnlySession,
187
- isEject: isEject ? 1 : 0,
188
- customerId: ctx == null ? void 0 : ctx.customerId,
189
- date: formatBookingDateForUI(ctx == null ? void 0 : ctx.date),
190
- productData: item
191
- };
192
- }
193
- function buildCacheItemFromCartDetail(item, ctx) {
194
- var _a;
195
- const cartDetailValue = item.cartDetailValue || {};
196
- const other = JSON.parse(JSON.stringify(cartDetailValue || {}));
197
- other.session = cartDetailValue.session;
198
- const resolvedId = item.id ?? item.product_id;
199
- let extend = (0, import_BookingContext.applySessionTimesToExtend)(
200
- item,
201
- {
202
- start_date: (ctx == null ? void 0 : ctx.date) || void 0,
203
- /** 列表连点 / 防抖合并时以 ctx.quantity 为准,避免 cartDetailValue 默认 1 盖掉合并数量 */
204
- quantity: (ctx == null ? void 0 : ctx.quantity) ?? (cartDetailValue == null ? void 0 : cartDetailValue.quantity) ?? 1,
205
- product_name: item.title,
206
- other,
207
- isNormalProduct: !(0, import_BookingContext.isBookingProduct)(item),
208
- price: ((_a = item == null ? void 0 : item._extend) == null ? void 0 : _a.price) ?? (item == null ? void 0 : item.price)
209
- },
210
- { date: ctx == null ? void 0 : ctx.date }
211
- );
212
- return {
213
- ...item,
214
- id: resolvedId,
215
- product_id: resolvedId,
216
- _key: cartDetailValue.key,
217
- _extend: extend,
218
- new: 1
219
- };
220
- }
221
- function buildCacheItemFromDetail(item, detailResult, ctx) {
222
- var _a, _b, _c;
223
- const _currentItem = detailResult.detail || item;
224
- const _detail = _currentItem;
225
- const detailExtend = (_detail == null ? void 0 : _detail._extend) || {};
226
- const other = JSON.parse(JSON.stringify(detailResult.e || {}));
227
- other.session = (_a = detailResult.e) == null ? void 0 : _a.session;
228
- const resolvedId = _currentItem.id ?? _currentItem.product_id;
229
- const mergedItem = { ...item, ..._detail, extension_type: _detail.extension_type ?? item.extension_type };
230
- const runtimeExtend = (0, import_BookingContext.applySessionTimesToExtend)(
231
- mergedItem,
232
- {
233
- start_date: (ctx == null ? void 0 : ctx.date) || detailExtend.start_date || void 0,
234
- quantity: (ctx == null ? void 0 : ctx.quantity) ?? ((_b = detailResult.e) == null ? void 0 : _b.quantity) ?? detailExtend.quantity ?? 1,
235
- price: detailExtend.price ?? (_detail == null ? void 0 : _detail.price) ?? (item == null ? void 0 : item.price),
236
- product_name: _currentItem.title ?? detailExtend.product_name,
237
- other,
238
- isNormalProduct: !(0, import_BookingContext.isBookingProduct)(mergedItem)
239
- },
240
- { date: ctx == null ? void 0 : ctx.date }
241
- );
242
- const extend = {
243
- ...detailExtend,
244
- ...runtimeExtend,
245
- other
246
- };
247
- const note = detailExtend.note ?? (_detail == null ? void 0 : _detail.note);
248
- return {
249
- ..._detail,
250
- id: resolvedId,
251
- product_id: resolvedId,
252
- extension_type: mergedItem.extension_type,
253
- _key: (_c = detailResult.e) == null ? void 0 : _c.key,
254
- ...note != null && note !== "" ? { note: String(note) } : {},
255
- _extend: extend,
256
- new: 1
257
- };
258
- }
259
- function transformDetailToProductAndBooking(cacheItem, ctx) {
260
- const preparedCacheItem = prepareBookingCacheItem(cacheItem, withDerivedBookingCtx(ctx));
261
- const payload = buildBasePayloadFromCacheItem(preparedCacheItem, ctx);
262
- const productInput = (0, import_transformBaseProductToOrderProduct.transformBaseProductToOrderProduct)({
263
- payload,
264
- sourceProduct: preparedCacheItem
265
- });
266
- if (!productInput) {
267
- throw new Error(
268
- "[BookingTicket] transformDetailToProductAndBooking: product transform failed (missing numeric item.id / item.product_id)"
269
- );
270
- }
271
- const isNormalProduct = isNormalBookingProduct(preparedCacheItem);
272
- let booking;
273
- if (!isNormalProduct) {
274
- booking = (0, import_BookingContext.cacheItemToBookingInput)(preparedCacheItem, { bookingConfig: ctx == null ? void 0 : ctx.bookingConfig });
275
- }
276
- return { product: productInput, booking, cacheItem: preparedCacheItem };
277
- }
278
- function buildBasePayloadFromCacheItem(cacheItem, ctx) {
279
- var _a, _b, _c, _d;
280
- const other = ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.other) || {};
281
- const quantity = (ctx == null ? void 0 : ctx.quantity) != null && ctx.quantity > 0 ? ctx.quantity : ((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.quantity) ?? 1;
282
- const resolvedPid = (cacheItem == null ? void 0 : cacheItem.product_id) ?? (cacheItem == null ? void 0 : cacheItem.id);
283
- const extend = (cacheItem == null ? void 0 : cacheItem._extend) || {};
284
- return {
285
- id: (cacheItem == null ? void 0 : cacheItem.id) ?? (cacheItem == null ? void 0 : cacheItem.product_id),
286
- product_id: resolvedPid,
287
- variant_id: (other == null ? void 0 : other.product_variant_id) ?? (other == null ? void 0 : other.variant_id) ?? 0,
288
- quantity,
289
- option: (other == null ? void 0 : other.option) || [],
290
- bundle: (other == null ? void 0 : other.bundle) || ((_c = extend == null ? void 0 : extend.skuValue) == null ? void 0 : _c.bundle) || ((_d = extend == null ? void 0 : extend._skuValue) == null ? void 0 : _d.bundle) || [],
291
- unique: other == null ? void 0 : other.unique,
292
- session: other == null ? void 0 : other.session,
293
- note: extend == null ? void 0 : extend.note,
294
- price: (extend == null ? void 0 : extend.price) ?? (cacheItem == null ? void 0 : cacheItem.price),
295
- selling_price: (extend == null ? void 0 : extend.price) ?? (cacheItem == null ? void 0 : cacheItem.price),
296
- line_total: extend == null ? void 0 : extend.total,
297
- total: extend == null ? void 0 : extend.total,
298
- origin_total: extend == null ? void 0 : extend.origin_total,
299
- price_override: extend == null ? void 0 : extend.priceOverride,
300
- bundle_edit: extend == null ? void 0 : extend.bundle_edit,
301
- discount_reason: extend == null ? void 0 : extend.discount_reason,
302
- discount_list: cacheItem == null ? void 0 : cacheItem.discount_list,
303
- _extend: extend
304
- };
305
- }
306
- // Annotate the CommonJS export names for ESM import in node:
307
- 0 && (module.exports = {
308
- buildCacheItemFromCartDetail,
309
- buildCacheItemFromDetail,
310
- buildRequiresDetailPayload,
311
- decideAddProduct,
312
- decideAfterDetail,
313
- decideAutoClose,
314
- getIsEject,
315
- getIsOnlySession,
316
- prepareBookingCacheItem,
317
- transformDetailToProductAndBooking
318
- });