@pisell/pisellos 2.1.100 → 2.1.101

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 (80) hide show
  1. package/dist/effects/index.d.ts +2 -2
  2. package/dist/modules/Customer/types.d.ts +1 -1
  3. package/dist/modules/Payment/types.d.ts +7 -7
  4. package/dist/modules/Rules/types.d.ts +1 -1
  5. package/dist/modules/Schedule/getDateIsInSchedule.d.ts +1 -1
  6. package/dist/modules/Schedule/type.d.ts +7 -7
  7. package/dist/modules/Schedule/types.d.ts +9 -9
  8. package/dist/solution/BookingByStep/index.d.ts +1 -1
  9. package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
  10. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  11. package/dist/solution/ShopDiscount/utils.d.ts +2 -2
  12. package/dist/types/index.d.ts +1 -1
  13. package/dist/utils/task.d.ts +2 -2
  14. package/dist/utils/watch.d.ts +2 -2
  15. package/lib/core/index.js +28 -27
  16. package/lib/effects/index.d.ts +2 -2
  17. package/lib/effects/index.js +7 -3
  18. package/lib/modules/Account/index.js +10 -9
  19. package/lib/modules/AccountList/index.js +11 -14
  20. package/lib/modules/BaseModule.js +3 -6
  21. package/lib/modules/Cart/index.js +9 -14
  22. package/lib/modules/Cart/utils/cartProduct.js +6 -3
  23. package/lib/modules/Customer/constants.js +1 -1
  24. package/lib/modules/Customer/index.js +15 -18
  25. package/lib/modules/Customer/types.d.ts +1 -1
  26. package/lib/modules/Date/index.js +6 -10
  27. package/lib/modules/Date/types.js +0 -1
  28. package/lib/modules/Discount/index.js +6 -11
  29. package/lib/modules/Guests/index.js +15 -10
  30. package/lib/modules/Order/index.js +7 -10
  31. package/lib/modules/Payment/cash.js +1 -1
  32. package/lib/modules/Payment/cashRecommendationAlgorithm.js +1 -1
  33. package/lib/modules/Payment/eftpos.js +1 -1
  34. package/lib/modules/Payment/index.js +73 -84
  35. package/lib/modules/Payment/types.d.ts +7 -7
  36. package/lib/modules/Payment/utils.js +6 -3
  37. package/lib/modules/Payment/walletpass.js +31 -31
  38. package/lib/modules/Product/index.js +5 -6
  39. package/lib/modules/ProductList/index.js +3 -5
  40. package/lib/modules/Resource/index.js +12 -8
  41. package/lib/modules/Rules/index.js +35 -21
  42. package/lib/modules/Rules/types.d.ts +1 -1
  43. package/lib/modules/Schedule/getDateIsInSchedule.d.ts +1 -1
  44. package/lib/modules/Schedule/index.js +5 -8
  45. package/lib/modules/Schedule/type.d.ts +7 -7
  46. package/lib/modules/Schedule/types.d.ts +9 -9
  47. package/lib/modules/Schedule/utils.js +4 -2
  48. package/lib/modules/Step/index.js +4 -7
  49. package/lib/modules/Summary/index.js +4 -9
  50. package/lib/modules/Summary/utils.js +16 -8
  51. package/lib/plugins/request.js +33 -34
  52. package/lib/plugins/window.js +113 -101
  53. package/lib/solution/BookingByStep/index.d.ts +1 -1
  54. package/lib/solution/BookingByStep/index.js +177 -110
  55. package/lib/solution/BookingByStep/utils/capacity.js +16 -11
  56. package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
  57. package/lib/solution/BookingByStep/utils/resources.js +8 -4
  58. package/lib/solution/BookingByStep/utils/stock.js +6 -3
  59. package/lib/solution/BookingByStep/utils/timeslots.js +27 -24
  60. package/lib/solution/BookingTicket/index.js +14 -19
  61. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +3 -3
  62. package/lib/solution/BookingTicket/utils/scan/handleScan.js +6 -6
  63. package/lib/solution/BookingTicket/utils/scan/index.js +1 -3
  64. package/lib/solution/BookingTicket/utils/scan/scanCache.js +9 -10
  65. package/lib/solution/BuyTickets/index.js +15 -15
  66. package/lib/solution/Checkout/index.js +211 -216
  67. package/lib/solution/Checkout/utils/index.js +22 -18
  68. package/lib/solution/RegisterAndLogin/config.js +2 -2
  69. package/lib/solution/RegisterAndLogin/index.js +110 -114
  70. package/lib/solution/RegisterAndLogin/utils.js +9 -9
  71. package/lib/solution/ShopDiscount/index.js +13 -16
  72. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  73. package/lib/solution/ShopDiscount/utils.d.ts +2 -2
  74. package/lib/solution/ShopDiscount/utils.js +2 -1
  75. package/lib/types/index.d.ts +1 -1
  76. package/lib/utils/task.d.ts +2 -2
  77. package/lib/utils/task.js +3 -3
  78. package/lib/utils/watch.d.ts +2 -2
  79. package/lib/utils/watch.js +7 -5
  80. package/package.json +17 -16
