@pisell/pisellos 2.1.150 → 2.1.151
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.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +99 -26
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +61 -8
- package/dist/model/strategy/adapter/walletPass/locales.js +12 -3
- package/dist/model/strategy/engine.d.ts +18 -5
- package/dist/model/strategy/engine.js +145 -45
- package/dist/model/strategy/type.d.ts +17 -0
- package/dist/model/strategy/type.js +4 -0
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +56 -25
- package/dist/modules/Discount/index.d.ts +2 -6
- package/dist/modules/Discount/index.js +8 -14
- package/dist/modules/Discount/types.d.ts +19 -1
- package/dist/modules/Order/index.d.ts +1 -65
- package/dist/modules/Order/index.js +30 -901
- package/dist/modules/Order/types.d.ts +12 -174
- package/dist/modules/Order/types.js +0 -2
- package/dist/modules/Order/utils.d.ts +0 -118
- package/dist/modules/Order/utils.js +2 -586
- package/dist/modules/Payment/index.d.ts +2 -1
- package/dist/modules/Payment/index.js +10 -7
- package/dist/modules/Payment/utils.js +3 -0
- package/dist/modules/Payment/walletpass.d.ts +23 -0
- package/dist/modules/Payment/walletpass.js +191 -95
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +3 -4
- package/dist/modules/Rules/index.d.ts +9 -5
- package/dist/modules/Rules/index.js +677 -168
- package/dist/modules/Rules/types.d.ts +2 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +18 -11
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/types.d.ts +2 -0
- package/dist/modules/Summary/utils.d.ts +9 -3
- package/dist/modules/Summary/utils.js +52 -41
- package/dist/modules/index.d.ts +0 -4
- package/dist/modules/index.js +1 -5
- package/dist/plugins/window.d.ts +2 -0
- package/dist/solution/BookingByStep/index.d.ts +3 -2
- package/dist/solution/BookingByStep/index.js +43 -46
- package/dist/solution/BookingByStep/types.d.ts +1 -3
- package/dist/solution/BookingByStep/types.js +1 -5
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
- package/dist/solution/Checkout/index.js +2 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -2
- package/dist/solution/ShopDiscount/index.js +41 -37
- package/dist/solution/ShopDiscount/types.d.ts +1 -1
- package/dist/solution/ShopDiscount/types.js +2 -1
- package/dist/solution/ShopDiscount/utils.js +26 -12
- package/dist/solution/index.d.ts +0 -2
- package/dist/solution/index.js +1 -3
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/model/strategy/adapter/promotion/evaluator.js +57 -8
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +34 -3
- package/lib/model/strategy/adapter/walletPass/locales.js +12 -3
- package/lib/model/strategy/engine.d.ts +18 -5
- package/lib/model/strategy/engine.js +85 -21
- package/lib/model/strategy/type.d.ts +17 -0
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +39 -12
- package/lib/modules/Discount/index.d.ts +2 -6
- package/lib/modules/Discount/index.js +1 -3
- package/lib/modules/Discount/types.d.ts +19 -1
- package/lib/modules/Order/index.d.ts +1 -65
- package/lib/modules/Order/index.js +1 -513
- package/lib/modules/Order/types.d.ts +12 -174
- package/lib/modules/Order/utils.d.ts +0 -118
- package/lib/modules/Order/utils.js +2 -483
- package/lib/modules/Payment/index.d.ts +2 -1
- package/lib/modules/Payment/index.js +1 -0
- package/lib/modules/Payment/utils.js +3 -0
- package/lib/modules/Payment/walletpass.d.ts +23 -0
- package/lib/modules/Payment/walletpass.js +94 -17
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +3 -5
- package/lib/modules/Rules/index.d.ts +9 -5
- package/lib/modules/Rules/index.js +780 -288
- package/lib/modules/Rules/types.d.ts +2 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +11 -9
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/types.d.ts +2 -0
- package/lib/modules/Summary/utils.d.ts +9 -3
- package/lib/modules/Summary/utils.js +31 -22
- package/lib/modules/index.d.ts +0 -4
- package/lib/modules/index.js +1 -9
- package/lib/plugins/window.d.ts +2 -0
- package/lib/solution/BookingByStep/index.d.ts +3 -2
- package/lib/solution/BookingByStep/index.js +4 -6
- package/lib/solution/BookingByStep/types.d.ts +1 -3
- package/lib/solution/BookingByStep/types.js +0 -10
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
- package/lib/solution/Checkout/index.js +2 -0
- package/lib/solution/ShopDiscount/index.d.ts +2 -2
- package/lib/solution/ShopDiscount/index.js +24 -16
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/solution/ShopDiscount/utils.js +10 -6
- package/lib/solution/index.d.ts +0 -2
- package/lib/solution/index.js +1 -5
- package/package.json +1 -1
- package/dist/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +0 -1
- package/dist/modules/OpenData/index.d.ts +0 -24
- package/dist/modules/OpenData/index.js +0 -173
- package/dist/modules/OpenData/types.d.ts +0 -73
- package/dist/modules/OpenData/types.js +0 -1
- package/dist/modules/OpenData/utils.d.ts +0 -2
- package/dist/modules/OpenData/utils.js +0 -75
- package/dist/modules/Quotation/index.d.ts +0 -48
- package/dist/modules/Quotation/index.js +0 -248
- package/dist/modules/Quotation/types.d.ts +0 -42
- package/dist/modules/Quotation/types.js +0 -1
- package/dist/modules/SalesSummary/index.d.ts +0 -63
- package/dist/modules/SalesSummary/index.js +0 -174
- package/dist/modules/SalesSummary/types.d.ts +0 -60
- package/dist/modules/SalesSummary/types.js +0 -1
- package/dist/modules/SalesSummary/utils.d.ts +0 -30
- package/dist/modules/SalesSummary/utils.js +0 -480
- package/dist/modules/ScanOrderLogger/index.d.ts +0 -23
- package/dist/modules/ScanOrderLogger/index.js +0 -174
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
- package/dist/modules/ScanOrderLogger/providers/feishu.js +0 -221
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
- package/dist/modules/ScanOrderLogger/providers/grafana.js +0 -50
- package/dist/modules/ScanOrderLogger/types.d.ts +0 -53
- package/dist/modules/ScanOrderLogger/types.js +0 -1
- package/dist/solution/ScanOrder/index.d.ts +0 -152
- package/dist/solution/ScanOrder/index.js +0 -3132
- package/dist/solution/ScanOrder/types.d.ts +0 -287
- package/dist/solution/ScanOrder/types.js +0 -35
- package/dist/solution/ScanOrder/utils.d.ts +0 -167
- package/dist/solution/ScanOrder/utils.js +0 -764
- package/dist/solution/VenueBooking/index.d.ts +0 -199
- package/dist/solution/VenueBooking/index.js +0 -3459
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -343
- package/dist/solution/VenueBooking/types.d.ts +0 -154
- package/dist/solution/VenueBooking/types.js +0 -21
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
- package/dist/solution/VenueBooking/utils/dateSummary.js +0 -104
- package/dist/solution/VenueBooking/utils/resource.d.ts +0 -14
- package/dist/solution/VenueBooking/utils/resource.js +0 -131
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -38
- package/dist/solution/VenueBooking/utils/slotMerge.js +0 -239
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -32
- package/dist/solution/VenueBooking/utils/timeSlot.js +0 -453
- package/dist/solution/VenueBooking/utils.d.ts +0 -1
- package/dist/solution/VenueBooking/utils.js +0 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/modules/OpenData/index.d.ts +0 -24
- package/lib/modules/OpenData/index.js +0 -119
- package/lib/modules/OpenData/types.d.ts +0 -73
- package/lib/modules/OpenData/types.js +0 -17
- package/lib/modules/OpenData/utils.d.ts +0 -2
- package/lib/modules/OpenData/utils.js +0 -111
- package/lib/modules/Quotation/index.d.ts +0 -48
- package/lib/modules/Quotation/index.js +0 -152
- package/lib/modules/Quotation/types.d.ts +0 -42
- package/lib/modules/Quotation/types.js +0 -17
- package/lib/modules/SalesSummary/index.d.ts +0 -63
- package/lib/modules/SalesSummary/index.js +0 -105
- package/lib/modules/SalesSummary/types.d.ts +0 -60
- package/lib/modules/SalesSummary/types.js +0 -17
- package/lib/modules/SalesSummary/utils.d.ts +0 -30
- package/lib/modules/SalesSummary/utils.js +0 -420
- package/lib/modules/ScanOrderLogger/index.d.ts +0 -23
- package/lib/modules/ScanOrderLogger/index.js +0 -147
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
- package/lib/modules/ScanOrderLogger/providers/feishu.js +0 -157
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
- package/lib/modules/ScanOrderLogger/providers/grafana.js +0 -52
- package/lib/modules/ScanOrderLogger/types.d.ts +0 -53
- package/lib/modules/ScanOrderLogger/types.js +0 -17
- package/lib/solution/ScanOrder/index.d.ts +0 -152
- package/lib/solution/ScanOrder/index.js +0 -1901
- package/lib/solution/ScanOrder/types.d.ts +0 -287
- package/lib/solution/ScanOrder/types.js +0 -36
- package/lib/solution/ScanOrder/utils.d.ts +0 -167
- package/lib/solution/ScanOrder/utils.js +0 -635
- package/lib/solution/VenueBooking/index.d.ts +0 -199
- package/lib/solution/VenueBooking/index.js +0 -1926
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -343
- package/lib/solution/VenueBooking/types.d.ts +0 -154
- package/lib/solution/VenueBooking/types.js +0 -44
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
- package/lib/solution/VenueBooking/utils/dateSummary.js +0 -110
- package/lib/solution/VenueBooking/utils/resource.d.ts +0 -14
- package/lib/solution/VenueBooking/utils/resource.js +0 -92
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -38
- package/lib/solution/VenueBooking/utils/slotMerge.js +0 -237
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -32
- package/lib/solution/VenueBooking/utils/timeSlot.js +0 -339
- package/lib/solution/VenueBooking/utils.d.ts +0 -1
- package/lib/solution/VenueBooking/utils.js +0 -69
|
@@ -1,339 +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
|
-
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
|
-
});
|
|
@@ -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
|
-
});
|