@pisell/pisellos 0.0.205 → 0.0.207

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 (48) hide show
  1. package/dist/effects/index.d.ts +1 -1
  2. package/dist/modules/Order/utils.js +8 -2
  3. package/dist/modules/Rules/types.d.ts +1 -1
  4. package/dist/modules/Schedule/type.d.ts +7 -7
  5. package/dist/modules/Schedule/types.d.ts +9 -9
  6. package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
  7. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  8. package/dist/types/index.d.ts +1 -1
  9. package/lib/core/index.js +27 -28
  10. package/lib/effects/index.d.ts +1 -1
  11. package/lib/effects/index.js +3 -7
  12. package/lib/modules/Account/index.js +9 -10
  13. package/lib/modules/AccountList/index.js +14 -11
  14. package/lib/modules/BaseModule.js +6 -3
  15. package/lib/modules/Cart/index.js +14 -9
  16. package/lib/modules/Cart/utils/cartProduct.js +3 -6
  17. package/lib/modules/Date/index.js +8 -4
  18. package/lib/modules/Date/types.js +1 -0
  19. package/lib/modules/Discount/index.js +11 -6
  20. package/lib/modules/Guests/index.js +10 -15
  21. package/lib/modules/Order/index.js +4 -2
  22. package/lib/modules/Order/utils.js +3 -2
  23. package/lib/modules/Payment/cash.js +1 -1
  24. package/lib/modules/Payment/eftpos.js +1 -1
  25. package/lib/modules/Payment/index.js +98 -86
  26. package/lib/modules/Payment/wallet.js +1 -1
  27. package/lib/modules/Product/index.js +6 -5
  28. package/lib/modules/ProductList/index.js +5 -4
  29. package/lib/modules/Resource/index.js +8 -12
  30. package/lib/modules/Rules/index.js +10 -13
  31. package/lib/modules/Rules/types.d.ts +1 -1
  32. package/lib/modules/Schedule/index.js +8 -5
  33. package/lib/modules/Schedule/type.d.ts +7 -7
  34. package/lib/modules/Schedule/types.d.ts +9 -9
  35. package/lib/modules/Schedule/utils.js +2 -4
  36. package/lib/modules/Step/index.js +7 -4
  37. package/lib/modules/Summary/index.js +9 -4
  38. package/lib/plugins/request.js +34 -33
  39. package/lib/plugins/window.js +101 -113
  40. package/lib/solution/BookingByStep/index.js +44 -69
  41. package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
  42. package/lib/solution/BookingByStep/utils/resources.js +4 -8
  43. package/lib/solution/BookingByStep/utils/timeslots.js +6 -12
  44. package/lib/solution/BuyTickets/index.js +15 -15
  45. package/lib/solution/ShopDiscount/index.js +15 -11
  46. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  47. package/lib/types/index.d.ts +1 -1
  48. package/package.json +1 -1
