@pisell/pisellos 2.1.170 → 2.1.172

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 (231) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +1 -3
  3. package/dist/model/strategy/adapter/index.d.ts +0 -4
  4. package/dist/model/strategy/adapter/index.js +1 -5
  5. package/dist/model/strategy/adapter/promotion/evaluator.js +99 -26
  6. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  7. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  8. package/dist/model/strategy/adapter/walletPass/evaluator.js +61 -8
  9. package/dist/model/strategy/adapter/walletPass/locales.js +12 -3
  10. package/dist/model/strategy/engine.d.ts +18 -5
  11. package/dist/model/strategy/engine.js +145 -45
  12. package/dist/model/strategy/type.d.ts +17 -0
  13. package/dist/model/strategy/type.js +4 -0
  14. package/dist/modules/Cart/types.d.ts +2 -0
  15. package/dist/modules/Cart/utils/cartProduct.js +56 -25
  16. package/dist/modules/Cart/utils/changePrice.js +9 -16
  17. package/dist/modules/Discount/index.d.ts +4 -13
  18. package/dist/modules/Discount/index.js +12 -124
  19. package/dist/modules/Discount/types.d.ts +18 -13
  20. package/dist/modules/Order/index.d.ts +1 -67
  21. package/dist/modules/Order/index.js +30 -918
  22. package/dist/modules/Order/types.d.ts +12 -176
  23. package/dist/modules/Order/types.js +0 -2
  24. package/dist/modules/Order/utils.d.ts +0 -118
  25. package/dist/modules/Order/utils.js +2 -586
  26. package/dist/modules/Payment/index.d.ts +2 -1
  27. package/dist/modules/Payment/index.js +10 -7
  28. package/dist/modules/Payment/utils.js +3 -0
  29. package/dist/modules/Payment/walletpass.d.ts +23 -0
  30. package/dist/modules/Payment/walletpass.js +191 -95
  31. package/dist/modules/Product/utils.js +2 -2
  32. package/dist/modules/ProductList/index.d.ts +2 -4
  33. package/dist/modules/ProductList/index.js +12 -24
  34. package/dist/modules/Rules/index.d.ts +9 -5
  35. package/dist/modules/Rules/index.js +669 -173
  36. package/dist/modules/Rules/types.d.ts +2 -0
  37. package/dist/modules/Schedule/getDateIsInSchedule.js +18 -16
  38. package/dist/modules/Schedule/utils.d.ts +1 -1
  39. package/dist/modules/Summary/types.d.ts +2 -0
  40. package/dist/modules/Summary/utils.d.ts +9 -3
  41. package/dist/modules/Summary/utils.js +57 -67
  42. package/dist/modules/index.d.ts +0 -4
  43. package/dist/modules/index.js +1 -5
  44. package/dist/plugins/window.d.ts +2 -0
  45. package/dist/solution/BookingByStep/index.d.ts +3 -2
  46. package/dist/solution/BookingByStep/index.js +43 -46
  47. package/dist/solution/BookingByStep/types.d.ts +1 -3
  48. package/dist/solution/BookingByStep/types.js +1 -5
  49. package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  50. package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
  51. package/dist/solution/Checkout/index.js +2 -0
  52. package/dist/solution/ShopDiscount/index.d.ts +2 -3
  53. package/dist/solution/ShopDiscount/index.js +60 -62
  54. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  55. package/dist/solution/ShopDiscount/types.js +2 -1
  56. package/dist/solution/ShopDiscount/utils.js +26 -12
  57. package/dist/solution/index.d.ts +0 -2
  58. package/dist/solution/index.js +1 -3
  59. package/lib/index.d.ts +1 -1
  60. package/lib/index.js +3 -4
  61. package/lib/model/strategy/adapter/index.d.ts +0 -4
  62. package/lib/model/strategy/adapter/index.js +2 -13
  63. package/lib/model/strategy/adapter/promotion/evaluator.js +57 -8
  64. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  65. package/lib/model/strategy/adapter/walletPass/evaluator.js +34 -3
  66. package/lib/model/strategy/adapter/walletPass/locales.js +12 -3
  67. package/lib/model/strategy/engine.d.ts +18 -5
  68. package/lib/model/strategy/engine.js +85 -21
  69. package/lib/model/strategy/type.d.ts +17 -0
  70. package/lib/modules/Cart/types.d.ts +2 -0
  71. package/lib/modules/Cart/utils/cartProduct.js +39 -12
  72. package/lib/modules/Cart/utils/changePrice.js +9 -13
  73. package/lib/modules/Discount/index.d.ts +4 -13
  74. package/lib/modules/Discount/index.js +5 -76
  75. package/lib/modules/Discount/types.d.ts +18 -13
  76. package/lib/modules/Order/index.d.ts +1 -67
  77. package/lib/modules/Order/index.js +1 -525
  78. package/lib/modules/Order/types.d.ts +12 -176
  79. package/lib/modules/Order/utils.d.ts +0 -118
  80. package/lib/modules/Order/utils.js +2 -483
  81. package/lib/modules/Payment/index.d.ts +2 -1
  82. package/lib/modules/Payment/index.js +1 -0
  83. package/lib/modules/Payment/utils.js +3 -0
  84. package/lib/modules/Payment/walletpass.d.ts +23 -0
  85. package/lib/modules/Payment/walletpass.js +94 -17
  86. package/lib/modules/Product/utils.js +2 -2
  87. package/lib/modules/ProductList/index.d.ts +2 -4
  88. package/lib/modules/ProductList/index.js +39 -46
  89. package/lib/modules/Rules/index.d.ts +9 -5
  90. package/lib/modules/Rules/index.js +776 -292
  91. package/lib/modules/Rules/types.d.ts +2 -0
  92. package/lib/modules/Schedule/getDateIsInSchedule.js +11 -13
  93. package/lib/modules/Schedule/utils.d.ts +1 -1
  94. package/lib/modules/Summary/types.d.ts +2 -0
  95. package/lib/modules/Summary/utils.d.ts +9 -3
  96. package/lib/modules/Summary/utils.js +34 -45
  97. package/lib/modules/index.d.ts +0 -4
  98. package/lib/modules/index.js +1 -9
  99. package/lib/plugins/window.d.ts +2 -0
  100. package/lib/solution/BookingByStep/index.d.ts +3 -2
  101. package/lib/solution/BookingByStep/index.js +4 -6
  102. package/lib/solution/BookingByStep/types.d.ts +1 -3
  103. package/lib/solution/BookingByStep/types.js +0 -10
  104. package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  105. package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
  106. package/lib/solution/Checkout/index.js +2 -0
  107. package/lib/solution/ShopDiscount/index.d.ts +2 -3
  108. package/lib/solution/ShopDiscount/index.js +27 -22
  109. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  110. package/lib/solution/ShopDiscount/utils.js +10 -6
  111. package/lib/solution/index.d.ts +0 -2
  112. package/lib/solution/index.js +1 -5
  113. package/package.json +2 -2
  114. package/dist/apis/picoding.d.ts +0 -0
  115. package/dist/apis/picoding.js +0 -1
  116. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  117. package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
  118. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  119. package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -867
  120. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  121. package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
  122. package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  123. package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
  124. package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -149
  125. package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
  126. package/dist/modules/OpenData/index.d.ts +0 -24
  127. package/dist/modules/OpenData/index.js +0 -173
  128. package/dist/modules/OpenData/types.d.ts +0 -73
  129. package/dist/modules/OpenData/types.js +0 -1
  130. package/dist/modules/OpenData/utils.d.ts +0 -2
  131. package/dist/modules/OpenData/utils.js +0 -75
  132. package/dist/modules/Quotation/index.d.ts +0 -48
  133. package/dist/modules/Quotation/index.js +0 -248
  134. package/dist/modules/Quotation/types.d.ts +0 -42
  135. package/dist/modules/Quotation/types.js +0 -1
  136. package/dist/modules/SalesSummary/index.d.ts +0 -63
  137. package/dist/modules/SalesSummary/index.js +0 -174
  138. package/dist/modules/SalesSummary/types.d.ts +0 -60
  139. package/dist/modules/SalesSummary/types.js +0 -1
  140. package/dist/modules/SalesSummary/utils.d.ts +0 -30
  141. package/dist/modules/SalesSummary/utils.js +0 -480
  142. package/dist/modules/ScanOrderLogger/index.d.ts +0 -23
  143. package/dist/modules/ScanOrderLogger/index.js +0 -174
  144. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
  145. package/dist/modules/ScanOrderLogger/providers/feishu.js +0 -221
  146. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
  147. package/dist/modules/ScanOrderLogger/providers/grafana.js +0 -50
  148. package/dist/modules/ScanOrderLogger/types.d.ts +0 -53
  149. package/dist/modules/ScanOrderLogger/types.js +0 -1
  150. package/dist/solution/ScanOrder/index.d.ts +0 -158
  151. package/dist/solution/ScanOrder/index.js +0 -3474
  152. package/dist/solution/ScanOrder/types.d.ts +0 -306
  153. package/dist/solution/ScanOrder/types.js +0 -35
  154. package/dist/solution/ScanOrder/utils.d.ts +0 -172
  155. package/dist/solution/ScanOrder/utils.js +0 -796
  156. package/dist/solution/VenueBooking/index.d.ts +0 -252
  157. package/dist/solution/VenueBooking/index.js +0 -3769
  158. package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -343
  159. package/dist/solution/VenueBooking/types.d.ts +0 -156
  160. package/dist/solution/VenueBooking/types.js +0 -22
  161. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
  162. package/dist/solution/VenueBooking/utils/dateSummary.js +0 -91
  163. package/dist/solution/VenueBooking/utils/resource.d.ts +0 -14
  164. package/dist/solution/VenueBooking/utils/resource.js +0 -131
  165. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
  166. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -233
  167. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -71
  168. package/dist/solution/VenueBooking/utils/smartPricing.js +0 -302
  169. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
  170. package/dist/solution/VenueBooking/utils/timeSlot.js +0 -458
  171. package/dist/solution/VenueBooking/utils.d.ts +0 -1
  172. package/dist/solution/VenueBooking/utils.js +0 -1
  173. package/lib/apis/picoding.d.ts +0 -0
  174. package/lib/apis/picoding.js +0 -0
  175. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  176. package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
  177. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  178. package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -666
  179. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  180. package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
  181. package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  182. package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
  183. package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -149
  184. package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
  185. package/lib/modules/OpenData/index.d.ts +0 -24
  186. package/lib/modules/OpenData/index.js +0 -119
  187. package/lib/modules/OpenData/types.d.ts +0 -73
  188. package/lib/modules/OpenData/types.js +0 -17
  189. package/lib/modules/OpenData/utils.d.ts +0 -2
  190. package/lib/modules/OpenData/utils.js +0 -111
  191. package/lib/modules/Quotation/index.d.ts +0 -48
  192. package/lib/modules/Quotation/index.js +0 -152
  193. package/lib/modules/Quotation/types.d.ts +0 -42
  194. package/lib/modules/Quotation/types.js +0 -17
  195. package/lib/modules/SalesSummary/index.d.ts +0 -63
  196. package/lib/modules/SalesSummary/index.js +0 -105
  197. package/lib/modules/SalesSummary/types.d.ts +0 -60
  198. package/lib/modules/SalesSummary/types.js +0 -17
  199. package/lib/modules/SalesSummary/utils.d.ts +0 -30
  200. package/lib/modules/SalesSummary/utils.js +0 -420
  201. package/lib/modules/ScanOrderLogger/index.d.ts +0 -23
  202. package/lib/modules/ScanOrderLogger/index.js +0 -147
  203. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
  204. package/lib/modules/ScanOrderLogger/providers/feishu.js +0 -157
  205. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
  206. package/lib/modules/ScanOrderLogger/providers/grafana.js +0 -52
  207. package/lib/modules/ScanOrderLogger/types.d.ts +0 -53
  208. package/lib/modules/ScanOrderLogger/types.js +0 -17
  209. package/lib/solution/ScanOrder/index.d.ts +0 -158
  210. package/lib/solution/ScanOrder/index.js +0 -2135
  211. package/lib/solution/ScanOrder/types.d.ts +0 -306
  212. package/lib/solution/ScanOrder/types.js +0 -36
  213. package/lib/solution/ScanOrder/utils.d.ts +0 -172
  214. package/lib/solution/ScanOrder/utils.js +0 -658
  215. package/lib/solution/VenueBooking/index.d.ts +0 -252
  216. package/lib/solution/VenueBooking/index.js +0 -2204
  217. package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -343
  218. package/lib/solution/VenueBooking/types.d.ts +0 -156
  219. package/lib/solution/VenueBooking/types.js +0 -45
  220. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
  221. package/lib/solution/VenueBooking/utils/dateSummary.js +0 -105
  222. package/lib/solution/VenueBooking/utils/resource.d.ts +0 -14
  223. package/lib/solution/VenueBooking/utils/resource.js +0 -92
  224. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
  225. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -236
  226. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -71
  227. package/lib/solution/VenueBooking/utils/smartPricing.js +0 -225
  228. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
  229. package/lib/solution/VenueBooking/utils/timeSlot.js +0 -343
  230. package/lib/solution/VenueBooking/utils.d.ts +0 -1
  231. package/lib/solution/VenueBooking/utils.js +0 -69
