@pisell/pisellos 3.0.90 → 3.0.92
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/index.d.ts +1 -0
- package/dist/model/index.js +1 -0
- package/dist/model/strategy/adapter/index.d.ts +7 -0
- package/dist/model/strategy/adapter/index.js +7 -0
- 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/model/strategy/adapter/promotion/adapter.d.ts +66 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +271 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +1206 -0
- package/dist/model/strategy/adapter/promotion/examples.d.ts +138 -0
- package/dist/model/strategy/adapter/promotion/examples.js +166 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/promotion/type.d.ts +447 -0
- package/dist/model/strategy/adapter/promotion/type.js +209 -0
- package/dist/model/strategy/adapter/type.d.ts +28 -0
- package/dist/model/strategy/adapter/type.js +1 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +502 -0
- package/dist/model/strategy/adapter/walletPass/example.d.ts +4 -0
- package/dist/model/strategy/adapter/walletPass/example.js +258 -0
- package/dist/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/dist/model/strategy/adapter/walletPass/index.js +182 -0
- package/dist/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/dist/model/strategy/adapter/walletPass/locales.js +26 -0
- package/dist/model/strategy/adapter/walletPass/type.d.ts +187 -0
- package/dist/model/strategy/adapter/walletPass/type.js +1 -0
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/dist/model/strategy/adapter/walletPass/utils.js +1104 -0
- package/dist/model/strategy/engine.d.ts +106 -0
- package/dist/model/strategy/engine.js +611 -0
- package/dist/model/strategy/index.d.ts +3 -0
- package/dist/model/strategy/index.js +8 -0
- package/dist/model/strategy/strategy-example.d.ts +5 -0
- package/dist/model/strategy/strategy-example.js +331 -0
- package/dist/model/strategy/type.d.ts +228 -0
- package/dist/model/strategy/type.js +94 -0
- package/dist/modules/Cart/utils/cartProduct.js +1 -0
- package/dist/modules/Discount/index.d.ts +4 -2
- package/dist/modules/Discount/index.js +90 -3
- package/dist/modules/Discount/types.d.ts +6 -0
- 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 +66 -1
- package/dist/modules/Order/index.js +884 -10
- package/dist/modules/Order/types.d.ts +174 -12
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils.d.ts +118 -0
- package/dist/modules/Order/utils.js +586 -2
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.d.ts +3 -1
- package/dist/modules/ProductList/index.js +26 -11
- package/dist/modules/Quotation/index.d.ts +48 -0
- package/dist/modules/Quotation/index.js +248 -0
- package/dist/modules/Quotation/types.d.ts +42 -0
- package/dist/modules/Quotation/types.js +1 -0
- package/dist/modules/Rules/index.js +17 -18
- package/dist/modules/SalesSummary/index.d.ts +63 -0
- package/dist/modules/SalesSummary/index.js +174 -0
- package/dist/modules/SalesSummary/types.d.ts +60 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +30 -0
- package/dist/modules/SalesSummary/utils.js +480 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +23 -0
- package/dist/modules/ScanOrderLogger/index.js +174 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +221 -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 +53 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/utils.d.ts +3 -3
- package/dist/modules/Summary/utils.js +41 -31
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/ScanOrder/index.d.ts +158 -0
- package/dist/solution/ScanOrder/index.js +3474 -0
- package/dist/solution/ScanOrder/types.d.ts +306 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +172 -0
- package/dist/solution/ScanOrder/utils.js +796 -0
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +23 -18
- package/dist/solution/VenueBooking/index.d.ts +201 -0
- package/dist/solution/VenueBooking/index.js +3472 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +154 -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 +131 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +239 -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 +2 -0
- package/dist/solution/index.js +3 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/model/index.d.ts +1 -0
- package/lib/model/index.js +23 -0
- package/lib/model/strategy/adapter/index.d.ts +7 -0
- package/lib/model/strategy/adapter/index.js +57 -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/adapter.d.ts +66 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +217 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +844 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +138 -0
- package/lib/model/strategy/adapter/promotion/examples.js +192 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/index.js +0 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +447 -0
- package/lib/model/strategy/adapter/promotion/type.js +51 -0
- package/lib/model/strategy/adapter/type.d.ts +28 -0
- package/lib/model/strategy/adapter/type.js +17 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +424 -0
- package/lib/model/strategy/adapter/walletPass/example.d.ts +4 -0
- package/lib/model/strategy/adapter/walletPass/example.js +207 -0
- package/lib/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/lib/model/strategy/adapter/walletPass/index.js +142 -0
- package/lib/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/lib/model/strategy/adapter/walletPass/locales.js +54 -0
- package/lib/model/strategy/adapter/walletPass/type.d.ts +187 -0
- package/lib/model/strategy/adapter/walletPass/type.js +17 -0
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +791 -0
- package/lib/model/strategy/engine.d.ts +106 -0
- package/lib/model/strategy/engine.js +450 -0
- package/lib/model/strategy/index.d.ts +3 -0
- package/lib/model/strategy/index.js +38 -0
- package/lib/model/strategy/strategy-example.d.ts +5 -0
- package/lib/model/strategy/strategy-example.js +318 -0
- package/lib/model/strategy/type.d.ts +228 -0
- package/lib/model/strategy/type.js +44 -0
- package/lib/modules/Cart/utils/cartProduct.js +1 -0
- package/lib/modules/Discount/index.d.ts +4 -2
- package/lib/modules/Discount/index.js +60 -2
- package/lib/modules/Discount/types.d.ts +6 -0
- 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 +66 -1
- package/lib/modules/Order/index.js +525 -0
- package/lib/modules/Order/types.d.ts +174 -12
- package/lib/modules/Order/utils.d.ts +118 -0
- package/lib/modules/Order/utils.js +483 -2
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +3 -1
- package/lib/modules/ProductList/index.js +51 -34
- package/lib/modules/Quotation/index.d.ts +48 -0
- package/lib/modules/Quotation/index.js +152 -0
- package/lib/modules/Quotation/types.d.ts +42 -0
- package/lib/modules/Quotation/types.js +17 -0
- package/lib/modules/Rules/index.js +17 -18
- package/lib/modules/SalesSummary/index.d.ts +63 -0
- package/lib/modules/SalesSummary/index.js +105 -0
- package/lib/modules/SalesSummary/types.d.ts +60 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +30 -0
- package/lib/modules/SalesSummary/utils.js +420 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +23 -0
- package/lib/modules/ScanOrderLogger/index.js +147 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +157 -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 +53 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/utils.d.ts +3 -3
- package/lib/modules/Summary/utils.js +22 -16
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/ScanOrder/index.d.ts +158 -0
- package/lib/solution/ScanOrder/index.js +2135 -0
- package/lib/solution/ScanOrder/types.d.ts +306 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +172 -0
- package/lib/solution/ScanOrder/utils.js +658 -0
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +4 -2
- package/lib/solution/VenueBooking/index.d.ts +201 -0
- package/lib/solution/VenueBooking/index.js +1937 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +154 -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 +92 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +237 -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 +2 -0
- package/lib/solution/index.js +5 -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
|
@@ -20,10 +20,14 @@ __reExport(solution_exports, require("./BuyTickets"), module.exports);
|
|
|
20
20
|
__reExport(solution_exports, require("./BookingByStep"), module.exports);
|
|
21
21
|
__reExport(solution_exports, require("./ShopDiscount"), module.exports);
|
|
22
22
|
__reExport(solution_exports, require("./RegisterAndLogin"), module.exports);
|
|
23
|
+
__reExport(solution_exports, require("./ScanOrder"), module.exports);
|
|
24
|
+
__reExport(solution_exports, require("./VenueBooking"), module.exports);
|
|
23
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
24
26
|
0 && (module.exports = {
|
|
25
27
|
...require("./BuyTickets"),
|
|
26
28
|
...require("./BookingByStep"),
|
|
27
29
|
...require("./ShopDiscount"),
|
|
28
|
-
...require("./RegisterAndLogin")
|
|
30
|
+
...require("./RegisterAndLogin"),
|
|
31
|
+
...require("./ScanOrder"),
|
|
32
|
+
...require("./VenueBooking")
|
|
29
33
|
});
|