@pisell/pisellos 0.0.567 → 0.0.569
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 +6 -9
- package/dist/model/strategy/adapter/promotion/evaluator.js +3 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -2
- package/dist/model/strategy/adapter/walletPass/example.js +3 -26
- package/dist/model/strategy/adapter/walletPass/utils.js +7 -7
- package/dist/model/strategy/strategy-example.js +5 -19
- package/dist/modules/BaseModule.d.ts +2 -2
- package/dist/modules/BaseModule.js +4 -4
- package/dist/modules/BookingContext/index.d.ts +48 -0
- package/dist/modules/BookingContext/index.js +566 -0
- package/dist/modules/BookingContext/types.d.ts +102 -0
- package/dist/modules/BookingContext/types.js +51 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +302 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +149 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +249 -0
- package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/dist/modules/BookingContext/utils/flexible.js +56 -0
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
- package/dist/modules/BookingContext/utils/index.d.ts +11 -0
- package/dist/modules/BookingContext/utils/index.js +11 -0
- package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/dist/modules/BookingContext/utils/noResource.js +77 -0
- package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/dist/modules/BookingContext/utils/orderLineDisplay.js +36 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/dist/modules/BookingContext/utils/productExtend.js +339 -0
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
- package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
- package/dist/modules/BookingContext/utils/resources.js +486 -0
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
- package/dist/modules/Cart/index.js +0 -3
- package/dist/modules/Cart/utils/cartProduct.js +26 -6
- package/dist/modules/Cart/utils/changePrice.js +27 -20
- package/dist/modules/Customer/index.d.ts +20 -0
- package/dist/modules/Customer/index.js +172 -83
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Date/index.js +1 -5
- package/dist/modules/Discount/index.d.ts +2 -1
- package/dist/modules/Discount/index.js +37 -12
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/OpenData/index.d.ts +8 -0
- package/dist/modules/OpenData/index.js +35 -17
- package/dist/modules/Order/index.d.ts +449 -24
- package/dist/modules/Order/index.js +5437 -608
- package/dist/modules/Order/types.d.ts +693 -88
- package/dist/modules/Order/types.js +68 -1
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/dist/modules/Order/utils/manualProductDiscount.js +210 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
- package/dist/modules/Order/utils.d.ts +167 -18
- package/dist/modules/Order/utils.js +960 -165
- package/dist/modules/Payment/index.d.ts +10 -9
- package/dist/modules/Payment/index.js +508 -874
- package/dist/modules/Payment/types.d.ts +40 -16
- package/dist/modules/Payment/utils.d.ts +1 -1
- package/dist/modules/Payment/utils.js +4 -3
- package/dist/modules/Payment/walletpass.js +48 -34
- package/dist/modules/Product/types.d.ts +29 -7
- package/dist/modules/ProductList/index.d.ts +17 -13
- package/dist/modules/ProductList/index.js +184 -74
- package/dist/modules/ProductList/types.d.ts +17 -0
- package/dist/modules/Quotation/index.d.ts +22 -2
- package/dist/modules/Quotation/index.js +108 -42
- package/dist/modules/Quotation/types.d.ts +19 -0
- package/dist/modules/ResourcePlanner/index.d.ts +24 -0
- package/dist/modules/ResourcePlanner/index.js +181 -0
- package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
- package/dist/modules/ResourcePlanner/planner.js +1069 -0
- package/dist/modules/ResourcePlanner/types.d.ts +227 -0
- package/dist/modules/ResourcePlanner/types.js +1 -0
- package/dist/modules/Rules/index.d.ts +8 -10
- package/dist/modules/Rules/index.js +219 -114
- package/dist/modules/Rules/types.d.ts +14 -3
- package/dist/modules/SalesSummary/index.d.ts +23 -26
- package/dist/modules/SalesSummary/index.js +152 -46
- package/dist/modules/SalesSummary/types.d.ts +9 -1
- package/dist/modules/SalesSummary/utils.d.ts +3 -22
- package/dist/modules/SalesSummary/utils.js +803 -163
- package/dist/modules/Schedule/getDateIsInSchedule.js +14 -7
- package/dist/modules/Schedule/index.d.ts +18 -5
- package/dist/modules/Schedule/index.js +78 -24
- package/dist/modules/Schedule/types.d.ts +2 -0
- package/dist/modules/Schedule/utils.js +0 -1
- package/dist/modules/Step/index.js +0 -1
- package/dist/modules/Summary/index.js +4 -3
- package/dist/modules/SurchargeList/index.d.ts +18 -0
- package/dist/modules/SurchargeList/index.js +185 -0
- package/dist/modules/SurchargeList/types.d.ts +15 -0
- package/dist/modules/SurchargeList/types.js +1 -0
- package/dist/modules/index.d.ts +3 -0
- package/dist/modules/index.js +4 -1
- package/dist/plugins/app.d.ts +2 -0
- package/dist/plugins/request.d.ts +1 -0
- package/dist/plugins/request.js +1 -4
- package/dist/plugins/window.js +2 -6
- package/dist/server/index.d.ts +462 -8
- package/dist/server/index.js +6137 -714
- package/dist/server/modules/floor-plan/index.d.ts +39 -0
- package/dist/server/modules/floor-plan/index.js +595 -0
- package/dist/server/modules/floor-plan/types.d.ts +43 -0
- package/dist/server/modules/floor-plan/types.js +13 -0
- package/dist/server/modules/index.d.ts +7 -2
- package/dist/server/modules/index.js +6 -0
- package/dist/server/modules/menu/index.js +32 -41
- package/dist/server/modules/order/index.d.ts +207 -14
- package/dist/server/modules/order/index.js +2326 -379
- package/dist/server/modules/order/types.d.ts +76 -5
- package/dist/server/modules/order/types.js +14 -1
- package/dist/server/modules/order/utils/filterBookings.d.ts +7 -1
- package/dist/server/modules/order/utils/filterBookings.js +118 -11
- package/dist/server/modules/order/utils/filterOrders.js +242 -14
- package/dist/server/modules/payment/index.d.ts +28 -0
- package/dist/server/modules/payment/index.js +305 -0
- package/dist/server/modules/payment/types.d.ts +9 -0
- package/dist/server/modules/payment/types.js +1 -0
- package/dist/server/modules/products/index.d.ts +105 -14
- package/dist/server/modules/products/index.js +1397 -540
- package/dist/server/modules/products/types.d.ts +34 -1
- package/dist/server/modules/products/types.js +4 -0
- package/dist/server/modules/quotation/index.d.ts +39 -0
- package/dist/server/modules/quotation/index.js +289 -86
- package/dist/server/modules/resource/index.d.ts +2 -3
- package/dist/server/modules/resource/index.js +105 -84
- package/dist/server/modules/schedule/index.d.ts +6 -4
- package/dist/server/modules/schedule/index.js +137 -114
- package/dist/server/test.json +713 -0
- package/dist/server/types.d.ts +2 -0
- package/dist/server/utils/product.js +2 -3
- package/dist/server/utils/small-ticket.d.ts +71 -0
- package/dist/server/utils/small-ticket.js +963 -0
- package/dist/solution/BaseSales/index.d.ts +378 -0
- package/dist/solution/BaseSales/index.js +4006 -0
- package/dist/solution/BaseSales/types.d.ts +394 -0
- package/dist/solution/BaseSales/types.js +40 -0
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
- package/dist/solution/BaseSales/utils/cartPromotion.js +1450 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +144 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +157 -0
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +18 -0
- package/dist/solution/BaseSales/utils/quotationPrice.js +250 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +63 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +218 -0
- package/dist/solution/BaseSales/utils.d.ts +40 -0
- package/dist/solution/BaseSales/utils.js +263 -0
- package/dist/solution/BookingByStep/index.js +7 -59
- package/dist/solution/BookingByStep/utils/capacity.js +1 -11
- package/dist/solution/BookingByStep/utils/resources.js +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +2 -43
- package/dist/solution/BookingTicket/index.d.ts +393 -24
- package/dist/solution/BookingTicket/index.js +2506 -445
- package/dist/solution/BookingTicket/types.d.ts +191 -6
- package/dist/solution/BookingTicket/types.js +83 -10
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
- package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
- package/dist/solution/BookingTicket/utils/addTimeAvailability.js +95 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.js +136 -0
- package/dist/solution/BookingTicket/utils/cartView.d.ts +29 -0
- package/dist/solution/BookingTicket/utils/cartView.js +209 -0
- package/dist/solution/BookingTicket/utils/exampleData.d.ts +123 -0
- package/dist/solution/BookingTicket/utils/exampleData.js +183 -0
- package/dist/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
- package/dist/solution/BookingTicket/utils/orderCustomer.js +31 -0
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +438 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +400 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +4 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +41 -1
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +56 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +36 -34
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +26 -18
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +150 -0
- package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
- package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +78 -0
- package/dist/solution/BuyTickets/index.js +9 -12
- package/dist/solution/Checkout/index.d.ts +1 -0
- package/dist/solution/Checkout/index.js +199 -277
- package/dist/solution/Checkout/utils/index.js +8 -20
- package/dist/solution/RegisterAndLogin/config.js +2 -10
- package/dist/solution/RegisterAndLogin/index.js +30 -76
- package/dist/solution/Sales/index.d.ts +50 -5
- package/dist/solution/Sales/index.js +484 -92
- package/dist/solution/Sales/types.d.ts +26 -2
- package/dist/solution/ScanOrder/index.d.ts +27 -21
- package/dist/solution/ScanOrder/index.js +509 -454
- package/dist/solution/ScanOrder/types.d.ts +33 -11
- package/dist/solution/ScanOrder/types.js +4 -5
- package/dist/solution/ScanOrder/utils.d.ts +4 -1
- package/dist/solution/ScanOrder/utils.js +109 -34
- package/dist/solution/ShopDiscount/index.js +6 -11
- package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/dist/solution/UnifiedBookingSales/index.js +1871 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/dist/solution/UnifiedBookingSales/types.js +11 -0
- package/dist/solution/VenueBooking/index.d.ts +34 -20
- package/dist/solution/VenueBooking/index.js +630 -505
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +9 -3
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -1
- package/dist/types/index.d.ts +11 -1
- package/dist/utils/task.js +15 -18
- package/dist/utils/watch.js +0 -1
- package/lib/apis/picoding.js +2 -0
- package/lib/core/index.js +130 -131
- package/lib/effects/index.js +46 -57
- package/lib/index.js +92 -53
- package/lib/model/index.js +14 -21
- package/lib/model/strategy/adapter/dataVariant/adapter.js +38 -50
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +162 -236
- package/lib/model/strategy/adapter/dataVariant/examples.js +229 -237
- package/lib/model/strategy/adapter/dataVariant/index.js +39 -34
- package/lib/model/strategy/adapter/dataVariant/type.js +57 -28
- package/lib/model/strategy/adapter/index.js +100 -64
- package/lib/model/strategy/adapter/itemRule/adapter.js +156 -144
- package/lib/model/strategy/adapter/itemRule/evaluator.js +36 -48
- package/lib/model/strategy/adapter/itemRule/examples.js +295 -225
- package/lib/model/strategy/adapter/itemRule/index.js +83 -57
- package/lib/model/strategy/adapter/itemRule/type.js +97 -36
- package/lib/model/strategy/adapter/promotion/adapter.js +84 -63
- package/lib/model/strategy/adapter/promotion/evaluator.js +383 -232
- package/lib/model/strategy/adapter/promotion/examples.js +139 -159
- package/lib/model/strategy/adapter/promotion/index.js +1 -49
- package/lib/model/strategy/adapter/promotion/type.js +199 -35
- package/lib/model/strategy/adapter/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -152
- package/lib/model/strategy/adapter/walletPass/example.js +217 -190
- package/lib/model/strategy/adapter/walletPass/index.js +75 -51
- package/lib/model/strategy/adapter/walletPass/locales.js +36 -58
- package/lib/model/strategy/adapter/walletPass/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/utils.js +654 -402
- package/lib/model/strategy/engine.js +270 -168
- package/lib/model/strategy/index.js +49 -34
- package/lib/model/strategy/strategy-example.js +243 -239
- package/lib/model/strategy/type.js +100 -40
- package/lib/modules/Account/index.js +39 -53
- package/lib/modules/Account/types.js +20 -33
- package/lib/modules/AccountList/index.js +116 -154
- package/lib/modules/AccountList/types.js +30 -31
- package/lib/modules/AccountList/utils.js +18 -30
- package/lib/modules/BaseModule.d.ts +2 -2
- package/lib/modules/BaseModule.js +26 -49
- package/lib/modules/BookingContext/index.d.ts +48 -0
- package/lib/modules/BookingContext/index.js +390 -0
- package/lib/modules/BookingContext/types.d.ts +102 -0
- package/lib/modules/BookingContext/types.js +48 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +286 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +148 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +242 -0
- package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/lib/modules/BookingContext/utils/flexible.js +63 -0
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/lib/modules/BookingContext/utils/formatResourceList.js +35 -0
- package/lib/modules/BookingContext/utils/index.d.ts +11 -0
- package/lib/modules/BookingContext/utils/index.js +126 -0
- package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/lib/modules/BookingContext/utils/noResource.js +78 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +29 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/lib/modules/BookingContext/utils/productExtend.js +330 -0
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/lib/modules/BookingContext/utils/resourceSelection.js +24 -0
- package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
- package/lib/modules/BookingContext/utils/resources.js +419 -0
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/lib/modules/BookingContext/utils/serviceTimes.js +161 -0
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/lib/modules/BookingContext/utils/timeSlices.js +114 -0
- package/lib/modules/Cart/index.js +170 -124
- package/lib/modules/Cart/types.js +46 -51
- package/lib/modules/Cart/utils/cartAccount.js +40 -39
- package/lib/modules/Cart/utils/cartDate.js +56 -61
- package/lib/modules/Cart/utils/cartDiscount.js +28 -33
- package/lib/modules/Cart/utils/cartNote.js +27 -32
- package/lib/modules/Cart/utils/cartProduct.js +331 -244
- package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
- package/lib/modules/Cart/utils/cartResource.js +72 -78
- package/lib/modules/Cart/utils/changePrice.js +37 -67
- package/lib/modules/Cart/utils/index.js +106 -48
- package/lib/modules/Customer/constants.js +13 -34
- package/lib/modules/Customer/index.d.ts +20 -0
- package/lib/modules/Customer/index.js +270 -154
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Customer/types.js +38 -35
- package/lib/modules/Date/index.js +116 -115
- package/lib/modules/Date/types.js +16 -28
- package/lib/modules/Date/utils.js +174 -123
- package/lib/modules/Discount/index.d.ts +2 -1
- package/lib/modules/Discount/index.js +133 -113
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Discount/types.js +9 -31
- package/lib/modules/Guests/index.js +30 -56
- package/lib/modules/Guests/types.js +23 -33
- package/lib/modules/Holder/index.js +209 -189
- package/lib/modules/Holder/types.js +4 -16
- package/lib/modules/Holder/utils.js +20 -49
- package/lib/modules/OpenData/index.d.ts +8 -0
- package/lib/modules/OpenData/index.js +81 -74
- package/lib/modules/OpenData/types.js +4 -16
- package/lib/modules/OpenData/utils.js +44 -78
- package/lib/modules/Order/index.d.ts +449 -24
- package/lib/modules/Order/index.js +3834 -489
- package/lib/modules/Order/types.d.ts +693 -88
- package/lib/modules/Order/types.js +78 -33
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/lib/modules/Order/utils/bundleDiscountHydration.js +106 -0
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/lib/modules/Order/utils/manualProductDiscount.js +207 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +353 -0
- package/lib/modules/Order/utils.d.ts +167 -18
- package/lib/modules/Order/utils.js +1247 -345
- package/lib/modules/Payment/cash.js +20 -33
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +145 -76
- package/lib/modules/Payment/eftpos.js +16 -30
- package/lib/modules/Payment/index.d.ts +10 -9
- package/lib/modules/Payment/index.js +542 -502
- package/lib/modules/Payment/mx51.js +1 -0
- package/lib/modules/Payment/types.d.ts +40 -16
- package/lib/modules/Payment/types.js +216 -107
- package/lib/modules/Payment/utils.d.ts +1 -1
- package/lib/modules/Payment/utils.js +53 -49
- package/lib/modules/Payment/walletpass.js +231 -203
- package/lib/modules/Product/index.js +51 -46
- package/lib/modules/Product/types.d.ts +29 -7
- package/lib/modules/Product/types.js +4 -16
- package/lib/modules/Product/utils.js +32 -33
- package/lib/modules/ProductList/index.d.ts +17 -13
- package/lib/modules/ProductList/index.js +160 -118
- package/lib/modules/ProductList/types.d.ts +17 -0
- package/lib/modules/ProductList/types.js +9 -31
- package/lib/modules/Quotation/index.d.ts +22 -2
- package/lib/modules/Quotation/index.js +123 -89
- package/lib/modules/Quotation/types.d.ts +19 -0
- package/lib/modules/Quotation/types.js +4 -16
- package/lib/modules/Resource/index.js +27 -59
- package/lib/modules/Resource/types.js +22 -32
- package/lib/modules/Resource/utils.js +30 -38
- package/lib/modules/ResourcePlanner/index.d.ts +24 -0
- package/lib/modules/ResourcePlanner/index.js +147 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
- package/lib/modules/ResourcePlanner/planner.js +895 -0
- package/lib/modules/ResourcePlanner/types.d.ts +227 -0
- package/lib/modules/ResourcePlanner/types.js +5 -0
- package/lib/modules/Rules/index.d.ts +8 -10
- package/lib/modules/Rules/index.js +1286 -894
- package/lib/modules/Rules/types.d.ts +14 -3
- package/lib/modules/Rules/types.js +17 -40
- package/lib/modules/SalesSummary/index.d.ts +23 -26
- package/lib/modules/SalesSummary/index.js +130 -71
- package/lib/modules/SalesSummary/types.d.ts +9 -1
- package/lib/modules/SalesSummary/types.js +4 -16
- package/lib/modules/SalesSummary/utils.d.ts +3 -22
- package/lib/modules/SalesSummary/utils.js +738 -250
- package/lib/modules/ScanOrderLogger/index.js +59 -79
- package/lib/modules/ScanOrderLogger/providers/feishu.js +54 -78
- package/lib/modules/ScanOrderLogger/providers/grafana.js +13 -36
- package/lib/modules/ScanOrderLogger/types.js +4 -16
- package/lib/modules/Schedule/getDateIsInSchedule.js +345 -171
- package/lib/modules/Schedule/index.d.ts +18 -5
- package/lib/modules/Schedule/index.js +139 -114
- package/lib/modules/Schedule/type.js +4 -16
- package/lib/modules/Schedule/types.d.ts +2 -0
- package/lib/modules/Schedule/types.js +4 -16
- package/lib/modules/Schedule/utils.js +433 -291
- package/lib/modules/Step/index.js +40 -52
- package/lib/modules/Step/tyeps.js +4 -16
- package/lib/modules/Summary/index.js +66 -70
- package/lib/modules/Summary/types.js +4 -16
- package/lib/modules/Summary/utils.js +782 -429
- package/lib/modules/SurchargeList/index.d.ts +18 -0
- package/lib/modules/SurchargeList/index.js +95 -0
- package/lib/modules/SurchargeList/types.d.ts +15 -0
- package/lib/modules/SurchargeList/types.js +5 -0
- package/lib/modules/index.d.ts +3 -0
- package/lib/modules/index.js +245 -57
- package/lib/plugins/app.d.ts +2 -0
- package/lib/plugins/app.js +4 -16
- package/lib/plugins/index.js +36 -25
- package/lib/plugins/request.d.ts +1 -0
- package/lib/plugins/request.js +137 -126
- package/lib/plugins/shopStore.js +4 -16
- package/lib/plugins/user.js +4 -16
- package/lib/plugins/window.js +171 -179
- package/lib/server/index.d.ts +462 -8
- package/lib/server/index.js +4668 -713
- package/lib/server/modules/floor-plan/index.d.ts +39 -0
- package/lib/server/modules/floor-plan/index.js +306 -0
- package/lib/server/modules/floor-plan/types.d.ts +43 -0
- package/lib/server/modules/floor-plan/types.js +19 -0
- package/lib/server/modules/index.d.ts +7 -2
- package/lib/server/modules/index.js +106 -59
- package/lib/server/modules/menu/index.js +146 -122
- package/lib/server/modules/menu/types.js +18 -31
- package/lib/server/modules/order/index.d.ts +207 -14
- package/lib/server/modules/order/index.js +1463 -316
- package/lib/server/modules/order/types.d.ts +76 -5
- package/lib/server/modules/order/types.js +117 -32
- package/lib/server/modules/order/utils/filterBookings.d.ts +7 -1
- package/lib/server/modules/order/utils/filterBookings.js +288 -146
- package/lib/server/modules/order/utils/filterOrders.js +318 -64
- package/lib/server/modules/payment/index.d.ts +28 -0
- package/lib/server/modules/payment/index.js +168 -0
- package/lib/server/modules/payment/types.d.ts +9 -0
- package/lib/server/modules/payment/types.js +5 -0
- package/lib/server/modules/products/index.d.ts +105 -14
- package/lib/server/modules/products/index.js +969 -383
- package/lib/server/modules/products/types.d.ts +34 -1
- package/lib/server/modules/products/types.js +44 -34
- package/lib/server/modules/quotation/index.d.ts +39 -0
- package/lib/server/modules/quotation/index.js +220 -77
- package/lib/server/modules/quotation/types.js +21 -31
- package/lib/server/modules/resource/index.d.ts +2 -3
- package/lib/server/modules/resource/index.js +269 -214
- package/lib/server/modules/resource/types.js +42 -33
- package/lib/server/modules/schedule/index.d.ts +6 -4
- package/lib/server/modules/schedule/index.js +158 -132
- package/lib/server/modules/schedule/types.js +14 -21
- package/lib/server/modules/schedule/utils.js +334 -163
- package/lib/server/test.json +713 -0
- package/lib/server/types.d.ts +2 -0
- package/lib/server/types.js +4 -16
- package/lib/server/utils/index.js +25 -23
- package/lib/server/utils/product.js +197 -140
- package/lib/server/utils/schedule.js +34 -41
- package/lib/server/utils/small-ticket.d.ts +71 -0
- package/lib/server/utils/small-ticket.js +926 -0
- package/lib/server/utils/time.js +40 -49
- package/lib/solution/BaseSales/index.d.ts +378 -0
- package/lib/solution/BaseSales/index.js +2367 -0
- package/lib/solution/BaseSales/types.d.ts +394 -0
- package/lib/solution/BaseSales/types.js +47 -0
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
- package/lib/solution/BaseSales/utils/cartPromotion.js +1155 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +144 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +140 -0
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +18 -0
- package/lib/solution/BaseSales/utils/quotationPrice.js +231 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +63 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +215 -0
- package/lib/solution/BaseSales/utils.d.ts +40 -0
- package/lib/solution/BaseSales/utils.js +259 -0
- package/lib/solution/BookingByStep/index.js +1530 -1343
- package/lib/solution/BookingByStep/types.js +40 -99
- package/lib/solution/BookingByStep/utils/capacity.js +192 -160
- package/lib/solution/BookingByStep/utils/products.js +42 -52
- package/lib/solution/BookingByStep/utils/resources.js +527 -330
- package/lib/solution/BookingByStep/utils/stock.js +65 -44
- package/lib/solution/BookingByStep/utils/timeslots.js +129 -131
- package/lib/solution/BookingTicket/index.d.ts +393 -24
- package/lib/solution/BookingTicket/index.js +1459 -160
- package/lib/solution/BookingTicket/types.d.ts +191 -6
- package/lib/solution/BookingTicket/types.js +101 -66
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +353 -0
- package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +94 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.js +136 -0
- package/lib/solution/BookingTicket/utils/cartView.d.ts +29 -0
- package/lib/solution/BookingTicket/utils/cartView.js +200 -0
- package/lib/solution/BookingTicket/utils/exampleData.d.ts +123 -0
- package/lib/solution/BookingTicket/utils/exampleData.js +185 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +35 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +387 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +220 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +85 -80
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +64 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +84 -80
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +103 -95
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +115 -0
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +83 -0
- package/lib/solution/BuyTickets/index.js +67 -70
- package/lib/solution/BuyTickets/types.js +22 -38
- package/lib/solution/Checkout/index.d.ts +1 -0
- package/lib/solution/Checkout/index.js +1461 -1169
- package/lib/solution/Checkout/types.js +91 -61
- package/lib/solution/Checkout/utils/index.js +228 -159
- package/lib/solution/PlaceOrder/index.js +55 -0
- package/lib/solution/RegisterAndLogin/config.js +495 -470
- package/lib/solution/RegisterAndLogin/index.js +633 -630
- package/lib/solution/RegisterAndLogin/types.js +189 -76
- package/lib/solution/RegisterAndLogin/utils.js +183 -125
- package/lib/solution/Sales/index.d.ts +50 -5
- package/lib/solution/Sales/index.js +495 -220
- package/lib/solution/Sales/types.d.ts +26 -2
- package/lib/solution/Sales/types.js +27 -33
- package/lib/solution/ScanOrder/index.d.ts +27 -21
- package/lib/solution/ScanOrder/index.js +908 -904
- package/lib/solution/ScanOrder/types.d.ts +33 -11
- package/lib/solution/ScanOrder/types.js +33 -34
- package/lib/solution/ScanOrder/utils.d.ts +4 -1
- package/lib/solution/ScanOrder/utils.js +457 -344
- package/lib/solution/ShopDiscount/index.js +230 -236
- package/lib/solution/ShopDiscount/types.js +15 -37
- package/lib/solution/ShopDiscount/utils.js +309 -172
- package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/lib/solution/UnifiedBookingSales/index.js +1050 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/lib/solution/UnifiedBookingSales/types.js +14 -0
- package/lib/solution/VenueBooking/index.d.ts +34 -20
- package/lib/solution/VenueBooking/index.js +982 -950
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/lib/solution/VenueBooking/types.js +20 -40
- package/lib/solution/VenueBooking/utils/dateSummary.js +22 -54
- package/lib/solution/VenueBooking/utils/resource.js +31 -54
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +96 -108
- package/lib/solution/VenueBooking/utils/smartPricing.js +112 -100
- package/lib/solution/VenueBooking/utils/timeSlot.js +133 -132
- package/lib/solution/VenueBooking/utils.js +130 -67
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +124 -37
- package/lib/store/createStore.js +32 -29
- package/lib/types/index.d.ts +11 -1
- package/lib/types/index.js +4 -16
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +81 -47
- package/package.json +2 -1
- package/dist/solution/Checkout/appointmentDemo.json +0 -1
- package/lib/solution/Checkout/appointmentDemo.json +0 -1
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatResource = formatResource;
|
|
7
|
+
exports.formatResources = formatResources;
|
|
8
|
+
exports.formatTimes = formatTimes;
|
|
9
|
+
exports.getResourceByIds = getResourceByIds;
|
|
10
|
+
exports.getResourceTimeIsUsable = getResourceTimeIsUsable;
|
|
11
|
+
exports.getSumCapacity = getSumCapacity;
|
|
12
|
+
exports.getUsableTime = getUsableTime;
|
|
13
|
+
exports.setDefaultCapacitys = setDefaultCapacitys;
|
|
14
|
+
exports.setDefaultResource = setDefaultResource;
|
|
15
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
16
|
+
var _lodashEs = require("lodash-es");
|
|
17
|
+
var _flexible = require("./flexible");
|
|
18
|
+
var _noResource = require("./noResource");
|
|
19
|
+
var _serviceTimes = require("./serviceTimes");
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
/**
|
|
22
|
+
* 资源运行态计算 helper(搬自 info2 `utilsByBooking.ts` + `service/addService/utils.tsx`)。
|
|
23
|
+
*
|
|
24
|
+
* 本文件输入输出全部为 plain object,不依赖 React / locales / @pisell/icon / mini-redux。
|
|
25
|
+
* 调用方传入:resource origin map(`/form/schedule` 返回) / cacheItem(含 `_extend.duration / _extend.start_date / _extend.start_time` 等)。
|
|
26
|
+
*
|
|
27
|
+
* 三个 info2 独有特性保留:
|
|
28
|
+
* 1. `resource_display_scope='all'`:取全部资源
|
|
29
|
+
* 2. `extraResources`:拖入未绑定资源时兼容渲染
|
|
30
|
+
* 3. `getNoResource2()`:占位"无资源"行
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 从已选资源中取「最早结束」的 usableTime,供灵活时长计算上限。
|
|
35
|
+
* 与 info2 `service/addService/utils.tsx#getUsableTime` 等价。
|
|
36
|
+
*/
|
|
37
|
+
function getUsableTime(cacheItem) {
|
|
38
|
+
try {
|
|
39
|
+
const resourceByForm = cacheItem?._extend?.resource || {};
|
|
40
|
+
const resourceMaps = cacheItem?._data?.resourceMaps || {};
|
|
41
|
+
let items = [];
|
|
42
|
+
for (const formId of Object.keys(resourceByForm)) {
|
|
43
|
+
const selected = resourceByForm[formId];
|
|
44
|
+
const maps = resourceMaps[formId]?.renderListMaps;
|
|
45
|
+
if (!Array.isArray(selected) || !maps) continue;
|
|
46
|
+
items = items.concat(selected.map(d => maps[d.relation_id]).filter(Boolean));
|
|
47
|
+
}
|
|
48
|
+
if (!items.length) return null;
|
|
49
|
+
return items.reduce((pre, event) => {
|
|
50
|
+
const endAt = (0, _dayjs.default)(event._extend?.usableTime?.end_at);
|
|
51
|
+
const preEnd = (0, _dayjs.default)(pre._extend?.usableTime?.end_at);
|
|
52
|
+
return endAt.isBefore(preEnd) ? event : pre;
|
|
53
|
+
}, items[0]);
|
|
54
|
+
} catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Σ cacheItem._extend.capacity[].value × _extend.quantity。 */
|
|
60
|
+
function getSumCapacity(cacheItem, isCalcQuantity = true) {
|
|
61
|
+
const list = cacheItem?._extend?.capacity || [];
|
|
62
|
+
let sum = 0;
|
|
63
|
+
for (const item of list) {
|
|
64
|
+
sum += Number(item?.value || 0);
|
|
65
|
+
}
|
|
66
|
+
return sum * (isCalcQuantity ? cacheItem?._extend?.quantity || 1 : 1);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** 当前 time 剩余容量 = totalCapacity - Σ event.pax。 */
|
|
70
|
+
function getUseableEventCount(eventList, current) {
|
|
71
|
+
return (eventList || []).reduce((pre, event) => pre - (event?.pax || 0), current || 0);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** 判断两个时间段是否有冲突。 */
|
|
75
|
+
function isConflict(event, current) {
|
|
76
|
+
const eventStart = (0, _dayjs.default)(event.start_at);
|
|
77
|
+
const eventEnd = (0, _dayjs.default)(event.end_at);
|
|
78
|
+
const currentStart = (0, _dayjs.default)(current.start_at);
|
|
79
|
+
const isBefore = currentStart.isBefore(eventEnd);
|
|
80
|
+
let isAfter = true;
|
|
81
|
+
if (current.end_at) {
|
|
82
|
+
const currentEnd = (0, _dayjs.default)(current.end_at);
|
|
83
|
+
isAfter = currentEnd.isAfter(eventStart);
|
|
84
|
+
}
|
|
85
|
+
return isBefore && isAfter;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 判断单个 time 是否可用,写回 `_extend` 标记位(isDateRange / isCountRange / isUsable / isMaxLimitRange)。
|
|
90
|
+
* 与 info2 `utilsByBooking.ts#getResourceTimeIsUsable` 等价。
|
|
91
|
+
*/
|
|
92
|
+
function getResourceTimeIsUsable(item, cacheItem, resourceItem) {
|
|
93
|
+
const startDate = (0, _dayjs.default)(`${(0, _dayjs.default)(cacheItem._extend.start_date).format('YYYY-MM-DD')} ${(0, _serviceTimes.getServeStartTime)(cacheItem._extend.start_time)}`);
|
|
94
|
+
const isFlexible = _flexible.flexibleObj.isFlexible(cacheItem._extend.duration);
|
|
95
|
+
let isMaxLimitRange = false;
|
|
96
|
+
let isDateRange = false;
|
|
97
|
+
let isCountRange = false;
|
|
98
|
+
const time = {
|
|
99
|
+
...item
|
|
100
|
+
};
|
|
101
|
+
const timeStartDate = (0, _dayjs.default)(`${time.start_date} ${time.start_time}`).subtract(1, 'second');
|
|
102
|
+
const timeEndDate = (0, _dayjs.default)(`${time.end_date} ${time.end_time}`).add(1, 'second');
|
|
103
|
+
const totalCount = getUseableEventCount(time.event_list, resourceItem.capacity);
|
|
104
|
+
const currentCount = getSumCapacity(cacheItem);
|
|
105
|
+
let eventList = time.event_list || [];
|
|
106
|
+
if (cacheItem?.booking_id) {
|
|
107
|
+
eventList = eventList.filter(event => event.id !== cacheItem.booking_id);
|
|
108
|
+
}
|
|
109
|
+
let endDate = null;
|
|
110
|
+
let isCalcCount = true;
|
|
111
|
+
if (isFlexible) {
|
|
112
|
+
isDateRange = startDate.isAfter(timeStartDate) && startDate.isBefore(timeEndDate);
|
|
113
|
+
if (!isDateRange && eventList.length) {
|
|
114
|
+
isCalcCount = false;
|
|
115
|
+
isDateRange = true;
|
|
116
|
+
isCountRange = false;
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
endDate = startDate.add(_flexible.flexibleObj.getValue(cacheItem._extend.duration), 'minute');
|
|
120
|
+
const isTimeRange = startDate.isAfter(timeStartDate) && endDate.isBefore(timeEndDate);
|
|
121
|
+
if (isTimeRange) isDateRange = true;
|
|
122
|
+
}
|
|
123
|
+
if (isCalcCount) {
|
|
124
|
+
const conflict = (eventList || []).filter(d => isConflict({
|
|
125
|
+
start_at: d.start_at,
|
|
126
|
+
end_at: d.end_at
|
|
127
|
+
}, {
|
|
128
|
+
start_at: startDate,
|
|
129
|
+
end_at: endDate
|
|
130
|
+
}));
|
|
131
|
+
if (resourceItem.resourceType === 'single') {
|
|
132
|
+
isCountRange = conflict.length === 0;
|
|
133
|
+
} else {
|
|
134
|
+
const conflictCount = getUseableEventCount(conflict, resourceItem.capacity);
|
|
135
|
+
isCountRange = currentCount <= conflictCount;
|
|
136
|
+
// totalCount 当前未直接参与判定,保留 reference 以与原版接近。
|
|
137
|
+
void totalCount;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const isUsable = isDateRange && isCountRange;
|
|
141
|
+
time._extend = {
|
|
142
|
+
isMaxLimitRange,
|
|
143
|
+
isDateRange,
|
|
144
|
+
isCountRange,
|
|
145
|
+
isUsable
|
|
146
|
+
};
|
|
147
|
+
return time;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 在 resource.times 中找到最佳可用 time,并写回 `_extend.usableTime`。
|
|
152
|
+
* 与 info2 `utilsByBooking.ts#formatTimes` 等价。
|
|
153
|
+
*/
|
|
154
|
+
function formatTimes(resourceItem, cacheItem) {
|
|
155
|
+
const usableTimes = [];
|
|
156
|
+
const _resourceItem = {
|
|
157
|
+
...resourceItem
|
|
158
|
+
};
|
|
159
|
+
const sum = getSumCapacity(cacheItem);
|
|
160
|
+
if (_resourceItem.capacity >= sum) {
|
|
161
|
+
_resourceItem.times = (_resourceItem.times || []).map(time => {
|
|
162
|
+
const _time = getResourceTimeIsUsable(time, cacheItem, _resourceItem);
|
|
163
|
+
if (_time?._extend?.isDateRange) usableTimes.push(_time);
|
|
164
|
+
return _time;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
const _time = usableTimes.sort((a, b) => {
|
|
168
|
+
const aEnd = (0, _dayjs.default)(`${a.end_date} ${a.end_time}`).valueOf();
|
|
169
|
+
const bEnd = (0, _dayjs.default)(`${b.end_date} ${b.end_time}`).valueOf();
|
|
170
|
+
return aEnd - bEnd;
|
|
171
|
+
})[0];
|
|
172
|
+
resourceItem._extend = {
|
|
173
|
+
...resourceItem._extend,
|
|
174
|
+
usableTime: _time
|
|
175
|
+
};
|
|
176
|
+
return resourceItem;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* 单个 resource 的整体可用性 + labelText 填充。
|
|
181
|
+
* 与 info2 `utilsByBooking.ts#formatResource` 等价;不再接收 formatLabel 回调(OS 不渲染 JSX)。
|
|
182
|
+
*/
|
|
183
|
+
function formatResource(resourceItem, cacheItem) {
|
|
184
|
+
let _resourceItem = {
|
|
185
|
+
...resourceItem
|
|
186
|
+
};
|
|
187
|
+
_resourceItem = formatTimes(_resourceItem, cacheItem);
|
|
188
|
+
_resourceItem.labelText = _resourceItem.main_field;
|
|
189
|
+
const usable = _resourceItem._extend?.usableTime?._extend?.isUsable;
|
|
190
|
+
_resourceItem.usable = usable;
|
|
191
|
+
return _resourceItem;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* 把单个 resource origin 类型(如「技师」)的 renderList 中每个资源跑一遍 formatResource,
|
|
196
|
+
* 并维护 unbound 标记(拖入未绑定资源时 UI 用)。
|
|
197
|
+
* 与 info2 `service/addService/utils.tsx#formatResources` 等价(剥 JSX)。
|
|
198
|
+
*/
|
|
199
|
+
function formatResources(params) {
|
|
200
|
+
const {
|
|
201
|
+
cacheItem,
|
|
202
|
+
resourcesOrigin
|
|
203
|
+
} = params;
|
|
204
|
+
try {
|
|
205
|
+
const maps = {};
|
|
206
|
+
const list = resourcesOrigin.map(item => {
|
|
207
|
+
const _item = (0, _lodashEs.cloneDeep)(item);
|
|
208
|
+
const renderListMaps = {};
|
|
209
|
+
_item.renderList = _item.renderList.map(d => {
|
|
210
|
+
const res = formatResource(d, cacheItem);
|
|
211
|
+
const unbound = !item.optional_resource.includes(res.id) && !item.default_resource.includes(res.id) && res.id !== 0;
|
|
212
|
+
if (unbound) res.unbound = true;
|
|
213
|
+
renderListMaps[res.id] = res;
|
|
214
|
+
return res;
|
|
215
|
+
}).sort((a, b) => b.usable ? 1 : -1);
|
|
216
|
+
maps[_item.form_id] = {
|
|
217
|
+
..._item,
|
|
218
|
+
renderListMaps
|
|
219
|
+
};
|
|
220
|
+
return _item;
|
|
221
|
+
});
|
|
222
|
+
return {
|
|
223
|
+
list,
|
|
224
|
+
maps
|
|
225
|
+
};
|
|
226
|
+
} catch (err) {
|
|
227
|
+
console.warn('[BookingContext] formatResources error', err);
|
|
228
|
+
return {
|
|
229
|
+
list: [],
|
|
230
|
+
maps: {}
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** 取可用资源中"最大空闲时长"的那一个,作为自动分派候选。 */
|
|
236
|
+
function getResourceMaxFreeTime(resource, isAutoAllocationOn) {
|
|
237
|
+
const {
|
|
238
|
+
renderList,
|
|
239
|
+
form_id
|
|
240
|
+
} = resource;
|
|
241
|
+
if (!isAutoAllocationOn(form_id)) return [];
|
|
242
|
+
const usableList = (renderList || []).filter(d => d.usable && d.id !== 0);
|
|
243
|
+
let defaultResource = [];
|
|
244
|
+
let maxFreeTime = 0;
|
|
245
|
+
usableList.forEach(d => {
|
|
246
|
+
const {
|
|
247
|
+
times = []
|
|
248
|
+
} = d;
|
|
249
|
+
const currentMaxFreeTime = times.reduce((pre, cur) => {
|
|
250
|
+
const start = cur.event_list?.[cur.event_list?.length - 1]?.end_at || cur.start_at;
|
|
251
|
+
const end = cur.end_at;
|
|
252
|
+
const diff = (0, _dayjs.default)(end).diff((0, _dayjs.default)(start), 'minute');
|
|
253
|
+
return diff > pre ? diff : pre;
|
|
254
|
+
}, 0);
|
|
255
|
+
if (currentMaxFreeTime > maxFreeTime) {
|
|
256
|
+
maxFreeTime = currentMaxFreeTime;
|
|
257
|
+
defaultResource = [d];
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
return defaultResource;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* 计算每类资源的默认值(写入 cacheItem._extend.resource)。
|
|
265
|
+
* 与 info2 `service/addService/utils.tsx#setDefaultResource` 等价;
|
|
266
|
+
* `resourceIdFromCalendar` 替代原版 sessionStorage `serviceParams.resource_id` 读取。
|
|
267
|
+
*/
|
|
268
|
+
function setDefaultResource(params) {
|
|
269
|
+
const {
|
|
270
|
+
cacheItem,
|
|
271
|
+
resources,
|
|
272
|
+
resourceIdFromCalendar,
|
|
273
|
+
isAutoAllocationOn = () => true
|
|
274
|
+
} = params;
|
|
275
|
+
const obj = {};
|
|
276
|
+
const resourceId = Number(resourceIdFromCalendar) || 0;
|
|
277
|
+
for (const item of resources) {
|
|
278
|
+
const {
|
|
279
|
+
select_type = {},
|
|
280
|
+
optional_resource = [],
|
|
281
|
+
default_resource = []
|
|
282
|
+
} = item;
|
|
283
|
+
const renderList = item.renderList.filter(d => {
|
|
284
|
+
if (select_type?.type === 'single') {
|
|
285
|
+
if (resourceId && (optional_resource.includes(resourceId) || default_resource.includes(resourceId))) {
|
|
286
|
+
return d.id === resourceId;
|
|
287
|
+
}
|
|
288
|
+
return d.is_default === 1;
|
|
289
|
+
}
|
|
290
|
+
return d.is_default === 1 || d.id === resourceId;
|
|
291
|
+
});
|
|
292
|
+
let defaultOriginalResource = [];
|
|
293
|
+
if (renderList.length === 0) {
|
|
294
|
+
defaultOriginalResource = getResourceMaxFreeTime(item, isAutoAllocationOn);
|
|
295
|
+
} else {
|
|
296
|
+
defaultOriginalResource = renderList;
|
|
297
|
+
}
|
|
298
|
+
obj[item.form_id] = defaultOriginalResource.map(d => ({
|
|
299
|
+
children: d.children,
|
|
300
|
+
relation_type: d.relation_type,
|
|
301
|
+
form_id: item.form_id,
|
|
302
|
+
relation_id: d.id,
|
|
303
|
+
like_status: 'common',
|
|
304
|
+
metadata: {
|
|
305
|
+
form_name: item.title,
|
|
306
|
+
resource_name: d.main_field
|
|
307
|
+
}
|
|
308
|
+
}));
|
|
309
|
+
// errors 字段由调用方在需要时通过 getResourceErrors 单独算,OS 这里不耦合。
|
|
310
|
+
}
|
|
311
|
+
return obj;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* 计算默认容量(与 info2 `setDefaultCapacitys` 等价)。
|
|
316
|
+
* package:按 _extend.other.bundle 拆 quantity;custom:按 capacity.custom[].min;其他:[{id:0,value:1}]。
|
|
317
|
+
*/
|
|
318
|
+
function setDefaultCapacitys(params) {
|
|
319
|
+
const {
|
|
320
|
+
capacitys,
|
|
321
|
+
cacheItem
|
|
322
|
+
} = params;
|
|
323
|
+
if (capacitys?.type === 'package') {
|
|
324
|
+
return (cacheItem?._extend?.other?.bundle || []).map(d => {
|
|
325
|
+
const id = d._bundle_product_id;
|
|
326
|
+
const item = (capacitys?.package || []).find(p => p.product_id === id);
|
|
327
|
+
return {
|
|
328
|
+
id,
|
|
329
|
+
value: item ? d.quantity || 0 : 0,
|
|
330
|
+
name: item?.name || d?.title
|
|
331
|
+
};
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
if (capacitys?.type === 'custom') {
|
|
335
|
+
return (capacitys?.custom || []).map(d => ({
|
|
336
|
+
id: d.id,
|
|
337
|
+
value: d.min,
|
|
338
|
+
name: d.name
|
|
339
|
+
}));
|
|
340
|
+
}
|
|
341
|
+
return [{
|
|
342
|
+
id: 0,
|
|
343
|
+
value: 1,
|
|
344
|
+
name: ''
|
|
345
|
+
}];
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* 通过商品 `product_resource.resources[]` 关联的 form/resource id,从 resourcesOriginMap 还原资源数据。
|
|
350
|
+
* 与 info2 `service/addService/utils.tsx#getResourceByIds` 等价(保留三特性)。
|
|
351
|
+
*/
|
|
352
|
+
function getResourceByIds(resourcesOriginMap, cacheItem, extraParams) {
|
|
353
|
+
const _resources = [...(cacheItem?.product_resource?.resources || [])].filter(d => Number(d?.status) === 1).map(item => ({
|
|
354
|
+
...item
|
|
355
|
+
}));
|
|
356
|
+
const {
|
|
357
|
+
extraResources = [],
|
|
358
|
+
resourcesOrigin = [],
|
|
359
|
+
resourceTab = {}
|
|
360
|
+
} = extraParams || {};
|
|
361
|
+
for (const item of _resources) {
|
|
362
|
+
const form_id = item.id;
|
|
363
|
+
const isAllResource = resourceTab?.[item.code]?.resource_display_scope === 'all';
|
|
364
|
+
let extraResourceIds = [];
|
|
365
|
+
if (isAllResource) {
|
|
366
|
+
extraResourceIds = (resourcesOrigin || []).filter(d => d.form_code === item.code).map(d => d.id);
|
|
367
|
+
} else {
|
|
368
|
+
extraResourceIds = extraResources.filter(_extraItem => _extraItem.form_id === form_id && !!_extraItem.id && !item.optional_resource.includes(_extraItem.id) && !item.default_resource.includes(_extraItem.id)).map(_extraItem => _extraItem.id);
|
|
369
|
+
}
|
|
370
|
+
extraResourceIds = Array.from(new Set(extraResourceIds));
|
|
371
|
+
item.optional_resource = (item.optional_resource || []).filter(d => item.default_resource.indexOf(d) === -1);
|
|
372
|
+
const getChildrenMetadata = id => {
|
|
373
|
+
const combiningResources = [];
|
|
374
|
+
const origin = resourcesOriginMap[id];
|
|
375
|
+
if (origin?.combined_resource && origin.combined_resource.status === 1) {
|
|
376
|
+
(origin.combined_resource.resource_ids || []).forEach(cid => {
|
|
377
|
+
if (resourcesOriginMap[cid]) {
|
|
378
|
+
combiningResources.push({
|
|
379
|
+
...resourcesOriginMap[cid],
|
|
380
|
+
relation_id: resourcesOriginMap[cid]?.relation_id || resourcesOriginMap[cid]?.id
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
return {
|
|
386
|
+
children: combiningResources,
|
|
387
|
+
metadata: {
|
|
388
|
+
...(origin?.metadata || {}),
|
|
389
|
+
combined_resource: origin?.combined_resource
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
};
|
|
393
|
+
const optional_resource = Array.from(new Set([...item.optional_resource, ...extraResourceIds])).map(d => {
|
|
394
|
+
if (!resourcesOriginMap[d]) return null;
|
|
395
|
+
return Object.assign({}, resourcesOriginMap[d], {
|
|
396
|
+
form_id,
|
|
397
|
+
resourceType: item.type,
|
|
398
|
+
...getChildrenMetadata(d)
|
|
399
|
+
});
|
|
400
|
+
}).filter(d => d).concat((0, _noResource.getNoResource2)({
|
|
401
|
+
form_id
|
|
402
|
+
}));
|
|
403
|
+
const default_resource = (item.default_resource || []).map(d => {
|
|
404
|
+
const origin = resourcesOriginMap[d];
|
|
405
|
+
if (origin) {
|
|
406
|
+
origin.is_default = 1;
|
|
407
|
+
return Object.assign({}, origin, {
|
|
408
|
+
form_id,
|
|
409
|
+
resourceType: item.type,
|
|
410
|
+
...getChildrenMetadata(d)
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
return null;
|
|
414
|
+
}).filter(d => d);
|
|
415
|
+
item.renderList = optional_resource.concat(default_resource);
|
|
416
|
+
item.form_id = form_id;
|
|
417
|
+
}
|
|
418
|
+
return _resources;
|
|
419
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Dayjs } from 'dayjs';
|
|
2
|
+
import { getDurationValue } from './flexible';
|
|
3
|
+
/**
|
|
4
|
+
* 判断商品是否为跨日预约(duration.type === 'days')。与 info2 isMultiDayProduct 等价。
|
|
5
|
+
*/
|
|
6
|
+
export declare function isMultiDayProduct(product: any): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* 判断 cacheItem 是否为 session 商品(extension_type ∈ session_product / session_ticket)。
|
|
9
|
+
*/
|
|
10
|
+
export declare function isSessionProduct(cacheItem: any): boolean;
|
|
11
|
+
/** 从 catalog `cartDetailValue` 或 `_extend.other` 取 session 快照。 */
|
|
12
|
+
export declare function getSessionFromItem(item: any): Record<string, any> | null;
|
|
13
|
+
/**
|
|
14
|
+
* 将 cartDetailValue.session 写入 _extend 的起止时间(与 info2 getServiceStartTimeAndEndTime 的 session 分支一致)。
|
|
15
|
+
* 日历日优先用 ctx.date,时分取自 session.start_at / end_at 或 session.start_time / end_time。
|
|
16
|
+
*/
|
|
17
|
+
export declare function applySessionTimesToExtend(item: any, extend: Record<string, any>, ctx?: {
|
|
18
|
+
date?: string | Dayjs | null;
|
|
19
|
+
}): Record<string, any>;
|
|
20
|
+
/**
|
|
21
|
+
* 是否应写入 booking(与 Product.utils isNormalProduct 对齐,并覆盖 session_ticket / cartDetailValue.session)。
|
|
22
|
+
*/
|
|
23
|
+
export declare function isBookingProduct(item: any): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* 处理 'now' 时间占位:'now' → 当前 HH:mm;其他原样返回。
|
|
26
|
+
* 与 info2 `getServeStartTime` 等价。
|
|
27
|
+
*/
|
|
28
|
+
export declare function getServeStartTime(startTime: string | undefined | null): string;
|
|
29
|
+
/**
|
|
30
|
+
* 计算商品的开始结束时间(统一为 dayjs 实例)。
|
|
31
|
+
* 与 info2 `getServiceTimes` 行为等价:
|
|
32
|
+
* - 跨日商品:startDate = start_date + start_time,endDate = _extend.end_date 原样
|
|
33
|
+
* - session 商品:从 _extend.other.session 取 start_at / end_at
|
|
34
|
+
* - 普通商品:startDate + duration(含 flexible 处理)
|
|
35
|
+
*/
|
|
36
|
+
export declare function getServiceTimes(service: any): {
|
|
37
|
+
startDate: Dayjs;
|
|
38
|
+
endDate: Dayjs;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* 跨日预约相关:把 _extend.start_date / end_date 都对齐到 dayjs startOf('day')。
|
|
42
|
+
* 与 info2 `formatDayDate` 等价。
|
|
43
|
+
*/
|
|
44
|
+
export declare function formatDayDate(_extend: any): {
|
|
45
|
+
start_date: Dayjs;
|
|
46
|
+
end_date: Dayjs;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* 计算跨日预约时长:
|
|
50
|
+
* - type='days' → end - start 的天数
|
|
51
|
+
* - type='minutes' → end - start 的分钟数
|
|
52
|
+
* 与 info2 `getDays` 等价。
|
|
53
|
+
*/
|
|
54
|
+
export declare function getDays(cacheItem: any, type: 'minutes' | 'days'): number;
|
|
55
|
+
export { getDurationValue };
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.applySessionTimesToExtend = applySessionTimesToExtend;
|
|
7
|
+
exports.formatDayDate = formatDayDate;
|
|
8
|
+
exports.getDays = getDays;
|
|
9
|
+
Object.defineProperty(exports, "getDurationValue", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _flexible.getDurationValue;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
exports.getServeStartTime = getServeStartTime;
|
|
16
|
+
exports.getServiceTimes = getServiceTimes;
|
|
17
|
+
exports.getSessionFromItem = getSessionFromItem;
|
|
18
|
+
exports.isBookingProduct = isBookingProduct;
|
|
19
|
+
exports.isMultiDayProduct = isMultiDayProduct;
|
|
20
|
+
exports.isSessionProduct = isSessionProduct;
|
|
21
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
22
|
+
var _flexible = require("./flexible");
|
|
23
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
+
/**
|
|
25
|
+
* 判断商品是否为跨日预约(duration.type === 'days')。与 info2 isMultiDayProduct 等价。
|
|
26
|
+
*/
|
|
27
|
+
function isMultiDayProduct(product) {
|
|
28
|
+
return product?.duration?.type === 'days';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 判断 cacheItem 是否为 session 商品(extension_type ∈ session_product / session_ticket)。
|
|
33
|
+
*/
|
|
34
|
+
function isSessionProduct(cacheItem) {
|
|
35
|
+
return ['session_product', 'session_ticket'].includes(cacheItem?.extension_type);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** 从 catalog `cartDetailValue` 或 `_extend.other` 取 session 快照。 */
|
|
39
|
+
function getSessionFromItem(item) {
|
|
40
|
+
const session = item?.cartDetailValue?.session ?? item?._extend?.other?.session;
|
|
41
|
+
return session && typeof session === 'object' ? session : null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 将 cartDetailValue.session 写入 _extend 的起止时间(与 info2 getServiceStartTimeAndEndTime 的 session 分支一致)。
|
|
46
|
+
* 日历日优先用 ctx.date,时分取自 session.start_at / end_at 或 session.start_time / end_time。
|
|
47
|
+
*/
|
|
48
|
+
function applySessionTimesToExtend(item, extend, ctx) {
|
|
49
|
+
const session = extend?.other?.session ?? getSessionFromItem(item);
|
|
50
|
+
if (!session || !isSessionProduct(item)) {
|
|
51
|
+
return extend;
|
|
52
|
+
}
|
|
53
|
+
const baseDate = ctx?.date ? (0, _dayjs.default)(ctx.date) : (0, _dayjs.default)();
|
|
54
|
+
const startAt = (0, _dayjs.default)(`${baseDate.format('YYYY-MM-DD')} ${(0, _dayjs.default)(session.start_at).format('HH:mm:ss')}`);
|
|
55
|
+
const endAt = (0, _dayjs.default)(`${baseDate.format('YYYY-MM-DD')} ${(0, _dayjs.default)(session.end_at).format('HH:mm:ss')}`);
|
|
56
|
+
const nextExtend = {
|
|
57
|
+
...extend,
|
|
58
|
+
other: {
|
|
59
|
+
...(extend.other || {}),
|
|
60
|
+
session
|
|
61
|
+
},
|
|
62
|
+
start_date: startAt,
|
|
63
|
+
startDate: startAt,
|
|
64
|
+
start_time: session.start_time ?? (0, _dayjs.default)(session.start_at).format('HH:mm'),
|
|
65
|
+
end_date: endAt,
|
|
66
|
+
endDate: endAt,
|
|
67
|
+
end_time: session.end_time ?? (0, _dayjs.default)(session.end_at).format('HH:mm')
|
|
68
|
+
};
|
|
69
|
+
return {
|
|
70
|
+
...nextExtend,
|
|
71
|
+
duration: getDays({
|
|
72
|
+
_extend: nextExtend
|
|
73
|
+
}, 'minutes')
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 是否应写入 booking(与 Product.utils isNormalProduct 对齐,并覆盖 session_ticket / cartDetailValue.session)。
|
|
79
|
+
*/
|
|
80
|
+
function isBookingProduct(item) {
|
|
81
|
+
if (!item) return false;
|
|
82
|
+
if (item.duration) return true;
|
|
83
|
+
if (item?.schedules?.length) return true;
|
|
84
|
+
if (item?.['schedule.ids']?.length) return true;
|
|
85
|
+
if (isSessionProduct(item)) return true;
|
|
86
|
+
if (getSessionFromItem(item)) return true;
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 处理 'now' 时间占位:'now' → 当前 HH:mm;其他原样返回。
|
|
92
|
+
* 与 info2 `getServeStartTime` 等价。
|
|
93
|
+
*/
|
|
94
|
+
function getServeStartTime(startTime) {
|
|
95
|
+
if (startTime === 'now') return (0, _dayjs.default)().format('HH:mm');
|
|
96
|
+
return startTime || '';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* 计算商品的开始结束时间(统一为 dayjs 实例)。
|
|
101
|
+
* 与 info2 `getServiceTimes` 行为等价:
|
|
102
|
+
* - 跨日商品:startDate = start_date + start_time,endDate = _extend.end_date 原样
|
|
103
|
+
* - session 商品:从 _extend.other.session 取 start_at / end_at
|
|
104
|
+
* - 普通商品:startDate + duration(含 flexible 处理)
|
|
105
|
+
*/
|
|
106
|
+
function getServiceTimes(service) {
|
|
107
|
+
const startDate = (0, _dayjs.default)(`${(0, _dayjs.default)(service?._extend?.start_date).format('YYYY-MM-DD')} ${getServeStartTime(service?._extend?.start_time)}`);
|
|
108
|
+
if (isMultiDayProduct(service)) {
|
|
109
|
+
const startTime = getServeStartTime(service?._extend?.start_time);
|
|
110
|
+
const endDateRaw = service?._extend?.end_date ?? service?._extend?.endDate;
|
|
111
|
+
const endBase = (0, _dayjs.default)(endDateRaw);
|
|
112
|
+
// 跨日结束日保留与开始相同的时刻(如 11:24),避免 end_date 仅日期时被解析为 00:00
|
|
113
|
+
const endDate = endBase.isValid() ? (0, _dayjs.default)(`${endBase.format('YYYY-MM-DD')} ${startTime}`) : endBase;
|
|
114
|
+
return {
|
|
115
|
+
startDate,
|
|
116
|
+
endDate
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const session = service?._extend?.other?.session;
|
|
120
|
+
if (isSessionProduct(service) && session) {
|
|
121
|
+
return {
|
|
122
|
+
startDate: (0, _dayjs.default)(session.start_at),
|
|
123
|
+
endDate: (0, _dayjs.default)(session.end_at)
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
const endDate = startDate.add(_flexible.flexibleObj.getValue(service?._extend?.duration), 'minute');
|
|
127
|
+
return {
|
|
128
|
+
startDate,
|
|
129
|
+
endDate
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* 跨日预约相关:把 _extend.start_date / end_date 都对齐到 dayjs startOf('day')。
|
|
135
|
+
* 与 info2 `formatDayDate` 等价。
|
|
136
|
+
*/
|
|
137
|
+
function formatDayDate(_extend) {
|
|
138
|
+
return {
|
|
139
|
+
start_date: (0, _dayjs.default)(_extend?.start_date).startOf('day'),
|
|
140
|
+
end_date: (0, _dayjs.default)(_extend?.end_date).startOf('day')
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* 计算跨日预约时长:
|
|
146
|
+
* - type='days' → end - start 的天数
|
|
147
|
+
* - type='minutes' → end - start 的分钟数
|
|
148
|
+
* 与 info2 `getDays` 等价。
|
|
149
|
+
*/
|
|
150
|
+
function getDays(cacheItem, type) {
|
|
151
|
+
if (type === 'days') {
|
|
152
|
+
const {
|
|
153
|
+
start_date,
|
|
154
|
+
end_date
|
|
155
|
+
} = formatDayDate(cacheItem._extend);
|
|
156
|
+
return end_date.diff(start_date, 'day');
|
|
157
|
+
}
|
|
158
|
+
const startDate = (0, _dayjs.default)(cacheItem?._extend?.start_date);
|
|
159
|
+
const endDate = (0, _dayjs.default)(cacheItem?._extend?.end_date);
|
|
160
|
+
return endDate.diff(startDate, type);
|
|
161
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import { getDurationValue } from './flexible';
|
|
3
|
+
export interface TimeSlice {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
export interface DurationSlice {
|
|
8
|
+
label: string;
|
|
9
|
+
value: number;
|
|
10
|
+
}
|
|
11
|
+
export interface TimeSlicesResult {
|
|
12
|
+
timeSlices: TimeSlice[];
|
|
13
|
+
durationSlicesBasedOnTime: DurationSlice[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 把一天切成等长时间槽,输出 timeSlices(开始时间标签)与 durationSlicesBasedOnTime(基于切片的时长选项)。
|
|
17
|
+
*
|
|
18
|
+
* 与 info2 `sliceDayIntoFiveMinutes` 行为等价;为了不依赖 `locales`,label 输出原始时间字符串('08:00 AM' / '90'),
|
|
19
|
+
* UI 侧需要本地化展示时可基于 value 自行包装。
|
|
20
|
+
*
|
|
21
|
+
* @param config booking config `basic.service_time`,{ value: minutes }
|
|
22
|
+
* @param isDay 是否跨日预约(true 时按 1~30 天切片)
|
|
23
|
+
*/
|
|
24
|
+
export declare function sliceDayIntoFiveMinutes(config: {
|
|
25
|
+
value?: number;
|
|
26
|
+
} | undefined | null, isDay?: boolean): TimeSlicesResult;
|
|
27
|
+
/**
|
|
28
|
+
* 取「下一个 duration 选项」:优先用 defaultValue;否则在 array 中找匹配的;找不到取第一个。
|
|
29
|
+
* 与 info2 `findNextDuration` 等价。
|
|
30
|
+
*/
|
|
31
|
+
export declare function findNextDuration(current: {
|
|
32
|
+
value?: number;
|
|
33
|
+
} | undefined, array: DurationSlice[], defaultValue?: number): number | undefined;
|
|
34
|
+
/** 取首选 time slice:若指定 date(HH:mm)则找第一个 >= date 的;否则第一个。 */
|
|
35
|
+
export declare function findNextSlice(params: {
|
|
36
|
+
timeSlices: TimeSlice[];
|
|
37
|
+
index?: number;
|
|
38
|
+
date?: string;
|
|
39
|
+
}): string | undefined;
|
|
40
|
+
/** 取 endDate;duration='flexible' 时取 endDate 与店铺营业时间的较小值,否则 startDate + duration 分钟。 */
|
|
41
|
+
export declare function getEndDate(startDate: dayjs.Dayjs, duration: string | number, endDate: any, shopOpeningHours?: string): dayjs.Dayjs;
|
|
42
|
+
export { getDurationValue };
|