@@ -23,9 +23,7 @@ __export(window_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(window_exports);
25
25
  var SimpleStorage = class {
26
- constructor() {
27
- this.items = {};
28
- }
26
+ items = {};
29
27
  get length() {
30
28
  return Object.keys(this.items).length;
31
29
  }
@@ -47,18 +45,16 @@ var SimpleStorage = class {
47
45
  }
48
46
  };
49
47
  var SimpleLocation = class {
50
- constructor() {
51
- this.hash = "";
52
- this.host = "localhost";
53
- this.hostname = "localhost";
54
- this.href = "https://localhost";
55
- this.origin = "https://localhost";
56
- this.pathname = "/";
57
- this.port = "";
58
- this.protocol = "https:";
59
- this.search = "";
60
- this.ancestorOrigins = {};
61
- }
48
+ hash = "";
49
+ host = "localhost";
50
+ hostname = "localhost";
51
+ href = "https://localhost";
52
+ origin = "https://localhost";
53
+ pathname = "/";
54
+ port = "";
55
+ protocol = "https:";
56
+ search = "";
57
+ ancestorOrigins = {};
62
58
  assign(url) {
63
59
  }
64
60
  reload() {
@@ -70,29 +66,25 @@ var SimpleLocation = class {
70
66
  }
71
67
  };
72
68
  var SimpleNavigator = class {
73
- constructor() {
74
- this.userAgent = "PisellOS/1.0";
75
- this.language = "zh-CN";
76
- this.languages = ["zh-CN", "en-US"];
77
- this.onLine = true;
78
- this.cookieEnabled = true;
79
- // 以下属性只提供必要实现
80
- this.appCodeName = "PisellOS";
81
- this.appName = "PisellOS";
82
- this.appVersion = "1.0";
83
- this.platform = "PisellOS";
84
- this.product = "PisellOS";
85
- }
69
+ userAgent = "PisellOS/1.0";
70
+ language = "zh-CN";
71
+ languages = ["zh-CN", "en-US"];
72
+ onLine = true;
73
+ cookieEnabled = true;
74
+ // 以下属性只提供必要实现
75
+ appCodeName = "PisellOS";
76
+ appName = "PisellOS";
77
+ appVersion = "1.0";
78
+ platform = "PisellOS";
79
+ product = "PisellOS";
86
80
  javaEnabled() {
87
81
  return false;
88
82
  }
89
83
  };
90
84
  var SimpleHistory = class {
91
- constructor() {
92
- this.length = 0;
93
- this.scrollRestoration = "auto";
94
- this.state = null;
95
- }
85
+ length = 0;
86
+ scrollRestoration = "auto";
87
+ state = null;
96
88
  back() {
97
89
  }
98
90
  forward() {
@@ -105,17 +97,8 @@ var SimpleHistory = class {
105
97
  }
106
98
  };
107
99
  var SimpleDocument = class {
108
- constructor() {
109
- // 仅实现基本功能
110
- this.elements = {};
111
- // Document 接口的必要属性
112
- this.URL = "https://localhost";
113
- this.documentURI = "https://localhost";
114
- this.origin = "https://localhost";
115
- this.characterSet = "UTF-8";
116
- this.contentType = "text/html";
117
- this.compatMode = "CSS1Compat";
118
- }
100
+ // 仅实现基本功能
101
+ elements = {};
119
102
  createElement(tagName) {
120
103
  const element = {
121
104
  tagName: tagName.toUpperCase(),
@@ -155,6 +138,13 @@ var SimpleDocument = class {
155
138
  getElementById(id) {
156
139
  return this.elements[id] || null;
157
140
  }
141
+ // Document 接口的必要属性
142
+ URL = "https://localhost";
143
+ documentURI = "https://localhost";
144
+ origin = "https://localhost";
145
+ characterSet = "UTF-8";
146
+ contentType = "text/html";
147
+ compatMode = "CSS1Compat";
158
148
  querySelector() {
159
149
  return null;
160
150
  }
@@ -169,84 +159,82 @@ var SimpleDocument = class {
169
159
  }
170
160
  };
171
161
  var WindowPluginImpl = class {
172
- constructor() {
173
- this.name = "window";
174
- this.version = "1.0.0";
175
- // 定时器相关
176
- this.setTimeout = Object.assign(
177
- function(handler, timeout, ...args) {
178
- if (typeof globalThis !== "undefined" && globalThis.setTimeout) {
179
- return globalThis.setTimeout(handler, timeout, ...args);
180
- }
181
- const timeoutId = Date.now();
182
- Promise.resolve().then(() => {
183
- setTimeout(() => {
184
- if (typeof handler === "function") {
185
- handler(...args);
186
- } else {
187
- eval(handler);
188
- }
189
- }, timeout || 0);
190
- });
191
- return timeoutId;
192
- },
193
- {
194
- __promisify__: function(delay, value) {
195
- return new Promise((resolve) => setTimeout(resolve, delay, value));
196
- }
162
+ name = "window";
163
+ version = "1.0.0";
164
+ // 定时器相关
165
+ setTimeout = Object.assign(
166
+ function(handler, timeout, ...args) {
167
+ if (typeof globalThis !== "undefined" && globalThis.setTimeout) {
168
+ return globalThis.setTimeout(handler, timeout, ...args);
197
169
  }
198
- );
199
- this.clearTimeout = function(timeout2) {
200
- if (typeof globalThis !== "undefined" && globalThis.clearTimeout) {
201
- globalThis.clearTimeout(timeout2);
170
+ const timeoutId = Date.now();
171
+ Promise.resolve().then(() => {
172
+ setTimeout(() => {
173
+ if (typeof handler === "function") {
174
+ handler(...args);
175
+ } else {
176
+ eval(handler);
177
+ }
178
+ }, timeout || 0);
179
+ });
180
+ return timeoutId;
181
+ },
182
+ {
183
+ __promisify__: function(delay, value) {
184
+ return new Promise((resolve) => setTimeout(resolve, delay, value));
202
185
  }
203
- };
204
- this.setInterval = Object.assign(
205
- function(handler, timeout, ...args) {
206
- if (typeof globalThis !== "undefined" && globalThis.setInterval) {
207
- return globalThis.setInterval(handler, timeout, ...args);
208
- }
209
- const intervalId = Date.now();
210
- const recursiveTimeout = () => {
211
- this.setTimeout(() => {
212
- if (typeof handler === "function") {
213
- handler(...args);
214
- } else {
215
- eval(handler);
216
- }
217
- recursiveTimeout();
218
- }, timeout || 0);
219
- };
220
- recursiveTimeout();
221
- return intervalId;
222
- },
223
- {
224
- __promisify__: function(delay, value) {
225
- return new Promise((resolve) => setInterval(resolve, delay, value));
226
- }
186
+ }
187
+ );
188
+ clearTimeout = function(timeout2) {
189
+ if (typeof globalThis !== "undefined" && globalThis.clearTimeout) {
190
+ globalThis.clearTimeout(timeout2);
191
+ }
192
+ };
193
+ setInterval = Object.assign(
194
+ function(handler, timeout, ...args) {
195
+ if (typeof globalThis !== "undefined" && globalThis.setInterval) {
196
+ return globalThis.setInterval(handler, timeout, ...args);
227
197
  }
228
- );
229
- this.clearInterval = function(timeout2) {
230
- if (typeof globalThis !== "undefined" && globalThis.clearInterval) {
231
- globalThis.clearInterval(timeout2);
198
+ const intervalId = Date.now();
199
+ const recursiveTimeout = () => {
200
+ this.setTimeout(() => {
201
+ if (typeof handler === "function") {
202
+ handler(...args);
203
+ } else {
204
+ eval(handler);
205
+ }
206
+ recursiveTimeout();
207
+ }, timeout || 0);
208
+ };
209
+ recursiveTimeout();
210
+ return intervalId;
211
+ },
212
+ {
213
+ __promisify__: function(delay, value) {
214
+ return new Promise((resolve) => setInterval(resolve, delay, value));
232
215
  }
233
- };
234
- // 存储相关
235
- this.localStorage = new SimpleStorage();
236
- this.sessionStorage = new SimpleStorage();
237
- // 浏览器环境对象
238
- this.location = new SimpleLocation();
239
- this.navigator = new SimpleNavigator();
240
- this.document = new SimpleDocument();
241
- this.history = new SimpleHistory();
242
- }
216
+ }
217
+ );
218
+ clearInterval = function(timeout2) {
219
+ if (typeof globalThis !== "undefined" && globalThis.clearInterval) {
220
+ globalThis.clearInterval(timeout2);
221
+ }
222
+ };
223
+ // 存储相关
224
+ localStorage = new SimpleStorage();
225
+ sessionStorage = new SimpleStorage();
226
+ // 浏览器环境对象
227
+ location = new SimpleLocation();
228
+ navigator = new SimpleNavigator();
229
+ document = new SimpleDocument();
230
+ history = new SimpleHistory();
243
231
  // 初始化方法
244
232
  initialize() {
245
- console.log("[WindowPlugin] 初始化完成");
233
+ console.log("[WindowPlugin] \u521D\u59CB\u5316\u5B8C\u6210");
246
234
  }
247
235
  // 销毁方法
248
236
  destroy() {
249
- console.log("[WindowPlugin] 已销毁");
237
+ console.log("[WindowPlugin] \u5DF2\u9500\u6BC1");
250
238
  }
251
239
  };
252
240
  var window_default = new WindowPluginImpl();
@@ -50,29 +50,31 @@ var import_capacity = require("./utils/capacity");
50
50
  import_dayjs.default.extend(import_isSameOrBefore.default);
51
51
  import_dayjs.default.extend(import_isSameOrAfter.default);
52
52
  var BookingByStepImpl = class extends import_BaseModule.BaseModule {
53
- constructor() {
54
- super(...arguments);
55
- this.defaultName = "bookingByStep";
56
- this.defaultVersion = "1.0.0";
57
- this.isSolution = true;
58
- this.otherParams = {};
59
- this.otherData = {};
60
- }
53
+ defaultName = "bookingByStep";
54
+ defaultVersion = "1.0.0";
55
+ isSolution = true;
56
+ request;
57
+ window;
58
+ shopStore;
59
+ store;
60
+ otherParams = {};
61
+ cacheId;
62
+ otherData = {};
61
63
  // 提供给 UI 层的临时数据存储,会进缓存
62
64
  async initialize(core, options) {
63
65
  var _a, _b, _c, _d;
64
66
  this.core = core;
65
67
  this.store = options.store || {};
66
68
  this.otherParams = options.otherParams || {};
67
- console.log("[BookingByStep] 初始化完成");
69
+ console.log("[BookingByStep] \u521D\u59CB\u5316\u5B8C\u6210");
68
70
  this.request = core.getPlugin("request");
69
71
  this.window = core.getPlugin("window");
70
72
  this.shopStore = core.getPlugin("shopStore");
71
73
  if (!this.request) {
72
- throw new Error("bookingByStep解决方案需要 request 插件支持");
74
+ throw new Error("bookingByStep\u89E3\u51B3\u65B9\u6848\u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
73
75
  }
74
76
  if (!this.shopStore) {
75
- throw new Error("SummaryModule 需要 shopStore 插件支持");
77
+ throw new Error("SummaryModule \u9700\u8981 shopStore \u63D2\u4EF6\u652F\u6301");
76
78
  }
77
79
  let targetCacheData = {};
78
80
  this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
@@ -109,7 +111,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
109
111
  }
110
112
  });
111
113
  } else {
112
- throw new Error(`模块 ${step} 不存在`);
114
+ throw new Error(`\u6A21\u5757 ${step} \u4E0D\u5B58\u5728`);
113
115
  }
114
116
  });
115
117
  this.store.schedule.loadAllSchedule();
@@ -477,7 +479,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
477
479
  this.updateQuotationPriceAndCart(date);
478
480
  }
479
481
  } else {
480
- throw new Error(`没有找到${accountId}账户`);
482
+ throw new Error(`\u6CA1\u6709\u627E\u5230${accountId}\u8D26\u6237`);
481
483
  }
482
484
  }
483
485
  // 生成购物车的正规数据
@@ -666,7 +668,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
666
668
  updateCart(params) {
667
669
  const targetCartItem = this.store.cart.getItem(params._id);
668
670
  if (!targetCartItem) {
669
- throw new Error(`没有找到${params._id}购物车商品`);
671
+ throw new Error(`\u6CA1\u6709\u627E\u5230${params._id}\u8D2D\u7269\u8F66\u5546\u54C1`);
670
672
  }
671
673
  this.beforeUpdateCart(params, targetCartItem);
672
674
  this.store.cart.updateItem(params);
@@ -693,15 +695,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
693
695
  const dateRange = this.store.date.getDateRange();
694
696
  if (dateRange == null ? void 0 : dateRange.length) {
695
697
  dateRange.forEach((n) => {
696
- if (n.resource)
697
- allOriginResources.push(...n.resource);
698
+ if (n.resource) allOriginResources.push(...n.resource);
698
699
  });
699
700
  }
700
701
  if (!allOriginResources.length) {
701
702
  const dateList = this.store.date.getDateList();
702
703
  dateList.forEach((n) => {
703
- if (n.resource)
704
- allOriginResources.push(...n.resource);
704
+ if (n.resource) allOriginResources.push(...n.resource);
705
705
  });
706
706
  }
707
707
  if (params.resources) {
@@ -830,8 +830,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
830
830
  const resources = [];
831
831
  if (dateRange == null ? void 0 : dateRange.length) {
832
832
  dateRange.forEach((n) => {
833
- if (n.resource)
834
- resources.push(...n.resource);
833
+ if (n.resource) resources.push(...n.resource);
835
834
  });
836
835
  }
837
836
  const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
@@ -845,8 +844,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
845
844
  } else {
846
845
  const dateList = this.store.date.getDateList();
847
846
  dateList.forEach((n) => {
848
- if (n.resource)
849
- resources.push(...n.resource);
847
+ if (n.resource) resources.push(...n.resource);
850
848
  });
851
849
  }
852
850
  }
@@ -915,8 +913,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
915
913
  }
916
914
  return res.usable;
917
915
  });
918
- if (m.onlyComputed)
919
- return false;
916
+ if (m.onlyComputed) return false;
920
917
  return !canUseArr.some((n2) => n2 === false);
921
918
  });
