@pisell/pisellos 2.2.147 → 2.2.149
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/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +1 -0
- package/dist/model/strategy/adapter/index.d.ts +2 -0
- package/dist/model/strategy/adapter/index.js +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +483 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
- package/dist/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +382 -0
- package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/dist/model/strategy/adapter/itemRule/index.js +5 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/dist/model/strategy/adapter/itemRule/type.js +101 -0
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +22 -1
- package/dist/modules/Cart/utils/changePrice.js +6 -0
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +16 -8
- package/dist/modules/Date/types.d.ts +3 -1
- package/dist/modules/OpenData/index.d.ts +24 -0
- package/dist/modules/OpenData/index.js +173 -0
- package/dist/modules/OpenData/types.d.ts +73 -0
- package/dist/modules/OpenData/types.js +1 -0
- package/dist/modules/OpenData/utils.d.ts +2 -0
- package/dist/modules/OpenData/utils.js +75 -0
- package/dist/modules/Order/index.d.ts +171 -1
- package/dist/modules/Order/index.js +2052 -112
- package/dist/modules/Order/types.d.ts +441 -20
- package/dist/modules/Order/types.js +23 -0
- package/dist/modules/Order/utils.d.ts +120 -0
- package/dist/modules/Order/utils.js +653 -2
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.js +2 -1
- package/dist/modules/Quotation/index.d.ts +8 -1
- package/dist/modules/Quotation/index.js +40 -10
- package/dist/modules/Quotation/types.d.ts +5 -0
- package/dist/modules/Rules/index.d.ts +3 -1
- package/dist/modules/Rules/index.js +136 -50
- package/dist/modules/Rules/types.d.ts +6 -0
- package/dist/modules/Rules/types.js +8 -0
- package/dist/modules/SalesSummary/index.d.ts +70 -0
- package/dist/modules/SalesSummary/index.js +175 -0
- package/dist/modules/SalesSummary/types.d.ts +64 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +34 -0
- package/dist/modules/SalesSummary/utils.js +488 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +21 -0
- package/dist/modules/ScanOrderLogger/index.js +161 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +203 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
- package/dist/modules/ScanOrderLogger/types.d.ts +52 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +7 -7
- package/dist/modules/Schedule/index.d.ts +4 -13
- package/dist/modules/Schedule/index.js +6 -23
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/index.d.ts +3 -0
- package/dist/modules/Summary/index.js +134 -15
- package/dist/modules/Summary/types.d.ts +7 -0
- package/dist/modules/Summary/utils.d.ts +104 -1
- package/dist/modules/Summary/utils.js +1116 -13
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/server/index.d.ts +41 -4
- package/dist/server/index.js +900 -405
- package/dist/server/modules/order/index.d.ts +10 -2
- package/dist/server/modules/order/index.js +251 -196
- package/dist/server/modules/products/index.d.ts +26 -0
- package/dist/server/modules/products/index.js +618 -338
- package/dist/server/modules/products/types.d.ts +5 -1
- package/dist/solution/BaseSales/index.d.ts +175 -0
- package/dist/solution/BaseSales/index.js +1293 -0
- package/dist/solution/BaseSales/types.d.ts +305 -0
- package/dist/solution/BaseSales/types.js +38 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +159 -0
- package/dist/solution/BaseSales/utils.d.ts +40 -0
- package/dist/solution/BaseSales/utils.js +222 -0
- package/dist/solution/BookingByStep/index.d.ts +14 -0
- package/dist/solution/BookingByStep/index.js +699 -212
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/BookingByStep/utils/capacity.js +1 -1
- package/dist/solution/BookingByStep/utils/resources.js +6 -1
- package/dist/solution/BookingTicket/index.d.ts +113 -15
- package/dist/solution/BookingTicket/index.js +534 -196
- package/dist/solution/BookingTicket/types.d.ts +69 -6
- package/dist/solution/BookingTicket/types.js +40 -9
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.js +66 -0
- package/dist/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/dist/solution/BookingTicket/utils/cartView.js +84 -0
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +1 -0
- package/dist/solution/ScanOrder/index.d.ts +146 -0
- package/dist/solution/ScanOrder/index.js +3029 -0
- package/dist/solution/ScanOrder/types.d.ts +305 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +167 -0
- package/dist/solution/ScanOrder/utils.js +768 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +9 -5
- package/dist/solution/ShopDiscount/types.d.ts +4 -0
- package/dist/solution/VenueBooking/index.d.ts +197 -0
- package/dist/solution/VenueBooking/index.js +3411 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +153 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/dist/solution/VenueBooking/utils/resource.js +130 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +224 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +3 -0
- package/dist/solution/index.js +4 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/model/strategy/adapter/index.d.ts +2 -0
- package/lib/model/strategy/adapter/index.js +6 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +377 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
- package/lib/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +316 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/lib/model/strategy/adapter/itemRule/index.js +60 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/lib/model/strategy/adapter/itemRule/type.js +46 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +17 -1
- package/lib/modules/Cart/utils/changePrice.js +5 -0
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +7 -1
- package/lib/modules/Date/types.d.ts +3 -1
- package/lib/modules/OpenData/index.d.ts +24 -0
- package/lib/modules/OpenData/index.js +119 -0
- package/lib/modules/OpenData/types.d.ts +73 -0
- package/lib/modules/OpenData/types.js +17 -0
- package/lib/modules/OpenData/utils.d.ts +2 -0
- package/lib/modules/OpenData/utils.js +111 -0
- package/lib/modules/Order/index.d.ts +171 -1
- package/lib/modules/Order/index.js +1396 -5
- package/lib/modules/Order/types.d.ts +441 -20
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils.d.ts +120 -0
- package/lib/modules/Order/utils.js +562 -2
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.js +2 -1
- package/lib/modules/Quotation/index.d.ts +8 -1
- package/lib/modules/Quotation/index.js +33 -4
- package/lib/modules/Quotation/types.d.ts +5 -0
- package/lib/modules/Rules/index.d.ts +3 -1
- package/lib/modules/Rules/index.js +46 -6
- package/lib/modules/Rules/types.d.ts +6 -0
- package/lib/modules/Rules/types.js +11 -2
- package/lib/modules/SalesSummary/index.d.ts +70 -0
- package/lib/modules/SalesSummary/index.js +106 -0
- package/lib/modules/SalesSummary/types.d.ts +64 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +34 -0
- package/lib/modules/SalesSummary/utils.js +430 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +21 -0
- package/lib/modules/ScanOrderLogger/index.js +135 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +148 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
- package/lib/modules/ScanOrderLogger/types.d.ts +52 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +5 -5
- package/lib/modules/Schedule/index.d.ts +4 -13
- package/lib/modules/Schedule/index.js +4 -15
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/index.d.ts +3 -0
- package/lib/modules/Summary/index.js +61 -2
- package/lib/modules/Summary/types.d.ts +7 -0
- package/lib/modules/Summary/utils.d.ts +104 -1
- package/lib/modules/Summary/utils.js +659 -8
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/server/index.d.ts +41 -4
- package/lib/server/index.js +272 -10
- package/lib/server/modules/order/index.d.ts +10 -2
- package/lib/server/modules/order/index.js +31 -4
- package/lib/server/modules/products/index.d.ts +26 -0
- package/lib/server/modules/products/index.js +174 -22
- package/lib/server/modules/products/types.d.ts +5 -1
- package/lib/solution/BaseSales/index.d.ts +175 -0
- package/lib/solution/BaseSales/index.js +655 -0
- package/lib/solution/BaseSales/types.d.ts +305 -0
- package/lib/solution/BaseSales/types.js +40 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +160 -0
- package/lib/solution/BaseSales/utils.d.ts +40 -0
- package/lib/solution/BaseSales/utils.js +200 -0
- package/lib/solution/BookingByStep/index.d.ts +14 -0
- package/lib/solution/BookingByStep/index.js +469 -91
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/BookingByStep/utils/capacity.js +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +5 -2
- package/lib/solution/BookingTicket/index.d.ts +113 -15
- package/lib/solution/BookingTicket/index.js +253 -61
- package/lib/solution/BookingTicket/types.d.ts +69 -6
- package/lib/solution/BookingTicket/types.js +16 -14
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.js +65 -0
- package/lib/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/lib/solution/BookingTicket/utils/cartView.js +103 -0
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.d.ts +146 -0
- package/lib/solution/ScanOrder/index.js +1820 -0
- package/lib/solution/ScanOrder/types.d.ts +305 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +167 -0
- package/lib/solution/ScanOrder/utils.js +639 -0
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +9 -4
- package/lib/solution/ShopDiscount/types.d.ts +4 -0
- package/lib/solution/VenueBooking/index.d.ts +197 -0
- package/lib/solution/VenueBooking/index.js +1892 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +153 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/lib/solution/VenueBooking/utils/resource.js +91 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +225 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +3 -0
- package/lib/solution/index.js +7 -1
- 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
|
+
});
|
package/lib/solution/index.d.ts
CHANGED
package/lib/solution/index.js
CHANGED
|
@@ -23,6 +23,9 @@ __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
25
|
__reExport(solution_exports, require("./Sales"), module.exports);
|
|
26
|
+
__reExport(solution_exports, require("./ScanOrder"), module.exports);
|
|
27
|
+
__reExport(solution_exports, require("./BaseSales"), module.exports);
|
|
28
|
+
__reExport(solution_exports, require("./VenueBooking"), module.exports);
|
|
26
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
27
30
|
0 && (module.exports = {
|
|
28
31
|
...require("./BuyTickets"),
|
|
@@ -31,5 +34,8 @@ __reExport(solution_exports, require("./Sales"), module.exports);
|
|
|
31
34
|
...require("./ShopDiscount"),
|
|
32
35
|
...require("./RegisterAndLogin"),
|
|
33
36
|
...require("./Checkout"),
|
|
34
|
-
...require("./Sales")
|
|
37
|
+
...require("./Sales"),
|
|
38
|
+
...require("./ScanOrder"),
|
|
39
|
+
...require("./BaseSales"),
|
|
40
|
+
...require("./VenueBooking")
|
|
35
41
|
});
|