@pisell/pisellos 2.2.323 → 2.2.325
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/inventory/index.d.ts +92 -0
- package/dist/inventory/index.js +509 -0
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/BookingContext/index.d.ts +2 -2
- package/dist/modules/BookingContext/index.js +55 -25
- package/dist/modules/BookingContext/types.d.ts +2 -0
- package/dist/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
- package/dist/modules/BookingContext/utils/calendarBooking.js +207 -0
- package/dist/modules/BookingContext/utils/index.d.ts +1 -0
- package/dist/modules/BookingContext/utils/index.js +1 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +20 -1
- package/dist/modules/BookingContext/utils/productExtend.js +122 -29
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +60 -14
- package/dist/modules/Date/types.d.ts +5 -0
- package/dist/modules/Discount/index.js +1 -0
- package/dist/modules/OpenData/index.d.ts +1 -0
- package/dist/modules/OpenData/index.js +1 -0
- package/dist/modules/OpenData/salesSettings.d.ts +32 -0
- package/dist/modules/OpenData/salesSettings.js +80 -0
- package/dist/modules/OpenData/types.d.ts +16 -0
- package/dist/modules/OpenData/utils.d.ts +1 -1
- package/dist/modules/OpenData/utils.js +3 -2
- package/dist/modules/Order/index.d.ts +55 -12
- package/dist/modules/Order/index.js +2699 -1411
- package/dist/modules/Order/types.d.ts +43 -5
- package/dist/modules/Order/types.js +4 -0
- package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/dist/modules/Order/unpaidAmountGap.js +72 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.js +2 -2
- package/dist/modules/Order/utils/productVoucherGroups.d.ts +15 -0
- package/dist/modules/Order/utils/productVoucherGroups.js +115 -0
- package/dist/modules/Order/utils.d.ts +3 -1
- package/dist/modules/Order/utils.js +6 -2
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ProductList/clientDataVariants.js +6 -2
- package/dist/modules/ProductList/index.d.ts +2 -0
- package/dist/modules/ProductList/index.js +161 -51
- package/dist/modules/ResourcePlanner/planner.js +58 -2
- package/dist/modules/ResourcePlanner/types.d.ts +13 -0
- package/dist/modules/Rules/index.d.ts +2 -0
- package/dist/modules/Rules/index.js +58 -39
- package/dist/modules/Schedule/index.d.ts +7 -1
- package/dist/modules/Schedule/index.js +155 -39
- package/dist/modules/Schedule/types.d.ts +2 -0
- package/dist/modules/bookingReadValidation.d.ts +6 -0
- package/dist/modules/bookingReadValidation.js +72 -0
- package/dist/plugins/request.d.ts +2 -0
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.js +1458 -1166
- package/dist/server/modules/order/index.js +2 -1
- package/dist/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
- package/dist/shared/receipt/customerInvoiceLanguages.js +5 -3
- package/dist/shared/receipt/small-ticket.d.ts +4 -0
- package/dist/shared/receipt/small-ticket.js +70 -12
- package/dist/solution/BaseSales/index.d.ts +39 -5
- package/dist/solution/BaseSales/index.js +1828 -1462
- package/dist/solution/BaseSales/types.d.ts +1 -0
- package/dist/solution/BaseSales/types.js +1 -0
- package/dist/solution/BookingByStep/index.d.ts +16 -2
- package/dist/solution/BookingByStep/index.js +676 -361
- package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/dist/solution/BookingByStep/utils/resources.js +117 -76
- package/dist/solution/BookingTicket/index.d.ts +15 -3
- package/dist/solution/BookingTicket/index.js +249 -135
- package/dist/solution/BookingTicket/types.d.ts +14 -2
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +3 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +39 -11
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +88 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +2 -1
- package/dist/solution/OrderInvoicePreview/index.js +14 -8
- package/dist/solution/ScanOrder/index.d.ts +2 -0
- package/dist/solution/ScanOrder/index.js +166 -67
- package/dist/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/dist/solution/ScanOrder/menuAvailability.js +363 -0
- package/dist/solution/UnifiedBookingSales/catalogQueryBatch.d.ts +21 -0
- package/dist/solution/UnifiedBookingSales/catalogQueryBatch.js +202 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +96 -4
- package/dist/solution/UnifiedBookingSales/index.js +3374 -1177
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +4 -0
- package/dist/solution/UnifiedBookingSales/salesSettings.d.ts +16 -0
- package/dist/solution/UnifiedBookingSales/salesSettings.js +81 -0
- package/dist/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
- package/dist/solution/UnifiedBookingSales/sessionResourceCache.js +271 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +71 -2
- package/dist/solution/UnifiedBookingSales/types.js +7 -1
- package/dist/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
- package/dist/solution/UnifiedBookingSales/venueCatalogSession.js +283 -0
- package/dist/utils/platform.d.ts +2 -0
- package/dist/utils/platform.js +6 -0
- package/dist/utils/pos-receipt-auto-print.d.ts +4 -0
- package/dist/utils/pos-receipt-auto-print.js +14 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +12 -0
- package/lib/inventory/index.d.ts +92 -0
- package/lib/inventory/index.js +287 -0
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/BookingContext/index.d.ts +2 -2
- package/lib/modules/BookingContext/index.js +42 -10
- package/lib/modules/BookingContext/types.d.ts +2 -0
- package/lib/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
- package/lib/modules/BookingContext/utils/calendarBooking.js +156 -0
- package/lib/modules/BookingContext/utils/index.d.ts +1 -0
- package/lib/modules/BookingContext/utils/index.js +11 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +20 -1
- package/lib/modules/BookingContext/utils/productExtend.js +96 -7
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +28 -5
- package/lib/modules/Date/types.d.ts +5 -0
- package/lib/modules/Discount/index.js +1 -0
- package/lib/modules/OpenData/index.d.ts +1 -0
- package/lib/modules/OpenData/index.js +12 -0
- package/lib/modules/OpenData/salesSettings.d.ts +32 -0
- package/lib/modules/OpenData/salesSettings.js +70 -0
- package/lib/modules/OpenData/types.d.ts +16 -0
- package/lib/modules/OpenData/utils.d.ts +1 -1
- package/lib/modules/OpenData/utils.js +3 -2
- package/lib/modules/Order/index.d.ts +55 -12
- package/lib/modules/Order/index.js +659 -80
- package/lib/modules/Order/types.d.ts +43 -5
- package/lib/modules/Order/types.js +2 -0
- package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/lib/modules/Order/unpaidAmountGap.js +60 -0
- package/lib/modules/Order/utils/discountProductLineIdentity.js +1 -1
- package/lib/modules/Order/utils/productVoucherGroups.d.ts +15 -0
- package/lib/modules/Order/utils/productVoucherGroups.js +64 -0
- package/lib/modules/Order/utils.d.ts +3 -1
- package/lib/modules/Order/utils.js +6 -2
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ProductList/clientDataVariants.js +6 -2
- package/lib/modules/ProductList/index.d.ts +2 -0
- package/lib/modules/ProductList/index.js +74 -0
- package/lib/modules/ResourcePlanner/planner.js +52 -1
- package/lib/modules/ResourcePlanner/types.d.ts +13 -0
- package/lib/modules/Rules/index.d.ts +2 -0
- package/lib/modules/Rules/index.js +25 -9
- package/lib/modules/Schedule/index.d.ts +7 -1
- package/lib/modules/Schedule/index.js +68 -4
- package/lib/modules/Schedule/types.d.ts +2 -0
- package/lib/modules/bookingReadValidation.d.ts +6 -0
- package/lib/modules/bookingReadValidation.js +56 -0
- package/lib/plugins/request.d.ts +2 -0
- package/lib/server/index.d.ts +8 -0
- package/lib/server/index.js +194 -19
- package/lib/server/modules/order/index.js +2 -1
- package/lib/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
- package/lib/shared/receipt/customerInvoiceLanguages.js +5 -3
- package/lib/shared/receipt/small-ticket.d.ts +4 -0
- package/lib/shared/receipt/small-ticket.js +63 -8
- package/lib/solution/BaseSales/index.d.ts +39 -5
- package/lib/solution/BaseSales/index.js +212 -18
- package/lib/solution/BaseSales/types.d.ts +1 -0
- package/lib/solution/BaseSales/types.js +1 -0
- package/lib/solution/BookingByStep/index.d.ts +16 -2
- package/lib/solution/BookingByStep/index.js +222 -14
- package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/lib/solution/BookingByStep/utils/resources.js +25 -15
- package/lib/solution/BookingTicket/index.d.ts +15 -3
- package/lib/solution/BookingTicket/index.js +47 -4
- package/lib/solution/BookingTicket/types.d.ts +14 -2
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +3 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +37 -6
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +54 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -1
- package/lib/solution/OrderInvoicePreview/index.js +7 -1
- package/lib/solution/ScanOrder/index.d.ts +2 -0
- package/lib/solution/ScanOrder/index.js +72 -2
- package/lib/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/lib/solution/ScanOrder/menuAvailability.js +203 -0
- package/lib/solution/UnifiedBookingSales/catalogQueryBatch.d.ts +21 -0
- package/lib/solution/UnifiedBookingSales/catalogQueryBatch.js +109 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +96 -4
- package/lib/solution/UnifiedBookingSales/index.js +1316 -73
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +2 -0
- package/lib/solution/UnifiedBookingSales/salesSettings.d.ts +16 -0
- package/lib/solution/UnifiedBookingSales/salesSettings.js +72 -0
- package/lib/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
- package/lib/solution/UnifiedBookingSales/sessionResourceCache.js +199 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +71 -2
- package/lib/solution/UnifiedBookingSales/types.js +4 -1
- package/lib/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
- package/lib/solution/UnifiedBookingSales/venueCatalogSession.js +155 -0
- package/lib/utils/platform.d.ts +2 -0
- package/lib/utils/platform.js +7 -0
- package/lib/utils/pos-receipt-auto-print.d.ts +4 -0
- package/lib/utils/pos-receipt-auto-print.js +13 -0
- package/package.json +1 -1
|
@@ -16,6 +16,7 @@ import { hasActualResourceSelection, productNeedsResourceExtend } from "./resour
|
|
|
16
16
|
import { isMultiDayProduct, isSessionProduct, getDays, getServiceTimes } from "./serviceTimes";
|
|
17
17
|
import { sliceDayIntoFiveMinutes, findNextDuration, getEndDate } from "./timeSlices";
|
|
18
18
|
import { flexibleObj, getDurationValue, isProductFlexibleDuration } from "./flexible";
|
|
19
|
+
import { getCalendarBookingRange, prepareCalendarBookingCacheItem, calendarBookingNeedsInput, calendarBookingPreparationKey, calendarBookingEntryKey, isManualBookingProduct } from "./calendarBooking";
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* 上下文(与 info2 state.bookingConfig / state.service / state.date 一一对应)。
|
|
@@ -29,7 +30,7 @@ function seedRememberedBookingStart(cacheItem, ctx) {
|
|
|
29
30
|
var _cacheItem$cartDetail, _cacheItem$_extend;
|
|
30
31
|
var remembered = ctx.rememberedTime;
|
|
31
32
|
var invalid = function invalid() {
|
|
32
|
-
return Object.assign(new Error('Remembered time requires a valid POS duration
|
|
33
|
+
return Object.assign(new Error('Remembered time requires a valid POS duration interval in the current order.'), {
|
|
33
34
|
code: 'INVALID_REMEMBERED_TIME'
|
|
34
35
|
});
|
|
35
36
|
};
|
|
@@ -42,12 +43,31 @@ function seedRememberedBookingStart(cacheItem, ctx) {
|
|
|
42
43
|
var date = new Date("".concat(value, "T00:00:00.000Z"));
|
|
43
44
|
return Number.isFinite(date.getTime()) && date.toISOString().slice(0, 10) === value;
|
|
44
45
|
};
|
|
45
|
-
var
|
|
46
|
-
|
|
46
|
+
var isDateTime = function isDateTime(value) {
|
|
47
|
+
var parts = typeof value === 'string' ? /^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,3})?)?(?:Z|[+-](\d{2}):(\d{2}))?$/.exec(value) : null;
|
|
48
|
+
return Boolean(parts && isCalendarDate(parts[1]) && Number(parts[2]) <= 23 && Number(parts[3]) <= 59 && Number(parts[4] || 0) <= 59 && Number(parts[5] || 0) <= 23 && Number(parts[6] || 0) <= 59);
|
|
49
|
+
};
|
|
50
|
+
if (String(ctx.channel || '').trim().toLowerCase() !== 'pos' || !isDuration || isMultiDayProduct(cacheItem) || isSessionProduct(cacheItem) || cacheItem !== null && cacheItem !== void 0 && (_cacheItem$cartDetail = cacheItem.cartDetailValue) !== null && _cacheItem$cartDetail !== void 0 && _cacheItem$cartDetail.session || cacheItem !== null && cacheItem !== void 0 && (_cacheItem$_extend = cacheItem._extend) !== null && _cacheItem$_extend !== void 0 && (_cacheItem$_extend = _cacheItem$_extend.other) !== null && _cacheItem$_extend !== void 0 && _cacheItem$_extend.session || !isCalendarDate(remembered === null || remembered === void 0 ? void 0 : remembered.businessDate) || !isDateTime(remembered === null || remembered === void 0 ? void 0 : remembered.startAt)) throw invalid();
|
|
47
51
|
// Parse the actual instant with the same runtime clock used by the legacy booking helpers.
|
|
48
52
|
// The business-day label must not replace the calendar date of an overnight start.
|
|
49
53
|
var start = dayjs(remembered.startAt);
|
|
50
54
|
if (!start.isValid()) throw invalid();
|
|
55
|
+
var hasRememberedInterval = remembered.endAt !== undefined || remembered.orderSessionId !== undefined;
|
|
56
|
+
var end;
|
|
57
|
+
var rememberedDuration;
|
|
58
|
+
if (hasRememberedInterval) {
|
|
59
|
+
if (!isDateTime(remembered.endAt) || typeof remembered.orderSessionId !== 'string' || !remembered.orderSessionId.trim() || remembered.orderSessionId !== ctx.orderSessionId || ctx.isOrderSessionCurrent && !ctx.isOrderSessionCurrent(remembered.orderSessionId)) throw invalid();
|
|
60
|
+
end = dayjs(remembered.endAt);
|
|
61
|
+
var durationMinutes = (end.valueOf() - start.valueOf()) / 60000;
|
|
62
|
+
if (!end.isValid() || !Number.isFinite(durationMinutes) || durationMinutes <= 0) throw invalid();
|
|
63
|
+
var flexible = isProductFlexibleDuration(duration);
|
|
64
|
+
var configuredDurationMinutes = Number(durationValue) * (['hour', 'hours'].includes(durationType) ? 60 : 1);
|
|
65
|
+
if (!flexible && durationMinutes !== configuredDurationMinutes) throw invalid();
|
|
66
|
+
rememberedDuration = flexible ? flexibleObj.create(durationMinutes) : durationMinutes;
|
|
67
|
+
}
|
|
68
|
+
var clockFormat = function clockFormat(value) {
|
|
69
|
+
return value.format(value.millisecond() ? 'HH:mm:ss.SSS' : value.second() ? 'HH:mm:ss' : 'HH:mm');
|
|
70
|
+
};
|
|
51
71
|
var extend = _objectSpread({}, (cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem._extend) || {});
|
|
52
72
|
for (var _i = 0, _arr = ['start_date', 'startDate', 'start_time', 'end_date', 'endDate', 'end_time', 'duration', 'resource', 'resources', 'capacity', 'booking', 'availabilitySelection']; _i < _arr.length; _i++) {
|
|
53
73
|
var key = _arr[_i];
|
|
@@ -59,8 +79,13 @@ function seedRememberedBookingStart(cacheItem, ctx) {
|
|
|
59
79
|
_data: {},
|
|
60
80
|
_extend: _objectSpread(_objectSpread({}, extend), {}, {
|
|
61
81
|
start_date: start.format('YYYY-MM-DD'),
|
|
62
|
-
start_time:
|
|
63
|
-
}
|
|
82
|
+
start_time: clockFormat(start)
|
|
83
|
+
}, end ? {
|
|
84
|
+
end_date: end.format('YYYY-MM-DD'),
|
|
85
|
+
end_time: clockFormat(end),
|
|
86
|
+
endDate: end,
|
|
87
|
+
duration: rememberedDuration
|
|
88
|
+
} : {})
|
|
64
89
|
});
|
|
65
90
|
}
|
|
66
91
|
|
|
@@ -86,12 +111,21 @@ function getAppointmentTimingPreference(ctx) {
|
|
|
86
111
|
* 灵活时长选项(cacheItem.duration.type === 'flexible' 时)。
|
|
87
112
|
*/
|
|
88
113
|
function getFlexibleOption(params) {
|
|
89
|
-
var _cacheItem$_extend2, _cacheItem$_extend3, _usable$_extend, _params$ctx;
|
|
114
|
+
var _cacheItem$_extend2, _cacheItem$_extend3, _params$ctx$remembere, _usable$_extend, _params$ctx;
|
|
90
115
|
var cacheItem = params.cacheItem,
|
|
91
116
|
useStartTime = params.useStartTime;
|
|
92
117
|
var duration = getDurationValue(cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.duration);
|
|
93
118
|
if (duration !== 'flexible') return null;
|
|
94
119
|
var startDate = dayjs("".concat(dayjs(cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.start_date).format('YYYY-MM-DD'), " ").concat(useStartTime || (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend3 = cacheItem._extend) === null || _cacheItem$_extend3 === void 0 ? void 0 : _cacheItem$_extend3.start_time) || '00:00'));
|
|
120
|
+
// The current-order interval was validated before rebuilding the cache item.
|
|
121
|
+
// Resource defaults may change, but must never extend its saved end.
|
|
122
|
+
if (((_params$ctx$remembere = params.ctx.rememberedTime) === null || _params$ctx$remembere === void 0 ? void 0 : _params$ctx$remembere.endAt) !== undefined) {
|
|
123
|
+
var _timeValue = (dayjs(params.ctx.rememberedTime.endAt).valueOf() - startDate.valueOf()) / 60000;
|
|
124
|
+
return {
|
|
125
|
+
label: String(_timeValue),
|
|
126
|
+
value: flexibleObj.create(_timeValue)
|
|
127
|
+
};
|
|
128
|
+
}
|
|
95
129
|
var usable = getUsableTime(cacheItem);
|
|
96
130
|
var usableEndAt = usable !== null && usable !== void 0 && (_usable$_extend = usable._extend) !== null && _usable$_extend !== void 0 && (_usable$_extend = _usable$_extend.usableTime) !== null && _usable$_extend !== void 0 && _usable$_extend.end_at ? dayjs(usable._extend.usableTime.end_at) : null;
|
|
97
131
|
var endDate = getEndDate(startDate, 'flexible', usableEndAt, (_params$ctx = params.ctx) === null || _params$ctx === void 0 ? void 0 : _params$ctx.shopOpeningHours);
|
|
@@ -136,6 +170,13 @@ export function getTimeObj(params) {
|
|
|
136
170
|
durationSlicesBasedOnTime: durationSlicesBasedOnTime
|
|
137
171
|
};
|
|
138
172
|
}
|
|
173
|
+
function getDefaultBookingStartFallback(cacheItem, ctx) {
|
|
174
|
+
var _ctx$date, _ref, _cacheItem$_extend$st, _cacheItem$_extend4;
|
|
175
|
+
if (ctx.useCurrentTimeAfterRememberedExpiry) return dayjs((_ctx$date = ctx.date) !== null && _ctx$date !== void 0 ? _ctx$date : dayjs()).format('YYYY-MM-DDTHH:mm');
|
|
176
|
+
var date = dayjs((_ref = (_cacheItem$_extend$st = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend4 = cacheItem._extend) === null || _cacheItem$_extend4 === void 0 ? void 0 : _cacheItem$_extend4.start_date) !== null && _cacheItem$_extend$st !== void 0 ? _cacheItem$_extend$st : ctx.date) !== null && _ref !== void 0 ? _ref : dayjs()).format('YYYY-MM-DD');
|
|
177
|
+
var time = ctx.presetStartTime || cacheItem.currentDefaultTime || dayjs().format('HH:mm');
|
|
178
|
+
return "".concat(date, "T").concat(time);
|
|
179
|
+
}
|
|
139
180
|
|
|
140
181
|
/**
|
|
141
182
|
* 计算商品行 _extend(包含 start_time / endDate / duration / start_date / end_date / sub_type 等)。
|
|
@@ -145,7 +186,7 @@ export function getTimeObj(params) {
|
|
|
145
186
|
* - cacheItem.isCustomItem → 直接返回 `{ duration: null }`。
|
|
146
187
|
*/
|
|
147
188
|
export function getServiceStartTimeAndEndTime(params) {
|
|
148
|
-
var _cacheItem$
|
|
189
|
+
var _cacheItem$_extend5, _cacheItem$_extend6, _cacheItem$_extend8;
|
|
149
190
|
var cacheItem = params.cacheItem,
|
|
150
191
|
timeObj = params.timeObj,
|
|
151
192
|
ctx = params.ctx;
|
|
@@ -154,7 +195,7 @@ export function getServiceStartTimeAndEndTime(params) {
|
|
|
154
195
|
duration: null
|
|
155
196
|
};
|
|
156
197
|
}
|
|
157
|
-
var appointmentTimingPreference = getAppointmentTimingPreference(ctx);
|
|
198
|
+
var appointmentTimingPreference = ctx.resolveDefaultBookingStart ? undefined : getAppointmentTimingPreference(ctx);
|
|
158
199
|
var lastServer = ctx.previousService || null;
|
|
159
200
|
var resolveDuration = function resolveDuration() {
|
|
160
201
|
var _cacheItem$duration;
|
|
@@ -164,7 +205,15 @@ export function getServiceStartTimeAndEndTime(params) {
|
|
|
164
205
|
var _extend = {
|
|
165
206
|
duration: resolveDuration()
|
|
166
207
|
};
|
|
167
|
-
if (
|
|
208
|
+
if (ctx.resolveDefaultBookingStart && !ctx.rememberedTime && !((_cacheItem$_extend5 = cacheItem._extend) !== null && _cacheItem$_extend5 !== void 0 && _cacheItem$_extend5.start_time) && !isSessionProduct(cacheItem)) {
|
|
209
|
+
var _params$defaultBookin;
|
|
210
|
+
var _fallback = (_params$defaultBookin = params.defaultBookingStartFallback) !== null && _params$defaultBookin !== void 0 ? _params$defaultBookin : getDefaultBookingStartFallback(cacheItem, ctx);
|
|
211
|
+
var start = ctx.resolveDefaultBookingStart(cacheItem, _fallback);
|
|
212
|
+
if (start) {
|
|
213
|
+
_extend.start_date = start.slice(0, 10);
|
|
214
|
+
_extend.start_time = start.slice(11);
|
|
215
|
+
}
|
|
216
|
+
} else if (lastServer) {
|
|
168
217
|
var _lastServer$_extend, _lastServer$_extend2;
|
|
169
218
|
var lastStart = (_lastServer$_extend = lastServer._extend) === null || _lastServer$_extend === void 0 ? void 0 : _lastServer$_extend.startDate;
|
|
170
219
|
var lastEnd = (_lastServer$_extend2 = lastServer._extend) === null || _lastServer$_extend2 === void 0 ? void 0 : _lastServer$_extend2.endDate;
|
|
@@ -188,7 +237,20 @@ export function getServiceStartTimeAndEndTime(params) {
|
|
|
188
237
|
_extend.start_time = dayjs().format('HH:mm');
|
|
189
238
|
}
|
|
190
239
|
}
|
|
240
|
+
var defaultStartDate = _extend.start_date;
|
|
191
241
|
_extend = _objectSpread(_objectSpread({}, _extend), cacheItem._extend);
|
|
242
|
+
// start_date on a new cache item is a calendar anchor, not a manually selected time.
|
|
243
|
+
// Preserve the complete default after a previous booking crossed midnight.
|
|
244
|
+
if (defaultStartDate && !((_cacheItem$_extend6 = cacheItem._extend) !== null && _cacheItem$_extend6 !== void 0 && _cacheItem$_extend6.start_time)) {
|
|
245
|
+
var _cacheItem$_extend7;
|
|
246
|
+
_extend.start_date = defaultStartDate;
|
|
247
|
+
if (isMultiDayProduct(cacheItem) && (_cacheItem$_extend7 = cacheItem._extend) !== null && _cacheItem$_extend7 !== void 0 && _cacheItem$_extend7.end_date) {
|
|
248
|
+
var _cacheItem$_extend$st2;
|
|
249
|
+
var originalDate = dayjs((_cacheItem$_extend$st2 = cacheItem._extend.start_date) !== null && _cacheItem$_extend$st2 !== void 0 ? _cacheItem$_extend$st2 : ctx.date).startOf('day');
|
|
250
|
+
var shiftDays = dayjs(defaultStartDate).diff(originalDate, 'day');
|
|
251
|
+
_extend.end_date = dayjs(cacheItem._extend.end_date).add(shiftDays, 'day').format('YYYY-MM-DD');
|
|
252
|
+
}
|
|
253
|
+
}
|
|
192
254
|
var _getServiceTimes = getServiceTimes(_objectSpread(_objectSpread({}, cacheItem), {}, {
|
|
193
255
|
_extend: _extend
|
|
194
256
|
})),
|
|
@@ -203,7 +265,7 @@ export function getServiceStartTimeAndEndTime(params) {
|
|
|
203
265
|
_extend.start_date = (_extend$start_date = _extend.start_date) !== null && _extend$start_date !== void 0 ? _extend$start_date : startDate;
|
|
204
266
|
_extend.end_date = (_extend$end_date = _extend.end_date) !== null && _extend$end_date !== void 0 ? _extend$end_date : endDate;
|
|
205
267
|
}
|
|
206
|
-
var session = cacheItem === null || cacheItem === void 0 || (_cacheItem$
|
|
268
|
+
var session = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend8 = cacheItem._extend) === null || _cacheItem$_extend8 === void 0 || (_cacheItem$_extend8 = _cacheItem$_extend8.other) === null || _cacheItem$_extend8 === void 0 ? void 0 : _cacheItem$_extend8.session;
|
|
207
269
|
if (isSessionProduct(cacheItem) && session) {
|
|
208
270
|
var baseDate = ctx.date ? dayjs(ctx.date) : dayjs();
|
|
209
271
|
var startAt = dayjs("".concat(baseDate.format('YYYY-MM-DD'), " ").concat(dayjs(session.start_at).format('HH:mm:ss')));
|
|
@@ -228,35 +290,66 @@ export function getServiceStartTimeAndEndTime(params) {
|
|
|
228
290
|
* 入参 ctx 必须至少给:bookingConfig / resourcesOriginMap / resourcesOrigin / date。
|
|
229
291
|
*/
|
|
230
292
|
export function getProductExtend(params) {
|
|
231
|
-
var _cacheItem$
|
|
293
|
+
var _cacheItem$_extend9;
|
|
232
294
|
var isDisabledTime = params.isDisabledTime;
|
|
295
|
+
if (getCalendarBookingRange(params.cacheItem, params.ctx)) {
|
|
296
|
+
var _params$cacheItem$_da;
|
|
297
|
+
var prepared = prepareCalendarBookingCacheItem(params.cacheItem, params.ctx);
|
|
298
|
+
var capacity = setDefaultCapacitys({
|
|
299
|
+
capacitys: prepared.capacity,
|
|
300
|
+
cacheItem: prepared
|
|
301
|
+
});
|
|
302
|
+
return _objectSpread(_objectSpread({}, prepared), {}, {
|
|
303
|
+
_extend: _objectSpread(_objectSpread({}, prepared._extend), {}, {
|
|
304
|
+
capacity: capacity
|
|
305
|
+
}),
|
|
306
|
+
_data: _objectSpread(_objectSpread({}, prepared._data), {}, {
|
|
307
|
+
capacitys: prepared.capacity,
|
|
308
|
+
calendarManualBooking: ((_params$cacheItem$_da = params.cacheItem._data) === null || _params$cacheItem$_da === void 0 ? void 0 : _params$cacheItem$_da.calendarManualBooking) === true || isManualBookingProduct(params.cacheItem),
|
|
309
|
+
calendarBookingEntryKey: calendarBookingEntryKey(params.ctx),
|
|
310
|
+
calendarBookingPreparationKey: calendarBookingPreparationKey(prepared, params.ctx)
|
|
311
|
+
}),
|
|
312
|
+
autoClose: !calendarBookingNeedsInput(prepared)
|
|
313
|
+
});
|
|
314
|
+
}
|
|
233
315
|
var hasRememberedTime = params.ctx.rememberedTime !== undefined;
|
|
234
316
|
var cacheItem = hasRememberedTime ? seedRememberedBookingStart(params.cacheItem, params.ctx) : params.cacheItem;
|
|
235
317
|
var ctx = hasRememberedTime ? _objectSpread(_objectSpread({}, params.ctx), {}, {
|
|
236
318
|
previousService: undefined,
|
|
237
319
|
presetStartTime: undefined
|
|
238
320
|
}) : params.ctx;
|
|
239
|
-
var isNew = cacheItem.new || !((_cacheItem$
|
|
321
|
+
var isNew = cacheItem.new || !((_cacheItem$_extend9 = cacheItem._extend) !== null && _cacheItem$_extend9 !== void 0 && _cacheItem$_extend9.endDate);
|
|
240
322
|
var _cacheItem = _objectSpread({}, cacheItem);
|
|
241
323
|
var resourcesOriginMap = ctx.resourcesOriginMap || {};
|
|
242
324
|
_cacheItem._data = {};
|
|
243
325
|
if (isMultiDayProduct(cacheItem)) {
|
|
244
|
-
var _cacheItem$
|
|
326
|
+
var _cacheItem$_extend10;
|
|
245
327
|
_cacheItem._extend = _cacheItem._extend || {};
|
|
246
|
-
_cacheItem._extend.holder_id = (cacheItem === null || cacheItem === void 0 || (_cacheItem$
|
|
328
|
+
_cacheItem._extend.holder_id = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend10 = cacheItem._extend) === null || _cacheItem$_extend10 === void 0 ? void 0 : _cacheItem$_extend10.holder_id) || [];
|
|
247
329
|
_cacheItem._extend.sub_type = 'days';
|
|
248
330
|
}
|
|
249
331
|
if (isNew) {
|
|
250
|
-
var _ctx$bookingConfig3;
|
|
332
|
+
var _ref2, _cacheItem$_data, _ctx$bookingConfig3;
|
|
251
333
|
_cacheItem._data.timeObj = getTimeObj({
|
|
252
334
|
cacheItem: cacheItem,
|
|
253
335
|
ctx: ctx
|
|
254
336
|
});
|
|
337
|
+
var defaultBookingStartFallback = (_ref2 = !ctx.useCurrentTimeAfterRememberedExpiry ? (_cacheItem$_data = cacheItem._data) === null || _cacheItem$_data === void 0 ? void 0 : _cacheItem$_data.salesDefaultBookingFallback : undefined) !== null && _ref2 !== void 0 ? _ref2 : getDefaultBookingStartFallback(cacheItem, ctx);
|
|
255
338
|
_cacheItem._extend = getServiceStartTimeAndEndTime({
|
|
256
339
|
cacheItem: cacheItem,
|
|
257
340
|
timeObj: _cacheItem._data.timeObj,
|
|
258
|
-
ctx: ctx
|
|
341
|
+
ctx: ctx,
|
|
342
|
+
defaultBookingStartFallback: defaultBookingStartFallback
|
|
259
343
|
});
|
|
344
|
+
if (ctx.resolveDefaultBookingStart && !hasRememberedTime && !isSessionProduct(cacheItem)) {
|
|
345
|
+
var _cacheItem$_data2, _cacheItem$_extend11;
|
|
346
|
+
var start = "".concat(dayjs(_cacheItem._extend.start_date).format('YYYY-MM-DD'), "T").concat(_cacheItem._extend.start_time);
|
|
347
|
+
var previousDefault = (_cacheItem$_data2 = cacheItem._data) === null || _cacheItem$_data2 === void 0 ? void 0 : _cacheItem$_data2.salesDefaultBookingStart;
|
|
348
|
+
if (!((_cacheItem$_extend11 = cacheItem._extend) !== null && _cacheItem$_extend11 !== void 0 && _cacheItem$_extend11.start_time) || previousDefault && dayjs(start).valueOf() === dayjs(previousDefault).valueOf()) {
|
|
349
|
+
_cacheItem._data.salesDefaultBookingStart = start;
|
|
350
|
+
_cacheItem._data.salesDefaultBookingFallback = defaultBookingStartFallback;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
260
353
|
_cacheItem._data.capacitys = cacheItem.capacity;
|
|
261
354
|
_cacheItem._data.resourcesOrigin = getResourceByIds(resourcesOriginMap, cacheItem, {
|
|
262
355
|
resourceTab: ctx === null || ctx === void 0 || (_ctx$bookingConfig3 = ctx.bookingConfig) === null || _ctx$bookingConfig3 === void 0 || (_ctx$bookingConfig3 = _ctx$bookingConfig3.config) === null || _ctx$bookingConfig3 === void 0 ? void 0 : _ctx$bookingConfig3.resource_tab,
|
|
@@ -304,14 +397,14 @@ export function getProductExtend(params) {
|
|
|
304
397
|
_cacheItem._time = new Date().getTime();
|
|
305
398
|
}
|
|
306
399
|
} else {
|
|
307
|
-
var _cacheItem$
|
|
400
|
+
var _cacheItem$_extend13;
|
|
308
401
|
if (!_cacheItem._data.capacitys) {
|
|
309
402
|
_cacheItem._data.capacitys = cacheItem.capacity;
|
|
310
403
|
}
|
|
311
404
|
if (!_cacheItem._data.resourcesOrigin) {
|
|
312
|
-
var _cacheItem$
|
|
405
|
+
var _cacheItem$_extend12, _ctx$bookingConfig4;
|
|
313
406
|
var extraResources = [];
|
|
314
|
-
if (Array.isArray((_cacheItem$
|
|
407
|
+
if (Array.isArray((_cacheItem$_extend12 = _cacheItem._extend) === null || _cacheItem$_extend12 === void 0 ? void 0 : _cacheItem$_extend12.event_resources)) {
|
|
315
408
|
_cacheItem._extend.event_resources.forEach(function (er) {
|
|
316
409
|
extraResources.push({
|
|
317
410
|
form_id: er.form_id,
|
|
@@ -337,7 +430,7 @@ export function getProductExtend(params) {
|
|
|
337
430
|
}
|
|
338
431
|
_cacheItem._data.timeObj = getTimeObj({
|
|
339
432
|
cacheItem: _cacheItem,
|
|
340
|
-
useStartTime: (_cacheItem$
|
|
433
|
+
useStartTime: (_cacheItem$_extend13 = _cacheItem._extend) === null || _cacheItem$_extend13 === void 0 ? void 0 : _cacheItem$_extend13.start_time,
|
|
341
434
|
ctx: ctx
|
|
342
435
|
});
|
|
343
436
|
}
|
|
@@ -350,13 +443,13 @@ export function getProductExtend(params) {
|
|
|
350
443
|
* `getAutoAllocationStorage` 抽象为入参 `isAutoAllocationOn(formId)`。
|
|
351
444
|
*/
|
|
352
445
|
export function getIsAutoClose(cacheItem, isAutoAllocationOn) {
|
|
353
|
-
var _cacheItem$
|
|
446
|
+
var _cacheItem$_data3, _cacheItem$_extend14;
|
|
354
447
|
if (productNeedsResourceExtend(cacheItem) && !hasActualResourceSelection(cacheItem)) {
|
|
355
448
|
return false;
|
|
356
449
|
}
|
|
357
|
-
if (((_cacheItem$
|
|
358
|
-
var _cacheItem$
|
|
359
|
-
var resources = (cacheItem === null || cacheItem === void 0 || (_cacheItem$
|
|
450
|
+
if (((_cacheItem$_data3 = cacheItem._data) === null || _cacheItem$_data3 === void 0 || (_cacheItem$_data3 = _cacheItem$_data3.capacitys) === null || _cacheItem$_data3 === void 0 ? void 0 : _cacheItem$_data3.type) !== 'custom') {
|
|
451
|
+
var _cacheItem$_data4;
|
|
452
|
+
var resources = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_data4 = cacheItem._data) === null || _cacheItem$_data4 === void 0 ? void 0 : _cacheItem$_data4.resources) || [];
|
|
360
453
|
if (resources.length === 1) {
|
|
361
454
|
var _first$select_type;
|
|
362
455
|
var first = resources[0];
|
|
@@ -365,14 +458,14 @@ export function getIsAutoClose(cacheItem, isAutoAllocationOn) {
|
|
|
365
458
|
}
|
|
366
459
|
}
|
|
367
460
|
}
|
|
368
|
-
var entries = Object.entries(((_cacheItem$
|
|
461
|
+
var entries = Object.entries(((_cacheItem$_extend14 = cacheItem._extend) === null || _cacheItem$_extend14 === void 0 ? void 0 : _cacheItem$_extend14.resource) || {});
|
|
369
462
|
if (entries.length === 0) {
|
|
370
463
|
return !productNeedsResourceExtend(cacheItem);
|
|
371
464
|
}
|
|
372
|
-
return entries.every(function (
|
|
373
|
-
var
|
|
374
|
-
key =
|
|
375
|
-
value =
|
|
465
|
+
return entries.every(function (_ref3) {
|
|
466
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
467
|
+
key = _ref4[0],
|
|
468
|
+
value = _ref4[1];
|
|
376
469
|
return isAutoAllocationOn(key) && Array.isArray(value) && value.length > 0;
|
|
377
470
|
});
|
|
378
471
|
}
|
|
@@ -15,7 +15,7 @@ export declare class DateModule extends BaseModule implements Module, DateModule
|
|
|
15
15
|
getDateRange(): ITime[];
|
|
16
16
|
getResourceDates(params: IGetAvailableTimeListParams): Promise<ITime[]>;
|
|
17
17
|
getDateList(): ITime[];
|
|
18
|
-
setDateList(dateList: ITime[]): void;
|
|
18
|
+
setDateList(dateList: ITime[], replaceDates?: boolean): void;
|
|
19
19
|
fetchResourceDates(params: IGetAvailableTimeListParams): Promise<any>;
|
|
20
20
|
/**
|
|
21
21
|
* 将时间向上取整到下一个10分钟整数
|
|
@@ -27,6 +27,7 @@ import dayjs from 'dayjs';
|
|
|
27
27
|
import { BaseModule } from "../BaseModule";
|
|
28
28
|
import { disableAllDates, generateMonthDates, handleAvailableDateByResource, handleAvailableDatesByRules } from "./utils";
|
|
29
29
|
import cloneDeep from 'lodash-es/cloneDeep';
|
|
30
|
+
import { isBookingResourceList } from "../bookingReadValidation";
|
|
30
31
|
export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
31
32
|
_inherits(DateModule, _BaseModule);
|
|
32
33
|
var _super = _createSuper(DateModule);
|
|
@@ -104,11 +105,12 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
104
105
|
key: "getResourceDates",
|
|
105
106
|
value: function () {
|
|
106
107
|
var _getResourceDates = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
107
|
-
var _params$
|
|
108
|
+
var _params$assertCurrent2;
|
|
109
|
+
var _params$query, currentDateList, currentDateListMap, resourceIds, hasResource, dates, _params$assertCurrent;
|
|
108
110
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
109
111
|
while (1) switch (_context2.prev = _context2.next) {
|
|
110
112
|
case 0:
|
|
111
|
-
if (!params.useCache) {
|
|
113
|
+
if (!(params.useCache && params.errorMode !== 'throw')) {
|
|
112
114
|
_context2.next = 7;
|
|
113
115
|
break;
|
|
114
116
|
}
|
|
@@ -131,17 +133,27 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
131
133
|
}
|
|
132
134
|
return _context2.abrupt("return", currentDateList);
|
|
133
135
|
case 7:
|
|
134
|
-
_context2.
|
|
136
|
+
_context2.prev = 7;
|
|
137
|
+
_context2.next = 10;
|
|
135
138
|
return this.getResourceAvailableTimeList(params);
|
|
136
|
-
case
|
|
139
|
+
case 10:
|
|
137
140
|
dates = _context2.sent;
|
|
138
|
-
|
|
141
|
+
_context2.next = 17;
|
|
142
|
+
break;
|
|
143
|
+
case 13:
|
|
144
|
+
_context2.prev = 13;
|
|
145
|
+
_context2.t0 = _context2["catch"](7);
|
|
146
|
+
(_params$assertCurrent = params.assertCurrent) === null || _params$assertCurrent === void 0 || _params$assertCurrent.call(params);
|
|
147
|
+
throw _context2.t0;
|
|
148
|
+
case 17:
|
|
149
|
+
(_params$assertCurrent2 = params.assertCurrent) === null || _params$assertCurrent2 === void 0 || _params$assertCurrent2.call(params);
|
|
150
|
+
this.setDateList(dates, params.errorMode === 'throw');
|
|
139
151
|
return _context2.abrupt("return", dates);
|
|
140
|
-
case
|
|
152
|
+
case 20:
|
|
141
153
|
case "end":
|
|
142
154
|
return _context2.stop();
|
|
143
155
|
}
|
|
144
|
-
}, _callee2, this);
|
|
156
|
+
}, _callee2, this, [[7, 13]]);
|
|
145
157
|
}));
|
|
146
158
|
function getResourceDates(_x3) {
|
|
147
159
|
return _getResourceDates.apply(this, arguments);
|
|
@@ -156,6 +168,16 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
156
168
|
}, {
|
|
157
169
|
key: "setDateList",
|
|
158
170
|
value: function setDateList(dateList) {
|
|
171
|
+
var replaceDates = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
172
|
+
if (replaceDates) {
|
|
173
|
+
var incoming = new Map(dateList.map(function (date) {
|
|
174
|
+
return [date.date, date];
|
|
175
|
+
}));
|
|
176
|
+
this.store.dateList = [].concat(_toConsumableArray((this.store.dateList || []).filter(function (date) {
|
|
177
|
+
return !incoming.has(date.date);
|
|
178
|
+
})), _toConsumableArray(cloneDeep(dateList)));
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
159
181
|
// this.store.dateList = dateList;
|
|
160
182
|
// 并不能直接简单的进行复制
|
|
161
183
|
// 我们需要把每一天的资源都进行一个合并
|
|
@@ -210,25 +232,43 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
210
232
|
end_date: end_date,
|
|
211
233
|
resource_ids: resource_ids,
|
|
212
234
|
front_end_cache_id: useCache && this.cacheId
|
|
213
|
-
}, {
|
|
235
|
+
}, _objectSpread({
|
|
214
236
|
useCache: useCache
|
|
215
|
-
}
|
|
237
|
+
}, params.bookingRead ? {
|
|
238
|
+
bookingRead: true
|
|
239
|
+
} : {}));
|
|
216
240
|
case 6:
|
|
217
241
|
res = _context3.sent;
|
|
242
|
+
if (!(params.errorMode === 'throw')) {
|
|
243
|
+
_context3.next = 10;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
if (!(!res || res.code !== undefined && Number(res.code) !== 200 || res.status === false || res.success === false || typeof res.status === 'number' && res.status >= 400 || !isBookingResourceList(res.data))) {
|
|
247
|
+
_context3.next = 10;
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
throw new Error((res === null || res === void 0 ? void 0 : res.message) || 'Invalid booking resource response');
|
|
251
|
+
case 10:
|
|
218
252
|
// 校正资源时间段数据
|
|
219
253
|
if (res !== null && res !== void 0 && res.data && Array.isArray(res.data)) {
|
|
220
254
|
res.data = this.correctResourceTimeSlots(res.data);
|
|
221
255
|
}
|
|
222
256
|
return _context3.abrupt("return", res);
|
|
223
|
-
case
|
|
224
|
-
_context3.prev =
|
|
257
|
+
case 14:
|
|
258
|
+
_context3.prev = 14;
|
|
225
259
|
_context3.t0 = _context3["catch"](3);
|
|
260
|
+
if (!(params.errorMode === 'throw')) {
|
|
261
|
+
_context3.next = 18;
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
throw _context3.t0;
|
|
265
|
+
case 18:
|
|
226
266
|
console.error(_context3.t0);
|
|
227
|
-
case
|
|
267
|
+
case 19:
|
|
228
268
|
case "end":
|
|
229
269
|
return _context3.stop();
|
|
230
270
|
}
|
|
231
|
-
}, _callee3, this, [[3,
|
|
271
|
+
}, _callee3, this, [[3, 14]]);
|
|
232
272
|
}));
|
|
233
273
|
function fetchResourceDates(_x4) {
|
|
234
274
|
return _fetchResourceDates.apply(this, arguments);
|
|
@@ -363,8 +403,14 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
363
403
|
case 18:
|
|
364
404
|
_context4.prev = 18;
|
|
365
405
|
_context4.t0 = _context4["catch"](7);
|
|
406
|
+
if (!(params.errorMode === 'throw')) {
|
|
407
|
+
_context4.next = 22;
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
throw _context4.t0;
|
|
411
|
+
case 22:
|
|
366
412
|
return _context4.abrupt("return", disableAllDates(dates));
|
|
367
|
-
case
|
|
413
|
+
case 23:
|
|
368
414
|
case "end":
|
|
369
415
|
return _context4.stop();
|
|
370
416
|
}
|
|
@@ -44,6 +44,11 @@ export interface DateModuleAPI {
|
|
|
44
44
|
getResourceDates: (params: IGetAvailableTimeListParams) => Promise<ITime[]>;
|
|
45
45
|
}
|
|
46
46
|
export interface IGetAvailableTimeListParams {
|
|
47
|
+
/** BookingByStep opts in; existing solutions retain unavailable-on-error behavior. */
|
|
48
|
+
errorMode?: 'unavailable' | 'throw';
|
|
49
|
+
bookingRead?: boolean;
|
|
50
|
+
/** Check the selection is still current before committing a response. */
|
|
51
|
+
assertCurrent?: () => void;
|
|
47
52
|
url?: string;
|
|
48
53
|
/** 是否使用缓存 */
|
|
49
54
|
useCache?: boolean;
|
|
@@ -265,6 +265,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
265
265
|
_context5.next = 3;
|
|
266
266
|
return this.request.get("/machinecode/batch-search", _objectSpread(_objectSpread({
|
|
267
267
|
code: code,
|
|
268
|
+
resolve_ticket_order: 1,
|
|
268
269
|
translate_flag: 1,
|
|
269
270
|
tags: ['entitlement_pass', 'good_pass', 'product_discount_card'],
|
|
270
271
|
// available: 1,
|
|
@@ -4,6 +4,7 @@ import type { ScheduleModule } from '../Schedule';
|
|
|
4
4
|
import type { OpenDataConfig, OpenDataFetchParams, OpenDataAvailabilityResult, InvoiceLayoutConfig, InvoiceTemplateSettings } from './types';
|
|
5
5
|
export * from './types';
|
|
6
6
|
export * from './contactInfo';
|
|
7
|
+
export * from './salesSettings';
|
|
7
8
|
export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceLayoutFromTemplateSettings, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, resolveInvoiceReceiptLocales, } from './utils';
|
|
8
9
|
export declare class OpenDataModule extends BaseModule implements Module {
|
|
9
10
|
protected defaultName: string;
|
|
@@ -19,6 +19,7 @@ import { BaseModule } from "../BaseModule";
|
|
|
19
19
|
import { computeAvailability, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutFromTemplateSettings, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings } from "./utils";
|
|
20
20
|
export * from "./types";
|
|
21
21
|
export * from "./contactInfo";
|
|
22
|
+
export * from "./salesSettings";
|
|
22
23
|
export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceLayoutFromTemplateSettings, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, resolveInvoiceReceiptLocales } from "./utils";
|
|
23
24
|
function isRecord(value) {
|
|
24
25
|
return !!value && _typeof(value) === 'object' && !Array.isArray(value);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { MultiLangObject, OpenDataConfig } from './types';
|
|
2
|
+
export type MultipleBookingScheduling = 'one_after_another' | 'same_start_time';
|
|
3
|
+
export type ResourceSelectionMode = 'customer_optional' | 'customer_required' | 'automatic';
|
|
4
|
+
export interface SalesResourceSetting {
|
|
5
|
+
name?: string | MultiLangObject;
|
|
6
|
+
resourceSelectionMode: ResourceSelectionMode;
|
|
7
|
+
skipResourceSelectionIfSingle: boolean;
|
|
8
|
+
autoAssignmentRule: 'optimal_idle_time';
|
|
9
|
+
}
|
|
10
|
+
export interface ResolvedSalesSettings {
|
|
11
|
+
cart: {
|
|
12
|
+
showProductImage: boolean;
|
|
13
|
+
showRemoveButton: boolean;
|
|
14
|
+
};
|
|
15
|
+
product: {
|
|
16
|
+
checkRequiredOptions: boolean;
|
|
17
|
+
};
|
|
18
|
+
stock: {
|
|
19
|
+
checkStock: boolean;
|
|
20
|
+
allowInsufficientStock: boolean;
|
|
21
|
+
showDontRemindAgainToday: boolean;
|
|
22
|
+
};
|
|
23
|
+
reservation: {
|
|
24
|
+
multipleBookingScheduling: MultipleBookingScheduling;
|
|
25
|
+
resourceSettings: Record<string, SalesResourceSetting>;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export declare const DEFAULT_SALES_RESOURCE_SETTING: Readonly<SalesResourceSetting>;
|
|
29
|
+
/** PiCoding stores this field as a form-ID map despite its administration schema's array declaration. */
|
|
30
|
+
export declare function normalizeSalesResourceSettings(value: unknown): Record<string, SalesResourceSetting>;
|
|
31
|
+
/** Normalize a successfully loaded OpenData snapshot; callers must propagate loading failures. */
|
|
32
|
+
export declare function normalizeSalesSettings(raw: OpenDataConfig | null | undefined, platform: unknown): ResolvedSalesSettings;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
7
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
9
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
10
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
13
|
+
import { normalizeRuntimePlatform } from "../../utils/platform";
|
|
14
|
+
export var DEFAULT_SALES_RESOURCE_SETTING = Object.freeze({
|
|
15
|
+
resourceSelectionMode: 'customer_optional',
|
|
16
|
+
skipResourceSelectionIfSingle: true,
|
|
17
|
+
autoAssignmentRule: 'optimal_idle_time'
|
|
18
|
+
});
|
|
19
|
+
function isRecord(value) {
|
|
20
|
+
return !!value && _typeof(value) === 'object' && !Array.isArray(value);
|
|
21
|
+
}
|
|
22
|
+
function booleanOr(value, fallback) {
|
|
23
|
+
return typeof value === 'boolean' ? value : fallback;
|
|
24
|
+
}
|
|
25
|
+
function normalizeResourceName(value) {
|
|
26
|
+
if (typeof value === 'string') return value.trim() ? value : undefined;
|
|
27
|
+
if (!isRecord(value)) return undefined;
|
|
28
|
+
var entries = Object.entries(value).filter(function (_ref) {
|
|
29
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
30
|
+
text = _ref2[1];
|
|
31
|
+
return typeof text === 'string' && text.trim();
|
|
32
|
+
});
|
|
33
|
+
return entries.length ? Object.fromEntries(entries) : undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** PiCoding stores this field as a form-ID map despite its administration schema's array declaration. */
|
|
37
|
+
export function normalizeSalesResourceSettings(value) {
|
|
38
|
+
if (!isRecord(value)) return {};
|
|
39
|
+
var entries = Object.entries(value).flatMap(function (_ref3) {
|
|
40
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
41
|
+
formId = _ref4[0],
|
|
42
|
+
setting = _ref4[1];
|
|
43
|
+
if (!/^[1-9]\d*$/.test(formId) || !isRecord(setting)) return [];
|
|
44
|
+
var name = normalizeResourceName(setting.name);
|
|
45
|
+
var mode = setting.resourceSelectionMode;
|
|
46
|
+
return [[formId, _objectSpread(_objectSpread({}, name === undefined ? {} : {
|
|
47
|
+
name: name
|
|
48
|
+
}), {}, {
|
|
49
|
+
resourceSelectionMode: mode === 'customer_required' || mode === 'automatic' ? mode : 'customer_optional',
|
|
50
|
+
skipResourceSelectionIfSingle: booleanOr(setting.skipResourceSelectionIfSingle, true),
|
|
51
|
+
// No new allocation algorithm is introduced by this migration.
|
|
52
|
+
autoAssignmentRule: 'optimal_idle_time'
|
|
53
|
+
})]];
|
|
54
|
+
});
|
|
55
|
+
return Object.fromEntries(entries);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Normalize a successfully loaded OpenData snapshot; callers must propagate loading failures. */
|
|
59
|
+
export function normalizeSalesSettings(raw, platform) {
|
|
60
|
+
var runtimePlatform = normalizeRuntimePlatform(platform);
|
|
61
|
+
var isPos = runtimePlatform === 'pos' || runtimePlatform === 'webpos';
|
|
62
|
+
return {
|
|
63
|
+
cart: {
|
|
64
|
+
showProductImage: booleanOr(raw === null || raw === void 0 ? void 0 : raw['interface.show_product_image'], true),
|
|
65
|
+
showRemoveButton: isPos || booleanOr(raw === null || raw === void 0 ? void 0 : raw['interface.show_remove_button'], true)
|
|
66
|
+
},
|
|
67
|
+
product: {
|
|
68
|
+
checkRequiredOptions: booleanOr(raw === null || raw === void 0 ? void 0 : raw['sale.check_required_options'], true)
|
|
69
|
+
},
|
|
70
|
+
stock: {
|
|
71
|
+
checkStock: !isPos || booleanOr(raw === null || raw === void 0 ? void 0 : raw['sale.stock_settings'], true),
|
|
72
|
+
allowInsufficientStock: isPos && booleanOr(raw === null || raw === void 0 ? void 0 : raw['sale.allow_adding_insufficient_stock'], false),
|
|
73
|
+
showDontRemindAgainToday: isPos && booleanOr(raw === null || raw === void 0 ? void 0 : raw['sale.show_option'], false)
|
|
74
|
+
},
|
|
75
|
+
reservation: {
|
|
76
|
+
multipleBookingScheduling: (raw === null || raw === void 0 ? void 0 : raw['reservation.multiple_booking_scheduling']) === 'one_after_another' ? 'one_after_another' : 'same_start_time',
|
|
77
|
+
resourceSettings: normalizeSalesResourceSettings(raw === null || raw === void 0 ? void 0 : raw['reservation.resource_setting'])
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|