@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,143 +1,107 @@
|
|
|
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/utils/resources.ts
|
|
30
|
+
var resources_exports = {};
|
|
31
|
+
__export(resources_exports, {
|
|
32
|
+
checkSessionProductLeadTime: () => checkSessionProductLeadTime,
|
|
33
|
+
checkTwoResourcesIntersection: () => checkTwoResourcesIntersection,
|
|
34
|
+
filterResourcesByFormItem: () => filterResourcesByFormItem,
|
|
35
|
+
filterScheduleByDateRange: () => filterScheduleByDateRange,
|
|
36
|
+
formatResources: () => formatResources,
|
|
37
|
+
getIsUsableByTimeItem: () => getIsUsableByTimeItem,
|
|
38
|
+
getOthersCartSelectedResources: () => getOthersCartSelectedResources,
|
|
39
|
+
getOthersSelectedResources: () => getOthersSelectedResources,
|
|
40
|
+
getResourcesByIds: () => getResourcesByIds,
|
|
41
|
+
getResourcesByProduct: () => getResourcesByProduct,
|
|
42
|
+
getResourcesIdsByProduct: () => getResourcesIdsByProduct,
|
|
43
|
+
getTimeSlicesByResource: () => getTimeSlicesByResource,
|
|
44
|
+
getTimeSlicesByResources: () => getTimeSlicesByResources,
|
|
45
|
+
getTimesIntersection: () => getTimesIntersection,
|
|
46
|
+
isConflict: () => isConflict,
|
|
47
|
+
mergeSubResourcesTimeSlices: () => mergeSubResourcesTimeSlices,
|
|
48
|
+
sortCombinedResources: () => sortCombinedResources
|
|
5
49
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.filterScheduleByDateRange = filterScheduleByDateRange;
|
|
10
|
-
exports.getResourcesByProduct = exports.getResourcesByIds = exports.getOthersSelectedResources = exports.getOthersCartSelectedResources = exports.getIsUsableByTimeItem = exports.formatResources = void 0;
|
|
11
|
-
exports.getResourcesIdsByProduct = getResourcesIdsByProduct;
|
|
12
|
-
exports.mergeSubResourcesTimeSlices = exports.isConflict = exports.getTimesIntersection = exports.getTimeSlicesByResources = exports.getTimeSlicesByResource = void 0;
|
|
13
|
-
exports.sortCombinedResources = sortCombinedResources;
|
|
14
|
-
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
/**
|
|
17
|
-
* 1. 获取资源列表
|
|
18
|
-
* 2. 根据当前选择的商品过滤出来对应的资源列表 getResourcesByProduct
|
|
19
|
-
* 3. 格式化资源相关 格式化资源列表 --> 格式化资源 --> 获取时间切片列表 --> 判断单个时间切片是否可用 formatResources
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @title: 获取重叠剩余量
|
|
25
|
-
* @description:
|
|
26
|
-
* @param {any} eventList
|
|
27
|
-
* @param {number} current
|
|
28
|
-
* @return {*}
|
|
29
|
-
* @Author: zhiwei.Wang
|
|
30
|
-
*/
|
|
31
|
-
const getUseableEventCount = (eventList, current) => {
|
|
50
|
+
module.exports = __toCommonJS(resources_exports);
|
|
51
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
52
|
+
var getUseableEventCount = (eventList, current) => {
|
|
32
53
|
return (eventList || []).reduce((pre, event) => {
|
|
33
54
|
return pre - event.pax;
|
|
34
55
|
}, current || 0);
|
|
35
56
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
* @param {object} event
|
|
41
|
-
* @param {object} current
|
|
42
|
-
* @return {*}
|
|
43
|
-
* @Author: zhiwei.Wang
|
|
44
|
-
*/
|
|
45
|
-
const isConflict = (event, current) => {
|
|
46
|
-
const eventStart = (0, _dayjs.default)(event.start_at);
|
|
47
|
-
const eventEnd = (0, _dayjs.default)(event.end_at);
|
|
48
|
-
const currentStart = (0, _dayjs.default)(current.start_at);
|
|
57
|
+
var isConflict = (event, current) => {
|
|
58
|
+
const eventStart = (0, import_dayjs.default)(event.start_at);
|
|
59
|
+
const eventEnd = (0, import_dayjs.default)(event.end_at);
|
|
60
|
+
const currentStart = (0, import_dayjs.default)(current.start_at);
|
|
49
61
|
const _isBefore = currentStart.isBefore(eventEnd);
|
|
50
62
|
let _isAfter = true;
|
|
51
|
-
|
|
52
|
-
// 如果传递结束时间,则比对结束时间
|
|
53
63
|
if (current.end_at) {
|
|
54
|
-
const currentEnd = (0,
|
|
64
|
+
const currentEnd = (0, import_dayjs.default)(current.end_at);
|
|
55
65
|
_isAfter = currentEnd.isAfter(eventStart);
|
|
56
66
|
}
|
|
57
|
-
|
|
58
|
-
// 检查是否有重叠
|
|
59
67
|
return _isBefore && _isAfter;
|
|
60
68
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
* @title: 判断传入日期是否在当前日期之后
|
|
64
|
-
* @description:
|
|
65
|
-
* @param {any} date
|
|
66
|
-
* @param {any} today
|
|
67
|
-
* @return {*}
|
|
68
|
-
* @Author: zhiwei.Wang
|
|
69
|
-
*/
|
|
70
|
-
exports.isConflict = isConflict;
|
|
71
|
-
const checkAfterToDay = (date, today = (0, _dayjs.default)()) => {
|
|
72
|
-
return (0, _dayjs.default)(date).isAfter((0, _dayjs.default)(today));
|
|
69
|
+
var checkAfterToDay = (date, today = (0, import_dayjs.default)()) => {
|
|
70
|
+
return (0, import_dayjs.default)(date).isAfter((0, import_dayjs.default)(today));
|
|
73
71
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
* @title: 格式化资源, 添加自定义参数
|
|
77
|
-
* @description:
|
|
78
|
-
* @param {any} resourceItem
|
|
79
|
-
* @return {*}
|
|
80
|
-
* @Author: zhiwei.Wang
|
|
81
|
-
* @Date: 2024-01-09 13:40
|
|
82
|
-
*/
|
|
83
|
-
const formatResource = (resourceItem, booking) => {
|
|
84
|
-
// 当前资源
|
|
85
|
-
let _resourceItem = {
|
|
86
|
-
...resourceItem
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
// 格式化times里面的数据
|
|
72
|
+
var formatResource = (resourceItem, booking) => {
|
|
73
|
+
let _resourceItem = { ...resourceItem };
|
|
90
74
|
_resourceItem.timeSlices = getTimeSlicesByResource({
|
|
91
75
|
resource: _resourceItem,
|
|
92
76
|
duration: booking.duration,
|
|
93
77
|
split: 10,
|
|
94
|
-
currentDate: (0,
|
|
78
|
+
currentDate: (0, import_dayjs.default)().format("YYYY-MM-DD")
|
|
95
79
|
});
|
|
96
|
-
|
|
97
|
-
// 格式化label
|
|
98
80
|
_resourceItem.labelText = _resourceItem.main_field;
|
|
99
81
|
return _resourceItem;
|
|
100
82
|
};
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* @title: 判断资源容量是否可用
|
|
104
|
-
* @description:
|
|
105
|
-
* @param {object} param1
|
|
106
|
-
* @return {*}
|
|
107
|
-
* @Author: zhiwei.Wang
|
|
108
|
-
*/
|
|
109
|
-
const checkCapacity = ({
|
|
83
|
+
var checkCapacity = ({
|
|
110
84
|
event_list,
|
|
111
85
|
timeSlice,
|
|
112
86
|
resource,
|
|
113
87
|
currentCount = 1
|
|
114
88
|
}) => {
|
|
115
|
-
|
|
116
|
-
// 多个预约:只需判断容量是否足够
|
|
117
|
-
const isMultipleBooking = resource.resourceType === 'multiple';
|
|
89
|
+
const isMultipleBooking = resource.resourceType === "multiple";
|
|
118
90
|
if (currentCount > resource.capacity && (isMultipleBooking || !isMultipleBooking && event_list.length === 0)) {
|
|
119
91
|
return {
|
|
120
92
|
status: false,
|
|
121
93
|
capacity: resource.capacity,
|
|
122
|
-
reason:
|
|
94
|
+
reason: "capacityOnly"
|
|
123
95
|
};
|
|
124
96
|
}
|
|
125
|
-
let conflict = (event_list || []).filter(d => {
|
|
126
|
-
return isConflict(
|
|
127
|
-
start_at: d.start_at,
|
|
128
|
-
end_at:
|
|
129
|
-
|
|
130
|
-
start_at: timeSlice.start_at,
|
|
131
|
-
end_at: timeSlice.end_at
|
|
132
|
-
});
|
|
97
|
+
let conflict = (event_list || []).filter((d) => {
|
|
98
|
+
return isConflict(
|
|
99
|
+
{ start_at: d.start_at, end_at: d.end_at },
|
|
100
|
+
{ start_at: timeSlice.start_at, end_at: timeSlice.end_at }
|
|
101
|
+
);
|
|
133
102
|
});
|
|
134
|
-
|
|
135
|
-
// 减去重叠的总量
|
|
136
103
|
let conflictCount = getUseableEventCount(conflict, resource.capacity);
|
|
137
|
-
|
|
138
|
-
// 同一时间段内只能进行一个预约,无论容量是否已满。
|
|
139
|
-
if (resource.resourceType === 'single') {
|
|
140
|
-
// 0代表着不重叠,则满足条件
|
|
104
|
+
if (resource.resourceType === "single") {
|
|
141
105
|
if (conflict.length === 0) {
|
|
142
106
|
return {
|
|
143
107
|
status: true,
|
|
@@ -150,7 +114,6 @@ const checkCapacity = ({
|
|
|
150
114
|
};
|
|
151
115
|
}
|
|
152
116
|
} else {
|
|
153
|
-
// 当前预约量 <= 总剩余容量
|
|
154
117
|
if (currentCount <= conflictCount) {
|
|
155
118
|
return {
|
|
156
119
|
status: true,
|
|
@@ -164,15 +127,7 @@ const checkCapacity = ({
|
|
|
164
127
|
}
|
|
165
128
|
}
|
|
166
129
|
};
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* @title: 获取时间切片是否可用
|
|
170
|
-
* @description: 根据时间切片、资源、当前预约量判断时间切片是否可用
|
|
171
|
-
* @param {any} param1
|
|
172
|
-
* @return {*}
|
|
173
|
-
* @Author: zhiwei.Wang
|
|
174
|
-
*/
|
|
175
|
-
const getIsUsableByTimeItem = ({
|
|
130
|
+
var getIsUsableByTimeItem = ({
|
|
176
131
|
timeSlice,
|
|
177
132
|
time,
|
|
178
133
|
resource,
|
|
@@ -180,34 +135,26 @@ const getIsUsableByTimeItem = ({
|
|
|
180
135
|
resourcesUseableMap = {},
|
|
181
136
|
cut_off_time
|
|
182
137
|
}) => {
|
|
138
|
+
var _a;
|
|
183
139
|
let status = {
|
|
184
140
|
afterToDay: false,
|
|
185
141
|
capacity: false,
|
|
186
142
|
usable: false,
|
|
187
143
|
remainingCapacity: 0,
|
|
188
144
|
// 剩余容量
|
|
189
|
-
reason:
|
|
145
|
+
reason: ""
|
|
190
146
|
};
|
|
191
|
-
|
|
192
|
-
let earliest = (0, _dayjs.default)();
|
|
147
|
+
let earliest = (0, import_dayjs.default)();
|
|
193
148
|
let canBookingForOngoing = false;
|
|
194
|
-
const {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
ongoing
|
|
199
|
-
} = cut_off_time || {};
|
|
200
|
-
// 允许购买已开始的活动
|
|
201
|
-
if (type === 'ongoing' && ongoing?.type === 'after_start') {
|
|
202
|
-
// 如果timeSlice.start_at 小于当前时间,判断当前时间是否在如果timeSlice.start_at+ongoing.unit之间
|
|
203
|
-
// 即,如果现在是15:30,timeSlice.start_at是15:00,ongoing.unit是60分钟,则允许预约
|
|
204
|
-
if ((0, _dayjs.default)(timeSlice.start_at).isBefore((0, _dayjs.default)())) {
|
|
205
|
-
if (earliest.isBefore((0, _dayjs.default)(timeSlice.start_at).add(ongoing.unit, 'minute'))) {
|
|
149
|
+
const { unit, unit_type, type, ongoing } = cut_off_time || {};
|
|
150
|
+
if (type === "ongoing" && (ongoing == null ? void 0 : ongoing.type) === "after_start") {
|
|
151
|
+
if ((0, import_dayjs.default)(timeSlice.start_at).isBefore((0, import_dayjs.default)())) {
|
|
152
|
+
if (earliest.isBefore((0, import_dayjs.default)(timeSlice.start_at).add(ongoing.unit, "minute"))) {
|
|
206
153
|
canBookingForOngoing = true;
|
|
207
154
|
}
|
|
208
155
|
}
|
|
209
|
-
} else if (type ===
|
|
210
|
-
if ((0,
|
|
156
|
+
} else if (type === "ongoing" && (ongoing == null ? void 0 : ongoing.type) === "before_end") {
|
|
157
|
+
if ((0, import_dayjs.default)(timeSlice.end_at).isAfter(earliest)) {
|
|
211
158
|
canBookingForOngoing = true;
|
|
212
159
|
}
|
|
213
160
|
} else {
|
|
@@ -215,28 +162,25 @@ const getIsUsableByTimeItem = ({
|
|
|
215
162
|
earliest = earliest.add(unit, unit_type);
|
|
216
163
|
}
|
|
217
164
|
}
|
|
218
|
-
// 不可预约提前量时间之前的
|
|
219
165
|
if (!checkAfterToDay(timeSlice.start_at, earliest) && !canBookingForOngoing) {
|
|
220
166
|
return status;
|
|
221
167
|
}
|
|
222
168
|
status.afterToDay = true;
|
|
223
169
|
const checkCapacityResult = checkCapacity({
|
|
224
|
-
event_list: time
|
|
170
|
+
event_list: time == null ? void 0 : time.event_list,
|
|
225
171
|
timeSlice,
|
|
226
172
|
resource,
|
|
227
173
|
currentCount
|
|
228
174
|
});
|
|
229
|
-
if (resource.combined_resource
|
|
230
|
-
// 组合资源中子资源是否可用
|
|
175
|
+
if ((_a = resource.combined_resource) == null ? void 0 : _a.status) {
|
|
231
176
|
const resourceIds = resource.combined_resource.resource_ids;
|
|
232
|
-
resourceIds.forEach(id => {
|
|
233
|
-
|
|
234
|
-
if (resourcesUseableMap?.[id] === false) {
|
|
177
|
+
resourceIds.forEach((id) => {
|
|
178
|
+
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[id]) === false) {
|
|
235
179
|
checkCapacityResult.status = false;
|
|
236
180
|
}
|
|
237
181
|
});
|
|
238
182
|
}
|
|
239
|
-
status.reason = checkCapacityResult.reason ||
|
|
183
|
+
status.reason = checkCapacityResult.reason || "";
|
|
240
184
|
if (!checkCapacityResult.status) {
|
|
241
185
|
return status;
|
|
242
186
|
}
|
|
@@ -245,113 +189,116 @@ const getIsUsableByTimeItem = ({
|
|
|
245
189
|
status.usable = true;
|
|
246
190
|
return status;
|
|
247
191
|
};
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* @title: 获取商品下绑定的资源列表
|
|
251
|
-
* @description:
|
|
252
|
-
* @param {any} resourcesMap
|
|
253
|
-
* @param {any} product
|
|
254
|
-
* @return {*}
|
|
255
|
-
* @Author: zhiwei.Wang
|
|
256
|
-
*/
|
|
257
|
-
exports.getIsUsableByTimeItem = getIsUsableByTimeItem;
|
|
258
|
-
const getResourcesByProduct = (resourcesMap, resources, selectedResources, capacity = 1) => {
|
|
192
|
+
var getResourcesByProduct = (resourcesMap, resources, selectedResources, capacity = 1) => {
|
|
259
193
|
return (resources || []).reduce((acc, item) => {
|
|
260
|
-
if (item
|
|
194
|
+
if ((item == null ? void 0 : item.status) == 1) {
|
|
261
195
|
const form_id = item.id;
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
196
|
+
item.optional_resource = (item.optional_resource || []).filter(
|
|
197
|
+
(d) => item.default_resource.indexOf(d) == -1
|
|
198
|
+
);
|
|
199
|
+
let optional_resource = item.optional_resource.reduce(
|
|
200
|
+
(childAcc, d) => {
|
|
201
|
+
var _a;
|
|
202
|
+
const isSelectSingleResources = ((_a = resourcesMap[d]) == null ? void 0 : _a.resourceType) === "single" && selectedResources.includes(resourcesMap[d].id);
|
|
203
|
+
if (resourcesMap[d] && !isSelectSingleResources) {
|
|
204
|
+
const combiningResources = [];
|
|
205
|
+
if (resourcesMap[d].combined_resource && resourcesMap[d].combined_resource.status === 1) {
|
|
206
|
+
resourcesMap[d].combined_resource.resource_ids.forEach(
|
|
207
|
+
(id) => {
|
|
208
|
+
if (resourcesMap[id]) {
|
|
209
|
+
combiningResources.push(resourcesMap[id]);
|
|
210
|
+
childAcc.push(
|
|
211
|
+
Object.assign({}, resourcesMap[id], {
|
|
212
|
+
form_id,
|
|
213
|
+
resourceType: item.type,
|
|
214
|
+
children: combiningResources,
|
|
215
|
+
onlyComputed: true,
|
|
216
|
+
// 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
|
|
217
|
+
metadata: {
|
|
218
|
+
...resourcesMap[id].metadata,
|
|
219
|
+
combined_resource: resourcesMap[id].combined_resource,
|
|
220
|
+
form_name: item.title,
|
|
221
|
+
resource_name: resourcesMap[id].main_field
|
|
222
|
+
}
|
|
223
|
+
})
|
|
224
|
+
);
|
|
286
225
|
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
childAcc.push(Object.assign({}, resourcesMap[d], {
|
|
292
|
-
form_id: form_id,
|
|
293
|
-
resourceType: item.type,
|
|
294
|
-
children: combiningResources,
|
|
295
|
-
metadata: {
|
|
296
|
-
...resourcesMap[d].metadata,
|
|
297
|
-
combined_resource: resourcesMap[d].combined_resource,
|
|
298
|
-
form_name: item.title,
|
|
299
|
-
resource_name: resourcesMap[d].main_field
|
|
226
|
+
}
|
|
227
|
+
);
|
|
300
228
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
childAcc.push(Object.assign({}, resourcesMap[id], {
|
|
315
|
-
form_id: form_id,
|
|
316
|
-
resourceType: item.type,
|
|
317
|
-
children: combiningResources,
|
|
318
|
-
onlyComputed: true,
|
|
319
|
-
// 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
|
|
320
|
-
metadata: {
|
|
321
|
-
...resourcesMap[id].metadata,
|
|
322
|
-
combined_resource: resourcesMap[id].combined_resource,
|
|
323
|
-
form_name: item.title,
|
|
324
|
-
resource_name: resourcesMap[id].main_field
|
|
325
|
-
}
|
|
326
|
-
}));
|
|
327
|
-
}
|
|
328
|
-
});
|
|
229
|
+
childAcc.push(
|
|
230
|
+
Object.assign({}, resourcesMap[d], {
|
|
231
|
+
form_id,
|
|
232
|
+
resourceType: item.type,
|
|
233
|
+
children: combiningResources,
|
|
234
|
+
metadata: {
|
|
235
|
+
...resourcesMap[d].metadata,
|
|
236
|
+
combined_resource: resourcesMap[d].combined_resource,
|
|
237
|
+
form_name: item.title,
|
|
238
|
+
resource_name: resourcesMap[d].main_field
|
|
239
|
+
}
|
|
240
|
+
})
|
|
241
|
+
);
|
|
329
242
|
}
|
|
330
|
-
childAcc
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
243
|
+
return childAcc;
|
|
244
|
+
},
|
|
245
|
+
[]
|
|
246
|
+
);
|
|
247
|
+
let default_resource = item.default_resource.reduce(
|
|
248
|
+
(childAcc, d) => {
|
|
249
|
+
var _a;
|
|
250
|
+
const isSelectSingleResources = ((_a = resourcesMap[d]) == null ? void 0 : _a.resourceType) === "single" && selectedResources.includes(resourcesMap[d].id);
|
|
251
|
+
if (resourcesMap[d] && !isSelectSingleResources) {
|
|
252
|
+
const combiningResources = [];
|
|
253
|
+
if (resourcesMap[d].combined_resource && resourcesMap[d].combined_resource.status === 1) {
|
|
254
|
+
resourcesMap[d].combined_resource.resource_ids.forEach(
|
|
255
|
+
(id) => {
|
|
256
|
+
if (resourcesMap[id]) {
|
|
257
|
+
combiningResources.push(resourcesMap[id]);
|
|
258
|
+
childAcc.push(
|
|
259
|
+
Object.assign({}, resourcesMap[id], {
|
|
260
|
+
form_id,
|
|
261
|
+
resourceType: item.type,
|
|
262
|
+
children: combiningResources,
|
|
263
|
+
onlyComputed: true,
|
|
264
|
+
// 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
|
|
265
|
+
metadata: {
|
|
266
|
+
...resourcesMap[id].metadata,
|
|
267
|
+
combined_resource: resourcesMap[id].combined_resource,
|
|
268
|
+
form_name: item.title,
|
|
269
|
+
resource_name: resourcesMap[id].main_field
|
|
270
|
+
}
|
|
271
|
+
})
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
);
|
|
340
276
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
277
|
+
childAcc.push(
|
|
278
|
+
Object.assign({}, resourcesMap[d], {
|
|
279
|
+
form_id,
|
|
280
|
+
resourceType: item.type,
|
|
281
|
+
is_default: 1,
|
|
282
|
+
children: combiningResources,
|
|
283
|
+
metadata: {
|
|
284
|
+
...resourcesMap[d].metadata,
|
|
285
|
+
combined_resource: resourcesMap[d].combined_resource,
|
|
286
|
+
form_name: item.title,
|
|
287
|
+
resource_name: resourcesMap[d].main_field
|
|
288
|
+
}
|
|
289
|
+
})
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
return childAcc;
|
|
293
|
+
},
|
|
294
|
+
[]
|
|
295
|
+
);
|
|
346
296
|
item.renderList = optional_resource.concat(default_resource);
|
|
347
|
-
|
|
348
|
-
item.renderList = item.renderList.filter(d => {
|
|
297
|
+
item.renderList = item.renderList.filter((d) => {
|
|
349
298
|
const latestTime = d.times.reduce((latest, current) => {
|
|
350
|
-
return (0,
|
|
299
|
+
return (0, import_dayjs.default)(current.end_at).isAfter((0, import_dayjs.default)(latest.end_at)) ? current : latest;
|
|
351
300
|
}, d.times[0]);
|
|
352
|
-
|
|
353
|
-
// 当前资源的配置容量需要大于当前需求的 capacity
|
|
354
|
-
return (0, _dayjs.default)(latestTime.end_at).isAfter((0, _dayjs.default)()) && d.capacity >= capacity;
|
|
301
|
+
return (0, import_dayjs.default)(latestTime.end_at).isAfter((0, import_dayjs.default)()) && d.capacity >= capacity;
|
|
355
302
|
});
|
|
356
303
|
item.form_id = form_id;
|
|
357
304
|
acc.push(item);
|
|
@@ -359,16 +306,7 @@ const getResourcesByProduct = (resourcesMap, resources, selectedResources, capac
|
|
|
359
306
|
return acc;
|
|
360
307
|
}, []);
|
|
361
308
|
};
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* @title: 获取资源列表
|
|
365
|
-
* @description:
|
|
366
|
-
* @return {*}
|
|
367
|
-
* @Author: zhiwei.Wang
|
|
368
|
-
* @Date: 2024-01-09 13:38
|
|
369
|
-
*/
|
|
370
|
-
exports.getResourcesByProduct = getResourcesByProduct;
|
|
371
|
-
const formatResources = ({
|
|
309
|
+
var formatResources = ({
|
|
372
310
|
booking,
|
|
373
311
|
resources
|
|
374
312
|
}) => {
|
|
@@ -377,39 +315,30 @@ const formatResources = ({
|
|
|
377
315
|
let maps = {};
|
|
378
316
|
for (let item of _list) {
|
|
379
317
|
let renderListMaps = {};
|
|
380
|
-
item.renderList = item.renderList.map(d => {
|
|
318
|
+
item.renderList = item.renderList.map((d) => {
|
|
381
319
|
let res = formatResource(d, booking);
|
|
382
320
|
renderListMaps[res.id] = res;
|
|
383
321
|
return res;
|
|
384
322
|
});
|
|
385
323
|
maps[item.form_id] = {
|
|
386
324
|
...item,
|
|
387
|
-
renderListMaps
|
|
325
|
+
renderListMaps
|
|
388
326
|
};
|
|
389
327
|
}
|
|
390
|
-
return {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
} catch (err) {}
|
|
328
|
+
return { list: _list, maps };
|
|
329
|
+
} catch (err) {
|
|
330
|
+
console.log("formatResourcesErr", err);
|
|
331
|
+
}
|
|
395
332
|
return {
|
|
396
333
|
list: [],
|
|
397
334
|
maps: {}
|
|
398
335
|
};
|
|
399
336
|
};
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* @title: 获取资源的时间切片列表
|
|
403
|
-
* @description:
|
|
404
|
-
* @return {*}
|
|
405
|
-
* @Author: zhiwei.Wang
|
|
406
|
-
*/
|
|
407
|
-
exports.formatResources = formatResources;
|
|
408
|
-
const getTimeSlicesByResource = ({
|
|
337
|
+
var getTimeSlicesByResource = ({
|
|
409
338
|
resource,
|
|
410
339
|
duration,
|
|
411
340
|
split = 10,
|
|
412
|
-
currentDate = (0,
|
|
341
|
+
currentDate = (0, import_dayjs.default)(),
|
|
413
342
|
capacity,
|
|
414
343
|
resourcesUseableMap = {},
|
|
415
344
|
cut_off_time,
|
|
@@ -417,45 +346,26 @@ const getTimeSlicesByResource = ({
|
|
|
417
346
|
operating_day_boundary,
|
|
418
347
|
maxBlockThreshold
|
|
419
348
|
}) => {
|
|
420
|
-
let {
|
|
421
|
-
times
|
|
422
|
-
} = resource;
|
|
423
|
-
|
|
424
|
-
// 存储所有时间切片
|
|
349
|
+
let { times } = resource;
|
|
425
350
|
const timeSlices = [];
|
|
426
|
-
// times 先以开始时间为准做个排序,时间早的先循环
|
|
427
351
|
times.sort((a, b) => {
|
|
428
|
-
return (0,
|
|
352
|
+
return (0, import_dayjs.default)(a.start_at).diff((0, import_dayjs.default)(b.start_at), "minute");
|
|
429
353
|
});
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
// 解析开始和结束时间
|
|
437
|
-
const startTime = (0, _dayjs.default)(`${time.start_at}`);
|
|
438
|
-
let endTime = (0, _dayjs.default)(`${time.end_at}`);
|
|
439
|
-
// 结束时间要做修复,如果time.end_at 是超过了 currentDate 的那一天,则把 end_at 设置为 currentDate 那一天的 23:59:59
|
|
440
|
-
if (endTime.isAfter((0, _dayjs.default)(currentDate).endOf('day'))) {
|
|
441
|
-
endTime = (0, _dayjs.default)(currentDate).endOf('day');
|
|
354
|
+
times.forEach((time) => {
|
|
355
|
+
const startTime = (0, import_dayjs.default)(`${time.start_at}`);
|
|
356
|
+
let endTime = (0, import_dayjs.default)(`${time.end_at}`);
|
|
357
|
+
if (endTime.isAfter((0, import_dayjs.default)(currentDate).endOf("day"))) {
|
|
358
|
+
endTime = (0, import_dayjs.default)(currentDate).endOf("day");
|
|
442
359
|
}
|
|
443
|
-
|
|
444
|
-
// 当前切片的开始时间
|
|
445
360
|
let currentStart = startTime;
|
|
446
|
-
|
|
447
|
-
// 生成时间切片
|
|
448
361
|
while (true) {
|
|
449
|
-
|
|
450
|
-
const currentEnd = currentStart.add(duration, 'minute');
|
|
451
|
-
|
|
452
|
-
// 如果结束时间超过了时间范围的结束时间,则停止
|
|
362
|
+
const currentEnd = currentStart.add(duration, "minute");
|
|
453
363
|
if (currentEnd.isAfter(endTime)) {
|
|
454
364
|
break;
|
|
455
365
|
}
|
|
456
366
|
const timeSlice = {
|
|
457
|
-
start_time: currentStart.format(
|
|
458
|
-
end_time: currentEnd.format(
|
|
367
|
+
start_time: currentStart.format("HH:mm"),
|
|
368
|
+
end_time: currentEnd.format("HH:mm"),
|
|
459
369
|
start_at: currentStart,
|
|
460
370
|
end_at: currentEnd
|
|
461
371
|
};
|
|
@@ -464,54 +374,39 @@ const getTimeSlicesByResource = ({
|
|
|
464
374
|
time,
|
|
465
375
|
resource,
|
|
466
376
|
currentCount: capacity || 1,
|
|
467
|
-
resourcesUseableMap
|
|
377
|
+
resourcesUseableMap,
|
|
468
378
|
cut_off_time
|
|
469
379
|
});
|
|
470
|
-
if (resourcesUseableMap
|
|
380
|
+
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[resource.id]) !== false) {
|
|
471
381
|
resourcesUseableMap[resource.id] = _status.usable;
|
|
472
382
|
}
|
|
473
383
|
if (_status.usable) {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= (operatingBoundaryDateTime || '23:59')) {
|
|
384
|
+
const operatingBoundaryDateTime = (operating_day_boundary == null ? void 0 : operating_day_boundary.type) === "start_time" ? "23:59" : operating_day_boundary == null ? void 0 : operating_day_boundary.time;
|
|
385
|
+
if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= (operatingBoundaryDateTime || "23:59")) {
|
|
477
386
|
break;
|
|
478
387
|
}
|
|
479
|
-
|
|
480
|
-
// 看一下endTime和operatingBoundaryDateTime哪个早,哪个早用哪个去比较
|
|
481
|
-
const operatingBoundaryDateTimeObj = (0, _dayjs.default)(`${endTime.format('YYYY-MM-DD')} ${operatingBoundaryDateTime}`);
|
|
388
|
+
const operatingBoundaryDateTimeObj = (0, import_dayjs.default)(`${endTime.format("YYYY-MM-DD")} ${operatingBoundaryDateTime}`);
|
|
482
389
|
const earlyTime = endTime.isBefore(operatingBoundaryDateTimeObj) ? endTime : operatingBoundaryDateTimeObj;
|
|
483
|
-
if (hasFlexibleDuration && operating_day_boundary && maxBlockThreshold && timeSlice.start_at.add(maxBlockThreshold || 0,
|
|
390
|
+
if (hasFlexibleDuration && operating_day_boundary && maxBlockThreshold && timeSlice.start_at.add(maxBlockThreshold || 0, "minutes").isAfter(earlyTime)) {
|
|
484
391
|
break;
|
|
485
392
|
}
|
|
486
|
-
// 添加时间切片 09:00 ~ 10:00 09:20 ~ 10:20 09:00 ~ 10:00 09:20 ~ 10:20 11:00 ~ 12:00 11:20 ~ 12:20
|
|
487
393
|
timeSlices.push({
|
|
488
394
|
...timeSlice,
|
|
489
395
|
// 这里需要补充这个时间段内是否可预约
|
|
490
|
-
_status
|
|
396
|
+
_status
|
|
491
397
|
});
|
|
492
398
|
}
|
|
493
|
-
|
|
494
|
-
currentStart = currentStart.add(split, 'minute');
|
|
399
|
+
currentStart = currentStart.add(split, "minute");
|
|
495
400
|
}
|
|
496
401
|
});
|
|
497
402
|
return timeSlices;
|
|
498
403
|
};
|
|
499
|
-
|
|
500
|
-
/**
|
|
501
|
-
* @title: 获取时间切片列表的交集
|
|
502
|
-
* @description: 注意: 需要将多个时间切片列表合并在一起,然后判断交集
|
|
503
|
-
* @param {TimeSliceItem} times 多个时间切片
|
|
504
|
-
* @param {number} count 交集次数, 符合此次数的会返回
|
|
505
|
-
* @return {*}
|
|
506
|
-
* @Author: zhiwei.Wang
|
|
507
|
-
*/
|
|
508
|
-
exports.getTimeSlicesByResource = getTimeSlicesByResource;
|
|
509
|
-
const getTimesIntersection = (times, count) => {
|
|
404
|
+
var getTimesIntersection = (times, count) => {
|
|
510
405
|
let obj = times.reduce((acc, item) => {
|
|
511
406
|
let _key = `${item.start_time}-${item.end_time}`;
|
|
512
407
|
if (!acc[_key]) {
|
|
513
408
|
acc[_key] = {
|
|
514
|
-
item
|
|
409
|
+
item,
|
|
515
410
|
count: 1
|
|
516
411
|
};
|
|
517
412
|
} else {
|
|
@@ -519,44 +414,24 @@ const getTimesIntersection = (times, count) => {
|
|
|
519
414
|
}
|
|
520
415
|
return acc;
|
|
521
416
|
}, {});
|
|
522
|
-
|
|
523
|
-
// 过滤出符合交集次数的
|
|
524
|
-
return Object.values(obj).filter(d => d.count >= count).map(d => d.item);
|
|
417
|
+
return Object.values(obj).filter((d) => d.count >= count).map((d) => d.item);
|
|
525
418
|
};
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
* @title: 根据ids筛选资源列表
|
|
529
|
-
* @description:
|
|
530
|
-
* @param {any} resourcesMap
|
|
531
|
-
* @param {any} ids
|
|
532
|
-
* @return {*}
|
|
533
|
-
* @Author: zhiwei.Wang
|
|
534
|
-
* @Date: 2024-09-19 20:23
|
|
535
|
-
*/
|
|
536
|
-
exports.getTimesIntersection = getTimesIntersection;
|
|
537
|
-
const getResourcesByIds = (resourcesMap, ids) => {
|
|
538
|
-
return (ids || []).map(id => resourcesMap[id]);
|
|
419
|
+
var getResourcesByIds = (resourcesMap, ids) => {
|
|
420
|
+
return (ids || []).map((id) => resourcesMap[id]);
|
|
539
421
|
};
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
* @param {Record<string, ResourceItem>} resourcesMap
|
|
546
|
-
* @return {*}
|
|
547
|
-
* @Author: zhiwei.Wang
|
|
548
|
-
*/
|
|
549
|
-
exports.getResourcesByIds = getResourcesByIds;
|
|
550
|
-
const mergeSubResourcesTimeSlices = (resources, resourcesMap) => {
|
|
551
|
-
return resources.forEach(item => {
|
|
552
|
-
if (item?.combined_resource?.status === 1) {
|
|
553
|
-
item?.combined_resource?.resource_ids.forEach(id => {
|
|
422
|
+
var mergeSubResourcesTimeSlices = (resources, resourcesMap) => {
|
|
423
|
+
return resources.forEach((item) => {
|
|
424
|
+
var _a, _b;
|
|
425
|
+
if (((_a = item == null ? void 0 : item.combined_resource) == null ? void 0 : _a.status) === 1) {
|
|
426
|
+
(_b = item == null ? void 0 : item.combined_resource) == null ? void 0 : _b.resource_ids.forEach((id) => {
|
|
554
427
|
const subResource = resourcesMap[id];
|
|
555
428
|
if (subResource) {
|
|
556
|
-
subResource.times.forEach(time => {
|
|
557
|
-
const fatherResourcesTime = item.times.find(
|
|
429
|
+
subResource.times.forEach((time) => {
|
|
430
|
+
const fatherResourcesTime = item.times.find(
|
|
431
|
+
(n) => n.start_at === time.start_at && n.end_at === time.end_at
|
|
432
|
+
);
|
|
558
433
|
if (fatherResourcesTime) {
|
|
559
|
-
fatherResourcesTime.event_list.push(...
|
|
434
|
+
fatherResourcesTime.event_list.push(...time.event_list || []);
|
|
560
435
|
}
|
|
561
436
|
});
|
|
562
437
|
}
|
|
@@ -564,17 +439,7 @@ const mergeSubResourcesTimeSlices = (resources, resourcesMap) => {
|
|
|
564
439
|
}
|
|
565
440
|
});
|
|
566
441
|
};
|
|
567
|
-
|
|
568
|
-
/**
|
|
569
|
-
* @title: 根据资源id列表获取时间切片
|
|
570
|
-
* @description: 传入一个技师id列表, 找出技师列表中公共的时间切片
|
|
571
|
-
* @param {ResourceItem} resources
|
|
572
|
-
* @param {CartItem} cart
|
|
573
|
-
* @return {*}
|
|
574
|
-
* @Author: zhiwei.Wang
|
|
575
|
-
*/
|
|
576
|
-
exports.mergeSubResourcesTimeSlices = mergeSubResourcesTimeSlices;
|
|
577
|
-
const getTimeSlicesByResources = ({
|
|
442
|
+
var getTimeSlicesByResources = ({
|
|
578
443
|
resourceIds,
|
|
579
444
|
resourcesMap,
|
|
580
445
|
duration,
|
|
@@ -587,181 +452,129 @@ const getTimeSlicesByResources = ({
|
|
|
587
452
|
operating_day_boundary,
|
|
588
453
|
maxBlockThreshold
|
|
589
454
|
}) => {
|
|
590
|
-
// 获取资源列表
|
|
591
455
|
let resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
592
456
|
mergeSubResourcesTimeSlices(resources, resourcesMap);
|
|
593
|
-
// 资源排下序,把单个资源靠前,组合资源排在后面
|
|
594
457
|
resources.sort((a, b) => {
|
|
595
|
-
|
|
596
|
-
const
|
|
597
|
-
|
|
598
|
-
if (
|
|
458
|
+
var _a, _b, _c, _d;
|
|
459
|
+
const aIsCombined = ((_b = (_a = a.metadata) == null ? void 0 : _a.combined_resource) == null ? void 0 : _b.status) === 1;
|
|
460
|
+
const bIsCombined = ((_d = (_c = b.metadata) == null ? void 0 : _c.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
461
|
+
if (aIsCombined && !bIsCombined)
|
|
462
|
+
return 1;
|
|
463
|
+
if (!aIsCombined && bIsCombined)
|
|
464
|
+
return -1;
|
|
599
465
|
return 0;
|
|
600
466
|
});
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
467
|
+
let timeSliceList = resources.reduce(
|
|
468
|
+
(acc, item) => {
|
|
469
|
+
return acc.concat(
|
|
470
|
+
getTimeSlicesByResource({
|
|
471
|
+
resource: item,
|
|
472
|
+
duration,
|
|
473
|
+
split,
|
|
474
|
+
currentDate,
|
|
475
|
+
capacity,
|
|
476
|
+
resourcesUseableMap,
|
|
477
|
+
cut_off_time,
|
|
478
|
+
hasFlexibleDuration,
|
|
479
|
+
operating_day_boundary,
|
|
480
|
+
maxBlockThreshold
|
|
481
|
+
})
|
|
482
|
+
);
|
|
483
|
+
},
|
|
484
|
+
[]
|
|
485
|
+
);
|
|
619
486
|
let intersection = getTimesIntersection(timeSliceList, resources.length);
|
|
620
487
|
return intersection;
|
|
621
488
|
};
|
|
622
|
-
|
|
623
|
-
/**
|
|
624
|
-
* @title: 获取其他人的已选资源
|
|
625
|
-
* @description:
|
|
626
|
-
* @param {CartItem[]} cartItems
|
|
627
|
-
* @param {number | string} accountId
|
|
628
|
-
* @return {*}
|
|
629
|
-
* @Author: jinglin.tan
|
|
630
|
-
*/
|
|
631
|
-
exports.getTimeSlicesByResources = getTimeSlicesByResources;
|
|
632
|
-
const getOthersSelectedResources = (cartItems, accountId, resourcesMap) => {
|
|
489
|
+
var getOthersSelectedResources = (cartItems, accountId, resourcesMap) => {
|
|
633
490
|
return cartItems.reduce((acc, d) => {
|
|
491
|
+
var _a;
|
|
634
492
|
if (d.holder_id !== accountId) {
|
|
635
|
-
if (d._origin
|
|
636
|
-
d._origin.resources.forEach(n => {
|
|
637
|
-
// 如果是组合资源,还需要检查组合资源里子资源是否被占用过
|
|
493
|
+
if ((_a = d._origin) == null ? void 0 : _a.resources) {
|
|
494
|
+
d._origin.resources.forEach((n) => {
|
|
638
495
|
if (n.metadata.combined_resource && n.metadata.combined_resource.status === 1) {
|
|
639
|
-
|
|
640
|
-
|
|
496
|
+
if (n.metadata.combined_resource.resource_ids.some(
|
|
497
|
+
(m) => acc.includes(m)
|
|
498
|
+
)) {
|
|
641
499
|
return acc;
|
|
642
500
|
}
|
|
643
501
|
acc.push(...n.metadata.combined_resource.resource_ids);
|
|
644
|
-
// n.metadata.combined_resource.resource_ids.forEach((m: number) => {
|
|
645
|
-
// if (resourcesMap[m]) resourcesMap[m].capacity -= d.num || 0;
|
|
646
|
-
// });
|
|
647
502
|
} else {
|
|
648
|
-
|
|
649
|
-
// 去 resourcesMap 里找一下 n.id 是不是别的组合资源里的子资源,是的话把别的组合资源也加进来
|
|
650
|
-
Object.values(resourcesMap).forEach(m => {
|
|
503
|
+
Object.values(resourcesMap).forEach((m) => {
|
|
651
504
|
if (m.combined_resource && m.combined_resource.status === 1) {
|
|
652
505
|
if (m.combined_resource.resource_ids.includes(n.id)) {
|
|
653
506
|
acc.push(m.id);
|
|
654
|
-
// if (resourcesMap[m.id]) resourcesMap[m.id].capacity -= d.num || 0;
|
|
655
507
|
}
|
|
656
508
|
}
|
|
657
509
|
});
|
|
658
510
|
}
|
|
659
511
|
acc.push(n.id);
|
|
660
|
-
// if (resourcesMap[n.id]) resourcesMap[n.id].capacity -= currentCapacity || 0;
|
|
661
512
|
});
|
|
662
513
|
}
|
|
663
514
|
}
|
|
664
515
|
return acc;
|
|
665
516
|
}, []);
|
|
666
517
|
};
|
|
667
|
-
|
|
668
|
-
/**
|
|
669
|
-
* @title: 获取其他购物车内商品的已选资源
|
|
670
|
-
* @description:
|
|
671
|
-
* @param {CartItem[]} cartItems
|
|
672
|
-
* @param {number | string} accountId
|
|
673
|
-
* @return {*}
|
|
674
|
-
* @Author: jinglin.tan
|
|
675
|
-
*/
|
|
676
|
-
exports.getOthersSelectedResources = getOthersSelectedResources;
|
|
677
|
-
const getOthersCartSelectedResources = (cartItems, cartItemId, resourcesMap) => {
|
|
518
|
+
var getOthersCartSelectedResources = (cartItems, cartItemId, resourcesMap) => {
|
|
678
519
|
return cartItems.reduce((acc, d) => {
|
|
520
|
+
var _a;
|
|
679
521
|
if (d._id !== cartItemId) {
|
|
680
|
-
if (d._origin
|
|
681
|
-
d._origin.resources.forEach(n => {
|
|
682
|
-
// 如果是组合资源,还需要检查组合资源里子资源是否被占用过
|
|
522
|
+
if ((_a = d._origin) == null ? void 0 : _a.resources) {
|
|
523
|
+
d._origin.resources.forEach((n) => {
|
|
683
524
|
if (n.metadata.combined_resource && n.metadata.combined_resource.status === 1) {
|
|
684
|
-
|
|
685
|
-
|
|
525
|
+
if (n.metadata.combined_resource.resource_ids.some(
|
|
526
|
+
(m) => acc.includes(m)
|
|
527
|
+
)) {
|
|
686
528
|
return acc;
|
|
687
529
|
}
|
|
688
530
|
acc.push(...n.metadata.combined_resource.resource_ids);
|
|
689
|
-
// n.metadata.combined_resource.resource_ids.forEach((m: number) => {
|
|
690
|
-
// resourcesMap[m].capacity -= n.num;
|
|
691
|
-
// });
|
|
692
531
|
} else {
|
|
693
|
-
|
|
694
|
-
// 去 resourcesMap 里找一下 n.id 是不是别的组合资源里的子资源,是的话把别的组合资源也加进来
|
|
695
|
-
Object.values(resourcesMap).forEach(m => {
|
|
532
|
+
Object.values(resourcesMap).forEach((m) => {
|
|
696
533
|
if (m.combined_resource && m.combined_resource.status === 1) {
|
|
697
534
|
if (m.combined_resource.resource_ids.includes(n.id)) {
|
|
698
535
|
acc.push(m.id);
|
|
699
|
-
// resourcesMap[m.id].capacity -= n.num;
|
|
700
536
|
}
|
|
701
537
|
}
|
|
702
538
|
});
|
|
703
539
|
}
|
|
704
540
|
acc.push(n.id);
|
|
705
|
-
// push 完以后,把 resourceMap 的 capacity 减掉当前的商品数量
|
|
706
|
-
// resourcesMap[n.id].capacity -= currentCapacity || 0;
|
|
707
541
|
});
|
|
708
542
|
}
|
|
709
543
|
}
|
|
710
544
|
return acc;
|
|
711
545
|
}, []);
|
|
712
546
|
};
|
|
713
|
-
exports.getOthersCartSelectedResources = getOthersCartSelectedResources;
|
|
714
|
-
/**
|
|
715
|
-
* @title: 根据日期范围过滤日程
|
|
716
|
-
*
|
|
717
|
-
* @export
|
|
718
|
-
* @param {any[]} schedule
|
|
719
|
-
* @param {string} startDate
|
|
720
|
-
* @param {string} endDate
|
|
721
|
-
* @return {*}
|
|
722
|
-
*/
|
|
723
547
|
function filterScheduleByDateRange(schedule, startDate, endDate) {
|
|
724
|
-
if (!schedule
|
|
548
|
+
if (!(schedule == null ? void 0 : schedule.length))
|
|
549
|
+
return [];
|
|
725
550
|
const start = new Date(startDate);
|
|
726
551
|
const end = new Date(endDate);
|
|
727
|
-
return schedule.filter(item => {
|
|
552
|
+
return schedule.filter((item) => {
|
|
728
553
|
const itemDate = new Date(item.date);
|
|
729
554
|
return itemDate >= start && itemDate <= end;
|
|
730
555
|
});
|
|
731
556
|
}
|
|
732
|
-
|
|
733
|
-
/**
|
|
734
|
-
* 传入商品数据,返回基于商品配置的提前量的最早开始日期和最晚结束日期
|
|
735
|
-
*
|
|
736
|
-
* @export
|
|
737
|
-
* @param {ProductData} product
|
|
738
|
-
* @return {*}
|
|
739
|
-
*/
|
|
740
557
|
function checkSessionProductLeadTime(product) {
|
|
741
|
-
let latestStartDate =
|
|
742
|
-
let earliestEndDate =
|
|
743
|
-
const {
|
|
744
|
-
future_day,
|
|
745
|
-
unit,
|
|
746
|
-
unit_type
|
|
747
|
-
} = product.cut_off_time;
|
|
748
|
-
// 预定天数存在,则开始计算从当前时间开始往后推预定天数作为结束时间
|
|
558
|
+
let latestStartDate = "";
|
|
559
|
+
let earliestEndDate = "";
|
|
560
|
+
const { future_day, unit, unit_type } = product.cut_off_time;
|
|
749
561
|
if (future_day) {
|
|
750
|
-
const endDate = (0,
|
|
751
|
-
if (!earliestEndDate || endDate.isBefore((0,
|
|
752
|
-
earliestEndDate = endDate.format(
|
|
562
|
+
const endDate = (0, import_dayjs.default)().add(future_day, "day");
|
|
563
|
+
if (!earliestEndDate || endDate.isBefore((0, import_dayjs.default)(earliestEndDate), "day")) {
|
|
564
|
+
earliestEndDate = endDate.format("YYYY-MM-DD");
|
|
753
565
|
}
|
|
754
566
|
} else if (future_day === 0) {
|
|
755
|
-
const endDate = (0,
|
|
756
|
-
if (!earliestEndDate || endDate.isBefore((0,
|
|
757
|
-
earliestEndDate = endDate.format(
|
|
567
|
+
const endDate = (0, import_dayjs.default)();
|
|
568
|
+
if (!earliestEndDate || endDate.isBefore((0, import_dayjs.default)(earliestEndDate), "day")) {
|
|
569
|
+
earliestEndDate = endDate.format("YYYY-MM-DD");
|
|
758
570
|
}
|
|
759
571
|
}
|
|
760
|
-
// 如果存在提前预约时间,则开始计算从当前时间开始往后推提前预约时间作为开始时间
|
|
761
572
|
if (unit && unit_type) {
|
|
762
|
-
const startDate = (0,
|
|
763
|
-
|
|
764
|
-
|
|
573
|
+
const startDate = (0, import_dayjs.default)(
|
|
574
|
+
(0, import_dayjs.default)().add(unit, unit_type).format("YYYY-MM-DD")
|
|
575
|
+
);
|
|
576
|
+
if (!latestStartDate || startDate.isAfter((0, import_dayjs.default)(latestStartDate), "day")) {
|
|
577
|
+
latestStartDate = startDate.format("YYYY-MM-DD");
|
|
765
578
|
}
|
|
766
579
|
}
|
|
767
580
|
return {
|
|
@@ -769,75 +582,65 @@ function checkSessionProductLeadTime(product) {
|
|
|
769
582
|
earliestEndDate
|
|
770
583
|
};
|
|
771
584
|
}
|
|
772
|
-
|
|
773
|
-
/**
|
|
774
|
-
* 基于商品的 resources 配置,返回可选择的资源的 id 列表
|
|
775
|
-
*
|
|
776
|
-
* @export
|
|
777
|
-
* @param {ProductData} product
|
|
778
|
-
* @return {*}
|
|
779
|
-
*/
|
|
780
585
|
function getResourcesIdsByProduct(product) {
|
|
586
|
+
var _a, _b, _c;
|
|
781
587
|
const tempResourceIds = [];
|
|
782
|
-
product
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
588
|
+
(_c = (_b = (_a = product == null ? void 0 : product.product_resource) == null ? void 0 : _a.resources) == null ? void 0 : _b.forEach) == null ? void 0 : _c.call(_b, (resource) => {
|
|
589
|
+
var _a2, _b2;
|
|
590
|
+
if ((resource == null ? void 0 : resource.status) == 1) {
|
|
591
|
+
if ((_a2 = resource == null ? void 0 : resource.default_resource) == null ? void 0 : _a2.length) {
|
|
592
|
+
tempResourceIds.push(...resource == null ? void 0 : resource.default_resource);
|
|
593
|
+
} else if ((_b2 = resource == null ? void 0 : resource.optional_resource) == null ? void 0 : _b2.length) {
|
|
594
|
+
tempResourceIds.push(...resource == null ? void 0 : resource.optional_resource);
|
|
788
595
|
}
|
|
789
596
|
}
|
|
790
597
|
});
|
|
791
598
|
return tempResourceIds;
|
|
792
599
|
}
|
|
793
|
-
|
|
794
|
-
/**
|
|
795
|
-
* 资源排序,把单个资源靠前,组合资源排在后面
|
|
796
|
-
*
|
|
797
|
-
* @export
|
|
798
|
-
* @param {ResourceItem[]} resourcesList
|
|
799
|
-
* @return {*}
|
|
800
|
-
*/
|
|
801
600
|
function sortCombinedResources(resourcesList) {
|
|
802
601
|
const newResourcesList = [...resourcesList];
|
|
803
602
|
newResourcesList.sort((a, b) => {
|
|
804
|
-
|
|
805
|
-
const
|
|
603
|
+
var _a, _b, _c, _d;
|
|
604
|
+
const aIsCombined = ((_b = (_a = a.metadata) == null ? void 0 : _a.combined_resource) == null ? void 0 : _b.status) === 1;
|
|
605
|
+
const bIsCombined = ((_d = (_c = b.metadata) == null ? void 0 : _c.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
806
606
|
return aIsCombined === bIsCombined ? 0 : aIsCombined ? 1 : -1;
|
|
807
607
|
});
|
|
808
608
|
return newResourcesList;
|
|
809
609
|
}
|
|
810
|
-
|
|
811
|
-
/**
|
|
812
|
-
* 传入一个资源组,根据 formid筛出相同类型的资源
|
|
813
|
-
*
|
|
814
|
-
* @export
|
|
815
|
-
* @param {ResourceItem[]} resources
|
|
816
|
-
* @param {string} form_id
|
|
817
|
-
* @return {*}
|
|
818
|
-
*/
|
|
819
610
|
function filterResourcesByFormItem(resources, form_id) {
|
|
820
|
-
return resources.filter(n => n.form_id === form_id);
|
|
611
|
+
return resources.filter((n) => n.form_id === form_id);
|
|
821
612
|
}
|
|
822
|
-
|
|
823
|
-
/**
|
|
824
|
-
* 传入两个资源,确认这两个资源是否有交集(包括组合资源)
|
|
825
|
-
*
|
|
826
|
-
* @export
|
|
827
|
-
* @param {ResourceItem} resource1
|
|
828
|
-
* @param {ResourceItem} resource2
|
|
829
|
-
* @return {*}
|
|
830
|
-
*/
|
|
831
613
|
function checkTwoResourcesIntersection(resource1, resource2) {
|
|
832
|
-
|
|
833
|
-
if (resource1.id === resource2.id)
|
|
834
|
-
|
|
835
|
-
if (resource1.metadata.combined_resource
|
|
836
|
-
// 如果现在选择的是组合资源,需要判断
|
|
614
|
+
var _a, _b;
|
|
615
|
+
if (resource1.id === resource2.id)
|
|
616
|
+
return true;
|
|
617
|
+
if (((_a = resource1.metadata.combined_resource) == null ? void 0 : _a.status) === 1 && // 如果现在选择的是组合资源,需要判断
|
|
837
618
|
// 1、当前其他购物车里是否选了当前组合资源的子资源
|
|
838
619
|
// 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
|
|
839
|
-
resource1.metadata.combined_resource.resource_ids.includes(resource2.id) || resource1.metadata.combined_resource.resource_ids.some(n => {
|
|
620
|
+
(resource1.metadata.combined_resource.resource_ids.includes(resource2.id) || resource1.metadata.combined_resource.resource_ids.some((n) => {
|
|
840
621
|
return resource2.metadata.combined_resource.resource_ids.includes(n);
|
|
841
|
-
})))
|
|
842
|
-
|
|
843
|
-
|
|
622
|
+
})))
|
|
623
|
+
return true;
|
|
624
|
+
if (((_b = resource2.metadata.combined_resource) == null ? void 0 : _b.status) === 1 && resource2.metadata.combined_resource.resource_ids.includes(resource2.id))
|
|
625
|
+
return true;
|
|
626
|
+
}
|
|
627
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
628
|
+
0 && (module.exports = {
|
|
629
|
+
checkSessionProductLeadTime,
|
|
630
|
+
checkTwoResourcesIntersection,
|
|
631
|
+
filterResourcesByFormItem,
|
|
632
|
+
filterScheduleByDateRange,
|
|
633
|
+
formatResources,
|
|
634
|
+
getIsUsableByTimeItem,
|
|
635
|
+
getOthersCartSelectedResources,
|
|
636
|
+
getOthersSelectedResources,
|
|
637
|
+
getResourcesByIds,
|
|
638
|
+
getResourcesByProduct,
|
|
639
|
+
getResourcesIdsByProduct,
|
|
640
|
+
getTimeSlicesByResource,
|
|
641
|
+
getTimeSlicesByResources,
|
|
642
|
+
getTimesIntersection,
|
|
643
|
+
isConflict,
|
|
644
|
+
mergeSubResourcesTimeSlices,
|
|
645
|
+
sortCombinedResources
|
|
646
|
+
});
|