@pisell/pisellos 1.0.147 → 1.0.148
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.
- package/dist/effects/index.d.ts +2 -2
- package/dist/model/strategy/adapter/itemRule/type.d.ts +6 -6
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/promotion/type.d.ts +5 -5
- package/dist/model/strategy/type.d.ts +1 -1
- package/dist/modules/Customer/types.d.ts +1 -1
- package/dist/modules/Discount/types.d.ts +1 -1
- package/dist/modules/Payment/types.d.ts +7 -7
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.js +2 -1
- package/dist/modules/Rules/types.d.ts +1 -1
- package/dist/modules/Schedule/getDateIsInSchedule.d.ts +1 -1
- package/dist/modules/Schedule/type.d.ts +7 -7
- package/dist/modules/Schedule/types.d.ts +9 -9
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ShopDiscount/types.d.ts +1 -1
- package/dist/solution/ShopDiscount/utils.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/task.d.ts +2 -2
- package/dist/utils/watch.d.ts +2 -2
- package/lib/core/index.js +27 -28
- package/lib/effects/index.d.ts +2 -2
- package/lib/effects/index.js +3 -7
- package/lib/model/strategy/adapter/itemRule/adapter.js +7 -14
- package/lib/model/strategy/adapter/itemRule/evaluator.js +5 -5
- package/lib/model/strategy/adapter/itemRule/examples.js +12 -12
- package/lib/model/strategy/adapter/itemRule/type.d.ts +6 -6
- package/lib/model/strategy/adapter/promotion/adapter.js +2 -4
- package/lib/model/strategy/adapter/promotion/evaluator.js +16 -19
- package/lib/model/strategy/adapter/promotion/examples.js +8 -8
- package/lib/model/strategy/adapter/promotion/type.d.ts +5 -5
- package/lib/model/strategy/adapter/walletPass/evaluator.js +5 -5
- package/lib/model/strategy/adapter/walletPass/example.js +21 -21
- package/lib/model/strategy/adapter/walletPass/index.js +2 -4
- package/lib/model/strategy/adapter/walletPass/locales.js +18 -18
- package/lib/model/strategy/adapter/walletPass/utils.js +21 -42
- package/lib/model/strategy/engine.js +6 -8
- package/lib/model/strategy/strategy-example.js +19 -19
- package/lib/model/strategy/type.d.ts +1 -1
- package/lib/modules/Account/index.js +9 -10
- package/lib/modules/AccountList/index.js +14 -11
- package/lib/modules/BaseModule.js +6 -3
- package/lib/modules/Cart/index.js +14 -9
- package/lib/modules/Cart/utils/cartProduct.js +3 -6
- package/lib/modules/Customer/constants.js +1 -1
- package/lib/modules/Customer/index.js +18 -15
- package/lib/modules/Customer/types.d.ts +1 -1
- package/lib/modules/Date/index.js +10 -6
- package/lib/modules/Date/types.js +1 -0
- package/lib/modules/Discount/index.js +11 -6
- package/lib/modules/Discount/types.d.ts +1 -1
- package/lib/modules/Guests/index.js +10 -15
- package/lib/modules/Order/index.js +10 -7
- package/lib/modules/Payment/cash.js +1 -1
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +1 -1
- package/lib/modules/Payment/eftpos.js +1 -1
- package/lib/modules/Payment/index.js +86 -73
- package/lib/modules/Payment/types.d.ts +7 -7
- package/lib/modules/Payment/utils.js +3 -6
- package/lib/modules/Payment/walletpass.js +33 -33
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/index.js +6 -5
- package/lib/modules/ProductList/index.js +5 -3
- package/lib/modules/Resource/index.js +8 -12
- package/lib/modules/Rules/index.js +24 -36
- package/lib/modules/Rules/types.d.ts +1 -1
- package/lib/modules/Schedule/getDateIsInSchedule.d.ts +1 -1
- package/lib/modules/Schedule/index.js +8 -5
- package/lib/modules/Schedule/type.d.ts +7 -7
- package/lib/modules/Schedule/types.d.ts +9 -9
- package/lib/modules/Schedule/utils.js +2 -4
- package/lib/modules/Step/index.js +7 -4
- package/lib/modules/Summary/index.js +9 -4
- package/lib/modules/Summary/utils.js +8 -16
- package/lib/plugins/request.js +34 -33
- package/lib/plugins/window.js +101 -113
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +110 -177
- package/lib/solution/BookingByStep/utils/capacity.js +10 -15
- package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +4 -8
- package/lib/solution/BookingByStep/utils/stock.js +3 -6
- package/lib/solution/BookingByStep/utils/timeslots.js +26 -31
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +19 -14
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +3 -3
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +6 -6
- package/lib/solution/BookingTicket/utils/scan/index.js +3 -1
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +10 -9
- package/lib/solution/BuyTickets/index.js +15 -15
- package/lib/solution/Checkout/index.js +216 -211
- package/lib/solution/Checkout/utils/index.js +18 -22
- package/lib/solution/RegisterAndLogin/config.js +2 -2
- package/lib/solution/RegisterAndLogin/index.js +114 -110
- package/lib/solution/RegisterAndLogin/utils.js +9 -9
- package/lib/solution/ShopDiscount/index.js +16 -13
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/solution/ShopDiscount/utils.d.ts +2 -2
- package/lib/solution/ShopDiscount/utils.js +1 -2
- package/lib/types/index.d.ts +1 -1
- package/lib/utils/task.d.ts +2 -2
- package/lib/utils/task.js +3 -3
- package/lib/utils/watch.d.ts +2 -2
- package/lib/utils/watch.js +5 -7
- package/package.json +16 -17
|
@@ -52,29 +52,33 @@ 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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
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;
|
|
63
67
|
// 平台类型,用于判断是 PC / H5
|
|
64
68
|
async initialize(core, options) {
|
|
65
69
|
var _a, _b, _c, _d, _e;
|
|
66
70
|
this.core = core;
|
|
67
71
|
this.store = options.store || {};
|
|
68
72
|
this.otherParams = options.otherParams || {};
|
|
69
|
-
console.log("[BookingByStep]
|
|
73
|
+
console.log("[BookingByStep] \u521D\u59CB\u5316\u5B8C\u6210");
|
|
70
74
|
this.request = core.getPlugin("request");
|
|
71
75
|
this.window = core.getPlugin("window");
|
|
72
76
|
this.shopStore = core.getPlugin("shopStore");
|
|
73
77
|
if (!this.request) {
|
|
74
|
-
throw new Error("bookingByStep
|
|
78
|
+
throw new Error("bookingByStep\u89E3\u51B3\u65B9\u6848\u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
|
|
75
79
|
}
|
|
76
80
|
if (!this.shopStore) {
|
|
77
|
-
throw new Error("SummaryModule
|
|
81
|
+
throw new Error("SummaryModule \u9700\u8981 shopStore \u63D2\u4EF6\u652F\u6301");
|
|
78
82
|
}
|
|
79
83
|
let targetCacheData = {};
|
|
80
84
|
this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
|
|
@@ -112,7 +116,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
112
116
|
}
|
|
113
117
|
});
|
|
114
118
|
} else {
|
|
115
|
-
throw new Error(
|
|
119
|
+
throw new Error(`\u6A21\u5757 ${step} \u4E0D\u5B58\u5728`);
|
|
116
120
|
}
|
|
117
121
|
});
|
|
118
122
|
this.store.schedule.loadAllSchedule();
|
|
@@ -488,7 +492,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
488
492
|
this.updateQuotationPriceAndCart(date);
|
|
489
493
|
}
|
|
490
494
|
} else {
|
|
491
|
-
throw new Error(
|
|
495
|
+
throw new Error(`\u6CA1\u6709\u627E\u5230${accountId}\u8D26\u6237`);
|
|
492
496
|
}
|
|
493
497
|
}
|
|
494
498
|
// 生成购物车的正规数据
|
|
@@ -696,7 +700,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
696
700
|
updateCart(params) {
|
|
697
701
|
const targetCartItem = this.store.cart.getItem(params._id);
|
|
698
702
|
if (!targetCartItem) {
|
|
699
|
-
throw new Error(
|
|
703
|
+
throw new Error(`\u6CA1\u6709\u627E\u5230${params._id}\u8D2D\u7269\u8F66\u5546\u54C1`);
|
|
700
704
|
}
|
|
701
705
|
this.beforeUpdateCart(params, targetCartItem);
|
|
702
706
|
this.store.cart.updateItem(params);
|
|
@@ -723,15 +727,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
723
727
|
const dateRange = this.store.date.getDateRange();
|
|
724
728
|
if (dateRange == null ? void 0 : dateRange.length) {
|
|
725
729
|
dateRange.forEach((n) => {
|
|
726
|
-
if (n.resource)
|
|
727
|
-
allOriginResources.push(...n.resource);
|
|
730
|
+
if (n.resource) allOriginResources.push(...n.resource);
|
|
728
731
|
});
|
|
729
732
|
}
|
|
730
733
|
if (!allOriginResources.length) {
|
|
731
734
|
const dateList = this.store.date.getDateList();
|
|
732
735
|
dateList == null ? void 0 : dateList.forEach((n) => {
|
|
733
|
-
if (n.resource)
|
|
734
|
-
allOriginResources.push(...n.resource);
|
|
736
|
+
if (n.resource) allOriginResources.push(...n.resource);
|
|
735
737
|
});
|
|
736
738
|
}
|
|
737
739
|
if (params.resources) {
|
|
@@ -863,8 +865,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
863
865
|
const resources = [];
|
|
864
866
|
if (dateRange == null ? void 0 : dateRange.length) {
|
|
865
867
|
dateRange.forEach((n) => {
|
|
866
|
-
if (n.resource)
|
|
867
|
-
resources.push(...n.resource);
|
|
868
|
+
if (n.resource) resources.push(...n.resource);
|
|
868
869
|
});
|
|
869
870
|
}
|
|
870
871
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
@@ -878,8 +879,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
878
879
|
} else {
|
|
879
880
|
const dateList = this.store.date.getDateList();
|
|
880
881
|
dateList == null ? void 0 : dateList.forEach((n) => {
|
|
881
|
-
if (n.resource)
|
|
882
|
-
resources.push(...n.resource);
|
|
882
|
+
if (n.resource) resources.push(...n.resource);
|
|
883
883
|
});
|
|
884
884
|
}
|
|
885
885
|
}
|
|
@@ -948,8 +948,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
948
948
|
}
|
|
949
949
|
return res.usable;
|
|
950
950
|
});
|
|
951
|
-
if (m.onlyComputed)
|
|
952
|
-
return false;
|
|
951
|
+
if (m.onlyComputed) return false;
|
|
953
952
|
return !canUseArr.some((n2) => n2 === false);
|
|
954
953
|
});
|
|
955
954
|
});
|
|
@@ -961,8 +960,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
961
960
|
item.renderList = item.renderList.filter((n) => {
|
|
962
961
|
var _a2, _b2, _c2;
|
|
963
962
|
const recordCount = n.capacity || 0;
|
|
964
|
-
if (n.onlyComputed)
|
|
965
|
-
return false;
|
|
963
|
+
if (n.onlyComputed) return false;
|
|
966
964
|
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
967
965
|
resource: n,
|
|
968
966
|
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
|
|
@@ -1016,13 +1014,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1016
1014
|
const dateRange = this.store.date.getDateRange();
|
|
1017
1015
|
const resources = [];
|
|
1018
1016
|
dateRange.forEach((n) => {
|
|
1019
|
-
if (n.resource)
|
|
1020
|
-
resources.push(...n.resource);
|
|
1017
|
+
if (n.resource) resources.push(...n.resource);
|
|
1021
1018
|
});
|
|
1022
1019
|
const resourcesMap = (0, import_utils2.getResourcesMap)(resources);
|
|
1023
1020
|
const targetCartItem = cartItems.find((n) => n._id === id);
|
|
1024
1021
|
if (!targetCartItem) {
|
|
1025
|
-
throw new Error(
|
|
1022
|
+
throw new Error(`\u6CA1\u6709\u627E\u5230${id}\u8D2D\u7269\u8F66\u5546\u54C1`);
|
|
1026
1023
|
}
|
|
1027
1024
|
let selectedResources = [];
|
|
1028
1025
|
const { currentCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(targetCartItem);
|
|
@@ -1048,8 +1045,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1048
1045
|
productResources.forEach((item) => {
|
|
1049
1046
|
item.renderList = item.renderList.filter((n) => {
|
|
1050
1047
|
const recordCount = n.capacity || 0;
|
|
1051
|
-
if (n.onlyComputed)
|
|
1052
|
-
return false;
|
|
1048
|
+
if (n.onlyComputed) return false;
|
|
1053
1049
|
return recordCount >= currentCapacity;
|
|
1054
1050
|
});
|
|
1055
1051
|
});
|
|
@@ -1092,8 +1088,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1092
1088
|
let AllResources = [];
|
|
1093
1089
|
if (dateRange == null ? void 0 : dateRange.length) {
|
|
1094
1090
|
dateRange.forEach((n) => {
|
|
1095
|
-
if (n.resource)
|
|
1096
|
-
AllResources.push(...n.resource);
|
|
1091
|
+
if (n.resource) AllResources.push(...n.resource);
|
|
1097
1092
|
});
|
|
1098
1093
|
}
|
|
1099
1094
|
if (!AllResources.length) {
|
|
@@ -1106,8 +1101,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1106
1101
|
} else {
|
|
1107
1102
|
const dateList = this.store.date.getDateList();
|
|
1108
1103
|
dateList.forEach((n) => {
|
|
1109
|
-
if (n.resource)
|
|
1110
|
-
AllResources.push(...n.resource);
|
|
1104
|
+
if (n.resource) AllResources.push(...n.resource);
|
|
1111
1105
|
});
|
|
1112
1106
|
}
|
|
1113
1107
|
}
|
|
@@ -1129,10 +1123,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1129
1123
|
var _a2, _b2, _c2, _d;
|
|
1130
1124
|
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
1131
1125
|
const bIsCombined = ((_d = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
1132
|
-
if (aIsCombined && !bIsCombined)
|
|
1133
|
-
|
|
1134
|
-
if (!aIsCombined && bIsCombined)
|
|
1135
|
-
return -1;
|
|
1126
|
+
if (aIsCombined && !bIsCombined) return 1;
|
|
1127
|
+
if (!aIsCombined && bIsCombined) return -1;
|
|
1136
1128
|
return 0;
|
|
1137
1129
|
});
|
|
1138
1130
|
const resourcesUseableMap = [
|
|
@@ -1219,8 +1211,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1219
1211
|
const resources = [];
|
|
1220
1212
|
if ((_a = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _a.date) {
|
|
1221
1213
|
dateRange.forEach((n) => {
|
|
1222
|
-
if (n.resource)
|
|
1223
|
-
resources.push(...n.resource);
|
|
1214
|
+
if (n.resource) resources.push(...n.resource);
|
|
1224
1215
|
});
|
|
1225
1216
|
}
|
|
1226
1217
|
const errorList = [];
|
|
@@ -1352,8 +1343,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1352
1343
|
productResources.forEach((item2) => {
|
|
1353
1344
|
item2.renderList = item2.renderList.filter((n) => {
|
|
1354
1345
|
const recordCount = (n.capacity || 0) - (selectResourcesMap[n.id] || 0);
|
|
1355
|
-
if (n.onlyComputed)
|
|
1356
|
-
return false;
|
|
1346
|
+
if (n.onlyComputed) return false;
|
|
1357
1347
|
return recordCount >= currentCapacity;
|
|
1358
1348
|
});
|
|
1359
1349
|
});
|
|
@@ -1535,8 +1525,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1535
1525
|
}
|
|
1536
1526
|
const calculateCapacityFromCartItems = (items) => {
|
|
1537
1527
|
var _a2;
|
|
1538
|
-
if (items.length === 0)
|
|
1539
|
-
return 0;
|
|
1528
|
+
if (items.length === 0) return 0;
|
|
1540
1529
|
const firstResource = (_a2 = items[0]._resourceOrigin) == null ? void 0 : _a2[0].id;
|
|
1541
1530
|
const sameResourceLength = items.filter((item) => {
|
|
1542
1531
|
var _a3;
|
|
@@ -1619,8 +1608,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1619
1608
|
}
|
|
1620
1609
|
}
|
|
1621
1610
|
});
|
|
1622
|
-
if (!resources.length)
|
|
1623
|
-
return [];
|
|
1611
|
+
if (!resources.length) return [];
|
|
1624
1612
|
let duration = 0;
|
|
1625
1613
|
const accountList = this.store.accountList.getAccounts();
|
|
1626
1614
|
const checkDuration = (cartItems2) => {
|
|
@@ -1670,8 +1658,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1670
1658
|
}
|
|
1671
1659
|
const calculateCapacityFromCartItems = (items) => {
|
|
1672
1660
|
var _a2;
|
|
1673
|
-
if (items.length === 0)
|
|
1674
|
-
return 0;
|
|
1661
|
+
if (items.length === 0) return 0;
|
|
1675
1662
|
const firstResource = (_a2 = items[0]._resourceOrigin) == null ? void 0 : _a2[0].id;
|
|
1676
1663
|
const sameResourceLength = items.filter((item) => {
|
|
1677
1664
|
var _a3;
|
|
@@ -1892,13 +1879,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1892
1879
|
const newScheduleArr = this.getScheduleDataByIds(
|
|
1893
1880
|
targetProductData["schedule.ids"]
|
|
1894
1881
|
);
|
|
1895
|
-
if (!this.store.currentProductMeta)
|
|
1896
|
-
this.store.currentProductMeta = {};
|
|
1882
|
+
if (!this.store.currentProductMeta) this.store.currentProductMeta = {};
|
|
1897
1883
|
this.store.currentProductMeta.schedule = newScheduleArr;
|
|
1898
1884
|
} else if (targetProductData.duration) {
|
|
1899
1885
|
const dateRange = this.store.date.getDateRange();
|
|
1900
|
-
if (!(dateRange == null ? void 0 : dateRange.length))
|
|
1901
|
-
return;
|
|
1886
|
+
if (!(dateRange == null ? void 0 : dateRange.length)) return;
|
|
1902
1887
|
this.getAvailableDate({
|
|
1903
1888
|
startDate: dateRange[0].date,
|
|
1904
1889
|
endDate: dateRange[dateRange.length - 1].date,
|
|
@@ -1957,10 +1942,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1957
1942
|
var _a2, _b2, _c2, _d2;
|
|
1958
1943
|
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
1959
1944
|
const bIsCombined = ((_d2 = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d2.status) === 1;
|
|
1960
|
-
if (aIsCombined && !bIsCombined)
|
|
1961
|
-
|
|
1962
|
-
if (!aIsCombined && bIsCombined)
|
|
1963
|
-
return -1;
|
|
1945
|
+
if (aIsCombined && !bIsCombined) return 1;
|
|
1946
|
+
if (!aIsCombined && bIsCombined) return -1;
|
|
1964
1947
|
return 0;
|
|
1965
1948
|
});
|
|
1966
1949
|
const enabledResourceTypeConfigs = ((_d = (_c = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.filter(
|
|
@@ -1982,8 +1965,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1982
1965
|
});
|
|
1983
1966
|
allProductResources == null ? void 0 : allProductResources.forEach((m) => {
|
|
1984
1967
|
const currentResourceTypeConfig = resourceTypeConfigById.get(m.form_id);
|
|
1985
|
-
if (!currentResourceTypeConfig)
|
|
1986
|
-
return;
|
|
1968
|
+
if (!currentResourceTypeConfig) return;
|
|
1987
1969
|
let currentResourceMaxRemainingCapacity = 0;
|
|
1988
1970
|
let isAllTimeSlicesUsable = true;
|
|
1989
1971
|
const mTimes = m.times.filter((n) => {
|
|
@@ -2001,8 +1983,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2001
1983
|
};
|
|
2002
1984
|
if (currentResourceTypeConfig.type === "multiple")
|
|
2003
1985
|
currentStats2.summaryConfigCount += m.capacity;
|
|
2004
|
-
else
|
|
2005
|
-
currentStats2.summaryConfigCount += 1;
|
|
1986
|
+
else currentStats2.summaryConfigCount += 1;
|
|
2006
1987
|
statsByResourceType[m.form_id] = currentStats2;
|
|
2007
1988
|
}
|
|
2008
1989
|
mTimes.forEach((childTiem) => {
|
|
@@ -2022,17 +2003,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2022
2003
|
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
2023
2004
|
resourcesUseableMap[m.id] = res.usable;
|
|
2024
2005
|
}
|
|
2025
|
-
if (!res.usable)
|
|
2026
|
-
isAllTimeSlicesUsable = false;
|
|
2006
|
+
if (!res.usable) isAllTimeSlicesUsable = false;
|
|
2027
2007
|
if (res.usable && !m.onlyComputed) {
|
|
2028
2008
|
if (res.remainingCapacity > currentResourceMaxRemainingCapacity)
|
|
2029
2009
|
currentResourceMaxRemainingCapacity = res.remainingCapacity;
|
|
2030
2010
|
}
|
|
2031
2011
|
});
|
|
2032
|
-
if (!isAllTimeSlicesUsable)
|
|
2033
|
-
|
|
2034
|
-
if (m.onlyComputed)
|
|
2035
|
-
return;
|
|
2012
|
+
if (!isAllTimeSlicesUsable) return;
|
|
2013
|
+
if (m.onlyComputed) return;
|
|
2036
2014
|
const currentStats = statsByResourceType[m.form_id] || {
|
|
2037
2015
|
count: 0,
|
|
2038
2016
|
left: 0,
|
|
@@ -2050,8 +2028,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2050
2028
|
const cartItems2 = this.store.cart.getItems();
|
|
2051
2029
|
productResources.forEach((n) => {
|
|
2052
2030
|
const currentResourceTypeConfig = resourceTypeConfigById.get(n.id);
|
|
2053
|
-
if (!currentResourceTypeConfig)
|
|
2054
|
-
return;
|
|
2031
|
+
if (!currentResourceTypeConfig) return;
|
|
2055
2032
|
const currentStats = statsByResourceType[n.id] || {
|
|
2056
2033
|
count: 0,
|
|
2057
2034
|
left: 0,
|
|
@@ -2183,26 +2160,19 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2183
2160
|
} : { count: 0, left: 0, summaryCount: 0, summaryConfigCount: 0 };
|
|
2184
2161
|
const bottleneckConfig = bottleneckResourceTypeId !== void 0 ? resourceTypeConfigById.get(bottleneckResourceTypeId) : void 0;
|
|
2185
2162
|
let status = "sold_out";
|
|
2186
|
-
if (bottleneckStats.left === 0)
|
|
2187
|
-
status = "sold_out";
|
|
2163
|
+
if (bottleneckStats.left === 0) status = "sold_out";
|
|
2188
2164
|
else if (!bottleneckConfig || bottleneckStats.summaryConfigCount === 0)
|
|
2189
2165
|
status = "sold_out";
|
|
2190
2166
|
else if (bottleneckConfig.type === "multiple") {
|
|
2191
2167
|
const usageRatio = bottleneckStats.summaryCount / bottleneckStats.summaryConfigCount;
|
|
2192
|
-
if (usageRatio > 0.5)
|
|
2193
|
-
|
|
2194
|
-
else
|
|
2195
|
-
status = "filling_up_fast";
|
|
2196
|
-
else
|
|
2197
|
-
status = "sold_out";
|
|
2168
|
+
if (usageRatio > 0.5) status = "lots_of_space";
|
|
2169
|
+
else if (bottleneckStats.summaryCount > 0) status = "filling_up_fast";
|
|
2170
|
+
else status = "sold_out";
|
|
2198
2171
|
} else {
|
|
2199
2172
|
const usageRatio = bottleneckStats.left / bottleneckStats.summaryConfigCount;
|
|
2200
|
-
if (usageRatio > 0.5)
|
|
2201
|
-
|
|
2202
|
-
else
|
|
2203
|
-
status = "filling_up_fast";
|
|
2204
|
-
else
|
|
2205
|
-
status = "sold_out";
|
|
2173
|
+
if (usageRatio > 0.5) status = "lots_of_space";
|
|
2174
|
+
else if (bottleneckStats.count > 0) status = "filling_up_fast";
|
|
2175
|
+
else status = "sold_out";
|
|
2206
2176
|
}
|
|
2207
2177
|
return {
|
|
2208
2178
|
start_time: startDayJs.format("HH:mm"),
|
|
@@ -2225,20 +2195,19 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2225
2195
|
* 找到多个资源的公共可用时间段
|
|
2226
2196
|
*/
|
|
2227
2197
|
findCommonAvailableTimeSlots(resources) {
|
|
2228
|
-
if (resources.length === 0)
|
|
2229
|
-
|
|
2230
|
-
console.log(`计算 ${resources.length} 个资源的公共时间段`);
|
|
2198
|
+
if (resources.length === 0) return [];
|
|
2199
|
+
console.log(`\u8BA1\u7B97 ${resources.length} \u4E2A\u8D44\u6E90\u7684\u516C\u5171\u65F6\u95F4\u6BB5`);
|
|
2231
2200
|
const allTimeSlots = resources.map(
|
|
2232
2201
|
(resource) => resource.times.map((time) => ({
|
|
2233
2202
|
start: (0, import_dayjs.default)(time.start_at),
|
|
2234
2203
|
end: (0, import_dayjs.default)(time.end_at)
|
|
2235
2204
|
}))
|
|
2236
2205
|
);
|
|
2237
|
-
console.log("
|
|
2206
|
+
console.log("\u6240\u6709\u8D44\u6E90\u7684\u65F6\u95F4\u6BB5:", allTimeSlots.map(
|
|
2238
2207
|
(slots) => slots.map((slot) => `${slot.start.format("HH:mm")}-${slot.end.format("HH:mm")}`)
|
|
2239
2208
|
));
|
|
2240
2209
|
let commonSlots = allTimeSlots[0];
|
|
2241
|
-
console.log("
|
|
2210
|
+
console.log("\u521D\u59CB\u516C\u5171\u65F6\u95F4\u6BB5:", commonSlots.map((slot) => `${slot.start.format("HH:mm")}-${slot.end.format("HH:mm")}`));
|
|
2242
2211
|
for (let i = 1; i < allTimeSlots.length; i++) {
|
|
2243
2212
|
const currentResourceSlots = allTimeSlots[i];
|
|
2244
2213
|
const intersections = [];
|
|
@@ -2255,24 +2224,23 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2255
2224
|
});
|
|
2256
2225
|
});
|
|
2257
2226
|
if (intersections.length === 0) {
|
|
2258
|
-
console.log(
|
|
2227
|
+
console.log(`\u8D44\u6E90${i}\u4E0E\u5F53\u524D\u516C\u5171\u65F6\u95F4\u6BB5\u65E0\u4EA4\u96C6\uFF0C\u8DF3\u8FC7\u8BE5\u8D44\u6E90`);
|
|
2259
2228
|
continue;
|
|
2260
2229
|
}
|
|
2261
2230
|
commonSlots = intersections;
|
|
2262
|
-
console.log(
|
|
2231
|
+
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")}`));
|
|
2263
2232
|
}
|
|
2264
2233
|
const result = commonSlots.map((slot) => ({
|
|
2265
2234
|
startTime: slot.start.format("HH:mm"),
|
|
2266
2235
|
endTime: slot.end.format("HH:mm")
|
|
2267
2236
|
}));
|
|
2268
|
-
console.log("
|
|
2237
|
+
console.log("\u6700\u7EC8\u516C\u5171\u65F6\u95F4\u6BB5:", result);
|
|
2269
2238
|
return result;
|
|
2270
2239
|
}
|
|
2271
2240
|
checkMaxDurationCapacity() {
|
|
2272
2241
|
var _a, _b;
|
|
2273
2242
|
const cartItems = this.store.cart.getItems().filter((item) => !(0, import_utils5.isNormalProduct)(item._productOrigin));
|
|
2274
|
-
if (cartItems.length === 0)
|
|
2275
|
-
return { success: true, minAvailableCount: 0 };
|
|
2243
|
+
if (cartItems.length === 0) return { success: true, minAvailableCount: 0 };
|
|
2276
2244
|
const itemsWithTime = [];
|
|
2277
2245
|
const itemsWithoutTime = [];
|
|
2278
2246
|
const availableCountsByResourceType = [];
|
|
@@ -2288,8 +2256,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2288
2256
|
const itemsByResourceType = {};
|
|
2289
2257
|
itemsWithoutTime.forEach((cartItem) => {
|
|
2290
2258
|
var _a2;
|
|
2291
|
-
if (!cartItem._productOrigin)
|
|
2292
|
-
return;
|
|
2259
|
+
if (!cartItem._productOrigin) return;
|
|
2293
2260
|
const resourceTypes = ((_a2 = cartItem._productOrigin.product_resource) == null ? void 0 : _a2.resources) || [];
|
|
2294
2261
|
resourceTypes.forEach((resourceType) => {
|
|
2295
2262
|
var _a3;
|
|
@@ -2308,12 +2275,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2308
2275
|
});
|
|
2309
2276
|
});
|
|
2310
2277
|
const dateRange = this.store.date.getDateRange();
|
|
2311
|
-
if (!dateRange || dateRange.length === 0)
|
|
2312
|
-
return { success: false, minAvailableCount: 0 };
|
|
2278
|
+
if (!dateRange || dateRange.length === 0) return { success: false, minAvailableCount: 0 };
|
|
2313
2279
|
const resourcesDates = this.store.date.getDateList();
|
|
2314
2280
|
const targetResourceDate = resourcesDates.find((n) => n.date === dateRange[0].date);
|
|
2315
|
-
if (!targetResourceDate)
|
|
2316
|
-
return { success: false, minAvailableCount: 0 };
|
|
2281
|
+
if (!targetResourceDate) return { success: false, minAvailableCount: 0 };
|
|
2317
2282
|
const resourcesMap = (0, import_utils2.getResourcesMap)(targetResourceDate.resource || []);
|
|
2318
2283
|
const resourceCodeToFormIdMap = {};
|
|
2319
2284
|
Object.values(itemsByResourceType).flat().forEach((cartItem) => {
|
|
@@ -2336,7 +2301,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2336
2301
|
for (const [resourceCode, items] of Object.entries(itemsByResourceType)) {
|
|
2337
2302
|
const targetFormId = resourceCodeToFormIdMap[resourceCode];
|
|
2338
2303
|
if (!targetFormId) {
|
|
2339
|
-
console.log(
|
|
2304
|
+
console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} \u627E\u4E0D\u5230\u5BF9\u5E94\u7684 form_id`);
|
|
2340
2305
|
return { success: false, minAvailableCount: 0 };
|
|
2341
2306
|
}
|
|
2342
2307
|
const resourcesOfThisType = [];
|
|
@@ -2353,7 +2318,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2353
2318
|
});
|
|
2354
2319
|
});
|
|
2355
2320
|
if (resourcesOfThisType.length === 0) {
|
|
2356
|
-
console.log(
|
|
2321
|
+
console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} \u6CA1\u6709\u627E\u5230\u53EF\u7528\u8D44\u6E90`);
|
|
2357
2322
|
return { success: false, minAvailableCount: 0 };
|
|
2358
2323
|
}
|
|
2359
2324
|
let resourceTypeConfig = null;
|
|
@@ -2362,8 +2327,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2362
2327
|
resourceTypeConfig = cartItem._productOrigin.product_resource.resources.find(
|
|
2363
2328
|
(r) => r.code === resourceCode && r.status === 1
|
|
2364
2329
|
);
|
|
2365
|
-
if (resourceTypeConfig)
|
|
2366
|
-
break;
|
|
2330
|
+
if (resourceTypeConfig) break;
|
|
2367
2331
|
}
|
|
2368
2332
|
}
|
|
2369
2333
|
const isMultipleBooking = (resourceTypeConfig == null ? void 0 : resourceTypeConfig.type) === "multiple";
|
|
@@ -2396,20 +2360,20 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2396
2360
|
availableCountsByResourceType.push(availableAmount);
|
|
2397
2361
|
if (requiredAmount > totalAvailable) {
|
|
2398
2362
|
hasCapacityIssue = true;
|
|
2399
|
-
console.log(
|
|
2363
|
+
console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} ${isMultipleBooking ? "\u5BB9\u91CF" : "\u8D44\u6E90\u6570\u91CF"}\u4E0D\u8DB3: \u9700\u8981 ${requiredAmount}, \u603B\u5171 ${totalAvailable}`);
|
|
2400
2364
|
}
|
|
2401
|
-
console.log(
|
|
2365
|
+
console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} \u7684\u8D44\u6E90\u65F6\u95F4\u4FE1\u606F:`, resourcesOfThisType.map((r) => ({
|
|
2402
2366
|
id: r.id,
|
|
2403
2367
|
times: r.times.map((t) => `${t.start_at} - ${t.end_at}`)
|
|
2404
2368
|
})));
|
|
2405
2369
|
const commonTimeSlots = this.findCommonAvailableTimeSlots(resourcesOfThisType);
|
|
2406
|
-
console.log(
|
|
2370
|
+
console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} \u7684\u516C\u5171\u65F6\u95F4\u6BB5:`, commonTimeSlots);
|
|
2407
2371
|
if (commonTimeSlots.length === 0) {
|
|
2408
|
-
console.log(
|
|
2372
|
+
console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} \u6CA1\u6709\u516C\u5171\u53EF\u7528\u65F6\u95F4\u6BB5`);
|
|
2409
2373
|
return { success: false, minAvailableCount: 0 };
|
|
2410
2374
|
}
|
|
2411
2375
|
const firstCommonSlot = commonTimeSlots[0];
|
|
2412
|
-
console.log(
|
|
2376
|
+
console.log(`\u4F7F\u7528\u516C\u5171\u65F6\u95F4\u6BB5: ${firstCommonSlot.startTime} - ${firstCommonSlot.endTime}`);
|
|
2413
2377
|
items.forEach((cartItem) => {
|
|
2414
2378
|
if (!processedCartItemIds.has(cartItem._id)) {
|
|
2415
2379
|
processedCartItemIds.add(cartItem._id);
|
|
@@ -2437,8 +2401,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2437
2401
|
const allProcessedItems = [...itemsWithTime, ...processedItemsWithoutTime];
|
|
2438
2402
|
const cartItemsByTimeSlot = {};
|
|
2439
2403
|
allProcessedItems.forEach((cartItem) => {
|
|
2440
|
-
if (!cartItem.start_time || !cartItem.end_time || !cartItem.start_date)
|
|
2441
|
-
return;
|
|
2404
|
+
if (!cartItem.start_time || !cartItem.end_time || !cartItem.start_date) return;
|
|
2442
2405
|
const timeSlotKey = `${cartItem.start_date}_${cartItem.start_time}_${cartItem.end_date || cartItem.start_date}_${cartItem.end_time}`;
|
|
2443
2406
|
if (!cartItemsByTimeSlot[timeSlotKey]) {
|
|
2444
2407
|
cartItemsByTimeSlot[timeSlotKey] = [];
|
|
@@ -2454,12 +2417,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2454
2417
|
const dateRange = this.store.date.getDateRange();
|
|
2455
2418
|
const resourcesDates = this.store.date.getDateList();
|
|
2456
2419
|
const targetResourceDate = resourcesDates.find((n) => n.date === startDate);
|
|
2457
|
-
if (!targetResourceDate)
|
|
2458
|
-
continue;
|
|
2420
|
+
if (!targetResourceDate) continue;
|
|
2459
2421
|
const resourcesMap = (0, import_utils2.getResourcesMap)(targetResourceDate.resource || []);
|
|
2460
2422
|
itemsInTimeSlot.forEach((cartItem) => {
|
|
2461
|
-
if (!cartItem._productOrigin)
|
|
2462
|
-
return;
|
|
2423
|
+
if (!cartItem._productOrigin) return;
|
|
2463
2424
|
const productResourceIds = (0, import_capacity.getResourcesIdsByProduct)(cartItem._productOrigin);
|
|
2464
2425
|
productResourceIds.forEach((resourceId) => {
|
|
2465
2426
|
if (resourcesMap[resourceId] && !resourcesIdSet.has(resourceId)) {
|
|
@@ -2538,8 +2499,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2538
2499
|
const cartItems = this.store.cart.getItems().filter((item) => !(0, import_utils5.isNormalProduct)(item._productOrigin));
|
|
2539
2500
|
const currentCartItem = this.convertProductToCartItem({ product, date, account });
|
|
2540
2501
|
cartItems.push(currentCartItem);
|
|
2541
|
-
if (cartItems.length === 0)
|
|
2542
|
-
return { success: true, minAvailableCount: 0 };
|
|
2502
|
+
if (cartItems.length === 0) return { success: true, minAvailableCount: 0 };
|
|
2543
2503
|
const itemsWithTime = [];
|
|
2544
2504
|
const itemsWithoutTime = [];
|
|
2545
2505
|
const availableCountsByResourceType = [];
|
|
@@ -2555,8 +2515,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2555
2515
|
const itemsByResourceType = {};
|
|
2556
2516
|
itemsWithoutTime.forEach((cartItem) => {
|
|
2557
2517
|
var _a2;
|
|
2558
|
-
if (!cartItem._productOrigin)
|
|
2559
|
-
return;
|
|
2518
|
+
if (!cartItem._productOrigin) return;
|
|
2560
2519
|
const resourceTypes = ((_a2 = cartItem._productOrigin.product_resource) == null ? void 0 : _a2.resources) || [];
|
|
2561
2520
|
resourceTypes.forEach((resourceType) => {
|
|
2562
2521
|
var _a3;
|
|
@@ -2572,12 +2531,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2572
2531
|
});
|
|
2573
2532
|
});
|
|
2574
2533
|
const dateRange = this.store.date.getDateRange();
|
|
2575
|
-
if (!dateRange || dateRange.length === 0)
|
|
2576
|
-
return { success: false, minAvailableCount: 0 };
|
|
2534
|
+
if (!dateRange || dateRange.length === 0) return { success: false, minAvailableCount: 0 };
|
|
2577
2535
|
const resourcesDates = this.store.date.getDateList();
|
|
2578
2536
|
const targetResourceDate = resourcesDates.find((n) => n.date === dateRange[0].date);
|
|
2579
|
-
if (!targetResourceDate)
|
|
2580
|
-
return { success: false, minAvailableCount: 0 };
|
|
2537
|
+
if (!targetResourceDate) return { success: false, minAvailableCount: 0 };
|
|
2581
2538
|
const resourcesMap = (0, import_utils2.getResourcesMap)(targetResourceDate.resource || []);
|
|
2582
2539
|
const resourceCodeToFormIdMap = {};
|
|
2583
2540
|
Object.values(itemsByResourceType).flat().forEach((cartItem) => {
|
|
@@ -2600,7 +2557,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2600
2557
|
for (const [resourceCode, items] of Object.entries(itemsByResourceType)) {
|
|
2601
2558
|
const targetFormId = resourceCodeToFormIdMap[resourceCode];
|
|
2602
2559
|
if (!targetFormId) {
|
|
2603
|
-
console.log(
|
|
2560
|
+
console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} \u627E\u4E0D\u5230\u5BF9\u5E94\u7684 form_id`);
|
|
2604
2561
|
return { success: false, minAvailableCount: 0 };
|
|
2605
2562
|
}
|
|
2606
2563
|
const resourcesOfThisType = [];
|
|
@@ -2617,7 +2574,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2617
2574
|
});
|
|
2618
2575
|
});
|
|
2619
2576
|
if (resourcesOfThisType.length === 0) {
|
|
2620
|
-
console.log(
|
|
2577
|
+
console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} \u6CA1\u6709\u627E\u5230\u53EF\u7528\u8D44\u6E90`);
|
|
2621
2578
|
return { success: false, minAvailableCount: 0 };
|
|
2622
2579
|
}
|
|
2623
2580
|
let resourceTypeConfig = null;
|
|
@@ -2626,8 +2583,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2626
2583
|
resourceTypeConfig = cartItem._productOrigin.product_resource.resources.find(
|
|
2627
2584
|
(r) => r.code === resourceCode && r.status === 1
|
|
2628
2585
|
);
|
|
2629
|
-
if (resourceTypeConfig)
|
|
2630
|
-
break;
|
|
2586
|
+
if (resourceTypeConfig) break;
|
|
2631
2587
|
}
|
|
2632
2588
|
}
|
|
2633
2589
|
const isMultipleBooking = (resourceTypeConfig == null ? void 0 : resourceTypeConfig.type) === "multiple";
|
|
@@ -2660,20 +2616,20 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2660
2616
|
availableCountsByResourceType.push(availableAmount);
|
|
2661
2617
|
if (requiredAmount > totalAvailable) {
|
|
2662
2618
|
hasCapacityIssue = true;
|
|
2663
|
-
console.log(
|
|
2619
|
+
console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} ${isMultipleBooking ? "\u5BB9\u91CF" : "\u8D44\u6E90\u6570\u91CF"}\u4E0D\u8DB3: \u9700\u8981 ${requiredAmount}, \u603B\u5171 ${totalAvailable}`);
|
|
2664
2620
|
}
|
|
2665
|
-
console.log(
|
|
2621
|
+
console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} \u7684\u8D44\u6E90\u65F6\u95F4\u4FE1\u606F:`, resourcesOfThisType.map((r) => ({
|
|
2666
2622
|
id: r.id,
|
|
2667
2623
|
times: r.times.map((t) => `${t.start_at} - ${t.end_at}`)
|
|
2668
2624
|
})));
|
|
2669
2625
|
const commonTimeSlots = this.findCommonAvailableTimeSlots(resourcesOfThisType);
|
|
2670
|
-
console.log(
|
|
2626
|
+
console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} \u7684\u516C\u5171\u65F6\u95F4\u6BB5:`, commonTimeSlots);
|
|
2671
2627
|
if (commonTimeSlots.length === 0) {
|
|
2672
|
-
console.log(
|
|
2628
|
+
console.log(`\u8D44\u6E90\u7C7B\u578B ${resourceCode} \u6CA1\u6709\u516C\u5171\u53EF\u7528\u65F6\u95F4\u6BB5`);
|
|
2673
2629
|
return { success: false, minAvailableCount: 0 };
|
|
2674
2630
|
}
|
|
2675
2631
|
const firstCommonSlot = commonTimeSlots[0];
|
|
2676
|
-
console.log(
|
|
2632
|
+
console.log(`\u4F7F\u7528\u516C\u5171\u65F6\u95F4\u6BB5: ${firstCommonSlot.startTime} - ${firstCommonSlot.endTime}`);
|
|
2677
2633
|
items.forEach((cartItem) => {
|
|
2678
2634
|
if (!processedCartItemIds.has(cartItem._id)) {
|
|
2679
2635
|
processedCartItemIds.add(cartItem._id);
|
|
@@ -2701,8 +2657,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2701
2657
|
const allProcessedItems = [...itemsWithTime, ...processedItemsWithoutTime];
|
|
2702
2658
|
const cartItemsByTimeSlot = {};
|
|
2703
2659
|
allProcessedItems.forEach((cartItem) => {
|
|
2704
|
-
if (!cartItem.start_time || !cartItem.end_time || !cartItem.start_date)
|
|
2705
|
-
return;
|
|
2660
|
+
if (!cartItem.start_time || !cartItem.end_time || !cartItem.start_date) return;
|
|
2706
2661
|
const timeSlotKey = `${cartItem.start_date}_${cartItem.start_time}_${cartItem.end_date || cartItem.start_date}_${cartItem.end_time}`;
|
|
2707
2662
|
if (!cartItemsByTimeSlot[timeSlotKey]) {
|
|
2708
2663
|
cartItemsByTimeSlot[timeSlotKey] = [];
|
|
@@ -2717,12 +2672,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2717
2672
|
const resourcesIdSet = /* @__PURE__ */ new Set();
|
|
2718
2673
|
const resourcesDates = this.store.date.getDateList();
|
|
2719
2674
|
const targetResourceDate = resourcesDates.find((n) => n.date === startDate);
|
|
2720
|
-
if (!targetResourceDate)
|
|
2721
|
-
continue;
|
|
2675
|
+
if (!targetResourceDate) continue;
|
|
2722
2676
|
const resourcesMap = (0, import_utils2.getResourcesMap)(targetResourceDate.resource || []);
|
|
2723
2677
|
itemsInTimeSlot.forEach((cartItem) => {
|
|
2724
|
-
if (!cartItem._productOrigin)
|
|
2725
|
-
return;
|
|
2678
|
+
if (!cartItem._productOrigin) return;
|
|
2726
2679
|
const productResourceIds = (0, import_capacity.getResourcesIdsByProduct)(cartItem._productOrigin);
|
|
2727
2680
|
productResourceIds.forEach((resourceId) => {
|
|
2728
2681
|
if (resourcesMap[resourceId] && !resourcesIdSet.has(resourceId)) {
|
|
@@ -2779,22 +2732,19 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2779
2732
|
const resources = [];
|
|
2780
2733
|
if (dateRange == null ? void 0 : dateRange.length) {
|
|
2781
2734
|
dateRange.forEach((n) => {
|
|
2782
|
-
if (n.resource)
|
|
2783
|
-
resources.push(...n.resource);
|
|
2735
|
+
if (n.resource) resources.push(...n.resource);
|
|
2784
2736
|
});
|
|
2785
2737
|
}
|
|
2786
2738
|
if (!resources.length) {
|
|
2787
2739
|
const dateList = this.store.date.getDateList();
|
|
2788
2740
|
dateList.forEach((n) => {
|
|
2789
|
-
if (n.resource)
|
|
2790
|
-
resources.push(...n.resource);
|
|
2741
|
+
if (n.resource) resources.push(...n.resource);
|
|
2791
2742
|
});
|
|
2792
2743
|
}
|
|
2793
2744
|
const resourcesMap = (0, import_utils2.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
2794
2745
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
2795
2746
|
const cartItem = cartItems.find((item) => item._id === cartItemId);
|
|
2796
|
-
if (!cartItem)
|
|
2797
|
-
return [];
|
|
2747
|
+
if (!cartItem) return [];
|
|
2798
2748
|
let selectedResources = [];
|
|
2799
2749
|
const { currentCapacity, formatCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(cartItem);
|
|
2800
2750
|
cartItem._origin.metadata.capacity = formatCapacity;
|
|
@@ -2820,8 +2770,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2820
2770
|
const targetResource = productResources.find(
|
|
2821
2771
|
(resource) => resource.code === resourceCode
|
|
2822
2772
|
);
|
|
2823
|
-
if (!targetResource)
|
|
2824
|
-
return [];
|
|
2773
|
+
if (!targetResource) return [];
|
|
2825
2774
|
if (cartItem._origin.start_time) {
|
|
2826
2775
|
const startTime = (0, import_dayjs.default)(
|
|
2827
2776
|
`${cartItem._origin.start_date} ${cartItem._origin.start_time}`
|
|
@@ -2835,10 +2784,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2835
2784
|
var _a2, _b2, _c, _d;
|
|
2836
2785
|
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
2837
2786
|
const bIsCombined = ((_d = (_c = b.metadata) == null ? void 0 : _c.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
2838
|
-
if (aIsCombined && !bIsCombined)
|
|
2839
|
-
|
|
2840
|
-
if (!aIsCombined && bIsCombined)
|
|
2841
|
-
return -1;
|
|
2787
|
+
if (aIsCombined && !bIsCombined) return 1;
|
|
2788
|
+
if (!aIsCombined && bIsCombined) return -1;
|
|
2842
2789
|
return 0;
|
|
2843
2790
|
}
|
|
2844
2791
|
);
|
|
@@ -2846,8 +2793,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2846
2793
|
const mTimes = m.times.filter((n) => {
|
|
2847
2794
|
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));
|
|
2848
2795
|
});
|
|
2849
|
-
if (mTimes.length === 0)
|
|
2850
|
-
return false;
|
|
2796
|
+
if (mTimes.length === 0) return false;
|
|
2851
2797
|
const canUseArr = mTimes.map((item) => {
|
|
2852
2798
|
var _a2;
|
|
2853
2799
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
@@ -2868,16 +2814,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2868
2814
|
}
|
|
2869
2815
|
return res.usable;
|
|
2870
2816
|
});
|
|
2871
|
-
if (m.onlyComputed)
|
|
2872
|
-
return false;
|
|
2817
|
+
if (m.onlyComputed) return false;
|
|
2873
2818
|
return !canUseArr.some((n) => n === false);
|
|
2874
2819
|
});
|
|
2875
2820
|
} else {
|
|
2876
2821
|
targetResource.renderList = targetResource.renderList.filter((n) => {
|
|
2877
2822
|
var _a2, _b2;
|
|
2878
2823
|
const recordCount = n.capacity || 0;
|
|
2879
|
-
if (n.onlyComputed)
|
|
2880
|
-
return false;
|
|
2824
|
+
if (n.onlyComputed) return false;
|
|
2881
2825
|
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
2882
2826
|
resource: n,
|
|
2883
2827
|
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
|
|
@@ -3043,8 +2987,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
3043
2987
|
const mTimes = m.times.filter((n) => {
|
|
3044
2988
|
return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(item.end), "minute");
|
|
3045
2989
|
});
|
|
3046
|
-
if (mTimes.length === 0)
|
|
3047
|
-
return;
|
|
2990
|
+
if (mTimes.length === 0) return;
|
|
3048
2991
|
if (!m.onlyComputed) {
|
|
3049
2992
|
if (resource.type === "multiple") {
|
|
3050
2993
|
summaryCount += m.capacity;
|
|
@@ -3054,8 +2997,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
3054
2997
|
}
|
|
3055
2998
|
let isAnyTimeSliceUseable = false;
|
|
3056
2999
|
mTimes.forEach((childTiem) => {
|
|
3057
|
-
if (isAnyTimeSliceUseable)
|
|
3058
|
-
return;
|
|
3000
|
+
if (isAnyTimeSliceUseable) return;
|
|
3059
3001
|
const res2 = (0, import_resources.getIsUsableByTimeItem)({
|
|
3060
3002
|
timeSlice: {
|
|
3061
3003
|
start_time: item.start,
|
|
@@ -3082,14 +3024,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
3082
3024
|
}
|
|
3083
3025
|
;
|
|
3084
3026
|
});
|
|
3085
|
-
if (isAnyTimeSliceUseable)
|
|
3086
|
-
isAnyResourceUseableInType = true;
|
|
3027
|
+
if (isAnyTimeSliceUseable) isAnyResourceUseableInType = true;
|
|
3087
3028
|
});
|
|
3088
|
-
if (!isAnyResourceUseableInType)
|
|
3089
|
-
isAllResourceTypesUseable = false;
|
|
3029
|
+
if (!isAnyResourceUseableInType) isAllResourceTypesUseable = false;
|
|
3090
3030
|
});
|
|
3091
|
-
if (isAllResourceTypesUseable)
|
|
3092
|
-
timesSlotCanUse = true;
|
|
3031
|
+
if (isAllResourceTypesUseable) timesSlotCanUse = true;
|
|
3093
3032
|
});
|
|
3094
3033
|
if (!timesSlotCanUse) {
|
|
3095
3034
|
status = "unavailable";
|
|
@@ -3100,16 +3039,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
3100
3039
|
}
|
|
3101
3040
|
let dateStatus;
|
|
3102
3041
|
if (status === "unavailable") {
|
|
3103
|
-
if (availableCount === 0 && summaryCount > 0)
|
|
3104
|
-
|
|
3105
|
-
else
|
|
3106
|
-
dateStatus = "unavailable";
|
|
3042
|
+
if (availableCount === 0 && summaryCount > 0) dateStatus = "sold_out";
|
|
3043
|
+
else dateStatus = "unavailable";
|
|
3107
3044
|
} else {
|
|
3108
3045
|
const usageRatio = availableCount / summaryCount;
|
|
3109
|
-
if (usageRatio > 0.5)
|
|
3110
|
-
|
|
3111
|
-
else
|
|
3112
|
-
dateStatus = "filling_up_fast";
|
|
3046
|
+
if (usageRatio > 0.5) dateStatus = "lots_of_space";
|
|
3047
|
+
else dateStatus = "filling_up_fast";
|
|
3113
3048
|
}
|
|
3114
3049
|
dates.push({
|
|
3115
3050
|
date: (0, import_dayjs.default)(currentDate).format("YYYY-MM-DD"),
|
|
@@ -3126,8 +3061,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
3126
3061
|
}
|
|
3127
3062
|
dates = (0, import_utils4.handleAvailableDateByResource)(res.data, dates);
|
|
3128
3063
|
this.store.date.setDateList(dates);
|
|
3129
|
-
if (!this.store.currentProductMeta)
|
|
3130
|
-
this.store.currentProductMeta = {};
|
|
3064
|
+
if (!this.store.currentProductMeta) this.store.currentProductMeta = {};
|
|
3131
3065
|
this.store.currentProductMeta.timeSlotBySchedule = {
|
|
3132
3066
|
dateList: dates,
|
|
3133
3067
|
firstAvailableDate,
|
|
@@ -3151,8 +3085,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
3151
3085
|
});
|
|
3152
3086
|
}
|
|
3153
3087
|
isTargetNormalProduct(product) {
|
|
3154
|
-
if (!product)
|
|
3155
|
-
return false;
|
|
3088
|
+
if (!product) return false;
|
|
3156
3089
|
return (0, import_utils5.isNormalProduct)(product);
|
|
3157
3090
|
}
|
|
3158
3091
|
isTargetCartIdNormalProduct(id) {
|