@pisell/pisellos 0.0.324 → 0.0.326

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 (90) hide show
  1. package/dist/effects/index.d.ts +2 -2
  2. package/dist/modules/Account/index.js +2 -3
  3. package/dist/modules/BaseModule.d.ts +3 -0
  4. package/dist/modules/BaseModule.js +15 -0
  5. package/dist/modules/Customer/index.js +9 -10
  6. package/dist/modules/Customer/types.d.ts +1 -1
  7. package/dist/modules/Discount/index.js +1 -1
  8. package/dist/modules/Guests/index.js +9 -9
  9. package/dist/modules/Payment/index.js +18 -18
  10. package/dist/modules/Payment/types.d.ts +7 -7
  11. package/dist/modules/Payment/walletpass.js +4 -1
  12. package/dist/modules/Product/index.d.ts +1 -1
  13. package/dist/modules/ProductList/index.js +2 -3
  14. package/dist/modules/Resource/index.js +1 -1
  15. package/dist/modules/Rules/index.js +2 -3
  16. package/dist/modules/Rules/types.d.ts +1 -1
  17. package/dist/modules/Schedule/type.d.ts +7 -7
  18. package/dist/modules/Schedule/types.d.ts +9 -9
  19. package/dist/solution/BookingByStep/index.d.ts +1 -1
  20. package/dist/solution/BookingByStep/index.js +2 -2
  21. package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
  22. package/dist/solution/BookingTicket/index.js +7 -7
  23. package/dist/solution/BuyTickets/index.js +7 -8
  24. package/dist/solution/Checkout/index.js +29 -29
  25. package/dist/solution/ShopDiscount/index.js +1 -1
  26. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  27. package/dist/types/index.d.ts +1 -1
  28. package/dist/utils/task.d.ts +2 -2
  29. package/dist/utils/watch.d.ts +2 -2
  30. package/lib/core/index.js +28 -27
  31. package/lib/effects/index.d.ts +2 -2
  32. package/lib/effects/index.js +7 -3
  33. package/lib/modules/Account/index.js +12 -12
  34. package/lib/modules/AccountList/index.js +11 -14
  35. package/lib/modules/BaseModule.d.ts +3 -0
  36. package/lib/modules/BaseModule.js +12 -6
  37. package/lib/modules/Cart/index.js +9 -14
  38. package/lib/modules/Cart/utils/cartProduct.js +6 -3
  39. package/lib/modules/Customer/constants.js +1 -1
  40. package/lib/modules/Customer/index.js +24 -28
  41. package/lib/modules/Customer/types.d.ts +1 -1
  42. package/lib/modules/Date/index.js +6 -10
  43. package/lib/modules/Date/types.js +0 -1
  44. package/lib/modules/Discount/index.js +7 -12
  45. package/lib/modules/Guests/index.js +24 -19
  46. package/lib/modules/Order/index.js +9 -11
  47. package/lib/modules/Payment/cash.js +1 -1
  48. package/lib/modules/Payment/cashRecommendationAlgorithm.js +1 -1
  49. package/lib/modules/Payment/eftpos.js +1 -1
  50. package/lib/modules/Payment/index.js +86 -97
  51. package/lib/modules/Payment/types.d.ts +7 -7
  52. package/lib/modules/Payment/utils.js +6 -3
  53. package/lib/modules/Payment/walletpass.js +34 -32
  54. package/lib/modules/Product/index.d.ts +1 -1
  55. package/lib/modules/Product/index.js +5 -6
  56. package/lib/modules/ProductList/index.js +5 -8
  57. package/lib/modules/Resource/index.js +13 -9
  58. package/lib/modules/Rules/index.js +19 -15
  59. package/lib/modules/Rules/types.d.ts +1 -1
  60. package/lib/modules/Schedule/index.js +5 -8
  61. package/lib/modules/Schedule/type.d.ts +7 -7
  62. package/lib/modules/Schedule/types.d.ts +9 -9
  63. package/lib/modules/Schedule/utils.js +4 -2
  64. package/lib/modules/Step/index.js +4 -7
  65. package/lib/modules/Summary/index.js +4 -9
  66. package/lib/plugins/request.js +33 -34
  67. package/lib/plugins/window.js +113 -101
  68. package/lib/solution/BookingByStep/index.d.ts +1 -1
  69. package/lib/solution/BookingByStep/index.js +105 -71
  70. package/lib/solution/BookingByStep/utils/capacity.js +15 -10
  71. package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
  72. package/lib/solution/BookingByStep/utils/resources.js +8 -4
  73. package/lib/solution/BookingByStep/utils/stock.js +6 -3
  74. package/lib/solution/BookingByStep/utils/timeslots.js +27 -24
  75. package/lib/solution/BookingTicket/index.js +20 -25
  76. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +3 -3
  77. package/lib/solution/BookingTicket/utils/scan/handleScan.js +6 -6
  78. package/lib/solution/BookingTicket/utils/scan/index.js +1 -3
  79. package/lib/solution/BookingTicket/utils/scan/scanCache.js +9 -10
  80. package/lib/solution/BuyTickets/index.js +22 -23
  81. package/lib/solution/Checkout/index.js +227 -234
  82. package/lib/solution/Checkout/utils/index.js +22 -18
  83. package/lib/solution/ShopDiscount/index.js +12 -16
  84. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  85. package/lib/types/index.d.ts +1 -1
  86. package/lib/utils/task.d.ts +2 -2
  87. package/lib/utils/task.js +3 -3
  88. package/lib/utils/watch.d.ts +2 -2
  89. package/lib/utils/watch.js +7 -5
  90. package/package.json +1 -1
