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