@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,51 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
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 });
|
|
8
10
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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/VenueBooking/index.ts
|
|
31
|
+
var VenueBooking_exports = {};
|
|
32
|
+
__export(VenueBooking_exports, {
|
|
33
|
+
VenueBookingImpl: () => VenueBookingImpl
|
|
22
34
|
});
|
|
23
|
-
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
|
|
35
|
+
module.exports = __toCommonJS(VenueBooking_exports);
|
|
36
|
+
var import_BaseSales = require("../BaseSales");
|
|
37
|
+
var import_types = require("./types");
|
|
38
|
+
var import_utils = require("./utils");
|
|
39
|
+
var import_types2 = require("../BookingByStep/types");
|
|
40
|
+
var import_ProductList = require("../../modules/ProductList");
|
|
41
|
+
var import_Date = require("../../modules/Date");
|
|
42
|
+
var import_Schedule = require("../../modules/Schedule");
|
|
43
|
+
var import_utils2 = require("../../modules/Schedule/utils");
|
|
44
|
+
var import_Quotation = require("../../modules/Quotation");
|
|
45
|
+
var import_OpenData = require("../../modules/OpenData");
|
|
46
|
+
var import_types3 = require("../../modules/Account/types");
|
|
47
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
48
|
+
var import_itemRule = require("../../model/strategy/adapter/itemRule");
|
|
49
|
+
var import_resource = require("./utils/resource");
|
|
50
|
+
var import_timeSlot = require("./utils/timeSlot");
|
|
51
|
+
var import_dateSummary = require("./utils/dateSummary");
|
|
52
|
+
var import_slotMerge = require("./utils/slotMerge");
|
|
53
|
+
var import_utils3 = require("../../modules/Order/utils");
|
|
54
|
+
var import_Order = require("../../modules/Order");
|
|
55
|
+
var import_types4 = require("../RegisterAndLogin/types");
|
|
56
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
57
|
+
var import_Holder = require("../../modules/Holder");
|
|
58
|
+
var import_utils4 = require("../../modules/Holder/utils");
|
|
59
|
+
__reExport(VenueBooking_exports, require("./types"), module.exports);
|
|
60
|
+
var OPEN_DATA_SECTION_CODES = [
|
|
61
|
+
"basic",
|
|
62
|
+
"fulfillment",
|
|
63
|
+
"reservation",
|
|
64
|
+
"sale",
|
|
65
|
+
"menu",
|
|
66
|
+
"availability",
|
|
67
|
+
"workflow",
|
|
68
|
+
"checkout"
|
|
69
|
+
];
|
|
47
70
|
function cloneCustomDepositData(customDepositData) {
|
|
48
|
-
if (!customDepositData || typeof customDepositData !==
|
|
71
|
+
if (!customDepositData || typeof customDepositData !== "object")
|
|
72
|
+
return void 0;
|
|
49
73
|
return {
|
|
50
74
|
...customDepositData,
|
|
51
75
|
self_deposit_policy_ids: Array.isArray(customDepositData.self_deposit_policy_ids) ? [...customDepositData.self_deposit_policy_ids] : [],
|
|
@@ -53,74 +77,69 @@ function cloneCustomDepositData(customDepositData) {
|
|
|
53
77
|
deposit_policy_data: Array.isArray(customDepositData.deposit_policy_data) ? [...customDepositData.deposit_policy_data] : []
|
|
54
78
|
};
|
|
55
79
|
}
|
|
56
|
-
class
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
customerLoginRefreshIdInFlight = null;
|
|
93
|
-
/** 最近一次确认登录的客户;登录事件与 user 插件更新之间可能存在时序差。 */
|
|
94
|
-
smartPricingCustomerId;
|
|
95
|
-
loadAllProductsInFlight = null;
|
|
96
|
-
productsLoaded = false;
|
|
97
|
-
loadOpenDataConfigInFlight = null;
|
|
98
|
-
static OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
|
|
99
|
-
/** 按日期缓存 slot 智能定价 Map,避免同周重复 resolveProducts */
|
|
100
|
-
slotPriceMapCache = new Map();
|
|
101
|
-
/** loadProducts 后缓存的全量商品(venue + addon),供分段算价复用 */
|
|
102
|
-
smartPricingProductCatalog = [];
|
|
103
|
-
static PISELL1_LOGIN_SUCCESS = 'pisell1.login.success';
|
|
80
|
+
var _VenueBookingImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
81
|
+
constructor(name, version) {
|
|
82
|
+
super(name, version);
|
|
83
|
+
this.defaultName = "venueBooking";
|
|
84
|
+
this.defaultVersion = "1.0.0";
|
|
85
|
+
this.isSolution = true;
|
|
86
|
+
this.initializeOptions = {};
|
|
87
|
+
this.store = {
|
|
88
|
+
entryContext: null,
|
|
89
|
+
status: "idle",
|
|
90
|
+
flow: {},
|
|
91
|
+
error: null,
|
|
92
|
+
products: void 0,
|
|
93
|
+
rawResourceData: [],
|
|
94
|
+
slotConfig: { ...import_types.DEFAULT_SLOT_CONFIG },
|
|
95
|
+
itemRuleQuantityLimits: [],
|
|
96
|
+
cartValidation: {
|
|
97
|
+
passed: null,
|
|
98
|
+
failures: []
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
this.otherParams = {};
|
|
102
|
+
this.baseSlotConfig = { ...import_types.DEFAULT_SLOT_CONFIG };
|
|
103
|
+
this.itemRuleEvaluator = new import_itemRule.ItemRuleEvaluator();
|
|
104
|
+
this.itemRuleConfigs = [];
|
|
105
|
+
this.itemRuleConfigsPromise = null;
|
|
106
|
+
this.itemRulePrefillApplied = false;
|
|
107
|
+
this.itemRuleRuntimeConfig = {};
|
|
108
|
+
this.resourceProductMap = /* @__PURE__ */ new Map();
|
|
109
|
+
this.loginEffectDisposers = [];
|
|
110
|
+
this.customerLoginRefreshInFlight = null;
|
|
111
|
+
this.customerLoginRefreshIdInFlight = null;
|
|
112
|
+
this.loadAllProductsInFlight = null;
|
|
113
|
+
this.productsLoaded = false;
|
|
114
|
+
this.loadOpenDataConfigInFlight = null;
|
|
115
|
+
}
|
|
104
116
|
getLoggerContext() {
|
|
105
117
|
return {
|
|
106
118
|
cacheId: this.cacheId,
|
|
107
119
|
solutionName: this.name,
|
|
108
|
-
moduleName:
|
|
120
|
+
moduleName: "venueBooking"
|
|
109
121
|
};
|
|
110
122
|
}
|
|
111
123
|
safeStringify(value) {
|
|
112
124
|
try {
|
|
113
125
|
return JSON.stringify(value);
|
|
114
126
|
} catch {
|
|
115
|
-
return
|
|
127
|
+
return void 0;
|
|
116
128
|
}
|
|
117
129
|
}
|
|
118
130
|
pickErrorMessage(error) {
|
|
119
|
-
|
|
131
|
+
var _a, _b, _c, _d;
|
|
132
|
+
const candidates = [
|
|
133
|
+
error.message,
|
|
134
|
+
(_a = error.data) == null ? void 0 : _a.message,
|
|
135
|
+
(_c = (_b = error.response) == null ? void 0 : _b.data) == null ? void 0 : _c.message,
|
|
136
|
+
(_d = error.error) == null ? void 0 : _d.message
|
|
137
|
+
];
|
|
120
138
|
for (const candidate of candidates) {
|
|
121
|
-
if (typeof candidate ===
|
|
139
|
+
if (typeof candidate === "string" && candidate.trim())
|
|
140
|
+
return candidate;
|
|
122
141
|
}
|
|
123
|
-
return
|
|
142
|
+
return void 0;
|
|
124
143
|
}
|
|
125
144
|
serializeError(error) {
|
|
126
145
|
if (error instanceof Error) {
|
|
@@ -130,23 +149,15 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
130
149
|
stack: error.stack
|
|
131
150
|
};
|
|
132
151
|
}
|
|
133
|
-
if (error && typeof error ===
|
|
152
|
+
if (error && typeof error === "object") {
|
|
134
153
|
const raw = error;
|
|
135
154
|
const message = this.pickErrorMessage(raw) || this.safeStringify(raw) || String(error);
|
|
136
155
|
return {
|
|
137
|
-
...
|
|
138
|
-
name: raw.name
|
|
139
|
-
} : {}),
|
|
156
|
+
...typeof raw.name === "string" ? { name: raw.name } : {},
|
|
140
157
|
message,
|
|
141
|
-
...
|
|
142
|
-
|
|
143
|
-
} : {}
|
|
144
|
-
...('status' in raw ? {
|
|
145
|
-
status: raw.status
|
|
146
|
-
} : {}),
|
|
147
|
-
...(this.safeStringify(raw) ? {
|
|
148
|
-
raw: this.safeStringify(raw)
|
|
149
|
-
} : {})
|
|
158
|
+
..."code" in raw ? { code: raw.code } : {},
|
|
159
|
+
..."status" in raw ? { status: raw.status } : {},
|
|
160
|
+
...this.safeStringify(raw) ? { raw: this.safeStringify(raw) } : {}
|
|
150
161
|
};
|
|
151
162
|
}
|
|
152
163
|
return {
|
|
@@ -156,19 +167,18 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
156
167
|
async addVenueBookingLog(params) {
|
|
157
168
|
const payload = {
|
|
158
169
|
cacheId: this.cacheId,
|
|
159
|
-
...
|
|
170
|
+
...params.payload || {}
|
|
160
171
|
};
|
|
161
172
|
const extra = {
|
|
162
|
-
...
|
|
173
|
+
...params.extra || {}
|
|
163
174
|
};
|
|
164
175
|
const logger = this.store.scanOrderLogger;
|
|
165
176
|
if (!logger) {
|
|
166
|
-
if ((params.level ||
|
|
167
|
-
console.error(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
} else {}
|
|
177
|
+
if ((params.level || "info") === "error") {
|
|
178
|
+
console.error("[VenueBooking][log-fallback]", params.title, { payload, extra });
|
|
179
|
+
} else {
|
|
180
|
+
console.log("[VenueBooking][log-fallback]", params.title, { payload, extra });
|
|
181
|
+
}
|
|
172
182
|
return;
|
|
173
183
|
}
|
|
174
184
|
await logger.addLog({
|
|
@@ -179,7 +189,7 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
179
189
|
}
|
|
180
190
|
logMethodStart(method, payload = {}) {
|
|
181
191
|
void this.addVenueBookingLog({
|
|
182
|
-
level:
|
|
192
|
+
level: "info",
|
|
183
193
|
title: `[VenueBooking] ${method} start`,
|
|
184
194
|
payload: {
|
|
185
195
|
method,
|
|
@@ -189,7 +199,7 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
189
199
|
}
|
|
190
200
|
logMethodSuccess(method, payload = {}) {
|
|
191
201
|
void this.addVenueBookingLog({
|
|
192
|
-
level:
|
|
202
|
+
level: "info",
|
|
193
203
|
title: `[VenueBooking] ${method} success`,
|
|
194
204
|
payload: {
|
|
195
205
|
method,
|
|
@@ -199,7 +209,7 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
199
209
|
}
|
|
200
210
|
logMethodError(method, error, payload = {}) {
|
|
201
211
|
void this.addVenueBookingLog({
|
|
202
|
-
level:
|
|
212
|
+
level: "error",
|
|
203
213
|
title: `[VenueBooking] ${method} failed`,
|
|
204
214
|
payload: {
|
|
205
215
|
method,
|
|
@@ -212,58 +222,145 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
212
222
|
await this.addVenueBookingLog({
|
|
213
223
|
...params,
|
|
214
224
|
payload: {
|
|
215
|
-
source:
|
|
216
|
-
...
|
|
225
|
+
source: "ui-bridge",
|
|
226
|
+
...params.payload || {}
|
|
217
227
|
}
|
|
218
228
|
});
|
|
219
229
|
}
|
|
220
|
-
|
|
221
|
-
|
|
230
|
+
getRegisteredModuleNames() {
|
|
231
|
+
return [
|
|
232
|
+
"scanOrderLogger",
|
|
233
|
+
"products",
|
|
234
|
+
"order",
|
|
235
|
+
"salesSummary",
|
|
236
|
+
"venueProducts",
|
|
237
|
+
"addonProducts",
|
|
238
|
+
"date",
|
|
239
|
+
"schedule",
|
|
240
|
+
"quotation",
|
|
241
|
+
"openData"
|
|
242
|
+
];
|
|
243
|
+
}
|
|
244
|
+
createSubModule(moduleName) {
|
|
245
|
+
switch (moduleName) {
|
|
246
|
+
case "scanOrderLogger":
|
|
247
|
+
return (0, import_types2.createModule)("scanOrderLogger", this.name);
|
|
248
|
+
case "venueProducts":
|
|
249
|
+
return new import_ProductList.ProductList(`${this.name}_venueProducts`);
|
|
250
|
+
case "addonProducts":
|
|
251
|
+
return new import_ProductList.ProductList(`${this.name}_addonProducts`);
|
|
252
|
+
case "date":
|
|
253
|
+
return new import_Date.DateModule(`${this.name}_date`);
|
|
254
|
+
case "openData":
|
|
255
|
+
return new import_OpenData.OpenDataModule(`${this.name}_openData`);
|
|
256
|
+
default:
|
|
257
|
+
return super.createSubModule(moduleName);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
attachProductOriginToTempOrder(tempOrder, productUid, origin) {
|
|
261
|
+
var _a, _b, _c;
|
|
262
|
+
if (!productUid || !origin)
|
|
263
|
+
return;
|
|
264
|
+
tempOrder._extend = {
|
|
265
|
+
...tempOrder._extend || {},
|
|
266
|
+
productsByUid: {
|
|
267
|
+
...((_a = tempOrder._extend) == null ? void 0 : _a.productsByUid) || {},
|
|
268
|
+
[productUid]: {
|
|
269
|
+
...((_c = (_b = tempOrder._extend) == null ? void 0 : _b.productsByUid) == null ? void 0 : _c[productUid]) || {},
|
|
270
|
+
origin
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
readProductOriginFromTempOrder(tempOrder, product) {
|
|
276
|
+
var _a, _b, _c, _d;
|
|
277
|
+
const uid = ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) || product.identity_key;
|
|
278
|
+
if (uid && ((_d = (_c = (_b = tempOrder._extend) == null ? void 0 : _b.productsByUid) == null ? void 0 : _c[uid]) == null ? void 0 : _d.origin)) {
|
|
279
|
+
return tempOrder._extend.productsByUid[uid].origin;
|
|
280
|
+
}
|
|
281
|
+
return product._origin;
|
|
282
|
+
}
|
|
283
|
+
normalizeVenueProductTitle(value) {
|
|
284
|
+
if (typeof value === "string") {
|
|
285
|
+
const text = value.trim();
|
|
286
|
+
return text ? { auto: text } : void 0;
|
|
287
|
+
}
|
|
288
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
289
|
+
return void 0;
|
|
290
|
+
const source = value;
|
|
291
|
+
const normalized = {};
|
|
292
|
+
Object.entries(source).forEach(([key, text]) => {
|
|
293
|
+
if (typeof text === "string")
|
|
294
|
+
normalized[key] = text;
|
|
295
|
+
});
|
|
296
|
+
if (!normalized.auto) {
|
|
297
|
+
const fallback = normalized.original || normalized.en || normalized["zh-CN"] || normalized["zh-HK"];
|
|
298
|
+
if (fallback)
|
|
299
|
+
normalized.auto = fallback;
|
|
300
|
+
}
|
|
301
|
+
return Object.values(normalized).some((text) => String(text || "").trim()) ? normalized : void 0;
|
|
222
302
|
}
|
|
223
303
|
normalizeCustomerId(value) {
|
|
224
304
|
const customerId = Number(value);
|
|
225
|
-
if (!Number.isFinite(customerId) || customerId <= 0)
|
|
305
|
+
if (!Number.isFinite(customerId) || customerId <= 0)
|
|
306
|
+
return null;
|
|
226
307
|
return customerId;
|
|
227
308
|
}
|
|
228
309
|
resolveCustomerIdFromLoginPayload(payload) {
|
|
229
|
-
|
|
310
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
311
|
+
const candidates = [
|
|
312
|
+
payload == null ? void 0 : payload.customerId,
|
|
313
|
+
payload == null ? void 0 : payload.customer_id,
|
|
314
|
+
payload == null ? void 0 : payload.id,
|
|
315
|
+
(_a = payload == null ? void 0 : payload.user) == null ? void 0 : _a.customerId,
|
|
316
|
+
(_b = payload == null ? void 0 : payload.user) == null ? void 0 : _b.customer_id,
|
|
317
|
+
(_c = payload == null ? void 0 : payload.user) == null ? void 0 : _c.id,
|
|
318
|
+
(_e = (_d = payload == null ? void 0 : payload.user) == null ? void 0 : _d._origin) == null ? void 0 : _e.customer_id,
|
|
319
|
+
(_f = payload == null ? void 0 : payload.account) == null ? void 0 : _f.customerId,
|
|
320
|
+
(_g = payload == null ? void 0 : payload.account) == null ? void 0 : _g.customer_id,
|
|
321
|
+
(_h = payload == null ? void 0 : payload.account) == null ? void 0 : _h.id,
|
|
322
|
+
(_i = payload == null ? void 0 : payload._origin) == null ? void 0 : _i.customer_id
|
|
323
|
+
];
|
|
230
324
|
for (const candidate of candidates) {
|
|
231
325
|
const customerId = this.normalizeCustomerId(candidate);
|
|
232
|
-
if (customerId)
|
|
326
|
+
if (customerId)
|
|
327
|
+
return customerId;
|
|
233
328
|
}
|
|
234
329
|
return null;
|
|
235
330
|
}
|
|
236
331
|
resolveHolderCustomerId() {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
332
|
+
var _a, _b;
|
|
333
|
+
const customer = JSON.parse(((_b = (_a = this.window) == null ? void 0 : _a.getLocalStorage) == null ? void 0 : _b.call(_a, "customer")) || "{}");
|
|
334
|
+
if (customer == null ? void 0 : customer.id)
|
|
335
|
+
return Number(customer.id);
|
|
336
|
+
return void 0;
|
|
240
337
|
}
|
|
241
|
-
|
|
242
338
|
/**
|
|
243
339
|
* 按商品 holder_config 预加载表单数据到 holderMap。
|
|
244
340
|
* appointment_booking 在加购时触发;venueBooking 在商品加载后预加载,避免 getHolderFormMap 为空。
|
|
245
341
|
*/
|
|
246
342
|
async preloadHolderForms(products) {
|
|
247
|
-
|
|
248
|
-
|
|
343
|
+
var _a, _b, _c, _d;
|
|
344
|
+
if (!this.store.holder || !products.length)
|
|
345
|
+
return;
|
|
346
|
+
const seenFormIds = /* @__PURE__ */ new Set();
|
|
249
347
|
for (const item of products) {
|
|
250
|
-
const holderConfig = (0,
|
|
251
|
-
if (!holderConfig)
|
|
252
|
-
|
|
253
|
-
|
|
348
|
+
const holderConfig = (0, import_utils4.getProductHolderConfig)((_a = item == null ? void 0 : item._origin) == null ? void 0 : _a.product);
|
|
349
|
+
if (!holderConfig)
|
|
350
|
+
continue;
|
|
351
|
+
const formId = (0, import_utils4.getFormIdFromHolderConfig)(holderConfig);
|
|
352
|
+
if (seenFormIds.has(formId))
|
|
353
|
+
continue;
|
|
254
354
|
seenFormIds.add(formId);
|
|
255
355
|
try {
|
|
256
356
|
await this.store.holder.ensureFormByProduct({
|
|
257
|
-
product: item
|
|
357
|
+
product: ((_b = item == null ? void 0 : item._origin) == null ? void 0 : _b.product) || {},
|
|
258
358
|
customer_id: this.resolveHolderCustomerId(),
|
|
259
|
-
shop_id: item
|
|
359
|
+
shop_id: (_d = (_c = item == null ? void 0 : item._origin) == null ? void 0 : _c.product) == null ? void 0 : _d.shop_id,
|
|
260
360
|
useCache: true
|
|
261
361
|
});
|
|
262
362
|
} catch (error) {
|
|
263
|
-
console.error(
|
|
264
|
-
formId,
|
|
265
|
-
error
|
|
266
|
-
});
|
|
363
|
+
console.error("[VenueBooking] 预加载 holder 表单失败", { formId, error });
|
|
267
364
|
}
|
|
268
365
|
}
|
|
269
366
|
}
|
|
@@ -274,30 +371,35 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
274
371
|
this.loginEffectDisposers = [];
|
|
275
372
|
}
|
|
276
373
|
registerLoginEffect(event, callback) {
|
|
277
|
-
|
|
278
|
-
|
|
374
|
+
var _a;
|
|
375
|
+
const effects = (_a = this.core) == null ? void 0 : _a.effects;
|
|
376
|
+
if (!(effects == null ? void 0 : effects.on))
|
|
377
|
+
return;
|
|
279
378
|
effects.on(event, callback);
|
|
280
379
|
this.loginEffectDisposers.push(() => {
|
|
281
|
-
if (typeof effects.off ===
|
|
380
|
+
if (typeof effects.off === "function") {
|
|
282
381
|
effects.off(event, callback);
|
|
283
382
|
}
|
|
284
383
|
});
|
|
285
384
|
}
|
|
286
385
|
registerCustomerLoginListeners() {
|
|
386
|
+
var _a, _b, _c, _d;
|
|
287
387
|
this.clearLoginEffectListeners();
|
|
288
|
-
const
|
|
388
|
+
const accountModule = (_a = this.core) == null ? void 0 : _a.getModule("account");
|
|
389
|
+
const registerAndLoginModule = (_b = this.core) == null ? void 0 : _b.getModule("registerAndLogin");
|
|
390
|
+
const currentAccount = ((_c = accountModule == null ? void 0 : accountModule.getCurrentAccount) == null ? void 0 : _c.call(accountModule)) || ((_d = accountModule == null ? void 0 : accountModule.getAccount) == null ? void 0 : _d.call(accountModule)) || null;
|
|
391
|
+
const createHandleLogin = (eventName) => async (payload) => {
|
|
289
392
|
const customerId = this.resolveCustomerIdFromLoginPayload(payload);
|
|
290
|
-
if (!customerId)
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
});
|
|
393
|
+
if (!customerId)
|
|
394
|
+
return;
|
|
395
|
+
await this.refreshOrderMarketingAfterLogin({ customerId });
|
|
294
396
|
};
|
|
295
|
-
this.registerLoginEffect(
|
|
296
|
-
this.registerLoginEffect(
|
|
297
|
-
this.registerLoginEffect(_types4.RegisterAndLoginHooks.onLoginSuccess, createHandleLogin());
|
|
397
|
+
this.registerLoginEffect(import_types3.AccountHooks.OnLogin, createHandleLogin(import_types3.AccountHooks.OnLogin));
|
|
398
|
+
this.registerLoginEffect(import_types4.RegisterAndLoginHooks.onLoginSuccess, createHandleLogin(import_types4.RegisterAndLoginHooks.onLoginSuccess));
|
|
298
399
|
}
|
|
299
400
|
async refreshOrderMarketingAfterLogin(params) {
|
|
300
|
-
if (!this.store.order)
|
|
401
|
+
if (!this.store.order)
|
|
402
|
+
throw new Error("order 模块未初始化");
|
|
301
403
|
if (this.customerLoginRefreshInFlight) {
|
|
302
404
|
if (this.customerLoginRefreshIdInFlight === params.customerId) {
|
|
303
405
|
await this.customerLoginRefreshInFlight;
|
|
@@ -307,14 +409,7 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
307
409
|
}
|
|
308
410
|
this.customerLoginRefreshIdInFlight = params.customerId;
|
|
309
411
|
const refreshTask = (async () => {
|
|
310
|
-
|
|
311
|
-
this.smartPricingCustomerId = params.customerId;
|
|
312
|
-
await this.store.order.loadDiscountConfig({
|
|
313
|
-
customerId: params.customerId
|
|
314
|
-
});
|
|
315
|
-
this.clearSlotPriceMapCache();
|
|
316
|
-
this.recalculateOrderPricesFromSmartPricing();
|
|
317
|
-
// 刷新 holder 表单数据
|
|
412
|
+
var _a;
|
|
318
413
|
if (this.store.holder) {
|
|
319
414
|
await this.store.holder.refreshAllFormRecords({
|
|
320
415
|
customer_id: params.customerId,
|
|
@@ -323,18 +418,17 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
323
418
|
}
|
|
324
419
|
if (this.store.quotation) {
|
|
325
420
|
await this.store.quotation.loadQuotations({
|
|
326
|
-
channel: this.otherParams
|
|
421
|
+
channel: (_a = this.otherParams) == null ? void 0 : _a.channel
|
|
327
422
|
});
|
|
328
423
|
}
|
|
329
|
-
|
|
330
|
-
|
|
424
|
+
this.recalculateOrderPricesFromQuotation();
|
|
425
|
+
await this.store.order.loadDiscountConfig({
|
|
426
|
+
customerId: params.customerId
|
|
331
427
|
});
|
|
428
|
+
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
332
429
|
this.store.order.persistTempOrder();
|
|
333
430
|
await this.refreshItemRuleQuantityLimits();
|
|
334
431
|
await this.refreshCartValidationPassed();
|
|
335
|
-
await this.core?.effects?.emit?.(_types.VenueBookingHooks.onSmartPricingUpdated, {
|
|
336
|
-
customerId: params.customerId
|
|
337
|
-
});
|
|
338
432
|
})();
|
|
339
433
|
this.customerLoginRefreshInFlight = refreshTask;
|
|
340
434
|
try {
|
|
@@ -349,28 +443,21 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
349
443
|
}
|
|
350
444
|
}
|
|
351
445
|
async initialize(core, options = {}) {
|
|
352
|
-
|
|
353
|
-
this.
|
|
354
|
-
this.
|
|
355
|
-
this.store =
|
|
356
|
-
|
|
357
|
-
...options.store
|
|
358
|
-
};
|
|
359
|
-
this.smartPricingCustomerId = undefined;
|
|
360
|
-
this.store.entryContext = options.otherParams?.entryContext || this.store.entryContext;
|
|
361
|
-
this.store.status = 'initializing';
|
|
446
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
447
|
+
this.logMethodStart("initialize");
|
|
448
|
+
this.store = { ...this.store, ...options.store };
|
|
449
|
+
this.store.entryContext = ((_a = options.otherParams) == null ? void 0 : _a.entryContext) || this.store.entryContext;
|
|
450
|
+
this.store.status = "initializing";
|
|
362
451
|
this.store.error = null;
|
|
363
452
|
this.store.rawResourceData = [];
|
|
364
453
|
this.baseSlotConfig = {
|
|
365
|
-
...
|
|
366
|
-
...(options.otherParams
|
|
367
|
-
};
|
|
368
|
-
this.store.slotConfig = {
|
|
369
|
-
...this.baseSlotConfig
|
|
454
|
+
...import_types.DEFAULT_SLOT_CONFIG,
|
|
455
|
+
...((_b = options.otherParams) == null ? void 0 : _b.slotConfig) || {}
|
|
370
456
|
};
|
|
457
|
+
this.store.slotConfig = { ...this.baseSlotConfig };
|
|
371
458
|
this.otherParams = options.otherParams || {};
|
|
372
|
-
this.cacheId = this.otherParams
|
|
373
|
-
this.itemRuleRuntimeConfig = this.otherParams
|
|
459
|
+
this.cacheId = (_c = this.otherParams) == null ? void 0 : _c.cacheId;
|
|
460
|
+
this.itemRuleRuntimeConfig = ((_d = this.otherParams) == null ? void 0 : _d.venueBookingItemRule) || ((_e = this.otherParams) == null ? void 0 : _e.itemRule) || {};
|
|
374
461
|
this.itemRuleConfigs = [];
|
|
375
462
|
this.itemRuleConfigsPromise = null;
|
|
376
463
|
this.itemRulePrefillApplied = false;
|
|
@@ -379,40 +466,49 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
379
466
|
passed: null,
|
|
380
467
|
failures: []
|
|
381
468
|
};
|
|
382
|
-
|
|
383
|
-
this.
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
469
|
+
await super.initialize(core, options);
|
|
470
|
+
if (this.store.scanOrderLogger) {
|
|
471
|
+
this.store.scanOrderLogger.setProvider(
|
|
472
|
+
((_f = this.otherParams) == null ? void 0 : _f.loggerProvider) || "feishu"
|
|
473
|
+
);
|
|
474
|
+
this.store.scanOrderLogger.setProviderConfig(
|
|
475
|
+
((_g = this.otherParams) == null ? void 0 : _g.loggerConfig) || {
|
|
476
|
+
feishu: {
|
|
477
|
+
webhook: "https://open.feishu.cn/open-apis/bot/v2/hook/8f069b14-9d39-4728-8f78-b56f393bfde8",
|
|
478
|
+
errorHook: "https://open.feishu.cn/open-apis/bot/v2/hook/bdefae5e-f233-4705-8688-946887d9543d"
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
);
|
|
482
|
+
this.store.scanOrderLogger.setContext(this.getLoggerContext());
|
|
391
483
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
484
|
+
const baseModules = [
|
|
485
|
+
"scanOrderLogger",
|
|
486
|
+
"products",
|
|
487
|
+
"order",
|
|
488
|
+
"salesSummary"
|
|
489
|
+
];
|
|
490
|
+
baseModules.forEach((step) => {
|
|
491
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
492
|
+
const targetModule = (0, import_types2.createModule)(step, this.name);
|
|
397
493
|
if (targetModule) {
|
|
398
494
|
this.store[step] = targetModule;
|
|
399
|
-
const initialState = step ===
|
|
400
|
-
summary: this.store.order
|
|
495
|
+
const initialState = step === "salesSummary" ? {
|
|
496
|
+
summary: ((_b2 = (_a2 = this.store.order) == null ? void 0 : _a2.getTempOrder()) == null ? void 0 : _b2.summary) || (0, import_utils.createEmptySummary)()
|
|
401
497
|
} : {};
|
|
402
|
-
const loggerProvider = this.otherParams
|
|
403
|
-
const loggerConfig = this.otherParams
|
|
404
|
-
feishu: {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
}
|
|
498
|
+
const loggerProvider = ((_c2 = this.otherParams) == null ? void 0 : _c2.loggerProvider) || "feishu";
|
|
499
|
+
const loggerConfig = ((_d2 = this.otherParams) == null ? void 0 : _d2.loggerConfig) || {
|
|
500
|
+
// feishu: {
|
|
501
|
+
// webhook: 'https://open.feishu.cn/open-apis/bot/v2/hook/8f069b14-9d39-4728-8f78-b56f393bfde8',
|
|
502
|
+
// errorHook: 'https://open.feishu.cn/open-apis/bot/v2/hook/bdefae5e-f233-4705-8688-946887d9543d',
|
|
503
|
+
// },
|
|
408
504
|
};
|
|
409
505
|
this.core.registerModule(targetModule, {
|
|
410
506
|
initialState,
|
|
411
507
|
otherParams: {
|
|
412
508
|
...this.otherParams,
|
|
413
509
|
fatherModule: this.name,
|
|
414
|
-
openCache: this.otherParams
|
|
415
|
-
cacheId: this.otherParams
|
|
510
|
+
openCache: ((_e2 = this.otherParams) == null ? void 0 : _e2.cacheId) ? true : false,
|
|
511
|
+
cacheId: (_f2 = this.otherParams) == null ? void 0 : _f2.cacheId,
|
|
416
512
|
salesSummaryModuleName: `${this.name}_salesSummary`,
|
|
417
513
|
provider: loggerProvider,
|
|
418
514
|
providerConfig: loggerConfig,
|
|
@@ -420,13 +516,11 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
420
516
|
}
|
|
421
517
|
});
|
|
422
518
|
} else {
|
|
423
|
-
this.logMethodError(
|
|
519
|
+
this.logMethodError("initialize", `module ${step} missing`);
|
|
424
520
|
throw new Error(`模块 ${step} 不存在`);
|
|
425
521
|
}
|
|
426
522
|
});
|
|
427
|
-
|
|
428
|
-
// 注册场地商品列表模块
|
|
429
|
-
const venueProductsModule = new _ProductList.ProductList(`${this.name}_venueProducts`);
|
|
523
|
+
const venueProductsModule = new import_ProductList.ProductList(`${this.name}_venueProducts`);
|
|
430
524
|
this.store.venueProducts = venueProductsModule;
|
|
431
525
|
this.core.registerModule(venueProductsModule, {
|
|
432
526
|
otherParams: {
|
|
@@ -434,9 +528,7 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
434
528
|
fatherModule: this.name
|
|
435
529
|
}
|
|
436
530
|
});
|
|
437
|
-
|
|
438
|
-
// 注册附加商品列表模块
|
|
439
|
-
const addonProductsModule = new _ProductList.ProductList(`${this.name}_addonProducts`);
|
|
531
|
+
const addonProductsModule = new import_ProductList.ProductList(`${this.name}_addonProducts`);
|
|
440
532
|
this.store.addonProducts = addonProductsModule;
|
|
441
533
|
this.core.registerModule(addonProductsModule, {
|
|
442
534
|
otherParams: {
|
|
@@ -444,9 +536,7 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
444
536
|
fatherModule: this.name
|
|
445
537
|
}
|
|
446
538
|
});
|
|
447
|
-
|
|
448
|
-
// 注册日期模块
|
|
449
|
-
const dateModule = new _Date.DateModule(`${this.name}_date`);
|
|
539
|
+
const dateModule = new import_Date.DateModule(`${this.name}_date`);
|
|
450
540
|
this.store.date = dateModule;
|
|
451
541
|
this.core.registerModule(dateModule, {
|
|
452
542
|
otherParams: {
|
|
@@ -455,9 +545,7 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
455
545
|
cacheId: this.cacheId
|
|
456
546
|
}
|
|
457
547
|
});
|
|
458
|
-
|
|
459
|
-
// 注册日程模块
|
|
460
|
-
const scheduleModule = new _Schedule.ScheduleModule(`${this.name}_schedule`);
|
|
548
|
+
const scheduleModule = new import_Schedule.ScheduleModule(`${this.name}_schedule`);
|
|
461
549
|
this.store.schedule = scheduleModule;
|
|
462
550
|
this.core.registerModule(scheduleModule, {
|
|
463
551
|
otherParams: {
|
|
@@ -465,9 +553,7 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
465
553
|
fatherModule: this.name
|
|
466
554
|
}
|
|
467
555
|
});
|
|
468
|
-
|
|
469
|
-
// 注册报价单模块
|
|
470
|
-
const quotationModule = new _Quotation.QuotationModule(`${this.name}_quotation`);
|
|
556
|
+
const quotationModule = new import_Quotation.QuotationModule(`${this.name}_quotation`);
|
|
471
557
|
this.store.quotation = quotationModule;
|
|
472
558
|
this.core.registerModule(quotationModule, {
|
|
473
559
|
otherParams: {
|
|
@@ -475,110 +561,109 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
475
561
|
fatherModule: this.name
|
|
476
562
|
}
|
|
477
563
|
});
|
|
478
|
-
|
|
479
|
-
// 注册 OpenData 配置模块
|
|
480
|
-
const openDataModule = new _OpenData.OpenDataModule(`${this.name}_openData`);
|
|
564
|
+
const openDataModule = new import_OpenData.OpenDataModule(`${this.name}_openData`);
|
|
481
565
|
this.store.openData = openDataModule;
|
|
482
566
|
this.core.registerModule(openDataModule, {
|
|
483
567
|
otherParams: {
|
|
484
568
|
...this.otherParams,
|
|
485
569
|
fatherModule: this.name,
|
|
486
|
-
openCache: !!this.otherParams
|
|
487
|
-
cacheId: this.otherParams
|
|
570
|
+
openCache: !!((_h = this.otherParams) == null ? void 0 : _h.cacheId),
|
|
571
|
+
cacheId: (_i = this.otherParams) == null ? void 0 : _i.cacheId
|
|
488
572
|
}
|
|
489
573
|
});
|
|
490
574
|
let holderCacheState;
|
|
491
|
-
if (this.otherParams
|
|
575
|
+
if ((_j = this.otherParams) == null ? void 0 : _j.cacheId) {
|
|
492
576
|
const sessionData = this.window.sessionStorage.getItem(this.name);
|
|
493
577
|
if (sessionData) {
|
|
494
578
|
try {
|
|
495
579
|
const data = JSON.parse(sessionData);
|
|
496
|
-
holderCacheState = data[this.otherParams.cacheId]
|
|
580
|
+
holderCacheState = (_k = data[this.otherParams.cacheId]) == null ? void 0 : _k[`${this.name}_holder`];
|
|
497
581
|
} catch {
|
|
498
|
-
// ignore invalid session cache
|
|
499
582
|
}
|
|
500
583
|
}
|
|
501
584
|
}
|
|
502
|
-
const holderModule = new
|
|
585
|
+
const holderModule = new import_Holder.HolderModule(`${this.name}_holder`);
|
|
503
586
|
this.store.holder = holderModule;
|
|
504
587
|
this.core.registerModule(holderModule, {
|
|
505
588
|
initialState: holderCacheState,
|
|
506
589
|
otherParams: {
|
|
507
590
|
...this.otherParams,
|
|
508
591
|
fatherModule: this.name,
|
|
509
|
-
openCache: !!this.otherParams
|
|
510
|
-
cacheId: this.otherParams
|
|
592
|
+
openCache: !!((_l = this.otherParams) == null ? void 0 : _l.cacheId),
|
|
593
|
+
cacheId: (_m = this.otherParams) == null ? void 0 : _m.cacheId
|
|
511
594
|
}
|
|
512
595
|
});
|
|
513
|
-
if (this.store.scanOrderLogger) {
|
|
514
|
-
this.store.scanOrderLogger.setContext(this.getLoggerContext());
|
|
515
|
-
}
|
|
516
596
|
this.registerCustomerLoginListeners();
|
|
597
|
+
console.log("[VenueBooking] 初始化开始");
|
|
517
598
|
try {
|
|
518
|
-
await this.store.order
|
|
519
|
-
|
|
520
|
-
});
|
|
521
|
-
this.store.order?.persistTempOrder();
|
|
599
|
+
await ((_n = this.store.order) == null ? void 0 : _n.recalculateSummary({ createIfMissing: false }));
|
|
600
|
+
(_o = this.store.order) == null ? void 0 : _o.persistTempOrder();
|
|
522
601
|
await this.loadRuntimeConfigs();
|
|
523
602
|
if (this.store.schedule) {
|
|
524
603
|
await this.store.schedule.loadAllSchedule();
|
|
604
|
+
this.injectScheduleResolverToQuotation();
|
|
605
|
+
(_q = this.store.quotation) == null ? void 0 : _q.loadQuotations({
|
|
606
|
+
channel: (_p = this.otherParams) == null ? void 0 : _p.channel
|
|
607
|
+
});
|
|
525
608
|
}
|
|
526
609
|
await this.refreshItemRuleQuantityLimits();
|
|
527
|
-
this.store.status =
|
|
528
|
-
|
|
610
|
+
this.store.status = "ready";
|
|
611
|
+
console.log("[VenueBooking] 初始化完成");
|
|
612
|
+
await this.core.effects.emit(import_types.VenueBookingHooks.onInited, {
|
|
529
613
|
status: this.store.status
|
|
530
614
|
});
|
|
531
|
-
this.logMethodSuccess(
|
|
615
|
+
this.logMethodSuccess("initialize", {
|
|
532
616
|
status: this.store.status
|
|
533
617
|
});
|
|
534
618
|
} catch (error) {
|
|
535
|
-
this.store.status =
|
|
536
|
-
this.store.error = error instanceof Error ? error.message :
|
|
537
|
-
console.error(
|
|
538
|
-
this.logMethodError(
|
|
619
|
+
this.store.status = "error";
|
|
620
|
+
this.store.error = error instanceof Error ? error.message : "初始化失败";
|
|
621
|
+
console.error("[VenueBooking] 初始化失败", error);
|
|
622
|
+
this.logMethodError("initialize", error, {
|
|
539
623
|
status: this.store.status
|
|
540
624
|
});
|
|
541
625
|
throw error;
|
|
542
626
|
}
|
|
543
627
|
}
|
|
544
628
|
async destroy() {
|
|
545
|
-
this.logMethodStart(
|
|
629
|
+
this.logMethodStart("destroy");
|
|
546
630
|
this.clearLoginEffectListeners();
|
|
547
|
-
await this.core.effects.emit(
|
|
548
|
-
|
|
631
|
+
await this.core.effects.emit(import_types.VenueBookingHooks.onDestroy, {});
|
|
632
|
+
console.log("[VenueBooking] 已销毁");
|
|
633
|
+
this.logMethodSuccess("destroy");
|
|
549
634
|
}
|
|
550
635
|
async retryInit() {
|
|
551
|
-
this.logMethodStart(
|
|
552
|
-
|
|
636
|
+
this.logMethodStart("retryInit");
|
|
637
|
+
console.log("[VenueBooking] retryInit 调用");
|
|
638
|
+
await this.core.effects.emit(import_types.VenueBookingHooks.onRetryInit, {});
|
|
553
639
|
try {
|
|
554
640
|
await this.initialize(this.core, this.initializeOptions);
|
|
555
|
-
this.logMethodSuccess(
|
|
641
|
+
this.logMethodSuccess("retryInit");
|
|
556
642
|
} catch (error) {
|
|
557
|
-
this.logMethodError(
|
|
643
|
+
this.logMethodError("retryInit", error);
|
|
558
644
|
throw error;
|
|
559
645
|
}
|
|
560
646
|
}
|
|
561
647
|
async refresh() {
|
|
562
|
-
this.logMethodStart(
|
|
648
|
+
this.logMethodStart("refresh");
|
|
649
|
+
console.log("[VenueBooking] refresh 调用");
|
|
563
650
|
try {
|
|
564
|
-
this.store.status =
|
|
651
|
+
this.store.status = "initializing";
|
|
565
652
|
await this.loadRuntimeConfigs();
|
|
566
653
|
await this.refreshItemRuleQuantityLimits();
|
|
567
|
-
this.store.status =
|
|
568
|
-
await this.core.effects.emit(
|
|
654
|
+
this.store.status = "ready";
|
|
655
|
+
await this.core.effects.emit(import_types.VenueBookingHooks.onRefresh, {
|
|
569
656
|
status: this.store.status
|
|
570
657
|
});
|
|
571
|
-
this.logMethodSuccess(
|
|
658
|
+
this.logMethodSuccess("refresh", {
|
|
572
659
|
status: this.store.status
|
|
573
660
|
});
|
|
574
661
|
} catch (error) {
|
|
575
|
-
this.logMethodError(
|
|
662
|
+
this.logMethodError("refresh", error);
|
|
576
663
|
throw error;
|
|
577
664
|
}
|
|
578
665
|
}
|
|
579
|
-
|
|
580
666
|
// ─── 状态查询 ───
|
|
581
|
-
|
|
582
667
|
getStatus() {
|
|
583
668
|
return this.store.status;
|
|
584
669
|
}
|
|
@@ -589,157 +674,65 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
589
674
|
return this.store.itemRuleQuantityLimits || [];
|
|
590
675
|
}
|
|
591
676
|
getCartValidationPassed() {
|
|
592
|
-
|
|
677
|
+
var _a;
|
|
678
|
+
return ((_a = this.store.cartValidation) == null ? void 0 : _a.passed) ?? null;
|
|
593
679
|
}
|
|
594
680
|
getCartValidation() {
|
|
595
|
-
return this.store.cartValidation || {
|
|
596
|
-
passed: null,
|
|
597
|
-
failures: []
|
|
598
|
-
};
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
/** 清除 slot 价格分段缓存(商品重载 / 登录后 customerId 变化时调用) */
|
|
602
|
-
clearSlotPriceMapCache() {
|
|
603
|
-
this.slotPriceMapCache.clear();
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
/** 读取当前登录 customerId */
|
|
607
|
-
resolveCustomerIdForSmartPricing() {
|
|
608
|
-
if (this.smartPricingCustomerId) return this.smartPricingCustomerId;
|
|
609
|
-
try {
|
|
610
|
-
const userPlugin = this.core?.getPlugin('user');
|
|
611
|
-
const customerId = Number(userPlugin?.get?.()?.id);
|
|
612
|
-
return Number.isFinite(customerId) && customerId > 0 ? customerId : undefined;
|
|
613
|
-
} catch {
|
|
614
|
-
return undefined;
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
resolveAvailableWalletIdsForSmartPricing() {
|
|
618
|
-
const orderWalletIds = this.store.order?.getAvailableWalletIds?.();
|
|
619
|
-
const fallbackWalletIds = this.otherParams?.available_wallet_ids || this.otherParams?.availableWalletIds || this.otherParams?.strategy_context?.available_wallet_ids || this.otherParams?.strategy_context?.availableWalletIds;
|
|
620
|
-
const source = Array.isArray(orderWalletIds) && orderWalletIds.length ? orderWalletIds : fallbackWalletIds;
|
|
621
|
-
if (!Array.isArray(source)) return [];
|
|
622
|
-
const ids = source.map(item => Number(item)).filter(item => Number.isFinite(item) && item > 0);
|
|
623
|
-
return Array.from(new Set(ids));
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
/** 读取 schedule 全量列表,供智能定价 schedule_match 使用 */
|
|
627
|
-
getScheduleListForSmartPricing() {
|
|
628
|
-
const scheduleModule = this.store.schedule;
|
|
629
|
-
const list = scheduleModule?.store?.scheduleList;
|
|
630
|
-
return Array.isArray(list) ? list : [];
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
/** 构建智能定价上下文,对齐 OS Server buildProductFormatterContext */
|
|
634
|
-
buildSmartPricingContext(customerId) {
|
|
635
|
-
const evaluator = this.core?.context?.dataVariantEvaluator;
|
|
636
|
-
return {
|
|
637
|
-
evaluator,
|
|
638
|
-
scheduleList: this.getScheduleListForSmartPricing(),
|
|
639
|
-
menuList: this.otherParams?.menuList || this.otherParams?.openData?.menuList || [],
|
|
640
|
-
customerId: customerId ?? this.resolveCustomerIdForSmartPricing(),
|
|
641
|
-
availableWalletIds: this.resolveAvailableWalletIdsForSmartPricing(),
|
|
642
|
-
channel: this.otherParams?.channel,
|
|
643
|
-
businessCode: this.otherParams?.businessCode,
|
|
644
|
-
orderType: this.otherParams?.orderType || this.otherParams?.type,
|
|
645
|
-
strategy_context: this.otherParams?.strategy_context
|
|
646
|
-
};
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
/** venue + addon 全量商品,供智能定价评估 */
|
|
650
|
-
getAllProductsForSmartPricing() {
|
|
651
|
-
if (this.smartPricingProductCatalog.length) {
|
|
652
|
-
return this.smartPricingProductCatalog;
|
|
653
|
-
}
|
|
654
|
-
const venueList = this.getVenueProducts();
|
|
655
|
-
const addonList = this.getAddonProductsList();
|
|
656
|
-
return [...venueList, ...addonList];
|
|
657
|
-
}
|
|
658
|
-
getSlotPriceMapCacheKey(date, context) {
|
|
659
|
-
return [date, context.customerId ?? '', (context.availableWalletIds || []).join(','), context.channel ?? '', context.businessCode ?? ''].join('|');
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
/**
|
|
663
|
-
* 按 schedule 分段构建 slot 价格 Map,带实例级缓存。
|
|
664
|
-
*/
|
|
665
|
-
buildSlotPriceMapForDate(date, config, productIds) {
|
|
666
|
-
const context = this.buildSmartPricingContext();
|
|
667
|
-
const cacheKey = this.getSlotPriceMapCacheKey(date, context);
|
|
668
|
-
const cached = this.slotPriceMapCache.get(cacheKey);
|
|
669
|
-
if (cached) return cached;
|
|
670
|
-
const timeLabels = (0, _timeSlot.generateTimeLabels)(config);
|
|
671
|
-
const slotPriceMap = (0, _smartPricing.buildSlotPriceMapByScheduleSegments)({
|
|
672
|
-
products: this.getAllProductsForSmartPricing(),
|
|
673
|
-
productIds,
|
|
674
|
-
date,
|
|
675
|
-
timeLabels,
|
|
676
|
-
config,
|
|
677
|
-
context
|
|
678
|
-
});
|
|
679
|
-
this.slotPriceMapCache.set(cacheKey, slotPriceMap);
|
|
680
|
-
return slotPriceMap;
|
|
681
|
+
return this.store.cartValidation || { passed: null, failures: [] };
|
|
681
682
|
}
|
|
682
|
-
|
|
683
683
|
// ─── 场地商品 & 附加商品 ───
|
|
684
|
-
|
|
685
684
|
async loadAllProducts() {
|
|
686
|
-
if (this.loadAllProductsInFlight)
|
|
685
|
+
if (this.loadAllProductsInFlight)
|
|
686
|
+
return this.loadAllProductsInFlight;
|
|
687
687
|
this.loadAllProductsInFlight = this._doLoadAllProducts().finally(() => {
|
|
688
688
|
this.loadAllProductsInFlight = null;
|
|
689
689
|
});
|
|
690
690
|
return this.loadAllProductsInFlight;
|
|
691
691
|
}
|
|
692
692
|
async _doLoadAllProducts() {
|
|
693
|
-
|
|
693
|
+
var _a, _b, _c, _d, _e;
|
|
694
|
+
this.logMethodStart("loadAllProducts");
|
|
694
695
|
try {
|
|
695
|
-
if (!this.store.venueProducts)
|
|
696
|
-
|
|
696
|
+
if (!this.store.venueProducts)
|
|
697
|
+
throw new Error("venueProducts 模块未初始化");
|
|
698
|
+
if (!this.store.addonProducts)
|
|
699
|
+
throw new Error("addonProducts 模块未初始化");
|
|
697
700
|
await this.loadOpenDataConfig();
|
|
698
|
-
const associatedMenus = this.otherParams
|
|
701
|
+
const associatedMenus = ((_b = (_a = this.otherParams) == null ? void 0 : _a.openData) == null ? void 0 : _b["menu.associated_menus"]) || [];
|
|
699
702
|
if (!associatedMenus.length) {
|
|
700
|
-
this.logMethodError(
|
|
701
|
-
throw new Error(
|
|
703
|
+
this.logMethodError("loadAllProducts", new Error("未获取到餐牌配置(menu.associated_menus),请检查 OpenData 配置"));
|
|
704
|
+
throw new Error("未获取到餐牌配置(menu.associated_menus),请检查 OpenData 配置");
|
|
702
705
|
}
|
|
703
|
-
const menuListIds = associatedMenus.map(n => Number(n.value));
|
|
706
|
+
const menuListIds = associatedMenus.map((n) => Number(n.value));
|
|
704
707
|
const allProducts = await this.store.venueProducts.loadProducts({
|
|
705
708
|
menu_list_ids: menuListIds,
|
|
706
709
|
cacheId: this.cacheId,
|
|
707
|
-
schedule_date: (0,
|
|
708
|
-
schedule_datetime: (0,
|
|
709
|
-
with_extra: ['dataVariants']
|
|
710
|
+
schedule_date: (0, import_dayjs.default)().format("YYYY-MM-DD"),
|
|
711
|
+
schedule_datetime: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
|
|
710
712
|
});
|
|
711
|
-
const
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
this.clearSlotPriceMapCache();
|
|
716
|
-
const venueList = list.filter(p => p.duration != null);
|
|
717
|
-
const addonList = list.filter(p => p.duration == null);
|
|
718
|
-
const venueStore = this.store.venueProducts?.store;
|
|
713
|
+
const list = Array.isArray(allProducts) ? allProducts : [];
|
|
714
|
+
const venueList = list.filter((p) => p.duration != null);
|
|
715
|
+
const addonList = list.filter((p) => p.duration == null);
|
|
716
|
+
const venueStore = (_c = this.store.venueProducts) == null ? void 0 : _c.store;
|
|
719
717
|
if (venueStore) {
|
|
720
718
|
venueStore.list = venueList.slice().sort((a, b) => Number(b.sort) - Number(a.sort));
|
|
721
719
|
}
|
|
722
720
|
this.store.addonProducts.addProduct(addonList);
|
|
723
|
-
this.resourceProductMap = (0,
|
|
724
|
-
|
|
725
|
-
// 加载 holder 表单
|
|
721
|
+
this.resourceProductMap = (0, import_resource.buildResourceProductMap)(venueList);
|
|
726
722
|
if (this.store.order) {
|
|
727
|
-
const products = this.store.order
|
|
723
|
+
const products = ((_e = (_d = this.store.order) == null ? void 0 : _d.getOrderProducts) == null ? void 0 : _e.call(_d)) || [];
|
|
728
724
|
await this.preloadHolderForms(products);
|
|
729
725
|
}
|
|
730
726
|
this.productsLoaded = true;
|
|
731
|
-
this.logMethodSuccess(
|
|
727
|
+
this.logMethodSuccess("loadAllProducts", {
|
|
732
728
|
total: list.length,
|
|
733
729
|
venueCount: venueList.length,
|
|
734
730
|
addonCount: addonList.length,
|
|
735
731
|
resourceCount: this.resourceProductMap.size
|
|
736
732
|
});
|
|
737
|
-
return {
|
|
738
|
-
venueProducts: venueList,
|
|
739
|
-
addonProducts: addonList
|
|
740
|
-
};
|
|
733
|
+
return { venueProducts: venueList, addonProducts: addonList };
|
|
741
734
|
} catch (error) {
|
|
742
|
-
this.logMethodError(
|
|
735
|
+
this.logMethodError("loadAllProducts", error);
|
|
743
736
|
throw error;
|
|
744
737
|
}
|
|
745
738
|
}
|
|
@@ -752,55 +745,49 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
752
745
|
return result.addonProducts;
|
|
753
746
|
}
|
|
754
747
|
getVenueProducts() {
|
|
755
|
-
|
|
748
|
+
var _a, _b;
|
|
749
|
+
return ((_b = (_a = this.store.venueProducts) == null ? void 0 : _a.store) == null ? void 0 : _b.list) || [];
|
|
756
750
|
}
|
|
757
751
|
getAddonProductsList() {
|
|
758
|
-
|
|
752
|
+
var _a, _b;
|
|
753
|
+
return ((_b = (_a = this.store.addonProducts) == null ? void 0 : _a.store) == null ? void 0 : _b.list) || [];
|
|
759
754
|
}
|
|
760
|
-
|
|
761
755
|
// ─── 报价单 ───
|
|
762
|
-
|
|
763
756
|
async loadQuotations(params) {
|
|
764
|
-
this.logMethodStart(
|
|
757
|
+
this.logMethodStart("loadQuotations");
|
|
765
758
|
try {
|
|
766
|
-
if (!this.store.quotation)
|
|
759
|
+
if (!this.store.quotation)
|
|
760
|
+
throw new Error("quotation 模块未初始化");
|
|
767
761
|
await this.store.quotation.loadQuotations(params);
|
|
768
|
-
this.logMethodSuccess(
|
|
762
|
+
this.logMethodSuccess("loadQuotations", {
|
|
769
763
|
count: this.store.quotation.getQuotationList().length
|
|
770
764
|
});
|
|
771
765
|
} catch (error) {
|
|
772
|
-
this.logMethodError(
|
|
766
|
+
this.logMethodError("loadQuotations", error);
|
|
773
767
|
throw error;
|
|
774
768
|
}
|
|
775
769
|
}
|
|
776
|
-
|
|
777
770
|
// ─── 资源可用性 ───
|
|
778
|
-
|
|
779
771
|
async fetchResourceAvailability(params) {
|
|
780
|
-
this.logMethodStart(
|
|
772
|
+
this.logMethodStart("fetchResourceAvailability", params);
|
|
781
773
|
try {
|
|
782
774
|
const venueProducts = this.getVenueProducts();
|
|
783
775
|
if (!venueProducts.length) {
|
|
784
776
|
this.store.rawResourceData = [];
|
|
785
|
-
this.logMethodSuccess(
|
|
786
|
-
resourceCount: 0
|
|
787
|
-
});
|
|
777
|
+
this.logMethodSuccess("fetchResourceAvailability", { resourceCount: 0 });
|
|
788
778
|
return;
|
|
789
779
|
}
|
|
790
|
-
const resourceIds = (0,
|
|
780
|
+
const resourceIds = (0, import_resource.extractResourceIds)(venueProducts);
|
|
791
781
|
if (!resourceIds.length) {
|
|
792
782
|
this.store.rawResourceData = [];
|
|
793
|
-
this.logMethodSuccess(
|
|
794
|
-
resourceIds: []
|
|
795
|
-
});
|
|
783
|
+
this.logMethodSuccess("fetchResourceAvailability", { resourceIds: [] });
|
|
796
784
|
return;
|
|
797
785
|
}
|
|
798
|
-
|
|
799
|
-
// 跨天营业时,endDate 扩展一天以覆盖次日凌晨时段
|
|
800
786
|
const config = this.store.slotConfig;
|
|
801
|
-
const crossDay = (0,
|
|
802
|
-
const effectiveEndDate = crossDay ? (0,
|
|
803
|
-
if (!this.store.date)
|
|
787
|
+
const crossDay = (0, import_timeSlot.isBusinessHoursCrossDay)(config);
|
|
788
|
+
const effectiveEndDate = crossDay ? (0, import_dayjs.default)(params.endDate).add(1, "day").format("YYYY-MM-DD") : params.endDate;
|
|
789
|
+
if (!this.store.date)
|
|
790
|
+
throw new Error("date 模块未初始化");
|
|
804
791
|
const res = await this.store.date.fetchResourceDates({
|
|
805
792
|
query: {
|
|
806
793
|
start_date: params.startDate,
|
|
@@ -810,7 +797,7 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
810
797
|
useCache: false
|
|
811
798
|
});
|
|
812
799
|
const rawData = [];
|
|
813
|
-
if (res
|
|
800
|
+
if ((res == null ? void 0 : res.data) && Array.isArray(res.data)) {
|
|
814
801
|
for (const item of res.data) {
|
|
815
802
|
rawData.push({
|
|
816
803
|
resourceId: item.id,
|
|
@@ -823,49 +810,63 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
823
810
|
this.store.rawResourceData = rawData;
|
|
824
811
|
for (const item of rawData) {
|
|
825
812
|
const mappings = this.resourceProductMap.get(item.resourceId);
|
|
826
|
-
if (!mappings)
|
|
813
|
+
if (!mappings)
|
|
814
|
+
continue;
|
|
827
815
|
for (const mapping of mappings) {
|
|
828
|
-
if (item.main_field)
|
|
829
|
-
|
|
816
|
+
if (item.main_field)
|
|
817
|
+
mapping.resourceName = item.main_field;
|
|
818
|
+
if (item.resource_form_id)
|
|
819
|
+
mapping.formId = item.resource_form_id;
|
|
830
820
|
}
|
|
831
821
|
}
|
|
832
|
-
this.logMethodSuccess(
|
|
822
|
+
this.logMethodSuccess("fetchResourceAvailability", {
|
|
833
823
|
resourceCount: rawData.length,
|
|
834
824
|
totalTimes: rawData.reduce((sum, r) => sum + r.times.length, 0)
|
|
835
825
|
});
|
|
836
826
|
} catch (error) {
|
|
837
827
|
this.store.rawResourceData = [];
|
|
838
|
-
this.logMethodError(
|
|
828
|
+
this.logMethodError("fetchResourceAvailability", error);
|
|
839
829
|
throw error;
|
|
840
830
|
}
|
|
841
831
|
}
|
|
842
|
-
|
|
843
832
|
// ─── 日期概览 & 时间槽矩阵(纯计算,不发请求) ───
|
|
844
|
-
|
|
845
833
|
getOperatingHoursScheduleIds() {
|
|
846
|
-
|
|
847
|
-
const
|
|
848
|
-
|
|
849
|
-
|
|
834
|
+
var _a, _b;
|
|
835
|
+
const openData = this.otherParams.openData || ((_b = (_a = this.store.openData) == null ? void 0 : _a.getOpenData) == null ? void 0 : _b.call(_a)) || null;
|
|
836
|
+
const rawIds = openData == null ? void 0 : openData["availability.operating_hours"];
|
|
837
|
+
if (!Array.isArray(rawIds))
|
|
838
|
+
return [];
|
|
839
|
+
return [...new Set(
|
|
840
|
+
rawIds.map((id) => Number(id)).filter((id) => Number.isFinite(id) && id > 0).map((id) => Math.floor(id))
|
|
841
|
+
)];
|
|
850
842
|
}
|
|
851
843
|
resolveSlotConfigForDate(date) {
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
844
|
+
var _a;
|
|
845
|
+
const nextSlotConfig = { ...this.baseSlotConfig };
|
|
846
|
+
if (!date || !this.store.schedule)
|
|
847
|
+
return nextSlotConfig;
|
|
856
848
|
const operatingHoursScheduleIds = this.getOperatingHoursScheduleIds();
|
|
857
|
-
if (!operatingHoursScheduleIds.length)
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
849
|
+
if (!operatingHoursScheduleIds.length)
|
|
850
|
+
return nextSlotConfig;
|
|
851
|
+
const scheduleList = this.store.schedule.getScheduleListByIds(
|
|
852
|
+
operatingHoursScheduleIds
|
|
853
|
+
);
|
|
854
|
+
if (!scheduleList.length)
|
|
855
|
+
return nextSlotConfig;
|
|
856
|
+
const timeRangeMap = (0, import_utils2.calcMinTimeMaxTimeBySchedules)(
|
|
857
|
+
scheduleList,
|
|
858
|
+
void 0,
|
|
859
|
+
date
|
|
860
|
+
);
|
|
861
861
|
let earliestStart = null;
|
|
862
862
|
let latestEnd = null;
|
|
863
863
|
for (const schedule of scheduleList) {
|
|
864
|
-
const dateRangeList = timeRangeMap
|
|
864
|
+
const dateRangeList = ((_a = timeRangeMap == null ? void 0 : timeRangeMap[schedule.id]) == null ? void 0 : _a.dateRangeFormat) || [];
|
|
865
865
|
for (const range of dateRangeList) {
|
|
866
|
-
const start = (0,
|
|
867
|
-
const end = (0,
|
|
868
|
-
if (!start.isValid() || !end.isValid())
|
|
866
|
+
const start = (0, import_dayjs.default)(range == null ? void 0 : range.start);
|
|
867
|
+
const end = (0, import_dayjs.default)(range == null ? void 0 : range.end);
|
|
868
|
+
if (!start.isValid() || !end.isValid())
|
|
869
|
+
continue;
|
|
869
870
|
if (!earliestStart || start.isBefore(earliestStart)) {
|
|
870
871
|
earliestStart = start;
|
|
871
872
|
}
|
|
@@ -874,11 +875,12 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
874
875
|
}
|
|
875
876
|
}
|
|
876
877
|
}
|
|
877
|
-
if (!earliestStart || !latestEnd)
|
|
878
|
+
if (!earliestStart || !latestEnd)
|
|
879
|
+
return nextSlotConfig;
|
|
878
880
|
return {
|
|
879
881
|
...nextSlotConfig,
|
|
880
|
-
businessStartTime: earliestStart.format(
|
|
881
|
-
businessEndTime: latestEnd.format(
|
|
882
|
+
businessStartTime: earliestStart.format("HH:mm"),
|
|
883
|
+
businessEndTime: latestEnd.format("HH:mm")
|
|
882
884
|
};
|
|
883
885
|
}
|
|
884
886
|
syncOperatingHoursToSlotConfig(date) {
|
|
@@ -887,31 +889,38 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
887
889
|
return resolvedSlotConfig;
|
|
888
890
|
}
|
|
889
891
|
getDateRangeSummary(params) {
|
|
890
|
-
return (0,
|
|
892
|
+
return (0, import_dateSummary.buildDateRangeSummary)({
|
|
891
893
|
startDate: params.startDate,
|
|
892
894
|
endDate: params.endDate,
|
|
893
895
|
config: this.baseSlotConfig,
|
|
894
896
|
rawResources: this.store.rawResourceData,
|
|
895
897
|
resourceProductMap: this.resourceProductMap,
|
|
896
|
-
|
|
897
|
-
|
|
898
|
+
quotationModule: this.store.quotation,
|
|
899
|
+
resolveConfig: (date) => this.resolveSlotConfigForDate(date)
|
|
898
900
|
});
|
|
899
901
|
}
|
|
900
902
|
getTimeSlotGrid(date) {
|
|
901
903
|
const resolvedSlotConfig = this.syncOperatingHoursToSlotConfig(date);
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
904
|
+
let quotationPriceMap;
|
|
905
|
+
if (this.store.quotation) {
|
|
906
|
+
const productIds = [
|
|
907
|
+
...new Set(
|
|
908
|
+
[...this.resourceProductMap.values()].flat().map((m) => m.productId)
|
|
909
|
+
)
|
|
910
|
+
];
|
|
911
|
+
const timeLabels = (0, import_timeSlot.generateTimeLabels)(resolvedSlotConfig);
|
|
912
|
+
const timePoints = timeLabels.map((label) => `${date} ${label}`);
|
|
913
|
+
quotationPriceMap = this.store.quotation.buildProductPriceMap({ productIds, timePoints });
|
|
914
|
+
}
|
|
915
|
+
return (0, import_timeSlot.buildTimeSlotGrid)({
|
|
905
916
|
date,
|
|
906
917
|
config: resolvedSlotConfig,
|
|
907
918
|
rawResources: this.store.rawResourceData,
|
|
908
919
|
resourceProductMap: this.resourceProductMap,
|
|
909
|
-
|
|
920
|
+
quotationPriceMap
|
|
910
921
|
});
|
|
911
922
|
}
|
|
912
|
-
|
|
913
923
|
// ─── 时间槽订单操作 ───
|
|
914
|
-
|
|
915
924
|
/**
|
|
916
925
|
* 切换单个时段的选中状态(选中/取消)。
|
|
917
926
|
* 内部自动处理连续时段的合并与拆分,订单是唯一真相源。
|
|
@@ -920,7 +929,7 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
920
929
|
* 同一资源下不同 productId 之间互相隔离,不会相互合并。
|
|
921
930
|
*/
|
|
922
931
|
async toggleSlot(slot) {
|
|
923
|
-
this.logMethodStart(
|
|
932
|
+
this.logMethodStart("toggleSlot", {
|
|
924
933
|
resourceId: slot.resourceId,
|
|
925
934
|
productId: slot.productId,
|
|
926
935
|
startTime: slot.startTime
|
|
@@ -930,73 +939,85 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
930
939
|
if (!mappings || !mappings.length) {
|
|
931
940
|
throw new Error(`未找到资源 ${slot.resourceId} 的商品映射`);
|
|
932
941
|
}
|
|
933
|
-
const mapping = mappings.find(m => m.productId === slot.productId);
|
|
942
|
+
const mapping = mappings.find((m) => m.productId === slot.productId);
|
|
934
943
|
if (!mapping) {
|
|
935
944
|
throw new Error(`资源 ${slot.resourceId} 未关联商品 ${slot.productId}`);
|
|
936
945
|
}
|
|
937
|
-
if (!this.store.order)
|
|
938
|
-
|
|
939
|
-
const
|
|
946
|
+
if (!this.store.order)
|
|
947
|
+
throw new Error("order 模块未初始化");
|
|
948
|
+
const currentSlots = this.getSelectedSlotsForResourceProduct(
|
|
949
|
+
slot.resourceId,
|
|
950
|
+
slot.productId
|
|
951
|
+
);
|
|
952
|
+
const existIndex = currentSlots.findIndex((s) => s.startTime === slot.startTime);
|
|
940
953
|
let nextSlots;
|
|
941
954
|
if (existIndex !== -1) {
|
|
942
955
|
nextSlots = currentSlots.filter((_, i) => i !== existIndex);
|
|
943
956
|
} else {
|
|
944
957
|
nextSlots = [...currentSlots, slot];
|
|
945
958
|
}
|
|
946
|
-
await this.reconcileOrderForResourceProduct(
|
|
959
|
+
await this.reconcileOrderForResourceProduct(
|
|
960
|
+
slot.resourceId,
|
|
961
|
+
slot.productId,
|
|
962
|
+
nextSlots
|
|
963
|
+
);
|
|
947
964
|
const products = this.store.order.getOrderProducts();
|
|
948
965
|
await this.refreshItemRuleQuantityLimits();
|
|
949
966
|
await this.refreshCartValidationPassed();
|
|
950
|
-
this.logMethodSuccess(
|
|
951
|
-
action: existIndex !== -1 ?
|
|
967
|
+
this.logMethodSuccess("toggleSlot", {
|
|
968
|
+
action: existIndex !== -1 ? "remove" : "add",
|
|
952
969
|
resourceId: slot.resourceId,
|
|
953
970
|
productId: slot.productId,
|
|
954
971
|
slotCount: nextSlots.length
|
|
955
972
|
});
|
|
956
973
|
return products;
|
|
957
974
|
} catch (error) {
|
|
958
|
-
this.logMethodError(
|
|
975
|
+
this.logMethodError("toggleSlot", error);
|
|
959
976
|
throw error;
|
|
960
977
|
}
|
|
961
978
|
}
|
|
962
|
-
|
|
963
979
|
/**
|
|
964
980
|
* 获取某资源当前选中的所有独立时段(从订单中解析)。
|
|
965
981
|
* 不传 productId 时返回该资源下所有商品的选中时段;传了则精确匹配。
|
|
966
982
|
*/
|
|
967
983
|
getSelectedSlotsForResource(resourceId, productId) {
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
984
|
+
var _a;
|
|
985
|
+
const tempOrder = (_a = this.store.order) == null ? void 0 : _a.getTempOrder();
|
|
986
|
+
if (!tempOrder)
|
|
987
|
+
return [];
|
|
988
|
+
const venueProducts = tempOrder.products.filter((p) => {
|
|
989
|
+
var _a2, _b;
|
|
990
|
+
if (!((_a2 = p.metadata) == null ? void 0 : _a2.venue_booking))
|
|
991
|
+
return false;
|
|
992
|
+
if (String((_b = p.metadata) == null ? void 0 : _b.resource_id) !== String(resourceId))
|
|
993
|
+
return false;
|
|
994
|
+
if (productId != null && Number(p.product_id) !== Number(productId))
|
|
995
|
+
return false;
|
|
974
996
|
return true;
|
|
975
997
|
});
|
|
976
998
|
const slotDuration = this.store.slotConfig.slotDurationMinutes;
|
|
977
999
|
const slots = [];
|
|
978
1000
|
for (const product of venueProducts) {
|
|
979
|
-
slots.push(
|
|
980
|
-
...s
|
|
981
|
-
|
|
982
|
-
|
|
1001
|
+
slots.push(
|
|
1002
|
+
...(0, import_slotMerge.expandMergedSlotToIndividual)(product, slotDuration).map((s) => ({
|
|
1003
|
+
...s,
|
|
1004
|
+
productId: Number(product.product_id)
|
|
1005
|
+
}))
|
|
1006
|
+
);
|
|
983
1007
|
}
|
|
984
1008
|
return slots.sort((a, b) => a.startTime.localeCompare(b.startTime));
|
|
985
1009
|
}
|
|
986
|
-
|
|
987
1010
|
/** getSelectedSlotsForResource 的 (resourceId, productId) 精确版,内部使用。 */
|
|
988
1011
|
getSelectedSlotsForResourceProduct(resourceId, productId) {
|
|
989
1012
|
return this.getSelectedSlotsForResource(resourceId, productId);
|
|
990
1013
|
}
|
|
991
|
-
|
|
992
1014
|
/**
|
|
993
1015
|
* 判断某个时段是否已选中。
|
|
994
1016
|
* 不传 productId 时:只要该资源下任一商品在 startTime 被选中即返回 true;传了则精确匹配。
|
|
995
1017
|
*/
|
|
996
1018
|
isSlotSelected(resourceId, startTime, productId) {
|
|
997
|
-
return this.getSelectedSlotsForResource(resourceId, productId).some(s => s.startTime === startTime);
|
|
1019
|
+
return this.getSelectedSlotsForResource(resourceId, productId).some((s) => s.startTime === startTime);
|
|
998
1020
|
}
|
|
999
|
-
|
|
1000
1021
|
/**
|
|
1001
1022
|
* 判断指定 (resourceId, productId, startTime) 格子是否应因其它已选项而被禁用。
|
|
1002
1023
|
* 规则:
|
|
@@ -1006,27 +1027,21 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
1006
1027
|
* 4) 两个组合资源的 child 集合有交集,且对方在该 startTime 被选中 → 禁用
|
|
1007
1028
|
*/
|
|
1008
1029
|
isSlotDisabledBySelection(params) {
|
|
1009
|
-
const {
|
|
1010
|
-
resourceId,
|
|
1011
|
-
productId,
|
|
1012
|
-
startTime
|
|
1013
|
-
} = params;
|
|
1030
|
+
const { resourceId, productId, startTime } = params;
|
|
1014
1031
|
const allSelected = this.getAllSelectedSlots();
|
|
1015
|
-
const getSelectedAt = resId => {
|
|
1032
|
+
const getSelectedAt = (resId) => {
|
|
1016
1033
|
const list = allSelected.get(resId) || [];
|
|
1017
|
-
return list.filter(s => s.startTime === startTime);
|
|
1034
|
+
return list.filter((s) => s.startTime === startTime);
|
|
1018
1035
|
};
|
|
1019
|
-
|
|
1020
|
-
// 规则 1:同场地、不同 productId 的已选
|
|
1021
1036
|
const sameResourceSelections = getSelectedAt(resourceId);
|
|
1022
|
-
if (sameResourceSelections.some(s => Number(s.productId) !== Number(productId))) {
|
|
1037
|
+
if (sameResourceSelections.some((s) => Number(s.productId) !== Number(productId))) {
|
|
1023
1038
|
return true;
|
|
1024
1039
|
}
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
const combined = raw
|
|
1040
|
+
const getCombinedChildIds = (resId) => {
|
|
1041
|
+
const raw = this.store.rawResourceData.find(
|
|
1042
|
+
(r) => String(r.resourceId) === String(resId)
|
|
1043
|
+
);
|
|
1044
|
+
const combined = raw == null ? void 0 : raw.combined_resource;
|
|
1030
1045
|
if (combined && combined.status === 1 && Array.isArray(combined.resource_ids)) {
|
|
1031
1046
|
return combined.resource_ids;
|
|
1032
1047
|
}
|
|
@@ -1034,53 +1049,59 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
1034
1049
|
};
|
|
1035
1050
|
const currentChildIds = getCombinedChildIds(resourceId);
|
|
1036
1051
|
const currentIsCombined = currentChildIds.length > 0;
|
|
1037
|
-
|
|
1038
|
-
// 规则 2:当前是组合资源,任一子资源被选 → 禁用
|
|
1039
1052
|
if (currentIsCombined) {
|
|
1040
1053
|
for (const childId of currentChildIds) {
|
|
1041
|
-
if (getSelectedAt(childId).length > 0)
|
|
1054
|
+
if (getSelectedAt(childId).length > 0)
|
|
1055
|
+
return true;
|
|
1042
1056
|
}
|
|
1043
1057
|
}
|
|
1044
|
-
|
|
1045
|
-
// 规则 3 & 4:扫描所有已选的 (resId),若是组合资源,检查其 children 是否包含当前 resourceId 或与当前 child 集合有交集
|
|
1046
1058
|
for (const [selectedResId, slots] of allSelected) {
|
|
1047
|
-
if (!slots.some(s => s.startTime === startTime))
|
|
1048
|
-
|
|
1059
|
+
if (!slots.some((s) => s.startTime === startTime))
|
|
1060
|
+
continue;
|
|
1061
|
+
if (String(selectedResId) === String(resourceId))
|
|
1062
|
+
continue;
|
|
1049
1063
|
const selectedChildIds = getCombinedChildIds(selectedResId);
|
|
1050
|
-
if (selectedChildIds.length === 0)
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
if (selectedChildIds.some(id => String(id) === String(resourceId))) {
|
|
1064
|
+
if (selectedChildIds.length === 0)
|
|
1065
|
+
continue;
|
|
1066
|
+
if (selectedChildIds.some((id) => String(id) === String(resourceId))) {
|
|
1054
1067
|
return true;
|
|
1055
1068
|
}
|
|
1056
|
-
|
|
1057
|
-
// 双方都是组合资源,child 集合有交集(规则 4)
|
|
1058
1069
|
if (currentIsCombined) {
|
|
1059
|
-
const intersect = selectedChildIds.some(
|
|
1060
|
-
|
|
1070
|
+
const intersect = selectedChildIds.some(
|
|
1071
|
+
(id) => currentChildIds.some((cid) => String(cid) === String(id))
|
|
1072
|
+
);
|
|
1073
|
+
if (intersect)
|
|
1074
|
+
return true;
|
|
1061
1075
|
}
|
|
1062
1076
|
}
|
|
1063
1077
|
return false;
|
|
1064
1078
|
}
|
|
1065
|
-
|
|
1066
1079
|
/**
|
|
1067
1080
|
* 获取所有已选时段(按资源分组)。每个 slot 上带 productId,便于 UI 做 per-product 判定。
|
|
1068
1081
|
*/
|
|
1069
1082
|
getAllSelectedSlots() {
|
|
1070
|
-
|
|
1071
|
-
const
|
|
1072
|
-
|
|
1073
|
-
|
|
1083
|
+
var _a, _b;
|
|
1084
|
+
const result = /* @__PURE__ */ new Map();
|
|
1085
|
+
const tempOrder = (_a = this.store.order) == null ? void 0 : _a.getTempOrder();
|
|
1086
|
+
if (!tempOrder)
|
|
1087
|
+
return result;
|
|
1088
|
+
const venueProducts = tempOrder.products.filter((p) => {
|
|
1089
|
+
var _a2;
|
|
1090
|
+
return (_a2 = p.metadata) == null ? void 0 : _a2.venue_booking;
|
|
1091
|
+
});
|
|
1074
1092
|
const slotDuration = this.store.slotConfig.slotDurationMinutes;
|
|
1075
1093
|
for (const product of venueProducts) {
|
|
1076
|
-
const resourceId = product.metadata
|
|
1077
|
-
if (resourceId == null)
|
|
1094
|
+
const resourceId = (_b = product.metadata) == null ? void 0 : _b.resource_id;
|
|
1095
|
+
if (resourceId == null)
|
|
1096
|
+
continue;
|
|
1078
1097
|
const productId = Number(product.product_id);
|
|
1079
1098
|
const existing = result.get(resourceId) || [];
|
|
1080
|
-
existing.push(
|
|
1081
|
-
...s
|
|
1082
|
-
|
|
1083
|
-
|
|
1099
|
+
existing.push(
|
|
1100
|
+
...(0, import_slotMerge.expandMergedSlotToIndividual)(product, slotDuration).map((s) => ({
|
|
1101
|
+
...s,
|
|
1102
|
+
productId
|
|
1103
|
+
}))
|
|
1104
|
+
);
|
|
1084
1105
|
result.set(resourceId, existing);
|
|
1085
1106
|
}
|
|
1086
1107
|
for (const [key, slots] of result) {
|
|
@@ -1088,83 +1109,128 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
1088
1109
|
}
|
|
1089
1110
|
return result;
|
|
1090
1111
|
}
|
|
1091
|
-
|
|
1092
1112
|
/**
|
|
1093
1113
|
* 对指定 (resourceId, productId) 的订单商品进行 reconcile:
|
|
1094
1114
|
* 清除旧商品 → 合并连续时段 → 重新写入。
|
|
1095
1115
|
* 同一场地下不同商品互不干扰,各自单独 reconcile。
|
|
1096
1116
|
*/
|
|
1097
1117
|
async reconcileOrderForResourceProduct(resourceId, productId, slots) {
|
|
1118
|
+
var _a, _b;
|
|
1098
1119
|
const mappings = this.resourceProductMap.get(resourceId);
|
|
1099
|
-
if (!mappings || !mappings.length || !this.store.order)
|
|
1100
|
-
|
|
1101
|
-
|
|
1120
|
+
if (!mappings || !mappings.length || !this.store.order)
|
|
1121
|
+
return;
|
|
1122
|
+
const mapping = mappings.find((m) => m.productId === productId);
|
|
1123
|
+
if (!mapping)
|
|
1124
|
+
return;
|
|
1102
1125
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
1103
|
-
const matchesCurrent = (meta, pid) => !!meta
|
|
1104
|
-
tempOrder.products = tempOrder.products.filter(
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1126
|
+
const matchesCurrent = (meta, pid) => !!(meta == null ? void 0 : meta.venue_booking) && String(meta == null ? void 0 : meta.resource_id) === String(resourceId) && Number(pid) === Number(productId);
|
|
1127
|
+
tempOrder.products = tempOrder.products.filter(
|
|
1128
|
+
(p) => !matchesCurrent(p.metadata, p.product_id)
|
|
1129
|
+
);
|
|
1130
|
+
tempOrder.bookings = (tempOrder.bookings || []).filter(
|
|
1131
|
+
(b) => {
|
|
1132
|
+
var _a2, _b2, _c, _d;
|
|
1133
|
+
if (!((_a2 = b.metadata) == null ? void 0 : _a2.venue_booking))
|
|
1134
|
+
return true;
|
|
1135
|
+
if (String((_b2 = b.metadata) == null ? void 0 : _b2.resource_id) !== String(resourceId))
|
|
1136
|
+
return true;
|
|
1137
|
+
const bookingProductId = ((_c = b.metadata) == null ? void 0 : _c.product_id) ?? ((_d = b == null ? void 0 : b.product) == null ? void 0 : _d.product_id);
|
|
1138
|
+
if (bookingProductId == null)
|
|
1139
|
+
return false;
|
|
1140
|
+
return Number(bookingProductId) !== Number(productId);
|
|
1141
|
+
}
|
|
1142
|
+
);
|
|
1112
1143
|
if (!slots.length) {
|
|
1113
1144
|
this.store.order.applyDiscount();
|
|
1114
|
-
await this.store.order.recalculateSummary({
|
|
1115
|
-
createIfMissing: true
|
|
1116
|
-
});
|
|
1145
|
+
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
1117
1146
|
this.store.order.persistTempOrder();
|
|
1118
1147
|
return;
|
|
1119
1148
|
}
|
|
1120
|
-
const merged = (0,
|
|
1121
|
-
const rawResource = this.store.rawResourceData.find(
|
|
1149
|
+
const merged = (0, import_slotMerge.mergeConsecutiveSlots)(slots);
|
|
1150
|
+
const rawResource = this.store.rawResourceData.find(
|
|
1151
|
+
(r) => String(r.resourceId) === String(resourceId)
|
|
1152
|
+
);
|
|
1122
1153
|
const childRawResources = this.getCombinedChildRawResources(rawResource);
|
|
1123
|
-
const venueProduct = this.getVenueProducts().find(p => p.id === mapping.productId);
|
|
1154
|
+
const venueProduct = this.getVenueProducts().find((p) => p.id === mapping.productId);
|
|
1124
1155
|
tempOrder.bookings = tempOrder.bookings || [];
|
|
1125
1156
|
for (let i = 0; i < merged.length; i++) {
|
|
1126
1157
|
const group = merged[i];
|
|
1127
|
-
const identityKey = (0,
|
|
1128
|
-
const bookingUuid = (0,
|
|
1129
|
-
const startMoment = (0,
|
|
1130
|
-
const endMoment = (0,
|
|
1131
|
-
const duration = endMoment.diff(startMoment,
|
|
1132
|
-
const customDepositData = cloneCustomDepositData(venueProduct
|
|
1158
|
+
const identityKey = (0, import_slotMerge.buildVenueIdentityKey)(resourceId, i);
|
|
1159
|
+
const bookingUuid = (0, import_utils3.createUuidV4)();
|
|
1160
|
+
const startMoment = (0, import_dayjs.default)(group.startTime, "YYYY-MM-DD HH:mm");
|
|
1161
|
+
const endMoment = (0, import_dayjs.default)(group.endTime, "YYYY-MM-DD HH:mm");
|
|
1162
|
+
const duration = endMoment.diff(startMoment, "minute");
|
|
1163
|
+
const customDepositData = cloneCustomDepositData(venueProduct == null ? void 0 : venueProduct.custom_deposit_data);
|
|
1164
|
+
const productTitle = this.normalizeVenueProductTitle(venueProduct == null ? void 0 : venueProduct.product_title) || this.normalizeVenueProductTitle(venueProduct == null ? void 0 : venueProduct.title) || this.normalizeVenueProductTitle(mapping.productTitle);
|
|
1133
1165
|
const resourceEntry = {
|
|
1134
|
-
relation_type:
|
|
1135
|
-
like_status:
|
|
1166
|
+
relation_type: "form",
|
|
1167
|
+
like_status: "common",
|
|
1136
1168
|
id: resourceId,
|
|
1137
1169
|
main_field: mapping.resourceName,
|
|
1138
|
-
form_id: rawResource
|
|
1170
|
+
form_id: (rawResource == null ? void 0 : rawResource.form_id) ?? mapping.formId,
|
|
1139
1171
|
relation_id: resourceId,
|
|
1140
1172
|
capacity: 1,
|
|
1141
|
-
metadata: (0,
|
|
1142
|
-
mapping,
|
|
1143
|
-
rawResource
|
|
1144
|
-
})
|
|
1173
|
+
metadata: (0, import_slotMerge.buildVenueResourceMetadata)({ mapping, rawResource })
|
|
1145
1174
|
};
|
|
1146
1175
|
if (childRawResources && childRawResources.length) {
|
|
1147
|
-
resourceEntry.children = childRawResources.map(child => ({
|
|
1148
|
-
relation_type:
|
|
1149
|
-
like_status:
|
|
1176
|
+
resourceEntry.children = childRawResources.map((child) => ({
|
|
1177
|
+
relation_type: "form",
|
|
1178
|
+
like_status: "common",
|
|
1150
1179
|
id: child.resourceId,
|
|
1151
|
-
main_field: child.main_field ||
|
|
1180
|
+
main_field: child.main_field || "",
|
|
1152
1181
|
form_id: child.form_id ?? child.formId,
|
|
1153
1182
|
relation_id: child.resourceId,
|
|
1154
1183
|
capacity: child.capacity ?? 1,
|
|
1155
1184
|
metadata: {}
|
|
1156
1185
|
}));
|
|
1157
1186
|
}
|
|
1158
|
-
|
|
1187
|
+
const venueProductOrigin = {
|
|
1188
|
+
name: mapping.productTitle,
|
|
1189
|
+
product_title: productTitle,
|
|
1190
|
+
cover: (venueProduct == null ? void 0 : venueProduct.cover) || "",
|
|
1191
|
+
custom_deposit_data: customDepositData,
|
|
1192
|
+
id: 0,
|
|
1193
|
+
number: 1,
|
|
1194
|
+
registration_type: "all",
|
|
1195
|
+
relation_products: [],
|
|
1196
|
+
is_all: false,
|
|
1197
|
+
product: {
|
|
1198
|
+
product_id: mapping.productId,
|
|
1199
|
+
product_variant_id: 0,
|
|
1200
|
+
num: 1,
|
|
1201
|
+
product_bundle: [],
|
|
1202
|
+
product_sku: { option: [] },
|
|
1203
|
+
discount_list: [],
|
|
1204
|
+
custom_deposit_data: customDepositData,
|
|
1205
|
+
metadata: {}
|
|
1206
|
+
},
|
|
1207
|
+
sub_type: "minutes",
|
|
1208
|
+
duration,
|
|
1209
|
+
like_status: "common",
|
|
1210
|
+
resources: [resourceEntry],
|
|
1211
|
+
schedule_id: 0,
|
|
1212
|
+
select_date: startMoment.format("YYYY-MM-DD"),
|
|
1213
|
+
start_date: startMoment.format("YYYY-MM-DD"),
|
|
1214
|
+
start_time: startMoment.format("HH:mm"),
|
|
1215
|
+
end_date: endMoment.format("YYYY-MM-DD"),
|
|
1216
|
+
end_time: endMoment.format("HH:mm"),
|
|
1217
|
+
metadata: {
|
|
1218
|
+
venue_booking: true,
|
|
1219
|
+
slot_count: group.slotCount
|
|
1220
|
+
},
|
|
1221
|
+
holder: null
|
|
1222
|
+
};
|
|
1223
|
+
const normalizedVenueOrderProduct = (0, import_utils.normalizeOrderProduct)({
|
|
1159
1224
|
product_id: mapping.productId,
|
|
1160
1225
|
product_variant_id: 0,
|
|
1161
1226
|
identity_key: identityKey,
|
|
1162
1227
|
num: 1,
|
|
1163
1228
|
selling_price: group.totalPrice,
|
|
1164
1229
|
original_price: group.totalPrice,
|
|
1165
|
-
is_charge_tax: venueProduct
|
|
1230
|
+
is_charge_tax: (venueProduct == null ? void 0 : venueProduct.is_charge_tax) ?? 0,
|
|
1166
1231
|
metadata: {
|
|
1167
1232
|
venue_booking: true,
|
|
1233
|
+
...productTitle ? { product_title: productTitle } : {},
|
|
1168
1234
|
resource_id: resourceId,
|
|
1169
1235
|
resource_form_id: mapping.formId,
|
|
1170
1236
|
resource_name: mapping.resourceName,
|
|
@@ -1172,51 +1238,18 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
1172
1238
|
end_time: group.endTime,
|
|
1173
1239
|
slot_count: group.slotCount,
|
|
1174
1240
|
booking_uid: bookingUuid,
|
|
1175
|
-
price_breakdown: (0,
|
|
1241
|
+
price_breakdown: (0, import_slotMerge.buildPriceBreakdown)({
|
|
1176
1242
|
group,
|
|
1177
|
-
productId: mapping.productId
|
|
1243
|
+
productId: mapping.productId,
|
|
1244
|
+
quotation: this.store.quotation
|
|
1178
1245
|
})
|
|
1179
1246
|
},
|
|
1180
|
-
_origin:
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
registration_type: 'all',
|
|
1187
|
-
relation_products: [],
|
|
1188
|
-
is_all: false,
|
|
1189
|
-
product: {
|
|
1190
|
-
product_id: mapping.productId,
|
|
1191
|
-
product_variant_id: 0,
|
|
1192
|
-
num: 1,
|
|
1193
|
-
product_bundle: [],
|
|
1194
|
-
product_option_item: [],
|
|
1195
|
-
discount_list: [],
|
|
1196
|
-
custom_deposit_data: customDepositData,
|
|
1197
|
-
metadata: {},
|
|
1198
|
-
holder_config: venueProduct?.holder_config,
|
|
1199
|
-
bookingUuid: bookingUuid,
|
|
1200
|
-
shop_id: venueProduct?.shop_id || 0
|
|
1201
|
-
},
|
|
1202
|
-
sub_type: 'minutes',
|
|
1203
|
-
duration,
|
|
1204
|
-
like_status: 'common',
|
|
1205
|
-
resources: [resourceEntry],
|
|
1206
|
-
schedule_id: 0,
|
|
1207
|
-
select_date: startMoment.format('YYYY-MM-DD'),
|
|
1208
|
-
start_date: startMoment.format('YYYY-MM-DD'),
|
|
1209
|
-
start_time: startMoment.format('HH:mm'),
|
|
1210
|
-
end_date: endMoment.format('YYYY-MM-DD'),
|
|
1211
|
-
end_time: endMoment.format('HH:mm'),
|
|
1212
|
-
metadata: {
|
|
1213
|
-
venue_booking: true,
|
|
1214
|
-
slot_count: group.slotCount
|
|
1215
|
-
},
|
|
1216
|
-
holder: null
|
|
1217
|
-
}
|
|
1218
|
-
}));
|
|
1219
|
-
const booking = (0, _slotMerge.buildVenueBookingEntry)({
|
|
1247
|
+
_origin: venueProductOrigin
|
|
1248
|
+
});
|
|
1249
|
+
const venueOrderProduct = productTitle ? { ...normalizedVenueOrderProduct, product_title: productTitle } : normalizedVenueOrderProduct;
|
|
1250
|
+
this.attachProductOriginToTempOrder(tempOrder, identityKey, venueProductOrigin);
|
|
1251
|
+
tempOrder.products.push(venueOrderProduct);
|
|
1252
|
+
const booking = (0, import_slotMerge.buildVenueBookingEntry)({
|
|
1220
1253
|
group,
|
|
1221
1254
|
resourceId,
|
|
1222
1255
|
mapping,
|
|
@@ -1227,34 +1260,31 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
1227
1260
|
});
|
|
1228
1261
|
tempOrder.bookings.push(booking);
|
|
1229
1262
|
}
|
|
1230
|
-
|
|
1231
|
-
// 获取表单信息
|
|
1232
|
-
const products = this.store.order?.getOrderProducts?.() || [];
|
|
1263
|
+
const products = ((_b = (_a = this.store.order) == null ? void 0 : _a.getOrderProducts) == null ? void 0 : _b.call(_a)) || [];
|
|
1233
1264
|
await this.preloadHolderForms(products);
|
|
1234
1265
|
this.store.order.applyDiscount();
|
|
1235
|
-
await this.store.order.recalculateSummary({
|
|
1236
|
-
createIfMissing: true
|
|
1237
|
-
});
|
|
1266
|
+
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
1238
1267
|
this.store.order.persistTempOrder();
|
|
1239
1268
|
}
|
|
1240
|
-
|
|
1241
1269
|
/** 给定一个父 rawResource,返回其 combined_resource.resource_ids 对应的子 rawResource 列表。 */
|
|
1242
1270
|
getCombinedChildRawResources(rawResource) {
|
|
1243
|
-
if (!rawResource)
|
|
1271
|
+
if (!rawResource)
|
|
1272
|
+
return void 0;
|
|
1244
1273
|
const combined = rawResource.combined_resource;
|
|
1245
1274
|
if (!combined || combined.status !== 1 || !Array.isArray(combined.resource_ids) || !combined.resource_ids.length) {
|
|
1246
|
-
return
|
|
1275
|
+
return void 0;
|
|
1247
1276
|
}
|
|
1248
1277
|
const children = [];
|
|
1249
1278
|
for (const id of combined.resource_ids) {
|
|
1250
|
-
const child = this.store.rawResourceData.find(
|
|
1251
|
-
|
|
1279
|
+
const child = this.store.rawResourceData.find(
|
|
1280
|
+
(r) => String(r.resourceId) === String(id)
|
|
1281
|
+
);
|
|
1282
|
+
if (child)
|
|
1283
|
+
children.push(child);
|
|
1252
1284
|
}
|
|
1253
|
-
return children.length ? children :
|
|
1285
|
+
return children.length ? children : void 0;
|
|
1254
1286
|
}
|
|
1255
|
-
|
|
1256
1287
|
// ─── 配置 ───
|
|
1257
|
-
|
|
1258
1288
|
setSlotConfig(config) {
|
|
1259
1289
|
this.baseSlotConfig = {
|
|
1260
1290
|
...this.baseSlotConfig,
|
|
@@ -1265,189 +1295,187 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
1265
1295
|
};
|
|
1266
1296
|
}
|
|
1267
1297
|
getSlotConfig() {
|
|
1268
|
-
return {
|
|
1269
|
-
...this.store.slotConfig
|
|
1270
|
-
};
|
|
1298
|
+
return { ...this.store.slotConfig };
|
|
1271
1299
|
}
|
|
1272
|
-
|
|
1273
1300
|
// ─── 日程 ───
|
|
1274
|
-
|
|
1275
1301
|
async loadSchedules() {
|
|
1276
|
-
this.logMethodStart(
|
|
1302
|
+
this.logMethodStart("loadSchedules");
|
|
1277
1303
|
try {
|
|
1278
|
-
if (!this.store.schedule)
|
|
1304
|
+
if (!this.store.schedule)
|
|
1305
|
+
throw new Error("schedule 模块未初始化");
|
|
1279
1306
|
await this.store.schedule.loadAllSchedule();
|
|
1280
|
-
this.
|
|
1307
|
+
this.injectScheduleResolverToQuotation();
|
|
1308
|
+
this.logMethodSuccess("loadSchedules");
|
|
1281
1309
|
} catch (error) {
|
|
1282
|
-
this.logMethodError(
|
|
1310
|
+
this.logMethodError("loadSchedules", error);
|
|
1283
1311
|
throw error;
|
|
1284
1312
|
}
|
|
1285
1313
|
}
|
|
1314
|
+
injectScheduleResolverToQuotation() {
|
|
1315
|
+
if (this.store.quotation && this.store.schedule) {
|
|
1316
|
+
this.store.quotation.setScheduleResolver(
|
|
1317
|
+
(id) => this.store.schedule.getScheduleListByIds([id])[0]
|
|
1318
|
+
);
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1286
1321
|
getScheduleListByIds(ids) {
|
|
1287
|
-
if (!this.store.schedule)
|
|
1322
|
+
if (!this.store.schedule)
|
|
1323
|
+
return [];
|
|
1288
1324
|
return this.store.schedule.getScheduleListByIds(ids);
|
|
1289
1325
|
}
|
|
1290
|
-
|
|
1291
1326
|
// ─── 临时订单操作(保留原有能力) ───
|
|
1292
|
-
|
|
1293
1327
|
getTempOrder() {
|
|
1294
|
-
|
|
1328
|
+
var _a;
|
|
1329
|
+
const result = ((_a = this.store.order) == null ? void 0 : _a.getTempOrder()) || null;
|
|
1295
1330
|
return result;
|
|
1296
1331
|
}
|
|
1297
|
-
updateTempOrderNote(note) {
|
|
1298
|
-
if (!this.store.order)
|
|
1299
|
-
|
|
1332
|
+
updateTempOrderNote(note, sync = false) {
|
|
1333
|
+
if (!this.store.order)
|
|
1334
|
+
throw new Error("order 模块未初始化");
|
|
1335
|
+
return this.store.order.updateTempOrderNote(note, sync);
|
|
1300
1336
|
}
|
|
1301
1337
|
updateTempOrderContactsInfo(contactsInfo) {
|
|
1302
|
-
if (!this.store.order)
|
|
1338
|
+
if (!this.store.order)
|
|
1339
|
+
throw new Error("order 模块未初始化");
|
|
1303
1340
|
return this.store.order.updateTempOrderContactsInfo(contactsInfo);
|
|
1304
1341
|
}
|
|
1305
|
-
|
|
1306
|
-
if (!this.store.order)
|
|
1342
|
+
ensureVenueTempOrder() {
|
|
1343
|
+
if (!this.store.order)
|
|
1344
|
+
throw new Error("order 模块未初始化");
|
|
1307
1345
|
return this.store.order.ensureTempOrder();
|
|
1308
1346
|
}
|
|
1309
1347
|
async onCustomerLogin(params) {
|
|
1310
|
-
this.logMethodStart(
|
|
1311
|
-
customerId: params.customerId
|
|
1312
|
-
});
|
|
1348
|
+
this.logMethodStart("onCustomerLogin", { customerId: params.customerId });
|
|
1313
1349
|
try {
|
|
1314
1350
|
await this.refreshOrderMarketingAfterLogin({
|
|
1315
1351
|
customerId: params.customerId
|
|
1316
1352
|
});
|
|
1317
|
-
this.logMethodSuccess(
|
|
1318
|
-
customerId: params.customerId
|
|
1319
|
-
});
|
|
1353
|
+
this.logMethodSuccess("onCustomerLogin", { customerId: params.customerId });
|
|
1320
1354
|
} catch (error) {
|
|
1321
|
-
this.logMethodError(
|
|
1355
|
+
this.logMethodError("onCustomerLogin", error);
|
|
1322
1356
|
throw error;
|
|
1323
1357
|
}
|
|
1324
1358
|
}
|
|
1325
|
-
|
|
1326
|
-
|
|
1359
|
+
recalculateOrderPricesFromQuotation() {
|
|
1360
|
+
var _a, _b;
|
|
1361
|
+
if (!this.store.order || !this.store.quotation)
|
|
1362
|
+
return;
|
|
1327
1363
|
const tempOrder = this.store.order.getTempOrder();
|
|
1328
|
-
if (!tempOrder
|
|
1329
|
-
|
|
1330
|
-
const
|
|
1331
|
-
const context = this.buildSmartPricingContext();
|
|
1364
|
+
if (!((_a = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _a.length))
|
|
1365
|
+
return;
|
|
1366
|
+
const now = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
1332
1367
|
for (const product of tempOrder.products) {
|
|
1333
|
-
if (product.metadata
|
|
1368
|
+
if ((_b = product.metadata) == null ? void 0 : _b.venue_booking) {
|
|
1334
1369
|
const mappings = this.resourceProductMap.get(product.metadata.resource_id);
|
|
1335
|
-
if (!mappings || !mappings.length)
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
const
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
const updatedSlots = slots.map(slot => {
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
...slot,
|
|
1370
|
+
if (!mappings || !mappings.length)
|
|
1371
|
+
continue;
|
|
1372
|
+
const mapping = mappings.find((m) => Number(m.productId) === Number(product.product_id)) || mappings[0];
|
|
1373
|
+
if (!mapping)
|
|
1374
|
+
continue;
|
|
1375
|
+
const slots = (0, import_slotMerge.expandMergedSlotToIndividual)(
|
|
1376
|
+
product,
|
|
1377
|
+
this.store.slotConfig.slotDurationMinutes
|
|
1378
|
+
);
|
|
1379
|
+
const updatedSlots = slots.map((slot) => ({
|
|
1380
|
+
...slot,
|
|
1381
|
+
productId: mapping.productId,
|
|
1382
|
+
price: this.store.quotation.getPriceForProduct({
|
|
1349
1383
|
productId: mapping.productId,
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
fallbackPrice: mapping.price
|
|
1355
|
-
}) : mapping.price
|
|
1356
|
-
};
|
|
1357
|
-
});
|
|
1358
|
-
const merged = (0, _slotMerge.mergeConsecutiveSlots)(updatedSlots);
|
|
1384
|
+
datetime: slot.startTime
|
|
1385
|
+
}) ?? mapping.price
|
|
1386
|
+
}));
|
|
1387
|
+
const merged = (0, import_slotMerge.mergeConsecutiveSlots)(updatedSlots);
|
|
1359
1388
|
if (merged.length === 1) {
|
|
1360
1389
|
product.selling_price = merged[0].totalPrice;
|
|
1361
1390
|
product.original_price = merged[0].totalPrice;
|
|
1362
|
-
product.metadata.price_breakdown = (0,
|
|
1391
|
+
product.metadata.price_breakdown = (0, import_slotMerge.buildPriceBreakdown)({
|
|
1363
1392
|
group: merged[0],
|
|
1364
|
-
productId: mapping.productId
|
|
1393
|
+
productId: mapping.productId,
|
|
1394
|
+
quotation: this.store.quotation
|
|
1365
1395
|
});
|
|
1366
1396
|
}
|
|
1367
1397
|
} else if (product.product_id != null) {
|
|
1368
|
-
const
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
datetime: now,
|
|
1373
|
-
fallbackPrice: product.selling_price
|
|
1398
|
+
const quotationPrice = this.store.quotation.getPriceForProduct({
|
|
1399
|
+
productId: product.product_id,
|
|
1400
|
+
variantId: product.product_variant_id ?? void 0,
|
|
1401
|
+
datetime: now
|
|
1374
1402
|
});
|
|
1375
|
-
|
|
1376
|
-
|
|
1403
|
+
if (quotationPrice !== null) {
|
|
1404
|
+
product.selling_price = quotationPrice;
|
|
1405
|
+
product.original_price = quotationPrice;
|
|
1406
|
+
}
|
|
1377
1407
|
}
|
|
1378
1408
|
}
|
|
1379
1409
|
}
|
|
1380
1410
|
async scanCode(code, customerId) {
|
|
1381
|
-
this.logMethodStart(
|
|
1382
|
-
code
|
|
1383
|
-
});
|
|
1411
|
+
this.logMethodStart("scanCode", { code });
|
|
1384
1412
|
try {
|
|
1385
|
-
if (!this.store.order)
|
|
1413
|
+
if (!this.store.order)
|
|
1414
|
+
throw new Error("order 模块未初始化");
|
|
1386
1415
|
const result = await this.store.order.scanCode(code, customerId);
|
|
1387
1416
|
if (result.isAvailable) {
|
|
1388
|
-
await this.store.order.recalculateSummary({
|
|
1389
|
-
createIfMissing: true
|
|
1390
|
-
});
|
|
1417
|
+
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
1391
1418
|
this.store.order.persistTempOrder();
|
|
1392
1419
|
}
|
|
1393
|
-
this.logMethodSuccess(
|
|
1394
|
-
isAvailable: result.isAvailable
|
|
1395
|
-
});
|
|
1420
|
+
this.logMethodSuccess("scanCode", { isAvailable: result.isAvailable });
|
|
1396
1421
|
return result;
|
|
1397
1422
|
} catch (error) {
|
|
1398
|
-
this.logMethodError(
|
|
1423
|
+
this.logMethodError("scanCode", error);
|
|
1399
1424
|
throw error;
|
|
1400
1425
|
}
|
|
1401
1426
|
}
|
|
1402
|
-
|
|
1403
1427
|
/** 获取当前折扣列表(包装 order.getDiscountList) */
|
|
1404
1428
|
getDiscountList() {
|
|
1405
|
-
if (!this.store.order)
|
|
1429
|
+
if (!this.store.order)
|
|
1430
|
+
return [];
|
|
1406
1431
|
return this.store.order.getDiscountList();
|
|
1407
1432
|
}
|
|
1408
|
-
|
|
1409
1433
|
/** 勾选/取消勾选某张折扣券,重新计算折扣并持久化 */
|
|
1410
1434
|
async setDiscountSelected(params) {
|
|
1411
|
-
|
|
1435
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1436
|
+
this.logMethodStart("setDiscountSelected", params);
|
|
1412
1437
|
try {
|
|
1413
|
-
if (!this.store.order)
|
|
1438
|
+
if (!this.store.order)
|
|
1439
|
+
throw new Error("order 模块未初始化");
|
|
1414
1440
|
const list = this.store.order.getDiscountList();
|
|
1415
|
-
const beforeTarget = list.find(d => d.id === params.discountId) || null;
|
|
1416
|
-
const updated = list.map(
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1441
|
+
const beforeTarget = list.find((d) => d.id === params.discountId) || null;
|
|
1442
|
+
const updated = list.map(
|
|
1443
|
+
(d) => d.id === params.discountId ? {
|
|
1444
|
+
...d,
|
|
1445
|
+
isSelected: params.isSelected,
|
|
1446
|
+
isManualSelect: !params.isSelected
|
|
1447
|
+
} : d
|
|
1448
|
+
);
|
|
1449
|
+
const updatedTarget = updated.find((d) => d.id === params.discountId) || null;
|
|
1422
1450
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
1423
1451
|
const orderStore = this.store.order.store || {};
|
|
1424
1452
|
const discountModule = orderStore.discount;
|
|
1425
1453
|
const rulesModule = orderStore.rules;
|
|
1426
|
-
const holders = tempOrder.holder
|
|
1427
|
-
form_record_id: tempOrder.holder.form_record_id
|
|
1428
|
-
}] : [];
|
|
1454
|
+
const holders = ((_a = tempOrder.holder) == null ? void 0 : _a.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
|
|
1429
1455
|
let nextDiscountList = updated;
|
|
1430
|
-
await discountModule
|
|
1456
|
+
await (discountModule == null ? void 0 : discountModule.setDiscountList(updated));
|
|
1431
1457
|
if (rulesModule) {
|
|
1432
|
-
const result = rulesModule.calcDiscount(
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
};
|
|
1444
|
-
if (result
|
|
1458
|
+
const result = rulesModule.calcDiscount(
|
|
1459
|
+
{
|
|
1460
|
+
productList: tempOrder.products,
|
|
1461
|
+
discountList: updated,
|
|
1462
|
+
holders,
|
|
1463
|
+
isFormSubject: !!((_b = tempOrder.holder) == null ? void 0 : _b.type) && tempOrder.holder.type === "form"
|
|
1464
|
+
},
|
|
1465
|
+
{
|
|
1466
|
+
discountId: params.discountId,
|
|
1467
|
+
isSelected: params.isSelected
|
|
1468
|
+
}
|
|
1469
|
+
) || { productList: tempOrder.products, discountList: updated };
|
|
1470
|
+
if (result == null ? void 0 : result.productList) {
|
|
1445
1471
|
tempOrder.products = result.productList;
|
|
1446
1472
|
}
|
|
1447
|
-
if (result
|
|
1473
|
+
if (result == null ? void 0 : result.discountList) {
|
|
1448
1474
|
nextDiscountList = result.discountList;
|
|
1449
1475
|
if (!params.isSelected) {
|
|
1450
|
-
const beforeSelectedIds = new Set(
|
|
1476
|
+
const beforeSelectedIds = new Set(
|
|
1477
|
+
updated.filter((d) => d.isSelected).map((d) => d.id)
|
|
1478
|
+
);
|
|
1451
1479
|
for (const d of nextDiscountList) {
|
|
1452
1480
|
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
1453
1481
|
d.isSelected = false;
|
|
@@ -1456,251 +1484,245 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
1456
1484
|
}
|
|
1457
1485
|
}
|
|
1458
1486
|
}
|
|
1459
|
-
const selectedResourceIds = new Set(
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
// 目的:避免 unselect 后 selling_price 残留、reselect 时把残留价带进下一轮 Rules 造成双折扣。
|
|
1463
|
-
// 手动改价商品(_origin.isManualDiscount=true)不参与券流程归一化,保留手工价。
|
|
1487
|
+
const selectedResourceIds = new Set(
|
|
1488
|
+
nextDiscountList.filter((d) => d.isSelected).map((d) => d.id)
|
|
1489
|
+
);
|
|
1464
1490
|
for (const product of tempOrder.products) {
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
product.discount_list = (product.discount_list || []).filter(pd => {
|
|
1469
|
-
|
|
1491
|
+
const origin = this.readProductOriginFromTempOrder(tempOrder, product);
|
|
1492
|
+
if (origin == null ? void 0 : origin.isManualDiscount)
|
|
1493
|
+
continue;
|
|
1494
|
+
product.discount_list = (product.discount_list || []).filter((pd) => {
|
|
1495
|
+
var _a2;
|
|
1496
|
+
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
|
1470
1497
|
return rid != null && selectedResourceIds.has(rid);
|
|
1471
1498
|
});
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
const optionSum = (0,
|
|
1477
|
-
const sourcePrice = product.metadata
|
|
1478
|
-
const newSourceSellingPrice = new
|
|
1479
|
-
const newMainSellingPrice = new
|
|
1499
|
+
const totalPerUnitDiscount = (product.discount_list || []).reduce(
|
|
1500
|
+
(sum, pd) => sum + (pd.amount || 0),
|
|
1501
|
+
0
|
|
1502
|
+
);
|
|
1503
|
+
const optionSum = (0, import_utils3.sumOptionUnitPrice)((0, import_utils3.getProductSkuOptions)(product));
|
|
1504
|
+
const sourcePrice = ((_c = product.metadata) == null ? void 0 : _c.source_product_price) ?? (((_d = product.metadata) == null ? void 0 : _d.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
|
|
1505
|
+
const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1506
|
+
const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
1480
1507
|
if (product.metadata) {
|
|
1481
1508
|
product.metadata.main_product_selling_price = newMainSellingPrice;
|
|
1482
1509
|
product.metadata.price_schema_version = 2;
|
|
1483
1510
|
}
|
|
1484
|
-
product.selling_price = (0,
|
|
1511
|
+
product.selling_price = (0, import_utils3.composeLinePrice)({
|
|
1485
1512
|
mainPrice: newMainSellingPrice,
|
|
1486
1513
|
bundle: product.product_bundle
|
|
1487
1514
|
});
|
|
1488
1515
|
}
|
|
1489
|
-
|
|
1490
|
-
await discountModule
|
|
1491
|
-
tempOrder.discount_list = (nextDiscountList || []).filter(d => d.isSelected);
|
|
1492
|
-
const afterApplyTarget = this.store.order.getDiscountList().find(d => d.id === params.discountId) || null;
|
|
1493
|
-
await this.store.order.recalculateSummary({
|
|
1494
|
-
createIfMissing: true
|
|
1495
|
-
});
|
|
1516
|
+
import_Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1517
|
+
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
1518
|
+
tempOrder.discount_list = (nextDiscountList || []).filter((d) => d.isSelected);
|
|
1519
|
+
const afterApplyTarget = this.store.order.getDiscountList().find((d) => d.id === params.discountId) || null;
|
|
1520
|
+
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
1496
1521
|
this.store.order.persistTempOrder();
|
|
1497
|
-
const finalSummary = this.store.order.getTempOrder()
|
|
1498
|
-
const finalProduct = this.store.order.getTempOrder()
|
|
1499
|
-
this.logMethodSuccess(
|
|
1500
|
-
const finalTarget = this.store.order.getDiscountList().find(d => d.id === params.discountId) || null;
|
|
1522
|
+
const finalSummary = ((_e = this.store.order.getTempOrder()) == null ? void 0 : _e.summary) || null;
|
|
1523
|
+
const finalProduct = ((_g = (_f = this.store.order.getTempOrder()) == null ? void 0 : _f.products) == null ? void 0 : _g[0]) || null;
|
|
1524
|
+
this.logMethodSuccess("setDiscountSelected", params);
|
|
1525
|
+
const finalTarget = this.store.order.getDiscountList().find((d) => d.id === params.discountId) || null;
|
|
1501
1526
|
return this.store.order.getDiscountList();
|
|
1502
1527
|
} catch (error) {
|
|
1503
|
-
this.logMethodError(
|
|
1528
|
+
this.logMethodError("setDiscountSelected", error);
|
|
1504
1529
|
throw error;
|
|
1505
1530
|
}
|
|
1506
1531
|
}
|
|
1507
1532
|
async addNewOrder() {
|
|
1508
|
-
this.logMethodStart(
|
|
1533
|
+
this.logMethodStart("addNewOrder");
|
|
1509
1534
|
try {
|
|
1510
|
-
if (!this.store.order)
|
|
1535
|
+
if (!this.store.order)
|
|
1536
|
+
throw new Error("order 模块未初始化");
|
|
1511
1537
|
const tempOrder = await this.store.order.addNewOrder();
|
|
1512
|
-
this.logMethodSuccess(
|
|
1538
|
+
this.logMethodSuccess("addNewOrder", {
|
|
1513
1539
|
productCount: tempOrder.products.length
|
|
1514
1540
|
});
|
|
1515
1541
|
return tempOrder;
|
|
1516
1542
|
} catch (error) {
|
|
1517
|
-
this.logMethodError(
|
|
1543
|
+
this.logMethodError("addNewOrder", error);
|
|
1518
1544
|
throw error;
|
|
1519
1545
|
}
|
|
1520
1546
|
}
|
|
1521
1547
|
getOrderProducts() {
|
|
1522
|
-
if (!this.store.order)
|
|
1523
|
-
|
|
1548
|
+
if (!this.store.order)
|
|
1549
|
+
throw new Error("order 模块未初始化");
|
|
1550
|
+
const products = this.store.order.getOrderProducts();
|
|
1551
|
+
return products;
|
|
1524
1552
|
}
|
|
1525
1553
|
async getSummary() {
|
|
1526
|
-
this.logMethodStart(
|
|
1554
|
+
this.logMethodStart("getSummary");
|
|
1527
1555
|
try {
|
|
1528
|
-
if (!this.store.order)
|
|
1529
|
-
|
|
1530
|
-
this.
|
|
1556
|
+
if (!this.store.order)
|
|
1557
|
+
throw new Error("order 模块未初始化");
|
|
1558
|
+
const summary = await this.store.order.getOrderSummary();
|
|
1559
|
+
this.logMethodSuccess("getSummary", {
|
|
1531
1560
|
totalAmount: summary.total_amount
|
|
1532
1561
|
});
|
|
1533
1562
|
return summary;
|
|
1534
1563
|
} catch (error) {
|
|
1535
|
-
this.logMethodError(
|
|
1564
|
+
this.logMethodError("getSummary", error);
|
|
1536
1565
|
throw error;
|
|
1537
1566
|
}
|
|
1538
1567
|
}
|
|
1539
1568
|
async submitOrder() {
|
|
1540
|
-
|
|
1569
|
+
var _a, _b, _c, _d, _e;
|
|
1570
|
+
this.logMethodStart("submitOrder");
|
|
1541
1571
|
try {
|
|
1542
1572
|
await this.validateBeforeSubmitByItemRule();
|
|
1543
1573
|
if (!this.store.order) {
|
|
1544
|
-
throw new Error(
|
|
1574
|
+
throw new Error("venueBooking解决方案需要 order 模块支持");
|
|
1545
1575
|
}
|
|
1546
1576
|
const result = await this.store.order.submitTempOrder({
|
|
1547
1577
|
cacheId: this.cacheId,
|
|
1548
|
-
platform: this.otherParams
|
|
1549
|
-
businessCode: this.otherParams
|
|
1550
|
-
channel: this.otherParams
|
|
1551
|
-
type: this.otherParams
|
|
1578
|
+
platform: (_a = this.otherParams) == null ? void 0 : _a.platform,
|
|
1579
|
+
businessCode: (_b = this.otherParams) == null ? void 0 : _b.businessCode,
|
|
1580
|
+
channel: (_c = this.otherParams) == null ? void 0 : _c.channel,
|
|
1581
|
+
type: (_d = this.otherParams) == null ? void 0 : _d.type
|
|
1552
1582
|
});
|
|
1553
1583
|
const tempOrder = this.store.order.getTempOrder();
|
|
1554
|
-
this.logMethodSuccess(
|
|
1555
|
-
productCount: tempOrder
|
|
1584
|
+
this.logMethodSuccess("submitOrder", {
|
|
1585
|
+
productCount: ((_e = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _e.length) || 0
|
|
1556
1586
|
});
|
|
1557
1587
|
return result;
|
|
1558
1588
|
} catch (error) {
|
|
1559
|
-
this.logMethodError(
|
|
1560
|
-
throw error;
|
|
1561
|
-
}
|
|
1562
|
-
}
|
|
1563
|
-
|
|
1564
|
-
/**
|
|
1565
|
-
* 0 元订单免费领取(非定金场景)
|
|
1566
|
-
* 与 appointment getFreeProduct 同接口:POST /pay/order/free-pay/:id
|
|
1567
|
-
*/
|
|
1568
|
-
async submitFreeOrder(id) {
|
|
1569
|
-
this.logMethodStart('submitFreeOrder', {
|
|
1570
|
-
id
|
|
1571
|
-
});
|
|
1572
|
-
try {
|
|
1573
|
-
if (!id) {
|
|
1574
|
-
throw new Error('订单 ID 不能为空');
|
|
1575
|
-
}
|
|
1576
|
-
const res = await this.request.post(`/pay/order/free-pay/${id}`);
|
|
1577
|
-
this.logMethodSuccess('submitFreeOrder', {
|
|
1578
|
-
id,
|
|
1579
|
-
status: res?.status
|
|
1580
|
-
});
|
|
1581
|
-
return res;
|
|
1582
|
-
} catch (error) {
|
|
1583
|
-
this.logMethodError('submitFreeOrder', error);
|
|
1589
|
+
this.logMethodError("submitOrder", error);
|
|
1584
1590
|
throw error;
|
|
1585
1591
|
}
|
|
1586
1592
|
}
|
|
1587
1593
|
async addProductToOrder(product) {
|
|
1588
|
-
|
|
1594
|
+
var _a;
|
|
1595
|
+
this.logMethodStart("addProductToOrder", {
|
|
1589
1596
|
product_id: product.product_id,
|
|
1590
1597
|
product_variant_id: product.product_variant_id
|
|
1591
1598
|
});
|
|
1592
1599
|
try {
|
|
1593
|
-
if (!this.store.order)
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
datetime: (0,
|
|
1600
|
-
fallbackPrice: product.selling_price
|
|
1600
|
+
if (!this.store.order)
|
|
1601
|
+
throw new Error("order 模块未初始化");
|
|
1602
|
+
if (!((_a = product.metadata) == null ? void 0 : _a.venue_booking) && this.store.quotation && product.product_id != null) {
|
|
1603
|
+
const quotationPrice = this.store.quotation.getPriceForProduct({
|
|
1604
|
+
productId: product.product_id,
|
|
1605
|
+
variantId: product.product_variant_id ?? void 0,
|
|
1606
|
+
datetime: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
|
|
1601
1607
|
});
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1608
|
+
if (quotationPrice !== null) {
|
|
1609
|
+
product.selling_price = quotationPrice;
|
|
1610
|
+
product.original_price = quotationPrice;
|
|
1611
|
+
} else if (product.selling_price != null) {
|
|
1612
|
+
product.original_price = product.selling_price;
|
|
1613
|
+
}
|
|
1606
1614
|
}
|
|
1607
1615
|
const products = await this.store.order.addProductToOrder(product);
|
|
1608
1616
|
await this.refreshItemRuleQuantityLimits();
|
|
1609
1617
|
await this.refreshCartValidationPassed();
|
|
1610
|
-
this.logMethodSuccess(
|
|
1618
|
+
this.logMethodSuccess("addProductToOrder", {
|
|
1611
1619
|
productCount: products.length
|
|
1612
1620
|
});
|
|
1613
1621
|
return products;
|
|
1614
1622
|
} catch (error) {
|
|
1615
|
-
this.logMethodError(
|
|
1623
|
+
this.logMethodError("addProductToOrder", error);
|
|
1616
1624
|
throw error;
|
|
1617
1625
|
}
|
|
1618
1626
|
}
|
|
1619
|
-
async
|
|
1620
|
-
this.logMethodStart(
|
|
1627
|
+
async updateOrderProduct(params) {
|
|
1628
|
+
this.logMethodStart("updateOrderProduct", {
|
|
1621
1629
|
product_id: params.product_id,
|
|
1622
1630
|
product_variant_id: params.product_variant_id
|
|
1623
1631
|
});
|
|
1624
1632
|
try {
|
|
1625
|
-
if (!this.store.order)
|
|
1626
|
-
|
|
1633
|
+
if (!this.store.order)
|
|
1634
|
+
throw new Error("order 模块未初始化");
|
|
1635
|
+
const products = await this.store.order.updateOrderProduct(params);
|
|
1627
1636
|
await this.refreshItemRuleQuantityLimits();
|
|
1628
1637
|
await this.refreshCartValidationPassed();
|
|
1629
|
-
this.logMethodSuccess(
|
|
1638
|
+
this.logMethodSuccess("updateOrderProduct", {
|
|
1630
1639
|
productCount: products.length
|
|
1631
1640
|
});
|
|
1632
1641
|
return products;
|
|
1633
1642
|
} catch (error) {
|
|
1634
|
-
this.logMethodError(
|
|
1643
|
+
this.logMethodError("updateOrderProduct", error);
|
|
1635
1644
|
throw error;
|
|
1636
1645
|
}
|
|
1637
1646
|
}
|
|
1638
1647
|
async removeProductFromOrder(identity) {
|
|
1639
|
-
|
|
1648
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1649
|
+
this.logMethodStart("removeProductFromOrder", {
|
|
1640
1650
|
product_id: identity.product_id,
|
|
1641
1651
|
product_variant_id: identity.product_variant_id
|
|
1642
1652
|
});
|
|
1643
1653
|
try {
|
|
1644
|
-
if (!this.store.order)
|
|
1645
|
-
|
|
1654
|
+
if (!this.store.order)
|
|
1655
|
+
throw new Error("order 模块未初始化");
|
|
1656
|
+
const tempOrder = ((_b = (_a = this.store.order).getTempOrder) == null ? void 0 : _b.call(_a)) || ((_d = (_c = this.store.order).ensureTempOrder) == null ? void 0 : _d.call(_c));
|
|
1646
1657
|
const products = await this.store.order.removeProductFromOrder(identity);
|
|
1647
|
-
if (tempOrder
|
|
1648
|
-
const venueProductUids = new Set();
|
|
1649
|
-
const venueBookingUids = new Set();
|
|
1658
|
+
if ((_e = tempOrder == null ? void 0 : tempOrder.bookings) == null ? void 0 : _e.length) {
|
|
1659
|
+
const venueProductUids = /* @__PURE__ */ new Set();
|
|
1660
|
+
const venueBookingUids = /* @__PURE__ */ new Set();
|
|
1650
1661
|
for (const product of tempOrder.products || []) {
|
|
1651
|
-
if (!product
|
|
1652
|
-
|
|
1653
|
-
if (product.
|
|
1662
|
+
if (!((_f = product == null ? void 0 : product.metadata) == null ? void 0 : _f.venue_booking))
|
|
1663
|
+
continue;
|
|
1664
|
+
if (product.identity_key)
|
|
1665
|
+
venueProductUids.add(String(product.identity_key));
|
|
1666
|
+
if ((_g = product.metadata) == null ? void 0 : _g.booking_uid) {
|
|
1654
1667
|
venueBookingUids.add(String(product.metadata.booking_uid));
|
|
1655
1668
|
}
|
|
1656
1669
|
}
|
|
1657
|
-
const beforeBookingCount = tempOrder.bookings
|
|
1658
|
-
tempOrder.bookings = (tempOrder.bookings || []).filter(booking => {
|
|
1659
|
-
|
|
1670
|
+
const beforeBookingCount = ((_h = tempOrder.bookings) == null ? void 0 : _h.length) || 0;
|
|
1671
|
+
tempOrder.bookings = (tempOrder.bookings || []).filter((booking) => {
|
|
1672
|
+
var _a2, _b2;
|
|
1673
|
+
if (!((_a2 = booking == null ? void 0 : booking.metadata) == null ? void 0 : _a2.venue_booking))
|
|
1674
|
+
return true;
|
|
1660
1675
|
if (booking.product_uid) {
|
|
1661
1676
|
return venueProductUids.has(String(booking.product_uid));
|
|
1662
1677
|
}
|
|
1663
|
-
const bookingUid = booking.metadata
|
|
1664
|
-
if (bookingUid)
|
|
1678
|
+
const bookingUid = (_b2 = booking.metadata) == null ? void 0 : _b2.unique_identification_number;
|
|
1679
|
+
if (bookingUid)
|
|
1680
|
+
return venueBookingUids.has(String(bookingUid));
|
|
1665
1681
|
return true;
|
|
1666
1682
|
});
|
|
1667
|
-
if ((tempOrder.bookings
|
|
1668
|
-
this.store.order.persistTempOrder
|
|
1683
|
+
if ((((_i = tempOrder.bookings) == null ? void 0 : _i.length) || 0) !== beforeBookingCount) {
|
|
1684
|
+
(_k = (_j = this.store.order).persistTempOrder) == null ? void 0 : _k.call(_j);
|
|
1669
1685
|
}
|
|
1670
1686
|
}
|
|
1671
1687
|
await this.refreshItemRuleQuantityLimits();
|
|
1672
1688
|
await this.refreshCartValidationPassed();
|
|
1673
|
-
this.logMethodSuccess(
|
|
1689
|
+
this.logMethodSuccess("removeProductFromOrder", {
|
|
1674
1690
|
productCount: products.length
|
|
1675
1691
|
});
|
|
1676
1692
|
return products;
|
|
1677
1693
|
} catch (error) {
|
|
1678
|
-
this.logMethodError(
|
|
1694
|
+
this.logMethodError("removeProductFromOrder", error);
|
|
1679
1695
|
throw error;
|
|
1680
1696
|
}
|
|
1681
1697
|
}
|
|
1682
1698
|
async getProductList() {
|
|
1683
1699
|
if (this.productsLoaded) {
|
|
1684
|
-
return (0,
|
|
1700
|
+
return (0, import_utils.attachItemRuleLimitsToTopLevelProducts)(
|
|
1701
|
+
this.getAddonProductsList(),
|
|
1702
|
+
this.store.itemRuleQuantityLimits || []
|
|
1703
|
+
);
|
|
1685
1704
|
}
|
|
1686
1705
|
const result = await this.loadAllProducts();
|
|
1687
|
-
return (0,
|
|
1706
|
+
return (0, import_utils.attachItemRuleLimitsToTopLevelProducts)(
|
|
1707
|
+
result.addonProducts,
|
|
1708
|
+
this.store.itemRuleQuantityLimits || []
|
|
1709
|
+
);
|
|
1688
1710
|
}
|
|
1689
|
-
|
|
1690
1711
|
// ─── ItemRule 引擎 ───
|
|
1691
|
-
|
|
1692
1712
|
async loadOpenDataConfig() {
|
|
1693
|
-
if (!this.store.openData)
|
|
1713
|
+
if (!this.store.openData)
|
|
1714
|
+
throw new Error("openData 模块未初始化");
|
|
1694
1715
|
const lastFetchedAt = this.store.openData.getLastFetchedAt();
|
|
1695
1716
|
const cachedData = this.store.openData.getOpenData();
|
|
1696
|
-
if (cachedData && lastFetchedAt && Date.now() - lastFetchedAt <
|
|
1717
|
+
if (cachedData && lastFetchedAt && Date.now() - lastFetchedAt < _VenueBookingImpl.OPEN_DATA_CACHE_TTL) {
|
|
1697
1718
|
this.otherParams.openData = cachedData;
|
|
1698
1719
|
return cachedData;
|
|
1699
1720
|
}
|
|
1700
|
-
if (this.loadOpenDataConfigInFlight)
|
|
1721
|
+
if (this.loadOpenDataConfigInFlight)
|
|
1722
|
+
return await this.loadOpenDataConfigInFlight;
|
|
1701
1723
|
this.loadOpenDataConfigInFlight = this.store.openData.fetchOpenData({
|
|
1702
|
-
scope:
|
|
1703
|
-
target:
|
|
1724
|
+
scope: "board",
|
|
1725
|
+
target: "venue_booking+online_store",
|
|
1704
1726
|
section_code: [...OPEN_DATA_SECTION_CODES]
|
|
1705
1727
|
});
|
|
1706
1728
|
try {
|
|
@@ -1714,53 +1736,52 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
1714
1736
|
async loadRuntimeConfigs() {
|
|
1715
1737
|
await this.loadOpenDataConfig();
|
|
1716
1738
|
const itemRuleConfigs = await this.ensureItemRuleConfigsLoaded();
|
|
1717
|
-
this.logMethodSuccess(
|
|
1739
|
+
this.logMethodSuccess("loadRuntimeConfigs", {
|
|
1718
1740
|
itemRuleCount: itemRuleConfigs.length
|
|
1719
1741
|
});
|
|
1720
|
-
return {
|
|
1721
|
-
itemRuleConfigs
|
|
1722
|
-
};
|
|
1742
|
+
return { itemRuleConfigs };
|
|
1723
1743
|
}
|
|
1724
1744
|
async fetchItemRuleConfigsByModelIds(strategyModelIds) {
|
|
1725
|
-
this.logMethodStart(
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
if (!strategyModelIds.length) return [];
|
|
1745
|
+
this.logMethodStart("fetchItemRuleConfigsByModelIds", { strategyModelIds });
|
|
1746
|
+
if (!strategyModelIds.length)
|
|
1747
|
+
return [];
|
|
1729
1748
|
try {
|
|
1730
|
-
const result = await this.request.get(
|
|
1749
|
+
const result = await this.request.get("/promotion", {
|
|
1731
1750
|
skip: 1,
|
|
1732
1751
|
num: 99,
|
|
1733
|
-
status:
|
|
1752
|
+
status: "active",
|
|
1734
1753
|
ids: strategyModelIds
|
|
1735
1754
|
});
|
|
1736
1755
|
let configs = [];
|
|
1737
1756
|
if (result.code === 200) {
|
|
1738
|
-
configs = result.data.list.map(item => item.metadata);
|
|
1757
|
+
configs = result.data.list.map((item) => item.metadata);
|
|
1739
1758
|
}
|
|
1740
|
-
this.logMethodSuccess(
|
|
1759
|
+
this.logMethodSuccess("fetchItemRuleConfigsByModelIds", {
|
|
1741
1760
|
strategyModelIds,
|
|
1742
1761
|
strategyCount: configs.length
|
|
1743
1762
|
});
|
|
1744
1763
|
return configs;
|
|
1745
1764
|
} catch (error) {
|
|
1746
|
-
this.logMethodError(
|
|
1747
|
-
strategyModelIds
|
|
1748
|
-
});
|
|
1765
|
+
this.logMethodError("fetchItemRuleConfigsByModelIds", error, { strategyModelIds });
|
|
1749
1766
|
return [];
|
|
1750
1767
|
}
|
|
1751
1768
|
}
|
|
1752
1769
|
async buildPrefillProductSourceMap() {
|
|
1753
|
-
const sourceMap = new Map();
|
|
1770
|
+
const sourceMap = /* @__PURE__ */ new Map();
|
|
1754
1771
|
try {
|
|
1755
1772
|
const productList = await this.getProductList();
|
|
1756
|
-
if (!Array.isArray(productList))
|
|
1757
|
-
|
|
1758
|
-
const
|
|
1759
|
-
|
|
1760
|
-
if (
|
|
1773
|
+
if (!Array.isArray(productList))
|
|
1774
|
+
return sourceMap;
|
|
1775
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1776
|
+
const collectFromValue = (value) => {
|
|
1777
|
+
if (!value || typeof value !== "object")
|
|
1778
|
+
return;
|
|
1779
|
+
if (visited.has(value))
|
|
1780
|
+
return;
|
|
1761
1781
|
visited.add(value);
|
|
1762
1782
|
if (Array.isArray(value)) {
|
|
1763
|
-
for (const item of value)
|
|
1783
|
+
for (const item of value)
|
|
1784
|
+
collectFromValue(item);
|
|
1764
1785
|
return;
|
|
1765
1786
|
}
|
|
1766
1787
|
const node = value;
|
|
@@ -1769,16 +1790,18 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
1769
1790
|
if (Number.isFinite(productId) && productId > 0) {
|
|
1770
1791
|
const productVariantId = Number(node.product_variant_id ?? node.variant_id ?? 0);
|
|
1771
1792
|
const normalizedVariantId = Number.isNaN(productVariantId) ? 0 : productVariantId;
|
|
1772
|
-
const key = (0,
|
|
1773
|
-
if (!sourceMap.has(key))
|
|
1793
|
+
const key = (0, import_utils.buildProductKey)(productId, normalizedVariantId);
|
|
1794
|
+
if (!sourceMap.has(key))
|
|
1795
|
+
sourceMap.set(key, node);
|
|
1774
1796
|
}
|
|
1775
1797
|
for (const childValue of Object.values(node)) {
|
|
1776
|
-
if (childValue && typeof childValue ===
|
|
1798
|
+
if (childValue && typeof childValue === "object")
|
|
1799
|
+
collectFromValue(childValue);
|
|
1777
1800
|
}
|
|
1778
1801
|
};
|
|
1779
1802
|
collectFromValue(productList);
|
|
1780
1803
|
} catch (error) {
|
|
1781
|
-
this.logMethodError(
|
|
1804
|
+
this.logMethodError("buildPrefillProductSourceMap", error);
|
|
1782
1805
|
}
|
|
1783
1806
|
return sourceMap;
|
|
1784
1807
|
}
|
|
@@ -1786,11 +1809,13 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
1786
1809
|
return this.itemRuleRuntimeConfig || {};
|
|
1787
1810
|
}
|
|
1788
1811
|
async ensureItemRuleConfigsLoaded() {
|
|
1789
|
-
if (this.itemRuleConfigs.length > 0)
|
|
1790
|
-
|
|
1812
|
+
if (this.itemRuleConfigs.length > 0)
|
|
1813
|
+
return this.itemRuleConfigs;
|
|
1814
|
+
if (this.itemRuleConfigsPromise)
|
|
1815
|
+
return this.itemRuleConfigsPromise;
|
|
1791
1816
|
this.itemRuleConfigsPromise = (async () => {
|
|
1792
1817
|
const runtimeConfig = this.getItemRuleRuntimeConfig();
|
|
1793
|
-
const staticConfigs = (0,
|
|
1818
|
+
const staticConfigs = (0, import_utils.normalizeItemRuleStrategies)(runtimeConfig.strategyConfigs);
|
|
1794
1819
|
if (staticConfigs.length > 0) {
|
|
1795
1820
|
this.itemRuleConfigs = staticConfigs;
|
|
1796
1821
|
this.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
|
|
@@ -1809,30 +1834,32 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
1809
1834
|
this.store.itemRuleQuantityLimits = [];
|
|
1810
1835
|
return [];
|
|
1811
1836
|
}
|
|
1812
|
-
const businessData = (0,
|
|
1813
|
-
tempOrder: this.
|
|
1837
|
+
const businessData = (0, import_utils.buildItemRuleBusinessData)({
|
|
1838
|
+
tempOrder: this.ensureVenueTempOrder(),
|
|
1814
1839
|
runtimeConfig: this.getItemRuleRuntimeConfig(),
|
|
1815
1840
|
itemRuleConfigs: this.itemRuleConfigs
|
|
1816
1841
|
});
|
|
1817
1842
|
const limits = this.itemRuleEvaluator.getQuantityLimits(businessData);
|
|
1818
1843
|
this.store.itemRuleQuantityLimits = limits;
|
|
1819
|
-
this.logMethodSuccess(
|
|
1820
|
-
limitCount: limits.length
|
|
1821
|
-
});
|
|
1844
|
+
this.logMethodSuccess("refreshItemRuleQuantityLimits", { limitCount: limits.length });
|
|
1822
1845
|
return limits;
|
|
1823
1846
|
} catch (error) {
|
|
1824
1847
|
this.store.itemRuleQuantityLimits = [];
|
|
1825
|
-
this.logMethodError(
|
|
1848
|
+
this.logMethodError("refreshItemRuleQuantityLimits", error);
|
|
1826
1849
|
return [];
|
|
1827
1850
|
}
|
|
1828
1851
|
}
|
|
1829
1852
|
async applyPrefillByItemRule() {
|
|
1830
|
-
|
|
1831
|
-
if (
|
|
1853
|
+
var _a, _b;
|
|
1854
|
+
if (this.itemRulePrefillApplied)
|
|
1855
|
+
return;
|
|
1856
|
+
if (!this.store.order)
|
|
1857
|
+
return;
|
|
1832
1858
|
const strategyConfigs = await this.ensureItemRuleConfigsLoaded();
|
|
1833
|
-
if (!strategyConfigs.length)
|
|
1834
|
-
|
|
1835
|
-
|
|
1859
|
+
if (!strategyConfigs.length)
|
|
1860
|
+
return;
|
|
1861
|
+
const businessData = (0, import_utils.buildItemRuleBusinessData)({
|
|
1862
|
+
tempOrder: this.ensureVenueTempOrder(),
|
|
1836
1863
|
runtimeConfig: this.getItemRuleRuntimeConfig(),
|
|
1837
1864
|
itemRuleConfigs: this.itemRuleConfigs
|
|
1838
1865
|
});
|
|
@@ -1842,92 +1869,84 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
1842
1869
|
return;
|
|
1843
1870
|
}
|
|
1844
1871
|
const productSourceMap = await this.buildPrefillProductSourceMap();
|
|
1845
|
-
const tempOrder = this.
|
|
1872
|
+
const tempOrder = this.ensureVenueTempOrder();
|
|
1846
1873
|
let hasChanges = false;
|
|
1847
1874
|
for (const prefillItem of prefillItems) {
|
|
1848
1875
|
const productId = Number(prefillItem.product_id);
|
|
1849
1876
|
const productVariantId = Number(prefillItem.product_variant_id ?? 0);
|
|
1850
|
-
const targetQuantity = (0,
|
|
1851
|
-
if (!Number.isFinite(productId) || targetQuantity <= 0)
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1877
|
+
const targetQuantity = (0, import_utils.toNonNegativeInt)(prefillItem.quantity);
|
|
1878
|
+
if (!Number.isFinite(productId) || targetQuantity <= 0)
|
|
1879
|
+
continue;
|
|
1880
|
+
if (Number.isNaN(productVariantId))
|
|
1881
|
+
continue;
|
|
1882
|
+
const sourceItem = productSourceMap.get((0, import_utils.buildProductKey)(productId, productVariantId)) || productSourceMap.get((0, import_utils.buildProductKey)(productId, 0)) || null;
|
|
1883
|
+
const productIndex = (0, import_utils.getProductIdentityIndex)(tempOrder.products, {
|
|
1855
1884
|
product_id: productId,
|
|
1856
1885
|
product_variant_id: productVariantId
|
|
1857
1886
|
});
|
|
1858
1887
|
if (productIndex === -1) {
|
|
1859
|
-
const sellingPrice = (0,
|
|
1860
|
-
|
|
1888
|
+
const sellingPrice = (0, import_utils.toPriceString)((sourceItem == null ? void 0 : sourceItem.price) ?? (sourceItem == null ? void 0 : sourceItem.selling_price), "0.00");
|
|
1889
|
+
const origin = { ...sourceItem || {}, item_rule_prefill: true, item_rule_id: prefillItem.ruleId };
|
|
1890
|
+
const product = (0, import_utils.normalizeOrderProduct)({
|
|
1861
1891
|
product_id: productId,
|
|
1862
1892
|
product_variant_id: productVariantId,
|
|
1863
1893
|
num: targetQuantity,
|
|
1864
1894
|
selling_price: sellingPrice,
|
|
1865
1895
|
original_price: sellingPrice,
|
|
1866
|
-
metadata: {
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
item_rule_prefill: true,
|
|
1873
|
-
item_rule_id: prefillItem.ruleId
|
|
1874
|
-
}
|
|
1875
|
-
}));
|
|
1896
|
+
metadata: { item_rule_prefill: true, item_rule_id: prefillItem.ruleId },
|
|
1897
|
+
_origin: origin
|
|
1898
|
+
});
|
|
1899
|
+
const productUid = String(((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) || "");
|
|
1900
|
+
this.attachProductOriginToTempOrder(tempOrder, productUid, origin);
|
|
1901
|
+
tempOrder.products.push(product);
|
|
1876
1902
|
hasChanges = true;
|
|
1877
1903
|
continue;
|
|
1878
1904
|
}
|
|
1879
1905
|
const targetProduct = tempOrder.products[productIndex];
|
|
1880
|
-
const
|
|
1906
|
+
const previousOrigin = this.readProductOriginFromTempOrder(tempOrder, targetProduct);
|
|
1907
|
+
const nextOrigin = sourceItem ? { ...previousOrigin || {}, ...sourceItem } : previousOrigin;
|
|
1908
|
+
const existedQuantity = (0, import_utils.toNonNegativeInt)(targetProduct.num);
|
|
1881
1909
|
const delta = targetQuantity - existedQuantity;
|
|
1882
1910
|
const nextProduct = {
|
|
1883
1911
|
...targetProduct,
|
|
1884
|
-
...
|
|
1885
|
-
|
|
1886
|
-
} : {}),
|
|
1887
|
-
metadata: {
|
|
1888
|
-
...(targetProduct.metadata || {}),
|
|
1889
|
-
item_rule_prefill: true,
|
|
1890
|
-
item_rule_id: prefillItem.ruleId
|
|
1891
|
-
},
|
|
1892
|
-
_origin: sourceItem ? {
|
|
1893
|
-
...(targetProduct._origin || {}),
|
|
1894
|
-
...sourceItem
|
|
1895
|
-
} : targetProduct._origin
|
|
1912
|
+
...delta > 0 ? { num: (0, import_utils.getSafeProductNum)(existedQuantity + delta) } : {},
|
|
1913
|
+
metadata: { ...targetProduct.metadata || {}, item_rule_prefill: true, item_rule_id: prefillItem.ruleId }
|
|
1896
1914
|
};
|
|
1897
|
-
if (delta > 0 || Boolean(
|
|
1915
|
+
if (delta > 0 || Boolean(
|
|
1916
|
+
sourceItem && (!previousOrigin || (previousOrigin == null ? void 0 : previousOrigin.price) !== (sourceItem == null ? void 0 : sourceItem.price))
|
|
1917
|
+
)) {
|
|
1918
|
+
const productUid = String(
|
|
1919
|
+
((_b = nextProduct.metadata) == null ? void 0 : _b.unique_identification_number) || ""
|
|
1920
|
+
);
|
|
1921
|
+
this.attachProductOriginToTempOrder(tempOrder, productUid, nextOrigin);
|
|
1898
1922
|
tempOrder.products[productIndex] = nextProduct;
|
|
1899
1923
|
hasChanges = true;
|
|
1900
1924
|
}
|
|
1901
1925
|
}
|
|
1902
1926
|
if (hasChanges) {
|
|
1903
|
-
// Prefill 属于 products CRUD 的一种形式:新增后让 Rules 重算,以支持自动应用可用优惠券。
|
|
1904
1927
|
this.store.order.applyDiscount();
|
|
1905
|
-
await this.store.order.recalculateSummary({
|
|
1906
|
-
createIfMissing: true
|
|
1907
|
-
});
|
|
1928
|
+
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
1908
1929
|
this.store.order.persistTempOrder();
|
|
1909
1930
|
}
|
|
1910
1931
|
await this.refreshItemRuleQuantityLimits();
|
|
1911
1932
|
this.itemRulePrefillApplied = true;
|
|
1912
|
-
this.logMethodSuccess(
|
|
1933
|
+
this.logMethodSuccess("applyPrefillByItemRule", {
|
|
1913
1934
|
prefillCount: prefillItems.length,
|
|
1914
1935
|
hasChanges
|
|
1915
1936
|
});
|
|
1916
1937
|
}
|
|
1917
1938
|
async applyItemRulePrefill() {
|
|
1918
|
-
this.logMethodStart(
|
|
1939
|
+
this.logMethodStart("applyItemRulePrefill");
|
|
1919
1940
|
await this.applyPrefillByItemRule();
|
|
1920
1941
|
await this.refreshItemRuleQuantityLimits();
|
|
1921
1942
|
await this.refreshCartValidationPassed();
|
|
1922
1943
|
}
|
|
1923
1944
|
async evaluateCartValidationByItemRule() {
|
|
1924
1945
|
const strategyConfigs = await this.ensureItemRuleConfigsLoaded();
|
|
1925
|
-
if (!strategyConfigs.length)
|
|
1926
|
-
passed: true,
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
const businessData = (0, _utils.buildItemRuleBusinessData)({
|
|
1930
|
-
tempOrder: this.ensureTempOrder(),
|
|
1946
|
+
if (!strategyConfigs.length)
|
|
1947
|
+
return { passed: true, failures: [] };
|
|
1948
|
+
const businessData = (0, import_utils.buildItemRuleBusinessData)({
|
|
1949
|
+
tempOrder: this.ensureVenueTempOrder(),
|
|
1931
1950
|
runtimeConfig: this.getItemRuleRuntimeConfig(),
|
|
1932
1951
|
itemRuleConfigs: this.itemRuleConfigs
|
|
1933
1952
|
});
|
|
@@ -1935,18 +1954,16 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
1935
1954
|
}
|
|
1936
1955
|
async validateBeforeSubmitByItemRule() {
|
|
1937
1956
|
const validationResult = await this.evaluateCartValidationByItemRule();
|
|
1938
|
-
if (validationResult.passed)
|
|
1957
|
+
if (validationResult.passed)
|
|
1958
|
+
return;
|
|
1939
1959
|
const firstFailure = validationResult.failures[0];
|
|
1940
|
-
const errorMessage = firstFailure
|
|
1960
|
+
const errorMessage = (firstFailure == null ? void 0 : firstFailure.validationMessage) || "当前购物车未满足商品规则,请调整后再提交";
|
|
1941
1961
|
const error = new Error(String(errorMessage));
|
|
1942
1962
|
error.failures = validationResult.failures;
|
|
1943
1963
|
throw error;
|
|
1944
1964
|
}
|
|
1945
1965
|
async refreshCartValidationPassed() {
|
|
1946
|
-
const previous = this.store.cartValidation || {
|
|
1947
|
-
passed: null,
|
|
1948
|
-
failures: []
|
|
1949
|
-
};
|
|
1966
|
+
const previous = this.store.cartValidation || { passed: null, failures: [] };
|
|
1950
1967
|
let nextState = {
|
|
1951
1968
|
passed: null,
|
|
1952
1969
|
failures: []
|
|
@@ -1958,15 +1975,12 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
1958
1975
|
failures: validationResult.failures || []
|
|
1959
1976
|
};
|
|
1960
1977
|
} catch {
|
|
1961
|
-
nextState = {
|
|
1962
|
-
passed: false,
|
|
1963
|
-
failures: []
|
|
1964
|
-
};
|
|
1978
|
+
nextState = { passed: false, failures: [] };
|
|
1965
1979
|
}
|
|
1966
1980
|
this.store.cartValidation = nextState;
|
|
1967
1981
|
const changed = previous.passed !== nextState.passed || previous.failures !== nextState.failures;
|
|
1968
1982
|
if (changed) {
|
|
1969
|
-
await this.core.effects.emit(
|
|
1983
|
+
await this.core.effects.emit(import_types.VenueBookingHooks.onCartValidationChanged, {
|
|
1970
1984
|
cartValidation: nextState,
|
|
1971
1985
|
cartValidationPassed: nextState.passed
|
|
1972
1986
|
});
|
|
@@ -1974,20 +1988,15 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
1974
1988
|
return nextState.passed;
|
|
1975
1989
|
}
|
|
1976
1990
|
async setItemRuleRuntimeConfig(config = {}) {
|
|
1977
|
-
|
|
1991
|
+
var _a, _b;
|
|
1992
|
+
this.logMethodStart("setItemRuleRuntimeConfig");
|
|
1978
1993
|
this.itemRuleRuntimeConfig = {
|
|
1979
1994
|
...this.itemRuleRuntimeConfig,
|
|
1980
1995
|
...config,
|
|
1981
|
-
pax: {
|
|
1982
|
-
|
|
1983
|
-
...(config?.pax || {})
|
|
1984
|
-
},
|
|
1985
|
-
custom: {
|
|
1986
|
-
...(this.itemRuleRuntimeConfig?.custom || {}),
|
|
1987
|
-
...(config?.custom || {})
|
|
1988
|
-
}
|
|
1996
|
+
pax: { ...((_a = this.itemRuleRuntimeConfig) == null ? void 0 : _a.pax) || {}, ...(config == null ? void 0 : config.pax) || {} },
|
|
1997
|
+
custom: { ...((_b = this.itemRuleRuntimeConfig) == null ? void 0 : _b.custom) || {}, ...(config == null ? void 0 : config.custom) || {} }
|
|
1989
1998
|
};
|
|
1990
|
-
if (
|
|
1999
|
+
if ("strategyConfigs" in config) {
|
|
1991
2000
|
this.itemRuleConfigs = [];
|
|
1992
2001
|
this.itemRuleConfigsPromise = null;
|
|
1993
2002
|
this.itemRuleEvaluator.setStrategyConfigs([]);
|
|
@@ -1995,54 +2004,54 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
1995
2004
|
this.itemRulePrefillApplied = false;
|
|
1996
2005
|
await this.refreshItemRuleQuantityLimits();
|
|
1997
2006
|
await this.refreshCartValidationPassed();
|
|
1998
|
-
this.logMethodSuccess(
|
|
2007
|
+
this.logMethodSuccess("setItemRuleRuntimeConfig", {
|
|
1999
2008
|
strategyCount: Array.isArray(this.itemRuleRuntimeConfig.strategyConfigs) ? this.itemRuleRuntimeConfig.strategyConfigs.length : 0
|
|
2000
2009
|
});
|
|
2001
2010
|
}
|
|
2002
2011
|
getOtherParams() {
|
|
2003
2012
|
return this.otherParams;
|
|
2004
2013
|
}
|
|
2005
|
-
|
|
2006
|
-
// ─── UI 状态缓存(按 cacheId 分桶,sessionStorage) ───
|
|
2007
|
-
//
|
|
2008
|
-
// 用于物料层持久化 UI 层面的轻量状态(如当前步骤、登录回跳意图等)。
|
|
2009
|
-
// 桶键:pisell.venueBooking.uiState:<cacheId>;内部以 JSON object 形式存储多个字段。
|
|
2010
|
-
// 无 cacheId 时所有方法自动降级为 no-op,上层不用判空。
|
|
2011
|
-
|
|
2012
|
-
static UI_STATE_KEY_PREFIX = 'pisell.venueBooking.uiState:';
|
|
2013
2014
|
getUIStateBucketKey() {
|
|
2014
|
-
if (!this.cacheId)
|
|
2015
|
-
|
|
2015
|
+
if (!this.cacheId)
|
|
2016
|
+
return null;
|
|
2017
|
+
return `${_VenueBookingImpl.UI_STATE_KEY_PREFIX}${this.cacheId}`;
|
|
2016
2018
|
}
|
|
2017
2019
|
readUIStateBucket() {
|
|
2020
|
+
var _a;
|
|
2018
2021
|
const key = this.getUIStateBucketKey();
|
|
2019
|
-
if (!key || !this.window
|
|
2022
|
+
if (!key || !((_a = this.window) == null ? void 0 : _a.sessionStorage))
|
|
2023
|
+
return {};
|
|
2020
2024
|
try {
|
|
2021
|
-
const raw = this.window.sessionStorage.getItem(key) ||
|
|
2025
|
+
const raw = this.window.sessionStorage.getItem(key) || "{}";
|
|
2022
2026
|
const parsed = JSON.parse(raw);
|
|
2023
|
-
return parsed && typeof parsed ===
|
|
2027
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
2024
2028
|
} catch {
|
|
2025
2029
|
return {};
|
|
2026
2030
|
}
|
|
2027
2031
|
}
|
|
2028
2032
|
writeUIStateBucket(bucket) {
|
|
2033
|
+
var _a;
|
|
2029
2034
|
const key = this.getUIStateBucketKey();
|
|
2030
|
-
if (!key || !this.window
|
|
2035
|
+
if (!key || !((_a = this.window) == null ? void 0 : _a.sessionStorage))
|
|
2036
|
+
return;
|
|
2031
2037
|
this.window.sessionStorage.setItem(key, JSON.stringify(bucket));
|
|
2032
2038
|
}
|
|
2033
2039
|
setUIState(key, value) {
|
|
2034
|
-
if (!this.getUIStateBucketKey())
|
|
2040
|
+
if (!this.getUIStateBucketKey())
|
|
2041
|
+
return;
|
|
2035
2042
|
const bucket = this.readUIStateBucket();
|
|
2036
2043
|
bucket[key] = value;
|
|
2037
2044
|
this.writeUIStateBucket(bucket);
|
|
2038
2045
|
}
|
|
2039
2046
|
getUIState(key) {
|
|
2040
|
-
if (!this.getUIStateBucketKey())
|
|
2047
|
+
if (!this.getUIStateBucketKey())
|
|
2048
|
+
return void 0;
|
|
2041
2049
|
const bucket = this.readUIStateBucket();
|
|
2042
2050
|
return bucket[key];
|
|
2043
2051
|
}
|
|
2044
2052
|
deleteUIState(key) {
|
|
2045
|
-
if (!this.getUIStateBucketKey())
|
|
2053
|
+
if (!this.getUIStateBucketKey())
|
|
2054
|
+
return;
|
|
2046
2055
|
const bucket = this.readUIStateBucket();
|
|
2047
2056
|
if (key in bucket) {
|
|
2048
2057
|
delete bucket[key];
|
|
@@ -2050,69 +2059,84 @@ class VenueBookingImpl extends _BaseModule.BaseModule {
|
|
|
2050
2059
|
}
|
|
2051
2060
|
}
|
|
2052
2061
|
setBookingHolder(bookingUid, holder) {
|
|
2053
|
-
|
|
2062
|
+
var _a, _b, _c, _d;
|
|
2063
|
+
if (!this.store.order)
|
|
2064
|
+
return;
|
|
2054
2065
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
2055
|
-
const booking = tempOrder.bookings
|
|
2066
|
+
const booking = (_a = tempOrder.bookings) == null ? void 0 : _a.find(
|
|
2067
|
+
(b) => {
|
|
2068
|
+
var _a2;
|
|
2069
|
+
return ((_a2 = b.metadata) == null ? void 0 : _a2.unique_identification_number) === bookingUid;
|
|
2070
|
+
}
|
|
2071
|
+
);
|
|
2056
2072
|
if (booking) {
|
|
2057
2073
|
booking.holder = holder;
|
|
2058
2074
|
}
|
|
2059
2075
|
for (const product of tempOrder.products) {
|
|
2060
|
-
const
|
|
2061
|
-
|
|
2062
|
-
|
|
2076
|
+
const runtimeProduct = product;
|
|
2077
|
+
const productBookingUid = ((_b = runtimeProduct.metadata) == null ? void 0 : _b.booking_uid) ?? ((_d = (_c = runtimeProduct._origin) == null ? void 0 : _c.product) == null ? void 0 : _d.bookingUuid);
|
|
2078
|
+
if (String(productBookingUid) !== String(bookingUid))
|
|
2079
|
+
continue;
|
|
2080
|
+
const origin = runtimeProduct._origin && typeof runtimeProduct._origin === "object" ? runtimeProduct._origin : {};
|
|
2063
2081
|
origin.holder = holder;
|
|
2064
|
-
|
|
2082
|
+
runtimeProduct._origin = origin;
|
|
2065
2083
|
}
|
|
2066
2084
|
this.store.order.notifyTempOrderChanged();
|
|
2067
2085
|
}
|
|
2068
|
-
|
|
2069
2086
|
/**
|
|
2070
2087
|
* 获取 holder 表单 map
|
|
2071
2088
|
*/
|
|
2072
2089
|
getHolderFormMap() {
|
|
2073
|
-
if (!this.store.holder)
|
|
2090
|
+
if (!this.store.holder)
|
|
2091
|
+
throw new Error("[VenueBooking] holder 模块未初始化");
|
|
2074
2092
|
return this.store.holder.getHolderFormMap();
|
|
2075
2093
|
}
|
|
2076
|
-
|
|
2077
2094
|
/**
|
|
2078
2095
|
* UI 层触发:按当前 holderMap 批量刷新所有表单的 records
|
|
2079
2096
|
*/
|
|
2080
2097
|
async refreshAllHolderFormRecords(params) {
|
|
2081
|
-
if (!this.store.holder)
|
|
2082
|
-
|
|
2098
|
+
if (!this.store.holder)
|
|
2099
|
+
throw new Error("[VenueBooking] holder 模块未初始化");
|
|
2100
|
+
const customer_id = (params == null ? void 0 : params.customer_id) ?? this.resolveHolderCustomerId();
|
|
2083
2101
|
return this.store.holder.refreshAllFormRecords({
|
|
2084
2102
|
...params,
|
|
2085
2103
|
customer_id,
|
|
2086
|
-
useCache: params
|
|
2104
|
+
useCache: (params == null ? void 0 : params.useCache) ?? false
|
|
2087
2105
|
});
|
|
2088
2106
|
}
|
|
2089
|
-
|
|
2090
2107
|
/**
|
|
2091
2108
|
* 添加表单记录
|
|
2092
2109
|
*/
|
|
2093
2110
|
appendFormRecord(params) {
|
|
2094
|
-
if (!this.store.holder)
|
|
2111
|
+
if (!this.store.holder)
|
|
2112
|
+
throw new Error("[VenueBooking] holder 模块未初始化");
|
|
2095
2113
|
return this.store.holder.appendFormRecord(params);
|
|
2096
2114
|
}
|
|
2097
|
-
|
|
2098
2115
|
// ─── OpenData 可用性 ───
|
|
2099
|
-
|
|
2100
2116
|
async checkOpenDataAvailability() {
|
|
2101
|
-
if (!this.store.openData)
|
|
2117
|
+
if (!this.store.openData)
|
|
2118
|
+
throw new Error("openData 模块未初始化");
|
|
2102
2119
|
await this.loadOpenDataConfig();
|
|
2103
2120
|
return this.store.openData.checkAvailability(this.store.schedule);
|
|
2104
2121
|
}
|
|
2105
|
-
async setOtherParams(params, {
|
|
2106
|
-
cover = false
|
|
2107
|
-
} = {}) {
|
|
2122
|
+
async setOtherParams(params, { cover = false } = {}) {
|
|
2108
2123
|
if (cover) {
|
|
2109
2124
|
this.otherParams = params;
|
|
2110
2125
|
} else {
|
|
2111
|
-
this.otherParams = {
|
|
2112
|
-
...this.otherParams,
|
|
2113
|
-
...params
|
|
2114
|
-
};
|
|
2126
|
+
this.otherParams = { ...this.otherParams, ...params };
|
|
2115
2127
|
}
|
|
2116
2128
|
}
|
|
2117
|
-
}
|
|
2118
|
-
|
|
2129
|
+
};
|
|
2130
|
+
var VenueBookingImpl = _VenueBookingImpl;
|
|
2131
|
+
VenueBookingImpl.OPEN_DATA_CACHE_TTL = 5 * 60 * 1e3;
|
|
2132
|
+
// ─── UI 状态缓存(按 cacheId 分桶,sessionStorage) ───
|
|
2133
|
+
//
|
|
2134
|
+
// 用于物料层持久化 UI 层面的轻量状态(如当前步骤、登录回跳意图等)。
|
|
2135
|
+
// 桶键:pisell.venueBooking.uiState:<cacheId>;内部以 JSON object 形式存储多个字段。
|
|
2136
|
+
// 无 cacheId 时所有方法自动降级为 no-op,上层不用判空。
|
|
2137
|
+
VenueBookingImpl.UI_STATE_KEY_PREFIX = "pisell.venueBooking.uiState:";
|
|
2138
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2139
|
+
0 && (module.exports = {
|
|
2140
|
+
VenueBookingImpl,
|
|
2141
|
+
...require("./types")
|
|
2142
|
+
});
|