@pisell/pisellos 0.0.569 → 0.10.2
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/core/index.js +10 -6
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -3
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +7 -5
- package/dist/model/strategy/adapter/walletPass/example.js +26 -3
- package/dist/model/strategy/adapter/walletPass/index.js +5 -5
- package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/dist/model/strategy/adapter/walletPass/utils.js +17 -92
- package/dist/model/strategy/strategy-example.js +19 -5
- package/dist/modules/BaseModule.d.ts +1 -1
- package/dist/modules/BaseModule.js +8 -10
- package/dist/modules/Cart/index.js +3 -0
- package/dist/modules/Cart/utils/cartProduct.js +1 -0
- package/dist/modules/Cart/utils/cartResource.js +0 -2
- package/dist/modules/Cart/utils/changePrice.js +9 -16
- package/dist/modules/Date/index.js +5 -1
- package/dist/modules/Discount/index.d.ts +0 -1
- package/dist/modules/Discount/index.js +7 -22
- package/dist/modules/Discount/types.d.ts +0 -1
- package/dist/modules/OpenData/index.js +2 -0
- package/dist/modules/Order/index.js +70 -40
- package/dist/modules/Payment/index.js +162 -97
- package/dist/modules/Payment/types.d.ts +4 -8
- package/dist/modules/Payment/walletpass.d.ts +0 -2
- package/dist/modules/Payment/walletpass.js +5 -4
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +3 -12
- package/dist/modules/ProductList/types.d.ts +0 -1
- package/dist/modules/Rules/index.js +126 -427
- package/dist/modules/SalesSummary/utils.js +1 -2
- package/dist/modules/Schedule/getDateIsInSchedule.js +0 -5
- package/dist/modules/Schedule/index.js +1 -0
- package/dist/modules/Schedule/utils.js +1 -0
- package/dist/modules/Step/index.js +1 -0
- package/dist/modules/Summary/utils.js +22 -43
- package/dist/plugins/request.js +4 -1
- package/dist/plugins/window.js +6 -2
- package/dist/server/index.js +129 -97
- package/dist/server/modules/menu/index.js +41 -32
- package/dist/server/modules/order/index.js +4 -2
- package/dist/server/modules/products/index.js +42 -24
- package/dist/server/modules/quotation/index.js +38 -29
- package/dist/server/modules/resource/index.js +4 -3
- package/dist/server/modules/schedule/index.js +35 -27
- package/dist/server/utils/product.js +1 -0
- package/dist/solution/BaseSales/index.js +41 -38
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +60 -11
- package/dist/solution/BookingByStep/utils/capacity.js +11 -1
- package/dist/solution/BookingByStep/utils/resources.js +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +43 -2
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +2 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +7 -6
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +31 -25
- package/dist/solution/BookingTicket/utils/scan/index.js +10 -6
- package/dist/solution/BuyTickets/index.js +12 -9
- package/dist/solution/Checkout/index.js +252 -177
- package/dist/solution/Checkout/utils/index.js +16 -4
- package/dist/solution/RegisterAndLogin/index.js +76 -30
- package/dist/solution/ScanOrder/index.js +60 -50
- package/dist/solution/ShopDiscount/index.js +14 -15
- package/dist/solution/ShopDiscount/types.d.ts +4 -5
- package/dist/solution/ShopDiscount/utils.d.ts +0 -9
- package/dist/solution/ShopDiscount/utils.js +0 -9
- package/dist/solution/VenueBooking/index.d.ts +3 -31
- package/dist/solution/VenueBooking/index.js +496 -651
- package/dist/solution/VenueBooking/types.d.ts +1 -3
- package/dist/solution/VenueBooking/types.js +0 -1
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/task.js +18 -15
- package/dist/utils/watch.js +1 -0
- package/lib/apis/picoding.js +0 -2
- package/lib/core/index.js +132 -130
- package/lib/effects/index.js +57 -46
- package/lib/index.d.ts +0 -1
- package/lib/index.js +50 -92
- package/lib/model/index.js +21 -14
- package/lib/model/strategy/adapter/dataVariant/adapter.js +50 -38
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +236 -162
- package/lib/model/strategy/adapter/dataVariant/examples.js +237 -229
- package/lib/model/strategy/adapter/dataVariant/index.js +34 -39
- package/lib/model/strategy/adapter/dataVariant/type.js +28 -57
- package/lib/model/strategy/adapter/index.js +64 -100
- package/lib/model/strategy/adapter/itemRule/adapter.js +144 -156
- package/lib/model/strategy/adapter/itemRule/evaluator.js +48 -36
- package/lib/model/strategy/adapter/itemRule/examples.js +225 -295
- package/lib/model/strategy/adapter/itemRule/index.js +57 -83
- package/lib/model/strategy/adapter/itemRule/type.js +36 -97
- package/lib/model/strategy/adapter/promotion/adapter.js +63 -84
- package/lib/model/strategy/adapter/promotion/evaluator.js +231 -381
- package/lib/model/strategy/adapter/promotion/examples.js +159 -139
- package/lib/model/strategy/adapter/promotion/index.js +49 -1
- package/lib/model/strategy/adapter/promotion/type.js +35 -199
- package/lib/model/strategy/adapter/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/evaluator.js +152 -180
- package/lib/model/strategy/adapter/walletPass/example.js +190 -217
- package/lib/model/strategy/adapter/walletPass/index.js +51 -75
- package/lib/model/strategy/adapter/walletPass/locales.js +58 -36
- package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/lib/model/strategy/adapter/walletPass/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/lib/model/strategy/adapter/walletPass/utils.js +383 -678
- package/lib/model/strategy/engine.js +168 -270
- package/lib/model/strategy/index.js +34 -49
- package/lib/model/strategy/strategy-example.js +239 -243
- package/lib/model/strategy/type.js +40 -100
- package/lib/modules/Account/index.js +53 -39
- package/lib/modules/Account/types.js +33 -20
- package/lib/modules/AccountList/index.js +154 -116
- package/lib/modules/AccountList/types.js +31 -30
- package/lib/modules/AccountList/utils.js +30 -18
- package/lib/modules/BaseModule.d.ts +1 -1
- package/lib/modules/BaseModule.js +46 -25
- package/lib/modules/BookingContext/index.js +136 -158
- package/lib/modules/BookingContext/types.js +32 -46
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +143 -131
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +82 -75
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +150 -170
- package/lib/modules/BookingContext/utils/flexible.js +55 -38
- package/lib/modules/BookingContext/utils/formatResourceList.js +34 -19
- package/lib/modules/BookingContext/utils/index.js +41 -124
- package/lib/modules/BookingContext/utils/noResource.js +70 -58
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +41 -14
- package/lib/modules/BookingContext/utils/productExtend.js +155 -202
- package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
- package/lib/modules/BookingContext/utils/resourceSelection.js +41 -19
- package/lib/modules/BookingContext/utils/resources.js +167 -209
- package/lib/modules/BookingContext/utils/serviceTimes.js +116 -115
- package/lib/modules/BookingContext/utils/timeSlices.js +80 -70
- package/lib/modules/Cart/index.js +124 -170
- package/lib/modules/Cart/types.js +51 -46
- package/lib/modules/Cart/utils/cartAccount.js +39 -40
- package/lib/modules/Cart/utils/cartDate.js +61 -56
- package/lib/modules/Cart/utils/cartDiscount.js +33 -28
- package/lib/modules/Cart/utils/cartNote.js +32 -27
- package/lib/modules/Cart/utils/cartProduct.js +251 -321
- package/lib/modules/Cart/utils/cartRelationForms.js +35 -29
- package/lib/modules/Cart/utils/cartResource.js +78 -72
- package/lib/modules/Cart/utils/changePrice.js +50 -28
- package/lib/modules/Cart/utils/index.js +48 -106
- package/lib/modules/Customer/constants.js +34 -13
- package/lib/modules/Customer/index.js +169 -232
- package/lib/modules/Customer/types.js +35 -38
- package/lib/modules/Date/index.js +115 -116
- package/lib/modules/Date/types.js +28 -16
- package/lib/modules/Date/utils.js +123 -174
- package/lib/modules/Discount/index.d.ts +0 -1
- package/lib/modules/Discount/index.js +128 -130
- package/lib/modules/Discount/types.d.ts +0 -1
- package/lib/modules/Discount/types.js +31 -9
- package/lib/modules/Guests/index.js +56 -30
- package/lib/modules/Guests/types.js +33 -23
- package/lib/modules/Holder/index.js +189 -209
- package/lib/modules/Holder/types.js +16 -4
- package/lib/modules/Holder/utils.js +49 -20
- package/lib/modules/OpenData/index.js +76 -69
- package/lib/modules/OpenData/types.js +16 -4
- package/lib/modules/OpenData/utils.js +78 -44
- package/lib/modules/Order/index.js +1909 -1572
- package/lib/modules/Order/types.js +35 -78
- package/lib/modules/Order/utils/bundleDiscountHydration.js +74 -41
- package/lib/modules/Order/utils/manualProductDiscount.js +123 -124
- package/lib/modules/Order/utils/orderCollectionIdentity.js +210 -148
- package/lib/modules/Order/utils.js +634 -799
- package/lib/modules/Payment/cash.js +33 -20
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +76 -145
- package/lib/modules/Payment/eftpos.js +30 -16
- package/lib/modules/Payment/index.js +378 -518
- package/lib/modules/Payment/mx51.js +0 -1
- package/lib/modules/Payment/types.d.ts +4 -8
- package/lib/modules/Payment/types.js +107 -216
- package/lib/modules/Payment/utils.js +48 -51
- package/lib/modules/Payment/walletpass.d.ts +0 -2
- package/lib/modules/Payment/walletpass.js +211 -226
- package/lib/modules/Product/index.js +46 -51
- package/lib/modules/Product/types.js +16 -4
- package/lib/modules/Product/utils.js +33 -32
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +117 -117
- package/lib/modules/ProductList/types.d.ts +0 -1
- package/lib/modules/ProductList/types.js +31 -9
- package/lib/modules/Quotation/index.js +100 -66
- package/lib/modules/Quotation/types.js +16 -4
- package/lib/modules/Resource/index.js +59 -27
- package/lib/modules/Resource/types.js +32 -22
- package/lib/modules/Resource/utils.js +38 -30
- package/lib/modules/ResourcePlanner/index.js +61 -60
- package/lib/modules/ResourcePlanner/planner.js +384 -346
- package/lib/modules/ResourcePlanner/types.js +16 -4
- package/lib/modules/Rules/index.js +903 -1475
- package/lib/modules/Rules/types.js +40 -17
- package/lib/modules/SalesSummary/index.js +90 -85
- package/lib/modules/SalesSummary/types.js +16 -4
- package/lib/modules/SalesSummary/utils.js +427 -351
- package/lib/modules/ScanOrderLogger/index.js +79 -59
- package/lib/modules/ScanOrderLogger/providers/feishu.js +78 -54
- package/lib/modules/ScanOrderLogger/providers/grafana.js +36 -13
- package/lib/modules/ScanOrderLogger/types.js +16 -4
- package/lib/modules/Schedule/getDateIsInSchedule.js +163 -339
- package/lib/modules/Schedule/index.js +114 -100
- package/lib/modules/Schedule/type.js +16 -4
- package/lib/modules/Schedule/types.js +16 -4
- package/lib/modules/Schedule/utils.js +291 -433
- package/lib/modules/Step/index.js +52 -40
- package/lib/modules/Step/tyeps.js +16 -4
- package/lib/modules/Summary/index.js +71 -66
- package/lib/modules/Summary/types.js +16 -4
- package/lib/modules/Summary/utils.js +418 -791
- package/lib/modules/SurchargeList/index.js +60 -46
- package/lib/modules/SurchargeList/types.js +16 -4
- package/lib/modules/index.js +63 -245
- package/lib/plugins/app.js +16 -4
- package/lib/plugins/index.js +25 -36
- package/lib/plugins/request.js +126 -137
- package/lib/plugins/shopStore.js +16 -4
- package/lib/plugins/user.js +16 -4
- package/lib/plugins/window.js +179 -171
- package/lib/server/index.js +2337 -2675
- package/lib/server/modules/floor-plan/index.js +123 -102
- package/lib/server/modules/floor-plan/types.js +30 -15
- package/lib/server/modules/index.js +68 -106
- package/lib/server/modules/menu/index.js +122 -146
- package/lib/server/modules/menu/types.js +31 -18
- package/lib/server/modules/order/index.js +642 -567
- package/lib/server/modules/order/types.js +32 -117
- package/lib/server/modules/order/utils/filterBookings.js +194 -219
- package/lib/server/modules/order/utils/filterOrders.js +92 -118
- package/lib/server/modules/payment/index.js +83 -59
- package/lib/server/modules/payment/types.js +16 -4
- package/lib/server/modules/products/index.js +459 -575
- package/lib/server/modules/products/types.js +34 -44
- package/lib/server/modules/quotation/index.js +172 -137
- package/lib/server/modules/quotation/types.js +31 -21
- package/lib/server/modules/resource/index.js +184 -213
- package/lib/server/modules/resource/types.js +33 -42
- package/lib/server/modules/schedule/index.js +123 -135
- package/lib/server/modules/schedule/types.js +21 -14
- package/lib/server/modules/schedule/utils.js +163 -334
- package/lib/server/types.js +16 -4
- package/lib/server/utils/index.js +23 -25
- package/lib/server/utils/product.js +139 -196
- package/lib/server/utils/schedule.js +41 -34
- package/lib/server/utils/small-ticket.js +456 -478
- package/lib/server/utils/time.js +49 -40
- package/lib/solution/BaseSales/index.js +1016 -850
- package/lib/solution/BaseSales/types.js +37 -41
- package/lib/solution/BaseSales/utils/cartPromotion.js +460 -611
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +105 -85
- package/lib/solution/BaseSales/utils/quotationPrice.js +114 -56
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +143 -102
- package/lib/solution/BaseSales/utils.js +140 -155
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +1340 -1530
- package/lib/solution/BookingByStep/types.js +99 -40
- package/lib/solution/BookingByStep/utils/capacity.js +160 -192
- package/lib/solution/BookingByStep/utils/products.js +52 -42
- package/lib/solution/BookingByStep/utils/resources.js +330 -527
- package/lib/solution/BookingByStep/utils/stock.js +44 -65
- package/lib/solution/BookingByStep/utils/timeslots.js +131 -129
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +459 -543
- package/lib/solution/BookingTicket/types.js +77 -99
- package/lib/solution/BookingTicket/utils/addProductDecision.js +184 -219
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +89 -58
- package/lib/solution/BookingTicket/utils/bookingStatus.js +78 -107
- package/lib/solution/BookingTicket/utils/cartView.js +94 -110
- package/lib/solution/BookingTicket/utils/exampleData.js +0 -185
- package/lib/solution/BookingTicket/utils/orderCustomer.js +41 -18
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +86 -219
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +93 -144
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +91 -79
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +41 -54
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +81 -84
- package/lib/solution/BookingTicket/utils/scan/index.js +104 -98
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +43 -90
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +64 -52
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +58 -56
- package/lib/solution/BuyTickets/index.js +70 -67
- package/lib/solution/BuyTickets/types.js +38 -22
- package/lib/solution/Checkout/index.js +1158 -1451
- package/lib/solution/Checkout/types.js +61 -91
- package/lib/solution/Checkout/utils/index.js +156 -228
- package/lib/solution/PlaceOrder/index.js +0 -55
- package/lib/solution/RegisterAndLogin/config.js +460 -493
- package/lib/solution/RegisterAndLogin/index.js +630 -633
- package/lib/solution/RegisterAndLogin/types.js +76 -189
- package/lib/solution/RegisterAndLogin/utils.js +125 -183
- package/lib/solution/Sales/index.js +320 -317
- package/lib/solution/Sales/types.js +33 -27
- package/lib/solution/ScanOrder/index.js +862 -831
- package/lib/solution/ScanOrder/types.js +34 -33
- package/lib/solution/ScanOrder/utils.js +371 -406
- package/lib/solution/ShopDiscount/index.js +233 -235
- package/lib/solution/ShopDiscount/types.d.ts +4 -5
- package/lib/solution/ShopDiscount/types.js +37 -15
- package/lib/solution/ShopDiscount/utils.d.ts +0 -9
- package/lib/solution/ShopDiscount/utils.js +172 -309
- package/lib/solution/UnifiedBookingSales/index.js +405 -379
- package/lib/solution/UnifiedBookingSales/types.js +31 -12
- package/lib/solution/VenueBooking/index.d.ts +3 -31
- package/lib/solution/VenueBooking/index.js +916 -967
- package/lib/solution/VenueBooking/types.d.ts +1 -3
- package/lib/solution/VenueBooking/types.js +39 -20
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/lib/solution/VenueBooking/utils/dateSummary.js +62 -25
- package/lib/solution/VenueBooking/utils/resource.js +54 -31
- package/lib/solution/VenueBooking/utils/slotMerge.js +107 -94
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/lib/solution/VenueBooking/utils/timeSlot.js +133 -138
- package/lib/solution/VenueBooking/utils.js +67 -130
- package/lib/solution/index.js +41 -124
- package/lib/store/createStore.js +29 -32
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.js +16 -4
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +47 -81
- package/package.json +2 -4
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/lib/solution/VenueBooking/utils/smartPricing.js +0 -192
|
@@ -1,84 +1,115 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/solution/BookingByStep/index.ts
|
|
30
|
+
var BookingByStep_exports = {};
|
|
31
|
+
__export(BookingByStep_exports, {
|
|
32
|
+
BookingByStepImpl: () => BookingByStepImpl
|
|
5
33
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
cacheId;
|
|
37
|
-
otherData = {}; // 提供给 UI 层的临时数据存储,会进缓存
|
|
38
|
-
platform; // 平台类型,用于判断是 PC / H5
|
|
39
|
-
|
|
34
|
+
module.exports = __toCommonJS(BookingByStep_exports);
|
|
35
|
+
var import_BaseModule = require("../../modules/BaseModule");
|
|
36
|
+
var import_types = require("./types");
|
|
37
|
+
var import_utils = require("../../modules/Cart/utils");
|
|
38
|
+
var import_products = require("./utils/products");
|
|
39
|
+
var import_resources = require("./utils/resources");
|
|
40
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
41
|
+
var import_isSameOrBefore = __toESM(require("dayjs/plugin/isSameOrBefore"));
|
|
42
|
+
var import_isSameOrAfter = __toESM(require("dayjs/plugin/isSameOrAfter"));
|
|
43
|
+
var import_utils2 = require("../../modules/Resource/utils");
|
|
44
|
+
var import_lodash_es = require("lodash-es");
|
|
45
|
+
var import_utils3 = require("../../modules/Schedule/utils");
|
|
46
|
+
var import_utils4 = require("../../modules/Date/utils");
|
|
47
|
+
var import_utils5 = require("../../modules/Product/utils");
|
|
48
|
+
var import_timeslots = require("./utils/timeslots");
|
|
49
|
+
var import_changePrice = require("../../modules/Cart/utils/changePrice");
|
|
50
|
+
var import_capacity = require("./utils/capacity");
|
|
51
|
+
var import_stock = require("./utils/stock");
|
|
52
|
+
import_dayjs.default.extend(import_isSameOrBefore.default);
|
|
53
|
+
import_dayjs.default.extend(import_isSameOrAfter.default);
|
|
54
|
+
var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
55
|
+
constructor() {
|
|
56
|
+
super(...arguments);
|
|
57
|
+
this.defaultName = "bookingByStep";
|
|
58
|
+
this.defaultVersion = "1.0.0";
|
|
59
|
+
this.isSolution = true;
|
|
60
|
+
this.otherParams = {};
|
|
61
|
+
this.otherData = {};
|
|
62
|
+
}
|
|
63
|
+
// 平台类型,用于判断是 PC / H5
|
|
40
64
|
async initialize(core, options) {
|
|
65
|
+
var _a, _b, _c, _d, _e;
|
|
41
66
|
this.core = core;
|
|
42
67
|
this.store = options.store || {};
|
|
43
68
|
this.otherParams = options.otherParams || {};
|
|
44
|
-
|
|
45
|
-
this.request = core.getPlugin(
|
|
46
|
-
this.window = core.getPlugin(
|
|
47
|
-
this.shopStore = core.getPlugin(
|
|
69
|
+
console.log("[BookingByStep] 初始化完成");
|
|
70
|
+
this.request = core.getPlugin("request");
|
|
71
|
+
this.window = core.getPlugin("window");
|
|
72
|
+
this.shopStore = core.getPlugin("shopStore");
|
|
48
73
|
if (!this.request) {
|
|
49
|
-
throw new Error(
|
|
74
|
+
throw new Error("bookingByStep解决方案需要 request 插件支持");
|
|
50
75
|
}
|
|
51
76
|
if (!this.shopStore) {
|
|
52
|
-
throw new Error(
|
|
77
|
+
throw new Error("SummaryModule 需要 shopStore 插件支持");
|
|
53
78
|
}
|
|
54
|
-
|
|
55
|
-
// 如果有传 cacheid,默认需要收集上面这些模块里用户操作选中的数据
|
|
56
|
-
// 并且在上面 registerModule 的时候,读取 sessionStroage 里的数据,塞进默认值
|
|
57
79
|
let targetCacheData = {};
|
|
58
|
-
this.cacheId = this.otherParams
|
|
59
|
-
this.platform = this.otherParams
|
|
60
|
-
if (this.otherParams
|
|
80
|
+
this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
|
|
81
|
+
this.platform = (_b = this.otherParams) == null ? void 0 : _b.platform;
|
|
82
|
+
if ((_c = this.otherParams) == null ? void 0 : _c.cacheId) {
|
|
61
83
|
const sessionData = this.window.sessionStorage.getItem(this.name);
|
|
62
84
|
if (sessionData) {
|
|
63
85
|
const data = JSON.parse(sessionData);
|
|
64
|
-
// 匹配 cacheid,如果匹配不到,直接把 sessionData 清掉即可
|
|
65
|
-
// 如果匹配到了,则把 sessionData 里的数据按模块塞到 store 里去
|
|
66
86
|
targetCacheData = data[this.otherParams.cacheId];
|
|
67
|
-
this.otherData = data[this.otherParams.cacheId]
|
|
87
|
+
this.otherData = ((_e = (_d = data[this.otherParams.cacheId]) == null ? void 0 : _d[this.name]) == null ? void 0 : _e["otherData"]) || {};
|
|
68
88
|
}
|
|
69
89
|
}
|
|
70
|
-
const moduleArr = [
|
|
71
|
-
|
|
72
|
-
|
|
90
|
+
const moduleArr = [
|
|
91
|
+
"accountList",
|
|
92
|
+
"holder",
|
|
93
|
+
"cart",
|
|
94
|
+
"schedule",
|
|
95
|
+
"summary",
|
|
96
|
+
"step",
|
|
97
|
+
"products",
|
|
98
|
+
"date",
|
|
99
|
+
"order"
|
|
100
|
+
];
|
|
101
|
+
moduleArr.forEach((step) => {
|
|
102
|
+
var _a2, _b2;
|
|
103
|
+
const targetModule = (0, import_types.createModule)(step, this.name);
|
|
73
104
|
if (targetModule) {
|
|
74
105
|
this.store[step] = targetModule;
|
|
75
106
|
this.core.registerModule(targetModule, {
|
|
76
|
-
initialState: targetCacheData
|
|
107
|
+
initialState: targetCacheData == null ? void 0 : targetCacheData[targetModule.name],
|
|
77
108
|
otherParams: {
|
|
78
109
|
...this.otherParams,
|
|
79
110
|
fatherModule: this.name,
|
|
80
|
-
openCache: this.otherParams
|
|
81
|
-
cacheId: this.otherParams
|
|
111
|
+
openCache: ((_a2 = this.otherParams) == null ? void 0 : _a2.cacheId) ? true : false,
|
|
112
|
+
cacheId: (_b2 = this.otherParams) == null ? void 0 : _b2.cacheId
|
|
82
113
|
}
|
|
83
114
|
});
|
|
84
115
|
} else {
|
|
@@ -98,7 +129,6 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
98
129
|
step: this.store.step.getCurrentStep()
|
|
99
130
|
};
|
|
100
131
|
}
|
|
101
|
-
|
|
102
132
|
// step: 下一个
|
|
103
133
|
next() {
|
|
104
134
|
this.store.step.nextStep();
|
|
@@ -107,38 +137,32 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
107
137
|
back() {
|
|
108
138
|
this.store.step.prevStep();
|
|
109
139
|
}
|
|
110
|
-
|
|
111
140
|
// 跳转到指定步骤
|
|
112
141
|
gotoStep(index) {
|
|
113
142
|
this.store.step.gotoStep(index);
|
|
114
143
|
}
|
|
115
|
-
|
|
116
144
|
// 获取所有step
|
|
117
145
|
getStepList() {
|
|
118
146
|
return this.store.step.getStepList();
|
|
119
147
|
}
|
|
120
|
-
|
|
121
148
|
/**
|
|
122
149
|
* 添加step
|
|
123
150
|
*/
|
|
124
151
|
addStep(step, key) {
|
|
125
152
|
this.store.step.addStep(step, key);
|
|
126
153
|
}
|
|
127
|
-
|
|
128
154
|
/**
|
|
129
155
|
* 删除step
|
|
130
156
|
*/
|
|
131
157
|
removeStep(key) {
|
|
132
158
|
this.store.step.removeStep(key);
|
|
133
159
|
}
|
|
134
|
-
|
|
135
160
|
/**
|
|
136
161
|
* 更新step
|
|
137
162
|
*/
|
|
138
163
|
updateStep(key, step) {
|
|
139
164
|
this.store.step.updateStep(key, step);
|
|
140
165
|
}
|
|
141
|
-
|
|
142
166
|
/**
|
|
143
167
|
*
|
|
144
168
|
* 加载商品,然后导到商品列表里去
|
|
@@ -169,15 +193,13 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
169
193
|
schedule_date,
|
|
170
194
|
cacheId: this.cacheId
|
|
171
195
|
});
|
|
172
|
-
// 预拉取当天的资源数据
|
|
173
196
|
this.getAvailableDate({
|
|
174
|
-
startDate: schedule_date || (0,
|
|
175
|
-
endDate: schedule_date || (0,
|
|
197
|
+
startDate: schedule_date || (0, import_dayjs.default)().format("YYYY-MM-DD"),
|
|
198
|
+
endDate: schedule_date || (0, import_dayjs.default)().format("YYYY-MM-DD"),
|
|
176
199
|
products: [...res]
|
|
177
200
|
});
|
|
178
201
|
return res;
|
|
179
202
|
}
|
|
180
|
-
|
|
181
203
|
/**
|
|
182
204
|
* 通过 schedule 来读取商品,适用于 session 类商品
|
|
183
205
|
*
|
|
@@ -198,40 +220,21 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
198
220
|
product_ids = [],
|
|
199
221
|
category_ids = []
|
|
200
222
|
}) {
|
|
223
|
+
var _a;
|
|
201
224
|
const scheduleList = this.store.schedule.getAvailabilityScheduleDateList();
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
date,
|
|
205
|
-
|
|
206
|
-
week: '',
|
|
207
|
-
weekNum: 0
|
|
208
|
-
}, {
|
|
209
|
-
date,
|
|
210
|
-
status: 'available',
|
|
211
|
-
week: '',
|
|
212
|
-
weekNum: 0
|
|
213
|
-
}]);
|
|
225
|
+
this.setDateRange([
|
|
226
|
+
{ date, status: "available", week: "", weekNum: 0 },
|
|
227
|
+
{ date, status: "available", week: "", weekNum: 0 }
|
|
228
|
+
]);
|
|
214
229
|
let newProductIds = [];
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
// .flatMap((n) => n.schedule_id)
|
|
218
|
-
// .filter((n) => n !== null && n !== undefined);
|
|
219
|
-
|
|
220
|
-
// 如果外面没传 product_ids,尝试从对应 schedule 里拿 product_ids
|
|
221
|
-
// if (!product_ids?.length) {
|
|
222
|
-
// const schedule = scheduleList.find((n) => n.date === date);
|
|
223
|
-
// if (schedule && schedule.product_ids?.length) {
|
|
224
|
-
// product_ids = schedule.product_ids;
|
|
225
|
-
// }
|
|
226
|
-
// }
|
|
227
|
-
// V2接口修改后,只能从schedule 接口里拿数据,不可以从外面拿,外面给的是装修数据
|
|
228
|
-
const schedule = scheduleList.find(n => n.date === date);
|
|
229
|
-
if (schedule && schedule.product_ids?.length) {
|
|
230
|
+
const schedule = scheduleList.find((n) => n.date === date);
|
|
231
|
+
if (schedule && ((_a = schedule.product_ids) == null ? void 0 : _a.length)) {
|
|
230
232
|
newProductIds = schedule.product_ids;
|
|
231
233
|
}
|
|
232
|
-
// 尝试去拿schedule 里的 other_product_ids 和 product_ids 拼在一起去重
|
|
233
234
|
const otherProductsIds = this.store.schedule.getOtherProductsIds() || [];
|
|
234
|
-
const allProductIds = [...newProductIds, ...otherProductsIds].filter(
|
|
235
|
+
const allProductIds = [...newProductIds, ...otherProductsIds].filter(
|
|
236
|
+
(n, index, self) => self.indexOf(n) === index
|
|
237
|
+
);
|
|
235
238
|
const res = await this.loadProducts({
|
|
236
239
|
product_ids: allProductIds,
|
|
237
240
|
category_ids,
|
|
@@ -239,7 +242,6 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
239
242
|
});
|
|
240
243
|
return res;
|
|
241
244
|
}
|
|
242
|
-
|
|
243
245
|
/**
|
|
244
246
|
* 更新完商品数据、切换日期、或者在较后的流程里登录了,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
|
|
245
247
|
*
|
|
@@ -247,25 +249,34 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
247
249
|
* @memberof BookingByStepImpl
|
|
248
250
|
*/
|
|
249
251
|
async updateQuotationPriceAndCart(date) {
|
|
252
|
+
var _a;
|
|
250
253
|
const cartItems = this.store.cart.getItems();
|
|
251
254
|
if (cartItems.length) {
|
|
252
|
-
let userPlugin = this.core.getPlugin(
|
|
253
|
-
let customer_id =
|
|
255
|
+
let userPlugin = this.core.getPlugin("user");
|
|
256
|
+
let customer_id = void 0;
|
|
254
257
|
try {
|
|
255
|
-
customer_id = userPlugin
|
|
258
|
+
customer_id = (_a = userPlugin == null ? void 0 : userPlugin.get()) == null ? void 0 : _a.id;
|
|
256
259
|
} catch (error) {
|
|
257
260
|
console.error(error);
|
|
258
261
|
}
|
|
259
262
|
const res = await this.store.products.loadProductsPrice({
|
|
260
|
-
ids: cartItems.map(n => n.id),
|
|
263
|
+
ids: cartItems.map((n) => n.id),
|
|
261
264
|
schedule_date: date,
|
|
262
265
|
customer_id
|
|
263
266
|
});
|
|
264
|
-
await (0,
|
|
265
|
-
|
|
267
|
+
await (0, import_changePrice.updateAllCartItemPrice)(
|
|
268
|
+
cartItems,
|
|
269
|
+
res,
|
|
270
|
+
(id) => this.store.products.getProduct(id),
|
|
271
|
+
(params) => this.store.cart.updateItem(params),
|
|
272
|
+
(params) => this.store.cart.updateItemInitInfo(params)
|
|
273
|
+
);
|
|
274
|
+
this.core.effects.emit(
|
|
275
|
+
`${this.store.cart.name}:onUpdateQuotationPrice`,
|
|
276
|
+
{}
|
|
277
|
+
);
|
|
266
278
|
}
|
|
267
279
|
}
|
|
268
|
-
|
|
269
280
|
/**
|
|
270
281
|
* ui 层提供日期的起始范围,返回一个起始范围内日期的可用情况
|
|
271
282
|
* 适用于先选日期的流程,确定日期是否可用
|
|
@@ -292,36 +303,36 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
292
303
|
channel
|
|
293
304
|
});
|
|
294
305
|
}
|
|
295
|
-
|
|
296
306
|
// 添加单个账户或者 guest
|
|
297
307
|
async addAccount(account, extra) {
|
|
298
|
-
|
|
299
|
-
if (extra?.type === 'holder') {
|
|
308
|
+
if ((extra == null ? void 0 : extra.type) === "holder") {
|
|
300
309
|
const accountModules = await this.store.accountList.addHolderAccounts({
|
|
301
310
|
holders: [account],
|
|
302
311
|
customerId: extra.customerId,
|
|
303
|
-
type:
|
|
312
|
+
type: "unshift"
|
|
304
313
|
});
|
|
305
314
|
return accountModules[0].getAccount();
|
|
306
315
|
}
|
|
307
|
-
const newAccount = await this.store.accountList.addAccount(
|
|
316
|
+
const newAccount = await this.store.accountList.addAccount(
|
|
317
|
+
account
|
|
318
|
+
);
|
|
308
319
|
return newAccount.getAccount();
|
|
309
320
|
}
|
|
310
|
-
|
|
311
321
|
// 添加账户或者 guest
|
|
312
322
|
async addAccounts(accounts, extra) {
|
|
313
|
-
|
|
314
|
-
if (extra?.type === 'holder') {
|
|
323
|
+
if ((extra == null ? void 0 : extra.type) === "holder") {
|
|
315
324
|
this.store.accountList.addHolderAccounts({
|
|
316
325
|
holders: accounts,
|
|
317
326
|
customerId: extra.customerId,
|
|
318
|
-
type:
|
|
327
|
+
type: "unshift"
|
|
319
328
|
});
|
|
320
329
|
return;
|
|
321
330
|
}
|
|
322
331
|
const res = [];
|
|
323
332
|
for (const account of accounts) {
|
|
324
|
-
const accountModule = await this.store.accountList.addAccount(
|
|
333
|
+
const accountModule = await this.store.accountList.addAccount(
|
|
334
|
+
account
|
|
335
|
+
);
|
|
325
336
|
const accountData = accountModule.getAccount();
|
|
326
337
|
if (accountData) {
|
|
327
338
|
res.push(accountData);
|
|
@@ -329,77 +340,70 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
329
340
|
}
|
|
330
341
|
return res;
|
|
331
342
|
}
|
|
332
|
-
|
|
333
343
|
// 获取所有账户
|
|
334
344
|
async getAccounts() {
|
|
335
345
|
const accounts = this.store.accountList.getAccounts();
|
|
336
|
-
return accounts.map(account => account.getAccount());
|
|
346
|
+
return accounts.map((account) => account.getAccount());
|
|
337
347
|
}
|
|
338
348
|
checkHasLoginAccount() {
|
|
339
349
|
const accounts = this.store.accountList.getAccounts();
|
|
340
|
-
return accounts.some(account => account.getLoginStatus());
|
|
350
|
+
return accounts.some((account) => account.getLoginStatus());
|
|
341
351
|
}
|
|
342
352
|
setActiveAccount(id) {
|
|
343
353
|
this.store.accountList.setActiveAccount(id);
|
|
344
354
|
}
|
|
345
355
|
getActiveAccount() {
|
|
346
356
|
const activeAccount = this.store.accountList.getActiveAccount();
|
|
347
|
-
const account = activeAccount
|
|
348
|
-
return account === null ?
|
|
357
|
+
const account = activeAccount == null ? void 0 : activeAccount.getAccount();
|
|
358
|
+
return account === null ? void 0 : account;
|
|
349
359
|
}
|
|
350
360
|
removeAccount(id) {
|
|
351
361
|
this.store.accountList.removeAccount(id);
|
|
352
|
-
// 还需要把对应账号的商品给她删了
|
|
353
362
|
this.clearCartByAccount(id);
|
|
354
363
|
}
|
|
355
|
-
|
|
356
364
|
/**
|
|
357
365
|
* 获取holder类型账户列表
|
|
358
366
|
* @param params
|
|
359
367
|
*/
|
|
360
368
|
async fetchHolderAccountsAsync(params) {
|
|
369
|
+
var _a, _b;
|
|
361
370
|
const cartItems = this.store.cart.getItems();
|
|
362
371
|
if (cartItems.length) {
|
|
363
|
-
let date = this.store.date.getDateRange()
|
|
372
|
+
let date = (_b = (_a = this.store.date.getDateRange()) == null ? void 0 : _a[0]) == null ? void 0 : _b.date;
|
|
364
373
|
if (!date) {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
date = normalProductCartItem
|
|
374
|
+
const normalProductCartItem = cartItems.find(
|
|
375
|
+
(n) => !(0, import_utils5.isNormalProduct)(n._productOrigin)
|
|
376
|
+
);
|
|
377
|
+
date = (normalProductCartItem == null ? void 0 : normalProductCartItem.start_date) || "";
|
|
369
378
|
}
|
|
370
379
|
this.updateQuotationPriceAndCart(date);
|
|
371
380
|
}
|
|
372
381
|
return this.store.accountList.fetchHolderAccounts(params);
|
|
373
382
|
}
|
|
374
|
-
|
|
375
383
|
/**
|
|
376
384
|
* 获取 holder 表单 map
|
|
377
385
|
*/
|
|
378
386
|
getHolderFormMap() {
|
|
379
387
|
return this.store.holder.getHolderFormMap();
|
|
380
388
|
}
|
|
381
|
-
|
|
382
389
|
/**
|
|
383
390
|
* 登录后或外部触发时,按当前 holderMap 批量刷新所有表单的 records
|
|
384
391
|
*/
|
|
385
392
|
async refreshAllHolderFormRecords(params) {
|
|
386
393
|
return this.store.holder.refreshAllFormRecords({
|
|
387
|
-
customer_id: params
|
|
394
|
+
customer_id: params == null ? void 0 : params.customer_id,
|
|
388
395
|
useCache: false
|
|
389
396
|
});
|
|
390
397
|
}
|
|
391
|
-
|
|
392
398
|
/**
|
|
393
399
|
* 添加表单记录
|
|
394
400
|
*/
|
|
395
401
|
appendFormRecord(params) {
|
|
396
402
|
return this.store.holder.appendFormRecord(params);
|
|
397
403
|
}
|
|
398
|
-
|
|
399
404
|
// 设置日期范围,注入到日期模块中
|
|
400
405
|
async setDateRange(dateRange) {
|
|
401
406
|
this.store.date.setDateRange(dateRange);
|
|
402
|
-
// 日期数据变更后,如果购物车里有数据,需要更新购物车里的报价单的价格
|
|
403
407
|
if (dateRange.length && this.store.cart.getItems().length) {
|
|
404
408
|
this.updateQuotationPriceAndCart(dateRange[0].date);
|
|
405
409
|
}
|
|
@@ -407,7 +411,6 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
407
411
|
clearDateRange() {
|
|
408
412
|
this.store.date.clearDateRange();
|
|
409
413
|
}
|
|
410
|
-
|
|
411
414
|
// 获取日期模块里选中的日期
|
|
412
415
|
async getDateRange() {
|
|
413
416
|
return this.store.date.getDateRange();
|
|
@@ -415,50 +418,37 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
415
418
|
getCart() {
|
|
416
419
|
return this.store.cart.getItems();
|
|
417
420
|
}
|
|
418
|
-
|
|
419
421
|
// 获取商品/服务的可用日期
|
|
420
422
|
async getAvailableDate(params = {}) {
|
|
421
|
-
|
|
422
|
-
let {
|
|
423
|
-
|
|
424
|
-
startDate,
|
|
425
|
-
endDate,
|
|
426
|
-
type,
|
|
427
|
-
useCache = true
|
|
428
|
-
} = params;
|
|
429
|
-
// 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
|
|
430
|
-
if ((0, _dayjs.default)(startDate).isBefore((0, _dayjs.default)(), 'day') && ((0, _dayjs.default)(endDate).isAfter((0, _dayjs.default)(), 'day') || (0, _dayjs.default)(endDate).isSame((0, _dayjs.default)(), 'day'))) {
|
|
431
|
-
startDate = (0, _dayjs.default)().format('YYYY-MM-DD');
|
|
423
|
+
var _a, _b, _c, _d;
|
|
424
|
+
let { products, startDate, endDate, type, useCache = true } = params;
|
|
425
|
+
if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day") && ((0, import_dayjs.default)(endDate).isAfter((0, import_dayjs.default)(), "day") || (0, import_dayjs.default)(endDate).isSame((0, import_dayjs.default)(), "day"))) {
|
|
426
|
+
startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
432
427
|
}
|
|
433
|
-
let tempProducts = products || this.store.cart.getItems().map(p => p._productOrigin);
|
|
428
|
+
let tempProducts = products || this.store.cart.getItems().map((p) => p._productOrigin);
|
|
434
429
|
if (tempProducts.length) {
|
|
435
|
-
tempProducts.forEach(p => {
|
|
436
|
-
if (p
|
|
437
|
-
const scheduleData = this.getScheduleDataByIds(p[
|
|
438
|
-
p[
|
|
430
|
+
tempProducts.forEach((p) => {
|
|
431
|
+
if (p == null ? void 0 : p["schedule.ids"]) {
|
|
432
|
+
const scheduleData = this.getScheduleDataByIds(p["schedule.ids"]);
|
|
433
|
+
p["_schedule"] = scheduleData;
|
|
439
434
|
}
|
|
440
435
|
});
|
|
441
436
|
}
|
|
442
|
-
// 如果当前打开了某个的商品详情弹窗,则应该默认用这个商品
|
|
443
437
|
if (this.store.currentProduct) {
|
|
444
|
-
tempProducts = [
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
438
|
+
tempProducts = [
|
|
439
|
+
{
|
|
440
|
+
...this.store.currentProduct,
|
|
441
|
+
_schedule: (_a = this.store.currentProductMeta) == null ? void 0 : _a["schedule"]
|
|
442
|
+
}
|
|
443
|
+
];
|
|
448
444
|
}
|
|
449
445
|
let dateRange = this.store.date.getDateRange();
|
|
450
|
-
const tempStartDate = startDate || dateRange
|
|
451
|
-
const tempEndDate = endDate || dateRange
|
|
446
|
+
const tempStartDate = startDate || ((_b = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _b.date);
|
|
447
|
+
const tempEndDate = endDate || ((_c = dateRange == null ? void 0 : dateRange[1]) == null ? void 0 : _c.date) || ((_d = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _d.date);
|
|
452
448
|
if (!tempProducts.length) {
|
|
453
449
|
return [];
|
|
454
450
|
}
|
|
455
|
-
|
|
456
|
-
// 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
|
|
457
|
-
const {
|
|
458
|
-
resourceIds,
|
|
459
|
-
rules,
|
|
460
|
-
resourcesMap
|
|
461
|
-
} = (0, _products.getAvailableProductResources)(tempProducts) || {};
|
|
451
|
+
const { resourceIds, rules, resourcesMap } = (0, import_products.getAvailableProductResources)(tempProducts) || {};
|
|
462
452
|
this.otherParams.currentResourcesMap = resourcesMap;
|
|
463
453
|
const res = await this.store.date.getResourceDates({
|
|
464
454
|
url: params.url,
|
|
@@ -473,7 +463,6 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
473
463
|
});
|
|
474
464
|
return res;
|
|
475
465
|
}
|
|
476
|
-
|
|
477
466
|
/**
|
|
478
467
|
* 获取购物车汇总信息
|
|
479
468
|
*/
|
|
@@ -482,29 +471,26 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
482
471
|
const summary = await this.store.summary.getSummary(cartItems);
|
|
483
472
|
return summary;
|
|
484
473
|
}
|
|
485
|
-
|
|
486
474
|
/**
|
|
487
475
|
* 获取协议
|
|
488
476
|
*/
|
|
489
477
|
async getProtocol(protocolId) {
|
|
490
478
|
return this.store.summary.getProtocol(protocolId);
|
|
491
479
|
}
|
|
492
|
-
|
|
493
480
|
// 获取可选择的商品、服务列表
|
|
494
481
|
async getProducts() {
|
|
495
482
|
return this.store.products.getProducts();
|
|
496
483
|
}
|
|
497
|
-
|
|
498
484
|
// 如果用户登录
|
|
499
485
|
async setLoginAccount(accountId, accountInfo) {
|
|
486
|
+
var _a, _b;
|
|
500
487
|
const account = this.store.accountList.getAccount(accountId);
|
|
501
488
|
if (account) {
|
|
502
489
|
let stateAccountId = account.getId();
|
|
503
490
|
accountInfo.isLogin = true;
|
|
504
491
|
account.setAccountInfo(accountInfo);
|
|
505
|
-
// 然后去购物车,把原先关联了 holder_id 为 accountId 的商品,替换为 holder_id = accountInfo.id
|
|
506
492
|
const cartItems = this.store.cart.getItems();
|
|
507
|
-
cartItems.forEach(item => {
|
|
493
|
+
cartItems.forEach((item) => {
|
|
508
494
|
if (item.holder_id === accountId) {
|
|
509
495
|
this.store.cart.updateItem({
|
|
510
496
|
_id: item._id,
|
|
@@ -514,39 +500,35 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
514
500
|
});
|
|
515
501
|
this.store.accountList.updateAccountListById(stateAccountId, accountInfo);
|
|
516
502
|
if (cartItems.length) {
|
|
517
|
-
let date = this.store.date.getDateRange()
|
|
503
|
+
let date = (_b = (_a = this.store.date.getDateRange()) == null ? void 0 : _a[0]) == null ? void 0 : _b.date;
|
|
518
504
|
if (!date) {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
date = normalProductCartItem
|
|
505
|
+
const normalProductCartItem = cartItems.find(
|
|
506
|
+
(n) => !(0, import_utils5.isNormalProduct)(n._productOrigin)
|
|
507
|
+
);
|
|
508
|
+
date = (normalProductCartItem == null ? void 0 : normalProductCartItem.start_date) || "";
|
|
523
509
|
}
|
|
524
510
|
this.updateQuotationPriceAndCart(date);
|
|
525
|
-
|
|
526
|
-
// 登录后刷新 holder 表单
|
|
527
511
|
try {
|
|
528
512
|
const customerId = Number(accountInfo.id);
|
|
529
513
|
await this.refreshAllHolderFormRecords({
|
|
530
514
|
customer_id: customerId
|
|
531
515
|
});
|
|
532
516
|
} catch (error) {
|
|
533
|
-
console.error(
|
|
517
|
+
console.error("[BookingByStep] 登录后刷新 holder 表单失败", error);
|
|
534
518
|
}
|
|
535
519
|
}
|
|
536
520
|
} else {
|
|
537
521
|
throw new Error(`没有找到${accountId}账户`);
|
|
538
522
|
}
|
|
539
523
|
}
|
|
540
|
-
|
|
541
524
|
// 生成购物车的正规数据
|
|
542
|
-
async generateCartData() {
|
|
543
|
-
|
|
525
|
+
async generateCartData() {
|
|
526
|
+
}
|
|
544
527
|
// 免费领取商品相关逻辑,上线了来不及加了,先放在这,后面要做到 payment 里面的
|
|
545
528
|
async getFreeProduct(id) {
|
|
546
529
|
const res = await this.request.post(`/pay/order/free-pay/${id}`);
|
|
547
530
|
return res;
|
|
548
531
|
}
|
|
549
|
-
|
|
550
532
|
/**
|
|
551
533
|
* 检查购物车提交订单前是否符合条件
|
|
552
534
|
* @param type 类型 "holder" | "account"
|
|
@@ -558,71 +540,61 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
558
540
|
cartItems: this.store.cart.getItems()
|
|
559
541
|
});
|
|
560
542
|
}
|
|
561
|
-
|
|
562
543
|
// 购物车提交订单
|
|
563
544
|
async submitOrder(extraData) {
|
|
545
|
+
var _a;
|
|
564
546
|
const cartItems = this.store.cart.getItems();
|
|
565
|
-
const newCartItems = (0,
|
|
566
|
-
|
|
567
|
-
|
|
547
|
+
const newCartItems = (0, import_lodash_es.cloneDeep)(cartItems);
|
|
548
|
+
newCartItems.forEach((item) => {
|
|
549
|
+
var _a2;
|
|
568
550
|
if (item._origin.resources && item._origin.resources.length) {
|
|
569
|
-
item._origin.resources = item._origin.resources.map(n => {
|
|
570
|
-
const newResourcesItem = (0,
|
|
551
|
+
item._origin.resources = item._origin.resources.map((n) => {
|
|
552
|
+
const newResourcesItem = (0, import_lodash_es.cloneDeep)(n);
|
|
571
553
|
delete newResourcesItem.id;
|
|
572
554
|
delete newResourcesItem.main_field;
|
|
573
555
|
delete newResourcesItem.resourceType;
|
|
574
|
-
return {
|
|
575
|
-
...newResourcesItem
|
|
576
|
-
};
|
|
556
|
+
return { ...newResourcesItem };
|
|
577
557
|
});
|
|
578
|
-
const {
|
|
579
|
-
|
|
580
|
-
formatCapacity
|
|
581
|
-
} = (0, _capacity.getCapacityInfoByCartItem)(item);
|
|
582
|
-
if (!item._origin?.metadata) {
|
|
558
|
+
const { currentCapacity, formatCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(item);
|
|
559
|
+
if (!((_a2 = item._origin) == null ? void 0 : _a2.metadata)) {
|
|
583
560
|
item._origin.metadata = {};
|
|
584
561
|
}
|
|
585
562
|
item._origin.metadata.capacity = formatCapacity;
|
|
586
563
|
item._origin.number = currentCapacity;
|
|
587
564
|
}
|
|
588
565
|
});
|
|
589
|
-
let type = this.otherParams.isRetailTemplate ?
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
566
|
+
let type = this.otherParams.isRetailTemplate ? "virtual" : "appointment_booking";
|
|
567
|
+
if ((0, import_utils5.areAllNormalProducts)(
|
|
568
|
+
newCartItems.map((n) => n._productOrigin)
|
|
569
|
+
)) {
|
|
570
|
+
type = "virtual";
|
|
593
571
|
}
|
|
594
572
|
return this.store.order.submitOrder({
|
|
595
573
|
query: {
|
|
596
574
|
cartItems: newCartItems,
|
|
597
575
|
type,
|
|
598
576
|
platform: this.platform,
|
|
599
|
-
business_code: this.otherParams
|
|
577
|
+
business_code: (_a = this.otherParams) == null ? void 0 : _a.business_code,
|
|
600
578
|
extraData
|
|
601
579
|
}
|
|
602
580
|
});
|
|
603
581
|
}
|
|
604
|
-
|
|
605
582
|
// 拉起支付模块
|
|
606
|
-
async pay() {
|
|
607
|
-
|
|
583
|
+
async pay() {
|
|
584
|
+
}
|
|
608
585
|
// 获取支付信息
|
|
609
|
-
async getPayInfo() {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
} = {}) {
|
|
586
|
+
async getPayInfo() {
|
|
587
|
+
}
|
|
588
|
+
async setOtherParams(params, { cover = false } = {}) {
|
|
613
589
|
if (cover) {
|
|
614
590
|
this.otherParams = params;
|
|
615
591
|
} else {
|
|
616
|
-
this.otherParams = {
|
|
617
|
-
...this.otherParams,
|
|
618
|
-
...params
|
|
619
|
-
};
|
|
592
|
+
this.otherParams = { ...this.otherParams, ...params };
|
|
620
593
|
}
|
|
621
594
|
}
|
|
622
595
|
async getOtherParams() {
|
|
623
596
|
return this.otherParams;
|
|
624
597
|
}
|
|
625
|
-
|
|
626
598
|
/**
|
|
627
599
|
* 往购物车加商品数据(duration 类、普通商品)
|
|
628
600
|
* 老接口,先不删,怕 UI 有问题,直接桥接到新接口addProductToCart上
|
|
@@ -631,15 +603,12 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
631
603
|
* @memberof BookingByStepImpl
|
|
632
604
|
*/
|
|
633
605
|
storeProduct(productData) {
|
|
634
|
-
// 往购物车加商品数据的时候,默认用当前 activeAccount 填充到 product 的 account 里面
|
|
635
606
|
const activeAccount = this.getActiveAccount();
|
|
636
|
-
// 直接调用 addProductToCart,不传递 date 参数以避免日期检查逻辑
|
|
637
607
|
return this.addProductToCart({
|
|
638
608
|
product: productData,
|
|
639
609
|
account: activeAccount
|
|
640
610
|
});
|
|
641
611
|
}
|
|
642
|
-
|
|
643
612
|
/**
|
|
644
613
|
* 往购物车加商品数据
|
|
645
614
|
*
|
|
@@ -668,31 +637,20 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
668
637
|
rowKey,
|
|
669
638
|
quantity = 1
|
|
670
639
|
} = product || {};
|
|
671
|
-
const productData = {
|
|
672
|
-
|
|
673
|
-
product_variant_id
|
|
674
|
-
};
|
|
675
|
-
// 保护,如果进来的是 session 商品,则必须要有 date 和时间片,否则不允许添加
|
|
676
|
-
if ((0, _products.isSessionProduct)(productData)) {
|
|
640
|
+
const productData = { ...origin, product_variant_id };
|
|
641
|
+
if ((0, import_products.isSessionProduct)(productData)) {
|
|
677
642
|
if (!date || !date.startTime || !date.endTime) {
|
|
678
|
-
return {
|
|
679
|
-
success: false,
|
|
680
|
-
errorCode: 'date_or_time_required'
|
|
681
|
-
};
|
|
643
|
+
return { success: false, errorCode: "date_or_time_required" };
|
|
682
644
|
}
|
|
683
645
|
}
|
|
684
|
-
|
|
685
|
-
// 库存检测
|
|
686
646
|
const currentCartItems = this.store.cart.getItems();
|
|
687
|
-
const stockCheckResult = (0,
|
|
647
|
+
const stockCheckResult = (0, import_stock.checkProductStock)({
|
|
688
648
|
productData,
|
|
689
649
|
product_variant_id,
|
|
690
650
|
quantity,
|
|
691
651
|
bundle,
|
|
692
652
|
currentCartItems
|
|
693
653
|
});
|
|
694
|
-
|
|
695
|
-
// 如果库存检测失败,直接返回
|
|
696
654
|
if (!stockCheckResult.success) {
|
|
697
655
|
return stockCheckResult;
|
|
698
656
|
}
|
|
@@ -705,21 +663,19 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
705
663
|
try {
|
|
706
664
|
this.store.holder.ensureFormByProduct({
|
|
707
665
|
product: productData,
|
|
708
|
-
shop_id: productData
|
|
666
|
+
shop_id: (productData == null ? void 0 : productData.shop_id) || "",
|
|
709
667
|
useCache: true
|
|
710
668
|
});
|
|
711
669
|
} catch (error) {
|
|
712
|
-
console.error(
|
|
670
|
+
console.error("[BookingByStep] 加载 holder 表单失败", error);
|
|
713
671
|
}
|
|
714
672
|
const flag = this.store.cart.mergeCartItemByRowKey({
|
|
715
673
|
rowKey,
|
|
716
674
|
quantity,
|
|
717
|
-
account: account ||
|
|
675
|
+
account: account || void 0
|
|
718
676
|
});
|
|
719
677
|
if (flag) {
|
|
720
|
-
return {
|
|
721
|
-
success: true
|
|
722
|
-
};
|
|
678
|
+
return { success: true };
|
|
723
679
|
}
|
|
724
680
|
const addItemParams = {
|
|
725
681
|
product: productData,
|
|
@@ -733,24 +689,18 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
733
689
|
if (account) {
|
|
734
690
|
addItemParams.account = account;
|
|
735
691
|
}
|
|
736
|
-
this.addProductCheck({
|
|
737
|
-
|
|
738
|
-
});
|
|
739
|
-
// 如果 quantity 大于 1,且是预约商品,则进入购物车拆散成多条数据
|
|
740
|
-
if (addItemParams.quantity > 1 && !(0, _utils5.isNormalProduct)(productData)) {
|
|
692
|
+
this.addProductCheck({ date });
|
|
693
|
+
if (addItemParams.quantity > 1 && !(0, import_utils5.isNormalProduct)(productData)) {
|
|
741
694
|
for (let i = 0; i < addItemParams.quantity; i++) {
|
|
742
|
-
const newAddItemParams = (0,
|
|
695
|
+
const newAddItemParams = (0, import_lodash_es.cloneDeep)(addItemParams);
|
|
743
696
|
newAddItemParams.quantity = 1;
|
|
744
697
|
this.store.cart.addItem(newAddItemParams);
|
|
745
698
|
}
|
|
746
699
|
} else {
|
|
747
700
|
this.store.cart.addItem(addItemParams);
|
|
748
701
|
}
|
|
749
|
-
return {
|
|
750
|
-
success: true
|
|
751
|
-
};
|
|
702
|
+
return { success: true };
|
|
752
703
|
}
|
|
753
|
-
|
|
754
704
|
/**
|
|
755
705
|
* 添加完购物车以后做的一些检测,比如日期是否在同一天
|
|
756
706
|
*
|
|
@@ -760,38 +710,28 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
760
710
|
addProductCheck({
|
|
761
711
|
date
|
|
762
712
|
}) {
|
|
763
|
-
// 检测,有传递 date,检查购物车里其他商品的 date 是否在同一天,如果不在,清空那些不在同一天的商品
|
|
764
713
|
if (date) {
|
|
765
|
-
const cartItems = this.store.cart.getItems().filter(n => !(0,
|
|
766
|
-
const cartItemsByDate = cartItems.filter(
|
|
714
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
715
|
+
const cartItemsByDate = cartItems.filter(
|
|
716
|
+
(n) => !(0, import_dayjs.default)(n.start_date).isSame((0, import_dayjs.default)(date.startTime), "day")
|
|
717
|
+
);
|
|
767
718
|
if (cartItemsByDate.length) {
|
|
768
|
-
cartItemsByDate.forEach(n => {
|
|
719
|
+
cartItemsByDate.forEach((n) => {
|
|
769
720
|
this.store.cart.removeItem(n._id);
|
|
770
721
|
});
|
|
771
722
|
}
|
|
772
|
-
// // 如果 date.startTime 和 dateRange 里的 startTime 不一样,需要修正 dateRange
|
|
773
|
-
// const dateRange = this.store.date.getDateRange()
|
|
774
|
-
// if (dateRange?.[0] && !dayjs(dateRange[0].date).isSame(dayjs(date.startTime), 'day')) {
|
|
775
|
-
// this.setDateRange([
|
|
776
|
-
// { date: dayjs(date.startTime).format('YYYY-MM-DD'), status: 'available', week: '', weekNum: 0 },
|
|
777
|
-
// { date: dayjs(date.endTime).format('YYYY-MM-DD'), status: 'available', week: '', weekNum: 0 },
|
|
778
|
-
// ]);
|
|
779
|
-
// }
|
|
780
723
|
}
|
|
781
724
|
}
|
|
782
725
|
beforeUpdateCart(params, targetCartItem) {
|
|
783
726
|
if (params.resources) {
|
|
784
|
-
const {
|
|
785
|
-
|
|
786
|
-
} = (0, _capacity.getCapacityInfoByCartItem)(targetCartItem);
|
|
787
|
-
params.resources = params.resources.map(n => {
|
|
727
|
+
const { currentCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(targetCartItem);
|
|
728
|
+
params.resources = params.resources.map((n) => {
|
|
788
729
|
n.capacity = currentCapacity || 1;
|
|
789
|
-
(0,
|
|
730
|
+
(0, import_capacity.checkSubResourcesCapacity)(n);
|
|
790
731
|
return n;
|
|
791
732
|
});
|
|
792
733
|
}
|
|
793
734
|
}
|
|
794
|
-
|
|
795
735
|
// 更新购物车
|
|
796
736
|
updateCart(params) {
|
|
797
737
|
const targetCartItem = this.store.cart.getItem(params._id);
|
|
@@ -802,7 +742,6 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
802
742
|
this.store.cart.updateItem(params);
|
|
803
743
|
this.updateCartCheck(params, targetCartItem);
|
|
804
744
|
}
|
|
805
|
-
|
|
806
745
|
/**
|
|
807
746
|
* 更新购物车以后的一些操作,比如检测资源是否重复,检测资源容量是否足够
|
|
808
747
|
*
|
|
@@ -812,59 +751,63 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
812
751
|
* @memberof BookingByStepImpl
|
|
813
752
|
*/
|
|
814
753
|
updateCartCheck(params, targetCartItem) {
|
|
815
|
-
|
|
754
|
+
var _a;
|
|
816
755
|
if (this.otherParams.isRetailTemplate) {
|
|
817
756
|
return;
|
|
818
757
|
}
|
|
819
758
|
let currentResourcesCapacityMap = {};
|
|
820
|
-
params.resources
|
|
759
|
+
(_a = params.resources) == null ? void 0 : _a.forEach((n) => {
|
|
821
760
|
currentResourcesCapacityMap[n.id] = n.capacity;
|
|
822
761
|
});
|
|
823
762
|
const allOriginResources = [];
|
|
824
763
|
const dateRange = this.store.date.getDateRange();
|
|
825
|
-
if (dateRange
|
|
826
|
-
dateRange.forEach(n => {
|
|
827
|
-
if (n.resource)
|
|
764
|
+
if (dateRange == null ? void 0 : dateRange.length) {
|
|
765
|
+
dateRange.forEach((n) => {
|
|
766
|
+
if (n.resource)
|
|
767
|
+
allOriginResources.push(...n.resource);
|
|
828
768
|
});
|
|
829
769
|
}
|
|
830
|
-
// 如果此时 resources 为空,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
|
|
831
770
|
if (!allOriginResources.length) {
|
|
832
771
|
const dateList = this.store.date.getDateList();
|
|
833
|
-
dateList
|
|
834
|
-
if (n.resource)
|
|
772
|
+
dateList == null ? void 0 : dateList.forEach((n) => {
|
|
773
|
+
if (n.resource)
|
|
774
|
+
allOriginResources.push(...n.resource);
|
|
835
775
|
});
|
|
836
776
|
}
|
|
837
|
-
// 只有在更新资源的时候做这个判断,其他情况下不做处理
|
|
838
777
|
if (params.resources) {
|
|
839
|
-
// 更新购物车后,需要判定购物车里是否存在多个账号选择了相同资源的情况,如果是,且资源是单个预约,则要把选择了相同资源的 product._origin.resources 给去除
|
|
840
778
|
const cartItems = this.store.cart.getItems();
|
|
841
|
-
cartItems.forEach(item => {
|
|
779
|
+
cartItems.forEach((item) => {
|
|
780
|
+
var _a2;
|
|
842
781
|
if (item._id !== targetCartItem._id) {
|
|
843
|
-
const {
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
if (!sameFormIdResources?.length) {
|
|
782
|
+
const { currentCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(item);
|
|
783
|
+
const resources = (_a2 = item._origin.resources) == null ? void 0 : _a2.filter((m) => {
|
|
784
|
+
const sameFormIdResources = (0, import_resources.filterResourcesByFormItem)(
|
|
785
|
+
targetCartItem._origin.resources,
|
|
786
|
+
m.form_id
|
|
787
|
+
);
|
|
788
|
+
if (!(sameFormIdResources == null ? void 0 : sameFormIdResources.length)) {
|
|
851
789
|
return true;
|
|
852
790
|
}
|
|
853
|
-
return !sameFormIdResources.some(targetRes => {
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
791
|
+
return !sameFormIdResources.some((targetRes) => {
|
|
792
|
+
if (targetRes.resourceType !== "single") {
|
|
793
|
+
const originResource = allOriginResources.find(
|
|
794
|
+
(n) => n.id === targetRes.id
|
|
795
|
+
);
|
|
796
|
+
const canUse = (0, import_capacity.checkResourceCanUseByCapacity)(
|
|
797
|
+
currentResourcesCapacityMap[m.id] || 0,
|
|
798
|
+
currentCapacity,
|
|
799
|
+
originResource == null ? void 0 : originResource.capacity
|
|
800
|
+
);
|
|
801
|
+
if (canUse)
|
|
802
|
+
currentResourcesCapacityMap[m.id] += currentCapacity;
|
|
859
803
|
return !canUse;
|
|
860
804
|
}
|
|
861
|
-
if (item.holder_id !== targetCartItem
|
|
862
|
-
return (0,
|
|
805
|
+
if (item.holder_id !== (targetCartItem == null ? void 0 : targetCartItem.holder_id)) {
|
|
806
|
+
return (0, import_resources.checkTwoResourcesIntersection)(targetRes, m);
|
|
863
807
|
}
|
|
864
808
|
return false;
|
|
865
809
|
});
|
|
866
810
|
});
|
|
867
|
-
// session 类商品应该只调用清空 resource 的方法
|
|
868
811
|
if (item.start_time) {
|
|
869
812
|
const start_time = item.start_time;
|
|
870
813
|
const end_time = item.end_time;
|
|
@@ -874,8 +817,12 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
874
817
|
_id: item._id,
|
|
875
818
|
resources,
|
|
876
819
|
date: {
|
|
877
|
-
startTime: (0,
|
|
878
|
-
|
|
820
|
+
startTime: (0, import_dayjs.default)(`${start_date} ${start_time}`).format(
|
|
821
|
+
"YYYY-MM-DD HH:mm"
|
|
822
|
+
),
|
|
823
|
+
endTime: (0, import_dayjs.default)(`${end_date} ${end_time}`).format(
|
|
824
|
+
"YYYY-MM-DD HH:mm"
|
|
825
|
+
)
|
|
879
826
|
}
|
|
880
827
|
});
|
|
881
828
|
} else {
|
|
@@ -888,34 +835,29 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
888
835
|
});
|
|
889
836
|
}
|
|
890
837
|
}
|
|
891
|
-
|
|
892
838
|
// 删除购物车里某个商品
|
|
893
839
|
deleteCart(cartItemId) {
|
|
894
840
|
this.store.cart.removeItem(cartItemId);
|
|
895
841
|
}
|
|
896
|
-
|
|
897
842
|
// 清空购物车
|
|
898
843
|
clearCart() {
|
|
899
844
|
this.store.cart.clear();
|
|
900
845
|
}
|
|
901
|
-
|
|
902
846
|
// 基于账户清空购物车
|
|
903
847
|
clearCartByAccount(account_id) {
|
|
904
848
|
this.store.cart.clearCartByAccount(account_id);
|
|
905
849
|
}
|
|
906
|
-
|
|
907
850
|
/**
|
|
908
851
|
* 批量更新购物车
|
|
909
852
|
*/
|
|
910
853
|
batchUpdateCart(paramsList) {
|
|
911
854
|
const cartItems = [];
|
|
912
|
-
paramsList.forEach(params => {
|
|
855
|
+
paramsList.forEach((params) => {
|
|
913
856
|
const cartItem = this.store.cart.formatCartItem(params);
|
|
914
857
|
cartItems.push(cartItem);
|
|
915
858
|
});
|
|
916
859
|
this.store.cart.batchSetItems(cartItems);
|
|
917
860
|
}
|
|
918
|
-
|
|
919
861
|
/**
|
|
920
862
|
* 从购物车中按类别删除信息
|
|
921
863
|
*/
|
|
@@ -925,17 +867,15 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
925
867
|
checkCartItemByType(cartItem, type) {
|
|
926
868
|
return this.store.cart.checkCartItemByType(cartItem, type);
|
|
927
869
|
}
|
|
928
|
-
|
|
929
870
|
/**
|
|
930
871
|
* 检查购物车商品是否符合条件
|
|
931
872
|
* @param type 类型
|
|
932
873
|
* @returns 不符合条件的购物车商品ID列表
|
|
933
874
|
*/
|
|
934
875
|
checkCartItems(type) {
|
|
935
|
-
|
|
936
|
-
const cartItems = this.store.cart.getItems().filter(n => !(0, _utils5.isNormalProduct)(n._productOrigin));
|
|
876
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
937
877
|
const errorCartItemIds = [];
|
|
938
|
-
cartItems.forEach(cartItem => {
|
|
878
|
+
cartItems.forEach((cartItem) => {
|
|
939
879
|
const result = this.store.cart.checkCartItemByType(cartItem, type);
|
|
940
880
|
if (!result) {
|
|
941
881
|
errorCartItemIds.push(cartItem._id);
|
|
@@ -944,120 +884,129 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
944
884
|
return errorCartItemIds;
|
|
945
885
|
}
|
|
946
886
|
destroy() {
|
|
947
|
-
|
|
948
|
-
this.store.
|
|
949
|
-
this.store.
|
|
950
|
-
this.store.
|
|
951
|
-
this.store.
|
|
952
|
-
this.store.
|
|
953
|
-
this.store.
|
|
954
|
-
this.store.summary?.destroy();
|
|
955
|
-
this.store.order?.destroy();
|
|
887
|
+
var _a, _b, _c, _d, _e, _f;
|
|
888
|
+
(_a = this.store.cart) == null ? void 0 : _a.destroy();
|
|
889
|
+
(_b = this.store.step) == null ? void 0 : _b.destroy();
|
|
890
|
+
(_c = this.store.products) == null ? void 0 : _c.destroy();
|
|
891
|
+
(_d = this.store.guests) == null ? void 0 : _d.destroy();
|
|
892
|
+
(_e = this.store.date) == null ? void 0 : _e.destroy();
|
|
893
|
+
(_f = this.store.accountList) == null ? void 0 : _f.destroy();
|
|
956
894
|
this.core.effects.offByModuleDestroy(this.name);
|
|
957
895
|
this.core.unregisterModule(this);
|
|
958
896
|
}
|
|
959
|
-
|
|
960
897
|
// 获取当前购物车内所有关联的资源列表,拼装数据格式
|
|
961
898
|
getResourcesList() {
|
|
962
899
|
const dateRange = this.store.date.getDateRange();
|
|
963
900
|
const resources = [];
|
|
964
|
-
if (dateRange
|
|
965
|
-
dateRange.forEach(n => {
|
|
966
|
-
if (n.resource)
|
|
901
|
+
if (dateRange == null ? void 0 : dateRange.length) {
|
|
902
|
+
dateRange.forEach((n) => {
|
|
903
|
+
if (n.resource)
|
|
904
|
+
resources.push(...n.resource);
|
|
967
905
|
});
|
|
968
906
|
}
|
|
969
|
-
const cartItems = this.store.cart.getItems().filter(n => !(0,
|
|
970
|
-
|
|
971
|
-
// 如果此时 resources 为空,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
|
|
907
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
972
908
|
if (!resources.length) {
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
909
|
+
const firstDateCartItem = cartItems == null ? void 0 : cartItems.find((n) => n.start_date);
|
|
910
|
+
if (firstDateCartItem == null ? void 0 : firstDateCartItem.start_date) {
|
|
911
|
+
const dateResources = this.store.date.getResourcesListByDate(
|
|
912
|
+
firstDateCartItem.start_date
|
|
913
|
+
);
|
|
914
|
+
resources.push(...dateResources || []);
|
|
978
915
|
} else {
|
|
979
916
|
const dateList = this.store.date.getDateList();
|
|
980
|
-
dateList
|
|
981
|
-
if (n.resource)
|
|
917
|
+
dateList == null ? void 0 : dateList.forEach((n) => {
|
|
918
|
+
if (n.resource)
|
|
919
|
+
resources.push(...n.resource);
|
|
982
920
|
});
|
|
983
921
|
}
|
|
984
922
|
}
|
|
985
|
-
const resourcesMap = (0,
|
|
923
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
986
924
|
const arr = [];
|
|
987
|
-
cartItems.forEach(cartItem => {
|
|
925
|
+
cartItems.forEach((cartItem) => {
|
|
926
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
988
927
|
let selectedResources = [];
|
|
989
|
-
const {
|
|
990
|
-
currentCapacity,
|
|
991
|
-
formatCapacity
|
|
992
|
-
} = (0, _capacity.getCapacityInfoByCartItem)(cartItem);
|
|
928
|
+
const { currentCapacity, formatCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(cartItem);
|
|
993
929
|
cartItem._origin.metadata.capacity = formatCapacity;
|
|
994
930
|
if (cartItem.holder_id) {
|
|
995
|
-
selectedResources = (0,
|
|
931
|
+
selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
932
|
+
cartItems,
|
|
933
|
+
cartItem.holder_id,
|
|
934
|
+
resourcesMap
|
|
935
|
+
);
|
|
996
936
|
} else {
|
|
997
|
-
selectedResources = (0,
|
|
937
|
+
selectedResources = (0, import_resources.getOthersCartSelectedResources)(
|
|
938
|
+
cartItems,
|
|
939
|
+
cartItem._id,
|
|
940
|
+
resourcesMap
|
|
941
|
+
);
|
|
998
942
|
}
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
943
|
+
const productResources = (0, import_resources.getResourcesByProduct)(
|
|
944
|
+
resourcesMap,
|
|
945
|
+
((_b = (_a = cartItem._productOrigin) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) || [],
|
|
946
|
+
selectedResources,
|
|
947
|
+
currentCapacity
|
|
948
|
+
);
|
|
1002
949
|
if (cartItem._origin.start_time) {
|
|
1003
|
-
const startTime = (0,
|
|
1004
|
-
|
|
950
|
+
const startTime = (0, import_dayjs.default)(
|
|
951
|
+
`${cartItem._origin.start_date} ${cartItem._origin.start_time}`
|
|
952
|
+
);
|
|
953
|
+
const endTime = (0, import_dayjs.default)(
|
|
954
|
+
`${cartItem._origin.end_date} ${cartItem._origin.end_time}`
|
|
955
|
+
);
|
|
1005
956
|
const resourcesUseableMap = {};
|
|
1006
|
-
productResources.forEach(n => {
|
|
1007
|
-
|
|
1008
|
-
n.renderList =
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
957
|
+
productResources.forEach((n) => {
|
|
958
|
+
n.renderList = (0, import_resources.sortCombinedResources)(n.renderList);
|
|
959
|
+
n.renderList = n.renderList.filter((m) => {
|
|
960
|
+
const mTimes = (0, import_timeslots.filterConditionTimeSlots)(
|
|
961
|
+
m.times,
|
|
962
|
+
startTime,
|
|
963
|
+
endTime
|
|
964
|
+
);
|
|
1015
965
|
if (mTimes.length === 0) {
|
|
1016
966
|
return false;
|
|
1017
967
|
}
|
|
1018
|
-
const canUseArr = mTimes.map(item => {
|
|
1019
|
-
|
|
968
|
+
const canUseArr = mTimes.map((item) => {
|
|
969
|
+
var _a2;
|
|
970
|
+
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
1020
971
|
timeSlice: {
|
|
1021
|
-
start_time: startTime.format(
|
|
1022
|
-
end_time: endTime.format(
|
|
972
|
+
start_time: startTime.format("HH:mm"),
|
|
973
|
+
end_time: endTime.format("HH:mm"),
|
|
1023
974
|
start_at: startTime,
|
|
1024
975
|
end_at: endTime
|
|
1025
976
|
},
|
|
1026
977
|
time: item,
|
|
1027
978
|
resource: m,
|
|
1028
979
|
currentCount: currentCapacity || 0,
|
|
1029
|
-
resourcesUseableMap
|
|
1030
|
-
cut_off_time: cartItem._productOrigin
|
|
980
|
+
resourcesUseableMap,
|
|
981
|
+
cut_off_time: (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.cut_off_time
|
|
1031
982
|
});
|
|
1032
|
-
|
|
1033
|
-
if (resourcesUseableMap?.[m.id] !== false && res.reason !== 'capacityOnly') {
|
|
983
|
+
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
1034
984
|
resourcesUseableMap[m.id] = res.usable;
|
|
1035
985
|
}
|
|
1036
986
|
return res.usable;
|
|
1037
987
|
});
|
|
1038
|
-
if (m.onlyComputed)
|
|
1039
|
-
|
|
1040
|
-
return !canUseArr.some(
|
|
988
|
+
if (m.onlyComputed)
|
|
989
|
+
return false;
|
|
990
|
+
return !canUseArr.some((n2) => n2 === false);
|
|
1041
991
|
});
|
|
1042
992
|
});
|
|
1043
993
|
} else {
|
|
1044
|
-
const hasFlexibleDuration = cartItem._productOrigin
|
|
1045
|
-
const operating_day_boundary = this.shopStore.get(
|
|
1046
|
-
const maxBlockThreshold = cartItem._productOrigin
|
|
1047
|
-
productResources.forEach(item => {
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
item.renderList = item.renderList.filter(n => {
|
|
994
|
+
const hasFlexibleDuration = ((_d = (_c = cartItem._productOrigin) == null ? void 0 : _c.duration) == null ? void 0 : _d.type) === "flexible";
|
|
995
|
+
const operating_day_boundary = (_f = (_e = this.shopStore.get("core")) == null ? void 0 : _e.core) == null ? void 0 : _f.operating_day_boundary;
|
|
996
|
+
const maxBlockThreshold = ((_i = (_h = (_g = cartItem._productOrigin) == null ? void 0 : _g.duration) == null ? void 0 : _h.flexible_config) == null ? void 0 : _i.is_enable_minimum_duration) ? ((_l = (_k = (_j = cartItem._productOrigin) == null ? void 0 : _j.duration) == null ? void 0 : _k.flexible_config) == null ? void 0 : _l.block_threshold) || 0 : 0;
|
|
997
|
+
productResources.forEach((item) => {
|
|
998
|
+
item.renderList = item.renderList.filter((n) => {
|
|
999
|
+
var _a2, _b2, _c2;
|
|
1051
1000
|
const recordCount = n.capacity || 0;
|
|
1052
|
-
if (n.onlyComputed)
|
|
1053
|
-
|
|
1054
|
-
const timeSlots = (0,
|
|
1001
|
+
if (n.onlyComputed)
|
|
1002
|
+
return false;
|
|
1003
|
+
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
1055
1004
|
resource: n,
|
|
1056
|
-
duration: cartItem._productOrigin
|
|
1005
|
+
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
|
|
1057
1006
|
split: 10,
|
|
1058
1007
|
currentDate: dateRange[0].date,
|
|
1059
1008
|
hasFlexibleDuration,
|
|
1060
|
-
cut_off_time: cartItem._productOrigin
|
|
1009
|
+
cut_off_time: (_c2 = cartItem._productOrigin) == null ? void 0 : _c2.cut_off_time,
|
|
1061
1010
|
operating_day_boundary,
|
|
1062
1011
|
maxBlockThreshold
|
|
1063
1012
|
});
|
|
@@ -1078,7 +1027,6 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1078
1027
|
});
|
|
1079
1028
|
return arr;
|
|
1080
1029
|
}
|
|
1081
|
-
|
|
1082
1030
|
/**
|
|
1083
1031
|
* 在日期那边点击下一步的时候,检查这一天购物车里的商品是不是都有资源可以用
|
|
1084
1032
|
*
|
|
@@ -1087,12 +1035,11 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1087
1035
|
*/
|
|
1088
1036
|
checkResourceListForDate() {
|
|
1089
1037
|
const resourcesList = this.getResourcesList();
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1038
|
+
const hasResource = resourcesList.every(
|
|
1039
|
+
(item) => item.resources.every((resource) => resource.renderList.length > 0)
|
|
1040
|
+
);
|
|
1093
1041
|
return hasResource;
|
|
1094
1042
|
}
|
|
1095
|
-
|
|
1096
1043
|
/**
|
|
1097
1044
|
* 给单个购物车里的商品获取资源列表,给 UI 用的
|
|
1098
1045
|
*
|
|
@@ -1101,32 +1048,45 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1101
1048
|
* @memberof BookingByStepImpl
|
|
1102
1049
|
*/
|
|
1103
1050
|
getResourcesListByCartItem(id) {
|
|
1104
|
-
|
|
1051
|
+
var _a, _b;
|
|
1052
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
1105
1053
|
const dateRange = this.store.date.getDateRange();
|
|
1106
1054
|
const resources = [];
|
|
1107
|
-
dateRange.forEach(n => {
|
|
1108
|
-
if (n.resource)
|
|
1055
|
+
dateRange.forEach((n) => {
|
|
1056
|
+
if (n.resource)
|
|
1057
|
+
resources.push(...n.resource);
|
|
1109
1058
|
});
|
|
1110
|
-
|
|
1111
|
-
const
|
|
1112
|
-
const targetCartItem = cartItems.find(n => n._id === id);
|
|
1059
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)(resources);
|
|
1060
|
+
const targetCartItem = cartItems.find((n) => n._id === id);
|
|
1113
1061
|
if (!targetCartItem) {
|
|
1114
1062
|
throw new Error(`没有找到${id}购物车商品`);
|
|
1115
1063
|
}
|
|
1116
1064
|
let selectedResources = [];
|
|
1117
|
-
const {
|
|
1118
|
-
currentCapacity
|
|
1119
|
-
} = (0, _capacity.getCapacityInfoByCartItem)(targetCartItem);
|
|
1065
|
+
const { currentCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(targetCartItem);
|
|
1120
1066
|
if (targetCartItem.holder_id) {
|
|
1121
|
-
selectedResources = (0,
|
|
1067
|
+
selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
1068
|
+
cartItems,
|
|
1069
|
+
targetCartItem.holder_id,
|
|
1070
|
+
resourcesMap
|
|
1071
|
+
);
|
|
1122
1072
|
} else {
|
|
1123
|
-
selectedResources = (0,
|
|
1073
|
+
selectedResources = (0, import_resources.getOthersCartSelectedResources)(
|
|
1074
|
+
cartItems,
|
|
1075
|
+
targetCartItem._id,
|
|
1076
|
+
resourcesMap
|
|
1077
|
+
);
|
|
1124
1078
|
}
|
|
1125
|
-
const productResources = (0,
|
|
1126
|
-
|
|
1127
|
-
|
|
1079
|
+
const productResources = (0, import_resources.getResourcesByProduct)(
|
|
1080
|
+
resourcesMap,
|
|
1081
|
+
((_b = (_a = targetCartItem._productOrigin) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) || [],
|
|
1082
|
+
selectedResources,
|
|
1083
|
+
currentCapacity
|
|
1084
|
+
);
|
|
1085
|
+
productResources.forEach((item) => {
|
|
1086
|
+
item.renderList = item.renderList.filter((n) => {
|
|
1128
1087
|
const recordCount = n.capacity || 0;
|
|
1129
|
-
if (n.onlyComputed)
|
|
1088
|
+
if (n.onlyComputed)
|
|
1089
|
+
return false;
|
|
1130
1090
|
return recordCount >= currentCapacity;
|
|
1131
1091
|
});
|
|
1132
1092
|
});
|
|
@@ -1143,7 +1103,6 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1143
1103
|
};
|
|
1144
1104
|
}
|
|
1145
1105
|
}
|
|
1146
|
-
|
|
1147
1106
|
// 自动分派可用资源-pro 版,ui 传递某个账号,自动给某个账号下所有商品分配第一种资源
|
|
1148
1107
|
autoSelectAccountResources({
|
|
1149
1108
|
cartItem,
|
|
@@ -1153,111 +1112,109 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1153
1112
|
countMap,
|
|
1154
1113
|
capacity
|
|
1155
1114
|
}) {
|
|
1156
|
-
|
|
1115
|
+
var _a, _b, _c;
|
|
1116
|
+
if ((0, import_utils5.isNormalProduct)(cartItem._productOrigin)) {
|
|
1157
1117
|
return {};
|
|
1158
1118
|
}
|
|
1159
1119
|
const dateRange = this.store.date.getDateRange();
|
|
1160
|
-
const cartItems = (0,
|
|
1161
|
-
|
|
1162
|
-
let accountCartItems = cartItems.filter(n => n.holder_id === holder_id) || [];
|
|
1163
|
-
// 账号下没商品则处理所有购物车
|
|
1120
|
+
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1121
|
+
let accountCartItems = cartItems.filter((n) => n.holder_id === holder_id) || [];
|
|
1164
1122
|
if (!accountCartItems.length) {
|
|
1165
1123
|
accountCartItems = cartItems;
|
|
1166
1124
|
}
|
|
1167
|
-
// duration=所有商品时间的集合,如果是灵活时长,当做占用 10 分钟处理
|
|
1168
1125
|
let duration = accountCartItems.reduce((acc, n) => {
|
|
1169
|
-
|
|
1126
|
+
var _a2, _b2;
|
|
1127
|
+
return acc + (((_b2 = (_a2 = n._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10);
|
|
1170
1128
|
}, 0);
|
|
1171
1129
|
let AllResources = [];
|
|
1172
|
-
if (dateRange
|
|
1173
|
-
dateRange.forEach(n => {
|
|
1174
|
-
if (n.resource)
|
|
1130
|
+
if (dateRange == null ? void 0 : dateRange.length) {
|
|
1131
|
+
dateRange.forEach((n) => {
|
|
1132
|
+
if (n.resource)
|
|
1133
|
+
AllResources.push(...n.resource);
|
|
1175
1134
|
});
|
|
1176
1135
|
}
|
|
1177
|
-
// 如果此时 resources 为空,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
|
|
1178
1136
|
if (!AllResources.length) {
|
|
1179
|
-
const firstDateCartItem = cartItems
|
|
1180
|
-
if (firstDateCartItem
|
|
1181
|
-
const dateResources = this.store.date.getResourcesListByDate(
|
|
1182
|
-
|
|
1137
|
+
const firstDateCartItem = cartItems == null ? void 0 : cartItems.find((n) => n.start_date);
|
|
1138
|
+
if (firstDateCartItem == null ? void 0 : firstDateCartItem.start_date) {
|
|
1139
|
+
const dateResources = this.store.date.getResourcesListByDate(
|
|
1140
|
+
firstDateCartItem.start_date
|
|
1141
|
+
);
|
|
1142
|
+
AllResources.push(...dateResources || []);
|
|
1183
1143
|
} else {
|
|
1184
1144
|
const dateList = this.store.date.getDateList();
|
|
1185
|
-
dateList.forEach(n => {
|
|
1186
|
-
if (n.resource)
|
|
1145
|
+
dateList.forEach((n) => {
|
|
1146
|
+
if (n.resource)
|
|
1147
|
+
AllResources.push(...n.resource);
|
|
1187
1148
|
});
|
|
1188
1149
|
}
|
|
1189
1150
|
}
|
|
1190
|
-
const resourcesMap = (0,
|
|
1191
|
-
const allCartItems = (0,
|
|
1192
|
-
const selectedResources = (0,
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1151
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)((0, import_lodash_es.cloneDeep)(AllResources));
|
|
1152
|
+
const allCartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1153
|
+
const selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
1154
|
+
allCartItems,
|
|
1155
|
+
holder_id,
|
|
1156
|
+
resourcesMap
|
|
1157
|
+
);
|
|
1158
|
+
let allProductResources = (0, import_resources.getResourcesByProduct)(
|
|
1159
|
+
resourcesMap,
|
|
1160
|
+
((_b = (_a = cartItem._productOrigin) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) || [],
|
|
1161
|
+
selectedResources,
|
|
1162
|
+
1
|
|
1163
|
+
);
|
|
1164
|
+
const resources = ((_c = allProductResources.find((n) => n.code === resources_code)) == null ? void 0 : _c.renderList) || [];
|
|
1196
1165
|
resources.sort((a, b) => {
|
|
1197
|
-
|
|
1198
|
-
const
|
|
1199
|
-
|
|
1200
|
-
if (
|
|
1166
|
+
var _a2, _b2, _c2, _d;
|
|
1167
|
+
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
1168
|
+
const bIsCombined = ((_d = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
1169
|
+
if (aIsCombined && !bIsCombined)
|
|
1170
|
+
return 1;
|
|
1171
|
+
if (!aIsCombined && bIsCombined)
|
|
1172
|
+
return -1;
|
|
1201
1173
|
return 0;
|
|
1202
1174
|
});
|
|
1203
|
-
const resourcesUseableMap = [
|
|
1204
|
-
|
|
1175
|
+
const resourcesUseableMap = [
|
|
1176
|
+
...selectedResources
|
|
1177
|
+
].reduce((acc, n) => {
|
|
1178
|
+
var _a2;
|
|
1179
|
+
acc[n] = ((_a2 = resourcesMap[n]) == null ? void 0 : _a2.resourceType) === "single" ? false : true;
|
|
1205
1180
|
return acc;
|
|
1206
1181
|
}, {});
|
|
1207
|
-
|
|
1208
|
-
// 如果有选择时间了,则代表不是第一种资源了,则需要根据开始时间去匹配
|
|
1209
|
-
// 每个商品
|
|
1210
1182
|
if (timeSlots) {
|
|
1211
|
-
// const start_time = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
1212
|
-
// const end_time = dayjs(`${dateRange[0].date} ${timeSlots.start_time}`)
|
|
1213
|
-
// .add(duration, durationType as dayjs.ManipulateType)
|
|
1214
|
-
// .format("HH:mm");
|
|
1215
|
-
// 根据 start_time 和 end_time 去匹配资源
|
|
1216
1183
|
let targetResource = null;
|
|
1217
1184
|
let targetResourceTime = 0;
|
|
1218
1185
|
for (const n of resources) {
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
// resourcesUseableMap[n.id] = false;
|
|
1222
|
-
// continue
|
|
1223
|
-
// }
|
|
1224
|
-
// const recordCount = countMap[n.id] || 0;
|
|
1225
|
-
// n.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
|
|
1226
|
-
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
1227
|
-
// 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
|
|
1228
|
-
const mTimes = n.times.filter(n => {
|
|
1229
|
-
return !(0, _dayjs.default)(n.start_at).isAfter((0, _dayjs.default)(timeSlots.start_at)) && !(0, _dayjs.default)(n.end_at).isBefore((0, _dayjs.default)(timeSlots.end_at));
|
|
1186
|
+
const mTimes = n.times.filter((n2) => {
|
|
1187
|
+
return !(0, import_dayjs.default)(n2.start_at).isAfter((0, import_dayjs.default)(timeSlots.start_at)) && !(0, import_dayjs.default)(n2.end_at).isBefore((0, import_dayjs.default)(timeSlots.end_at));
|
|
1230
1188
|
});
|
|
1231
|
-
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
1232
1189
|
if (mTimes.length === 0) {
|
|
1233
1190
|
continue;
|
|
1234
1191
|
}
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
if (n.resourceType ===
|
|
1192
|
+
const totalCapacity = (countMap[n.id] || []).reduce(
|
|
1193
|
+
(sum, item) => {
|
|
1194
|
+
const hasOverlap = (0, import_dayjs.default)(item.time.start_at).isBefore((0, import_dayjs.default)(timeSlots.end_at)) && (0, import_dayjs.default)(item.time.end_at).isAfter((0, import_dayjs.default)(timeSlots.start_at));
|
|
1195
|
+
return hasOverlap ? sum + item.pax : sum;
|
|
1196
|
+
},
|
|
1197
|
+
0
|
|
1198
|
+
);
|
|
1199
|
+
if (n.resourceType === "single" && totalCapacity > 0) {
|
|
1243
1200
|
continue;
|
|
1244
1201
|
}
|
|
1245
|
-
const canUseTime = mTimes.find(item => {
|
|
1246
|
-
|
|
1202
|
+
const canUseTime = mTimes.find((item) => {
|
|
1203
|
+
var _a2;
|
|
1204
|
+
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
1247
1205
|
timeSlice: timeSlots,
|
|
1248
1206
|
time: item,
|
|
1249
1207
|
resource: n,
|
|
1250
1208
|
currentCount: totalCapacity + (capacity || 0),
|
|
1251
1209
|
resourcesUseableMap,
|
|
1252
|
-
cut_off_time: cartItem._productOrigin
|
|
1210
|
+
cut_off_time: (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.cut_off_time
|
|
1253
1211
|
});
|
|
1254
|
-
|
|
1255
|
-
if (resourcesUseableMap?.[n.id] !== false && res.reason !== 'capacityOnly') {
|
|
1212
|
+
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== "capacityOnly") {
|
|
1256
1213
|
resourcesUseableMap[n.id] = res.usable;
|
|
1257
1214
|
}
|
|
1258
1215
|
return res.usable;
|
|
1259
1216
|
});
|
|
1260
|
-
const currentResourceIdleTime = (0,
|
|
1217
|
+
const currentResourceIdleTime = (0, import_timeslots.calculateResourceAvailableTime)({
|
|
1261
1218
|
resource: n,
|
|
1262
1219
|
timeSlots,
|
|
1263
1220
|
currentCapacity: totalCapacity + (capacity || 0)
|
|
@@ -1272,82 +1229,79 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1272
1229
|
selectedResource: targetResource
|
|
1273
1230
|
};
|
|
1274
1231
|
} else {
|
|
1275
|
-
const
|
|
1276
|
-
const resourceIds = resources.map(n => n.id);
|
|
1277
|
-
const
|
|
1232
|
+
const resourcesMap2 = (0, import_utils2.getResourcesMap)(resources);
|
|
1233
|
+
const resourceIds = resources.map((n) => n.id);
|
|
1234
|
+
const timeSlots2 = (0, import_resources.getTimeSlicesByResources)({
|
|
1278
1235
|
resourceIds,
|
|
1279
|
-
resourcesMap,
|
|
1236
|
+
resourcesMap: resourcesMap2,
|
|
1280
1237
|
duration,
|
|
1281
1238
|
currentDate: dateRange[0].date,
|
|
1282
1239
|
split: 10,
|
|
1283
1240
|
capacity,
|
|
1284
1241
|
resourcesUseableMap
|
|
1285
1242
|
});
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
return; // 给一个提示?
|
|
1243
|
+
if (!timeSlots2) {
|
|
1244
|
+
return;
|
|
1289
1245
|
}
|
|
1290
1246
|
return {
|
|
1291
|
-
timeSlots,
|
|
1247
|
+
timeSlots: timeSlots2,
|
|
1292
1248
|
selectedResource: resources[0]
|
|
1293
1249
|
};
|
|
1294
1250
|
}
|
|
1295
1251
|
}
|
|
1296
|
-
|
|
1297
1252
|
// 给所有购物车里的商品先分配一个资源
|
|
1298
1253
|
autoSelectAllProductResources(resources_code, timeSlots) {
|
|
1254
|
+
var _a;
|
|
1299
1255
|
const dateRange = this.store.date.getDateRange();
|
|
1300
1256
|
const resources = [];
|
|
1301
|
-
if (dateRange
|
|
1302
|
-
dateRange.forEach(n => {
|
|
1303
|
-
if (n.resource)
|
|
1257
|
+
if ((_a = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _a.date) {
|
|
1258
|
+
dateRange.forEach((n) => {
|
|
1259
|
+
if (n.resource)
|
|
1260
|
+
resources.push(...n.resource);
|
|
1304
1261
|
});
|
|
1305
1262
|
}
|
|
1306
|
-
// 一个账号一个账号处理
|
|
1307
1263
|
const errorList = [];
|
|
1308
|
-
// 资源使用情况-单个预约
|
|
1309
1264
|
const selectResourcesMap = {};
|
|
1310
|
-
// 资源使用情况-多个预约
|
|
1311
1265
|
const selectResourcesWithTimeSlots = {};
|
|
1312
1266
|
const accountList = this.store.accountList.getAccounts();
|
|
1313
|
-
const selectForCartResources =
|
|
1314
|
-
let recordTimeSlots = (0,
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
} = (0,
|
|
1324
|
-
const hasOriginTimeSlot = Boolean(item._origin.start_time) && Boolean(item._origin.end_time) && !timeSlots
|
|
1325
|
-
// 如果商品已经有时间数据了,意味着是通过先选日期再选商品流程进来的,相当于时间切片已经选中了
|
|
1267
|
+
const selectForCartResources = (cartItems2) => {
|
|
1268
|
+
let recordTimeSlots = (0, import_lodash_es.cloneDeep)(timeSlots);
|
|
1269
|
+
const hasFlexibleProduct = cartItems2.some(
|
|
1270
|
+
(item) => {
|
|
1271
|
+
var _a2, _b;
|
|
1272
|
+
return ((_b = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b.type) === "flexible";
|
|
1273
|
+
}
|
|
1274
|
+
);
|
|
1275
|
+
cartItems2.forEach((item, index) => {
|
|
1276
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
1277
|
+
const { currentCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(item);
|
|
1278
|
+
const hasOriginTimeSlot = Boolean(item._origin.start_time) && Boolean(item._origin.end_time) && !(timeSlots == null ? void 0 : timeSlots.start_time);
|
|
1326
1279
|
if (hasOriginTimeSlot) {
|
|
1327
1280
|
recordTimeSlots = {
|
|
1328
1281
|
start_time: item._origin.start_time,
|
|
1329
1282
|
end_time: item._origin.end_time,
|
|
1330
|
-
start_at: (0,
|
|
1331
|
-
end_at: (0,
|
|
1283
|
+
start_at: (0, import_dayjs.default)(`${item.start_date} ${item._origin.start_time}`),
|
|
1284
|
+
end_at: (0, import_dayjs.default)(`${item.end_date} ${item._origin.end_time}`)
|
|
1332
1285
|
};
|
|
1333
1286
|
}
|
|
1334
1287
|
if (recordTimeSlots) {
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
const recordEndAt = recordTimeSlots.end_at ? (0, _dayjs.default)(recordTimeSlots.end_at) : (0, _dayjs.default)(`${item.start_date} ${recordTimeSlots.end_time}`);
|
|
1288
|
+
const currentResourceConfig = (_c = (_b = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b.resources) == null ? void 0 : _c.find(
|
|
1289
|
+
(n) => n.code === resources_code
|
|
1290
|
+
);
|
|
1291
|
+
if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single" && ((_d = item._productOrigin) == null ? void 0 : _d.duration) && !hasFlexibleProduct && !hasOriginTimeSlot) {
|
|
1292
|
+
const recordEndAt = recordTimeSlots.end_at ? (0, import_dayjs.default)(recordTimeSlots.end_at) : (0, import_dayjs.default)(`${item.start_date} ${recordTimeSlots.end_time}`);
|
|
1341
1293
|
let start_at = recordEndAt;
|
|
1342
|
-
let end_at = start_at.add(
|
|
1294
|
+
let end_at = start_at.add(
|
|
1295
|
+
((_f = (_e = item._productOrigin) == null ? void 0 : _e.duration) == null ? void 0 : _f.value) || 10,
|
|
1296
|
+
"minutes"
|
|
1297
|
+
);
|
|
1343
1298
|
recordTimeSlots = {
|
|
1344
|
-
start_time: start_at.format(
|
|
1345
|
-
end_time: end_at.format(
|
|
1299
|
+
start_time: start_at.format("HH:mm"),
|
|
1300
|
+
end_time: end_at.format("HH:mm"),
|
|
1346
1301
|
start_at,
|
|
1347
1302
|
end_at
|
|
1348
1303
|
};
|
|
1349
1304
|
}
|
|
1350
|
-
// 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
|
|
1351
1305
|
const res = this.autoSelectAccountResources({
|
|
1352
1306
|
cartItem: item,
|
|
1353
1307
|
holder_id: item.holder_id,
|
|
@@ -1356,12 +1310,14 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1356
1310
|
countMap: selectResourcesWithTimeSlots,
|
|
1357
1311
|
capacity: currentCapacity
|
|
1358
1312
|
});
|
|
1359
|
-
if (res
|
|
1313
|
+
if (res == null ? void 0 : res.selectedResource) {
|
|
1360
1314
|
if (!selectResourcesWithTimeSlots[res.selectedResource.id]) {
|
|
1361
|
-
selectResourcesWithTimeSlots[res.selectedResource.id] = [
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1315
|
+
selectResourcesWithTimeSlots[res.selectedResource.id] = [
|
|
1316
|
+
{
|
|
1317
|
+
pax: currentCapacity,
|
|
1318
|
+
time: recordTimeSlots
|
|
1319
|
+
}
|
|
1320
|
+
];
|
|
1365
1321
|
} else {
|
|
1366
1322
|
selectResourcesWithTimeSlots[res.selectedResource.id].push({
|
|
1367
1323
|
pax: currentCapacity,
|
|
@@ -1369,73 +1325,94 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1369
1325
|
});
|
|
1370
1326
|
}
|
|
1371
1327
|
res.selectedResource.capacity = currentCapacity;
|
|
1372
|
-
(0,
|
|
1328
|
+
(0, import_capacity.checkSubResourcesCapacity)(res.selectedResource);
|
|
1373
1329
|
this.store.cart.updateItem({
|
|
1374
1330
|
_id: item._id,
|
|
1375
1331
|
// 这里要做去重,避免出现同样类型的资源被塞进同一个商品
|
|
1376
|
-
resources: [
|
|
1332
|
+
resources: [
|
|
1333
|
+
...(item._origin.resources || []).filter(
|
|
1334
|
+
(existingRes) => {
|
|
1335
|
+
var _a3;
|
|
1336
|
+
return existingRes.form_id !== ((_a3 = res.selectedResource) == null ? void 0 : _a3.form_id);
|
|
1337
|
+
}
|
|
1338
|
+
),
|
|
1339
|
+
res.selectedResource
|
|
1340
|
+
]
|
|
1377
1341
|
});
|
|
1378
1342
|
} else {
|
|
1379
|
-
// 如果没有可用的技师了,推到错误列表里让 UI 去提示
|
|
1380
1343
|
errorList.push(item._id);
|
|
1381
1344
|
}
|
|
1382
1345
|
} else {
|
|
1383
|
-
|
|
1384
|
-
// 能进到这种逻辑,说明是 duration 类商品或者灵活时长商品,且是第一种资源,还没有确定时间
|
|
1385
|
-
const allCartItems = (0, _lodashEs.cloneDeep)(this.store.cart.getItems());
|
|
1386
|
-
// 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
|
|
1346
|
+
const allCartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1387
1347
|
let selectedResources = [];
|
|
1388
|
-
const
|
|
1348
|
+
const resources2 = (0, import_lodash_es.cloneDeep)(
|
|
1349
|
+
((_h = (_g = item._productOrigin) == null ? void 0 : _g.product_resource) == null ? void 0 : _h.resources) || []
|
|
1350
|
+
);
|
|
1389
1351
|
const currentResourcesRenderList = [];
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
n.renderList = n.renderList.filter(m => {
|
|
1394
|
-
|
|
1352
|
+
resources2.forEach((n) => {
|
|
1353
|
+
var _a3;
|
|
1354
|
+
if ((_a3 = n.renderList) == null ? void 0 : _a3.length) {
|
|
1355
|
+
n.renderList = n.renderList.filter((m) => {
|
|
1356
|
+
var _a4;
|
|
1395
1357
|
const recordCount = (m.capacity || 0) - (selectResourcesMap[m.id] || 0);
|
|
1396
|
-
const
|
|
1358
|
+
const timeSlots2 = (0, import_resources.getTimeSlicesByResource)({
|
|
1397
1359
|
resource: m,
|
|
1398
|
-
duration: item
|
|
1360
|
+
duration: ((_a4 = item == null ? void 0 : item.duration) == null ? void 0 : _a4.value) || 10,
|
|
1399
1361
|
split: 10,
|
|
1400
1362
|
currentDate: dateRange[0].date
|
|
1401
1363
|
});
|
|
1402
|
-
return recordCount >= currentCapacity &&
|
|
1364
|
+
return recordCount >= currentCapacity && timeSlots2.length > 0;
|
|
1403
1365
|
});
|
|
1404
|
-
currentResourcesRenderList.push(...
|
|
1366
|
+
currentResourcesRenderList.push(...n.renderList || []);
|
|
1405
1367
|
}
|
|
1406
1368
|
});
|
|
1407
|
-
const resourcesMap = (0,
|
|
1369
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)(currentResourcesRenderList);
|
|
1408
1370
|
if (item.holder_id) {
|
|
1409
|
-
selectedResources = (0,
|
|
1371
|
+
selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
1372
|
+
allCartItems,
|
|
1373
|
+
item.holder_id,
|
|
1374
|
+
resourcesMap
|
|
1375
|
+
);
|
|
1410
1376
|
} else {
|
|
1411
|
-
selectedResources = (0,
|
|
1377
|
+
selectedResources = (0, import_resources.getOthersCartSelectedResources)(
|
|
1378
|
+
allCartItems,
|
|
1379
|
+
item._id,
|
|
1380
|
+
resourcesMap
|
|
1381
|
+
);
|
|
1412
1382
|
}
|
|
1413
|
-
const productResources = (0,
|
|
1414
|
-
|
|
1415
|
-
|
|
1383
|
+
const productResources = (0, import_resources.getResourcesByProduct)(
|
|
1384
|
+
resourcesMap,
|
|
1385
|
+
(0, import_lodash_es.cloneDeep)(resources2),
|
|
1386
|
+
selectedResources,
|
|
1387
|
+
currentCapacity
|
|
1388
|
+
);
|
|
1389
|
+
productResources.forEach((item2) => {
|
|
1390
|
+
item2.renderList = item2.renderList.filter((n) => {
|
|
1416
1391
|
const recordCount = (n.capacity || 0) - (selectResourcesMap[n.id] || 0);
|
|
1417
|
-
if (n.onlyComputed)
|
|
1392
|
+
if (n.onlyComputed)
|
|
1393
|
+
return false;
|
|
1418
1394
|
return recordCount >= currentCapacity;
|
|
1419
1395
|
});
|
|
1420
1396
|
});
|
|
1421
|
-
|
|
1422
|
-
|
|
1397
|
+
const targetRenderList = (_i = productResources.find(
|
|
1398
|
+
(n) => n.code === resources_code
|
|
1399
|
+
)) == null ? void 0 : _i.renderList;
|
|
1423
1400
|
if (targetRenderList && targetRenderList.length > 0) {
|
|
1424
|
-
|
|
1425
|
-
|
|
1401
|
+
if ((_j = item._origin.resources) == null ? void 0 : _j.some(
|
|
1402
|
+
(n) => n.form_id === targetRenderList[0].form_id
|
|
1403
|
+
)) {
|
|
1426
1404
|
return;
|
|
1427
1405
|
}
|
|
1428
|
-
const fastestResource = (0,
|
|
1406
|
+
const fastestResource = (0, import_timeslots.findFastestAvailableResource)({
|
|
1429
1407
|
resources: targetRenderList,
|
|
1430
|
-
currentCapacity
|
|
1408
|
+
currentCapacity,
|
|
1431
1409
|
countMap: selectResourcesMap,
|
|
1432
|
-
targetDate: dateRange
|
|
1433
|
-
durationMinutes: item
|
|
1410
|
+
targetDate: (_k = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _k.date,
|
|
1411
|
+
durationMinutes: ((_l = item == null ? void 0 : item.duration) == null ? void 0 : _l.value) || ((_n = (_m = item == null ? void 0 : item._productOrigin) == null ? void 0 : _m.duration) == null ? void 0 : _n.value) || 10
|
|
1434
1412
|
});
|
|
1435
1413
|
const targetResource = fastestResource || targetRenderList[0];
|
|
1436
1414
|
targetResource.capacity = currentCapacity;
|
|
1437
|
-
|
|
1438
|
-
(0, _capacity.checkSubResourcesCapacity)(targetResource);
|
|
1415
|
+
(0, import_capacity.checkSubResourcesCapacity)(targetResource);
|
|
1439
1416
|
if (!selectResourcesMap[targetResource.id]) {
|
|
1440
1417
|
selectResourcesMap[targetResource.id] = currentCapacity;
|
|
1441
1418
|
} else {
|
|
@@ -1443,107 +1420,101 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1443
1420
|
}
|
|
1444
1421
|
this.store.cart.updateItem({
|
|
1445
1422
|
_id: item._id,
|
|
1446
|
-
resources: [
|
|
1423
|
+
resources: [
|
|
1424
|
+
...(item._origin.resources || []).filter(
|
|
1425
|
+
(existingRes) => existingRes.resourceType !== targetRenderList[0].resourceType
|
|
1426
|
+
),
|
|
1427
|
+
targetResource
|
|
1428
|
+
]
|
|
1447
1429
|
});
|
|
1448
1430
|
} else {
|
|
1449
|
-
// 如果没有可用的技师了,推到错误列表里让 UI 去提示
|
|
1450
1431
|
errorList.push(item._id);
|
|
1451
1432
|
}
|
|
1452
1433
|
}
|
|
1453
1434
|
});
|
|
1454
1435
|
};
|
|
1455
|
-
const cartItems = this.store.cart.getItems().filter(n => !(0,
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
const cartItems = this.store.cart.getCartByAccount(account.getId());
|
|
1461
|
-
selectForCartResources(cartItems);
|
|
1436
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
1437
|
+
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
1438
|
+
accountList.forEach((account) => {
|
|
1439
|
+
const cartItems2 = this.store.cart.getCartByAccount(account.getId());
|
|
1440
|
+
selectForCartResources(cartItems2);
|
|
1462
1441
|
});
|
|
1463
1442
|
} else {
|
|
1464
1443
|
selectForCartResources(cartItems);
|
|
1465
1444
|
}
|
|
1466
|
-
return {
|
|
1467
|
-
errorList
|
|
1468
|
-
};
|
|
1445
|
+
return { errorList };
|
|
1469
1446
|
}
|
|
1470
1447
|
// 从购物车中获取已经分配好第一步资源的所有时间片
|
|
1471
1448
|
getTimeSlotByAllResources(resources_code, split = 10) {
|
|
1449
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1472
1450
|
let dateRange = this.store.date.getDateRange();
|
|
1473
|
-
// 取出购物车中所有一已选择的第一步资源
|
|
1474
1451
|
const resources = [];
|
|
1475
|
-
const cartItems = this.store.cart.getItems().filter(n => !(0,
|
|
1476
|
-
// if (cartItems?.[0].start_date) return [];
|
|
1452
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
1477
1453
|
const resourceIds = [];
|
|
1478
|
-
let resourcesTypeId =
|
|
1454
|
+
let resourcesTypeId = void 0;
|
|
1479
1455
|
let isSingleResource = false;
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
item._productOrigin?.product_resource?.resources?.forEach(n => {
|
|
1486
|
-
// TODO: 少了个 status 的判断
|
|
1456
|
+
let maxCutOffTime = void 0;
|
|
1457
|
+
let maxCutOffTimeValue = (0, import_dayjs.default)();
|
|
1458
|
+
cartItems.forEach((item) => {
|
|
1459
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
|
|
1460
|
+
(_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
|
|
1487
1461
|
if (n.code === resources_code) {
|
|
1488
|
-
resources.push(...
|
|
1489
|
-
isSingleResource = n.type ===
|
|
1462
|
+
resources.push(...n.renderList || []);
|
|
1463
|
+
isSingleResource = n.type === "single";
|
|
1490
1464
|
}
|
|
1491
1465
|
});
|
|
1492
|
-
// item._origin.resources?.forEach((n: any) => {
|
|
1493
|
-
// resourceIds.push(n.relation_id);
|
|
1494
|
-
// });
|
|
1495
1466
|
if (item.resource_id && !resourceIds.includes(item.resource_id)) {
|
|
1496
1467
|
resourceIds.push(item.resource_id);
|
|
1497
1468
|
}
|
|
1498
|
-
resourcesTypeId = item
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1469
|
+
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(
|
|
1470
|
+
(n) => n.code === resources_code
|
|
1471
|
+
)) == null ? void 0 : _g2.id;
|
|
1472
|
+
if (((_h2 = item._productOrigin) == null ? void 0 : _h2.cut_off_time) && ((_i2 = item._productOrigin) == null ? void 0 : _i2.cut_off_time.type) === "advance") {
|
|
1473
|
+
const currentCutOffTime = (0, import_dayjs.default)().add(
|
|
1474
|
+
item._productOrigin.cut_off_time.unit,
|
|
1475
|
+
item._productOrigin.cut_off_time.unit_type
|
|
1476
|
+
);
|
|
1477
|
+
if (currentCutOffTime.isAfter(maxCutOffTimeValue, "minute")) {
|
|
1502
1478
|
maxCutOffTimeValue = currentCutOffTime;
|
|
1503
1479
|
maxCutOffTime = item._productOrigin.cut_off_time;
|
|
1504
1480
|
}
|
|
1505
1481
|
}
|
|
1506
1482
|
});
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
dateRange[0].resource.forEach(n => {
|
|
1511
|
-
if (n.form_id === resourcesTypeId && !resources.find(m => m.id === n.id)) {
|
|
1483
|
+
if ((_b = (_a = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _a.resource) == null ? void 0 : _b.length) {
|
|
1484
|
+
dateRange[0].resource.forEach((n) => {
|
|
1485
|
+
if (n.form_id === resourcesTypeId && !resources.find((m) => m.id === n.id)) {
|
|
1512
1486
|
resources.push(n);
|
|
1513
1487
|
}
|
|
1514
1488
|
});
|
|
1515
1489
|
}
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
const currentDate = dateRange?.[0]?.date;
|
|
1490
|
+
if (((_c = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _c.date) && resources.length) {
|
|
1491
|
+
const currentDate = (_d = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _d.date;
|
|
1519
1492
|
const theDateResources = this.store.date.getResourcesListByDate(currentDate);
|
|
1520
|
-
resources.forEach(item => {
|
|
1521
|
-
|
|
1522
|
-
|
|
1493
|
+
resources.forEach((item) => {
|
|
1494
|
+
var _a2;
|
|
1495
|
+
const noCurrentDateTimes = item.times.some((n) => {
|
|
1496
|
+
return (0, import_dayjs.default)(n.start_at).isSame((0, import_dayjs.default)(currentDate), "day");
|
|
1523
1497
|
});
|
|
1524
1498
|
if (!noCurrentDateTimes) {
|
|
1525
|
-
item.times = theDateResources
|
|
1499
|
+
item.times = ((_a2 = theDateResources == null ? void 0 : theDateResources.find((n) => n.id === item.id)) == null ? void 0 : _a2.times) || [];
|
|
1526
1500
|
}
|
|
1527
1501
|
});
|
|
1528
1502
|
}
|
|
1529
|
-
|
|
1530
|
-
// 如果依然 resources 空的,则证明他是切换日期了,此时直接从 date 模块里取
|
|
1531
1503
|
if (resources.length === 0) {
|
|
1532
|
-
resources.push(...
|
|
1504
|
+
resources.push(...this.store.date.getResourcesListByDate(dateRange[0].date) || []);
|
|
1533
1505
|
}
|
|
1534
|
-
const resourcesMap = (0,
|
|
1506
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)(resources);
|
|
1535
1507
|
let duration = 0;
|
|
1536
|
-
// duration = 不同账号的最长时间
|
|
1537
1508
|
const accountList = this.store.accountList.getAccounts();
|
|
1538
|
-
const checkDuration =
|
|
1509
|
+
const checkDuration = (cartItems2) => {
|
|
1539
1510
|
let accountDuration = 0;
|
|
1540
|
-
|
|
1541
|
-
|
|
1511
|
+
cartItems2.forEach((item) => {
|
|
1512
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
1542
1513
|
if (isSingleResource) {
|
|
1543
|
-
accountDuration += item._productOrigin
|
|
1514
|
+
accountDuration += ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10;
|
|
1544
1515
|
} else {
|
|
1545
|
-
if (accountDuration < (item._productOrigin
|
|
1546
|
-
accountDuration = item._productOrigin
|
|
1516
|
+
if (accountDuration < (((_d2 = (_c2 = item._productOrigin) == null ? void 0 : _c2.duration) == null ? void 0 : _d2.value) || 10)) {
|
|
1517
|
+
accountDuration = ((_f2 = (_e2 = item._productOrigin) == null ? void 0 : _e2.duration) == null ? void 0 : _f2.value) || 10;
|
|
1547
1518
|
}
|
|
1548
1519
|
}
|
|
1549
1520
|
});
|
|
@@ -1551,68 +1522,74 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1551
1522
|
duration = accountDuration;
|
|
1552
1523
|
}
|
|
1553
1524
|
};
|
|
1554
|
-
if (cartItems
|
|
1555
|
-
accountList.forEach(account => {
|
|
1556
|
-
const
|
|
1557
|
-
checkDuration(
|
|
1525
|
+
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
1526
|
+
accountList.forEach((account) => {
|
|
1527
|
+
const cartItems2 = this.store.cart.getCartByAccount(account.getId());
|
|
1528
|
+
checkDuration(cartItems2);
|
|
1558
1529
|
});
|
|
1559
1530
|
} else {
|
|
1560
1531
|
checkDuration(cartItems);
|
|
1561
1532
|
}
|
|
1562
|
-
|
|
1563
|
-
// 同时 session 类商品的流程也不应该调用这个方法
|
|
1564
|
-
if (!cartItems?.[0]?.start_date && !cartItems?.[0]?.resource_id || !cartItems?.[0].duration) {
|
|
1533
|
+
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)) {
|
|
1565
1534
|
return [];
|
|
1566
1535
|
}
|
|
1567
|
-
if (cartItems
|
|
1568
|
-
dateRange = [
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1536
|
+
if ((cartItems == null ? void 0 : cartItems[0].start_date) && !dateRange) {
|
|
1537
|
+
dateRange = [
|
|
1538
|
+
{
|
|
1539
|
+
date: cartItems == null ? void 0 : cartItems[0].start_date,
|
|
1540
|
+
status: "available",
|
|
1541
|
+
week: "",
|
|
1542
|
+
weekNum: 0
|
|
1543
|
+
},
|
|
1544
|
+
{
|
|
1545
|
+
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) || "",
|
|
1546
|
+
status: "available",
|
|
1547
|
+
week: "",
|
|
1548
|
+
weekNum: 0
|
|
1549
|
+
}
|
|
1550
|
+
];
|
|
1579
1551
|
}
|
|
1580
1552
|
const resourcesUseableMap = {};
|
|
1581
|
-
const hasFlexibleDuration = cartItems.some(
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1553
|
+
const hasFlexibleDuration = cartItems.some(
|
|
1554
|
+
(item) => {
|
|
1555
|
+
var _a2, _b2;
|
|
1556
|
+
return ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.type) === "flexible";
|
|
1557
|
+
}
|
|
1558
|
+
);
|
|
1559
|
+
let operating_day_boundary = (_j = (_i = this.shopStore.get("core")) == null ? void 0 : _i.core) == null ? void 0 : _j.operating_day_boundary;
|
|
1585
1560
|
let maxBlockThreshold = 0;
|
|
1586
1561
|
if (hasFlexibleDuration) {
|
|
1587
1562
|
maxBlockThreshold = cartItems.reduce((max, item) => {
|
|
1588
|
-
|
|
1589
|
-
if (item._productOrigin
|
|
1590
|
-
return Math.max(
|
|
1563
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
1564
|
+
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) {
|
|
1565
|
+
return Math.max(
|
|
1566
|
+
max,
|
|
1567
|
+
((_f2 = (_e2 = (_d2 = item._productOrigin) == null ? void 0 : _d2.duration) == null ? void 0 : _e2.flexible_config) == null ? void 0 : _f2.block_threshold) || 0
|
|
1568
|
+
);
|
|
1591
1569
|
}
|
|
1592
1570
|
return 0;
|
|
1593
1571
|
}, 0);
|
|
1594
1572
|
}
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
if (items.length === 0)
|
|
1598
|
-
|
|
1599
|
-
const firstResource = items[0]._resourceOrigin
|
|
1600
|
-
const sameResourceLength = items.filter(item =>
|
|
1573
|
+
const calculateCapacityFromCartItems = (items) => {
|
|
1574
|
+
var _a2;
|
|
1575
|
+
if (items.length === 0)
|
|
1576
|
+
return 0;
|
|
1577
|
+
const firstResource = (_a2 = items[0]._resourceOrigin) == null ? void 0 : _a2[0].id;
|
|
1578
|
+
const sameResourceLength = items.filter((item) => {
|
|
1579
|
+
var _a3;
|
|
1580
|
+
return ((_a3 = item._resourceOrigin) == null ? void 0 : _a3[0].id) === firstResource;
|
|
1581
|
+
}).length;
|
|
1601
1582
|
if (sameResourceLength === items.length) {
|
|
1602
1583
|
return 1;
|
|
1603
1584
|
}
|
|
1604
|
-
|
|
1605
|
-
return Math.max(...items.map(item => (0, _capacity.getCapacityInfoByCartItem)(item).currentCapacity || 1));
|
|
1606
|
-
// return items.reduce((total, item) => {
|
|
1607
|
-
// return total + (getCapacityInfoByCartItem(item).currentCapacity || 0);
|
|
1608
|
-
// }, 0);
|
|
1585
|
+
return Math.max(...items.map((item) => (0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 1));
|
|
1609
1586
|
};
|
|
1610
|
-
|
|
1611
|
-
// 如果是多个人预约,去要求出几个 holder 下最大的商品需求容量capacity
|
|
1612
1587
|
let maxCapacity = 1;
|
|
1613
|
-
if (cartItems
|
|
1614
|
-
accountList.forEach(account => {
|
|
1615
|
-
const accountCartItems = this.store.cart.getCartByAccount(
|
|
1588
|
+
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
1589
|
+
accountList.forEach((account) => {
|
|
1590
|
+
const accountCartItems = this.store.cart.getCartByAccount(
|
|
1591
|
+
account.getId()
|
|
1592
|
+
);
|
|
1616
1593
|
const currentCapacity = calculateCapacityFromCartItems(accountCartItems);
|
|
1617
1594
|
if (currentCapacity > maxCapacity) {
|
|
1618
1595
|
maxCapacity = currentCapacity;
|
|
@@ -1621,13 +1598,13 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1621
1598
|
} else {
|
|
1622
1599
|
maxCapacity = calculateCapacityFromCartItems(cartItems);
|
|
1623
1600
|
}
|
|
1624
|
-
const timeSlots = (0,
|
|
1601
|
+
const timeSlots = (0, import_resources.getTimeSlicesByResources)({
|
|
1625
1602
|
resourceIds,
|
|
1626
1603
|
resourcesMap,
|
|
1627
1604
|
duration,
|
|
1628
1605
|
currentDate: dateRange[0].date,
|
|
1629
|
-
split
|
|
1630
|
-
resourcesUseableMap
|
|
1606
|
+
split,
|
|
1607
|
+
resourcesUseableMap,
|
|
1631
1608
|
capacity: maxCapacity,
|
|
1632
1609
|
cut_off_time: maxCutOffTime,
|
|
1633
1610
|
hasFlexibleDuration,
|
|
@@ -1637,70 +1614,61 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1637
1614
|
return timeSlots;
|
|
1638
1615
|
}
|
|
1639
1616
|
// 从购物车中获取已经分配好第一步资源的所有时间片,批量版本,用于给日期提供能否高亮的判断
|
|
1640
|
-
async getTimeSlotByAllResourcesForDate({
|
|
1641
|
-
|
|
1642
|
-
startDate,
|
|
1643
|
-
|
|
1644
|
-
}) {
|
|
1645
|
-
// 如果 end_date 距离start_date小于 30 天,自动追加 end_date 为今天往后的 30 天
|
|
1646
|
-
if ((0, _dayjs.default)(endDate).diff((0, _dayjs.default)(startDate), 'day') < 30) {
|
|
1647
|
-
endDate = (0, _dayjs.default)(startDate).add(30, 'day').format('YYYY-MM-DD');
|
|
1617
|
+
async getTimeSlotByAllResourcesForDate({ resources_code, startDate, endDate }) {
|
|
1618
|
+
var _a, _b, _c, _d;
|
|
1619
|
+
if ((0, import_dayjs.default)(endDate).diff((0, import_dayjs.default)(startDate), "day") < 30) {
|
|
1620
|
+
endDate = (0, import_dayjs.default)(startDate).add(30, "day").format("YYYY-MM-DD");
|
|
1648
1621
|
}
|
|
1649
|
-
// 预请求资源数据,防止日期超过之前选择的范围
|
|
1650
1622
|
await this.getAvailableDate({
|
|
1651
|
-
startDate
|
|
1652
|
-
endDate
|
|
1623
|
+
startDate,
|
|
1624
|
+
endDate,
|
|
1653
1625
|
useCache: true
|
|
1654
1626
|
});
|
|
1655
|
-
// 取出购物车中所有一已选择的第一步资源
|
|
1656
1627
|
const resources = [];
|
|
1657
|
-
const cartItems = this.store.cart.getItems().filter(n => !(0,
|
|
1658
|
-
// if (cartItems?.[0].start_date) return [];
|
|
1628
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
1659
1629
|
const resourceIds = [];
|
|
1660
|
-
let resourcesTypeId =
|
|
1630
|
+
let resourcesTypeId = void 0;
|
|
1661
1631
|
let isSingleResource = false;
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
item._productOrigin?.product_resource?.resources?.forEach(n => {
|
|
1668
|
-
// TODO: 少了个 status 的判断
|
|
1632
|
+
let maxCutOffTime = void 0;
|
|
1633
|
+
let maxCutOffTimeValue = (0, import_dayjs.default)();
|
|
1634
|
+
cartItems.forEach((item) => {
|
|
1635
|
+
var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i;
|
|
1636
|
+
(_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
|
|
1669
1637
|
if (n.code === resources_code) {
|
|
1670
|
-
resources.push(...
|
|
1671
|
-
isSingleResource = n.type ===
|
|
1638
|
+
resources.push(...n.renderList || []);
|
|
1639
|
+
isSingleResource = n.type === "single";
|
|
1672
1640
|
}
|
|
1673
1641
|
});
|
|
1674
|
-
// item._origin.resources?.forEach((n: any) => {
|
|
1675
|
-
// resourceIds.push(n.relation_id);
|
|
1676
|
-
// });
|
|
1677
1642
|
if (item.resource_id && !resourceIds.includes(item.resource_id)) {
|
|
1678
1643
|
resourceIds.push(item.resource_id);
|
|
1679
1644
|
}
|
|
1680
|
-
resourcesTypeId = item
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1645
|
+
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(
|
|
1646
|
+
(n) => n.code === resources_code
|
|
1647
|
+
)) == null ? void 0 : _g.id;
|
|
1648
|
+
if (((_h = item._productOrigin) == null ? void 0 : _h.cut_off_time) && ((_i = item._productOrigin) == null ? void 0 : _i.cut_off_time.type) === "advance") {
|
|
1649
|
+
const currentCutOffTime = (0, import_dayjs.default)().add(
|
|
1650
|
+
item._productOrigin.cut_off_time.unit,
|
|
1651
|
+
item._productOrigin.cut_off_time.unit_type
|
|
1652
|
+
);
|
|
1653
|
+
if (currentCutOffTime.isAfter(maxCutOffTimeValue, "minute")) {
|
|
1684
1654
|
maxCutOffTimeValue = currentCutOffTime;
|
|
1685
1655
|
maxCutOffTime = item._productOrigin.cut_off_time;
|
|
1686
1656
|
}
|
|
1687
1657
|
}
|
|
1688
1658
|
});
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
if (!resources.length) return [];
|
|
1659
|
+
if (!resources.length)
|
|
1660
|
+
return [];
|
|
1692
1661
|
let duration = 0;
|
|
1693
|
-
// duration = 不同账号的最长时间
|
|
1694
1662
|
const accountList = this.store.accountList.getAccounts();
|
|
1695
|
-
const checkDuration =
|
|
1663
|
+
const checkDuration = (cartItems2) => {
|
|
1696
1664
|
let accountDuration = 0;
|
|
1697
|
-
|
|
1698
|
-
|
|
1665
|
+
cartItems2.forEach((item) => {
|
|
1666
|
+
var _a2, _b2, _c2, _d2, _e, _f;
|
|
1699
1667
|
if (isSingleResource) {
|
|
1700
|
-
accountDuration += item._productOrigin
|
|
1668
|
+
accountDuration += ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10;
|
|
1701
1669
|
} else {
|
|
1702
|
-
if (accountDuration < (item._productOrigin
|
|
1703
|
-
accountDuration = item._productOrigin
|
|
1670
|
+
if (accountDuration < (((_d2 = (_c2 = item._productOrigin) == null ? void 0 : _c2.duration) == null ? void 0 : _d2.value) || 10)) {
|
|
1671
|
+
accountDuration = ((_f = (_e = item._productOrigin) == null ? void 0 : _e.duration) == null ? void 0 : _f.value) || 10;
|
|
1704
1672
|
}
|
|
1705
1673
|
}
|
|
1706
1674
|
});
|
|
@@ -1708,50 +1676,52 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1708
1676
|
duration = accountDuration;
|
|
1709
1677
|
}
|
|
1710
1678
|
};
|
|
1711
|
-
if (cartItems
|
|
1712
|
-
accountList.forEach(account => {
|
|
1713
|
-
const
|
|
1714
|
-
checkDuration(
|
|
1679
|
+
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
1680
|
+
accountList.forEach((account) => {
|
|
1681
|
+
const cartItems2 = this.store.cart.getCartByAccount(account.getId());
|
|
1682
|
+
checkDuration(cartItems2);
|
|
1715
1683
|
});
|
|
1716
1684
|
} else {
|
|
1717
1685
|
checkDuration(cartItems);
|
|
1718
1686
|
}
|
|
1719
|
-
|
|
1720
|
-
// 同时 session 类商品的流程也不应该调用这个方法
|
|
1721
|
-
if (!cartItems?.[0]?.start_date && !cartItems?.[0]?.resource_id || !cartItems?.[0].duration) {
|
|
1687
|
+
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)) {
|
|
1722
1688
|
return [];
|
|
1723
1689
|
}
|
|
1724
1690
|
const resourcesUseableMap = {};
|
|
1725
|
-
const hasFlexibleDuration = cartItems.some(
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1691
|
+
const hasFlexibleDuration = cartItems.some(
|
|
1692
|
+
(item) => {
|
|
1693
|
+
var _a2, _b2;
|
|
1694
|
+
return ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.type) === "flexible";
|
|
1695
|
+
}
|
|
1696
|
+
);
|
|
1697
|
+
let operating_day_boundary = (_d = (_c = this.shopStore.get("core")) == null ? void 0 : _c.core) == null ? void 0 : _d.operating_day_boundary;
|
|
1729
1698
|
let maxBlockThreshold = 0;
|
|
1730
1699
|
if (hasFlexibleDuration) {
|
|
1731
1700
|
maxBlockThreshold = cartItems.reduce((max, item) => {
|
|
1732
|
-
|
|
1733
|
-
if (item._productOrigin
|
|
1734
|
-
return Math.max(max, item._productOrigin
|
|
1701
|
+
var _a2, _b2, _c2, _d2, _e, _f;
|
|
1702
|
+
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) {
|
|
1703
|
+
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);
|
|
1735
1704
|
}
|
|
1736
1705
|
return 0;
|
|
1737
1706
|
}, 0);
|
|
1738
1707
|
}
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
if (items.length === 0)
|
|
1742
|
-
|
|
1743
|
-
const firstResource = items[0]._resourceOrigin
|
|
1744
|
-
const sameResourceLength = items.filter(item =>
|
|
1708
|
+
const calculateCapacityFromCartItems = (items) => {
|
|
1709
|
+
var _a2;
|
|
1710
|
+
if (items.length === 0)
|
|
1711
|
+
return 0;
|
|
1712
|
+
const firstResource = (_a2 = items[0]._resourceOrigin) == null ? void 0 : _a2[0].id;
|
|
1713
|
+
const sameResourceLength = items.filter((item) => {
|
|
1714
|
+
var _a3;
|
|
1715
|
+
return ((_a3 = item._resourceOrigin) == null ? void 0 : _a3[0].id) === firstResource;
|
|
1716
|
+
}).length;
|
|
1745
1717
|
if (sameResourceLength !== items.length) {
|
|
1746
1718
|
return 1;
|
|
1747
1719
|
}
|
|
1748
|
-
|
|
1749
|
-
return Math.max(...items.map(item => (0, _capacity.getCapacityInfoByCartItem)(item).currentCapacity || 1));
|
|
1720
|
+
return Math.max(...items.map((item) => (0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 1));
|
|
1750
1721
|
};
|
|
1751
|
-
// 如果是多个预约,去要求出几个 holder 下最大的需求容量capacity
|
|
1752
1722
|
let maxCapacity = 1;
|
|
1753
|
-
if (cartItems
|
|
1754
|
-
accountList.forEach(account => {
|
|
1723
|
+
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
1724
|
+
accountList.forEach((account) => {
|
|
1755
1725
|
const accountCartItems = this.store.cart.getCartByAccount(account.getId());
|
|
1756
1726
|
const currentCapacity = calculateCapacityFromCartItems(accountCartItems);
|
|
1757
1727
|
if (currentCapacity > maxCapacity) {
|
|
@@ -1762,33 +1732,31 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1762
1732
|
maxCapacity = calculateCapacityFromCartItems(cartItems);
|
|
1763
1733
|
}
|
|
1764
1734
|
const arr = [];
|
|
1765
|
-
const today = (0,
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
const currentDate = i.format('YYYY-MM-DD');
|
|
1735
|
+
const today = (0, import_dayjs.default)().startOf("day");
|
|
1736
|
+
for (let i = (0, import_dayjs.default)(startDate); i.isBefore((0, import_dayjs.default)(endDate)); i = i.add(1, "day")) {
|
|
1737
|
+
const currentDate = i.format("YYYY-MM-DD");
|
|
1769
1738
|
const theDateResources = this.store.date.getResourcesListByDate(currentDate);
|
|
1770
|
-
resources.forEach(item => {
|
|
1771
|
-
|
|
1739
|
+
resources.forEach((item) => {
|
|
1740
|
+
var _a2;
|
|
1741
|
+
item.times = ((_a2 = theDateResources == null ? void 0 : theDateResources.find((n) => n.id === item.id)) == null ? void 0 : _a2.times) || [];
|
|
1772
1742
|
});
|
|
1773
|
-
const resourcesMap = (0,
|
|
1774
|
-
|
|
1775
|
-
// 如果日期已经过期则直接标记为不可用
|
|
1743
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)(resources);
|
|
1776
1744
|
if (i.isBefore(today)) {
|
|
1777
1745
|
arr.push({
|
|
1778
1746
|
date: currentDate,
|
|
1779
|
-
status:
|
|
1780
|
-
week: i.format(
|
|
1747
|
+
status: "unavailable",
|
|
1748
|
+
week: i.format("ddd"),
|
|
1781
1749
|
weekNum: i.day()
|
|
1782
1750
|
});
|
|
1783
1751
|
continue;
|
|
1784
1752
|
}
|
|
1785
|
-
const timeSlots = (0,
|
|
1753
|
+
const timeSlots = (0, import_resources.getTimeSlicesByResources)({
|
|
1786
1754
|
resourceIds,
|
|
1787
1755
|
resourcesMap,
|
|
1788
1756
|
duration,
|
|
1789
|
-
currentDate
|
|
1757
|
+
currentDate,
|
|
1790
1758
|
split: 10,
|
|
1791
|
-
resourcesUseableMap
|
|
1759
|
+
resourcesUseableMap,
|
|
1792
1760
|
capacity: maxCapacity,
|
|
1793
1761
|
cut_off_time: maxCutOffTime,
|
|
1794
1762
|
hasFlexibleDuration,
|
|
@@ -1798,74 +1766,63 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1798
1766
|
if (timeSlots.length > 0) {
|
|
1799
1767
|
arr.push({
|
|
1800
1768
|
date: currentDate,
|
|
1801
|
-
status:
|
|
1802
|
-
week: i.format(
|
|
1769
|
+
status: "available",
|
|
1770
|
+
week: i.format("ddd"),
|
|
1803
1771
|
weekNum: i.day()
|
|
1804
1772
|
});
|
|
1805
1773
|
} else {
|
|
1806
1774
|
arr.push({
|
|
1807
1775
|
date: currentDate,
|
|
1808
|
-
status:
|
|
1809
|
-
week: i.format(
|
|
1776
|
+
status: "unavailable",
|
|
1777
|
+
week: i.format("ddd"),
|
|
1810
1778
|
weekNum: i.day()
|
|
1811
1779
|
});
|
|
1812
1780
|
}
|
|
1813
1781
|
}
|
|
1814
1782
|
return arr;
|
|
1815
1783
|
}
|
|
1816
|
-
|
|
1817
1784
|
// 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
|
|
1818
1785
|
submitTimeSlot(timeSlots) {
|
|
1819
|
-
|
|
1820
|
-
const cartItems = this.store.cart.getItems().filter(n => !(0,
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
// 处理每个账号的商品
|
|
1839
|
-
Object.values(itemsByAccount).forEach(accountItems => {
|
|
1840
|
-
let currentStartTime = timeSlots.start_at.format('YYYY-MM-DD HH:mm');
|
|
1786
|
+
var _a, _b;
|
|
1787
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
1788
|
+
const allResources = this.store.date.getResourcesListByDate(
|
|
1789
|
+
timeSlots.start_at.format("YYYY-MM-DD")
|
|
1790
|
+
);
|
|
1791
|
+
const itemsByAccount = cartItems.reduce(
|
|
1792
|
+
(acc, item) => {
|
|
1793
|
+
const holderId = item.holder_id;
|
|
1794
|
+
if (!acc[holderId]) {
|
|
1795
|
+
acc[holderId] = [];
|
|
1796
|
+
}
|
|
1797
|
+
acc[holderId].push(item);
|
|
1798
|
+
return acc;
|
|
1799
|
+
},
|
|
1800
|
+
{}
|
|
1801
|
+
);
|
|
1802
|
+
const operating_day_boundary = (_b = (_a = this.shopStore.get("core")) == null ? void 0 : _a.core) == null ? void 0 : _b.operating_day_boundary;
|
|
1803
|
+
Object.values(itemsByAccount).forEach((accountItems) => {
|
|
1804
|
+
let currentStartTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
1841
1805
|
accountItems.forEach((item, index) => {
|
|
1806
|
+
var _a2;
|
|
1842
1807
|
const osWarnTips = [];
|
|
1843
|
-
const newResources = (0,
|
|
1844
|
-
newResources.forEach(resource => {
|
|
1845
|
-
|
|
1846
|
-
if (item._productOrigin
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
value: 10
|
|
1850
|
-
};
|
|
1851
|
-
resource.startTime = timeSlots.start_at.format('YYYY-MM-DD HH:mm');
|
|
1852
|
-
// 找到resource.times里最晚的end_at
|
|
1853
|
-
const targetResourceTimes = allResources?.find(n => n.id === resource.id)?.times;
|
|
1854
|
-
// 找到最晚的 end_at 还没用,因为可能存在资源工作时间是 10:00-19:00,但是资源的 times 里有 16:30-19:00 被 block 的情况
|
|
1855
|
-
// 所以还需要排除掉 block 时间
|
|
1856
|
-
function getEarliestBlockedStartTime({
|
|
1857
|
-
currentStartTime,
|
|
1808
|
+
const newResources = (0, import_lodash_es.cloneDeep)(item._origin.resources);
|
|
1809
|
+
newResources.forEach((resource) => {
|
|
1810
|
+
var _a3, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1811
|
+
if (((_b2 = (_a3 = item._productOrigin) == null ? void 0 : _a3.duration) == null ? void 0 : _b2.type) === "flexible") {
|
|
1812
|
+
let getEarliestBlockedStartTime = function({
|
|
1813
|
+
currentStartTime: currentStartTime2,
|
|
1858
1814
|
times
|
|
1859
1815
|
}) {
|
|
1860
|
-
|
|
1816
|
+
var _a4;
|
|
1817
|
+
const currentStart = (0, import_dayjs.default)(currentStartTime2);
|
|
1861
1818
|
let earliestBlockStart;
|
|
1862
1819
|
for (const time of times || []) {
|
|
1863
|
-
const blockedTimes = time.event_list
|
|
1820
|
+
const blockedTimes = (_a4 = time.event_list) == null ? void 0 : _a4.filter((event) => event.type !== "schedule_event");
|
|
1864
1821
|
for (const event of blockedTimes || []) {
|
|
1865
|
-
const eventStart = (0,
|
|
1866
|
-
const eventEnd = (0,
|
|
1822
|
+
const eventStart = (0, import_dayjs.default)(event.start_at);
|
|
1823
|
+
const eventEnd = (0, import_dayjs.default)(event.end_at);
|
|
1867
1824
|
if (eventStart.isBefore(currentStart) && eventEnd.isAfter(currentStart)) {
|
|
1868
|
-
return currentStart.format(
|
|
1825
|
+
return currentStart.format("YYYY-MM-DD HH:mm");
|
|
1869
1826
|
}
|
|
1870
1827
|
if (eventStart.isAfter(currentStart)) {
|
|
1871
1828
|
if (!earliestBlockStart || eventStart.isBefore(earliestBlockStart)) {
|
|
@@ -1874,68 +1831,79 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1874
1831
|
}
|
|
1875
1832
|
}
|
|
1876
1833
|
}
|
|
1877
|
-
return earliestBlockStart
|
|
1878
|
-
}
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1834
|
+
return earliestBlockStart == null ? void 0 : earliestBlockStart.format("YYYY-MM-DD HH:mm");
|
|
1835
|
+
};
|
|
1836
|
+
item.duration = {
|
|
1837
|
+
type: "minutes",
|
|
1838
|
+
value: 10
|
|
1839
|
+
};
|
|
1840
|
+
resource.startTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
1841
|
+
const targetResourceTimes = (_c = allResources == null ? void 0 : allResources.find(
|
|
1842
|
+
(n) => n.id === resource.id
|
|
1843
|
+
)) == null ? void 0 : _c.times;
|
|
1844
|
+
const resourcesEndTime = targetResourceTimes.reduce(
|
|
1845
|
+
(acc, curr) => {
|
|
1846
|
+
return (0, import_dayjs.default)(curr.end_at).isAfter((0, import_dayjs.default)(acc.end_at)) ? curr : acc;
|
|
1847
|
+
},
|
|
1848
|
+
targetResourceTimes[0]
|
|
1849
|
+
);
|
|
1882
1850
|
const earliestBlockedStartTime = getEarliestBlockedStartTime({
|
|
1883
1851
|
currentStartTime,
|
|
1884
1852
|
times: targetResourceTimes
|
|
1885
1853
|
});
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
const operatingBoundaryDateTime = `${resourceDate} ${operating_day_boundary.type ===
|
|
1890
|
-
const endTimeCandidates = [
|
|
1854
|
+
const resourceDate = (0, import_dayjs.default)(resourcesEndTime.end_at).format(
|
|
1855
|
+
"YYYY-MM-DD"
|
|
1856
|
+
);
|
|
1857
|
+
const operatingBoundaryDateTime = `${resourceDate} ${operating_day_boundary.type === "start_time" ? "23:59" : operating_day_boundary.time}`;
|
|
1858
|
+
const endTimeCandidates = [
|
|
1859
|
+
resourcesEndTime.end_at,
|
|
1860
|
+
operatingBoundaryDateTime,
|
|
1861
|
+
...earliestBlockedStartTime ? [earliestBlockedStartTime] : []
|
|
1862
|
+
];
|
|
1891
1863
|
const endTime = endTimeCandidates.reduce((earliest, value) => {
|
|
1892
|
-
return (0,
|
|
1864
|
+
return (0, import_dayjs.default)(value).isBefore((0, import_dayjs.default)(earliest)) ? value : earliest;
|
|
1893
1865
|
}, endTimeCandidates[0]);
|
|
1894
|
-
// 修复:如果 endTime 只是时间格式(如 "17:00"),需要加上日期
|
|
1895
1866
|
let formattedEndTime;
|
|
1896
|
-
if (typeof endTime ===
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
formattedEndTime = (0, _dayjs.default)(`${currentDate} ${endTime}`);
|
|
1867
|
+
if (typeof endTime === "string" && endTime.includes(":") && !endTime.includes(" ") && !endTime.includes("T")) {
|
|
1868
|
+
const currentDate = timeSlots.start_at.format("YYYY-MM-DD");
|
|
1869
|
+
formattedEndTime = (0, import_dayjs.default)(`${currentDate} ${endTime}`);
|
|
1900
1870
|
} else {
|
|
1901
|
-
formattedEndTime = (0,
|
|
1871
|
+
formattedEndTime = (0, import_dayjs.default)(endTime);
|
|
1902
1872
|
}
|
|
1903
|
-
resource.endTime = formattedEndTime.format(
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
if (!osWarnTips.includes('pisell2.product.card.closing-soon.warning')) {
|
|
1908
|
-
osWarnTips.push('pisell2.product.card.closing-soon.warning');
|
|
1873
|
+
resource.endTime = formattedEndTime.format("YYYY-MM-DD HH:mm");
|
|
1874
|
+
if (((_f = (_e = (_d = item._productOrigin) == null ? void 0 : _d.duration) == null ? void 0 : _e.flexible_config) == null ? void 0 : _f.is_enable_minimum_duration) && (0, import_dayjs.default)(currentStartTime).add(((_i = (_h = (_g = item._productOrigin) == null ? void 0 : _g.duration) == null ? void 0 : _h.flexible_config) == null ? void 0 : _i.warning_threshold) || 0, "minutes").isAfter((0, import_dayjs.default)(formattedEndTime))) {
|
|
1875
|
+
if (!osWarnTips.includes("pisell2.product.card.closing-soon.warning")) {
|
|
1876
|
+
osWarnTips.push("pisell2.product.card.closing-soon.warning");
|
|
1909
1877
|
}
|
|
1910
1878
|
}
|
|
1911
1879
|
} else {
|
|
1912
1880
|
resource.startTime = currentStartTime;
|
|
1913
|
-
resource.endTime = (0,
|
|
1881
|
+
resource.endTime = (0, import_dayjs.default)(currentStartTime).add(((_k = (_j = item._productOrigin) == null ? void 0 : _j.duration) == null ? void 0 : _k.value) || 10, "minutes").format("YYYY-MM-DD HH:mm");
|
|
1914
1882
|
}
|
|
1915
|
-
// delete resource.times;
|
|
1916
1883
|
});
|
|
1917
1884
|
this.store.cart.updateItem({
|
|
1918
1885
|
_id: item._id,
|
|
1919
1886
|
resources: newResources,
|
|
1920
1887
|
osWarnTips
|
|
1921
1888
|
});
|
|
1922
|
-
|
|
1923
|
-
// 更新下一个商品的开始时间为当前商品的结束时间
|
|
1924
|
-
if (index < accountItems.length - 1 && newResources?.[0]?.resourceType === 'single') {
|
|
1889
|
+
if (index < accountItems.length - 1 && ((_a2 = newResources == null ? void 0 : newResources[0]) == null ? void 0 : _a2.resourceType) === "single") {
|
|
1925
1890
|
currentStartTime = newResources[0].endTime;
|
|
1926
1891
|
}
|
|
1927
1892
|
});
|
|
1928
1893
|
});
|
|
1929
|
-
this.core.effects.emit(
|
|
1894
|
+
this.core.effects.emit(
|
|
1895
|
+
`${this.store.cart.name}:onUpdateBookingDate`,
|
|
1896
|
+
{}
|
|
1897
|
+
);
|
|
1930
1898
|
}
|
|
1931
1899
|
getScheduleDataByIds(scheduleIds) {
|
|
1932
1900
|
const targetSchedules = this.store.schedule.getScheduleListByIds(scheduleIds);
|
|
1933
|
-
const targetSchedulesData = targetSchedules.map(item => {
|
|
1934
|
-
return (0,
|
|
1901
|
+
const targetSchedulesData = targetSchedules.map((item) => {
|
|
1902
|
+
return (0, import_utils3.calcCalendarDataByScheduleResult)(item);
|
|
1935
1903
|
});
|
|
1936
1904
|
const newSchedule = {};
|
|
1937
|
-
targetSchedulesData.forEach(item => {
|
|
1938
|
-
item.forEach(n => {
|
|
1905
|
+
targetSchedulesData.forEach((item) => {
|
|
1906
|
+
item.forEach((n) => {
|
|
1939
1907
|
if (!newSchedule[n.date]) {
|
|
1940
1908
|
newSchedule[n.date] = n;
|
|
1941
1909
|
} else {
|
|
@@ -1946,9 +1914,8 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1946
1914
|
});
|
|
1947
1915
|
});
|
|
1948
1916
|
const newScheduleArr = Object.values(newSchedule);
|
|
1949
|
-
// newScheduleArr 需要做个排序,按日期从小到大
|
|
1950
1917
|
newScheduleArr.sort((a, b) => {
|
|
1951
|
-
return (0,
|
|
1918
|
+
return (0, import_dayjs.default)(a.date).diff((0, import_dayjs.default)(b.date));
|
|
1952
1919
|
});
|
|
1953
1920
|
return newScheduleArr;
|
|
1954
1921
|
}
|
|
@@ -1958,22 +1925,17 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1958
1925
|
if (targetProductData) {
|
|
1959
1926
|
this.store.currentProduct = targetProductData;
|
|
1960
1927
|
this.store.currentProductMeta = {};
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1928
|
+
if (targetProductData["schedule.ids"]) {
|
|
1929
|
+
const newScheduleArr = this.getScheduleDataByIds(
|
|
1930
|
+
targetProductData["schedule.ids"]
|
|
1931
|
+
);
|
|
1932
|
+
if (!this.store.currentProductMeta)
|
|
1933
|
+
this.store.currentProductMeta = {};
|
|
1965
1934
|
this.store.currentProductMeta.schedule = newScheduleArr;
|
|
1966
1935
|
} else if (targetProductData.duration) {
|
|
1967
1936
|
const dateRange = this.store.date.getDateRange();
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
// this.store.date.getResourceDates({
|
|
1971
|
-
// query: {
|
|
1972
|
-
// start_date: dateRange[0].date,
|
|
1973
|
-
// end_date: dateRange[dateRange.length - 1].date,
|
|
1974
|
-
// resource_ids: targetProductData.product_resource?.resources?.map((n: any) => n.id),
|
|
1975
|
-
// },
|
|
1976
|
-
// });
|
|
1937
|
+
if (!(dateRange == null ? void 0 : dateRange.length))
|
|
1938
|
+
return;
|
|
1977
1939
|
this.getAvailableDate({
|
|
1978
1940
|
startDate: dateRange[0].date,
|
|
1979
1941
|
endDate: dateRange[dateRange.length - 1].date,
|
|
@@ -1986,9 +1948,8 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1986
1948
|
if (this.store.currentProductMeta) {
|
|
1987
1949
|
this.store.currentProductMeta.schedule = [];
|
|
1988
1950
|
}
|
|
1989
|
-
this.store.currentProduct =
|
|
1951
|
+
this.store.currentProduct = void 0;
|
|
1990
1952
|
}
|
|
1991
|
-
|
|
1992
1953
|
// 通过商品和 schedule 来获取视频可用的时间片、时间片内资源可用的数据
|
|
1993
1954
|
getTimeslotBySchedule({
|
|
1994
1955
|
date,
|
|
@@ -1996,43 +1957,59 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
1996
1957
|
resources,
|
|
1997
1958
|
product
|
|
1998
1959
|
}) {
|
|
1960
|
+
var _a, _b, _c, _d;
|
|
1999
1961
|
const targetProduct = this.store.currentProduct;
|
|
2000
|
-
// 如果外面传递了product 优先用外面的
|
|
2001
1962
|
const targetProductData = product || targetProduct;
|
|
2002
1963
|
let targetSchedules = [];
|
|
2003
|
-
|
|
2004
|
-
if (scheduleIds?.length) {
|
|
1964
|
+
if (scheduleIds == null ? void 0 : scheduleIds.length) {
|
|
2005
1965
|
targetSchedules = this.store.schedule.getScheduleListByIds(scheduleIds);
|
|
2006
1966
|
} else {
|
|
2007
|
-
targetSchedules = this.store.schedule.getScheduleListByIds(
|
|
1967
|
+
targetSchedules = this.store.schedule.getScheduleListByIds(
|
|
1968
|
+
targetProductData["schedule.ids"]
|
|
1969
|
+
);
|
|
2008
1970
|
}
|
|
2009
1971
|
const resourcesDates = this.store.date.getDateList();
|
|
2010
|
-
const targetResourceDate = resourcesDates.find(n => n.date === date);
|
|
2011
|
-
const cartItems = (0,
|
|
2012
|
-
const resourcesMap = (0,
|
|
2013
|
-
const selectedResources = (0,
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
1972
|
+
const targetResourceDate = resourcesDates.find((n) => n.date === date);
|
|
1973
|
+
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1974
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)((targetResourceDate == null ? void 0 : targetResourceDate.resource) || []);
|
|
1975
|
+
const selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
1976
|
+
cartItems,
|
|
1977
|
+
"",
|
|
1978
|
+
resourcesMap
|
|
1979
|
+
);
|
|
1980
|
+
const productResources = (0, import_resources.getResourcesByProduct)(
|
|
1981
|
+
resourcesMap,
|
|
1982
|
+
resources || ((_b = (_a = this.store.currentProduct) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) || [],
|
|
1983
|
+
selectedResources,
|
|
1984
|
+
1
|
|
1985
|
+
);
|
|
1986
|
+
const minTimeMaxTime = (0, import_utils3.calcMinTimeMaxTimeBySchedules)(
|
|
1987
|
+
targetSchedules,
|
|
1988
|
+
{},
|
|
1989
|
+
date
|
|
1990
|
+
);
|
|
1991
|
+
const scheduleTimeSlots = (0, import_utils3.getAllSortedDateRanges)(minTimeMaxTime);
|
|
1992
|
+
let allProductResources = productResources.flatMap((n) => n.renderList);
|
|
2020
1993
|
allProductResources.sort((a, b) => {
|
|
2021
|
-
|
|
2022
|
-
const
|
|
2023
|
-
|
|
2024
|
-
if (
|
|
1994
|
+
var _a2, _b2, _c2, _d2;
|
|
1995
|
+
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
1996
|
+
const bIsCombined = ((_d2 = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d2.status) === 1;
|
|
1997
|
+
if (aIsCombined && !bIsCombined)
|
|
1998
|
+
return 1;
|
|
1999
|
+
if (!aIsCombined && bIsCombined)
|
|
2000
|
+
return -1;
|
|
2025
2001
|
return 0;
|
|
2026
2002
|
});
|
|
2027
|
-
const enabledResourceTypeConfigs =
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2003
|
+
const enabledResourceTypeConfigs = ((_d = (_c = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.filter(
|
|
2004
|
+
(n) => n.status === 1
|
|
2005
|
+
)) || [];
|
|
2006
|
+
const resourceTypeConfigById = new Map(
|
|
2007
|
+
enabledResourceTypeConfigs.map((n) => [n.id, n])
|
|
2008
|
+
);
|
|
2009
|
+
const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
|
|
2033
2010
|
const resourcesUseableMap = {};
|
|
2034
2011
|
const statsByResourceType = {};
|
|
2035
|
-
enabledResourceTypeConfigs.forEach(cfg => {
|
|
2012
|
+
enabledResourceTypeConfigs.forEach((cfg) => {
|
|
2036
2013
|
statsByResourceType[cfg.id] = {
|
|
2037
2014
|
count: 0,
|
|
2038
2015
|
left: 0,
|
|
@@ -2040,68 +2017,59 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
2040
2017
|
summaryConfigCount: 0
|
|
2041
2018
|
};
|
|
2042
2019
|
});
|
|
2043
|
-
|
|
2044
|
-
// 遍历所有资源
|
|
2045
|
-
allProductResources?.forEach(m => {
|
|
2020
|
+
allProductResources == null ? void 0 : allProductResources.forEach((m) => {
|
|
2046
2021
|
const currentResourceTypeConfig = resourceTypeConfigById.get(m.form_id);
|
|
2047
|
-
if (!currentResourceTypeConfig)
|
|
2048
|
-
|
|
2049
|
-
// 遍历所有资源的上工时间片
|
|
2022
|
+
if (!currentResourceTypeConfig)
|
|
2023
|
+
return;
|
|
2050
2024
|
let currentResourceMaxRemainingCapacity = 0;
|
|
2051
2025
|
let isAllTimeSlicesUsable = true;
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
// 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
|
|
2055
|
-
|
|
2056
|
-
// n.start_at 是 2025-06-30 15:00 end_at 2025-06-30 17:00
|
|
2057
|
-
// item.start 是 2025-06-30 16:00 item.end 是 2025-06-30 19:00
|
|
2058
|
-
// 需要判断 n.start_at 和 n.end_at 是否在 item.start 和 item.end 之间
|
|
2059
|
-
// 如果是仅用于计算的资源, n.start_at 和 n.end_at 在 item.start 和 item.end 有交集,则此时间需要计算
|
|
2060
|
-
// https://project.feishu.cn/v2qint/bug/detail/6657165010
|
|
2061
|
-
const mTimes = m.times.filter(n => {
|
|
2062
|
-
return !(0, _dayjs.default)(n.start_at).isAfter((0, _dayjs.default)(item.start), 'minute') && !(0, _dayjs.default)(n.end_at).isBefore((0, _dayjs.default)(item.end), 'minute') || m.onlyComputed && (0, _dayjs.default)(n.start_at).isBefore((0, _dayjs.default)(item.end), 'minute') && (0, _dayjs.default)(n.end_at).isAfter((0, _dayjs.default)(item.start), 'minute');
|
|
2026
|
+
const mTimes = m.times.filter((n) => {
|
|
2027
|
+
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");
|
|
2063
2028
|
});
|
|
2064
|
-
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
2065
2029
|
if (mTimes.length === 0) {
|
|
2066
2030
|
return;
|
|
2067
2031
|
}
|
|
2068
|
-
|
|
2069
|
-
// 统计该资源类型在这个时间片的“配置容量”(无占用),只统计上工的资源
|
|
2070
2032
|
if (!m.onlyComputed) {
|
|
2071
|
-
const
|
|
2033
|
+
const currentStats2 = statsByResourceType[m.form_id] || {
|
|
2072
2034
|
count: 0,
|
|
2073
2035
|
left: 0,
|
|
2074
2036
|
summaryCount: 0,
|
|
2075
2037
|
summaryConfigCount: 0
|
|
2076
2038
|
};
|
|
2077
|
-
if (currentResourceTypeConfig.type ===
|
|
2078
|
-
|
|
2039
|
+
if (currentResourceTypeConfig.type === "multiple")
|
|
2040
|
+
currentStats2.summaryConfigCount += m.capacity;
|
|
2041
|
+
else
|
|
2042
|
+
currentStats2.summaryConfigCount += 1;
|
|
2043
|
+
statsByResourceType[m.form_id] = currentStats2;
|
|
2079
2044
|
}
|
|
2080
|
-
mTimes.forEach(childTiem => {
|
|
2081
|
-
|
|
2082
|
-
const res = (0, _resources.getIsUsableByTimeItem)({
|
|
2045
|
+
mTimes.forEach((childTiem) => {
|
|
2046
|
+
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
2083
2047
|
timeSlice: {
|
|
2084
2048
|
start_time: item.start,
|
|
2085
2049
|
end_time: item.end,
|
|
2086
|
-
start_at: (0,
|
|
2087
|
-
end_at: (0,
|
|
2050
|
+
start_at: (0, import_dayjs.default)(item.start),
|
|
2051
|
+
end_at: (0, import_dayjs.default)(item.end)
|
|
2088
2052
|
},
|
|
2089
2053
|
time: childTiem,
|
|
2090
2054
|
resource: m,
|
|
2091
2055
|
currentCount: 1,
|
|
2092
2056
|
resourcesUseableMap,
|
|
2093
|
-
cut_off_time: targetProductData
|
|
2057
|
+
cut_off_time: targetProductData == null ? void 0 : targetProductData.cut_off_time
|
|
2094
2058
|
});
|
|
2095
|
-
if (resourcesUseableMap
|
|
2059
|
+
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
2096
2060
|
resourcesUseableMap[m.id] = res.usable;
|
|
2097
2061
|
}
|
|
2098
|
-
if (!res.usable)
|
|
2062
|
+
if (!res.usable)
|
|
2063
|
+
isAllTimeSlicesUsable = false;
|
|
2099
2064
|
if (res.usable && !m.onlyComputed) {
|
|
2100
|
-
if (res.remainingCapacity > currentResourceMaxRemainingCapacity)
|
|
2065
|
+
if (res.remainingCapacity > currentResourceMaxRemainingCapacity)
|
|
2066
|
+
currentResourceMaxRemainingCapacity = res.remainingCapacity;
|
|
2101
2067
|
}
|
|
2102
2068
|
});
|
|
2103
|
-
if (!isAllTimeSlicesUsable)
|
|
2104
|
-
|
|
2069
|
+
if (!isAllTimeSlicesUsable)
|
|
2070
|
+
return;
|
|
2071
|
+
if (m.onlyComputed)
|
|
2072
|
+
return;
|
|
2105
2073
|
const currentStats = statsByResourceType[m.form_id] || {
|
|
2106
2074
|
count: 0,
|
|
2107
2075
|
left: 0,
|
|
@@ -2109,61 +2077,55 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
2109
2077
|
summaryConfigCount: 0
|
|
2110
2078
|
};
|
|
2111
2079
|
currentStats.left += 1;
|
|
2112
|
-
if (currentResourceTypeConfig.type ===
|
|
2080
|
+
if (currentResourceTypeConfig.type === "multiple") {
|
|
2113
2081
|
currentStats.summaryCount += currentResourceMaxRemainingCapacity;
|
|
2114
2082
|
}
|
|
2115
|
-
if (currentResourceMaxRemainingCapacity > currentStats.count)
|
|
2116
|
-
|
|
2117
|
-
// 单个预约:一个资源只计 1,不关心剩余容量
|
|
2118
|
-
// currentStats.summaryCount += 1;
|
|
2119
|
-
// if (currentStats.count < 1) currentStats.count = 1;
|
|
2120
|
-
//}
|
|
2121
|
-
|
|
2083
|
+
if (currentResourceMaxRemainingCapacity > currentStats.count)
|
|
2084
|
+
currentStats.count = currentResourceMaxRemainingCapacity;
|
|
2122
2085
|
statsByResourceType[m.form_id] = currentStats;
|
|
2123
2086
|
});
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
productResources.forEach(n => {
|
|
2087
|
+
const cartItems2 = this.store.cart.getItems();
|
|
2088
|
+
productResources.forEach((n) => {
|
|
2127
2089
|
const currentResourceTypeConfig = resourceTypeConfigById.get(n.id);
|
|
2128
|
-
if (!currentResourceTypeConfig)
|
|
2090
|
+
if (!currentResourceTypeConfig)
|
|
2091
|
+
return;
|
|
2129
2092
|
const currentStats = statsByResourceType[n.id] || {
|
|
2130
2093
|
count: 0,
|
|
2131
2094
|
left: 0,
|
|
2132
2095
|
summaryCount: 0
|
|
2133
2096
|
};
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
// 规则 1
|
|
2141
|
-
const sameCartItems = cartItems.filter(m => m._productOrigin?.id?.toString() === targetProductData?.id?.toString() && `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end);
|
|
2097
|
+
if (n.type === "single") {
|
|
2098
|
+
const currentResourcesSet = /* @__PURE__ */ new Set([...n.optional_resource, ...n.default_resource]);
|
|
2099
|
+
const sameCartItems = cartItems2.filter((m) => {
|
|
2100
|
+
var _a2, _b2, _c2;
|
|
2101
|
+
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;
|
|
2102
|
+
});
|
|
2142
2103
|
if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length > currentStats.left) {
|
|
2143
2104
|
currentStats.left = 0;
|
|
2144
2105
|
currentStats.count = 0;
|
|
2145
2106
|
currentStats.summaryCount = 0;
|
|
2146
2107
|
}
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2108
|
+
let otherCartItems = cartItems2.filter(
|
|
2109
|
+
(m) => {
|
|
2110
|
+
var _a2, _b2, _c2, _d2, _e, _f;
|
|
2111
|
+
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;
|
|
2112
|
+
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);
|
|
2113
|
+
return isTimeMatch && isResourceMatch;
|
|
2114
|
+
}
|
|
2115
|
+
);
|
|
2116
|
+
otherCartItems.forEach((m) => {
|
|
2117
|
+
var _a2, _b2, _c2;
|
|
2118
|
+
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);
|
|
2119
|
+
const sameTypeResourcesSet = /* @__PURE__ */ new Set([...(sameTypeResources == null ? void 0 : sameTypeResources.optional_resource) || [], ...(sameTypeResources == null ? void 0 : sameTypeResources.default_resource) || []]);
|
|
2120
|
+
sameTypeResourcesSet.forEach((resource) => currentResourcesSet.add(resource));
|
|
2158
2121
|
});
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
currentDataResources?.forEach(m => {
|
|
2122
|
+
const currentDataResources = this.store.date.getResourcesListByDate((0, import_dayjs.default)(item.start).format("YYYY-MM-DD"));
|
|
2123
|
+
currentDataResources == null ? void 0 : currentDataResources.forEach((m) => {
|
|
2162
2124
|
if (currentResourcesSet.has(m.id)) {
|
|
2163
|
-
const mTimes = m.times.filter(
|
|
2164
|
-
return !(0,
|
|
2125
|
+
const mTimes = m.times.filter((n2) => {
|
|
2126
|
+
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");
|
|
2165
2127
|
});
|
|
2166
|
-
if (!mTimes.length || mTimes.some(
|
|
2128
|
+
if (!mTimes.length || mTimes.some((n2) => n2.event_list.length)) {
|
|
2167
2129
|
currentResourcesSet.delete(m.id);
|
|
2168
2130
|
}
|
|
2169
2131
|
}
|
|
@@ -2174,61 +2136,57 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
2174
2136
|
currentStats.summaryCount = 0;
|
|
2175
2137
|
}
|
|
2176
2138
|
} else {
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2139
|
+
const sameCartItems = cartItems2.filter((m) => {
|
|
2140
|
+
var _a2, _b2, _c2;
|
|
2141
|
+
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;
|
|
2142
|
+
});
|
|
2143
|
+
const sameCartNeedCapacity = sameCartItems.reduce((acc, curr) => acc + (0, import_capacity.getCapacityInfoByCartItem)(curr).currentCapacity, 0);
|
|
2181
2144
|
const currentProductResourcesCapacity = n.renderList.reduce((acc, curr) => !curr.onlyComputed ? acc + curr.capacity || 0 : acc, 0);
|
|
2182
2145
|
if (sameCartNeedCapacity >= currentProductResourcesCapacity) {
|
|
2183
2146
|
currentStats.left = 0;
|
|
2184
2147
|
currentStats.count = 0;
|
|
2185
2148
|
currentStats.summaryCount = 0;
|
|
2186
2149
|
}
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
const
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2150
|
+
const otherSameTimesCartItems = cartItems2.filter((m) => `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end);
|
|
2151
|
+
const otherCartNeedCapacity = otherSameTimesCartItems.reduce((acc, curr) => acc + (0, import_capacity.getCapacityInfoByCartItem)(curr).currentCapacity, 0);
|
|
2152
|
+
const allRenderList = [...n.renderList.filter((m) => !m.onlyComputed)];
|
|
2153
|
+
otherSameTimesCartItems.forEach((m) => {
|
|
2154
|
+
var _a2, _b2;
|
|
2155
|
+
const productResources2 = (0, import_resources.getResourcesByProduct)(
|
|
2156
|
+
(0, import_utils2.getResourcesMap)((targetResourceDate == null ? void 0 : targetResourceDate.resource) || []),
|
|
2157
|
+
((_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) || [],
|
|
2158
|
+
selectedResources,
|
|
2159
|
+
1
|
|
2160
|
+
);
|
|
2161
|
+
productResources2.forEach((m2) => {
|
|
2162
|
+
if (m2.id === n.id) {
|
|
2163
|
+
m2.renderList.forEach((n2) => {
|
|
2164
|
+
if (!n2.onlyComputed && !allRenderList.find((m3) => m3.id === n2.id)) {
|
|
2165
|
+
allRenderList.push(n2);
|
|
2199
2166
|
}
|
|
2200
2167
|
});
|
|
2201
2168
|
}
|
|
2202
2169
|
});
|
|
2203
2170
|
});
|
|
2204
2171
|
const currentTypeResourcesCapacity = allRenderList.reduce((acc, curr) => acc + curr.capacity || 0, 0);
|
|
2205
|
-
// 计算当前时间段内所有资源的已使用容量
|
|
2206
2172
|
const usedCapacity = allRenderList.reduce((acc, curr) => {
|
|
2207
|
-
const mTimes = curr.times.filter(
|
|
2208
|
-
return !(0,
|
|
2173
|
+
const mTimes = curr.times.filter((n2) => {
|
|
2174
|
+
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");
|
|
2209
2175
|
});
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
if ((0, _resources.isConflict)({
|
|
2218
|
-
start_at: m.start_at,
|
|
2219
|
-
end_at: m.end_at
|
|
2220
|
-
}, {
|
|
2221
|
-
start_at: (0, _dayjs.default)(item.start),
|
|
2222
|
-
end_at: (0, _dayjs.default)(item.end)
|
|
2223
|
-
})) {
|
|
2176
|
+
const mSet = /* @__PURE__ */ new Map();
|
|
2177
|
+
mTimes.forEach((n2) => {
|
|
2178
|
+
n2.event_list.forEach((m) => {
|
|
2179
|
+
if ((0, import_resources.isConflict)(
|
|
2180
|
+
{ start_at: m.start_at, end_at: m.end_at },
|
|
2181
|
+
{ start_at: (0, import_dayjs.default)(item.start), end_at: (0, import_dayjs.default)(item.end) }
|
|
2182
|
+
)) {
|
|
2224
2183
|
mSet.set(m.id, m.pax ?? 1);
|
|
2225
2184
|
}
|
|
2226
2185
|
});
|
|
2227
2186
|
});
|
|
2228
|
-
acc += Array.from(mSet.values()).reduce((
|
|
2187
|
+
acc += Array.from(mSet.values()).reduce((acc2, curr2) => acc2 + curr2, 0);
|
|
2229
2188
|
return acc;
|
|
2230
2189
|
}, 0);
|
|
2231
|
-
// 如果已使用容量超过了当前类型资源的容量,则不可用
|
|
2232
2190
|
if (otherCartNeedCapacity + usedCapacity >= currentTypeResourcesCapacity) {
|
|
2233
2191
|
currentStats.left = 0;
|
|
2234
2192
|
currentStats.count = 0;
|
|
@@ -2237,48 +2195,55 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
2237
2195
|
}
|
|
2238
2196
|
statsByResourceType[n.id] = currentStats;
|
|
2239
2197
|
});
|
|
2240
|
-
const startDayJs = (0,
|
|
2241
|
-
const endDayJs = (0,
|
|
2242
|
-
|
|
2243
|
-
// 选择“瓶颈资源类型”:multiple 取 summaryCount 最小,single 取 left 最小
|
|
2198
|
+
const startDayJs = (0, import_dayjs.default)(item.start);
|
|
2199
|
+
const endDayJs = (0, import_dayjs.default)(item.end);
|
|
2244
2200
|
let bottleneckResourceTypeId;
|
|
2245
2201
|
let bottleneckValue = Infinity;
|
|
2246
|
-
enabledResourceTypeConfigs.forEach(cfg => {
|
|
2202
|
+
enabledResourceTypeConfigs.forEach((cfg) => {
|
|
2247
2203
|
const stats = statsByResourceType[cfg.id] || {
|
|
2248
2204
|
count: 0,
|
|
2249
2205
|
left: 0,
|
|
2250
2206
|
summaryCount: 0,
|
|
2251
2207
|
summaryConfigCount: 0
|
|
2252
2208
|
};
|
|
2253
|
-
const value = cfg.type ===
|
|
2209
|
+
const value = cfg.type === "multiple" ? stats.summaryCount : stats.left;
|
|
2254
2210
|
if (value < bottleneckValue) {
|
|
2255
2211
|
bottleneckValue = value;
|
|
2256
2212
|
bottleneckResourceTypeId = cfg.id;
|
|
2257
2213
|
}
|
|
2258
2214
|
});
|
|
2259
|
-
const bottleneckStats = bottleneckResourceTypeId !==
|
|
2215
|
+
const bottleneckStats = bottleneckResourceTypeId !== void 0 ? statsByResourceType[bottleneckResourceTypeId] || {
|
|
2260
2216
|
count: 0,
|
|
2261
2217
|
left: 0,
|
|
2262
2218
|
summaryCount: 0,
|
|
2263
2219
|
summaryConfigCount: 0
|
|
2264
|
-
} : {
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
if (bottleneckStats.left === 0) status = 'sold_out';else if (!bottleneckConfig || bottleneckStats.summaryConfigCount === 0) status = 'sold_out';else if (bottleneckConfig.type === 'multiple') {
|
|
2220
|
+
} : { count: 0, left: 0, summaryCount: 0, summaryConfigCount: 0 };
|
|
2221
|
+
const bottleneckConfig = bottleneckResourceTypeId !== void 0 ? resourceTypeConfigById.get(bottleneckResourceTypeId) : void 0;
|
|
2222
|
+
let status = "sold_out";
|
|
2223
|
+
if (bottleneckStats.left === 0)
|
|
2224
|
+
status = "sold_out";
|
|
2225
|
+
else if (!bottleneckConfig || bottleneckStats.summaryConfigCount === 0)
|
|
2226
|
+
status = "sold_out";
|
|
2227
|
+
else if (bottleneckConfig.type === "multiple") {
|
|
2273
2228
|
const usageRatio = bottleneckStats.summaryCount / bottleneckStats.summaryConfigCount;
|
|
2274
|
-
if (usageRatio > 0.5)
|
|
2229
|
+
if (usageRatio > 0.5)
|
|
2230
|
+
status = "lots_of_space";
|
|
2231
|
+
else if (bottleneckStats.summaryCount > 0)
|
|
2232
|
+
status = "filling_up_fast";
|
|
2233
|
+
else
|
|
2234
|
+
status = "sold_out";
|
|
2275
2235
|
} else {
|
|
2276
2236
|
const usageRatio = bottleneckStats.left / bottleneckStats.summaryConfigCount;
|
|
2277
|
-
if (usageRatio > 0.5)
|
|
2237
|
+
if (usageRatio > 0.5)
|
|
2238
|
+
status = "lots_of_space";
|
|
2239
|
+
else if (bottleneckStats.count > 0)
|
|
2240
|
+
status = "filling_up_fast";
|
|
2241
|
+
else
|
|
2242
|
+
status = "sold_out";
|
|
2278
2243
|
}
|
|
2279
2244
|
return {
|
|
2280
|
-
start_time: startDayJs.format(
|
|
2281
|
-
end_time: endDayJs.format(
|
|
2245
|
+
start_time: startDayJs.format("HH:mm"),
|
|
2246
|
+
end_time: endDayJs.format("HH:mm"),
|
|
2282
2247
|
start_at: startDayJs,
|
|
2283
2248
|
end_at: endDayJs,
|
|
2284
2249
|
count: bottleneckStats.count,
|
|
@@ -2289,7 +2254,6 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
2289
2254
|
});
|
|
2290
2255
|
return formatScheduleTimeSlots;
|
|
2291
2256
|
}
|
|
2292
|
-
|
|
2293
2257
|
// 提供给 UI的方法,当前步骤是选择商品,下一步不管是什么都需要在这里做一次检测
|
|
2294
2258
|
// 时长类商品关联的资源为多个预约时,在点击进入"选择资源"步骤之前,需要检测当前所有资源的总容量
|
|
2295
2259
|
// 选择商品数量大于所有资源配置的总容量时,不能进入下一步,需要在"选择商品"这一步时提示。
|
|
@@ -2298,27 +2262,27 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
2298
2262
|
* 找到多个资源的公共可用时间段
|
|
2299
2263
|
*/
|
|
2300
2264
|
findCommonAvailableTimeSlots(resources) {
|
|
2301
|
-
if (resources.length === 0)
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2265
|
+
if (resources.length === 0)
|
|
2266
|
+
return [];
|
|
2267
|
+
console.log(`计算 ${resources.length} 个资源的公共时间段`);
|
|
2268
|
+
const allTimeSlots = resources.map(
|
|
2269
|
+
(resource) => resource.times.map((time) => ({
|
|
2270
|
+
start: (0, import_dayjs.default)(time.start_at),
|
|
2271
|
+
end: (0, import_dayjs.default)(time.end_at)
|
|
2272
|
+
}))
|
|
2273
|
+
);
|
|
2274
|
+
console.log("所有资源的时间段:", allTimeSlots.map(
|
|
2275
|
+
(slots) => slots.map((slot) => `${slot.start.format("HH:mm")}-${slot.end.format("HH:mm")}`)
|
|
2276
|
+
));
|
|
2277
|
+
let commonSlots = allTimeSlots[0];
|
|
2278
|
+
console.log("初始公共时间段:", commonSlots.map((slot) => `${slot.start.format("HH:mm")}-${slot.end.format("HH:mm")}`));
|
|
2311
2279
|
for (let i = 1; i < allTimeSlots.length; i++) {
|
|
2312
2280
|
const currentResourceSlots = allTimeSlots[i];
|
|
2313
2281
|
const intersections = [];
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
commonSlots.forEach(commonSlot => {
|
|
2317
|
-
currentResourceSlots.forEach(currentSlot => {
|
|
2282
|
+
commonSlots.forEach((commonSlot) => {
|
|
2283
|
+
currentResourceSlots.forEach((currentSlot) => {
|
|
2318
2284
|
const overlapStart = commonSlot.start.isAfter(currentSlot.start) ? commonSlot.start : currentSlot.start;
|
|
2319
2285
|
const overlapEnd = commonSlot.end.isBefore(currentSlot.end) ? commonSlot.end : currentSlot.end;
|
|
2320
|
-
|
|
2321
|
-
// 如果有重叠时间且重叠时间大于0
|
|
2322
2286
|
if (overlapStart.isBefore(overlapEnd)) {
|
|
2323
2287
|
intersections.push({
|
|
2324
2288
|
start: overlapStart,
|
|
@@ -2328,88 +2292,74 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
2328
2292
|
});
|
|
2329
2293
|
});
|
|
2330
2294
|
if (intersections.length === 0) {
|
|
2295
|
+
console.log(`资源${i}与当前公共时间段无交集,跳过该资源`);
|
|
2331
2296
|
continue;
|
|
2332
2297
|
}
|
|
2333
2298
|
commonSlots = intersections;
|
|
2299
|
+
console.log(`与资源${i}求交集后的公共时间段:`, commonSlots.map((slot) => `${slot.start.format("HH:mm")}-${slot.end.format("HH:mm")}`));
|
|
2334
2300
|
}
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
startTime: slot.start.format('HH:mm'),
|
|
2339
|
-
endTime: slot.end.format('HH:mm')
|
|
2301
|
+
const result = commonSlots.map((slot) => ({
|
|
2302
|
+
startTime: slot.start.format("HH:mm"),
|
|
2303
|
+
endTime: slot.end.format("HH:mm")
|
|
2340
2304
|
}));
|
|
2305
|
+
console.log("最终公共时间段:", result);
|
|
2341
2306
|
return result;
|
|
2342
2307
|
}
|
|
2343
2308
|
checkMaxDurationCapacity() {
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
minAvailableCount: 0
|
|
2348
|
-
};
|
|
2349
|
-
|
|
2350
|
-
// 将购物车商品分为有时间的和没有时间的
|
|
2309
|
+
var _a, _b;
|
|
2310
|
+
const cartItems = this.store.cart.getItems().filter((item) => !(0, import_utils5.isNormalProduct)(item._productOrigin));
|
|
2311
|
+
if (cartItems.length === 0)
|
|
2312
|
+
return { success: true, minAvailableCount: 0 };
|
|
2351
2313
|
const itemsWithTime = [];
|
|
2352
2314
|
const itemsWithoutTime = [];
|
|
2353
|
-
// 记录每种资源类型的可用数量
|
|
2354
2315
|
const availableCountsByResourceType = [];
|
|
2355
|
-
cartItems.forEach(cartItem => {
|
|
2316
|
+
cartItems.forEach((cartItem) => {
|
|
2356
2317
|
if (cartItem.start_time && cartItem.end_time && cartItem.start_date) {
|
|
2357
2318
|
itemsWithTime.push(cartItem);
|
|
2358
2319
|
} else {
|
|
2359
2320
|
itemsWithoutTime.push(cartItem);
|
|
2360
2321
|
}
|
|
2361
2322
|
});
|
|
2362
|
-
|
|
2363
|
-
// 处理没有时间的商品,为它们分配公共可用时间的第一个时间片
|
|
2364
2323
|
const processedItemsWithoutTime = [];
|
|
2365
2324
|
if (itemsWithoutTime.length > 0) {
|
|
2366
|
-
// 按资源类型分组处理没有时间的商品
|
|
2367
2325
|
const itemsByResourceType = {};
|
|
2368
|
-
itemsWithoutTime.forEach(cartItem => {
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2326
|
+
itemsWithoutTime.forEach((cartItem) => {
|
|
2327
|
+
var _a2;
|
|
2328
|
+
if (!cartItem._productOrigin)
|
|
2329
|
+
return;
|
|
2330
|
+
const resourceTypes = ((_a2 = cartItem._productOrigin.product_resource) == null ? void 0 : _a2.resources) || [];
|
|
2331
|
+
resourceTypes.forEach((resourceType) => {
|
|
2332
|
+
var _a3;
|
|
2372
2333
|
if (resourceType.status === 1) {
|
|
2373
|
-
const resourceCode = resourceType.code || resourceType.id
|
|
2334
|
+
const resourceCode = resourceType.code || ((_a3 = resourceType.id) == null ? void 0 : _a3.toString());
|
|
2374
2335
|
if (!itemsByResourceType[resourceCode]) {
|
|
2375
2336
|
itemsByResourceType[resourceCode] = [];
|
|
2376
2337
|
}
|
|
2377
|
-
|
|
2378
|
-
// 如果之前添加过的依赖相同资源的跟我现在是同一个 holder,也不需要重复添加
|
|
2379
|
-
if (itemsByResourceType[resourceCode].find(item => item.holder_id === cartItem.holder_id)) {
|
|
2338
|
+
if (itemsByResourceType[resourceCode].find((item) => item.holder_id === cartItem.holder_id)) {
|
|
2380
2339
|
return;
|
|
2381
2340
|
}
|
|
2382
|
-
if (!itemsByResourceType[resourceCode].find(item => item._id === cartItem._id)) {
|
|
2341
|
+
if (!itemsByResourceType[resourceCode].find((item) => item._id === cartItem._id)) {
|
|
2383
2342
|
itemsByResourceType[resourceCode].push(cartItem);
|
|
2384
2343
|
}
|
|
2385
2344
|
}
|
|
2386
2345
|
});
|
|
2387
2346
|
});
|
|
2388
|
-
|
|
2389
|
-
// 为每种资源类型检查容量
|
|
2390
2347
|
const dateRange = this.store.date.getDateRange();
|
|
2391
|
-
if (!dateRange || dateRange.length === 0)
|
|
2392
|
-
success: false,
|
|
2393
|
-
minAvailableCount: 0
|
|
2394
|
-
};
|
|
2348
|
+
if (!dateRange || dateRange.length === 0)
|
|
2349
|
+
return { success: false, minAvailableCount: 0 };
|
|
2395
2350
|
const resourcesDates = this.store.date.getDateList();
|
|
2396
|
-
const targetResourceDate = resourcesDates.find(n => n.date === dateRange[0].date);
|
|
2397
|
-
if (!targetResourceDate)
|
|
2398
|
-
success: false,
|
|
2399
|
-
|
|
2400
|
-
};
|
|
2401
|
-
const resourcesMap = (0, _utils2.getResourcesMap)(targetResourceDate.resource || []);
|
|
2402
|
-
|
|
2403
|
-
// 从购物车商品中获取资源类型配置,建立 resourceCode 到 form_id 的映射关系
|
|
2351
|
+
const targetResourceDate = resourcesDates.find((n) => n.date === dateRange[0].date);
|
|
2352
|
+
if (!targetResourceDate)
|
|
2353
|
+
return { success: false, minAvailableCount: 0 };
|
|
2354
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)(targetResourceDate.resource || []);
|
|
2404
2355
|
const resourceCodeToFormIdMap = {};
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
// 只处理启用的资源类型 (status === 1)
|
|
2356
|
+
Object.values(itemsByResourceType).flat().forEach((cartItem) => {
|
|
2357
|
+
var _a2, _b2;
|
|
2358
|
+
if ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) {
|
|
2359
|
+
cartItem._productOrigin.product_resource.resources.forEach((resourceConfig) => {
|
|
2360
|
+
var _a3, _b3;
|
|
2411
2361
|
if (resourceConfig.status === 1 && resourceConfig.code) {
|
|
2412
|
-
const formId = resourceConfig.id
|
|
2362
|
+
const formId = ((_a3 = resourceConfig.id) == null ? void 0 : _a3.toString()) || ((_b3 = resourceConfig.resource_type_id) == null ? void 0 : _b3.toString());
|
|
2413
2363
|
if (formId) {
|
|
2414
2364
|
resourceCodeToFormIdMap[resourceConfig.code] = formId;
|
|
2415
2365
|
}
|
|
@@ -2419,77 +2369,60 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
2419
2369
|
});
|
|
2420
2370
|
let hasCapacityIssue = false;
|
|
2421
2371
|
const resourceCapacityInfo = [];
|
|
2422
|
-
|
|
2423
|
-
// 用于跟踪已处理的商品,避免重复添加
|
|
2424
|
-
const processedCartItemIds = new Set();
|
|
2425
|
-
|
|
2426
|
-
// 先检查所有资源类型,收集可用数量信息
|
|
2372
|
+
const processedCartItemIds = /* @__PURE__ */ new Set();
|
|
2427
2373
|
for (const [resourceCode, items] of Object.entries(itemsByResourceType)) {
|
|
2428
|
-
// 获取该资源类型对应的 form_id
|
|
2429
2374
|
const targetFormId = resourceCodeToFormIdMap[resourceCode];
|
|
2430
2375
|
if (!targetFormId) {
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
minAvailableCount: 0
|
|
2434
|
-
};
|
|
2376
|
+
console.log(`资源类型 ${resourceCode} 找不到对应的 form_id`);
|
|
2377
|
+
return { success: false, minAvailableCount: 0 };
|
|
2435
2378
|
}
|
|
2436
|
-
|
|
2437
|
-
// 获取该资源类型的所有资源
|
|
2438
2379
|
const resourcesOfThisType = [];
|
|
2439
|
-
items.forEach(cartItem => {
|
|
2440
|
-
const productResourceIds = (0,
|
|
2441
|
-
productResourceIds.forEach(resourceId => {
|
|
2380
|
+
items.forEach((cartItem) => {
|
|
2381
|
+
const productResourceIds = (0, import_capacity.getResourcesIdsByProduct)(cartItem._productOrigin);
|
|
2382
|
+
productResourceIds.forEach((resourceId) => {
|
|
2383
|
+
var _a2;
|
|
2442
2384
|
const resource = resourcesMap[resourceId];
|
|
2443
|
-
if (resource && resource.form_id
|
|
2444
|
-
|
|
2445
|
-
if (!resourcesOfThisType.find(r => r.id === resource.id)) {
|
|
2385
|
+
if (resource && ((_a2 = resource.form_id) == null ? void 0 : _a2.toString()) === targetFormId) {
|
|
2386
|
+
if (!resourcesOfThisType.find((r) => r.id === resource.id)) {
|
|
2446
2387
|
resourcesOfThisType.push(resource);
|
|
2447
2388
|
}
|
|
2448
2389
|
}
|
|
2449
2390
|
});
|
|
2450
2391
|
});
|
|
2451
2392
|
if (resourcesOfThisType.length === 0) {
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
minAvailableCount: 0
|
|
2455
|
-
};
|
|
2393
|
+
console.log(`资源类型 ${resourceCode} 没有找到可用资源`);
|
|
2394
|
+
return { success: false, minAvailableCount: 0 };
|
|
2456
2395
|
}
|
|
2457
|
-
|
|
2458
|
-
// 检查资源类型(单个预约 vs 多个预约)
|
|
2459
|
-
// 从商品配置中获取资源类型信息
|
|
2460
2396
|
let resourceTypeConfig = null;
|
|
2461
2397
|
for (const cartItem of items) {
|
|
2462
|
-
if (cartItem._productOrigin
|
|
2463
|
-
resourceTypeConfig = cartItem._productOrigin.product_resource.resources.find(
|
|
2464
|
-
|
|
2398
|
+
if ((_b = (_a = cartItem._productOrigin) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) {
|
|
2399
|
+
resourceTypeConfig = cartItem._productOrigin.product_resource.resources.find(
|
|
2400
|
+
(r) => r.code === resourceCode && r.status === 1
|
|
2401
|
+
);
|
|
2402
|
+
if (resourceTypeConfig)
|
|
2403
|
+
break;
|
|
2465
2404
|
}
|
|
2466
2405
|
}
|
|
2467
|
-
const isMultipleBooking = resourceTypeConfig
|
|
2406
|
+
const isMultipleBooking = (resourceTypeConfig == null ? void 0 : resourceTypeConfig.type) === "multiple";
|
|
2468
2407
|
let totalAvailable;
|
|
2469
2408
|
let requiredAmount;
|
|
2470
2409
|
let availableAmount;
|
|
2471
2410
|
if (isMultipleBooking) {
|
|
2472
|
-
// 多个预约:计算容量
|
|
2473
2411
|
totalAvailable = resourcesOfThisType.reduce((sum, resource) => {
|
|
2474
2412
|
return sum + (resource.capacity || 0);
|
|
2475
2413
|
}, 0);
|
|
2476
2414
|
requiredAmount = items.reduce((sum, cartItem) => {
|
|
2477
|
-
const {
|
|
2478
|
-
currentCapacity
|
|
2479
|
-
} = (0, _capacity.getCapacityInfoByCartItem)(cartItem);
|
|
2415
|
+
const { currentCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(cartItem);
|
|
2480
2416
|
return sum + currentCapacity;
|
|
2481
2417
|
}, 0);
|
|
2482
2418
|
availableAmount = Math.max(0, totalAvailable - requiredAmount);
|
|
2483
2419
|
} else {
|
|
2484
|
-
// 单个预约:计算资源个数
|
|
2485
2420
|
totalAvailable = resourcesOfThisType.length;
|
|
2486
2421
|
requiredAmount = items.reduce((sum, cartItem) => {
|
|
2487
2422
|
return sum + (cartItem.num || 1);
|
|
2488
2423
|
}, 0);
|
|
2489
2424
|
availableAmount = Math.max(0, totalAvailable - requiredAmount);
|
|
2490
2425
|
}
|
|
2491
|
-
|
|
2492
|
-
// 记录资源容量信息
|
|
2493
2426
|
resourceCapacityInfo.push({
|
|
2494
2427
|
code: resourceCode,
|
|
2495
2428
|
available: availableAmount,
|
|
@@ -2498,27 +2431,23 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
2498
2431
|
isMultiple: isMultipleBooking
|
|
2499
2432
|
});
|
|
2500
2433
|
availableCountsByResourceType.push(availableAmount);
|
|
2501
|
-
|
|
2502
|
-
// 检查是否有容量问题
|
|
2503
2434
|
if (requiredAmount > totalAvailable) {
|
|
2504
2435
|
hasCapacityIssue = true;
|
|
2436
|
+
console.log(`资源类型 ${resourceCode} ${isMultipleBooking ? "容量" : "资源数量"}不足: 需要 ${requiredAmount}, 总共 ${totalAvailable}`);
|
|
2505
2437
|
}
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2438
|
+
console.log(`资源类型 ${resourceCode} 的资源时间信息:`, resourcesOfThisType.map((r) => ({
|
|
2439
|
+
id: r.id,
|
|
2440
|
+
times: r.times.map((t) => `${t.start_at} - ${t.end_at}`)
|
|
2441
|
+
})));
|
|
2510
2442
|
const commonTimeSlots = this.findCommonAvailableTimeSlots(resourcesOfThisType);
|
|
2443
|
+
console.log(`资源类型 ${resourceCode} 的公共时间段:`, commonTimeSlots);
|
|
2511
2444
|
if (commonTimeSlots.length === 0) {
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
minAvailableCount: 0
|
|
2515
|
-
};
|
|
2445
|
+
console.log(`资源类型 ${resourceCode} 没有公共可用时间段`);
|
|
2446
|
+
return { success: false, minAvailableCount: 0 };
|
|
2516
2447
|
}
|
|
2517
|
-
|
|
2518
|
-
// 使用第一个公共可用时间段,但只处理未处理过的商品
|
|
2519
2448
|
const firstCommonSlot = commonTimeSlots[0];
|
|
2520
|
-
|
|
2521
|
-
|
|
2449
|
+
console.log(`使用公共时间段: ${firstCommonSlot.startTime} - ${firstCommonSlot.endTime}`);
|
|
2450
|
+
items.forEach((cartItem) => {
|
|
2522
2451
|
if (!processedCartItemIds.has(cartItem._id)) {
|
|
2523
2452
|
processedCartItemIds.add(cartItem._id);
|
|
2524
2453
|
const processedItem = {
|
|
@@ -2532,93 +2461,59 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
2532
2461
|
}
|
|
2533
2462
|
});
|
|
2534
2463
|
}
|
|
2535
|
-
|
|
2536
|
-
// 如果有容量问题,找出限制最严格的资源类型,返回其总容量
|
|
2537
2464
|
if (hasCapacityIssue) {
|
|
2538
|
-
|
|
2539
|
-
const overCapacityResources = resourceCapacityInfo.filter(info => info.required > info.total);
|
|
2465
|
+
const overCapacityResources = resourceCapacityInfo.filter((info) => info.required > info.total);
|
|
2540
2466
|
if (overCapacityResources.length > 0) {
|
|
2541
|
-
const
|
|
2542
|
-
return {
|
|
2543
|
-
success: false,
|
|
2544
|
-
minAvailableCount: minTotalCapacity
|
|
2545
|
-
};
|
|
2467
|
+
const minTotalCapacity2 = Math.min(...overCapacityResources.map((info) => info.total));
|
|
2468
|
+
return { success: false, minAvailableCount: minTotalCapacity2 };
|
|
2546
2469
|
}
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
return {
|
|
2550
|
-
success: false,
|
|
2551
|
-
minAvailableCount: minTotalCapacity
|
|
2552
|
-
};
|
|
2470
|
+
const minTotalCapacity = Math.min(...resourceCapacityInfo.map((info) => info.total));
|
|
2471
|
+
return { success: false, minAvailableCount: minTotalCapacity };
|
|
2553
2472
|
}
|
|
2554
2473
|
}
|
|
2555
|
-
|
|
2556
|
-
// 合并所有商品(有时间的 + 处理后的没有时间的)
|
|
2557
2474
|
const allProcessedItems = [...itemsWithTime, ...processedItemsWithoutTime];
|
|
2558
|
-
|
|
2559
|
-
// 按时间段分组检查
|
|
2560
2475
|
const cartItemsByTimeSlot = {};
|
|
2561
|
-
allProcessedItems.forEach(cartItem => {
|
|
2562
|
-
if (!cartItem.start_time || !cartItem.end_time || !cartItem.start_date)
|
|
2476
|
+
allProcessedItems.forEach((cartItem) => {
|
|
2477
|
+
if (!cartItem.start_time || !cartItem.end_time || !cartItem.start_date)
|
|
2478
|
+
return;
|
|
2563
2479
|
const timeSlotKey = `${cartItem.start_date}_${cartItem.start_time}_${cartItem.end_date || cartItem.start_date}_${cartItem.end_time}`;
|
|
2564
2480
|
if (!cartItemsByTimeSlot[timeSlotKey]) {
|
|
2565
2481
|
cartItemsByTimeSlot[timeSlotKey] = [];
|
|
2566
2482
|
}
|
|
2567
2483
|
cartItemsByTimeSlot[timeSlotKey].push(cartItem);
|
|
2568
2484
|
});
|
|
2569
|
-
// 检查每个时间段是否有足够的资源容量
|
|
2570
2485
|
for (const [timeSlotKey, itemsInTimeSlot] of Object.entries(cartItemsByTimeSlot)) {
|
|
2571
|
-
const [startDate, startTime, endDate, endTime] = timeSlotKey.split(
|
|
2486
|
+
const [startDate, startTime, endDate, endTime] = timeSlotKey.split("_");
|
|
2572
2487
|
const timeSlotStart = `${startDate} ${startTime}`;
|
|
2573
2488
|
const timeSlotEnd = `${endDate} ${endTime}`;
|
|
2574
|
-
|
|
2575
|
-
// 获取这个时间段所有商品涉及的资源
|
|
2576
2489
|
const allResourcesForTimeSlot = [];
|
|
2577
|
-
const resourcesIdSet = new Set();
|
|
2578
|
-
|
|
2579
|
-
// 获取资源数据
|
|
2490
|
+
const resourcesIdSet = /* @__PURE__ */ new Set();
|
|
2580
2491
|
const dateRange = this.store.date.getDateRange();
|
|
2581
2492
|
const resourcesDates = this.store.date.getDateList();
|
|
2582
|
-
const targetResourceDate = resourcesDates.find(n => n.date === startDate);
|
|
2583
|
-
if (!targetResourceDate)
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
const productResourceIds = (0,
|
|
2590
|
-
productResourceIds.forEach(resourceId => {
|
|
2493
|
+
const targetResourceDate = resourcesDates.find((n) => n.date === startDate);
|
|
2494
|
+
if (!targetResourceDate)
|
|
2495
|
+
continue;
|
|
2496
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)(targetResourceDate.resource || []);
|
|
2497
|
+
itemsInTimeSlot.forEach((cartItem) => {
|
|
2498
|
+
if (!cartItem._productOrigin)
|
|
2499
|
+
return;
|
|
2500
|
+
const productResourceIds = (0, import_capacity.getResourcesIdsByProduct)(cartItem._productOrigin);
|
|
2501
|
+
productResourceIds.forEach((resourceId) => {
|
|
2591
2502
|
if (resourcesMap[resourceId] && !resourcesIdSet.has(resourceId)) {
|
|
2592
2503
|
resourcesIdSet.add(resourceId);
|
|
2593
2504
|
allResourcesForTimeSlot.push(resourcesMap[resourceId]);
|
|
2594
2505
|
}
|
|
2595
2506
|
});
|
|
2596
2507
|
});
|
|
2597
|
-
|
|
2598
|
-
// 按资源类型分组检查容量
|
|
2599
|
-
const {
|
|
2600
|
-
success,
|
|
2601
|
-
required,
|
|
2602
|
-
available
|
|
2603
|
-
} = (0, _capacity.checkTimeSlotCapacity)(timeSlotStart, timeSlotEnd, itemsInTimeSlot, allResourcesForTimeSlot);
|
|
2508
|
+
const { success, required, available } = (0, import_capacity.checkTimeSlotCapacity)(timeSlotStart, timeSlotEnd, itemsInTimeSlot, allResourcesForTimeSlot);
|
|
2604
2509
|
if (!success) {
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
return {
|
|
2608
|
-
success: false,
|
|
2609
|
-
minAvailableCount
|
|
2610
|
-
};
|
|
2510
|
+
const minAvailableCount2 = availableCountsByResourceType.length > 0 ? Math.min(...availableCountsByResourceType) : 0;
|
|
2511
|
+
return { success: false, minAvailableCount: minAvailableCount2 };
|
|
2611
2512
|
}
|
|
2612
2513
|
}
|
|
2613
|
-
|
|
2614
|
-
// 全部通过检测,返回成功和最小可用数量
|
|
2615
2514
|
const minAvailableCount = availableCountsByResourceType.length > 0 ? Math.min(...availableCountsByResourceType) : 0;
|
|
2616
|
-
return {
|
|
2617
|
-
success: true,
|
|
2618
|
-
minAvailableCount
|
|
2619
|
-
};
|
|
2515
|
+
return { success: true, minAvailableCount };
|
|
2620
2516
|
}
|
|
2621
|
-
|
|
2622
2517
|
/**
|
|
2623
2518
|
* 将 ProductData 转换为 CartItem,但不添加到购物车
|
|
2624
2519
|
* 参考 addProductToCart 方法的实现
|
|
@@ -2635,34 +2530,21 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
2635
2530
|
product_variant_id,
|
|
2636
2531
|
quantity = 1
|
|
2637
2532
|
} = product || {};
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
const productData = {
|
|
2641
|
-
...origin,
|
|
2642
|
-
product_variant_id
|
|
2643
|
-
};
|
|
2644
|
-
|
|
2645
|
-
// 处理组合商品
|
|
2646
|
-
const processedProduct = (0, _utils.handleVariantProduct)(productData);
|
|
2647
|
-
|
|
2648
|
-
// 如果没有传入账户,获取当前活跃账户
|
|
2533
|
+
const productData = { ...origin, product_variant_id };
|
|
2534
|
+
const processedProduct = (0, import_utils.handleVariantProduct)(productData);
|
|
2649
2535
|
if (!account) {
|
|
2650
2536
|
const activeAccount = this.getActiveAccount();
|
|
2651
2537
|
if (activeAccount) {
|
|
2652
2538
|
account = activeAccount;
|
|
2653
2539
|
}
|
|
2654
2540
|
}
|
|
2655
|
-
|
|
2656
|
-
// 创建基础的 CartItem
|
|
2657
2541
|
const cartItem = {
|
|
2658
|
-
_id: (0,
|
|
2659
|
-
_origin: (0,
|
|
2542
|
+
_id: (0, import_utils.getUniqueId)("temp_"),
|
|
2543
|
+
_origin: (0, import_utils.createCartItemOrigin)(),
|
|
2660
2544
|
_productOrigin: processedProduct,
|
|
2661
2545
|
_productInit: product
|
|
2662
2546
|
};
|
|
2663
|
-
|
|
2664
|
-
// 使用格式化函数填充 CartItem 数据
|
|
2665
|
-
(0, _utils.formatProductToCartItem)({
|
|
2547
|
+
(0, import_utils.formatProductToCartItem)({
|
|
2666
2548
|
cartItem,
|
|
2667
2549
|
product: processedProduct,
|
|
2668
2550
|
bundle,
|
|
@@ -2670,18 +2552,14 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
2670
2552
|
product_variant_id,
|
|
2671
2553
|
quantity
|
|
2672
2554
|
});
|
|
2673
|
-
|
|
2674
|
-
// 如果有日期信息,格式化日期到购物车
|
|
2675
2555
|
if (date) {
|
|
2676
|
-
(0,
|
|
2556
|
+
(0, import_utils.formatDateToCartItem)({
|
|
2677
2557
|
cartItem,
|
|
2678
2558
|
date
|
|
2679
2559
|
});
|
|
2680
2560
|
}
|
|
2681
|
-
|
|
2682
|
-
// 如果有账户信息,格式化账户到购物车
|
|
2683
2561
|
if (account) {
|
|
2684
|
-
(0,
|
|
2562
|
+
(0, import_utils.formatAccountToCartItem)({
|
|
2685
2563
|
cartItem,
|
|
2686
2564
|
account
|
|
2687
2565
|
});
|
|
@@ -2693,79 +2571,59 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
2693
2571
|
date,
|
|
2694
2572
|
account
|
|
2695
2573
|
}) {
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
const currentCartItem = this.convertProductToCartItem({
|
|
2700
|
-
product,
|
|
2701
|
-
date,
|
|
2702
|
-
account
|
|
2703
|
-
});
|
|
2574
|
+
var _a, _b;
|
|
2575
|
+
const cartItems = this.store.cart.getItems().filter((item) => !(0, import_utils5.isNormalProduct)(item._productOrigin));
|
|
2576
|
+
const currentCartItem = this.convertProductToCartItem({ product, date, account });
|
|
2704
2577
|
cartItems.push(currentCartItem);
|
|
2705
|
-
if (cartItems.length === 0)
|
|
2706
|
-
success: true,
|
|
2707
|
-
minAvailableCount: 0
|
|
2708
|
-
};
|
|
2709
|
-
|
|
2710
|
-
// 将购物车商品分为有时间的和没有时间的
|
|
2578
|
+
if (cartItems.length === 0)
|
|
2579
|
+
return { success: true, minAvailableCount: 0 };
|
|
2711
2580
|
const itemsWithTime = [];
|
|
2712
2581
|
const itemsWithoutTime = [];
|
|
2713
|
-
// 记录每种资源类型的可用数量
|
|
2714
2582
|
const availableCountsByResourceType = [];
|
|
2715
|
-
cartItems.forEach(cartItem => {
|
|
2583
|
+
cartItems.forEach((cartItem) => {
|
|
2716
2584
|
if (cartItem.start_time && cartItem.end_time && cartItem.start_date) {
|
|
2717
2585
|
itemsWithTime.push(cartItem);
|
|
2718
2586
|
} else {
|
|
2719
2587
|
itemsWithoutTime.push(cartItem);
|
|
2720
2588
|
}
|
|
2721
2589
|
});
|
|
2722
|
-
|
|
2723
|
-
// 处理没有时间的商品,为它们分配公共可用时间的第一个时间片
|
|
2724
2590
|
const processedItemsWithoutTime = [];
|
|
2725
2591
|
if (itemsWithoutTime.length > 0) {
|
|
2726
|
-
// 按资源类型分组处理没有时间的商品
|
|
2727
2592
|
const itemsByResourceType = {};
|
|
2728
|
-
itemsWithoutTime.forEach(cartItem => {
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2593
|
+
itemsWithoutTime.forEach((cartItem) => {
|
|
2594
|
+
var _a2;
|
|
2595
|
+
if (!cartItem._productOrigin)
|
|
2596
|
+
return;
|
|
2597
|
+
const resourceTypes = ((_a2 = cartItem._productOrigin.product_resource) == null ? void 0 : _a2.resources) || [];
|
|
2598
|
+
resourceTypes.forEach((resourceType) => {
|
|
2599
|
+
var _a3;
|
|
2732
2600
|
if (resourceType.status === 1) {
|
|
2733
|
-
const resourceCode = resourceType.code || resourceType.id
|
|
2601
|
+
const resourceCode = resourceType.code || ((_a3 = resourceType.id) == null ? void 0 : _a3.toString());
|
|
2734
2602
|
if (!itemsByResourceType[resourceCode]) {
|
|
2735
2603
|
itemsByResourceType[resourceCode] = [];
|
|
2736
2604
|
}
|
|
2737
|
-
|
|
2738
|
-
if (!itemsByResourceType[resourceCode].find(item => item._id === cartItem._id)) {
|
|
2605
|
+
if (!itemsByResourceType[resourceCode].find((item) => item._id === cartItem._id)) {
|
|
2739
2606
|
itemsByResourceType[resourceCode].push(cartItem);
|
|
2740
2607
|
}
|
|
2741
2608
|
}
|
|
2742
2609
|
});
|
|
2743
2610
|
});
|
|
2744
|
-
|
|
2745
|
-
// 为每种资源类型检查容量
|
|
2746
2611
|
const dateRange = this.store.date.getDateRange();
|
|
2747
|
-
if (!dateRange || dateRange.length === 0)
|
|
2748
|
-
success: false,
|
|
2749
|
-
minAvailableCount: 0
|
|
2750
|
-
};
|
|
2612
|
+
if (!dateRange || dateRange.length === 0)
|
|
2613
|
+
return { success: false, minAvailableCount: 0 };
|
|
2751
2614
|
const resourcesDates = this.store.date.getDateList();
|
|
2752
|
-
const targetResourceDate = resourcesDates.find(n => n.date === dateRange[0].date);
|
|
2753
|
-
if (!targetResourceDate)
|
|
2754
|
-
success: false,
|
|
2755
|
-
|
|
2756
|
-
};
|
|
2757
|
-
const resourcesMap = (0, _utils2.getResourcesMap)(targetResourceDate.resource || []);
|
|
2758
|
-
|
|
2759
|
-
// 从购物车商品中获取资源类型配置,建立 resourceCode 到 form_id 的映射关系
|
|
2615
|
+
const targetResourceDate = resourcesDates.find((n) => n.date === dateRange[0].date);
|
|
2616
|
+
if (!targetResourceDate)
|
|
2617
|
+
return { success: false, minAvailableCount: 0 };
|
|
2618
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)(targetResourceDate.resource || []);
|
|
2760
2619
|
const resourceCodeToFormIdMap = {};
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
// 只处理启用的资源类型 (status === 1)
|
|
2620
|
+
Object.values(itemsByResourceType).flat().forEach((cartItem) => {
|
|
2621
|
+
var _a2, _b2;
|
|
2622
|
+
if ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) {
|
|
2623
|
+
cartItem._productOrigin.product_resource.resources.forEach((resourceConfig) => {
|
|
2624
|
+
var _a3, _b3;
|
|
2767
2625
|
if (resourceConfig.status === 1 && resourceConfig.code) {
|
|
2768
|
-
const formId = resourceConfig.id
|
|
2626
|
+
const formId = ((_a3 = resourceConfig.id) == null ? void 0 : _a3.toString()) || ((_b3 = resourceConfig.resource_type_id) == null ? void 0 : _b3.toString());
|
|
2769
2627
|
if (formId) {
|
|
2770
2628
|
resourceCodeToFormIdMap[resourceConfig.code] = formId;
|
|
2771
2629
|
}
|
|
@@ -2775,77 +2633,60 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
2775
2633
|
});
|
|
2776
2634
|
let hasCapacityIssue = false;
|
|
2777
2635
|
const resourceCapacityInfo = [];
|
|
2778
|
-
|
|
2779
|
-
// 用于跟踪已处理的商品,避免重复添加
|
|
2780
|
-
const processedCartItemIds = new Set();
|
|
2781
|
-
|
|
2782
|
-
// 先检查所有资源类型,收集可用数量信息
|
|
2636
|
+
const processedCartItemIds = /* @__PURE__ */ new Set();
|
|
2783
2637
|
for (const [resourceCode, items] of Object.entries(itemsByResourceType)) {
|
|
2784
|
-
// 获取该资源类型对应的 form_id
|
|
2785
2638
|
const targetFormId = resourceCodeToFormIdMap[resourceCode];
|
|
2786
2639
|
if (!targetFormId) {
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
minAvailableCount: 0
|
|
2790
|
-
};
|
|
2640
|
+
console.log(`资源类型 ${resourceCode} 找不到对应的 form_id`);
|
|
2641
|
+
return { success: false, minAvailableCount: 0 };
|
|
2791
2642
|
}
|
|
2792
|
-
|
|
2793
|
-
// 获取该资源类型的所有资源
|
|
2794
2643
|
const resourcesOfThisType = [];
|
|
2795
|
-
items.forEach(cartItem => {
|
|
2796
|
-
const productResourceIds = (0,
|
|
2797
|
-
productResourceIds.forEach(resourceId => {
|
|
2644
|
+
items.forEach((cartItem) => {
|
|
2645
|
+
const productResourceIds = (0, import_capacity.getResourcesIdsByProduct)(cartItem._productOrigin);
|
|
2646
|
+
productResourceIds.forEach((resourceId) => {
|
|
2647
|
+
var _a2;
|
|
2798
2648
|
const resource = resourcesMap[resourceId];
|
|
2799
|
-
if (resource && resource.form_id
|
|
2800
|
-
|
|
2801
|
-
if (!resourcesOfThisType.find(r => r.id === resource.id)) {
|
|
2649
|
+
if (resource && ((_a2 = resource.form_id) == null ? void 0 : _a2.toString()) === targetFormId) {
|
|
2650
|
+
if (!resourcesOfThisType.find((r) => r.id === resource.id)) {
|
|
2802
2651
|
resourcesOfThisType.push(resource);
|
|
2803
2652
|
}
|
|
2804
2653
|
}
|
|
2805
2654
|
});
|
|
2806
2655
|
});
|
|
2807
2656
|
if (resourcesOfThisType.length === 0) {
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
minAvailableCount: 0
|
|
2811
|
-
};
|
|
2657
|
+
console.log(`资源类型 ${resourceCode} 没有找到可用资源`);
|
|
2658
|
+
return { success: false, minAvailableCount: 0 };
|
|
2812
2659
|
}
|
|
2813
|
-
|
|
2814
|
-
// 检查资源类型(单个预约 vs 多个预约)
|
|
2815
|
-
// 从商品配置中获取资源类型信息
|
|
2816
2660
|
let resourceTypeConfig = null;
|
|
2817
2661
|
for (const cartItem of items) {
|
|
2818
|
-
if (cartItem._productOrigin
|
|
2819
|
-
resourceTypeConfig = cartItem._productOrigin.product_resource.resources.find(
|
|
2820
|
-
|
|
2662
|
+
if ((_b = (_a = cartItem._productOrigin) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) {
|
|
2663
|
+
resourceTypeConfig = cartItem._productOrigin.product_resource.resources.find(
|
|
2664
|
+
(r) => r.code === resourceCode && r.status === 1
|
|
2665
|
+
);
|
|
2666
|
+
if (resourceTypeConfig)
|
|
2667
|
+
break;
|
|
2821
2668
|
}
|
|
2822
2669
|
}
|
|
2823
|
-
const isMultipleBooking = resourceTypeConfig
|
|
2670
|
+
const isMultipleBooking = (resourceTypeConfig == null ? void 0 : resourceTypeConfig.type) === "multiple";
|
|
2824
2671
|
let totalAvailable;
|
|
2825
2672
|
let requiredAmount;
|
|
2826
2673
|
let availableAmount;
|
|
2827
2674
|
if (isMultipleBooking) {
|
|
2828
|
-
// 多个预约:计算容量
|
|
2829
2675
|
totalAvailable = resourcesOfThisType.reduce((sum, resource) => {
|
|
2830
2676
|
return sum + (resource.capacity || 0);
|
|
2831
2677
|
}, 0);
|
|
2832
2678
|
requiredAmount = items.reduce((sum, cartItem) => {
|
|
2833
|
-
const {
|
|
2834
|
-
currentCapacity
|
|
2835
|
-
} = (0, _capacity.getCapacityInfoByCartItem)(cartItem);
|
|
2679
|
+
const { currentCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(cartItem);
|
|
2836
2680
|
return sum + currentCapacity;
|
|
2837
2681
|
}, 0);
|
|
2838
2682
|
availableAmount = Math.max(0, totalAvailable - requiredAmount);
|
|
2839
2683
|
} else {
|
|
2840
|
-
// 单个预约:计算资源个数
|
|
2841
2684
|
totalAvailable = resourcesOfThisType.length;
|
|
2842
2685
|
requiredAmount = items.reduce((sum, cartItem) => {
|
|
2843
2686
|
return sum + (cartItem.num || 1);
|
|
2844
2687
|
}, 0);
|
|
2845
2688
|
availableAmount = Math.max(0, totalAvailable - requiredAmount);
|
|
2846
2689
|
}
|
|
2847
|
-
|
|
2848
|
-
// 记录资源容量信息
|
|
2849
2690
|
resourceCapacityInfo.push({
|
|
2850
2691
|
code: resourceCode,
|
|
2851
2692
|
available: availableAmount,
|
|
@@ -2854,27 +2695,23 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
2854
2695
|
isMultiple: isMultipleBooking
|
|
2855
2696
|
});
|
|
2856
2697
|
availableCountsByResourceType.push(availableAmount);
|
|
2857
|
-
|
|
2858
|
-
// 检查是否有容量问题
|
|
2859
2698
|
if (requiredAmount > totalAvailable) {
|
|
2860
2699
|
hasCapacityIssue = true;
|
|
2700
|
+
console.log(`资源类型 ${resourceCode} ${isMultipleBooking ? "容量" : "资源数量"}不足: 需要 ${requiredAmount}, 总共 ${totalAvailable}`);
|
|
2861
2701
|
}
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2702
|
+
console.log(`资源类型 ${resourceCode} 的资源时间信息:`, resourcesOfThisType.map((r) => ({
|
|
2703
|
+
id: r.id,
|
|
2704
|
+
times: r.times.map((t) => `${t.start_at} - ${t.end_at}`)
|
|
2705
|
+
})));
|
|
2866
2706
|
const commonTimeSlots = this.findCommonAvailableTimeSlots(resourcesOfThisType);
|
|
2707
|
+
console.log(`资源类型 ${resourceCode} 的公共时间段:`, commonTimeSlots);
|
|
2867
2708
|
if (commonTimeSlots.length === 0) {
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
minAvailableCount: 0
|
|
2871
|
-
};
|
|
2709
|
+
console.log(`资源类型 ${resourceCode} 没有公共可用时间段`);
|
|
2710
|
+
return { success: false, minAvailableCount: 0 };
|
|
2872
2711
|
}
|
|
2873
|
-
|
|
2874
|
-
// 使用第一个公共可用时间段,但只处理未处理过的商品
|
|
2875
2712
|
const firstCommonSlot = commonTimeSlots[0];
|
|
2876
|
-
|
|
2877
|
-
|
|
2713
|
+
console.log(`使用公共时间段: ${firstCommonSlot.startTime} - ${firstCommonSlot.endTime}`);
|
|
2714
|
+
items.forEach((cartItem) => {
|
|
2878
2715
|
if (!processedCartItemIds.has(cartItem._id)) {
|
|
2879
2716
|
processedCartItemIds.add(cartItem._id);
|
|
2880
2717
|
const processedItem = {
|
|
@@ -2888,120 +2725,83 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
2888
2725
|
}
|
|
2889
2726
|
});
|
|
2890
2727
|
}
|
|
2891
|
-
|
|
2892
|
-
// 如果有容量问题,找出限制最严格的资源类型,返回其总容量
|
|
2893
2728
|
if (hasCapacityIssue) {
|
|
2894
|
-
|
|
2895
|
-
const overCapacityResources = resourceCapacityInfo.filter(info => info.required > info.total);
|
|
2729
|
+
const overCapacityResources = resourceCapacityInfo.filter((info) => info.required > info.total);
|
|
2896
2730
|
if (overCapacityResources.length > 0) {
|
|
2897
|
-
const
|
|
2898
|
-
return {
|
|
2899
|
-
success: false,
|
|
2900
|
-
minAvailableCount: minTotalCapacity
|
|
2901
|
-
};
|
|
2731
|
+
const minTotalCapacity2 = Math.min(...overCapacityResources.map((info) => info.total));
|
|
2732
|
+
return { success: false, minAvailableCount: minTotalCapacity2 };
|
|
2902
2733
|
}
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
return {
|
|
2906
|
-
success: false,
|
|
2907
|
-
minAvailableCount: minTotalCapacity
|
|
2908
|
-
};
|
|
2734
|
+
const minTotalCapacity = Math.min(...resourceCapacityInfo.map((info) => info.total));
|
|
2735
|
+
return { success: false, minAvailableCount: minTotalCapacity };
|
|
2909
2736
|
}
|
|
2910
2737
|
}
|
|
2911
|
-
|
|
2912
|
-
// 合并所有商品(有时间的 + 处理后的没有时间的)
|
|
2913
2738
|
const allProcessedItems = [...itemsWithTime, ...processedItemsWithoutTime];
|
|
2914
|
-
|
|
2915
|
-
// 按时间段分组检查
|
|
2916
2739
|
const cartItemsByTimeSlot = {};
|
|
2917
|
-
allProcessedItems.forEach(cartItem => {
|
|
2918
|
-
if (!cartItem.start_time || !cartItem.end_time || !cartItem.start_date)
|
|
2740
|
+
allProcessedItems.forEach((cartItem) => {
|
|
2741
|
+
if (!cartItem.start_time || !cartItem.end_time || !cartItem.start_date)
|
|
2742
|
+
return;
|
|
2919
2743
|
const timeSlotKey = `${cartItem.start_date}_${cartItem.start_time}_${cartItem.end_date || cartItem.start_date}_${cartItem.end_time}`;
|
|
2920
2744
|
if (!cartItemsByTimeSlot[timeSlotKey]) {
|
|
2921
2745
|
cartItemsByTimeSlot[timeSlotKey] = [];
|
|
2922
2746
|
}
|
|
2923
2747
|
cartItemsByTimeSlot[timeSlotKey].push(cartItem);
|
|
2924
2748
|
});
|
|
2925
|
-
// 检查每个时间段是否有足够的资源容量
|
|
2926
2749
|
for (const [timeSlotKey, itemsInTimeSlot] of Object.entries(cartItemsByTimeSlot)) {
|
|
2927
|
-
const [startDate, startTime, endDate, endTime] = timeSlotKey.split(
|
|
2750
|
+
const [startDate, startTime, endDate, endTime] = timeSlotKey.split("_");
|
|
2928
2751
|
const timeSlotStart = `${startDate} ${startTime}`;
|
|
2929
2752
|
const timeSlotEnd = `${endDate} ${endTime}`;
|
|
2930
|
-
|
|
2931
|
-
// 获取这个时间段所有商品涉及的资源
|
|
2932
2753
|
const allResourcesForTimeSlot = [];
|
|
2933
|
-
const resourcesIdSet = new Set();
|
|
2934
|
-
|
|
2935
|
-
// 获取资源数据
|
|
2936
|
-
// const dateRange = this.store.date.getDateRange();
|
|
2754
|
+
const resourcesIdSet = /* @__PURE__ */ new Set();
|
|
2937
2755
|
const resourcesDates = this.store.date.getDateList();
|
|
2938
|
-
const targetResourceDate = resourcesDates.find(n => n.date === startDate);
|
|
2939
|
-
if (!targetResourceDate)
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
const productResourceIds = (0,
|
|
2946
|
-
productResourceIds.forEach(resourceId => {
|
|
2756
|
+
const targetResourceDate = resourcesDates.find((n) => n.date === startDate);
|
|
2757
|
+
if (!targetResourceDate)
|
|
2758
|
+
continue;
|
|
2759
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)(targetResourceDate.resource || []);
|
|
2760
|
+
itemsInTimeSlot.forEach((cartItem) => {
|
|
2761
|
+
if (!cartItem._productOrigin)
|
|
2762
|
+
return;
|
|
2763
|
+
const productResourceIds = (0, import_capacity.getResourcesIdsByProduct)(cartItem._productOrigin);
|
|
2764
|
+
productResourceIds.forEach((resourceId) => {
|
|
2947
2765
|
if (resourcesMap[resourceId] && !resourcesIdSet.has(resourceId)) {
|
|
2948
2766
|
resourcesIdSet.add(resourceId);
|
|
2949
2767
|
allResourcesForTimeSlot.push(resourcesMap[resourceId]);
|
|
2950
2768
|
}
|
|
2951
2769
|
});
|
|
2952
2770
|
});
|
|
2953
|
-
|
|
2954
|
-
// 按资源类型分组检查容量
|
|
2955
|
-
const {
|
|
2956
|
-
success,
|
|
2957
|
-
required,
|
|
2958
|
-
available
|
|
2959
|
-
} = (0, _capacity.checkTimeSlotCapacity)(timeSlotStart, timeSlotEnd, itemsInTimeSlot, allResourcesForTimeSlot);
|
|
2771
|
+
const { success, required, available } = (0, import_capacity.checkTimeSlotCapacity)(timeSlotStart, timeSlotEnd, itemsInTimeSlot, allResourcesForTimeSlot);
|
|
2960
2772
|
if (!success) {
|
|
2961
|
-
|
|
2962
|
-
// const minAvailableCount = availableCountsByResourceType.length > 0 ? Math.min(...availableCountsByResourceType) : 0;
|
|
2963
|
-
return {
|
|
2964
|
-
success: false,
|
|
2965
|
-
minAvailableCount: available
|
|
2966
|
-
};
|
|
2773
|
+
return { success: false, minAvailableCount: available };
|
|
2967
2774
|
}
|
|
2968
2775
|
}
|
|
2969
|
-
|
|
2970
|
-
// 全部通过检测,返回成功和最小可用数量
|
|
2971
2776
|
const minAvailableCount = availableCountsByResourceType.length > 0 ? Math.min(...availableCountsByResourceType) : 0;
|
|
2972
|
-
return {
|
|
2973
|
-
success: true,
|
|
2974
|
-
minAvailableCount
|
|
2975
|
-
};
|
|
2777
|
+
return { success: true, minAvailableCount };
|
|
2976
2778
|
}
|
|
2977
2779
|
setOtherData(key, value) {
|
|
2978
2780
|
this.otherData[key] = value;
|
|
2979
2781
|
this.checkSaveCache({
|
|
2980
2782
|
cacheId: this.cacheId,
|
|
2981
2783
|
fatherModule: this.name,
|
|
2982
|
-
store: {
|
|
2983
|
-
|
|
2984
|
-
},
|
|
2985
|
-
cacheKey: ['otherData']
|
|
2784
|
+
store: { otherData: this.otherData },
|
|
2785
|
+
cacheKey: ["otherData"]
|
|
2986
2786
|
});
|
|
2987
2787
|
}
|
|
2988
2788
|
getOtherData(key) {
|
|
2989
2789
|
return this.otherData[key];
|
|
2990
2790
|
}
|
|
2991
2791
|
async getProductTypeById(id) {
|
|
2792
|
+
var _a;
|
|
2992
2793
|
const productData = await this.store.products.getProduct(id);
|
|
2993
2794
|
if (productData) {
|
|
2994
2795
|
if (productData.duration) {
|
|
2995
|
-
return
|
|
2796
|
+
return "duration";
|
|
2996
2797
|
}
|
|
2997
|
-
if (productData[
|
|
2998
|
-
return
|
|
2798
|
+
if ((_a = productData["schedule.ids"]) == null ? void 0 : _a.length) {
|
|
2799
|
+
return "session";
|
|
2999
2800
|
}
|
|
3000
|
-
return
|
|
2801
|
+
return "normal";
|
|
3001
2802
|
}
|
|
3002
|
-
return
|
|
2803
|
+
return "normal";
|
|
3003
2804
|
}
|
|
3004
|
-
|
|
3005
2805
|
/**
|
|
3006
2806
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
3007
2807
|
*
|
|
@@ -3011,82 +2811,113 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
3011
2811
|
* @memberof BookingByStepImpl
|
|
3012
2812
|
*/
|
|
3013
2813
|
getResourcesByCartItemAndCode(cartItemId, resourceCode) {
|
|
2814
|
+
var _a, _b;
|
|
3014
2815
|
const dateRange = this.store.date.getDateRange();
|
|
3015
2816
|
const resources = [];
|
|
3016
|
-
if (dateRange
|
|
3017
|
-
dateRange.forEach(n => {
|
|
3018
|
-
if (n.resource)
|
|
2817
|
+
if (dateRange == null ? void 0 : dateRange.length) {
|
|
2818
|
+
dateRange.forEach((n) => {
|
|
2819
|
+
if (n.resource)
|
|
2820
|
+
resources.push(...n.resource);
|
|
3019
2821
|
});
|
|
3020
2822
|
}
|
|
3021
2823
|
if (!resources.length) {
|
|
3022
2824
|
const dateList = this.store.date.getDateList();
|
|
3023
|
-
dateList.forEach(n => {
|
|
3024
|
-
if (n.resource)
|
|
2825
|
+
dateList.forEach((n) => {
|
|
2826
|
+
if (n.resource)
|
|
2827
|
+
resources.push(...n.resource);
|
|
3025
2828
|
});
|
|
3026
2829
|
}
|
|
3027
|
-
const resourcesMap = (0,
|
|
3028
|
-
const cartItems = this.store.cart.getItems().filter(n => !(0,
|
|
3029
|
-
const cartItem = cartItems.find(item => item._id === cartItemId);
|
|
3030
|
-
if (!cartItem)
|
|
2830
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
2831
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
2832
|
+
const cartItem = cartItems.find((item) => item._id === cartItemId);
|
|
2833
|
+
if (!cartItem)
|
|
2834
|
+
return [];
|
|
3031
2835
|
let selectedResources = [];
|
|
3032
|
-
const {
|
|
3033
|
-
currentCapacity,
|
|
3034
|
-
formatCapacity
|
|
3035
|
-
} = (0, _capacity.getCapacityInfoByCartItem)(cartItem);
|
|
2836
|
+
const { currentCapacity, formatCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(cartItem);
|
|
3036
2837
|
cartItem._origin.metadata.capacity = formatCapacity;
|
|
3037
2838
|
if (cartItem.holder_id) {
|
|
3038
|
-
selectedResources = (0,
|
|
2839
|
+
selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
2840
|
+
cartItems,
|
|
2841
|
+
cartItem.holder_id,
|
|
2842
|
+
resourcesMap
|
|
2843
|
+
);
|
|
3039
2844
|
} else {
|
|
3040
|
-
selectedResources = (0,
|
|
2845
|
+
selectedResources = (0, import_resources.getOthersCartSelectedResources)(
|
|
2846
|
+
cartItems,
|
|
2847
|
+
cartItem._id,
|
|
2848
|
+
resourcesMap
|
|
2849
|
+
);
|
|
3041
2850
|
}
|
|
3042
|
-
const productResources = (0,
|
|
3043
|
-
|
|
3044
|
-
|
|
2851
|
+
const productResources = (0, import_resources.getResourcesByProduct)(
|
|
2852
|
+
resourcesMap,
|
|
2853
|
+
((_b = (_a = cartItem._productOrigin) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) || [],
|
|
2854
|
+
selectedResources,
|
|
2855
|
+
currentCapacity
|
|
2856
|
+
);
|
|
2857
|
+
const targetResource = productResources.find(
|
|
2858
|
+
(resource) => resource.code === resourceCode
|
|
2859
|
+
);
|
|
2860
|
+
if (!targetResource)
|
|
2861
|
+
return [];
|
|
3045
2862
|
if (cartItem._origin.start_time) {
|
|
3046
|
-
const startTime = (0,
|
|
3047
|
-
|
|
2863
|
+
const startTime = (0, import_dayjs.default)(
|
|
2864
|
+
`${cartItem._origin.start_date} ${cartItem._origin.start_time}`
|
|
2865
|
+
);
|
|
2866
|
+
const endTime = (0, import_dayjs.default)(
|
|
2867
|
+
`${cartItem._origin.end_date} ${cartItem._origin.end_time}`
|
|
2868
|
+
);
|
|
3048
2869
|
const resourcesUseableMap = {};
|
|
3049
|
-
targetResource.renderList = targetResource.renderList.sort(
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
return
|
|
2870
|
+
targetResource.renderList = targetResource.renderList.sort(
|
|
2871
|
+
(a, b) => {
|
|
2872
|
+
var _a2, _b2, _c, _d;
|
|
2873
|
+
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
2874
|
+
const bIsCombined = ((_d = (_c = b.metadata) == null ? void 0 : _c.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
2875
|
+
if (aIsCombined && !bIsCombined)
|
|
2876
|
+
return 1;
|
|
2877
|
+
if (!aIsCombined && bIsCombined)
|
|
2878
|
+
return -1;
|
|
2879
|
+
return 0;
|
|
2880
|
+
}
|
|
2881
|
+
);
|
|
2882
|
+
targetResource.renderList = targetResource.renderList.filter((m) => {
|
|
2883
|
+
const mTimes = m.times.filter((n) => {
|
|
2884
|
+
return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(startTime)) && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(endTime));
|
|
3059
2885
|
});
|
|
3060
|
-
if (mTimes.length === 0)
|
|
3061
|
-
|
|
3062
|
-
|
|
2886
|
+
if (mTimes.length === 0)
|
|
2887
|
+
return false;
|
|
2888
|
+
const canUseArr = mTimes.map((item) => {
|
|
2889
|
+
var _a2;
|
|
2890
|
+
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
3063
2891
|
timeSlice: {
|
|
3064
|
-
start_time: startTime.format(
|
|
3065
|
-
end_time: endTime.format(
|
|
2892
|
+
start_time: startTime.format("HH:mm"),
|
|
2893
|
+
end_time: endTime.format("HH:mm"),
|
|
3066
2894
|
start_at: startTime,
|
|
3067
2895
|
end_at: endTime
|
|
3068
2896
|
},
|
|
3069
2897
|
time: item,
|
|
3070
2898
|
resource: m,
|
|
3071
2899
|
currentCount: currentCapacity || 0,
|
|
3072
|
-
resourcesUseableMap
|
|
3073
|
-
cut_off_time: cartItem._productOrigin
|
|
2900
|
+
resourcesUseableMap,
|
|
2901
|
+
cut_off_time: (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.cut_off_time
|
|
3074
2902
|
});
|
|
3075
|
-
if (resourcesUseableMap
|
|
2903
|
+
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
3076
2904
|
resourcesUseableMap[m.id] = res.usable;
|
|
3077
2905
|
}
|
|
3078
2906
|
return res.usable;
|
|
3079
2907
|
});
|
|
3080
|
-
if (m.onlyComputed)
|
|
3081
|
-
|
|
2908
|
+
if (m.onlyComputed)
|
|
2909
|
+
return false;
|
|
2910
|
+
return !canUseArr.some((n) => n === false);
|
|
3082
2911
|
});
|
|
3083
2912
|
} else {
|
|
3084
|
-
targetResource.renderList = targetResource.renderList.filter(n => {
|
|
2913
|
+
targetResource.renderList = targetResource.renderList.filter((n) => {
|
|
2914
|
+
var _a2, _b2;
|
|
3085
2915
|
const recordCount = n.capacity || 0;
|
|
3086
|
-
if (n.onlyComputed)
|
|
3087
|
-
|
|
2916
|
+
if (n.onlyComputed)
|
|
2917
|
+
return false;
|
|
2918
|
+
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
3088
2919
|
resource: n,
|
|
3089
|
-
duration: cartItem._productOrigin
|
|
2920
|
+
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
|
|
3090
2921
|
split: 10,
|
|
3091
2922
|
currentDate: dateRange[0].date
|
|
3092
2923
|
});
|
|
@@ -3095,7 +2926,6 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
3095
2926
|
}
|
|
3096
2927
|
return targetResource.renderList;
|
|
3097
2928
|
}
|
|
3098
|
-
|
|
3099
2929
|
/**
|
|
3100
2930
|
* 根据日期范围批量获取时间槽
|
|
3101
2931
|
* @param params 参数对象
|
|
@@ -3107,15 +2937,17 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
3107
2937
|
scheduleIds,
|
|
3108
2938
|
resources
|
|
3109
2939
|
}) {
|
|
3110
|
-
|
|
2940
|
+
console.log(
|
|
2941
|
+
"appoimentBooking-session-date-getTimeslotsScheduleByDateRange",
|
|
2942
|
+
{ startDate, endDate, scheduleIds, resources }
|
|
2943
|
+
);
|
|
3111
2944
|
const dates = [];
|
|
3112
|
-
let currentDate = (0,
|
|
3113
|
-
const end = (0,
|
|
2945
|
+
let currentDate = (0, import_dayjs.default)(startDate);
|
|
2946
|
+
const end = (0, import_dayjs.default)(endDate);
|
|
3114
2947
|
while (currentDate.isSameOrBefore(end)) {
|
|
3115
|
-
dates.push(currentDate.format(
|
|
3116
|
-
currentDate = currentDate.add(1,
|
|
2948
|
+
dates.push(currentDate.format("YYYY-MM-DD"));
|
|
2949
|
+
currentDate = currentDate.add(1, "day");
|
|
3117
2950
|
}
|
|
3118
|
-
// 如果不支持 Web Worker,使用同步方式处理
|
|
3119
2951
|
const results = {};
|
|
3120
2952
|
for (const date of dates) {
|
|
3121
2953
|
results[date] = this.getTimeslotBySchedule({
|
|
@@ -3127,36 +2959,25 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
3127
2959
|
return results;
|
|
3128
2960
|
}
|
|
3129
2961
|
async getAvailableDateForSessionOptimize(params = {}) {
|
|
3130
|
-
|
|
3131
|
-
let {
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
}
|
|
3135
|
-
|
|
3136
|
-
if ((0, _dayjs.default)(startDate).isBefore((0, _dayjs.default)(), 'day') && ((0, _dayjs.default)(endDate).isAfter((0, _dayjs.default)(), 'day') || (0, _dayjs.default)(endDate).isSame((0, _dayjs.default)(), 'day'))) {
|
|
3137
|
-
startDate = (0, _dayjs.default)().format('YYYY-MM-DD');
|
|
3138
|
-
}
|
|
3139
|
-
// 不管前端传什么 endDate 默认查一个月的,以今天为开始日期。用于找到一个月内最近可用的日期
|
|
3140
|
-
// 优化策略:
|
|
3141
|
-
// 在 endDate 添加完一个月以后,如果 endDate 还小于 startDate + 7 天,则还需要 endDate+7 天
|
|
3142
|
-
const endDateAfterMonth = (0, _dayjs.default)().add(1, 'month').format('YYYY-MM-DD');
|
|
2962
|
+
var _a, _b, _c, _d;
|
|
2963
|
+
let { startDate, endDate } = params;
|
|
2964
|
+
if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day") && ((0, import_dayjs.default)(endDate).isAfter((0, import_dayjs.default)(), "day") || (0, import_dayjs.default)(endDate).isSame((0, import_dayjs.default)(), "day"))) {
|
|
2965
|
+
startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
2966
|
+
}
|
|
2967
|
+
const endDateAfterMonth = (0, import_dayjs.default)().add(1, "month").format("YYYY-MM-DD");
|
|
3143
2968
|
let tempEndDate = endDateAfterMonth;
|
|
3144
|
-
if ((0,
|
|
3145
|
-
tempEndDate = (0,
|
|
2969
|
+
if ((0, import_dayjs.default)(startDate).add(7, "day").isAfter((0, import_dayjs.default)(endDateAfterMonth), "day")) {
|
|
2970
|
+
tempEndDate = (0, import_dayjs.default)(startDate).add(7, "day").format("YYYY-MM-DD");
|
|
3146
2971
|
} else {
|
|
3147
2972
|
tempEndDate = endDateAfterMonth;
|
|
3148
2973
|
}
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
tempEndDate = endDate || '';
|
|
2974
|
+
if ((0, import_dayjs.default)(tempEndDate).isBefore((0, import_dayjs.default)(endDate), "day")) {
|
|
2975
|
+
tempEndDate = endDate || "";
|
|
3152
2976
|
}
|
|
3153
2977
|
endDate = tempEndDate;
|
|
3154
|
-
|
|
3155
|
-
// 先去读缓存结果,因为正常 UI 调用的是 7 天,而下面我会直接计算 30 天(最少也是 14 天),所以先去读缓存结果,如果缓存结果存在,则直接返回
|
|
3156
|
-
const cache = this.store.currentProductMeta?.['timeSlotBySchedule'];
|
|
2978
|
+
const cache = (_a = this.store.currentProductMeta) == null ? void 0 : _a["timeSlotBySchedule"];
|
|
3157
2979
|
if (cache) {
|
|
3158
|
-
|
|
3159
|
-
if ((0, _dayjs.default)(params.startDate).isSameOrAfter((0, _dayjs.default)(cache.startDate), 'day') && (0, _dayjs.default)(params.endDate).isSameOrBefore((0, _dayjs.default)(cache.endDate), 'day')) {
|
|
2980
|
+
if ((0, import_dayjs.default)(params.startDate).isSameOrAfter((0, import_dayjs.default)(cache.startDate), "day") && (0, import_dayjs.default)(params.endDate).isSameOrBefore((0, import_dayjs.default)(cache.endDate), "day")) {
|
|
3160
2981
|
this.store.date.setDateList(cache.dateList);
|
|
3161
2982
|
return {
|
|
3162
2983
|
dateList: cache.dateList,
|
|
@@ -3165,207 +2986,190 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
3165
2986
|
}
|
|
3166
2987
|
}
|
|
3167
2988
|
let tempProducts;
|
|
3168
|
-
// 如果当前打开了某个的商品详情弹窗,则应该默认用这个商品
|
|
3169
2989
|
tempProducts = this.store.currentProduct;
|
|
3170
|
-
const schedule = this.store.currentProductMeta
|
|
3171
|
-
const filteredSchedule = (0,
|
|
3172
|
-
|
|
3173
|
-
|
|
2990
|
+
const schedule = (_b = this.store.currentProductMeta) == null ? void 0 : _b["schedule"];
|
|
2991
|
+
const filteredSchedule = (0, import_resources.filterScheduleByDateRange)(
|
|
2992
|
+
schedule,
|
|
2993
|
+
startDate || "",
|
|
2994
|
+
endDate || ""
|
|
2995
|
+
);
|
|
2996
|
+
const tempResourceIds = (0, import_capacity.getResourcesIdsByProduct)(tempProducts);
|
|
3174
2997
|
const res = await this.store.date.fetchResourceDates({
|
|
3175
2998
|
query: {
|
|
3176
|
-
start_date: startDate ||
|
|
3177
|
-
end_date: endDate ||
|
|
2999
|
+
start_date: startDate || "",
|
|
3000
|
+
end_date: endDate || "",
|
|
3178
3001
|
resource_ids: tempResourceIds
|
|
3179
3002
|
}
|
|
3180
3003
|
});
|
|
3181
|
-
// 2. 商品 schedule 数据,确定日程在每一天的时间片
|
|
3182
|
-
// 3. 把后端返回的和 schedule 的数据进行合并,确定每一天的可用和使用情况
|
|
3183
3004
|
let dates = [];
|
|
3184
|
-
let currentDate = (0,
|
|
3185
|
-
let firstAvailableDate =
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3005
|
+
let currentDate = (0, import_dayjs.default)(startDate);
|
|
3006
|
+
let firstAvailableDate = "";
|
|
3007
|
+
const openResources = ((_d = (_c = tempProducts == null ? void 0 : tempProducts.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.filter(
|
|
3008
|
+
(m) => m.status === 1
|
|
3009
|
+
)) || [];
|
|
3010
|
+
const allProductResources = (0, import_lodash_es.cloneDeep)((0, import_resources.sortCombinedResources)(res.data) || []);
|
|
3011
|
+
allProductResources.forEach((m) => {
|
|
3012
|
+
var _a2, _b2;
|
|
3013
|
+
const resource = (_b2 = (_a2 = tempProducts == null ? void 0 : tempProducts.product_resource) == null ? void 0 : _a2.resources) == null ? void 0 : _b2.find(
|
|
3014
|
+
(n) => n.id === m.form_id
|
|
3015
|
+
);
|
|
3195
3016
|
if (resource) {
|
|
3196
3017
|
m.resourceType = resource.type;
|
|
3197
3018
|
}
|
|
3198
3019
|
});
|
|
3199
|
-
const targetSchedules = this.store.schedule.getScheduleListByIds(
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3020
|
+
const targetSchedules = this.store.schedule.getScheduleListByIds(
|
|
3021
|
+
tempProducts["schedule.ids"]
|
|
3022
|
+
);
|
|
3023
|
+
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")) {
|
|
3024
|
+
const currentDateStr = currentDate.format("YYYY-MM-DD");
|
|
3025
|
+
let status = "available";
|
|
3203
3026
|
let summaryCount = 0;
|
|
3204
3027
|
let availableCount = 0;
|
|
3205
|
-
|
|
3206
|
-
const {
|
|
3207
|
-
latestStartDate,
|
|
3208
|
-
earliestEndDate
|
|
3209
|
-
} = (0, _resources.checkSessionProductLeadTime)(tempProducts);
|
|
3028
|
+
const { latestStartDate, earliestEndDate } = (0, import_resources.checkSessionProductLeadTime)(tempProducts);
|
|
3210
3029
|
if (latestStartDate || earliestEndDate) {
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
status = 'unavailable';
|
|
3030
|
+
if (latestStartDate && (0, import_dayjs.default)(currentDate).isBefore(latestStartDate, "day")) {
|
|
3031
|
+
status = "unavailable";
|
|
3214
3032
|
}
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
status = 'unavailable';
|
|
3033
|
+
if (earliestEndDate && (0, import_dayjs.default)(currentDate).isAfter(earliestEndDate, "day")) {
|
|
3034
|
+
status = "unavailable";
|
|
3218
3035
|
}
|
|
3219
3036
|
}
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3037
|
+
if (status === "available") {
|
|
3038
|
+
const scheduleByDate = filteredSchedule.find(
|
|
3039
|
+
(n) => n.date === currentDateStr
|
|
3040
|
+
);
|
|
3041
|
+
if (!scheduleByDate || (scheduleByDate == null ? void 0 : scheduleByDate.isExcluded)) {
|
|
3042
|
+
status = "unavailable";
|
|
3225
3043
|
}
|
|
3226
3044
|
}
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3045
|
+
if (status === "available") {
|
|
3046
|
+
const minTimeMaxTime = (0, import_utils3.calcMinTimeMaxTimeBySchedules)(
|
|
3047
|
+
targetSchedules,
|
|
3048
|
+
{},
|
|
3049
|
+
currentDateStr
|
|
3050
|
+
);
|
|
3051
|
+
const scheduleTimeSlots = (0, import_utils3.getAllSortedDateRanges)(minTimeMaxTime);
|
|
3233
3052
|
let timesSlotCanUse = false;
|
|
3234
|
-
scheduleTimeSlots.forEach(item => {
|
|
3235
|
-
// 用来计算资源的可使用情况,针对单个schedule 时间片
|
|
3053
|
+
scheduleTimeSlots.forEach((item) => {
|
|
3236
3054
|
const resourcesUseableMap = {};
|
|
3237
|
-
// 遍历产品下启用的资源
|
|
3238
|
-
// 必须要保证每种类型的资源都至少有一个能够在对应时间点被选择
|
|
3239
|
-
// 求出第一个资源的剩余量和总量
|
|
3240
|
-
// 剩余量=每个资源在每个时间片内剩余之和
|
|
3241
|
-
// 总量=每个资源在每个时间片内资源总量之和
|
|
3242
3055
|
let isAllResourceTypesUseable = true;
|
|
3243
|
-
openResources.forEach(resource => {
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
const targetIndex = currentResourcesList.findIndex(n => n.id === item.id);
|
|
3056
|
+
openResources.forEach((resource) => {
|
|
3057
|
+
var _a2;
|
|
3058
|
+
const currentResourcesList = allProductResources.filter(
|
|
3059
|
+
(n) => n.form_id === resource.resource_type_id
|
|
3060
|
+
);
|
|
3061
|
+
(_a2 = resource.renderList) == null ? void 0 : _a2.forEach((item2) => {
|
|
3062
|
+
if (item2.onlyComputed) {
|
|
3063
|
+
const targetIndex = currentResourcesList.findIndex((n) => n.id === item2.id);
|
|
3252
3064
|
if (targetIndex && targetIndex !== -1) {
|
|
3253
3065
|
currentResourcesList[targetIndex].onlyComputed = true;
|
|
3254
3066
|
}
|
|
3255
3067
|
}
|
|
3256
3068
|
});
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
if (!resource.optional_resource
|
|
3260
|
-
|
|
3069
|
+
currentResourcesList.forEach((item2) => {
|
|
3070
|
+
var _a3, _b2;
|
|
3071
|
+
if (!((_a3 = resource.optional_resource) == null ? void 0 : _a3.includes(item2.id)) && !((_b2 = resource.default_resource) == null ? void 0 : _b2.includes(item2.id))) {
|
|
3072
|
+
item2.onlyComputed = true;
|
|
3261
3073
|
}
|
|
3262
3074
|
});
|
|
3263
|
-
// currentResourcesList 排序,onlyComputed 的资源排在前面先计算
|
|
3264
3075
|
currentResourcesList.sort((a, b) => {
|
|
3265
3076
|
return a.onlyComputed ? -1 : 1;
|
|
3266
3077
|
});
|
|
3267
3078
|
let isAnyResourceUseableInType = false;
|
|
3268
|
-
currentResourcesList
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
3272
|
-
// 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
|
|
3273
|
-
const mTimes = m.times.filter(n => {
|
|
3274
|
-
return !(0, _dayjs.default)(n.start_at).isAfter((0, _dayjs.default)(item.start), 'minute') && !(0, _dayjs.default)(n.end_at).isBefore((0, _dayjs.default)(item.end), 'minute');
|
|
3079
|
+
currentResourcesList == null ? void 0 : currentResourcesList.forEach((m) => {
|
|
3080
|
+
const mTimes = m.times.filter((n) => {
|
|
3081
|
+
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");
|
|
3275
3082
|
});
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
if (mTimes.length === 0) return;
|
|
3279
|
-
// 如果资源可用则把他的容量纳入总计
|
|
3083
|
+
if (mTimes.length === 0)
|
|
3084
|
+
return;
|
|
3280
3085
|
if (!m.onlyComputed) {
|
|
3281
|
-
if (resource.type ===
|
|
3086
|
+
if (resource.type === "multiple") {
|
|
3282
3087
|
summaryCount += m.capacity;
|
|
3283
3088
|
} else {
|
|
3284
3089
|
summaryCount += 1;
|
|
3285
3090
|
}
|
|
3286
3091
|
}
|
|
3287
3092
|
let isAnyTimeSliceUseable = false;
|
|
3288
|
-
mTimes.forEach(childTiem => {
|
|
3289
|
-
if (isAnyTimeSliceUseable)
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
const res = (0, _resources.getIsUsableByTimeItem)({
|
|
3093
|
+
mTimes.forEach((childTiem) => {
|
|
3094
|
+
if (isAnyTimeSliceUseable)
|
|
3095
|
+
return;
|
|
3096
|
+
const res2 = (0, import_resources.getIsUsableByTimeItem)({
|
|
3293
3097
|
timeSlice: {
|
|
3294
3098
|
start_time: item.start,
|
|
3295
3099
|
end_time: item.end,
|
|
3296
|
-
start_at: (0,
|
|
3297
|
-
end_at: (0,
|
|
3100
|
+
start_at: (0, import_dayjs.default)(item.start),
|
|
3101
|
+
end_at: (0, import_dayjs.default)(item.end)
|
|
3298
3102
|
},
|
|
3299
3103
|
time: childTiem,
|
|
3300
3104
|
resource: m,
|
|
3301
3105
|
currentCount: 1,
|
|
3302
3106
|
resourcesUseableMap,
|
|
3303
|
-
cut_off_time: tempProducts
|
|
3107
|
+
cut_off_time: tempProducts == null ? void 0 : tempProducts.cut_off_time
|
|
3304
3108
|
});
|
|
3305
|
-
if (resourcesUseableMap
|
|
3306
|
-
resourcesUseableMap[m.id] =
|
|
3109
|
+
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res2.reason !== "capacityOnly") {
|
|
3110
|
+
resourcesUseableMap[m.id] = res2.usable;
|
|
3307
3111
|
}
|
|
3308
|
-
if (
|
|
3112
|
+
if (res2.usable && !m.onlyComputed) {
|
|
3309
3113
|
isAnyTimeSliceUseable = true;
|
|
3310
|
-
if (resource.type ===
|
|
3311
|
-
availableCount +=
|
|
3114
|
+
if (resource.type === "multiple") {
|
|
3115
|
+
availableCount += res2.remainingCapacity;
|
|
3312
3116
|
} else {
|
|
3313
3117
|
availableCount += 1;
|
|
3314
3118
|
}
|
|
3315
3119
|
}
|
|
3316
3120
|
;
|
|
3317
3121
|
});
|
|
3318
|
-
if (isAnyTimeSliceUseable)
|
|
3122
|
+
if (isAnyTimeSliceUseable)
|
|
3123
|
+
isAnyResourceUseableInType = true;
|
|
3319
3124
|
});
|
|
3320
|
-
if (!isAnyResourceUseableInType)
|
|
3125
|
+
if (!isAnyResourceUseableInType)
|
|
3126
|
+
isAllResourceTypesUseable = false;
|
|
3321
3127
|
});
|
|
3322
|
-
if (isAllResourceTypesUseable)
|
|
3128
|
+
if (isAllResourceTypesUseable)
|
|
3129
|
+
timesSlotCanUse = true;
|
|
3323
3130
|
});
|
|
3324
3131
|
if (!timesSlotCanUse) {
|
|
3325
|
-
status =
|
|
3132
|
+
status = "unavailable";
|
|
3326
3133
|
}
|
|
3327
|
-
if (status ===
|
|
3134
|
+
if (status === "available" && !firstAvailableDate) {
|
|
3328
3135
|
firstAvailableDate = currentDateStr;
|
|
3329
3136
|
}
|
|
3330
3137
|
}
|
|
3331
|
-
// 状态: lots_of_space: availableCount / summaryCount > 0.5
|
|
3332
|
-
// filling_up_fast: availableCount / summaryCount <= 0.5 && availableCount > 0
|
|
3333
|
-
// sold_out: summaryCount = 0
|
|
3334
|
-
// unavailable: summaryCount > 0 && availableCount = 0
|
|
3335
3138
|
let dateStatus;
|
|
3336
|
-
if (status ===
|
|
3337
|
-
|
|
3338
|
-
|
|
3139
|
+
if (status === "unavailable") {
|
|
3140
|
+
if (availableCount === 0 && summaryCount > 0)
|
|
3141
|
+
dateStatus = "sold_out";
|
|
3142
|
+
else
|
|
3143
|
+
dateStatus = "unavailable";
|
|
3339
3144
|
} else {
|
|
3340
3145
|
const usageRatio = availableCount / summaryCount;
|
|
3341
|
-
if (usageRatio > 0.5)
|
|
3146
|
+
if (usageRatio > 0.5)
|
|
3147
|
+
dateStatus = "lots_of_space";
|
|
3148
|
+
else
|
|
3149
|
+
dateStatus = "filling_up_fast";
|
|
3342
3150
|
}
|
|
3343
3151
|
dates.push({
|
|
3344
|
-
date: (0,
|
|
3345
|
-
week: (0,
|
|
3346
|
-
weekNum: (0,
|
|
3152
|
+
date: (0, import_dayjs.default)(currentDate).format("YYYY-MM-DD"),
|
|
3153
|
+
week: (0, import_dayjs.default)(currentDate).format("ddd"),
|
|
3154
|
+
weekNum: (0, import_dayjs.default)(currentDate).day(),
|
|
3347
3155
|
summaryCount,
|
|
3348
3156
|
availableCount,
|
|
3349
3157
|
status: dateStatus
|
|
3350
3158
|
});
|
|
3351
|
-
|
|
3352
|
-
// 如果 firstAvailableDate 距离 startDate 大于 14 天了,则后面就不需要再找了,也是一种性能保护
|
|
3353
|
-
if (firstAvailableDate && (0, _dayjs.default)(currentDate).diff((0, _dayjs.default)(startDate), 'day') > 31) {
|
|
3159
|
+
if (firstAvailableDate && (0, import_dayjs.default)(currentDate).diff((0, import_dayjs.default)(startDate), "day") > 31) {
|
|
3354
3160
|
break;
|
|
3355
3161
|
}
|
|
3356
|
-
currentDate = (0,
|
|
3162
|
+
currentDate = (0, import_dayjs.default)(currentDate).add(1, "day");
|
|
3357
3163
|
}
|
|
3358
|
-
|
|
3359
|
-
dates = (0, _utils4.handleAvailableDateByResource)(res.data, dates);
|
|
3164
|
+
dates = (0, import_utils4.handleAvailableDateByResource)(res.data, dates);
|
|
3360
3165
|
this.store.date.setDateList(dates);
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
if (!this.store.currentProductMeta) this.store.currentProductMeta = {};
|
|
3166
|
+
if (!this.store.currentProductMeta)
|
|
3167
|
+
this.store.currentProductMeta = {};
|
|
3364
3168
|
this.store.currentProductMeta.timeSlotBySchedule = {
|
|
3365
3169
|
dateList: dates,
|
|
3366
3170
|
firstAvailableDate,
|
|
3367
3171
|
startDate,
|
|
3368
|
-
endDate: (0,
|
|
3172
|
+
endDate: (0, import_dayjs.default)(currentDate).format("YYYY-MM-DD")
|
|
3369
3173
|
};
|
|
3370
3174
|
return {
|
|
3371
3175
|
dateList: dates,
|
|
@@ -3373,27 +3177,33 @@ class BookingByStepImpl extends _BaseModule.BaseModule {
|
|
|
3373
3177
|
};
|
|
3374
3178
|
}
|
|
3375
3179
|
isCartAllNormalProducts() {
|
|
3376
|
-
const cartItems = this.store.cart.getItems().filter(n => !(0,
|
|
3180
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
3377
3181
|
return !cartItems.length;
|
|
3378
3182
|
}
|
|
3379
3183
|
isCartHasDurationProduct() {
|
|
3380
|
-
const cartItems = this.store.cart.getItems().filter(n => !(0,
|
|
3381
|
-
return cartItems.some(n =>
|
|
3184
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
3185
|
+
return cartItems.some((n) => {
|
|
3186
|
+
var _a;
|
|
3187
|
+
return (_a = n._productOrigin) == null ? void 0 : _a.duration;
|
|
3188
|
+
});
|
|
3382
3189
|
}
|
|
3383
3190
|
isTargetNormalProduct(product) {
|
|
3384
|
-
if (!product)
|
|
3385
|
-
|
|
3191
|
+
if (!product)
|
|
3192
|
+
return false;
|
|
3193
|
+
return (0, import_utils5.isNormalProduct)(product);
|
|
3386
3194
|
}
|
|
3387
3195
|
isTargetCartIdNormalProduct(id) {
|
|
3388
|
-
const cartItem = this.store.cart.getItems().find(n => n._id === id);
|
|
3389
|
-
return cartItem && (0,
|
|
3196
|
+
const cartItem = this.store.cart.getItems().find((n) => n._id === id);
|
|
3197
|
+
return cartItem && (0, import_utils5.isNormalProduct)(cartItem._productOrigin);
|
|
3390
3198
|
}
|
|
3391
|
-
|
|
3392
3199
|
/**
|
|
3393
3200
|
* 获取联系信息
|
|
3394
3201
|
*/
|
|
3395
3202
|
async getContactInfo(params) {
|
|
3396
|
-
return this.request.get(
|
|
3203
|
+
return this.request.get("/customer/metadata", params);
|
|
3397
3204
|
}
|
|
3398
|
-
}
|
|
3399
|
-
|
|
3205
|
+
};
|
|
3206
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
3207
|
+
0 && (module.exports = {
|
|
3208
|
+
BookingByStepImpl
|
|
3209
|
+
});
|