@pisell/pisellos 2.1.34 → 2.1.35

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.
Files changed (53) hide show
  1. package/dist/effects/index.d.ts +1 -0
  2. package/dist/effects/index.js +29 -6
  3. package/dist/modules/Account/index.js +2 -3
  4. package/dist/modules/BaseModule.d.ts +3 -0
  5. package/dist/modules/BaseModule.js +15 -0
  6. package/dist/modules/Customer/index.js +9 -10
  7. package/dist/modules/Customer/types.d.ts +2 -2
  8. package/dist/modules/Customer/types.js +2 -2
  9. package/dist/modules/Discount/index.js +1 -1
  10. package/dist/modules/Guests/index.js +9 -9
  11. package/dist/modules/Order/index.js +1 -1
  12. package/dist/modules/Payment/index.js +17 -17
  13. package/dist/modules/Payment/walletpass.js +4 -1
  14. package/dist/modules/Product/index.d.ts +1 -1
  15. package/dist/modules/ProductList/index.js +2 -3
  16. package/dist/modules/Resource/index.js +1 -1
  17. package/dist/modules/Rules/index.js +2 -3
  18. package/dist/solution/BookingByStep/index.js +2 -2
  19. package/dist/solution/BookingTicket/index.d.ts +4 -0
  20. package/dist/solution/BookingTicket/index.js +17 -8
  21. package/dist/solution/BookingTicket/utils/scan/index.d.ts +4 -0
  22. package/dist/solution/BookingTicket/utils/scan/index.js +25 -16
  23. package/dist/solution/BuyTickets/index.js +7 -8
  24. package/dist/solution/Checkout/index.js +35 -35
  25. package/dist/solution/ShopDiscount/index.js +9 -10
  26. package/dist/types/index.d.ts +1 -0
  27. package/lib/effects/index.d.ts +1 -0
  28. package/lib/effects/index.js +13 -0
  29. package/lib/modules/Account/index.js +2 -3
  30. package/lib/modules/BaseModule.d.ts +3 -0
  31. package/lib/modules/BaseModule.js +9 -0
  32. package/lib/modules/Customer/index.js +9 -10
  33. package/lib/modules/Customer/types.d.ts +2 -2
  34. package/lib/modules/Customer/types.js +2 -2
  35. package/lib/modules/Discount/index.js +1 -1
  36. package/lib/modules/Guests/index.js +9 -9
  37. package/lib/modules/Order/index.js +1 -1
  38. package/lib/modules/Payment/index.js +16 -16
  39. package/lib/modules/Payment/walletpass.js +3 -1
  40. package/lib/modules/Product/index.d.ts +1 -1
  41. package/lib/modules/ProductList/index.js +2 -3
  42. package/lib/modules/Resource/index.js +1 -1
  43. package/lib/modules/Rules/index.js +2 -3
  44. package/lib/solution/BookingByStep/index.js +1 -1
  45. package/lib/solution/BookingTicket/index.d.ts +4 -0
  46. package/lib/solution/BookingTicket/index.js +6 -6
  47. package/lib/solution/BookingTicket/utils/scan/index.d.ts +4 -0
  48. package/lib/solution/BookingTicket/utils/scan/index.js +7 -1
  49. package/lib/solution/BuyTickets/index.js +7 -8
  50. package/lib/solution/Checkout/index.js +34 -34
  51. package/lib/solution/ShopDiscount/index.js +10 -11
  52. package/lib/types/index.d.ts +1 -0
  53. package/package.json +1 -1
