@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,72 @@
|
|
|
1
|
+
import { getSumCapacity } from './resources';
|
|
2
|
+
import { TimeSlicesResult, TimeSlice, DurationSlice } from './timeSlices';
|
|
3
|
+
/**
|
|
4
|
+
* 上下文(与 info2 state.bookingConfig / state.service / state.date 一一对应)。
|
|
5
|
+
*
|
|
6
|
+
* 设计原则:所有助手函数都通过 context 显式拿数据,**不读 mini-redux**,
|
|
7
|
+
* 让 OS 这层完全可在 Node 单测下运行(dayjs 在 Node 也是纯函数)。
|
|
8
|
+
*/
|
|
9
|
+
export interface BookingCalcContext {
|
|
10
|
+
/** 来自 `/core/board/management/config` 的整套配置;常用路径见 sliceTimeSlices / appointmentTimingPreference。 */
|
|
11
|
+
bookingConfig?: any;
|
|
12
|
+
/** 资源 origin map(id → resource origin)。 */
|
|
13
|
+
resourcesOriginMap?: Record<string, any>;
|
|
14
|
+
/** 资源全集列表(display_scope=all 时用)。 */
|
|
15
|
+
resourcesOrigin?: any[];
|
|
16
|
+
/** 当前选择的日期(dayjs 或 string)。 */
|
|
17
|
+
date?: any;
|
|
18
|
+
/** 上一个服务行(getServiceStartTimeAndEndTime 拼接续接 start_time 用)。可缺省。 */
|
|
19
|
+
previousService?: any;
|
|
20
|
+
/** 日历选中的资源 id(替代 info2 sessionStorage.serviceParams.resource_id)。 */
|
|
21
|
+
resourceIdFromCalendar?: number;
|
|
22
|
+
/** 资源自动分派开关(替代 info2 localStorage 'resource-auto-allocation');默认全开。 */
|
|
23
|
+
isAutoAllocationOn?: (formId: any) => boolean;
|
|
24
|
+
/** 当前预设开始时间(替代 info2 sessionStorage.serviceParams.start_date 取 HH:mm)。 */
|
|
25
|
+
presetStartTime?: string;
|
|
26
|
+
/** 店铺打烊时间(替代 info2 localStorage shopOpeningHours),默认 23:59。 */
|
|
27
|
+
shopOpeningHours?: string;
|
|
28
|
+
}
|
|
29
|
+
/** 从 BookingContext.date 提取 HH:mm(仅当日期带有效时分时)。 */
|
|
30
|
+
export declare function derivePresetStartTimeFromDate(date: any): string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* 时间切片对象(含灵活时长选项)。与 info2 `getTimeObj` 等价。
|
|
33
|
+
*/
|
|
34
|
+
export declare function getTimeObj(params: {
|
|
35
|
+
cacheItem: any;
|
|
36
|
+
useStartTime?: string;
|
|
37
|
+
useDuration?: number | string;
|
|
38
|
+
ctx: BookingCalcContext;
|
|
39
|
+
}): TimeSlicesResult & {
|
|
40
|
+
timeSlices: TimeSlice[];
|
|
41
|
+
durationSlicesBasedOnTime: DurationSlice[];
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* 计算商品行 _extend(包含 start_time / endDate / duration / start_date / end_date / sub_type 等)。
|
|
45
|
+
* 与 info2 `utilsByBooking.ts#getServiceStartTimeAndEndTime` 等价;显著差异:
|
|
46
|
+
* - 不读 `state.service.value` / `mini-redux`,由 ctx.previousService 显式注入。
|
|
47
|
+
* - 不读 `sessionStorage.serviceParams`,由 ctx.presetStartTime / ctx.resourceIdFromCalendar 注入。
|
|
48
|
+
* - cacheItem.isCustomItem → 直接返回 `{ duration: null }`。
|
|
49
|
+
*/
|
|
50
|
+
export declare function getServiceStartTimeAndEndTime(params: {
|
|
51
|
+
cacheItem: any;
|
|
52
|
+
timeObj: TimeSlicesResult;
|
|
53
|
+
ctx: BookingCalcContext;
|
|
54
|
+
}): any;
|
|
55
|
+
/**
|
|
56
|
+
* 综合:把 cacheItem 拼装出完整的 _extend / _data(资源 / 容量 / timeObj),并标记 autoClose。
|
|
57
|
+
* 与 info2 `service/addService/utils.tsx#getProductExtend` 等价;剥 React `console.time` / JSX。
|
|
58
|
+
*
|
|
59
|
+
* 入参 ctx 必须至少给:bookingConfig / resourcesOriginMap / resourcesOrigin / date。
|
|
60
|
+
*/
|
|
61
|
+
export declare function getProductExtend(params: {
|
|
62
|
+
cacheItem: any;
|
|
63
|
+
ctx: BookingCalcContext;
|
|
64
|
+
isDisabledTime?: boolean;
|
|
65
|
+
}): any;
|
|
66
|
+
/**
|
|
67
|
+
* 是否可自动关闭弹窗(不需要用户进 EditService 抽屉)。
|
|
68
|
+
* 与 info2 `service/addService/utils.tsx#getIsAutoClose` 等价;
|
|
69
|
+
* `getAutoAllocationStorage` 抽象为入参 `isAutoAllocationOn(formId)`。
|
|
70
|
+
*/
|
|
71
|
+
export declare function getIsAutoClose(cacheItem: any, isAutoAllocationOn: (formId: any) => boolean): boolean;
|
|
72
|
+
export { getSumCapacity };
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
5
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
12
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
15
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
16
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
17
|
+
import dayjs from 'dayjs';
|
|
18
|
+
import { formatResources, getResourceByIds, getSumCapacity, getUsableTime, setDefaultCapacitys, setDefaultResource } from "./resources";
|
|
19
|
+
import { hasActualResourceSelection, productNeedsResourceExtend } from "./resourceSelection";
|
|
20
|
+
import { isMultiDayProduct, isSessionProduct, getDays, getServiceTimes } from "./serviceTimes";
|
|
21
|
+
import { sliceDayIntoFiveMinutes, findNextDuration, getEndDate } from "./timeSlices";
|
|
22
|
+
import { flexibleObj, getDurationValue, isProductFlexibleDuration } from "./flexible";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 上下文(与 info2 state.bookingConfig / state.service / state.date 一一对应)。
|
|
26
|
+
*
|
|
27
|
+
* 设计原则:所有助手函数都通过 context 显式拿数据,**不读 mini-redux**,
|
|
28
|
+
* 让 OS 这层完全可在 Node 单测下运行(dayjs 在 Node 也是纯函数)。
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/** 从 BookingContext.date 提取 HH:mm(仅当日期带有效时分时)。 */
|
|
32
|
+
export function derivePresetStartTimeFromDate(date) {
|
|
33
|
+
if (date == null) return undefined;
|
|
34
|
+
var d = dayjs(date);
|
|
35
|
+
if (!d.isValid()) return undefined;
|
|
36
|
+
var hhmm = d.format('HH:mm');
|
|
37
|
+
if (hhmm === '00:00') return undefined;
|
|
38
|
+
return hhmm;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 取预约时间偏好(sequential / parallel);默认 sequential。
|
|
43
|
+
*/
|
|
44
|
+
function getAppointmentTimingPreference(ctx) {
|
|
45
|
+
var _ctx$bookingConfig;
|
|
46
|
+
return (ctx === null || ctx === void 0 || (_ctx$bookingConfig = ctx.bookingConfig) === null || _ctx$bookingConfig === void 0 || (_ctx$bookingConfig = _ctx$bookingConfig.config) === null || _ctx$bookingConfig === void 0 || (_ctx$bookingConfig = _ctx$bookingConfig.information_tab) === null || _ctx$bookingConfig === void 0 ? void 0 : _ctx$bookingConfig.appointment_timing_preference) || 'sequential';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 灵活时长选项(cacheItem.duration.type === 'flexible' 时)。
|
|
51
|
+
*/
|
|
52
|
+
function getFlexibleOption(params) {
|
|
53
|
+
var _cacheItem$_extend, _cacheItem$_extend2, _usable$_extend, _params$ctx;
|
|
54
|
+
var cacheItem = params.cacheItem,
|
|
55
|
+
useStartTime = params.useStartTime;
|
|
56
|
+
var duration = getDurationValue(cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.duration);
|
|
57
|
+
if (duration !== 'flexible') return null;
|
|
58
|
+
var startDate = dayjs("".concat(dayjs(cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.start_date).format('YYYY-MM-DD'), " ").concat(useStartTime || (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.start_time) || '00:00'));
|
|
59
|
+
var usable = getUsableTime(cacheItem);
|
|
60
|
+
var usableEndAt = usable !== null && usable !== void 0 && (_usable$_extend = usable._extend) !== null && _usable$_extend !== void 0 && (_usable$_extend = _usable$_extend.usableTime) !== null && _usable$_extend !== void 0 && _usable$_extend.end_at ? dayjs(usable._extend.usableTime.end_at) : null;
|
|
61
|
+
var endDate = getEndDate(startDate, 'flexible', usableEndAt, (_params$ctx = params.ctx) === null || _params$ctx === void 0 ? void 0 : _params$ctx.shopOpeningHours);
|
|
62
|
+
var timeValue = endDate.diff(startDate, 'minute');
|
|
63
|
+
return {
|
|
64
|
+
label: String(timeValue),
|
|
65
|
+
value: flexibleObj.create(timeValue)
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 时间切片对象(含灵活时长选项)。与 info2 `getTimeObj` 等价。
|
|
71
|
+
*/
|
|
72
|
+
export function getTimeObj(params) {
|
|
73
|
+
var _ctx$bookingConfig2;
|
|
74
|
+
var cacheItem = params.cacheItem,
|
|
75
|
+
useStartTime = params.useStartTime,
|
|
76
|
+
useDuration = params.useDuration,
|
|
77
|
+
ctx = params.ctx;
|
|
78
|
+
var isMultiDay = isMultiDayProduct(cacheItem);
|
|
79
|
+
var flexibleOption = getFlexibleOption({
|
|
80
|
+
cacheItem: cacheItem,
|
|
81
|
+
useStartTime: useStartTime,
|
|
82
|
+
ctx: ctx
|
|
83
|
+
});
|
|
84
|
+
var baseSlices = sliceDayIntoFiveMinutes(ctx === null || ctx === void 0 || (_ctx$bookingConfig2 = ctx.bookingConfig) === null || _ctx$bookingConfig2 === void 0 || (_ctx$bookingConfig2 = _ctx$bookingConfig2.config) === null || _ctx$bookingConfig2 === void 0 || (_ctx$bookingConfig2 = _ctx$bookingConfig2.basic) === null || _ctx$bookingConfig2 === void 0 ? void 0 : _ctx$bookingConfig2.service_time, isMultiDay);
|
|
85
|
+
var timeSlices = _toConsumableArray(baseSlices.timeSlices);
|
|
86
|
+
var durationSlicesBasedOnTime = _toConsumableArray(baseSlices.durationSlicesBasedOnTime);
|
|
87
|
+
if (flexibleOption) {
|
|
88
|
+
durationSlicesBasedOnTime.unshift(flexibleOption);
|
|
89
|
+
}
|
|
90
|
+
if (useDuration && !durationSlicesBasedOnTime.some(function (d) {
|
|
91
|
+
return d.value === useDuration;
|
|
92
|
+
})) {
|
|
93
|
+
durationSlicesBasedOnTime.unshift({
|
|
94
|
+
label: String(useDuration),
|
|
95
|
+
value: useDuration
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
timeSlices: timeSlices,
|
|
100
|
+
durationSlicesBasedOnTime: durationSlicesBasedOnTime
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 计算商品行 _extend(包含 start_time / endDate / duration / start_date / end_date / sub_type 等)。
|
|
106
|
+
* 与 info2 `utilsByBooking.ts#getServiceStartTimeAndEndTime` 等价;显著差异:
|
|
107
|
+
* - 不读 `state.service.value` / `mini-redux`,由 ctx.previousService 显式注入。
|
|
108
|
+
* - 不读 `sessionStorage.serviceParams`,由 ctx.presetStartTime / ctx.resourceIdFromCalendar 注入。
|
|
109
|
+
* - cacheItem.isCustomItem → 直接返回 `{ duration: null }`。
|
|
110
|
+
*/
|
|
111
|
+
export function getServiceStartTimeAndEndTime(params) {
|
|
112
|
+
var _cacheItem$_extend3;
|
|
113
|
+
var cacheItem = params.cacheItem,
|
|
114
|
+
timeObj = params.timeObj,
|
|
115
|
+
ctx = params.ctx;
|
|
116
|
+
if (cacheItem !== null && cacheItem !== void 0 && cacheItem.isCustomItem) {
|
|
117
|
+
return {
|
|
118
|
+
duration: null
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
var appointmentTimingPreference = getAppointmentTimingPreference(ctx);
|
|
122
|
+
var lastServer = ctx.previousService || null;
|
|
123
|
+
var resolveDuration = function resolveDuration() {
|
|
124
|
+
var _cacheItem$duration;
|
|
125
|
+
if (isMultiDayProduct(cacheItem)) return getDays(cacheItem, 'days');
|
|
126
|
+
return findNextDuration(cacheItem.duration, timeObj.durationSlicesBasedOnTime, cacheItem === null || cacheItem === void 0 || (_cacheItem$duration = cacheItem.duration) === null || _cacheItem$duration === void 0 ? void 0 : _cacheItem$duration.value);
|
|
127
|
+
};
|
|
128
|
+
var _extend = {
|
|
129
|
+
duration: resolveDuration()
|
|
130
|
+
};
|
|
131
|
+
if (lastServer) {
|
|
132
|
+
var _lastServer$_extend, _lastServer$_extend2;
|
|
133
|
+
var lastStart = (_lastServer$_extend = lastServer._extend) === null || _lastServer$_extend === void 0 ? void 0 : _lastServer$_extend.startDate;
|
|
134
|
+
var lastEnd = (_lastServer$_extend2 = lastServer._extend) === null || _lastServer$_extend2 === void 0 ? void 0 : _lastServer$_extend2.endDate;
|
|
135
|
+
if (appointmentTimingPreference === 'parallel') {
|
|
136
|
+
_extend.start_time = dayjs(lastStart).format('HH:mm');
|
|
137
|
+
} else if (dayjs(lastEnd).isAfter(dayjs(lastStart), 'day')) {
|
|
138
|
+
var _timeObj$timeSlices;
|
|
139
|
+
_extend.start_time = (_timeObj$timeSlices = timeObj.timeSlices[timeObj.timeSlices.length - 1]) === null || _timeObj$timeSlices === void 0 ? void 0 : _timeObj$timeSlices.value;
|
|
140
|
+
} else {
|
|
141
|
+
_extend.start_time = lastEnd ? dayjs(lastEnd).format('HH:mm') : dayjs().format('HH:mm');
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
var presetStartTime = ctx.presetStartTime;
|
|
145
|
+
// 与 info2 getServiceStartTimeAndEndTime 一致:日历/顶部日期带 HH:mm 时原样使用,
|
|
146
|
+
// 不做 findNextSlice 栅格对齐(否则 01:47 会被抬到 01:50)。
|
|
147
|
+
if (presetStartTime && presetStartTime !== '00:00') {
|
|
148
|
+
_extend.start_time = presetStartTime;
|
|
149
|
+
} else if (cacheItem.currentDefaultTime) {
|
|
150
|
+
_extend.start_time = cacheItem.currentDefaultTime;
|
|
151
|
+
} else {
|
|
152
|
+
_extend.start_time = dayjs().format('HH:mm');
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
_extend = _objectSpread(_objectSpread({}, _extend), cacheItem._extend);
|
|
156
|
+
var _getServiceTimes = getServiceTimes(_objectSpread(_objectSpread({}, cacheItem), {}, {
|
|
157
|
+
_extend: _extend
|
|
158
|
+
})),
|
|
159
|
+
startDate = _getServiceTimes.startDate,
|
|
160
|
+
endDate = _getServiceTimes.endDate;
|
|
161
|
+
_extend.startDate = startDate;
|
|
162
|
+
_extend.endDate = endDate;
|
|
163
|
+
if (isMultiDayProduct(cacheItem)) {
|
|
164
|
+
var _extend$start_date, _extend$end_date;
|
|
165
|
+
_extend.start_time = _extend.start_time || startDate.format('HH:mm');
|
|
166
|
+
_extend.end_time = _extend.end_time || endDate.format('HH:mm');
|
|
167
|
+
_extend.start_date = (_extend$start_date = _extend.start_date) !== null && _extend$start_date !== void 0 ? _extend$start_date : startDate;
|
|
168
|
+
_extend.end_date = (_extend$end_date = _extend.end_date) !== null && _extend$end_date !== void 0 ? _extend$end_date : endDate;
|
|
169
|
+
}
|
|
170
|
+
var session = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend3 = cacheItem._extend) === null || _cacheItem$_extend3 === void 0 || (_cacheItem$_extend3 = _cacheItem$_extend3.other) === null || _cacheItem$_extend3 === void 0 ? void 0 : _cacheItem$_extend3.session;
|
|
171
|
+
if (isSessionProduct(cacheItem) && session) {
|
|
172
|
+
var baseDate = ctx.date ? dayjs(ctx.date) : dayjs();
|
|
173
|
+
var startAt = dayjs("".concat(baseDate.format('YYYY-MM-DD'), " ").concat(dayjs(session.start_at).format('HH:mm:ss')));
|
|
174
|
+
var endAt = dayjs("".concat(baseDate.format('YYYY-MM-DD'), " ").concat(dayjs(session.end_at).format('HH:mm:ss')));
|
|
175
|
+
_extend.start_date = startAt;
|
|
176
|
+
_extend.startDate = startAt;
|
|
177
|
+
_extend.start_time = session.start_time;
|
|
178
|
+
_extend.end_date = endAt;
|
|
179
|
+
_extend.endDate = endAt;
|
|
180
|
+
_extend.end_time = session.end_time;
|
|
181
|
+
_extend.duration = getDays({
|
|
182
|
+
_extend: _extend
|
|
183
|
+
}, 'minutes');
|
|
184
|
+
}
|
|
185
|
+
return _extend;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* 综合:把 cacheItem 拼装出完整的 _extend / _data(资源 / 容量 / timeObj),并标记 autoClose。
|
|
190
|
+
* 与 info2 `service/addService/utils.tsx#getProductExtend` 等价;剥 React `console.time` / JSX。
|
|
191
|
+
*
|
|
192
|
+
* 入参 ctx 必须至少给:bookingConfig / resourcesOriginMap / resourcesOrigin / date。
|
|
193
|
+
*/
|
|
194
|
+
export function getProductExtend(params) {
|
|
195
|
+
var _cacheItem$_extend4;
|
|
196
|
+
var cacheItem = params.cacheItem,
|
|
197
|
+
ctx = params.ctx,
|
|
198
|
+
isDisabledTime = params.isDisabledTime;
|
|
199
|
+
var isNew = cacheItem.new || !((_cacheItem$_extend4 = cacheItem._extend) !== null && _cacheItem$_extend4 !== void 0 && _cacheItem$_extend4.endDate);
|
|
200
|
+
var _cacheItem = _objectSpread({}, cacheItem);
|
|
201
|
+
var resourcesOriginMap = ctx.resourcesOriginMap || {};
|
|
202
|
+
_cacheItem._data = {};
|
|
203
|
+
if (isMultiDayProduct(cacheItem)) {
|
|
204
|
+
var _cacheItem$_extend5;
|
|
205
|
+
_cacheItem._extend = _cacheItem._extend || {};
|
|
206
|
+
_cacheItem._extend.holder_id = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend5 = cacheItem._extend) === null || _cacheItem$_extend5 === void 0 ? void 0 : _cacheItem$_extend5.holder_id) || [];
|
|
207
|
+
_cacheItem._extend.sub_type = 'days';
|
|
208
|
+
}
|
|
209
|
+
if (isNew) {
|
|
210
|
+
var _ctx$bookingConfig3;
|
|
211
|
+
_cacheItem._data.timeObj = getTimeObj({
|
|
212
|
+
cacheItem: cacheItem,
|
|
213
|
+
ctx: ctx
|
|
214
|
+
});
|
|
215
|
+
_cacheItem._extend = getServiceStartTimeAndEndTime({
|
|
216
|
+
cacheItem: cacheItem,
|
|
217
|
+
timeObj: _cacheItem._data.timeObj,
|
|
218
|
+
ctx: ctx
|
|
219
|
+
});
|
|
220
|
+
_cacheItem._data.capacitys = cacheItem.capacity;
|
|
221
|
+
_cacheItem._data.resourcesOrigin = getResourceByIds(resourcesOriginMap, cacheItem, {
|
|
222
|
+
resourceTab: ctx === null || ctx === void 0 || (_ctx$bookingConfig3 = ctx.bookingConfig) === null || _ctx$bookingConfig3 === void 0 || (_ctx$bookingConfig3 = _ctx$bookingConfig3.config) === null || _ctx$bookingConfig3 === void 0 ? void 0 : _ctx$bookingConfig3.resource_tab,
|
|
223
|
+
resourcesOrigin: ctx.resourcesOrigin || []
|
|
224
|
+
});
|
|
225
|
+
_cacheItem._extend.capacity = setDefaultCapacitys({
|
|
226
|
+
capacitys: _cacheItem._data.capacitys,
|
|
227
|
+
cacheItem: _cacheItem
|
|
228
|
+
});
|
|
229
|
+
var _formatResources = formatResources({
|
|
230
|
+
cacheItem: _cacheItem,
|
|
231
|
+
resourcesOrigin: _cacheItem._data.resourcesOrigin
|
|
232
|
+
}),
|
|
233
|
+
list = _formatResources.list,
|
|
234
|
+
maps = _formatResources.maps;
|
|
235
|
+
_cacheItem._data.resources = list;
|
|
236
|
+
_cacheItem._data.resourceMaps = maps;
|
|
237
|
+
_cacheItem._extend.resource = setDefaultResource({
|
|
238
|
+
cacheItem: _cacheItem,
|
|
239
|
+
resources: _cacheItem._data.resources,
|
|
240
|
+
resourceIdFromCalendar: ctx.resourceIdFromCalendar,
|
|
241
|
+
isAutoAllocationOn: ctx.isAutoAllocationOn
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
// 灵活时长二次计算(资源默认选中后,按 usableTime 重算 flexible 分钟数)
|
|
245
|
+
if (isProductFlexibleDuration(_cacheItem === null || _cacheItem === void 0 ? void 0 : _cacheItem.duration)) {
|
|
246
|
+
var _cacheItem$_data$time;
|
|
247
|
+
_cacheItem._data.timeObj = getTimeObj({
|
|
248
|
+
cacheItem: _cacheItem,
|
|
249
|
+
useStartTime: _cacheItem._extend.start_time,
|
|
250
|
+
ctx: ctx
|
|
251
|
+
});
|
|
252
|
+
_cacheItem._extend.duration = (_cacheItem$_data$time = _cacheItem._data.timeObj) === null || _cacheItem$_data$time === void 0 || (_cacheItem$_data$time = _cacheItem$_data$time.durationSlicesBasedOnTime) === null || _cacheItem$_data$time === void 0 || (_cacheItem$_data$time = _cacheItem$_data$time[0]) === null || _cacheItem$_data$time === void 0 ? void 0 : _cacheItem$_data$time.value;
|
|
253
|
+
var _getServiceTimes2 = getServiceTimes(_cacheItem),
|
|
254
|
+
endDate = _getServiceTimes2.endDate;
|
|
255
|
+
_cacheItem._extend.endDate = endDate;
|
|
256
|
+
}
|
|
257
|
+
_cacheItem.autoClose = getIsAutoClose(_cacheItem, ctx.isAutoAllocationOn || function () {
|
|
258
|
+
return true;
|
|
259
|
+
});
|
|
260
|
+
if (_cacheItem._extend.bundle_edit !== undefined) {
|
|
261
|
+
_cacheItem._extend.bundle_edit = 1;
|
|
262
|
+
}
|
|
263
|
+
if (!isDisabledTime) {
|
|
264
|
+
_cacheItem._time = new Date().getTime();
|
|
265
|
+
}
|
|
266
|
+
} else {
|
|
267
|
+
var _cacheItem$_extend7;
|
|
268
|
+
if (!_cacheItem._data.capacitys) {
|
|
269
|
+
_cacheItem._data.capacitys = cacheItem.capacity;
|
|
270
|
+
}
|
|
271
|
+
if (!_cacheItem._data.resourcesOrigin) {
|
|
272
|
+
var _cacheItem$_extend6, _ctx$bookingConfig4;
|
|
273
|
+
var extraResources = [];
|
|
274
|
+
if (Array.isArray((_cacheItem$_extend6 = _cacheItem._extend) === null || _cacheItem$_extend6 === void 0 ? void 0 : _cacheItem$_extend6.event_resources)) {
|
|
275
|
+
_cacheItem._extend.event_resources.forEach(function (er) {
|
|
276
|
+
extraResources.push({
|
|
277
|
+
form_id: er.form_id,
|
|
278
|
+
id: er.relation_id
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
_cacheItem._data.resourcesOrigin = getResourceByIds(resourcesOriginMap, cacheItem, {
|
|
283
|
+
extraResources: extraResources,
|
|
284
|
+
resourceTab: ctx === null || ctx === void 0 || (_ctx$bookingConfig4 = ctx.bookingConfig) === null || _ctx$bookingConfig4 === void 0 || (_ctx$bookingConfig4 = _ctx$bookingConfig4.config) === null || _ctx$bookingConfig4 === void 0 ? void 0 : _ctx$bookingConfig4.resource_tab,
|
|
285
|
+
resourcesOrigin: ctx.resourcesOrigin || []
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
if (!_cacheItem._data.resources) {
|
|
289
|
+
var _formatResources2 = formatResources({
|
|
290
|
+
cacheItem: _cacheItem,
|
|
291
|
+
resourcesOrigin: _cacheItem._data.resourcesOrigin
|
|
292
|
+
}),
|
|
293
|
+
_list = _formatResources2.list,
|
|
294
|
+
_maps = _formatResources2.maps;
|
|
295
|
+
_cacheItem._data.resources = _list;
|
|
296
|
+
_cacheItem._data.resourceMaps = _maps;
|
|
297
|
+
}
|
|
298
|
+
_cacheItem._data.timeObj = getTimeObj({
|
|
299
|
+
cacheItem: _cacheItem,
|
|
300
|
+
useStartTime: (_cacheItem$_extend7 = _cacheItem._extend) === null || _cacheItem$_extend7 === void 0 ? void 0 : _cacheItem$_extend7.start_time,
|
|
301
|
+
ctx: ctx
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
return _cacheItem;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* 是否可自动关闭弹窗(不需要用户进 EditService 抽屉)。
|
|
309
|
+
* 与 info2 `service/addService/utils.tsx#getIsAutoClose` 等价;
|
|
310
|
+
* `getAutoAllocationStorage` 抽象为入参 `isAutoAllocationOn(formId)`。
|
|
311
|
+
*/
|
|
312
|
+
export function getIsAutoClose(cacheItem, isAutoAllocationOn) {
|
|
313
|
+
var _cacheItem$_data, _cacheItem$_extend8;
|
|
314
|
+
if (productNeedsResourceExtend(cacheItem) && !hasActualResourceSelection(cacheItem)) {
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
if (((_cacheItem$_data = cacheItem._data) === null || _cacheItem$_data === void 0 || (_cacheItem$_data = _cacheItem$_data.capacitys) === null || _cacheItem$_data === void 0 ? void 0 : _cacheItem$_data.type) !== 'custom') {
|
|
318
|
+
var _cacheItem$_data2;
|
|
319
|
+
var resources = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_data2 = cacheItem._data) === null || _cacheItem$_data2 === void 0 ? void 0 : _cacheItem$_data2.resources) || [];
|
|
320
|
+
if (resources.length === 1) {
|
|
321
|
+
var _first$select_type;
|
|
322
|
+
var first = resources[0];
|
|
323
|
+
if (((_first$select_type = first.select_type) === null || _first$select_type === void 0 ? void 0 : _first$select_type.type) === 'single' && (first.default_resource || []).length > 0) {
|
|
324
|
+
return true;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
var entries = Object.entries(((_cacheItem$_extend8 = cacheItem._extend) === null || _cacheItem$_extend8 === void 0 ? void 0 : _cacheItem$_extend8.resource) || {});
|
|
329
|
+
if (entries.length === 0) {
|
|
330
|
+
return !productNeedsResourceExtend(cacheItem);
|
|
331
|
+
}
|
|
332
|
+
return entries.every(function (_ref) {
|
|
333
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
334
|
+
key = _ref2[0],
|
|
335
|
+
value = _ref2[1];
|
|
336
|
+
return isAutoAllocationOn(key) && Array.isArray(value) && value.length > 0;
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
export { getSumCapacity };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 结构化的「资源不可用」原因(替代 info2 `getErrorList` 输出的 i18n 文案 + type 字段)。
|
|
3
|
+
*
|
|
4
|
+
* 与 info2 type 字段映射:
|
|
5
|
+
* - `no_product` ↔ type='products'
|
|
6
|
+
* - `time_out_of_range` ↔ type='time'
|
|
7
|
+
* - `count_out_of_range` ↔ type='limit'
|
|
8
|
+
* - `resource_unbound` ↔ type='unbound'
|
|
9
|
+
*
|
|
10
|
+
* OS 这边不耦合 i18n 文案,UI 拿到 reason + params 后自行渲染(参考 docs/SDK 中给出的 i18n key 对照表)。
|
|
11
|
+
*/
|
|
12
|
+
export type ResourceUnavailableReason = 'no_product' | 'time_out_of_range' | 'count_out_of_range' | 'resource_unbound';
|
|
13
|
+
export interface ResourceError {
|
|
14
|
+
reason: ResourceUnavailableReason;
|
|
15
|
+
params: {
|
|
16
|
+
/** 资源名(time / limit 用)。 */
|
|
17
|
+
labelText?: string;
|
|
18
|
+
/** 起始时间(time / limit 用,格式 'hh:mm A')。 */
|
|
19
|
+
startText?: string;
|
|
20
|
+
/** 结束时间(time / limit 用,格式 'hh:mm A')。 */
|
|
21
|
+
endText?: string;
|
|
22
|
+
/**
|
|
23
|
+
* 结束时间是否跨到第二天。UI 收到 true 时可在 endText 前加 'tomorrow' / '明天' 前缀。
|
|
24
|
+
* 与 info2 旧实现「endText = locales.getText('pisell1.text.tomorrow') + endText」等价。
|
|
25
|
+
*/
|
|
26
|
+
isCrossDay?: boolean;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 替代 info2 `utilsByBooking.ts#getErrorList`,输出结构化错误。
|
|
31
|
+
*
|
|
32
|
+
* 行为对齐:
|
|
33
|
+
* 1. cacheItem 没有 id → `no_product`(与 info2 `!cacheItem?.id` 分支等价)。
|
|
34
|
+
* 2. 资源 null / 无 _extend → 返回 []。
|
|
35
|
+
* 3. resource.usable=false 时:
|
|
36
|
+
* - 没有 _extend.usableTime → `time_out_of_range`
|
|
37
|
+
* - 有 usableTime 但 `_extend.isCountRange=false` → `count_out_of_range`
|
|
38
|
+
* 4. resource.unbound=true → 追加 `resource_unbound`。
|
|
39
|
+
* 5. 不再耦合 `_data.resourceMaps[form_id].type === 'single'` 判断(与 info2 实际未使用此变量一致)。
|
|
40
|
+
*/
|
|
41
|
+
export declare function getResourceErrors(resource: any, cacheItem: any): ResourceError[];
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import { getServiceTimes } from "./serviceTimes";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 结构化的「资源不可用」原因(替代 info2 `getErrorList` 输出的 i18n 文案 + type 字段)。
|
|
6
|
+
*
|
|
7
|
+
* 与 info2 type 字段映射:
|
|
8
|
+
* - `no_product` ↔ type='products'
|
|
9
|
+
* - `time_out_of_range` ↔ type='time'
|
|
10
|
+
* - `count_out_of_range` ↔ type='limit'
|
|
11
|
+
* - `resource_unbound` ↔ type='unbound'
|
|
12
|
+
*
|
|
13
|
+
* OS 这边不耦合 i18n 文案,UI 拿到 reason + params 后自行渲染(参考 docs/SDK 中给出的 i18n key 对照表)。
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 替代 info2 `utilsByBooking.ts#getErrorList`,输出结构化错误。
|
|
18
|
+
*
|
|
19
|
+
* 行为对齐:
|
|
20
|
+
* 1. cacheItem 没有 id → `no_product`(与 info2 `!cacheItem?.id` 分支等价)。
|
|
21
|
+
* 2. 资源 null / 无 _extend → 返回 []。
|
|
22
|
+
* 3. resource.usable=false 时:
|
|
23
|
+
* - 没有 _extend.usableTime → `time_out_of_range`
|
|
24
|
+
* - 有 usableTime 但 `_extend.isCountRange=false` → `count_out_of_range`
|
|
25
|
+
* 4. resource.unbound=true → 追加 `resource_unbound`。
|
|
26
|
+
* 5. 不再耦合 `_data.resourceMaps[form_id].type === 'single'` 判断(与 info2 实际未使用此变量一致)。
|
|
27
|
+
*/
|
|
28
|
+
export function getResourceErrors(resource, cacheItem) {
|
|
29
|
+
if (!(cacheItem !== null && cacheItem !== void 0 && cacheItem.id)) {
|
|
30
|
+
return [{
|
|
31
|
+
reason: 'no_product',
|
|
32
|
+
params: {}
|
|
33
|
+
}];
|
|
34
|
+
}
|
|
35
|
+
if (!resource) return [];
|
|
36
|
+
var list = [];
|
|
37
|
+
if (!resource.usable) {
|
|
38
|
+
var _resource$_extend, _resource$_extend2;
|
|
39
|
+
var _getServiceTimes = getServiceTimes(cacheItem),
|
|
40
|
+
startDate = _getServiceTimes.startDate,
|
|
41
|
+
endDate = _getServiceTimes.endDate;
|
|
42
|
+
var startText = startDate.format('hh:mm A');
|
|
43
|
+
var endText = endDate.format('hh:mm A');
|
|
44
|
+
var isCrossDay = dayjs(endDate).isAfter(startDate, 'day');
|
|
45
|
+
if (!((_resource$_extend = resource._extend) !== null && _resource$_extend !== void 0 && _resource$_extend.usableTime)) {
|
|
46
|
+
list.push({
|
|
47
|
+
reason: 'time_out_of_range',
|
|
48
|
+
params: {
|
|
49
|
+
labelText: resource.labelText,
|
|
50
|
+
startText: startText,
|
|
51
|
+
endText: endText,
|
|
52
|
+
isCrossDay: isCrossDay
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
} else if (!((_resource$_extend2 = resource._extend) !== null && _resource$_extend2 !== void 0 && (_resource$_extend2 = _resource$_extend2.usableTime) !== null && _resource$_extend2 !== void 0 && (_resource$_extend2 = _resource$_extend2._extend) !== null && _resource$_extend2 !== void 0 && _resource$_extend2.isCountRange)) {
|
|
56
|
+
list.push({
|
|
57
|
+
reason: 'count_out_of_range',
|
|
58
|
+
params: {
|
|
59
|
+
labelText: resource.labelText,
|
|
60
|
+
startText: startText,
|
|
61
|
+
endText: endText,
|
|
62
|
+
isCrossDay: isCrossDay
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (resource.unbound) {
|
|
68
|
+
list.push({
|
|
69
|
+
reason: 'resource_unbound',
|
|
70
|
+
params: {}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return list;
|
|
74
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 预约商品资源是否「需要补齐 / 已选中」——供 getProductExtend 门禁与 getIsAutoClose 共用。
|
|
3
|
+
*/
|
|
4
|
+
/** 商品是否挂了生效的资源表单(product_resource.resources status=1)。 */
|
|
5
|
+
export declare function productNeedsResourceExtend(cacheItem: any): boolean;
|
|
6
|
+
/** `_extend.resource` 是否至少有一类表单选中了具体资源。 */
|
|
7
|
+
export declare function hasActualResourceSelection(cacheItem: any): boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
/**
|
|
3
|
+
* 预约商品资源是否「需要补齐 / 已选中」——供 getProductExtend 门禁与 getIsAutoClose 共用。
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** 商品是否挂了生效的资源表单(product_resource.resources status=1)。 */
|
|
7
|
+
export function productNeedsResourceExtend(cacheItem) {
|
|
8
|
+
var _cacheItem$product_re;
|
|
9
|
+
var forms = cacheItem === null || cacheItem === void 0 || (_cacheItem$product_re = cacheItem.product_resource) === null || _cacheItem$product_re === void 0 ? void 0 : _cacheItem$product_re.resources;
|
|
10
|
+
if (!Array.isArray(forms)) return false;
|
|
11
|
+
return forms.some(function (d) {
|
|
12
|
+
return Number(d === null || d === void 0 ? void 0 : d.status) === 1;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** `_extend.resource` 是否至少有一类表单选中了具体资源。 */
|
|
17
|
+
export function hasActualResourceSelection(cacheItem) {
|
|
18
|
+
var _cacheItem$_extend;
|
|
19
|
+
var resource = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.resource;
|
|
20
|
+
if (!resource || _typeof(resource) !== 'object') return false;
|
|
21
|
+
return Object.values(resource).some(function (rows) {
|
|
22
|
+
return Array.isArray(rows) && rows.length > 0;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 资源运行态计算 helper(搬自 info2 `utilsByBooking.ts` + `service/addService/utils.tsx`)。
|
|
3
|
+
*
|
|
4
|
+
* 本文件输入输出全部为 plain object,不依赖 React / locales / @pisell/icon / mini-redux。
|
|
5
|
+
* 调用方传入:resource origin map(`/form/schedule` 返回) / cacheItem(含 `_extend.duration / _extend.start_date / _extend.start_time` 等)。
|
|
6
|
+
*
|
|
7
|
+
* 三个 info2 独有特性保留:
|
|
8
|
+
* 1. `resource_display_scope='all'`:取全部资源
|
|
9
|
+
* 2. `extraResources`:拖入未绑定资源时兼容渲染
|
|
10
|
+
* 3. `getNoResource2()`:占位"无资源"行
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* 从已选资源中取「最早结束」的 usableTime,供灵活时长计算上限。
|
|
14
|
+
* 与 info2 `service/addService/utils.tsx#getUsableTime` 等价。
|
|
15
|
+
*/
|
|
16
|
+
export declare function getUsableTime(cacheItem: any): any | null;
|
|
17
|
+
/** Σ cacheItem._extend.capacity[].value × _extend.quantity。 */
|
|
18
|
+
export declare function getSumCapacity(cacheItem: any, isCalcQuantity?: boolean): number;
|
|
19
|
+
/**
|
|
20
|
+
* 判断单个 time 是否可用,写回 `_extend` 标记位(isDateRange / isCountRange / isUsable / isMaxLimitRange)。
|
|
21
|
+
* 与 info2 `utilsByBooking.ts#getResourceTimeIsUsable` 等价。
|
|
22
|
+
*/
|
|
23
|
+
export declare function getResourceTimeIsUsable(item: any, cacheItem: any, resourceItem: any): any;
|
|
24
|
+
/**
|
|
25
|
+
* 在 resource.times 中找到最佳可用 time,并写回 `_extend.usableTime`。
|
|
26
|
+
* 与 info2 `utilsByBooking.ts#formatTimes` 等价。
|
|
27
|
+
*/
|
|
28
|
+
export declare function formatTimes(resourceItem: any, cacheItem: any): any;
|
|
29
|
+
/**
|
|
30
|
+
* 单个 resource 的整体可用性 + labelText 填充。
|
|
31
|
+
* 与 info2 `utilsByBooking.ts#formatResource` 等价;不再接收 formatLabel 回调(OS 不渲染 JSX)。
|
|
32
|
+
*/
|
|
33
|
+
export declare function formatResource(resourceItem: any, cacheItem?: any): any;
|
|
34
|
+
/**
|
|
35
|
+
* 把单个 resource origin 类型(如「技师」)的 renderList 中每个资源跑一遍 formatResource,
|
|
36
|
+
* 并维护 unbound 标记(拖入未绑定资源时 UI 用)。
|
|
37
|
+
* 与 info2 `service/addService/utils.tsx#formatResources` 等价(剥 JSX)。
|
|
38
|
+
*/
|
|
39
|
+
export declare function formatResources(params: {
|
|
40
|
+
cacheItem: any;
|
|
41
|
+
resourcesOrigin: any[];
|
|
42
|
+
}): {
|
|
43
|
+
list: any[];
|
|
44
|
+
maps: Record<string, any>;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* 计算每类资源的默认值(写入 cacheItem._extend.resource)。
|
|
48
|
+
* 与 info2 `service/addService/utils.tsx#setDefaultResource` 等价;
|
|
49
|
+
* `resourceIdFromCalendar` 替代原版 sessionStorage `serviceParams.resource_id` 读取。
|
|
50
|
+
*/
|
|
51
|
+
export declare function setDefaultResource(params: {
|
|
52
|
+
cacheItem: any;
|
|
53
|
+
resources: any[];
|
|
54
|
+
resourceIdFromCalendar?: number;
|
|
55
|
+
isAutoAllocationOn?: (formId: any) => boolean;
|
|
56
|
+
}): Record<string, any[]>;
|
|
57
|
+
/**
|
|
58
|
+
* 计算默认容量(与 info2 `setDefaultCapacitys` 等价)。
|
|
59
|
+
* package:按 _extend.other.bundle 拆 quantity;custom:按 capacity.custom[].min;其他:[{id:0,value:1}]。
|
|
60
|
+
*/
|
|
61
|
+
export declare function setDefaultCapacitys(params: {
|
|
62
|
+
capacitys: any;
|
|
63
|
+
cacheItem: any;
|
|
64
|
+
}): Array<{
|
|
65
|
+
id: number | string;
|
|
66
|
+
value: number;
|
|
67
|
+
name?: string;
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* 通过商品 `product_resource.resources[]` 关联的 form/resource id,从 resourcesOriginMap 还原资源数据。
|
|
71
|
+
* 与 info2 `service/addService/utils.tsx#getResourceByIds` 等价(保留三特性)。
|
|
72
|
+
*/
|
|
73
|
+
export declare function getResourceByIds(resourcesOriginMap: Record<string, any>, cacheItem: any, extraParams?: {
|
|
74
|
+
extraResources?: Array<{
|
|
75
|
+
form_id: number | string;
|
|
76
|
+
id: number;
|
|
77
|
+
}>;
|
|
78
|
+
resourcesOrigin?: any[];
|
|
79
|
+
resourceTab?: Record<string, any>;
|
|
80
|
+
}): any[];
|