@pisell/pisellos 0.0.568 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.js +10 -6
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -3
- package/dist/model/strategy/adapter/promotion/evaluator.js +3 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +7 -5
- package/dist/model/strategy/adapter/walletPass/example.js +26 -3
- package/dist/model/strategy/adapter/walletPass/index.js +5 -5
- package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/dist/model/strategy/adapter/walletPass/utils.js +24 -96
- package/dist/model/strategy/strategy-example.js +19 -5
- package/dist/modules/BaseModule.d.ts +2 -2
- package/dist/modules/BaseModule.js +12 -14
- 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 +3 -0
- package/dist/modules/Cart/utils/cartProduct.js +27 -5
- package/dist/modules/Cart/utils/cartResource.js +0 -2
- package/dist/modules/Cart/utils/changePrice.js +11 -11
- 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 +5 -1
- package/dist/modules/Discount/index.d.ts +2 -2
- package/dist/modules/Discount/index.js +43 -30
- package/dist/modules/Discount/types.d.ts +1 -1
- package/dist/modules/OpenData/index.d.ts +8 -0
- package/dist/modules/OpenData/index.js +38 -16
- package/dist/modules/Order/index.d.ts +449 -24
- package/dist/modules/Order/index.js +5460 -574
- 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 +573 -746
- package/dist/modules/Payment/types.d.ts +44 -24
- package/dist/modules/Payment/utils.d.ts +1 -1
- package/dist/modules/Payment/utils.js +4 -3
- package/dist/modules/Payment/walletpass.d.ts +0 -2
- package/dist/modules/Payment/walletpass.js +49 -33
- package/dist/modules/Product/types.d.ts +29 -7
- package/dist/modules/ProductList/index.d.ts +17 -13
- package/dist/modules/ProductList/index.js +182 -81
- package/dist/modules/ProductList/types.d.ts +16 -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 +324 -513
- 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 +804 -165
- package/dist/modules/Schedule/getDateIsInSchedule.js +14 -12
- package/dist/modules/Schedule/index.d.ts +18 -5
- package/dist/modules/Schedule/index.js +79 -24
- package/dist/modules/Schedule/types.d.ts +2 -0
- package/dist/modules/Schedule/utils.js +1 -0
- package/dist/modules/Step/index.js +1 -0
- package/dist/modules/Summary/index.js +4 -3
- package/dist/modules/Summary/utils.js +22 -43
- 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 +4 -1
- package/dist/plugins/window.js +6 -2
- package/dist/server/index.d.ts +462 -8
- package/dist/server/index.js +6168 -680
- 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 +41 -32
- package/dist/server/modules/order/index.d.ts +207 -14
- package/dist/server/modules/order/index.js +2328 -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 +1416 -521
- 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 +298 -77
- package/dist/server/modules/resource/index.d.ts +2 -3
- package/dist/server/modules/resource/index.js +109 -86
- package/dist/server/modules/schedule/index.d.ts +6 -4
- package/dist/server/modules/schedule/index.js +145 -106
- package/dist/server/test.json +713 -0
- package/dist/server/types.d.ts +2 -0
- package/dist/server/utils/product.js +3 -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 +4009 -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/BookingByStep/index.js +60 -11
- package/dist/solution/BookingByStep/utils/capacity.js +11 -1
- package/dist/solution/BookingByStep/utils/resources.js +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +43 -2
- package/dist/solution/BookingTicket/index.d.ts +393 -24
- package/dist/solution/BookingTicket/index.js +2508 -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 +42 -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 +42 -28
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +30 -14
- 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 +12 -9
- package/dist/solution/Checkout/index.d.ts +1 -0
- package/dist/solution/Checkout/index.js +275 -209
- package/dist/solution/Checkout/utils/index.js +20 -8
- package/dist/solution/RegisterAndLogin/config.js +2 -10
- package/dist/solution/RegisterAndLogin/index.js +76 -30
- 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 +519 -444
- 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 +18 -19
- package/dist/solution/ShopDiscount/types.d.ts +4 -5
- package/dist/solution/ShopDiscount/utils.d.ts +0 -9
- package/dist/solution/ShopDiscount/utils.js +0 -9
- package/dist/solution/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 +32 -51
- package/dist/solution/VenueBooking/index.js +741 -808
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/dist/solution/VenueBooking/types.d.ts +1 -3
- package/dist/solution/VenueBooking/types.js +0 -1
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +9 -3
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -1
- package/dist/types/index.d.ts +12 -2
- package/dist/utils/task.js +18 -15
- package/dist/utils/watch.js +1 -0
- package/lib/apis/picoding.js +0 -2
- package/lib/core/index.js +132 -130
- package/lib/effects/index.js +57 -46
- package/lib/index.d.ts +0 -1
- package/lib/index.js +50 -92
- package/lib/model/index.js +21 -14
- package/lib/model/strategy/adapter/dataVariant/adapter.js +50 -38
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +236 -162
- package/lib/model/strategy/adapter/dataVariant/examples.js +237 -229
- package/lib/model/strategy/adapter/dataVariant/index.js +34 -39
- package/lib/model/strategy/adapter/dataVariant/type.js +28 -57
- package/lib/model/strategy/adapter/index.js +64 -100
- package/lib/model/strategy/adapter/itemRule/adapter.js +144 -156
- package/lib/model/strategy/adapter/itemRule/evaluator.js +48 -36
- package/lib/model/strategy/adapter/itemRule/examples.js +225 -295
- package/lib/model/strategy/adapter/itemRule/index.js +57 -83
- package/lib/model/strategy/adapter/itemRule/type.js +36 -97
- package/lib/model/strategy/adapter/promotion/adapter.js +63 -84
- package/lib/model/strategy/adapter/promotion/evaluator.js +233 -382
- package/lib/model/strategy/adapter/promotion/examples.js +159 -139
- package/lib/model/strategy/adapter/promotion/index.js +0 -1
- package/lib/model/strategy/adapter/promotion/type.js +35 -199
- package/lib/model/strategy/adapter/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/evaluator.js +152 -180
- package/lib/model/strategy/adapter/walletPass/example.js +190 -217
- package/lib/model/strategy/adapter/walletPass/index.js +51 -75
- package/lib/model/strategy/adapter/walletPass/locales.js +58 -36
- package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/lib/model/strategy/adapter/walletPass/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/lib/model/strategy/adapter/walletPass/utils.js +383 -676
- package/lib/model/strategy/engine.js +168 -270
- package/lib/model/strategy/index.js +34 -49
- package/lib/model/strategy/strategy-example.js +239 -243
- package/lib/model/strategy/type.js +40 -100
- package/lib/modules/Account/index.js +53 -39
- package/lib/modules/Account/types.js +33 -20
- package/lib/modules/AccountList/index.js +154 -116
- package/lib/modules/AccountList/types.js +31 -30
- package/lib/modules/AccountList/utils.js +30 -18
- package/lib/modules/BaseModule.d.ts +2 -2
- package/lib/modules/BaseModule.js +50 -29
- package/lib/modules/BookingContext/index.d.ts +48 -0
- package/lib/modules/BookingContext/index.js +368 -0
- package/lib/modules/BookingContext/types.d.ts +102 -0
- package/lib/modules/BookingContext/types.js +34 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +298 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +155 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +222 -0
- package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/lib/modules/BookingContext/utils/flexible.js +80 -0
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
- package/lib/modules/BookingContext/utils/index.d.ts +11 -0
- package/lib/modules/BookingContext/utils/index.js +43 -0
- package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/lib/modules/BookingContext/utils/noResource.js +90 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +56 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/lib/modules/BookingContext/utils/productExtend.js +283 -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 +46 -0
- package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
- package/lib/modules/BookingContext/utils/resources.js +377 -0
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
- package/lib/modules/Cart/index.js +124 -170
- package/lib/modules/Cart/types.js +51 -46
- package/lib/modules/Cart/utils/cartAccount.js +39 -40
- package/lib/modules/Cart/utils/cartDate.js +61 -56
- package/lib/modules/Cart/utils/cartDiscount.js +33 -28
- package/lib/modules/Cart/utils/cartNote.js +32 -27
- package/lib/modules/Cart/utils/cartProduct.js +261 -309
- package/lib/modules/Cart/utils/cartRelationForms.js +35 -29
- package/lib/modules/Cart/utils/cartResource.js +78 -72
- package/lib/modules/Cart/utils/changePrice.js +59 -31
- package/lib/modules/Cart/utils/index.js +48 -106
- package/lib/modules/Customer/constants.js +34 -13
- package/lib/modules/Customer/index.d.ts +20 -0
- package/lib/modules/Customer/index.js +207 -217
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Customer/types.js +35 -38
- package/lib/modules/Date/index.js +115 -116
- package/lib/modules/Date/types.js +28 -16
- package/lib/modules/Date/utils.js +123 -174
- package/lib/modules/Discount/index.d.ts +2 -2
- package/lib/modules/Discount/index.js +133 -119
- package/lib/modules/Discount/types.d.ts +1 -1
- package/lib/modules/Discount/types.js +31 -9
- package/lib/modules/Guests/index.js +56 -30
- package/lib/modules/Guests/types.js +33 -23
- package/lib/modules/Holder/index.js +189 -209
- package/lib/modules/Holder/types.js +16 -4
- package/lib/modules/Holder/utils.js +49 -20
- package/lib/modules/OpenData/index.d.ts +8 -0
- package/lib/modules/OpenData/index.js +88 -63
- package/lib/modules/OpenData/types.js +16 -4
- package/lib/modules/OpenData/utils.js +78 -44
- package/lib/modules/Order/index.d.ts +449 -24
- package/lib/modules/Order/index.js +4184 -514
- package/lib/modules/Order/types.d.ts +693 -88
- package/lib/modules/Order/types.js +35 -24
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/lib/modules/Order/utils/bundleDiscountHydration.js +139 -0
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/lib/modules/Order/utils/manualProductDiscount.js +206 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +415 -0
- package/lib/modules/Order/utils.d.ts +167 -18
- package/lib/modules/Order/utils.js +1085 -414
- package/lib/modules/Payment/cash.js +33 -20
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +76 -145
- package/lib/modules/Payment/eftpos.js +30 -16
- package/lib/modules/Payment/index.d.ts +10 -9
- package/lib/modules/Payment/index.js +402 -636
- package/lib/modules/Payment/mx51.js +0 -1
- package/lib/modules/Payment/types.d.ts +44 -24
- package/lib/modules/Payment/types.js +107 -216
- package/lib/modules/Payment/utils.d.ts +1 -1
- package/lib/modules/Payment/utils.js +50 -52
- package/lib/modules/Payment/walletpass.d.ts +0 -2
- package/lib/modules/Payment/walletpass.js +216 -221
- package/lib/modules/Product/index.js +46 -51
- package/lib/modules/Product/types.d.ts +29 -7
- package/lib/modules/Product/types.js +16 -4
- package/lib/modules/Product/utils.js +33 -32
- package/lib/modules/ProductList/index.d.ts +17 -13
- package/lib/modules/ProductList/index.js +161 -120
- package/lib/modules/ProductList/types.d.ts +16 -0
- package/lib/modules/ProductList/types.js +31 -9
- package/lib/modules/Quotation/index.d.ts +22 -2
- package/lib/modules/Quotation/index.js +154 -64
- package/lib/modules/Quotation/types.d.ts +19 -0
- package/lib/modules/Quotation/types.js +16 -4
- package/lib/modules/Resource/index.js +59 -27
- package/lib/modules/Resource/types.js +32 -22
- package/lib/modules/Resource/utils.js +38 -30
- package/lib/modules/ResourcePlanner/index.d.ts +24 -0
- package/lib/modules/ResourcePlanner/index.js +148 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
- package/lib/modules/ResourcePlanner/planner.js +933 -0
- package/lib/modules/ResourcePlanner/types.d.ts +227 -0
- package/lib/modules/ResourcePlanner/types.js +17 -0
- package/lib/modules/Rules/index.d.ts +8 -10
- package/lib/modules/Rules/index.js +960 -1440
- package/lib/modules/Rules/types.d.ts +14 -3
- package/lib/modules/Rules/types.js +40 -17
- package/lib/modules/SalesSummary/index.d.ts +23 -26
- package/lib/modules/SalesSummary/index.js +134 -61
- package/lib/modules/SalesSummary/types.d.ts +9 -1
- package/lib/modules/SalesSummary/types.js +16 -4
- package/lib/modules/SalesSummary/utils.d.ts +3 -22
- package/lib/modules/SalesSummary/utils.js +814 -233
- package/lib/modules/ScanOrderLogger/index.js +79 -59
- package/lib/modules/ScanOrderLogger/providers/feishu.js +78 -54
- package/lib/modules/ScanOrderLogger/providers/grafana.js +36 -13
- package/lib/modules/ScanOrderLogger/types.js +16 -4
- package/lib/modules/Schedule/getDateIsInSchedule.js +169 -338
- package/lib/modules/Schedule/index.d.ts +18 -5
- package/lib/modules/Schedule/index.js +153 -104
- package/lib/modules/Schedule/type.js +16 -4
- package/lib/modules/Schedule/types.d.ts +2 -0
- package/lib/modules/Schedule/types.js +16 -4
- package/lib/modules/Schedule/utils.js +291 -433
- package/lib/modules/Step/index.js +52 -40
- package/lib/modules/Step/tyeps.js +16 -4
- package/lib/modules/Summary/index.js +71 -66
- package/lib/modules/Summary/types.js +16 -4
- package/lib/modules/Summary/utils.js +418 -791
- package/lib/modules/SurchargeList/index.d.ts +18 -0
- package/lib/modules/SurchargeList/index.js +109 -0
- package/lib/modules/SurchargeList/types.d.ts +15 -0
- package/lib/modules/SurchargeList/types.js +17 -0
- package/lib/modules/index.d.ts +3 -0
- package/lib/modules/index.js +63 -212
- package/lib/plugins/app.d.ts +2 -0
- package/lib/plugins/app.js +16 -4
- package/lib/plugins/index.js +25 -36
- package/lib/plugins/request.d.ts +1 -0
- package/lib/plugins/request.js +126 -137
- package/lib/plugins/shopStore.js +16 -4
- package/lib/plugins/user.js +16 -4
- package/lib/plugins/window.js +179 -171
- package/lib/server/index.d.ts +462 -8
- package/lib/server/index.js +4520 -1162
- package/lib/server/modules/floor-plan/index.d.ts +39 -0
- package/lib/server/modules/floor-plan/index.js +327 -0
- package/lib/server/modules/floor-plan/types.d.ts +43 -0
- package/lib/server/modules/floor-plan/types.js +34 -0
- package/lib/server/modules/index.d.ts +7 -2
- package/lib/server/modules/index.js +67 -84
- package/lib/server/modules/menu/index.js +122 -146
- package/lib/server/modules/menu/types.js +31 -18
- package/lib/server/modules/order/index.d.ts +207 -14
- package/lib/server/modules/order/index.js +1543 -285
- package/lib/server/modules/order/types.d.ts +76 -5
- package/lib/server/modules/order/types.js +32 -107
- package/lib/server/modules/order/utils/filterBookings.d.ts +7 -1
- package/lib/server/modules/order/utils/filterBookings.js +259 -176
- package/lib/server/modules/order/utils/filterOrders.js +293 -94
- package/lib/server/modules/payment/index.d.ts +28 -0
- package/lib/server/modules/payment/index.js +192 -0
- package/lib/server/modules/payment/types.d.ts +9 -0
- package/lib/server/modules/payment/types.js +17 -0
- package/lib/server/modules/products/index.d.ts +105 -14
- package/lib/server/modules/products/index.js +850 -475
- package/lib/server/modules/products/types.d.ts +34 -1
- package/lib/server/modules/products/types.js +34 -41
- package/lib/server/modules/quotation/index.d.ts +39 -0
- package/lib/server/modules/quotation/index.js +254 -75
- package/lib/server/modules/quotation/types.js +31 -21
- package/lib/server/modules/resource/index.d.ts +2 -3
- package/lib/server/modules/resource/index.js +240 -243
- package/lib/server/modules/resource/types.js +33 -42
- package/lib/server/modules/schedule/index.d.ts +6 -4
- package/lib/server/modules/schedule/index.js +146 -147
- package/lib/server/modules/schedule/types.js +21 -14
- package/lib/server/modules/schedule/utils.js +163 -334
- package/lib/server/test.json +713 -0
- package/lib/server/types.d.ts +2 -0
- package/lib/server/types.js +16 -4
- package/lib/server/utils/index.js +23 -25
- package/lib/server/utils/product.js +140 -197
- package/lib/server/utils/schedule.js +41 -34
- package/lib/server/utils/small-ticket.d.ts +71 -0
- package/lib/server/utils/small-ticket.js +904 -0
- package/lib/server/utils/time.js +49 -40
- package/lib/solution/BaseSales/index.d.ts +378 -0
- package/lib/solution/BaseSales/index.js +2533 -0
- package/lib/solution/BaseSales/types.d.ts +394 -0
- package/lib/solution/BaseSales/types.js +43 -0
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
- package/lib/solution/BaseSales/utils/cartPromotion.js +1004 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +144 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +160 -0
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +18 -0
- package/lib/solution/BaseSales/utils/quotationPrice.js +289 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +63 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +256 -0
- package/lib/solution/BaseSales/utils.d.ts +40 -0
- package/lib/solution/BaseSales/utils.js +244 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +1340 -1530
- package/lib/solution/BookingByStep/types.js +99 -40
- package/lib/solution/BookingByStep/utils/capacity.js +160 -192
- package/lib/solution/BookingByStep/utils/products.js +52 -42
- package/lib/solution/BookingByStep/utils/resources.js +330 -527
- package/lib/solution/BookingByStep/utils/stock.js +44 -65
- package/lib/solution/BookingByStep/utils/timeslots.js +131 -129
- package/lib/solution/BookingTicket/index.d.ts +393 -24
- package/lib/solution/BookingTicket/index.js +1374 -184
- package/lib/solution/BookingTicket/types.d.ts +191 -6
- package/lib/solution/BookingTicket/types.js +79 -40
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
- package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +125 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.js +107 -0
- package/lib/solution/BookingTicket/utils/cartView.d.ts +29 -0
- package/lib/solution/BookingTicket/utils/cartView.js +184 -0
- package/lib/solution/BookingTicket/utils/exampleData.d.ts +123 -0
- package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +58 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +254 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +169 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +97 -64
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +51 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +81 -82
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +109 -91
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +43 -90
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +127 -0
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +85 -0
- package/lib/solution/BuyTickets/index.js +70 -67
- package/lib/solution/BuyTickets/types.js +38 -22
- package/lib/solution/Checkout/index.d.ts +1 -0
- package/lib/solution/Checkout/index.js +1169 -1463
- package/lib/solution/Checkout/types.js +61 -91
- package/lib/solution/Checkout/utils/index.js +156 -228
- package/lib/solution/PlaceOrder/index.js +0 -55
- package/lib/solution/RegisterAndLogin/config.js +462 -503
- package/lib/solution/RegisterAndLogin/index.js +630 -633
- package/lib/solution/RegisterAndLogin/types.js +76 -189
- package/lib/solution/RegisterAndLogin/utils.js +125 -183
- package/lib/solution/Sales/index.d.ts +50 -5
- package/lib/solution/Sales/index.js +498 -238
- package/lib/solution/Sales/types.d.ts +26 -2
- package/lib/solution/Sales/types.js +33 -27
- package/lib/solution/ScanOrder/index.d.ts +27 -21
- package/lib/solution/ScanOrder/index.js +936 -864
- package/lib/solution/ScanOrder/types.d.ts +33 -11
- package/lib/solution/ScanOrder/types.js +34 -34
- package/lib/solution/ScanOrder/utils.d.ts +4 -1
- package/lib/solution/ScanOrder/utils.js +422 -385
- package/lib/solution/ShopDiscount/index.js +233 -235
- package/lib/solution/ShopDiscount/types.d.ts +4 -5
- package/lib/solution/ShopDiscount/types.js +37 -15
- package/lib/solution/ShopDiscount/utils.d.ts +0 -9
- package/lib/solution/ShopDiscount/utils.js +172 -309
- package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/lib/solution/UnifiedBookingSales/index.js +1076 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/lib/solution/UnifiedBookingSales/types.js +33 -0
- package/lib/solution/VenueBooking/index.d.ts +32 -51
- package/lib/solution/VenueBooking/index.js +1008 -984
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/lib/solution/VenueBooking/types.d.ts +1 -3
- package/lib/solution/VenueBooking/types.js +39 -20
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/lib/solution/VenueBooking/utils/dateSummary.js +62 -25
- package/lib/solution/VenueBooking/utils/resource.js +54 -31
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +109 -90
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/lib/solution/VenueBooking/utils/timeSlot.js +133 -138
- package/lib/solution/VenueBooking/utils.js +67 -130
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +41 -102
- package/lib/store/createStore.js +29 -32
- package/lib/types/index.d.ts +12 -2
- package/lib/types/index.js +16 -4
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +47 -81
- package/package.json +2 -4
- package/dist/solution/Checkout/appointmentDemo.json +0 -1
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
- package/lib/solution/Checkout/appointmentDemo.json +0 -1
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/lib/solution/VenueBooking/utils/smartPricing.js +0 -192
|
@@ -1,142 +1,138 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/solution/Sales/index.ts
|
|
31
|
+
var Sales_exports = {};
|
|
32
|
+
__export(Sales_exports, {
|
|
33
|
+
Sales: () => SalesImpl,
|
|
34
|
+
SalesImpl: () => SalesImpl,
|
|
35
|
+
default: () => Sales_default
|
|
24
36
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
* - 基础生命周期占位
|
|
33
|
-
*
|
|
34
|
-
* 不提前实现 store 编排、初始化流程细节、状态计算逻辑。
|
|
35
|
-
*/
|
|
36
|
-
class SalesImpl extends _BaseModule.BaseModule {
|
|
37
|
-
defaultName = 'sales';
|
|
38
|
-
defaultVersion = '1.0.0';
|
|
39
|
-
defaultTimelineBucketMinutes = 15;
|
|
40
|
-
isSolution = true;
|
|
41
|
-
store;
|
|
42
|
-
options = {};
|
|
43
|
-
otherParams = {};
|
|
44
|
-
request;
|
|
37
|
+
module.exports = __toCommonJS(Sales_exports);
|
|
38
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
39
|
+
var import_BaseModule = require("../../modules/BaseModule");
|
|
40
|
+
var import_types = require("./types");
|
|
41
|
+
__reExport(Sales_exports, require("./types"), module.exports);
|
|
42
|
+
var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
43
|
+
// LoggerManager 实例
|
|
45
44
|
constructor(name, version) {
|
|
46
45
|
super(name, version);
|
|
46
|
+
this.defaultName = "sales";
|
|
47
|
+
this.defaultVersion = "1.0.0";
|
|
48
|
+
this.defaultTimelineBucketMinutes = 15;
|
|
49
|
+
this.isSolution = true;
|
|
50
|
+
this.options = {};
|
|
51
|
+
this.otherParams = {};
|
|
47
52
|
}
|
|
48
53
|
async initialize(core, options = {}) {
|
|
49
54
|
this.core = core;
|
|
50
55
|
this.options = options;
|
|
51
56
|
this.otherParams = options.otherParams || {};
|
|
52
|
-
const appPlugin = this.core.getPlugin(
|
|
53
|
-
|
|
54
|
-
this.request = appPlugin?.getApp().request;
|
|
57
|
+
const appPlugin = this.core.getPlugin("app");
|
|
58
|
+
this.request = appPlugin == null ? void 0 : appPlugin.getApp().request;
|
|
55
59
|
if (!this.request) {
|
|
56
|
-
throw new Error(
|
|
60
|
+
throw new Error("Sales 解决方案需要 request 插件支持");
|
|
57
61
|
}
|
|
58
|
-
|
|
59
|
-
// 初始化 store 状态
|
|
60
62
|
this.store = {
|
|
61
|
-
currentDay: (0,
|
|
63
|
+
currentDay: (0, import_dayjs.default)().startOf("day"),
|
|
62
64
|
reservationList: []
|
|
63
65
|
};
|
|
64
|
-
|
|
65
|
-
// TODO(Rolo): 等领导提供 reservationList 的目标结构后,
|
|
66
|
-
// 在这里补充从 Server/Order 读取 currentDay 原始数据并转换为预约列表。
|
|
67
|
-
|
|
66
|
+
this.logger = appPlugin == null ? void 0 : appPlugin.getApp().logger;
|
|
68
67
|
await this.core.effects.emit(`${this.name}:onInited`, {});
|
|
69
68
|
}
|
|
70
|
-
|
|
71
69
|
// -------------------------------------------------------------------------
|
|
72
70
|
// SalesModuleAPI 实现
|
|
73
71
|
// -------------------------------------------------------------------------
|
|
74
|
-
|
|
75
72
|
/** 获取当前 store 快照 */
|
|
76
73
|
getState() {
|
|
77
|
-
return {
|
|
78
|
-
...this.store
|
|
79
|
-
};
|
|
74
|
+
return { ...this.store };
|
|
80
75
|
}
|
|
81
|
-
|
|
82
76
|
/** 获取当前选择日期 */
|
|
83
77
|
getCurrentDay() {
|
|
84
78
|
return this.store.currentDay;
|
|
85
79
|
}
|
|
86
|
-
|
|
87
80
|
/** 设置当前选择日期,会自动归一到当天 00:00:00 */
|
|
88
81
|
setCurrentDay(currentDay) {
|
|
89
|
-
const normalized = (0,
|
|
82
|
+
const normalized = (0, import_dayjs.default)(currentDay).startOf("day");
|
|
90
83
|
this.store.currentDay = normalized;
|
|
91
|
-
this.core.effects.emit(
|
|
92
|
-
currentDay: normalized
|
|
93
|
-
});
|
|
84
|
+
this.core.effects.emit(import_types.SalesHooks.onCurrentDayChanged, { currentDay: normalized });
|
|
94
85
|
return normalized;
|
|
95
86
|
}
|
|
96
|
-
|
|
97
87
|
/** 获取当前预约列表 */
|
|
98
88
|
getReservationList() {
|
|
99
89
|
return [...this.store.reservationList];
|
|
100
90
|
}
|
|
101
|
-
|
|
102
91
|
/** 覆盖设置当前预约列表 */
|
|
103
92
|
setReservationList(reservationList) {
|
|
104
93
|
this.store.reservationList = reservationList;
|
|
105
|
-
this.core.effects.emit(
|
|
106
|
-
reservationList
|
|
107
|
-
});
|
|
94
|
+
this.core.effects.emit(import_types.SalesHooks.onReservationListChanged, { reservationList });
|
|
108
95
|
return reservationList;
|
|
109
96
|
}
|
|
110
|
-
|
|
111
97
|
/** 重置预约列表为空 */
|
|
112
98
|
resetReservationList() {
|
|
113
99
|
this.store.reservationList = [];
|
|
114
|
-
this.core.effects.emit(
|
|
115
|
-
reservationList: []
|
|
116
|
-
});
|
|
100
|
+
this.core.effects.emit(import_types.SalesHooks.onReservationListChanged, { reservationList: [] });
|
|
117
101
|
return [];
|
|
118
102
|
}
|
|
119
|
-
|
|
103
|
+
async cancelOrder(orderIds) {
|
|
104
|
+
const orderModule = this.core.getModule("order");
|
|
105
|
+
if (!orderModule) {
|
|
106
|
+
throw new Error("Sales 取消订单失败:Order 模块未注册");
|
|
107
|
+
}
|
|
108
|
+
return orderModule.cancelOrder({ order_ids: orderIds });
|
|
109
|
+
}
|
|
110
|
+
async changeBookingStatus(params) {
|
|
111
|
+
const orderModule = this.core.getModule("order");
|
|
112
|
+
if (!orderModule) {
|
|
113
|
+
throw new Error("Sales 变更预约状态失败:Order 模块未注册");
|
|
114
|
+
}
|
|
115
|
+
return orderModule.changeBookingStatus(params);
|
|
116
|
+
}
|
|
120
117
|
// -------------------------------------------------------------------------
|
|
121
118
|
// 生命周期
|
|
122
119
|
// -------------------------------------------------------------------------
|
|
123
|
-
|
|
124
120
|
async destroy() {
|
|
125
121
|
await this.core.effects.emit(`${this.name}:onDestroy`, {});
|
|
126
122
|
super.destroy();
|
|
127
123
|
}
|
|
128
|
-
|
|
129
124
|
/**
|
|
130
125
|
* 时间轴粒度(分钟)
|
|
131
126
|
* - 默认 15 分钟
|
|
132
127
|
* - 可通过 registerModule 时的 options.otherParams.timelineBucketMinutes 覆盖
|
|
133
128
|
*/
|
|
134
129
|
getTimelineBucketMinutes() {
|
|
135
|
-
|
|
136
|
-
|
|
130
|
+
var _a;
|
|
131
|
+
const dynamicBucket = Number((_a = this.otherParams) == null ? void 0 : _a.timelineBucketMinutes);
|
|
132
|
+
if (!Number.isFinite(dynamicBucket) || dynamicBucket <= 0)
|
|
133
|
+
return this.defaultTimelineBucketMinutes;
|
|
137
134
|
return Math.floor(dynamicBucket);
|
|
138
135
|
}
|
|
139
|
-
|
|
140
136
|
/**
|
|
141
137
|
* 解析营业日统计窗口:
|
|
142
138
|
* - 当 operating_day_boundary.type === 'start_time'
|
|
@@ -144,32 +140,23 @@ class SalesImpl extends _BaseModule.BaseModule {
|
|
|
144
140
|
* - 否则回退自然日(00:00 到次日 00:00)
|
|
145
141
|
*/
|
|
146
142
|
getTimelineRangeByOperatingBoundary() {
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
const
|
|
150
|
-
const
|
|
151
|
-
const
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
endExclusiveAt: defaultEndExclusive
|
|
157
|
-
};
|
|
143
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
144
|
+
const today = (0, import_dayjs.default)();
|
|
145
|
+
const defaultStart = today.startOf("day");
|
|
146
|
+
const defaultEndExclusive = defaultStart.add(1, "day");
|
|
147
|
+
const appPlugin = this.core.getPlugin("app");
|
|
148
|
+
const coreData = (_f = (_d = (_c = (_b = (_a = appPlugin == null ? void 0 : appPlugin.getApp()) == null ? void 0 : _a.data) == null ? void 0 : _b.store) == null ? void 0 : _c.getStore) == null ? void 0 : (_e = _d.call(_c)).getDataByModel) == null ? void 0 : _f.call(_e, "core");
|
|
149
|
+
const operatingDayBoundary = (_g = coreData == null ? void 0 : coreData.core) == null ? void 0 : _g.operating_day_boundary;
|
|
150
|
+
if ((operatingDayBoundary == null ? void 0 : operatingDayBoundary.type) !== "start_time") {
|
|
151
|
+
return { startAt: defaultStart, endExclusiveAt: defaultEndExclusive };
|
|
158
152
|
}
|
|
159
|
-
const boundaryTime = String(operatingDayBoundary.time ||
|
|
160
|
-
const startAt = (0,
|
|
153
|
+
const boundaryTime = String(operatingDayBoundary.time || "").trim();
|
|
154
|
+
const startAt = (0, import_dayjs.default)(`${today.format("YYYY-MM-DD")} ${boundaryTime}`);
|
|
161
155
|
if (!startAt.isValid()) {
|
|
162
|
-
return {
|
|
163
|
-
startAt: defaultStart,
|
|
164
|
-
endExclusiveAt: defaultEndExclusive
|
|
165
|
-
};
|
|
156
|
+
return { startAt: defaultStart, endExclusiveAt: defaultEndExclusive };
|
|
166
157
|
}
|
|
167
|
-
return {
|
|
168
|
-
startAt,
|
|
169
|
-
endExclusiveAt: startAt.add(1, 'day')
|
|
170
|
-
};
|
|
158
|
+
return { startAt, endExclusiveAt: startAt.add(1, "day") };
|
|
171
159
|
}
|
|
172
|
-
|
|
173
160
|
/**
|
|
174
161
|
* 统计时间轴每个时间片的预约数量。
|
|
175
162
|
* 算法使用差分数组,复杂度 O(n + s):
|
|
@@ -178,35 +165,39 @@ class SalesImpl extends _BaseModule.BaseModule {
|
|
|
178
165
|
*/
|
|
179
166
|
getTimelineHighlights(bookingList = [], startDateTime, endDateTime) {
|
|
180
167
|
const bucketMinutes = this.getTimelineBucketMinutes();
|
|
181
|
-
const bucketMs = bucketMinutes * 60 *
|
|
182
|
-
const customStartAt = startDateTime ? (0,
|
|
183
|
-
const customEndExclusiveAt = endDateTime ? (0,
|
|
168
|
+
const bucketMs = bucketMinutes * 60 * 1e3;
|
|
169
|
+
const customStartAt = startDateTime ? (0, import_dayjs.default)(startDateTime) : (0, import_dayjs.default)("");
|
|
170
|
+
const customEndExclusiveAt = endDateTime ? (0, import_dayjs.default)(endDateTime) : (0, import_dayjs.default)("");
|
|
184
171
|
const hasValidCustomRange = customStartAt.isValid() && customEndExclusiveAt.isValid();
|
|
185
|
-
const {
|
|
186
|
-
startAt,
|
|
187
|
-
endExclusiveAt
|
|
188
|
-
} = hasValidCustomRange ? {
|
|
189
|
-
startAt: customStartAt,
|
|
190
|
-
endExclusiveAt: customEndExclusiveAt
|
|
191
|
-
} : this.getTimelineRangeByOperatingBoundary();
|
|
172
|
+
const { startAt, endExclusiveAt } = hasValidCustomRange ? { startAt: customStartAt, endExclusiveAt: customEndExclusiveAt } : this.getTimelineRangeByOperatingBoundary();
|
|
192
173
|
const startAtMs = startAt.valueOf();
|
|
193
174
|
const endExclusiveAtMs = endExclusiveAt.valueOf();
|
|
194
|
-
if (!startAt.isValid() || !endExclusiveAt.isValid() || endExclusiveAtMs <= startAtMs)
|
|
175
|
+
if (!startAt.isValid() || !endExclusiveAt.isValid() || endExclusiveAtMs <= startAtMs)
|
|
176
|
+
return [];
|
|
195
177
|
const slotCount = Math.ceil((endExclusiveAtMs - startAtMs) / bucketMs);
|
|
196
|
-
if (slotCount <= 0)
|
|
178
|
+
if (slotCount <= 0)
|
|
179
|
+
return [];
|
|
197
180
|
const diff = new Int32Array(slotCount + 1);
|
|
198
181
|
for (let i = 0; i < bookingList.length; i++) {
|
|
199
182
|
const booking = bookingList[i];
|
|
183
|
+
const appointmentStatus = String(booking.appointment_status ?? booking.status ?? "");
|
|
184
|
+
if (appointmentStatus === "new" || appointmentStatus === "rejected" || appointmentStatus === "cancelled")
|
|
185
|
+
continue;
|
|
200
186
|
const bookingStartAt = this.toBookingDateTime(booking.start_date, booking.start_time);
|
|
201
187
|
const bookingEndAt = this.toBookingDateTime(booking.end_date, booking.end_time);
|
|
202
|
-
if (!bookingStartAt.isValid() || !bookingEndAt.isValid())
|
|
188
|
+
if (!bookingStartAt.isValid() || !bookingEndAt.isValid())
|
|
189
|
+
continue;
|
|
203
190
|
const overlapStartMs = Math.max(bookingStartAt.valueOf(), startAtMs);
|
|
204
|
-
// 结束时间按 <= 处理:转成右开区间时 +1ms,保证命中 end_time 所在时间片
|
|
205
191
|
const overlapEndExclusiveMs = Math.min(bookingEndAt.valueOf() + 1, endExclusiveAtMs);
|
|
206
|
-
if (overlapStartMs >= overlapEndExclusiveMs)
|
|
192
|
+
if (overlapStartMs >= overlapEndExclusiveMs)
|
|
193
|
+
continue;
|
|
207
194
|
const startIdx = Math.max(0, Math.ceil((overlapStartMs - startAtMs) / bucketMs));
|
|
208
|
-
const endIdx = Math.min(
|
|
209
|
-
|
|
195
|
+
const endIdx = Math.min(
|
|
196
|
+
slotCount - 1,
|
|
197
|
+
Math.floor((overlapEndExclusiveMs - 1 - startAtMs) / bucketMs)
|
|
198
|
+
);
|
|
199
|
+
if (startIdx > endIdx)
|
|
200
|
+
continue;
|
|
210
201
|
diff[startIdx] += 1;
|
|
211
202
|
diff[endIdx + 1] -= 1;
|
|
212
203
|
}
|
|
@@ -218,17 +209,14 @@ class SalesImpl extends _BaseModule.BaseModule {
|
|
|
218
209
|
}
|
|
219
210
|
return timeline;
|
|
220
211
|
}
|
|
221
|
-
|
|
222
212
|
/** dayjs 未启用插件时,手动封装 >= 判断 */
|
|
223
213
|
isSameOrAfter(left, right) {
|
|
224
214
|
return left.isAfter(right) || left.isSame(right);
|
|
225
215
|
}
|
|
226
|
-
|
|
227
216
|
/** dayjs 未启用插件时,手动封装 <= 判断 */
|
|
228
217
|
isSameOrBefore(left, right) {
|
|
229
218
|
return left.isBefore(right) || left.isSame(right);
|
|
230
219
|
}
|
|
231
|
-
|
|
232
220
|
/**
|
|
233
221
|
* 将 booking 的日期/时间字段统一组装为 dayjs
|
|
234
222
|
* - date + time 都有:按完整时间解析
|
|
@@ -236,28 +224,88 @@ class SalesImpl extends _BaseModule.BaseModule {
|
|
|
236
224
|
* - 都没有:返回 invalid
|
|
237
225
|
*/
|
|
238
226
|
toBookingDateTime(date, time) {
|
|
239
|
-
if (!date && !time)
|
|
240
|
-
|
|
241
|
-
|
|
227
|
+
if (!date && !time)
|
|
228
|
+
return (0, import_dayjs.default)("");
|
|
229
|
+
if (date && time)
|
|
230
|
+
return (0, import_dayjs.default)(`${date} ${time}`);
|
|
231
|
+
return (0, import_dayjs.default)(date || time);
|
|
242
232
|
}
|
|
243
|
-
|
|
244
233
|
/**
|
|
245
234
|
* 预约状态映射(面向 UI 的统一状态)
|
|
246
235
|
* 说明:locked 逻辑后续会补业务规则,这里先保留分支占位。
|
|
247
236
|
*/
|
|
248
237
|
getBookingStatus(appointmentStatus) {
|
|
249
|
-
if (appointmentStatus ===
|
|
250
|
-
|
|
251
|
-
|
|
238
|
+
if (appointmentStatus === "started")
|
|
239
|
+
return "occupied";
|
|
240
|
+
if (appointmentStatus === "confirmed" || appointmentStatus === "arrived") {
|
|
241
|
+
return "reserved";
|
|
252
242
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
return
|
|
243
|
+
if (appointmentStatus === "locked")
|
|
244
|
+
return "locked";
|
|
245
|
+
return void 0;
|
|
256
246
|
}
|
|
257
247
|
getResourceId(resource) {
|
|
258
|
-
return resource.id ?? resource.form_record_id ??
|
|
248
|
+
return resource.id ?? resource.form_record_id ?? "";
|
|
249
|
+
}
|
|
250
|
+
getBookingAppointmentStatus(booking) {
|
|
251
|
+
return String(booking.appointment_status ?? booking.status ?? "");
|
|
252
|
+
}
|
|
253
|
+
isBookingIncludedInStats(booking) {
|
|
254
|
+
const appointmentStatus = this.getBookingAppointmentStatus(booking);
|
|
255
|
+
return appointmentStatus !== "new" && appointmentStatus !== "rejected" && appointmentStatus !== "cancelled";
|
|
256
|
+
}
|
|
257
|
+
getBookingOrderPaymentStatus(booking) {
|
|
258
|
+
var _a;
|
|
259
|
+
return String(((_a = booking.order) == null ? void 0 : _a.payment_status) ?? "");
|
|
260
|
+
}
|
|
261
|
+
countBookingOrders(bookings) {
|
|
262
|
+
const orderIds = /* @__PURE__ */ new Set();
|
|
263
|
+
bookings.forEach((booking) => {
|
|
264
|
+
var _a;
|
|
265
|
+
const orderId = booking.order_id ?? ((_a = booking.order) == null ? void 0 : _a.order_id);
|
|
266
|
+
if (orderId === void 0 || orderId === null)
|
|
267
|
+
return;
|
|
268
|
+
orderIds.add(String(orderId));
|
|
269
|
+
});
|
|
270
|
+
return orderIds.size;
|
|
271
|
+
}
|
|
272
|
+
countCompletedBookings(bookings) {
|
|
273
|
+
return bookings.filter((booking) => this.getBookingAppointmentStatus(booking) === "completed").length;
|
|
274
|
+
}
|
|
275
|
+
groupBookingsByResource(bookingList) {
|
|
276
|
+
const bookingMap = /* @__PURE__ */ new Map();
|
|
277
|
+
bookingList.forEach((booking) => {
|
|
278
|
+
if (!Array.isArray(booking.resources))
|
|
279
|
+
return;
|
|
280
|
+
booking.resources.forEach((resource) => {
|
|
281
|
+
const relationId = resource == null ? void 0 : resource.relation_id;
|
|
282
|
+
if (relationId === void 0 || relationId === null)
|
|
283
|
+
return;
|
|
284
|
+
const key = String(relationId);
|
|
285
|
+
const list = bookingMap.get(key) || [];
|
|
286
|
+
list.push(booking);
|
|
287
|
+
bookingMap.set(key, list);
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
return bookingMap;
|
|
291
|
+
}
|
|
292
|
+
isBookingMatchedResource(booking, resourceId) {
|
|
293
|
+
if (!Array.isArray(booking.resources))
|
|
294
|
+
return false;
|
|
295
|
+
return booking.resources.some((resource) => {
|
|
296
|
+
const relationId = resource == null ? void 0 : resource.relation_id;
|
|
297
|
+
if (relationId === void 0 || relationId === null)
|
|
298
|
+
return false;
|
|
299
|
+
return String(relationId) === String(resourceId);
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
sortMatchedBookings(bookings) {
|
|
303
|
+
return [...bookings].sort((left, right) => {
|
|
304
|
+
const leftStartAt = this.toBookingDateTime(left.start_date, left.start_time).valueOf();
|
|
305
|
+
const rightStartAt = this.toBookingDateTime(right.start_date, right.start_time).valueOf();
|
|
306
|
+
return leftStartAt - rightStartAt;
|
|
307
|
+
});
|
|
259
308
|
}
|
|
260
|
-
|
|
261
309
|
/**
|
|
262
310
|
* 资源下 bookings 的返回裁剪策略:
|
|
263
311
|
* 1) 优先返回当前时刻正在进行中的预约(允许并发返回多条)
|
|
@@ -266,105 +314,174 @@ class SalesImpl extends _BaseModule.BaseModule {
|
|
|
266
314
|
* 4) 最后兜底返回一条(避免资源有历史预约时完全无反馈)
|
|
267
315
|
*/
|
|
268
316
|
pickBookingsForCurrentPoint(current, bookings) {
|
|
269
|
-
if (bookings.length === 0)
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
const dayScopedBookings = bookings.filter(booking => {
|
|
317
|
+
if (bookings.length === 0)
|
|
318
|
+
return [];
|
|
319
|
+
const currentDayStart = current.startOf("day");
|
|
320
|
+
const currentDayEnd = current.endOf("day");
|
|
321
|
+
const dayScopedBookings = bookings.filter((booking) => {
|
|
275
322
|
const startAt = this.toBookingDateTime(booking.start_date, booking.start_time);
|
|
276
323
|
const endAt = this.toBookingDateTime(booking.end_date, booking.end_time);
|
|
277
|
-
if (!startAt.isValid() || !endAt.isValid())
|
|
324
|
+
if (!startAt.isValid() || !endAt.isValid())
|
|
325
|
+
return false;
|
|
278
326
|
return this.isSameOrBefore(startAt, currentDayEnd) && this.isSameOrAfter(endAt, currentDayStart);
|
|
279
327
|
});
|
|
280
|
-
if (dayScopedBookings.length === 0)
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
const
|
|
286
|
-
|
|
328
|
+
if (dayScopedBookings.length === 0)
|
|
329
|
+
return [];
|
|
330
|
+
const appendNextStartGroupIfNeeded = (selectedBookings) => {
|
|
331
|
+
if (selectedBookings.length === 0)
|
|
332
|
+
return selectedBookings;
|
|
333
|
+
const shouldAppendNextGroup = selectedBookings.some(
|
|
334
|
+
(booking) => booking.status === "reserved" || booking.status === "occupied"
|
|
335
|
+
);
|
|
336
|
+
if (!shouldAppendNextGroup)
|
|
337
|
+
return selectedBookings;
|
|
338
|
+
const selectedStartValues = new Set(
|
|
339
|
+
selectedBookings.map((booking) => this.toBookingDateTime(booking.start_date, booking.start_time)).filter((startAt) => startAt.isValid()).map((startAt) => startAt.valueOf())
|
|
340
|
+
);
|
|
341
|
+
const futureCandidates = dayScopedBookings.filter((booking) => {
|
|
287
342
|
const startAt = this.toBookingDateTime(booking.start_date, booking.start_time);
|
|
288
|
-
if (!startAt.isValid())
|
|
343
|
+
if (!startAt.isValid())
|
|
344
|
+
return false;
|
|
289
345
|
return startAt.isAfter(current) && !selectedStartValues.has(startAt.valueOf());
|
|
290
346
|
});
|
|
291
|
-
if (futureCandidates.length === 0)
|
|
292
|
-
|
|
293
|
-
const
|
|
347
|
+
if (futureCandidates.length === 0)
|
|
348
|
+
return selectedBookings;
|
|
349
|
+
const nextStartAt = this.toBookingDateTime(
|
|
350
|
+
futureCandidates[0].start_date,
|
|
351
|
+
futureCandidates[0].start_time
|
|
352
|
+
).valueOf();
|
|
353
|
+
const nextStartGroup = futureCandidates.filter((booking) => {
|
|
294
354
|
const startAt = this.toBookingDateTime(booking.start_date, booking.start_time);
|
|
295
355
|
return startAt.isValid() && startAt.valueOf() === nextStartAt;
|
|
296
356
|
});
|
|
297
|
-
if (nextStartGroup.length === 0)
|
|
357
|
+
if (nextStartGroup.length === 0)
|
|
358
|
+
return selectedBookings;
|
|
359
|
+
nextStartGroup.forEach((booking) => {
|
|
360
|
+
booking.isNext = true;
|
|
361
|
+
});
|
|
298
362
|
return [...selectedBookings, ...nextStartGroup];
|
|
299
363
|
};
|
|
300
|
-
|
|
301
|
-
// active: current 处于 [startAt, endAt] 区间
|
|
302
|
-
const activeBookings = dayScopedBookings.filter(booking => {
|
|
364
|
+
const activeBookings = dayScopedBookings.filter((booking) => {
|
|
303
365
|
const startAt = this.toBookingDateTime(booking.start_date, booking.start_time);
|
|
304
366
|
const endAt = this.toBookingDateTime(booking.end_date, booking.end_time);
|
|
305
|
-
if (!startAt.isValid() || !endAt.isValid())
|
|
367
|
+
if (!startAt.isValid() || !endAt.isValid())
|
|
368
|
+
return false;
|
|
306
369
|
return this.isSameOrAfter(current, startAt) && this.isSameOrBefore(current, endAt);
|
|
307
370
|
});
|
|
308
|
-
if (activeBookings.length > 0)
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
const upcoming = dayScopedBookings.filter(booking => {
|
|
371
|
+
if (activeBookings.length > 0)
|
|
372
|
+
return appendNextStartGroupIfNeeded(activeBookings);
|
|
373
|
+
const timeoutOccupied = dayScopedBookings.filter(
|
|
374
|
+
(booking) => booking.status === "occupied" && booking.isTimeout
|
|
375
|
+
);
|
|
376
|
+
if (timeoutOccupied.length > 0)
|
|
377
|
+
return appendNextStartGroupIfNeeded(timeoutOccupied);
|
|
378
|
+
const upcoming = dayScopedBookings.filter((booking) => {
|
|
316
379
|
const startAt = this.toBookingDateTime(booking.start_date, booking.start_time);
|
|
317
|
-
return startAt.isValid() && startAt.isAfter(current) && startAt.isSame(current,
|
|
380
|
+
return startAt.isValid() && startAt.isAfter(current) && startAt.isSame(current, "day");
|
|
318
381
|
});
|
|
319
382
|
if (upcoming.length > 0) {
|
|
320
383
|
const firstStartAt = this.toBookingDateTime(upcoming[0].start_date, upcoming[0].start_time).valueOf();
|
|
321
|
-
const upcomingStartGroup = upcoming.filter(booking => {
|
|
384
|
+
const upcomingStartGroup = upcoming.filter((booking) => {
|
|
322
385
|
const startAt = this.toBookingDateTime(booking.start_date, booking.start_time);
|
|
323
386
|
return startAt.valueOf() === firstStartAt;
|
|
324
387
|
});
|
|
325
388
|
return appendNextStartGroupIfNeeded(upcomingStartGroup);
|
|
326
389
|
}
|
|
327
|
-
|
|
328
|
-
// fallback: 全部是过去且非 timeout 的场景,保留末条便于前端兜底展示
|
|
329
390
|
const fallback = dayScopedBookings[dayScopedBookings.length - 1];
|
|
330
391
|
return fallback ? [fallback] : [];
|
|
331
392
|
}
|
|
332
|
-
|
|
333
393
|
/**
|
|
334
|
-
*
|
|
335
|
-
* -
|
|
336
|
-
* -
|
|
394
|
+
* 计算 booking 在 current 时刻的执行进度百分比(0-100)。
|
|
395
|
+
* - startAt/endAt 非法或 totalMinutes <= 0 返回 0
|
|
396
|
+
* - current 早于 startAt 返回 0,晚于 endAt 返回 100
|
|
337
397
|
*/
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
398
|
+
calcProgressPercent(current, startAt, endAt) {
|
|
399
|
+
if (!startAt.isValid() || !endAt.isValid())
|
|
400
|
+
return 0;
|
|
401
|
+
const totalMinutes = endAt.diff(startAt, "minute");
|
|
402
|
+
if (totalMinutes <= 0)
|
|
403
|
+
return 0;
|
|
404
|
+
const elapsedMinutes = current.diff(startAt, "minute");
|
|
405
|
+
if (elapsedMinutes <= 0)
|
|
406
|
+
return 0;
|
|
407
|
+
if (elapsedMinutes >= totalMinutes)
|
|
408
|
+
return 100;
|
|
409
|
+
return Math.floor(elapsedMinutes / totalMinutes * 100);
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* 标准化单条 booking 的分发入口:
|
|
413
|
+
* - 统一过滤 rejected / cancelled(视为没来过)
|
|
414
|
+
* - current === deviceCurrent 走实时分支(信任 appointment_status)
|
|
415
|
+
* - 否则走快照分支(纯时间窗判定,忽略 appointment_status 的 arrived/started/completed 差异)
|
|
416
|
+
*/
|
|
417
|
+
normalizeMatchedBooking(current, deviceCurrent, booking, options = {}) {
|
|
418
|
+
const appointmentStatus = this.getBookingAppointmentStatus(booking);
|
|
419
|
+
if (appointmentStatus === "rejected" || appointmentStatus === "cancelled")
|
|
341
420
|
return null;
|
|
421
|
+
const startAt = this.toBookingDateTime(booking.start_date, booking.start_time);
|
|
422
|
+
const endAt = this.toBookingDateTime(booking.end_date, booking.end_time);
|
|
423
|
+
if (appointmentStatus === "completed" && options.includeCompleted) {
|
|
424
|
+
return this.buildCompletedBooking(current, booking, startAt, endAt);
|
|
425
|
+
}
|
|
426
|
+
if (current.isSame(deviceCurrent)) {
|
|
427
|
+
return this.buildRealtimeBooking(current, booking, appointmentStatus, startAt, endAt);
|
|
342
428
|
}
|
|
429
|
+
return this.buildSnapshotBooking(current, booking, appointmentStatus, startAt, endAt);
|
|
430
|
+
}
|
|
431
|
+
normalizeResourceBookings(current, deviceCurrent, bookingList, options = {}) {
|
|
432
|
+
const normalizedBookings = bookingList.map((booking) => this.normalizeMatchedBooking(current, deviceCurrent, booking, options)).filter((booking) => Boolean(booking)).filter((booking) => booking.status);
|
|
433
|
+
return this.sortMatchedBookings(normalizedBookings);
|
|
434
|
+
}
|
|
435
|
+
buildCompletedBooking(current, booking, startAt, endAt) {
|
|
436
|
+
if (!startAt.isValid() || !endAt.isValid())
|
|
437
|
+
return null;
|
|
438
|
+
if (current.isBefore(startAt)) {
|
|
439
|
+
return {
|
|
440
|
+
...booking,
|
|
441
|
+
status: "reserved",
|
|
442
|
+
isTimeout: false,
|
|
443
|
+
timeoutTime: void 0,
|
|
444
|
+
progressPercent: 0,
|
|
445
|
+
lateTime: void 0,
|
|
446
|
+
reserved_status: "not_arrived",
|
|
447
|
+
remainingReserveTime: Math.max(startAt.diff(current, "minute"), 0)
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
return {
|
|
451
|
+
...booking,
|
|
452
|
+
status: "occupied",
|
|
453
|
+
isTimeout: false,
|
|
454
|
+
timeoutTime: void 0,
|
|
455
|
+
progressPercent: this.isSameOrAfter(current, endAt) ? 100 : this.calcProgressPercent(current, startAt, endAt),
|
|
456
|
+
lateTime: void 0,
|
|
457
|
+
reserved_status: void 0,
|
|
458
|
+
remainingReserveTime: void 0
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* 实时模式(current === deviceCurrent):信任 appointment_status
|
|
463
|
+
* - 过滤 new / completed(实时视角下视为非活跃数据)
|
|
464
|
+
* - status 由 getBookingStatus 映射
|
|
465
|
+
* - occupied 且 current > endAt 标记 isTimeout + timeoutTime
|
|
466
|
+
* - reserved 且 current < startAt 标记 not_arrived,否则标记 late
|
|
467
|
+
*/
|
|
468
|
+
buildRealtimeBooking(current, booking, appointmentStatus, startAt, endAt) {
|
|
469
|
+
if (appointmentStatus === "new" || appointmentStatus === "completed")
|
|
470
|
+
return null;
|
|
343
471
|
const bookingStatus = this.getBookingStatus(appointmentStatus);
|
|
344
|
-
const
|
|
345
|
-
const
|
|
346
|
-
const
|
|
347
|
-
const timeoutTime = isTimeout ? current.diff(endAt, 'minute') : undefined;
|
|
348
|
-
const progressPercent = (() => {
|
|
349
|
-
if (bookingStatus !== 'occupied') return 0;
|
|
350
|
-
if (!startAt.isValid() || !endAt.isValid()) return 0;
|
|
351
|
-
const totalMinutes = endAt.diff(startAt, 'minute');
|
|
352
|
-
if (totalMinutes <= 0) return 0;
|
|
353
|
-
const elapsedMinutes = current.diff(startAt, 'minute');
|
|
354
|
-
if (elapsedMinutes <= 0) return 0;
|
|
355
|
-
if (elapsedMinutes >= totalMinutes) return 100;
|
|
356
|
-
return Math.floor(elapsedMinutes / totalMinutes * 100);
|
|
357
|
-
})();
|
|
472
|
+
const isTimeout = bookingStatus === "occupied" && endAt.isValid() && current.isAfter(endAt);
|
|
473
|
+
const timeoutTime = isTimeout ? current.diff(endAt, "minute") : void 0;
|
|
474
|
+
const progressPercent = bookingStatus === "occupied" ? this.calcProgressPercent(current, startAt, endAt) : 0;
|
|
358
475
|
let reservedStatus;
|
|
359
476
|
let lateTime;
|
|
360
477
|
let remainingReserveTime;
|
|
361
|
-
if (bookingStatus ===
|
|
478
|
+
if (bookingStatus === "reserved" && startAt.isValid()) {
|
|
362
479
|
if (current.isBefore(startAt)) {
|
|
363
|
-
reservedStatus =
|
|
364
|
-
remainingReserveTime = startAt.diff(current,
|
|
480
|
+
reservedStatus = "not_arrived";
|
|
481
|
+
remainingReserveTime = startAt.diff(current, "minute");
|
|
365
482
|
} else {
|
|
366
|
-
reservedStatus =
|
|
367
|
-
lateTime = Math.max(current.diff(startAt,
|
|
483
|
+
reservedStatus = "late";
|
|
484
|
+
lateTime = Math.max(current.diff(startAt, "minute"), 0);
|
|
368
485
|
}
|
|
369
486
|
}
|
|
370
487
|
return {
|
|
@@ -378,57 +495,200 @@ class SalesImpl extends _BaseModule.BaseModule {
|
|
|
378
495
|
remainingReserveTime
|
|
379
496
|
};
|
|
380
497
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
498
|
+
/**
|
|
499
|
+
* 快照模式(current !== deviceCurrent,过去或未来):忽略 appointment_status
|
|
500
|
+
* 的实时态差异,仅按 booking 时间窗判定,为 current 提供时间点快照视图。
|
|
501
|
+
*
|
|
502
|
+
* - new:视作尚未成为真实预约,过滤
|
|
503
|
+
* - locked:保留 status=locked,不计算 timeout/late/progress
|
|
504
|
+
* - 其他非终态:
|
|
505
|
+
* - startAt/endAt 非法 → 过滤
|
|
506
|
+
* - current > endAt → 过滤(已结束,不入池)
|
|
507
|
+
* - current ∈ [startAt, endAt] → occupied,附带 progressPercent
|
|
508
|
+
* - current < startAt → reserved + not_arrived,附带 remainingReserveTime
|
|
509
|
+
*
|
|
510
|
+
* 快照模式下 isTimeout 恒为 false,lateTime / timeoutTime 始终置空。
|
|
511
|
+
*/
|
|
512
|
+
buildSnapshotBooking(current, booking, appointmentStatus, startAt, endAt) {
|
|
513
|
+
if (appointmentStatus === "new")
|
|
514
|
+
return null;
|
|
515
|
+
if (appointmentStatus === "locked") {
|
|
516
|
+
return {
|
|
517
|
+
...booking,
|
|
518
|
+
status: "locked",
|
|
519
|
+
isTimeout: false,
|
|
520
|
+
timeoutTime: void 0,
|
|
521
|
+
progressPercent: 0,
|
|
522
|
+
lateTime: void 0,
|
|
523
|
+
reserved_status: void 0,
|
|
524
|
+
remainingReserveTime: void 0
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
if (!startAt.isValid() || !endAt.isValid())
|
|
528
|
+
return null;
|
|
529
|
+
if (current.isAfter(endAt))
|
|
530
|
+
return null;
|
|
531
|
+
if (this.isSameOrAfter(current, startAt) && this.isSameOrBefore(current, endAt)) {
|
|
532
|
+
return {
|
|
533
|
+
...booking,
|
|
534
|
+
status: "occupied",
|
|
535
|
+
isTimeout: false,
|
|
536
|
+
timeoutTime: void 0,
|
|
537
|
+
progressPercent: this.calcProgressPercent(current, startAt, endAt),
|
|
538
|
+
lateTime: void 0,
|
|
539
|
+
reserved_status: void 0,
|
|
540
|
+
remainingReserveTime: void 0
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
return {
|
|
544
|
+
...booking,
|
|
545
|
+
status: "reserved",
|
|
546
|
+
isTimeout: false,
|
|
547
|
+
timeoutTime: void 0,
|
|
548
|
+
progressPercent: 0,
|
|
549
|
+
lateTime: void 0,
|
|
550
|
+
reserved_status: "not_arrived",
|
|
551
|
+
remainingReserveTime: Math.max(startAt.diff(current, "minute"), 0)
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
async getResourceBookingList(currentTime, bookingList = [], deviceTime = currentTime) {
|
|
555
|
+
var _a;
|
|
556
|
+
const current = (0, import_dayjs.default)(currentTime);
|
|
557
|
+
if (!current.isValid())
|
|
558
|
+
return [];
|
|
559
|
+
const deviceCurrent = (0, import_dayjs.default)(deviceTime);
|
|
560
|
+
if (!deviceCurrent.isValid())
|
|
561
|
+
return [];
|
|
562
|
+
const resourceResponse = await this.request.get(
|
|
563
|
+
"/shop/form/resource/page",
|
|
564
|
+
{ skip: 1, num: 999 },
|
|
565
|
+
// @ts-ignore
|
|
566
|
+
{ osServer: true, isShopApi: true }
|
|
567
|
+
);
|
|
568
|
+
const resourceList = ((_a = resourceResponse == null ? void 0 : resourceResponse.data) == null ? void 0 : _a.list) ?? [];
|
|
569
|
+
if (!Array.isArray(resourceList) || resourceList.length === 0)
|
|
570
|
+
return [];
|
|
571
|
+
const normalizedBookings = this.normalizeResourceBookings(current, deviceCurrent, bookingList);
|
|
572
|
+
const rawBookingMap = this.groupBookingsByResource(bookingList);
|
|
573
|
+
const bookingMap = this.groupBookingsByResource(normalizedBookings);
|
|
574
|
+
const list = resourceList.map((resource) => {
|
|
422
575
|
const resourceId = this.getResourceId(resource);
|
|
576
|
+
const rawMatchedBookings = rawBookingMap.get(String(resourceId)) || [];
|
|
423
577
|
const matchedBookings = bookingMap.get(String(resourceId)) || [];
|
|
578
|
+
const statsBookings = rawMatchedBookings.filter((booking) => this.isBookingIncludedInStats(booking));
|
|
579
|
+
const orderCount = this.countBookingOrders(statsBookings);
|
|
580
|
+
const bookingCount = statsBookings.length;
|
|
581
|
+
const compeleteBookingCount = this.countCompletedBookings(statsBookings);
|
|
424
582
|
const bookings = this.pickBookingsForCurrentPoint(current, matchedBookings);
|
|
425
583
|
return {
|
|
426
584
|
...resource,
|
|
427
585
|
resource_id: resourceId,
|
|
586
|
+
orderCount,
|
|
587
|
+
bookingCount,
|
|
588
|
+
compeleteBookingCount,
|
|
428
589
|
bookings
|
|
429
590
|
};
|
|
430
591
|
});
|
|
592
|
+
this.logger.addLog({
|
|
593
|
+
type: "info",
|
|
594
|
+
title: "getResourceBookingList",
|
|
595
|
+
metadata: {
|
|
596
|
+
currentTime,
|
|
597
|
+
bookingList: bookingList == null ? void 0 : bookingList.length,
|
|
598
|
+
deviceTime,
|
|
599
|
+
list: list == null ? void 0 : list.length
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
return list;
|
|
431
603
|
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
604
|
+
async getResourceBookingItem(params) {
|
|
605
|
+
var _a, _b;
|
|
606
|
+
const current = (0, import_dayjs.default)(params.currentTime);
|
|
607
|
+
if (!current.isValid())
|
|
608
|
+
return null;
|
|
609
|
+
const deviceCurrent = (0, import_dayjs.default)(params.deviceTime || params.currentTime);
|
|
610
|
+
if (!deviceCurrent.isValid())
|
|
611
|
+
return null;
|
|
612
|
+
const resourceResponse = await this.request.get(
|
|
613
|
+
"/shop/form/resource/page",
|
|
614
|
+
{ skip: 1, num: 999 },
|
|
615
|
+
// @ts-ignore
|
|
616
|
+
{ osServer: true, isShopApi: true }
|
|
617
|
+
);
|
|
618
|
+
const resourceList = ((_a = resourceResponse == null ? void 0 : resourceResponse.data) == null ? void 0 : _a.list) ?? [];
|
|
619
|
+
if (!Array.isArray(resourceList) || resourceList.length === 0)
|
|
620
|
+
return null;
|
|
621
|
+
const targetResource = resourceList.find(
|
|
622
|
+
(resource) => String(this.getResourceId(resource)) === String(params.resourceId)
|
|
623
|
+
);
|
|
624
|
+
if (!targetResource)
|
|
625
|
+
return null;
|
|
626
|
+
const resourceId = this.getResourceId(targetResource);
|
|
627
|
+
const matchedBookingList = params.bookingList.filter(
|
|
628
|
+
(booking) => this.isBookingMatchedResource(booking, resourceId)
|
|
629
|
+
);
|
|
630
|
+
const statsBookingList = matchedBookingList.filter((booking) => this.isBookingIncludedInStats(booking));
|
|
631
|
+
const completedBookingList = matchedBookingList.filter(
|
|
632
|
+
(booking) => this.getBookingAppointmentStatus(booking) === "completed"
|
|
633
|
+
);
|
|
634
|
+
const unpaidBookingList = matchedBookingList.filter(
|
|
635
|
+
(booking) => this.getBookingOrderPaymentStatus(booking) === "unpaid" || this.getBookingOrderPaymentStatus(booking) === "payment_processing"
|
|
636
|
+
);
|
|
637
|
+
const bookings = this.pickBookingsForCurrentPoint(
|
|
638
|
+
current,
|
|
639
|
+
this.normalizeResourceBookings(current, deviceCurrent, matchedBookingList)
|
|
640
|
+
);
|
|
641
|
+
const completedBookings = completedBookingList.map((booking) => {
|
|
642
|
+
return {
|
|
643
|
+
...booking,
|
|
644
|
+
status: "compelete",
|
|
645
|
+
isTimeout: false,
|
|
646
|
+
timeoutTime: void 0,
|
|
647
|
+
progressPercent: 100,
|
|
648
|
+
lateTime: void 0,
|
|
649
|
+
reserved_status: void 0,
|
|
650
|
+
remainingReserveTime: void 0
|
|
651
|
+
};
|
|
652
|
+
});
|
|
653
|
+
const unpaidBookings = this.pickBookingsForCurrentPoint(
|
|
654
|
+
current,
|
|
655
|
+
this.normalizeResourceBookings(current, deviceCurrent, unpaidBookingList)
|
|
656
|
+
);
|
|
657
|
+
const orderCount = this.countBookingOrders(statsBookingList);
|
|
658
|
+
const bookingCount = statsBookingList.length;
|
|
659
|
+
const compeleteBookingCount = this.countCompletedBookings(statsBookingList);
|
|
660
|
+
this.logger.addLog({
|
|
661
|
+
type: "info",
|
|
662
|
+
title: "getResourceBookingItem",
|
|
663
|
+
metadata: {
|
|
664
|
+
currentTime: params.currentTime,
|
|
665
|
+
deviceTime: params.deviceTime || params.currentTime,
|
|
666
|
+
resourceId,
|
|
667
|
+
bookingList: (_b = params.bookingList) == null ? void 0 : _b.length,
|
|
668
|
+
bookings: bookings.length,
|
|
669
|
+
completedBookings: completedBookings.length,
|
|
670
|
+
unpaidBookings: unpaidBookings.length,
|
|
671
|
+
orderCount,
|
|
672
|
+
bookingCount,
|
|
673
|
+
compeleteBookingCount
|
|
674
|
+
}
|
|
675
|
+
});
|
|
676
|
+
return {
|
|
677
|
+
...targetResource,
|
|
678
|
+
resource_id: resourceId,
|
|
679
|
+
orderCount,
|
|
680
|
+
bookingCount,
|
|
681
|
+
compeleteBookingCount,
|
|
682
|
+
bookings,
|
|
683
|
+
completedBookings,
|
|
684
|
+
unpaidBookings
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
};
|
|
688
|
+
var Sales_default = SalesImpl;
|
|
689
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
690
|
+
0 && (module.exports = {
|
|
691
|
+
Sales,
|
|
692
|
+
SalesImpl,
|
|
693
|
+
...require("./types")
|
|
694
|
+
});
|