@pisell/pisellos 0.0.373 → 0.0.376

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 (92) hide show
  1. package/dist/effects/index.d.ts +2 -2
  2. package/dist/model/strategy/adapter/walletPass/utils.js +7 -2
  3. package/dist/model/strategy/type.d.ts +1 -1
  4. package/dist/modules/Customer/types.d.ts +1 -1
  5. package/dist/modules/Payment/index.js +35 -7
  6. package/dist/modules/Payment/types.d.ts +9 -7
  7. package/dist/modules/Product/index.d.ts +1 -1
  8. package/dist/modules/Rules/types.d.ts +1 -1
  9. package/dist/modules/Schedule/type.d.ts +7 -7
  10. package/dist/modules/Schedule/types.d.ts +9 -9
  11. package/dist/solution/BookingByStep/index.d.ts +2 -2
  12. package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
  13. package/dist/solution/Checkout/index.js +31 -2
  14. package/dist/solution/Checkout/types.d.ts +2 -0
  15. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  16. package/dist/solution/ShopDiscount/utils.d.ts +2 -2
  17. package/dist/types/index.d.ts +1 -1
  18. package/dist/utils/task.d.ts +2 -2
  19. package/dist/utils/watch.d.ts +2 -2
  20. package/lib/core/index.js +28 -27
  21. package/lib/effects/index.d.ts +2 -2
  22. package/lib/effects/index.js +7 -3
  23. package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -3
  24. package/lib/model/strategy/adapter/walletPass/example.js +21 -21
  25. package/lib/model/strategy/adapter/walletPass/index.js +4 -2
  26. package/lib/model/strategy/adapter/walletPass/locales.js +10 -10
  27. package/lib/model/strategy/adapter/walletPass/utils.js +9 -4
  28. package/lib/model/strategy/index.js +10 -7
  29. package/lib/model/strategy/strategy-example.js +19 -19
  30. package/lib/model/strategy/type.d.ts +1 -1
  31. package/lib/modules/Account/index.js +10 -9
  32. package/lib/modules/AccountList/index.js +11 -14
  33. package/lib/modules/BaseModule.js +3 -6
  34. package/lib/modules/Cart/index.js +9 -14
  35. package/lib/modules/Cart/utils/cartProduct.js +6 -3
  36. package/lib/modules/Customer/constants.js +1 -1
  37. package/lib/modules/Customer/index.js +15 -18
  38. package/lib/modules/Customer/types.d.ts +1 -1
  39. package/lib/modules/Date/index.js +6 -10
  40. package/lib/modules/Date/types.js +0 -1
  41. package/lib/modules/Discount/index.js +6 -11
  42. package/lib/modules/Guests/index.js +15 -10
  43. package/lib/modules/Order/index.js +9 -11
  44. package/lib/modules/Payment/cash.js +1 -1
  45. package/lib/modules/Payment/cashRecommendationAlgorithm.js +1 -1
  46. package/lib/modules/Payment/eftpos.js +1 -1
  47. package/lib/modules/Payment/index.js +94 -86
  48. package/lib/modules/Payment/types.d.ts +9 -7
  49. package/lib/modules/Payment/utils.js +6 -3
  50. package/lib/modules/Payment/walletpass.js +33 -33
  51. package/lib/modules/Product/index.d.ts +1 -1
  52. package/lib/modules/Product/index.js +5 -6
  53. package/lib/modules/ProductList/index.js +3 -5
  54. package/lib/modules/Resource/index.js +12 -8
  55. package/lib/modules/Rules/index.js +21 -16
  56. package/lib/modules/Rules/types.d.ts +1 -1
  57. package/lib/modules/Schedule/index.js +5 -8
  58. package/lib/modules/Schedule/type.d.ts +7 -7
  59. package/lib/modules/Schedule/types.d.ts +9 -9
  60. package/lib/modules/Schedule/utils.js +4 -2
  61. package/lib/modules/Step/index.js +4 -7
  62. package/lib/modules/Summary/index.js +4 -9
  63. package/lib/plugins/request.js +33 -34
  64. package/lib/plugins/window.js +113 -101
  65. package/lib/solution/BookingByStep/index.d.ts +2 -2
  66. package/lib/solution/BookingByStep/index.js +129 -86
  67. package/lib/solution/BookingByStep/utils/capacity.js +15 -10
  68. package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
  69. package/lib/solution/BookingByStep/utils/resources.js +8 -4
  70. package/lib/solution/BookingByStep/utils/stock.js +6 -3
  71. package/lib/solution/BookingByStep/utils/timeslots.js +27 -24
  72. package/lib/solution/BookingTicket/index.js +14 -19
  73. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +3 -3
  74. package/lib/solution/BookingTicket/utils/scan/handleScan.js +6 -6
  75. package/lib/solution/BookingTicket/utils/scan/index.js +1 -3
  76. package/lib/solution/BookingTicket/utils/scan/scanCache.js +9 -10
  77. package/lib/solution/BuyTickets/index.js +15 -15
  78. package/lib/solution/Checkout/index.js +233 -217
  79. package/lib/solution/Checkout/types.d.ts +2 -0
  80. package/lib/solution/Checkout/utils/index.js +22 -18
  81. package/lib/solution/RegisterAndLogin/config.js +2 -2
  82. package/lib/solution/RegisterAndLogin/index.js +110 -114
  83. package/lib/solution/RegisterAndLogin/utils.js +9 -9
  84. package/lib/solution/ShopDiscount/index.js +13 -16
  85. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  86. package/lib/solution/ShopDiscount/utils.d.ts +2 -2
  87. package/lib/types/index.d.ts +1 -1
  88. package/lib/utils/task.d.ts +2 -2
  89. package/lib/utils/task.js +3 -3
  90. package/lib/utils/watch.d.ts +2 -2
  91. package/lib/utils/watch.js +7 -5
  92. package/package.json +18 -17
