@pisell/pisellos 2.2.148 → 2.2.149
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/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +1 -0
- package/dist/model/strategy/adapter/index.d.ts +2 -0
- package/dist/model/strategy/adapter/index.js +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +483 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
- package/dist/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +382 -0
- package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/dist/model/strategy/adapter/itemRule/index.js +5 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/dist/model/strategy/adapter/itemRule/type.js +101 -0
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +22 -1
- package/dist/modules/Cart/utils/changePrice.js +6 -0
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +16 -8
- package/dist/modules/Date/types.d.ts +3 -1
- package/dist/modules/OpenData/index.d.ts +24 -0
- package/dist/modules/OpenData/index.js +173 -0
- package/dist/modules/OpenData/types.d.ts +73 -0
- package/dist/modules/OpenData/types.js +1 -0
- package/dist/modules/OpenData/utils.d.ts +2 -0
- package/dist/modules/OpenData/utils.js +75 -0
- package/dist/modules/Order/index.d.ts +171 -1
- package/dist/modules/Order/index.js +2052 -112
- package/dist/modules/Order/types.d.ts +441 -20
- package/dist/modules/Order/types.js +23 -0
- package/dist/modules/Order/utils.d.ts +120 -0
- package/dist/modules/Order/utils.js +653 -2
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.js +2 -1
- package/dist/modules/Quotation/index.d.ts +8 -1
- package/dist/modules/Quotation/index.js +40 -10
- package/dist/modules/Quotation/types.d.ts +5 -0
- package/dist/modules/Rules/index.d.ts +3 -1
- package/dist/modules/Rules/index.js +136 -50
- package/dist/modules/Rules/types.d.ts +6 -0
- package/dist/modules/Rules/types.js +8 -0
- package/dist/modules/SalesSummary/index.d.ts +70 -0
- package/dist/modules/SalesSummary/index.js +175 -0
- package/dist/modules/SalesSummary/types.d.ts +64 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +34 -0
- package/dist/modules/SalesSummary/utils.js +488 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +21 -0
- package/dist/modules/ScanOrderLogger/index.js +161 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +203 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
- package/dist/modules/ScanOrderLogger/types.d.ts +52 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +7 -7
- package/dist/modules/Schedule/index.d.ts +4 -13
- package/dist/modules/Schedule/index.js +6 -23
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/index.d.ts +3 -0
- package/dist/modules/Summary/index.js +134 -15
- package/dist/modules/Summary/types.d.ts +7 -0
- package/dist/modules/Summary/utils.d.ts +104 -1
- package/dist/modules/Summary/utils.js +1116 -13
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/server/index.d.ts +41 -4
- package/dist/server/index.js +900 -405
- package/dist/server/modules/order/index.d.ts +10 -2
- package/dist/server/modules/order/index.js +246 -193
- package/dist/server/modules/products/index.d.ts +26 -0
- package/dist/server/modules/products/index.js +618 -338
- package/dist/server/modules/products/types.d.ts +5 -1
- package/dist/solution/BaseSales/index.d.ts +175 -0
- package/dist/solution/BaseSales/index.js +1293 -0
- package/dist/solution/BaseSales/types.d.ts +305 -0
- package/dist/solution/BaseSales/types.js +38 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +159 -0
- package/dist/solution/BaseSales/utils.d.ts +40 -0
- package/dist/solution/BaseSales/utils.js +222 -0
- package/dist/solution/BookingByStep/index.d.ts +14 -0
- package/dist/solution/BookingByStep/index.js +699 -212
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/BookingByStep/utils/capacity.js +1 -1
- package/dist/solution/BookingByStep/utils/resources.js +6 -1
- package/dist/solution/BookingTicket/index.d.ts +113 -15
- package/dist/solution/BookingTicket/index.js +534 -196
- package/dist/solution/BookingTicket/types.d.ts +69 -6
- package/dist/solution/BookingTicket/types.js +40 -9
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.js +66 -0
- package/dist/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/dist/solution/BookingTicket/utils/cartView.js +84 -0
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +1 -0
- package/dist/solution/ScanOrder/index.d.ts +146 -0
- package/dist/solution/ScanOrder/index.js +3029 -0
- package/dist/solution/ScanOrder/types.d.ts +305 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +167 -0
- package/dist/solution/ScanOrder/utils.js +768 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +9 -5
- package/dist/solution/ShopDiscount/types.d.ts +4 -0
- package/dist/solution/VenueBooking/index.d.ts +197 -0
- package/dist/solution/VenueBooking/index.js +3411 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +153 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/dist/solution/VenueBooking/utils/resource.js +130 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +224 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +3 -0
- package/dist/solution/index.js +4 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/model/strategy/adapter/index.d.ts +2 -0
- package/lib/model/strategy/adapter/index.js +6 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +377 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
- package/lib/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +316 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/lib/model/strategy/adapter/itemRule/index.js +60 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/lib/model/strategy/adapter/itemRule/type.js +46 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +17 -1
- package/lib/modules/Cart/utils/changePrice.js +5 -0
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +7 -1
- package/lib/modules/Date/types.d.ts +3 -1
- package/lib/modules/OpenData/index.d.ts +24 -0
- package/lib/modules/OpenData/index.js +119 -0
- package/lib/modules/OpenData/types.d.ts +73 -0
- package/lib/modules/OpenData/types.js +17 -0
- package/lib/modules/OpenData/utils.d.ts +2 -0
- package/lib/modules/OpenData/utils.js +111 -0
- package/lib/modules/Order/index.d.ts +171 -1
- package/lib/modules/Order/index.js +1396 -5
- package/lib/modules/Order/types.d.ts +441 -20
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils.d.ts +120 -0
- package/lib/modules/Order/utils.js +562 -2
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.js +2 -1
- package/lib/modules/Quotation/index.d.ts +8 -1
- package/lib/modules/Quotation/index.js +33 -4
- package/lib/modules/Quotation/types.d.ts +5 -0
- package/lib/modules/Rules/index.d.ts +3 -1
- package/lib/modules/Rules/index.js +46 -6
- package/lib/modules/Rules/types.d.ts +6 -0
- package/lib/modules/Rules/types.js +11 -2
- package/lib/modules/SalesSummary/index.d.ts +70 -0
- package/lib/modules/SalesSummary/index.js +106 -0
- package/lib/modules/SalesSummary/types.d.ts +64 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +34 -0
- package/lib/modules/SalesSummary/utils.js +430 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +21 -0
- package/lib/modules/ScanOrderLogger/index.js +135 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +148 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
- package/lib/modules/ScanOrderLogger/types.d.ts +52 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +5 -5
- package/lib/modules/Schedule/index.d.ts +4 -13
- package/lib/modules/Schedule/index.js +4 -15
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/index.d.ts +3 -0
- package/lib/modules/Summary/index.js +61 -2
- package/lib/modules/Summary/types.d.ts +7 -0
- package/lib/modules/Summary/utils.d.ts +104 -1
- package/lib/modules/Summary/utils.js +659 -8
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/server/index.d.ts +41 -4
- package/lib/server/index.js +272 -10
- package/lib/server/modules/order/index.d.ts +10 -2
- package/lib/server/modules/order/index.js +26 -1
- package/lib/server/modules/products/index.d.ts +26 -0
- package/lib/server/modules/products/index.js +174 -22
- package/lib/server/modules/products/types.d.ts +5 -1
- package/lib/solution/BaseSales/index.d.ts +175 -0
- package/lib/solution/BaseSales/index.js +655 -0
- package/lib/solution/BaseSales/types.d.ts +305 -0
- package/lib/solution/BaseSales/types.js +40 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +160 -0
- package/lib/solution/BaseSales/utils.d.ts +40 -0
- package/lib/solution/BaseSales/utils.js +200 -0
- package/lib/solution/BookingByStep/index.d.ts +14 -0
- package/lib/solution/BookingByStep/index.js +469 -91
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/BookingByStep/utils/capacity.js +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +5 -2
- package/lib/solution/BookingTicket/index.d.ts +113 -15
- package/lib/solution/BookingTicket/index.js +253 -61
- package/lib/solution/BookingTicket/types.d.ts +69 -6
- package/lib/solution/BookingTicket/types.js +16 -14
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.js +65 -0
- package/lib/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/lib/solution/BookingTicket/utils/cartView.js +103 -0
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.d.ts +146 -0
- package/lib/solution/ScanOrder/index.js +1820 -0
- package/lib/solution/ScanOrder/types.d.ts +305 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +167 -0
- package/lib/solution/ScanOrder/utils.js +639 -0
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +9 -4
- package/lib/solution/ShopDiscount/types.d.ts +4 -0
- package/lib/solution/VenueBooking/index.d.ts +197 -0
- package/lib/solution/VenueBooking/index.js +1892 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +153 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/lib/solution/VenueBooking/utils/resource.js +91 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +225 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +3 -0
- package/lib/solution/index.js +7 -1
- package/package.json +1 -1
|
@@ -873,7 +873,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
873
873
|
resources.push(...dateResources || []);
|
|
874
874
|
} else {
|
|
875
875
|
const dateList = this.store.date.getDateList();
|
|
876
|
-
dateList.forEach((n) => {
|
|
876
|
+
dateList == null ? void 0 : dateList.forEach((n) => {
|
|
877
877
|
if (n.resource)
|
|
878
878
|
resources.push(...n.resource);
|
|
879
879
|
});
|
|
@@ -1178,7 +1178,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1178
1178
|
timeSlots,
|
|
1179
1179
|
currentCapacity: totalCapacity + (capacity || 0)
|
|
1180
1180
|
});
|
|
1181
|
-
if (canUseTime && !n.onlyComputed && currentResourceIdleTime > targetResourceTime) {
|
|
1181
|
+
if (canUseTime && !n.onlyComputed && currentResourceIdleTime > targetResourceTime && n.capacity >= (capacity || 0)) {
|
|
1182
1182
|
targetResource = n;
|
|
1183
1183
|
targetResourceTime = currentResourceIdleTime;
|
|
1184
1184
|
break;
|
|
@@ -1404,7 +1404,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1404
1404
|
}
|
|
1405
1405
|
// 从购物车中获取已经分配好第一步资源的所有时间片
|
|
1406
1406
|
getTimeSlotByAllResources(resources_code) {
|
|
1407
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1407
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1408
1408
|
let dateRange = this.store.date.getDateRange();
|
|
1409
1409
|
const resources = [];
|
|
1410
1410
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
@@ -1414,7 +1414,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1414
1414
|
let maxCutOffTime = void 0;
|
|
1415
1415
|
let maxCutOffTimeValue = (0, import_dayjs.default)();
|
|
1416
1416
|
cartItems.forEach((item) => {
|
|
1417
|
-
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2,
|
|
1417
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
|
|
1418
1418
|
(_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
|
|
1419
1419
|
if (n.code === resources_code) {
|
|
1420
1420
|
resources.push(...n.renderList || []);
|
|
@@ -1427,7 +1427,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1427
1427
|
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(
|
|
1428
1428
|
(n) => n.code === resources_code
|
|
1429
1429
|
)) == null ? void 0 : _g2.id;
|
|
1430
|
-
if (((_h2 = item._productOrigin) == null ? void 0 : _h2.cut_off_time) && ((
|
|
1430
|
+
if (((_h2 = item._productOrigin) == null ? void 0 : _h2.cut_off_time) && ((_i2 = item._productOrigin) == null ? void 0 : _i2.cut_off_time.type) === "advance") {
|
|
1431
1431
|
const currentCutOffTime = (0, import_dayjs.default)().add(
|
|
1432
1432
|
item._productOrigin.cut_off_time.unit,
|
|
1433
1433
|
item._productOrigin.cut_off_time.unit_type
|
|
@@ -1445,6 +1445,22 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1445
1445
|
}
|
|
1446
1446
|
});
|
|
1447
1447
|
}
|
|
1448
|
+
if (((_c = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _c.date) && resources.length) {
|
|
1449
|
+
const currentDate = (_d = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _d.date;
|
|
1450
|
+
const theDateResources = this.store.date.getResourcesListByDate(currentDate);
|
|
1451
|
+
resources.forEach((item) => {
|
|
1452
|
+
var _a2;
|
|
1453
|
+
const noCurrentDateTimes = item.times.some((n) => {
|
|
1454
|
+
return (0, import_dayjs.default)(n.start_at).isSame((0, import_dayjs.default)(currentDate), "day");
|
|
1455
|
+
});
|
|
1456
|
+
if (!noCurrentDateTimes) {
|
|
1457
|
+
item.times = ((_a2 = theDateResources == null ? void 0 : theDateResources.find((n) => n.id === item.id)) == null ? void 0 : _a2.times) || [];
|
|
1458
|
+
}
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
if (resources.length === 0) {
|
|
1462
|
+
resources.push(...this.store.date.getResourcesListByDate(dateRange[0].date) || []);
|
|
1463
|
+
}
|
|
1448
1464
|
const resourcesMap = (0, import_utils2.getResourcesMap)(resources);
|
|
1449
1465
|
let duration = 0;
|
|
1450
1466
|
const accountList = this.store.accountList.getAccounts();
|
|
@@ -1472,7 +1488,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1472
1488
|
} else {
|
|
1473
1489
|
checkDuration(cartItems);
|
|
1474
1490
|
}
|
|
1475
|
-
if (!((
|
|
1491
|
+
if (!((_e = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _e.start_date) && !((_f = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _f.resource_id) || !(cartItems == null ? void 0 : cartItems[0].duration)) {
|
|
1476
1492
|
return [];
|
|
1477
1493
|
}
|
|
1478
1494
|
if ((cartItems == null ? void 0 : cartItems[0].start_date) && !dateRange) {
|
|
@@ -1484,7 +1500,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1484
1500
|
weekNum: 0
|
|
1485
1501
|
},
|
|
1486
1502
|
{
|
|
1487
|
-
date: ((
|
|
1503
|
+
date: ((_g = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _g.end_date) || ((_h = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _h.start_date) || "",
|
|
1488
1504
|
status: "available",
|
|
1489
1505
|
week: "",
|
|
1490
1506
|
weekNum: 0
|
|
@@ -1498,26 +1514,40 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1498
1514
|
return ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.type) === "flexible";
|
|
1499
1515
|
}
|
|
1500
1516
|
);
|
|
1501
|
-
let operating_day_boundary = (
|
|
1517
|
+
let operating_day_boundary = (_j = (_i = this.shopStore.get("core")) == null ? void 0 : _i.core) == null ? void 0 : _j.operating_day_boundary;
|
|
1502
1518
|
let maxBlockThreshold = 0;
|
|
1503
1519
|
if (hasFlexibleDuration) {
|
|
1504
1520
|
maxBlockThreshold = cartItems.reduce((max, item) => {
|
|
1505
1521
|
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
1506
1522
|
if ((_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.flexible_config) == null ? void 0 : _c2.is_enable_minimum_duration) {
|
|
1507
|
-
return Math.max(
|
|
1523
|
+
return Math.max(
|
|
1524
|
+
max,
|
|
1525
|
+
((_f2 = (_e2 = (_d2 = item._productOrigin) == null ? void 0 : _d2.duration) == null ? void 0 : _e2.flexible_config) == null ? void 0 : _f2.block_threshold) || 0
|
|
1526
|
+
);
|
|
1508
1527
|
}
|
|
1509
1528
|
return 0;
|
|
1510
1529
|
}, 0);
|
|
1511
1530
|
}
|
|
1512
1531
|
const calculateCapacityFromCartItems = (items) => {
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1532
|
+
var _a2;
|
|
1533
|
+
if (items.length === 0)
|
|
1534
|
+
return 0;
|
|
1535
|
+
const firstResource = (_a2 = items[0]._resourceOrigin) == null ? void 0 : _a2[0].id;
|
|
1536
|
+
const sameResourceLength = items.filter((item) => {
|
|
1537
|
+
var _a3;
|
|
1538
|
+
return ((_a3 = item._resourceOrigin) == null ? void 0 : _a3[0].id) === firstResource;
|
|
1539
|
+
}).length;
|
|
1540
|
+
if (sameResourceLength === items.length) {
|
|
1541
|
+
return 1;
|
|
1542
|
+
}
|
|
1543
|
+
return Math.max(...items.map((item) => (0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 1));
|
|
1516
1544
|
};
|
|
1517
1545
|
let maxCapacity = 1;
|
|
1518
1546
|
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
1519
1547
|
accountList.forEach((account) => {
|
|
1520
|
-
const accountCartItems = this.store.cart.getCartByAccount(
|
|
1548
|
+
const accountCartItems = this.store.cart.getCartByAccount(
|
|
1549
|
+
account.getId()
|
|
1550
|
+
);
|
|
1521
1551
|
const currentCapacity = calculateCapacityFromCartItems(accountCartItems);
|
|
1522
1552
|
if (currentCapacity > maxCapacity) {
|
|
1523
1553
|
maxCapacity = currentCapacity;
|
|
@@ -1541,6 +1571,174 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1541
1571
|
});
|
|
1542
1572
|
return timeSlots;
|
|
1543
1573
|
}
|
|
1574
|
+
// 从购物车中获取已经分配好第一步资源的所有时间片,批量版本,用于给日期提供能否高亮的判断
|
|
1575
|
+
async getTimeSlotByAllResourcesForDate({ resources_code, startDate, endDate }) {
|
|
1576
|
+
var _a, _b, _c, _d;
|
|
1577
|
+
if ((0, import_dayjs.default)(endDate).diff((0, import_dayjs.default)(startDate), "day") < 30) {
|
|
1578
|
+
endDate = (0, import_dayjs.default)(startDate).add(30, "day").format("YYYY-MM-DD");
|
|
1579
|
+
}
|
|
1580
|
+
await this.getAvailableDate({
|
|
1581
|
+
startDate,
|
|
1582
|
+
endDate,
|
|
1583
|
+
useCache: true
|
|
1584
|
+
});
|
|
1585
|
+
const resources = [];
|
|
1586
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
1587
|
+
const resourceIds = [];
|
|
1588
|
+
let resourcesTypeId = void 0;
|
|
1589
|
+
let isSingleResource = false;
|
|
1590
|
+
let maxCutOffTime = void 0;
|
|
1591
|
+
let maxCutOffTimeValue = (0, import_dayjs.default)();
|
|
1592
|
+
cartItems.forEach((item) => {
|
|
1593
|
+
var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i;
|
|
1594
|
+
(_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
|
|
1595
|
+
if (n.code === resources_code) {
|
|
1596
|
+
resources.push(...n.renderList || []);
|
|
1597
|
+
isSingleResource = n.type === "single";
|
|
1598
|
+
}
|
|
1599
|
+
});
|
|
1600
|
+
if (item.resource_id && !resourceIds.includes(item.resource_id)) {
|
|
1601
|
+
resourceIds.push(item.resource_id);
|
|
1602
|
+
}
|
|
1603
|
+
resourcesTypeId = (_g = (_f = (_e = (_d2 = item == null ? void 0 : item._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e.resources) == null ? void 0 : _f.find(
|
|
1604
|
+
(n) => n.code === resources_code
|
|
1605
|
+
)) == null ? void 0 : _g.id;
|
|
1606
|
+
if (((_h = item._productOrigin) == null ? void 0 : _h.cut_off_time) && ((_i = item._productOrigin) == null ? void 0 : _i.cut_off_time.type) === "advance") {
|
|
1607
|
+
const currentCutOffTime = (0, import_dayjs.default)().add(
|
|
1608
|
+
item._productOrigin.cut_off_time.unit,
|
|
1609
|
+
item._productOrigin.cut_off_time.unit_type
|
|
1610
|
+
);
|
|
1611
|
+
if (currentCutOffTime.isAfter(maxCutOffTimeValue, "minute")) {
|
|
1612
|
+
maxCutOffTimeValue = currentCutOffTime;
|
|
1613
|
+
maxCutOffTime = item._productOrigin.cut_off_time;
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
});
|
|
1617
|
+
if (!resources.length)
|
|
1618
|
+
return [];
|
|
1619
|
+
let duration = 0;
|
|
1620
|
+
const accountList = this.store.accountList.getAccounts();
|
|
1621
|
+
const checkDuration = (cartItems2) => {
|
|
1622
|
+
let accountDuration = 0;
|
|
1623
|
+
cartItems2.forEach((item) => {
|
|
1624
|
+
var _a2, _b2, _c2, _d2, _e, _f;
|
|
1625
|
+
if (isSingleResource) {
|
|
1626
|
+
accountDuration += ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10;
|
|
1627
|
+
} else {
|
|
1628
|
+
if (accountDuration < (((_d2 = (_c2 = item._productOrigin) == null ? void 0 : _c2.duration) == null ? void 0 : _d2.value) || 10)) {
|
|
1629
|
+
accountDuration = ((_f = (_e = item._productOrigin) == null ? void 0 : _e.duration) == null ? void 0 : _f.value) || 10;
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
});
|
|
1633
|
+
if (accountDuration > duration) {
|
|
1634
|
+
duration = accountDuration;
|
|
1635
|
+
}
|
|
1636
|
+
};
|
|
1637
|
+
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
1638
|
+
accountList.forEach((account) => {
|
|
1639
|
+
const cartItems2 = this.store.cart.getCartByAccount(account.getId());
|
|
1640
|
+
checkDuration(cartItems2);
|
|
1641
|
+
});
|
|
1642
|
+
} else {
|
|
1643
|
+
checkDuration(cartItems);
|
|
1644
|
+
}
|
|
1645
|
+
if (!((_a = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _a.start_date) && !((_b = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _b.resource_id) || !(cartItems == null ? void 0 : cartItems[0].duration)) {
|
|
1646
|
+
return [];
|
|
1647
|
+
}
|
|
1648
|
+
const resourcesUseableMap = {};
|
|
1649
|
+
const hasFlexibleDuration = cartItems.some(
|
|
1650
|
+
(item) => {
|
|
1651
|
+
var _a2, _b2;
|
|
1652
|
+
return ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.type) === "flexible";
|
|
1653
|
+
}
|
|
1654
|
+
);
|
|
1655
|
+
let operating_day_boundary = (_d = (_c = this.shopStore.get("core")) == null ? void 0 : _c.core) == null ? void 0 : _d.operating_day_boundary;
|
|
1656
|
+
let maxBlockThreshold = 0;
|
|
1657
|
+
if (hasFlexibleDuration) {
|
|
1658
|
+
maxBlockThreshold = cartItems.reduce((max, item) => {
|
|
1659
|
+
var _a2, _b2, _c2, _d2, _e, _f;
|
|
1660
|
+
if ((_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.flexible_config) == null ? void 0 : _c2.is_enable_minimum_duration) {
|
|
1661
|
+
return Math.max(max, ((_f = (_e = (_d2 = item._productOrigin) == null ? void 0 : _d2.duration) == null ? void 0 : _e.flexible_config) == null ? void 0 : _f.block_threshold) || 0);
|
|
1662
|
+
}
|
|
1663
|
+
return 0;
|
|
1664
|
+
}, 0);
|
|
1665
|
+
}
|
|
1666
|
+
const calculateCapacityFromCartItems = (items) => {
|
|
1667
|
+
var _a2;
|
|
1668
|
+
if (items.length === 0)
|
|
1669
|
+
return 0;
|
|
1670
|
+
const firstResource = (_a2 = items[0]._resourceOrigin) == null ? void 0 : _a2[0].id;
|
|
1671
|
+
const sameResourceLength = items.filter((item) => {
|
|
1672
|
+
var _a3;
|
|
1673
|
+
return ((_a3 = item._resourceOrigin) == null ? void 0 : _a3[0].id) === firstResource;
|
|
1674
|
+
}).length;
|
|
1675
|
+
if (sameResourceLength !== items.length) {
|
|
1676
|
+
return 1;
|
|
1677
|
+
}
|
|
1678
|
+
return Math.max(...items.map((item) => (0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 1));
|
|
1679
|
+
};
|
|
1680
|
+
let maxCapacity = 1;
|
|
1681
|
+
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
1682
|
+
accountList.forEach((account) => {
|
|
1683
|
+
const accountCartItems = this.store.cart.getCartByAccount(account.getId());
|
|
1684
|
+
const currentCapacity = calculateCapacityFromCartItems(accountCartItems);
|
|
1685
|
+
if (currentCapacity > maxCapacity) {
|
|
1686
|
+
maxCapacity = currentCapacity;
|
|
1687
|
+
}
|
|
1688
|
+
});
|
|
1689
|
+
} else {
|
|
1690
|
+
maxCapacity = calculateCapacityFromCartItems(cartItems);
|
|
1691
|
+
}
|
|
1692
|
+
const arr = [];
|
|
1693
|
+
const today = (0, import_dayjs.default)().startOf("day");
|
|
1694
|
+
for (let i = (0, import_dayjs.default)(startDate); i.isBefore((0, import_dayjs.default)(endDate)); i = i.add(1, "day")) {
|
|
1695
|
+
const currentDate = i.format("YYYY-MM-DD");
|
|
1696
|
+
const theDateResources = this.store.date.getResourcesListByDate(currentDate);
|
|
1697
|
+
resources.forEach((item) => {
|
|
1698
|
+
var _a2;
|
|
1699
|
+
item.times = ((_a2 = theDateResources == null ? void 0 : theDateResources.find((n) => n.id === item.id)) == null ? void 0 : _a2.times) || [];
|
|
1700
|
+
});
|
|
1701
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)(resources);
|
|
1702
|
+
if (i.isBefore(today)) {
|
|
1703
|
+
arr.push({
|
|
1704
|
+
date: currentDate,
|
|
1705
|
+
status: "unavailable",
|
|
1706
|
+
week: i.format("ddd"),
|
|
1707
|
+
weekNum: i.day()
|
|
1708
|
+
});
|
|
1709
|
+
continue;
|
|
1710
|
+
}
|
|
1711
|
+
const timeSlots = (0, import_resources.getTimeSlicesByResources)({
|
|
1712
|
+
resourceIds,
|
|
1713
|
+
resourcesMap,
|
|
1714
|
+
duration,
|
|
1715
|
+
currentDate,
|
|
1716
|
+
split: 10,
|
|
1717
|
+
resourcesUseableMap,
|
|
1718
|
+
capacity: maxCapacity,
|
|
1719
|
+
cut_off_time: maxCutOffTime,
|
|
1720
|
+
hasFlexibleDuration,
|
|
1721
|
+
operating_day_boundary,
|
|
1722
|
+
maxBlockThreshold
|
|
1723
|
+
});
|
|
1724
|
+
if (timeSlots.length > 0) {
|
|
1725
|
+
arr.push({
|
|
1726
|
+
date: currentDate,
|
|
1727
|
+
status: "available",
|
|
1728
|
+
week: i.format("ddd"),
|
|
1729
|
+
weekNum: i.day()
|
|
1730
|
+
});
|
|
1731
|
+
} else {
|
|
1732
|
+
arr.push({
|
|
1733
|
+
date: currentDate,
|
|
1734
|
+
status: "unavailable",
|
|
1735
|
+
week: i.format("ddd"),
|
|
1736
|
+
weekNum: i.day()
|
|
1737
|
+
});
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
return arr;
|
|
1741
|
+
}
|
|
1544
1742
|
// 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
|
|
1545
1743
|
submitTimeSlot(timeSlots) {
|
|
1546
1744
|
var _a, _b;
|
|
@@ -1569,6 +1767,30 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1569
1767
|
newResources.forEach((resource) => {
|
|
1570
1768
|
var _a3, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1571
1769
|
if (((_b2 = (_a3 = item._productOrigin) == null ? void 0 : _a3.duration) == null ? void 0 : _b2.type) === "flexible") {
|
|
1770
|
+
let getEarliestBlockedStartTime = function({
|
|
1771
|
+
currentStartTime: currentStartTime2,
|
|
1772
|
+
times
|
|
1773
|
+
}) {
|
|
1774
|
+
var _a4;
|
|
1775
|
+
const currentStart = (0, import_dayjs.default)(currentStartTime2);
|
|
1776
|
+
let earliestBlockStart;
|
|
1777
|
+
for (const time of times || []) {
|
|
1778
|
+
const blockedTimes = (_a4 = time.event_list) == null ? void 0 : _a4.filter((event) => event.type !== "schedule_event");
|
|
1779
|
+
for (const event of blockedTimes || []) {
|
|
1780
|
+
const eventStart = (0, import_dayjs.default)(event.start_at);
|
|
1781
|
+
const eventEnd = (0, import_dayjs.default)(event.end_at);
|
|
1782
|
+
if (eventStart.isBefore(currentStart) && eventEnd.isAfter(currentStart)) {
|
|
1783
|
+
return currentStart.format("YYYY-MM-DD HH:mm");
|
|
1784
|
+
}
|
|
1785
|
+
if (eventStart.isAfter(currentStart)) {
|
|
1786
|
+
if (!earliestBlockStart || eventStart.isBefore(earliestBlockStart)) {
|
|
1787
|
+
earliestBlockStart = eventStart;
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
return earliestBlockStart == null ? void 0 : earliestBlockStart.format("YYYY-MM-DD HH:mm");
|
|
1793
|
+
};
|
|
1572
1794
|
item.duration = {
|
|
1573
1795
|
type: "minutes",
|
|
1574
1796
|
value: 10
|
|
@@ -1583,13 +1805,22 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1583
1805
|
},
|
|
1584
1806
|
targetResourceTimes[0]
|
|
1585
1807
|
);
|
|
1808
|
+
const earliestBlockedStartTime = getEarliestBlockedStartTime({
|
|
1809
|
+
currentStartTime,
|
|
1810
|
+
times: targetResourceTimes
|
|
1811
|
+
});
|
|
1586
1812
|
const resourceDate = (0, import_dayjs.default)(resourcesEndTime.end_at).format(
|
|
1587
1813
|
"YYYY-MM-DD"
|
|
1588
1814
|
);
|
|
1589
1815
|
const operatingBoundaryDateTime = `${resourceDate} ${operating_day_boundary.type === "start_time" ? "23:59" : operating_day_boundary.time}`;
|
|
1590
|
-
const
|
|
1591
|
-
|
|
1592
|
-
|
|
1816
|
+
const endTimeCandidates = [
|
|
1817
|
+
resourcesEndTime.end_at,
|
|
1818
|
+
operatingBoundaryDateTime,
|
|
1819
|
+
...earliestBlockedStartTime ? [earliestBlockedStartTime] : []
|
|
1820
|
+
];
|
|
1821
|
+
const endTime = endTimeCandidates.reduce((earliest, value) => {
|
|
1822
|
+
return (0, import_dayjs.default)(value).isBefore((0, import_dayjs.default)(earliest)) ? value : earliest;
|
|
1823
|
+
}, endTimeCandidates[0]);
|
|
1593
1824
|
let formattedEndTime;
|
|
1594
1825
|
if (typeof endTime === "string" && endTime.includes(":") && !endTime.includes(" ") && !endTime.includes("T")) {
|
|
1595
1826
|
const currentDate = timeSlots.start_at.format("YYYY-MM-DD");
|
|
@@ -1684,7 +1915,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1684
1915
|
resources,
|
|
1685
1916
|
product
|
|
1686
1917
|
}) {
|
|
1687
|
-
var _a, _b, _c, _d
|
|
1918
|
+
var _a, _b, _c, _d;
|
|
1688
1919
|
const targetProduct = this.store.currentProduct;
|
|
1689
1920
|
const targetProductData = product || targetProduct;
|
|
1690
1921
|
let targetSchedules = [];
|
|
@@ -1727,24 +1958,48 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1727
1958
|
return -1;
|
|
1728
1959
|
return 0;
|
|
1729
1960
|
});
|
|
1730
|
-
const
|
|
1961
|
+
const enabledResourceTypeConfigs = ((_d = (_c = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.filter(
|
|
1731
1962
|
(n) => n.status === 1
|
|
1732
|
-
))
|
|
1963
|
+
)) || [];
|
|
1964
|
+
const resourceTypeConfigById = new Map(
|
|
1965
|
+
enabledResourceTypeConfigs.map((n) => [n.id, n])
|
|
1966
|
+
);
|
|
1733
1967
|
const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
|
|
1734
1968
|
const resourcesUseableMap = {};
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1969
|
+
const statsByResourceType = {};
|
|
1970
|
+
enabledResourceTypeConfigs.forEach((cfg) => {
|
|
1971
|
+
statsByResourceType[cfg.id] = {
|
|
1972
|
+
count: 0,
|
|
1973
|
+
left: 0,
|
|
1974
|
+
summaryCount: 0,
|
|
1975
|
+
summaryConfigCount: 0
|
|
1976
|
+
};
|
|
1977
|
+
});
|
|
1738
1978
|
allProductResources == null ? void 0 : allProductResources.forEach((m) => {
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1979
|
+
const currentResourceTypeConfig = resourceTypeConfigById.get(m.form_id);
|
|
1980
|
+
if (!currentResourceTypeConfig)
|
|
1981
|
+
return;
|
|
1982
|
+
let currentResourceMaxRemainingCapacity = 0;
|
|
1983
|
+
let isAllTimeSlicesUsable = true;
|
|
1742
1984
|
const mTimes = m.times.filter((n) => {
|
|
1743
|
-
return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(item.end), "minute") || (0, import_dayjs.default)(n.start_at).isBefore((0, import_dayjs.default)(item.end), "minute") && (0, import_dayjs.default)(n.end_at).isAfter((0, import_dayjs.default)(item.start), "minute");
|
|
1985
|
+
return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(item.end), "minute") || m.onlyComputed && (0, import_dayjs.default)(n.start_at).isBefore((0, import_dayjs.default)(item.end), "minute") && (0, import_dayjs.default)(n.end_at).isAfter((0, import_dayjs.default)(item.start), "minute");
|
|
1744
1986
|
});
|
|
1745
1987
|
if (mTimes.length === 0) {
|
|
1746
1988
|
return;
|
|
1747
1989
|
}
|
|
1990
|
+
if (!m.onlyComputed) {
|
|
1991
|
+
const currentStats2 = statsByResourceType[m.form_id] || {
|
|
1992
|
+
count: 0,
|
|
1993
|
+
left: 0,
|
|
1994
|
+
summaryCount: 0,
|
|
1995
|
+
summaryConfigCount: 0
|
|
1996
|
+
};
|
|
1997
|
+
if (currentResourceTypeConfig.type === "multiple")
|
|
1998
|
+
currentStats2.summaryConfigCount += m.capacity;
|
|
1999
|
+
else
|
|
2000
|
+
currentStats2.summaryConfigCount += 1;
|
|
2001
|
+
statsByResourceType[m.form_id] = currentStats2;
|
|
2002
|
+
}
|
|
1748
2003
|
mTimes.forEach((childTiem) => {
|
|
1749
2004
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
1750
2005
|
timeSlice: {
|
|
@@ -1762,47 +2017,63 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1762
2017
|
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
1763
2018
|
resourcesUseableMap[m.id] = res.usable;
|
|
1764
2019
|
}
|
|
1765
|
-
if (res.usable
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
2020
|
+
if (!res.usable)
|
|
2021
|
+
isAllTimeSlicesUsable = false;
|
|
2022
|
+
if (res.usable && !m.onlyComputed) {
|
|
2023
|
+
if (res.remainingCapacity > currentResourceMaxRemainingCapacity)
|
|
2024
|
+
currentResourceMaxRemainingCapacity = res.remainingCapacity;
|
|
1770
2025
|
}
|
|
1771
|
-
currentResourcesTimeSlotCanUsedArr.push(res.usable);
|
|
1772
2026
|
});
|
|
1773
|
-
if (!
|
|
1774
|
-
|
|
1775
|
-
)
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
2027
|
+
if (!isAllTimeSlicesUsable)
|
|
2028
|
+
return;
|
|
2029
|
+
if (m.onlyComputed)
|
|
2030
|
+
return;
|
|
2031
|
+
const currentStats = statsByResourceType[m.form_id] || {
|
|
2032
|
+
count: 0,
|
|
2033
|
+
left: 0,
|
|
2034
|
+
summaryCount: 0,
|
|
2035
|
+
summaryConfigCount: 0
|
|
2036
|
+
};
|
|
2037
|
+
currentStats.left += 1;
|
|
2038
|
+
if (currentResourceTypeConfig.type === "multiple") {
|
|
2039
|
+
currentStats.summaryCount += currentResourceMaxRemainingCapacity;
|
|
1784
2040
|
}
|
|
2041
|
+
if (currentResourceMaxRemainingCapacity > currentStats.count)
|
|
2042
|
+
currentStats.count = currentResourceMaxRemainingCapacity;
|
|
2043
|
+
statsByResourceType[m.form_id] = currentStats;
|
|
1785
2044
|
});
|
|
1786
2045
|
const cartItems2 = this.store.cart.getItems();
|
|
1787
2046
|
productResources.forEach((n) => {
|
|
2047
|
+
const currentResourceTypeConfig = resourceTypeConfigById.get(n.id);
|
|
2048
|
+
if (!currentResourceTypeConfig)
|
|
2049
|
+
return;
|
|
2050
|
+
const currentStats = statsByResourceType[n.id] || {
|
|
2051
|
+
count: 0,
|
|
2052
|
+
left: 0,
|
|
2053
|
+
summaryCount: 0
|
|
2054
|
+
};
|
|
1788
2055
|
if (n.type === "single") {
|
|
1789
2056
|
const currentResourcesSet = /* @__PURE__ */ new Set([...n.optional_resource, ...n.default_resource]);
|
|
1790
2057
|
const sameCartItems = cartItems2.filter((m) => {
|
|
1791
2058
|
var _a2, _b2, _c2;
|
|
1792
2059
|
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;
|
|
1793
2060
|
});
|
|
1794
|
-
if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length >
|
|
1795
|
-
|
|
1796
|
-
count = 0;
|
|
1797
|
-
summaryCount = 0;
|
|
2061
|
+
if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length > currentStats.left) {
|
|
2062
|
+
currentStats.left = 0;
|
|
2063
|
+
currentStats.count = 0;
|
|
2064
|
+
currentStats.summaryCount = 0;
|
|
1798
2065
|
}
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
2066
|
+
let otherCartItems = cartItems2.filter(
|
|
2067
|
+
(m) => {
|
|
2068
|
+
var _a2, _b2, _c2, _d2, _e, _f;
|
|
2069
|
+
const isTimeMatch = ((_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;
|
|
2070
|
+
const isResourceMatch = (_f = (_e = (_d2 = m._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e.resources) == null ? void 0 : _f.find((m2) => m2.type === n.type && m2.status === 1);
|
|
2071
|
+
return isTimeMatch && isResourceMatch;
|
|
2072
|
+
}
|
|
2073
|
+
);
|
|
1803
2074
|
otherCartItems.forEach((m) => {
|
|
1804
2075
|
var _a2, _b2, _c2;
|
|
1805
|
-
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);
|
|
2076
|
+
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 && m2.status === 1);
|
|
1806
2077
|
const sameTypeResourcesSet = /* @__PURE__ */ new Set([...(sameTypeResources == null ? void 0 : sameTypeResources.optional_resource) || [], ...(sameTypeResources == null ? void 0 : sameTypeResources.default_resource) || []]);
|
|
1807
2078
|
sameTypeResourcesSet.forEach((resource) => currentResourcesSet.add(resource));
|
|
1808
2079
|
});
|
|
@@ -1818,9 +2089,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1818
2089
|
}
|
|
1819
2090
|
});
|
|
1820
2091
|
if (currentResourcesSet.size > 0 && otherCartItems.length + sameCartItems.length >= currentResourcesSet.size) {
|
|
1821
|
-
|
|
1822
|
-
count = 0;
|
|
1823
|
-
summaryCount = 0;
|
|
2092
|
+
currentStats.left = 0;
|
|
2093
|
+
currentStats.count = 0;
|
|
2094
|
+
currentStats.summaryCount = 0;
|
|
1824
2095
|
}
|
|
1825
2096
|
} else {
|
|
1826
2097
|
const sameCartItems = cartItems2.filter((m) => {
|
|
@@ -1830,9 +2101,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1830
2101
|
const sameCartNeedCapacity = sameCartItems.reduce((acc, curr) => acc + (0, import_capacity.getCapacityInfoByCartItem)(curr).currentCapacity, 0);
|
|
1831
2102
|
const currentProductResourcesCapacity = n.renderList.reduce((acc, curr) => !curr.onlyComputed ? acc + curr.capacity || 0 : acc, 0);
|
|
1832
2103
|
if (sameCartNeedCapacity >= currentProductResourcesCapacity) {
|
|
1833
|
-
|
|
1834
|
-
count = 0;
|
|
1835
|
-
summaryCount = 0;
|
|
2104
|
+
currentStats.left = 0;
|
|
2105
|
+
currentStats.count = 0;
|
|
2106
|
+
currentStats.summaryCount = 0;
|
|
1836
2107
|
}
|
|
1837
2108
|
const otherSameTimesCartItems = cartItems2.filter((m) => `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end);
|
|
1838
2109
|
const otherCartNeedCapacity = otherSameTimesCartItems.reduce((acc, curr) => acc + (0, import_capacity.getCapacityInfoByCartItem)(curr).currentCapacity, 0);
|
|
@@ -1867,7 +2138,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1867
2138
|
{ start_at: m.start_at, end_at: m.end_at },
|
|
1868
2139
|
{ start_at: (0, import_dayjs.default)(item.start), end_at: (0, import_dayjs.default)(item.end) }
|
|
1869
2140
|
)) {
|
|
1870
|
-
mSet.set(m.id, m.pax
|
|
2141
|
+
mSet.set(m.id, m.pax ?? 1);
|
|
1871
2142
|
}
|
|
1872
2143
|
});
|
|
1873
2144
|
});
|
|
@@ -1875,22 +2146,68 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1875
2146
|
return acc;
|
|
1876
2147
|
}, 0);
|
|
1877
2148
|
if (otherCartNeedCapacity + usedCapacity >= currentTypeResourcesCapacity) {
|
|
1878
|
-
|
|
1879
|
-
count = 0;
|
|
1880
|
-
summaryCount = 0;
|
|
2149
|
+
currentStats.left = 0;
|
|
2150
|
+
currentStats.count = 0;
|
|
2151
|
+
currentStats.summaryCount = 0;
|
|
1881
2152
|
}
|
|
1882
2153
|
}
|
|
2154
|
+
statsByResourceType[n.id] = currentStats;
|
|
1883
2155
|
});
|
|
1884
2156
|
const startDayJs = (0, import_dayjs.default)(item.start);
|
|
1885
2157
|
const endDayJs = (0, import_dayjs.default)(item.end);
|
|
2158
|
+
let bottleneckResourceTypeId;
|
|
2159
|
+
let bottleneckValue = Infinity;
|
|
2160
|
+
enabledResourceTypeConfigs.forEach((cfg) => {
|
|
2161
|
+
const stats = statsByResourceType[cfg.id] || {
|
|
2162
|
+
count: 0,
|
|
2163
|
+
left: 0,
|
|
2164
|
+
summaryCount: 0,
|
|
2165
|
+
summaryConfigCount: 0
|
|
2166
|
+
};
|
|
2167
|
+
const value = cfg.type === "multiple" ? stats.summaryCount : stats.left;
|
|
2168
|
+
if (value < bottleneckValue) {
|
|
2169
|
+
bottleneckValue = value;
|
|
2170
|
+
bottleneckResourceTypeId = cfg.id;
|
|
2171
|
+
}
|
|
2172
|
+
});
|
|
2173
|
+
const bottleneckStats = bottleneckResourceTypeId !== void 0 ? statsByResourceType[bottleneckResourceTypeId] || {
|
|
2174
|
+
count: 0,
|
|
2175
|
+
left: 0,
|
|
2176
|
+
summaryCount: 0,
|
|
2177
|
+
summaryConfigCount: 0
|
|
2178
|
+
} : { count: 0, left: 0, summaryCount: 0, summaryConfigCount: 0 };
|
|
2179
|
+
const bottleneckConfig = bottleneckResourceTypeId !== void 0 ? resourceTypeConfigById.get(bottleneckResourceTypeId) : void 0;
|
|
2180
|
+
let status = "sold_out";
|
|
2181
|
+
if (bottleneckStats.left === 0)
|
|
2182
|
+
status = "sold_out";
|
|
2183
|
+
else if (!bottleneckConfig || bottleneckStats.summaryConfigCount === 0)
|
|
2184
|
+
status = "sold_out";
|
|
2185
|
+
else if (bottleneckConfig.type === "multiple") {
|
|
2186
|
+
const usageRatio = bottleneckStats.summaryCount / bottleneckStats.summaryConfigCount;
|
|
2187
|
+
if (usageRatio > 0.5)
|
|
2188
|
+
status = "lots_of_space";
|
|
2189
|
+
else if (bottleneckStats.summaryCount > 0)
|
|
2190
|
+
status = "filling_up_fast";
|
|
2191
|
+
else
|
|
2192
|
+
status = "sold_out";
|
|
2193
|
+
} else {
|
|
2194
|
+
const usageRatio = bottleneckStats.left / bottleneckStats.summaryConfigCount;
|
|
2195
|
+
if (usageRatio > 0.5)
|
|
2196
|
+
status = "lots_of_space";
|
|
2197
|
+
else if (bottleneckStats.count > 0)
|
|
2198
|
+
status = "filling_up_fast";
|
|
2199
|
+
else
|
|
2200
|
+
status = "sold_out";
|
|
2201
|
+
}
|
|
1886
2202
|
return {
|
|
1887
2203
|
start_time: startDayJs.format("HH:mm"),
|
|
1888
2204
|
end_time: endDayJs.format("HH:mm"),
|
|
1889
2205
|
start_at: startDayJs,
|
|
1890
2206
|
end_at: endDayJs,
|
|
1891
|
-
count,
|
|
1892
|
-
left:
|
|
1893
|
-
summaryCount
|
|
2207
|
+
count: bottleneckStats.count,
|
|
2208
|
+
left: bottleneckStats.left,
|
|
2209
|
+
summaryCount: bottleneckStats.summaryCount,
|
|
2210
|
+
status
|
|
1894
2211
|
};
|
|
1895
2212
|
});
|
|
1896
2213
|
return formatScheduleTimeSlots;
|
|
@@ -1976,6 +2293,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1976
2293
|
if (!itemsByResourceType[resourceCode]) {
|
|
1977
2294
|
itemsByResourceType[resourceCode] = [];
|
|
1978
2295
|
}
|
|
2296
|
+
if (itemsByResourceType[resourceCode].find((item) => item.holder_id === cartItem.holder_id)) {
|
|
2297
|
+
return;
|
|
2298
|
+
}
|
|
1979
2299
|
if (!itemsByResourceType[resourceCode].find((item) => item._id === cartItem._id)) {
|
|
1980
2300
|
itemsByResourceType[resourceCode].push(cartItem);
|
|
1981
2301
|
}
|
|
@@ -2645,7 +2965,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2645
2965
|
const openResources = ((_d = (_c = tempProducts == null ? void 0 : tempProducts.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.filter(
|
|
2646
2966
|
(m) => m.status === 1
|
|
2647
2967
|
)) || [];
|
|
2648
|
-
const allProductResources = (0, import_resources.sortCombinedResources)(res.data);
|
|
2968
|
+
const allProductResources = (0, import_lodash_es.cloneDeep)((0, import_resources.sortCombinedResources)(res.data) || []);
|
|
2649
2969
|
allProductResources.forEach((m) => {
|
|
2650
2970
|
var _a2, _b2;
|
|
2651
2971
|
const resource = (_b2 = (_a2 = tempProducts == null ? void 0 : tempProducts.product_resource) == null ? void 0 : _a2.resources) == null ? void 0 : _b2.find(
|
|
@@ -2661,6 +2981,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2661
2981
|
while ((0, import_dayjs.default)(currentDate).isBefore((0, import_dayjs.default)(endDate), "day") || (0, import_dayjs.default)(currentDate).isSame((0, import_dayjs.default)(endDate), "day")) {
|
|
2662
2982
|
const currentDateStr = currentDate.format("YYYY-MM-DD");
|
|
2663
2983
|
let status = "available";
|
|
2984
|
+
let summaryCount = 0;
|
|
2985
|
+
let availableCount = 0;
|
|
2664
2986
|
const { latestStartDate, earliestEndDate } = (0, import_resources.checkSessionProductLeadTime)(tempProducts);
|
|
2665
2987
|
if (latestStartDate || earliestEndDate) {
|
|
2666
2988
|
if (latestStartDate && (0, import_dayjs.default)(currentDate).isBefore(latestStartDate, "day")) {
|
|
@@ -2685,43 +3007,84 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2685
3007
|
currentDateStr
|
|
2686
3008
|
);
|
|
2687
3009
|
const scheduleTimeSlots = (0, import_utils3.getAllSortedDateRanges)(minTimeMaxTime);
|
|
2688
|
-
|
|
3010
|
+
let timesSlotCanUse = false;
|
|
3011
|
+
scheduleTimeSlots.forEach((item) => {
|
|
2689
3012
|
const resourcesUseableMap = {};
|
|
2690
|
-
|
|
3013
|
+
let isAllResourceTypesUseable = true;
|
|
3014
|
+
openResources.forEach((resource) => {
|
|
3015
|
+
var _a2;
|
|
2691
3016
|
const currentResourcesList = allProductResources.filter(
|
|
2692
3017
|
(n) => n.form_id === resource.resource_type_id
|
|
2693
3018
|
);
|
|
2694
|
-
|
|
3019
|
+
(_a2 = resource.renderList) == null ? void 0 : _a2.forEach((item2) => {
|
|
3020
|
+
if (item2.onlyComputed) {
|
|
3021
|
+
const targetIndex = currentResourcesList.findIndex((n) => n.id === item2.id);
|
|
3022
|
+
if (targetIndex && targetIndex !== -1) {
|
|
3023
|
+
currentResourcesList[targetIndex].onlyComputed = true;
|
|
3024
|
+
}
|
|
3025
|
+
}
|
|
3026
|
+
});
|
|
3027
|
+
currentResourcesList.forEach((item2) => {
|
|
3028
|
+
var _a3, _b2;
|
|
3029
|
+
if (!((_a3 = resource.optional_resource) == null ? void 0 : _a3.includes(item2.id)) && !((_b2 = resource.default_resource) == null ? void 0 : _b2.includes(item2.id))) {
|
|
3030
|
+
item2.onlyComputed = true;
|
|
3031
|
+
}
|
|
3032
|
+
});
|
|
3033
|
+
currentResourcesList.sort((a, b) => {
|
|
3034
|
+
return a.onlyComputed ? -1 : 1;
|
|
3035
|
+
});
|
|
3036
|
+
let isAnyResourceUseableInType = false;
|
|
3037
|
+
currentResourcesList == null ? void 0 : currentResourcesList.forEach((m) => {
|
|
2695
3038
|
const mTimes = m.times.filter((n) => {
|
|
2696
3039
|
return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(item.end), "minute");
|
|
2697
3040
|
});
|
|
2698
|
-
if (mTimes.length === 0)
|
|
3041
|
+
if (mTimes.length === 0)
|
|
2699
3042
|
return;
|
|
3043
|
+
if (!m.onlyComputed) {
|
|
3044
|
+
if (resource.type === "multiple") {
|
|
3045
|
+
summaryCount += m.capacity;
|
|
3046
|
+
} else {
|
|
3047
|
+
summaryCount += 1;
|
|
3048
|
+
}
|
|
2700
3049
|
}
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
3050
|
+
let isAnyTimeSliceUseable = false;
|
|
3051
|
+
mTimes.forEach((childTiem) => {
|
|
3052
|
+
if (isAnyTimeSliceUseable)
|
|
3053
|
+
return;
|
|
3054
|
+
const res2 = (0, import_resources.getIsUsableByTimeItem)({
|
|
3055
|
+
timeSlice: {
|
|
3056
|
+
start_time: item.start,
|
|
3057
|
+
end_time: item.end,
|
|
3058
|
+
start_at: (0, import_dayjs.default)(item.start),
|
|
3059
|
+
end_at: (0, import_dayjs.default)(item.end)
|
|
3060
|
+
},
|
|
3061
|
+
time: childTiem,
|
|
3062
|
+
resource: m,
|
|
3063
|
+
currentCount: 1,
|
|
3064
|
+
resourcesUseableMap,
|
|
3065
|
+
cut_off_time: tempProducts == null ? void 0 : tempProducts.cut_off_time
|
|
3066
|
+
});
|
|
3067
|
+
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res2.reason !== "capacityOnly") {
|
|
3068
|
+
resourcesUseableMap[m.id] = res2.usable;
|
|
3069
|
+
}
|
|
3070
|
+
if (res2.usable && !m.onlyComputed) {
|
|
3071
|
+
isAnyTimeSliceUseable = true;
|
|
3072
|
+
if (resource.type === "multiple") {
|
|
3073
|
+
availableCount += res2.remainingCapacity;
|
|
3074
|
+
} else {
|
|
3075
|
+
availableCount += 1;
|
|
2718
3076
|
}
|
|
2719
|
-
return res2.usable && !m.onlyComputed;
|
|
2720
3077
|
}
|
|
2721
|
-
|
|
2722
|
-
|
|
3078
|
+
;
|
|
3079
|
+
});
|
|
3080
|
+
if (isAnyTimeSliceUseable)
|
|
3081
|
+
isAnyResourceUseableInType = true;
|
|
2723
3082
|
});
|
|
3083
|
+
if (!isAnyResourceUseableInType)
|
|
3084
|
+
isAllResourceTypesUseable = false;
|
|
2724
3085
|
});
|
|
3086
|
+
if (isAllResourceTypesUseable)
|
|
3087
|
+
timesSlotCanUse = true;
|
|
2725
3088
|
});
|
|
2726
3089
|
if (!timesSlotCanUse) {
|
|
2727
3090
|
status = "unavailable";
|
|
@@ -2730,11 +3093,26 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2730
3093
|
firstAvailableDate = currentDateStr;
|
|
2731
3094
|
}
|
|
2732
3095
|
}
|
|
3096
|
+
let dateStatus;
|
|
3097
|
+
if (status === "unavailable") {
|
|
3098
|
+
if (availableCount === 0 && summaryCount > 0)
|
|
3099
|
+
dateStatus = "sold_out";
|
|
3100
|
+
else
|
|
3101
|
+
dateStatus = "unavailable";
|
|
3102
|
+
} else {
|
|
3103
|
+
const usageRatio = availableCount / summaryCount;
|
|
3104
|
+
if (usageRatio > 0.5)
|
|
3105
|
+
dateStatus = "lots_of_space";
|
|
3106
|
+
else
|
|
3107
|
+
dateStatus = "filling_up_fast";
|
|
3108
|
+
}
|
|
2733
3109
|
dates.push({
|
|
2734
3110
|
date: (0, import_dayjs.default)(currentDate).format("YYYY-MM-DD"),
|
|
2735
3111
|
week: (0, import_dayjs.default)(currentDate).format("ddd"),
|
|
2736
3112
|
weekNum: (0, import_dayjs.default)(currentDate).day(),
|
|
2737
|
-
|
|
3113
|
+
summaryCount,
|
|
3114
|
+
availableCount,
|
|
3115
|
+
status: dateStatus
|
|
2738
3116
|
});
|
|
2739
3117
|
if (firstAvailableDate && (0, import_dayjs.default)(currentDate).diff((0, import_dayjs.default)(startDate), "day") > 31) {
|
|
2740
3118
|
break;
|