@@ -27,11 +27,11 @@ 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
@@ -42,7 +42,7 @@ var WalletPassPaymentImpl = class {
42
42
  const fullEventName = `${this.paymentModule.name}:${eventName}`;
43
43
  this.paymentModule.core.effects.emit(fullEventName, data);
44
44
  } catch (error) {
45
- this.paymentModule.logError("[WalletPass] \u53D1\u9001\u4E8B\u4EF6\u5931\u8D25", error, { hook });
45
+ this.paymentModule.logError("[WalletPass] 发送事件失败", error, { hook });
46
46
  }
47
47
  }
48
48
  /**
@@ -77,7 +77,7 @@ var WalletPassPaymentImpl = class {
77
77
  payment_order_id
78
78
  };
79
79
  this.walletParams = walletParams;
80
- this.paymentModule.logInfo("[WalletPass] \u94B1\u5305\u9ED8\u8BA4\u53C2\u6570\u5DF2\u751F\u6210\u5E76\u5B58\u50A8", {
80
+ this.paymentModule.logInfo("[WalletPass] 钱包默认参数已生成并存储", {
81
81
  customer_id: walletParams.customer_id,
82
82
  order_expect_amount: walletParams.order_expect_amount,
83
83
  order_product_amount: walletParams.order_product_amount,
@@ -99,7 +99,7 @@ var WalletPassPaymentImpl = class {
99
99
  */
100
100
  clearStoredWalletParams() {
101
101
  this.walletParams = null;
102
- this.paymentModule.logInfo("[WalletPass] \u5DF2\u5B58\u50A8\u7684\u94B1\u5305\u53C2\u6570\u5DF2\u6E05\u7406");
102
+ this.paymentModule.logInfo("[WalletPass] 已存储的钱包参数已清理");
103
103
  }
