@pisell/pisellos 0.0.568 → 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/model/strategy/adapter/promotion/evaluator.js +3 -2
- package/dist/model/strategy/adapter/walletPass/utils.js +7 -4
- 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/utils/cartProduct.js +26 -5
- 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/Discount/index.d.ts +2 -1
- package/dist/modules/Discount/index.js +37 -9
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/OpenData/index.d.ts +8 -0
- package/dist/modules/OpenData/index.js +36 -16
- package/dist/modules/Order/index.d.ts +448 -23
- package/dist/modules/Order/index.js +5417 -561
- 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 +465 -703
- 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 +44 -29
- 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 +221 -109
- 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/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/server/index.d.ts +462 -8
- package/dist/server/index.js +6112 -656
- 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/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 +1393 -516
- 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 +278 -66
- package/dist/server/modules/resource/index.d.ts +2 -3
- package/dist/server/modules/resource/index.js +108 -86
- package/dist/server/modules/schedule/index.d.ts +6 -4
- package/dist/server/modules/schedule/index.js +116 -85
- package/dist/server/test.json +713 -0
- package/dist/server/types.d.ts +2 -0
- package/dist/server/utils/product.js +2 -2
- 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.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +394 -25
- package/dist/solution/BookingTicket/index.js +2506 -443
- 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 +11 -3
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +20 -8
- 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/Checkout/index.d.ts +1 -0
- package/dist/solution/Checkout/index.js +25 -34
- package/dist/solution/Checkout/utils/index.js +4 -4
- package/dist/solution/RegisterAndLogin/config.js +2 -10
- 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 +499 -434
- 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 +4 -4
- 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 +29 -20
- package/dist/solution/VenueBooking/index.js +301 -213
- 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/lib/model/strategy/adapter/promotion/evaluator.js +3 -2
- package/lib/model/strategy/adapter/walletPass/utils.js +6 -4
- package/lib/modules/BaseModule.d.ts +2 -2
- package/lib/modules/BaseModule.js +4 -4
- 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/utils/cartProduct.js +27 -5
- package/lib/modules/Cart/utils/changePrice.js +20 -14
- package/lib/modules/Customer/index.d.ts +20 -0
- package/lib/modules/Customer/index.js +63 -10
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/index.d.ts +2 -1
- package/lib/modules/Discount/index.js +18 -2
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/OpenData/index.d.ts +8 -0
- package/lib/modules/OpenData/index.js +21 -3
- package/lib/modules/Order/index.d.ts +448 -23
- package/lib/modules/Order/index.js +3641 -308
- package/lib/modules/Order/types.d.ts +693 -88
- package/lib/modules/Order/types.js +55 -1
- 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 +974 -138
- package/lib/modules/Payment/index.d.ts +10 -9
- package/lib/modules/Payment/index.js +30 -124
- package/lib/modules/Payment/types.d.ts +40 -16
- package/lib/modules/Payment/utils.d.ts +1 -1
- package/lib/modules/Payment/utils.js +4 -3
- package/lib/modules/Payment/walletpass.js +16 -6
- package/lib/modules/Product/types.d.ts +29 -7
- package/lib/modules/ProductList/index.d.ts +17 -13
- package/lib/modules/ProductList/index.js +92 -51
- package/lib/modules/ProductList/types.d.ts +17 -0
- package/lib/modules/Quotation/index.d.ts +22 -2
- package/lib/modules/Quotation/index.js +76 -20
- package/lib/modules/Quotation/types.d.ts +19 -0
- 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 +152 -60
- package/lib/modules/Rules/types.d.ts +14 -3
- package/lib/modules/SalesSummary/index.d.ts +23 -26
- package/lib/modules/SalesSummary/index.js +84 -16
- package/lib/modules/SalesSummary/types.d.ts +9 -1
- package/lib/modules/SalesSummary/utils.d.ts +3 -22
- package/lib/modules/SalesSummary/utils.js +616 -111
- package/lib/modules/Schedule/getDateIsInSchedule.js +14 -7
- package/lib/modules/Schedule/index.d.ts +18 -5
- package/lib/modules/Schedule/index.js +49 -14
- package/lib/modules/Schedule/types.d.ts +2 -0
- package/lib/modules/Summary/index.js +2 -2
- 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 +33 -0
- package/lib/plugins/app.d.ts +2 -0
- package/lib/plugins/request.d.ts +1 -0
- package/lib/server/index.d.ts +462 -8
- package/lib/server/index.js +3901 -205
- 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 +21 -0
- package/lib/server/modules/order/index.d.ts +207 -14
- package/lib/server/modules/order/index.js +1324 -141
- package/lib/server/modules/order/types.d.ts +76 -5
- package/lib/server/modules/order/types.js +11 -1
- package/lib/server/modules/order/utils/filterBookings.d.ts +7 -1
- package/lib/server/modules/order/utils/filterBookings.js +119 -11
- package/lib/server/modules/order/utils/filterOrders.js +238 -13
- 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 +588 -97
- package/lib/server/modules/products/types.d.ts +34 -1
- package/lib/server/modules/products/types.js +3 -0
- package/lib/server/modules/quotation/index.d.ts +39 -0
- package/lib/server/modules/quotation/index.js +145 -1
- package/lib/server/modules/resource/index.d.ts +2 -3
- package/lib/server/modules/resource/index.js +71 -45
- package/lib/server/modules/schedule/index.d.ts +6 -4
- package/lib/server/modules/schedule/index.js +55 -44
- package/lib/server/test.json +713 -0
- package/lib/server/types.d.ts +2 -0
- package/lib/server/utils/product.js +2 -2
- package/lib/server/utils/small-ticket.d.ts +71 -0
- package/lib/server/utils/small-ticket.js +926 -0
- 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.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +394 -25
- package/lib/solution/BookingTicket/index.js +1350 -76
- package/lib/solution/BookingTicket/types.d.ts +191 -6
- package/lib/solution/BookingTicket/types.js +71 -10
- 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 +24 -3
- 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 +4 -2
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +14 -2
- 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/Checkout/index.d.ts +1 -0
- package/lib/solution/Checkout/index.js +18 -19
- package/lib/solution/Checkout/utils/index.js +4 -4
- package/lib/solution/RegisterAndLogin/config.js +2 -10
- package/lib/solution/Sales/index.d.ts +50 -5
- package/lib/solution/Sales/index.js +296 -39
- package/lib/solution/Sales/types.d.ts +26 -2
- package/lib/solution/ScanOrder/index.d.ts +27 -21
- package/lib/solution/ScanOrder/index.js +144 -103
- package/lib/solution/ScanOrder/types.d.ts +33 -11
- package/lib/solution/ScanOrder/types.js +4 -5
- package/lib/solution/ScanOrder/utils.d.ts +4 -1
- package/lib/solution/ScanOrder/utils.js +98 -26
- package/lib/solution/ShopDiscount/index.js +3 -3
- 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 +29 -20
- package/lib/solution/VenueBooking/index.js +169 -94
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +9 -3
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +22 -0
- package/lib/types/index.d.ts +11 -1
- package/package.json +1 -1
- package/dist/solution/Checkout/appointmentDemo.json +0 -1
- package/lib/solution/Checkout/appointmentDemo.json +0 -1
|
@@ -71,8 +71,6 @@
|
|
|
71
71
|
"num__comment": "数量;int;↕;必填。统一使用 num,不再使用 product_quantity。",
|
|
72
72
|
"product_variant_id": 0,
|
|
73
73
|
"product_variant_id__comment": "多规格 ID;int;↕;可选。",
|
|
74
|
-
"product_option_item": [],
|
|
75
|
-
"product_option_item__comment": "选项配置;array;↕;可选。",
|
|
76
74
|
"selling_price": "50.00",
|
|
77
75
|
"selling_price__comment": "销售单价(交易快照);string;←;服务端返回,不能依赖基准数据回填。",
|
|
78
76
|
"original_price": "60.00",
|
|
@@ -5,6 +5,12 @@ export declare function mergeConsecutiveSlots(slots: VenueSlotSelection[]): Merg
|
|
|
5
5
|
export declare function buildPriceBreakdown(params: {
|
|
6
6
|
group: MergedSlotGroup;
|
|
7
7
|
productId: number;
|
|
8
|
+
quotation?: {
|
|
9
|
+
getQuotationShelfId: (p: {
|
|
10
|
+
productId: number;
|
|
11
|
+
datetime: string;
|
|
12
|
+
}) => number;
|
|
13
|
+
};
|
|
8
14
|
}): PriceBreakdownEntry[];
|
|
9
15
|
export interface BuildVenueBookingParams {
|
|
10
16
|
group: MergedSlotGroup;
|
|
@@ -51,7 +51,9 @@ export function mergeConsecutiveSlots(slots) {
|
|
|
51
51
|
return groups;
|
|
52
52
|
}
|
|
53
53
|
export function buildPriceBreakdown(params) {
|
|
54
|
-
var group = params.group
|
|
54
|
+
var group = params.group,
|
|
55
|
+
productId = params.productId,
|
|
56
|
+
quotation = params.quotation;
|
|
55
57
|
if (!group.slots.length) return [];
|
|
56
58
|
var entries = [];
|
|
57
59
|
var _iterator = _createForOfIteratorHelper(group.slots),
|
|
@@ -60,10 +62,14 @@ export function buildPriceBreakdown(params) {
|
|
|
60
62
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
61
63
|
var slot = _step.value;
|
|
62
64
|
var unitPrice = Number(slot.price || '0');
|
|
65
|
+
var shelfId = quotation ? quotation.getQuotationShelfId({
|
|
66
|
+
productId: productId,
|
|
67
|
+
datetime: slot.startTime
|
|
68
|
+
}) : 0;
|
|
63
69
|
var startHm = dayjs(slot.startTime, 'YYYY-MM-DD HH:mm').format('YYYY-MM-DD HH:mm');
|
|
64
70
|
var endHm = dayjs(slot.endTime, 'YYYY-MM-DD HH:mm').format('YYYY-MM-DD HH:mm');
|
|
65
71
|
var last = entries[entries.length - 1];
|
|
66
|
-
if (last && last.unit_price === unitPrice && last.quotation_shelf_id ===
|
|
72
|
+
if (last && last.unit_price === unitPrice && last.quotation_shelf_id === shelfId && last.end_time === startHm) {
|
|
67
73
|
last.end_time = endHm;
|
|
68
74
|
last.quantity += 1;
|
|
69
75
|
} else {
|
|
@@ -71,7 +77,7 @@ export function buildPriceBreakdown(params) {
|
|
|
71
77
|
start_time: startHm,
|
|
72
78
|
end_time: endHm,
|
|
73
79
|
unit_price: unitPrice,
|
|
74
|
-
quotation_shelf_id:
|
|
80
|
+
quotation_shelf_id: shelfId,
|
|
75
81
|
quantity: 1
|
|
76
82
|
});
|
|
77
83
|
}
|
package/dist/solution/index.d.ts
CHANGED
package/dist/solution/index.js
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -15,6 +15,16 @@ export interface Module {
|
|
|
15
15
|
name: string;
|
|
16
16
|
version: string;
|
|
17
17
|
initialize: (core: PisellCore, options: ModuleOptions) => Promise<void> | void;
|
|
18
|
+
/**
|
|
19
|
+
* 父级解决方案运行时更新 otherParams 后,显式通知子模块刷新自己的运行态参数。
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* await module.updateOtherParams?.({ channel: 'pos' }, { changedParams: { channel: 'pos' } });
|
|
23
|
+
*/
|
|
24
|
+
updateOtherParams?: (params: Record<string, any>, meta?: {
|
|
25
|
+
changedParams?: Record<string, any>;
|
|
26
|
+
cover?: boolean;
|
|
27
|
+
}) => Promise<void> | void;
|
|
18
28
|
destroy?: () => Promise<void> | void;
|
|
19
29
|
exports?: Record<string, any>;
|
|
20
30
|
isSolution?: boolean;
|
|
@@ -39,7 +49,7 @@ export interface PisellCore {
|
|
|
39
49
|
getModuleExports: <T = any>(name: string) => T | null;
|
|
40
50
|
hasModule: (name: string) => boolean;
|
|
41
51
|
effects: {
|
|
42
|
-
on: (event: string, callback: (payload: any) => void
|
|
52
|
+
on: (event: string, callback: (payload: any) => void) => () => void;
|
|
43
53
|
once: (event: string, callback: (payload: any) => void, force?: boolean) => void;
|
|
44
54
|
only: (event: string, callback: (payload: any) => void) => () => void;
|
|
45
55
|
off: (event: string, callback: (payload: any) => void) => void;
|
|
@@ -609,9 +609,10 @@ class PromotionEvaluator {
|
|
|
609
609
|
return b.price - a.price;
|
|
610
610
|
});
|
|
611
611
|
|
|
612
|
-
// 3.
|
|
612
|
+
// 3. 计算可以凑成多少组(cumulative 缺省视为 true,与 adapter 一致)
|
|
613
613
|
const totalUnits = unitProducts.length;
|
|
614
|
-
const
|
|
614
|
+
const isCumulative = cumulative !== false;
|
|
615
|
+
const groupCount = isCumulative ? Math.floor(totalUnits / x) : totalUnits >= x ? 1 : 0;
|
|
615
616
|
const promotionUnits = groupCount * x;
|
|
616
617
|
|
|
617
618
|
// 4. 分离参与促销的和不参与的商品
|
|
@@ -444,7 +444,7 @@ function processVouchers(applicableVouchers, orderTotalAmount, products) {
|
|
|
444
444
|
// ======================================================================================
|
|
445
445
|
|
|
446
446
|
// 计算本次抵扣金额(使用同样的 usageAmount)
|
|
447
|
-
const maxDeduction = _decimal.default.min(new _decimal.default(usageAmount), new _decimal.default(maxDeductionAmount));
|
|
447
|
+
const maxDeduction = _decimal.default.min(new _decimal.default(usageAmount), new _decimal.default(maxDeductionAmount), remainingOrderAmount);
|
|
448
448
|
let deductionLeft = maxDeduction;
|
|
449
449
|
const deductionDetails = [];
|
|
450
450
|
if (allowCrossProduct) {
|
|
@@ -649,9 +649,11 @@ function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmount, pr
|
|
|
649
649
|
return;
|
|
650
650
|
}
|
|
651
651
|
|
|
652
|
-
//
|
|
653
|
-
//
|
|
654
|
-
|
|
652
|
+
// 计算本次抵扣金额:
|
|
653
|
+
// - 用户手动编辑时以编辑金额为准;
|
|
654
|
+
// - 自动推荐/重算时沿用上一轮基于剩余待付金额算出的 _available_max_amount,
|
|
655
|
+
// 避免 recalculateVouchers 又回退到后端单券 recommended_usage_amount 造成超付。
|
|
656
|
+
const usageAmount = typeof selectedVoucher.edit_current_amount === 'number' ? selectedVoucher.edit_current_amount : selectedVoucher._available_max_amount ?? getRecommendedAmount(selectedVoucher);
|
|
655
657
|
const maxDeduction = _decimal.default.min(new _decimal.default(usageAmount), new _decimal.default(maxDeductionAmount), remainingOrderAmount);
|
|
656
658
|
let deductionLeft = maxDeduction;
|
|
657
659
|
const deductionDetails = [];
|
|
@@ -14,9 +14,9 @@ export declare class BaseModule {
|
|
|
14
14
|
store: any;
|
|
15
15
|
cacheKey: string[];
|
|
16
16
|
}): void;
|
|
17
|
-
effectsOn(eventType: string, callback: (payload: any) => void
|
|
17
|
+
effectsOn(eventType: string, callback: (payload: any) => void): () => void;
|
|
18
18
|
effectsOff(eventType: string, callback: (payload: any) => void): void;
|
|
19
|
-
effectsOnce(eventType: string, callback: (payload: any) => void
|
|
19
|
+
effectsOnce(eventType: string, callback: (payload: any) => void): void;
|
|
20
20
|
effectsEmit(eventType: string, payload: any): Promise<{
|
|
21
21
|
status: boolean;
|
|
22
22
|
data: any;
|
|
@@ -64,14 +64,14 @@ class BaseModule {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
effectsOn(eventType, callback
|
|
68
|
-
return this.core.effects.on(`${this.name}:${eventType}`, callback
|
|
67
|
+
effectsOn(eventType, callback) {
|
|
68
|
+
return this.core.effects.on(`${this.name}:${eventType}`, callback);
|
|
69
69
|
}
|
|
70
70
|
effectsOff(eventType, callback) {
|
|
71
71
|
return this.core.effects.off(`${this.name}:${eventType}`, callback);
|
|
72
72
|
}
|
|
73
|
-
effectsOnce(eventType, callback
|
|
74
|
-
return this.core.effects.once(`${this.name}:${eventType}`, callback
|
|
73
|
+
effectsOnce(eventType, callback) {
|
|
74
|
+
return this.core.effects.once(`${this.name}:${eventType}`, callback);
|
|
75
75
|
}
|
|
76
76
|
effectsEmit(eventType, payload) {
|
|
77
77
|
return this.core.effects.emit(`${this.name}:${eventType}`, payload);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
|
+
import { BaseModule } from '../BaseModule';
|
|
3
|
+
import { BookingContextConfig, BookingContextDateInput, BookingContextModuleAPI, BookingContextResource, BookingContextResourceMap, BookingContextState, InitBookingContextParams, LoadBookingConfigParams, LoadBookingResourcesParams } from './types';
|
|
4
|
+
export * from './types';
|
|
5
|
+
export * from './utils';
|
|
6
|
+
/**
|
|
7
|
+
* 清理跨实例共享缓存,仅供单元测试隔离使用。
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* __clearBookingContextSharedCacheForTest();
|
|
11
|
+
*/
|
|
12
|
+
export declare function __clearBookingContextSharedCacheForTest(): void;
|
|
13
|
+
/** 稳定序列化 config 查询参数,用于判断是否与上次 loadBookingConfig 一致。 */
|
|
14
|
+
export declare function buildBookingConfigQueryKey(params?: LoadBookingConfigParams): string;
|
|
15
|
+
/** 稳定序列化资源列表查询(date + bookingIds),用于跳过重复 loadResources。 */
|
|
16
|
+
export declare function buildBookingResourcesQueryKey(params?: LoadBookingResourcesParams): string;
|
|
17
|
+
export declare class BookingContextModule extends BaseModule implements Module, BookingContextModuleAPI {
|
|
18
|
+
protected defaultName: string;
|
|
19
|
+
protected defaultVersion: string;
|
|
20
|
+
private request;
|
|
21
|
+
private store;
|
|
22
|
+
/** 上次成功 loadBookingConfig 的 query key;命中则不再请求。 */
|
|
23
|
+
private lastConfigQueryKey;
|
|
24
|
+
/** 上次成功 loadResources 的 query key(date|bookingIds);命中则不再请求。 */
|
|
25
|
+
private lastResourcesQueryKey;
|
|
26
|
+
constructor(name?: string, version?: string);
|
|
27
|
+
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
28
|
+
loadBookingConfig(params?: LoadBookingConfigParams, options?: {
|
|
29
|
+
forceRefresh?: boolean;
|
|
30
|
+
}): Promise<BookingContextConfig | null>;
|
|
31
|
+
loadResources(params?: LoadBookingResourcesParams, options?: {
|
|
32
|
+
forceRefresh?: boolean;
|
|
33
|
+
}): Promise<BookingContextResource[]>;
|
|
34
|
+
/**
|
|
35
|
+
* store 内是否已具备与本次 init 入参等价的 config / resources(不再打接口)。
|
|
36
|
+
*/
|
|
37
|
+
isBookingContextReady(params?: InitBookingContextParams): boolean;
|
|
38
|
+
initBookingContext(params?: InitBookingContextParams): Promise<BookingContextState>;
|
|
39
|
+
setBookingConfig(config: BookingContextConfig | null): void;
|
|
40
|
+
getBookingConfig(): BookingContextConfig | null;
|
|
41
|
+
setResources(resources: BookingContextResource[] | null | undefined): void;
|
|
42
|
+
getResourcesOrigin(): BookingContextResource[];
|
|
43
|
+
getResourcesOriginMap(): BookingContextResourceMap;
|
|
44
|
+
setDate(date: BookingContextDateInput): void;
|
|
45
|
+
getDate(): string | null;
|
|
46
|
+
getState(): BookingContextState;
|
|
47
|
+
clear(): void;
|
|
48
|
+
}
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
__clearBookingContextSharedCacheForTest: true,
|
|
8
|
+
buildBookingConfigQueryKey: true,
|
|
9
|
+
buildBookingResourcesQueryKey: true,
|
|
10
|
+
BookingContextModule: true
|
|
11
|
+
};
|
|
12
|
+
exports.BookingContextModule = void 0;
|
|
13
|
+
exports.__clearBookingContextSharedCacheForTest = __clearBookingContextSharedCacheForTest;
|
|
14
|
+
exports.buildBookingConfigQueryKey = buildBookingConfigQueryKey;
|
|
15
|
+
exports.buildBookingResourcesQueryKey = buildBookingResourcesQueryKey;
|
|
16
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
17
|
+
var _BaseModule = require("../BaseModule");
|
|
18
|
+
var _request = require("../../plugins/request");
|
|
19
|
+
var _types = require("./types");
|
|
20
|
+
Object.keys(_types).forEach(function (key) {
|
|
21
|
+
if (key === "default" || key === "__esModule") return;
|
|
22
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
23
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
24
|
+
Object.defineProperty(exports, key, {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _types[key];
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
var _formatResourceList = require("./utils/formatResourceList");
|
|
32
|
+
var _utils = require("./utils");
|
|
33
|
+
Object.keys(_utils).forEach(function (key) {
|
|
34
|
+
if (key === "default" || key === "__esModule") return;
|
|
35
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
36
|
+
if (key in exports && exports[key] === _utils[key]) return;
|
|
37
|
+
Object.defineProperty(exports, key, {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () {
|
|
40
|
+
return _utils[key];
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
45
|
+
const EMPTY_STATE = {
|
|
46
|
+
bookingConfig: null,
|
|
47
|
+
resourcesOrigin: [],
|
|
48
|
+
resourcesOriginMap: {},
|
|
49
|
+
date: null
|
|
50
|
+
};
|
|
51
|
+
const DEFAULT_BOOKING_CONFIG_PARAMS = {
|
|
52
|
+
item_type: 'appointment_booking',
|
|
53
|
+
sub_type: 'ticket'
|
|
54
|
+
};
|
|
55
|
+
const BOARD_CONFIG_CACHE = {
|
|
56
|
+
useCache: true,
|
|
57
|
+
cache: {
|
|
58
|
+
mode: _request.RequestModeENUM.REMOTE_LOCAL,
|
|
59
|
+
type: 'indexDB',
|
|
60
|
+
updateCache: true
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const RESOURCE_LIST_CACHE = {
|
|
64
|
+
useCache: true,
|
|
65
|
+
cache: {
|
|
66
|
+
mode: _request.RequestModeENUM.REMOTE_LOCAL,
|
|
67
|
+
type: 'memory'
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const requestScopeIds = new WeakMap();
|
|
71
|
+
let nextRequestScopeId = 1;
|
|
72
|
+
const sharedBookingConfigCache = new Map();
|
|
73
|
+
const sharedBookingConfigPending = new Map();
|
|
74
|
+
const sharedResourcesCache = new Map();
|
|
75
|
+
const sharedResourcesPending = new Map();
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 为 request 插件生成稳定作用域,避免不同 request 客户端之间共享缓存数据。
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* const scopedKey = buildSharedCacheKey(requestPlugin, '{"sub_type":"ticket"}');
|
|
82
|
+
*/
|
|
83
|
+
function getRequestScopeId(request) {
|
|
84
|
+
const key = request;
|
|
85
|
+
const existed = requestScopeIds.get(key);
|
|
86
|
+
if (existed) return existed;
|
|
87
|
+
const id = nextRequestScopeId++;
|
|
88
|
+
requestScopeIds.set(key, id);
|
|
89
|
+
return id;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 共享缓存 key = request 作用域 + 已稳定序列化的业务参数。
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* const cacheKey = buildSharedCacheKey(requestPlugin, '2026-06-10|1,2');
|
|
97
|
+
*/
|
|
98
|
+
function buildSharedCacheKey(request, queryKey) {
|
|
99
|
+
return `${getRequestScopeId(request)}:${queryKey}`;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* 清理跨实例共享缓存,仅供单元测试隔离使用。
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* __clearBookingContextSharedCacheForTest();
|
|
107
|
+
*/
|
|
108
|
+
function __clearBookingContextSharedCacheForTest() {
|
|
109
|
+
sharedBookingConfigCache.clear();
|
|
110
|
+
sharedBookingConfigPending.clear();
|
|
111
|
+
sharedResourcesCache.clear();
|
|
112
|
+
sharedResourcesPending.clear();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 把多形态 date 入参 normalize 成字符串。
|
|
117
|
+
* - dayjs 实例:调用 format()(无参 ISO)。
|
|
118
|
+
* - Date 实例:toISOString()。
|
|
119
|
+
* - 字符串:原样保留。
|
|
120
|
+
* - null/undefined/空串:→ null。
|
|
121
|
+
*/
|
|
122
|
+
function normalizeDate(input) {
|
|
123
|
+
if (input === null || input === undefined) return null;
|
|
124
|
+
if (typeof input === 'string') return input || null;
|
|
125
|
+
if (input instanceof Date) return input.toISOString();
|
|
126
|
+
if (typeof input.format === 'function') {
|
|
127
|
+
try {
|
|
128
|
+
return input.format() || null;
|
|
129
|
+
} catch {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** 资源接口使用的 `YYYY-MM-DD` 日期串。 */
|
|
137
|
+
function toScheduleQueryDate(input) {
|
|
138
|
+
const normalized = normalizeDate(input);
|
|
139
|
+
if (!normalized) return (0, _dayjs.default)().format('YYYY-MM-DD');
|
|
140
|
+
const parsed = (0, _dayjs.default)(normalized);
|
|
141
|
+
return parsed.isValid() ? parsed.format('YYYY-MM-DD') : (0, _dayjs.default)().format('YYYY-MM-DD');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* 由 resources 数组派生出以 id 为 key 的 map,便于 `getResourceByIds` 直接命中。
|
|
146
|
+
*/
|
|
147
|
+
function buildResourcesMap(resources) {
|
|
148
|
+
const map = {};
|
|
149
|
+
resources.forEach(resource => {
|
|
150
|
+
if (resource && resource.id !== undefined && resource.id !== null) {
|
|
151
|
+
map[String(resource.id)] = resource;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
return map;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** 稳定序列化 config 查询参数,用于判断是否与上次 loadBookingConfig 一致。 */
|
|
158
|
+
function buildBookingConfigQueryKey(params = {}) {
|
|
159
|
+
const merged = {
|
|
160
|
+
...DEFAULT_BOOKING_CONFIG_PARAMS,
|
|
161
|
+
...params
|
|
162
|
+
};
|
|
163
|
+
const keys = Object.keys(merged).sort();
|
|
164
|
+
const sorted = {};
|
|
165
|
+
keys.forEach(k => {
|
|
166
|
+
sorted[k] = merged[k];
|
|
167
|
+
});
|
|
168
|
+
return JSON.stringify(sorted);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** 稳定序列化资源列表查询(date + bookingIds),用于跳过重复 loadResources。 */
|
|
172
|
+
function buildBookingResourcesQueryKey(params = {}) {
|
|
173
|
+
const date = toScheduleQueryDate(params.date);
|
|
174
|
+
const ids = (params.bookingIds || []).filter(id => typeof id === 'number' && Number.isFinite(id)).sort((a, b) => a - b);
|
|
175
|
+
return `${date}|${ids.join(',')}`;
|
|
176
|
+
}
|
|
177
|
+
class BookingContextModule extends _BaseModule.BaseModule {
|
|
178
|
+
defaultName = 'bookingContext';
|
|
179
|
+
defaultVersion = '1.0.0';
|
|
180
|
+
request;
|
|
181
|
+
store = {
|
|
182
|
+
...EMPTY_STATE
|
|
183
|
+
};
|
|
184
|
+
/** 上次成功 loadBookingConfig 的 query key;命中则不再请求。 */
|
|
185
|
+
lastConfigQueryKey = null;
|
|
186
|
+
/** 上次成功 loadResources 的 query key(date|bookingIds);命中则不再请求。 */
|
|
187
|
+
lastResourcesQueryKey = null;
|
|
188
|
+
constructor(name, version) {
|
|
189
|
+
super(name, version);
|
|
190
|
+
}
|
|
191
|
+
async initialize(core, options = {}) {
|
|
192
|
+
this.core = core;
|
|
193
|
+
this.request = core.getPlugin('request');
|
|
194
|
+
if (!this.request) {
|
|
195
|
+
throw new Error('BookingContextModule 需要 request 插件支持');
|
|
196
|
+
}
|
|
197
|
+
this.store = {
|
|
198
|
+
bookingConfig: null,
|
|
199
|
+
resourcesOrigin: [],
|
|
200
|
+
resourcesOriginMap: {},
|
|
201
|
+
date: null
|
|
202
|
+
};
|
|
203
|
+
const initialState = options.initialState || {};
|
|
204
|
+
if (initialState.bookingConfig) {
|
|
205
|
+
this.store.bookingConfig = initialState.bookingConfig;
|
|
206
|
+
}
|
|
207
|
+
if (Array.isArray(initialState.resourcesOrigin)) {
|
|
208
|
+
this.store.resourcesOrigin = initialState.resourcesOrigin;
|
|
209
|
+
this.store.resourcesOriginMap = buildResourcesMap(initialState.resourcesOrigin);
|
|
210
|
+
}
|
|
211
|
+
if (initialState.date) {
|
|
212
|
+
this.store.date = initialState.date;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
async loadBookingConfig(params = {}, options = {}) {
|
|
216
|
+
const configKey = buildBookingConfigQueryKey(params);
|
|
217
|
+
if (!options.forceRefresh && this.store.bookingConfig != null && this.lastConfigQueryKey === configKey) {
|
|
218
|
+
return this.store.bookingConfig;
|
|
219
|
+
}
|
|
220
|
+
const query = {
|
|
221
|
+
...DEFAULT_BOOKING_CONFIG_PARAMS,
|
|
222
|
+
...params
|
|
223
|
+
};
|
|
224
|
+
const sharedKey = buildSharedCacheKey(this.request, configKey);
|
|
225
|
+
if (!options.forceRefresh && sharedBookingConfigCache.has(sharedKey)) {
|
|
226
|
+
const cached = sharedBookingConfigCache.get(sharedKey) ?? null;
|
|
227
|
+
this.setBookingConfig(cached);
|
|
228
|
+
this.lastConfigQueryKey = configKey;
|
|
229
|
+
return cached;
|
|
230
|
+
}
|
|
231
|
+
let pending = !options.forceRefresh ? sharedBookingConfigPending.get(sharedKey) : undefined;
|
|
232
|
+
if (!pending) {
|
|
233
|
+
const requestPromise = (async () => {
|
|
234
|
+
try {
|
|
235
|
+
const res = await this.request.get('/core/board/management/config', query, BOARD_CONFIG_CACHE);
|
|
236
|
+
const config = res?.data ?? null;
|
|
237
|
+
sharedBookingConfigCache.set(sharedKey, config);
|
|
238
|
+
return config;
|
|
239
|
+
} finally {
|
|
240
|
+
sharedBookingConfigPending.delete(sharedKey);
|
|
241
|
+
}
|
|
242
|
+
})();
|
|
243
|
+
pending = requestPromise;
|
|
244
|
+
sharedBookingConfigPending.set(sharedKey, requestPromise);
|
|
245
|
+
}
|
|
246
|
+
const config = await pending;
|
|
247
|
+
this.setBookingConfig(config);
|
|
248
|
+
this.lastConfigQueryKey = configKey;
|
|
249
|
+
return config;
|
|
250
|
+
}
|
|
251
|
+
async loadResources(params = {}, options = {}) {
|
|
252
|
+
const date = toScheduleQueryDate(params.date ?? this.store.date);
|
|
253
|
+
const resourcesKey = buildBookingResourcesQueryKey({
|
|
254
|
+
date,
|
|
255
|
+
bookingIds: params.bookingIds
|
|
256
|
+
});
|
|
257
|
+
if (!options.forceRefresh && this.lastResourcesQueryKey === resourcesKey) {
|
|
258
|
+
return this.getResourcesOrigin();
|
|
259
|
+
}
|
|
260
|
+
const sharedKey = buildSharedCacheKey(this.request, resourcesKey);
|
|
261
|
+
if (!options.forceRefresh && sharedResourcesCache.has(sharedKey)) {
|
|
262
|
+
const cached = sharedResourcesCache.get(sharedKey) ?? [];
|
|
263
|
+
this.setResources(cached);
|
|
264
|
+
this.lastResourcesQueryKey = resourcesKey;
|
|
265
|
+
return this.getResourcesOrigin();
|
|
266
|
+
}
|
|
267
|
+
let pending = !options.forceRefresh ? sharedResourcesPending.get(sharedKey) : undefined;
|
|
268
|
+
if (!pending) {
|
|
269
|
+
const requestPromise = (async () => {
|
|
270
|
+
try {
|
|
271
|
+
const res = await this.request.get('/schedule/resource/list', {
|
|
272
|
+
date
|
|
273
|
+
}, RESOURCE_LIST_CACHE);
|
|
274
|
+
const {
|
|
275
|
+
list
|
|
276
|
+
} = (0, _formatResourceList.formatResourceListAndMap)(res?.data, params.bookingIds || []);
|
|
277
|
+
sharedResourcesCache.set(sharedKey, list);
|
|
278
|
+
return list;
|
|
279
|
+
} finally {
|
|
280
|
+
sharedResourcesPending.delete(sharedKey);
|
|
281
|
+
}
|
|
282
|
+
})();
|
|
283
|
+
pending = requestPromise;
|
|
284
|
+
sharedResourcesPending.set(sharedKey, requestPromise);
|
|
285
|
+
}
|
|
286
|
+
const list = await pending;
|
|
287
|
+
this.setResources(list);
|
|
288
|
+
this.lastResourcesQueryKey = resourcesKey;
|
|
289
|
+
return this.getResourcesOrigin();
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* store 内是否已具备与本次 init 入参等价的 config / resources(不再打接口)。
|
|
294
|
+
*/
|
|
295
|
+
isBookingContextReady(params = {}) {
|
|
296
|
+
const configKey = buildBookingConfigQueryKey(params.bookingConfigParams);
|
|
297
|
+
const dateInput = params.date ?? this.store.date ?? (0, _dayjs.default)();
|
|
298
|
+
const queryDate = toScheduleQueryDate(dateInput);
|
|
299
|
+
const resourcesKey = buildBookingResourcesQueryKey({
|
|
300
|
+
date: queryDate,
|
|
301
|
+
bookingIds: params.bookingIds
|
|
302
|
+
});
|
|
303
|
+
const configReady = this.store.bookingConfig != null && this.lastConfigQueryKey === configKey;
|
|
304
|
+
const resourcesReady = params.loadResources === false || this.lastResourcesQueryKey === resourcesKey;
|
|
305
|
+
return configReady && resourcesReady;
|
|
306
|
+
}
|
|
307
|
+
async initBookingContext(params = {}) {
|
|
308
|
+
const dateInput = params.date ?? this.store.date ?? (0, _dayjs.default)();
|
|
309
|
+
const queryDate = toScheduleQueryDate(dateInput);
|
|
310
|
+
this.setDate(dateInput);
|
|
311
|
+
if (!params.forceRefresh && this.isBookingContextReady(params)) {
|
|
312
|
+
return this.getState();
|
|
313
|
+
}
|
|
314
|
+
const configKey = buildBookingConfigQueryKey(params.bookingConfigParams);
|
|
315
|
+
const resourcesKey = buildBookingResourcesQueryKey({
|
|
316
|
+
date: queryDate,
|
|
317
|
+
bookingIds: params.bookingIds
|
|
318
|
+
});
|
|
319
|
+
const needConfig = params.forceRefresh || this.store.bookingConfig == null || this.lastConfigQueryKey !== configKey;
|
|
320
|
+
const needResources = params.loadResources !== false && (params.forceRefresh || this.lastResourcesQueryKey !== resourcesKey);
|
|
321
|
+
if (needConfig) {
|
|
322
|
+
await this.loadBookingConfig(params.bookingConfigParams, {
|
|
323
|
+
forceRefresh: params.forceRefresh
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
if (needResources) {
|
|
327
|
+
await this.loadResources({
|
|
328
|
+
date: queryDate,
|
|
329
|
+
bookingIds: params.bookingIds
|
|
330
|
+
}, {
|
|
331
|
+
forceRefresh: params.forceRefresh
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
return this.getState();
|
|
335
|
+
}
|
|
336
|
+
setBookingConfig(config) {
|
|
337
|
+
this.store.bookingConfig = config || null;
|
|
338
|
+
this.core.effects.emit(`${this.name}:${_types.BookingContextEvent.OnBookingConfigChange}`, this.store.bookingConfig);
|
|
339
|
+
}
|
|
340
|
+
getBookingConfig() {
|
|
341
|
+
return this.store.bookingConfig;
|
|
342
|
+
}
|
|
343
|
+
setResources(resources) {
|
|
344
|
+
const list = Array.isArray(resources) ? resources : [];
|
|
345
|
+
this.store.resourcesOrigin = list;
|
|
346
|
+
this.store.resourcesOriginMap = buildResourcesMap(list);
|
|
347
|
+
this.core.effects.emit(`${this.name}:${_types.BookingContextEvent.OnResourcesChange}`, {
|
|
348
|
+
resourcesOrigin: this.store.resourcesOrigin,
|
|
349
|
+
resourcesOriginMap: this.store.resourcesOriginMap
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
getResourcesOrigin() {
|
|
353
|
+
return [...this.store.resourcesOrigin];
|
|
354
|
+
}
|
|
355
|
+
getResourcesOriginMap() {
|
|
356
|
+
return this.store.resourcesOriginMap;
|
|
357
|
+
}
|
|
358
|
+
setDate(date) {
|
|
359
|
+
this.store.date = normalizeDate(date);
|
|
360
|
+
this.core.effects.emit(`${this.name}:${_types.BookingContextEvent.OnDateChange}`, this.store.date);
|
|
361
|
+
}
|
|
362
|
+
getDate() {
|
|
363
|
+
return this.store.date;
|
|
364
|
+
}
|
|
365
|
+
getState() {
|
|
366
|
+
return {
|
|
367
|
+
bookingConfig: this.store.bookingConfig,
|
|
368
|
+
resourcesOrigin: [...this.store.resourcesOrigin],
|
|
369
|
+
resourcesOriginMap: this.store.resourcesOriginMap,
|
|
370
|
+
date: this.store.date
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
clear() {
|
|
374
|
+
this.lastConfigQueryKey = null;
|
|
375
|
+
this.lastResourcesQueryKey = null;
|
|
376
|
+
this.store = {
|
|
377
|
+
bookingConfig: null,
|
|
378
|
+
resourcesOrigin: [],
|
|
379
|
+
resourcesOriginMap: {},
|
|
380
|
+
date: null
|
|
381
|
+
};
|
|
382
|
+
this.core.effects.emit(`${this.name}:${_types.BookingContextEvent.OnBookingConfigChange}`, null);
|
|
383
|
+
this.core.effects.emit(`${this.name}:${_types.BookingContextEvent.OnResourcesChange}`, {
|
|
384
|
+
resourcesOrigin: [],
|
|
385
|
+
resourcesOriginMap: {}
|
|
386
|
+
});
|
|
387
|
+
this.core.effects.emit(`${this.name}:${_types.BookingContextEvent.OnDateChange}`, null);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
exports.BookingContextModule = BookingContextModule;
|