@pisell/pisellos 2.1.151 → 2.1.152

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 (201) hide show
  1. package/dist/apis/picoding.d.ts +0 -0
  2. package/dist/apis/picoding.js +1 -0
  3. package/dist/index.d.ts +0 -1
  4. package/dist/index.js +0 -1
  5. package/dist/model/strategy/adapter/promotion/evaluator.js +26 -99
  6. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
  7. package/dist/model/strategy/adapter/walletPass/evaluator.js +8 -61
  8. package/dist/model/strategy/adapter/walletPass/locales.js +3 -12
  9. package/dist/model/strategy/engine.d.ts +5 -18
  10. package/dist/model/strategy/engine.js +45 -145
  11. package/dist/model/strategy/type.d.ts +0 -17
  12. package/dist/model/strategy/type.js +0 -4
  13. package/dist/modules/Cart/types.d.ts +0 -2
  14. package/dist/modules/Cart/utils/cartProduct.js +25 -56
  15. package/dist/modules/Discount/index.d.ts +9 -3
  16. package/dist/modules/Discount/index.js +103 -11
  17. package/dist/modules/Discount/types.d.ts +8 -19
  18. package/dist/modules/OpenData/index.d.ts +24 -0
  19. package/dist/modules/OpenData/index.js +173 -0
  20. package/dist/modules/OpenData/types.d.ts +73 -0
  21. package/dist/modules/OpenData/types.js +1 -0
  22. package/dist/modules/OpenData/utils.d.ts +2 -0
  23. package/dist/modules/OpenData/utils.js +75 -0
  24. package/dist/modules/Order/index.d.ts +66 -1
  25. package/dist/modules/Order/index.js +906 -30
  26. package/dist/modules/Order/types.d.ts +174 -12
  27. package/dist/modules/Order/types.js +2 -0
  28. package/dist/modules/Order/utils.d.ts +118 -0
  29. package/dist/modules/Order/utils.js +586 -2
  30. package/dist/modules/Payment/index.d.ts +1 -2
  31. package/dist/modules/Payment/index.js +7 -10
  32. package/dist/modules/Payment/utils.js +0 -3
  33. package/dist/modules/Payment/walletpass.d.ts +0 -23
  34. package/dist/modules/Payment/walletpass.js +95 -191
  35. package/dist/modules/Product/utils.js +2 -2
  36. package/dist/modules/ProductList/index.d.ts +1 -1
  37. package/dist/modules/ProductList/index.js +4 -3
  38. package/dist/modules/Quotation/index.d.ts +48 -0
  39. package/dist/modules/Quotation/index.js +248 -0
  40. package/dist/modules/Quotation/types.d.ts +42 -0
  41. package/dist/modules/Quotation/types.js +1 -0
  42. package/dist/modules/Rules/index.d.ts +5 -9
  43. package/dist/modules/Rules/index.js +168 -677
  44. package/dist/modules/Rules/types.d.ts +0 -2
  45. package/dist/modules/SalesSummary/index.d.ts +63 -0
  46. package/dist/modules/SalesSummary/index.js +174 -0
  47. package/dist/modules/SalesSummary/types.d.ts +60 -0
  48. package/dist/modules/SalesSummary/types.js +1 -0
  49. package/dist/modules/SalesSummary/utils.d.ts +30 -0
  50. package/dist/modules/SalesSummary/utils.js +480 -0
  51. package/dist/modules/ScanOrderLogger/index.d.ts +23 -0
  52. package/dist/modules/ScanOrderLogger/index.js +174 -0
  53. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  54. package/dist/modules/ScanOrderLogger/providers/feishu.js +221 -0
  55. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  56. package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
  57. package/dist/modules/ScanOrderLogger/types.d.ts +53 -0
  58. package/dist/modules/ScanOrderLogger/types.js +1 -0
  59. package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
  60. package/dist/modules/Schedule/utils.d.ts +1 -1
  61. package/dist/modules/Summary/types.d.ts +0 -2
  62. package/dist/modules/Summary/utils.d.ts +3 -9
  63. package/dist/modules/Summary/utils.js +41 -52
  64. package/dist/modules/index.d.ts +4 -0
  65. package/dist/modules/index.js +5 -1
  66. package/dist/plugins/window.d.ts +0 -2
  67. package/dist/solution/BookingByStep/index.d.ts +1 -2
  68. package/dist/solution/BookingByStep/index.js +46 -43
  69. package/dist/solution/BookingByStep/types.d.ts +3 -1
  70. package/dist/solution/BookingByStep/types.js +5 -1
  71. package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  72. package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
  73. package/dist/solution/Checkout/index.js +0 -2
  74. package/dist/solution/ScanOrder/index.d.ts +152 -0
  75. package/dist/solution/ScanOrder/index.js +3132 -0
  76. package/dist/solution/ScanOrder/types.d.ts +287 -0
  77. package/dist/solution/ScanOrder/types.js +35 -0
  78. package/dist/solution/ScanOrder/utils.d.ts +167 -0
  79. package/dist/solution/ScanOrder/utils.js +764 -0
  80. package/dist/solution/ShopDiscount/index.d.ts +3 -2
  81. package/dist/solution/ShopDiscount/index.js +60 -59
  82. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  83. package/dist/solution/ShopDiscount/types.js +1 -2
  84. package/dist/solution/ShopDiscount/utils.js +12 -26
  85. package/dist/solution/VenueBooking/index.d.ts +200 -0
  86. package/dist/solution/VenueBooking/index.js +3459 -0
  87. package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  88. package/dist/solution/VenueBooking/types.d.ts +154 -0
  89. package/dist/solution/VenueBooking/types.js +21 -0
  90. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
  91. package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
  92. package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
  93. package/dist/solution/VenueBooking/utils/resource.js +131 -0
  94. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
  95. package/dist/solution/VenueBooking/utils/slotMerge.js +239 -0
  96. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  97. package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
  98. package/dist/solution/VenueBooking/utils.d.ts +1 -0
  99. package/dist/solution/VenueBooking/utils.js +1 -0
  100. package/dist/solution/index.d.ts +2 -0
  101. package/dist/solution/index.js +3 -1
  102. package/lib/apis/picoding.d.ts +0 -0
  103. package/lib/apis/picoding.js +0 -0
  104. package/lib/index.d.ts +0 -1
  105. package/lib/index.js +1 -3
  106. package/lib/model/strategy/adapter/promotion/evaluator.js +8 -57
  107. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  108. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
  109. package/lib/model/strategy/adapter/walletPass/evaluator.js +3 -34
  110. package/lib/model/strategy/adapter/walletPass/locales.js +3 -12
  111. package/lib/model/strategy/engine.d.ts +5 -18
  112. package/lib/model/strategy/engine.js +21 -85
  113. package/lib/model/strategy/type.d.ts +0 -17
  114. package/lib/modules/Cart/types.d.ts +0 -2
  115. package/lib/modules/Cart/utils/cartProduct.js +12 -39
  116. package/lib/modules/Discount/index.d.ts +9 -3
  117. package/lib/modules/Discount/index.js +65 -4
  118. package/lib/modules/Discount/types.d.ts +8 -19
  119. package/lib/modules/OpenData/index.d.ts +24 -0
  120. package/lib/modules/OpenData/index.js +119 -0
  121. package/lib/modules/OpenData/types.d.ts +73 -0
  122. package/lib/modules/OpenData/types.js +17 -0
  123. package/lib/modules/OpenData/utils.d.ts +2 -0
  124. package/lib/modules/OpenData/utils.js +111 -0
  125. package/lib/modules/Order/index.d.ts +66 -1
  126. package/lib/modules/Order/index.js +515 -1
  127. package/lib/modules/Order/types.d.ts +174 -12
  128. package/lib/modules/Order/utils.d.ts +118 -0
  129. package/lib/modules/Order/utils.js +483 -2
  130. package/lib/modules/Payment/index.d.ts +1 -2
  131. package/lib/modules/Payment/index.js +0 -1
  132. package/lib/modules/Payment/utils.js +0 -3
  133. package/lib/modules/Payment/walletpass.d.ts +0 -23
  134. package/lib/modules/Payment/walletpass.js +17 -94
  135. package/lib/modules/Product/utils.js +2 -2
  136. package/lib/modules/ProductList/index.d.ts +1 -1
  137. package/lib/modules/ProductList/index.js +5 -3
  138. package/lib/modules/Quotation/index.d.ts +48 -0
  139. package/lib/modules/Quotation/index.js +152 -0
  140. package/lib/modules/Quotation/types.d.ts +42 -0
  141. package/lib/modules/Quotation/types.js +17 -0
  142. package/lib/modules/Rules/index.d.ts +5 -9
  143. package/lib/modules/Rules/index.js +288 -780
  144. package/lib/modules/Rules/types.d.ts +0 -2
  145. package/lib/modules/SalesSummary/index.d.ts +63 -0
  146. package/lib/modules/SalesSummary/index.js +105 -0
  147. package/lib/modules/SalesSummary/types.d.ts +60 -0
  148. package/lib/modules/SalesSummary/types.js +17 -0
  149. package/lib/modules/SalesSummary/utils.d.ts +30 -0
  150. package/lib/modules/SalesSummary/utils.js +420 -0
  151. package/lib/modules/ScanOrderLogger/index.d.ts +23 -0
  152. package/lib/modules/ScanOrderLogger/index.js +147 -0
  153. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  154. package/lib/modules/ScanOrderLogger/providers/feishu.js +157 -0
  155. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  156. package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
  157. package/lib/modules/ScanOrderLogger/types.d.ts +53 -0
  158. package/lib/modules/ScanOrderLogger/types.js +17 -0
  159. package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
  160. package/lib/modules/Schedule/utils.d.ts +1 -1
  161. package/lib/modules/Summary/types.d.ts +0 -2
  162. package/lib/modules/Summary/utils.d.ts +3 -9
  163. package/lib/modules/Summary/utils.js +22 -31
  164. package/lib/modules/index.d.ts +4 -0
  165. package/lib/modules/index.js +9 -1
  166. package/lib/plugins/window.d.ts +0 -2
  167. package/lib/solution/BookingByStep/index.d.ts +1 -2
  168. package/lib/solution/BookingByStep/index.js +6 -4
  169. package/lib/solution/BookingByStep/types.d.ts +3 -1
  170. package/lib/solution/BookingByStep/types.js +10 -0
  171. package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  172. package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
  173. package/lib/solution/Checkout/index.js +0 -2
  174. package/lib/solution/ScanOrder/index.d.ts +152 -0
  175. package/lib/solution/ScanOrder/index.js +1901 -0
  176. package/lib/solution/ScanOrder/types.d.ts +287 -0
  177. package/lib/solution/ScanOrder/types.js +36 -0
  178. package/lib/solution/ScanOrder/utils.d.ts +167 -0
  179. package/lib/solution/ScanOrder/utils.js +635 -0
  180. package/lib/solution/ShopDiscount/index.d.ts +3 -2
  181. package/lib/solution/ShopDiscount/index.js +19 -25
  182. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  183. package/lib/solution/ShopDiscount/utils.js +6 -10
  184. package/lib/solution/VenueBooking/index.d.ts +200 -0
  185. package/lib/solution/VenueBooking/index.js +1926 -0
  186. package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  187. package/lib/solution/VenueBooking/types.d.ts +154 -0
  188. package/lib/solution/VenueBooking/types.js +44 -0
  189. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
  190. package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
  191. package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
  192. package/lib/solution/VenueBooking/utils/resource.js +92 -0
  193. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
  194. package/lib/solution/VenueBooking/utils/slotMerge.js +237 -0
  195. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  196. package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
  197. package/lib/solution/VenueBooking/utils.d.ts +1 -0
  198. package/lib/solution/VenueBooking/utils.js +69 -0
  199. package/lib/solution/index.d.ts +2 -0
  200. package/lib/solution/index.js +5 -1
  201. package/package.json +1 -1
