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