@@ -46,9 +46,12 @@ var sortUserIdentificationCodeList = (list) => {
46
46
  var _a;
47
47
  const errorCode = (_a = item.unified_error_code) == null ? void 0 : _a.toString();
48
48
  const availableStatus = item.unified_available_status;
49
- if (errorCode && middlePriorityErrorCodes.includes(errorCode)) return 2;
50
- if (availableStatus === 0) return 3;
51
- if (availableStatus === 1) return 1;
49
+ if (errorCode && middlePriorityErrorCodes.includes(errorCode))
50
+ return 2;
51
+ if (availableStatus === 0)
52
+ return 3;
53
+ if (availableStatus === 1)
54
+ return 1;
52
55
  return 0;
53
56
  };
54
57
  const aPriority = getPriority(a);
@@ -27,20 +27,22 @@ var import_utils = require("./utils");
27
27
  var WalletPassPaymentImpl = class {
28
28
  constructor(paymentModule) {
29
29
  this.paymentModule = paymentModule;
30
+ this.walletRecommendList = [];
31
+ this.userIdentificationCodes = [];
32
+ this.searchResults = [];
33
+ this.walletParams = null;
30
34
  }
31
- walletRecommendList = [];
32
- userIdentificationCodes = [];
33
- searchResults = [];
34
- walletParams = null;
35
35
  /**
36
36
  * 发送事件的辅助方法
37
37
  * 支持使用WalletPassHooks或PaymentHooks
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
- this.paymentModule.logError("[WalletPass] \u53D1\u9001\u4E8B\u4EF6\u5931\u8D25", error, { hook });
45
+ this.paymentModule.logError("[WalletPass] 发送事件失败", error, { hook });
44
46
  }
45
47
  }
46
48
  /**
@@ -67,7 +69,7 @@ var WalletPassPaymentImpl = class {
67
69
  payment_order_id
68
70
  };
69
71
  this.walletParams = walletParams;
70
- this.paymentModule.logInfo("[WalletPass] \u94B1\u5305\u9ED8\u8BA4\u53C2\u6570\u5DF2\u751F\u6210\u5E76\u5B58\u50A8", {
72
+ this.paymentModule.logInfo("[WalletPass] 钱包默认参数已生成并存储", {
71
73
  customer_id: walletParams.customer_id,
72
74
  order_expect_amount: walletParams.order_expect_amount,
73
75
  order_product_amount: walletParams.order_product_amount,
@@ -89,7 +91,7 @@ var WalletPassPaymentImpl = class {
89
91
  */
90
92
  clearStoredWalletParams() {
91
93
  this.walletParams = null;
92
- this.paymentModule.logInfo("[WalletPass] \u5DF2\u5B58\u50A8\u7684\u94B1\u5305\u53C2\u6570\u5DF2\u6E05\u7406");
94
+ this.paymentModule.logInfo("[WalletPass] 已存储的钱包参数已清理");
93
95
  }
94
96
  /**
95
97
  * 从业务数据初始化钱包数据
@@ -109,7 +111,7 @@ var WalletPassPaymentImpl = class {
109
111
  businessData,
110
112
  startTime
111
113
  });
112
- this.paymentModule.logInfo("[WalletPass] \u5F00\u59CB\u4ECE\u4E1A\u52A1\u6570\u636E\u521D\u59CB\u5316\u94B1\u5305\u6570\u636E", {
114
+ this.paymentModule.logInfo("[WalletPass] 开始从业务数据初始化钱包数据", {
113
115
  customer_id: businessData.customer_id,
114
116
  totalAmount: (_c = businessData.amountInfo) == null ? void 0 : _c.totalAmount,
115
117
  subTotal: (_d = businessData.amountInfo) == null ? void 0 : _d.subTotal,
@@ -127,7 +129,7 @@ var WalletPassPaymentImpl = class {
127
129
  endTime,
128
130
  duration
129
131
  });
130
- this.paymentModule.logInfo(`[WalletPass] \u4ECE\u4E1A\u52A1\u6570\u636E\u521D\u59CB\u5316\u94B1\u5305\u6570\u636E\u6210\u529F`, {
132
+ this.paymentModule.logInfo(`[WalletPass] 从业务数据初始化钱包数据成功`, {
131
133
  duration: `${duration}ms`,
132
134
  walletRecommendList_count: ((_f = result.walletRecommendList) == null ? void 0 : _f.length) || 0,
133
135
  userIdentificationCodes_count: ((_g = result.userIdentificationCodes) == null ? void 0 : _g.length) || 0
@@ -143,7 +145,7 @@ var WalletPassPaymentImpl = class {
143
145
  endTime,
144
146
  duration
145
147
  });
146
- this.paymentModule.logError(`[WalletPass] \u4ECE\u4E1A\u52A1\u6570\u636E\u521D\u59CB\u5316\u94B1\u5305\u6570\u636E\u5931\u8D25`, error, {
148
+ this.paymentModule.logError(`[WalletPass] 从业务数据初始化钱包数据失败`, error, {
147
149
  duration: `${duration}ms`,
148
150
  customer_id: businessData.customer_id,
149
151
  totalAmount: (_h = businessData.amountInfo) == null ? void 0 : _h.totalAmount
@@ -171,7 +173,7 @@ var WalletPassPaymentImpl = class {
171
173
  userIdentificationCodes
172
174
  };
173
175
  } catch (error) {
174
- this.paymentModule.logError("[WalletPass] \u521D\u59CB\u5316\u94B1\u5305\u6570\u636E\u5931\u8D25", error, {
176
+ this.paymentModule.logError("[WalletPass] 初始化钱包数据失败", error, {
175
177
  customer_id: baseParams.customer_id,
176
178
  order_expect_amount: baseParams.order_expect_amount
177
179
  });
@@ -181,7 +183,7 @@ var WalletPassPaymentImpl = class {
181
183
  async getWalletPassRecommendListAsync(params) {
182
184
  var _a;
183
185
  try {
184
- this.paymentModule.logInfo("[WalletPass] \u5F00\u59CB\u83B7\u53D6\u94B1\u5305\u63A8\u8350\u5217\u8868", {
186
+ this.paymentModule.logInfo("[WalletPass] 开始获取钱包推荐列表", {
185
187
  customer_id: params.customer_id,
186
188
  order_expect_amount: params.order_expect_amount,
187
189
  sale_channel: params.sale_channel,
@@ -196,7 +198,7 @@ var WalletPassPaymentImpl = class {
196
198
  this.emitEvent(import_types.WalletPassHooks.OnWalletRecommendListUpdated, {
197
199
  walletRecommendList: this.walletRecommendList
198
200
  });
199
- this.paymentModule.logInfo("[WalletPass] \u94B1\u5305\u63A8\u8350\u5217\u8868\u5DF2\u66F4\u65B0", {
201
+ this.paymentModule.logInfo("[WalletPass] 钱包推荐列表已更新", {
200
202
  count: this.walletRecommendList.length,
201
203
  items: this.walletRecommendList.map((item) => ({
202
204
  voucher_id: item.voucher_id,
@@ -207,7 +209,7 @@ var WalletPassPaymentImpl = class {
207
209
  });
208
210
  return this.walletRecommendList;
209
211
  } catch (error) {
210
- this.paymentModule.logError("[WalletPass] \u83B7\u53D6\u94B1\u5305\u63A8\u8350\u5217\u8868\u5931\u8D25", error, {
212
+ this.paymentModule.logError("[WalletPass] 获取钱包推荐列表失败", error, {
211
213
  customer_id: params.customer_id,
212
214
  order_expect_amount: params.order_expect_amount,
213
215
  sale_channel: params.sale_channel
@@ -225,7 +227,7 @@ var WalletPassPaymentImpl = class {
225
227
  ...this.walletParams,
226
228
  ...params
227
229
  };
228
- this.paymentModule.logInfo("[WalletPass] \u5F00\u59CB\u83B7\u53D6\u7528\u6237\u8BC6\u522B\u7801\u5217\u8868", {
230
+ this.paymentModule.logInfo("[WalletPass] 开始获取用户识别码列表", {
229
231
  customer_id: newParams.customer_id,
230
232
  available: newParams.available,
231
233
  prepare_payments_count: ((_a = newParams.prepare_payments) == null ? void 0 : _a.length) || 0,
@@ -241,7 +243,7 @@ var WalletPassPaymentImpl = class {
241
243
  this.emitEvent(import_types.WalletPassHooks.OnUserIdentificationCodesUpdated, {
242
244
  userIdentificationCodes: this.userIdentificationCodes
243
245
  });
244
- this.paymentModule.logInfo("[WalletPass] \u7528\u6237\u8BC6\u522B\u7801\u5217\u8868\u5DF2\u66F4\u65B0", {
246
+ this.paymentModule.logInfo("[WalletPass] 用户识别码列表已更新", {
245
247
  count: this.userIdentificationCodes.length,
246
248
  sorted_items: this.userIdentificationCodes.slice(0, 5).map((item) => ({
247
249
  code: item.code,
@@ -251,7 +253,7 @@ var WalletPassPaymentImpl = class {
251
253
  });
252
254
  return this.userIdentificationCodes;
253
255
  } catch (error) {
254
- this.paymentModule.logError("[WalletPass] \u83B7\u53D6\u7528\u6237\u8BC6\u522B\u7801\u5217\u8868\u5931\u8D25", error, {
256
+ this.paymentModule.logError("[WalletPass] 获取用户识别码列表失败", error, {
255
257
  customer_id: params.customer_id,
256
258
  available: params.available
257
259
  });
@@ -267,7 +269,7 @@ var WalletPassPaymentImpl = class {
267
269
  async searchIdentificationCodeAsync(params, config = {}) {
268
270
  try {
269
271
  const { code } = params;
270
- this.paymentModule.logInfo("[WalletPass] \u5F00\u59CB\u641C\u7D22\u8BC6\u522B\u7801", {
272
+ this.paymentModule.logInfo("[WalletPass] 开始搜索识别码", {
271
273
  code,
272
274
  code_length: code.length,
273
275
  noCache: config.noCache || false
@@ -279,7 +281,7 @@ var WalletPassPaymentImpl = class {
279
281
  with_customer: 1,
280
282
  with: ["wallet"]
281
283
  };
282
- this.paymentModule.logInfo("[WalletPass] \u641C\u7D22\u94B1\u5305\u8BC6\u522B\u7801", {
284
+ this.paymentModule.logInfo("[WalletPass] 搜索钱包识别码", {
283
285
  code,
284
286
  with_customer: walletDetailParams.with_customer,
285
287
  with: walletDetailParams.with
@@ -289,7 +291,7 @@ var WalletPassPaymentImpl = class {
289
291
  walletDetailParams
290
292
  );
291
293
  const searchResults2 = (response2 == null ? void 0 : response2.data) || [];
292
- this.paymentModule.logInfo("[WalletPass] \u94B1\u5305\u8BC6\u522B\u7801\u641C\u7D22\u5B8C\u6210", {
294
+ this.paymentModule.logInfo("[WalletPass] 钱包识别码搜索完成", {
293
295
  code,
294
296
  results_count: searchResults2.length,
295
297
  type: "walletCode"
@@ -315,7 +317,7 @@ var WalletPassPaymentImpl = class {
315
317
  code: params.code,
316
318
  payment_order_id: baseWalletParams == null ? void 0 : baseWalletParams.payment_order_id
317
319
  };
318
- this.paymentModule.logInfo("[WalletPass] \u641C\u7D22\u666E\u901A\u8BC6\u522B\u7801", {
320
+ this.paymentModule.logInfo("[WalletPass] 搜索普通识别码", {
319
321
  code: searchParams.code,
320
322
  customer_id: searchParams.customer_id,
321
323
  order_expect_amount: searchParams.order_expect_amount,
@@ -348,7 +350,7 @@ var WalletPassPaymentImpl = class {
348
350
  cachedSearchResults: [...this.searchResults],
349
351
  searchParams: params
350
352
  });
351
- this.paymentModule.logInfo("[WalletPass] \u666E\u901A\u8BC6\u522B\u7801\u641C\u7D22\u5B8C\u6210", {
353
+ this.paymentModule.logInfo("[WalletPass] 普通识别码搜索完成", {
352
354
  code: params.code,
353
355
  results_count: searchResults.length,
354
356
  cached_results_count: this.searchResults.length,
@@ -359,7 +361,7 @@ var WalletPassPaymentImpl = class {
359
361
  data: searchResults
360
362
  };
361
363
  } catch (error) {
362
- this.paymentModule.logError("[WalletPass] \u641C\u7D22\u8BC6\u522B\u7801\u4FE1\u606F\u5931\u8D25", error, {
364
+ this.paymentModule.logError("[WalletPass] 搜索识别码信息失败", error, {
363
365
  code: params.code,
364
366
  customer_id: params.customer_id,
365
367
  order_expect_amount: params.order_expect_amount
@@ -368,19 +370,19 @@ var WalletPassPaymentImpl = class {
368
370
  }
369
371
  }
370
372
  async processWalletPayment(amount, orderUuid, voucherId) {
371
- this.paymentModule.logInfo("[WalletPass] \u5F00\u59CB\u5904\u7406\u94B1\u5305\u652F\u4ED8", {
373
+ this.paymentModule.logInfo("[WalletPass] 开始处理钱包支付", {
372
374
  amount,
373
375
  orderUuid,
374
376
  voucherId: voucherId || "none"
375
377
  });
376
378
  const walletMethod = await this.paymentModule.getWalletPaymentMethod();
377
379
  if (!walletMethod) {
378
- this.paymentModule.logError("[WalletPass] \u94B1\u5305\u652F\u4ED8\u65B9\u5F0F\u672A\u627E\u5230", null, {
380
+ this.paymentModule.logError("[WalletPass] 钱包支付方式未找到", null, {
379
381
  amount,
380
382
  orderUuid,
381
383
  voucherId
382
384
  });
383
- throw new Error("\u94B1\u5305\u652F\u4ED8\u65B9\u5F0F\u672A\u627E\u5230");
385
+ throw new Error("钱包支付方式未找到");
384
386
  }
385
387
  const paymentItem = {
386
388
  amount: amount.toString(),
@@ -391,7 +393,7 @@ var WalletPassPaymentImpl = class {
391
393
  voucher_id: voucherId || ""
392
394
  };
393
395
  await this.paymentModule.addPaymentItemAsync(orderUuid, paymentItem);
394
- this.paymentModule.logInfo("[WalletPass] \u94B1\u5305\u652F\u4ED8\u5904\u7406\u5B8C\u6210", {
396
+ this.paymentModule.logInfo("[WalletPass] 钱包支付处理完成", {
395
397
  amount,
396
398
  orderUuid,
397
399
  voucherId: voucherId || "none",
@@ -421,7 +423,7 @@ var WalletPassPaymentImpl = class {
421
423
  this.emitEvent(import_types.WalletPassHooks.OnWalletRecommendListCleared, {
422
424
  clearedTypes: ["walletRecommendList"]
423
425
  });
424
- this.paymentModule.logInfo("[WalletPass] \u94B1\u5305\u63A8\u8350\u5217\u8868\u5DF2\u6E05\u9664");
426
+ this.paymentModule.logInfo("[WalletPass] 钱包推荐列表已清除");
425
427
  }
426
428
  /**
427
429
  * 清除用户识别码列表
@@ -431,7 +433,7 @@ var WalletPassPaymentImpl = class {
431
433
  this.emitEvent(import_types.WalletPassHooks.OnUserIdentificationCodesCleared, {
432
434
  clearedTypes: ["userIdentificationCodes"]
433
435
  });
434
- this.paymentModule.logInfo("[WalletPass] \u7528\u6237\u8BC6\u522B\u7801\u5217\u8868\u5DF2\u6E05\u9664");
436
+ this.paymentModule.logInfo("[WalletPass] 用户识别码列表已清除");
435
437
  }
436
438
  /**
437
439
  * 获取缓存的搜索结果列表
@@ -450,7 +452,7 @@ var WalletPassPaymentImpl = class {
450
452
  */
451
453
  clearSearchResults() {
452
454
  this.searchResults = [];
453
- this.paymentModule.logInfo("[WalletPass] \u641C\u7D22\u7ED3\u679C\u7F13\u5B58\u5DF2\u6E05\u9664");
455
+ this.paymentModule.logInfo("[WalletPass] 搜索结果缓存已清除");
454
456
  }
455
457
  /**
456
458
  * 清除所有缓存数据
@@ -463,7 +465,7 @@ var WalletPassPaymentImpl = class {
463
465
  this.emitEvent(import_types.WalletPassHooks.OnWalletCacheCleared, {
464
466
  clearedTypes: ["all"]
465
467
  });
466
- this.paymentModule.logInfo("[WalletPass] \u6240\u6709\u7F13\u5B58\u6570\u636E\u5DF2\u6E05\u9664", {
468
+ this.paymentModule.logInfo("[WalletPass] 所有缓存数据已清除", {
467
469
  cleared_types: ["walletRecommendList", "userIdentificationCodes", "searchResults", "walletParams"]
468
470
  });
469
471
  }
@@ -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
  }
@@ -26,14 +26,13 @@ module.exports = __toCommonJS(Product_exports);
26
26
  var import_BaseModule = require("../BaseModule");
27
27
  __reExport(Product_exports, require("./types"), module.exports);
28
28
  var Product = class extends import_BaseModule.BaseModule {
29
- defaultName = "product";
30
- defaultVersion = "1.0.0";
31
- store;
32
- otherParams = {
33
- scheduler: []
34
- };
35
29
  constructor(name, version) {
36
30
  super(name, version);
31
+ this.defaultName = "product";
32
+ this.defaultVersion = "1.0.0";
33
+ this.otherParams = {
34
+ scheduler: []
35
+ };
37
36
  }
38
37
  async initialize(core, options) {
39
38
  this.core = core;
@@ -24,17 +24,14 @@ __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 {
31
- defaultName = "productList";
32
- defaultVersion = "1.0.0";
33
- store;
34
- request;
35
- otherParams = {};
36
30
  constructor(name, version) {
37
31
  super(name, version);
32
+ this.defaultName = "productList";
33
+ this.defaultVersion = "1.0.0";
34
+ this.otherParams = {};
38
35
  }
39
36
  async initialize(core, options) {
40
37
  var _a;
@@ -129,14 +126,14 @@ var ProductList = class extends import_BaseModule.BaseModule {
129
126
  }
130
127
  async getProducts() {
131
128
  await this.core.effects.emit(
132
- import_types.ProductListHooks.onGetProducts,
129
+ `${this.name}:onGetProducts`,
133
130
  this.store.list
134
131
  );
135
132
  return (0, import_lodash_es.cloneDeep)(this.store.list);
136
133
  }
137
134
  async getProduct(id) {
138
135
  await this.core.effects.emit(
139
- import_types.ProductListHooks.onGetProduct,
136
+ `${this.name}:onGetProduct`,
140
137
  this.store.list
141
138
  );
142
139
  const product = this.store.list.find((product2) => product2.id === id);
@@ -25,11 +25,10 @@ module.exports = __toCommonJS(Resource_exports);
25
25
  var import_BaseModule = require("../BaseModule");
26
26
  var import_types = require("./types");
27
27
  var ResourceListModule = class extends import_BaseModule.BaseModule {
28
- defaultName = "resourceList";
29
- defaultVersion = "1.0.0";
30
- store;
31
28
  constructor(name, version) {
32
29
  super(name, version);
30
+ this.defaultName = "resourceList";
31
+ this.defaultVersion = "1.0.0";
33
32
  }
34
33
  async initialize(core, options) {
35
34
  this.core = core;
@@ -40,28 +39,32 @@ var ResourceListModule = class extends import_BaseModule.BaseModule {
40
39
  }
41
40
  async selectResource(resourceId) {
42
41
  const resource = this.store.list.find((r) => r.id === resourceId);
43
- if (!resource) return;
42
+ if (!resource)
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;
49
49
  }
50
50
  async checkAvailability(resourceId, start, end) {
51
51
  const resource = this.store.list.find((r) => r.id === resourceId);
52
- if (!resource) return false;
52
+ if (!resource)
53
+ return false;
53
54
  return resource.timeSlots.some(
54
55
  (slot) => slot.start.getTime() <= start.getTime() && slot.end.getTime() >= end.getTime() && slot.availableCapacity > 0
55
56
  );
56
57
  }
57
58
  async getAvailableTimeSlots(resourceId) {
58
59
  const resource = this.store.list.find((r) => r.id === resourceId);
59
- if (!resource) return [];
60
+ if (!resource)
61
+ return [];
60
62
  return resource.timeSlots.filter((slot) => slot.availableCapacity > 0);
61
63
  }
62
64
  getAvailableCapacity(resourceId, timeSlot) {
63
65
  const resource = this.store.list.find((r) => r.id === resourceId);
64
- if (!resource) return 0;
66
+ if (!resource)
67
+ return 0;
65
68
  const slot = resource.timeSlots.find(
66
69
  (s) => s.start.getTime() === timeSlot.start.getTime() && s.end.getTime() === timeSlot.end.getTime()
67
70
  );
@@ -69,7 +72,8 @@ var ResourceListModule = class extends import_BaseModule.BaseModule {
69
72
  }
70
73
  async updateResource(resourceId, updates) {
71
74
  const index = this.store.list.findIndex((r) => r.id === resourceId);
72
- if (index === -1) return;
75
+ if (index === -1)
76
+ return;
73
77
  this.store.list[index] = {
74
78
  ...this.store.list[index],
75
79
  ...updates
@@ -33,18 +33,15 @@ __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"));
40
39
  var import_lodash_es = require("lodash-es");
41
40
  var RulesModule = class extends import_BaseModule.BaseModule {
42
- defaultName = "rules";
43
- defaultVersion = "1.0.0";
44
- store;
45
- hooks;
46
41
  constructor(name, version) {
47
42
  super(name, version);
43
+ this.defaultName = "rules";
44
+ this.defaultVersion = "1.0.0";
48
45
  this.hooks = {};
49
46
  }
50
47
  async initialize(core, options) {
@@ -54,7 +51,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
54
51
  }
55
52
  async setRulesList(rulesList) {
56
53
  this.store.rulesList = rulesList;
57
- await this.core.effects.emit(import_types.RulesHooks.OnRulesListChange, rulesList);
54
+ await this.core.effects.emit(`${this.name}:onRulesListChange`, rulesList);
58
55
  }
59
56
  getRulesList() {
60
57
  return this.store.rulesList;
@@ -135,15 +132,19 @@ var RulesModule = class extends import_BaseModule.BaseModule {
135
132
  });
136
133
  const sortedDiscountList = [...filteredDiscountList].sort((a, b) => {
137
134
  var _a, _b;
138
- if (a.tag === "good_pass" && b.tag !== "good_pass") return -1;
139
- if (b.tag === "good_pass" && a.tag !== "good_pass") return 1;
135
+ if (a.tag === "good_pass" && b.tag !== "good_pass")
136
+ return -1;
137
+ if (b.tag === "good_pass" && a.tag !== "good_pass")
138
+ return 1;
140
139
  if (a.tag === "good_pass" && b.tag === "good_pass") {
141
140
  return compareByExpireTime(a, b);
142
141
  } else if (a.tag === "product_discount_card" && b.tag === "product_discount_card") {
143
142
  const typeA = ((_a = a.metadata) == null ? void 0 : _a.discount_card_type) || "percent";
144
143
  const typeB = ((_b = b.metadata) == null ? void 0 : _b.discount_card_type) || "percent";
145
- if (typeA === "fixed_amount" && typeB === "percent") return -1;
146
- if (typeA === "percent" && typeB === "fixed_amount") return 1;
144
+ if (typeA === "fixed_amount" && typeB === "percent")
145
+ return -1;
146
+ if (typeA === "percent" && typeB === "fixed_amount")
147
+ return 1;
147
148
  if (typeA === "fixed_amount" && typeB === "fixed_amount") {
148
149
  if (a.par_value !== b.par_value) {
149
150
  const valueA = new import_decimal.default(a.par_value || 0);
@@ -236,13 +237,16 @@ var RulesModule = class extends import_BaseModule.BaseModule {
236
237
  }
237
238
  const applicableDiscounts = sortedDiscountList.filter((discount) => {
238
239
  var _a2;
239
- if ((Number(product.price) <= 0 || !product.price) && (discount.tag || discount.type) === "good_pass") return false;
240
+ if ((Number(product.price) <= 0 || !product.price) && (discount.tag || discount.type) === "good_pass")
241
+ return false;
240
242
  if ((Number(product.total) <= 0 || !product.total) && !((_a2 = product.discount_list) == null ? void 0 : _a2.find((n) => {
241
243
  var _a3;
242
244
  return ((_a3 = n.discount) == null ? void 0 : _a3.resource_id) === discount.id;
243
- })) && (discount.tag || discount.type) !== "good_pass") return false;
245
+ })) && (discount.tag || discount.type) !== "good_pass")
246
+ return false;
244
247
  const targetUsedDiscounts = usedDiscounts.get(discount.id);
245
- if (targetUsedDiscounts && (discount.tag || discount.type) === "good_pass") return false;
248
+ if (targetUsedDiscounts && (discount.tag || discount.type) === "good_pass")
249
+ return false;
246
250
  const limitedData = discount.limited_relation_product_data;
247
251
  if (limitedData.type === "product_all") {
248
252
  return true;
@@ -484,8 +488,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
484
488
  }
485
489
  async destroy() {
486
490
  this.core.effects.offByModuleDestroy(this.name);
487
- await this.core.effects.emit(import_types.RulesHooks.OnDestroy, {});
488
- console.log("[Rules] \u5DF2\u9500\u6BC1");
491
+ await this.core.effects.emit(`${this.name}:onDestroy`, {});
492
+ console.log("[Rules] 已销毁");
489
493
  }
490
494
  async clear() {
491
495
  console.log("[Rules] clear");
@@ -24,7 +24,7 @@ export interface RulesModuleAPI {
24
24
  productList: any[];
25
25
  }) => DiscountResult;
26
26
  }
27
- declare type ProductDetail = {
27
+ type ProductDetail = {
28
28
  isClient?: boolean;
29
29
  isManualDiscount?: boolean;
30
30
  booking_id: any;
@@ -42,22 +42,19 @@ var import_utils2 = require("./utils");
42
42
  import_dayjs.default.extend(import_isSameOrBefore.default);
43
43
  import_dayjs.default.extend(import_isSameOrAfter.default);
44
44
  var ScheduleModule = class extends import_BaseModule.BaseModule {
45
- defaultName = "schedule";
46
- defaultVersion = "1.0.0";
47
- request;
48
- store = {};
49
- cacheId;
50
- openCache = false;
51
- fatherModule;
52
45
  constructor(name, version) {
53
46
  super(name, version);
47
+ this.defaultName = "schedule";
48
+ this.defaultVersion = "1.0.0";
49
+ this.store = {};
50
+ this.openCache = false;
54
51
  }
55
52
  async initialize(core, options) {
56
53
  var _a, _b;
57
54
  this.core = core;
58
55
  this.request = core.getPlugin("request");
59
56
  if (!this.request) {
60
- throw new Error("ScheduleModule \u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
57
+ throw new Error("ScheduleModule 需要 request 插件支持");
61
58
  }
62
59
  this.store = options == null ? void 0 : options.store;
63
60
  if (options.initialState) {
@@ -1,4 +1,4 @@
1
- export declare type ScheduleItem = {
1
+ export type ScheduleItem = {
2
2
  /** 颜色 */
3
3
  color: string;
4
4
  /** 创建时间 */
@@ -65,7 +65,7 @@ export declare type ScheduleItem = {
65
65
  schedule_id: number;
66
66
  }[];
67
67
  };