@@ -52,33 +52,29 @@ var import_stock = require("./utils/stock");
52
52
  import_dayjs.default.extend(import_isSameOrBefore.default);
53
53
  import_dayjs.default.extend(import_isSameOrAfter.default);
54
54
  var BookingByStepImpl = class extends import_BaseModule.BaseModule {
55
- defaultName = "bookingByStep";
56
- defaultVersion = "1.0.0";
57
- isSolution = true;
58
- request;
59
- window;
60
- shopStore;
61
- store;
62
- otherParams = {};
63
- cacheId;
64
- otherData = {};
65
- // 提供给 UI 层的临时数据存储,会进缓存
66
- platform;
55
+ constructor() {
56
+ super(...arguments);
57
+ this.defaultName = "bookingByStep";
58
+ this.defaultVersion = "1.0.0";
59
+ this.isSolution = true;
60
+ this.otherParams = {};
61
+ this.otherData = {};
62
+ }
67
63
  // 平台类型,用于判断是 PC / H5
68
64
  async initialize(core, options) {
69
65
  var _a, _b, _c, _d, _e;
70
66
  this.core = core;
71
67
  this.store = options.store || {};
72
68
  this.otherParams = options.otherParams || {};
73
- console.log("[BookingByStep] \u521D\u59CB\u5316\u5B8C\u6210");
69
+ console.log("[BookingByStep] 初始化完成");
74
70
  this.request = core.getPlugin("request");
75
71
  this.window = core.getPlugin("window");
76
72
  this.shopStore = core.getPlugin("shopStore");
77
73
  if (!this.request) {
78
- throw new Error("bookingByStep\u89E3\u51B3\u65B9\u6848\u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
74
+ throw new Error("bookingByStep解决方案需要 request 插件支持");
79
75
  }
80
76
  if (!this.shopStore) {
81
- throw new Error("SummaryModule \u9700\u8981 shopStore \u63D2\u4EF6\u652F\u6301");
77
+ throw new Error("SummaryModule 需要 shopStore 插件支持");
82
78
  }
83
79
  let targetCacheData = {};
84
80
  this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
@@ -116,7 +112,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
116
112
  }
117
113
  });
118
114
  } else {
119
- throw new Error(`\u6A21\u5757 ${step} \u4E0D\u5B58\u5728`);
115
+ throw new Error(`模块 ${step} 不存在`);
120
116
  }
121
117
  });
122
118
  this.store.schedule.loadAllSchedule();
@@ -492,7 +488,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
492
488
  this.updateQuotationPriceAndCart(date);
493
489
  }
494
490
  } else {
495
- throw new Error(`\u6CA1\u6709\u627E\u5230${accountId}\u8D26\u6237`);
491
+ throw new Error(`没有找到${accountId}账户`);
496
492
  }
497
493
  }
498
494
  // 生成购物车的正规数据
@@ -700,7 +696,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
700
696
  updateCart(params) {
701
697
  const targetCartItem = this.store.cart.getItem(params._id);
702
698
  if (!targetCartItem) {
703
- throw new Error(`\u6CA1\u6709\u627E\u5230${params._id}\u8D2D\u7269\u8F66\u5546\u54C1`);
699
+ throw new Error(`没有找到${params._id}购物车商品`);
704
700
  }
705
701
  this.beforeUpdateCart(params, targetCartItem);
706
702
  this.store.cart.updateItem(params);
@@ -727,13 +723,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
727
723
  const dateRange = this.store.date.getDateRange();
728
724
  if (dateRange == null ? void 0 : dateRange.length) {
729
725
  dateRange.forEach((n) => {
730
- if (n.resource) allOriginResources.push(...n.resource);
726
+ if (n.resource)
727
+ allOriginResources.push(...n.resource);
731
728
  });
732
729
  }
733
730
  if (!allOriginResources.length) {
734
731
  const dateList = this.store.date.getDateList();
735
732
  dateList == null ? void 0 : dateList.forEach((n) => {
736
- if (n.resource) allOriginResources.push(...n.resource);
733
+ if (n.resource)
734
+ allOriginResources.push(...n.resource);
737
735
  });
738
736
  }
739
737
  if (params.resources) {
@@ -865,7 +863,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
865
863
  const resources = [];
866
864
  if (dateRange == null ? void 0 : dateRange.length) {
867
865
  dateRange.forEach((n) => {
868
- if (n.resource) resources.push(...n.resource);
866
+ if (n.resource)
867
+ resources.push(...n.resource);
869
868
  });
870
869
  }
871
870
  const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
@@ -879,7 +878,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
879
878
  } else {
880
879
  const dateList = this.store.date.getDateList();
881
880
  dateList.forEach((n) => {
882
- if (n.resource) resources.push(...n.resource);
881
+ if (n.resource)
882
+ resources.push(...n.resource);
883
883
  });
884
884
  }
885
885
  }