922
919
  });
@@ -927,8 +924,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
927
924
  item.renderList = item.renderList.filter((n) => {
928
925
  var _a2, _b2, _c2;
929
926
  const recordCount = n.capacity || 0;
930
- if (n.onlyComputed)
931
- return false;
927
+ if (n.onlyComputed) return false;
932
928
  const timeSlots = (0, import_resources.getTimeSlicesByResource)({
933
929
  resource: n,
934
930
  duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
@@ -981,13 +977,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
981
977
  const dateRange = this.store.date.getDateRange();
982
978
  const resources = [];
983
979
  dateRange.forEach((n) => {
984
- if (n.resource)
985
- resources.push(...n.resource);
980
+ if (n.resource) resources.push(...n.resource);
986
981
  });
987
982
  const resourcesMap = (0, import_utils.getResourcesMap)(resources);
988
983
  const targetCartItem = cartItems.find((n) => n._id === id);
989
984
  if (!targetCartItem) {
990
- throw new Error(`没有找到${id}购物车商品`);
985
+ throw new Error(`\u6CA1\u6709\u627E\u5230${id}\u8D2D\u7269\u8F66\u5546\u54C1`);
991
986
  }
992
987
  let selectedResources = [];
993
988
  const { currentCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(targetCartItem);
@@ -1013,8 +1008,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1013
1008
  productResources.forEach((item) => {
1014
1009
  item.renderList = item.renderList.filter((n) => {
1015
1010
  const recordCount = n.capacity || 0;
1016
- if (n.onlyComputed)
1017
- return false;
1011
+ if (n.onlyComputed) return false;
1018
1012
  return recordCount >= currentCapacity;
1019
1013
  });
1020
1014
  });
@@ -1057,8 +1051,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1057
1051
  let AllResources = [];
1058
1052
  if (dateRange == null ? void 0 : dateRange.length) {
1059
1053
  dateRange.forEach((n) => {
1060
- if (n.resource)
1061
- AllResources.push(...n.resource);
1054
+ if (n.resource) AllResources.push(...n.resource);
1062
1055
  });
1063
1056
  }
1064
1057
  if (!AllResources.length) {
@@ -1071,8 +1064,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1071
1064
  } else {
1072
1065
  const dateList = this.store.date.getDateList();
1073
1066
  dateList.forEach((n) => {
1074
- if (n.resource)
1075
- AllResources.push(...n.resource);
1067
+ if (n.resource) AllResources.push(...n.resource);
1076
1068
  });
1077
1069
  }
1078
1070
  }
@@ -1094,10 +1086,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1094
1086
  var _a2, _b2, _c2, _d;
1095
1087
  const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
1096
1088
  const bIsCombined = ((_d = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d.status) === 1;
1097
- if (aIsCombined && !bIsCombined)
1098
- return 1;
1099
- if (!aIsCombined && bIsCombined)
1100
- return -1;
1089
+ if (aIsCombined && !bIsCombined) return 1;
1090
+ if (!aIsCombined && bIsCombined) return -1;
1101
1091
  return 0;
1102
1092
  });
1103
1093
  const resourcesUseableMap = [
@@ -1184,8 +1174,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1184
1174
  const resources = [];
1185
1175
  if ((_a = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _a.date) {
1186
1176
  dateRange.forEach((n) => {
1187
- if (n.resource)
1188
- resources.push(...n.resource);
1177
+ if (n.resource) resources.push(...n.resource);
1189
1178
  });
1190
1179
  }
1191
1180
  const errorList = [];
@@ -1318,8 +1307,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1318
1307
  productResources.forEach((item2) => {
1319
1308
  item2.renderList = item2.renderList.filter((n) => {
1320
1309
  const recordCount = (n.capacity || 0) - (selectResourcesMap[n.id] || 0);
1321
- if (n.onlyComputed)
1322
- return false;
1310
+ if (n.onlyComputed) return false;
1323
1311
  return recordCount >= currentCapacity;
1324
1312
  });
1325
1313
  });
@@ -1592,8 +1580,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1592
1580
  targetProduct.setOtherParams("schedule", newScheduleArr);
1593
1581
  } else if (targetProductData.duration) {
1594
1582
  const dateRange = this.store.date.getDateRange();
1595
- if (!(dateRange == null ? void 0 : dateRange.length))
1596
- return;
1583
+ if (!(dateRange == null ? void 0 : dateRange.length)) return;
1597
1584
  this.getAvailableDate({
1598
1585
  startDate: dateRange[0].date,
1599
1586
  endDate: dateRange[dateRange.length - 1].date,
@@ -1650,10 +1637,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1650
1637
  var _a2, _b2, _c2, _d2;
1651
1638
  const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
1652
1639
  const bIsCombined = ((_d2 = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d2.status) === 1;
1653
- if (aIsCombined && !bIsCombined)
1654
- return 1;
1655
- if (!aIsCombined && bIsCombined)
1656
- return -1;
1640
+ if (aIsCombined && !bIsCombined) return 1;
1641
+ if (!aIsCombined && bIsCombined) return -1;
1657
1642
  return 0;
1658
1643
  });
1659
1644
  const firstEnabledResourceId = (_f = (_e = (_d = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _d.resources) == null ? void 0 : _e.find(
@@ -1752,22 +1737,19 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1752
1737
  const resources = [];
1753
1738
  if (dateRange == null ? void 0 : dateRange.length) {
1754
1739
  dateRange.forEach((n) => {
1755
- if (n.resource)
1756
- resources.push(...n.resource);
1740
+ if (n.resource) resources.push(...n.resource);
1757
1741
  });
1758
1742
  }
1759
1743
  if (!resources.length) {
1760
1744
  const dateList = this.store.date.getDateList();
1761
1745
  dateList.forEach((n) => {
1762
- if (n.resource)
1763
- resources.push(...n.resource);
1746
+ if (n.resource) resources.push(...n.resource);
1764
1747
  });
1765
1748
  }
1766
1749
  const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
1767
1750
  const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
1768
1751
  const cartItem = cartItems.find((item) => item._id === cartItemId);
1769
- if (!cartItem)
1770
- return [];
1752
+ if (!cartItem) return [];
1771
1753
  let selectedResources = [];
1772
1754
  const { currentCapacity, formatCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(cartItem);
1773
1755
  cartItem._origin.metadata.capacity = formatCapacity;
@@ -1793,8 +1775,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1793
1775
  const targetResource = productResources.find(
1794
1776
  (resource) => resource.code === resourceCode
1795
1777
  );
1796
- if (!targetResource)
1797
- return [];
1778
+ if (!targetResource) return [];
1798
1779
  if (cartItem._origin.start_time) {
1799
1780
  const startTime = (0, import_dayjs.default)(
1800
1781
  `${cartItem._origin.start_date} ${cartItem._origin.start_time}`
@@ -1808,10 +1789,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1808
1789
  var _a2, _b2, _c, _d;
1809
1790
  const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
1810
1791
  const bIsCombined = ((_d = (_c = b.metadata) == null ? void 0 : _c.combined_resource) == null ? void 0 : _d.status) === 1;
1811
- if (aIsCombined && !bIsCombined)
1812
- return 1;
1813
- if (!aIsCombined && bIsCombined)
1814
- return -1;
1792
+ if (aIsCombined && !bIsCombined) return 1;
1793
+ if (!aIsCombined && bIsCombined) return -1;
1815
1794
  return 0;
1816
1795
  }
1817
1796
  );
@@ -1819,8 +1798,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1819
1798
  const mTimes = m.times.filter((n) => {
1820
1799
  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));
1821
1800
  });
1822
- if (mTimes.length === 0)
1823
- return false;
1801
+ if (mTimes.length === 0) return false;
1824
1802
  const canUseArr = mTimes.map((item) => {
1825
1803
  var _a2;
1826
1804
  const res = (0, import_resources.getIsUsableByTimeItem)({
@@ -1841,16 +1819,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1841
1819
  }
1842
1820
  return res.usable;
1843
1821
  });
1844
- if (m.onlyComputed)
1845
- return false;
1822
+ if (m.onlyComputed) return false;
1846
1823
  return !canUseArr.some((n) => n === false);
1847
1824
  });
1848
1825
  } else {
1849
1826
  targetResource.renderList = targetResource.renderList.filter((n) => {
1850
1827
  var _a2, _b2;
1851
1828
  const recordCount = n.capacity || 0;
1852
- if (n.onlyComputed)
1853
- return false;
1829
+ if (n.onlyComputed) return false;
1854
1830
  const timeSlots = (0, import_resources.getTimeSlicesByResource)({
1855
1831
  resource: n,
1856
1832
  duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
@@ -2064,8 +2040,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2064
2040
  });
2065
2041
  }
2066
2042
  isTargetNormalProduct(product) {
2067
- if (!product)
2068
- return false;
2043
+ if (!product) return false;
2069
2044
  return (0, import_utils4.isNormalProduct)(product);
2070
2045
  }
2071
2046
  isTargetCartIdNormalProduct(id) {
@@ -6,7 +6,7 @@ import { CartItem, ProductData } from '../../../modules';
6
6
  * 3. 格式化资源相关 格式化资源列表 --> 格式化资源 --> 获取时间切片列表 --> 判断单个时间切片是否可用 formatResources
7
7
  *
8
8
  */
9
- type DateType = Dayjs;
9
+ declare type DateType = Dayjs;
10
10
  export interface TimeSliceItem {
11
11
  start_time: string;
12
12
  end_time: string;
@@ -444,10 +444,8 @@ var getTimeSlicesByResources = ({
444
444
  var _a, _b, _c, _d;
445
445
  const aIsCombined = ((_b = (_a = a.metadata) == null ? void 0 : _a.combined_resource) == null ? void 0 : _b.status) === 1;
446
446
  const bIsCombined = ((_d = (_c = b.metadata) == null ? void 0 : _c.combined_resource) == null ? void 0 : _d.status) === 1;
447
- if (aIsCombined && !bIsCombined)
448
- return 1;
449
- if (!aIsCombined && bIsCombined)
450
- return -1;
447
+ if (aIsCombined && !bIsCombined) return 1;
448
+ if (!aIsCombined && bIsCombined) return -1;
451
449
  return 0;
452
450
  });
453
451
  let timeSliceList = resources.reduce(
@@ -530,8 +528,7 @@ var getOthersCartSelectedResources = (cartItems, cartItemId, resourcesMap) => {
530
528
  }, []);
531
529
  };
532
530
  function filterScheduleByDateRange(schedule, startDate, endDate) {
533
- if (!(schedule == null ? void 0 : schedule.length))
534
- return [];
531
+ if (!(schedule == null ? void 0 : schedule.length)) return [];
535
532
  const start = new Date(startDate);
536
533
  const end = new Date(endDate);
537
534
  return schedule.filter((item) => {
@@ -597,8 +594,7 @@ function filterResourcesByFormItem(resources, form_id) {
597
594
  }
598
595
  function checkTwoResourcesIntersection(resource1, resource2) {
599
596
  var _a, _b;
600
- if (resource1.id === resource2.id)
601
- return true;
597
+ if (resource1.id === resource2.id) return true;
602
598
  if (((_a = resource1.metadata.combined_resource) == null ? void 0 : _a.status) === 1 && // 如果现在选择的是组合资源,需要判断
603
599
  // 1、当前其他购物车里是否选了当前组合资源的子资源
604
600
  // 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
@@ -43,8 +43,7 @@ function calculateResourceAvailableTime({
43
43
  const matchingTimes = resource.times.filter((time) => {
44
44
  return (0, import_dayjs.default)(time.start_at).isSame((0, import_dayjs.default)(timeSlots.start_at), "day");
45
45
  });
46
- if (matchingTimes.length === 0)
47
- return 0;
46
+ if (matchingTimes.length === 0) return 0;
48
47
  const overlaps = [];
49
48
  for (const time of matchingTimes) {
50
49
  const overlapStart = (0, import_dayjs.default)(time.start_at).isAfter((0, import_dayjs.default)(timeSlots.start_at)) ? (0, import_dayjs.default)(time.start_at) : (0, import_dayjs.default)(timeSlots.start_at);
@@ -53,8 +52,7 @@ function calculateResourceAvailableTime({
53
52
  overlaps.push({ start: overlapStart, end: overlapEnd });
54
53
  }
55
54
  }
56
- if (overlaps.length === 0)
57
- return 0;
55
+ if (overlaps.length === 0) return 0;
58
56
  overlaps.sort((a, b) => a.start.diff(b.start));
59
57
  const merged = [];
60
58
  let current = overlaps[0];
@@ -87,15 +85,13 @@ function findFastestAvailableResource({
87
85
  const todayTimes = resource.times.filter((time) => {
88
86
  return (0, import_dayjs.default)(time.start_at).isSame(currentTime, "day");
89
87
  });
90
- if (todayTimes.length === 0)
91
- continue;
88
+ if (todayTimes.length === 0) continue;
92
89
  todayTimes.sort((a, b) => {
93
90
  return (0, import_dayjs.default)(a.start_at).diff((0, import_dayjs.default)(b.start_at));
94
91
  });
95
92
  for (const time of todayTimes) {
96
93
  const startTime = (0, import_dayjs.default)(time.start_at);
97
- if (startTime.isBefore(currentTime))
98
- continue;
94
+ if (startTime.isBefore(currentTime)) continue;
99
95
  if (resource.resourceType === "single") {
100
96
  const hasBooking = (_a = time.event_list) == null ? void 0 : _a.some((event) => {
101
97
  return (0, import_dayjs.default)(event.start_at).isSame(startTime);
@@ -129,10 +125,8 @@ function findFastestAvailableResource({
129
125
  }
130
126
  }
131
127
  }
132
- if (!fastestTime || fastestResources.length === 0)
133
- return null;
134
- if (fastestResources.length === 1)
135
- return fastestResources[0];
128
+ if (!fastestTime || fastestResources.length === 0) return null;
129
+ if (fastestResources.length === 1) return fastestResources[0];
136
130
  let maxIdleTime = 0;
137
131
  let selectedResource = null;
138
132
  for (const resource of fastestResources) {