104
104
  /**
105
105
  * 从业务数据初始化钱包数据
@@ -119,7 +119,7 @@ var WalletPassPaymentImpl = class {
119
119
  businessData,
120
120
  startTime
121
121
  });
122
- this.paymentModule.logInfo("[WalletPass] \u5F00\u59CB\u4ECE\u4E1A\u52A1\u6570\u636E\u521D\u59CB\u5316\u94B1\u5305\u6570\u636E", {
122
+ this.paymentModule.logInfo("[WalletPass] 开始从业务数据初始化钱包数据", {
123
123
  customer_id: businessData.customer_id,
124
124
  totalAmount: (_c = businessData.amountInfo) == null ? void 0 : _c.totalAmount,
125
125
  subTotal: (_d = businessData.amountInfo) == null ? void 0 : _d.subTotal,
@@ -137,7 +137,7 @@ var WalletPassPaymentImpl = class {
137
137
  endTime,
138
138
  duration
139
139
  });
140
- this.paymentModule.logInfo(`[WalletPass] \u4ECE\u4E1A\u52A1\u6570\u636E\u521D\u59CB\u5316\u94B1\u5305\u6570\u636E\u6210\u529F`, {
140
+ this.paymentModule.logInfo(`[WalletPass] 从业务数据初始化钱包数据成功`, {
141
141
  duration: `${duration}ms`,
142
142
  walletRecommendList_count: ((_f = result.walletRecommendList) == null ? void 0 : _f.length) || 0,
143
143
  userIdentificationCodes_count: ((_g = result.userIdentificationCodes) == null ? void 0 : _g.length) || 0
@@ -153,7 +153,7 @@ var WalletPassPaymentImpl = class {
153
153
  endTime,
154
154
  duration
155
155
  });
156
- this.paymentModule.logError(`[WalletPass] \u4ECE\u4E1A\u52A1\u6570\u636E\u521D\u59CB\u5316\u94B1\u5305\u6570\u636E\u5931\u8D25`, error, {
156
+ this.paymentModule.logError(`[WalletPass] 从业务数据初始化钱包数据失败`, error, {
157
157
  duration: `${duration}ms`,
158
158
  customer_id: businessData.customer_id,
159
159
  totalAmount: (_h = businessData.amountInfo) == null ? void 0 : _h.totalAmount
@@ -181,7 +181,7 @@ var WalletPassPaymentImpl = class {
181
181
  userIdentificationCodes
182
182
  };
183
183
  } catch (error) {
184
- this.paymentModule.logError("[WalletPass] \u521D\u59CB\u5316\u94B1\u5305\u6570\u636E\u5931\u8D25", error, {
184
+ this.paymentModule.logError("[WalletPass] 初始化钱包数据失败", error, {
185
185
  customer_id: baseParams.customer_id,
186
186
  order_expect_amount: baseParams.order_expect_amount
187
187
  });
@@ -191,7 +191,7 @@ var WalletPassPaymentImpl = class {
191
191
  async getWalletPassRecommendListAsync(params) {
192
192
  var _a;
193
193
  try {
194
- this.paymentModule.logInfo("[WalletPass] \u5F00\u59CB\u83B7\u53D6\u94B1\u5305\u63A8\u8350\u5217\u8868", {
194
+ this.paymentModule.logInfo("[WalletPass] 开始获取钱包推荐列表", {
195
195
  customer_id: params.customer_id,
196
196
  order_expect_amount: params.order_expect_amount,
197
197
  sale_channel: params.sale_channel,
@@ -206,7 +206,7 @@ var WalletPassPaymentImpl = class {
206
206
  this.emitEvent(import_types.WalletPassHooks.OnWalletRecommendListUpdated, {
207
207
  walletRecommendList: this.walletRecommendList
208
208
  });
209
- this.paymentModule.logInfo("[WalletPass] \u94B1\u5305\u63A8\u8350\u5217\u8868\u5DF2\u66F4\u65B0", {
209
+ this.paymentModule.logInfo("[WalletPass] 钱包推荐列表已更新", {
210
210
  count: this.walletRecommendList.length,
211
211
  items: this.walletRecommendList.map((item) => ({
212
212
  voucher_id: item.voucher_id,
@@ -217,7 +217,7 @@ var WalletPassPaymentImpl = class {
217
217
  });
218
218
  return this.walletRecommendList;
219
219
  } catch (error) {
220
- this.paymentModule.logError("[WalletPass] \u83B7\u53D6\u94B1\u5305\u63A8\u8350\u5217\u8868\u5931\u8D25", error, {
220
+ this.paymentModule.logError("[WalletPass] 获取钱包推荐列表失败", error, {
221
221
  customer_id: params.customer_id,
222
222
  order_expect_amount: params.order_expect_amount,
223
223
  sale_channel: params.sale_channel
@@ -235,7 +235,7 @@ var WalletPassPaymentImpl = class {
235
235
  ...this.walletParams,
236
236
  ...params
237
237
  };
238
- this.paymentModule.logInfo("[WalletPass] \u5F00\u59CB\u83B7\u53D6\u7528\u6237\u8BC6\u522B\u7801\u5217\u8868", {
238
+ this.paymentModule.logInfo("[WalletPass] 开始获取用户识别码列表", {
239
239
  customer_id: newParams.customer_id,
240
240
  available: newParams.available,
241
241
  prepare_payments_count: ((_a = newParams.prepare_payments) == null ? void 0 : _a.length) || 0,
@@ -251,7 +251,7 @@ var WalletPassPaymentImpl = class {
251
251
  this.emitEvent(import_types.WalletPassHooks.OnUserIdentificationCodesUpdated, {
252
252
  userIdentificationCodes: this.userIdentificationCodes
253
253
  });
254
- this.paymentModule.logInfo("[WalletPass] \u7528\u6237\u8BC6\u522B\u7801\u5217\u8868\u5DF2\u66F4\u65B0", {
254
+ this.paymentModule.logInfo("[WalletPass] 用户识别码列表已更新", {
255
255
  count: this.userIdentificationCodes.length,
256
256
  sorted_items: this.userIdentificationCodes.slice(0, 5).map((item) => ({
257
257
  code: item.code,
@@ -261,7 +261,7 @@ var WalletPassPaymentImpl = class {
261
261
  });
262
262
  return this.userIdentificationCodes;
263
263
  } catch (error) {
264
- this.paymentModule.logError("[WalletPass] \u83B7\u53D6\u7528\u6237\u8BC6\u522B\u7801\u5217\u8868\u5931\u8D25", error, {
264
+ this.paymentModule.logError("[WalletPass] 获取用户识别码列表失败", error, {
265
265
  customer_id: params.customer_id,
266
266
  available: params.available
267
267
  });
@@ -277,7 +277,7 @@ var WalletPassPaymentImpl = class {
277
277
  async searchIdentificationCodeAsync(params, config = {}) {
278
278
  try {
279
279
  const { code } = params;
280
- this.paymentModule.logInfo("[WalletPass] \u5F00\u59CB\u641C\u7D22\u8BC6\u522B\u7801", {
280
+ this.paymentModule.logInfo("[WalletPass] 开始搜索识别码", {
281
281
  code,
282
282
  code_length: code.length,
283
283
  noCache: config.noCache || false
@@ -289,7 +289,7 @@ var WalletPassPaymentImpl = class {
289
289
  with_customer: 1,
290
290
  with: ["wallet"]
291
291
  };
292
- this.paymentModule.logInfo("[WalletPass] \u641C\u7D22\u94B1\u5305\u8BC6\u522B\u7801", {
292
+ this.paymentModule.logInfo("[WalletPass] 搜索钱包识别码", {
293
293
  code,
294
294
  with_customer: walletDetailParams.with_customer,
295
295
  with: walletDetailParams.with
@@ -299,7 +299,7 @@ var WalletPassPaymentImpl = class {
299
299
  walletDetailParams
300
300
  );
301
301
  const searchResults2 = (response2 == null ? void 0 : response2.data) || [];
302
- this.paymentModule.logInfo("[WalletPass] \u94B1\u5305\u8BC6\u522B\u7801\u641C\u7D22\u5B8C\u6210", {
302
+ this.paymentModule.logInfo("[WalletPass] 钱包识别码搜索完成", {
303
303
  code,
304
304
  results_count: searchResults2.length,
305
305
  type: "walletCode"
@@ -325,7 +325,7 @@ var WalletPassPaymentImpl = class {
325
325
  code: params.code,
326
326
  payment_order_id: baseWalletParams == null ? void 0 : baseWalletParams.payment_order_id
327
327
  };
328
- this.paymentModule.logInfo("[WalletPass] \u641C\u7D22\u666E\u901A\u8BC6\u522B\u7801", {
328
+ this.paymentModule.logInfo("[WalletPass] 搜索普通识别码", {
329
329
  code: searchParams.code,
330
330
  customer_id: searchParams.customer_id,
331
331
  order_expect_amount: searchParams.order_expect_amount,
@@ -358,7 +358,7 @@ var WalletPassPaymentImpl = class {
358
358
  cachedSearchResults: [...this.searchResults],
359
359
  searchParams: params
360
360
  });
361
- this.paymentModule.logInfo("[WalletPass] \u666E\u901A\u8BC6\u522B\u7801\u641C\u7D22\u5B8C\u6210", {
361
+ this.paymentModule.logInfo("[WalletPass] 普通识别码搜索完成", {
362
362
  code: params.code,
363
363
  results_count: searchResults.length,
364
364
  cached_results_count: this.searchResults.length,
@@ -369,7 +369,7 @@ var WalletPassPaymentImpl = class {
369
369
  data: searchResults
370
370
  };
371
371
  } catch (error) {
372
- this.paymentModule.logError("[WalletPass] \u641C\u7D22\u8BC6\u522B\u7801\u4FE1\u606F\u5931\u8D25", error, {
372
+ this.paymentModule.logError("[WalletPass] 搜索识别码信息失败", error, {
373
373
  code: params.code,
374
374
  customer_id: params.customer_id,
375
375
  order_expect_amount: params.order_expect_amount
@@ -378,19 +378,19 @@ var WalletPassPaymentImpl = class {
378
378
  }
379
379
  }
380
380
  async processWalletPayment(amount, orderUuid, voucherId) {
381
- this.paymentModule.logInfo("[WalletPass] \u5F00\u59CB\u5904\u7406\u94B1\u5305\u652F\u4ED8", {
381
+ this.paymentModule.logInfo("[WalletPass] 开始处理钱包支付", {
382
382
  amount,
383
383
  orderUuid,
384
384
  voucherId: voucherId || "none"
385
385
  });
386
386
  const walletMethod = await this.paymentModule.getWalletPaymentMethod();
387
387
  if (!walletMethod) {
388
- this.paymentModule.logError("[WalletPass] \u94B1\u5305\u652F\u4ED8\u65B9\u5F0F\u672A\u627E\u5230", null, {
388
+ this.paymentModule.logError("[WalletPass] 钱包支付方式未找到", null, {
389
389
  amount,
390
390
  orderUuid,
391
391
  voucherId
392
392
  });
393
- throw new Error("\u94B1\u5305\u652F\u4ED8\u65B9\u5F0F\u672A\u627E\u5230");
393
+ throw new Error("钱包支付方式未找到");
394
394
  }
395
395
  const paymentItem = {
396
396
  amount: amount.toString(),
@@ -401,7 +401,7 @@ var WalletPassPaymentImpl = class {
401
401
  voucher_id: voucherId || ""
402
402
  };
403
403
  await this.paymentModule.addPaymentItemAsync(orderUuid, paymentItem);
404
- this.paymentModule.logInfo("[WalletPass] \u94B1\u5305\u652F\u4ED8\u5904\u7406\u5B8C\u6210", {
404
+ this.paymentModule.logInfo("[WalletPass] 钱包支付处理完成", {
405
405
  amount,
406
406
  orderUuid,
407
407
  voucherId: voucherId || "none",
@@ -431,7 +431,7 @@ var WalletPassPaymentImpl = class {
431
431
  this.emitEvent(import_types.WalletPassHooks.OnWalletRecommendListCleared, {
432
432
  clearedTypes: ["walletRecommendList"]
433
433
  });
434
- this.paymentModule.logInfo("[WalletPass] \u94B1\u5305\u63A8\u8350\u5217\u8868\u5DF2\u6E05\u9664");
434
+ this.paymentModule.logInfo("[WalletPass] 钱包推荐列表已清除");
435
435
  }
436
436
  /**
437
437
  * 清除用户识别码列表
@@ -441,7 +441,7 @@ var WalletPassPaymentImpl = class {
441
441
  this.emitEvent(import_types.WalletPassHooks.OnUserIdentificationCodesCleared, {
442
442
  clearedTypes: ["userIdentificationCodes"]
443
443
  });
444
- this.paymentModule.logInfo("[WalletPass] \u7528\u6237\u8BC6\u522B\u7801\u5217\u8868\u5DF2\u6E05\u9664");
444
+ this.paymentModule.logInfo("[WalletPass] 用户识别码列表已清除");
445
445
  }
446
446
  /**
447
447
  * 获取缓存的搜索结果列表
@@ -460,7 +460,7 @@ var WalletPassPaymentImpl = class {
460
460
  */
