@pisell/pisellos 0.0.497 → 0.0.499

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.
@@ -226,7 +226,7 @@ export function buildTimeSlotGrid(params) {
226
226
  resources.push({
227
227
  resourceId: resource.resourceId,
228
228
  resourceFormId: resource.formId,
229
- resourceName: mapping.resourceName,
229
+ resourceName: resource.main_field || mapping.resourceName,
230
230
  productId: mapping.productId,
231
231
  productTitle: mapping.productTitle,
232
232
  slots: slots
@@ -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(
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 1 | 4 | 2 | 3 | 6 | 5;
314
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -330,7 +330,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
330
330
  count: number;
331
331
  left: number;
332
332
  summaryCount: number;
333
- status: "sold_out" | "lots_of_space" | "filling_up_fast";
333
+ status: "lots_of_space" | "filling_up_fast" | "sold_out";
334
334
  }[];
335
335
  /**
336
336
  * 找到多个资源的公共可用时间段
@@ -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[];
@@ -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 VenueBookingImpl = class extends import_BaseModule.BaseModule {
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 {
@@ -423,6 +426,7 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
423
426
  await this.store.schedule.loadAllSchedule();
424
427
  this.injectScheduleResolverToQuotation();
425
428
  }
429
+ this.loadQuotations();
426
430
  await this.refreshItemRuleQuantityLimits();
427
431
  this.store.status = "ready";
428
432
  console.log("[VenueBooking] 初始化完成");
@@ -499,6 +503,14 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
499
503
  }
500
504
  // ─── 场地商品 & 附加商品 ───
501
505
  async loadAllProducts() {
506
+ if (this.loadAllProductsInFlight)
507
+ return this.loadAllProductsInFlight;
508
+ this.loadAllProductsInFlight = this._doLoadAllProducts().finally(() => {
509
+ this.loadAllProductsInFlight = null;
510
+ });
511
+ return this.loadAllProductsInFlight;
512
+ }
513
+ async _doLoadAllProducts() {
502
514
  var _a, _b, _c;
503
515
  this.logMethodStart("loadAllProducts");
504
516
  try {
@@ -526,6 +538,7 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
526
538
  }
527
539
  this.store.addonProducts.addProduct(addonList);
528
540
  this.resourceProductMap = (0, import_resource.buildResourceProductMap)(venueList);
541
+ this.productsLoaded = true;
529
542
  this.logMethodSuccess("loadAllProducts", {
530
543
  total: list.length,
531
544
  venueCount: venueList.length,
@@ -1241,6 +1254,12 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
1241
1254
  }
1242
1255
  }
1243
1256
  async getProductList() {
1257
+ if (this.productsLoaded) {
1258
+ return (0, import_utils.attachItemRuleLimitsToTopLevelProducts)(
1259
+ this.getAddonProductsList(),
1260
+ this.store.itemRuleQuantityLimits || []
1261
+ );
1262
+ }
1244
1263
  const result = await this.loadAllProducts();
1245
1264
  return (0, import_utils.attachItemRuleLimitsToTopLevelProducts)(
1246
1265
  result.addonProducts,
@@ -1251,13 +1270,25 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
1251
1270
  async loadOpenDataConfig() {
1252
1271
  if (!this.store.openData)
1253
1272
  throw new Error("openData 模块未初始化");
1254
- const openDataConfig = await this.store.openData.fetchOpenData({
1273
+ const lastFetchedAt = this.store.openData.getLastFetchedAt();
1274
+ const cachedData = this.store.openData.getOpenData();
1275
+ if (cachedData && lastFetchedAt && Date.now() - lastFetchedAt < _VenueBookingImpl.OPEN_DATA_CACHE_TTL) {
1276
+ this.otherParams.openData = cachedData;
1277
+ return cachedData;
1278
+ }
1279
+ if (this.loadOpenDataConfigInFlight)
1280
+ return this.loadOpenDataConfigInFlight;
1281
+ this.loadOpenDataConfigInFlight = this.store.openData.fetchOpenData({
1255
1282
  scope: "board",
1256
1283
  target: "venue_booking+online_store",
1257
1284
  section_code: [...OPEN_DATA_SECTION_CODES]
1285
+ }).then((openDataConfig) => {
1286
+ this.otherParams.openData = openDataConfig;
1287
+ return openDataConfig;
1288
+ }).finally(() => {
1289
+ this.loadOpenDataConfigInFlight = null;
1258
1290
  });
1259
- this.otherParams.openData = openDataConfig;
1260
- return openDataConfig;
1291
+ return this.loadOpenDataConfigInFlight;
1261
1292
  }
1262
1293
  async loadRuntimeConfigs() {
1263
1294
  await this.loadOpenDataConfig();
@@ -1538,6 +1569,8 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
1538
1569
  return this.store.openData.checkAvailability(this.store.schedule);
1539
1570
  }
1540
1571
  };
1572
+ var VenueBookingImpl = _VenueBookingImpl;
1573
+ VenueBookingImpl.OPEN_DATA_CACHE_TTL = 5 * 60 * 1e3;
1541
1574
  // Annotate the CommonJS export names for ESM import in node:
1542
1575
  0 && (module.exports = {
1543
1576
  VenueBookingImpl,
@@ -175,7 +175,7 @@ function buildTimeSlotGrid(params) {
175
175
  resources.push({
176
176
  resourceId: resource.resourceId,
177
177
  resourceFormId: resource.formId,
178
- resourceName: mapping.resourceName,
178
+ resourceName: resource.main_field || mapping.resourceName,
179
179
  productId: mapping.productId,
180
180
  productTitle: mapping.productTitle,
181
181
  slots
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.497",
4
+ "version": "0.0.499",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",