@pisell/pisellos 0.0.324 → 0.0.326
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/effects/index.d.ts +2 -2
- package/dist/modules/Account/index.js +2 -3
- package/dist/modules/BaseModule.d.ts +3 -0
- package/dist/modules/BaseModule.js +15 -0
- package/dist/modules/Customer/index.js +9 -10
- package/dist/modules/Customer/types.d.ts +1 -1
- package/dist/modules/Discount/index.js +1 -1
- package/dist/modules/Guests/index.js +9 -9
- package/dist/modules/Payment/index.js +18 -18
- package/dist/modules/Payment/types.d.ts +7 -7
- package/dist/modules/Payment/walletpass.js +4 -1
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +2 -3
- package/dist/modules/Resource/index.js +1 -1
- package/dist/modules/Rules/index.js +2 -3
- package/dist/modules/Rules/types.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/index.js +2 -2
- package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +7 -7
- package/dist/solution/BuyTickets/index.js +7 -8
- package/dist/solution/Checkout/index.js +29 -29
- package/dist/solution/ShopDiscount/index.js +1 -1
- package/dist/solution/ShopDiscount/types.d.ts +1 -1
- 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 +28 -27
- package/lib/effects/index.d.ts +2 -2
- package/lib/effects/index.js +7 -3
- package/lib/modules/Account/index.js +12 -12
- package/lib/modules/AccountList/index.js +11 -14
- package/lib/modules/BaseModule.d.ts +3 -0
- package/lib/modules/BaseModule.js +12 -6
- package/lib/modules/Cart/index.js +9 -14
- package/lib/modules/Cart/utils/cartProduct.js +6 -3
- package/lib/modules/Customer/constants.js +1 -1
- package/lib/modules/Customer/index.js +24 -28
- package/lib/modules/Customer/types.d.ts +1 -1
- package/lib/modules/Date/index.js +6 -10
- package/lib/modules/Date/types.js +0 -1
- package/lib/modules/Discount/index.js +7 -12
- package/lib/modules/Guests/index.js +24 -19
- package/lib/modules/Order/index.js +9 -11
- 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 -97
- package/lib/modules/Payment/types.d.ts +7 -7
- package/lib/modules/Payment/utils.js +6 -3
- package/lib/modules/Payment/walletpass.js +34 -32
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/index.js +5 -6
- package/lib/modules/ProductList/index.js +5 -8
- package/lib/modules/Resource/index.js +13 -9
- package/lib/modules/Rules/index.js +19 -15
- package/lib/modules/Rules/types.d.ts +1 -1
- package/lib/modules/Schedule/index.js +5 -8
- package/lib/modules/Schedule/type.d.ts +7 -7
- package/lib/modules/Schedule/types.d.ts +9 -9
- package/lib/modules/Schedule/utils.js +4 -2
- package/lib/modules/Step/index.js +4 -7
- package/lib/modules/Summary/index.js +4 -9
- package/lib/plugins/request.js +33 -34
- package/lib/plugins/window.js +113 -101
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +105 -71
- package/lib/solution/BookingByStep/utils/capacity.js +15 -10
- package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +8 -4
- package/lib/solution/BookingByStep/utils/stock.js +6 -3
- package/lib/solution/BookingByStep/utils/timeslots.js +27 -24
- package/lib/solution/BookingTicket/index.js +20 -25
- 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 +1 -3
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +9 -10
- package/lib/solution/BuyTickets/index.js +22 -23
- package/lib/solution/Checkout/index.js +227 -234
- package/lib/solution/Checkout/utils/index.js +22 -18
- package/lib/solution/ShopDiscount/index.js +12 -16
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- 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 +7 -5
- package/package.json +1 -1
|
@@ -51,33 +51,29 @@ var import_stock = require("./utils/stock");
|
|
|
51
51
|
import_dayjs.default.extend(import_isSameOrBefore.default);
|
|
52
52
|
import_dayjs.default.extend(import_isSameOrAfter.default);
|
|
53
53
|
var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
cacheId;
|
|
63
|
-
otherData = {};
|
|
64
|
-
// 提供给 UI 层的临时数据存储,会进缓存
|
|
65
|
-
platform;
|
|
54
|
+
constructor() {
|
|
55
|
+
super(...arguments);
|
|
56
|
+
this.defaultName = "bookingByStep";
|
|
57
|
+
this.defaultVersion = "1.0.0";
|
|
58
|
+
this.isSolution = true;
|
|
59
|
+
this.otherParams = {};
|
|
60
|
+
this.otherData = {};
|
|
61
|
+
}
|
|
66
62
|
// 平台类型,用于判断是 PC / H5
|
|
67
63
|
async initialize(core, options) {
|
|
68
64
|
var _a, _b, _c, _d, _e;
|
|
69
65
|
this.core = core;
|
|
70
66
|
this.store = options.store || {};
|
|
71
67
|
this.otherParams = options.otherParams || {};
|
|
72
|
-
console.log("[BookingByStep]
|
|
68
|
+
console.log("[BookingByStep] 初始化完成");
|
|
73
69
|
this.request = core.getPlugin("request");
|
|
74
70
|
this.window = core.getPlugin("window");
|
|
75
71
|
this.shopStore = core.getPlugin("shopStore");
|
|
76
72
|
if (!this.request) {
|
|
77
|
-
throw new Error("bookingByStep
|
|
73
|
+
throw new Error("bookingByStep解决方案需要 request 插件支持");
|
|
78
74
|
}
|
|
79
75
|
if (!this.shopStore) {
|
|
80
|
-
throw new Error("SummaryModule
|
|
76
|
+
throw new Error("SummaryModule 需要 shopStore 插件支持");
|
|
81
77
|
}
|
|
82
78
|
let targetCacheData = {};
|
|
83
79
|
this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
|
|
@@ -115,11 +111,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
115
111
|
}
|
|
116
112
|
});
|
|
117
113
|
} else {
|
|
118
|
-
throw new Error(
|
|
114
|
+
throw new Error(`模块 ${step} 不存在`);
|
|
119
115
|
}
|
|
120
116
|
});
|
|
121
117
|
this.store.schedule.loadAllSchedule();
|
|
122
|
-
this.core.effects.emit(
|
|
118
|
+
this.core.effects.emit(`${this.name}:onInited`, {});
|
|
123
119
|
}
|
|
124
120
|
// 初始化step
|
|
125
121
|
initStep(stepList) {
|
|
@@ -484,7 +480,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
484
480
|
this.updateQuotationPriceAndCart(date);
|
|
485
481
|
}
|
|
486
482
|
} else {
|
|
487
|
-
throw new Error(
|
|
483
|
+
throw new Error(`没有找到${accountId}账户`);
|
|
488
484
|
}
|
|
489
485
|
}
|
|
490
486
|
// 生成购物车的正规数据
|
|
@@ -677,7 +673,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
677
673
|
updateCart(params) {
|
|
678
674
|
const targetCartItem = this.store.cart.getItem(params._id);
|
|
679
675
|
if (!targetCartItem) {
|
|
680
|
-
throw new Error(
|
|
676
|
+
throw new Error(`没有找到${params._id}购物车商品`);
|
|
681
677
|
}
|
|
682
678
|
this.beforeUpdateCart(params, targetCartItem);
|
|
683
679
|
this.store.cart.updateItem(params);
|
|
@@ -704,13 +700,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
704
700
|
const dateRange = this.store.date.getDateRange();
|
|
705
701
|
if (dateRange == null ? void 0 : dateRange.length) {
|
|
706
702
|
dateRange.forEach((n) => {
|
|
707
|
-
if (n.resource)
|
|
703
|
+
if (n.resource)
|
|
704
|
+
allOriginResources.push(...n.resource);
|
|
708
705
|
});
|
|
709
706
|
}
|
|
710
707
|
if (!allOriginResources.length) {
|
|
711
708
|
const dateList = this.store.date.getDateList();
|
|
712
709
|
dateList == null ? void 0 : dateList.forEach((n) => {
|
|
713
|
-
if (n.resource)
|
|
710
|
+
if (n.resource)
|
|
711
|
+
allOriginResources.push(...n.resource);
|
|
714
712
|
});
|
|
715
713
|
}
|
|
716
714
|
if (params.resources) {
|
|
@@ -842,7 +840,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
842
840
|
const resources = [];
|
|
843
841
|
if (dateRange == null ? void 0 : dateRange.length) {
|
|
844
842
|
dateRange.forEach((n) => {
|
|
845
|
-
if (n.resource)
|
|
843
|
+
if (n.resource)
|
|
844
|
+
resources.push(...n.resource);
|
|
846
845
|
});
|
|
847
846
|
}
|
|
848
847
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
@@ -856,7 +855,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
856
855
|
} else {
|
|
857
856
|
const dateList = this.store.date.getDateList();
|
|
858
857
|
dateList.forEach((n) => {
|
|
859
|
-
if (n.resource)
|
|
858
|
+
if (n.resource)
|
|
859
|
+
resources.push(...n.resource);
|
|
860
860
|
});
|
|
861
861
|
}
|
|
862
862
|
}
|
|
@@ -925,7 +925,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
925
925
|
}
|
|
926
926
|
return res.usable;
|
|
927
927
|
});
|
|
928
|
-
if (m.onlyComputed)
|
|
928
|
+
if (m.onlyComputed)
|
|
929
|
+
return false;
|
|
929
930
|
return !canUseArr.some((n2) => n2 === false);
|
|
930
931
|
});
|
|
931
932
|
});
|
|
@@ -937,7 +938,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
937
938
|
item.renderList = item.renderList.filter((n) => {
|
|
938
939
|
var _a2, _b2, _c2;
|
|
939
940
|
const recordCount = n.capacity || 0;
|
|
940
|
-
if (n.onlyComputed)
|
|
941
|
+
if (n.onlyComputed)
|
|
942
|
+
return false;
|
|
941
943
|
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
942
944
|
resource: n,
|
|
943
945
|
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
|
|
@@ -991,12 +993,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
991
993
|
const dateRange = this.store.date.getDateRange();
|
|
992
994
|
const resources = [];
|
|
993
995
|
dateRange.forEach((n) => {
|
|
994
|
-
if (n.resource)
|
|
996
|
+
if (n.resource)
|
|
997
|
+
resources.push(...n.resource);
|
|
995
998
|
});
|
|
996
999
|
const resourcesMap = (0, import_utils.getResourcesMap)(resources);
|
|
997
1000
|
const targetCartItem = cartItems.find((n) => n._id === id);
|
|
998
1001
|
if (!targetCartItem) {
|
|
999
|
-
throw new Error(
|
|
1002
|
+
throw new Error(`没有找到${id}购物车商品`);
|
|
1000
1003
|
}
|
|
1001
1004
|
let selectedResources = [];
|
|
1002
1005
|
const { currentCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(targetCartItem);
|
|
@@ -1022,7 +1025,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1022
1025
|
productResources.forEach((item) => {
|
|
1023
1026
|
item.renderList = item.renderList.filter((n) => {
|
|
1024
1027
|
const recordCount = n.capacity || 0;
|
|
1025
|
-
if (n.onlyComputed)
|
|
1028
|
+
if (n.onlyComputed)
|
|
1029
|
+
return false;
|
|
1026
1030
|
return recordCount >= currentCapacity;
|
|
1027
1031
|
});
|
|
1028
1032
|
});
|
|
@@ -1065,7 +1069,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1065
1069
|
let AllResources = [];
|
|
1066
1070
|
if (dateRange == null ? void 0 : dateRange.length) {
|
|
1067
1071
|
dateRange.forEach((n) => {
|
|
1068
|
-
if (n.resource)
|
|
1072
|
+
if (n.resource)
|
|
1073
|
+
AllResources.push(...n.resource);
|
|
1069
1074
|
});
|
|
1070
1075
|
}
|
|
1071
1076
|
if (!AllResources.length) {
|
|
@@ -1078,7 +1083,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1078
1083
|
} else {
|
|
1079
1084
|
const dateList = this.store.date.getDateList();
|
|
1080
1085
|
dateList.forEach((n) => {
|
|
1081
|
-
if (n.resource)
|
|
1086
|
+
if (n.resource)
|
|
1087
|
+
AllResources.push(...n.resource);
|
|
1082
1088
|
});
|
|
1083
1089
|
}
|
|
1084
1090
|
}
|
|
@@ -1100,8 +1106,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1100
1106
|
var _a2, _b2, _c2, _d;
|
|
1101
1107
|
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
1102
1108
|
const bIsCombined = ((_d = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
1103
|
-
if (aIsCombined && !bIsCombined)
|
|
1104
|
-
|
|
1109
|
+
if (aIsCombined && !bIsCombined)
|
|
1110
|
+
return 1;
|
|
1111
|
+
if (!aIsCombined && bIsCombined)
|
|
1112
|
+
return -1;
|
|
1105
1113
|
return 0;
|
|
1106
1114
|
});
|
|
1107
1115
|
const resourcesUseableMap = [
|
|
@@ -1188,7 +1196,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1188
1196
|
const resources = [];
|
|
1189
1197
|
if ((_a = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _a.date) {
|
|
1190
1198
|
dateRange.forEach((n) => {
|
|
1191
|
-
if (n.resource)
|
|
1199
|
+
if (n.resource)
|
|
1200
|
+
resources.push(...n.resource);
|
|
1192
1201
|
});
|
|
1193
1202
|
}
|
|
1194
1203
|
const errorList = [];
|
|
@@ -1321,7 +1330,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1321
1330
|
productResources.forEach((item2) => {
|
|
1322
1331
|
item2.renderList = item2.renderList.filter((n) => {
|
|
1323
1332
|
const recordCount = (n.capacity || 0) - (selectResourcesMap[n.id] || 0);
|
|
1324
|
-
if (n.onlyComputed)
|
|
1333
|
+
if (n.onlyComputed)
|
|
1334
|
+
return false;
|
|
1325
1335
|
return recordCount >= currentCapacity;
|
|
1326
1336
|
});
|
|
1327
1337
|
});
|
|
@@ -1623,11 +1633,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1623
1633
|
const newScheduleArr = this.getScheduleDataByIds(
|
|
1624
1634
|
targetProductData["schedule.ids"]
|
|
1625
1635
|
);
|
|
1626
|
-
if (!this.store.currentProductMeta)
|
|
1636
|
+
if (!this.store.currentProductMeta)
|
|
1637
|
+
this.store.currentProductMeta = {};
|
|
1627
1638
|
this.store.currentProductMeta.schedule = newScheduleArr;
|
|
1628
1639
|
} else if (targetProductData.duration) {
|
|
1629
1640
|
const dateRange = this.store.date.getDateRange();
|
|
1630
|
-
if (!(dateRange == null ? void 0 : dateRange.length))
|
|
1641
|
+
if (!(dateRange == null ? void 0 : dateRange.length))
|
|
1642
|
+
return;
|
|
1631
1643
|
this.getAvailableDate({
|
|
1632
1644
|
startDate: dateRange[0].date,
|
|
1633
1645
|
endDate: dateRange[dateRange.length - 1].date,
|
|
@@ -1686,8 +1698,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1686
1698
|
var _a2, _b2, _c2, _d2;
|
|
1687
1699
|
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
1688
1700
|
const bIsCombined = ((_d2 = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d2.status) === 1;
|
|
1689
|
-
if (aIsCombined && !bIsCombined)
|
|
1690
|
-
|
|
1701
|
+
if (aIsCombined && !bIsCombined)
|
|
1702
|
+
return 1;
|
|
1703
|
+
if (!aIsCombined && bIsCombined)
|
|
1704
|
+
return -1;
|
|
1691
1705
|
return 0;
|
|
1692
1706
|
});
|
|
1693
1707
|
const firstEnabledResourceId = (_e = (_d = (_c = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.find(
|
|
@@ -1855,19 +1869,20 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1855
1869
|
* 找到多个资源的公共可用时间段
|
|
1856
1870
|
*/
|
|
1857
1871
|
findCommonAvailableTimeSlots(resources) {
|
|
1858
|
-
if (resources.length === 0)
|
|
1859
|
-
|
|
1872
|
+
if (resources.length === 0)
|
|
1873
|
+
return [];
|
|
1874
|
+
console.log(`计算 ${resources.length} 个资源的公共时间段`);
|
|
1860
1875
|
const allTimeSlots = resources.map(
|
|
1861
1876
|
(resource) => resource.times.map((time) => ({
|
|
1862
1877
|
start: (0, import_dayjs.default)(time.start_at),
|
|
1863
1878
|
end: (0, import_dayjs.default)(time.end_at)
|
|
1864
1879
|
}))
|
|
1865
1880
|
);
|
|
1866
|
-
console.log("
|
|
1881
|
+
console.log("所有资源的时间段:", allTimeSlots.map(
|
|
1867
1882
|
(slots) => slots.map((slot) => `${slot.start.format("HH:mm")}-${slot.end.format("HH:mm")}`)
|
|
1868
1883
|
));
|
|
1869
1884
|
let commonSlots = allTimeSlots[0];
|
|
1870
|
-
console.log("
|
|
1885
|
+
console.log("初始公共时间段:", commonSlots.map((slot) => `${slot.start.format("HH:mm")}-${slot.end.format("HH:mm")}`));
|
|
1871
1886
|
for (let i = 1; i < allTimeSlots.length; i++) {
|
|
1872
1887
|
const currentResourceSlots = allTimeSlots[i];
|
|
1873
1888
|
const intersections = [];
|
|
@@ -1884,9 +1899,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1884
1899
|
});
|
|
1885
1900
|
});
|
|
1886
1901
|
commonSlots = intersections;
|
|
1887
|
-
console.log(
|
|
1902
|
+
console.log(`与资源${i}求交集后的公共时间段:`, commonSlots.map((slot) => `${slot.start.format("HH:mm")}-${slot.end.format("HH:mm")}`));
|
|
1888
1903
|
if (commonSlots.length === 0) {
|
|
1889
|
-
console.log("
|
|
1904
|
+
console.log("没有找到公共时间段");
|
|
1890
1905
|
return [];
|
|
1891
1906
|
}
|
|
1892
1907
|
}
|
|
@@ -1894,13 +1909,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1894
1909
|
startTime: slot.start.format("HH:mm"),
|
|
1895
1910
|
endTime: slot.end.format("HH:mm")
|
|
1896
1911
|
}));
|
|
1897
|
-
console.log("
|
|
1912
|
+
console.log("最终公共时间段:", result);
|
|
1898
1913
|
return result;
|
|
1899
1914
|
}
|
|
1900
1915
|
checkMaxDurationCapacity() {
|
|
1901
1916
|
var _a, _b;
|
|
1902
1917
|
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1903
|
-
if (cartItems.length === 0)
|
|
1918
|
+
if (cartItems.length === 0)
|
|
1919
|
+
return { success: true, minAvailableCount: 0 };
|
|
1904
1920
|
const itemsWithTime = [];
|
|
1905
1921
|
const itemsWithoutTime = [];
|
|
1906
1922
|
const availableCountsByResourceType = [];
|
|
@@ -1916,7 +1932,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1916
1932
|
const itemsByResourceType = {};
|
|
1917
1933
|
itemsWithoutTime.forEach((cartItem) => {
|
|
1918
1934
|
var _a2;
|
|
1919
|
-
if (!cartItem._productOrigin)
|
|
1935
|
+
if (!cartItem._productOrigin)
|
|
1936
|
+
return;
|
|
1920
1937
|
const resourceTypes = ((_a2 = cartItem._productOrigin.product_resource) == null ? void 0 : _a2.resources) || [];
|
|
1921
1938
|
resourceTypes.forEach((resourceType) => {
|
|
1922
1939
|
var _a3;
|
|
@@ -1932,10 +1949,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1932
1949
|
});
|
|
1933
1950
|
});
|
|
1934
1951
|
const dateRange = this.store.date.getDateRange();
|
|
1935
|
-
if (!dateRange || dateRange.length === 0)
|
|
1952
|
+
if (!dateRange || dateRange.length === 0)
|
|
1953
|
+
return { success: false, minAvailableCount: 0 };
|
|
1936
1954
|
const resourcesDates = this.store.date.getDateList();
|
|
1937
1955
|
const targetResourceDate = resourcesDates.find((n) => n.date === dateRange[0].date);
|
|
1938
|
-
if (!targetResourceDate)
|
|
1956
|
+
if (!targetResourceDate)
|
|
1957
|
+
return { success: false, minAvailableCount: 0 };
|
|
1939
1958
|
const resourcesMap = (0, import_utils.getResourcesMap)(targetResourceDate.resource || []);
|
|
1940
1959
|
const resourceCodeToFormIdMap = {};
|
|
1941
1960
|
Object.values(itemsByResourceType).flat().forEach((cartItem) => {
|
|
@@ -1958,7 +1977,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1958
1977
|
for (const [resourceCode, items] of Object.entries(itemsByResourceType)) {
|
|
1959
1978
|
const targetFormId = resourceCodeToFormIdMap[resourceCode];
|
|
1960
1979
|
if (!targetFormId) {
|
|
1961
|
-
console.log(
|
|
1980
|
+
console.log(`资源类型 ${resourceCode} 找不到对应的 form_id`);
|
|
1962
1981
|
return { success: false, minAvailableCount: 0 };
|
|
1963
1982
|
}
|
|
1964
1983
|
const resourcesOfThisType = [];
|
|
@@ -1975,7 +1994,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1975
1994
|
});
|
|
1976
1995
|
});
|
|
1977
1996
|
if (resourcesOfThisType.length === 0) {
|
|
1978
|
-
console.log(
|
|
1997
|
+
console.log(`资源类型 ${resourceCode} 没有找到可用资源`);
|
|
1979
1998
|
return { success: false, minAvailableCount: 0 };
|
|
1980
1999
|
}
|
|
1981
2000
|
let resourceTypeConfig = null;
|
|
@@ -1984,7 +2003,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1984
2003
|
resourceTypeConfig = cartItem._productOrigin.product_resource.resources.find(
|
|
1985
2004
|
(r) => r.code === resourceCode && r.status === 1
|
|
1986
2005
|
);
|
|
1987
|
-
if (resourceTypeConfig)
|
|
2006
|
+
if (resourceTypeConfig)
|
|
2007
|
+
break;
|
|
1988
2008
|
}
|
|
1989
2009
|
}
|
|
1990
2010
|
const isMultipleBooking = (resourceTypeConfig == null ? void 0 : resourceTypeConfig.type) === "multiple";
|
|
@@ -2017,20 +2037,20 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2017
2037
|
availableCountsByResourceType.push(availableAmount);
|
|
2018
2038
|
if (requiredAmount > totalAvailable) {
|
|
2019
2039
|
hasCapacityIssue = true;
|
|
2020
|
-
console.log(
|
|
2040
|
+
console.log(`资源类型 ${resourceCode} ${isMultipleBooking ? "容量" : "资源数量"}不足: 需要 ${requiredAmount}, 总共 ${totalAvailable}`);
|
|
2021
2041
|
}
|
|
2022
|
-
console.log(
|
|
2042
|
+
console.log(`资源类型 ${resourceCode} 的资源时间信息:`, resourcesOfThisType.map((r) => ({
|
|
2023
2043
|
id: r.id,
|
|
2024
2044
|
times: r.times.map((t) => `${t.start_at} - ${t.end_at}`)
|
|
2025
2045
|
})));
|
|
2026
2046
|
const commonTimeSlots = this.findCommonAvailableTimeSlots(resourcesOfThisType);
|
|
2027
|
-
console.log(
|
|
2047
|
+
console.log(`资源类型 ${resourceCode} 的公共时间段:`, commonTimeSlots);
|
|
2028
2048
|
if (commonTimeSlots.length === 0) {
|
|
2029
|
-
console.log(
|
|
2049
|
+
console.log(`资源类型 ${resourceCode} 没有公共可用时间段`);
|
|
2030
2050
|
return { success: false, minAvailableCount: 0 };
|
|
2031
2051
|
}
|
|
2032
2052
|
const firstCommonSlot = commonTimeSlots[0];
|
|
2033
|
-
console.log(
|
|
2053
|
+
console.log(`使用公共时间段: ${firstCommonSlot.startTime} - ${firstCommonSlot.endTime}`);
|
|
2034
2054
|
items.forEach((cartItem) => {
|
|
2035
2055
|
if (!processedCartItemIds.has(cartItem._id)) {
|
|
2036
2056
|
processedCartItemIds.add(cartItem._id);
|
|
@@ -2058,7 +2078,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2058
2078
|
const allProcessedItems = [...itemsWithTime, ...processedItemsWithoutTime];
|
|
2059
2079
|
const cartItemsByTimeSlot = {};
|
|
2060
2080
|
allProcessedItems.forEach((cartItem) => {
|
|
2061
|
-
if (!cartItem.start_time || !cartItem.end_time || !cartItem.start_date)
|
|
2081
|
+
if (!cartItem.start_time || !cartItem.end_time || !cartItem.start_date)
|
|
2082
|
+
return;
|
|
2062
2083
|
const timeSlotKey = `${cartItem.start_date}_${cartItem.start_time}_${cartItem.end_date || cartItem.start_date}_${cartItem.end_time}`;
|
|
2063
2084
|
if (!cartItemsByTimeSlot[timeSlotKey]) {
|
|
2064
2085
|
cartItemsByTimeSlot[timeSlotKey] = [];
|
|
@@ -2074,10 +2095,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2074
2095
|
const dateRange = this.store.date.getDateRange();
|
|
2075
2096
|
const resourcesDates = this.store.date.getDateList();
|
|
2076
2097
|
const targetResourceDate = resourcesDates.find((n) => n.date === startDate);
|
|
2077
|
-
if (!targetResourceDate)
|
|
2098
|
+
if (!targetResourceDate)
|
|
2099
|
+
continue;
|
|
2078
2100
|
const resourcesMap = (0, import_utils.getResourcesMap)(targetResourceDate.resource || []);
|
|
2079
2101
|
itemsInTimeSlot.forEach((cartItem) => {
|
|
2080
|
-
if (!cartItem._productOrigin)
|
|
2102
|
+
if (!cartItem._productOrigin)
|
|
2103
|
+
return;
|
|
2081
2104
|
const productResourceIds = (0, import_capacity.getResourcesIdsByProduct)(cartItem._productOrigin);
|
|
2082
2105
|
productResourceIds.forEach((resourceId) => {
|
|
2083
2106
|
if (resourcesMap[resourceId] && !resourcesIdSet.has(resourceId)) {
|
|
@@ -2134,19 +2157,22 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2134
2157
|
const resources = [];
|
|
2135
2158
|
if (dateRange == null ? void 0 : dateRange.length) {
|
|
2136
2159
|
dateRange.forEach((n) => {
|
|
2137
|
-
if (n.resource)
|
|
2160
|
+
if (n.resource)
|
|
2161
|
+
resources.push(...n.resource);
|
|
2138
2162
|
});
|
|
2139
2163
|
}
|
|
2140
2164
|
if (!resources.length) {
|
|
2141
2165
|
const dateList = this.store.date.getDateList();
|
|
2142
2166
|
dateList.forEach((n) => {
|
|
2143
|
-
if (n.resource)
|
|
2167
|
+
if (n.resource)
|
|
2168
|
+
resources.push(...n.resource);
|
|
2144
2169
|
});
|
|
2145
2170
|
}
|
|
2146
2171
|
const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
2147
2172
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
2148
2173
|
const cartItem = cartItems.find((item) => item._id === cartItemId);
|
|
2149
|
-
if (!cartItem)
|
|
2174
|
+
if (!cartItem)
|
|
2175
|
+
return [];
|
|
2150
2176
|
let selectedResources = [];
|
|
2151
2177
|
const { currentCapacity, formatCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(cartItem);
|
|
2152
2178
|
cartItem._origin.metadata.capacity = formatCapacity;
|
|
@@ -2172,7 +2198,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2172
2198
|
const targetResource = productResources.find(
|
|
2173
2199
|
(resource) => resource.code === resourceCode
|
|
2174
2200
|
);
|
|
2175
|
-
if (!targetResource)
|
|
2201
|
+
if (!targetResource)
|
|
2202
|
+
return [];
|
|
2176
2203
|
if (cartItem._origin.start_time) {
|
|
2177
2204
|
const startTime = (0, import_dayjs.default)(
|
|
2178
2205
|
`${cartItem._origin.start_date} ${cartItem._origin.start_time}`
|
|
@@ -2186,8 +2213,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2186
2213
|
var _a2, _b2, _c, _d;
|
|
2187
2214
|
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
2188
2215
|
const bIsCombined = ((_d = (_c = b.metadata) == null ? void 0 : _c.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
2189
|
-
if (aIsCombined && !bIsCombined)
|
|
2190
|
-
|
|
2216
|
+
if (aIsCombined && !bIsCombined)
|
|
2217
|
+
return 1;
|
|
2218
|
+
if (!aIsCombined && bIsCombined)
|
|
2219
|
+
return -1;
|
|
2191
2220
|
return 0;
|
|
2192
2221
|
}
|
|
2193
2222
|
);
|
|
@@ -2195,7 +2224,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2195
2224
|
const mTimes = m.times.filter((n) => {
|
|
2196
2225
|
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));
|
|
2197
2226
|
});
|
|
2198
|
-
if (mTimes.length === 0)
|
|
2227
|
+
if (mTimes.length === 0)
|
|
2228
|
+
return false;
|
|
2199
2229
|
const canUseArr = mTimes.map((item) => {
|
|
2200
2230
|
var _a2;
|
|
2201
2231
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
@@ -2216,14 +2246,16 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2216
2246
|
}
|
|
2217
2247
|
return res.usable;
|
|
2218
2248
|
});
|
|
2219
|
-
if (m.onlyComputed)
|
|
2249
|
+
if (m.onlyComputed)
|
|
2250
|
+
return false;
|
|
2220
2251
|
return !canUseArr.some((n) => n === false);
|
|
2221
2252
|
});
|
|
2222
2253
|
} else {
|
|
2223
2254
|
targetResource.renderList = targetResource.renderList.filter((n) => {
|
|
2224
2255
|
var _a2, _b2;
|
|
2225
2256
|
const recordCount = n.capacity || 0;
|
|
2226
|
-
if (n.onlyComputed)
|
|
2257
|
+
if (n.onlyComputed)
|
|
2258
|
+
return false;
|
|
2227
2259
|
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
2228
2260
|
resource: n,
|
|
2229
2261
|
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
|
|
@@ -2414,7 +2446,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2414
2446
|
}
|
|
2415
2447
|
dates = (0, import_utils3.handleAvailableDateByResource)(res.data, dates);
|
|
2416
2448
|
this.store.date.setDateList(dates);
|
|
2417
|
-
if (!this.store.currentProductMeta)
|
|
2449
|
+
if (!this.store.currentProductMeta)
|
|
2450
|
+
this.store.currentProductMeta = {};
|
|
2418
2451
|
this.store.currentProductMeta.timeSlotBySchedule = {
|
|
2419
2452
|
dateList: dates,
|
|
2420
2453
|
firstAvailableDate,
|
|
@@ -2438,7 +2471,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2438
2471
|
});
|
|
2439
2472
|
}
|
|
2440
2473
|
isTargetNormalProduct(product) {
|
|
2441
|
-
if (!product)
|
|
2474
|
+
if (!product)
|
|
2475
|
+
return false;
|
|
2442
2476
|
return (0, import_utils4.isNormalProduct)(product);
|
|
2443
2477
|
}
|
|
2444
2478
|
isTargetCartIdNormalProduct(id) {
|
|
@@ -131,16 +131,19 @@ function calculateCartItemsCapacityUsageByResourceType({
|
|
|
131
131
|
const resourcesInThisType = resourceTypeMap[formId];
|
|
132
132
|
const resourceIdsInThisType = resourcesInThisType.map((r) => r.id);
|
|
133
133
|
cartItems.forEach((cartItem) => {
|
|
134
|
-
if (!cartItem.start_time || !cartItem.end_time)
|
|
134
|
+
if (!cartItem.start_time || !cartItem.end_time)
|
|
135
|
+
return;
|
|
135
136
|
const itemStart = `${cartItem.start_date} ${cartItem.start_time}`;
|
|
136
137
|
const itemEnd = `${cartItem.end_date || cartItem.start_date} ${cartItem.end_time}`;
|
|
137
138
|
const hasTimeOverlap = !((0, import_dayjs.default)(itemEnd).isBefore((0, import_dayjs.default)(timeSlotStart)) || (0, import_dayjs.default)(itemStart).isAfter((0, import_dayjs.default)(timeSlotEnd)));
|
|
138
|
-
if (!hasTimeOverlap)
|
|
139
|
+
if (!hasTimeOverlap)
|
|
140
|
+
return;
|
|
139
141
|
const productResourceIds = getResourcesIdsByProduct(cartItem._productOrigin);
|
|
140
142
|
const hasResourceTypeOverlap = productResourceIds.some(
|
|
141
143
|
(id) => resourceIdsInThisType.includes(id)
|
|
142
144
|
);
|
|
143
|
-
if (!hasResourceTypeOverlap)
|
|
145
|
+
if (!hasResourceTypeOverlap)
|
|
146
|
+
return;
|
|
144
147
|
const { currentCapacity } = getCapacityInfoByCartItem(cartItem);
|
|
145
148
|
totalUsage += currentCapacity;
|
|
146
149
|
});
|
|
@@ -200,7 +203,8 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
|
|
|
200
203
|
});
|
|
201
204
|
for (const [formId, requiredCapacity] of Object.entries(requiredCapacityByType)) {
|
|
202
205
|
const resourcesInType = resourceTypeMap[formId];
|
|
203
|
-
if (resourcesInType.length === 0)
|
|
206
|
+
if (resourcesInType.length === 0)
|
|
207
|
+
continue;
|
|
204
208
|
let resourceTypeConfig = null;
|
|
205
209
|
for (const cartItem of cartItems) {
|
|
206
210
|
if ((_b = (_a = cartItem._productOrigin) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) {
|
|
@@ -210,11 +214,12 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
|
|
|
210
214
|
return ((_a2 = r.id) == null ? void 0 : _a2.toString()) === formId && r.status === 1;
|
|
211
215
|
}
|
|
212
216
|
);
|
|
213
|
-
if (resourceTypeConfig)
|
|
217
|
+
if (resourceTypeConfig)
|
|
218
|
+
break;
|
|
214
219
|
}
|
|
215
220
|
}
|
|
216
221
|
const isMultipleBooking = (resourceTypeConfig == null ? void 0 : resourceTypeConfig.type) === "multiple";
|
|
217
|
-
console.log(`capacity.ts -
|
|
222
|
+
console.log(`capacity.ts - 资源类型 ${formId} 配置:`, {
|
|
218
223
|
resourceTypeConfig,
|
|
219
224
|
type: resourceTypeConfig == null ? void 0 : resourceTypeConfig.type,
|
|
220
225
|
isMultipleBooking,
|
|
@@ -230,9 +235,9 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
|
|
|
230
235
|
totalAvailableCapacity += resource.capacity || 0;
|
|
231
236
|
}
|
|
232
237
|
});
|
|
233
|
-
console.log(`capacity.ts -
|
|
238
|
+
console.log(`capacity.ts - 资源类型 ${formId} 多个预约检查: 总容量 ${totalAvailableCapacity}, 需求 ${requiredCapacity}`);
|
|
234
239
|
if (totalAvailableCapacity < requiredCapacity) {
|
|
235
|
-
console.log(
|
|
240
|
+
console.log(`资源类型 ${formId} 容量不足: 需要 ${requiredCapacity}, 可用 ${totalAvailableCapacity}`);
|
|
236
241
|
return false;
|
|
237
242
|
}
|
|
238
243
|
} else {
|
|
@@ -245,9 +250,9 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
|
|
|
245
250
|
availableResourceCount++;
|
|
246
251
|
}
|
|
247
252
|
});
|
|
248
|
-
console.log(`capacity.ts -
|
|
253
|
+
console.log(`capacity.ts - 资源类型 ${formId} 单个预约检查: 可用资源数 ${availableResourceCount}, 需求 ${requiredCapacity}`);
|
|
249
254
|
if (availableResourceCount < requiredCapacity) {
|
|
250
|
-
console.log(
|
|
255
|
+
console.log(`资源类型 ${formId} 数量不足: 需要 ${requiredCapacity}, 可用 ${availableResourceCount}`);
|
|
251
256
|
return false;
|
|
252
257
|
}
|
|
253
258
|
}
|
|
@@ -6,7 +6,7 @@ import { CartItem, ProductData } from '../../../modules';
|
|
|
6
6
|
* 3. 格式化资源相关 格式化资源列表 --> 格式化资源 --> 获取时间切片列表 --> 判断单个时间切片是否可用 formatResources
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
type DateType = Dayjs;
|
|
10
10
|
export interface TimeSliceItem {
|
|
11
11
|
start_time: string;
|
|
12
12
|
end_time: string;
|
|
@@ -455,8 +455,10 @@ var getTimeSlicesByResources = ({
|
|
|
455
455
|
var _a, _b, _c, _d;
|
|
456
456
|
const aIsCombined = ((_b = (_a = a.metadata) == null ? void 0 : _a.combined_resource) == null ? void 0 : _b.status) === 1;
|
|
457
457
|
const bIsCombined = ((_d = (_c = b.metadata) == null ? void 0 : _c.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
458
|
-
if (aIsCombined && !bIsCombined)
|
|
459
|
-
|
|
458
|
+
if (aIsCombined && !bIsCombined)
|
|
459
|
+
return 1;
|
|
460
|
+
if (!aIsCombined && bIsCombined)
|
|
461
|
+
return -1;
|
|
460
462
|
return 0;
|
|
461
463
|
});
|
|
462
464
|
let timeSliceList = resources.reduce(
|
|
@@ -540,7 +542,8 @@ var getOthersCartSelectedResources = (cartItems, cartItemId, resourcesMap) => {
|
|
|
540
542
|
}, []);
|
|
541
543
|
};
|
|
542
544
|
function filterScheduleByDateRange(schedule, startDate, endDate) {
|
|
543
|
-
if (!(schedule == null ? void 0 : schedule.length))
|
|
545
|
+
if (!(schedule == null ? void 0 : schedule.length))
|
|
546
|
+
return [];
|
|
544
547
|
const start = new Date(startDate);
|
|
545
548
|
const end = new Date(endDate);
|
|
546
549
|
return schedule.filter((item) => {
|
|
@@ -606,7 +609,8 @@ function filterResourcesByFormItem(resources, form_id) {
|
|
|
606
609
|
}
|
|
607
610
|
function checkTwoResourcesIntersection(resource1, resource2) {
|
|
608
611
|
var _a, _b;
|
|
609
|
-
if (resource1.id === resource2.id)
|
|
612
|
+
if (resource1.id === resource2.id)
|
|
613
|
+
return true;
|
|
610
614
|
if (((_a = resource1.metadata.combined_resource) == null ? void 0 : _a.status) === 1 && // 如果现在选择的是组合资源,需要判断
|
|
611
615
|
// 1、当前其他购物车里是否选了当前组合资源的子资源
|
|
612
616
|
// 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
|
|
@@ -61,10 +61,13 @@ function checkProductStock({
|
|
|
61
61
|
const bundleRequiredQuantity = (bundleItem.num || 1) * quantity;
|
|
62
62
|
const isBundleTrackingEnabled = bundleItem.is_track === 1 || bundleItem.is_track === true;
|
|
63
63
|
const isBundleOverSoldDisabled = bundleItem.over_sold === 0;
|
|
64
|
-
if (!isBundleTrackingEnabled || !isBundleOverSoldDisabled)
|
|
65
|
-
|
|
64
|
+
if (!isBundleTrackingEnabled || !isBundleOverSoldDisabled)
|
|
65
|
+
continue;
|
|
66
|
+
if (bundleStockQuantity === void 0 || bundleStockQuantity === null)
|
|
67
|
+
continue;
|
|
66
68
|
const existingBundleQuantity = currentCartItems.reduce((total, cartItem) => {
|
|
67
|
-
if (!cartItem._bundleOrigin || !Array.isArray(cartItem._bundleOrigin))
|
|
69
|
+
if (!cartItem._bundleOrigin || !Array.isArray(cartItem._bundleOrigin))
|
|
70
|
+
return total;
|
|
68
71
|
cartItem._bundleOrigin.forEach((cartBundleItem) => {
|
|
69
72
|
if (cartBundleItem.bundle_product_id === bundleProductId) {
|
|
70
73
|
total += (cartBundleItem.num || 1) * (cartItem.num || 1);
|