68
- export declare type ScheduleFormOtherValue = {
68
+ export type ScheduleFormOtherValue = {
69
69
  /** 截止模式
70
70
  * 1: 永不截止
71
71
  * 2: 按日期截止
@@ -79,11 +79,11 @@ export declare type ScheduleFormOtherValue = {
79
79
  includeStatus: boolean;
80
80
  type: 'standard' | 'time-slots' | 'designation';
81
81
  };
82
- export declare type ExcIncDate = {
82
+ export type ExcIncDate = {
83
83
  start: string;
84
84
  end: string;
85
85
  };
86
- export declare type ScheduleFormData = {
86
+ export type ScheduleFormData = {
87
87
  /** 颜色 */
88
88
  color: string;
89
89
  /** 日程名称 */
@@ -131,20 +131,20 @@ export declare type ScheduleFormData = {
131
131
  start_time: any;
132
132
  end_time: any;
133
133
  };
134
- export declare type CalendarDataItem = {
134
+ export type CalendarDataItem = {
135
135
  date: string;
136
136
  color: string[];
137
137
  isExcluded: boolean;
138
138
  schedule_ids?: number[];
139
139
  [key: string]: any;
140
140
  };
141
- export declare type RequestData<Data> = {
141
+ export type RequestData<Data> = {
142
142
  data: Data;
143
143
  status: boolean;
144
144
  message: string;
145
145
  code: number;
146
146
  };
147
- export declare type ResponseListData<Data> = {
147
+ export type ResponseListData<Data> = {
148
148
  status: boolean;
149
149
  message: string;
150
150
  code: number;
@@ -4,7 +4,7 @@ export interface ScheduleState {
4
4
  availabilityDateList: ScheduleAvailabilityDateItem[];
5
5
  otherProductsIds: number[];
6
6
  }
7
- export declare type ScheduleAvailabilityDateItem = {
7
+ export type ScheduleAvailabilityDateItem = {
8
8
  date: string;
9
9
  schedule_id: number[];
10
10
  product_ids: number[];
@@ -24,7 +24,7 @@ export interface LoadScheduleAvailableDateParams {
24
24
  }
25
25
  export interface ScheduleModuleAPI {
26
26
  }
27
- export declare type ScheduleItem = {
27
+ export type ScheduleItem = {
28
28
  /** 颜色 */
29
29
  color: string;
30
30
  /** 创建时间 */
@@ -91,7 +91,7 @@ export declare type ScheduleItem = {
91
91
  schedule_id: number;
92
92
  }[];
93
93
  };
94
- export declare type ScheduleFormOtherValue = {
94
+ export type ScheduleFormOtherValue = {
95
95
  /** 截止模式
96
96
  * 1: 永不截止
97
97
  * 2: 按日期截止
@@ -105,11 +105,11 @@ export declare type ScheduleFormOtherValue = {
105
105
  includeStatus: boolean;
106
106
  type: 'standard' | 'time-slots' | 'designation';
107
107
  };
108
- export declare type ExcIncDate = {
108
+ export type ExcIncDate = {
109
109
  start: string;
110
110
  end: string;
111
111
  };
112
- export declare type ScheduleFormData = {
112
+ export type ScheduleFormData = {
113
113
  /** 颜色 */
114
114
  color: string;
115
115
  /** 日程名称 */
@@ -157,20 +157,20 @@ export declare type ScheduleFormData = {
157
157
  start_time: any;
158
158
  end_time: any;
159
159
  };
160
- export declare type CalendarDataItem = {
160
+ export type CalendarDataItem = {
161
161
  date: string;
162
162
  color: string[];
163
163
  isExcluded: boolean;
164
164
  schedule_ids?: number[];
165
165
  [key: string]: any;
166
166
  };
167
- export declare type RequestData<Data> = {
167
+ export type RequestData<Data> = {
168
168
  data: Data;
169
169
  status: boolean;
170
170
  message: string;
171
171
  code: number;
172
172
  };
173
- export declare type ResponseListData<Data> = {
173
+ export type ResponseListData<Data> = {
174
174
  status: boolean;
175
175
  message: string;
176
176
  code: number;
@@ -181,7 +181,7 @@ export declare type ResponseListData<Data> = {
181
181
  skip: number;
182
182
  };
183
183
  };
184
- export declare type ScheduleAllMap = Record<string, {
184
+ export type ScheduleAllMap = Record<string, {
185
185
  minTime: dayjs.Dayjs | null;
186
186
  maxTime: dayjs.Dayjs | null;
187
187
  minTimeStr: string | null;
@@ -346,7 +346,8 @@ var calcCalendarDataByTimeSlots = (values, others, isGetRange) => {
346
346
  time_slot
347
347
  } = values;
348
348
  const { endRadio, excludedStatus, includeStatus } = others;
349
- if (!start_time) return [];
349
+ if (!start_time)
350
+ return [];
350
351
  const start = (0, import_dayjs.default)(start_time);
351
352
  const end = (0, import_dayjs.default)(start_time);
352
353
  return processDateRange(
@@ -580,7 +581,8 @@ function getAllSortedDateRanges(schedules) {
580
581
  }
581
582
  let sortedDateRanges = allDateRanges.sort((a, b) => {
582
583
  const startTimeCompare = (0, import_dayjs.default)(a.start).valueOf() - (0, import_dayjs.default)(b.start).valueOf();
583
- if (startTimeCompare !== 0) return startTimeCompare;
584
+ if (startTimeCompare !== 0)
585
+ return startTimeCompare;
584
586
  const durationA = (0, import_dayjs.default)(a.end).valueOf() - (0, import_dayjs.default)(a.start).valueOf();
585
587
  const durationB = (0, import_dayjs.default)(b.end).valueOf() - (0, import_dayjs.default)(b.start).valueOf();
586
588
  return durationA - durationB;