@pisell/pisellos 2.2.178 → 2.2.180
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/modules/Customer/index.d.ts +0 -6
- package/dist/modules/Customer/index.js +83 -129
- package/dist/modules/Customer/types.d.ts +0 -2
- package/dist/modules/Discount/index.d.ts +4 -2
- package/dist/modules/Discount/index.js +93 -8
- package/dist/modules/Discount/types.d.ts +7 -1
- package/dist/modules/Order/index.d.ts +17 -87
- package/dist/modules/Order/index.js +501 -1357
- package/dist/modules/Order/types.d.ts +19 -198
- package/dist/modules/Order/types.js +0 -31
- package/dist/modules/Order/utils.d.ts +1 -50
- package/dist/modules/Order/utils.js +32 -261
- package/dist/modules/Quotation/index.d.ts +1 -0
- package/dist/modules/Quotation/index.js +21 -23
- package/dist/modules/Rules/index.d.ts +0 -4
- package/dist/modules/Rules/index.js +10 -26
- package/dist/modules/SalesSummary/index.js +2 -4
- package/dist/modules/SalesSummary/utils.js +7 -21
- package/dist/modules/Schedule/index.js +2 -6
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +1 -2
- package/dist/server/index.js +29 -87
- package/dist/server/modules/order/index.d.ts +0 -23
- package/dist/server/modules/order/index.js +46 -123
- package/dist/server/modules/order/types.d.ts +2 -0
- package/dist/server/modules/order/utils/filterOrders.js +6 -20
- package/dist/server/modules/products/index.d.ts +1 -1
- package/dist/server/modules/products/index.js +113 -130
- package/dist/server/modules/schedule/index.js +6 -13
- package/dist/solution/BaseSales/index.d.ts +7 -89
- package/dist/solution/BaseSales/index.js +375 -1494
- package/dist/solution/BaseSales/types.d.ts +1 -67
- package/dist/solution/BaseSales/types.js +1 -3
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -68
- package/dist/solution/BaseSales/utils.js +8 -46
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -133
- package/dist/solution/BookingTicket/index.js +175 -780
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/BookingTicket/types.js +0 -3
- package/dist/solution/BookingTicket/utils/cartView.js +2 -4
- package/dist/solution/ScanOrder/index.d.ts +3 -9
- package/dist/solution/ScanOrder/index.js +128 -231
- package/dist/solution/ScanOrder/utils.js +8 -46
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +23 -18
- package/dist/solution/VenueBooking/index.d.ts +9 -5
- package/dist/solution/VenueBooking/index.js +55 -103
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Customer/index.d.ts +0 -6
- package/lib/modules/Customer/index.js +11 -26
- package/lib/modules/Customer/types.d.ts +0 -2
- package/lib/modules/Discount/index.d.ts +4 -2
- package/lib/modules/Discount/index.js +63 -8
- package/lib/modules/Discount/types.d.ts +7 -1
- package/lib/modules/Order/index.d.ts +17 -87
- package/lib/modules/Order/index.js +150 -677
- package/lib/modules/Order/types.d.ts +19 -198
- package/lib/modules/Order/types.js +0 -1
- package/lib/modules/Order/utils.d.ts +1 -50
- package/lib/modules/Order/utils.js +22 -229
- package/lib/modules/Quotation/index.d.ts +1 -0
- package/lib/modules/Quotation/index.js +15 -18
- package/lib/modules/Rules/index.d.ts +0 -4
- package/lib/modules/Rules/index.js +14 -22
- package/lib/modules/SalesSummary/index.js +2 -4
- package/lib/modules/SalesSummary/utils.js +7 -21
- package/lib/modules/Schedule/index.js +1 -3
- package/lib/modules/index.d.ts +0 -1
- package/lib/modules/index.js +1 -3
- package/lib/server/index.js +4 -41
- package/lib/server/modules/order/index.d.ts +0 -23
- package/lib/server/modules/order/index.js +14 -46
- package/lib/server/modules/order/types.d.ts +2 -0
- package/lib/server/modules/order/utils/filterOrders.js +4 -12
- package/lib/server/modules/products/index.d.ts +1 -1
- package/lib/server/modules/products/index.js +20 -30
- package/lib/server/modules/schedule/index.js +1 -2
- package/lib/solution/BaseSales/index.d.ts +7 -89
- package/lib/solution/BaseSales/index.js +22 -736
- package/lib/solution/BaseSales/types.d.ts +1 -67
- package/lib/solution/BaseSales/types.js +1 -3
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +12 -71
- package/lib/solution/BaseSales/utils.js +6 -46
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -133
- package/lib/solution/BookingTicket/index.js +8 -352
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/BookingTicket/types.js +0 -6
- package/lib/solution/BookingTicket/utils/cartView.js +2 -4
- package/lib/solution/ScanOrder/index.d.ts +3 -9
- package/lib/solution/ScanOrder/index.js +66 -147
- package/lib/solution/ScanOrder/utils.js +6 -46
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +4 -2
- package/lib/solution/VenueBooking/index.d.ts +9 -5
- package/lib/solution/VenueBooking/index.js +14 -50
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/package.json +2 -2
- package/dist/modules/BookingContext/index.d.ts +0 -37
- package/dist/modules/BookingContext/index.js +0 -436
- package/dist/modules/BookingContext/types.d.ts +0 -102
- package/dist/modules/BookingContext/types.js +0 -51
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -193
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -137
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -215
- package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/dist/modules/BookingContext/utils/flexible.js +0 -56
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
- package/dist/modules/BookingContext/utils/index.d.ts +0 -11
- package/dist/modules/BookingContext/utils/index.js +0 -11
- package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/dist/modules/BookingContext/utils/noResource.js +0 -77
- package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/dist/modules/BookingContext/utils/productExtend.js +0 -339
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
- package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
- package/dist/modules/BookingContext/utils/resources.js +0 -486
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/dist/modules/Order/utils/manualProductDiscount.js +0 -212
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +0 -275
- package/dist/solution/BaseSales/utils/cartPromotion.js +0 -1258
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
- package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
- package/lib/modules/BookingContext/index.d.ts +0 -37
- package/lib/modules/BookingContext/index.js +0 -297
- package/lib/modules/BookingContext/types.d.ts +0 -102
- package/lib/modules/BookingContext/types.js +0 -34
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -207
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -141
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -198
- package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/lib/modules/BookingContext/utils/flexible.js +0 -80
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
- package/lib/modules/BookingContext/utils/index.d.ts +0 -11
- package/lib/modules/BookingContext/utils/index.js +0 -43
- package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/lib/modules/BookingContext/utils/noResource.js +0 -90
- package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/lib/modules/BookingContext/utils/productExtend.js +0 -283
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
- package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
- package/lib/modules/BookingContext/utils/resources.js +0 -377
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/lib/modules/Order/utils/manualProductDiscount.js +0 -207
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +0 -275
- package/lib/solution/BaseSales/utils/cartPromotion.js +0 -836
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
- package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
|
@@ -1,377 +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/modules/BookingContext/utils/resources.ts
|
|
30
|
-
var resources_exports = {};
|
|
31
|
-
__export(resources_exports, {
|
|
32
|
-
formatResource: () => formatResource,
|
|
33
|
-
formatResources: () => formatResources,
|
|
34
|
-
formatTimes: () => formatTimes,
|
|
35
|
-
getResourceByIds: () => getResourceByIds,
|
|
36
|
-
getResourceTimeIsUsable: () => getResourceTimeIsUsable,
|
|
37
|
-
getSumCapacity: () => getSumCapacity,
|
|
38
|
-
getUsableTime: () => getUsableTime,
|
|
39
|
-
setDefaultCapacitys: () => setDefaultCapacitys,
|
|
40
|
-
setDefaultResource: () => setDefaultResource
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(resources_exports);
|
|
43
|
-
var import_dayjs = __toESM(require("dayjs"));
|
|
44
|
-
var import_lodash_es = require("lodash-es");
|
|
45
|
-
var import_flexible = require("./flexible");
|
|
46
|
-
var import_noResource = require("./noResource");
|
|
47
|
-
var import_serviceTimes = require("./serviceTimes");
|
|
48
|
-
function getUsableTime(cacheItem) {
|
|
49
|
-
var _a, _b, _c;
|
|
50
|
-
try {
|
|
51
|
-
const resourceByForm = ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.resource) || {};
|
|
52
|
-
const resourceMaps = ((_b = cacheItem == null ? void 0 : cacheItem._data) == null ? void 0 : _b.resourceMaps) || {};
|
|
53
|
-
let items = [];
|
|
54
|
-
for (const formId of Object.keys(resourceByForm)) {
|
|
55
|
-
const selected = resourceByForm[formId];
|
|
56
|
-
const maps = (_c = resourceMaps[formId]) == null ? void 0 : _c.renderListMaps;
|
|
57
|
-
if (!Array.isArray(selected) || !maps)
|
|
58
|
-
continue;
|
|
59
|
-
items = items.concat(
|
|
60
|
-
selected.map((d) => maps[d.relation_id]).filter(Boolean)
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
if (!items.length)
|
|
64
|
-
return null;
|
|
65
|
-
return items.reduce((pre, event) => {
|
|
66
|
-
var _a2, _b2, _c2, _d;
|
|
67
|
-
const endAt = (0, import_dayjs.default)((_b2 = (_a2 = event._extend) == null ? void 0 : _a2.usableTime) == null ? void 0 : _b2.end_at);
|
|
68
|
-
const preEnd = (0, import_dayjs.default)((_d = (_c2 = pre._extend) == null ? void 0 : _c2.usableTime) == null ? void 0 : _d.end_at);
|
|
69
|
-
return endAt.isBefore(preEnd) ? event : pre;
|
|
70
|
-
}, items[0]);
|
|
71
|
-
} catch {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function getSumCapacity(cacheItem, isCalcQuantity = true) {
|
|
76
|
-
var _a, _b;
|
|
77
|
-
const list = ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.capacity) || [];
|
|
78
|
-
let sum = 0;
|
|
79
|
-
for (const item of list) {
|
|
80
|
-
sum += Number((item == null ? void 0 : item.value) || 0);
|
|
81
|
-
}
|
|
82
|
-
return sum * (isCalcQuantity ? ((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.quantity) || 1 : 1);
|
|
83
|
-
}
|
|
84
|
-
function getUseableEventCount(eventList, current) {
|
|
85
|
-
return (eventList || []).reduce((pre, event) => pre - ((event == null ? void 0 : event.pax) || 0), current || 0);
|
|
86
|
-
}
|
|
87
|
-
function isConflict(event, current) {
|
|
88
|
-
const eventStart = (0, import_dayjs.default)(event.start_at);
|
|
89
|
-
const eventEnd = (0, import_dayjs.default)(event.end_at);
|
|
90
|
-
const currentStart = (0, import_dayjs.default)(current.start_at);
|
|
91
|
-
const isBefore = currentStart.isBefore(eventEnd);
|
|
92
|
-
let isAfter = true;
|
|
93
|
-
if (current.end_at) {
|
|
94
|
-
const currentEnd = (0, import_dayjs.default)(current.end_at);
|
|
95
|
-
isAfter = currentEnd.isAfter(eventStart);
|
|
96
|
-
}
|
|
97
|
-
return isBefore && isAfter;
|
|
98
|
-
}
|
|
99
|
-
function getResourceTimeIsUsable(item, cacheItem, resourceItem) {
|
|
100
|
-
const startDate = (0, import_dayjs.default)(
|
|
101
|
-
`${(0, import_dayjs.default)(cacheItem._extend.start_date).format("YYYY-MM-DD")} ${(0, import_serviceTimes.getServeStartTime)(cacheItem._extend.start_time)}`
|
|
102
|
-
);
|
|
103
|
-
const isFlexible = import_flexible.flexibleObj.isFlexible(cacheItem._extend.duration);
|
|
104
|
-
let isMaxLimitRange = false;
|
|
105
|
-
let isDateRange = false;
|
|
106
|
-
let isCountRange = false;
|
|
107
|
-
const time = { ...item };
|
|
108
|
-
const timeStartDate = (0, import_dayjs.default)(`${time.start_date} ${time.start_time}`).subtract(1, "second");
|
|
109
|
-
const timeEndDate = (0, import_dayjs.default)(`${time.end_date} ${time.end_time}`).add(1, "second");
|
|
110
|
-
const totalCount = getUseableEventCount(time.event_list, resourceItem.capacity);
|
|
111
|
-
const currentCount = getSumCapacity(cacheItem);
|
|
112
|
-
let eventList = time.event_list || [];
|
|
113
|
-
if (cacheItem == null ? void 0 : cacheItem.booking_id) {
|
|
114
|
-
eventList = eventList.filter((event) => event.id !== cacheItem.booking_id);
|
|
115
|
-
}
|
|
116
|
-
let endDate = null;
|
|
117
|
-
let isCalcCount = true;
|
|
118
|
-
if (isFlexible) {
|
|
119
|
-
isDateRange = startDate.isAfter(timeStartDate) && startDate.isBefore(timeEndDate);
|
|
120
|
-
if (!isDateRange && eventList.length) {
|
|
121
|
-
isCalcCount = false;
|
|
122
|
-
isDateRange = true;
|
|
123
|
-
isCountRange = false;
|
|
124
|
-
}
|
|
125
|
-
} else {
|
|
126
|
-
endDate = startDate.add(import_flexible.flexibleObj.getValue(cacheItem._extend.duration), "minute");
|
|
127
|
-
const isTimeRange = startDate.isAfter(timeStartDate) && endDate.isBefore(timeEndDate);
|
|
128
|
-
if (isTimeRange)
|
|
129
|
-
isDateRange = true;
|
|
130
|
-
}
|
|
131
|
-
if (isCalcCount) {
|
|
132
|
-
const conflict = (eventList || []).filter(
|
|
133
|
-
(d) => isConflict({ start_at: d.start_at, end_at: d.end_at }, { start_at: startDate, end_at: endDate })
|
|
134
|
-
);
|
|
135
|
-
if (resourceItem.resourceType === "single") {
|
|
136
|
-
isCountRange = conflict.length === 0;
|
|
137
|
-
} else {
|
|
138
|
-
const conflictCount = getUseableEventCount(conflict, resourceItem.capacity);
|
|
139
|
-
isCountRange = currentCount <= conflictCount;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
const isUsable = isDateRange && isCountRange;
|
|
143
|
-
time._extend = {
|
|
144
|
-
isMaxLimitRange,
|
|
145
|
-
isDateRange,
|
|
146
|
-
isCountRange,
|
|
147
|
-
isUsable
|
|
148
|
-
};
|
|
149
|
-
return time;
|
|
150
|
-
}
|
|
151
|
-
function formatTimes(resourceItem, cacheItem) {
|
|
152
|
-
const usableTimes = [];
|
|
153
|
-
const _resourceItem = { ...resourceItem };
|
|
154
|
-
const sum = getSumCapacity(cacheItem);
|
|
155
|
-
if (_resourceItem.capacity >= sum) {
|
|
156
|
-
_resourceItem.times = (_resourceItem.times || []).map((time) => {
|
|
157
|
-
var _a;
|
|
158
|
-
const _time2 = getResourceTimeIsUsable(time, cacheItem, _resourceItem);
|
|
159
|
-
if ((_a = _time2 == null ? void 0 : _time2._extend) == null ? void 0 : _a.isDateRange)
|
|
160
|
-
usableTimes.push(_time2);
|
|
161
|
-
return _time2;
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
const _time = usableTimes.sort((a, b) => {
|
|
165
|
-
const aEnd = (0, import_dayjs.default)(`${a.end_date} ${a.end_time}`).valueOf();
|
|
166
|
-
const bEnd = (0, import_dayjs.default)(`${b.end_date} ${b.end_time}`).valueOf();
|
|
167
|
-
return aEnd - bEnd;
|
|
168
|
-
})[0];
|
|
169
|
-
resourceItem._extend = {
|
|
170
|
-
...resourceItem._extend,
|
|
171
|
-
usableTime: _time
|
|
172
|
-
};
|
|
173
|
-
return resourceItem;
|
|
174
|
-
}
|
|
175
|
-
function formatResource(resourceItem, cacheItem) {
|
|
176
|
-
var _a, _b, _c;
|
|
177
|
-
let _resourceItem = { ...resourceItem };
|
|
178
|
-
_resourceItem = formatTimes(_resourceItem, cacheItem);
|
|
179
|
-
_resourceItem.labelText = _resourceItem.main_field;
|
|
180
|
-
const usable = (_c = (_b = (_a = _resourceItem._extend) == null ? void 0 : _a.usableTime) == null ? void 0 : _b._extend) == null ? void 0 : _c.isUsable;
|
|
181
|
-
_resourceItem.usable = usable;
|
|
182
|
-
return _resourceItem;
|
|
183
|
-
}
|
|
184
|
-
function formatResources(params) {
|
|
185
|
-
const { cacheItem, resourcesOrigin } = params;
|
|
186
|
-
try {
|
|
187
|
-
const maps = {};
|
|
188
|
-
const list = resourcesOrigin.map((item) => {
|
|
189
|
-
const _item = (0, import_lodash_es.cloneDeep)(item);
|
|
190
|
-
const renderListMaps = {};
|
|
191
|
-
_item.renderList = _item.renderList.map((d) => {
|
|
192
|
-
const res = formatResource(d, cacheItem);
|
|
193
|
-
const unbound = !item.optional_resource.includes(res.id) && !item.default_resource.includes(res.id) && res.id !== 0;
|
|
194
|
-
if (unbound)
|
|
195
|
-
res.unbound = true;
|
|
196
|
-
renderListMaps[res.id] = res;
|
|
197
|
-
return res;
|
|
198
|
-
}).sort((a, b) => b.usable ? 1 : -1);
|
|
199
|
-
maps[_item.form_id] = { ..._item, renderListMaps };
|
|
200
|
-
return _item;
|
|
201
|
-
});
|
|
202
|
-
return { list, maps };
|
|
203
|
-
} catch (err) {
|
|
204
|
-
console.warn("[BookingContext] formatResources error", err);
|
|
205
|
-
return { list: [], maps: {} };
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
function getResourceMaxFreeTime(resource, isAutoAllocationOn) {
|
|
209
|
-
const { renderList, form_id } = resource;
|
|
210
|
-
if (!isAutoAllocationOn(form_id))
|
|
211
|
-
return [];
|
|
212
|
-
const usableList = (renderList || []).filter((d) => d.usable && d.id !== 0);
|
|
213
|
-
let defaultResource = [];
|
|
214
|
-
let maxFreeTime = 0;
|
|
215
|
-
usableList.forEach((d) => {
|
|
216
|
-
const { times = [] } = d;
|
|
217
|
-
const currentMaxFreeTime = times.reduce((pre, cur) => {
|
|
218
|
-
var _a, _b, _c;
|
|
219
|
-
const start = ((_c = (_b = cur.event_list) == null ? void 0 : _b[((_a = cur.event_list) == null ? void 0 : _a.length) - 1]) == null ? void 0 : _c.end_at) || cur.start_at;
|
|
220
|
-
const end = cur.end_at;
|
|
221
|
-
const diff = (0, import_dayjs.default)(end).diff((0, import_dayjs.default)(start), "minute");
|
|
222
|
-
return diff > pre ? diff : pre;
|
|
223
|
-
}, 0);
|
|
224
|
-
if (currentMaxFreeTime > maxFreeTime) {
|
|
225
|
-
maxFreeTime = currentMaxFreeTime;
|
|
226
|
-
defaultResource = [d];
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
return defaultResource;
|
|
230
|
-
}
|
|
231
|
-
function setDefaultResource(params) {
|
|
232
|
-
const { cacheItem, resources, resourceIdFromCalendar, isAutoAllocationOn = () => true } = params;
|
|
233
|
-
const obj = {};
|
|
234
|
-
const resourceId = Number(resourceIdFromCalendar) || 0;
|
|
235
|
-
for (const item of resources) {
|
|
236
|
-
const {
|
|
237
|
-
select_type = {},
|
|
238
|
-
optional_resource = [],
|
|
239
|
-
default_resource = []
|
|
240
|
-
} = item;
|
|
241
|
-
const renderList = item.renderList.filter((d) => {
|
|
242
|
-
if ((select_type == null ? void 0 : select_type.type) === "single") {
|
|
243
|
-
if (resourceId && (optional_resource.includes(resourceId) || default_resource.includes(resourceId))) {
|
|
244
|
-
return d.id === resourceId;
|
|
245
|
-
}
|
|
246
|
-
return d.is_default === 1;
|
|
247
|
-
}
|
|
248
|
-
return d.is_default === 1 || d.id === resourceId;
|
|
249
|
-
});
|
|
250
|
-
let defaultOriginalResource = [];
|
|
251
|
-
if (renderList.length === 0) {
|
|
252
|
-
defaultOriginalResource = getResourceMaxFreeTime(item, isAutoAllocationOn);
|
|
253
|
-
} else {
|
|
254
|
-
defaultOriginalResource = renderList;
|
|
255
|
-
}
|
|
256
|
-
obj[item.form_id] = defaultOriginalResource.map((d) => ({
|
|
257
|
-
children: d.children,
|
|
258
|
-
relation_type: d.relation_type,
|
|
259
|
-
form_id: item.form_id,
|
|
260
|
-
relation_id: d.id,
|
|
261
|
-
like_status: "common",
|
|
262
|
-
metadata: {
|
|
263
|
-
form_name: item.title,
|
|
264
|
-
resource_name: d.main_field
|
|
265
|
-
}
|
|
266
|
-
}));
|
|
267
|
-
}
|
|
268
|
-
return obj;
|
|
269
|
-
}
|
|
270
|
-
function setDefaultCapacitys(params) {
|
|
271
|
-
var _a, _b;
|
|
272
|
-
const { capacitys, cacheItem } = params;
|
|
273
|
-
if ((capacitys == null ? void 0 : capacitys.type) === "package") {
|
|
274
|
-
return (((_b = (_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.other) == null ? void 0 : _b.bundle) || []).map((d) => {
|
|
275
|
-
const id = d._bundle_product_id;
|
|
276
|
-
const item = ((capacitys == null ? void 0 : capacitys.package) || []).find((p) => p.product_id === id);
|
|
277
|
-
return {
|
|
278
|
-
id,
|
|
279
|
-
value: item ? d.quantity || 0 : 0,
|
|
280
|
-
name: (item == null ? void 0 : item.name) || (d == null ? void 0 : d.title)
|
|
281
|
-
};
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
if ((capacitys == null ? void 0 : capacitys.type) === "custom") {
|
|
285
|
-
return ((capacitys == null ? void 0 : capacitys.custom) || []).map((d) => ({
|
|
286
|
-
id: d.id,
|
|
287
|
-
value: d.min,
|
|
288
|
-
name: d.name
|
|
289
|
-
}));
|
|
290
|
-
}
|
|
291
|
-
return [{ id: 0, value: 1, name: "" }];
|
|
292
|
-
}
|
|
293
|
-
function getResourceByIds(resourcesOriginMap, cacheItem, extraParams) {
|
|
294
|
-
var _a, _b;
|
|
295
|
-
const _resources = [...((_a = cacheItem == null ? void 0 : cacheItem.product_resource) == null ? void 0 : _a.resources) || []].filter((d) => Number(d == null ? void 0 : d.status) === 1).map((item) => ({ ...item }));
|
|
296
|
-
const {
|
|
297
|
-
extraResources = [],
|
|
298
|
-
resourcesOrigin = [],
|
|
299
|
-
resourceTab = {}
|
|
300
|
-
} = extraParams || {};
|
|
301
|
-
for (const item of _resources) {
|
|
302
|
-
const form_id = item.id;
|
|
303
|
-
const isAllResource = ((_b = resourceTab == null ? void 0 : resourceTab[item.code]) == null ? void 0 : _b.resource_display_scope) === "all";
|
|
304
|
-
let extraResourceIds = [];
|
|
305
|
-
if (isAllResource) {
|
|
306
|
-
extraResourceIds = (resourcesOrigin || []).filter((d) => d.form_code === item.code).map((d) => d.id);
|
|
307
|
-
} else {
|
|
308
|
-
extraResourceIds = extraResources.filter(
|
|
309
|
-
(_extraItem) => _extraItem.form_id === form_id && !!_extraItem.id && !item.optional_resource.includes(_extraItem.id) && !item.default_resource.includes(_extraItem.id)
|
|
310
|
-
).map((_extraItem) => _extraItem.id);
|
|
311
|
-
}
|
|
312
|
-
extraResourceIds = Array.from(new Set(extraResourceIds));
|
|
313
|
-
item.optional_resource = (item.optional_resource || []).filter(
|
|
314
|
-
(d) => item.default_resource.indexOf(d) === -1
|
|
315
|
-
);
|
|
316
|
-
const getChildrenMetadata = (id) => {
|
|
317
|
-
const combiningResources = [];
|
|
318
|
-
const origin = resourcesOriginMap[id];
|
|
319
|
-
if ((origin == null ? void 0 : origin.combined_resource) && origin.combined_resource.status === 1) {
|
|
320
|
-
(origin.combined_resource.resource_ids || []).forEach((cid) => {
|
|
321
|
-
var _a2, _b2;
|
|
322
|
-
if (resourcesOriginMap[cid]) {
|
|
323
|
-
combiningResources.push({
|
|
324
|
-
...resourcesOriginMap[cid],
|
|
325
|
-
relation_id: ((_a2 = resourcesOriginMap[cid]) == null ? void 0 : _a2.relation_id) || ((_b2 = resourcesOriginMap[cid]) == null ? void 0 : _b2.id)
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
return {
|
|
331
|
-
children: combiningResources,
|
|
332
|
-
metadata: {
|
|
333
|
-
...(origin == null ? void 0 : origin.metadata) || {},
|
|
334
|
-
combined_resource: origin == null ? void 0 : origin.combined_resource
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
};
|
|
338
|
-
const optional_resource = Array.from(
|
|
339
|
-
/* @__PURE__ */ new Set([...item.optional_resource, ...extraResourceIds])
|
|
340
|
-
).map((d) => {
|
|
341
|
-
if (!resourcesOriginMap[d])
|
|
342
|
-
return null;
|
|
343
|
-
return Object.assign({}, resourcesOriginMap[d], {
|
|
344
|
-
form_id,
|
|
345
|
-
resourceType: item.type,
|
|
346
|
-
...getChildrenMetadata(d)
|
|
347
|
-
});
|
|
348
|
-
}).filter((d) => d).concat((0, import_noResource.getNoResource2)({ form_id }));
|
|
349
|
-
const default_resource = (item.default_resource || []).map((d) => {
|
|
350
|
-
const origin = resourcesOriginMap[d];
|
|
351
|
-
if (origin) {
|
|
352
|
-
origin.is_default = 1;
|
|
353
|
-
return Object.assign({}, origin, {
|
|
354
|
-
form_id,
|
|
355
|
-
resourceType: item.type,
|
|
356
|
-
...getChildrenMetadata(d)
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
return null;
|
|
360
|
-
}).filter((d) => d);
|
|
361
|
-
item.renderList = optional_resource.concat(default_resource);
|
|
362
|
-
item.form_id = form_id;
|
|
363
|
-
}
|
|
364
|
-
return _resources;
|
|
365
|
-
}
|
|
366
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
367
|
-
0 && (module.exports = {
|
|
368
|
-
formatResource,
|
|
369
|
-
formatResources,
|
|
370
|
-
formatTimes,
|
|
371
|
-
getResourceByIds,
|
|
372
|
-
getResourceTimeIsUsable,
|
|
373
|
-
getSumCapacity,
|
|
374
|
-
getUsableTime,
|
|
375
|
-
setDefaultCapacitys,
|
|
376
|
-
setDefaultResource
|
|
377
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Dayjs } from 'dayjs';
|
|
2
|
-
import { getDurationValue } from './flexible';
|
|
3
|
-
/**
|
|
4
|
-
* 判断商品是否为跨日预约(duration.type === 'days')。与 info2 isMultiDayProduct 等价。
|
|
5
|
-
*/
|
|
6
|
-
export declare function isMultiDayProduct(product: any): boolean;
|
|
7
|
-
/**
|
|
8
|
-
* 判断 cacheItem 是否为 session 商品(extension_type ∈ session_product / session_ticket)。
|
|
9
|
-
*/
|
|
10
|
-
export declare function isSessionProduct(cacheItem: any): boolean;
|
|
11
|
-
/** 从 catalog `cartDetailValue` 或 `_extend.other` 取 session 快照。 */
|
|
12
|
-
export declare function getSessionFromItem(item: any): Record<string, any> | null;
|
|
13
|
-
/**
|
|
14
|
-
* 将 cartDetailValue.session 写入 _extend 的起止时间(与 info2 getServiceStartTimeAndEndTime 的 session 分支一致)。
|
|
15
|
-
* 日历日优先用 ctx.date,时分取自 session.start_at / end_at 或 session.start_time / end_time。
|
|
16
|
-
*/
|
|
17
|
-
export declare function applySessionTimesToExtend(item: any, extend: Record<string, any>, ctx?: {
|
|
18
|
-
date?: string | Dayjs | null;
|
|
19
|
-
}): Record<string, any>;
|
|
20
|
-
/**
|
|
21
|
-
* 是否应写入 booking(与 Product.utils isNormalProduct 对齐,并覆盖 session_ticket / cartDetailValue.session)。
|
|
22
|
-
*/
|
|
23
|
-
export declare function isBookingProduct(item: any): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* 处理 'now' 时间占位:'now' → 当前 HH:mm;其他原样返回。
|
|
26
|
-
* 与 info2 `getServeStartTime` 等价。
|
|
27
|
-
*/
|
|
28
|
-
export declare function getServeStartTime(startTime: string | undefined | null): string;
|
|
29
|
-
/**
|
|
30
|
-
* 计算商品的开始结束时间(统一为 dayjs 实例)。
|
|
31
|
-
* 与 info2 `getServiceTimes` 行为等价:
|
|
32
|
-
* - 跨日商品:startDate = start_date + start_time,endDate = _extend.end_date 原样
|
|
33
|
-
* - session 商品:从 _extend.other.session 取 start_at / end_at
|
|
34
|
-
* - 普通商品:startDate + duration(含 flexible 处理)
|
|
35
|
-
*/
|
|
36
|
-
export declare function getServiceTimes(service: any): {
|
|
37
|
-
startDate: Dayjs;
|
|
38
|
-
endDate: Dayjs;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* 跨日预约相关:把 _extend.start_date / end_date 都对齐到 dayjs startOf('day')。
|
|
42
|
-
* 与 info2 `formatDayDate` 等价。
|
|
43
|
-
*/
|
|
44
|
-
export declare function formatDayDate(_extend: any): {
|
|
45
|
-
start_date: Dayjs;
|
|
46
|
-
end_date: Dayjs;
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* 计算跨日预约时长:
|
|
50
|
-
* - type='days' → end - start 的天数
|
|
51
|
-
* - type='minutes' → end - start 的分钟数
|
|
52
|
-
* 与 info2 `getDays` 等价。
|
|
53
|
-
*/
|
|
54
|
-
export declare function getDays(cacheItem: any, type: 'minutes' | 'days'): number;
|
|
55
|
-
export { getDurationValue };
|
|
@@ -1,162 +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/modules/BookingContext/utils/serviceTimes.ts
|
|
30
|
-
var serviceTimes_exports = {};
|
|
31
|
-
__export(serviceTimes_exports, {
|
|
32
|
-
applySessionTimesToExtend: () => applySessionTimesToExtend,
|
|
33
|
-
formatDayDate: () => formatDayDate,
|
|
34
|
-
getDays: () => getDays,
|
|
35
|
-
getDurationValue: () => import_flexible.getDurationValue,
|
|
36
|
-
getServeStartTime: () => getServeStartTime,
|
|
37
|
-
getServiceTimes: () => getServiceTimes,
|
|
38
|
-
getSessionFromItem: () => getSessionFromItem,
|
|
39
|
-
isBookingProduct: () => isBookingProduct,
|
|
40
|
-
isMultiDayProduct: () => isMultiDayProduct,
|
|
41
|
-
isSessionProduct: () => isSessionProduct
|
|
42
|
-
});
|
|
43
|
-
module.exports = __toCommonJS(serviceTimes_exports);
|
|
44
|
-
var import_dayjs = __toESM(require("dayjs"));
|
|
45
|
-
var import_flexible = require("./flexible");
|
|
46
|
-
function isMultiDayProduct(product) {
|
|
47
|
-
var _a;
|
|
48
|
-
return ((_a = product == null ? void 0 : product.duration) == null ? void 0 : _a.type) === "days";
|
|
49
|
-
}
|
|
50
|
-
function isSessionProduct(cacheItem) {
|
|
51
|
-
return ["session_product", "session_ticket"].includes(cacheItem == null ? void 0 : cacheItem.extension_type);
|
|
52
|
-
}
|
|
53
|
-
function getSessionFromItem(item) {
|
|
54
|
-
var _a, _b, _c;
|
|
55
|
-
const session = ((_a = item == null ? void 0 : item.cartDetailValue) == null ? void 0 : _a.session) ?? ((_c = (_b = item == null ? void 0 : item._extend) == null ? void 0 : _b.other) == null ? void 0 : _c.session);
|
|
56
|
-
return session && typeof session === "object" ? session : null;
|
|
57
|
-
}
|
|
58
|
-
function applySessionTimesToExtend(item, extend, ctx) {
|
|
59
|
-
var _a;
|
|
60
|
-
const session = ((_a = extend == null ? void 0 : extend.other) == null ? void 0 : _a.session) ?? getSessionFromItem(item);
|
|
61
|
-
if (!session || !isSessionProduct(item)) {
|
|
62
|
-
return extend;
|
|
63
|
-
}
|
|
64
|
-
const baseDate = (ctx == null ? void 0 : ctx.date) ? (0, import_dayjs.default)(ctx.date) : (0, import_dayjs.default)();
|
|
65
|
-
const startAt = (0, import_dayjs.default)(
|
|
66
|
-
`${baseDate.format("YYYY-MM-DD")} ${(0, import_dayjs.default)(session.start_at).format("HH:mm:ss")}`
|
|
67
|
-
);
|
|
68
|
-
const endAt = (0, import_dayjs.default)(
|
|
69
|
-
`${baseDate.format("YYYY-MM-DD")} ${(0, import_dayjs.default)(session.end_at).format("HH:mm:ss")}`
|
|
70
|
-
);
|
|
71
|
-
const nextExtend = {
|
|
72
|
-
...extend,
|
|
73
|
-
other: { ...extend.other || {}, session },
|
|
74
|
-
start_date: startAt,
|
|
75
|
-
startDate: startAt,
|
|
76
|
-
start_time: session.start_time ?? (0, import_dayjs.default)(session.start_at).format("HH:mm"),
|
|
77
|
-
end_date: endAt,
|
|
78
|
-
endDate: endAt,
|
|
79
|
-
end_time: session.end_time ?? (0, import_dayjs.default)(session.end_at).format("HH:mm")
|
|
80
|
-
};
|
|
81
|
-
return {
|
|
82
|
-
...nextExtend,
|
|
83
|
-
duration: getDays({ _extend: nextExtend }, "minutes")
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
function isBookingProduct(item) {
|
|
87
|
-
var _a, _b;
|
|
88
|
-
if (!item)
|
|
89
|
-
return false;
|
|
90
|
-
if (item.duration)
|
|
91
|
-
return true;
|
|
92
|
-
if ((_a = item == null ? void 0 : item.schedules) == null ? void 0 : _a.length)
|
|
93
|
-
return true;
|
|
94
|
-
if ((_b = item == null ? void 0 : item["schedule.ids"]) == null ? void 0 : _b.length)
|
|
95
|
-
return true;
|
|
96
|
-
if (isSessionProduct(item))
|
|
97
|
-
return true;
|
|
98
|
-
if (getSessionFromItem(item))
|
|
99
|
-
return true;
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
function getServeStartTime(startTime) {
|
|
103
|
-
if (startTime === "now")
|
|
104
|
-
return (0, import_dayjs.default)().format("HH:mm");
|
|
105
|
-
return startTime || "";
|
|
106
|
-
}
|
|
107
|
-
function getServiceTimes(service) {
|
|
108
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
109
|
-
const startDate = (0, import_dayjs.default)(
|
|
110
|
-
`${(0, import_dayjs.default)((_a = service == null ? void 0 : service._extend) == null ? void 0 : _a.start_date).format("YYYY-MM-DD")} ${getServeStartTime(
|
|
111
|
-
(_b = service == null ? void 0 : service._extend) == null ? void 0 : _b.start_time
|
|
112
|
-
)}`
|
|
113
|
-
);
|
|
114
|
-
if (isMultiDayProduct(service)) {
|
|
115
|
-
const startTime = getServeStartTime((_c = service == null ? void 0 : service._extend) == null ? void 0 : _c.start_time);
|
|
116
|
-
const endDateRaw = ((_d = service == null ? void 0 : service._extend) == null ? void 0 : _d.end_date) ?? ((_e = service == null ? void 0 : service._extend) == null ? void 0 : _e.endDate);
|
|
117
|
-
const endBase = (0, import_dayjs.default)(endDateRaw);
|
|
118
|
-
const endDate2 = endBase.isValid() ? (0, import_dayjs.default)(`${endBase.format("YYYY-MM-DD")} ${startTime}`) : endBase;
|
|
119
|
-
return {
|
|
120
|
-
startDate,
|
|
121
|
-
endDate: endDate2
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
const session = (_g = (_f = service == null ? void 0 : service._extend) == null ? void 0 : _f.other) == null ? void 0 : _g.session;
|
|
125
|
-
if (isSessionProduct(service) && session) {
|
|
126
|
-
return {
|
|
127
|
-
startDate: (0, import_dayjs.default)(session.start_at),
|
|
128
|
-
endDate: (0, import_dayjs.default)(session.end_at)
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
const endDate = startDate.add(import_flexible.flexibleObj.getValue((_h = service == null ? void 0 : service._extend) == null ? void 0 : _h.duration), "minute");
|
|
132
|
-
return { startDate, endDate };
|
|
133
|
-
}
|
|
134
|
-
function formatDayDate(_extend) {
|
|
135
|
-
return {
|
|
136
|
-
start_date: (0, import_dayjs.default)(_extend == null ? void 0 : _extend.start_date).startOf("day"),
|
|
137
|
-
end_date: (0, import_dayjs.default)(_extend == null ? void 0 : _extend.end_date).startOf("day")
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
function getDays(cacheItem, type) {
|
|
141
|
-
var _a, _b;
|
|
142
|
-
if (type === "days") {
|
|
143
|
-
const { start_date, end_date } = formatDayDate(cacheItem._extend);
|
|
144
|
-
return end_date.diff(start_date, "day");
|
|
145
|
-
}
|
|
146
|
-
const startDate = (0, import_dayjs.default)((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.start_date);
|
|
147
|
-
const endDate = (0, import_dayjs.default)((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.end_date);
|
|
148
|
-
return endDate.diff(startDate, type);
|
|
149
|
-
}
|
|
150
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
151
|
-
0 && (module.exports = {
|
|
152
|
-
applySessionTimesToExtend,
|
|
153
|
-
formatDayDate,
|
|
154
|
-
getDays,
|
|
155
|
-
getDurationValue,
|
|
156
|
-
getServeStartTime,
|
|
157
|
-
getServiceTimes,
|
|
158
|
-
getSessionFromItem,
|
|
159
|
-
isBookingProduct,
|
|
160
|
-
isMultiDayProduct,
|
|
161
|
-
isSessionProduct
|
|
162
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import dayjs from 'dayjs';
|
|
2
|
-
import { getDurationValue } from './flexible';
|
|
3
|
-
export interface TimeSlice {
|
|
4
|
-
label: string;
|
|
5
|
-
value: string;
|
|
6
|
-
}
|
|
7
|
-
export interface DurationSlice {
|
|
8
|
-
label: string;
|
|
9
|
-
value: number;
|
|
10
|
-
}
|
|
11
|
-
export interface TimeSlicesResult {
|
|
12
|
-
timeSlices: TimeSlice[];
|
|
13
|
-
durationSlicesBasedOnTime: DurationSlice[];
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* 把一天切成等长时间槽,输出 timeSlices(开始时间标签)与 durationSlicesBasedOnTime(基于切片的时长选项)。
|
|
17
|
-
*
|
|
18
|
-
* 与 info2 `sliceDayIntoFiveMinutes` 行为等价;为了不依赖 `locales`,label 输出原始时间字符串('08:00 AM' / '90'),
|
|
19
|
-
* UI 侧需要本地化展示时可基于 value 自行包装。
|
|
20
|
-
*
|
|
21
|
-
* @param config booking config `basic.service_time`,{ value: minutes }
|
|
22
|
-
* @param isDay 是否跨日预约(true 时按 1~30 天切片)
|
|
23
|
-
*/
|
|
24
|
-
export declare function sliceDayIntoFiveMinutes(config: {
|
|
25
|
-
value?: number;
|
|
26
|
-
} | undefined | null, isDay?: boolean): TimeSlicesResult;
|
|
27
|
-
/**
|
|
28
|
-
* 取「下一个 duration 选项」:优先用 defaultValue;否则在 array 中找匹配的;找不到取第一个。
|
|
29
|
-
* 与 info2 `findNextDuration` 等价。
|
|
30
|
-
*/
|
|
31
|
-
export declare function findNextDuration(current: {
|
|
32
|
-
value?: number;
|
|
33
|
-
} | undefined, array: DurationSlice[], defaultValue?: number): number | undefined;
|
|
34
|
-
/** 取首选 time slice:若指定 date(HH:mm)则找第一个 >= date 的;否则第一个。 */
|
|
35
|
-
export declare function findNextSlice(params: {
|
|
36
|
-
timeSlices: TimeSlice[];
|
|
37
|
-
index?: number;
|
|
38
|
-
date?: string;
|
|
39
|
-
}): string | undefined;
|
|
40
|
-
/** 取 endDate;duration='flexible' 时取 endDate 与店铺营业时间的较小值,否则 startDate + duration 分钟。 */
|
|
41
|
-
export declare function getEndDate(startDate: dayjs.Dayjs, duration: string | number, endDate: any, shopOpeningHours?: string): dayjs.Dayjs;
|
|
42
|
-
export { getDurationValue };
|