@@ -948,7 +948,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
948
948
  }
949
949
  return res.usable;
950
950
  });
951
- if (m.onlyComputed) return false;
951
+ if (m.onlyComputed)
952
+ return false;
952
953
  return !canUseArr.some((n2) => n2 === false);
953
954
  });
954
955
  });
@@ -960,7 +961,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
960
961
  item.renderList = item.renderList.filter((n) => {
961
962
  var _a2, _b2, _c2;
962
963
  const recordCount = n.capacity || 0;
963
- if (n.onlyComputed) return false;
964
+ if (n.onlyComputed)
965
+ return false;
964
966
  const timeSlots = (0, import_resources.getTimeSlicesByResource)({
965
967
  resource: n,
966
968
  duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
@@ -1014,12 +1016,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1014
1016
  const dateRange = this.store.date.getDateRange();
1015
1017
  const resources = [];
1016
1018
  dateRange.forEach((n) => {
1017
- if (n.resource) resources.push(...n.resource);
1019
+ if (n.resource)
1020
+ resources.push(...n.resource);
1018
1021
  });
1019
1022
  const resourcesMap = (0, import_utils2.getResourcesMap)(resources);
1020
1023
  const targetCartItem = cartItems.find((n) => n._id === id);
1021
1024
  if (!targetCartItem) {
1022
- throw new Error(`\u6CA1\u6709\u627E\u5230${id}\u8D2D\u7269\u8F66\u5546\u54C1`);
1025
+ throw new Error(`没有找到${id}购物车商品`);
1023
1026
  }
1024
1027
  let selectedResources = [];
1025
1028
  const { currentCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(targetCartItem);
@@ -1045,7 +1048,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1045
1048
  productResources.forEach((item) => {
1046
1049
  item.renderList = item.renderList.filter((n) => {
1047
1050
  const recordCount = n.capacity || 0;
1048
- if (n.onlyComputed) return false;
1051
+ if (n.onlyComputed)
1052
+ return false;
1049
1053
  return recordCount >= currentCapacity;
1050
1054
  });
1051
1055
  });
@@ -1088,7 +1092,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1088
1092
  let AllResources = [];
1089
1093
  if (dateRange == null ? void 0 : dateRange.length) {
1090
1094
  dateRange.forEach((n) => {
1091
- if (n.resource) AllResources.push(...n.resource);
1095
+ if (n.resource)
1096
+ AllResources.push(...n.resource);
1092
1097
  });
1093
1098
  }
1094
1099
  if (!AllResources.length) {
@@ -1101,7 +1106,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1101
1106
  } else {
1102
1107
  const dateList = this.store.date.getDateList();
1103
1108
  dateList.forEach((n) => {
1104
- if (n.resource) AllResources.push(...n.resource);
1109
+ if (n.resource)
1110
+ AllResources.push(...n.resource);
1105
1111
  });
1106
1112
  }
1107
1113
  }
@@ -1123,8 +1129,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1123
1129
  var _a2, _b2, _c2, _d;
1124
1130
  const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
1125
1131
  const bIsCombined = ((_d = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d.status) === 1;
1126
- if (aIsCombined && !bIsCombined) return 1;
1127
- if (!aIsCombined && bIsCombined) return -1;
1132
+ if (aIsCombined && !bIsCombined)
1133
+ return 1;
1134
+ if (!aIsCombined && bIsCombined)
1135
+ return -1;
1128
1136
  return 0;
1129
1137
  });
1130
1138
  const resourcesUseableMap = [
@@ -1211,7 +1219,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1211
1219
  const resources = [];
1212
1220
  if ((_a = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _a.date) {
1213
1221
  dateRange.forEach((n) => {
1214
- if (n.resource) resources.push(...n.resource);
1222
+ if (n.resource)
1223
+ resources.push(...n.resource);
1215
1224
  });
1216
1225
  }
1217
1226
  const errorList = [];
@@ -1344,7 +1353,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1344
1353
  productResources.forEach((item2) => {
1345
1354
  item2.renderList = item2.renderList.filter((n) => {
1346
1355
  const recordCount = (n.capacity || 0) - (selectResourcesMap[n.id] || 0);
1347
- if (n.onlyComputed) return false;
1356
+ if (n.onlyComputed)
1357
+ return false;
1348
1358
  return recordCount >= currentCapacity;
1349
1359
  });
1350
1360
  });
@@ -1596,7 +1606,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1596
1606
  }
1597
1607
  }
1598
1608
  });
1599
- if (!resources.length) return [];
1609
+ if (!resources.length)
1610
+ return [];
1600
1611
  let duration = 0;
1601
1612
  const accountList = this.store.accountList.getAccounts();
1602
1613
  const checkDuration = (cartItems2) => {
@@ -1826,11 +1837,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1826
1837
  const newScheduleArr = this.getScheduleDataByIds(
1827
1838
  targetProductData["schedule.ids"]
1828
1839
  );
1829
- if (!this.store.currentProductMeta) this.store.currentProductMeta = {};
1840
+ if (!this.store.currentProductMeta)
1841
+ this.store.currentProductMeta = {};
1830
1842
  this.store.currentProductMeta.schedule = newScheduleArr;
1831
1843
  } else if (targetProductData.duration) {
1832
1844
  const dateRange = this.store.date.getDateRange();
1833
- if (!(dateRange == null ? void 0 : dateRange.length)) return;
1845
+ if (!(dateRange == null ? void 0 : dateRange.length))
1846
+ return;
1834
1847
  this.getAvailableDate({
1835
1848
  startDate: dateRange[0].date,
1836
1849
  endDate: dateRange[dateRange.length - 1].date,
@@ -1889,8 +1902,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1889
1902
  var _a2, _b2, _c2, _d2;
1890
1903
  const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
1891
1904
  const bIsCombined = ((_d2 = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d2.status) === 1;
1892
- if (aIsCombined && !bIsCombined) return 1;
1893
- if (!aIsCombined && bIsCombined) return -1;
1905
+ if (aIsCombined && !bIsCombined)
1906
+ return 1;
1907
+ if (!aIsCombined && bIsCombined)
1908
+ return -1;
1894
1909
  return 0;
1895
1910
  });
1896
1911
  const firstEnabledResourceId = (_e = (_d = (_c = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.find(
@@ -2062,19 +2077,20 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2062
2077
  * 找到多个资源的公共可用时间段
2063
2078
  */
2064
2079
  findCommonAvailableTimeSlots(resources) {
2065
- if (resources.length === 0) return [];
2066
- console.log(`\u8BA1\u7B97 ${resources.length} \u4E2A\u8D44\u6E90\u7684\u516C\u5171\u65F6\u95F4\u6BB5`);
2080
+ if (resources.length === 0)
2081
+ return [];
2082
+ console.log(`计算 ${resources.length} 个资源的公共时间段`);
2067
2083
  const allTimeSlots = resources.map(
2068
2084
  (resource) => resource.times.map((time) => ({
2069
2085
  start: (0, import_dayjs.default)(time.start_at),
2070
2086
  end: (0, import_dayjs.default)(time.end_at)
2071
2087
  }))
2072
2088
  );
2073
- console.log("\u6240\u6709\u8D44\u6E90\u7684\u65F6\u95F4\u6BB5:", allTimeSlots.map(
2089
+ console.log("所有资源的时间段:", allTimeSlots.map(
2074
2090
  (slots) => slots.map((slot) => `${slot.start.format("HH:mm")}-${slot.end.format("HH:mm")}`)
2075
2091
  ));
2076
2092
  let commonSlots = allTimeSlots[0];
2077
- console.log("\u521D\u59CB\u516C\u5171\u65F6\u95F4\u6BB5:", commonSlots.map((slot) => `${slot.start.format("HH:mm")}-${slot.end.format("HH:mm")}`));
2093
+ console.log("初始公共时间段:", commonSlots.map((slot) => `${slot.start.format("HH:mm")}-${slot.end.format("HH:mm")}`));
2078
2094
  for (let i = 1; i < allTimeSlots.length; i++) {
2079
2095
  const currentResourceSlots = allTimeSlots[i];
2080
2096
  const intersections = [];
@@ -2091,23 +2107,24 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2091
2107
  });
2092
2108
  });
2093
2109
  if (intersections.length === 0) {
2094
- console.log(`\u8D44\u6E90${i}\u4E0E\u5F53\u524D\u516C\u5171\u65F6\u95F4\u6BB5\u65E0\u4EA4\u96C6\uFF0C\u8DF3\u8FC7\u8BE5\u8D44\u6E90`);
2110
+ console.log(`资源${i}与当前公共时间段无交集,跳过该资源`);
2095
2111
  continue;
2096
2112
  }
2097
2113
  commonSlots = intersections;
2098
- console.log(`\u4E0E\u8D44\u6E90${i}\u6C42\u4EA4\u96C6\u540E\u7684\u516C\u5171\u65F6\u95F4\u6BB5:`, commonSlots.map((slot) => `${slot.start.format("HH:mm")}-${slot.end.format("HH:mm")}`));
2114
+ console.log(`与资源${i}求交集后的公共时间段:`, commonSlots.map((slot) => `${slot.start.format("HH:mm")}-${slot.end.format("HH:mm")}`));
2099
2115
  }
2100
2116
  const result = commonSlots.map((slot) => ({
2101
2117
  startTime: slot.start.format("HH:mm"),
2102
2118
  endTime: slot.end.format("HH:mm")
2103
2119
  }));
2104
- console.log("\u6700\u7EC8\u516C\u5171\u65F6\u95F4\u6BB5:", result);
2120
+ console.log("最终公共时间段:", result);
2105
2121
  return result;
2106
2122
  }
2107
2123
  checkMaxDurationCapacity() {
2108
2124
  var _a, _b;
2109
2125
  const cartItems = this.store.cart.getItems().filter((item) => !(0, import_utils5.isNormalProduct)(item._productOrigin));
2110
- if (cartItems.length === 0) return { success: true, minAvailableCount: 0 };
2126
+ if (cartItems.length === 0)
2127
+ return { success: true, minAvailableCount: 0 };
2111
2128
  const itemsWithTime = [];
2112
2129
  const itemsWithoutTime = [];
2113
2130
  const availableCountsByResourceType = [];
@@ -2123,7 +2140,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2123
2140
  const itemsByResourceType = {};
2124
2141
  itemsWithoutTime.forEach((cartItem) => {
2125
2142
  var _a2;
2126
- if (!cartItem._productOrigin) return;
2143
+ if (!cartItem._productOrigin)
2144
+ return;
2127
2145
  const resourceTypes = ((_a2 = cartItem._productOrigin.product_resource) == null ? void 0 : _a2.resources) || [];
2128
2146
  resourceTypes.forEach((resourceType) => {
2129
2147
  var _a3;
@@ -2139,10 +2157,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2139
2157
  });
2140
2158
  });
2141
2159
  const dateRange = this.store.date.getDateRange();
2142
- if (!dateRange || dateRange.length === 0) return { success: false, minAvailableCount: 0 };
2160
+ if (!dateRange || dateRange.length === 0)
2161
+ return { success: false, minAvailableCount: 0 };
2143
2162
  const resourcesDates = this.store.date.getDateList();
2144
2163
  const targetResourceDate = resourcesDates.find((n) => n.date === dateRange[0].date);
2145
- if (!targetResourceDate) return { success: false, minAvailableCount: 0 };
2164
+ if (!targetResourceDate)
2165
+ return { success: false, minAvailableCount: 0 };
2146
2166
  const resourcesMap = (0, import_utils2.getResourcesMap)(targetResourceDate.resource || []);
2147
2167
  const resourceCodeToFormIdMap = {};
2148
2168
  Object.values(itemsByResourceType).flat().forEach((cartItem) => {
@@ -2165,7 +2185,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2165
2185
  for (const [resourceCode, items] of Object.entries(itemsByResourceType)) {
2166
2186
  const targetFormId = resourceCodeToFormIdMap[resourceCode];
2167
2187
  if (!targetFormId) {
2168
- console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} \u627E\u4E0D\u5230\u5BF9\u5E94\u7684 form_id`);
2188
+ console.log(`资源类型 ${resourceCode} 找不到对应的 form_id`);
2169
2189
  return { success: false, minAvailableCount: 0 };
2170
2190
  }
2171
2191
  const resourcesOfThisType = [];
@@ -2182,7 +2202,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2182
2202
  });
2183
2203
  });
2184
2204
  if (resourcesOfThisType.length === 0) {
2185
- console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} \u6CA1\u6709\u627E\u5230\u53EF\u7528\u8D44\u6E90`);
2205
+ console.log(`资源类型 ${resourceCode} 没有找到可用资源`);
2186
2206
  return { success: false, minAvailableCount: 0 };
2187
2207
  }
2188
2208
  let resourceTypeConfig = null;
@@ -2191,7 +2211,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2191
2211
  resourceTypeConfig = cartItem._productOrigin.product_resource.resources.find(
2192
2212
  (r) => r.code === resourceCode && r.status === 1
2193
2213
  );
2194
- if (resourceTypeConfig) break;
2214
+ if (resourceTypeConfig)
2215
+ break;
2195
2216
  }
2196
2217
  }
2197
2218
  const isMultipleBooking = (resourceTypeConfig == null ? void 0 : resourceTypeConfig.type) === "multiple";
@@ -2224,20 +2245,20 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2224
2245
  availableCountsByResourceType.push(availableAmount);
2225
2246
  if (requiredAmount > totalAvailable) {
2226
2247
  hasCapacityIssue = true;
2227
- console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} ${isMultipleBooking ? "\u5BB9\u91CF" : "\u8D44\u6E90\u6570\u91CF"}\u4E0D\u8DB3: \u9700\u8981 ${requiredAmount}, \u603B\u5171 ${totalAvailable}`);
2248
+ console.log(`资源类型 ${resourceCode} ${isMultipleBooking ? "容量" : "资源数量"}不足: 需要 ${requiredAmount}, 总共 ${totalAvailable}`);
2228
2249
  }
2229
- console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} \u7684\u8D44\u6E90\u65F6\u95F4\u4FE1\u606F:`, resourcesOfThisType.map((r) => ({
2250
+ console.log(`资源类型 ${resourceCode} 的资源时间信息:`, resourcesOfThisType.map((r) => ({
2230
2251
  id: r.id,
2231
2252
  times: r.times.map((t) => `${t.start_at} - ${t.end_at}`)
2232
2253
  })));
2233
2254
  const commonTimeSlots = this.findCommonAvailableTimeSlots(resourcesOfThisType);
2234
- console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} \u7684\u516C\u5171\u65F6\u95F4\u6BB5:`, commonTimeSlots);
2255
+ console.log(`资源类型 ${resourceCode} 的公共时间段:`, commonTimeSlots);
2235
2256
  if (commonTimeSlots.length === 0) {
2236
- console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} \u6CA1\u6709\u516C\u5171\u53EF\u7528\u65F6\u95F4\u6BB5`);
2257
+ console.log(`资源类型 ${resourceCode} 没有公共可用时间段`);
2237
2258
  return { success: false, minAvailableCount: 0 };
2238
2259
  }
2239
2260
  const firstCommonSlot = commonTimeSlots[0];
2240
- console.log(`\u4F7F\u7528\u516C\u5171\u65F6\u95F4\u6BB5: ${firstCommonSlot.startTime} - ${firstCommonSlot.endTime}`);
2261
+ console.log(`使用公共时间段: ${firstCommonSlot.startTime} - ${firstCommonSlot.endTime}`);
2241
2262
  items.forEach((cartItem) => {
2242
2263
  if (!processedCartItemIds.has(cartItem._id)) {
2243
2264
  processedCartItemIds.add(cartItem._id);
@@ -2265,7 +2286,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2265
2286
  const allProcessedItems = [...itemsWithTime, ...processedItemsWithoutTime];
2266
2287
  const cartItemsByTimeSlot = {};
2267
2288
  allProcessedItems.forEach((cartItem) => {
2268
- if (!cartItem.start_time || !cartItem.end_time || !cartItem.start_date) return;
2289
+ if (!cartItem.start_time || !cartItem.end_time || !cartItem.start_date)
2290
+ return;
2269
2291
  const timeSlotKey = `${cartItem.start_date}_${cartItem.start_time}_${cartItem.end_date || cartItem.start_date}_${cartItem.end_time}`;
2270
2292
  if (!cartItemsByTimeSlot[timeSlotKey]) {
2271
2293
  cartItemsByTimeSlot[timeSlotKey] = [];
@@ -2281,10 +2303,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2281
2303
  const dateRange = this.store.date.getDateRange();
2282
2304
  const resourcesDates = this.store.date.getDateList();
2283
2305
  const targetResourceDate = resourcesDates.find((n) => n.date === startDate);
2284
- if (!targetResourceDate) continue;
2306
+ if (!targetResourceDate)
2307
+ continue;
2285
2308
  const resourcesMap = (0, import_utils2.getResourcesMap)(targetResourceDate.resource || []);
2286
2309
  itemsInTimeSlot.forEach((cartItem) => {
2287
- if (!cartItem._productOrigin) return;
2310
+ if (!cartItem._productOrigin)
2311
+ return;
2288
2312
  const productResourceIds = (0, import_capacity.getResourcesIdsByProduct)(cartItem._productOrigin);
2289
2313
  productResourceIds.forEach((resourceId) => {
2290
2314
  if (resourcesMap[resourceId] && !resourcesIdSet.has(resourceId)) {
@@ -2363,7 +2387,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2363
2387
  const cartItems = this.store.cart.getItems().filter((item) => !(0, import_utils5.isNormalProduct)(item._productOrigin));
2364
2388
  const currentCartItem = this.convertProductToCartItem({ product, date, account });
2365
2389
  cartItems.push(currentCartItem);
2366
- if (cartItems.length === 0) return { success: true, minAvailableCount: 0 };
2390
+ if (cartItems.length === 0)
2391
+ return { success: true, minAvailableCount: 0 };
2367
2392
  const itemsWithTime = [];
2368
2393
  const itemsWithoutTime = [];
2369
2394
  const availableCountsByResourceType = [];
@@ -2379,7 +2404,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2379
2404
  const itemsByResourceType = {};
2380
2405
  itemsWithoutTime.forEach((cartItem) => {
2381
2406
  var _a2;
2382
- if (!cartItem._productOrigin) return;
2407
+ if (!cartItem._productOrigin)
2408
+ return;
2383
2409
  const resourceTypes = ((_a2 = cartItem._productOrigin.product_resource) == null ? void 0 : _a2.resources) || [];
2384
2410
  resourceTypes.forEach((resourceType) => {
2385
2411
  var _a3;
@@ -2395,10 +2421,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2395
2421
  });
2396
2422
  });
2397
2423
  const dateRange = this.store.date.getDateRange();
2398
- if (!dateRange || dateRange.length === 0) return { success: false, minAvailableCount: 0 };
2424
+ if (!dateRange || dateRange.length === 0)
2425
+ return { success: false, minAvailableCount: 0 };
2399
2426
  const resourcesDates = this.store.date.getDateList();
2400
2427
  const targetResourceDate = resourcesDates.find((n) => n.date === dateRange[0].date);
2401
- if (!targetResourceDate) return { success: false, minAvailableCount: 0 };
2428
+ if (!targetResourceDate)
2429
+ return { success: false, minAvailableCount: 0 };
2402
2430
  const resourcesMap = (0, import_utils2.getResourcesMap)(targetResourceDate.resource || []);
2403
2431
  const resourceCodeToFormIdMap = {};
2404
2432
  Object.values(itemsByResourceType).flat().forEach((cartItem) => {
@@ -2421,7 +2449,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2421
2449
  for (const [resourceCode, items] of Object.entries(itemsByResourceType)) {
2422
2450
  const targetFormId = resourceCodeToFormIdMap[resourceCode];
2423
2451
  if (!targetFormId) {
2424
- console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} \u627E\u4E0D\u5230\u5BF9\u5E94\u7684 form_id`);
2452
+ console.log(`资源类型 ${resourceCode} 找不到对应的 form_id`);
2425
2453
  return { success: false, minAvailableCount: 0 };
2426
2454
  }
2427
2455
  const resourcesOfThisType = [];
@@ -2438,7 +2466,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2438
2466
  });
2439
2467
  });
2440
2468
  if (resourcesOfThisType.length === 0) {
2441
- console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} \u6CA1\u6709\u627E\u5230\u53EF\u7528\u8D44\u6E90`);
2469
+ console.log(`资源类型 ${resourceCode} 没有找到可用资源`);
2442
2470
  return { success: false, minAvailableCount: 0 };
2443
2471
  }
2444
2472
  let resourceTypeConfig = null;
@@ -2447,7 +2475,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2447
2475
  resourceTypeConfig = cartItem._productOrigin.product_resource.resources.find(
2448
2476
  (r) => r.code === resourceCode && r.status === 1
2449
2477
  );
2450
- if (resourceTypeConfig) break;
2478
+ if (resourceTypeConfig)
2479
+ break;
2451
2480
  }
2452
2481
  }
2453
2482
  const isMultipleBooking = (resourceTypeConfig == null ? void 0 : resourceTypeConfig.type) === "multiple";
@@ -2480,20 +2509,20 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2480
2509
  availableCountsByResourceType.push(availableAmount);
2481
2510
  if (requiredAmount > totalAvailable) {
2482
2511
  hasCapacityIssue = true;
2483
- console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} ${isMultipleBooking ? "\u5BB9\u91CF" : "\u8D44\u6E90\u6570\u91CF"}\u4E0D\u8DB3: \u9700\u8981 ${requiredAmount}, \u603B\u5171 ${totalAvailable}`);
2512
+ console.log(`资源类型 ${resourceCode} ${isMultipleBooking ? "容量" : "资源数量"}不足: 需要 ${requiredAmount}, 总共 ${totalAvailable}`);
2484
2513
  }
2485
- console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} \u7684\u8D44\u6E90\u65F6\u95F4\u4FE1\u606F:`, resourcesOfThisType.map((r) => ({
2514
+ console.log(`资源类型 ${resourceCode} 的资源时间信息:`, resourcesOfThisType.map((r) => ({
2486
2515
  id: r.id,
2487
2516
  times: r.times.map((t) => `${t.start_at} - ${t.end_at}`)
2488
2517
  })));
2489
2518
  const commonTimeSlots = this.findCommonAvailableTimeSlots(resourcesOfThisType);
2490
- console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} \u7684\u516C\u5171\u65F6\u95F4\u6BB5:`, commonTimeSlots);
2519
+ console.log(`资源类型 ${resourceCode} 的公共时间段:`, commonTimeSlots);
2491
2520
  if (commonTimeSlots.length === 0) {
2492
- console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} \u6CA1\u6709\u516C\u5171\u53EF\u7528\u65F6\u95F4\u6BB5`);
2521
+ console.log(`资源类型 ${resourceCode} 没有公共可用时间段`);
2493
2522
  return { success: false, minAvailableCount: 0 };
2494
2523
  }
2495
2524
  const firstCommonSlot = commonTimeSlots[0];
2496
- console.log(`\u4F7F\u7528\u516C\u5171\u65F6\u95F4\u6BB5: ${firstCommonSlot.startTime} - ${firstCommonSlot.endTime}`);
2525
+ console.log(`使用公共时间段: ${firstCommonSlot.startTime} - ${firstCommonSlot.endTime}`);
2497
2526
  items.forEach((cartItem) => {
2498
2527
  if (!processedCartItemIds.has(cartItem._id)) {
2499
2528
  processedCartItemIds.add(cartItem._id);
@@ -2521,7 +2550,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2521
2550
  const allProcessedItems = [...itemsWithTime, ...processedItemsWithoutTime];
2522
2551
  const cartItemsByTimeSlot = {};
2523
2552
  allProcessedItems.forEach((cartItem) => {
2524
- if (!cartItem.start_time || !cartItem.end_time || !cartItem.start_date) return;
2553
+ if (!cartItem.start_time || !cartItem.end_time || !cartItem.start_date)
2554
+ return;
2525
2555
  const timeSlotKey = `${cartItem.start_date}_${cartItem.start_time}_${cartItem.end_date || cartItem.start_date}_${cartItem.end_time}`;
2526
2556
  if (!cartItemsByTimeSlot[timeSlotKey]) {
2527
2557
  cartItemsByTimeSlot[timeSlotKey] = [];
@@ -2536,10 +2566,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2536
2566
  const resourcesIdSet = /* @__PURE__ */ new Set();
2537
2567
  const resourcesDates = this.store.date.getDateList();
2538
2568
  const targetResourceDate = resourcesDates.find((n) => n.date === startDate);
2539
- if (!targetResourceDate) continue;
2569
+ if (!targetResourceDate)
2570
+ continue;
2540
2571
  const resourcesMap = (0, import_utils2.getResourcesMap)(targetResourceDate.resource || []);
2541
2572
  itemsInTimeSlot.forEach((cartItem) => {
2542
- if (!cartItem._productOrigin) return;
2573
+ if (!cartItem._productOrigin)
2574
+ return;
2543
2575
  const productResourceIds = (0, import_capacity.getResourcesIdsByProduct)(cartItem._productOrigin);
2544
2576
  productResourceIds.forEach((resourceId) => {
2545
2577
  if (resourcesMap[resourceId] && !resourcesIdSet.has(resourceId)) {
@@ -2596,19 +2628,22 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2596
2628
  const resources = [];
2597
2629
  if (dateRange == null ? void 0 : dateRange.length) {
2598
2630
  dateRange.forEach((n) => {
2599
- if (n.resource) resources.push(...n.resource);
2631
+ if (n.resource)
2632
+ resources.push(...n.resource);
2600
2633
  });
2601
2634
  }
2602
2635
  if (!resources.length) {
2603
2636
  const dateList = this.store.date.getDateList();
2604
2637
  dateList.forEach((n) => {
2605
- if (n.resource) resources.push(...n.resource);
2638
+ if (n.resource)
2639
+ resources.push(...n.resource);
2606
2640
  });
2607
2641
  }
2608
2642
  const resourcesMap = (0, import_utils2.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
2609
2643
  const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
2610
2644
  const cartItem = cartItems.find((item) => item._id === cartItemId);
2611
- if (!cartItem) return [];
2645
+ if (!cartItem)
2646
+ return [];
2612
2647
  let selectedResources = [];
2613
2648
  const { currentCapacity, formatCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(cartItem);
2614
2649
  cartItem._origin.metadata.capacity = formatCapacity;
@@ -2634,7 +2669,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2634
2669
  const targetResource = productResources.find(
2635
2670
  (resource) => resource.code === resourceCode
2636
2671
  );
2637
- if (!targetResource) return [];
2672
+ if (!targetResource)
2673
+ return [];
2638
2674
  if (cartItem._origin.start_time) {
2639
2675
  const startTime = (0, import_dayjs.default)(
2640
2676
  `${cartItem._origin.start_date} ${cartItem._origin.start_time}`
@@ -2648,8 +2684,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2648
2684
  var _a2, _b2, _c, _d;
2649
2685
  const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
2650
2686
  const bIsCombined = ((_d = (_c = b.metadata) == null ? void 0 : _c.combined_resource) == null ? void 0 : _d.status) === 1;
2651
- if (aIsCombined && !bIsCombined) return 1;
2652
- if (!aIsCombined && bIsCombined) return -1;
2687
+ if (aIsCombined && !bIsCombined)
2688
+ return 1;
2689
+ if (!aIsCombined && bIsCombined)
2690
+ return -1;
2653
2691
  return 0;
2654
2692
  }
2655
2693
  );
@@ -2657,7 +2695,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2657
2695
  const mTimes = m.times.filter((n) => {
2658
2696
  return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(startTime)) && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(endTime));
2659
2697
  });
2660
- if (mTimes.length === 0) return false;
2698
+ if (mTimes.length === 0)
2699
+ return false;
2661
2700
  const canUseArr = mTimes.map((item) => {
2662
2701
  var _a2;
2663
2702
  const res = (0, import_resources.getIsUsableByTimeItem)({
@@ -2678,14 +2717,16 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2678
2717
  }
2679
2718
  return res.usable;
2680
2719
  });
2681
- if (m.onlyComputed) return false;
2720
+ if (m.onlyComputed)
2721
+ return false;
2682
2722
  return !canUseArr.some((n) => n === false);
2683
2723
  });
2684
2724
  } else {
2685
2725
  targetResource.renderList = targetResource.renderList.filter((n) => {
2686
2726
  var _a2, _b2;
2687
2727
  const recordCount = n.capacity || 0;
2688
- if (n.onlyComputed) return false;
2728
+ if (n.onlyComputed)
2729
+ return false;
2689
2730
  const timeSlots = (0, import_resources.getTimeSlicesByResource)({
2690
2731
  resource: n,
2691
2732
  duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
@@ -2876,7 +2917,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2876
2917
  }
2877
2918
  dates = (0, import_utils4.handleAvailableDateByResource)(res.data, dates);
2878
2919
  this.store.date.setDateList(dates);
2879
- if (!this.store.currentProductMeta) this.store.currentProductMeta = {};
2920
+ if (!this.store.currentProductMeta)
2921
+ this.store.currentProductMeta = {};
2880
2922
  this.store.currentProductMeta.timeSlotBySchedule = {
2881
2923
  dateList: dates,
2882
2924
  firstAvailableDate,
@@ -2900,7 +2942,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2900
2942
  });
2901
2943
  }
2902
2944
  isTargetNormalProduct(product) {
2903
- if (!product) return false;
2945
+ if (!product)
2946
+ return false;
2904
2947
  return (0, import_utils5.isNormalProduct)(product);
2905
2948
  }
2906
2949
  isTargetCartIdNormalProduct(id) {