@pisell/pisellos 3.0.65 → 3.0.67
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/modules/ProductList/index.js +10 -2
- package/dist/solution/BookingByStep/index.d.ts +32 -4
- package/dist/solution/BookingByStep/index.js +1147 -112
- package/dist/solution/BookingByStep/utils/capacity.d.ts +29 -1
- package/dist/solution/BookingByStep/utils/capacity.js +249 -4
- package/dist/solution/BookingByStep/utils/resources.d.ts +15 -0
- package/dist/solution/BookingByStep/utils/resources.js +1 -1
- package/dist/solution/BookingByStep/utils/stock.d.ts +29 -0
- package/dist/solution/BookingByStep/utils/stock.js +126 -0
- package/dist/solution/ShopDiscount/index.js +27 -9
- package/lib/modules/ProductList/index.js +9 -1
- package/lib/solution/BookingByStep/index.d.ts +32 -4
- package/lib/solution/BookingByStep/index.js +694 -44
- package/lib/solution/BookingByStep/utils/capacity.d.ts +29 -1
- package/lib/solution/BookingByStep/utils/capacity.js +182 -3
- package/lib/solution/BookingByStep/utils/resources.d.ts +15 -0
- package/lib/solution/BookingByStep/utils/resources.js +2 -0
- package/lib/solution/BookingByStep/utils/stock.d.ts +29 -0
- package/lib/solution/BookingByStep/utils/stock.js +89 -0
- package/lib/solution/ShopDiscount/index.js +9 -0
- package/package.json +1 -1
|
@@ -34,19 +34,21 @@ __export(BookingByStep_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(BookingByStep_exports);
|
|
35
35
|
var import_BaseModule = require("../../modules/BaseModule");
|
|
36
36
|
var import_types = require("./types");
|
|
37
|
+
var import_utils = require("../../modules/Cart/utils");
|
|
37
38
|
var import_products = require("./utils/products");
|
|
38
39
|
var import_resources = require("./utils/resources");
|
|
39
40
|
var import_dayjs = __toESM(require("dayjs"));
|
|
40
41
|
var import_isSameOrBefore = __toESM(require("dayjs/plugin/isSameOrBefore"));
|
|
41
42
|
var import_isSameOrAfter = __toESM(require("dayjs/plugin/isSameOrAfter"));
|
|
42
|
-
var
|
|
43
|
+
var import_utils2 = require("../../modules/Resource/utils");
|
|
43
44
|
var import_lodash_es = require("lodash-es");
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
var
|
|
45
|
+
var import_utils3 = require("../../modules/Schedule/utils");
|
|
46
|
+
var import_utils4 = require("../../modules/Date/utils");
|
|
47
|
+
var import_utils5 = require("../../modules/Product/utils");
|
|
47
48
|
var import_timeslots = require("./utils/timeslots");
|
|
48
49
|
var import_changePrice = require("../../modules/Cart/utils/changePrice");
|
|
49
50
|
var import_capacity = require("./utils/capacity");
|
|
51
|
+
var import_stock = require("./utils/stock");
|
|
50
52
|
import_dayjs.default.extend(import_isSameOrBefore.default);
|
|
51
53
|
import_dayjs.default.extend(import_isSameOrAfter.default);
|
|
52
54
|
var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
@@ -363,7 +365,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
363
365
|
let date = (_b = (_a = this.store.date.getDateRange()) == null ? void 0 : _a[0]) == null ? void 0 : _b.date;
|
|
364
366
|
if (!date) {
|
|
365
367
|
const normalProductCartItem = cartItems.find(
|
|
366
|
-
(n) => !(0,
|
|
368
|
+
(n) => !(0, import_utils5.isNormalProduct)(n._productOrigin)
|
|
367
369
|
);
|
|
368
370
|
date = (normalProductCartItem == null ? void 0 : normalProductCartItem.start_date) || "";
|
|
369
371
|
}
|
|
@@ -473,7 +475,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
473
475
|
let date = (_b = (_a = this.store.date.getDateRange()) == null ? void 0 : _a[0]) == null ? void 0 : _b.date;
|
|
474
476
|
if (!date) {
|
|
475
477
|
const normalProductCartItem = cartItems.find(
|
|
476
|
-
(n) => !(0,
|
|
478
|
+
(n) => !(0, import_utils5.isNormalProduct)(n._productOrigin)
|
|
477
479
|
);
|
|
478
480
|
date = (normalProductCartItem == null ? void 0 : normalProductCartItem.start_date) || "";
|
|
479
481
|
}
|
|
@@ -525,7 +527,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
525
527
|
}
|
|
526
528
|
});
|
|
527
529
|
let type = this.otherParams.isRetailTemplate ? "virtual" : "appointment_booking";
|
|
528
|
-
if ((0,
|
|
530
|
+
if ((0, import_utils5.areAllNormalProducts)(
|
|
529
531
|
newCartItems.map((n) => n._productOrigin)
|
|
530
532
|
)) {
|
|
531
533
|
type = "virtual";
|
|
@@ -561,9 +563,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
561
563
|
* @param {ProductData} productData
|
|
562
564
|
* @memberof BookingByStepImpl
|
|
563
565
|
*/
|
|
564
|
-
|
|
566
|
+
storeProduct(productData) {
|
|
565
567
|
const activeAccount = this.getActiveAccount();
|
|
566
|
-
this.addProductToCart({
|
|
568
|
+
return this.addProductToCart({
|
|
567
569
|
product: productData,
|
|
568
570
|
account: activeAccount
|
|
569
571
|
});
|
|
@@ -597,6 +599,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
597
599
|
quantity = 1
|
|
598
600
|
} = product || {};
|
|
599
601
|
const productData = { ...origin, product_variant_id };
|
|
602
|
+
const currentCartItems = this.store.cart.getItems();
|
|
603
|
+
const stockCheckResult = (0, import_stock.checkProductStock)({
|
|
604
|
+
productData,
|
|
605
|
+
product_variant_id,
|
|
606
|
+
quantity,
|
|
607
|
+
bundle,
|
|
608
|
+
currentCartItems
|
|
609
|
+
});
|
|
610
|
+
if (!stockCheckResult.success) {
|
|
611
|
+
return stockCheckResult;
|
|
612
|
+
}
|
|
600
613
|
if (!account) {
|
|
601
614
|
const activeAccount = this.getActiveAccount();
|
|
602
615
|
if (activeAccount) {
|
|
@@ -609,7 +622,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
609
622
|
account: account || void 0
|
|
610
623
|
});
|
|
611
624
|
if (flag) {
|
|
612
|
-
return;
|
|
625
|
+
return { success: true };
|
|
613
626
|
}
|
|
614
627
|
const addItemParams = {
|
|
615
628
|
product: productData,
|
|
@@ -624,7 +637,16 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
624
637
|
addItemParams.account = account;
|
|
625
638
|
}
|
|
626
639
|
this.addProductCheck({ date });
|
|
627
|
-
|
|
640
|
+
if (addItemParams.quantity > 1 && !(0, import_utils5.isNormalProduct)(productData)) {
|
|
641
|
+
for (let i = 0; i < addItemParams.quantity; i++) {
|
|
642
|
+
const newAddItemParams = (0, import_lodash_es.cloneDeep)(addItemParams);
|
|
643
|
+
newAddItemParams.quantity = 1;
|
|
644
|
+
this.store.cart.addItem(newAddItemParams);
|
|
645
|
+
}
|
|
646
|
+
} else {
|
|
647
|
+
this.store.cart.addItem(addItemParams);
|
|
648
|
+
}
|
|
649
|
+
return { success: true };
|
|
628
650
|
}
|
|
629
651
|
/**
|
|
630
652
|
* 添加完购物车以后做的一些检测,比如日期是否在同一天
|
|
@@ -636,7 +658,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
636
658
|
date
|
|
637
659
|
}) {
|
|
638
660
|
if (date) {
|
|
639
|
-
const cartItems = this.store.cart.getItems().filter((n) => !(0,
|
|
661
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
640
662
|
const cartItemsByDate = cartItems.filter(
|
|
641
663
|
(n) => !(0, import_dayjs.default)(n.start_date).isSame((0, import_dayjs.default)(date.startTime), "day")
|
|
642
664
|
);
|
|
@@ -798,7 +820,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
798
820
|
* @returns 不符合条件的购物车商品ID列表
|
|
799
821
|
*/
|
|
800
822
|
checkCartItems(type) {
|
|
801
|
-
const cartItems = this.store.cart.getItems().filter((n) => !(0,
|
|
823
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
802
824
|
const errorCartItemIds = [];
|
|
803
825
|
cartItems.forEach((cartItem) => {
|
|
804
826
|
const result = this.store.cart.checkCartItemByType(cartItem, type);
|
|
@@ -829,7 +851,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
829
851
|
resources.push(...n.resource);
|
|
830
852
|
});
|
|
831
853
|
}
|
|
832
|
-
const cartItems = this.store.cart.getItems().filter((n) => !(0,
|
|
854
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
833
855
|
if (!resources.length) {
|
|
834
856
|
const firstDateCartItem = cartItems == null ? void 0 : cartItems.find((n) => n.start_date);
|
|
835
857
|
if (firstDateCartItem == null ? void 0 : firstDateCartItem.start_date) {
|
|
@@ -845,7 +867,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
845
867
|
});
|
|
846
868
|
}
|
|
847
869
|
}
|
|
848
|
-
const resourcesMap = (0,
|
|
870
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
849
871
|
const arr = [];
|
|
850
872
|
cartItems.forEach((cartItem) => {
|
|
851
873
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
@@ -974,14 +996,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
974
996
|
*/
|
|
975
997
|
getResourcesListByCartItem(id) {
|
|
976
998
|
var _a, _b;
|
|
977
|
-
const cartItems = this.store.cart.getItems().filter((n) => !(0,
|
|
999
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
978
1000
|
const dateRange = this.store.date.getDateRange();
|
|
979
1001
|
const resources = [];
|
|
980
1002
|
dateRange.forEach((n) => {
|
|
981
1003
|
if (n.resource)
|
|
982
1004
|
resources.push(...n.resource);
|
|
983
1005
|
});
|
|
984
|
-
const resourcesMap = (0,
|
|
1006
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)(resources);
|
|
985
1007
|
const targetCartItem = cartItems.find((n) => n._id === id);
|
|
986
1008
|
if (!targetCartItem) {
|
|
987
1009
|
throw new Error(`没有找到${id}购物车商品`);
|
|
@@ -1038,7 +1060,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1038
1060
|
capacity
|
|
1039
1061
|
}) {
|
|
1040
1062
|
var _a, _b, _c;
|
|
1041
|
-
if ((0,
|
|
1063
|
+
if ((0, import_utils5.isNormalProduct)(cartItem._productOrigin)) {
|
|
1042
1064
|
return {};
|
|
1043
1065
|
}
|
|
1044
1066
|
const dateRange = this.store.date.getDateRange();
|
|
@@ -1073,7 +1095,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1073
1095
|
});
|
|
1074
1096
|
}
|
|
1075
1097
|
}
|
|
1076
|
-
const resourcesMap = (0,
|
|
1098
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)((0, import_lodash_es.cloneDeep)(AllResources));
|
|
1077
1099
|
const allCartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1078
1100
|
const selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
1079
1101
|
allCartItems,
|
|
@@ -1154,7 +1176,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1154
1176
|
selectedResource: targetResource
|
|
1155
1177
|
};
|
|
1156
1178
|
} else {
|
|
1157
|
-
const resourcesMap2 = (0,
|
|
1179
|
+
const resourcesMap2 = (0, import_utils2.getResourcesMap)(resources);
|
|
1158
1180
|
const resourceIds = resources.map((n) => n.id);
|
|
1159
1181
|
const timeSlots2 = (0, import_resources.getTimeSlicesByResources)({
|
|
1160
1182
|
resourceIds,
|
|
@@ -1292,7 +1314,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1292
1314
|
currentResourcesRenderList.push(...n.renderList || []);
|
|
1293
1315
|
}
|
|
1294
1316
|
});
|
|
1295
|
-
const resourcesMap = (0,
|
|
1317
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)(currentResourcesRenderList);
|
|
1296
1318
|
if (item.holder_id) {
|
|
1297
1319
|
selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
1298
1320
|
allCartItems,
|
|
@@ -1357,7 +1379,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1357
1379
|
}
|
|
1358
1380
|
});
|
|
1359
1381
|
};
|
|
1360
|
-
const cartItems = this.store.cart.getItems().filter((n) => !(0,
|
|
1382
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
1361
1383
|
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
1362
1384
|
accountList.forEach((account) => {
|
|
1363
1385
|
const cartItems2 = this.store.cart.getCartByAccount(account.getId());
|
|
@@ -1373,7 +1395,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1373
1395
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1374
1396
|
let dateRange = this.store.date.getDateRange();
|
|
1375
1397
|
const resources = [];
|
|
1376
|
-
const cartItems = this.store.cart.getItems().filter((n) => !(0,
|
|
1398
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
1377
1399
|
const resourceIds = [];
|
|
1378
1400
|
let resourcesTypeId = void 0;
|
|
1379
1401
|
let isSingleResource = false;
|
|
@@ -1387,7 +1409,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1387
1409
|
isSingleResource = n.type === "single";
|
|
1388
1410
|
}
|
|
1389
1411
|
});
|
|
1390
|
-
if (item.resource_id) {
|
|
1412
|
+
if (item.resource_id && !resourceIds.includes(item.resource_id)) {
|
|
1391
1413
|
resourceIds.push(item.resource_id);
|
|
1392
1414
|
}
|
|
1393
1415
|
resourcesTypeId = (_g2 = (_f2 = (_e2 = (_d2 = item == null ? void 0 : item._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e2.resources) == null ? void 0 : _f2.find(
|
|
@@ -1411,7 +1433,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1411
1433
|
}
|
|
1412
1434
|
});
|
|
1413
1435
|
}
|
|
1414
|
-
const resourcesMap = (0,
|
|
1436
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)(resources);
|
|
1415
1437
|
let duration = 0;
|
|
1416
1438
|
const accountList = this.store.accountList.getAccounts();
|
|
1417
1439
|
const checkDuration = (cartItems2) => {
|
|
@@ -1475,6 +1497,23 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1475
1497
|
return 0;
|
|
1476
1498
|
}, 0);
|
|
1477
1499
|
}
|
|
1500
|
+
const calculateCapacityFromCartItems = (items) => {
|
|
1501
|
+
return items.reduce((total, item) => {
|
|
1502
|
+
return total + ((0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 0);
|
|
1503
|
+
}, 0);
|
|
1504
|
+
};
|
|
1505
|
+
let maxCapacity = 1;
|
|
1506
|
+
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
1507
|
+
accountList.forEach((account) => {
|
|
1508
|
+
const accountCartItems = this.store.cart.getCartByAccount(account.getId());
|
|
1509
|
+
const currentCapacity = calculateCapacityFromCartItems(accountCartItems);
|
|
1510
|
+
if (currentCapacity > maxCapacity) {
|
|
1511
|
+
maxCapacity = currentCapacity;
|
|
1512
|
+
}
|
|
1513
|
+
});
|
|
1514
|
+
} else {
|
|
1515
|
+
maxCapacity = calculateCapacityFromCartItems(cartItems);
|
|
1516
|
+
}
|
|
1478
1517
|
const timeSlots = (0, import_resources.getTimeSlicesByResources)({
|
|
1479
1518
|
resourceIds,
|
|
1480
1519
|
resourcesMap,
|
|
@@ -1482,6 +1521,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1482
1521
|
currentDate: dateRange[0].date,
|
|
1483
1522
|
split: 10,
|
|
1484
1523
|
resourcesUseableMap,
|
|
1524
|
+
capacity: maxCapacity,
|
|
1485
1525
|
cut_off_time: maxCutOffTime,
|
|
1486
1526
|
hasFlexibleDuration,
|
|
1487
1527
|
operating_day_boundary,
|
|
@@ -1492,7 +1532,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1492
1532
|
// 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
|
|
1493
1533
|
submitTimeSlot(timeSlots) {
|
|
1494
1534
|
var _a, _b;
|
|
1495
|
-
const cartItems = this.store.cart.getItems().filter((n) => !(0,
|
|
1535
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
1496
1536
|
const allResources = this.store.date.getResourcesListByDate(
|
|
1497
1537
|
timeSlots.start_at.format("YYYY-MM-DD")
|
|
1498
1538
|
);
|
|
@@ -1567,14 +1607,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1567
1607
|
});
|
|
1568
1608
|
});
|
|
1569
1609
|
}
|
|
1570
|
-
clearCache() {
|
|
1571
|
-
}
|
|
1572
|
-
clearCacheByModule(module2) {
|
|
1573
|
-
}
|
|
1574
1610
|
getScheduleDataByIds(scheduleIds) {
|
|
1575
1611
|
const targetSchedules = this.store.schedule.getScheduleListByIds(scheduleIds);
|
|
1576
1612
|
const targetSchedulesData = targetSchedules.map((item) => {
|
|
1577
|
-
return (0,
|
|
1613
|
+
return (0, import_utils3.calcCalendarDataByScheduleResult)(item);
|
|
1578
1614
|
});
|
|
1579
1615
|
const newSchedule = {};
|
|
1580
1616
|
targetSchedulesData.forEach((item) => {
|
|
@@ -1625,6 +1661,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1625
1661
|
}
|
|
1626
1662
|
this.store.currentProduct = void 0;
|
|
1627
1663
|
}
|
|
1664
|
+
// 通过商品和 schedule 来获取视频可用的时间片、时间片内资源可用的数据
|
|
1628
1665
|
getTimeslotBySchedule({
|
|
1629
1666
|
date,
|
|
1630
1667
|
scheduleIds,
|
|
@@ -1645,7 +1682,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1645
1682
|
const resourcesDates = this.store.date.getDateList();
|
|
1646
1683
|
const targetResourceDate = resourcesDates.find((n) => n.date === date);
|
|
1647
1684
|
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1648
|
-
const resourcesMap = (0,
|
|
1685
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)((targetResourceDate == null ? void 0 : targetResourceDate.resource) || []);
|
|
1649
1686
|
const selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
1650
1687
|
cartItems,
|
|
1651
1688
|
"",
|
|
@@ -1657,12 +1694,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1657
1694
|
selectedResources,
|
|
1658
1695
|
1
|
|
1659
1696
|
);
|
|
1660
|
-
const minTimeMaxTime = (0,
|
|
1697
|
+
const minTimeMaxTime = (0, import_utils3.calcMinTimeMaxTimeBySchedules)(
|
|
1661
1698
|
targetSchedules,
|
|
1662
1699
|
{},
|
|
1663
1700
|
date
|
|
1664
1701
|
);
|
|
1665
|
-
const scheduleTimeSlots = (0,
|
|
1702
|
+
const scheduleTimeSlots = (0, import_utils3.getAllSortedDateRanges)(minTimeMaxTime);
|
|
1666
1703
|
let allProductResources = productResources.flatMap((n) => n.renderList);
|
|
1667
1704
|
allProductResources.sort((a, b) => {
|
|
1668
1705
|
var _a2, _b2, _c2, _d2;
|
|
@@ -1724,6 +1761,100 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1724
1761
|
}
|
|
1725
1762
|
}
|
|
1726
1763
|
});
|
|
1764
|
+
const cartItems2 = this.store.cart.getItems();
|
|
1765
|
+
productResources.forEach((n) => {
|
|
1766
|
+
if (n.type === "single") {
|
|
1767
|
+
const currentResourcesSet = /* @__PURE__ */ new Set([...n.optional_resource, ...n.default_resource]);
|
|
1768
|
+
const sameCartItems = cartItems2.filter((m) => {
|
|
1769
|
+
var _a2, _b2, _c2;
|
|
1770
|
+
return ((_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.id) == null ? void 0 : _b2.toString()) === ((_c2 = targetProductData == null ? void 0 : targetProductData.id) == null ? void 0 : _c2.toString()) && `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end;
|
|
1771
|
+
});
|
|
1772
|
+
if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length > bookingLeft) {
|
|
1773
|
+
bookingLeft = 0;
|
|
1774
|
+
count = 0;
|
|
1775
|
+
}
|
|
1776
|
+
const otherCartItems = cartItems2.filter((m) => {
|
|
1777
|
+
var _a2, _b2, _c2;
|
|
1778
|
+
return ((_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.id) == null ? void 0 : _b2.toString()) !== ((_c2 = targetProductData == null ? void 0 : targetProductData.id) == null ? void 0 : _c2.toString()) && `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end;
|
|
1779
|
+
});
|
|
1780
|
+
otherCartItems.forEach((m) => {
|
|
1781
|
+
var _a2, _b2, _c2;
|
|
1782
|
+
const sameTypeResources = (_c2 = (_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.find((m2) => m2.type === n.type);
|
|
1783
|
+
const sameTypeResourcesSet = /* @__PURE__ */ new Set([...(sameTypeResources == null ? void 0 : sameTypeResources.optional_resource) || [], ...(sameTypeResources == null ? void 0 : sameTypeResources.default_resource) || []]);
|
|
1784
|
+
sameTypeResourcesSet.forEach((resource) => currentResourcesSet.add(resource));
|
|
1785
|
+
});
|
|
1786
|
+
const currentDataResources = this.store.date.getResourcesListByDate((0, import_dayjs.default)(item.start).format("YYYY-MM-DD"));
|
|
1787
|
+
currentDataResources == null ? void 0 : currentDataResources.forEach((m) => {
|
|
1788
|
+
if (currentResourcesSet.has(m.id)) {
|
|
1789
|
+
const mTimes = m.times.filter((n2) => {
|
|
1790
|
+
return !(0, import_dayjs.default)(n2.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n2.end_at).isBefore((0, import_dayjs.default)(item.end), "minute") || (0, import_dayjs.default)(n2.start_at).isBefore((0, import_dayjs.default)(item.end), "minute") && (0, import_dayjs.default)(n2.end_at).isAfter((0, import_dayjs.default)(item.start), "minute");
|
|
1791
|
+
});
|
|
1792
|
+
if (!mTimes.length || mTimes.some((n2) => n2.event_list.length)) {
|
|
1793
|
+
currentResourcesSet.delete(m.id);
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
});
|
|
1797
|
+
if (currentResourcesSet.size > 0 && otherCartItems.length + sameCartItems.length >= currentResourcesSet.size) {
|
|
1798
|
+
bookingLeft = 0;
|
|
1799
|
+
count = 0;
|
|
1800
|
+
}
|
|
1801
|
+
} else {
|
|
1802
|
+
const sameCartItems = cartItems2.filter((m) => {
|
|
1803
|
+
var _a2, _b2, _c2;
|
|
1804
|
+
return ((_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.id) == null ? void 0 : _b2.toString()) === ((_c2 = targetProductData == null ? void 0 : targetProductData.id) == null ? void 0 : _c2.toString()) && `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end;
|
|
1805
|
+
});
|
|
1806
|
+
const sameCartNeedCapacity = sameCartItems.reduce((acc, curr) => acc + (0, import_capacity.getCapacityInfoByCartItem)(curr).currentCapacity, 0);
|
|
1807
|
+
const currentProductResourcesCapacity = n.renderList.reduce((acc, curr) => !curr.onlyComputed ? acc + curr.capacity || 0 : acc, 0);
|
|
1808
|
+
if (sameCartNeedCapacity >= currentProductResourcesCapacity) {
|
|
1809
|
+
bookingLeft = 0;
|
|
1810
|
+
count = 0;
|
|
1811
|
+
}
|
|
1812
|
+
const otherSameTimesCartItems = cartItems2.filter((m) => `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end);
|
|
1813
|
+
const otherCartNeedCapacity = otherSameTimesCartItems.reduce((acc, curr) => acc + (0, import_capacity.getCapacityInfoByCartItem)(curr).currentCapacity, 0);
|
|
1814
|
+
const allRenderList = [...n.renderList.filter((m) => !m.onlyComputed)];
|
|
1815
|
+
otherSameTimesCartItems.forEach((m) => {
|
|
1816
|
+
var _a2, _b2;
|
|
1817
|
+
const productResources2 = (0, import_resources.getResourcesByProduct)(
|
|
1818
|
+
(0, import_utils2.getResourcesMap)((targetResourceDate == null ? void 0 : targetResourceDate.resource) || []),
|
|
1819
|
+
((_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) || [],
|
|
1820
|
+
selectedResources,
|
|
1821
|
+
1
|
|
1822
|
+
);
|
|
1823
|
+
productResources2.forEach((m2) => {
|
|
1824
|
+
if (m2.id === n.id) {
|
|
1825
|
+
m2.renderList.forEach((n2) => {
|
|
1826
|
+
if (!n2.onlyComputed && !allRenderList.find((m3) => m3.id === n2.id)) {
|
|
1827
|
+
allRenderList.push(n2);
|
|
1828
|
+
}
|
|
1829
|
+
});
|
|
1830
|
+
}
|
|
1831
|
+
});
|
|
1832
|
+
});
|
|
1833
|
+
const currentTypeResourcesCapacity = allRenderList.reduce((acc, curr) => acc + curr.capacity || 0, 0);
|
|
1834
|
+
const usedCapacity = allRenderList.reduce((acc, curr) => {
|
|
1835
|
+
const mTimes = curr.times.filter((n2) => {
|
|
1836
|
+
return !(0, import_dayjs.default)(n2.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n2.end_at).isBefore((0, import_dayjs.default)(item.end), "minute") || (0, import_dayjs.default)(n2.start_at).isBefore((0, import_dayjs.default)(item.end), "minute") && (0, import_dayjs.default)(n2.end_at).isAfter((0, import_dayjs.default)(item.start), "minute");
|
|
1837
|
+
});
|
|
1838
|
+
const mSet = /* @__PURE__ */ new Map();
|
|
1839
|
+
mTimes.forEach((n2) => {
|
|
1840
|
+
n2.event_list.forEach((m) => {
|
|
1841
|
+
if ((0, import_resources.isConflict)(
|
|
1842
|
+
{ start_at: m.start_at, end_at: m.end_at },
|
|
1843
|
+
{ start_at: (0, import_dayjs.default)(item.start), end_at: (0, import_dayjs.default)(item.end) }
|
|
1844
|
+
)) {
|
|
1845
|
+
mSet.set(m.id, m.pax || 1);
|
|
1846
|
+
}
|
|
1847
|
+
});
|
|
1848
|
+
});
|
|
1849
|
+
acc += Array.from(mSet.values()).reduce((acc2, curr2) => acc2 + curr2, 0);
|
|
1850
|
+
return acc;
|
|
1851
|
+
}, 0);
|
|
1852
|
+
if (otherCartNeedCapacity + usedCapacity >= currentTypeResourcesCapacity) {
|
|
1853
|
+
bookingLeft = 0;
|
|
1854
|
+
count = 0;
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
});
|
|
1727
1858
|
const startDayJs = (0, import_dayjs.default)(item.start);
|
|
1728
1859
|
const endDayJs = (0, import_dayjs.default)(item.end);
|
|
1729
1860
|
return {
|
|
@@ -1737,6 +1868,525 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1737
1868
|
});
|
|
1738
1869
|
return formatScheduleTimeSlots;
|
|
1739
1870
|
}
|
|
1871
|
+
// 提供给 UI的方法,当前步骤是选择商品,下一步不管是什么都需要在这里做一次检测
|
|
1872
|
+
// 时长类商品关联的资源为多个预约时,在点击进入"选择资源"步骤之前,需要检测当前所有资源的总容量
|
|
1873
|
+
// 选择商品数量大于所有资源配置的总容量时,不能进入下一步,需要在"选择商品"这一步时提示。
|
|
1874
|
+
// 注意 资源分为多个种类,需要每个种类单独检测,不能一股脑把所有资源的容量加起来检测
|
|
1875
|
+
/**
|
|
1876
|
+
* 找到多个资源的公共可用时间段
|
|
1877
|
+
*/
|
|
1878
|
+
findCommonAvailableTimeSlots(resources) {
|
|
1879
|
+
if (resources.length === 0)
|
|
1880
|
+
return [];
|
|
1881
|
+
console.log(`计算 ${resources.length} 个资源的公共时间段`);
|
|
1882
|
+
const allTimeSlots = resources.map(
|
|
1883
|
+
(resource) => resource.times.map((time) => ({
|
|
1884
|
+
start: (0, import_dayjs.default)(time.start_at),
|
|
1885
|
+
end: (0, import_dayjs.default)(time.end_at)
|
|
1886
|
+
}))
|
|
1887
|
+
);
|
|
1888
|
+
console.log("所有资源的时间段:", allTimeSlots.map(
|
|
1889
|
+
(slots) => slots.map((slot) => `${slot.start.format("HH:mm")}-${slot.end.format("HH:mm")}`)
|
|
1890
|
+
));
|
|
1891
|
+
let commonSlots = allTimeSlots[0];
|
|
1892
|
+
console.log("初始公共时间段:", commonSlots.map((slot) => `${slot.start.format("HH:mm")}-${slot.end.format("HH:mm")}`));
|
|
1893
|
+
for (let i = 1; i < allTimeSlots.length; i++) {
|
|
1894
|
+
const currentResourceSlots = allTimeSlots[i];
|
|
1895
|
+
const intersections = [];
|
|
1896
|
+
commonSlots.forEach((commonSlot) => {
|
|
1897
|
+
currentResourceSlots.forEach((currentSlot) => {
|
|
1898
|
+
const overlapStart = commonSlot.start.isAfter(currentSlot.start) ? commonSlot.start : currentSlot.start;
|
|
1899
|
+
const overlapEnd = commonSlot.end.isBefore(currentSlot.end) ? commonSlot.end : currentSlot.end;
|
|
1900
|
+
if (overlapStart.isBefore(overlapEnd)) {
|
|
1901
|
+
intersections.push({
|
|
1902
|
+
start: overlapStart,
|
|
1903
|
+
end: overlapEnd
|
|
1904
|
+
});
|
|
1905
|
+
}
|
|
1906
|
+
});
|
|
1907
|
+
});
|
|
1908
|
+
if (intersections.length === 0) {
|
|
1909
|
+
console.log(`资源${i}与当前公共时间段无交集,跳过该资源`);
|
|
1910
|
+
continue;
|
|
1911
|
+
}
|
|
1912
|
+
commonSlots = intersections;
|
|
1913
|
+
console.log(`与资源${i}求交集后的公共时间段:`, commonSlots.map((slot) => `${slot.start.format("HH:mm")}-${slot.end.format("HH:mm")}`));
|
|
1914
|
+
}
|
|
1915
|
+
const result = commonSlots.map((slot) => ({
|
|
1916
|
+
startTime: slot.start.format("HH:mm"),
|
|
1917
|
+
endTime: slot.end.format("HH:mm")
|
|
1918
|
+
}));
|
|
1919
|
+
console.log("最终公共时间段:", result);
|
|
1920
|
+
return result;
|
|
1921
|
+
}
|
|
1922
|
+
checkMaxDurationCapacity() {
|
|
1923
|
+
var _a, _b;
|
|
1924
|
+
const cartItems = this.store.cart.getItems().filter((item) => !(0, import_utils5.isNormalProduct)(item._productOrigin));
|
|
1925
|
+
if (cartItems.length === 0)
|
|
1926
|
+
return { success: true, minAvailableCount: 0 };
|
|
1927
|
+
const itemsWithTime = [];
|
|
1928
|
+
const itemsWithoutTime = [];
|
|
1929
|
+
const availableCountsByResourceType = [];
|
|
1930
|
+
cartItems.forEach((cartItem) => {
|
|
1931
|
+
if (cartItem.start_time && cartItem.end_time && cartItem.start_date) {
|
|
1932
|
+
itemsWithTime.push(cartItem);
|
|
1933
|
+
} else {
|
|
1934
|
+
itemsWithoutTime.push(cartItem);
|
|
1935
|
+
}
|
|
1936
|
+
});
|
|
1937
|
+
const processedItemsWithoutTime = [];
|
|
1938
|
+
if (itemsWithoutTime.length > 0) {
|
|
1939
|
+
const itemsByResourceType = {};
|
|
1940
|
+
itemsWithoutTime.forEach((cartItem) => {
|
|
1941
|
+
var _a2;
|
|
1942
|
+
if (!cartItem._productOrigin)
|
|
1943
|
+
return;
|
|
1944
|
+
const resourceTypes = ((_a2 = cartItem._productOrigin.product_resource) == null ? void 0 : _a2.resources) || [];
|
|
1945
|
+
resourceTypes.forEach((resourceType) => {
|
|
1946
|
+
var _a3;
|
|
1947
|
+
if (resourceType.status === 1) {
|
|
1948
|
+
const resourceCode = resourceType.code || ((_a3 = resourceType.id) == null ? void 0 : _a3.toString());
|
|
1949
|
+
if (!itemsByResourceType[resourceCode]) {
|
|
1950
|
+
itemsByResourceType[resourceCode] = [];
|
|
1951
|
+
}
|
|
1952
|
+
if (!itemsByResourceType[resourceCode].find((item) => item._id === cartItem._id)) {
|
|
1953
|
+
itemsByResourceType[resourceCode].push(cartItem);
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
});
|
|
1957
|
+
});
|
|
1958
|
+
const dateRange = this.store.date.getDateRange();
|
|
1959
|
+
if (!dateRange || dateRange.length === 0)
|
|
1960
|
+
return { success: false, minAvailableCount: 0 };
|
|
1961
|
+
const resourcesDates = this.store.date.getDateList();
|
|
1962
|
+
const targetResourceDate = resourcesDates.find((n) => n.date === dateRange[0].date);
|
|
1963
|
+
if (!targetResourceDate)
|
|
1964
|
+
return { success: false, minAvailableCount: 0 };
|
|
1965
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)(targetResourceDate.resource || []);
|
|
1966
|
+
const resourceCodeToFormIdMap = {};
|
|
1967
|
+
Object.values(itemsByResourceType).flat().forEach((cartItem) => {
|
|
1968
|
+
var _a2, _b2;
|
|
1969
|
+
if ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) {
|
|
1970
|
+
cartItem._productOrigin.product_resource.resources.forEach((resourceConfig) => {
|
|
1971
|
+
var _a3, _b3;
|
|
1972
|
+
if (resourceConfig.status === 1 && resourceConfig.code) {
|
|
1973
|
+
const formId = ((_a3 = resourceConfig.id) == null ? void 0 : _a3.toString()) || ((_b3 = resourceConfig.resource_type_id) == null ? void 0 : _b3.toString());
|
|
1974
|
+
if (formId) {
|
|
1975
|
+
resourceCodeToFormIdMap[resourceConfig.code] = formId;
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
});
|
|
1979
|
+
}
|
|
1980
|
+
});
|
|
1981
|
+
let hasCapacityIssue = false;
|
|
1982
|
+
const resourceCapacityInfo = [];
|
|
1983
|
+
const processedCartItemIds = /* @__PURE__ */ new Set();
|
|
1984
|
+
for (const [resourceCode, items] of Object.entries(itemsByResourceType)) {
|
|
1985
|
+
const targetFormId = resourceCodeToFormIdMap[resourceCode];
|
|
1986
|
+
if (!targetFormId) {
|
|
1987
|
+
console.log(`资源类型 ${resourceCode} 找不到对应的 form_id`);
|
|
1988
|
+
return { success: false, minAvailableCount: 0 };
|
|
1989
|
+
}
|
|
1990
|
+
const resourcesOfThisType = [];
|
|
1991
|
+
items.forEach((cartItem) => {
|
|
1992
|
+
const productResourceIds = (0, import_capacity.getResourcesIdsByProduct)(cartItem._productOrigin);
|
|
1993
|
+
productResourceIds.forEach((resourceId) => {
|
|
1994
|
+
var _a2;
|
|
1995
|
+
const resource = resourcesMap[resourceId];
|
|
1996
|
+
if (resource && ((_a2 = resource.form_id) == null ? void 0 : _a2.toString()) === targetFormId) {
|
|
1997
|
+
if (!resourcesOfThisType.find((r) => r.id === resource.id)) {
|
|
1998
|
+
resourcesOfThisType.push(resource);
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
});
|
|
2002
|
+
});
|
|
2003
|
+
if (resourcesOfThisType.length === 0) {
|
|
2004
|
+
console.log(`资源类型 ${resourceCode} 没有找到可用资源`);
|
|
2005
|
+
return { success: false, minAvailableCount: 0 };
|
|
2006
|
+
}
|
|
2007
|
+
let resourceTypeConfig = null;
|
|
2008
|
+
for (const cartItem of items) {
|
|
2009
|
+
if ((_b = (_a = cartItem._productOrigin) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) {
|
|
2010
|
+
resourceTypeConfig = cartItem._productOrigin.product_resource.resources.find(
|
|
2011
|
+
(r) => r.code === resourceCode && r.status === 1
|
|
2012
|
+
);
|
|
2013
|
+
if (resourceTypeConfig)
|
|
2014
|
+
break;
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
const isMultipleBooking = (resourceTypeConfig == null ? void 0 : resourceTypeConfig.type) === "multiple";
|
|
2018
|
+
let totalAvailable;
|
|
2019
|
+
let requiredAmount;
|
|
2020
|
+
let availableAmount;
|
|
2021
|
+
if (isMultipleBooking) {
|
|
2022
|
+
totalAvailable = resourcesOfThisType.reduce((sum, resource) => {
|
|
2023
|
+
return sum + (resource.capacity || 0);
|
|
2024
|
+
}, 0);
|
|
2025
|
+
requiredAmount = items.reduce((sum, cartItem) => {
|
|
2026
|
+
const { currentCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(cartItem);
|
|
2027
|
+
return sum + currentCapacity;
|
|
2028
|
+
}, 0);
|
|
2029
|
+
availableAmount = Math.max(0, totalAvailable - requiredAmount);
|
|
2030
|
+
} else {
|
|
2031
|
+
totalAvailable = resourcesOfThisType.length;
|
|
2032
|
+
requiredAmount = items.reduce((sum, cartItem) => {
|
|
2033
|
+
return sum + (cartItem.num || 1);
|
|
2034
|
+
}, 0);
|
|
2035
|
+
availableAmount = Math.max(0, totalAvailable - requiredAmount);
|
|
2036
|
+
}
|
|
2037
|
+
resourceCapacityInfo.push({
|
|
2038
|
+
code: resourceCode,
|
|
2039
|
+
available: availableAmount,
|
|
2040
|
+
total: totalAvailable,
|
|
2041
|
+
required: requiredAmount,
|
|
2042
|
+
isMultiple: isMultipleBooking
|
|
2043
|
+
});
|
|
2044
|
+
availableCountsByResourceType.push(availableAmount);
|
|
2045
|
+
if (requiredAmount > totalAvailable) {
|
|
2046
|
+
hasCapacityIssue = true;
|
|
2047
|
+
console.log(`资源类型 ${resourceCode} ${isMultipleBooking ? "容量" : "资源数量"}不足: 需要 ${requiredAmount}, 总共 ${totalAvailable}`);
|
|
2048
|
+
}
|
|
2049
|
+
console.log(`资源类型 ${resourceCode} 的资源时间信息:`, resourcesOfThisType.map((r) => ({
|
|
2050
|
+
id: r.id,
|
|
2051
|
+
times: r.times.map((t) => `${t.start_at} - ${t.end_at}`)
|
|
2052
|
+
})));
|
|
2053
|
+
const commonTimeSlots = this.findCommonAvailableTimeSlots(resourcesOfThisType);
|
|
2054
|
+
console.log(`资源类型 ${resourceCode} 的公共时间段:`, commonTimeSlots);
|
|
2055
|
+
if (commonTimeSlots.length === 0) {
|
|
2056
|
+
console.log(`资源类型 ${resourceCode} 没有公共可用时间段`);
|
|
2057
|
+
return { success: false, minAvailableCount: 0 };
|
|
2058
|
+
}
|
|
2059
|
+
const firstCommonSlot = commonTimeSlots[0];
|
|
2060
|
+
console.log(`使用公共时间段: ${firstCommonSlot.startTime} - ${firstCommonSlot.endTime}`);
|
|
2061
|
+
items.forEach((cartItem) => {
|
|
2062
|
+
if (!processedCartItemIds.has(cartItem._id)) {
|
|
2063
|
+
processedCartItemIds.add(cartItem._id);
|
|
2064
|
+
const processedItem = {
|
|
2065
|
+
...cartItem,
|
|
2066
|
+
start_date: dateRange[0].date,
|
|
2067
|
+
start_time: firstCommonSlot.startTime,
|
|
2068
|
+
end_time: firstCommonSlot.endTime,
|
|
2069
|
+
end_date: dateRange[0].date
|
|
2070
|
+
};
|
|
2071
|
+
processedItemsWithoutTime.push(processedItem);
|
|
2072
|
+
}
|
|
2073
|
+
});
|
|
2074
|
+
}
|
|
2075
|
+
if (hasCapacityIssue) {
|
|
2076
|
+
const overCapacityResources = resourceCapacityInfo.filter((info) => info.required > info.total);
|
|
2077
|
+
if (overCapacityResources.length > 0) {
|
|
2078
|
+
const minTotalCapacity2 = Math.min(...overCapacityResources.map((info) => info.total));
|
|
2079
|
+
return { success: false, minAvailableCount: minTotalCapacity2 };
|
|
2080
|
+
}
|
|
2081
|
+
const minTotalCapacity = Math.min(...resourceCapacityInfo.map((info) => info.total));
|
|
2082
|
+
return { success: false, minAvailableCount: minTotalCapacity };
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
const allProcessedItems = [...itemsWithTime, ...processedItemsWithoutTime];
|
|
2086
|
+
const cartItemsByTimeSlot = {};
|
|
2087
|
+
allProcessedItems.forEach((cartItem) => {
|
|
2088
|
+
if (!cartItem.start_time || !cartItem.end_time || !cartItem.start_date)
|
|
2089
|
+
return;
|
|
2090
|
+
const timeSlotKey = `${cartItem.start_date}_${cartItem.start_time}_${cartItem.end_date || cartItem.start_date}_${cartItem.end_time}`;
|
|
2091
|
+
if (!cartItemsByTimeSlot[timeSlotKey]) {
|
|
2092
|
+
cartItemsByTimeSlot[timeSlotKey] = [];
|
|
2093
|
+
}
|
|
2094
|
+
cartItemsByTimeSlot[timeSlotKey].push(cartItem);
|
|
2095
|
+
});
|
|
2096
|
+
for (const [timeSlotKey, itemsInTimeSlot] of Object.entries(cartItemsByTimeSlot)) {
|
|
2097
|
+
const [startDate, startTime, endDate, endTime] = timeSlotKey.split("_");
|
|
2098
|
+
const timeSlotStart = `${startDate} ${startTime}`;
|
|
2099
|
+
const timeSlotEnd = `${endDate} ${endTime}`;
|
|
2100
|
+
const allResourcesForTimeSlot = [];
|
|
2101
|
+
const resourcesIdSet = /* @__PURE__ */ new Set();
|
|
2102
|
+
const dateRange = this.store.date.getDateRange();
|
|
2103
|
+
const resourcesDates = this.store.date.getDateList();
|
|
2104
|
+
const targetResourceDate = resourcesDates.find((n) => n.date === startDate);
|
|
2105
|
+
if (!targetResourceDate)
|
|
2106
|
+
continue;
|
|
2107
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)(targetResourceDate.resource || []);
|
|
2108
|
+
itemsInTimeSlot.forEach((cartItem) => {
|
|
2109
|
+
if (!cartItem._productOrigin)
|
|
2110
|
+
return;
|
|
2111
|
+
const productResourceIds = (0, import_capacity.getResourcesIdsByProduct)(cartItem._productOrigin);
|
|
2112
|
+
productResourceIds.forEach((resourceId) => {
|
|
2113
|
+
if (resourcesMap[resourceId] && !resourcesIdSet.has(resourceId)) {
|
|
2114
|
+
resourcesIdSet.add(resourceId);
|
|
2115
|
+
allResourcesForTimeSlot.push(resourcesMap[resourceId]);
|
|
2116
|
+
}
|
|
2117
|
+
});
|
|
2118
|
+
});
|
|
2119
|
+
const { success, required, available } = (0, import_capacity.checkTimeSlotCapacity)(timeSlotStart, timeSlotEnd, itemsInTimeSlot, allResourcesForTimeSlot);
|
|
2120
|
+
if (!success) {
|
|
2121
|
+
const minAvailableCount2 = availableCountsByResourceType.length > 0 ? Math.min(...availableCountsByResourceType) : 0;
|
|
2122
|
+
return { success: false, minAvailableCount: minAvailableCount2 };
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
const minAvailableCount = availableCountsByResourceType.length > 0 ? Math.min(...availableCountsByResourceType) : 0;
|
|
2126
|
+
return { success: true, minAvailableCount };
|
|
2127
|
+
}
|
|
2128
|
+
/**
|
|
2129
|
+
* 将 ProductData 转换为 CartItem,但不添加到购物车
|
|
2130
|
+
* 参考 addProductToCart 方法的实现
|
|
2131
|
+
*/
|
|
2132
|
+
convertProductToCartItem({
|
|
2133
|
+
product,
|
|
2134
|
+
date,
|
|
2135
|
+
account
|
|
2136
|
+
}) {
|
|
2137
|
+
const {
|
|
2138
|
+
bundle,
|
|
2139
|
+
options,
|
|
2140
|
+
origin,
|
|
2141
|
+
product_variant_id,
|
|
2142
|
+
quantity = 1
|
|
2143
|
+
} = product || {};
|
|
2144
|
+
const productData = { ...origin, product_variant_id };
|
|
2145
|
+
const processedProduct = (0, import_utils.handleVariantProduct)(productData);
|
|
2146
|
+
if (!account) {
|
|
2147
|
+
const activeAccount = this.getActiveAccount();
|
|
2148
|
+
if (activeAccount) {
|
|
2149
|
+
account = activeAccount;
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
const cartItem = {
|
|
2153
|
+
_id: (0, import_utils.getUniqueId)("temp_"),
|
|
2154
|
+
_origin: (0, import_utils.createCartItemOrigin)(),
|
|
2155
|
+
_productOrigin: processedProduct,
|
|
2156
|
+
_productInit: product
|
|
2157
|
+
};
|
|
2158
|
+
(0, import_utils.formatProductToCartItem)({
|
|
2159
|
+
cartItem,
|
|
2160
|
+
product: processedProduct,
|
|
2161
|
+
bundle,
|
|
2162
|
+
options,
|
|
2163
|
+
product_variant_id,
|
|
2164
|
+
quantity
|
|
2165
|
+
});
|
|
2166
|
+
if (date) {
|
|
2167
|
+
(0, import_utils.formatDateToCartItem)({
|
|
2168
|
+
cartItem,
|
|
2169
|
+
date
|
|
2170
|
+
});
|
|
2171
|
+
}
|
|
2172
|
+
if (account) {
|
|
2173
|
+
(0, import_utils.formatAccountToCartItem)({
|
|
2174
|
+
cartItem,
|
|
2175
|
+
account
|
|
2176
|
+
});
|
|
2177
|
+
}
|
|
2178
|
+
return cartItem;
|
|
2179
|
+
}
|
|
2180
|
+
checkMaxDurationCapacityForDetailNums({
|
|
2181
|
+
product,
|
|
2182
|
+
date,
|
|
2183
|
+
account
|
|
2184
|
+
}) {
|
|
2185
|
+
var _a, _b;
|
|
2186
|
+
const cartItems = this.store.cart.getItems().filter((item) => !(0, import_utils5.isNormalProduct)(item._productOrigin));
|
|
2187
|
+
const currentCartItem = this.convertProductToCartItem({ product, date, account });
|
|
2188
|
+
cartItems.push(currentCartItem);
|
|
2189
|
+
if (cartItems.length === 0)
|
|
2190
|
+
return { success: true, minAvailableCount: 0 };
|
|
2191
|
+
const itemsWithTime = [];
|
|
2192
|
+
const itemsWithoutTime = [];
|
|
2193
|
+
const availableCountsByResourceType = [];
|
|
2194
|
+
cartItems.forEach((cartItem) => {
|
|
2195
|
+
if (cartItem.start_time && cartItem.end_time && cartItem.start_date) {
|
|
2196
|
+
itemsWithTime.push(cartItem);
|
|
2197
|
+
} else {
|
|
2198
|
+
itemsWithoutTime.push(cartItem);
|
|
2199
|
+
}
|
|
2200
|
+
});
|
|
2201
|
+
const processedItemsWithoutTime = [];
|
|
2202
|
+
if (itemsWithoutTime.length > 0) {
|
|
2203
|
+
const itemsByResourceType = {};
|
|
2204
|
+
itemsWithoutTime.forEach((cartItem) => {
|
|
2205
|
+
var _a2;
|
|
2206
|
+
if (!cartItem._productOrigin)
|
|
2207
|
+
return;
|
|
2208
|
+
const resourceTypes = ((_a2 = cartItem._productOrigin.product_resource) == null ? void 0 : _a2.resources) || [];
|
|
2209
|
+
resourceTypes.forEach((resourceType) => {
|
|
2210
|
+
var _a3;
|
|
2211
|
+
if (resourceType.status === 1) {
|
|
2212
|
+
const resourceCode = resourceType.code || ((_a3 = resourceType.id) == null ? void 0 : _a3.toString());
|
|
2213
|
+
if (!itemsByResourceType[resourceCode]) {
|
|
2214
|
+
itemsByResourceType[resourceCode] = [];
|
|
2215
|
+
}
|
|
2216
|
+
if (!itemsByResourceType[resourceCode].find((item) => item._id === cartItem._id)) {
|
|
2217
|
+
itemsByResourceType[resourceCode].push(cartItem);
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
});
|
|
2221
|
+
});
|
|
2222
|
+
const dateRange = this.store.date.getDateRange();
|
|
2223
|
+
if (!dateRange || dateRange.length === 0)
|
|
2224
|
+
return { success: false, minAvailableCount: 0 };
|
|
2225
|
+
const resourcesDates = this.store.date.getDateList();
|
|
2226
|
+
const targetResourceDate = resourcesDates.find((n) => n.date === dateRange[0].date);
|
|
2227
|
+
if (!targetResourceDate)
|
|
2228
|
+
return { success: false, minAvailableCount: 0 };
|
|
2229
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)(targetResourceDate.resource || []);
|
|
2230
|
+
const resourceCodeToFormIdMap = {};
|
|
2231
|
+
Object.values(itemsByResourceType).flat().forEach((cartItem) => {
|
|
2232
|
+
var _a2, _b2;
|
|
2233
|
+
if ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) {
|
|
2234
|
+
cartItem._productOrigin.product_resource.resources.forEach((resourceConfig) => {
|
|
2235
|
+
var _a3, _b3;
|
|
2236
|
+
if (resourceConfig.status === 1 && resourceConfig.code) {
|
|
2237
|
+
const formId = ((_a3 = resourceConfig.id) == null ? void 0 : _a3.toString()) || ((_b3 = resourceConfig.resource_type_id) == null ? void 0 : _b3.toString());
|
|
2238
|
+
if (formId) {
|
|
2239
|
+
resourceCodeToFormIdMap[resourceConfig.code] = formId;
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
});
|
|
2243
|
+
}
|
|
2244
|
+
});
|
|
2245
|
+
let hasCapacityIssue = false;
|
|
2246
|
+
const resourceCapacityInfo = [];
|
|
2247
|
+
const processedCartItemIds = /* @__PURE__ */ new Set();
|
|
2248
|
+
for (const [resourceCode, items] of Object.entries(itemsByResourceType)) {
|
|
2249
|
+
const targetFormId = resourceCodeToFormIdMap[resourceCode];
|
|
2250
|
+
if (!targetFormId) {
|
|
2251
|
+
console.log(`资源类型 ${resourceCode} 找不到对应的 form_id`);
|
|
2252
|
+
return { success: false, minAvailableCount: 0 };
|
|
2253
|
+
}
|
|
2254
|
+
const resourcesOfThisType = [];
|
|
2255
|
+
items.forEach((cartItem) => {
|
|
2256
|
+
const productResourceIds = (0, import_capacity.getResourcesIdsByProduct)(cartItem._productOrigin);
|
|
2257
|
+
productResourceIds.forEach((resourceId) => {
|
|
2258
|
+
var _a2;
|
|
2259
|
+
const resource = resourcesMap[resourceId];
|
|
2260
|
+
if (resource && ((_a2 = resource.form_id) == null ? void 0 : _a2.toString()) === targetFormId) {
|
|
2261
|
+
if (!resourcesOfThisType.find((r) => r.id === resource.id)) {
|
|
2262
|
+
resourcesOfThisType.push(resource);
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2265
|
+
});
|
|
2266
|
+
});
|
|
2267
|
+
if (resourcesOfThisType.length === 0) {
|
|
2268
|
+
console.log(`资源类型 ${resourceCode} 没有找到可用资源`);
|
|
2269
|
+
return { success: false, minAvailableCount: 0 };
|
|
2270
|
+
}
|
|
2271
|
+
let resourceTypeConfig = null;
|
|
2272
|
+
for (const cartItem of items) {
|
|
2273
|
+
if ((_b = (_a = cartItem._productOrigin) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) {
|
|
2274
|
+
resourceTypeConfig = cartItem._productOrigin.product_resource.resources.find(
|
|
2275
|
+
(r) => r.code === resourceCode && r.status === 1
|
|
2276
|
+
);
|
|
2277
|
+
if (resourceTypeConfig)
|
|
2278
|
+
break;
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
const isMultipleBooking = (resourceTypeConfig == null ? void 0 : resourceTypeConfig.type) === "multiple";
|
|
2282
|
+
let totalAvailable;
|
|
2283
|
+
let requiredAmount;
|
|
2284
|
+
let availableAmount;
|
|
2285
|
+
if (isMultipleBooking) {
|
|
2286
|
+
totalAvailable = resourcesOfThisType.reduce((sum, resource) => {
|
|
2287
|
+
return sum + (resource.capacity || 0);
|
|
2288
|
+
}, 0);
|
|
2289
|
+
requiredAmount = items.reduce((sum, cartItem) => {
|
|
2290
|
+
const { currentCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(cartItem);
|
|
2291
|
+
return sum + currentCapacity;
|
|
2292
|
+
}, 0);
|
|
2293
|
+
availableAmount = Math.max(0, totalAvailable - requiredAmount);
|
|
2294
|
+
} else {
|
|
2295
|
+
totalAvailable = resourcesOfThisType.length;
|
|
2296
|
+
requiredAmount = items.reduce((sum, cartItem) => {
|
|
2297
|
+
return sum + (cartItem.num || 1);
|
|
2298
|
+
}, 0);
|
|
2299
|
+
availableAmount = Math.max(0, totalAvailable - requiredAmount);
|
|
2300
|
+
}
|
|
2301
|
+
resourceCapacityInfo.push({
|
|
2302
|
+
code: resourceCode,
|
|
2303
|
+
available: availableAmount,
|
|
2304
|
+
total: totalAvailable,
|
|
2305
|
+
required: requiredAmount,
|
|
2306
|
+
isMultiple: isMultipleBooking
|
|
2307
|
+
});
|
|
2308
|
+
availableCountsByResourceType.push(availableAmount);
|
|
2309
|
+
if (requiredAmount > totalAvailable) {
|
|
2310
|
+
hasCapacityIssue = true;
|
|
2311
|
+
console.log(`资源类型 ${resourceCode} ${isMultipleBooking ? "容量" : "资源数量"}不足: 需要 ${requiredAmount}, 总共 ${totalAvailable}`);
|
|
2312
|
+
}
|
|
2313
|
+
console.log(`资源类型 ${resourceCode} 的资源时间信息:`, resourcesOfThisType.map((r) => ({
|
|
2314
|
+
id: r.id,
|
|
2315
|
+
times: r.times.map((t) => `${t.start_at} - ${t.end_at}`)
|
|
2316
|
+
})));
|
|
2317
|
+
const commonTimeSlots = this.findCommonAvailableTimeSlots(resourcesOfThisType);
|
|
2318
|
+
console.log(`资源类型 ${resourceCode} 的公共时间段:`, commonTimeSlots);
|
|
2319
|
+
if (commonTimeSlots.length === 0) {
|
|
2320
|
+
console.log(`资源类型 ${resourceCode} 没有公共可用时间段`);
|
|
2321
|
+
return { success: false, minAvailableCount: 0 };
|
|
2322
|
+
}
|
|
2323
|
+
const firstCommonSlot = commonTimeSlots[0];
|
|
2324
|
+
console.log(`使用公共时间段: ${firstCommonSlot.startTime} - ${firstCommonSlot.endTime}`);
|
|
2325
|
+
items.forEach((cartItem) => {
|
|
2326
|
+
if (!processedCartItemIds.has(cartItem._id)) {
|
|
2327
|
+
processedCartItemIds.add(cartItem._id);
|
|
2328
|
+
const processedItem = {
|
|
2329
|
+
...cartItem,
|
|
2330
|
+
start_date: dateRange[0].date,
|
|
2331
|
+
start_time: firstCommonSlot.startTime,
|
|
2332
|
+
end_time: firstCommonSlot.endTime,
|
|
2333
|
+
end_date: dateRange[0].date
|
|
2334
|
+
};
|
|
2335
|
+
processedItemsWithoutTime.push(processedItem);
|
|
2336
|
+
}
|
|
2337
|
+
});
|
|
2338
|
+
}
|
|
2339
|
+
if (hasCapacityIssue) {
|
|
2340
|
+
const overCapacityResources = resourceCapacityInfo.filter((info) => info.required > info.total);
|
|
2341
|
+
if (overCapacityResources.length > 0) {
|
|
2342
|
+
const minTotalCapacity2 = Math.min(...overCapacityResources.map((info) => info.total));
|
|
2343
|
+
return { success: false, minAvailableCount: minTotalCapacity2 };
|
|
2344
|
+
}
|
|
2345
|
+
const minTotalCapacity = Math.min(...resourceCapacityInfo.map((info) => info.total));
|
|
2346
|
+
return { success: false, minAvailableCount: minTotalCapacity };
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2349
|
+
const allProcessedItems = [...itemsWithTime, ...processedItemsWithoutTime];
|
|
2350
|
+
const cartItemsByTimeSlot = {};
|
|
2351
|
+
allProcessedItems.forEach((cartItem) => {
|
|
2352
|
+
if (!cartItem.start_time || !cartItem.end_time || !cartItem.start_date)
|
|
2353
|
+
return;
|
|
2354
|
+
const timeSlotKey = `${cartItem.start_date}_${cartItem.start_time}_${cartItem.end_date || cartItem.start_date}_${cartItem.end_time}`;
|
|
2355
|
+
if (!cartItemsByTimeSlot[timeSlotKey]) {
|
|
2356
|
+
cartItemsByTimeSlot[timeSlotKey] = [];
|
|
2357
|
+
}
|
|
2358
|
+
cartItemsByTimeSlot[timeSlotKey].push(cartItem);
|
|
2359
|
+
});
|
|
2360
|
+
for (const [timeSlotKey, itemsInTimeSlot] of Object.entries(cartItemsByTimeSlot)) {
|
|
2361
|
+
const [startDate, startTime, endDate, endTime] = timeSlotKey.split("_");
|
|
2362
|
+
const timeSlotStart = `${startDate} ${startTime}`;
|
|
2363
|
+
const timeSlotEnd = `${endDate} ${endTime}`;
|
|
2364
|
+
const allResourcesForTimeSlot = [];
|
|
2365
|
+
const resourcesIdSet = /* @__PURE__ */ new Set();
|
|
2366
|
+
const resourcesDates = this.store.date.getDateList();
|
|
2367
|
+
const targetResourceDate = resourcesDates.find((n) => n.date === startDate);
|
|
2368
|
+
if (!targetResourceDate)
|
|
2369
|
+
continue;
|
|
2370
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)(targetResourceDate.resource || []);
|
|
2371
|
+
itemsInTimeSlot.forEach((cartItem) => {
|
|
2372
|
+
if (!cartItem._productOrigin)
|
|
2373
|
+
return;
|
|
2374
|
+
const productResourceIds = (0, import_capacity.getResourcesIdsByProduct)(cartItem._productOrigin);
|
|
2375
|
+
productResourceIds.forEach((resourceId) => {
|
|
2376
|
+
if (resourcesMap[resourceId] && !resourcesIdSet.has(resourceId)) {
|
|
2377
|
+
resourcesIdSet.add(resourceId);
|
|
2378
|
+
allResourcesForTimeSlot.push(resourcesMap[resourceId]);
|
|
2379
|
+
}
|
|
2380
|
+
});
|
|
2381
|
+
});
|
|
2382
|
+
const { success, required, available } = (0, import_capacity.checkTimeSlotCapacity)(timeSlotStart, timeSlotEnd, itemsInTimeSlot, allResourcesForTimeSlot);
|
|
2383
|
+
if (!success) {
|
|
2384
|
+
return { success: false, minAvailableCount: available };
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
const minAvailableCount = availableCountsByResourceType.length > 0 ? Math.min(...availableCountsByResourceType) : 0;
|
|
2388
|
+
return { success: true, minAvailableCount };
|
|
2389
|
+
}
|
|
1740
2390
|
setOtherData(key, value) {
|
|
1741
2391
|
this.otherData[key] = value;
|
|
1742
2392
|
this.checkSaveCache({
|
|
@@ -1788,8 +2438,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1788
2438
|
resources.push(...n.resource);
|
|
1789
2439
|
});
|
|
1790
2440
|
}
|
|
1791
|
-
const resourcesMap = (0,
|
|
1792
|
-
const cartItems = this.store.cart.getItems().filter((n) => !(0,
|
|
2441
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
2442
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
1793
2443
|
const cartItem = cartItems.find((item) => item._id === cartItemId);
|
|
1794
2444
|
if (!cartItem)
|
|
1795
2445
|
return [];
|
|
@@ -1954,7 +2604,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1954
2604
|
startDate || "",
|
|
1955
2605
|
endDate || ""
|
|
1956
2606
|
);
|
|
1957
|
-
const tempResourceIds = (0,
|
|
2607
|
+
const tempResourceIds = (0, import_capacity.getResourcesIdsByProduct)(tempProducts);
|
|
1958
2608
|
const res = await this.store.date.fetchResourceDates({
|
|
1959
2609
|
query: {
|
|
1960
2610
|
start_date: startDate || "",
|
|
@@ -2002,12 +2652,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2002
2652
|
}
|
|
2003
2653
|
}
|
|
2004
2654
|
if (status === "available") {
|
|
2005
|
-
const minTimeMaxTime = (0,
|
|
2655
|
+
const minTimeMaxTime = (0, import_utils3.calcMinTimeMaxTimeBySchedules)(
|
|
2006
2656
|
targetSchedules,
|
|
2007
2657
|
{},
|
|
2008
2658
|
currentDateStr
|
|
2009
2659
|
);
|
|
2010
|
-
const scheduleTimeSlots = (0,
|
|
2660
|
+
const scheduleTimeSlots = (0, import_utils3.getAllSortedDateRanges)(minTimeMaxTime);
|
|
2011
2661
|
const timesSlotCanUse = scheduleTimeSlots.some((item) => {
|
|
2012
2662
|
const resourcesUseableMap = {};
|
|
2013
2663
|
return openResources.every((resource) => {
|
|
@@ -2064,7 +2714,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2064
2714
|
}
|
|
2065
2715
|
currentDate = (0, import_dayjs.default)(currentDate).add(1, "day");
|
|
2066
2716
|
}
|
|
2067
|
-
dates = (0,
|
|
2717
|
+
dates = (0, import_utils4.handleAvailableDateByResource)(res.data, dates);
|
|
2068
2718
|
this.store.date.setDateList(dates);
|
|
2069
2719
|
if (!this.store.currentProductMeta)
|
|
2070
2720
|
this.store.currentProductMeta = {};
|
|
@@ -2080,11 +2730,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2080
2730
|
};
|
|
2081
2731
|
}
|
|
2082
2732
|
isCartAllNormalProducts() {
|
|
2083
|
-
const cartItems = this.store.cart.getItems().filter((n) => !(0,
|
|
2733
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
2084
2734
|
return !cartItems.length;
|
|
2085
2735
|
}
|
|
2086
2736
|
isCartHasDurationProduct() {
|
|
2087
|
-
const cartItems = this.store.cart.getItems().filter((n) => !(0,
|
|
2737
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
2088
2738
|
return cartItems.some((n) => {
|
|
2089
2739
|
var _a;
|
|
2090
2740
|
return (_a = n._productOrigin) == null ? void 0 : _a.duration;
|
|
@@ -2093,11 +2743,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2093
2743
|
isTargetNormalProduct(product) {
|
|
2094
2744
|
if (!product)
|
|
2095
2745
|
return false;
|
|
2096
|
-
return (0,
|
|
2746
|
+
return (0, import_utils5.isNormalProduct)(product);
|
|
2097
2747
|
}
|
|
2098
2748
|
isTargetCartIdNormalProduct(id) {
|
|
2099
2749
|
const cartItem = this.store.cart.getItems().find((n) => n._id === id);
|
|
2100
|
-
return cartItem && (0,
|
|
2750
|
+
return cartItem && (0, import_utils5.isNormalProduct)(cartItem._productOrigin);
|
|
2101
2751
|
}
|
|
2102
2752
|
};
|
|
2103
2753
|
// Annotate the CommonJS export names for ESM import in node:
|