@@ -0,0 +1,339 @@
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/VenueBooking/utils/timeSlot.ts
30
+ var timeSlot_exports = {};
31
+ __export(timeSlot_exports, {
32
+ buildTimeSlotGrid: () => buildTimeSlotGrid,
33
+ collectEventsForDate: () => collectEventsForDate,
34
+ computeSlotStatus: () => computeSlotStatus,
35
+ generateTimeLabels: () => generateTimeLabels,
36
+ isBusinessHoursCrossDay: () => isBusinessHoursCrossDay,
37
+ isSlotOccupied: () => isSlotOccupied
38
+ });
39
+ module.exports = __toCommonJS(timeSlot_exports);
40
+ var import_dayjs = __toESM(require("dayjs"));
41
+ var import_decimal = __toESM(require("decimal.js"));
42
+ function isBusinessHoursCrossDay(config) {
43
+ const [startH, startM] = config.businessStartTime.split(":").map(Number);
44
+ const [endH, endM] = config.businessEndTime.split(":").map(Number);
45
+ return endH < startH || endH === startH && endM <= startM;
46
+ }
47
+ function generateTimeLabels(config) {
48
+ const { slotDurationMinutes, businessStartTime, businessEndTime } = config;
49
+ const labels = [];
50
+ const baseDate = "2000-01-01";
51
+ let cursor = (0, import_dayjs.default)(`${baseDate} ${businessStartTime}`);
52
+ const crossDay = isBusinessHoursCrossDay(config);
53
+ const endBase = crossDay ? "2000-01-02" : baseDate;
54
+ const end = (0, import_dayjs.default)(`${endBase} ${businessEndTime}`);
55
+ while (cursor.isBefore(end)) {
56
+ labels.push(cursor.format("HH:mm"));
57
+ cursor = cursor.add(slotDurationMinutes, "minute");
58
+ }
59
+ return labels;
60
+ }
61
+ function isSlotOccupied(slotStart, slotEnd, occupiedTimes) {
62
+ for (const occupied of occupiedTimes) {
63
+ const occStart = (0, import_dayjs.default)(occupied.start_at);
64
+ const occEnd = (0, import_dayjs.default)(occupied.end_at);
65
+ if (slotStart.isBefore(occEnd) && slotEnd.isAfter(occStart)) {
66
+ return true;
67
+ }
68
+ }
69
+ return false;
70
+ }
71
+ function isSlotWithinResourceTimes(slotStart, slotEnd, resourceTimes) {
72
+ for (const t of resourceTimes) {
73
+ const tStart = (0, import_dayjs.default)(t.start_at);
74
+ const tEnd = (0, import_dayjs.default)(t.end_at);
75
+ if (slotStart.isBefore(tEnd) && slotEnd.isAfter(tStart))
76
+ return true;
77
+ }
78
+ return false;
79
+ }
80
+ function getResourceTimesForDate(resource, date, config) {
81
+ const crossDay = isBusinessHoursCrossDay(config);
82
+ const dayStart = (0, import_dayjs.default)(`${date} ${config.businessStartTime}`);
83
+ const dayEnd = crossDay ? (0, import_dayjs.default)(`${date} ${config.businessEndTime}`).add(1, "day") : (0, import_dayjs.default)(`${date} ${config.businessEndTime}`);
84
+ return resource.times.filter((t) => {
85
+ const tStart = (0, import_dayjs.default)(t.start_at);
86
+ const tEnd = (0, import_dayjs.default)(t.end_at);
87
+ return tStart.isBefore(dayEnd) && tEnd.isAfter(dayStart);
88
+ });
89
+ }
90
+ function collectEventsForDate(resource, date, config) {
91
+ const timesForDate = getResourceTimesForDate(resource, date, config);
92
+ const events = [];
93
+ for (const t of timesForDate) {
94
+ if (Array.isArray(t.event_list)) {
95
+ for (const evt of t.event_list) {
96
+ events.push({
97
+ start_at: evt.start_at,
98
+ end_at: evt.end_at,
99
+ pax: evt.pax ?? 1
100
+ });
101
+ }
102
+ }
103
+ }
104
+ return events;
105
+ }
106
+ function computeSlotStatus(params) {
107
+ const { slotStart, slotEnd, events, resourceType, capacity } = params;
108
+ const overlapping = events.filter((evt) => {
109
+ const evtStart = (0, import_dayjs.default)(evt.start_at);
110
+ const evtEnd = (0, import_dayjs.default)(evt.end_at);
111
+ return slotStart.isBefore(evtEnd) && slotEnd.isAfter(evtStart);
112
+ });
113
+ if (resourceType === "single") {
114
+ if (overlapping.length > 0)
115
+ return { status: "occupied", remainingCapacity: 0 };
116
+ return { status: "available", remainingCapacity: 1 };
117
+ }
118
+ const usedCapacity = overlapping.reduce((sum, evt) => sum + evt.pax, 0);
119
+ const remaining = Math.max(0, capacity - usedCapacity);
120
+ if (remaining <= 0)
121
+ return { status: "occupied", remainingCapacity: 0 };
122
+ if (remaining < capacity)
123
+ return { status: "partially_occupied", remainingCapacity: remaining };
124
+ return { status: "available", remainingCapacity: remaining };
125
+ }
126
+ function mergeSubSlots(subSlots) {
127
+ const priority = {
128
+ available: 5,
129
+ partially_occupied: 4,
130
+ occupied: 3,
131
+ unavailable: 2,
132
+ past: 1
133
+ };
134
+ let best = subSlots[0];
135
+ for (const slot of subSlots) {
136
+ if ((priority[slot.status] ?? 0) > (priority[best.status] ?? 0))
137
+ best = slot;
138
+ }
139
+ let minPrice = null;
140
+ for (const slot of subSlots) {
141
+ if (slot.price == null)
142
+ continue;
143
+ const decimal = new import_decimal.default(slot.price || "0");
144
+ if (!minPrice || decimal.lt(minPrice))
145
+ minPrice = decimal;
146
+ }
147
+ return {
148
+ startTime: best.startTime,
149
+ endTime: best.endTime,
150
+ status: best.status,
151
+ price: minPrice ? minPrice.toFixed(2) : null,
152
+ resourceId: best.resourceId,
153
+ resourceFormId: best.resourceFormId,
154
+ capacity: best.capacity,
155
+ remainingCapacity: best.remainingCapacity
156
+ };
157
+ }
158
+ function buildProductSlots(params) {
159
+ const {
160
+ date,
161
+ config,
162
+ resource,
163
+ mapping,
164
+ timeLabels,
165
+ timesForDate,
166
+ events,
167
+ resCapacity,
168
+ now,
169
+ crossDay,
170
+ quotationPriceMap,
171
+ childRawResources,
172
+ childTimesCache,
173
+ childEventsCache,
174
+ config_businessStartHour
175
+ } = params;
176
+ const slots = [];
177
+ for (const label of timeLabels) {
178
+ const [h] = label.split(":").map(Number);
179
+ const isNextDay = crossDay && h < config_businessStartHour;
180
+ const slotDate = isNextDay ? (0, import_dayjs.default)(date).add(1, "day").format("YYYY-MM-DD") : date;
181
+ const slotStart = (0, import_dayjs.default)(`${slotDate} ${label}`);
182
+ const slotEnd = slotStart.add(config.slotDurationMinutes, "minute");
183
+ let status;
184
+ let remainingCapacity = null;
185
+ if (slotStart.isBefore(now)) {
186
+ status = "past";
187
+ } else if (!isSlotWithinResourceTimes(slotStart, slotEnd, timesForDate)) {
188
+ status = "unavailable";
189
+ } else {
190
+ const result = computeSlotStatus({
191
+ slotStart,
192
+ slotEnd,
193
+ events,
194
+ resourceType: mapping.resourceType,
195
+ capacity: resCapacity
196
+ });
197
+ status = result.status;
198
+ remainingCapacity = result.remainingCapacity;
199
+ if (status !== "occupied" && childRawResources && childRawResources.length) {
200
+ for (let i = 0; i < childRawResources.length; i++) {
201
+ const child = childRawResources[i];
202
+ const childTimes = (childTimesCache == null ? void 0 : childTimesCache[i]) ?? getResourceTimesForDate(child, date, config);
203
+ const childEvents = (childEventsCache == null ? void 0 : childEventsCache[i]) ?? collectEventsForDate(child, date, config);
204
+ if (!isSlotWithinResourceTimes(slotStart, slotEnd, childTimes)) {
205
+ status = "unavailable";
206
+ remainingCapacity = null;
207
+ break;
208
+ }
209
+ const childType = child.type || "single";
210
+ const childResult = computeSlotStatus({
211
+ slotStart,
212
+ slotEnd,
213
+ events: childEvents,
214
+ resourceType: childType,
215
+ capacity: child.capacity ?? 1
216
+ });
217
+ if (childResult.status === "occupied") {
218
+ status = "occupied";
219
+ remainingCapacity = 0;
220
+ break;
221
+ }
222
+ if (childResult.status === "partially_occupied" && status === "available") {
223
+ status = "partially_occupied";
224
+ remainingCapacity = Math.min(
225
+ remainingCapacity ?? childResult.remainingCapacity,
226
+ childResult.remainingCapacity
227
+ );
228
+ }
229
+ }
230
+ }
231
+ }
232
+ const isBookable = status === "available" || status === "partially_occupied";
233
+ const slotStartStr = slotStart.format("YYYY-MM-DD HH:mm");
234
+ slots.push({
235
+ startTime: slotStartStr,
236
+ endTime: slotEnd.format("YYYY-MM-DD HH:mm"),
237
+ status,
238
+ price: isBookable ? (quotationPriceMap == null ? void 0 : quotationPriceMap.get(`${mapping.productId}:${slotStartStr}`)) ?? mapping.price : null,
239
+ resourceId: resource.resourceId,
240
+ resourceFormId: resource.formId,
241
+ capacity: status === "past" || status === "unavailable" ? null : resCapacity,
242
+ remainingCapacity,
243
+ productId: mapping.productId
244
+ });
245
+ }
246
+ return slots;
247
+ }
248
+ function buildTimeSlotGrid(params) {
249
+ const { date, config, rawResources, resourceProductMap, quotationPriceMap } = params;
250
+ const timeLabels = generateTimeLabels(config);
251
+ const now = (0, import_dayjs.default)();
252
+ const crossDay = isBusinessHoursCrossDay(config);
253
+ const config_businessStartHour = Number(config.businessStartTime.split(":")[0]);
254
+ const rawResourceById = /* @__PURE__ */ new Map();
255
+ for (const item of rawResources)
256
+ rawResourceById.set(item.resourceId, item);
257
+ const resources = [];
258
+ for (const resource of rawResources) {
259
+ const mappings = resourceProductMap.get(resource.resourceId);
260
+ if (!mappings || !mappings.length)
261
+ continue;
262
+ const timesForDate = getResourceTimesForDate(resource, date, config);
263
+ const events = collectEventsForDate(resource, date, config);
264
+ const resCapacity = resource.capacity ?? 1;
265
+ const combined = resource.combined_resource;
266
+ const isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids) && combined.resource_ids.length);
267
+ const childRawResources = isCombined ? combined.resource_ids.map((id) => rawResourceById.get(id)).filter((r) => !!r) : void 0;
268
+ const childTimesCache = childRawResources == null ? void 0 : childRawResources.map((child) => getResourceTimesForDate(child, date, config));
269
+ const childEventsCache = childRawResources == null ? void 0 : childRawResources.map((child) => collectEventsForDate(child, date, config));
270
+ const subRows = mappings.map((mapping) => {
271
+ const productSlots = buildProductSlots({
272
+ date,
273
+ config,
274
+ resource,
275
+ mapping,
276
+ timeLabels,
277
+ timesForDate,
278
+ events,
279
+ resCapacity,
280
+ now,
281
+ crossDay,
282
+ quotationPriceMap,
283
+ childRawResources,
284
+ childTimesCache,
285
+ childEventsCache,
286
+ config_businessStartHour
287
+ });
288
+ return {
289
+ productId: mapping.productId,
290
+ productTitle: mapping.productTitle,
291
+ price: mapping.price,
292
+ slots: productSlots
293
+ };
294
+ });
295
+ const hasMultipleProducts = subRows.length > 1;
296
+ const primary = mappings[0];
297
+ let outerSlots;
298
+ if (hasMultipleProducts) {
299
+ outerSlots = timeLabels.map((_label, slotIndex) => {
300
+ const group = subRows.map((row2) => row2.slots[slotIndex]);
301
+ return mergeSubSlots(group);
302
+ });
303
+ } else {
304
+ outerSlots = subRows[0].slots.map((slot) => ({ ...slot, productId: void 0 }));
305
+ }
306
+ const row = {
307
+ resourceId: resource.resourceId,
308
+ resourceFormId: resource.formId,
309
+ resourceName: resource.main_field || primary.resourceName,
310
+ productId: primary.productId,
311
+ productTitle: primary.productTitle,
312
+ slots: outerSlots
313
+ };
314
+ if (hasMultipleProducts) {
315
+ row.products = subRows;
316
+ row.hasMultipleProducts = true;
317
+ }
318
+ if (isCombined && combined) {
319
+ row.combinedResource = { resourceIds: [...combined.resource_ids] };
320
+ }
321
+ resources.push(row);
322
+ }
323
+ const productOrder = /* @__PURE__ */ new Map();
324
+ for (const row of resources) {
325
+ if (!productOrder.has(row.productId))
326
+ productOrder.set(row.productId, productOrder.size);
327
+ }
328
+ resources.sort((a, b) => (productOrder.get(a.productId) ?? 0) - (productOrder.get(b.productId) ?? 0));
329
+ return { date, timeLabels, resources };
330
+ }
331
+ // Annotate the CommonJS export names for ESM import in node:
332
+ 0 && (module.exports = {
333
+ buildTimeSlotGrid,
334
+ collectEventsForDate,
335
+ computeSlotStatus,
336
+ generateTimeLabels,
337
+ isBusinessHoursCrossDay,
338
+ isSlotOccupied
339
+ });
@@ -0,0 +1 @@
1
+ export { createEmptySummary, getSafeProductNum, toBoolean, toPositiveString, normalizeEnabledItemRuleIds, extractStrategyModelIdsFromTableConfig, normalizeItemRuleStrategies, toNonNegativeNumber, toNonNegativeInt, toPriceString, buildProductKey, getTopLevelProductId, getTopLevelVariantId, buildQuantityLimitIndex, resolveSkuMatchedQuantityLimits, aggregateItemRuleLimit, buildItemRuleBusinessData, attachItemRuleLimitsToTopLevelProducts, getProductIdentityIndex, isIdentityMatch, normalizeOrderProduct, } from '../ScanOrder/utils';
@@ -0,0 +1,69 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/solution/VenueBooking/utils.ts
20
+ var utils_exports = {};
21
+ __export(utils_exports, {
22
+ aggregateItemRuleLimit: () => import_utils.aggregateItemRuleLimit,
23
+ attachItemRuleLimitsToTopLevelProducts: () => import_utils.attachItemRuleLimitsToTopLevelProducts,
24
+ buildItemRuleBusinessData: () => import_utils.buildItemRuleBusinessData,
25
+ buildProductKey: () => import_utils.buildProductKey,
26
+ buildQuantityLimitIndex: () => import_utils.buildQuantityLimitIndex,
27
+ createEmptySummary: () => import_utils.createEmptySummary,
28
+ extractStrategyModelIdsFromTableConfig: () => import_utils.extractStrategyModelIdsFromTableConfig,
29
+ getProductIdentityIndex: () => import_utils.getProductIdentityIndex,
30
+ getSafeProductNum: () => import_utils.getSafeProductNum,
31
+ getTopLevelProductId: () => import_utils.getTopLevelProductId,
32
+ getTopLevelVariantId: () => import_utils.getTopLevelVariantId,
33
+ isIdentityMatch: () => import_utils.isIdentityMatch,
34
+ normalizeEnabledItemRuleIds: () => import_utils.normalizeEnabledItemRuleIds,
35
+ normalizeItemRuleStrategies: () => import_utils.normalizeItemRuleStrategies,
36
+ normalizeOrderProduct: () => import_utils.normalizeOrderProduct,
37
+ resolveSkuMatchedQuantityLimits: () => import_utils.resolveSkuMatchedQuantityLimits,
38
+ toBoolean: () => import_utils.toBoolean,
39
+ toNonNegativeInt: () => import_utils.toNonNegativeInt,
40
+ toNonNegativeNumber: () => import_utils.toNonNegativeNumber,
41
+ toPositiveString: () => import_utils.toPositiveString,
42
+ toPriceString: () => import_utils.toPriceString
43
+ });
44
+ module.exports = __toCommonJS(utils_exports);
45
+ var import_utils = require("../ScanOrder/utils");
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
48
+ aggregateItemRuleLimit,
49
+ attachItemRuleLimitsToTopLevelProducts,
50
+ buildItemRuleBusinessData,
51
+ buildProductKey,
52
+ buildQuantityLimitIndex,
53
+ createEmptySummary,
54
+ extractStrategyModelIdsFromTableConfig,
55
+ getProductIdentityIndex,
56
+ getSafeProductNum,
57
+ getTopLevelProductId,
58
+ getTopLevelVariantId,
59
+ isIdentityMatch,
60
+ normalizeEnabledItemRuleIds,
61
+ normalizeItemRuleStrategies,
62
+ normalizeOrderProduct,
63
+ resolveSkuMatchedQuantityLimits,
64
+ toBoolean,
65
+ toNonNegativeInt,
66
+ toNonNegativeNumber,
67
+ toPositiveString,
68
+ toPriceString
69
+ });
@@ -4,3 +4,5 @@ export * from './BookingTicket';
4
4
  export * from './ShopDiscount';