@@ -24,7 +24,6 @@ __export(Account_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(Account_exports);
26
26
  var import_BaseModule = require("../BaseModule");
27
- var import_types = require("./types");
28
27
  __reExport(Account_exports, require("./types"), module.exports);
29
28
  var AccountModule = class extends import_BaseModule.BaseModule {
30
29
  constructor(name, version) {
@@ -59,7 +58,7 @@ var AccountModule = class extends import_BaseModule.BaseModule {
59
58
  };
60
59
  this.store.accountInfo = account;
61
60
  this.store.isLoggedIn = true;
62
- await this.core.effects.emit(import_types.AccountHooks.OnLogin, account);
61
+ await this.core.effects.emit(`${this.name}:onLogin`, account);
63
62
  }
64
63
  getCurrentAccount() {
65
64
  return this.store.accountInfo;
@@ -72,7 +71,7 @@ var AccountModule = class extends import_BaseModule.BaseModule {
72
71
  ...updates
73
72
  };
74
73
  await this.core.effects.emit(
75
- import_types.AccountHooks.OnProfileUpdate,
74
+ `${this.name}:onProfileUpdate`,
76
75
  this.store.accountInfo
77
76
  );
78
77
  }
@@ -14,4 +14,7 @@ export declare class BaseModule {
14
14
  store: any;
15
15
  cacheKey: string[];
16
16
  }): void;
17
+ effectsOn(eventType: string, callback: (payload: any) => void): () => void;
18
+ effectsOff(eventType: string, callback: (payload: any) => void): void;
19
+ effectsOnce(eventType: string, callback: (payload: any) => void): () => void;
17
20
  }
@@ -82,6 +82,15 @@ var BaseModule = class {
82
82
  }
83
83
  }
84
84
  }
85
+ effectsOn(eventType, callback) {
86
+ return this.core.effects.on(`${this.name}:${eventType}`, callback);
87
+ }
88
+ effectsOff(eventType, callback) {
89
+ return this.core.effects.off(`${this.name}:${eventType}`, callback);
90
+ }
91
+ effectsOnce(eventType, callback) {
92
+ return this.core.effects.once(`${this.name}:${eventType}`, callback);
93
+ }
85
94
  };
86
95
  // Annotate the CommonJS export names for ESM import in node:
87
96
  0 && (module.exports = {
@@ -25,7 +25,6 @@ __export(Customer_exports, {
25
25
  module.exports = __toCommonJS(Customer_exports);
26
26
  var import_lodash_es = require("lodash-es");
27
27
  var import_BaseModule = require("../BaseModule");
28
- var import_types = require("./types");
29
28
  var import_constants = require("./constants");
30
29
  __reExport(Customer_exports, require("./types"), module.exports);
31
30
  var CustomerModule = class extends import_BaseModule.BaseModule {
@@ -128,7 +127,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
128
127
  console.error(`Failed to ${operation}:`, error);
129
128
  this.store.error = error instanceof Error ? error.message : `Failed to ${operation}`;
130
129
  await this.core.effects.emit(
131
- import_types.CustomerHooks.OnCustomerListError,
130
+ `${this.name}:onCustomerListError`,
132
131
  this.store.error
133
132
  );
134
133
  }
@@ -150,7 +149,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
150
149
  this.store.hasMore = page * pageSize < total;
151
150
  this.store.customerList = (0, import_lodash_es.cloneDeep)(customerList);
152
151
  await this.core.effects.emit(
153
- import_types.CustomerHooks.OnCustomerListUpdate,
152
+ `${this.name}:onCustomerListUpdate`,
154
153
  this.store
155
154
  );
156
155
  this.triggerPaginationChange({
@@ -193,7 +192,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
193
192
  setSelectedCustomer(customer) {
194
193
  this.store.selectedCustomer = !customer ? import_constants.DEFAULT_CUSTOMER : (0, import_lodash_es.cloneDeep)(customer);
195
194
  this.core.effects.emit(
196
- import_types.CustomerHooks.OnCustomerSelected,
195
+ `${this.name}:onCustomerSelected`,
197
196
  this.store.selectedCustomer
198
197
  );
199
198
  this.storeChange();
@@ -233,7 +232,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
233
232
  this.store.loadingMore = false;
234
233
  this.store.searchParams = {};
235
234
  this.core.effects.emit(
236
- import_types.CustomerHooks.OnCustomerListUpdate,
235
+ `${this.name}:onCustomerListUpdate`,
237
236
  this.store
238
237
  );
239
238
  this.storeChange();
@@ -247,7 +246,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
247
246
  this.store.customerList = [newCustomer, ...this.store.customerList];
248
247
  this.store.total += 1;
249
248
  this.core.effects.emit(
250
- import_types.CustomerHooks.OnCustomerListUpdate,
249
+ `${this.name}:onCustomerListUpdate`,
251
250
  this.store
252
251
  );
253
252
  this.storeChange();
@@ -277,7 +276,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
277
276
  */
278
277
  triggerPaginationChange(pagination) {
279
278
  this.core.effects.emit(
280
- import_types.CustomerHooks.OnPaginationChange,
279
+ `${this.name}:onPaginationChange`,
281
280
  pagination
282
281
  );
283
282
  }
@@ -344,7 +343,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
344
343
  this.store.total = total;
345
344
  this.store.hasMore = page * pageSize < total;
346
345
  await this.core.effects.emit(
347
- import_types.CustomerHooks.OnScrollLoadMore,
346
+ `${this.name}:onScrollLoadMore`,
348
347
  {
349
348
  newCustomers,
350
349
  allCustomers: this.store.customerList,
@@ -353,7 +352,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
353
352
  }
354
353
  );
355
354
  await this.core.effects.emit(
356
- import_types.CustomerHooks.OnCustomerListUpdate,
355
+ `${this.name}:onCustomerListUpdate`,
357
356
  this.store
358
357
  );
359
358
  this.triggerPaginationChange({
@@ -395,7 +394,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
395
394
  };
396
395
  const response = await this.getCustomerList(resetParams);
397
396
  await this.core.effects.emit(
398
- import_types.CustomerHooks.OnScrollLoadComplete,
397
+ `${this.name}:onScrollLoadComplete`,
399
398
  {
400
399
  customers: this.store.customerList,
401
400
  total: this.store.total,
@@ -1,8 +1,8 @@
1
1
  import { ICustomer } from "../AccountList/types";
2
2
  export declare enum CustomerHooks {
3
- OnCustomerListUpdate = "customer:onUpdate",
3
+ OnCustomerListUpdate = "customer:onCustomerListUpdate",
4
4
  OnCustomerListError = "customer:onError",
5
- OnCustomerSelected = "customer:onSelected",
5
+ OnCustomerSelected = "customer:onCustomerSelected",
6
6
  OnPaginationChange = "customer:onPaginationChange",
7
7
  OnScrollLoadMore = "customer:onScrollLoadMore",
8
8
  OnScrollLoadComplete = "customer:onScrollLoadComplete"
@@ -23,9 +23,9 @@ __export(types_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(types_exports);
25
25
  var CustomerHooks = /* @__PURE__ */ ((CustomerHooks2) => {
26
- CustomerHooks2["OnCustomerListUpdate"] = "customer:onUpdate";
26
+ CustomerHooks2["OnCustomerListUpdate"] = "customer:onCustomerListUpdate";
27
27
  CustomerHooks2["OnCustomerListError"] = "customer:onError";
28
- CustomerHooks2["OnCustomerSelected"] = "customer:onSelected";
28
+ CustomerHooks2["OnCustomerSelected"] = "customer:onCustomerSelected";
29
29
  CustomerHooks2["OnPaginationChange"] = "customer:onPaginationChange";
30
30
  CustomerHooks2["OnScrollLoadMore"] = "customer:onScrollLoadMore";
31
31
  CustomerHooks2["OnScrollLoadComplete"] = "customer:onScrollLoadComplete";
@@ -171,7 +171,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
171
171
  async destroy() {
172
172
  this.store.discountList = [];
173
173
  this.core.effects.offByModuleDestroy(this.name);
174
- await this.core.effects.emit(import_types.DiscountHooks.OnDestroy, {});
174
+ await this.core.effects.emit(`${this.name}:onDestroy`, {});
175
175
  console.log("[Discount] 已销毁");
176
176
  }
177
177
  async clear() {
@@ -41,8 +41,8 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
41
41
  }
42
42
  async addGuest(guest) {
43
43
  this.state.list.push(guest);
44
- await this.core.effects.emit(import_types.GuestHooks.OnGuestAdd, guest);
45
- await this.core.effects.emit(import_types.GuestHooks.OnGuestChange, this.state.list);
44
+ await this.core.effects.emit(`${this.name}:onGuestAdd`, guest);
45
+ await this.core.effects.emit(`${this.name}:onGuestChange`, this.state.list);
46
46
  }
47
47
  async updateGuest(id, updates) {
48
48
  const index = this.state.list.findIndex((g) => g.id === id);
@@ -56,15 +56,15 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
56
56
  import_types.GuestHooks.OnGuestUpdate,
57
57
  this.state.list[index]
58
58
  );
59
- await this.core.effects.emit(import_types.GuestHooks.OnGuestChange, this.state.list);
59
+ await this.core.effects.emit(`${this.name}:onGuestChange`, this.state.list);
60
60
  }
61
61
  async removeGuest(id) {
62
62
  const index = this.state.list.findIndex((g) => g.id === id);
63
63
  if (index === -1)
64
64
  return;
65
65
  const [removed] = this.state.list.splice(index, 1);
66
- await this.core.effects.emit(import_types.GuestHooks.OnGuestRemove, removed);
67
- await this.core.effects.emit(import_types.GuestHooks.OnGuestChange, this.state.list);
66
+ await this.core.effects.emit(`${this.name}:onGuestRemove`, removed);
67
+ await this.core.effects.emit(`${this.name}:onGuestChange`, this.state.list);
68
68
  }
69
69
  async getGuests() {
70
70
  return this.state.list;
@@ -77,8 +77,8 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
77
77
  if (!guest)
78
78
  return;
79
79
  guest.items.push(item);
80
- await this.core.effects.emit(import_types.GuestHooks.OnGuestUpdate, guest);
81
- await this.core.effects.emit(import_types.GuestHooks.OnGuestChange, this.state.list);
80
+ await this.core.effects.emit(`${this.name}:onGuestUpdate`, guest);
81
+ await this.core.effects.emit(`${this.name}:onGuestChange`, this.state.list);
82
82
  }
83
83
  async removeItemFromGuest(guestId, itemId) {
84
84
  const guest = this.state.list.find((g) => g.id === guestId);
@@ -88,8 +88,8 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
88
88
  if (index === -1)
89
89
  return;
90
90
  guest.items.splice(index, 1);
91
- await this.core.effects.emit(import_types.GuestHooks.OnGuestUpdate, guest);
92
- await this.core.effects.emit(import_types.GuestHooks.OnGuestChange, this.state.list);
91
+ await this.core.effects.emit(`${this.name}:onGuestUpdate`, guest);
92
+ await this.core.effects.emit(`${this.name}:onGuestChange`, this.state.list);
93
93
  }
94
94
  };
95
95
  // Annotate the CommonJS export names for ESM import in node:
@@ -39,7 +39,7 @@ var import_dayjs = __toESM(require("dayjs"));
39
39
  var OrderModule = class extends import_BaseModule.BaseModule {
40
40
  // LoggerManager 实例
41
41
  constructor(name, version) {
42
- super(name, version);
42
+ super(name || "order", version);
43
43
  this.defaultName = "order";
44
44
  this.defaultVersion = "1.0.0";
45
45
  }
@@ -55,7 +55,7 @@ function generateRequestUniqueId() {
55
55
  }
56
56
  var PaymentModule = class extends import_BaseModule.BaseModule {
57
57
  constructor(name, version) {
58
- super(name, version);
58
+ super(name || "payment", version);
59
59
  this.defaultName = "pay";
60
60
  this.defaultVersion = "1.0.0";
61
61
  // LoggerManager 实例
@@ -193,7 +193,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
193
193
  console.warn("[PaymentModule] 无法缓存支付方式,pay_method 表不存在");
194
194
  }
195
195
  await this.core.effects.emit(
196
- import_types.PaymentHooks.OnPaymentMethodsLoaded,
196
+ `${this.name}:onPaymentMethodsLoaded`,
197
197
  payMethods
198
198
  );
199
199
  this.logInfo("getPayMethodListAsync completed successfully", {
@@ -243,7 +243,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
243
243
  newMethods: newPayMethods
244
244
  };
245
245
  await this.core.effects.emit(
246
- import_types.PaymentHooks.OnPaymentMethodsChanged,
246
+ `${this.name}:onPaymentMethodsChanged`,
247
247
  eventData
248
248
  );
249
249
  } else {
@@ -368,7 +368,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
368
368
  const order = await this.dbManager.get("order", orderUuid);
369
369
  if (order) {
370
370
  await this.dbManager.delete("order", orderUuid);
371
- await this.core.effects.emit(import_types.PaymentHooks.OnOrderDeleted, order);
371
+ await this.core.effects.emit(`${this.name}:onOrderDeleted`, order);
372
372
  console.log("[PaymentModule] 支付订单删除成功:", orderUuid);
373
373
  }
374
374
  } catch (error) {
@@ -386,8 +386,8 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
386
386
  const updatedOrder = { ...order, ...params };
387
387
  this.recalculateOrderAmount(updatedOrder);
388
388
  await this.dbManager.update("order", updatedOrder);
389
- await this.core.effects.emit(import_types.PaymentHooks.OnOrderUpdated, updatedOrder);
390
- await this.core.effects.emit(import_types.PaymentHooks.OnOrderChanged, {
389
+ await this.core.effects.emit(`${this.name}:onOrderUpdated`, updatedOrder);
390
+ await this.core.effects.emit(`${this.name}:onOrderChanged`, {
391
391
  action: "update",
392
392
  order: updatedOrder,
393
393
  originalOrder: order
@@ -445,8 +445,8 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
445
445
  }
446
446
  };
447
447
  await this.dbManager.update("order", updatedOrder);
448
- await this.core.effects.emit(import_types.PaymentHooks.OnOrderUpdated, updatedOrder);
449
- await this.core.effects.emit(import_types.PaymentHooks.OnOrderChanged, {
448
+ await this.core.effects.emit(`${this.name}:onOrderUpdated`, updatedOrder);
449
+ await this.core.effects.emit(`${this.name}:onOrderChanged`, {
450
450
  action: "order_id_replaced",
451
451
  order: updatedOrder,
452
452
  originalOrder: existingOrder,
@@ -563,7 +563,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
563
563
  order.payment.push(newPaymentItem);
564
564
  this.recalculateOrderAmount(order);
565
565
  await this.dbManager.update("order", order);
566
- await this.core.effects.emit(import_types.PaymentHooks.OnPaymentAdded, {
566
+ await this.core.effects.emit(`${this.name}:onPaymentAdded`, {
567
567
  orderUuid,
568
568
  payment: newPaymentItem
569
569
  });
@@ -619,11 +619,11 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
619
619
  });
620
620
  this.recalculateOrderAmount(order);
621
621
  await this.dbManager.update("order", order);
622
- await this.core.effects.emit(import_types.PaymentHooks.OnPaymentDeleted, {
622
+ await this.core.effects.emit(`${this.name}:onPaymentDeleted`, {
623
623
  order,
624
624
  paymentItem
625
625
  });
626
- await this.core.effects.emit(import_types.PaymentHooks.OnOrderChanged, {
626
+ await this.core.effects.emit(`${this.name}:onOrderChanged`, {
627
627
  action: "payment_delete",
628
628
  order,
629
629
  paymentItem
@@ -700,7 +700,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
700
700
  await this.addPaymentItemAsync(orderUuid, voucherItem);
701
701
  }
702
702
  const updatedOrder = await this.getPaymentOrderByUuidAsync(orderUuid);
703
- await this.core.effects.emit(import_types.PaymentHooks.OnPaymentAdded, {
703
+ await this.core.effects.emit(`${this.name}:onPaymentAdded`, {
704
704
  orderUuid,
705
705
  order: updatedOrder,
706
706
  payment: null
@@ -741,11 +741,11 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
741
741
  Object.assign(paymentItem, formattedParams);
742
742
  this.recalculateOrderAmount(order);
743
743
  await this.dbManager.update("order", order);
744
- await this.core.effects.emit(import_types.PaymentHooks.OnPaymentUpdated, {
744
+ await this.core.effects.emit(`${this.name}:onPaymentUpdated`, {
745
745
  order,
746
746
  paymentItem
747
747
  });
748
- await this.core.effects.emit(import_types.PaymentHooks.OnOrderChanged, {
748
+ await this.core.effects.emit(`${this.name}:onOrderChanged`, {
749
749
  action: "payment_update",
750
750
  order,
751
751
  paymentItem
@@ -833,8 +833,8 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
833
833
  });
834
834
  return;
835
835
  }
836
- await this.core.effects.emit(import_types.PaymentHooks.OnPaymentSubmitted, order);
837
- await this.core.effects.emit(import_types.PaymentHooks.OnOrderChanged, {
836
+ await this.core.effects.emit(`${this.name}:onPaymentSubmitted`, order);
837
+ await this.core.effects.emit(`${this.name}:onOrderChanged`, {
838
838
  action: "submit",
839
839
  order
840
840
  });
@@ -38,7 +38,9 @@ var WalletPassPaymentImpl = class {
38
38
  */
39
39
  emitEvent(hook, data) {
40
40
  try {
41
- this.paymentModule.core.effects.emit(hook, data);
41
+ const eventName = hook.split(":")[1] || hook.replace(/^[A-Z][a-z]+/, "").replace(/^On/, "").toLowerCase();
42
+ const fullEventName = `${this.paymentModule.name}:${eventName}`;
43
+ this.paymentModule.core.effects.emit(fullEventName, data);
42
44
  } catch (error) {
43
45
  this.paymentModule.logError("[WalletPass] 发送事件失败", error, { hook });
44
46
  }
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "duration" | "session" | "normal";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -24,7 +24,6 @@ __export(ProductList_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(ProductList_exports);
26
26
  var import_BaseModule = require("../BaseModule");
27
- var import_types = require("./types");
28
27
  var import_lodash_es = require("lodash-es");
29
28
  __reExport(ProductList_exports, require("./types"), module.exports);
30
29
  var ProductList = class extends import_BaseModule.BaseModule {
@@ -134,14 +133,14 @@ var ProductList = class extends import_BaseModule.BaseModule {
134
133
  }
135
134
  async getProducts() {
136
135
  await this.core.effects.emit(
137
- import_types.ProductListHooks.onGetProducts,
136
+ `${this.name}:onGetProducts`,
138
137
  this.store.list
139
138
  );
140
139
  return (0, import_lodash_es.cloneDeep)(this.store.list);
141
140
  }
142
141
  async getProduct(id) {
143
142
  await this.core.effects.emit(
144
- import_types.ProductListHooks.onGetProduct,
143
+ `${this.name}:onGetProduct`,
145
144
  this.store.list
146
145
  );
147
146
  const product = this.store.list.find((product2) => product2.id === id);
@@ -42,7 +42,7 @@ var ResourceListModule = class extends import_BaseModule.BaseModule {
42
42
  if (!resource)
43
43
  return;
44
44
  this.store.selectedResource = resource;
45
- await this.core.effects.emit(import_types.ResourceHooks.OnResourceSelect, resource);
45
+ await this.core.effects.emit(`${this.name}:onResourceSelect`, resource);
46
46
  }
47
47
  getSelectedResource() {
48
48
  return this.store.selectedResource;
@@ -33,7 +33,6 @@ __export(Rules_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(Rules_exports);
35
35
  var import_BaseModule = require("../BaseModule");
36
- var import_types = require("./types");
37
36
  var import_utils = require("../../solution/ShopDiscount/utils");
38
37
  var import_utils2 = require("../Cart/utils");
39
38
  var import_decimal = __toESM(require("decimal.js"));
@@ -52,7 +51,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
52
51
  }
53
52
  async setRulesList(rulesList) {
54
53
  this.store.rulesList = rulesList;
55
- await this.core.effects.emit(import_types.RulesHooks.OnRulesListChange, rulesList);
54
+ await this.core.effects.emit(`${this.name}:onRulesListChange`, rulesList);
56
55
  }
57
56
  getRulesList() {
58
57
  return this.store.rulesList;
@@ -489,7 +488,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
489
488
  }
490
489
  async destroy() {
491
490
  this.core.effects.offByModuleDestroy(this.name);
492
- await this.core.effects.emit(import_types.RulesHooks.OnDestroy, {});
491
+ await this.core.effects.emit(`${this.name}:onDestroy`, {});
493
492
  console.log("[Rules] 已销毁");
494
493
  }
495
494
  async clear() {
@@ -116,7 +116,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
116
116
  }
117
117
  });
118
118
  this.store.schedule.loadAllSchedule();
119
- this.core.effects.emit(import_types.BookingByStepHooks.onInited, {});
119
+ this.core.effects.emit(`${this.name}:onInited`, {});
120
120
  }
121
121
  // 初始化step
122
122
  initStep(stepList) {
@@ -22,6 +22,10 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
22
22
  * @returns 商品列表
23
23
  */
24
24
  loadProducts(params?: ILoadProductsParams): Promise<any>;
25
+ /**
26
+ * 初始化外设扫码结果监听
27
+ */
28
+ initPeripheralsListener(): void;
25
29
  /**
26
30
  * 获取商品列表(不加载到模块中)
27
31
  * @returns 商品列表
@@ -99,7 +99,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
99
99
  throw new Error(`模块 ${step} 不存在`);
100
100
  }
101
101
  });
102
- this.core.effects.emit(import_types.BookingTicketHooks.onInited, {});
102
+ this.core.effects.emit(`${this.name}:onInited`, {});
103
103
  }
104
104
  /**
105
105
  * 获取商品列表
@@ -115,7 +115,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
115
115
  ...params,
116
116
  cacheId: this.cacheId
117
117
  });
118
- this.core.effects.emit(import_types.BookingTicketHooks.onProductsLoaded, result);
118
+ this.core.effects.emit(`${this.name}:onProductsLoaded`, result);
119
119
  return result;
120
120
  } catch (error) {
121
121
  console.error("Failed to load products:", error);
@@ -149,7 +149,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
149
149
  */
150
150
  setActiveCustomer(customer) {
151
151
  this.store.customer.setSelectedCustomer(customer);
152
- this.core.effects.emit(import_types.BookingTicketHooks.onCustomerSelected, {
152
+ this.core.effects.emit(`${this.name}:onCustomerSelected`, {
153
153
  customer
154
154
  });
155
155
  }
@@ -168,7 +168,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
168
168
  const customer = this.store.customer.getCustomerById(customerId);
169
169
  if (customer) {
170
170
  this.store.customer.setSelectedCustomer(customer);
171
- this.core.effects.emit(import_types.BookingTicketHooks.onCustomerSelected, {
171
+ this.core.effects.emit(`${this.name}:onCustomerSelected`, {
172
172
  customer
173
173
  });
174
174
  }
@@ -248,7 +248,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
248
248
  async loadMoreCustomers() {
249
249
  try {
250
250
  const result = await this.store.customer.loadMoreCustomers();
251
- this.core.effects.emit(import_types.BookingTicketHooks.onCustomerListUpdate, result);
251
+ this.core.effects.emit(`${this.name}:onCustomerListUpdate`, result);
252
252
  return result;
253
253
  } catch (error) {
254
254
  console.error("Failed to load more customers:", error);
@@ -263,7 +263,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
263
263
  async resetAndLoadCustomers(params = {}) {
264
264
  try {
265
265
  const result = await this.store.customer.resetAndLoadCustomers(params);
266
- this.core.effects.emit(import_types.BookingTicketHooks.onCustomerListReset, result);
266
+ this.core.effects.emit(`${this.name}:onCustomerListReset`, result);
267
267
  return result;
268
268
  } catch (error) {
269
269
  console.error("Failed to reset and load customers:", error);
@@ -18,6 +18,10 @@ export default class Scan {
18
18
  private watchKey;
19
19
  private listenerConfig;
20
20
  constructor(solution: BookingTicketImpl, watchKey: string);
21
+ /**
22
+ * 初始化外设扫码结果监听
23
+ */
24
+ initPeripheralsListener(): void;
21
25
  /**
22
26
  * 处理扫码事件
23
27
  * @param eventKey 事件key
@@ -37,9 +37,15 @@ var import_task = __toESM(require("../../../../utils/task"));
37
37
  var Scan = class {
38
38
  constructor(solution, watchKey) {
39
39
  this.listenerConfig = /* @__PURE__ */ new Map();
40
- var _a, _b, _c, _d, _e;
41
40
  this.solution = solution;
42
41
  this.watchKey = watchKey;
42
+ this.initPeripheralsListener();
43
+ }
44
+ /**
45
+ * 初始化外设扫码结果监听
46
+ */
47
+ initPeripheralsListener() {
48
+ var _a, _b, _c, _d, _e;
43
49
  (_e = (_d = (_c = (_b = (_a = this.solution) == null ? void 0 : _a.window) == null ? void 0 : _b.interaction) == null ? void 0 : _c.utils) == null ? void 0 : _d.mountFunction) == null ? void 0 : _e.call(
44
50
  _d,
45
51
  "global",
@@ -24,7 +24,6 @@ __export(BuyTickets_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(BuyTickets_exports);
26
26
  var import_modules = require("../../modules/");
27
- var import_types = require("./types");
28
27
  var import_BaseModule = require("../../modules/BaseModule");
29
28
  __reExport(BuyTickets_exports, require("./types"), module.exports);
30
29
  var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
@@ -49,7 +48,7 @@ var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
49
48
  if (this.otherParams.prodctIds) {
50
49
  await this.loadProductsByIds(this.otherParams.prodctIds);
51
50
  }
52
- await this.core.effects.emit(import_types.BuyTicketsHooks.onInited, {});
51
+ await this.core.effects.emit(`${this.name}:onInited`, {});
53
52
  }
54
53
  // 通过 ids 获取产品,在当前解决方案下,获取到的就是主商品
55
54
  async loadProductsByIds(ids) {
@@ -69,13 +68,13 @@ var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
69
68
  }
70
69
  });
71
70
  this.store.mainProducts = mainProducts;
72
- await this.core.effects.emit(import_types.BuyTicketsHooks.onMainProductsLoaded, {});
71
+ await this.core.effects.emit(`${this.name}:onMainProductsLoaded`, {});
73
72
  }
74
73
  // 通过 ids 获取产品,在当前解决方案下,获取到的就是其他商品
75
74
  async loadProductsByCategory(categoryId) {
76
75
  }
77
76
  async destroy() {
78
- await this.core.effects.emit(import_types.BuyTicketsHooks.onDestroy, {});
77
+ await this.core.effects.emit(`${this.name}:onDestroy`, {});
79
78
  console.log("[BuyTickets] 已销毁");
80
79
  }
81
80
  // 获取当前绑定的所有商品
@@ -83,7 +82,7 @@ var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
83
82
  var _a;
84
83
  const mainData = await this.store.mainProducts.getProducts() || [];
85
84
  const otherData = await ((_a = this.store.otherProducts) == null ? void 0 : _a.getProducts()) || [];
86
- await this.core.effects.emit(import_types.BuyTicketsHooks.OnGetProducts, [
85
+ await this.core.effects.emit(`${this.name}:onGetProducts`, [
87
86
  ...mainData,
88
87
  ...otherData
89
88
  ]);
@@ -102,7 +101,7 @@ var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
102
101
  }
103
102
  // 商品列表页提交
104
103
  async listSubmit(data) {
105
- const res = await this.core.effects.emit(import_types.BuyTicketsHooks.onListSubmit, {
104
+ const res = await this.core.effects.emit(`${this.name}:onListSubmit`, {
106
105
  ...data,
107
106
  products: this.getProducts()
108
107
  });
@@ -116,14 +115,14 @@ var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
116
115
  }
117
116
  // 购物车提交
118
117
  async cartSubmit(data) {
119
- await this.core.effects.emit(import_types.BuyTicketsHooks.onCartSubmit, {
118
+ await this.core.effects.emit(`${this.name}:onCartSubmit`, {
120
119
  ...data,
121
120
  products: this.getProducts()
122
121
  });
123
122
  }
124
123
  // 结算提交
125
124
  async checkoutSubmit(data) {
126
- await this.core.effects.emit(import_types.BuyTicketsHooks.onCheckoutSubmit, {
125
+ await this.core.effects.emit(`${this.name}:onCheckoutSubmit`, {
127
126
  ...data,
128
127
  products: this.getProducts()
129
128
  });