@pisell/pisellos 2.1.120 → 2.1.121

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.
@@ -131,8 +131,7 @@ export function buildVenueBookingEntry(params) {
131
131
  metadata: {
132
132
  unique_identification_number: bookingUuid,
133
133
  venue_booking: true,
134
- resource_id: resourceId,
135
- slot_count: group.slotCount
134
+ resource_id: resourceId
136
135
  }
137
136
  };
138
137
  }
@@ -0,0 +1,49 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/model/strategy/adapter/promotion/index.ts
30
+ var promotion_exports = {};
31
+ __export(promotion_exports, {
32
+ BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
+ PromotionAdapter: () => import_adapter.PromotionAdapter,
34
+ PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
35
+ X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
36
+ default: () => import_adapter2.default
37
+ });
38
+ module.exports = __toCommonJS(promotion_exports);
39
+ var import_evaluator = require("./evaluator");
40
+ var import_adapter = require("./adapter");
41
+ var import_adapter2 = __toESM(require("./adapter"));
42
+ var import_examples = require("./examples");
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ BUY_X_GET_Y_FREE_STRATEGY,
46
+ PromotionAdapter,
47
+ PromotionEvaluator,
48
+ X_ITEMS_FOR_Y_PRICE_STRATEGY
49
+ });
@@ -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(
@@ -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;
@@ -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;
@@ -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;
@@ -255,7 +273,7 @@ function buildSubmitPayload(params) {
255
273
  surcharge_fee: summary.surcharge_fee || tempOrder.surcharge_fee || "0.00",
256
274
  note: tempOrder.note || "",
257
275
  schedule_date: scheduleDate,
258
- bookings,
276
+ bookings: bookings.map((booking) => normalizeSubmitBooking(booking)),
259
277
  payments: tempOrder.payments || [],
260
278
  // discount_list: tempOrder.discount_list || [],
261
279
  relation_forms: tempOrder.relation_forms || [],
@@ -298,5 +316,6 @@ function formatV1Product(products) {
298
316
  generateDuration,
299
317
  getAllDiscountList,
300
318
  isTempOrder,
301
- mergeRelationForms
319
+ mergeRelationForms,
320
+ normalizeSubmitBooking
302
321
  });
@@ -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 | 5;
313
+ weekNum: 0 | 2 | 1 | 5 | 4 | 3 | 6;
314
314
  }[]>;
315
315
  submitTimeSlot(timeSlots: TimeSliceItem): void;
316
316
  private getScheduleDataByIds;
@@ -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,
@@ -142,8 +142,7 @@ function buildVenueBookingEntry(params) {
142
142
  metadata: {
143
143
  unique_identification_number: bookingUuid,
144
144
  venue_booking: true,
145
- resource_id: resourceId,
146
- slot_count: group.slotCount
145
+ resource_id: resourceId
147
146
  }
148
147
  };
149
148
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.1.120",
4
+ "version": "2.1.121",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",