461
461
  clearSearchResults() {
462
462
  this.searchResults = [];
463
- this.paymentModule.logInfo("[WalletPass] \u641C\u7D22\u7ED3\u679C\u7F13\u5B58\u5DF2\u6E05\u9664");
463
+ this.paymentModule.logInfo("[WalletPass] 搜索结果缓存已清除");
464
464
  }
465
465
  /**
466
466
  * 清除所有缓存数据
@@ -473,7 +473,7 @@ var WalletPassPaymentImpl = class {
473
473
  this.emitEvent(import_types.WalletPassHooks.OnWalletCacheCleared, {
474
474
  clearedTypes: ["all"]
475
475
  });
476
- this.paymentModule.logInfo("[WalletPass] \u6240\u6709\u7F13\u5B58\u6570\u636E\u5DF2\u6E05\u9664", {
476
+ this.paymentModule.logInfo("[WalletPass] 所有缓存数据已清除", {
477
477
  cleared_types: ["walletRecommendList", "userIdentificationCodes", "searchResults", "walletParams"]
478
478
  });
479
479
  }
@@ -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;
@@ -27,13 +27,11 @@ var import_BaseModule = require("../BaseModule");
27
27
  var import_lodash_es = require("lodash-es");
28
28
  __reExport(ProductList_exports, require("./types"), module.exports);
29
29
  var ProductList = class extends import_BaseModule.BaseModule {
30
- defaultName = "productList";
31
- defaultVersion = "1.0.0";
32
- store;
33
- request;
34
- otherParams = {};
35
30
  constructor(name, version) {
36
31
  super(name, version);
32
+ this.defaultName = "productList";
33
+ this.defaultVersion = "1.0.0";
34
+ this.otherParams = {};
37
35
  }
38
36
  async initialize(core, options) {
39
37
  var _a;
@@ -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,7 +39,8 @@ 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
45
  await this.core.effects.emit(`${this.name}:onResourceSelect`, resource);
46
46
  }
@@ -49,19 +49,22 @@ var ResourceListModule = class extends import_BaseModule.BaseModule {
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
@@ -40,12 +40,10 @@ var import_decimal = __toESM(require("decimal.js"));
40
40
  var import_lodash_es = require("lodash-es");
41
41
  var import_dayjs = __toESM(require("dayjs"));
42
42
  var RulesModule = class extends import_BaseModule.BaseModule {
43
- defaultName = "rules";
44
- defaultVersion = "1.0.0";
45
- store;
46
- hooks;
47
43
  constructor(name, version) {
48
44
  super(name, version);
45
+ this.defaultName = "rules";
46
+ this.defaultVersion = "1.0.0";
49
47
  this.hooks = {};
50
48
  }
51
49
  async initialize(core, options) {
@@ -63,11 +61,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
63
61
  // 商品不需要holder,则不需要判断,直接返回true,商品需要holder但是还没填写,那么暂时不使用带有holder的券,直到填写才去匹配
64
62
  checkHolderMatch(discount, product, holders) {
65
63
  var _a;
66
- if (((_a = discount.holder) == null ? void 0 : _a.holder_type) !== "form") return true;
64
+ if (((_a = discount.holder) == null ? void 0 : _a.holder_type) !== "form")
65
+ return true;
67
66
  const orderHolderId = Array.isArray(holders) && holders.length > 0 ? holders[0].form_record_id : void 0;
68
67
  const productHolderId = Array.isArray(product.holder_id) ? product.holder_id[0] : product.holder_id;
69
- if (!product.isNeedHolder) return true;
70
- if (!orderHolderId && !productHolderId) return false;
68
+ if (!product.isNeedHolder)
69
+ return true;
70
+ if (!orderHolderId && !productHolderId)
71
+ return false;
71
72
  return (productHolderId || orderHolderId) === discount.holder.holder_id;
72
73
  }
73
74
  // 判断discountList 是否可以对当前productList生效
@@ -271,13 +272,19 @@ var RulesModule = class extends import_BaseModule.BaseModule {
271
272
  const getPriority = (discount) => {
272
273
  const isHolder = isHolderDiscount(discount);
273
274
  if (isHolder) {
274
- if (isGoodPass(discount)) return 1;
275
- if (isItemLevelDiscount(discount)) return 2;
276
- if (isOrderLevelDiscount(discount)) return 3;
275
+ if (isGoodPass(discount))
276
+ return 1;
277
+ if (isItemLevelDiscount(discount))
278
+ return 2;
279
+ if (isOrderLevelDiscount(discount))
280
+ return 3;
277
281
  } else {
278
- if (isGoodPass(discount)) return 4;
279
- if (isItemLevelDiscount(discount)) return 5;
280
- if (isOrderLevelDiscount(discount)) return 6;
282
+ if (isGoodPass(discount))
283
+ return 4;
284
+ if (isItemLevelDiscount(discount))
285
+ return 5;
286
+ if (isOrderLevelDiscount(discount))
287
+ return 6;
281
288
  }
282
289
  return 7;
283
290
  };
@@ -293,8 +300,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
293
300
  var _a, _b;
294
301
  const typeA = ((_a = itemA.metadata) == null ? void 0 : _a.discount_card_type) || "percent";
295
302
  const typeB = ((_b = itemB.metadata) == null ? void 0 : _b.discount_card_type) || "percent";
296
- if (typeA === "fixed_amount" && typeB === "percent") return -1;
297
- if (typeA === "percent" && typeB === "fixed_amount") return 1;
303
+ if (typeA === "fixed_amount" && typeB === "percent")
304
+ return -1;
305
+ if (typeA === "percent" && typeB === "fixed_amount")
306
+ return 1;
298
307
  if (typeA === "fixed_amount" && typeB === "fixed_amount") {
299
308
  if (itemA.par_value !== itemB.par_value) {
300
309
  const valueA = new import_decimal.default(itemA.par_value || 0);
@@ -321,7 +330,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
321
330
  }
322
331
  if (a.tag === "product_discount_card" && b.tag === "product_discount_card") {
323
332
  const valueCompare = compareDiscountCardValue(a, b);
324
- if (valueCompare !== 0) return valueCompare;
333
+ if (valueCompare !== 0)
334
+ return valueCompare;
325
335
  return compareByExpireTime(a, b);
326
336
  }
327
337
  return compareByExpireTime(a, b);
@@ -594,13 +604,16 @@ var RulesModule = class extends import_BaseModule.BaseModule {
594
604
  }
595
605
  const applicableDiscounts = sortedDiscountList.filter((discount) => {
596
606
  var _a2, _b2;
597
- if ((Number(product.price) <= 0 || !product.price) && !((_a2 = product.discount_list) == null ? void 0 : _a2.length) && (discount.tag || discount.type) === "good_pass") return false;
607
+ if ((Number(product.price) <= 0 || !product.price) && !((_a2 = product.discount_list) == null ? void 0 : _a2.length) && (discount.tag || discount.type) === "good_pass")
608
+ return false;
598
609
  if ((Number(product.price) <= 0 || !product.price) && !((_b2 = product.discount_list) == null ? void 0 : _b2.find((n) => {
599
610
  var _a3;
600
611
  return ((_a3 = n.discount) == null ? void 0 : _a3.resource_id) === discount.id;
601
- })) && (discount.tag || discount.type) !== "good_pass") return false;
612
+ })) && (discount.tag || discount.type) !== "good_pass")
613
+ return false;
602
614
  const targetUsedDiscounts = usedDiscounts.get(discount.id);
603
- if (targetUsedDiscounts && (discount.tag || discount.type) === "good_pass") return false;
615
+ if (targetUsedDiscounts && (discount.tag || discount.type) === "good_pass")
616
+ return false;
604
617
  const limitedData = discount.limited_relation_product_data;
605
618
  const _tempVar = (flatItem == null ? void 0 : flatItem.type) === "bundle" ? flatItem == null ? void 0 : flatItem.parentProduct : flatItem == null ? void 0 : flatItem.product;
606
619
  const isHolderMatch = this.checkHolderMatch(
@@ -611,7 +624,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
611
624
  },
612
625
  holders
613
626
  );
614
- if (!isHolderMatch) return false;
627
+ if (!isHolderMatch)
628
+ return false;
615
629
  let timeLimit = true;
616
630
  timeLimit = !!(0, import_utils.filterDiscountListByBookingTime)([discount], (product.startDate || (0, import_dayjs.default)()).format("YYYY-MM-DD HH:mm:ss")).length;
617
631
  if (!timeLimit) {
@@ -1438,7 +1452,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1438
1452
  async destroy() {
1439
1453
  this.core.effects.offByModuleDestroy(this.name);
1440
1454
  await this.core.effects.emit(`${this.name}:onDestroy`, {});
1441
- console.log("[Rules] \u5DF2\u9500\u6BC1");
1455
+ console.log("[Rules] 已销毁");
1442
1456
  }
1443
1457
  async clear() {
1444
1458
  console.log("[Rules] clear");
@@ -34,7 +34,7 @@ export interface RulesModuleAPI {
34
34
  isFormSubject: boolean;
35
35
  }) => DiscountResult;
36
36
  }
37
- declare type ProductDetail = {
37
+ type ProductDetail = {
38
38
  isClient?: boolean;
39
39
  isManualDiscount?: boolean;
40
40
  booking_id: any;
@@ -1,7 +1,7 @@
1
1
  import dayjs from "dayjs";
2
2
  import { ScheduleItem } from "./types";
3
3
  export declare const getDateIsInSchedule: (dateTime: string, scheduleList: ScheduleItem[]) => boolean;
4
- export declare type ScheduleTimeSlot = {
4
+ export type ScheduleTimeSlot = {
5
5
  /** 开始时间 HH:mm */
6
6
  start_time: string;
7
7
  /** 结束时间 HH:mm */
@@ -43,22 +43,19 @@ var import_getDateIsInSchedule = require("./getDateIsInSchedule");
43
43
  import_dayjs.default.extend(import_isSameOrBefore.default);
44
44
  import_dayjs.default.extend(import_isSameOrAfter.default);
45
45
  var ScheduleModule = class extends import_BaseModule.BaseModule {
46
- defaultName = "schedule";
47
- defaultVersion = "1.0.0";
48
- request;
49
- store = {};
50
- cacheId;
51
- openCache = false;
52
- fatherModule;
53
46
  constructor(name, version) {
54
47
  super(name, version);
48
+ this.defaultName = "schedule";
49
+ this.defaultVersion = "1.0.0";
50
+ this.store = {};
51
+ this.openCache = false;
55
52
  }
56
53
  async initialize(core, options) {
57
54
  var _a, _b;
58
55
  this.core = core;
59
56
  this.request = core.getPlugin("request");
60
57
  if (!this.request) {
61
- throw new Error("ScheduleModule \u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
58
+ throw new Error("ScheduleModule 需要 request 插件支持");
62
59
  }
63
60
  this.store = options == null ? void 0 : options.store;
64
61
  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;