@pisell/pisellos 0.10.90 → 0.10.91
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/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/dist/model/strategy/adapter/itemRule/type.js +10 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
- package/dist/model/strategy/adapter/promotion/evaluator.js +103 -112
- 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 +21 -0
- package/dist/modules/BookingContext/utils/productExtend.js +132 -33
- package/dist/modules/BookingContext/utils/resources.js +1 -1
- package/dist/modules/Cart/index.js +4 -3
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/dist/modules/Cart/utils/cartProduct.js +59 -32
- 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/OpenData/salesSettings.js +1 -1
- package/dist/modules/OpenData/types.d.ts +9 -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 +22 -7
- package/dist/modules/Order/index.js +1565 -1161
- package/dist/modules/Order/localEftposState.d.ts +13 -0
- package/dist/modules/Order/localEftposState.js +39 -0
- package/dist/modules/Order/types.d.ts +33 -11
- package/dist/modules/Order/types.js +2 -2
- package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/dist/modules/Order/unpaidAmountGap.js +72 -0
- package/dist/modules/Order/utils.d.ts +4 -1
- package/dist/modules/Order/utils.js +75 -52
- package/dist/modules/Payment/walletpass.js +32 -6
- package/dist/modules/Product/types.d.ts +16 -0
- package/dist/modules/ProductList/index.js +1 -1
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
- package/dist/modules/ResourcePlanner/planner.js +383 -24
- package/dist/modules/ResourcePlanner/types.d.ts +42 -0
- package/dist/modules/Rules/index.js +86 -54
- 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 +9 -0
- package/dist/server/index.js +1928 -1462
- package/dist/server/modules/form/index.d.ts +19 -0
- package/dist/server/modules/form/index.js +205 -0
- package/dist/server/modules/form/types.d.ts +13 -0
- package/dist/server/modules/form/types.js +3 -0
- package/dist/server/modules/index.d.ts +3 -0
- package/dist/server/modules/index.js +4 -0
- package/dist/server/modules/order/index.d.ts +21 -0
- package/dist/server/modules/order/index.js +1399 -831
- package/dist/server/modules/order/types.d.ts +3 -0
- package/dist/server/modules/order/utils/filterOrders.js +20 -0
- package/dist/server/modules/products/index.d.ts +28 -7
- package/dist/server/modules/products/index.js +1295 -769
- package/dist/server/modules/products/replication.d.ts +8 -0
- package/dist/server/modules/products/replication.js +69 -0
- package/dist/server/modules/products/types.d.ts +12 -1
- package/dist/server/modules/products/types.js +4 -0
- 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 +1 -0
- package/dist/shared/receipt/small-ticket.js +58 -26
- package/dist/shared/receipt/templateVisibility.d.ts +3 -0
- package/dist/shared/receipt/templateVisibility.js +6 -2
- package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
- package/dist/solution/BaseSales/index.d.ts +22 -6
- package/dist/solution/BaseSales/index.js +1881 -1347
- package/dist/solution/BaseSales/pickupTiming.d.ts +4 -0
- package/dist/solution/BaseSales/pickupTiming.js +35 -8
- package/dist/solution/BaseSales/types.d.ts +4 -0
- package/dist/solution/BaseSales/types.js +1 -0
- package/dist/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
- package/dist/solution/BaseSales/utils/posDurationPricing.js +174 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -8
- package/dist/solution/BookingByStep/index.d.ts +18 -2
- package/dist/solution/BookingByStep/index.js +681 -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 +6 -0
- package/dist/solution/BookingTicket/index.js +666 -593
- package/dist/solution/BookingTicket/types.d.ts +1 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +35 -8
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +3 -3
- 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/applyGlobalScan.js +58 -94
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +33 -62
- package/dist/solution/OrderInvoicePreview/index.js +4 -3
- package/dist/solution/Sales/index.js +1 -1
- package/dist/solution/ScanOrder/index.d.ts +2 -0
- package/dist/solution/ScanOrder/index.js +230 -97
- package/dist/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/dist/solution/ScanOrder/menuAvailability.js +363 -0
- package/dist/solution/ScanOrder/types.d.ts +3 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +42 -10
- package/dist/solution/UnifiedBookingSales/index.js +2493 -1496
- package/dist/solution/UnifiedBookingSales/salesSettings.js +1 -1
- package/dist/solution/UnifiedBookingSales/types.d.ts +20 -5
- package/dist/utils/pos-receipt-auto-print.d.ts +4 -0
- package/dist/utils/pos-receipt-auto-print.js +14 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/lib/model/strategy/adapter/itemRule/type.js +10 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
- package/lib/model/strategy/adapter/promotion/evaluator.js +22 -21
- 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 +21 -0
- package/lib/modules/BookingContext/utils/productExtend.js +104 -5
- package/lib/modules/BookingContext/utils/resources.js +1 -1
- package/lib/modules/Cart/index.js +4 -2
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/lib/modules/Cart/utils/cartProduct.js +39 -20
- 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/OpenData/salesSettings.js +1 -1
- package/lib/modules/OpenData/types.d.ts +9 -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 +22 -7
- package/lib/modules/Order/index.js +457 -174
- package/lib/modules/Order/localEftposState.d.ts +13 -0
- package/lib/modules/Order/localEftposState.js +44 -0
- package/lib/modules/Order/types.d.ts +33 -11
- package/lib/modules/Order/types.js +2 -2
- package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/lib/modules/Order/unpaidAmountGap.js +60 -0
- package/lib/modules/Order/utils.d.ts +4 -1
- package/lib/modules/Order/utils.js +29 -3
- package/lib/modules/Payment/walletpass.js +23 -1
- package/lib/modules/Product/types.d.ts +16 -0
- package/lib/modules/ProductList/index.js +1 -1
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
- package/lib/modules/ResourcePlanner/planner.js +299 -9
- package/lib/modules/ResourcePlanner/types.d.ts +42 -0
- package/lib/modules/Rules/index.js +32 -3
- 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 +9 -0
- package/lib/server/index.js +279 -30
- package/lib/server/modules/form/index.d.ts +19 -0
- package/lib/server/modules/form/index.js +73 -0
- package/lib/server/modules/form/types.d.ts +13 -0
- package/lib/server/modules/form/types.js +9 -0
- package/lib/server/modules/index.d.ts +3 -0
- package/lib/server/modules/index.js +15 -1
- package/lib/server/modules/order/index.d.ts +21 -0
- package/lib/server/modules/order/index.js +344 -35
- package/lib/server/modules/order/types.d.ts +3 -0
- package/lib/server/modules/order/utils/filterOrders.js +18 -0
- package/lib/server/modules/products/index.d.ts +28 -7
- package/lib/server/modules/products/index.js +224 -62
- package/lib/server/modules/products/replication.d.ts +8 -0
- package/lib/server/modules/products/replication.js +30 -0
- package/lib/server/modules/products/types.d.ts +12 -1
- package/lib/server/modules/products/types.js +3 -0
- 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 +1 -0
- package/lib/shared/receipt/small-ticket.js +53 -25
- package/lib/shared/receipt/templateVisibility.d.ts +3 -0
- package/lib/shared/receipt/templateVisibility.js +6 -2
- package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
- package/lib/solution/BaseSales/index.d.ts +22 -6
- package/lib/solution/BaseSales/index.js +347 -59
- package/lib/solution/BaseSales/pickupTiming.d.ts +4 -0
- package/lib/solution/BaseSales/pickupTiming.js +24 -3
- package/lib/solution/BaseSales/types.d.ts +4 -0
- package/lib/solution/BaseSales/types.js +1 -0
- package/lib/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
- package/lib/solution/BaseSales/utils/posDurationPricing.js +133 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
- package/lib/solution/BookingByStep/index.d.ts +18 -2
- package/lib/solution/BookingByStep/index.js +229 -17
- 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 +6 -0
- package/lib/solution/BookingTicket/index.js +40 -5
- package/lib/solution/BookingTicket/types.d.ts +1 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +34 -4
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +3 -3
- 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/applyGlobalScan.js +2 -14
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +17 -34
- package/lib/solution/OrderInvoicePreview/index.js +1 -0
- package/lib/solution/Sales/index.js +1 -1
- package/lib/solution/ScanOrder/index.d.ts +2 -0
- package/lib/solution/ScanOrder/index.js +131 -22
- package/lib/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/lib/solution/ScanOrder/menuAvailability.js +203 -0
- package/lib/solution/ScanOrder/types.d.ts +3 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +42 -10
- package/lib/solution/UnifiedBookingSales/index.js +717 -144
- package/lib/solution/UnifiedBookingSales/salesSettings.js +1 -1
- package/lib/solution/UnifiedBookingSales/types.d.ts +20 -5
- 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
|
@@ -33,14 +33,90 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
33
33
|
shopStore;
|
|
34
34
|
store;
|
|
35
35
|
otherParams = {};
|
|
36
|
+
scheduleRuntimeParams = {};
|
|
36
37
|
cacheId;
|
|
37
38
|
otherData = {}; // 提供给 UI 层的临时数据存储,会进缓存
|
|
38
39
|
platform; // 平台类型,用于判断是 PC / H5
|
|
40
|
+
productDetailGeneration = 0;
|
|
41
|
+
sessionAvailabilityRequestVersion = 0;
|
|
42
|
+
lifecycleGeneration = 0;
|
|
43
|
+
disposed = false;
|
|
44
|
+
resourcePreparation;
|
|
45
|
+
staleSelection() {
|
|
46
|
+
return Object.assign(new Error('Booking selection changed'), {
|
|
47
|
+
name: 'AbortError'
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
resourceSelectionKey() {
|
|
51
|
+
const items = this.store.cart.getItems();
|
|
52
|
+
const sessionDates = items.filter(item => (0, _products.isSessionProduct)(item._productOrigin)).flatMap(item => [item.start_date, item.end_date]).filter(Boolean);
|
|
53
|
+
return JSON.stringify({
|
|
54
|
+
lifecycle: this.lifecycleGeneration,
|
|
55
|
+
dates: sessionDates.length ? [...new Set(sessionDates)].sort() : (this.store.date.getDateRange() || []).map(date => date.date).sort(),
|
|
56
|
+
cart: items.map(item => ({
|
|
57
|
+
id: item._id,
|
|
58
|
+
num: item.num,
|
|
59
|
+
holder: item.holder_id,
|
|
60
|
+
start: [item.start_date, item.start_time],
|
|
61
|
+
end: [item.end_date, item.end_time],
|
|
62
|
+
resources: item._origin?.resources,
|
|
63
|
+
capacity: (0, _capacity.getCapacityInfoByCartItem)(item).currentCapacity,
|
|
64
|
+
product: {
|
|
65
|
+
id: item._productOrigin?.id,
|
|
66
|
+
schedules: item._productOrigin?.['schedule.ids'],
|
|
67
|
+
resources: item._productOrigin?.product_resource?.resources?.map(resource => ({
|
|
68
|
+
id: resource.id,
|
|
69
|
+
resource_type_id: resource.resource_type_id,
|
|
70
|
+
status: resource.status,
|
|
71
|
+
code: resource.code,
|
|
72
|
+
type: resource.type,
|
|
73
|
+
default_resource: resource.default_resource || [],
|
|
74
|
+
// Resource rendering removes required IDs from the optional list in place.
|
|
75
|
+
// Compare the same effective inputs before and after that normalization.
|
|
76
|
+
optional_resource: (resource.optional_resource || []).filter(id => !(resource.default_resource || []).includes(id)),
|
|
77
|
+
select_type: resource.select_type && {
|
|
78
|
+
type: resource.select_type.type,
|
|
79
|
+
min: resource.select_type.min,
|
|
80
|
+
max: resource.select_type.max
|
|
81
|
+
}
|
|
82
|
+
})),
|
|
83
|
+
duration: item._productOrigin?.duration,
|
|
84
|
+
cutoff: item._productOrigin?.cut_off_time
|
|
85
|
+
},
|
|
86
|
+
bundle: item._bundleOrigin,
|
|
87
|
+
options: item._optionsOrigin
|
|
88
|
+
}))
|
|
89
|
+
});
|
|
90
|
+
}
|
|
39
91
|
|
|
92
|
+
/** Semantic selection token for async UI transitions. */
|
|
93
|
+
getBookingSelectionKey() {
|
|
94
|
+
return this.resourceSelectionKey();
|
|
95
|
+
}
|
|
96
|
+
refreshCurrentProductSchedule() {
|
|
97
|
+
const product = this.store.currentProduct;
|
|
98
|
+
if (!product?.['schedule.ids'] || !this.store.schedule.isScheduleListLoaded()) return;
|
|
99
|
+
const version = this.store.schedule.getScheduleCatalogVersion();
|
|
100
|
+
const meta = this.store.currentProductMeta || {};
|
|
101
|
+
if (meta.scheduleCatalogVersion !== version) {
|
|
102
|
+
this.store.currentProductMeta = {
|
|
103
|
+
...meta,
|
|
104
|
+
schedule: this.getScheduleDataByIds(product['schedule.ids']),
|
|
105
|
+
scheduleCatalogVersion: version,
|
|
106
|
+
timeSlotBySchedule: undefined
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
40
110
|
async initialize(core, options) {
|
|
111
|
+
this.disposed = false;
|
|
112
|
+
this.lifecycleGeneration += 1;
|
|
113
|
+
this.productDetailGeneration += 1;
|
|
41
114
|
this.core = core;
|
|
42
115
|
this.store = options.store || {};
|
|
43
116
|
this.otherParams = options.otherParams || {};
|
|
117
|
+
this.scheduleRuntimeParams = {
|
|
118
|
+
...this.otherParams
|
|
119
|
+
};
|
|
44
120
|
// 获取依赖的插件
|
|
45
121
|
this.request = core.getPlugin('request');
|
|
46
122
|
this.window = core.getPlugin('window');
|
|
@@ -78,14 +154,20 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
78
154
|
...this.otherParams,
|
|
79
155
|
fatherModule: this.name,
|
|
80
156
|
openCache: this.otherParams?.cacheId ? true : false,
|
|
81
|
-
cacheId: this.otherParams?.cacheId
|
|
157
|
+
cacheId: this.otherParams?.cacheId,
|
|
158
|
+
...(step === 'schedule' ? {
|
|
159
|
+
scheduleCatalogCache: 'memory',
|
|
160
|
+
bookingRead: true
|
|
161
|
+
} : {})
|
|
82
162
|
}
|
|
83
163
|
});
|
|
84
164
|
} else {
|
|
85
165
|
throw new Error(`模块 ${step} 不存在`);
|
|
86
166
|
}
|
|
87
167
|
});
|
|
88
|
-
this.store.schedule.
|
|
168
|
+
this.store.schedule.ensureScheduleReady().catch(error => {
|
|
169
|
+
if (error?.name !== 'AbortError') console.error('[BookingByStep] Schedule preload failed', error);
|
|
170
|
+
});
|
|
89
171
|
this.core.effects.emit(`${this.name}:onInited`, {});
|
|
90
172
|
}
|
|
91
173
|
// 初始化step
|
|
@@ -174,6 +256,8 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
174
256
|
startDate: schedule_date || (0, _dayjs.default)().format('YYYY-MM-DD'),
|
|
175
257
|
endDate: schedule_date || (0, _dayjs.default)().format('YYYY-MM-DD'),
|
|
176
258
|
products: [...res]
|
|
259
|
+
}).catch(error => {
|
|
260
|
+
if (error?.name !== 'AbortError') console.error('[BookingByStep] Resource preload failed', error);
|
|
177
261
|
});
|
|
178
262
|
return res;
|
|
179
263
|
}
|
|
@@ -283,13 +367,15 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
283
367
|
startDate,
|
|
284
368
|
endDate,
|
|
285
369
|
custom_page_id,
|
|
286
|
-
channel
|
|
370
|
+
channel,
|
|
371
|
+
assertCurrent
|
|
287
372
|
}) {
|
|
288
373
|
return await this.store.schedule.loadScheduleAvailableDate({
|
|
289
374
|
startDate,
|
|
290
375
|
endDate,
|
|
291
376
|
custom_page_id,
|
|
292
|
-
channel
|
|
377
|
+
channel,
|
|
378
|
+
assertCurrent
|
|
293
379
|
});
|
|
294
380
|
}
|
|
295
381
|
|
|
@@ -431,6 +517,24 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
431
517
|
startDate = (0, _dayjs.default)().format('YYYY-MM-DD');
|
|
432
518
|
}
|
|
433
519
|
let tempProducts = products || this.store.cart.getItems().map(p => p._productOrigin);
|
|
520
|
+
const generation = this.productDetailGeneration;
|
|
521
|
+
const lifecycle = this.lifecycleGeneration;
|
|
522
|
+
const selectionKey = products ? undefined : this.resourceSelectionKey();
|
|
523
|
+
const assertCurrent = () => {
|
|
524
|
+
if (this.disposed || lifecycle !== this.lifecycleGeneration || (!products || !params.assertCurrent) && generation !== this.productDetailGeneration || selectionKey !== undefined && selectionKey !== this.resourceSelectionKey()) throw this.staleSelection();
|
|
525
|
+
params.assertCurrent?.();
|
|
526
|
+
};
|
|
527
|
+
const requiresSchedule = tempProducts.some(product => product?.['schedule.ids']?.length) || !products && !!this.store.currentProduct?.['schedule.ids']?.length;
|
|
528
|
+
if (requiresSchedule) {
|
|
529
|
+
try {
|
|
530
|
+
await this.store.schedule.ensureScheduleReady();
|
|
531
|
+
} catch (error) {
|
|
532
|
+
assertCurrent();
|
|
533
|
+
throw error;
|
|
534
|
+
}
|
|
535
|
+
assertCurrent();
|
|
536
|
+
this.refreshCurrentProductSchedule();
|
|
537
|
+
}
|
|
434
538
|
if (tempProducts.length) {
|
|
435
539
|
tempProducts.forEach(p => {
|
|
436
540
|
if (p?.['schedule.ids']) {
|
|
@@ -440,7 +544,7 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
440
544
|
});
|
|
441
545
|
}
|
|
442
546
|
// 如果当前打开了某个的商品详情弹窗,则应该默认用这个商品
|
|
443
|
-
if (this.store.currentProduct) {
|
|
547
|
+
if (!products && this.store.currentProduct) {
|
|
444
548
|
tempProducts = [{
|
|
445
549
|
...this.store.currentProduct,
|
|
446
550
|
_schedule: this.store.currentProductMeta?.['schedule']
|
|
@@ -460,6 +564,7 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
460
564
|
resourcesMap
|
|
461
565
|
} = (0, _products.getAvailableProductResources)(tempProducts) || {};
|
|
462
566
|
this.otherParams.currentResourcesMap = resourcesMap;
|
|
567
|
+
const catalogVersion = this.store.schedule.getScheduleCatalogVersion();
|
|
463
568
|
const res = await this.store.date.getResourceDates({
|
|
464
569
|
url: params.url,
|
|
465
570
|
query: {
|
|
@@ -469,11 +574,56 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
469
574
|
},
|
|
470
575
|
rules,
|
|
471
576
|
type,
|
|
472
|
-
useCache
|
|
577
|
+
useCache,
|
|
578
|
+
bookingRead: true,
|
|
579
|
+
errorMode: 'throw',
|
|
580
|
+
assertCurrent: () => {
|
|
581
|
+
assertCurrent();
|
|
582
|
+
if (requiresSchedule && catalogVersion !== this.store.schedule.getScheduleCatalogVersion()) throw this.staleSelection();
|
|
583
|
+
}
|
|
473
584
|
});
|
|
474
585
|
return res;
|
|
475
586
|
}
|
|
476
587
|
|
|
588
|
+
/** Prepare the exact cart/date selection before synchronous resource checks. */
|
|
589
|
+
prepareResourcesForCurrentSelection() {
|
|
590
|
+
const key = this.resourceSelectionKey();
|
|
591
|
+
if (this.resourcePreparation?.key === key) return this.resourcePreparation.promise;
|
|
592
|
+
const selected = (0, _lodashEs.cloneDeep)(this.store.date.getDateRange() || []);
|
|
593
|
+
const cart = this.store.cart.getItems().filter(item => !(0, _utils5.isNormalProduct)(item._productOrigin));
|
|
594
|
+
const sessionDates = cart.filter(item => (0, _products.isSessionProduct)(item._productOrigin)).flatMap(item => [item.start_date, item.end_date]).filter(Boolean);
|
|
595
|
+
const selectedDates = sessionDates.length ? [...new Set(sessionDates)].sort() : selected.map(date => date.date).sort();
|
|
596
|
+
const dates = selectedDates;
|
|
597
|
+
if (!cart.length || !dates.length) return Promise.resolve();
|
|
598
|
+
const assertCurrent = () => {
|
|
599
|
+
if (this.disposed || key !== this.resourceSelectionKey()) throw this.staleSelection();
|
|
600
|
+
};
|
|
601
|
+
const promise = (async () => {
|
|
602
|
+
const available = await this.getAvailableDate({
|
|
603
|
+
startDate: dates[0],
|
|
604
|
+
endDate: dates[dates.length - 1],
|
|
605
|
+
products: cart.map(item => item._productOrigin),
|
|
606
|
+
assertCurrent
|
|
607
|
+
});
|
|
608
|
+
assertCurrent();
|
|
609
|
+
this.store.date.setDateRange(selectedDates.map(date => available.find(item => item.date === date) || {
|
|
610
|
+
date,
|
|
611
|
+
week: (0, _dayjs.default)(date).format('ddd'),
|
|
612
|
+
weekNum: (0, _dayjs.default)(date).day(),
|
|
613
|
+
status: 'unavailable',
|
|
614
|
+
resource: []
|
|
615
|
+
}));
|
|
616
|
+
})();
|
|
617
|
+
this.resourcePreparation = {
|
|
618
|
+
key,
|
|
619
|
+
promise
|
|
620
|
+
};
|
|
621
|
+
void promise.finally(() => {
|
|
622
|
+
if (this.resourcePreparation?.promise === promise) this.resourcePreparation = undefined;
|
|
623
|
+
}).catch(() => {});
|
|
624
|
+
return promise;
|
|
625
|
+
}
|
|
626
|
+
|
|
477
627
|
/**
|
|
478
628
|
* 获取购物车汇总信息
|
|
479
629
|
*/
|
|
@@ -610,6 +760,10 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
610
760
|
async setOtherParams(params, {
|
|
611
761
|
cover = false
|
|
612
762
|
} = {}) {
|
|
763
|
+
this.scheduleRuntimeParams = {
|
|
764
|
+
...this.scheduleRuntimeParams,
|
|
765
|
+
...params
|
|
766
|
+
};
|
|
613
767
|
if (cover) {
|
|
614
768
|
this.otherParams = params;
|
|
615
769
|
} else {
|
|
@@ -618,6 +772,13 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
618
772
|
...params
|
|
619
773
|
};
|
|
620
774
|
}
|
|
775
|
+
this.store.schedule?.updateOtherParams({
|
|
776
|
+
...this.scheduleRuntimeParams,
|
|
777
|
+
fatherModule: this.name,
|
|
778
|
+
openCache: !!this.scheduleRuntimeParams.cacheId,
|
|
779
|
+
scheduleCatalogCache: 'memory',
|
|
780
|
+
bookingRead: true
|
|
781
|
+
});
|
|
621
782
|
}
|
|
622
783
|
async getOtherParams() {
|
|
623
784
|
return this.otherParams;
|
|
@@ -636,7 +797,8 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
636
797
|
// 直接调用 addProductToCart,不传递 date 参数以避免日期检查逻辑
|
|
637
798
|
return this.addProductToCart({
|
|
638
799
|
product: productData,
|
|
639
|
-
account: activeAccount
|
|
800
|
+
account: activeAccount,
|
|
801
|
+
isLegacyOrder: true
|
|
640
802
|
});
|
|
641
803
|
}
|
|
642
804
|
|
|
@@ -647,6 +809,7 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
647
809
|
* product: ProductData;
|
|
648
810
|
* date?: { startTime: string; endTime: string } | null;
|
|
649
811
|
* account?: Account | null;
|
|
812
|
+
* isLegacyOrder?: boolean;
|
|
650
813
|
* })} {
|
|
651
814
|
* product,
|
|
652
815
|
* date,
|
|
@@ -658,7 +821,8 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
658
821
|
addProductToCart({
|
|
659
822
|
product,
|
|
660
823
|
date,
|
|
661
|
-
account
|
|
824
|
+
account,
|
|
825
|
+
isLegacyOrder = false
|
|
662
826
|
}) {
|
|
663
827
|
const {
|
|
664
828
|
bundle,
|
|
@@ -725,7 +889,8 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
725
889
|
product: productData,
|
|
726
890
|
bundle,
|
|
727
891
|
options,
|
|
728
|
-
quantity
|
|
892
|
+
quantity,
|
|
893
|
+
isLegacyOrder
|
|
729
894
|
};
|
|
730
895
|
if (date) {
|
|
731
896
|
addItemParams.date = date;
|
|
@@ -944,6 +1109,11 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
944
1109
|
return errorCartItemIds;
|
|
945
1110
|
}
|
|
946
1111
|
destroy() {
|
|
1112
|
+
this.disposed = true;
|
|
1113
|
+
this.lifecycleGeneration += 1;
|
|
1114
|
+
this.productDetailGeneration += 1;
|
|
1115
|
+
this.resourcePreparation = undefined;
|
|
1116
|
+
this.store.schedule?.destroy();
|
|
947
1117
|
this.store.cart?.destroy();
|
|
948
1118
|
this.store.step?.destroy();
|
|
949
1119
|
this.store.products?.destroy();
|
|
@@ -1951,7 +2121,17 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1951
2121
|
}
|
|
1952
2122
|
// 打开某个商品详情的弹窗,OS 层这边会记录当前选中的商品,适用于 session 类商品预约
|
|
1953
2123
|
async openProductDetail(productId) {
|
|
1954
|
-
const
|
|
2124
|
+
const generation = ++this.productDetailGeneration;
|
|
2125
|
+
let targetProductData;
|
|
2126
|
+
try {
|
|
2127
|
+
targetProductData = await this.store.products.getProduct(productId);
|
|
2128
|
+
if (targetProductData?.['schedule.ids']?.length) await this.store.schedule.ensureScheduleReady();
|
|
2129
|
+
} catch (error) {
|
|
2130
|
+
if (this.disposed || generation !== this.productDetailGeneration) throw this.staleSelection();
|
|
2131
|
+
throw error;
|
|
2132
|
+
}
|
|
2133
|
+
if (this.disposed || generation !== this.productDetailGeneration) throw this.staleSelection();
|
|
2134
|
+
if (!targetProductData) throw new Error('Booking product is unavailable');
|
|
1955
2135
|
if (targetProductData) {
|
|
1956
2136
|
this.store.currentProduct = targetProductData;
|
|
1957
2137
|
this.store.currentProductMeta = {};
|
|
@@ -1960,6 +2140,7 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1960
2140
|
const newScheduleArr = this.getScheduleDataByIds(targetProductData['schedule.ids']);
|
|
1961
2141
|
if (!this.store.currentProductMeta) this.store.currentProductMeta = {};
|
|
1962
2142
|
this.store.currentProductMeta.schedule = newScheduleArr;
|
|
2143
|
+
this.store.currentProductMeta.scheduleCatalogVersion = this.store.schedule.getScheduleCatalogVersion();
|
|
1963
2144
|
} else if (targetProductData.duration) {
|
|
1964
2145
|
const dateRange = this.store.date.getDateRange();
|
|
1965
2146
|
// 如果不是先选日期的流程 duration 商品就啥也不做
|
|
@@ -1975,14 +2156,15 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1975
2156
|
startDate: dateRange[0].date,
|
|
1976
2157
|
endDate: dateRange[dateRange.length - 1].date,
|
|
1977
2158
|
products: [targetProductData]
|
|
2159
|
+
}).catch(error => {
|
|
2160
|
+
if (error?.name !== 'AbortError') console.error('[BookingByStep] Product resource preload failed', error);
|
|
1978
2161
|
});
|
|
1979
2162
|
}
|
|
1980
2163
|
}
|
|
1981
2164
|
}
|
|
1982
2165
|
closeProductDetail() {
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
}
|
|
2166
|
+
this.productDetailGeneration += 1;
|
|
2167
|
+
this.store.currentProductMeta = {};
|
|
1986
2168
|
this.store.currentProduct = undefined;
|
|
1987
2169
|
}
|
|
1988
2170
|
|
|
@@ -2218,11 +2400,19 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
2218
2400
|
start_at: (0, _dayjs.default)(item.start),
|
|
2219
2401
|
end_at: (0, _dayjs.default)(item.end)
|
|
2220
2402
|
})) {
|
|
2221
|
-
mSet.set(m.id,
|
|
2403
|
+
mSet.set(m.id, {
|
|
2404
|
+
...m,
|
|
2405
|
+
pax: m.pax ?? 1
|
|
2406
|
+
});
|
|
2222
2407
|
}
|
|
2223
2408
|
});
|
|
2224
2409
|
});
|
|
2225
|
-
|
|
2410
|
+
const peakUsedCapacity = (0, _resources.getPeakConcurrentPax)(Array.from(mSet.values()), {
|
|
2411
|
+
start_at: (0, _dayjs.default)(item.start),
|
|
2412
|
+
end_at: (0, _dayjs.default)(item.end)
|
|
2413
|
+
});
|
|
2414
|
+
// 单个资源的超额占用不能扣减其他资源的可用容量。
|
|
2415
|
+
acc += Math.min(curr.capacity, peakUsedCapacity);
|
|
2226
2416
|
return acc;
|
|
2227
2417
|
}, 0);
|
|
2228
2418
|
// 如果已使用容量超过了当前类型资源的容量,则不可用
|
|
@@ -3124,6 +3314,20 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
3124
3314
|
return results;
|
|
3125
3315
|
}
|
|
3126
3316
|
async getAvailableDateForSessionOptimize(params = {}) {
|
|
3317
|
+
const requestVersion = ++this.sessionAvailabilityRequestVersion;
|
|
3318
|
+
const generation = this.productDetailGeneration;
|
|
3319
|
+
try {
|
|
3320
|
+
await this.store.schedule.ensureScheduleReady();
|
|
3321
|
+
} catch (error) {
|
|
3322
|
+
if (this.disposed || generation !== this.productDetailGeneration || requestVersion !== this.sessionAvailabilityRequestVersion) throw this.staleSelection();
|
|
3323
|
+
throw error;
|
|
3324
|
+
}
|
|
3325
|
+
if (this.disposed || generation !== this.productDetailGeneration || requestVersion !== this.sessionAvailabilityRequestVersion || !this.store.currentProduct) throw this.staleSelection();
|
|
3326
|
+
this.refreshCurrentProductSchedule();
|
|
3327
|
+
const catalogVersion = this.store.schedule.getScheduleCatalogVersion();
|
|
3328
|
+
const assertCurrent = () => {
|
|
3329
|
+
if (this.disposed || generation !== this.productDetailGeneration || requestVersion !== this.sessionAvailabilityRequestVersion || catalogVersion !== this.store.schedule.getScheduleCatalogVersion()) throw this.staleSelection();
|
|
3330
|
+
};
|
|
3127
3331
|
// 开始日期如果小于今天,直接以今天当做开始日期
|
|
3128
3332
|
let {
|
|
3129
3333
|
startDate,
|
|
@@ -3154,7 +3358,8 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
3154
3358
|
if (cache) {
|
|
3155
3359
|
// 开始日期大于等于缓存的开始日期,且结束日期小于等于缓存的结束日期,则直接返回缓存结果
|
|
3156
3360
|
if ((0, _dayjs.default)(params.startDate).isSameOrAfter((0, _dayjs.default)(cache.startDate), 'day') && (0, _dayjs.default)(params.endDate).isSameOrBefore((0, _dayjs.default)(cache.endDate), 'day')) {
|
|
3157
|
-
|
|
3361
|
+
assertCurrent();
|
|
3362
|
+
this.store.date.setDateList(cache.dateList, true);
|
|
3158
3363
|
return {
|
|
3159
3364
|
dateList: cache.dateList,
|
|
3160
3365
|
firstAvailableDate: cache.firstAvailableDate
|
|
@@ -3169,12 +3374,18 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
3169
3374
|
// 1.后端返回的数据,确定资源在每一天的可用和使用情况
|
|
3170
3375
|
const tempResourceIds = (0, _capacity.getResourcesIdsByProduct)(tempProducts);
|
|
3171
3376
|
const res = await this.store.date.fetchResourceDates({
|
|
3377
|
+
errorMode: 'throw',
|
|
3378
|
+
bookingRead: true,
|
|
3172
3379
|
query: {
|
|
3173
3380
|
start_date: startDate || '',
|
|
3174
3381
|
end_date: endDate || '',
|
|
3175
3382
|
resource_ids: tempResourceIds
|
|
3176
3383
|
}
|
|
3384
|
+
}).catch(error => {
|
|
3385
|
+
assertCurrent();
|
|
3386
|
+
throw error;
|
|
3177
3387
|
});
|
|
3388
|
+
assertCurrent();
|
|
3178
3389
|
// 2. 商品 schedule 数据,确定日程在每一天的时间片
|
|
3179
3390
|
// 3. 把后端返回的和 schedule 的数据进行合并,确定每一天的可用和使用情况
|
|
3180
3391
|
let dates = [];
|
|
@@ -3354,7 +3565,8 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
3354
3565
|
}
|
|
3355
3566
|
// 最终把资源数据也加到日期内
|
|
3356
3567
|
dates = (0, _utils4.handleAvailableDateByResource)(res.data, dates);
|
|
3357
|
-
|
|
3568
|
+
assertCurrent();
|
|
3569
|
+
this.store.date.setDateList(dates, true);
|
|
3358
3570
|
|
|
3359
3571
|
// 缓存这次结果,以防后面他小幅度范围内去修改天数
|
|
3360
3572
|
if (!this.store.currentProductMeta) this.store.currentProductMeta = {};
|
|
@@ -7,6 +7,11 @@ import { CartItem, ProductData } from '../../../modules';
|
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
type DateType = Dayjs;
|
|
10
|
+
interface EventItem {
|
|
11
|
+
pax: number;
|
|
12
|
+
start_at: DateType;
|
|
13
|
+
end_at: DateType;
|
|
14
|
+
}
|
|
10
15
|
export interface TimeSliceItem {
|
|
11
16
|
start_time: string;
|
|
12
17
|
end_time: string;
|
|
@@ -20,6 +25,11 @@ export interface ResourceItem {
|
|
|
20
25
|
interface BookingItem {
|
|
21
26
|
[key: string]: any;
|
|
22
27
|
}
|
|
28
|
+
/** 计算目标区间内的最大同时占用人数;事件去重由调用方负责。 */
|
|
29
|
+
export declare const getPeakConcurrentPax: (eventList: EventItem[], timeSlice: {
|
|
30
|
+
start_at: DateType;
|
|
31
|
+
end_at: DateType;
|
|
32
|
+
}) => number;
|
|
23
33
|
/**
|
|
24
34
|
* @title: 判断两个时间段是否有重叠
|
|
25
35
|
* @description:
|
|
@@ -7,7 +7,7 @@ exports.checkSessionProductLeadTime = checkSessionProductLeadTime;
|
|
|
7
7
|
exports.checkTwoResourcesIntersection = checkTwoResourcesIntersection;
|
|
8
8
|
exports.filterResourcesByFormItem = filterResourcesByFormItem;
|
|
9
9
|
exports.filterScheduleByDateRange = filterScheduleByDateRange;
|
|
10
|
-
exports.getResourcesByProduct = exports.getResourcesByIds = exports.getOthersSelectedResources = exports.getOthersCartSelectedResources = exports.getIsUsableByTimeItem = exports.formatResources = void 0;
|
|
10
|
+
exports.getResourcesByProduct = exports.getResourcesByIds = exports.getPeakConcurrentPax = exports.getOthersSelectedResources = exports.getOthersCartSelectedResources = exports.getIsUsableByTimeItem = exports.formatResources = void 0;
|
|
11
11
|
exports.getResourcesIdsByProduct = getResourcesIdsByProduct;
|
|
12
12
|
exports.mergeSubResourcesTimeSlices = exports.isConflict = exports.getTimesIntersection = exports.getTimeSlicesByResources = exports.getTimeSlicesByResource = void 0;
|
|
13
13
|
exports.sortCombinedResources = sortCombinedResources;
|
|
@@ -20,18 +20,27 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
/** 计算目标区间内的最大同时占用人数;事件去重由调用方负责。 */
|
|
24
|
+
const getPeakConcurrentPax = (eventList, timeSlice) => {
|
|
25
|
+
const start = (0, _dayjs.default)(timeSlice.start_at).valueOf();
|
|
26
|
+
const end = (0, _dayjs.default)(timeSlice.end_at).valueOf();
|
|
27
|
+
const changes = new Map();
|
|
28
|
+
for (const event of eventList || []) {
|
|
29
|
+
const eventStart = Math.max(start, (0, _dayjs.default)(event.start_at).valueOf());
|
|
30
|
+
const eventEnd = Math.min(end, (0, _dayjs.default)(event.end_at).valueOf());
|
|
31
|
+
if (!(eventStart < eventEnd)) continue;
|
|
32
|
+
const pax = Number(event.pax);
|
|
33
|
+
changes.set(eventStart, (changes.get(eventStart) ?? 0) + pax);
|
|
34
|
+
changes.set(eventEnd, (changes.get(eventEnd) ?? 0) - pax);
|
|
35
|
+
}
|
|
36
|
+
let current = 0;
|
|
37
|
+
let peak = 0;
|
|
38
|
+
// 同一时刻合并增减量,保持 [start, end) 语义,首尾相接不叠加。
|
|
39
|
+
for (const [, change] of [...changes].sort(([a], [b]) => a - b)) {
|
|
40
|
+
current += change;
|
|
41
|
+
peak = Math.max(peak, current);
|
|
42
|
+
}
|
|
43
|
+
return peak;
|
|
35
44
|
};
|
|
36
45
|
|
|
37
46
|
/**
|
|
@@ -42,6 +51,7 @@ const getUseableEventCount = (eventList, current) => {
|
|
|
42
51
|
* @return {*}
|
|
43
52
|
* @Author: zhiwei.Wang
|
|
44
53
|
*/
|
|
54
|
+
exports.getPeakConcurrentPax = getPeakConcurrentPax;
|
|
45
55
|
const isConflict = (event, current) => {
|
|
46
56
|
const eventStart = (0, _dayjs.default)(event.start_at);
|
|
47
57
|
const eventEnd = (0, _dayjs.default)(event.end_at);
|
|
@@ -132,8 +142,8 @@ const checkCapacity = ({
|
|
|
132
142
|
});
|
|
133
143
|
});
|
|
134
144
|
|
|
135
|
-
//
|
|
136
|
-
|
|
145
|
+
// 多人预约按同时占用峰值扣减,不能把先后到访的所有人数相加。
|
|
146
|
+
const conflictCount = resource.resourceType === 'single' ? conflict.reduce((remaining, event) => remaining - event.pax, resource.capacity || 0) : (resource.capacity || 0) - getPeakConcurrentPax(conflict, timeSlice);
|
|
137
147
|
|
|
138
148
|
// 同一时间段内只能进行一个预约,无论容量是否已满。
|
|
139
149
|
if (resource.resourceType === 'single') {
|
|
@@ -43,6 +43,10 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
43
43
|
*/
|
|
44
44
|
protected getRegisteredModuleNames(): readonly string[];
|
|
45
45
|
protected getSubmitOrderSalesChannel(): string;
|
|
46
|
+
/** 供销售展示层按 booking.resources[].form_id 读取当前多语言表单标题。 */
|
|
47
|
+
getFormTitleMap(): Record<string, Record<string, string> | string>;
|
|
48
|
+
/** 表单定义由 Ably 更新后通知展示层刷新,不改动订单里的历史 metadata。 */
|
|
49
|
+
onFormTitlesChanged(callback: (titles: Record<string, Record<string, string> | string>) => void): () => void;
|
|
46
50
|
/**
|
|
47
51
|
* 业务侧子模块工厂:BookingTicket 自带的 createBookingTicketModule 优先匹配;
|
|
48
52
|
* 未识别的模块名(如 BookingByStep 公共类型)回退到父类工厂。
|
|
@@ -60,6 +64,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
60
64
|
protected loadOpenDataConfig(): Promise<OpenDataConfig | null>;
|
|
61
65
|
getOpenData(): Promise<OpenDataConfig | null>;
|
|
62
66
|
protected loadContactInfoOpenData(): Promise<OpenDataConfig | null>;
|
|
67
|
+
protected loadFulfillmentItemRuleOpenData(): Promise<OpenDataConfig | null>;
|
|
63
68
|
getInvoiceLayoutConfig(): Promise<InvoiceLayoutConfig>;
|
|
64
69
|
getInvoiceTemplateSettings(): Promise<InvoiceTemplateSettings>;
|
|
65
70
|
protected isInvoiceOpenDataCacheCurrent(): boolean;
|
|
@@ -68,6 +73,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
68
73
|
private getShortNumberOrDeviceId;
|
|
69
74
|
private configureIdGeneratorFromOpenData;
|
|
70
75
|
private normalizePositiveInteger;
|
|
76
|
+
private normalizeShortNumberMaximum;
|
|
71
77
|
private normalizeIdPrefix;
|
|
72
78
|
/**
|
|
73
79
|
* 加载销售详情,并在父类基础上把 customer 信息装配到 CustomerModule。
|
|
@@ -44,6 +44,7 @@ var _utils = require("../../modules/Order/utils");
|
|
|
44
44
|
var _contactInfo = require("../../modules/OpenData/contactInfo");
|
|
45
45
|
var _platform = require("../../utils/platform");
|
|
46
46
|
var _lodashEs = require("lodash-es");
|
|
47
|
+
var _types2 = require("../../server/modules/form/types");
|
|
47
48
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
48
49
|
const OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow', 'documents'];
|
|
49
50
|
const OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
|
|
@@ -185,6 +186,16 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
185
186
|
return !channel || channel === 'system' ? 'pos' : channel;
|
|
186
187
|
}
|
|
187
188
|
|
|
189
|
+
/** 供销售展示层按 booking.resources[].form_id 读取当前多语言表单标题。 */
|
|
190
|
+
getFormTitleMap() {
|
|
191
|
+
return this.core?.server?.form?.getTitleMap?.() || {};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** 表单定义由 Ably 更新后通知展示层刷新,不改动订单里的历史 metadata。 */
|
|
195
|
+
onFormTitlesChanged(callback) {
|
|
196
|
+
return this.core.effects.on(_types2.FormHooks.onChanged, callback);
|
|
197
|
+
}
|
|
198
|
+
|
|
188
199
|
/**
|
|
189
200
|
* 业务侧子模块工厂:BookingTicket 自带的 createBookingTicketModule 优先匹配;
|
|
190
201
|
* 未识别的模块名(如 BookingByStep 公共类型)回退到父类工厂。
|
|
@@ -298,6 +309,9 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
298
309
|
async loadContactInfoOpenData() {
|
|
299
310
|
return this.store.openData ? this.getOpenData() : super.loadContactInfoOpenData();
|
|
300
311
|
}
|
|
312
|
+
async loadFulfillmentItemRuleOpenData() {
|
|
313
|
+
return this.store.openData ? this.getOpenData() : super.loadFulfillmentItemRuleOpenData();
|
|
314
|
+
}
|
|
301
315
|
async getInvoiceLayoutConfig() {
|
|
302
316
|
const openData = await this.loadOpenDataConfig();
|
|
303
317
|
if (!openData) return (0, _OpenData.getDefaultInvoiceLayoutConfig)();
|
|
@@ -374,9 +388,10 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
374
388
|
config: {
|
|
375
389
|
prefix,
|
|
376
390
|
deviceCode: deviceId,
|
|
377
|
-
|
|
378
|
-
padReceiptSequence: false,
|
|
391
|
+
padReceiptSequence: openDataConfig?.['sale.pad_with_leading_zeros'] === true,
|
|
379
392
|
receiptSequenceLength,
|
|
393
|
+
receiptSequenceMax: this.normalizeShortNumberMaximum(openDataConfig?.['sale.maximum_number']),
|
|
394
|
+
randomReceiptSequence: openDataConfig?.['sale.short_number_random'] === true,
|
|
380
395
|
resetReceiptSequenceDaily,
|
|
381
396
|
receiptSequenceResetTime: operatingDayBoundary?.time,
|
|
382
397
|
receiptSequenceStart,
|
|
@@ -392,6 +407,17 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
392
407
|
if (!Number.isInteger(numeric) || numeric <= 0) return fallback;
|
|
393
408
|
return numeric;
|
|
394
409
|
}
|
|
410
|
+
normalizeShortNumberMaximum(value) {
|
|
411
|
+
if (value === undefined || value === null || typeof value === 'string' && !value.trim()) return null;
|
|
412
|
+
if (typeof value !== 'number' && typeof value !== 'string') {
|
|
413
|
+
throw new Error('sale.maximum_number 必须是安全正整数或空值');
|
|
414
|
+
}
|
|
415
|
+
const numeric = Number(value);
|
|
416
|
+
if (!Number.isSafeInteger(numeric) || numeric <= 0) {
|
|
417
|
+
throw new Error('sale.maximum_number 必须是安全正整数或空值');
|
|
418
|
+
}
|
|
419
|
+
return numeric;
|
|
420
|
+
}
|
|
395
421
|
normalizeIdPrefix(value, fallback) {
|
|
396
422
|
if (value === undefined || value === null) return fallback;
|
|
397
423
|
const normalized = String(value).trim().toUpperCase();
|
|
@@ -1597,7 +1623,10 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1597
1623
|
resourcesOriginMap: state.resourcesOriginMap,
|
|
1598
1624
|
date,
|
|
1599
1625
|
presetStartTime: extra?.presetStartTime ?? (0, _BookingContext.derivePresetStartTimeFromDate)(date),
|
|
1600
|
-
...(extra || {})
|
|
1626
|
+
...(extra || {}),
|
|
1627
|
+
orderSessionId: this.getOrderSessionId() ?? undefined,
|
|
1628
|
+
isOrderSessionCurrent: sessionId => this.isOrderSessionCurrent(sessionId),
|
|
1629
|
+
platform: String(this.otherParams?.platform || '').trim().toLowerCase()
|
|
1601
1630
|
};
|
|
1602
1631
|
}
|
|
1603
1632
|
|
|
@@ -1689,7 +1718,10 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1689
1718
|
presetStartTime: extra?.presetStartTime ?? (0, _BookingContext.derivePresetStartTimeFromDate)(date),
|
|
1690
1719
|
customerId: orderCustomerId,
|
|
1691
1720
|
...(extra || {}),
|
|
1692
|
-
channel: this.getSubmitOrderSalesChannel()
|
|
1721
|
+
channel: this.getSubmitOrderSalesChannel(),
|
|
1722
|
+
orderSessionId: this.getOrderSessionId() ?? undefined,
|
|
1723
|
+
isOrderSessionCurrent: sessionId => this.isOrderSessionCurrent(sessionId),
|
|
1724
|
+
platform: String(this.otherParams?.platform || '').trim().toLowerCase()
|
|
1693
1725
|
};
|
|
1694
1726
|
}
|
|
1695
1727
|
|
|
@@ -1874,11 +1906,12 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1874
1906
|
};
|
|
1875
1907
|
const result = guardedBridge?.scanScope === 'product-voucher-collection' ? await (0, _applyProductVoucherCollectionScan.applyProductVoucherCollectionScan)({
|
|
1876
1908
|
...host,
|
|
1877
|
-
waitForCustomerDiscounts: () => this.orderCustomerDiscountRefreshInFlight || Promise.resolve(),
|
|
1878
1909
|
loadCustomerDiscounts: async () => {
|
|
1910
|
+
beforeScanCommit();
|
|
1879
1911
|
const customerId = Number(this.getOrderCustomer()?.customer_id || 0);
|
|
1880
1912
|
if (customerId <= 1) return [];
|
|
1881
1913
|
await this.refreshDiscountConfigAfterOrderCustomerChange(customerId);
|
|
1914
|
+
beforeScanCommit();
|
|
1882
1915
|
return this.getDiscountList();
|
|
1883
1916
|
}
|
|
1884
1917
|
}, formatted, guardedBridge) : await (0, _applyGlobalScan.applyGlobalScan)(host, formatted, guardedBridge);
|
|
@@ -2130,6 +2163,8 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
2130
2163
|
const write = this.replaceTempOrder({
|
|
2131
2164
|
...tempOrder,
|
|
2132
2165
|
vouchers: nextVouchers
|
|
2166
|
+
}, {
|
|
2167
|
+
preserveOrderSessionId: this.getOrderSessionId() || undefined
|
|
2133
2168
|
});
|
|
2134
2169
|
this.redeemStatusWrite = write;
|
|
2135
2170
|
try {
|
|
@@ -208,7 +208,7 @@ export interface AddAddTimeProductsToBookingInput {
|
|
|
208
208
|
}
|
|
209
209
|
/** 扫码宿主桥接:SalesSdk 在 pubsub 订阅回调里注入,OS 需要 UI 时直接调用 */
|
|
210
210
|
export interface GlobalScanHostBridge {
|
|
211
|
-
/** product-voucher handles voucher codes
|
|
211
|
+
/** product-voucher handles voucher codes; product-voucher-collection loads all vouchers for the scanned customer. */
|
|
212
212
|
scanScope?: 'all' | 'product-voucher' | 'product-voucher-collection';
|
|
213
213
|
/** A one-shot entry may outlive its page while requests are in flight. */
|
|
214
214
|
isCurrent?: () => boolean;
|