5
5
  export * from './RegisterAndLogin';
6
6
  export * from './Checkout';
7
+ export * from './ScanOrder';
8
+ export * from './VenueBooking';
@@ -22,6 +22,8 @@ __reExport(solution_exports, require("./BookingTicket"), module.exports);
22
22
  __reExport(solution_exports, require("./ShopDiscount"), module.exports);
23
23
  __reExport(solution_exports, require("./RegisterAndLogin"), module.exports);
24
24
  __reExport(solution_exports, require("./Checkout"), module.exports);
25
+ __reExport(solution_exports, require("./ScanOrder"), module.exports);
26
+ __reExport(solution_exports, require("./VenueBooking"), module.exports);
25
27
  // Annotate the CommonJS export names for ESM import in node:
26
28
  0 && (module.exports = {
27
29
  ...require("./BuyTickets"),
@@ -29,5 +31,7 @@ __reExport(solution_exports, require("./Checkout"), module.exports);
29
31
  ...require("./BookingTicket"),
30
32
  ...require("./ShopDiscount"),
31
33
  ...require("./RegisterAndLogin"),
32
- ...require("./Checkout")
34
+ ...require("./Checkout"),
35
+ ...require("./ScanOrder"),
36
+ ...require("./VenueBooking")
33
37
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.1.151",
4
+ "version": "2.1.152",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",