@pisell/pisellos 2.1.120 → 2.1.122
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/OpenData/index.d.ts +1 -0
- package/dist/modules/OpenData/index.js +6 -0
- package/dist/modules/Order/index.d.ts +4 -0
- package/dist/modules/Order/index.js +23 -3
- package/dist/modules/Order/types.d.ts +4 -0
- package/dist/modules/Order/utils.d.ts +7 -0
- package/dist/modules/Order/utils.js +36 -7
- package/dist/modules/ProductList/index.js +2 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/ScanOrder/index.js +13 -9
- package/dist/solution/VenueBooking/index.d.ts +15 -0
- package/dist/solution/VenueBooking/index.js +606 -457
- package/dist/solution/VenueBooking/utils/slotMerge.js +1 -2
- package/lib/modules/OpenData/index.d.ts +1 -0
- package/lib/modules/OpenData/index.js +3 -0
- package/lib/modules/Order/index.d.ts +4 -0
- package/lib/modules/Order/index.js +20 -2
- package/lib/modules/Order/types.d.ts +4 -0
- package/lib/modules/Order/utils.d.ts +7 -0
- package/lib/modules/Order/utils.js +35 -8
- package/lib/modules/ProductList/index.js +2 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/ScanOrder/index.js +7 -3
- package/lib/solution/VenueBooking/index.d.ts +15 -0
- package/lib/solution/VenueBooking/index.js +103 -7
- package/lib/solution/VenueBooking/utils/slotMerge.js +1 -2
- package/package.json +1 -1
|
@@ -18,6 +18,7 @@ export declare class OpenDataModule extends BaseModule implements Module {
|
|
|
18
18
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
19
19
|
fetchOpenData(params: OpenDataFetchParams): Promise<OpenDataConfig>;
|
|
20
20
|
getOpenData(): OpenDataConfig | null;
|
|
21
|
+
getLastFetchedAt(): number | null;
|
|
21
22
|
checkAvailability(scheduleModule?: ScheduleModule): OpenDataAvailabilityResult;
|
|
22
23
|
storeChange(): void;
|
|
23
24
|
}
|
|
@@ -87,6 +87,9 @@ var OpenDataModule = class extends import_BaseModule.BaseModule {
|
|
|
87
87
|
getOpenData() {
|
|
88
88
|
return this.store.data;
|
|
89
89
|
}
|
|
90
|
+
getLastFetchedAt() {
|
|
91
|
+
return this.store.lastFetchedAt ?? null;
|
|
92
|
+
}
|
|
90
93
|
checkAvailability(scheduleModule) {
|
|
91
94
|
var _a;
|
|
92
95
|
const scheduleList = scheduleModule ? scheduleModule.getScheduleListByIds(
|
|
@@ -76,6 +76,10 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
76
76
|
removeProductFromOrder(identity: ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
|
|
77
77
|
submitTempOrder<T = any>(params?: {
|
|
78
78
|
cacheId?: string;
|
|
79
|
+
platform?: string;
|
|
80
|
+
businessCode?: string;
|
|
81
|
+
channel?: string;
|
|
82
|
+
type?: string;
|
|
79
83
|
}): Promise<T>;
|
|
80
84
|
createOrder(params: CommitOrderParams['query']): {
|
|
81
85
|
type: "virtual" | "appointment_booking";
|
|
@@ -130,10 +130,24 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
130
130
|
}
|
|
131
131
|
// ─── Discount: 子模块注册 ───
|
|
132
132
|
registerDiscountModules(options) {
|
|
133
|
+
let targetCacheData = {};
|
|
134
|
+
if (this.cacheId && this.window) {
|
|
135
|
+
const sessionData = this.window.sessionStorage.getItem(this.name);
|
|
136
|
+
if (sessionData) {
|
|
137
|
+
try {
|
|
138
|
+
const data = JSON.parse(sessionData);
|
|
139
|
+
targetCacheData = (data == null ? void 0 : data[this.cacheId]) || {};
|
|
140
|
+
} catch {
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
133
144
|
const discount = new import_Discount.DiscountModule(`${this.name}_discount`);
|
|
134
145
|
this.core.registerModule(discount, {
|
|
146
|
+
initialState: targetCacheData == null ? void 0 : targetCacheData[discount.name],
|
|
135
147
|
otherParams: {
|
|
136
|
-
fatherModule: this.name
|
|
148
|
+
fatherModule: this.name,
|
|
149
|
+
openCache: !!this.cacheId,
|
|
150
|
+
cacheId: this.cacheId
|
|
137
151
|
}
|
|
138
152
|
});
|
|
139
153
|
this.store.discount = discount;
|
|
@@ -473,7 +487,11 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
473
487
|
const effectiveCacheId = (params == null ? void 0 : params.cacheId) ?? this.cacheId;
|
|
474
488
|
const payload = (0, import_utils.buildSubmitPayload)({
|
|
475
489
|
tempOrder,
|
|
476
|
-
cacheId: effectiveCacheId
|
|
490
|
+
cacheId: effectiveCacheId,
|
|
491
|
+
platform: params == null ? void 0 : params.platform,
|
|
492
|
+
businessCode: params == null ? void 0 : params.businessCode,
|
|
493
|
+
channel: params == null ? void 0 : params.channel,
|
|
494
|
+
type: params == null ? void 0 : params.type
|
|
477
495
|
});
|
|
478
496
|
let result;
|
|
479
497
|
if (tempOrder.order_id) {
|
|
@@ -212,6 +212,10 @@ export interface OrderModuleAPI {
|
|
|
212
212
|
persistTempOrder: () => void;
|
|
213
213
|
submitTempOrder: <T = any>(params?: {
|
|
214
214
|
cacheId?: string;
|
|
215
|
+
platform?: string;
|
|
216
|
+
businessCode?: string;
|
|
217
|
+
channel?: string;
|
|
218
|
+
type?: string;
|
|
215
219
|
}) => Promise<T>;
|
|
216
220
|
loadDiscountConfig: (params: {
|
|
217
221
|
customerId: number;
|
|
@@ -25,6 +25,9 @@ export declare const getAllDiscountList: (cartItem: CartItem) => any;
|
|
|
25
25
|
export declare function createUuidV4(): string;
|
|
26
26
|
export declare function isTempOrder(data: any): data is ScanOrderTempOrder;
|
|
27
27
|
export declare function formatDateTime(date: Date): string;
|
|
28
|
+
export declare function normalizeSubmitBooking<T extends {
|
|
29
|
+
metadata?: Record<string, any>;
|
|
30
|
+
}>(booking: T): T;
|
|
28
31
|
export declare function createDefaultTempOrder(params: {
|
|
29
32
|
now: string;
|
|
30
33
|
summary?: ScanOrderSummary;
|
|
@@ -33,6 +36,10 @@ export declare function buildSubmitPayload(params: {
|
|
|
33
36
|
tempOrder: ScanOrderTempOrder;
|
|
34
37
|
cacheId?: string;
|
|
35
38
|
now?: Date;
|
|
39
|
+
platform?: string;
|
|
40
|
+
businessCode?: string;
|
|
41
|
+
channel?: string;
|
|
42
|
+
type?: string;
|
|
36
43
|
}): ScanOrderSubmitPayload;
|
|
37
44
|
export declare function formatV1Product(products: ScanOrderSubmitProduct[]): {
|
|
38
45
|
bundle: any[];
|
|
@@ -38,7 +38,8 @@ __export(utils_exports, {
|
|
|
38
38
|
generateDuration: () => generateDuration,
|
|
39
39
|
getAllDiscountList: () => getAllDiscountList,
|
|
40
40
|
isTempOrder: () => isTempOrder,
|
|
41
|
-
mergeRelationForms: () => mergeRelationForms
|
|
41
|
+
mergeRelationForms: () => mergeRelationForms,
|
|
42
|
+
normalizeSubmitBooking: () => normalizeSubmitBooking
|
|
42
43
|
});
|
|
43
44
|
module.exports = __toCommonJS(utils_exports);
|
|
44
45
|
var import_dayjs = __toESM(require("dayjs"));
|
|
@@ -132,6 +133,23 @@ function normalizeSubmitProduct(product) {
|
|
|
132
133
|
metadata: cleanMetadata
|
|
133
134
|
};
|
|
134
135
|
}
|
|
136
|
+
var SUBMIT_BOOKING_METADATA_WHITELIST = [
|
|
137
|
+
"unique_identification_number",
|
|
138
|
+
"collect_pax"
|
|
139
|
+
];
|
|
140
|
+
function normalizeSubmitBooking(booking) {
|
|
141
|
+
const rawMetadata = booking.metadata || {};
|
|
142
|
+
const cleanMetadata = {};
|
|
143
|
+
for (const key of SUBMIT_BOOKING_METADATA_WHITELIST) {
|
|
144
|
+
if (rawMetadata[key] !== void 0) {
|
|
145
|
+
cleanMetadata[key] = rawMetadata[key];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
...booking,
|
|
150
|
+
metadata: cleanMetadata
|
|
151
|
+
};
|
|
152
|
+
}
|
|
135
153
|
var DEFAULT_TABLE_OCCUPANCY_DURATION = 20;
|
|
136
154
|
function resolveTableOccupancyDuration(tempOrder) {
|
|
137
155
|
var _a, _b, _c, _d;
|
|
@@ -203,7 +221,15 @@ function createDefaultTempOrder(params) {
|
|
|
203
221
|
};
|
|
204
222
|
}
|
|
205
223
|
function buildSubmitPayload(params) {
|
|
206
|
-
const {
|
|
224
|
+
const {
|
|
225
|
+
tempOrder,
|
|
226
|
+
cacheId,
|
|
227
|
+
now = /* @__PURE__ */ new Date(),
|
|
228
|
+
platform,
|
|
229
|
+
businessCode,
|
|
230
|
+
channel,
|
|
231
|
+
type
|
|
232
|
+
} = params;
|
|
207
233
|
const scheduleDate = tempOrder.schedule_date || tempOrder.created_at || formatDateTime(now);
|
|
208
234
|
const summary = tempOrder.summary || (0, import_utils.createEmptySummary)();
|
|
209
235
|
const relationId = tempOrder.relation_id;
|
|
@@ -238,12 +264,12 @@ function buildSubmitPayload(params) {
|
|
|
238
264
|
const { created_at: _createdAt, summary: _summary, surcharges: _surcharges, ...tempOrderRest } = tempOrder;
|
|
239
265
|
return {
|
|
240
266
|
...tempOrderRest,
|
|
241
|
-
platform: normalizeSubmitPlatform(tempOrder.platform),
|
|
267
|
+
platform: normalizeSubmitPlatform(platform ?? tempOrder.platform),
|
|
242
268
|
request_unique_idempotency_token: cacheId,
|
|
243
|
-
type: tempOrder.type
|
|
244
|
-
business_code: tempOrder.business_code
|
|
269
|
+
type: type ?? tempOrder.type ?? "table-order",
|
|
270
|
+
business_code: businessCode ?? tempOrder.business_code ?? "table-order",
|
|
245
271
|
sales_channel: tempOrder.sales_channel || "my_pisel",
|
|
246
|
-
order_sales_channel: tempOrder.order_sales_channel
|
|
272
|
+
order_sales_channel: channel ?? tempOrder.order_sales_channel ?? "online_store",
|
|
247
273
|
status: tempOrder.status || "normal",
|
|
248
274
|
payment_status: tempOrder.payment_status || "payment_processing",
|
|
249
275
|
// shipping_status: tempOrder.shipping_status || 'unfulfilled',
|
|
@@ -255,7 +281,7 @@ function buildSubmitPayload(params) {
|
|
|
255
281
|
surcharge_fee: summary.surcharge_fee || tempOrder.surcharge_fee || "0.00",
|
|
256
282
|
note: tempOrder.note || "",
|
|
257
283
|
schedule_date: scheduleDate,
|
|
258
|
-
bookings,
|
|
284
|
+
bookings: bookings.map((booking) => normalizeSubmitBooking(booking)),
|
|
259
285
|
payments: tempOrder.payments || [],
|
|
260
286
|
// discount_list: tempOrder.discount_list || [],
|
|
261
287
|
relation_forms: tempOrder.relation_forms || [],
|
|
@@ -298,5 +324,6 @@ function formatV1Product(products) {
|
|
|
298
324
|
generateDuration,
|
|
299
325
|
getAllDiscountList,
|
|
300
326
|
isTempOrder,
|
|
301
|
-
mergeRelationForms
|
|
327
|
+
mergeRelationForms,
|
|
328
|
+
normalizeSubmitBooking
|
|
302
329
|
});
|
|
@@ -61,7 +61,7 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
61
61
|
cacheId,
|
|
62
62
|
with_schedule
|
|
63
63
|
}) {
|
|
64
|
-
var _a, _b;
|
|
64
|
+
var _a, _b, _c;
|
|
65
65
|
let userPlugin = this.core.getPlugin("user");
|
|
66
66
|
let customer_id = void 0;
|
|
67
67
|
try {
|
|
@@ -95,7 +95,7 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
95
95
|
with_count,
|
|
96
96
|
// client_schedule_ids: schedule_ids,
|
|
97
97
|
schedule_date,
|
|
98
|
-
application_code: (_b = this.otherParams) == null ? void 0 : _b.channel,
|
|
98
|
+
application_code: ((_b = this.otherParams) == null ? void 0 : _b.channel) === "online_store" ? "online-store" : (_c = this.otherParams) == null ? void 0 : _c.channel,
|
|
99
99
|
with_schedule,
|
|
100
100
|
schedule_datetime,
|
|
101
101
|
is_eject: 1
|
|
@@ -310,7 +310,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
310
310
|
date: string;
|
|
311
311
|
status: string;
|
|
312
312
|
week: string;
|
|
313
|
-
weekNum: 0 | 2 | 1 | 4 | 3 | 6
|
|
313
|
+
weekNum: 0 | 2 | 1 | 5 | 4 | 3 | 6;
|
|
314
314
|
}[]>;
|
|
315
315
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
316
316
|
private getScheduleDataByIds;
|
|
@@ -410,7 +410,7 @@ var ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
412
|
async submitScanOrder() {
|
|
413
|
-
var _a;
|
|
413
|
+
var _a, _b, _c, _d, _e;
|
|
414
414
|
this.logMethodStart("submitScanOrder");
|
|
415
415
|
try {
|
|
416
416
|
await this.validateBeforeSubmitByItemRule();
|
|
@@ -418,11 +418,15 @@ var ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
418
418
|
throw new Error("scanOrder解决方案需要 order 模块支持");
|
|
419
419
|
}
|
|
420
420
|
const result = await this.store.order.submitTempOrder({
|
|
421
|
-
cacheId: this.cacheId
|
|
421
|
+
cacheId: this.cacheId,
|
|
422
|
+
platform: (_a = this.otherParams) == null ? void 0 : _a.platform,
|
|
423
|
+
businessCode: (_b = this.otherParams) == null ? void 0 : _b.businessCode,
|
|
424
|
+
channel: (_c = this.otherParams) == null ? void 0 : _c.channel,
|
|
425
|
+
type: (_d = this.otherParams) == null ? void 0 : _d.type
|
|
422
426
|
});
|
|
423
427
|
const tempOrder = this.store.order.getTempOrder();
|
|
424
428
|
this.logMethodSuccess("submitScanOrder", {
|
|
425
|
-
productCount: ((
|
|
429
|
+
productCount: ((_e = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _e.length) || 0
|
|
426
430
|
});
|
|
427
431
|
return result;
|
|
428
432
|
} catch (error) {
|
|
@@ -34,6 +34,10 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
|
|
|
34
34
|
private loginEffectDisposers;
|
|
35
35
|
private customerLoginRefreshInFlight;
|
|
36
36
|
private customerLoginRefreshIdInFlight;
|
|
37
|
+
private loadAllProductsInFlight;
|
|
38
|
+
private productsLoaded;
|
|
39
|
+
private loadOpenDataConfigInFlight;
|
|
40
|
+
private static readonly OPEN_DATA_CACHE_TTL;
|
|
37
41
|
private getLoggerContext;
|
|
38
42
|
private serializeError;
|
|
39
43
|
private addVenueBookingLog;
|
|
@@ -64,6 +68,7 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
|
|
|
64
68
|
venueProducts: ProductData[];
|
|
65
69
|
addonProducts: ProductData[];
|
|
66
70
|
}>;
|
|
71
|
+
private _doLoadAllProducts;
|
|
67
72
|
loadVenueProducts(): Promise<ProductData[]>;
|
|
68
73
|
loadAddonProducts(): Promise<ProductData[]>;
|
|
69
74
|
getVenueProducts(): ProductData[];
|
|
@@ -154,5 +159,15 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
|
|
|
154
159
|
private refreshCartValidationPassed;
|
|
155
160
|
setItemRuleRuntimeConfig(config?: VenueBookingItemRuleRuntimeConfig): Promise<void>;
|
|
156
161
|
getOtherParams(): Record<string, any>;
|
|
162
|
+
private static readonly UI_STATE_KEY_PREFIX;
|
|
163
|
+
private getUIStateBucketKey;
|
|
164
|
+
private readUIStateBucket;
|
|
165
|
+
private writeUIStateBucket;
|
|
166
|
+
setUIState(key: string, value: any): void;
|
|
167
|
+
getUIState<T = any>(key: string): T | undefined;
|
|
168
|
+
deleteUIState(key: string): void;
|
|
157
169
|
checkOpenDataAvailability(): Promise<OpenDataAvailabilityResult>;
|
|
170
|
+
setOtherParams(params: Record<string, any>, { cover }?: {
|
|
171
|
+
cover?: boolean;
|
|
172
|
+
}): Promise<void>;
|
|
158
173
|
}
|
|
@@ -74,7 +74,7 @@ function cloneCustomDepositData(customDepositData) {
|
|
|
74
74
|
deposit_policy_data: Array.isArray(customDepositData.deposit_policy_data) ? [...customDepositData.deposit_policy_data] : []
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
|
-
var
|
|
77
|
+
var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
78
78
|
constructor(name, version) {
|
|
79
79
|
super(name, version);
|
|
80
80
|
this.defaultName = "venueBooking";
|
|
@@ -105,6 +105,9 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
105
105
|
this.loginEffectDisposers = [];
|
|
106
106
|
this.customerLoginRefreshInFlight = null;
|
|
107
107
|
this.customerLoginRefreshIdInFlight = null;
|
|
108
|
+
this.loadAllProductsInFlight = null;
|
|
109
|
+
this.productsLoaded = false;
|
|
110
|
+
this.loadOpenDataConfigInFlight = null;
|
|
108
111
|
}
|
|
109
112
|
getLoggerContext() {
|
|
110
113
|
return {
|
|
@@ -499,6 +502,14 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
499
502
|
}
|
|
500
503
|
// ─── 场地商品 & 附加商品 ───
|
|
501
504
|
async loadAllProducts() {
|
|
505
|
+
if (this.loadAllProductsInFlight)
|
|
506
|
+
return this.loadAllProductsInFlight;
|
|
507
|
+
this.loadAllProductsInFlight = this._doLoadAllProducts().finally(() => {
|
|
508
|
+
this.loadAllProductsInFlight = null;
|
|
509
|
+
});
|
|
510
|
+
return this.loadAllProductsInFlight;
|
|
511
|
+
}
|
|
512
|
+
async _doLoadAllProducts() {
|
|
502
513
|
var _a, _b, _c;
|
|
503
514
|
this.logMethodStart("loadAllProducts");
|
|
504
515
|
try {
|
|
@@ -526,6 +537,7 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
526
537
|
}
|
|
527
538
|
this.store.addonProducts.addProduct(addonList);
|
|
528
539
|
this.resourceProductMap = (0, import_resource.buildResourceProductMap)(venueList);
|
|
540
|
+
this.productsLoaded = true;
|
|
529
541
|
this.logMethodSuccess("loadAllProducts", {
|
|
530
542
|
total: list.length,
|
|
531
543
|
venueCount: venueList.length,
|
|
@@ -1145,7 +1157,7 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1145
1157
|
}
|
|
1146
1158
|
}
|
|
1147
1159
|
async submitOrder() {
|
|
1148
|
-
var _a;
|
|
1160
|
+
var _a, _b, _c, _d, _e;
|
|
1149
1161
|
this.logMethodStart("submitOrder");
|
|
1150
1162
|
try {
|
|
1151
1163
|
await this.validateBeforeSubmitByItemRule();
|
|
@@ -1153,11 +1165,15 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1153
1165
|
throw new Error("venueBooking解决方案需要 order 模块支持");
|
|
1154
1166
|
}
|
|
1155
1167
|
const result = await this.store.order.submitTempOrder({
|
|
1156
|
-
cacheId: this.cacheId
|
|
1168
|
+
cacheId: this.cacheId,
|
|
1169
|
+
platform: (_a = this.otherParams) == null ? void 0 : _a.platform,
|
|
1170
|
+
businessCode: (_b = this.otherParams) == null ? void 0 : _b.businessCode,
|
|
1171
|
+
channel: (_c = this.otherParams) == null ? void 0 : _c.channel,
|
|
1172
|
+
type: (_d = this.otherParams) == null ? void 0 : _d.type
|
|
1157
1173
|
});
|
|
1158
1174
|
const tempOrder = this.store.order.getTempOrder();
|
|
1159
1175
|
this.logMethodSuccess("submitOrder", {
|
|
1160
|
-
productCount: ((
|
|
1176
|
+
productCount: ((_e = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _e.length) || 0
|
|
1161
1177
|
});
|
|
1162
1178
|
return result;
|
|
1163
1179
|
} catch (error) {
|
|
@@ -1241,6 +1257,12 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1241
1257
|
}
|
|
1242
1258
|
}
|
|
1243
1259
|
async getProductList() {
|
|
1260
|
+
if (this.productsLoaded) {
|
|
1261
|
+
return (0, import_utils.attachItemRuleLimitsToTopLevelProducts)(
|
|
1262
|
+
this.getAddonProductsList(),
|
|
1263
|
+
this.store.itemRuleQuantityLimits || []
|
|
1264
|
+
);
|
|
1265
|
+
}
|
|
1244
1266
|
const result = await this.loadAllProducts();
|
|
1245
1267
|
return (0, import_utils.attachItemRuleLimitsToTopLevelProducts)(
|
|
1246
1268
|
result.addonProducts,
|
|
@@ -1251,13 +1273,25 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1251
1273
|
async loadOpenDataConfig() {
|
|
1252
1274
|
if (!this.store.openData)
|
|
1253
1275
|
throw new Error("openData 模块未初始化");
|
|
1254
|
-
const
|
|
1276
|
+
const lastFetchedAt = this.store.openData.getLastFetchedAt();
|
|
1277
|
+
const cachedData = this.store.openData.getOpenData();
|
|
1278
|
+
if (cachedData && lastFetchedAt && Date.now() - lastFetchedAt < _VenueBookingImpl.OPEN_DATA_CACHE_TTL) {
|
|
1279
|
+
this.otherParams.openData = cachedData;
|
|
1280
|
+
return cachedData;
|
|
1281
|
+
}
|
|
1282
|
+
if (this.loadOpenDataConfigInFlight)
|
|
1283
|
+
return this.loadOpenDataConfigInFlight;
|
|
1284
|
+
this.loadOpenDataConfigInFlight = this.store.openData.fetchOpenData({
|
|
1255
1285
|
scope: "board",
|
|
1256
1286
|
target: "venue_booking+online_store",
|
|
1257
1287
|
section_code: [...OPEN_DATA_SECTION_CODES]
|
|
1288
|
+
}).then((openDataConfig) => {
|
|
1289
|
+
this.otherParams.openData = openDataConfig;
|
|
1290
|
+
return openDataConfig;
|
|
1291
|
+
}).finally(() => {
|
|
1292
|
+
this.loadOpenDataConfigInFlight = null;
|
|
1258
1293
|
});
|
|
1259
|
-
this.
|
|
1260
|
-
return openDataConfig;
|
|
1294
|
+
return this.loadOpenDataConfigInFlight;
|
|
1261
1295
|
}
|
|
1262
1296
|
async loadRuntimeConfigs() {
|
|
1263
1297
|
await this.loadOpenDataConfig();
|
|
@@ -1530,6 +1564,53 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1530
1564
|
getOtherParams() {
|
|
1531
1565
|
return this.otherParams;
|
|
1532
1566
|
}
|
|
1567
|
+
getUIStateBucketKey() {
|
|
1568
|
+
if (!this.cacheId)
|
|
1569
|
+
return null;
|
|
1570
|
+
return `${_VenueBookingImpl.UI_STATE_KEY_PREFIX}${this.cacheId}`;
|
|
1571
|
+
}
|
|
1572
|
+
readUIStateBucket() {
|
|
1573
|
+
var _a;
|
|
1574
|
+
const key = this.getUIStateBucketKey();
|
|
1575
|
+
if (!key || !((_a = this.window) == null ? void 0 : _a.sessionStorage))
|
|
1576
|
+
return {};
|
|
1577
|
+
try {
|
|
1578
|
+
const raw = this.window.sessionStorage.getItem(key) || "{}";
|
|
1579
|
+
const parsed = JSON.parse(raw);
|
|
1580
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
1581
|
+
} catch {
|
|
1582
|
+
return {};
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
writeUIStateBucket(bucket) {
|
|
1586
|
+
var _a;
|
|
1587
|
+
const key = this.getUIStateBucketKey();
|
|
1588
|
+
if (!key || !((_a = this.window) == null ? void 0 : _a.sessionStorage))
|
|
1589
|
+
return;
|
|
1590
|
+
this.window.sessionStorage.setItem(key, JSON.stringify(bucket));
|
|
1591
|
+
}
|
|
1592
|
+
setUIState(key, value) {
|
|
1593
|
+
if (!this.getUIStateBucketKey())
|
|
1594
|
+
return;
|
|
1595
|
+
const bucket = this.readUIStateBucket();
|
|
1596
|
+
bucket[key] = value;
|
|
1597
|
+
this.writeUIStateBucket(bucket);
|
|
1598
|
+
}
|
|
1599
|
+
getUIState(key) {
|
|
1600
|
+
if (!this.getUIStateBucketKey())
|
|
1601
|
+
return void 0;
|
|
1602
|
+
const bucket = this.readUIStateBucket();
|
|
1603
|
+
return bucket[key];
|
|
1604
|
+
}
|
|
1605
|
+
deleteUIState(key) {
|
|
1606
|
+
if (!this.getUIStateBucketKey())
|
|
1607
|
+
return;
|
|
1608
|
+
const bucket = this.readUIStateBucket();
|
|
1609
|
+
if (key in bucket) {
|
|
1610
|
+
delete bucket[key];
|
|
1611
|
+
this.writeUIStateBucket(bucket);
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1533
1614
|
// ─── OpenData 可用性 ───
|
|
1534
1615
|
async checkOpenDataAvailability() {
|
|
1535
1616
|
if (!this.store.openData)
|
|
@@ -1537,7 +1618,22 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1537
1618
|
await this.loadOpenDataConfig();
|
|
1538
1619
|
return this.store.openData.checkAvailability(this.store.schedule);
|
|
1539
1620
|
}
|
|
1621
|
+
async setOtherParams(params, { cover = false } = {}) {
|
|
1622
|
+
if (cover) {
|
|
1623
|
+
this.otherParams = params;
|
|
1624
|
+
} else {
|
|
1625
|
+
this.otherParams = { ...this.otherParams, ...params };
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1540
1628
|
};
|
|
1629
|
+
var VenueBookingImpl = _VenueBookingImpl;
|
|
1630
|
+
VenueBookingImpl.OPEN_DATA_CACHE_TTL = 5 * 60 * 1e3;
|
|
1631
|
+
// ─── UI 状态缓存(按 cacheId 分桶,sessionStorage) ───
|
|
1632
|
+
//
|
|
1633
|
+
// 用于物料层持久化 UI 层面的轻量状态(如当前步骤、登录回跳意图等)。
|
|
1634
|
+
// 桶键:pisell.venueBooking.uiState:<cacheId>;内部以 JSON object 形式存储多个字段。
|
|
1635
|
+
// 无 cacheId 时所有方法自动降级为 no-op,上层不用判空。
|
|
1636
|
+
VenueBookingImpl.UI_STATE_KEY_PREFIX = "pisell.venueBooking.uiState:";
|
|
1541
1637
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1542
1638
|
0 && (module.exports = {
|
|
1543
1639
|
VenueBookingImpl,
|