@@ -1,34 +0,0 @@
1
- import dayjs from 'dayjs';
2
- import type { VenueBookingSlotConfig, VenueResourceRawData, VenueTimeSlotGrid, ResourceProductMapping } from '../types';
3
- export declare function isBusinessHoursCrossDay(config: VenueBookingSlotConfig): boolean;
4
- export declare function generateTimeLabels(config: VenueBookingSlotConfig): string[];
5
- export declare function isSlotOccupied(slotStart: dayjs.Dayjs, slotEnd: dayjs.Dayjs, occupiedTimes: Array<{
6
- start_at: string;
7
- end_at: string;
8
- }>): boolean;
9
- interface SlotEvent {
10
- start_at: string;
11
- end_at: string;
12
- pax: number;
13
- }
14
- export declare function collectEventsForDate(resource: VenueResourceRawData, date: string, config: VenueBookingSlotConfig): SlotEvent[];
15
- export declare function computeSlotStatus(params: {
16
- slotStart: dayjs.Dayjs;
17
- slotEnd: dayjs.Dayjs;
18
- events: SlotEvent[];
19
- resourceType: 'single' | 'multiple' | 'capacity';
20
- capacity: number;
21
- }): {
22
- status: 'available' | 'occupied' | 'partially_occupied';
23
- remainingCapacity: number;
24
- };
25
- export declare function buildTimeSlotGrid(params: {
26
- date: string;
27
- config: VenueBookingSlotConfig;
28
- rawResources: VenueResourceRawData[];
29
- resourceProductMap: Map<number | string, ResourceProductMapping[]>;
30
- /** @deprecated 使用 slotPriceMap */
31
- quotationPriceMap?: Map<string, string | null>;
32
- slotPriceMap?: Map<string, string | null>;
33
- }): VenueTimeSlotGrid;
34
- export {};
@@ -1,343 +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/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
- slotPriceMap,
172
- childRawResources,
173
- childTimesCache,
174
- childEventsCache,
175
- config_businessStartHour
176
- } = params;
177
- const slots = [];
178
- for (const label of timeLabels) {
179
- const [h] = label.split(":").map(Number);
180
- const isNextDay = crossDay && h < config_businessStartHour;
181
- const slotDate = isNextDay ? (0, import_dayjs.default)(date).add(1, "day").format("YYYY-MM-DD") : date;
182
- const slotStart = (0, import_dayjs.default)(`${slotDate} ${label}`);
183
- const slotEnd = slotStart.add(config.slotDurationMinutes, "minute");
184
- let status;
185
- let remainingCapacity = null;
186
- if (slotStart.isBefore(now)) {
187
- status = "past";
188
- } else if (!isSlotWithinResourceTimes(slotStart, slotEnd, timesForDate)) {
189
- status = "unavailable";
190
- } else {
191
- const result = computeSlotStatus({
192
- slotStart,
193
- slotEnd,
194
- events,
195
- resourceType: mapping.resourceType,
196
- capacity: resCapacity
197
- });
198
- status = result.status;
199
- remainingCapacity = result.remainingCapacity;
200
- if (status !== "occupied" && childRawResources && childRawResources.length) {
201
- for (let i = 0; i < childRawResources.length; i++) {
202
- const child = childRawResources[i];
203
- const childTimes = (childTimesCache == null ? void 0 : childTimesCache[i]) ?? getResourceTimesForDate(child, date, config);
204
- const childEvents = (childEventsCache == null ? void 0 : childEventsCache[i]) ?? collectEventsForDate(child, date, config);
205
- if (!isSlotWithinResourceTimes(slotStart, slotEnd, childTimes)) {
206
- status = "unavailable";
207
- remainingCapacity = null;
208
- break;
209
- }
210
- const childType = child.type || "single";
211
- const childResult = computeSlotStatus({
212
- slotStart,
213
- slotEnd,
214
- events: childEvents,
215
- resourceType: childType,
216
- capacity: child.capacity ?? 1
217
- });
218
- if (childResult.status === "occupied") {
219
- status = "occupied";
220
- remainingCapacity = 0;
221
- break;
222
- }
223
- if (childResult.status === "partially_occupied" && status === "available") {
224
- status = "partially_occupied";
225
- remainingCapacity = Math.min(
226
- remainingCapacity ?? childResult.remainingCapacity,
227
- childResult.remainingCapacity
228
- );
229
- }
230
- }
231
- }
232
- }
233
- const isBookable = status === "available" || status === "partially_occupied";
234
- const slotStartStr = slotStart.format("YYYY-MM-DD HH:mm");
235
- const resolvedPriceMap = slotPriceMap ?? quotationPriceMap;
236
- slots.push({
237
- startTime: slotStartStr,
238
- endTime: slotEnd.format("YYYY-MM-DD HH:mm"),
239
- status,
240
- price: isBookable ? (resolvedPriceMap == null ? void 0 : resolvedPriceMap.get(`${mapping.productId}:${slotStartStr}`)) ?? mapping.price : null,
241
- resourceId: resource.resourceId,
242
- resourceFormId: resource.formId,
243
- capacity: status === "past" || status === "unavailable" ? null : resCapacity,
244
- remainingCapacity,
245
- productId: mapping.productId
246
- });
247
- }
248
- return slots;
249
- }
250
- function buildTimeSlotGrid(params) {
251
- const { date, config, rawResources, resourceProductMap, quotationPriceMap, slotPriceMap } = params;
252
- const resolvedPriceMap = slotPriceMap ?? quotationPriceMap;
253
- const timeLabels = generateTimeLabels(config);
254
- const now = (0, import_dayjs.default)();
255
- const crossDay = isBusinessHoursCrossDay(config);
256
- const config_businessStartHour = Number(config.businessStartTime.split(":")[0]);
257
- const rawResourceById = /* @__PURE__ */ new Map();
258
- for (const item of rawResources)
259
- rawResourceById.set(item.resourceId, item);
260
- const resources = [];
261
- for (const resource of rawResources) {
262
- const mappings = resourceProductMap.get(resource.resourceId);
263
- if (!mappings || !mappings.length)
264
- continue;
265
- const timesForDate = getResourceTimesForDate(resource, date, config);
266
- const events = collectEventsForDate(resource, date, config);
267
- const resCapacity = resource.capacity ?? 1;
268
- const combined = resource.combined_resource;
269
- const isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids) && combined.resource_ids.length);
270
- const childRawResources = isCombined ? combined.resource_ids.map((id) => rawResourceById.get(id)).filter((r) => !!r) : void 0;
271
- const childTimesCache = childRawResources == null ? void 0 : childRawResources.map((child) => getResourceTimesForDate(child, date, config));
272
- const childEventsCache = childRawResources == null ? void 0 : childRawResources.map((child) => collectEventsForDate(child, date, config));
273
- const subRows = mappings.map((mapping) => {
274
- const productSlots = buildProductSlots({
275
- date,
276
- config,
277
- resource,
278
- mapping,
279
- timeLabels,
280
- timesForDate,
281
- events,
282
- resCapacity,
283
- now,
284
- crossDay,
285
- quotationPriceMap: resolvedPriceMap,
286
- slotPriceMap: resolvedPriceMap,
287
- childRawResources,
288
- childTimesCache,
289
- childEventsCache,
290
- config_businessStartHour
291
- });
292
- return {
293
- productId: mapping.productId,
294
- productTitle: mapping.productTitle,
295
- price: mapping.price,
296
- slots: productSlots
297
- };
298
- });
299
- const hasMultipleProducts = subRows.length > 1;
300
- const primary = mappings[0];
301
- let outerSlots;
302
- if (hasMultipleProducts) {
303
- outerSlots = timeLabels.map((_label, slotIndex) => {
304
- const group = subRows.map((row2) => row2.slots[slotIndex]);
305
- return mergeSubSlots(group);
306
- });
307
- } else {
308
- outerSlots = subRows[0].slots.map((slot) => ({ ...slot, productId: void 0 }));
309
- }
310
- const row = {
311
- resourceId: resource.resourceId,
312
- resourceFormId: resource.formId,
313
- resourceName: resource.main_field || primary.resourceName,
314
- productId: primary.productId,
315
- productTitle: primary.productTitle,
316
- slots: outerSlots
317
- };
318
- if (hasMultipleProducts) {
319
- row.products = subRows;
320
- row.hasMultipleProducts = true;
321
- }
322
- if (isCombined && combined) {
323
- row.combinedResource = { resourceIds: [...combined.resource_ids] };
324
- }
325
- resources.push(row);
326
- }
327
- const productOrder = /* @__PURE__ */ new Map();
328
- for (const row of resources) {
329
- if (!productOrder.has(row.productId))
330
- productOrder.set(row.productId, productOrder.size);
331
- }
332
- resources.sort((a, b) => (productOrder.get(a.productId) ?? 0) - (productOrder.get(b.productId) ?? 0));
333
- return { date, timeLabels, resources };
334
- }
335
- // Annotate the CommonJS export names for ESM import in node:
336
- 0 && (module.exports = {
337
- buildTimeSlotGrid,
338
- collectEventsForDate,
339
- computeSlotStatus,
340
- generateTimeLabels,
341
- isBusinessHoursCrossDay,
342
- isSlotOccupied
343
- });
@@ -1 +0,0 @@
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';
@@ -1,69 +0,0 @@
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
- });