@pisell/pisellos 2.3.195 → 2.3.197
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/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 +6 -0
- package/dist/modules/BookingContext/utils/productExtend.js +21 -0
- package/dist/modules/Order/index.d.ts +3 -0
- package/dist/modules/Order/index.js +127 -46
- package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/dist/modules/Order/unpaidAmountGap.js +72 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ResourcePlanner/planner.js +24 -0
- package/dist/modules/ResourcePlanner/types.d.ts +7 -0
- package/dist/server/index.js +207 -193
- package/dist/server/modules/order/index.js +2 -1
- package/dist/shared/receipt/small-ticket.d.ts +3 -0
- package/dist/shared/receipt/small-ticket.js +26 -3
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.d.ts +2 -14
- package/dist/solution/BookingTicket/index.js +8 -4
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +35 -8
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
- package/dist/solution/OrderInvoicePreview/index.js +13 -8
- package/dist/solution/UnifiedBookingSales/index.d.ts +16 -2
- package/dist/solution/UnifiedBookingSales/index.js +1670 -1377
- package/dist/solution/UnifiedBookingSales/types.d.ts +1 -0
- package/dist/solution/UnifiedBookingSales/venueCatalogSession.js +11 -5
- 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 +6 -0
- package/lib/modules/BookingContext/utils/productExtend.js +23 -0
- package/lib/modules/Order/index.d.ts +3 -0
- package/lib/modules/Order/index.js +85 -16
- package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/lib/modules/Order/unpaidAmountGap.js +60 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ResourcePlanner/planner.js +23 -0
- package/lib/modules/ResourcePlanner/types.d.ts +7 -0
- package/lib/server/index.js +21 -5
- package/lib/server/modules/order/index.js +2 -1
- package/lib/shared/receipt/small-ticket.d.ts +3 -0
- package/lib/shared/receipt/small-ticket.js +24 -1
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.d.ts +2 -14
- package/lib/solution/BookingTicket/index.js +4 -2
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +33 -3
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
- package/lib/solution/OrderInvoicePreview/index.js +6 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +16 -2
- package/lib/solution/UnifiedBookingSales/index.js +176 -36
- package/lib/solution/UnifiedBookingSales/types.d.ts +1 -0
- package/lib/solution/UnifiedBookingSales/venueCatalogSession.js +9 -5
- package/package.json +1 -1
|
@@ -310,6 +310,7 @@ export interface UnifiedBookingSalesApi {
|
|
|
310
310
|
loadProductsByScheduleDate: (params: UnifiedBookingSalesLoadProductsByScheduleDateParams) => Promise<unknown[]>;
|
|
311
311
|
queryProducts: (params?: ProductListStoreQueryParams) => Promise<ProductData[]>;
|
|
312
312
|
stageRetailProducts: (params: UnifiedBookingSalesStageRetailProductsParams) => Promise<Record<string, any> | null>;
|
|
313
|
+
supportsVenueExtraHolders: () => boolean;
|
|
313
314
|
addRetailProduct: (params: UnifiedBookingSalesAddRetailProductParams) => Promise<Record<string, any>[]>;
|
|
314
315
|
prepareAvailabilityProjection: (params: UnifiedBookingSalesPrepareAvailabilityProjectionParams) => Promise<AvailabilityContextRef>;
|
|
315
316
|
getProductTimeRanges: (contextId: string, request?: GetProductTimeRangesRequest) => Promise<ContextualProductTimeRangeGroup[]>;
|
|
@@ -24,18 +24,24 @@ export function readVenueCatalogList(response, description) {
|
|
|
24
24
|
throw venueCatalogError('VENUE_CATALOG_LOAD_FAILED', (response === null || response === void 0 ? void 0 : response.message) || "".concat(description, " could not be loaded."));
|
|
25
25
|
}
|
|
26
26
|
var total = (_ref = (_response$data$total = response.data.total) !== null && _response$data$total !== void 0 ? _response$data$total : response.data.total_count) !== null && _ref !== void 0 ? _ref : response.data.total_num;
|
|
27
|
-
if (total
|
|
27
|
+
if (total == null ? list.length >= 999 : !Number.isSafeInteger(Number(total)) || Number(total) < 0 || Number(total) > list.length) {
|
|
28
28
|
throw venueCatalogError('VENUE_CATALOG_INCOMPLETE', "".concat(description, " is incomplete. A complete catalog response is required."));
|
|
29
29
|
}
|
|
30
|
+
if (list.some(function (row) {
|
|
31
|
+
return !Number.isSafeInteger(Number(row === null || row === void 0 ? void 0 : row.form_record_id)) || Number(row.form_record_id) <= 0;
|
|
32
|
+
})) {
|
|
33
|
+
throw venueCatalogError('VENUE_CATALOG_INCOMPLETE', "".concat(description, " contains a record without a valid menu ID."));
|
|
34
|
+
}
|
|
30
35
|
return list;
|
|
31
36
|
}
|
|
32
37
|
export function validateVenueMenus(records, ids) {
|
|
33
|
-
return ids.
|
|
38
|
+
return ids.flatMap(function (id) {
|
|
34
39
|
var menu = records.find(function (row) {
|
|
35
40
|
return Number(row.form_record_id) === id;
|
|
36
41
|
});
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
if (!menu || menu.deleted_at || menu.status && menu.status !== 'valid') return [];
|
|
43
|
+
var config = menu.partyroom_package;
|
|
44
|
+
if (!['product_all', 'products', 'product_collection'].includes(config === null || config === void 0 ? void 0 : config.type) || !Array.isArray(menu.schedule) || menu.schedule.some(function (value) {
|
|
39
45
|
return !Number.isSafeInteger(Number(value)) || Number(value) <= 0;
|
|
40
46
|
}) || config.type !== 'product_all' && (!Array.isArray(config.products) || config.products.some(function (row) {
|
|
41
47
|
var value = Number(row === null || row === void 0 ? void 0 : row[config.type === 'products' ? 'product_id' : 'product_collection_id']);
|
|
@@ -43,7 +49,7 @@ export function validateVenueMenus(records, ids) {
|
|
|
43
49
|
}))) {
|
|
44
50
|
throw venueCatalogError('VENUE_MENU_INCOMPLETE', 'The configured menu is incomplete. Reload the booking page.');
|
|
45
51
|
}
|
|
46
|
-
return cloneDeep(menu);
|
|
52
|
+
return [cloneDeep(menu)];
|
|
47
53
|
});
|
|
48
54
|
}
|
|
49
55
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import type { BookingCalcContext } from './productExtend';
|
|
3
|
+
export declare function isManualBookingProduct(product: any): boolean;
|
|
4
|
+
export declare function getCalendarBookingRange(product: any, ctx?: BookingCalcContext): {
|
|
5
|
+
startAt: string;
|
|
6
|
+
endAt: string;
|
|
7
|
+
duration: number;
|
|
8
|
+
startDate: dayjs.Dayjs;
|
|
9
|
+
endDate: dayjs.Dayjs;
|
|
10
|
+
} | undefined;
|
|
11
|
+
/** A prepared calendar cache is reused after SKU input; no availability-driven replacement is allowed. */
|
|
12
|
+
export declare function prepareCalendarBookingCacheItem(cacheItem: any, ctx: BookingCalcContext): any;
|
|
13
|
+
export declare function calendarBookingEntryKey(ctx: BookingCalcContext): string;
|
|
14
|
+
export declare function calendarBookingNeedsInput(cacheItem: any): boolean;
|
|
15
|
+
export declare function calendarBookingPreparationKey(cacheItem: any, ctx: BookingCalcContext): string;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.calendarBookingEntryKey = calendarBookingEntryKey;
|
|
7
|
+
exports.calendarBookingNeedsInput = calendarBookingNeedsInput;
|
|
8
|
+
exports.calendarBookingPreparationKey = calendarBookingPreparationKey;
|
|
9
|
+
exports.getCalendarBookingRange = getCalendarBookingRange;
|
|
10
|
+
exports.isManualBookingProduct = isManualBookingProduct;
|
|
11
|
+
exports.prepareCalendarBookingCacheItem = prepareCalendarBookingCacheItem;
|
|
12
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
13
|
+
var _localClock = require("../../ResourcePlanner/localClock");
|
|
14
|
+
var _serviceTimes = require("./serviceTimes");
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
function isManualBookingProduct(product) {
|
|
17
|
+
return !(0, _serviceTimes.isBookingProduct)(product) && Boolean(product?.extension_type === 'product_appointment' || product?.product_resource?.resources?.some(group => Number(group.status) === 1) || ['custom', 'package'].includes(product?.capacity?.type));
|
|
18
|
+
}
|
|
19
|
+
function getCalendarBookingRange(product, ctx) {
|
|
20
|
+
const range = ctx?.bookingTimeRangeFromCalendar;
|
|
21
|
+
if (!range || ctx?.platform !== 'pos' || (0, _serviceTimes.isMultiDayProduct)(product) || product?.duration_type === 'days' || product?.flexible?.duration?.type === 'days' || product?._extend?.sub_type === 'days' || !(0, _serviceTimes.isBookingProduct)(product) && !isManualBookingProduct(product)) return undefined;
|
|
22
|
+
try {
|
|
23
|
+
const offset = (0, _localClock.captureRuntimeOffsetMinutes)();
|
|
24
|
+
const normalize = text => {
|
|
25
|
+
const scalar = (0, _localClock.localDateTimeToScalar)((0, _localClock.parseLocalDateTime)(text));
|
|
26
|
+
const inputOffset = (0, _localClock.extractFixedOffsetMinutes)(text) ?? offset;
|
|
27
|
+
return (0, _localClock.formatLocalDateTime)(scalar + (offset - inputOffset) * 60000, offset);
|
|
28
|
+
};
|
|
29
|
+
const startAt = normalize(range.startAt);
|
|
30
|
+
const endAt = normalize(range.endAt);
|
|
31
|
+
const start = (0, _localClock.localDateTimeToScalar)((0, _localClock.parseLocalDateTime)(startAt));
|
|
32
|
+
const end = (0, _localClock.localDateTimeToScalar)((0, _localClock.parseLocalDateTime)(endAt));
|
|
33
|
+
const duration = (end - start) / 60000;
|
|
34
|
+
if (!Number.isInteger(duration) || duration <= 0 || start % 60000 || end % 60000) throw new Error();
|
|
35
|
+
return {
|
|
36
|
+
startAt,
|
|
37
|
+
endAt,
|
|
38
|
+
duration,
|
|
39
|
+
startDate: (0, _dayjs.default)(startAt.slice(0, 19)),
|
|
40
|
+
endDate: (0, _dayjs.default)(endAt.slice(0, 19))
|
|
41
|
+
};
|
|
42
|
+
} catch {
|
|
43
|
+
throw Object.assign(new Error('Calendar booking requires valid complete start/end times.'), {
|
|
44
|
+
code: 'INVALID_TARGET_FILTER'
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** A prepared calendar cache is reused after SKU input; no availability-driven replacement is allowed. */
|
|
50
|
+
function prepareCalendarBookingCacheItem(cacheItem, ctx) {
|
|
51
|
+
let range = getCalendarBookingRange(cacheItem, ctx);
|
|
52
|
+
if (!range) return cacheItem;
|
|
53
|
+
const resource = {};
|
|
54
|
+
const forms = (cacheItem.product_resource?.resources || []).filter(group => Number(group.status) === 1);
|
|
55
|
+
const entry = Number(ctx.resourceIdFromCalendar);
|
|
56
|
+
const preserveInput = cacheItem._data?.calendarBookingEntryKey === calendarBookingEntryKey(ctx);
|
|
57
|
+
let inputInvalid = false;
|
|
58
|
+
if (preserveInput) {
|
|
59
|
+
const ext = cacheItem._extend || {};
|
|
60
|
+
try {
|
|
61
|
+
if (!(ext.start_date ?? ext.startDate) || !(ext.end_date ?? ext.endDate) || !ext.start_time || !ext.end_time) throw new Error('Incomplete calendar input.');
|
|
62
|
+
range = getCalendarBookingRange(cacheItem, {
|
|
63
|
+
...ctx,
|
|
64
|
+
bookingTimeRangeFromCalendar: {
|
|
65
|
+
startAt: `${(0, _dayjs.default)(ext.start_date ?? ext.startDate).format('YYYY-MM-DD')}T${ext.start_time}:00`,
|
|
66
|
+
endAt: `${(0, _dayjs.default)(ext.end_date ?? ext.endDate).format('YYYY-MM-DD')}T${ext.end_time}:00`
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
} catch {
|
|
70
|
+
range = undefined;
|
|
71
|
+
inputInvalid = true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
for (const form of forms) {
|
|
75
|
+
const ids = [...(form.optional_resource || []), ...(form.default_resource || [])];
|
|
76
|
+
const linked = ids.some(id => String(id) === String(entry));
|
|
77
|
+
const origin = ctx.resourcesOriginMap?.[entry];
|
|
78
|
+
const chosen = cacheItem._extend?.resource?.[String(form.id)];
|
|
79
|
+
const hasChosen = preserveInput && chosen !== undefined;
|
|
80
|
+
const validChosen = hasChosen && Array.isArray(chosen) && new Set(chosen.map(row => String(row.relation_id))).size === chosen.length && chosen.every(row => (row.form_id == null || String(row.form_id) === String(form.id)) && (Number(row.relation_id) === 0 || ids.some(id => String(id) === String(row.relation_id)) && ctx.resourcesOriginMap?.[row.relation_id] && (ctx.resourcesOriginMap[row.relation_id].form_id == null || String(ctx.resourcesOriginMap[row.relation_id].form_id) === String(form.id))));
|
|
81
|
+
if (hasChosen && !validChosen) inputInvalid = true;
|
|
82
|
+
if (hasChosen) {
|
|
83
|
+
resource[String(form.id)] = validChosen ? chosen : [];
|
|
84
|
+
} else if (linked && origin && (origin.form_id == null || String(origin.form_id) === String(form.id))) {
|
|
85
|
+
resource[String(form.id)] = [{
|
|
86
|
+
relation_type: origin.relation_type || 'form',
|
|
87
|
+
form_id: form.id,
|
|
88
|
+
relation_id: entry,
|
|
89
|
+
like_status: 'common',
|
|
90
|
+
metadata: {
|
|
91
|
+
form_name: form.title,
|
|
92
|
+
resource_name: origin.main_field
|
|
93
|
+
}
|
|
94
|
+
}];
|
|
95
|
+
} else {
|
|
96
|
+
resource[String(form.id)] = [];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
...cacheItem,
|
|
101
|
+
...(isManualBookingProduct(cacheItem) && range ? {
|
|
102
|
+
duration: {
|
|
103
|
+
type: 'minutes',
|
|
104
|
+
value: range.duration
|
|
105
|
+
}
|
|
106
|
+
} : {}),
|
|
107
|
+
_data: {
|
|
108
|
+
...cacheItem._data,
|
|
109
|
+
calendarBookingInputInvalid: inputInvalid
|
|
110
|
+
},
|
|
111
|
+
_extend: {
|
|
112
|
+
...cacheItem._extend,
|
|
113
|
+
...(range ? {
|
|
114
|
+
startDate: range.startDate,
|
|
115
|
+
start_date: range.startDate,
|
|
116
|
+
start_time: range.startAt.slice(11, 16),
|
|
117
|
+
endDate: range.endDate,
|
|
118
|
+
end_date: range.endDate,
|
|
119
|
+
end_time: range.endAt.slice(11, 16),
|
|
120
|
+
duration: range.duration
|
|
121
|
+
} : {}),
|
|
122
|
+
resource
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function calendarBookingEntryKey(ctx) {
|
|
127
|
+
return JSON.stringify([ctx.bookingTimeRangeFromCalendar, ctx.resourceIdFromCalendar]);
|
|
128
|
+
}
|
|
129
|
+
function calendarBookingNeedsInput(cacheItem) {
|
|
130
|
+
if (cacheItem._data?.calendarBookingInputInvalid) return true;
|
|
131
|
+
const capacity = cacheItem.capacity;
|
|
132
|
+
if (capacity?.type === 'custom' && (!Array.isArray(capacity.custom) || !capacity.custom.length || capacity.custom.some(item => !Number.isFinite(Number(item.min)) || item.max == null || Number(item.min) !== Number(item.max)))) return true;
|
|
133
|
+
const groups = cacheItem.product_resource?.resources;
|
|
134
|
+
if (groups != null && !Array.isArray(groups)) return true;
|
|
135
|
+
const seen = new Set();
|
|
136
|
+
return (groups || []).some(group => {
|
|
137
|
+
if (Number(group.status) === 0) return false;
|
|
138
|
+
if (group.id == null || seen.has(String(group.id))) return true;
|
|
139
|
+
seen.add(String(group.id));
|
|
140
|
+
const rule = group.select_type;
|
|
141
|
+
if (Number(group.status) !== 1 || !rule || !['single', 'multiple'].includes(rule.type)) return true;
|
|
142
|
+
const min = Number(rule.min ?? (rule.type === 'single' ? 1 : NaN));
|
|
143
|
+
const max = Number(rule.max ?? (rule.type === 'single' ? 1 : NaN));
|
|
144
|
+
const rows = cacheItem._extend?.resource?.[String(group.id)];
|
|
145
|
+
const required = group.required ?? true;
|
|
146
|
+
const minimum = Math.max(required ? 1 : 0, min);
|
|
147
|
+
return !Number.isInteger(min) || !Number.isInteger(max) || min < 0 || max < minimum || !Array.isArray(rows) || rows.length < minimum || rows.length > max;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function calendarBookingPreparationKey(cacheItem, ctx) {
|
|
151
|
+
const identities = rows => (rows || []).map(row => [row.group_id ?? row.option_group_id ?? row.bundle_group_id, row.product_option_item_id ?? row.option_group_item_id ?? row.id, row._bundle_product_id ?? row.bundle_product_id, row.product_variant_id ?? row.bundle_variant_id, row.quantity ?? row.num ?? 1, identities(row.option)]).sort((left, right) => JSON.stringify(left).localeCompare(JSON.stringify(right)));
|
|
152
|
+
const sku = cacheItem._extend?.other || {};
|
|
153
|
+
const ext = cacheItem._extend || {};
|
|
154
|
+
const dateKey = value => value == null || value === '' ? null : (0, _dayjs.default)(value).format('YYYY-MM-DD');
|
|
155
|
+
return JSON.stringify([ctx.bookingTimeRangeFromCalendar, ctx.resourceIdFromCalendar, cacheItem.capacity, cacheItem.product_resource, sku.product_variant_id ?? sku.variant_id, identities(sku.option), identities(sku.bundle), dateKey(ext.start_date ?? ext.startDate), ext.start_time, dateKey(ext.end_date ?? ext.endDate), ext.end_time, Object.entries(ext.resource || {}).map(([formId, rows]) => [formId, Array.isArray(rows) ? rows.map(row => [row.form_id, row.relation_id]) : null])]);
|
|
156
|
+
}
|
|
@@ -6,6 +6,7 @@ export * from './resources';
|
|
|
6
6
|
export * from './resourceSelection';
|
|
7
7
|
export * from './resourceErrors';
|
|
8
8
|
export * from './productExtend';
|
|
9
|
+
export * from './calendarBooking';
|
|
9
10
|
export * from './cacheItemToBookingInput';
|
|
10
11
|
export * from './buildCacheItemFromOrderLine';
|
|
11
12
|
export * from './buildNormalProductCacheItemFromOrderLine';
|
|
@@ -91,6 +91,17 @@ Object.keys(_productExtend).forEach(function (key) {
|
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
});
|
|
94
|
+
var _calendarBooking = require("./calendarBooking");
|
|
95
|
+
Object.keys(_calendarBooking).forEach(function (key) {
|
|
96
|
+
if (key === "default" || key === "__esModule") return;
|
|
97
|
+
if (key in exports && exports[key] === _calendarBooking[key]) return;
|
|
98
|
+
Object.defineProperty(exports, key, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return _calendarBooking[key];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
94
105
|
var _cacheItemToBookingInput = require("./cacheItemToBookingInput");
|
|
95
106
|
Object.keys(_cacheItemToBookingInput).forEach(function (key) {
|
|
96
107
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -7,6 +7,12 @@ import { TimeSlicesResult, TimeSlice, DurationSlice } from './timeSlices';
|
|
|
7
7
|
* 让 OS 这层完全可在 Node 单测下运行(dayjs 在 Node 也是纯函数)。
|
|
8
8
|
*/
|
|
9
9
|
export interface BookingCalcContext {
|
|
10
|
+
/** Real runtime platform, injected by BookingTicket rather than inferred from sales channel. */
|
|
11
|
+
platform?: string;
|
|
12
|
+
bookingTimeRangeFromCalendar?: {
|
|
13
|
+
startAt: string;
|
|
14
|
+
endAt: string;
|
|
15
|
+
};
|
|
10
16
|
/** Sales channel; remembered duration starts are accepted only by POS. */
|
|
11
17
|
channel?: string;
|
|
12
18
|
/** Current in-memory order session, supplied by the owning Order module. */
|
|
@@ -20,6 +20,7 @@ var _resourceSelection = require("./resourceSelection");
|
|
|
20
20
|
var _serviceTimes = require("./serviceTimes");
|
|
21
21
|
var _timeSlices = require("./timeSlices");
|
|
22
22
|
var _flexible = require("./flexible");
|
|
23
|
+
var _calendarBooking = require("./calendarBooking");
|
|
23
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
25
|
/**
|
|
25
26
|
* 上下文(与 info2 state.bookingConfig / state.service / state.date 一一对应)。
|
|
@@ -291,6 +292,28 @@ function getProductExtend(params) {
|
|
|
291
292
|
const {
|
|
292
293
|
isDisabledTime
|
|
293
294
|
} = params;
|
|
295
|
+
if ((0, _calendarBooking.getCalendarBookingRange)(params.cacheItem, params.ctx)) {
|
|
296
|
+
const prepared = (0, _calendarBooking.prepareCalendarBookingCacheItem)(params.cacheItem, params.ctx);
|
|
297
|
+
const capacity = (0, _resources.setDefaultCapacitys)({
|
|
298
|
+
capacitys: prepared.capacity,
|
|
299
|
+
cacheItem: prepared
|
|
300
|
+
});
|
|
301
|
+
return {
|
|
302
|
+
...prepared,
|
|
303
|
+
_extend: {
|
|
304
|
+
...prepared._extend,
|
|
305
|
+
capacity
|
|
306
|
+
},
|
|
307
|
+
_data: {
|
|
308
|
+
...prepared._data,
|
|
309
|
+
capacitys: prepared.capacity,
|
|
310
|
+
calendarManualBooking: params.cacheItem._data?.calendarManualBooking === true || (0, _calendarBooking.isManualBookingProduct)(params.cacheItem),
|
|
311
|
+
calendarBookingEntryKey: (0, _calendarBooking.calendarBookingEntryKey)(params.ctx),
|
|
312
|
+
calendarBookingPreparationKey: (0, _calendarBooking.calendarBookingPreparationKey)(prepared, params.ctx)
|
|
313
|
+
},
|
|
314
|
+
autoClose: !(0, _calendarBooking.calendarBookingNeedsInput)(prepared)
|
|
315
|
+
};
|
|
316
|
+
}
|
|
294
317
|
const hasRememberedTime = params.ctx.rememberedTime !== undefined;
|
|
295
318
|
const cacheItem = hasRememberedTime ? seedRememberedBookingStart(params.cacheItem, params.ctx) : params.cacheItem;
|
|
296
319
|
const ctx = hasRememberedTime ? {
|
|
@@ -243,6 +243,9 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
243
243
|
private calculatePaymentTotal;
|
|
244
244
|
private calculateOrderPaidPaymentTotal;
|
|
245
245
|
private getDepositAmount;
|
|
246
|
+
private isDepositSelectionDisabled;
|
|
247
|
+
/** Cap only the active target; product rules, manual intent and saved snapshots stay raw. */
|
|
248
|
+
private applyEffectiveDepositSummary;
|
|
246
249
|
private normalizeDepositAmount;
|
|
247
250
|
private normalizeDepositFlag;
|
|
248
251
|
private getHistoricalDepositSnapshot;
|
|
@@ -1600,7 +1600,37 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
1600
1600
|
}, new _decimal.default(0));
|
|
1601
1601
|
}
|
|
1602
1602
|
getDepositAmount(tempOrder, summary) {
|
|
1603
|
-
|
|
1603
|
+
const summaryAmount = summary.deposit_amount;
|
|
1604
|
+
const amount = summaryAmount === '' ? tempOrder.deposit_amount : summaryAmount ?? tempOrder.deposit_amount;
|
|
1605
|
+
return _decimal.default.min(_decimal.default.max(new _decimal.default(amount || 0), 0), this.getOrderExpectedAmount(summary));
|
|
1606
|
+
}
|
|
1607
|
+
isDepositSelectionDisabled(tempOrder) {
|
|
1608
|
+
return tempOrder._extend?.depositSelectionDisabled === true || tempOrder.is_deposit === 0 && new _decimal.default(tempOrder.deposit_amount || 0).gt(0);
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
/** Cap only the active target; product rules, manual intent and saved snapshots stay raw. */
|
|
1612
|
+
applyEffectiveDepositSummary(tempOrder, summary) {
|
|
1613
|
+
const disabled = this.isDepositSelectionDisabled(tempOrder);
|
|
1614
|
+
if (disabled) {
|
|
1615
|
+
tempOrder._extend = {
|
|
1616
|
+
...(tempOrder._extend || {}),
|
|
1617
|
+
depositSelectionDisabled: true
|
|
1618
|
+
};
|
|
1619
|
+
}
|
|
1620
|
+
const depositAmount = this.getDepositAmount(tempOrder, summary).toFixed(2);
|
|
1621
|
+
const hasDepositAmount = new _decimal.default(depositAmount).gt(0);
|
|
1622
|
+
const nextSummary = {
|
|
1623
|
+
...summary,
|
|
1624
|
+
deposit_amount: depositAmount,
|
|
1625
|
+
deposit: hasDepositAmount ? {
|
|
1626
|
+
...(summary.deposit || {}),
|
|
1627
|
+
total: depositAmount,
|
|
1628
|
+
hasDeposit: true
|
|
1629
|
+
} : undefined
|
|
1630
|
+
};
|
|
1631
|
+
tempOrder.deposit_amount = depositAmount;
|
|
1632
|
+
tempOrder.is_deposit = hasDepositAmount && tempOrder.is_deposit === 1 && !disabled ? 1 : 0;
|
|
1633
|
+
return nextSummary;
|
|
1604
1634
|
}
|
|
1605
1635
|
normalizeDepositAmount(amount) {
|
|
1606
1636
|
return _decimal.default.max(new _decimal.default(Number(amount) || 0), 0).toDecimalPlaces(2).toFixed(2);
|
|
@@ -1614,8 +1644,19 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
1614
1644
|
if (!source || typeof source !== 'object') return null;
|
|
1615
1645
|
const record = source;
|
|
1616
1646
|
const rawDepositAmount = record.deposit_amount ?? record.summary?.deposit_amount;
|
|
1647
|
+
if (rawDepositAmount === undefined || rawDepositAmount === null || rawDepositAmount === '') return null;
|
|
1617
1648
|
const depositAmount = this.normalizeDepositAmount(rawDepositAmount ?? 0);
|
|
1618
|
-
if (!new _decimal.default(depositAmount).gt(0))
|
|
1649
|
+
if (!new _decimal.default(depositAmount).gt(0)) {
|
|
1650
|
+
// A saved zero is meaningful for an existing deposit product, but must not
|
|
1651
|
+
// freeze ordinary historical retail orders when a deposit product is added.
|
|
1652
|
+
const products = Array.isArray(record.products) ? record.products : [];
|
|
1653
|
+
const hasDepositContext = this.normalizeDepositFlag(record.is_deposit) === 1 || products.some(product => Number(product?.deposit?.total) > 0) || (0, _utils.calculateOrderProductsDeposit)(products.map(product => ({
|
|
1654
|
+
...product
|
|
1655
|
+
})), {
|
|
1656
|
+
productsByUid: record._extend?.productsByUid
|
|
1657
|
+
}).hasDeposit;
|
|
1658
|
+
if (!hasDepositContext) return null;
|
|
1659
|
+
}
|
|
1619
1660
|
return {
|
|
1620
1661
|
// 兼容历史数据:旧快照缺少 is_deposit 时,沿用正定金金额的推导规则。
|
|
1621
1662
|
isDeposit: this.normalizeDepositFlag(record.is_deposit) ?? 1,
|
|
@@ -1679,7 +1720,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
1679
1720
|
return tempOrder.is_deposit === 1 && depositAmount.gt(0);
|
|
1680
1721
|
}
|
|
1681
1722
|
getOrderExpectedAmount(summary) {
|
|
1682
|
-
|
|
1723
|
+
const expected = summary.expect_amount;
|
|
1724
|
+
const amount = expected === '' ? summary.total_amount : expected ?? summary.total_amount;
|
|
1725
|
+
return _decimal.default.max(new _decimal.default(amount || 0), 0);
|
|
1683
1726
|
}
|
|
1684
1727
|
isDepositCovered(params) {
|
|
1685
1728
|
const depositAmount = this.getDepositAmount(params.tempOrder, params.summary);
|
|
@@ -1728,7 +1771,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
1728
1771
|
});
|
|
1729
1772
|
}
|
|
1730
1773
|
resolveNextOrderPaymentType(tempOrder) {
|
|
1731
|
-
const depositAmount =
|
|
1774
|
+
const depositAmount = this.getDepositAmount(tempOrder, this.store.summary || (0, _utils.createEmptySummary)());
|
|
1732
1775
|
if (!this.isDepositOrder(tempOrder, depositAmount)) return 'normal';
|
|
1733
1776
|
if (depositAmount.lte(0)) return 'normal';
|
|
1734
1777
|
if (this.hasPaidNormalPayment(tempOrder.payments || [])) return 'normal';
|
|
@@ -2229,6 +2272,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2229
2272
|
tempOrder.is_deposit = historicalDepositSnapshot.isDeposit;
|
|
2230
2273
|
}
|
|
2231
2274
|
}
|
|
2275
|
+
summary = this.applyEffectiveDepositSummary(tempOrder, summary);
|
|
2232
2276
|
const isPayableAmountUnchanged = this.isSnapshotPayableAmountUnchanged(tempOrder, snapshot, summary);
|
|
2233
2277
|
if (!isPayableAmountUnchanged) return null;
|
|
2234
2278
|
const currentPaidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
@@ -2244,8 +2288,6 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2244
2288
|
tempOrder.surcharges = (0, _lodashEs.cloneDeep)(snapshot.surcharges);
|
|
2245
2289
|
}
|
|
2246
2290
|
tempOrder.surcharge_fee = summary.surcharge_fee || tempOrder.surcharge_fee;
|
|
2247
|
-
tempOrder.deposit_amount = this.normalizeDepositAmount(summary.deposit_amount || 0);
|
|
2248
|
-
tempOrder.is_deposit = shouldUseManualDepositOverride ? new _decimal.default(tempOrder.deposit_amount).gt(0) ? 1 : 0 : historicalDepositSnapshot?.isDeposit ?? (new _decimal.default(tempOrder.deposit_amount).gt(0) ? 1 : 0);
|
|
2249
2291
|
const previousSummary = this.store.summary;
|
|
2250
2292
|
this.store.summary = summary;
|
|
2251
2293
|
this.updateTempOrderPaymentStatus(tempOrder, {
|
|
@@ -2378,7 +2420,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2378
2420
|
const tempOrder = this.store.tempOrder;
|
|
2379
2421
|
if (!tempOrder) return null;
|
|
2380
2422
|
const summary = this.store.summary || (0, _utils.createEmptySummary)();
|
|
2381
|
-
const depositAmount = tempOrder
|
|
2423
|
+
const depositAmount = this.getDepositAmount(tempOrder, summary);
|
|
2382
2424
|
const paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
2383
2425
|
const amountGap = this.calculateSummaryAmountGap({
|
|
2384
2426
|
tempOrder,
|
|
@@ -2386,10 +2428,10 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2386
2428
|
orderPaidAmount: paidPaymentSummary.gapPaidAmount
|
|
2387
2429
|
});
|
|
2388
2430
|
return {
|
|
2389
|
-
isDeposit: tempOrder
|
|
2390
|
-
depositAmount,
|
|
2391
|
-
expectAmount: summary.expect_amount
|
|
2392
|
-
totalAmount: summary.total_amount
|
|
2431
|
+
isDeposit: this.isDepositOrder(tempOrder, depositAmount),
|
|
2432
|
+
depositAmount: depositAmount.toFixed(2),
|
|
2433
|
+
expectAmount: String(summary.expect_amount ?? '0.00'),
|
|
2434
|
+
totalAmount: String(summary.total_amount ?? '0.00'),
|
|
2393
2435
|
amountGap,
|
|
2394
2436
|
summary
|
|
2395
2437
|
};
|
|
@@ -2707,6 +2749,13 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2707
2749
|
return this.core.getModule(this.salesSummaryModuleName);
|
|
2708
2750
|
}
|
|
2709
2751
|
applyOrderProductsDepositSummary(tempOrder, summary) {
|
|
2752
|
+
const isExistingDepositDisabled = this.isDepositSelectionDisabled(tempOrder);
|
|
2753
|
+
if (isExistingDepositDisabled) {
|
|
2754
|
+
tempOrder._extend = {
|
|
2755
|
+
...(tempOrder._extend || {}),
|
|
2756
|
+
depositSelectionDisabled: true
|
|
2757
|
+
};
|
|
2758
|
+
}
|
|
2710
2759
|
const depositSummary = (0, _utils.calculateOrderProductsDeposit)(tempOrder.products || [], {
|
|
2711
2760
|
productsByUid: tempOrder._extend?.productsByUid
|
|
2712
2761
|
});
|
|
@@ -2728,10 +2777,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2728
2777
|
hasDeposit: true
|
|
2729
2778
|
} : undefined
|
|
2730
2779
|
};
|
|
2731
|
-
const isExistingDepositDisabled = tempOrder.is_deposit === 0 && new _decimal.default(tempOrder.deposit_amount || 0).gt(0);
|
|
2732
2780
|
tempOrder.deposit_amount = depositAmount;
|
|
2733
2781
|
tempOrder.is_deposit = hasDepositAmount && !isExistingDepositDisabled ? 1 : 0;
|
|
2734
|
-
return shouldUseManualDepositOverride ? nextSummary : this.applyLastOrderDepositSnapshot(tempOrder, nextSummary);
|
|
2782
|
+
return this.applyEffectiveDepositSummary(tempOrder, shouldUseManualDepositOverride ? nextSummary : this.applyLastOrderDepositSnapshot(tempOrder, nextSummary));
|
|
2735
2783
|
}
|
|
2736
2784
|
async recalculateSummary(options) {
|
|
2737
2785
|
if (options?.isCurrentOrder && !options.isCurrentOrder()) return null;
|
|
@@ -3066,11 +3114,15 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3066
3114
|
updateTempOrderDepositAmount(amount) {
|
|
3067
3115
|
const tempOrder = this.ensureTempOrder();
|
|
3068
3116
|
const depositAmount = this.normalizeDepositAmount(amount);
|
|
3117
|
+
tempOrder._extend = {
|
|
3118
|
+
...(tempOrder._extend || {}),
|
|
3119
|
+
depositSelectionDisabled: new _decimal.default(depositAmount).lte(0)
|
|
3120
|
+
};
|
|
3069
3121
|
const previousSummary = this.store.summary || (0, _utils.createEmptySummary)();
|
|
3070
|
-
const summaryWithDeposit = this.applyDepositAmountToSummary(tempOrder, {
|
|
3122
|
+
const summaryWithDeposit = this.applyEffectiveDepositSummary(tempOrder, this.applyDepositAmountToSummary(tempOrder, {
|
|
3071
3123
|
...(0, _utils.createEmptySummary)(),
|
|
3072
3124
|
...previousSummary
|
|
3073
|
-
}, depositAmount);
|
|
3125
|
+
}, depositAmount));
|
|
3074
3126
|
this.setManualDepositOverride(tempOrder, depositAmount);
|
|
3075
3127
|
const paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
3076
3128
|
const summary = {
|
|
@@ -4018,7 +4070,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4018
4070
|
// 库存/商品券校验与自动预约共用草稿,全部门禁通过后才发布完整批次。
|
|
4019
4071
|
const tempOrder = availabilityCommitGuard && !mutation.commit ? (0, _lodashEs.cloneDeep)(liveTempOrder) : mutation.draft;
|
|
4020
4072
|
const beforeAppend = mutation.commit ? undefined : beforeCommit;
|
|
4021
|
-
const guardedMutationFields = ['products', 'bookings', 'notes', '_extend', 'metadata', 'currency_code', 'currency_symbol', 'currency_format'];
|
|
4073
|
+
const guardedMutationFields = ['products', 'bookings', 'notes', '_extend', 'metadata', 'currency_code', 'currency_symbol', 'currency_format', ...(!booking && Array.isArray(product._extend?.holder_relations) ? ['holder_relations'] : [])];
|
|
4022
4074
|
const readGuardedMutationFields = order => Object.fromEntries(guardedMutationFields.map(key => [key, order[key]]));
|
|
4023
4075
|
const guardedMutationBaseline = availabilityCommitGuard ? (0, _lodashEs.cloneDeep)(readGuardedMutationFields(liveTempOrder)) : null;
|
|
4024
4076
|
const beforePublish = () => {
|
|
@@ -5881,6 +5933,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5881
5933
|
};
|
|
5882
5934
|
const rawSummary = raw.summary && typeof raw.summary === 'object' ? raw.summary : {};
|
|
5883
5935
|
const historicalDepositSnapshot = this.getHistoricalDepositSnapshot(sourceLastOrderInfo);
|
|
5936
|
+
if (historicalDepositSnapshot && this.normalizeDepositFlag(raw.is_deposit) === null) {
|
|
5937
|
+
nextTempOrder.is_deposit = historicalDepositSnapshot.isDeposit;
|
|
5938
|
+
}
|
|
5884
5939
|
const summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(s => ({
|
|
5885
5940
|
...(s || {})
|
|
5886
5941
|
})) : (0, _lodashEs.cloneDeep)(nextTempOrder.surcharges || []);
|
|
@@ -5934,6 +5989,20 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5934
5989
|
createIfMissing: false,
|
|
5935
5990
|
isCurrentOrder: () => this.orderReplacement === replacement
|
|
5936
5991
|
});
|
|
5992
|
+
} else if (!isMergedSalesDetailHydrate && [rawSummary.expect_amount, rawSummary.total_amount].some(amount => amount !== undefined && amount !== null && amount !== '')) {
|
|
5993
|
+
// Keep the remote baseline intact; only normalize the active priced order.
|
|
5994
|
+
const previousSummary = this.store.summary;
|
|
5995
|
+
const summary = this.applyEffectiveDepositSummary(nextTempOrder, previousSummary);
|
|
5996
|
+
summary.amount_gap = this.calculateSummaryAmountGap({
|
|
5997
|
+
tempOrder: nextTempOrder,
|
|
5998
|
+
summary,
|
|
5999
|
+
orderPaidAmount: this.calculatePaidPaymentSummary(nextTempOrder.payments || []).gapPaidAmount
|
|
6000
|
+
});
|
|
6001
|
+
this.store.summary = summary;
|
|
6002
|
+
this.updateTempOrderPaymentStatus(nextTempOrder, {
|
|
6003
|
+
previousSummary,
|
|
6004
|
+
summary
|
|
6005
|
+
});
|
|
5937
6006
|
}
|
|
5938
6007
|
return nextTempOrder;
|
|
5939
6008
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloud saved orders with no payment rows report a zero gap, even while unpaid.
|
|
3
|
+
* Restore the OS payment target from the same snapshot, without repricing products.
|
|
4
|
+
* Voided rows are local payment history and are omitted from cloud checkout.
|
|
5
|
+
*/
|
|
6
|
+
export declare function normalizeUnpaidOrderAmountGap<T extends Record<string, any>>(order: T): T;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.normalizeUnpaidOrderAmountGap = normalizeUnpaidOrderAmountGap;
|
|
7
|
+
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
const UNPAID_STATUSES = new Set(['unpaid', 'payment_pending', 'payment_processing']);
|
|
10
|
+
const CANCELLED_STATUSES = new Set(['cancelled', 'canceled', 'voided']);
|
|
11
|
+
function firstValue(...values) {
|
|
12
|
+
return values.find(value => value != null && String(value).trim() !== '');
|
|
13
|
+
}
|
|
14
|
+
function money(value) {
|
|
15
|
+
if (typeof value !== 'string' && typeof value !== 'number') return undefined;
|
|
16
|
+
try {
|
|
17
|
+
const amount = new _decimal.default(value);
|
|
18
|
+
return amount.isFinite() ? amount : undefined;
|
|
19
|
+
} catch {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Cloud saved orders with no payment rows report a zero gap, even while unpaid.
|
|
26
|
+
* Restore the OS payment target from the same snapshot, without repricing products.
|
|
27
|
+
* Voided rows are local payment history and are omitted from cloud checkout.
|
|
28
|
+
*/
|
|
29
|
+
function normalizeUnpaidOrderAmountGap(order) {
|
|
30
|
+
const summary = order.summary && typeof order.summary === 'object' && !Array.isArray(order.summary) ? order.summary : {};
|
|
31
|
+
const status = String(firstValue(order.payment_status, summary.payment_status, order.original_payment_status) ?? '').trim().toLowerCase();
|
|
32
|
+
if (!UNPAID_STATUSES.has(status) || CANCELLED_STATUSES.has(String(order.status ?? '').trim().toLowerCase())) return order;
|
|
33
|
+
if (Array.isArray(order.refunds) && order.refunds.length > 0) return order;
|
|
34
|
+
|
|
35
|
+
// An omitted collection is a sparse patch, not proof that the order has no payments.
|
|
36
|
+
if (!Array.isArray(order.payments) || order.payments.some(payment => String(payment?.status ?? '').trim().toLowerCase() !== 'voided')) return order;
|
|
37
|
+
for (const field of ['order_paid_amount', 'customer_paid_amount', 'total_refund_amount', 'paid_amount', 'payment_amount']) {
|
|
38
|
+
const values = [summary[field], order[field]].filter(value => value != null && String(value).trim() !== '');
|
|
39
|
+
if (values.some(value => !money(value)?.isZero())) return order;
|
|
40
|
+
}
|
|
41
|
+
const gapValue = firstValue(summary.amount_gap, order.amount_gap);
|
|
42
|
+
if (gapValue !== undefined && !money(gapValue)?.isZero()) return order;
|
|
43
|
+
const expected = money(firstValue(summary.expect_amount, order.expect_amount, summary.total_amount, order.total_amount));
|
|
44
|
+
if (!expected?.gt(0)) return order;
|
|
45
|
+
let target = expected;
|
|
46
|
+
if (Number(order.is_deposit) === 1) {
|
|
47
|
+
const deposit = money(firstValue(summary.deposit_amount, order.deposit_amount, 0));
|
|
48
|
+
if (!deposit || deposit.lt(0) || deposit.gt(expected)) return order;
|
|
49
|
+
if (deposit.gt(0)) target = deposit;
|
|
50
|
+
}
|
|
51
|
+
const amountGap = target.toFixed(2);
|
|
52
|
+
return {
|
|
53
|
+
...order,
|
|
54
|
+
amount_gap: amountGap,
|
|
55
|
+
summary: {
|
|
56
|
+
...summary,
|
|
57
|
+
amount_gap: amountGap
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "duration" | "
|
|
52
|
+
getProductType(): "duration" | "session" | "normal";
|
|
53
53
|
}
|
|
@@ -1061,6 +1061,19 @@ function getDurationBusinessDate(projection, startAt) {
|
|
|
1061
1061
|
});
|
|
1062
1062
|
return period?.businessDate || startAt.slice(0, 10);
|
|
1063
1063
|
}
|
|
1064
|
+
function getRequestedProductRange(projection, product, request, runtimeOptions, fixedOffsetMinutes) {
|
|
1065
|
+
const range = request.requestedRangesByProductId?.[String(product.id)];
|
|
1066
|
+
if (!runtimeOptions.allowRequestedRanges || !range || product.kind !== 'duration' && product.kind !== 'session') return [];
|
|
1067
|
+
const start = toDateTime(range.startAt);
|
|
1068
|
+
const end = toDateTime(range.endAt);
|
|
1069
|
+
if (!Number.isFinite(start) || !Number.isFinite(end) || !Number.isInteger((end - start) / 60000) || end <= start) {
|
|
1070
|
+
throw availabilityError('INVALID_TARGET_FILTER', '手工预约范围必须包含有效起止时间和正整数分钟时长');
|
|
1071
|
+
}
|
|
1072
|
+
const candidate = createDurationTimeRangeWithEnd(product, start, end, projection, fixedOffsetMinutes);
|
|
1073
|
+
candidate.businessDate = getDurationBusinessDate(projection, candidate.startAt);
|
|
1074
|
+
assertRangesWithinProjection(projection, [candidate]);
|
|
1075
|
+
return [candidate];
|
|
1076
|
+
}
|
|
1064
1077
|
function getAlignedDurationRanges(params) {
|
|
1065
1078
|
const {
|
|
1066
1079
|
projection,
|
|
@@ -1221,6 +1234,16 @@ function getProductTimeRanges(projection, request = {}, runtimeOptions = {}) {
|
|
|
1221
1234
|
const resourceWindowIndex = buildResourceWindowIndex(projection, allowExcludedScheduleDateOverride);
|
|
1222
1235
|
const filteredProductIdSet = request.productIds?.length ? new Set(request.productIds.map(String)) : null;
|
|
1223
1236
|
return projection.products.filter(product => !filteredProductIdSet || filteredProductIdSet.has(String(product.id))).map(product => {
|
|
1237
|
+
const requestedRanges = getRequestedProductRange(projection, product, request, runtimeOptions, fixedOffsetMinutes);
|
|
1238
|
+
if (requestedRanges.length > 0) {
|
|
1239
|
+
return {
|
|
1240
|
+
productId: product.id,
|
|
1241
|
+
title: product.title,
|
|
1242
|
+
kind: product.kind,
|
|
1243
|
+
slotStepMinutes,
|
|
1244
|
+
ranges: dedupeProductRanges(requestedRanges)
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1224
1247
|
if (product.kind === 'normal') {
|
|
1225
1248
|
return {
|
|
1226
1249
|
productId: product.id,
|
|
@@ -263,6 +263,11 @@ export interface GetProductTimeRangesRequest {
|
|
|
263
263
|
partySize?: number;
|
|
264
264
|
durationMinutesByProductId?: Record<string, number>;
|
|
265
265
|
durationStartTimesByProductId?: Record<string, string[]>;
|
|
266
|
+
/** Explicit POS manual interval. Endpoints are absolute datetimes, not business-day HH:mm. */
|
|
267
|
+
requestedRangesByProductId?: Record<string, {
|
|
268
|
+
startAt: string;
|
|
269
|
+
endAt: string;
|
|
270
|
+
}>;
|
|
266
271
|
/** Restore only the exact remembered start; recompute the end from current product/windows. */
|
|
267
272
|
rememberedStartAtByProductId?: Record<string, string>;
|
|
268
273
|
/** Order-scoped v2 memory preserves the complete actual booking interval. */
|
|
@@ -300,6 +305,8 @@ export interface GetProductTimeRangesRuntimeOptions {
|
|
|
300
305
|
* disabled.
|
|
301
306
|
*/
|
|
302
307
|
allowSessionCustomRanges?: boolean;
|
|
308
|
+
/** Internal POS manual capability; automatic/remembered selections must leave this disabled. */
|
|
309
|
+
allowRequestedRanges?: boolean;
|
|
303
310
|
/**
|
|
304
311
|
* Internal POS capability: materialize candidates whose schedule date was
|
|
305
312
|
* explicitly excluded, while availability evaluation keeps them unavailable.
|