@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,12 +1,24 @@
|
|
|
1
|
+
var _excluded = ["id"],
|
|
2
|
+
_excluded2 = ["product_id"],
|
|
3
|
+
_excluded3 = ["product_id"];
|
|
1
4
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
6
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
7
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
2
8
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
9
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
6
10
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
11
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
12
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
15
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
16
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
17
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
18
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
9
19
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
20
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
21
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
10
22
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
11
23
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
24
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
@@ -14,16 +26,137 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
14
26
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
15
27
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
16
28
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
29
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
30
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17
31
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
32
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
19
33
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
20
|
-
import
|
|
21
|
-
import {
|
|
34
|
+
import dayjs from 'dayjs';
|
|
35
|
+
import { createBookingTicketModule } from "./types";
|
|
36
|
+
import { getProductExtend as getProductExtendUtil, getResourceByIds as getResourceByIdsUtil, getResourceErrors as getResourceErrorsUtil, derivePresetStartTimeFromDate } from "../../modules/BookingContext";
|
|
37
|
+
import { BaseSalesImpl } from "../BaseSales";
|
|
22
38
|
import Scan from "./utils/scan";
|
|
39
|
+
import { formatOrderCustomerPatch } from "./utils/orderCustomer";
|
|
23
40
|
import { handleGlobalScan, handleCustomerScan, handleUniversalScan } from "./utils/scan/handleScan";
|
|
24
41
|
import scanCache from "./utils/scan/scanCache";
|
|
25
|
-
|
|
26
|
-
|
|
42
|
+
import { formatGlobalScanResult } from "./utils/scan/formatGlobalScan";
|
|
43
|
+
import { applyGlobalScan } from "./utils/scan/applyGlobalScan";
|
|
44
|
+
import { buildCartView } from "./utils/cartView";
|
|
45
|
+
import { buildCacheItemFromCartDetail, buildCacheItemFromDetail, buildRequiresDetailPayload as _buildRequiresDetailPayload, decideAddProduct as decideAddProductUtil, decideAfterDetail as decideAfterDetailUtil, decideAutoClose as decideAutoCloseUtil, getIsEject as getIsEjectUtil, getIsOnlySession as getIsOnlySessionUtil, transformDetailToProductAndBooking as transformDetailToProductAndBookingUtil } from "./utils/addProductDecision";
|
|
46
|
+
import { buildCacheItemFromOrderLine as buildCacheItemFromOrderLineUtil } from "../../modules/BookingContext/utils/buildCacheItemFromOrderLine";
|
|
47
|
+
import { buildSessionCatalogStaleInfo, isSessionCatalogDateStale } from "./utils/sessionCatalogStale";
|
|
48
|
+
import { buildNormalProductCacheItemFromOrderLine as buildNormalProductCacheItemFromOrderLineUtil } from "../../modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine";
|
|
49
|
+
import { buildProductOptionStringFromOrderLine } from "../../modules/BookingContext/utils/orderLineDisplay";
|
|
50
|
+
import { applyBookingsStatus, applyChildBookingStatus, resolveScheduleId, resolveStatusAfterTransition, restoreBookingsStatus, restoreChildBookingStatus } from "./utils/bookingStatus";
|
|
51
|
+
import { resolveBestAddTimePlan as _resolveBestAddTimePlan } from "./utils/resolveBestAddTimePlan";
|
|
52
|
+
import { createUuidV4 } from "../../modules/Order/utils";
|
|
53
|
+
var OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow'];
|
|
54
|
+
var OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 读取已有 booking 的协议唯一值,用于加时商品行绑定原预约。
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* const bookingUid = resolveBookingUidForAddTime(booking);
|
|
61
|
+
*/
|
|
62
|
+
function resolveBookingUidForAddTime(booking) {
|
|
63
|
+
var _booking$metadata;
|
|
64
|
+
var uid = booking === null || booking === void 0 || (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.unique_identification_number;
|
|
65
|
+
return uid === undefined || uid === null ? '' : String(uid);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 规范化加车数量,避免非法值进入 OrderModule。
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* const quantity = normalizeAddTimeQuantity(product.num);
|
|
73
|
+
*/
|
|
74
|
+
function normalizeAddTimeQuantity(value) {
|
|
75
|
+
var parsed = Math.floor(Number(value));
|
|
76
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : 1;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 解析加时时长,优先使用显式入参,其次回退商品字段。
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* const minutes = resolveAddTimeScheduleMinutes(input.product_add_schedule_time, product);
|
|
84
|
+
*/
|
|
85
|
+
function resolveAddTimeScheduleMinutes(explicitValue, product) {
|
|
86
|
+
var raw = explicitValue !== null && explicitValue !== void 0 ? explicitValue : product === null || product === void 0 ? void 0 : product.product_add_schedule_time;
|
|
87
|
+
if (raw === undefined || raw === null || raw === '') return undefined;
|
|
88
|
+
var parsed = Number(raw);
|
|
89
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 计算加时商品行价格字段,保持 `price` 与 `selling_price` 输入口径一致。
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* const price = resolveAddTimeProductPrice(input.price, product);
|
|
97
|
+
*/
|
|
98
|
+
function resolveAddTimeProductPrice(explicitValue, product) {
|
|
99
|
+
var _ref, _ref2;
|
|
100
|
+
return (_ref = (_ref2 = explicitValue !== null && explicitValue !== void 0 ? explicitValue : product === null || product === void 0 ? void 0 : product.price) !== null && _ref2 !== void 0 ? _ref2 : product === null || product === void 0 ? void 0 : product.selling_price) !== null && _ref !== void 0 ? _ref : product === null || product === void 0 ? void 0 : product.base_price;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 规范化加时覆盖分钟数。
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* const minutes = normalizeCoveredMinutes(input.coveredMinutes);
|
|
108
|
+
*/
|
|
109
|
+
function normalizeCoveredMinutes(value) {
|
|
110
|
+
var parsed = Math.ceil(Number(value));
|
|
111
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* 计算 booking 加时后的结束时间与时长。
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* const updates = buildAddTimeBookingTimePatch(booking, 30);
|
|
119
|
+
*/
|
|
120
|
+
function buildAddTimeBookingTimePatch(booking, coveredMinutes) {
|
|
121
|
+
if (coveredMinutes <= 0) return null;
|
|
122
|
+
var endDate = booking === null || booking === void 0 ? void 0 : booking.end_date;
|
|
123
|
+
var endTime = booking === null || booking === void 0 ? void 0 : booking.end_time;
|
|
124
|
+
if (!endDate || !endTime) {
|
|
125
|
+
throw new Error('[BookingTicket] addAddTimeProductsToBooking: booking.end_date/end_time 缺失');
|
|
126
|
+
}
|
|
127
|
+
var currentEnd = dayjs("".concat(endDate, " ").concat(endTime));
|
|
128
|
+
if (!currentEnd.isValid()) {
|
|
129
|
+
throw new Error('[BookingTicket] addAddTimeProductsToBooking: booking.end_date/end_time 无效');
|
|
130
|
+
}
|
|
131
|
+
var nextEnd = currentEnd.add(coveredMinutes, 'minute');
|
|
132
|
+
var currentDuration = Number(booking === null || booking === void 0 ? void 0 : booking.duration);
|
|
133
|
+
var duration = Number.isFinite(currentDuration) ? currentDuration + coveredMinutes : coveredMinutes;
|
|
134
|
+
if (booking !== null && booking !== void 0 && booking.start_date && booking !== null && booking !== void 0 && booking.start_time) {
|
|
135
|
+
var start = dayjs("".concat(booking.start_date, " ").concat(booking.start_time));
|
|
136
|
+
if (start.isValid()) {
|
|
137
|
+
var diffMinutes = nextEnd.diff(start, 'minute');
|
|
138
|
+
duration = diffMinutes > 0 ? diffMinutes : duration;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
end_date: nextEnd.format('YYYY-MM-DD'),
|
|
143
|
+
end_time: nextEnd.format('HH:mm'),
|
|
144
|
+
duration: duration
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function withProductOptionString(cacheItem) {
|
|
148
|
+
var _cacheItem$_extend;
|
|
149
|
+
var productOptionString = buildProductOptionStringFromOrderLine(cacheItem);
|
|
150
|
+
if (!productOptionString) return cacheItem;
|
|
151
|
+
return _objectSpread(_objectSpread({}, cacheItem), {}, {
|
|
152
|
+
product_option_string: (cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.product_option_string) || productOptionString,
|
|
153
|
+
_extend: _objectSpread(_objectSpread({}, (cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem._extend) || {}), {}, {
|
|
154
|
+
product_option_string: (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.product_option_string) || productOptionString
|
|
155
|
+
})
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
159
|
+
_inherits(BookingTicketImpl, _BaseSalesImpl);
|
|
27
160
|
var _super = _createSuper(BookingTicketImpl);
|
|
28
161
|
function BookingTicketImpl() {
|
|
29
162
|
var _this;
|
|
@@ -34,339 +167,1478 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
34
167
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
35
168
|
_defineProperty(_assertThisInitialized(_this), "defaultName", 'bookingTicket');
|
|
36
169
|
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
_defineProperty(_assertThisInitialized(_this), "store",
|
|
42
|
-
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
43
|
-
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
170
|
+
/**
|
|
171
|
+
* 子类覆盖 store 类型为 BookingTicket 子模块清单(在父类基础上追加 customer)。
|
|
172
|
+
* 父类按 `getRegisteredModuleNames` 注入成员到该 store。
|
|
173
|
+
*/
|
|
174
|
+
_defineProperty(_assertThisInitialized(_this), "store", {});
|
|
44
175
|
_defineProperty(_assertThisInitialized(_this), "platform", void 0);
|
|
45
|
-
// 平台类型,用于判断是 PC / H5
|
|
46
176
|
_defineProperty(_assertThisInitialized(_this), "scan", void 0);
|
|
177
|
+
_defineProperty(_assertThisInitialized(_this), "productCatalog", []);
|
|
178
|
+
_defineProperty(_assertThisInitialized(_this), "addTimeProductsCatalog", []);
|
|
179
|
+
_defineProperty(_assertThisInitialized(_this), "orderCustomerDiscountRefreshInFlight", null);
|
|
180
|
+
_defineProperty(_assertThisInitialized(_this), "orderCustomerDiscountRefreshCustomerId", null);
|
|
181
|
+
_defineProperty(_assertThisInitialized(_this), "loadOpenDataConfigInFlight", null);
|
|
47
182
|
return _this;
|
|
48
183
|
}
|
|
49
184
|
_createClass(BookingTicketImpl, [{
|
|
185
|
+
key: "getRegisteredModuleNames",
|
|
186
|
+
value:
|
|
187
|
+
/**
|
|
188
|
+
* 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer + bookingContext。
|
|
189
|
+
* bookingContext 是 SalesSdk 加车下沉所需的「预约 UI 上下文」(bookingConfig / resourcesOrigin / date)。
|
|
190
|
+
*/
|
|
191
|
+
function getRegisteredModuleNames() {
|
|
192
|
+
return [].concat(_toConsumableArray(_get(_getPrototypeOf(BookingTicketImpl.prototype), "getRegisteredModuleNames", this).call(this)), ['customer', 'bookingContext', 'openData']);
|
|
193
|
+
}
|
|
194
|
+
}, {
|
|
195
|
+
key: "getSubmitOrderSalesChannel",
|
|
196
|
+
value: function getSubmitOrderSalesChannel() {
|
|
197
|
+
var _this$core, _this$core$getChannel;
|
|
198
|
+
var channel = (_this$core = this.core) === null || _this$core === void 0 || (_this$core = _this$core.context) === null || _this$core === void 0 || (_this$core$getChannel = _this$core.getChannel) === null || _this$core$getChannel === void 0 ? void 0 : _this$core$getChannel.call(_this$core);
|
|
199
|
+
return !channel || channel === 'system' ? 'pos' : channel;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* 业务侧子模块工厂:BookingTicket 自带的 createBookingTicketModule 优先匹配;
|
|
204
|
+
* 未识别的模块名(如 BookingByStep 公共类型)回退到父类工厂。
|
|
205
|
+
*/
|
|
206
|
+
}, {
|
|
207
|
+
key: "createSubModule",
|
|
208
|
+
value: function createSubModule(moduleName) {
|
|
209
|
+
var localModule = createBookingTicketModule(moduleName, this.name);
|
|
210
|
+
if (localModule) return localModule;
|
|
211
|
+
return _get(_getPrototypeOf(BookingTicketImpl.prototype), "createSubModule", this).call(this, moduleName);
|
|
212
|
+
}
|
|
213
|
+
}, {
|
|
50
214
|
key: "initialize",
|
|
51
215
|
value: function () {
|
|
52
|
-
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core
|
|
53
|
-
var _this$otherParams
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
_this2 = this;
|
|
57
|
-
var targetCacheData, sessionData, _data, moduleArr;
|
|
216
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core) {
|
|
217
|
+
var _this$otherParams;
|
|
218
|
+
var options,
|
|
219
|
+
_args = arguments;
|
|
58
220
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
59
221
|
while (1) switch (_context.prev = _context.next) {
|
|
60
222
|
case 0:
|
|
61
|
-
|
|
62
|
-
this.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
this.window = core.getPlugin('window');
|
|
67
|
-
this.shopStore = core.getPlugin('shopStore');
|
|
223
|
+
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
224
|
+
this.scan = new Scan(this, "BOOKING_TICKET_SCAN:".concat(this.name));
|
|
225
|
+
_context.next = 4;
|
|
226
|
+
return _get(_getPrototypeOf(BookingTicketImpl.prototype), "initialize", this).call(this, core, options);
|
|
227
|
+
case 4:
|
|
68
228
|
if (this.request) {
|
|
69
|
-
_context.next =
|
|
229
|
+
_context.next = 6;
|
|
70
230
|
break;
|
|
71
231
|
}
|
|
72
232
|
throw new Error('bookingTicket解决方案需要 request 插件支持');
|
|
73
|
-
case
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
233
|
+
case 6:
|
|
234
|
+
this.platform = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform;
|
|
235
|
+
_context.next = 9;
|
|
236
|
+
return this.configureIdGeneratorFromOpenData();
|
|
237
|
+
case 9:
|
|
238
|
+
console.log('[BookingTicket] 初始化完成');
|
|
79
239
|
case 10:
|
|
80
|
-
// 如果有传 cacheid,默认需要收集上面这些模块里用户操作选中的数据
|
|
81
|
-
targetCacheData = {};
|
|
82
|
-
this.cacheId = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.cacheId;
|
|
83
|
-
this.platform = (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.platform;
|
|
84
|
-
this.scan = new Scan(this, 'BOOKING_TICKET_SCAN');
|
|
85
|
-
if ((_this$otherParams3 = this.otherParams) !== null && _this$otherParams3 !== void 0 && _this$otherParams3.cacheId) {
|
|
86
|
-
sessionData = this.window.sessionStorage.getItem(this.name);
|
|
87
|
-
if (sessionData) {
|
|
88
|
-
_data = JSON.parse(sessionData);
|
|
89
|
-
targetCacheData = _data[this.otherParams.cacheId];
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
moduleArr = ['cart', 'products', 'accountList', 'customer', 'order'];
|
|
93
|
-
moduleArr.forEach(function (step) {
|
|
94
|
-
var targetModule = createModule(step, _this2.name);
|
|
95
|
-
if (targetModule) {
|
|
96
|
-
var _targetCacheData, _this2$otherParams, _this2$otherParams2;
|
|
97
|
-
_this2.store[step] = targetModule;
|
|
98
|
-
_this2.core.registerModule(targetModule, {
|
|
99
|
-
initialState: (_targetCacheData = targetCacheData) === null || _targetCacheData === void 0 ? void 0 : _targetCacheData[targetModule.name],
|
|
100
|
-
otherParams: _objectSpread(_objectSpread({}, _this2.otherParams), {}, {
|
|
101
|
-
fatherModule: _this2.name,
|
|
102
|
-
openCache: (_this2$otherParams = _this2.otherParams) !== null && _this2$otherParams !== void 0 && _this2$otherParams.cacheId ? true : false,
|
|
103
|
-
cacheId: (_this2$otherParams2 = _this2.otherParams) === null || _this2$otherParams2 === void 0 ? void 0 : _this2$otherParams2.cacheId
|
|
104
|
-
})
|
|
105
|
-
});
|
|
106
|
-
} else {
|
|
107
|
-
throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
this.core.effects.emit("".concat(this.name, ":onInited"), {});
|
|
111
|
-
case 18:
|
|
112
240
|
case "end":
|
|
113
241
|
return _context.stop();
|
|
114
242
|
}
|
|
115
243
|
}, _callee, this);
|
|
116
244
|
}));
|
|
117
|
-
function initialize(_x
|
|
245
|
+
function initialize(_x) {
|
|
118
246
|
return _initialize.apply(this, arguments);
|
|
119
247
|
}
|
|
120
248
|
return initialize;
|
|
121
249
|
}()
|
|
122
|
-
/**
|
|
123
|
-
* 获取商品列表
|
|
124
|
-
* @param params 包含 schedule_date 的参数
|
|
125
|
-
* @returns 商品列表
|
|
126
|
-
*/
|
|
127
250
|
}, {
|
|
128
|
-
key: "
|
|
129
|
-
value:
|
|
130
|
-
var
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
251
|
+
key: "getBookingTicketBusinessCode",
|
|
252
|
+
value: function getBookingTicketBusinessCode() {
|
|
253
|
+
var _this$otherParams$bus, _this$otherParams2, _this$otherParams3;
|
|
254
|
+
var businessCode = (_this$otherParams$bus = (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.businessCode) !== null && _this$otherParams$bus !== void 0 ? _this$otherParams$bus : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.business_code;
|
|
255
|
+
if (businessCode === undefined || businessCode === null) return null;
|
|
256
|
+
var normalized = String(businessCode).trim();
|
|
257
|
+
return normalized || null;
|
|
258
|
+
}
|
|
259
|
+
}, {
|
|
260
|
+
key: "getIdGeneratorPlugin",
|
|
261
|
+
value: function getIdGeneratorPlugin() {
|
|
262
|
+
var _appPlugin$getApp, _app$getPlugin;
|
|
263
|
+
var appPlugin = this.core.getPlugin('app');
|
|
264
|
+
var app = appPlugin === null || appPlugin === void 0 || (_appPlugin$getApp = appPlugin.getApp) === null || _appPlugin$getApp === void 0 ? void 0 : _appPlugin$getApp.call(appPlugin);
|
|
265
|
+
return (app === null || app === void 0 || (_app$getPlugin = app.getPlugin) === null || _app$getPlugin === void 0 ? void 0 : _app$getPlugin.call(app, 'idGenerator')) || null;
|
|
266
|
+
}
|
|
267
|
+
}, {
|
|
268
|
+
key: "loadOpenDataConfig",
|
|
269
|
+
value: function () {
|
|
270
|
+
var _loadOpenDataConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
271
|
+
var businessCode, lastFetchedAt, cachedData, channel, openDataConfig;
|
|
139
272
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
140
273
|
while (1) switch (_context2.prev = _context2.next) {
|
|
141
274
|
case 0:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
275
|
+
if (this.store.openData) {
|
|
276
|
+
_context2.next = 2;
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
throw new Error('openData 模块未初始化');
|
|
280
|
+
case 2:
|
|
281
|
+
businessCode = this.getBookingTicketBusinessCode();
|
|
282
|
+
if (businessCode) {
|
|
283
|
+
_context2.next = 6;
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
console.warn('[BookingTicket] businessCode 缺失,跳过 OpenData 配置加载,当前 module name: ', this.name);
|
|
287
|
+
return _context2.abrupt("return", null);
|
|
153
288
|
case 6:
|
|
154
|
-
|
|
155
|
-
this.
|
|
156
|
-
|
|
289
|
+
lastFetchedAt = this.store.openData.getLastFetchedAt();
|
|
290
|
+
cachedData = this.store.openData.getOpenData();
|
|
291
|
+
if (!(cachedData && lastFetchedAt && Date.now() - lastFetchedAt < OPEN_DATA_CACHE_TTL)) {
|
|
292
|
+
_context2.next = 11;
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
this.otherParams.openData = cachedData;
|
|
296
|
+
return _context2.abrupt("return", cachedData);
|
|
157
297
|
case 11:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
298
|
+
if (!this.loadOpenDataConfigInFlight) {
|
|
299
|
+
_context2.next = 15;
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
_context2.next = 14;
|
|
303
|
+
return this.loadOpenDataConfigInFlight;
|
|
304
|
+
case 14:
|
|
305
|
+
return _context2.abrupt("return", _context2.sent);
|
|
162
306
|
case 15:
|
|
307
|
+
channel = this.getSubmitOrderSalesChannel();
|
|
308
|
+
this.loadOpenDataConfigInFlight = this.store.openData.fetchOpenData({
|
|
309
|
+
scope: 'board',
|
|
310
|
+
target: "".concat(businessCode, "+").concat(channel),
|
|
311
|
+
// target: `dine_in+pos`,
|
|
312
|
+
section_code: [].concat(OPEN_DATA_SECTION_CODES)
|
|
313
|
+
});
|
|
314
|
+
_context2.prev = 17;
|
|
315
|
+
_context2.next = 20;
|
|
316
|
+
return this.loadOpenDataConfigInFlight;
|
|
317
|
+
case 20:
|
|
318
|
+
openDataConfig = _context2.sent;
|
|
319
|
+
this.otherParams.openData = openDataConfig;
|
|
320
|
+
return _context2.abrupt("return", openDataConfig);
|
|
321
|
+
case 23:
|
|
322
|
+
_context2.prev = 23;
|
|
323
|
+
this.loadOpenDataConfigInFlight = null;
|
|
324
|
+
return _context2.finish(23);
|
|
325
|
+
case 26:
|
|
163
326
|
case "end":
|
|
164
327
|
return _context2.stop();
|
|
165
328
|
}
|
|
166
|
-
}, _callee2, this, [[
|
|
329
|
+
}, _callee2, this, [[17,, 23, 26]]);
|
|
167
330
|
}));
|
|
168
|
-
function
|
|
169
|
-
return
|
|
331
|
+
function loadOpenDataConfig() {
|
|
332
|
+
return _loadOpenDataConfig.apply(this, arguments);
|
|
170
333
|
}
|
|
171
|
-
return
|
|
334
|
+
return loadOpenDataConfig;
|
|
172
335
|
}()
|
|
173
|
-
/**
|
|
174
|
-
* 取消商品查询订阅
|
|
175
|
-
* @param subscriberId 订阅时传入的 subscriberId
|
|
176
|
-
*/
|
|
177
|
-
)
|
|
178
|
-
}, {
|
|
179
|
-
key: "unsubscribeProductQuery",
|
|
180
|
-
value: function unsubscribeProductQuery(subscriberId) {
|
|
181
|
-
var _this$core$server;
|
|
182
|
-
(_this$core$server = this.core.server) === null || _this$core$server === void 0 || _this$core$server.removeProductQuerySubscriber(subscriberId);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* 初始化外设扫码结果监听
|
|
187
|
-
*/
|
|
188
|
-
}, {
|
|
189
|
-
key: "initPeripheralsListener",
|
|
190
|
-
value: function initPeripheralsListener() {
|
|
191
|
-
this.scan.initPeripheralsListener();
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* 获取商品列表(不加载到模块中)
|
|
196
|
-
* @returns 商品列表
|
|
197
|
-
*/
|
|
198
336
|
}, {
|
|
199
|
-
key: "
|
|
200
|
-
value:
|
|
201
|
-
var
|
|
337
|
+
key: "getOpenData",
|
|
338
|
+
value: function () {
|
|
339
|
+
var _getOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
340
|
+
var _this$store$openData;
|
|
202
341
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
203
342
|
while (1) switch (_context3.prev = _context3.next) {
|
|
204
343
|
case 0:
|
|
205
|
-
return _context3.abrupt("return", this.store.
|
|
344
|
+
return _context3.abrupt("return", (_this$store$openData = this.store.openData) === null || _this$store$openData === void 0 ? void 0 : _this$store$openData.getOpenData());
|
|
206
345
|
case 1:
|
|
207
346
|
case "end":
|
|
208
347
|
return _context3.stop();
|
|
209
348
|
}
|
|
210
349
|
}, _callee3, this);
|
|
211
350
|
}));
|
|
212
|
-
function
|
|
213
|
-
return
|
|
351
|
+
function getOpenData() {
|
|
352
|
+
return _getOpenData.apply(this, arguments);
|
|
214
353
|
}
|
|
215
|
-
return
|
|
354
|
+
return getOpenData;
|
|
216
355
|
}()
|
|
217
|
-
/**
|
|
218
|
-
* 获取日程时间段点
|
|
219
|
-
* @param params 参数
|
|
220
|
-
* @returns 日程时间段点
|
|
221
|
-
*/
|
|
222
|
-
)
|
|
223
356
|
}, {
|
|
224
|
-
key: "
|
|
225
|
-
value:
|
|
226
|
-
var
|
|
227
|
-
var
|
|
357
|
+
key: "getShortNumberOrDeviceId",
|
|
358
|
+
value: function () {
|
|
359
|
+
var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
360
|
+
var getAsyncIotDeviceInfo, res;
|
|
228
361
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
229
362
|
while (1) switch (_context4.prev = _context4.next) {
|
|
230
363
|
case 0:
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
result = _context4.sent;
|
|
239
|
-
return _context4.abrupt("return", result.data || []);
|
|
364
|
+
getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
|
|
365
|
+
if (!getAsyncIotDeviceInfo) {
|
|
366
|
+
_context4.next = 7;
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
_context4.next = 4;
|
|
370
|
+
return getAsyncIotDeviceInfo === null || getAsyncIotDeviceInfo === void 0 ? void 0 : getAsyncIotDeviceInfo();
|
|
240
371
|
case 4:
|
|
372
|
+
res = _context4.sent;
|
|
373
|
+
if (!(res !== null && res !== void 0 && res.short_number)) {
|
|
374
|
+
_context4.next = 7;
|
|
375
|
+
break;
|
|
376
|
+
}
|
|
377
|
+
return _context4.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
|
|
378
|
+
case 7:
|
|
379
|
+
return _context4.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
|
|
380
|
+
case 8:
|
|
241
381
|
case "end":
|
|
242
382
|
return _context4.stop();
|
|
243
383
|
}
|
|
244
384
|
}, _callee4, this);
|
|
245
385
|
}));
|
|
246
|
-
function
|
|
247
|
-
return
|
|
386
|
+
function getShortNumberOrDeviceId() {
|
|
387
|
+
return _getShortNumberOrDeviceId.apply(this, arguments);
|
|
248
388
|
}
|
|
249
|
-
return
|
|
389
|
+
return getShortNumberOrDeviceId;
|
|
250
390
|
}()
|
|
251
|
-
/**
|
|
252
|
-
* 获取客户列表
|
|
253
|
-
* @param params 查询参数
|
|
254
|
-
* @returns 客户列表响应
|
|
255
|
-
*/
|
|
256
|
-
)
|
|
257
391
|
}, {
|
|
258
|
-
key: "
|
|
259
|
-
value:
|
|
260
|
-
var
|
|
261
|
-
var
|
|
262
|
-
|
|
263
|
-
_args5 = arguments;
|
|
392
|
+
key: "configureIdGeneratorFromOpenData",
|
|
393
|
+
value: function () {
|
|
394
|
+
var _configureIdGeneratorFromOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
395
|
+
var _openDataConfig, _openDataConfig2, _openDataConfig3, _openDataConfig4, _openDataConfig5, _openDataConfig6;
|
|
396
|
+
var openDataConfig, idGenerator, receiptSequenceLength, receiptSequenceStart, prefix, shopOrderPrefix, resetReceiptSequenceDaily, operatingDayBoundary, deviceId, businessCode;
|
|
264
397
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
265
398
|
while (1) switch (_context5.prev = _context5.next) {
|
|
266
399
|
case 0:
|
|
267
|
-
|
|
400
|
+
openDataConfig = null;
|
|
268
401
|
_context5.prev = 1;
|
|
269
402
|
_context5.next = 4;
|
|
270
|
-
return this.
|
|
403
|
+
return this.loadOpenDataConfig();
|
|
271
404
|
case 4:
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
405
|
+
openDataConfig = _context5.sent;
|
|
406
|
+
_context5.next = 11;
|
|
407
|
+
break;
|
|
408
|
+
case 7:
|
|
409
|
+
_context5.prev = 7;
|
|
276
410
|
_context5.t0 = _context5["catch"](1);
|
|
277
|
-
console.
|
|
278
|
-
|
|
279
|
-
case
|
|
411
|
+
console.warn('[BookingTicket] OpenData 配置加载失败,跳过 idGenerator 配置', _context5.t0);
|
|
412
|
+
return _context5.abrupt("return");
|
|
413
|
+
case 11:
|
|
414
|
+
// if (!openDataConfig) return;
|
|
415
|
+
idGenerator = this.getIdGeneratorPlugin();
|
|
416
|
+
if (idGenerator !== null && idGenerator !== void 0 && idGenerator.configure) {
|
|
417
|
+
_context5.next = 15;
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
420
|
+
console.warn('[BookingTicket] idGenerator 插件不可用,跳过配置');
|
|
421
|
+
return _context5.abrupt("return");
|
|
422
|
+
case 15:
|
|
423
|
+
receiptSequenceLength = this.normalizePositiveInteger((_openDataConfig = openDataConfig) === null || _openDataConfig === void 0 ? void 0 : _openDataConfig['sale.short_number_digits'], 5);
|
|
424
|
+
receiptSequenceStart = this.normalizePositiveInteger((_openDataConfig2 = openDataConfig) === null || _openDataConfig2 === void 0 ? void 0 : _openDataConfig2['sale.short_number_start_number'], 1);
|
|
425
|
+
prefix = this.normalizeIdPrefix((_openDataConfig3 = openDataConfig) === null || _openDataConfig3 === void 0 ? void 0 : _openDataConfig3['sale.short_number_prefix'], '');
|
|
426
|
+
shopOrderPrefix = this.normalizeIdPrefix((_openDataConfig4 = openDataConfig) === null || _openDataConfig4 === void 0 ? void 0 : _openDataConfig4['sale.sale_number_prefix'], '');
|
|
427
|
+
resetReceiptSequenceDaily = typeof ((_openDataConfig5 = openDataConfig) === null || _openDataConfig5 === void 0 ? void 0 : _openDataConfig5['sale.short_number_daily_reset']) === 'boolean' ? (_openDataConfig6 = openDataConfig) === null || _openDataConfig6 === void 0 ? void 0 : _openDataConfig6['sale.short_number_daily_reset'] : false;
|
|
428
|
+
operatingDayBoundary = this.getAppData('operating_day_boundary');
|
|
429
|
+
_context5.next = 23;
|
|
430
|
+
return this.getShortNumberOrDeviceId();
|
|
431
|
+
case 23:
|
|
432
|
+
deviceId = _context5.sent;
|
|
433
|
+
businessCode = this.getBookingTicketBusinessCode();
|
|
434
|
+
if (businessCode) {
|
|
435
|
+
_context5.next = 28;
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
console.warn('[BookingTicket] businessCode 缺失,跳过 idGenerator 配置');
|
|
439
|
+
return _context5.abrupt("return");
|
|
440
|
+
case 28:
|
|
441
|
+
_context5.prev = 28;
|
|
442
|
+
_context5.next = 31;
|
|
443
|
+
return idGenerator.configure({
|
|
444
|
+
biz: businessCode,
|
|
445
|
+
config: {
|
|
446
|
+
prefix: prefix,
|
|
447
|
+
deviceCode: deviceId,
|
|
448
|
+
// TODO 现在 picoding 没这个配置的 key
|
|
449
|
+
padReceiptSequence: false,
|
|
450
|
+
receiptSequenceLength: receiptSequenceLength,
|
|
451
|
+
resetReceiptSequenceDaily: resetReceiptSequenceDaily,
|
|
452
|
+
receiptSequenceResetTime: operatingDayBoundary.time,
|
|
453
|
+
receiptSequenceStart: receiptSequenceStart,
|
|
454
|
+
shopOrderPrefix: shopOrderPrefix
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
case 31:
|
|
458
|
+
_context5.next = 36;
|
|
459
|
+
break;
|
|
460
|
+
case 33:
|
|
461
|
+
_context5.prev = 33;
|
|
462
|
+
_context5.t1 = _context5["catch"](28);
|
|
463
|
+
console.warn('[BookingTicket] idGenerator 配置失败', _context5.t1);
|
|
464
|
+
case 36:
|
|
280
465
|
case "end":
|
|
281
466
|
return _context5.stop();
|
|
282
467
|
}
|
|
283
|
-
}, _callee5, this, [[1,
|
|
468
|
+
}, _callee5, this, [[1, 7], [28, 33]]);
|
|
284
469
|
}));
|
|
285
|
-
function
|
|
286
|
-
return
|
|
470
|
+
function configureIdGeneratorFromOpenData() {
|
|
471
|
+
return _configureIdGeneratorFromOpenData.apply(this, arguments);
|
|
287
472
|
}
|
|
288
|
-
return
|
|
473
|
+
return configureIdGeneratorFromOpenData;
|
|
289
474
|
}()
|
|
290
|
-
/**
|
|
291
|
-
* 设置活跃客户
|
|
292
|
-
* @param customer 客户信息
|
|
293
|
-
*/
|
|
294
|
-
)
|
|
295
475
|
}, {
|
|
296
|
-
key: "
|
|
297
|
-
value: function
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
});
|
|
476
|
+
key: "normalizePositiveInteger",
|
|
477
|
+
value: function normalizePositiveInteger(value, fallback) {
|
|
478
|
+
var numeric = Number(value);
|
|
479
|
+
if (!Number.isInteger(numeric) || numeric <= 0) return fallback;
|
|
480
|
+
return numeric;
|
|
302
481
|
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* 获取当前活跃客户
|
|
306
|
-
* @returns 当前活跃客户
|
|
307
|
-
*/
|
|
308
482
|
}, {
|
|
309
|
-
key: "
|
|
310
|
-
value: function
|
|
311
|
-
|
|
483
|
+
key: "normalizeIdPrefix",
|
|
484
|
+
value: function normalizeIdPrefix(value, fallback) {
|
|
485
|
+
if (value === undefined || value === null) return fallback;
|
|
486
|
+
var normalized = String(value).trim().toUpperCase();
|
|
487
|
+
return normalized || fallback;
|
|
312
488
|
}
|
|
313
489
|
|
|
314
490
|
/**
|
|
315
|
-
*
|
|
316
|
-
*
|
|
491
|
+
* 加载销售详情,并在父类基础上把 customer 信息装配到 CustomerModule。
|
|
492
|
+
*
|
|
493
|
+
* 业务上 ticketBooking 进入「编辑/查看」时需要 active customer 状态,因此从
|
|
494
|
+
* sales.customer / sales.header / tempOrder 顶层字段中拼装 ICustomer 后调 setSelectedCustomer,
|
|
495
|
+
* 让现有 setActiveCustomer / getActiveCustomer 调用方零成本拿到详情态客户。
|
|
317
496
|
*/
|
|
318
497
|
}, {
|
|
319
|
-
key: "
|
|
320
|
-
value: function
|
|
321
|
-
var
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
498
|
+
key: "loadSalesDetail",
|
|
499
|
+
value: (function () {
|
|
500
|
+
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(orderIdOrParams) {
|
|
501
|
+
var _ref3;
|
|
502
|
+
var sales, customerModule, detailCustomer, orderCustomerSnapshot, protocolCustomerId, protocolCustomer, selectedCustomer, _selectedCustomer$nam, _ref4, detailCustomerId, detailCustomerRest, rawId, customer;
|
|
503
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
504
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
505
|
+
case 0:
|
|
506
|
+
_context6.next = 2;
|
|
507
|
+
return _get(_getPrototypeOf(BookingTicketImpl.prototype), "loadSalesDetail", this).call(this, orderIdOrParams);
|
|
508
|
+
case 2:
|
|
509
|
+
sales = _context6.sent;
|
|
510
|
+
customerModule = this.store.customer;
|
|
511
|
+
detailCustomer = sales === null || sales === void 0 ? void 0 : sales.customer;
|
|
512
|
+
orderCustomerSnapshot = this.store.order.getOrderCustomerSnapshot();
|
|
513
|
+
protocolCustomerId = sales === null || sales === void 0 ? void 0 : sales.customer_id;
|
|
514
|
+
protocolCustomer = protocolCustomerId !== undefined && protocolCustomerId !== null ? {
|
|
515
|
+
id: protocolCustomerId,
|
|
516
|
+
name: String((sales === null || sales === void 0 ? void 0 : sales.customer_name) || ''),
|
|
517
|
+
phone: sales === null || sales === void 0 ? void 0 : sales.phone,
|
|
518
|
+
email: sales === null || sales === void 0 ? void 0 : sales.email,
|
|
519
|
+
country_calling_code: sales === null || sales === void 0 ? void 0 : sales.country_calling_code
|
|
520
|
+
} : null;
|
|
521
|
+
selectedCustomer = (_ref3 = detailCustomer !== null && detailCustomer !== void 0 ? detailCustomer : orderCustomerSnapshot) !== null && _ref3 !== void 0 ? _ref3 : protocolCustomer;
|
|
522
|
+
if (customerModule && selectedCustomer) {
|
|
523
|
+
_ref4 = selectedCustomer !== null && selectedCustomer !== void 0 ? selectedCustomer : {}, detailCustomerId = _ref4.id, detailCustomerRest = _objectWithoutProperties(_ref4, _excluded);
|
|
524
|
+
rawId = detailCustomerId !== null && detailCustomerId !== void 0 ? detailCustomerId : '';
|
|
525
|
+
customer = _objectSpread(_objectSpread({}, detailCustomerRest), {}, {
|
|
526
|
+
id: rawId == null ? '' : rawId,
|
|
527
|
+
name: (_selectedCustomer$nam = selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.name) !== null && _selectedCustomer$nam !== void 0 ? _selectedCustomer$nam : '',
|
|
528
|
+
phone: selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.phone,
|
|
529
|
+
email: selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.email,
|
|
530
|
+
country_calling_code: selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.country_calling_code
|
|
531
|
+
});
|
|
532
|
+
customerModule.setSelectedCustomer(customer);
|
|
533
|
+
this.setOrderCustomer(customer);
|
|
534
|
+
// await this.store.order.saveDraft();
|
|
535
|
+
}
|
|
536
|
+
return _context6.abrupt("return", sales);
|
|
537
|
+
case 11:
|
|
538
|
+
case "end":
|
|
539
|
+
return _context6.stop();
|
|
540
|
+
}
|
|
541
|
+
}, _callee6, this);
|
|
542
|
+
}));
|
|
543
|
+
function loadSalesDetail(_x2) {
|
|
544
|
+
return _loadSalesDetail.apply(this, arguments);
|
|
327
545
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* 获取所有客户
|
|
332
|
-
* @returns 客户列表
|
|
333
|
-
*/
|
|
334
|
-
}, {
|
|
335
|
-
key: "getCustomers",
|
|
336
|
-
value: function getCustomers() {
|
|
337
|
-
return this.store.customer.getCustomers();
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* 根据ID获取客户
|
|
342
|
-
* @param customerId 客户ID
|
|
343
|
-
* @returns 客户信息
|
|
344
|
-
*/
|
|
345
|
-
}, {
|
|
346
|
-
key: "getCustomerById",
|
|
347
|
-
value: function getCustomerById(customerId) {
|
|
348
|
-
return this.store.customer.getCustomerById(customerId);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* 清空客户列表
|
|
353
|
-
*/
|
|
546
|
+
return loadSalesDetail;
|
|
547
|
+
}())
|
|
354
548
|
}, {
|
|
355
|
-
key: "
|
|
356
|
-
value: function
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
549
|
+
key: "scanPromotionCode",
|
|
550
|
+
value: function () {
|
|
551
|
+
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(code, customerId) {
|
|
552
|
+
var raw, scannedList, extractedCustomerId, hasOrderCustomer, tempOrder;
|
|
553
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
554
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
555
|
+
case 0:
|
|
556
|
+
if (this.store.order) {
|
|
557
|
+
_context7.next = 2;
|
|
558
|
+
break;
|
|
559
|
+
}
|
|
560
|
+
throw new Error('order 模块未初始化');
|
|
561
|
+
case 2:
|
|
562
|
+
_context7.next = 4;
|
|
563
|
+
return this.store.order.scanCode(code, customerId);
|
|
564
|
+
case 4:
|
|
565
|
+
raw = _context7.sent;
|
|
566
|
+
scannedList = raw.scannedDiscountList || [];
|
|
567
|
+
extractedCustomerId = this.getDiscountCustomerId(scannedList);
|
|
568
|
+
hasOrderCustomer = Boolean(this.store.order.getOrderCustomer()); // 缺 Holder 等场景 isAvailable=false,但仍需把 Pass 归属客户带入订单,供 Holder 弹窗使用。
|
|
569
|
+
if (!(!hasOrderCustomer && extractedCustomerId)) {
|
|
570
|
+
_context7.next = 11;
|
|
571
|
+
break;
|
|
572
|
+
}
|
|
573
|
+
_context7.next = 11;
|
|
574
|
+
return this.hydrateOrderCustomerFromScanDiscounts(scannedList);
|
|
575
|
+
case 11:
|
|
576
|
+
if (!raw.isAvailable) {
|
|
577
|
+
_context7.next = 18;
|
|
578
|
+
break;
|
|
579
|
+
}
|
|
580
|
+
_context7.next = 14;
|
|
581
|
+
return this.store.order.recalculateSummary({
|
|
582
|
+
createIfMissing: true
|
|
583
|
+
});
|
|
584
|
+
case 14:
|
|
585
|
+
this.store.order.persistTempOrder();
|
|
586
|
+
tempOrder = this.store.order.ensureTempOrder();
|
|
587
|
+
_context7.next = 18;
|
|
588
|
+
return this.effectsEmit('onDiscountApplied', {
|
|
589
|
+
productList: tempOrder.products || [],
|
|
590
|
+
discountList: this.store.order.getDiscountList(),
|
|
591
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
592
|
+
tempOrder: tempOrder
|
|
593
|
+
});
|
|
594
|
+
case 18:
|
|
595
|
+
return _context7.abrupt("return", {
|
|
596
|
+
isAvailable: raw.isAvailable,
|
|
597
|
+
type: raw.type,
|
|
598
|
+
unavailableReason: raw.unavailableReason,
|
|
599
|
+
scannedDiscountList: raw.scannedDiscountList
|
|
600
|
+
});
|
|
601
|
+
case 19:
|
|
602
|
+
case "end":
|
|
603
|
+
return _context7.stop();
|
|
604
|
+
}
|
|
605
|
+
}, _callee7, this);
|
|
606
|
+
}));
|
|
607
|
+
function scanPromotionCode(_x3, _x4) {
|
|
608
|
+
return _scanPromotionCode.apply(this, arguments);
|
|
609
|
+
}
|
|
610
|
+
return scanPromotionCode;
|
|
611
|
+
}()
|
|
364
612
|
}, {
|
|
365
|
-
key: "
|
|
613
|
+
key: "hydrateOrderCustomerFromScanDiscounts",
|
|
614
|
+
value: function () {
|
|
615
|
+
var _hydrateOrderCustomerFromScanDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(discounts) {
|
|
616
|
+
var currentOrderCustomer, customerId, customer;
|
|
617
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
618
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
619
|
+
case 0:
|
|
620
|
+
currentOrderCustomer = this.store.order.getOrderCustomer();
|
|
621
|
+
if (!currentOrderCustomer) {
|
|
622
|
+
_context8.next = 3;
|
|
623
|
+
break;
|
|
624
|
+
}
|
|
625
|
+
return _context8.abrupt("return");
|
|
626
|
+
case 3:
|
|
627
|
+
customerId = this.getDiscountCustomerId(discounts);
|
|
628
|
+
if (customerId) {
|
|
629
|
+
_context8.next = 6;
|
|
630
|
+
break;
|
|
631
|
+
}
|
|
632
|
+
return _context8.abrupt("return");
|
|
633
|
+
case 6:
|
|
634
|
+
_context8.next = 8;
|
|
635
|
+
return this.resolveCustomerByDiscountCustomerId(customerId);
|
|
636
|
+
case 8:
|
|
637
|
+
customer = _context8.sent;
|
|
638
|
+
if (customer) {
|
|
639
|
+
_context8.next = 11;
|
|
640
|
+
break;
|
|
641
|
+
}
|
|
642
|
+
return _context8.abrupt("return");
|
|
643
|
+
case 11:
|
|
644
|
+
this.store.customer.setSelectedCustomer(customer);
|
|
645
|
+
this.setOrderCustomer(customer);
|
|
646
|
+
case 13:
|
|
647
|
+
case "end":
|
|
648
|
+
return _context8.stop();
|
|
649
|
+
}
|
|
650
|
+
}, _callee8, this);
|
|
651
|
+
}));
|
|
652
|
+
function hydrateOrderCustomerFromScanDiscounts(_x5) {
|
|
653
|
+
return _hydrateOrderCustomerFromScanDiscounts.apply(this, arguments);
|
|
654
|
+
}
|
|
655
|
+
return hydrateOrderCustomerFromScanDiscounts;
|
|
656
|
+
}()
|
|
657
|
+
}, {
|
|
658
|
+
key: "getDiscountCustomerId",
|
|
659
|
+
value: function getDiscountCustomerId(discounts) {
|
|
660
|
+
var _iterator = _createForOfIteratorHelper(discounts),
|
|
661
|
+
_step;
|
|
662
|
+
try {
|
|
663
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
664
|
+
var item = _step.value;
|
|
665
|
+
var topLevelId = Number(item.customer_id);
|
|
666
|
+
if (Number.isFinite(topLevelId) && topLevelId > 0) {
|
|
667
|
+
return topLevelId;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
} catch (err) {
|
|
671
|
+
_iterator.e(err);
|
|
672
|
+
} finally {
|
|
673
|
+
_iterator.f();
|
|
674
|
+
}
|
|
675
|
+
return null;
|
|
676
|
+
}
|
|
677
|
+
}, {
|
|
678
|
+
key: "resolveCustomerByDiscountCustomerId",
|
|
679
|
+
value: function () {
|
|
680
|
+
var _resolveCustomerByDiscountCustomerId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(customerId) {
|
|
681
|
+
var _result$list;
|
|
682
|
+
var localCustomers, localCustomer, normalizedLocalCustomer, result, remoteCustomer;
|
|
683
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
684
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
685
|
+
case 0:
|
|
686
|
+
localCustomers = this.store.customer.getCustomers();
|
|
687
|
+
localCustomer = this.findCustomerById(localCustomers, customerId);
|
|
688
|
+
normalizedLocalCustomer = localCustomer ? this.normalizeCustomer(localCustomer) : null;
|
|
689
|
+
if (!(normalizedLocalCustomer && this.hasUsableCustomerDetails(normalizedLocalCustomer))) {
|
|
690
|
+
_context9.next = 5;
|
|
691
|
+
break;
|
|
692
|
+
}
|
|
693
|
+
return _context9.abrupt("return", normalizedLocalCustomer);
|
|
694
|
+
case 5:
|
|
695
|
+
_context9.next = 7;
|
|
696
|
+
return this.store.customer.queryCustomerList({
|
|
697
|
+
ids: [customerId],
|
|
698
|
+
skip: 1,
|
|
699
|
+
num: 1
|
|
700
|
+
});
|
|
701
|
+
case 7:
|
|
702
|
+
result = _context9.sent;
|
|
703
|
+
remoteCustomer = this.findCustomerById((result === null || result === void 0 ? void 0 : result.list) || [], customerId) || (result === null || result === void 0 || (_result$list = result.list) === null || _result$list === void 0 ? void 0 : _result$list[0]) || null;
|
|
704
|
+
return _context9.abrupt("return", remoteCustomer ? this.normalizeCustomer(remoteCustomer) : null);
|
|
705
|
+
case 10:
|
|
706
|
+
case "end":
|
|
707
|
+
return _context9.stop();
|
|
708
|
+
}
|
|
709
|
+
}, _callee9, this);
|
|
710
|
+
}));
|
|
711
|
+
function resolveCustomerByDiscountCustomerId(_x6) {
|
|
712
|
+
return _resolveCustomerByDiscountCustomerId.apply(this, arguments);
|
|
713
|
+
}
|
|
714
|
+
return resolveCustomerByDiscountCustomerId;
|
|
715
|
+
}()
|
|
716
|
+
}, {
|
|
717
|
+
key: "findCustomerById",
|
|
718
|
+
value: function findCustomerById() {
|
|
719
|
+
var _this2 = this;
|
|
720
|
+
var customers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
721
|
+
var customerId = arguments.length > 1 ? arguments[1] : undefined;
|
|
722
|
+
return customers.find(function (customer) {
|
|
723
|
+
var rawId = _this2.getRawCustomerId(customer);
|
|
724
|
+
return rawId !== null && String(rawId) === String(customerId);
|
|
725
|
+
}) || null;
|
|
726
|
+
}
|
|
727
|
+
}, {
|
|
728
|
+
key: "normalizeCustomer",
|
|
729
|
+
value: function normalizeCustomer(customer) {
|
|
730
|
+
var _ref5, _ref6, _customer$phone, _ref7, _customer$email, _ref8, _customer$country_cal;
|
|
731
|
+
var raw = customer;
|
|
732
|
+
var rawId = this.getRawCustomerId(customer);
|
|
733
|
+
var name = customer.name || raw.display_name || raw.nickname || raw.customer_name || [raw.first_name, raw.last_name].filter(Boolean).join(' ') || '';
|
|
734
|
+
return _objectSpread(_objectSpread({}, customer), {}, {
|
|
735
|
+
id: rawId !== null && rawId !== void 0 ? rawId : customer.id,
|
|
736
|
+
name: name,
|
|
737
|
+
phone: (_ref5 = (_ref6 = (_customer$phone = customer.phone) !== null && _customer$phone !== void 0 ? _customer$phone : raw.phone) !== null && _ref6 !== void 0 ? _ref6 : raw.mobile) !== null && _ref5 !== void 0 ? _ref5 : '',
|
|
738
|
+
email: (_ref7 = (_customer$email = customer.email) !== null && _customer$email !== void 0 ? _customer$email : raw.email) !== null && _ref7 !== void 0 ? _ref7 : '',
|
|
739
|
+
country_calling_code: (_ref8 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : raw.country_calling_code) !== null && _ref8 !== void 0 ? _ref8 : ''
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
}, {
|
|
743
|
+
key: "getRawCustomerId",
|
|
744
|
+
value: function getRawCustomerId(customer) {
|
|
745
|
+
var _ref9, _ref10, _customer$id;
|
|
746
|
+
var raw = customer;
|
|
747
|
+
return (_ref9 = (_ref10 = (_customer$id = customer.id) !== null && _customer$id !== void 0 ? _customer$id : raw.customer_id) !== null && _ref10 !== void 0 ? _ref10 : raw.customerId) !== null && _ref9 !== void 0 ? _ref9 : null;
|
|
748
|
+
}
|
|
749
|
+
}, {
|
|
750
|
+
key: "hasUsableCustomerDetails",
|
|
751
|
+
value: function hasUsableCustomerDetails(customer) {
|
|
752
|
+
return !!(customer.name || customer.phone || customer.email || customer.display_name || customer.customer_name);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* 更新当前预约的 appointment_status。
|
|
757
|
+
*
|
|
758
|
+
* 数据源:从 OrderModule.tempOrder 内部读取,调用方无需传 orderId / scheduleId。
|
|
759
|
+
* schedule id 解析优先级:
|
|
760
|
+
* 1. `tempOrder.metadata.appointment_booking_parent_schedule_id`
|
|
761
|
+
* 2. `tempOrder.bookings` 中 `parent_id === 0` 的 `schedule_event_id`
|
|
762
|
+
*
|
|
763
|
+
* 流程:先乐观更新本地 bookings 的 appointment_status,再调 PUT 接口,
|
|
764
|
+
* 接口成功后强制刷新销售详情;任一步失败都回滚本地状态并抛错。
|
|
765
|
+
*
|
|
766
|
+
* @param status 目标状态(如 'confirmed')
|
|
767
|
+
* @returns 接口返回的 data
|
|
768
|
+
*/
|
|
769
|
+
}, {
|
|
770
|
+
key: "setBookingStatus",
|
|
771
|
+
value: (function () {
|
|
772
|
+
var _setBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(status) {
|
|
773
|
+
var _this$store$order, _this$store$order$get;
|
|
774
|
+
var tempOrder, orderId, scheduleId, bookings, previous, _data, res;
|
|
775
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
776
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
777
|
+
case 0:
|
|
778
|
+
tempOrder = (_this$store$order = this.store.order) === null || _this$store$order === void 0 || (_this$store$order$get = _this$store$order.getTempOrder) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.call(_this$store$order);
|
|
779
|
+
if (tempOrder) {
|
|
780
|
+
_context10.next = 3;
|
|
781
|
+
break;
|
|
782
|
+
}
|
|
783
|
+
throw new Error('setBookingStatus: tempOrder 未加载');
|
|
784
|
+
case 3:
|
|
785
|
+
orderId = tempOrder.order_id;
|
|
786
|
+
if (!(orderId === undefined || orderId === null)) {
|
|
787
|
+
_context10.next = 6;
|
|
788
|
+
break;
|
|
789
|
+
}
|
|
790
|
+
throw new Error('setBookingStatus: tempOrder.order_id 缺失');
|
|
791
|
+
case 6:
|
|
792
|
+
scheduleId = resolveScheduleId(tempOrder);
|
|
793
|
+
if (!(scheduleId === null)) {
|
|
794
|
+
_context10.next = 9;
|
|
795
|
+
break;
|
|
796
|
+
}
|
|
797
|
+
throw new Error('setBookingStatus: 无法解析 schedule id(metadata 与 root booking 均缺失)');
|
|
798
|
+
case 9:
|
|
799
|
+
bookings = Array.isArray(tempOrder.bookings) ? tempOrder.bookings : [];
|
|
800
|
+
previous = applyBookingsStatus(bookings, status);
|
|
801
|
+
_context10.prev = 11;
|
|
802
|
+
_context10.next = 14;
|
|
803
|
+
return this.request.put("/schedule/booking/appointment-status/".concat(scheduleId), {
|
|
804
|
+
appointment_status: status
|
|
805
|
+
});
|
|
806
|
+
case 14:
|
|
807
|
+
res = _context10.sent;
|
|
808
|
+
_context10.next = 17;
|
|
809
|
+
return this.refreshSalesDetail();
|
|
810
|
+
case 17:
|
|
811
|
+
this.core.effects.emit("".concat(this.name, ":onBookingStatusChange"), {
|
|
812
|
+
orderId: orderId,
|
|
813
|
+
status: status
|
|
814
|
+
});
|
|
815
|
+
return _context10.abrupt("return", (_data = res === null || res === void 0 ? void 0 : res.data) !== null && _data !== void 0 ? _data : res);
|
|
816
|
+
case 21:
|
|
817
|
+
_context10.prev = 21;
|
|
818
|
+
_context10.t0 = _context10["catch"](11);
|
|
819
|
+
restoreBookingsStatus(bookings, previous);
|
|
820
|
+
throw _context10.t0;
|
|
821
|
+
case 25:
|
|
822
|
+
case "end":
|
|
823
|
+
return _context10.stop();
|
|
824
|
+
}
|
|
825
|
+
}, _callee10, this, [[11, 21]]);
|
|
826
|
+
}));
|
|
827
|
+
function setBookingStatus(_x7) {
|
|
828
|
+
return _setBookingStatus.apply(this, arguments);
|
|
829
|
+
}
|
|
830
|
+
return setBookingStatus;
|
|
831
|
+
}()
|
|
832
|
+
/**
|
|
833
|
+
* 子预约状态机转移(POST /schedule/booking-transition/{schedule_event_id})。
|
|
834
|
+
*
|
|
835
|
+
* 与 `setBookingStatus`(父预约 PUT appointment-status)不同,本方法按子预约
|
|
836
|
+
* `schedule_event_id` 调用状态转移接口,body 为 `{ action }`。
|
|
837
|
+
*
|
|
838
|
+
* 流程:能解析出目标状态时先乐观更新对应子预约的 `appointment_status`,
|
|
839
|
+
* 再调 POST;成功后强制刷新销售详情;失败则回滚该子预约本地状态并抛错。
|
|
840
|
+
* `reschedule` 暂未启用状态矩阵,跳过乐观更新仅调接口。
|
|
841
|
+
*
|
|
842
|
+
* @param params.schedule_event_id 子预约 schedule_event_id
|
|
843
|
+
* @param params.action 转移动作:confirm | reject | arrive | start | complete | cancel | no_show | reschedule
|
|
844
|
+
* @returns 接口返回的 data
|
|
845
|
+
*
|
|
846
|
+
* @example
|
|
847
|
+
* await bookingTicket.transitionChildBooking({
|
|
848
|
+
* schedule_event_id: 301,
|
|
849
|
+
* action: 'confirm',
|
|
850
|
+
* });
|
|
851
|
+
*/
|
|
852
|
+
)
|
|
853
|
+
}, {
|
|
854
|
+
key: "transitionChildBooking",
|
|
855
|
+
value: (function () {
|
|
856
|
+
var _transitionChildBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
|
|
857
|
+
var _this$store$order2, _this$store$order2$ge;
|
|
858
|
+
var schedule_event_id, action, tempOrder, orderId, bookings, targetStatus, previous, _data2, res;
|
|
859
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
860
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
861
|
+
case 0:
|
|
862
|
+
schedule_event_id = params.schedule_event_id, action = params.action;
|
|
863
|
+
if (!(schedule_event_id === undefined || schedule_event_id === null || schedule_event_id === '')) {
|
|
864
|
+
_context11.next = 3;
|
|
865
|
+
break;
|
|
866
|
+
}
|
|
867
|
+
throw new Error('transitionChildBooking: schedule_event_id 不能为空');
|
|
868
|
+
case 3:
|
|
869
|
+
if (action) {
|
|
870
|
+
_context11.next = 5;
|
|
871
|
+
break;
|
|
872
|
+
}
|
|
873
|
+
throw new Error('transitionChildBooking: action 不能为空');
|
|
874
|
+
case 5:
|
|
875
|
+
tempOrder = (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || (_this$store$order2$ge = _this$store$order2.getTempOrder) === null || _this$store$order2$ge === void 0 ? void 0 : _this$store$order2$ge.call(_this$store$order2);
|
|
876
|
+
if (tempOrder) {
|
|
877
|
+
_context11.next = 8;
|
|
878
|
+
break;
|
|
879
|
+
}
|
|
880
|
+
throw new Error('transitionChildBooking: tempOrder 未加载');
|
|
881
|
+
case 8:
|
|
882
|
+
orderId = tempOrder.order_id;
|
|
883
|
+
if (!(orderId === undefined || orderId === null)) {
|
|
884
|
+
_context11.next = 11;
|
|
885
|
+
break;
|
|
886
|
+
}
|
|
887
|
+
throw new Error('transitionChildBooking: tempOrder.order_id 缺失');
|
|
888
|
+
case 11:
|
|
889
|
+
bookings = Array.isArray(tempOrder.bookings) ? tempOrder.bookings : [];
|
|
890
|
+
targetStatus = resolveStatusAfterTransition(action);
|
|
891
|
+
previous = targetStatus !== null ? applyChildBookingStatus(bookings, schedule_event_id, targetStatus) : undefined;
|
|
892
|
+
_context11.prev = 14;
|
|
893
|
+
_context11.next = 17;
|
|
894
|
+
return this.request.post("/schedule/booking-transition/".concat(schedule_event_id), {
|
|
895
|
+
action: action
|
|
896
|
+
});
|
|
897
|
+
case 17:
|
|
898
|
+
res = _context11.sent;
|
|
899
|
+
_context11.next = 20;
|
|
900
|
+
return this.refreshSalesDetail();
|
|
901
|
+
case 20:
|
|
902
|
+
this.core.effects.emit("".concat(this.name, ":onChildBookingStatusChange"), {
|
|
903
|
+
orderId: orderId,
|
|
904
|
+
schedule_event_id: schedule_event_id,
|
|
905
|
+
action: action,
|
|
906
|
+
status: targetStatus
|
|
907
|
+
});
|
|
908
|
+
return _context11.abrupt("return", (_data2 = res === null || res === void 0 ? void 0 : res.data) !== null && _data2 !== void 0 ? _data2 : res);
|
|
909
|
+
case 24:
|
|
910
|
+
_context11.prev = 24;
|
|
911
|
+
_context11.t0 = _context11["catch"](14);
|
|
912
|
+
if (previous !== undefined) {
|
|
913
|
+
restoreChildBookingStatus(bookings, schedule_event_id, previous);
|
|
914
|
+
}
|
|
915
|
+
throw _context11.t0;
|
|
916
|
+
case 28:
|
|
917
|
+
case "end":
|
|
918
|
+
return _context11.stop();
|
|
919
|
+
}
|
|
920
|
+
}, _callee11, this, [[14, 24]]);
|
|
921
|
+
}));
|
|
922
|
+
function transitionChildBooking(_x8) {
|
|
923
|
+
return _transitionChildBooking.apply(this, arguments);
|
|
924
|
+
}
|
|
925
|
+
return transitionChildBooking;
|
|
926
|
+
}()
|
|
927
|
+
/**
|
|
928
|
+
* 基于当前 tempOrder.order_id 强制从远端重新拉取销售详情。
|
|
929
|
+
*
|
|
930
|
+
* 适用场景:在 BookingTicket 内执行了「修改服务端订单状态」的动作(如改预约状态、
|
|
931
|
+
* 改下单客户、改商品行等)后,统一刷新本地销售详情,保证 UI 与服务端一致。
|
|
932
|
+
*
|
|
933
|
+
* 约束:调用前必须已有 tempOrder 且 order_id 存在,否则视为非法调用并抛错。
|
|
934
|
+
*
|
|
935
|
+
* @returns loadSalesDetail 的返回值
|
|
936
|
+
*/
|
|
937
|
+
)
|
|
938
|
+
}, {
|
|
939
|
+
key: "refreshSalesDetail",
|
|
940
|
+
value: (function () {
|
|
941
|
+
var _refreshSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
942
|
+
var _this$store$order3, _this$store$order3$ge;
|
|
943
|
+
var params,
|
|
944
|
+
tempOrder,
|
|
945
|
+
orderId,
|
|
946
|
+
_args12 = arguments;
|
|
947
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
948
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
949
|
+
case 0:
|
|
950
|
+
params = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
|
|
951
|
+
tempOrder = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 || (_this$store$order3$ge = _this$store$order3.getTempOrder) === null || _this$store$order3$ge === void 0 ? void 0 : _this$store$order3$ge.call(_this$store$order3);
|
|
952
|
+
if (tempOrder) {
|
|
953
|
+
_context12.next = 4;
|
|
954
|
+
break;
|
|
955
|
+
}
|
|
956
|
+
throw new Error('refreshSalesDetail: tempOrder 未加载');
|
|
957
|
+
case 4:
|
|
958
|
+
debugger;
|
|
959
|
+
orderId = tempOrder.order_id || tempOrder.external_sale_number;
|
|
960
|
+
if (!(orderId === undefined || orderId === null)) {
|
|
961
|
+
_context12.next = 8;
|
|
962
|
+
break;
|
|
963
|
+
}
|
|
964
|
+
return _context12.abrupt("return", {});
|
|
965
|
+
case 8:
|
|
966
|
+
return _context12.abrupt("return", this.loadSalesDetail({
|
|
967
|
+
orderId: orderId,
|
|
968
|
+
// merge: true
|
|
969
|
+
forceRemote: params.forceRemote
|
|
970
|
+
}));
|
|
971
|
+
case 9:
|
|
972
|
+
case "end":
|
|
973
|
+
return _context12.stop();
|
|
974
|
+
}
|
|
975
|
+
}, _callee12, this);
|
|
976
|
+
}));
|
|
977
|
+
function refreshSalesDetail() {
|
|
978
|
+
return _refreshSalesDetail.apply(this, arguments);
|
|
979
|
+
}
|
|
980
|
+
return refreshSalesDetail;
|
|
981
|
+
}()
|
|
982
|
+
/**
|
|
983
|
+
* 获取商品列表
|
|
984
|
+
* @param params 包含 schedule_date 的参数
|
|
985
|
+
* @returns 商品列表
|
|
986
|
+
*/
|
|
987
|
+
)
|
|
988
|
+
}, {
|
|
989
|
+
key: "loadProducts",
|
|
990
|
+
value: (function () {
|
|
991
|
+
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
992
|
+
var params,
|
|
993
|
+
options,
|
|
994
|
+
schedule_date,
|
|
995
|
+
customer_id,
|
|
996
|
+
menu_list_ids,
|
|
997
|
+
schedule_datetime,
|
|
998
|
+
bookingDate,
|
|
999
|
+
_result,
|
|
1000
|
+
_args13 = arguments;
|
|
1001
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1002
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1003
|
+
case 0:
|
|
1004
|
+
params = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
|
|
1005
|
+
options = _args13.length > 1 ? _args13[1] : undefined;
|
|
1006
|
+
schedule_date = params.schedule_date, customer_id = params.customer_id, menu_list_ids = params.menu_list_ids, schedule_datetime = params.schedule_datetime; // 优先写入 schedule_datetime(含时分),供加购 presetStartTime 与 TimeBar 对齐;
|
|
1007
|
+
// requiresDetail 弹窗仍通过 formatBookingDateForUI 只取日历日 YYYY-MM-DD。
|
|
1008
|
+
bookingDate = schedule_datetime || schedule_date || '';
|
|
1009
|
+
if (bookingDate) {
|
|
1010
|
+
this.setBookingDate(bookingDate);
|
|
1011
|
+
}
|
|
1012
|
+
_context13.prev = 5;
|
|
1013
|
+
_context13.next = 8;
|
|
1014
|
+
return this.store.products.loadProducts(_objectSpread(_objectSpread({
|
|
1015
|
+
with_count: ['bundleGroup', 'optionGroup'],
|
|
1016
|
+
with_schedule: 1
|
|
1017
|
+
}, params), {}, {
|
|
1018
|
+
cacheId: this.cacheId
|
|
1019
|
+
}), options);
|
|
1020
|
+
case 8:
|
|
1021
|
+
_result = _context13.sent;
|
|
1022
|
+
this.productCatalog = Array.isArray(_result) ? _toConsumableArray(_result) : [];
|
|
1023
|
+
this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), _result);
|
|
1024
|
+
return _context13.abrupt("return", _result);
|
|
1025
|
+
case 14:
|
|
1026
|
+
_context13.prev = 14;
|
|
1027
|
+
_context13.t0 = _context13["catch"](5);
|
|
1028
|
+
console.error('Failed to load products:', _context13.t0);
|
|
1029
|
+
throw _context13.t0;
|
|
1030
|
+
case 18:
|
|
1031
|
+
case "end":
|
|
1032
|
+
return _context13.stop();
|
|
1033
|
+
}
|
|
1034
|
+
}, _callee13, this, [[5, 14]]);
|
|
1035
|
+
}));
|
|
1036
|
+
function loadProducts() {
|
|
1037
|
+
return _loadProducts.apply(this, arguments);
|
|
1038
|
+
}
|
|
1039
|
+
return loadProducts;
|
|
1040
|
+
}()
|
|
1041
|
+
/**
|
|
1042
|
+
* 获取加时商品列表。
|
|
1043
|
+
*
|
|
1044
|
+
* @example
|
|
1045
|
+
* const products = await bookingTicket.getAddTimeProducts({ schedule_date: '2026-06-16' });
|
|
1046
|
+
*/
|
|
1047
|
+
)
|
|
1048
|
+
}, {
|
|
1049
|
+
key: "getAddTimeProducts",
|
|
1050
|
+
value: (function () {
|
|
1051
|
+
var _getAddTimeProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
1052
|
+
var params,
|
|
1053
|
+
result,
|
|
1054
|
+
_args14 = arguments;
|
|
1055
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1056
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1057
|
+
case 0:
|
|
1058
|
+
params = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
|
|
1059
|
+
_context14.next = 3;
|
|
1060
|
+
return this.store.products.getAddTimeProducts(_objectSpread(_objectSpread({}, params), {}, {
|
|
1061
|
+
cacheId: this.cacheId
|
|
1062
|
+
}));
|
|
1063
|
+
case 3:
|
|
1064
|
+
result = _context14.sent;
|
|
1065
|
+
this.addTimeProductsCatalog = Array.isArray(result) ? _toConsumableArray(result) : [];
|
|
1066
|
+
return _context14.abrupt("return", result);
|
|
1067
|
+
case 6:
|
|
1068
|
+
case "end":
|
|
1069
|
+
return _context14.stop();
|
|
1070
|
+
}
|
|
1071
|
+
}, _callee14, this);
|
|
1072
|
+
}));
|
|
1073
|
+
function getAddTimeProducts() {
|
|
1074
|
+
return _getAddTimeProducts.apply(this, arguments);
|
|
1075
|
+
}
|
|
1076
|
+
return getAddTimeProducts;
|
|
1077
|
+
}()
|
|
1078
|
+
/**
|
|
1079
|
+
* 只读查询单商品详情:走 ProductList 报价查询,但不写 productCatalog、
|
|
1080
|
+
* 不 emit onProductsLoaded、不修改 BookingDate。
|
|
1081
|
+
*
|
|
1082
|
+
* 供「列表已 loadProducts、仅需补 product_resource / capacity」等场景使用,
|
|
1083
|
+
* 避免 loadProductDetail 覆盖左侧商品列表。
|
|
1084
|
+
*
|
|
1085
|
+
* @example
|
|
1086
|
+
* const detail = await bookingTicket.queryProductDetail({
|
|
1087
|
+
* product_id: 2,
|
|
1088
|
+
* schedule_date: '2030-01-15',
|
|
1089
|
+
* schedule_datetime: '2030-01-15 10:00:00',
|
|
1090
|
+
* });
|
|
1091
|
+
*/
|
|
1092
|
+
)
|
|
1093
|
+
}, {
|
|
1094
|
+
key: "queryProductDetail",
|
|
1095
|
+
value: (function () {
|
|
1096
|
+
var _queryProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params, options) {
|
|
1097
|
+
var product_id, queryParams, _result2, list;
|
|
1098
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1099
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1100
|
+
case 0:
|
|
1101
|
+
product_id = params.product_id, queryParams = _objectWithoutProperties(params, _excluded2);
|
|
1102
|
+
_context15.prev = 1;
|
|
1103
|
+
_context15.next = 4;
|
|
1104
|
+
return this.store.products.loadProducts(_objectSpread(_objectSpread({
|
|
1105
|
+
with_count: ['bundleGroup', 'optionGroup'],
|
|
1106
|
+
with_schedule: 1
|
|
1107
|
+
}, queryParams), {}, {
|
|
1108
|
+
product_ids: [product_id],
|
|
1109
|
+
cacheId: this.cacheId
|
|
1110
|
+
}), options);
|
|
1111
|
+
case 4:
|
|
1112
|
+
_result2 = _context15.sent;
|
|
1113
|
+
list = Array.isArray(_result2) ? _result2 : [];
|
|
1114
|
+
return _context15.abrupt("return", list.find(function (product) {
|
|
1115
|
+
return Number(product.id) === Number(product_id);
|
|
1116
|
+
}));
|
|
1117
|
+
case 9:
|
|
1118
|
+
_context15.prev = 9;
|
|
1119
|
+
_context15.t0 = _context15["catch"](1);
|
|
1120
|
+
console.error('Failed to query product detail:', _context15.t0);
|
|
1121
|
+
throw _context15.t0;
|
|
1122
|
+
case 13:
|
|
1123
|
+
case "end":
|
|
1124
|
+
return _context15.stop();
|
|
1125
|
+
}
|
|
1126
|
+
}, _callee15, this, [[1, 9]]);
|
|
1127
|
+
}));
|
|
1128
|
+
function queryProductDetail(_x9, _x10) {
|
|
1129
|
+
return _queryProductDetail.apply(this, arguments);
|
|
1130
|
+
}
|
|
1131
|
+
return queryProductDetail;
|
|
1132
|
+
}()
|
|
1133
|
+
/**
|
|
1134
|
+
* 按预约时间加载单个商品详情。
|
|
1135
|
+
* 价格仍由 server products 的报价单桥接统一计算,避免 solution 实例重复请求报价单。
|
|
1136
|
+
*/
|
|
1137
|
+
)
|
|
1138
|
+
}, {
|
|
1139
|
+
key: "loadProductDetail",
|
|
1140
|
+
value: (function () {
|
|
1141
|
+
var _loadProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params, options) {
|
|
1142
|
+
var product_id, queryParams, products;
|
|
1143
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1144
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1145
|
+
case 0:
|
|
1146
|
+
product_id = params.product_id, queryParams = _objectWithoutProperties(params, _excluded3);
|
|
1147
|
+
_context16.next = 3;
|
|
1148
|
+
return this.loadProducts(_objectSpread(_objectSpread({}, queryParams), {}, {
|
|
1149
|
+
product_ids: [product_id]
|
|
1150
|
+
}), options);
|
|
1151
|
+
case 3:
|
|
1152
|
+
products = _context16.sent;
|
|
1153
|
+
return _context16.abrupt("return", products.find(function (product) {
|
|
1154
|
+
return Number(product.id) === Number(product_id);
|
|
1155
|
+
}));
|
|
1156
|
+
case 5:
|
|
1157
|
+
case "end":
|
|
1158
|
+
return _context16.stop();
|
|
1159
|
+
}
|
|
1160
|
+
}, _callee16, this);
|
|
1161
|
+
}));
|
|
1162
|
+
function loadProductDetail(_x11, _x12) {
|
|
1163
|
+
return _loadProductDetail.apply(this, arguments);
|
|
1164
|
+
}
|
|
1165
|
+
return loadProductDetail;
|
|
1166
|
+
}()
|
|
1167
|
+
/**
|
|
1168
|
+
* 取消商品查询订阅
|
|
1169
|
+
* @param subscriberId 订阅时传入的 subscriberId
|
|
1170
|
+
*/
|
|
1171
|
+
)
|
|
1172
|
+
}, {
|
|
1173
|
+
key: "unsubscribeProductQuery",
|
|
1174
|
+
value: function unsubscribeProductQuery(subscriberId) {
|
|
1175
|
+
var _this$core$server;
|
|
1176
|
+
(_this$core$server = this.core.server) === null || _this$core$server === void 0 || _this$core$server.removeProductQuerySubscriber(subscriberId);
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
/**
|
|
1180
|
+
* 初始化外设扫码结果监听
|
|
1181
|
+
*/
|
|
1182
|
+
}, {
|
|
1183
|
+
key: "initPeripheralsListener",
|
|
1184
|
+
value: function initPeripheralsListener() {
|
|
1185
|
+
this.scan.initPeripheralsListener();
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
/**
|
|
1189
|
+
* 获取商品列表(不加载到模块中)
|
|
1190
|
+
* @returns 商品列表
|
|
1191
|
+
*/
|
|
1192
|
+
}, {
|
|
1193
|
+
key: "getProducts",
|
|
1194
|
+
value: (function () {
|
|
1195
|
+
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
1196
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1197
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1198
|
+
case 0:
|
|
1199
|
+
return _context17.abrupt("return", this.store.products.getProducts());
|
|
1200
|
+
case 1:
|
|
1201
|
+
case "end":
|
|
1202
|
+
return _context17.stop();
|
|
1203
|
+
}
|
|
1204
|
+
}, _callee17, this);
|
|
1205
|
+
}));
|
|
1206
|
+
function getProducts() {
|
|
1207
|
+
return _getProducts.apply(this, arguments);
|
|
1208
|
+
}
|
|
1209
|
+
return getProducts;
|
|
1210
|
+
}()
|
|
1211
|
+
/**
|
|
1212
|
+
* 获取当前已加载的商品池 UI 视图。
|
|
1213
|
+
*
|
|
1214
|
+
* ProductList.getProducts 是异步 API;BookingTicket 维护最近一次 loadProducts 结果,
|
|
1215
|
+
* 供 UI 同步 getter 使用。未加载时返回空列表。
|
|
1216
|
+
*/
|
|
1217
|
+
)
|
|
1218
|
+
}, {
|
|
1219
|
+
key: "getProductCatalog",
|
|
1220
|
+
value: function getProductCatalog() {
|
|
1221
|
+
return {
|
|
1222
|
+
products: _toConsumableArray(this.productCatalog)
|
|
1223
|
+
};
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
/**
|
|
1227
|
+
* 获取购物车 UI 视图。
|
|
1228
|
+
*
|
|
1229
|
+
* tempOrder 仍是 checkout 协议对象;商品行直接透传 products,bookings 附带关联商品。
|
|
1230
|
+
*/
|
|
1231
|
+
}, {
|
|
1232
|
+
key: "getCart",
|
|
1233
|
+
value: function getCart() {
|
|
1234
|
+
var _this$store$order$get2, _this$store$order4, _salesDetail$bookings, _operatingDayBoundary, _operatingDayBoundary2, _tempOrder$_extend;
|
|
1235
|
+
var tempOrder = (_this$store$order$get2 = (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 ? void 0 : _this$store$order4.getTempOrder()) !== null && _this$store$order$get2 !== void 0 ? _this$store$order$get2 : null;
|
|
1236
|
+
var salesDetail = this.getSalesOrder();
|
|
1237
|
+
var bookings = (_salesDetail$bookings = salesDetail === null || salesDetail === void 0 ? void 0 : salesDetail.bookings) !== null && _salesDetail$bookings !== void 0 ? _salesDetail$bookings : (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) || [];
|
|
1238
|
+
var operatingDayBoundary;
|
|
1239
|
+
try {
|
|
1240
|
+
operatingDayBoundary = this.getAppData('operating_day_boundary');
|
|
1241
|
+
} catch (_unused) {
|
|
1242
|
+
operatingDayBoundary = undefined;
|
|
1243
|
+
}
|
|
1244
|
+
var shopOpeningHours = ((_operatingDayBoundary = operatingDayBoundary) === null || _operatingDayBoundary === void 0 ? void 0 : _operatingDayBoundary.type) === 'start_time' ? '23:59' : (_operatingDayBoundary2 = operatingDayBoundary) === null || _operatingDayBoundary2 === void 0 ? void 0 : _operatingDayBoundary2.time;
|
|
1245
|
+
return buildCartView((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [], bookings, {
|
|
1246
|
+
addTimeProducts: this.addTimeProductsCatalog,
|
|
1247
|
+
bookingConfig: this.getBookingConfig(),
|
|
1248
|
+
productsByUid: tempOrder === null || tempOrder === void 0 || (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.productsByUid,
|
|
1249
|
+
shopOpeningHours: shopOpeningHours
|
|
1250
|
+
});
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
/**
|
|
1254
|
+
* 获取当前下单客户(与 OrderModule.tempOrder snapshot 一致)。
|
|
1255
|
+
*/
|
|
1256
|
+
}, {
|
|
1257
|
+
key: "getCustomer",
|
|
1258
|
+
value: function getCustomer() {
|
|
1259
|
+
return this.getOrderCustomerSnapshot();
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
/**
|
|
1263
|
+
* 通过 ids 获取商品列表(不加载到模块中)
|
|
1264
|
+
* @returns 商品列表
|
|
1265
|
+
*/
|
|
1266
|
+
}, {
|
|
1267
|
+
key: "getProductByIds",
|
|
1268
|
+
value: (function () {
|
|
1269
|
+
var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(ids) {
|
|
1270
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1271
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1272
|
+
case 0:
|
|
1273
|
+
return _context18.abrupt("return", this.store.products.getProductByIds(ids));
|
|
1274
|
+
case 1:
|
|
1275
|
+
case "end":
|
|
1276
|
+
return _context18.stop();
|
|
1277
|
+
}
|
|
1278
|
+
}, _callee18, this);
|
|
1279
|
+
}));
|
|
1280
|
+
function getProductByIds(_x13) {
|
|
1281
|
+
return _getProductByIds.apply(this, arguments);
|
|
1282
|
+
}
|
|
1283
|
+
return getProductByIds;
|
|
1284
|
+
}()
|
|
1285
|
+
/**
|
|
1286
|
+
* 获取日程时间段点
|
|
1287
|
+
* @param params 参数
|
|
1288
|
+
* @returns 日程时间段点
|
|
1289
|
+
*/
|
|
1290
|
+
)
|
|
1291
|
+
}, {
|
|
1292
|
+
key: "getScheduleTimePoints",
|
|
1293
|
+
value: (function () {
|
|
1294
|
+
var _getScheduleTimePoints = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
|
|
1295
|
+
var result;
|
|
1296
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1297
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1298
|
+
case 0:
|
|
1299
|
+
_context19.next = 2;
|
|
1300
|
+
return this.request.post('/menu/schedule-time-points', {
|
|
1301
|
+
menu_list_ids: params.menu_list_ids
|
|
1302
|
+
}, {
|
|
1303
|
+
osServer: true
|
|
1304
|
+
});
|
|
1305
|
+
case 2:
|
|
1306
|
+
result = _context19.sent;
|
|
1307
|
+
return _context19.abrupt("return", result.data || []);
|
|
1308
|
+
case 4:
|
|
1309
|
+
case "end":
|
|
1310
|
+
return _context19.stop();
|
|
1311
|
+
}
|
|
1312
|
+
}, _callee19, this);
|
|
1313
|
+
}));
|
|
1314
|
+
function getScheduleTimePoints(_x14) {
|
|
1315
|
+
return _getScheduleTimePoints.apply(this, arguments);
|
|
1316
|
+
}
|
|
1317
|
+
return getScheduleTimePoints;
|
|
1318
|
+
}()
|
|
1319
|
+
/**
|
|
1320
|
+
* 获取客户列表
|
|
1321
|
+
* @param params 查询参数
|
|
1322
|
+
* @returns 客户列表响应
|
|
1323
|
+
*/
|
|
1324
|
+
)
|
|
1325
|
+
}, {
|
|
1326
|
+
key: "getCustomerList",
|
|
1327
|
+
value: (function () {
|
|
1328
|
+
var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
1329
|
+
var params,
|
|
1330
|
+
_result3,
|
|
1331
|
+
_args20 = arguments;
|
|
1332
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1333
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1334
|
+
case 0:
|
|
1335
|
+
params = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : {};
|
|
1336
|
+
_context20.prev = 1;
|
|
1337
|
+
_context20.next = 4;
|
|
1338
|
+
return this.store.customer.getCustomerList(params);
|
|
1339
|
+
case 4:
|
|
1340
|
+
_result3 = _context20.sent;
|
|
1341
|
+
return _context20.abrupt("return", _result3);
|
|
1342
|
+
case 8:
|
|
1343
|
+
_context20.prev = 8;
|
|
1344
|
+
_context20.t0 = _context20["catch"](1);
|
|
1345
|
+
console.error('Failed to get customer list:', _context20.t0);
|
|
1346
|
+
throw _context20.t0;
|
|
1347
|
+
case 12:
|
|
1348
|
+
case "end":
|
|
1349
|
+
return _context20.stop();
|
|
1350
|
+
}
|
|
1351
|
+
}, _callee20, this, [[1, 8]]);
|
|
1352
|
+
}));
|
|
1353
|
+
function getCustomerList() {
|
|
1354
|
+
return _getCustomerList.apply(this, arguments);
|
|
1355
|
+
}
|
|
1356
|
+
return getCustomerList;
|
|
1357
|
+
}()
|
|
1358
|
+
/**
|
|
1359
|
+
* 设置活跃客户
|
|
1360
|
+
* @param customer 客户信息
|
|
1361
|
+
*/
|
|
1362
|
+
)
|
|
1363
|
+
}, {
|
|
1364
|
+
key: "setActiveCustomer",
|
|
1365
|
+
value: function setActiveCustomer(customer) {
|
|
1366
|
+
this.store.customer.setSelectedCustomer(customer);
|
|
1367
|
+
this.core.effects.emit("".concat(this.name, ":onCustomerSelected"), {
|
|
1368
|
+
customer: customer
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
/**
|
|
1373
|
+
* 获取当前活跃客户
|
|
1374
|
+
* @returns 当前活跃客户
|
|
1375
|
+
*/
|
|
1376
|
+
}, {
|
|
1377
|
+
key: "getActiveCustomer",
|
|
1378
|
+
value: function getActiveCustomer() {
|
|
1379
|
+
return this.store.customer.getSelectedCustomer();
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
/**
|
|
1383
|
+
* 根据ID设置选中的客户
|
|
1384
|
+
* @param customerId 客户ID
|
|
1385
|
+
*/
|
|
1386
|
+
}, {
|
|
1387
|
+
key: "setSelectedCustomerById",
|
|
1388
|
+
value: function setSelectedCustomerById(customerId) {
|
|
1389
|
+
var customer = this.store.customer.getCustomerById(customerId);
|
|
1390
|
+
if (customer) {
|
|
1391
|
+
this.store.customer.setSelectedCustomer(customer);
|
|
1392
|
+
this.core.effects.emit("".concat(this.name, ":onCustomerSelected"), {
|
|
1393
|
+
customer: customer
|
|
1394
|
+
});
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
/**
|
|
1399
|
+
* 获取所有客户
|
|
1400
|
+
* @returns 客户列表
|
|
1401
|
+
*/
|
|
1402
|
+
}, {
|
|
1403
|
+
key: "getCustomers",
|
|
1404
|
+
value: function getCustomers() {
|
|
1405
|
+
return this.store.customer.getCustomers();
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
/**
|
|
1409
|
+
* 根据ID获取客户
|
|
1410
|
+
* @param customerId 客户ID
|
|
1411
|
+
* @returns 客户信息
|
|
1412
|
+
*/
|
|
1413
|
+
}, {
|
|
1414
|
+
key: "getCustomerById",
|
|
1415
|
+
value: function getCustomerById(customerId) {
|
|
1416
|
+
return this.store.customer.getCustomerById(customerId);
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
/**
|
|
1420
|
+
* 清空客户列表
|
|
1421
|
+
*/
|
|
1422
|
+
}, {
|
|
1423
|
+
key: "clearCustomers",
|
|
1424
|
+
value: function clearCustomers() {
|
|
1425
|
+
this.store.customer.clearCustomers();
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
/**
|
|
1429
|
+
* 添加客户到列表第一位
|
|
1430
|
+
* @param customer 要添加的客户信息
|
|
1431
|
+
*/
|
|
1432
|
+
}, {
|
|
1433
|
+
key: "addCustomerToFirst",
|
|
366
1434
|
value: function addCustomerToFirst(customer) {
|
|
367
1435
|
this.store.customer.addCustomerToFirst(customer);
|
|
368
1436
|
}
|
|
369
1437
|
|
|
1438
|
+
// ─── 下单客户(基于 OrderModule.tempOrder,单一真源)───
|
|
1439
|
+
// 与老的 setActiveCustomer/getActiveCustomer 解耦:
|
|
1440
|
+
// - 老路:写入 CustomerModule.selectedCustomer(保留兼容,存量调用方不动)
|
|
1441
|
+
// - 新路:写入 tempOrder 的 customer 协议字段 + _extend.customerSnapshot
|
|
1442
|
+
// 新业务(如 SalesSdk)应优先使用本组方法。
|
|
1443
|
+
|
|
1444
|
+
/**
|
|
1445
|
+
* 设置当前下单客户。
|
|
1446
|
+
*
|
|
1447
|
+
* @param customer 完整客户对象;null 表示清空
|
|
1448
|
+
*
|
|
1449
|
+
* 内部将 customer 格式化为 tempOrder 协议字段后写入 OrderModule,
|
|
1450
|
+
* 并以 customer 作为 snapshot 保存富字段。
|
|
1451
|
+
*
|
|
1452
|
+
* 同时透传 OrderModule 内部 emit 的 `order:onOrderCustomerChange` 之外,
|
|
1453
|
+
* 在 BookingTicket 命名空间也 emit 一次,方便上层统一从 Solution 订阅。
|
|
1454
|
+
*/
|
|
1455
|
+
}, {
|
|
1456
|
+
key: "setOrderCustomer",
|
|
1457
|
+
value: function setOrderCustomer(customer) {
|
|
1458
|
+
var _this$store$order$get3;
|
|
1459
|
+
if (!customer) {
|
|
1460
|
+
this.clearOrderCustomer();
|
|
1461
|
+
return;
|
|
1462
|
+
}
|
|
1463
|
+
var previousCustomerId = (_this$store$order$get3 = this.store.order.getOrderCustomer()) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.customer_id;
|
|
1464
|
+
var snapshotBeforeSet = this.store.order.getOrderCustomerSnapshot();
|
|
1465
|
+
var patch = formatOrderCustomerPatch(customer);
|
|
1466
|
+
var customerUnchanged = Number(previousCustomerId || 0) === Number(patch.customer_id || 0);
|
|
1467
|
+
if (!customerUnchanged) {
|
|
1468
|
+
this.discountConfigCacheKey = null;
|
|
1469
|
+
this.hasManualDiscountSelection = false;
|
|
1470
|
+
}
|
|
1471
|
+
this.store.order.setOrderCustomer(patch, customer);
|
|
1472
|
+
var snapshotAfterOrderSet = this.store.order.getOrderCustomerSnapshot();
|
|
1473
|
+
if (customerUnchanged) {
|
|
1474
|
+
// hydrate 后 customer_id 已存在但 _extend.customerSnapshot 仍为空时,
|
|
1475
|
+
// 须通知 SalesSdk 刷新 selected(否则会一直停在 onSalesOrderLoaded 时的 null)。
|
|
1476
|
+
var snapshotReplenished = !snapshotBeforeSet && Boolean(snapshotAfterOrderSet);
|
|
1477
|
+
if (snapshotReplenished) {
|
|
1478
|
+
var _next2 = this.buildOrderCustomerPayload();
|
|
1479
|
+
this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), _next2);
|
|
1480
|
+
}
|
|
1481
|
+
return;
|
|
1482
|
+
}
|
|
1483
|
+
var next = this.buildOrderCustomerPayload();
|
|
1484
|
+
this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), next);
|
|
1485
|
+
this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
|
|
1486
|
+
// 客户切换可能改变可用促销/赠品;触发一次重算(recursion-safe)。
|
|
1487
|
+
void this.store.order.applyPromotion().catch(function (error) {
|
|
1488
|
+
console.error('[BookingTicket] applyPromotion after customer change failed', error);
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
/**
|
|
1493
|
+
* 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
|
|
1494
|
+
*/
|
|
1495
|
+
}, {
|
|
1496
|
+
key: "getOrderCustomer",
|
|
1497
|
+
value: function getOrderCustomer() {
|
|
1498
|
+
return this.store.order.getOrderCustomer();
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
/**
|
|
1502
|
+
* 读取 tempOrder._extend.customerSnapshot 中的完整客户对象。
|
|
1503
|
+
*/
|
|
1504
|
+
}, {
|
|
1505
|
+
key: "getOrderCustomerSnapshot",
|
|
1506
|
+
value: function getOrderCustomerSnapshot() {
|
|
1507
|
+
return this.store.order.getOrderCustomerSnapshot();
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
/**
|
|
1511
|
+
* 清空下单客户(协议字段 + snapshot)。
|
|
1512
|
+
*/
|
|
1513
|
+
}, {
|
|
1514
|
+
key: "clearOrderCustomer",
|
|
1515
|
+
value: function clearOrderCustomer() {
|
|
1516
|
+
var _discountModule$setOr,
|
|
1517
|
+
_discountModule$setDi,
|
|
1518
|
+
_this3 = this;
|
|
1519
|
+
this.store.order.clearOrderCustomer();
|
|
1520
|
+
this.discountConfigCacheKey = null;
|
|
1521
|
+
this.hasManualDiscountSelection = false;
|
|
1522
|
+
var orderStore = this.store.order.store || {};
|
|
1523
|
+
var discountModule = orderStore.discount;
|
|
1524
|
+
void (discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, []));
|
|
1525
|
+
void (discountModule === null || discountModule === void 0 || (_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, []));
|
|
1526
|
+
this.store.order.applyDiscount();
|
|
1527
|
+
void this.store.order.recalculateSummary({
|
|
1528
|
+
createIfMissing: true
|
|
1529
|
+
}).then(function () {
|
|
1530
|
+
var _discountModule$getDi;
|
|
1531
|
+
var tempOrder = _this3.store.order.ensureTempOrder();
|
|
1532
|
+
_this3.store.order.persistTempOrder();
|
|
1533
|
+
return _this3.effectsEmit('onDiscountApplied', {
|
|
1534
|
+
productList: tempOrder.products || [],
|
|
1535
|
+
discountList: (discountModule === null || discountModule === void 0 || (_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [],
|
|
1536
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
1537
|
+
tempOrder: tempOrder
|
|
1538
|
+
});
|
|
1539
|
+
}).catch(function (error) {
|
|
1540
|
+
console.error('Failed to recalculate summary after clearing customer:', error);
|
|
1541
|
+
});
|
|
1542
|
+
this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), null);
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
/**
|
|
1546
|
+
* 重置 tempOrder,并同步清空下单客户运行态。
|
|
1547
|
+
*
|
|
1548
|
+
* OrderModule.restoreOrder 会重建空单(customer_id 已为 null),但不会:
|
|
1549
|
+
* - emit BookingTicket `onOrderCustomerChange`
|
|
1550
|
+
* - 重置 CustomerModule.selectedCustomer(老路 getActiveCustomer)
|
|
1551
|
+
*
|
|
1552
|
+
* 因此在 super.restoreOrder 之后显式清客户,保证 SalesSdk / ticketBooking 订阅方与 tempOrder 一致。
|
|
1553
|
+
*/
|
|
1554
|
+
}, {
|
|
1555
|
+
key: "restoreOrder",
|
|
1556
|
+
value: (function () {
|
|
1557
|
+
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
1558
|
+
var _this$store$customer;
|
|
1559
|
+
var tempOrder;
|
|
1560
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1561
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1562
|
+
case 0:
|
|
1563
|
+
_context21.next = 2;
|
|
1564
|
+
return _get(_getPrototypeOf(BookingTicketImpl.prototype), "restoreOrder", this).call(this);
|
|
1565
|
+
case 2:
|
|
1566
|
+
tempOrder = _context21.sent;
|
|
1567
|
+
this.clearOrderCustomer();
|
|
1568
|
+
(_this$store$customer = this.store.customer) === null || _this$store$customer === void 0 || _this$store$customer.setSelectedCustomer(null);
|
|
1569
|
+
return _context21.abrupt("return", tempOrder);
|
|
1570
|
+
case 6:
|
|
1571
|
+
case "end":
|
|
1572
|
+
return _context21.stop();
|
|
1573
|
+
}
|
|
1574
|
+
}, _callee21, this);
|
|
1575
|
+
}));
|
|
1576
|
+
function restoreOrder() {
|
|
1577
|
+
return _restoreOrder.apply(this, arguments);
|
|
1578
|
+
}
|
|
1579
|
+
return restoreOrder;
|
|
1580
|
+
}() /** 内部:基于 OrderModule 当前状态构造一份 OrderCustomerChangePayload。 */)
|
|
1581
|
+
}, {
|
|
1582
|
+
key: "buildOrderCustomerPayload",
|
|
1583
|
+
value: function buildOrderCustomerPayload() {
|
|
1584
|
+
var patch = this.store.order.getOrderCustomer();
|
|
1585
|
+
if (!patch) return null;
|
|
1586
|
+
return {
|
|
1587
|
+
patch: patch,
|
|
1588
|
+
snapshot: this.store.order.getOrderCustomerSnapshot()
|
|
1589
|
+
};
|
|
1590
|
+
}
|
|
1591
|
+
}, {
|
|
1592
|
+
key: "refreshDiscountConfigAfterOrderCustomerChange",
|
|
1593
|
+
value: function refreshDiscountConfigAfterOrderCustomerChange(customerId) {
|
|
1594
|
+
var _this4 = this;
|
|
1595
|
+
if (!customerId || customerId === 1) return;
|
|
1596
|
+
if (this.orderCustomerDiscountRefreshInFlight && this.orderCustomerDiscountRefreshCustomerId === customerId) {
|
|
1597
|
+
return;
|
|
1598
|
+
}
|
|
1599
|
+
var previousRefresh = this.orderCustomerDiscountRefreshInFlight;
|
|
1600
|
+
var refreshTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
1601
|
+
var currentCustomer;
|
|
1602
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1603
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1604
|
+
case 0:
|
|
1605
|
+
if (!previousRefresh) {
|
|
1606
|
+
_context22.next = 3;
|
|
1607
|
+
break;
|
|
1608
|
+
}
|
|
1609
|
+
_context22.next = 3;
|
|
1610
|
+
return previousRefresh.catch(function () {
|
|
1611
|
+
return undefined;
|
|
1612
|
+
});
|
|
1613
|
+
case 3:
|
|
1614
|
+
currentCustomer = _this4.store.order.getOrderCustomer();
|
|
1615
|
+
if (!(!currentCustomer || Number(currentCustomer.customer_id) !== customerId)) {
|
|
1616
|
+
_context22.next = 6;
|
|
1617
|
+
break;
|
|
1618
|
+
}
|
|
1619
|
+
return _context22.abrupt("return");
|
|
1620
|
+
case 6:
|
|
1621
|
+
_context22.next = 8;
|
|
1622
|
+
return _this4.loadDiscountConfig({
|
|
1623
|
+
customerId: customerId
|
|
1624
|
+
});
|
|
1625
|
+
case 8:
|
|
1626
|
+
case "end":
|
|
1627
|
+
return _context22.stop();
|
|
1628
|
+
}
|
|
1629
|
+
}, _callee22);
|
|
1630
|
+
}))();
|
|
1631
|
+
this.orderCustomerDiscountRefreshInFlight = refreshTask;
|
|
1632
|
+
this.orderCustomerDiscountRefreshCustomerId = customerId;
|
|
1633
|
+
refreshTask.catch(function (error) {
|
|
1634
|
+
console.error('Failed to load discount config after customer change:', error);
|
|
1635
|
+
}).finally(function () {
|
|
1636
|
+
if (_this4.orderCustomerDiscountRefreshInFlight !== refreshTask) return;
|
|
1637
|
+
_this4.orderCustomerDiscountRefreshInFlight = null;
|
|
1638
|
+
_this4.orderCustomerDiscountRefreshCustomerId = null;
|
|
1639
|
+
});
|
|
1640
|
+
}
|
|
1641
|
+
|
|
370
1642
|
/**
|
|
371
1643
|
* 获取客户分页信息
|
|
372
1644
|
* @returns 分页信息
|
|
@@ -407,29 +1679,29 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
407
1679
|
}, {
|
|
408
1680
|
key: "changeCustomerPage",
|
|
409
1681
|
value: (function () {
|
|
410
|
-
var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
411
|
-
var
|
|
412
|
-
return _regeneratorRuntime().wrap(function
|
|
413
|
-
while (1) switch (
|
|
1682
|
+
var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(page, pageSize) {
|
|
1683
|
+
var _result4;
|
|
1684
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1685
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
414
1686
|
case 0:
|
|
415
|
-
|
|
416
|
-
|
|
1687
|
+
_context23.prev = 0;
|
|
1688
|
+
_context23.next = 3;
|
|
417
1689
|
return this.store.customer.changeCustomerPage(page, pageSize);
|
|
418
1690
|
case 3:
|
|
419
|
-
|
|
420
|
-
return
|
|
1691
|
+
_result4 = _context23.sent;
|
|
1692
|
+
return _context23.abrupt("return", _result4);
|
|
421
1693
|
case 7:
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
console.error('Failed to change customer page:',
|
|
425
|
-
throw
|
|
1694
|
+
_context23.prev = 7;
|
|
1695
|
+
_context23.t0 = _context23["catch"](0);
|
|
1696
|
+
console.error('Failed to change customer page:', _context23.t0);
|
|
1697
|
+
throw _context23.t0;
|
|
426
1698
|
case 11:
|
|
427
1699
|
case "end":
|
|
428
|
-
return
|
|
1700
|
+
return _context23.stop();
|
|
429
1701
|
}
|
|
430
|
-
},
|
|
1702
|
+
}, _callee23, this, [[0, 7]]);
|
|
431
1703
|
}));
|
|
432
|
-
function changeCustomerPage(
|
|
1704
|
+
function changeCustomerPage(_x15, _x16) {
|
|
433
1705
|
return _changeCustomerPage.apply(this, arguments);
|
|
434
1706
|
}
|
|
435
1707
|
return changeCustomerPage;
|
|
@@ -442,28 +1714,28 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
442
1714
|
}, {
|
|
443
1715
|
key: "loadMoreCustomers",
|
|
444
1716
|
value: (function () {
|
|
445
|
-
var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
446
|
-
var
|
|
447
|
-
return _regeneratorRuntime().wrap(function
|
|
448
|
-
while (1) switch (
|
|
1717
|
+
var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
1718
|
+
var _result5;
|
|
1719
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1720
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
449
1721
|
case 0:
|
|
450
|
-
|
|
451
|
-
|
|
1722
|
+
_context24.prev = 0;
|
|
1723
|
+
_context24.next = 3;
|
|
452
1724
|
return this.store.customer.loadMoreCustomers();
|
|
453
1725
|
case 3:
|
|
454
|
-
|
|
455
|
-
this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"),
|
|
456
|
-
return
|
|
1726
|
+
_result5 = _context24.sent;
|
|
1727
|
+
this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), _result5);
|
|
1728
|
+
return _context24.abrupt("return", _result5);
|
|
457
1729
|
case 8:
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
console.error('Failed to load more customers:',
|
|
461
|
-
throw
|
|
1730
|
+
_context24.prev = 8;
|
|
1731
|
+
_context24.t0 = _context24["catch"](0);
|
|
1732
|
+
console.error('Failed to load more customers:', _context24.t0);
|
|
1733
|
+
throw _context24.t0;
|
|
462
1734
|
case 12:
|
|
463
1735
|
case "end":
|
|
464
|
-
return
|
|
1736
|
+
return _context24.stop();
|
|
465
1737
|
}
|
|
466
|
-
},
|
|
1738
|
+
}, _callee24, this, [[0, 8]]);
|
|
467
1739
|
}));
|
|
468
1740
|
function loadMoreCustomers() {
|
|
469
1741
|
return _loadMoreCustomers.apply(this, arguments);
|
|
@@ -479,31 +1751,31 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
479
1751
|
}, {
|
|
480
1752
|
key: "resetAndLoadCustomers",
|
|
481
1753
|
value: (function () {
|
|
482
|
-
var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1754
|
+
var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
483
1755
|
var params,
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
return _regeneratorRuntime().wrap(function
|
|
487
|
-
while (1) switch (
|
|
1756
|
+
_result6,
|
|
1757
|
+
_args25 = arguments;
|
|
1758
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1759
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
488
1760
|
case 0:
|
|
489
|
-
params =
|
|
490
|
-
|
|
491
|
-
|
|
1761
|
+
params = _args25.length > 0 && _args25[0] !== undefined ? _args25[0] : {};
|
|
1762
|
+
_context25.prev = 1;
|
|
1763
|
+
_context25.next = 4;
|
|
492
1764
|
return this.store.customer.resetAndLoadCustomers(params);
|
|
493
1765
|
case 4:
|
|
494
|
-
|
|
495
|
-
this.core.effects.emit("".concat(this.name, ":onCustomerListReset"),
|
|
496
|
-
return
|
|
1766
|
+
_result6 = _context25.sent;
|
|
1767
|
+
this.core.effects.emit("".concat(this.name, ":onCustomerListReset"), _result6);
|
|
1768
|
+
return _context25.abrupt("return", _result6);
|
|
497
1769
|
case 9:
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
console.error('Failed to reset and load customers:',
|
|
501
|
-
throw
|
|
1770
|
+
_context25.prev = 9;
|
|
1771
|
+
_context25.t0 = _context25["catch"](1);
|
|
1772
|
+
console.error('Failed to reset and load customers:', _context25.t0);
|
|
1773
|
+
throw _context25.t0;
|
|
502
1774
|
case 13:
|
|
503
1775
|
case "end":
|
|
504
|
-
return
|
|
1776
|
+
return _context25.stop();
|
|
505
1777
|
}
|
|
506
|
-
},
|
|
1778
|
+
}, _callee25, this, [[1, 9]]);
|
|
507
1779
|
}));
|
|
508
1780
|
function resetAndLoadCustomers() {
|
|
509
1781
|
return _resetAndLoadCustomers.apply(this, arguments);
|
|
@@ -511,232 +1783,1025 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
511
1783
|
return resetAndLoadCustomers;
|
|
512
1784
|
}()
|
|
513
1785
|
/**
|
|
514
|
-
* 检查是否还有更多客户数据可以加载
|
|
515
|
-
* @returns 是否还有更多数据
|
|
1786
|
+
* 检查是否还有更多客户数据可以加载
|
|
1787
|
+
* @returns 是否还有更多数据
|
|
1788
|
+
*/
|
|
1789
|
+
)
|
|
1790
|
+
}, {
|
|
1791
|
+
key: "hasMoreCustomers",
|
|
1792
|
+
value: function hasMoreCustomers() {
|
|
1793
|
+
return this.store.customer.hasMoreCustomers();
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
/**
|
|
1797
|
+
* 获取当前的客户搜索条件
|
|
1798
|
+
* @returns 当前搜索条件
|
|
1799
|
+
*/
|
|
1800
|
+
}, {
|
|
1801
|
+
key: "getCurrentCustomerSearchParams",
|
|
1802
|
+
value: function getCurrentCustomerSearchParams() {
|
|
1803
|
+
return this.store.customer.getCurrentSearchParams();
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
/**
|
|
1807
|
+
* 获取客户列表状态(包含滚动加载相关状态)
|
|
1808
|
+
* @returns 客户状态
|
|
1809
|
+
*/
|
|
1810
|
+
}, {
|
|
1811
|
+
key: "getCustomerState",
|
|
1812
|
+
value: function getCustomerState() {
|
|
1813
|
+
return this.store.customer.getState();
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
/**
|
|
1817
|
+
* 全局扫描监听
|
|
1818
|
+
* @param callback 回调
|
|
1819
|
+
*/
|
|
1820
|
+
}, {
|
|
1821
|
+
key: "scanGlobalListener",
|
|
1822
|
+
value: function scanGlobalListener(callback) {
|
|
1823
|
+
var _this5 = this;
|
|
1824
|
+
var localSearch = function localSearch(v) {
|
|
1825
|
+
return _this5.store.products.findProductsByCodeOrBarcode(v);
|
|
1826
|
+
};
|
|
1827
|
+
var scanCallback = handleGlobalScan(this.request, localSearch, this.getSubmitOrderSalesChannel());
|
|
1828
|
+
var safeCallback = function safeCallback(d) {
|
|
1829
|
+
try {
|
|
1830
|
+
callback(d);
|
|
1831
|
+
} catch (error) {
|
|
1832
|
+
console.error('scanGlobalListener传入的回调函数异常', error);
|
|
1833
|
+
}
|
|
1834
|
+
};
|
|
1835
|
+
var listener = {
|
|
1836
|
+
key: 'global',
|
|
1837
|
+
callback: safeCallback
|
|
1838
|
+
};
|
|
1839
|
+
var removeListener = this.scan.addListener(listener, scanCallback);
|
|
1840
|
+
return removeListener;
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
/**
|
|
1844
|
+
* 客户扫描监听
|
|
1845
|
+
* @param callback 回调
|
|
1846
|
+
*/
|
|
1847
|
+
}, {
|
|
1848
|
+
key: "scanCustomerListener",
|
|
1849
|
+
value: function scanCustomerListener(callback) {
|
|
1850
|
+
var scanCallback = handleCustomerScan();
|
|
1851
|
+
var safeCallback = function safeCallback(d) {
|
|
1852
|
+
try {
|
|
1853
|
+
callback(d);
|
|
1854
|
+
} catch (error) {
|
|
1855
|
+
console.error('scanCustomerListener传入的回调函数异常', error);
|
|
1856
|
+
}
|
|
1857
|
+
};
|
|
1858
|
+
var listener = {
|
|
1859
|
+
key: 'customer',
|
|
1860
|
+
callback: safeCallback
|
|
1861
|
+
};
|
|
1862
|
+
var removeListener = this.scan.addListener(listener, scanCallback);
|
|
1863
|
+
return removeListener;
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
/**
|
|
1867
|
+
* @title 通用扫描监听
|
|
1868
|
+
* @description 直接将扫描结果返回给调用方
|
|
1869
|
+
* @param callback 回调
|
|
1870
|
+
*/
|
|
1871
|
+
}, {
|
|
1872
|
+
key: "scanUniversalListener",
|
|
1873
|
+
value: function scanUniversalListener(callback, key) {
|
|
1874
|
+
var scanCallback = handleUniversalScan();
|
|
1875
|
+
var safeCallback = function safeCallback(d) {
|
|
1876
|
+
try {
|
|
1877
|
+
callback(d);
|
|
1878
|
+
} catch (error) {
|
|
1879
|
+
console.error("scanUniversalListener\u4F20\u5165\u7684\u56DE\u8C03\u51FD\u6570\u5F02\u5E38, key: ".concat(key), error);
|
|
1880
|
+
}
|
|
1881
|
+
};
|
|
1882
|
+
var listener = {
|
|
1883
|
+
key: key,
|
|
1884
|
+
callback: safeCallback
|
|
1885
|
+
};
|
|
1886
|
+
var removeListener = this.scan.addListener(listener, scanCallback);
|
|
1887
|
+
return removeListener;
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
/**
|
|
1891
|
+
* 调用摄像头
|
|
1892
|
+
* @param data 用户自定义数据
|
|
1893
|
+
*/
|
|
1894
|
+
}, {
|
|
1895
|
+
key: "activateCamera",
|
|
1896
|
+
value: function activateCamera(data) {
|
|
1897
|
+
var _this$window, _this$window$postMess;
|
|
1898
|
+
(_this$window = this.window) === null || _this$window === void 0 || (_this$window = _this$window.interaction) === null || _this$window === void 0 || (_this$window = _this$window.utils) === null || _this$window === void 0 || (_this$window$postMess = _this$window.postMessageToApp) === null || _this$window$postMess === void 0 || _this$window$postMess.call(_this$window, {
|
|
1899
|
+
module: 'global',
|
|
1900
|
+
key: 'active_native_scanner',
|
|
1901
|
+
data: data
|
|
1902
|
+
});
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
/**
|
|
1906
|
+
* 禁用所有扫描监听
|
|
1907
|
+
*/
|
|
1908
|
+
}, {
|
|
1909
|
+
key: "disableAllScanListeners",
|
|
1910
|
+
value: function disableAllScanListeners() {
|
|
1911
|
+
this.scan.disableAllListeners();
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
/**
|
|
1915
|
+
* 启用所有扫描监听
|
|
1916
|
+
*/
|
|
1917
|
+
}, {
|
|
1918
|
+
key: "enableAllScanListeners",
|
|
1919
|
+
value: function enableAllScanListeners() {
|
|
1920
|
+
this.scan.enableAllListeners();
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
/**
|
|
1924
|
+
* 清空所有扫描监听对应的任务执行队列
|
|
1925
|
+
*/
|
|
1926
|
+
}, {
|
|
1927
|
+
key: "clearAllScanListenersTaskQueue",
|
|
1928
|
+
value: function clearAllScanListenersTaskQueue() {
|
|
1929
|
+
this.scan.clearTaskQueue();
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
/**
|
|
1933
|
+
* 获取其他参数
|
|
1934
|
+
* @returns 其他参数
|
|
1935
|
+
*/
|
|
1936
|
+
}, {
|
|
1937
|
+
key: "getOtherParams",
|
|
1938
|
+
value: (function () {
|
|
1939
|
+
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
1940
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1941
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1942
|
+
case 0:
|
|
1943
|
+
return _context26.abrupt("return", this.otherParams);
|
|
1944
|
+
case 1:
|
|
1945
|
+
case "end":
|
|
1946
|
+
return _context26.stop();
|
|
1947
|
+
}
|
|
1948
|
+
}, _callee26, this);
|
|
1949
|
+
}));
|
|
1950
|
+
function getOtherParams() {
|
|
1951
|
+
return _getOtherParams.apply(this, arguments);
|
|
1952
|
+
}
|
|
1953
|
+
return getOtherParams;
|
|
1954
|
+
}() // ─── BookingContext API(透传给 BookingContextModule) ──────────────────────
|
|
1955
|
+
// SalesSdkProvider 挂载时默认调 initBookingContext;也可由 UI 显式 set* 灌入已有数据。
|
|
1956
|
+
/** 拉取 board config 并写入 BookingContext。 */
|
|
1957
|
+
)
|
|
1958
|
+
}, {
|
|
1959
|
+
key: "loadBookingConfig",
|
|
1960
|
+
value: function loadBookingConfig(params) {
|
|
1961
|
+
return this.store.bookingContext.loadBookingConfig(params);
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
/** 拉取资源全集并写入 BookingContext。 */
|
|
1965
|
+
}, {
|
|
1966
|
+
key: "loadBookingResources",
|
|
1967
|
+
value: function loadBookingResources(params) {
|
|
1968
|
+
return this.store.bookingContext.loadResources(params);
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
/** 初始化 BookingContext(date + config + resources)。 */
|
|
1972
|
+
}, {
|
|
1973
|
+
key: "initBookingContext",
|
|
1974
|
+
value: function initBookingContext(params) {
|
|
1975
|
+
return this.store.bookingContext.initBookingContext(params);
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
/** 当前 store 是否已具备与入参等价的 config / resources(无需再请求接口)。 */
|
|
1979
|
+
}, {
|
|
1980
|
+
key: "isBookingContextReady",
|
|
1981
|
+
value: function isBookingContextReady(params) {
|
|
1982
|
+
return this.store.bookingContext.isBookingContextReady(params);
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1985
|
+
/** 写入 booking config(来源:`/core/board/management/config`)。 */
|
|
1986
|
+
}, {
|
|
1987
|
+
key: "setBookingConfig",
|
|
1988
|
+
value: function setBookingConfig(config) {
|
|
1989
|
+
this.store.bookingContext.setBookingConfig(config);
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
/** 读取当前 booking config。 */
|
|
1993
|
+
}, {
|
|
1994
|
+
key: "getBookingConfig",
|
|
1995
|
+
value: function getBookingConfig() {
|
|
1996
|
+
return this.store.bookingContext.getBookingConfig();
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
/** 写入资源全集(来源:`/form/schedule`),同步派生 resourcesOriginMap。 */
|
|
2000
|
+
}, {
|
|
2001
|
+
key: "setResources",
|
|
2002
|
+
value: function setResources(resources) {
|
|
2003
|
+
this.store.bookingContext.setResources(resources);
|
|
2004
|
+
}
|
|
2005
|
+
|
|
2006
|
+
/** 读取资源全集(浅克隆)。 */
|
|
2007
|
+
}, {
|
|
2008
|
+
key: "getResourcesOrigin",
|
|
2009
|
+
value: function getResourcesOrigin() {
|
|
2010
|
+
return this.store.bookingContext.getResourcesOrigin();
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
/** 读取资源全集 map(id → resource)。 */
|
|
2014
|
+
}, {
|
|
2015
|
+
key: "getResourcesOriginMap",
|
|
2016
|
+
value: function getResourcesOriginMap() {
|
|
2017
|
+
return this.store.bookingContext.getResourcesOriginMap();
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
/** 写入当前选择的日期;支持 dayjs / Date / string。 */
|
|
2021
|
+
}, {
|
|
2022
|
+
key: "setBookingDate",
|
|
2023
|
+
value: function setBookingDate(date) {
|
|
2024
|
+
this.store.bookingContext.setDate(date);
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
/** 读取当前选择的日期(统一 string)。 */
|
|
2028
|
+
}, {
|
|
2029
|
+
key: "getBookingDate",
|
|
2030
|
+
value: function getBookingDate() {
|
|
2031
|
+
return this.store.bookingContext.getDate();
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
/** 读取 BookingContext 完整 store(调试 / 测试 / 透传给 SDK 使用)。 */
|
|
2035
|
+
}, {
|
|
2036
|
+
key: "getBookingContextState",
|
|
2037
|
+
value: function getBookingContextState() {
|
|
2038
|
+
return this.store.bookingContext.getState();
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
/** 清空 BookingContext(切租户 / destroy 场景)。 */
|
|
2042
|
+
}, {
|
|
2043
|
+
key: "clearBookingContext",
|
|
2044
|
+
value: function clearBookingContext() {
|
|
2045
|
+
this.store.bookingContext.clear();
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
/**
|
|
2049
|
+
* 构造 BookingContext 计算上下文(供 getProductExtend / getResourceByIds 等读 API 复用)。
|
|
2050
|
+
*/
|
|
2051
|
+
}, {
|
|
2052
|
+
key: "buildBookingCalcContext",
|
|
2053
|
+
value: function buildBookingCalcContext(extra) {
|
|
2054
|
+
var _extra$date, _extra$presetStartTim;
|
|
2055
|
+
var state = this.store.bookingContext.getState();
|
|
2056
|
+
var date = (_extra$date = extra === null || extra === void 0 ? void 0 : extra.date) !== null && _extra$date !== void 0 ? _extra$date : state.date;
|
|
2057
|
+
return _objectSpread({
|
|
2058
|
+
bookingConfig: state.bookingConfig,
|
|
2059
|
+
resourcesOrigin: state.resourcesOrigin,
|
|
2060
|
+
resourcesOriginMap: state.resourcesOriginMap,
|
|
2061
|
+
date: date,
|
|
2062
|
+
presetStartTime: (_extra$presetStartTim = extra === null || extra === void 0 ? void 0 : extra.presetStartTime) !== null && _extra$presetStartTim !== void 0 ? _extra$presetStartTim : derivePresetStartTimeFromDate(date)
|
|
2063
|
+
}, extra || {});
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
/**
|
|
2067
|
+
* 取商品当前可选资源列表(透传 OS BookingContext utils#getResourceByIds)。
|
|
2068
|
+
* `extraResources` 用于把拖入未绑定的资源也展示出来。
|
|
2069
|
+
*/
|
|
2070
|
+
}, {
|
|
2071
|
+
key: "getResourcesForProduct",
|
|
2072
|
+
value: function getResourcesForProduct(product, options) {
|
|
2073
|
+
var _ctx$bookingConfig;
|
|
2074
|
+
var ctx = this.buildBookingCalcContext();
|
|
2075
|
+
return getResourceByIdsUtil(ctx.resourcesOriginMap || {}, product, {
|
|
2076
|
+
resourceTab: (_ctx$bookingConfig = ctx.bookingConfig) === null || _ctx$bookingConfig === void 0 || (_ctx$bookingConfig = _ctx$bookingConfig.config) === null || _ctx$bookingConfig === void 0 ? void 0 : _ctx$bookingConfig.resource_tab,
|
|
2077
|
+
resourcesOrigin: ctx.resourcesOrigin,
|
|
2078
|
+
extraResources: (options === null || options === void 0 ? void 0 : options.extraResources) || []
|
|
2079
|
+
});
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
/**
|
|
2083
|
+
* 拼装 cacheItem 的 _extend / _data(资源 / 容量 / timeObj),与 info2 `getProductExtend` 等价。
|
|
516
2084
|
*/
|
|
517
|
-
)
|
|
518
2085
|
}, {
|
|
519
|
-
key: "
|
|
520
|
-
value: function
|
|
521
|
-
|
|
2086
|
+
key: "getProductExtend",
|
|
2087
|
+
value: function getProductExtend(cacheItem, extra) {
|
|
2088
|
+
var preparedCacheItem = withProductOptionString(cacheItem);
|
|
2089
|
+
var result = getProductExtendUtil({
|
|
2090
|
+
cacheItem: preparedCacheItem,
|
|
2091
|
+
ctx: this.buildBookingCalcContext(extra)
|
|
2092
|
+
});
|
|
2093
|
+
return result;
|
|
522
2094
|
}
|
|
523
2095
|
|
|
524
2096
|
/**
|
|
525
|
-
*
|
|
526
|
-
* @returns 当前搜索条件
|
|
2097
|
+
* 取资源不可用原因列表(结构化 enum + params,i18n 文案由 UI 渲染)。
|
|
527
2098
|
*/
|
|
528
2099
|
}, {
|
|
529
|
-
key: "
|
|
530
|
-
value: function
|
|
531
|
-
return
|
|
2100
|
+
key: "getResourceErrors",
|
|
2101
|
+
value: function getResourceErrors(resource, cacheItem) {
|
|
2102
|
+
return getResourceErrorsUtil(resource, cacheItem);
|
|
532
2103
|
}
|
|
533
2104
|
|
|
2105
|
+
// ─── addProduct 决策 / 转换 API(SDK 加车下沉所需) ─────────────────────────
|
|
2106
|
+
// 这一组方法是 SalesSdkCartContext.addProduct / confirmDetail 的 OS 后端。
|
|
2107
|
+
// 调用方传入 ProductData,OS 自取 bookingContext / customer / date 等上下文,
|
|
2108
|
+
// 输出 (a) autoClose 决策结果或 (b) `{ product, booking }` 协议入参。
|
|
2109
|
+
|
|
534
2110
|
/**
|
|
535
|
-
*
|
|
536
|
-
*
|
|
2111
|
+
* session 商品 catalog 日期与 TimeBar 不一致时写业务日志。
|
|
2112
|
+
*
|
|
2113
|
+
* @example
|
|
2114
|
+
* this.logSessionCatalogDateMismatch(product, ctx.date);
|
|
537
2115
|
*/
|
|
538
2116
|
}, {
|
|
539
|
-
key: "
|
|
540
|
-
value: function
|
|
541
|
-
|
|
2117
|
+
key: "logSessionCatalogDateMismatch",
|
|
2118
|
+
value: function logSessionCatalogDateMismatch(item, bookingDate) {
|
|
2119
|
+
var _this$getTempOrder, _tempOrder$order_id, _tempOrder$external_s, _item$cartDetailValue, _item$cartDetailValue2;
|
|
2120
|
+
var logger = this.logger;
|
|
2121
|
+
if (!(logger !== null && logger !== void 0 && logger.addLog)) return;
|
|
2122
|
+
var tempOrder = (_this$getTempOrder = this.getTempOrder) === null || _this$getTempOrder === void 0 ? void 0 : _this$getTempOrder.call(this);
|
|
2123
|
+
var staleInfo = buildSessionCatalogStaleInfo(item, bookingDate);
|
|
2124
|
+
logger.addLog({
|
|
2125
|
+
type: 'warning',
|
|
2126
|
+
title: "[BookingTicket] session catalog date mismatch, reload products",
|
|
2127
|
+
metadata: _objectSpread(_objectSpread({
|
|
2128
|
+
order_id: (_tempOrder$order_id = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : null,
|
|
2129
|
+
external_sale_number: (_tempOrder$external_s = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.external_sale_number) !== null && _tempOrder$external_s !== void 0 ? _tempOrder$external_s : null
|
|
2130
|
+
}, staleInfo), {}, {
|
|
2131
|
+
cartDetailValueSession: (_item$cartDetailValue = item === null || item === void 0 || (_item$cartDetailValue2 = item.cartDetailValue) === null || _item$cartDetailValue2 === void 0 ? void 0 : _item$cartDetailValue2.session) !== null && _item$cartDetailValue !== void 0 ? _item$cartDetailValue : null
|
|
2132
|
+
})
|
|
2133
|
+
});
|
|
542
2134
|
}
|
|
543
2135
|
|
|
544
2136
|
/**
|
|
545
|
-
*
|
|
546
|
-
* @param callback 回调
|
|
2137
|
+
* 加车前:session 商品 catalog 日历日与 bookingDate 不一致时中断加购,交由 SDK reload products。
|
|
547
2138
|
*/
|
|
548
2139
|
}, {
|
|
549
|
-
key: "
|
|
550
|
-
value: function
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
try {
|
|
558
|
-
callback(d);
|
|
559
|
-
} catch (error) {
|
|
560
|
-
console.error('scanGlobalListener传入的回调函数异常', error);
|
|
561
|
-
}
|
|
562
|
-
};
|
|
563
|
-
var listener = {
|
|
564
|
-
key: 'global',
|
|
565
|
-
callback: safeCallback
|
|
2140
|
+
key: "resolveSessionCatalogBeforeAdd",
|
|
2141
|
+
value: function resolveSessionCatalogBeforeAdd(item, ctx) {
|
|
2142
|
+
if (!isSessionCatalogDateStale(item, ctx.date)) {
|
|
2143
|
+
return null;
|
|
2144
|
+
}
|
|
2145
|
+
this.logSessionCatalogDateMismatch(item, ctx.date);
|
|
2146
|
+
return {
|
|
2147
|
+
action: 'reloadCatalog'
|
|
566
2148
|
};
|
|
567
|
-
var removeListener = this.scan.addListener(listener, scanCallback);
|
|
568
|
-
return removeListener;
|
|
569
2149
|
}
|
|
570
2150
|
|
|
571
2151
|
/**
|
|
572
|
-
*
|
|
573
|
-
* @param callback 回调
|
|
2152
|
+
* 拼装 addProductDecision 通用上下文(从 store 自取)。
|
|
574
2153
|
*/
|
|
575
2154
|
}, {
|
|
576
|
-
key: "
|
|
577
|
-
value: function
|
|
578
|
-
var
|
|
579
|
-
var
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
};
|
|
590
|
-
var removeListener = this.scan.addListener(listener, scanCallback);
|
|
591
|
-
return removeListener;
|
|
2155
|
+
key: "buildAddProductCtx",
|
|
2156
|
+
value: function buildAddProductCtx(extra) {
|
|
2157
|
+
var _extra$date2, _ref12, _this$getOrderCustome, _this$getOrderCustome2, _this$store$order$get4, _extra$presetStartTim2;
|
|
2158
|
+
var bookingContextState = this.store.bookingContext.getState();
|
|
2159
|
+
var date = (_extra$date2 = extra === null || extra === void 0 ? void 0 : extra.date) !== null && _extra$date2 !== void 0 ? _extra$date2 : bookingContextState.date;
|
|
2160
|
+
var orderCustomerId = (_ref12 = (_this$getOrderCustome = (_this$getOrderCustome2 = this.getOrderCustomerSnapshot()) === null || _this$getOrderCustome2 === void 0 ? void 0 : _this$getOrderCustome2.id) !== null && _this$getOrderCustome !== void 0 ? _this$getOrderCustome : (_this$store$order$get4 = this.store.order.getTempOrder()) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.customer_id) !== null && _ref12 !== void 0 ? _ref12 : undefined;
|
|
2161
|
+
return _objectSpread({
|
|
2162
|
+
bookingConfig: bookingContextState.bookingConfig,
|
|
2163
|
+
resourcesOrigin: bookingContextState.resourcesOrigin,
|
|
2164
|
+
resourcesOriginMap: bookingContextState.resourcesOriginMap,
|
|
2165
|
+
date: date,
|
|
2166
|
+
presetStartTime: (_extra$presetStartTim2 = extra === null || extra === void 0 ? void 0 : extra.presetStartTime) !== null && _extra$presetStartTim2 !== void 0 ? _extra$presetStartTim2 : derivePresetStartTimeFromDate(date),
|
|
2167
|
+
customerId: orderCustomerId
|
|
2168
|
+
}, extra || {});
|
|
592
2169
|
}
|
|
593
2170
|
|
|
594
2171
|
/**
|
|
595
|
-
*
|
|
596
|
-
*
|
|
597
|
-
* @param callback 回调
|
|
2172
|
+
* 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
|
|
2173
|
+
* 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
|
|
598
2174
|
*/
|
|
599
2175
|
}, {
|
|
600
|
-
key: "
|
|
601
|
-
value: function
|
|
602
|
-
var
|
|
603
|
-
var
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
return removeListener;
|
|
2176
|
+
key: "decideAddProduct",
|
|
2177
|
+
value: function decideAddProduct(item, options) {
|
|
2178
|
+
var ctx = this.buildAddProductCtx(options);
|
|
2179
|
+
var staleDecision = this.resolveSessionCatalogBeforeAdd(item, ctx);
|
|
2180
|
+
if (staleDecision) {
|
|
2181
|
+
return staleDecision;
|
|
2182
|
+
}
|
|
2183
|
+
return decideAddProductUtil(item, ctx);
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
/** 规格弹窗 callback 后的第二段决策。 */
|
|
2187
|
+
}, {
|
|
2188
|
+
key: "decideAfterDetail",
|
|
2189
|
+
value: function decideAfterDetail(cacheItem, options) {
|
|
2190
|
+
return decideAfterDetailUtil(cacheItem, this.buildAddProductCtx(options));
|
|
616
2191
|
}
|
|
617
2192
|
|
|
618
2193
|
/**
|
|
619
|
-
*
|
|
620
|
-
* @param data 用户自定义数据
|
|
2194
|
+
* @deprecated 请用 `decideAddProduct`;`autoClose=true` 仅当 action=add。
|
|
621
2195
|
*/
|
|
622
2196
|
}, {
|
|
623
|
-
key: "
|
|
624
|
-
value: function
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
2197
|
+
key: "decideAutoClose",
|
|
2198
|
+
value: function decideAutoClose(item, options) {
|
|
2199
|
+
return decideAutoCloseUtil(item, this.buildAddProductCtx(options));
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
/** 替代 info2 `getIsEject`:商品是否需要弹窗(0/1)。 */
|
|
2203
|
+
}, {
|
|
2204
|
+
key: "getIsEject",
|
|
2205
|
+
value: function getIsEject(item) {
|
|
2206
|
+
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'select';
|
|
2207
|
+
return getIsEjectUtil(item, type);
|
|
2208
|
+
}
|
|
2209
|
+
|
|
2210
|
+
/** 仅 session 商品(无 variant/option/package)→ true。 */
|
|
2211
|
+
}, {
|
|
2212
|
+
key: "getIsOnlySession",
|
|
2213
|
+
value: function getIsOnlySession(item) {
|
|
2214
|
+
return getIsOnlySessionUtil(item);
|
|
631
2215
|
}
|
|
632
2216
|
|
|
633
2217
|
/**
|
|
634
|
-
*
|
|
2218
|
+
* 拼装 requiresDetail payload(给 SDK 直接 return 给 UI 用)。
|
|
635
2219
|
*/
|
|
636
2220
|
}, {
|
|
637
|
-
key: "
|
|
638
|
-
value: function
|
|
639
|
-
this.
|
|
2221
|
+
key: "buildRequiresDetailPayload",
|
|
2222
|
+
value: function buildRequiresDetailPayload(item, options) {
|
|
2223
|
+
var ctx = this.buildAddProductCtx(options);
|
|
2224
|
+
return _buildRequiresDetailPayload(item, ctx);
|
|
640
2225
|
}
|
|
641
2226
|
|
|
642
2227
|
/**
|
|
643
|
-
*
|
|
2228
|
+
* 把 detail 弹窗回调结果(e, extension_type, detail)转换为 `(product, booking)` 入参。
|
|
2229
|
+
* 内部会先拼 cacheItem,再走 cacheItemToBookingInput 严格协议对齐。
|
|
644
2230
|
*/
|
|
645
2231
|
}, {
|
|
646
|
-
key: "
|
|
647
|
-
value: function
|
|
648
|
-
|
|
2232
|
+
key: "transformDetailToProductAndBooking",
|
|
2233
|
+
value: function transformDetailToProductAndBooking(input) {
|
|
2234
|
+
var item = input.item,
|
|
2235
|
+
preparedCacheItem = input.cacheItem,
|
|
2236
|
+
detailResult = input.detailResult,
|
|
2237
|
+
options = input.options;
|
|
2238
|
+
var ctx = this.buildAddProductCtx(options);
|
|
2239
|
+
var cacheItem = preparedCacheItem || (detailResult ? buildCacheItemFromDetail(item, detailResult, ctx) : buildCacheItemFromCartDetail(item, ctx));
|
|
2240
|
+
return transformDetailToProductAndBookingUtil(cacheItem, ctx);
|
|
649
2241
|
}
|
|
650
2242
|
|
|
651
2243
|
/**
|
|
652
|
-
*
|
|
2244
|
+
* 从已加车的 order line + booking 反查资源编辑抽屉所需的 cacheItem。
|
|
2245
|
+
* 供 SalesSdk「编辑资源」等场景使用;字段语义与 buildCacheItemFromDetail 产出对齐。
|
|
653
2246
|
*/
|
|
654
2247
|
}, {
|
|
655
|
-
key: "
|
|
656
|
-
value: function
|
|
657
|
-
|
|
2248
|
+
key: "buildCacheItemFromOrderLine",
|
|
2249
|
+
value: function buildCacheItemFromOrderLine(input) {
|
|
2250
|
+
return buildCacheItemFromOrderLineUtil(input);
|
|
658
2251
|
}
|
|
659
2252
|
|
|
660
2253
|
/**
|
|
661
|
-
*
|
|
662
|
-
* @param params 参数
|
|
663
|
-
* @param options 选项
|
|
2254
|
+
* 从已加车的普通商品 order line 反查 SkuDetailModal edit 所需的 cacheItem。
|
|
664
2255
|
*/
|
|
665
2256
|
}, {
|
|
666
|
-
key: "
|
|
2257
|
+
key: "buildNormalProductCacheItemFromOrderLine",
|
|
2258
|
+
value: function buildNormalProductCacheItemFromOrderLine(input) {
|
|
2259
|
+
return buildNormalProductCacheItemFromOrderLineUtil(input);
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
/** 文档别名:与 OrderModule.updateOrderProduct 一致。 */
|
|
2263
|
+
}, {
|
|
2264
|
+
key: "updateProductInOrder",
|
|
667
2265
|
value: (function () {
|
|
668
|
-
var
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
cover,
|
|
672
|
-
_args9 = arguments;
|
|
673
|
-
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
674
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
2266
|
+
var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
2267
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2268
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
675
2269
|
case 0:
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
this.otherParams = params;
|
|
679
|
-
} else {
|
|
680
|
-
this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
|
|
681
|
-
}
|
|
682
|
-
case 2:
|
|
2270
|
+
return _context27.abrupt("return", this.updateOrderProduct(params));
|
|
2271
|
+
case 1:
|
|
683
2272
|
case "end":
|
|
684
|
-
return
|
|
2273
|
+
return _context27.stop();
|
|
685
2274
|
}
|
|
686
|
-
},
|
|
2275
|
+
}, _callee27, this);
|
|
687
2276
|
}));
|
|
688
|
-
function
|
|
689
|
-
return
|
|
2277
|
+
function updateProductInOrder(_x17) {
|
|
2278
|
+
return _updateProductInOrder.apply(this, arguments);
|
|
690
2279
|
}
|
|
691
|
-
return
|
|
2280
|
+
return updateProductInOrder;
|
|
692
2281
|
}()
|
|
693
2282
|
/**
|
|
694
|
-
*
|
|
695
|
-
*
|
|
2283
|
+
* 全局扫码 pubsub 入口:解析码值 → 搜索 → 业务分发(客户 / 加车 / 开单)。
|
|
2284
|
+
* UI 层在 pubsub 订阅回调里注入 `bridge`(uiHosts / action / cart.confirm*)。
|
|
2285
|
+
*
|
|
2286
|
+
* @example
|
|
2287
|
+
* ```ts
|
|
2288
|
+
* await bookingTicket.handleGlobalScanCode(payload.data, {
|
|
2289
|
+
* openProductDetail: uiHosts.openProductDetail,
|
|
2290
|
+
* confirmDetail: cart.confirmDetail,
|
|
2291
|
+
* openOrder: ({ order_id }) => action({ type: 'pisell1.handleOpenCachedBigSale', data: { order_id } }),
|
|
2292
|
+
* });
|
|
2293
|
+
* ```
|
|
696
2294
|
*/
|
|
697
2295
|
)
|
|
698
2296
|
}, {
|
|
699
|
-
key: "
|
|
2297
|
+
key: "handleGlobalScanCode",
|
|
700
2298
|
value: (function () {
|
|
701
|
-
var
|
|
702
|
-
|
|
703
|
-
|
|
2299
|
+
var _handleGlobalScanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(code, bridge) {
|
|
2300
|
+
var _this6 = this;
|
|
2301
|
+
var trimmed, _bridge$onNotify, _bridge$refresh, localSearch, scanCallback, raw, formatted, _bridge$onNotify2, _result7, _bridge$onNotify3;
|
|
2302
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2303
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2304
|
+
case 0:
|
|
2305
|
+
trimmed = typeof code === 'string' ? code.trim() : '';
|
|
2306
|
+
if (trimmed) {
|
|
2307
|
+
_context28.next = 4;
|
|
2308
|
+
break;
|
|
2309
|
+
}
|
|
2310
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify = bridge.onNotify) === null || _bridge$onNotify === void 0 || _bridge$onNotify.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
2311
|
+
return _context28.abrupt("return", {
|
|
2312
|
+
status: 'failed',
|
|
2313
|
+
reason: 'empty_code'
|
|
2314
|
+
});
|
|
2315
|
+
case 4:
|
|
2316
|
+
_context28.prev = 4;
|
|
2317
|
+
localSearch = function localSearch(v) {
|
|
2318
|
+
return _this6.store.products.findProductsByCodeOrBarcode(v);
|
|
2319
|
+
};
|
|
2320
|
+
scanCallback = handleGlobalScan(this.request, localSearch, this.getSubmitOrderSalesChannel());
|
|
2321
|
+
_context28.next = 9;
|
|
2322
|
+
return scanCallback({
|
|
2323
|
+
type: 'nativeScanner',
|
|
2324
|
+
value: trimmed
|
|
2325
|
+
});
|
|
2326
|
+
case 9:
|
|
2327
|
+
raw = _context28.sent;
|
|
2328
|
+
formatted = formatGlobalScanResult(raw, trimmed);
|
|
2329
|
+
if (formatted) {
|
|
2330
|
+
_context28.next = 14;
|
|
2331
|
+
break;
|
|
2332
|
+
}
|
|
2333
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify2 = bridge.onNotify) === null || _bridge$onNotify2 === void 0 || _bridge$onNotify2.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
2334
|
+
return _context28.abrupt("return", {
|
|
2335
|
+
status: 'failed',
|
|
2336
|
+
reason: 'not_found'
|
|
2337
|
+
});
|
|
2338
|
+
case 14:
|
|
2339
|
+
_context28.next = 16;
|
|
2340
|
+
return applyGlobalScan({
|
|
2341
|
+
setOrderCustomer: function setOrderCustomer(customer) {
|
|
2342
|
+
return _this6.setOrderCustomer(customer);
|
|
2343
|
+
},
|
|
2344
|
+
getOrderCustomerSnapshot: function getOrderCustomerSnapshot() {
|
|
2345
|
+
return _this6.getOrderCustomerSnapshot();
|
|
2346
|
+
},
|
|
2347
|
+
getBusinessCode: function getBusinessCode() {
|
|
2348
|
+
var _this6$otherParams;
|
|
2349
|
+
return (_this6$otherParams = _this6.otherParams) === null || _this6$otherParams === void 0 ? void 0 : _this6$otherParams.businessCode;
|
|
2350
|
+
},
|
|
2351
|
+
buildAddProductCtx: function buildAddProductCtx(extra) {
|
|
2352
|
+
return _this6.buildAddProductCtx(extra);
|
|
2353
|
+
},
|
|
2354
|
+
decideAddProduct: function decideAddProduct(item, options) {
|
|
2355
|
+
return _this6.decideAddProduct(item, options);
|
|
2356
|
+
},
|
|
2357
|
+
decideAfterDetail: function decideAfterDetail(cacheItem, options) {
|
|
2358
|
+
return _this6.decideAfterDetail(cacheItem, options);
|
|
2359
|
+
},
|
|
2360
|
+
transformDetailToProductAndBooking: function transformDetailToProductAndBooking(input) {
|
|
2361
|
+
return _this6.transformDetailToProductAndBooking(input);
|
|
2362
|
+
},
|
|
2363
|
+
addProductToOrder: function addProductToOrder(product, booking) {
|
|
2364
|
+
return _this6.addProductToOrder(product, booking);
|
|
2365
|
+
}
|
|
2366
|
+
}, formatted, bridge);
|
|
2367
|
+
case 16:
|
|
2368
|
+
_result7 = _context28.sent;
|
|
2369
|
+
bridge === null || bridge === void 0 || (_bridge$refresh = bridge.refresh) === null || _bridge$refresh === void 0 || _bridge$refresh.call(bridge);
|
|
2370
|
+
return _context28.abrupt("return", _result7);
|
|
2371
|
+
case 21:
|
|
2372
|
+
_context28.prev = 21;
|
|
2373
|
+
_context28.t0 = _context28["catch"](4);
|
|
2374
|
+
console.error('[BookingTicket] handleGlobalScanCode failed', _context28.t0);
|
|
2375
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify3 = bridge.onNotify) === null || _bridge$onNotify3 === void 0 || _bridge$onNotify3.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
2376
|
+
return _context28.abrupt("return", {
|
|
2377
|
+
status: 'failed',
|
|
2378
|
+
reason: 'not_found'
|
|
2379
|
+
});
|
|
2380
|
+
case 26:
|
|
2381
|
+
case "end":
|
|
2382
|
+
return _context28.stop();
|
|
2383
|
+
}
|
|
2384
|
+
}, _callee28, this, [[4, 21]]);
|
|
2385
|
+
}));
|
|
2386
|
+
function handleGlobalScanCode(_x18, _x19) {
|
|
2387
|
+
return _handleGlobalScanCode.apply(this, arguments);
|
|
2388
|
+
}
|
|
2389
|
+
return handleGlobalScanCode;
|
|
2390
|
+
}())
|
|
2391
|
+
}, {
|
|
2392
|
+
key: "resolveBestAddTimePlan",
|
|
2393
|
+
value: function resolveBestAddTimePlan(addTimeProducts, targetMinutes) {
|
|
2394
|
+
return _resolveBestAddTimePlan(addTimeProducts, targetMinutes);
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
/**
|
|
2398
|
+
* 构造一条绑定到已有 booking 的加时商品行。
|
|
2399
|
+
*
|
|
2400
|
+
* @example
|
|
2401
|
+
* const line = this.buildAddTimeOrderLine({ product, product_add_schedule_time: 30 }, 'booking-1');
|
|
2402
|
+
*/
|
|
2403
|
+
}, {
|
|
2404
|
+
key: "buildAddTimeOrderLine",
|
|
2405
|
+
value: function buildAddTimeOrderLine(input, bookingUid) {
|
|
2406
|
+
var _input$num, _product$id, _product$product_id, _ref13, _product$product_vari, _ref14, _product$variant_id, _product$original_pri, _ref15, _ref16, _product$option, _product$product_sku, _ref17, _ref18, _product$bundle, _product$id2;
|
|
2407
|
+
var product = input === null || input === void 0 ? void 0 : input.product;
|
|
2408
|
+
if (!product || _typeof(product) !== 'object') {
|
|
2409
|
+
throw new Error('[BookingTicket] addAddTimeProductToBooking: product 不能为空');
|
|
2410
|
+
}
|
|
2411
|
+
var quantity = normalizeAddTimeQuantity((_input$num = input.num) !== null && _input$num !== void 0 ? _input$num : product.num);
|
|
2412
|
+
var price = resolveAddTimeProductPrice(input.price, product);
|
|
2413
|
+
var addScheduleTime = resolveAddTimeScheduleMinutes(input.product_add_schedule_time, product);
|
|
2414
|
+
var payload = {
|
|
2415
|
+
id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : product.product_id,
|
|
2416
|
+
product_id: (_product$product_id = product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product.id,
|
|
2417
|
+
product_variant_id: (_ref13 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : product.variant_id) !== null && _ref13 !== void 0 ? _ref13 : 0,
|
|
2418
|
+
variant_id: (_ref14 = (_product$variant_id = product.variant_id) !== null && _product$variant_id !== void 0 ? _product$variant_id : product.product_variant_id) !== null && _ref14 !== void 0 ? _ref14 : 0,
|
|
2419
|
+
quantity: quantity,
|
|
2420
|
+
num: quantity,
|
|
2421
|
+
price: price,
|
|
2422
|
+
selling_price: price,
|
|
2423
|
+
original_price: (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : price,
|
|
2424
|
+
line_total: price,
|
|
2425
|
+
total: price,
|
|
2426
|
+
product_sku: product.product_sku,
|
|
2427
|
+
option: (_ref15 = (_ref16 = (_product$option = product.option) !== null && _product$option !== void 0 ? _product$option : product.options) !== null && _ref16 !== void 0 ? _ref16 : (_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.option) !== null && _ref15 !== void 0 ? _ref15 : [],
|
|
2428
|
+
bundle: (_ref17 = (_ref18 = (_product$bundle = product.bundle) !== null && _product$bundle !== void 0 ? _product$bundle : product.bundles) !== null && _ref18 !== void 0 ? _ref18 : product.product_bundle) !== null && _ref17 !== void 0 ? _ref17 : []
|
|
2429
|
+
};
|
|
2430
|
+
var orderLine = this.transformBaseProductToOrderProduct({
|
|
2431
|
+
payload: payload,
|
|
2432
|
+
fallbackProductId: (_product$id2 = product.id) !== null && _product$id2 !== void 0 ? _product$id2 : product.product_id,
|
|
2433
|
+
sourceProduct: product,
|
|
2434
|
+
sourceItem: product
|
|
2435
|
+
});
|
|
2436
|
+
if (!orderLine) {
|
|
2437
|
+
throw new Error('[BookingTicket] addAddTimeProductToBooking: product transform failed');
|
|
2438
|
+
}
|
|
2439
|
+
var metadata = _objectSpread(_objectSpread(_objectSpread({}, orderLine.metadata || {}), addScheduleTime !== undefined ? {
|
|
2440
|
+
product_add_schedule_time: addScheduleTime
|
|
2441
|
+
} : {}), {}, {
|
|
2442
|
+
booking_uid: bookingUid
|
|
2443
|
+
});
|
|
2444
|
+
return _objectSpread(_objectSpread({}, orderLine), {}, {
|
|
2445
|
+
booking_uid: bookingUid,
|
|
2446
|
+
metadata: metadata
|
|
2447
|
+
});
|
|
2448
|
+
}
|
|
2449
|
+
|
|
2450
|
+
/**
|
|
2451
|
+
* 将加时商品作为独立商品行绑定到已有 booking。
|
|
2452
|
+
*
|
|
2453
|
+
* 与预约商品加车不同,本方法不会把当前 booking 作为 `addProductToOrder` 第二参数传入,
|
|
2454
|
+
* 避免 OrderModule 新建 booking 或重写已有 booking.product_uid。
|
|
2455
|
+
*
|
|
2456
|
+
* @example
|
|
2457
|
+
* await bookingTicket.addAddTimeProductToBooking({
|
|
2458
|
+
* booking,
|
|
2459
|
+
* product,
|
|
2460
|
+
* num: 1,
|
|
2461
|
+
* price: '10.00',
|
|
2462
|
+
* product_add_schedule_time: 30,
|
|
2463
|
+
* });
|
|
2464
|
+
*/
|
|
2465
|
+
}, {
|
|
2466
|
+
key: "addAddTimeProductToBooking",
|
|
2467
|
+
value: (function () {
|
|
2468
|
+
var _addAddTimeProductToBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(input) {
|
|
2469
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2470
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
704
2471
|
case 0:
|
|
705
|
-
return
|
|
2472
|
+
return _context29.abrupt("return", this.addAddTimeProductsToBooking({
|
|
2473
|
+
booking: input.booking,
|
|
2474
|
+
products: [input],
|
|
2475
|
+
coveredMinutes: input.coveredMinutes,
|
|
2476
|
+
bookingPatch: input.bookingPatch
|
|
2477
|
+
}));
|
|
706
2478
|
case 1:
|
|
707
2479
|
case "end":
|
|
708
|
-
return
|
|
2480
|
+
return _context29.stop();
|
|
709
2481
|
}
|
|
710
|
-
},
|
|
2482
|
+
}, _callee29, this);
|
|
711
2483
|
}));
|
|
712
|
-
function
|
|
713
|
-
return
|
|
2484
|
+
function addAddTimeProductToBooking(_x20) {
|
|
2485
|
+
return _addAddTimeProductToBooking.apply(this, arguments);
|
|
714
2486
|
}
|
|
715
|
-
return
|
|
2487
|
+
return addAddTimeProductToBooking;
|
|
716
2488
|
}()
|
|
717
2489
|
/**
|
|
718
|
-
*
|
|
2490
|
+
* 批量将加时商品作为独立商品行绑定到已有 booking,并只触发一次购物车重算。
|
|
2491
|
+
*
|
|
2492
|
+
* @example
|
|
2493
|
+
* await bookingTicket.addAddTimeProductsToBooking({
|
|
2494
|
+
* booking,
|
|
2495
|
+
* products: [{ product, product_add_schedule_time: 30 }],
|
|
2496
|
+
* });
|
|
719
2497
|
*/
|
|
720
2498
|
)
|
|
721
2499
|
}, {
|
|
722
|
-
key: "
|
|
723
|
-
value: function
|
|
724
|
-
var
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
2500
|
+
key: "addAddTimeProductsToBooking",
|
|
2501
|
+
value: (function () {
|
|
2502
|
+
var _addAddTimeProductsToBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(input) {
|
|
2503
|
+
var _this7 = this,
|
|
2504
|
+
_input$bookingPatch;
|
|
2505
|
+
var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result, _iterator2, _step2, line;
|
|
2506
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2507
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2508
|
+
case 0:
|
|
2509
|
+
bookingUid = resolveBookingUidForAddTime(input === null || input === void 0 ? void 0 : input.booking);
|
|
2510
|
+
if (bookingUid) {
|
|
2511
|
+
_context30.next = 3;
|
|
2512
|
+
break;
|
|
2513
|
+
}
|
|
2514
|
+
throw new Error('[BookingTicket] addAddTimeProductToBooking: booking.metadata.unique_identification_number 缺失');
|
|
2515
|
+
case 3:
|
|
2516
|
+
orderLines = (input.products || []).map(function (line) {
|
|
2517
|
+
return {
|
|
2518
|
+
product: _this7.buildAddTimeOrderLine(line, bookingUid)
|
|
2519
|
+
};
|
|
2520
|
+
});
|
|
2521
|
+
if (this.store.order) {
|
|
2522
|
+
_context30.next = 6;
|
|
2523
|
+
break;
|
|
2524
|
+
}
|
|
2525
|
+
throw new Error('order 模块未初始化');
|
|
2526
|
+
case 6:
|
|
2527
|
+
coveredMinutes = normalizeCoveredMinutes(input.coveredMinutes);
|
|
2528
|
+
bookingTimePatch = (_input$bookingPatch = input.bookingPatch) !== null && _input$bookingPatch !== void 0 ? _input$bookingPatch : buildAddTimeBookingTimePatch(input.booking, coveredMinutes);
|
|
2529
|
+
if (bookingTimePatch) {
|
|
2530
|
+
this.store.order.updateOrderBooking({
|
|
2531
|
+
unique_identification_number: bookingUid,
|
|
2532
|
+
updates: bookingTimePatch
|
|
2533
|
+
});
|
|
2534
|
+
}
|
|
2535
|
+
if (!(typeof this.store.order.addProductsToOrder === 'function')) {
|
|
2536
|
+
_context30.next = 11;
|
|
2537
|
+
break;
|
|
2538
|
+
}
|
|
2539
|
+
return _context30.abrupt("return", this.store.order.addProductsToOrder(orderLines, {
|
|
2540
|
+
skipEditDiscountConfigRefresh: true,
|
|
2541
|
+
skipDiscountRecalculation: true
|
|
2542
|
+
}));
|
|
2543
|
+
case 11:
|
|
2544
|
+
result = [];
|
|
2545
|
+
_iterator2 = _createForOfIteratorHelper(orderLines);
|
|
2546
|
+
_context30.prev = 13;
|
|
2547
|
+
_iterator2.s();
|
|
2548
|
+
case 15:
|
|
2549
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
2550
|
+
_context30.next = 29;
|
|
2551
|
+
break;
|
|
2552
|
+
}
|
|
2553
|
+
line = _step2.value;
|
|
2554
|
+
_context30.t0 = result.splice;
|
|
2555
|
+
_context30.t1 = result;
|
|
2556
|
+
_context30.t2 = [0, result.length];
|
|
2557
|
+
_context30.t3 = _toConsumableArray;
|
|
2558
|
+
_context30.next = 23;
|
|
2559
|
+
return this.addProductToOrder(line.product);
|
|
2560
|
+
case 23:
|
|
2561
|
+
_context30.t4 = _context30.sent;
|
|
2562
|
+
_context30.t5 = (0, _context30.t3)(_context30.t4);
|
|
2563
|
+
_context30.t6 = _context30.t2.concat.call(_context30.t2, _context30.t5);
|
|
2564
|
+
_context30.t0.apply.call(_context30.t0, _context30.t1, _context30.t6);
|
|
2565
|
+
case 27:
|
|
2566
|
+
_context30.next = 15;
|
|
2567
|
+
break;
|
|
2568
|
+
case 29:
|
|
2569
|
+
_context30.next = 34;
|
|
2570
|
+
break;
|
|
2571
|
+
case 31:
|
|
2572
|
+
_context30.prev = 31;
|
|
2573
|
+
_context30.t7 = _context30["catch"](13);
|
|
2574
|
+
_iterator2.e(_context30.t7);
|
|
2575
|
+
case 34:
|
|
2576
|
+
_context30.prev = 34;
|
|
2577
|
+
_iterator2.f();
|
|
2578
|
+
return _context30.finish(34);
|
|
2579
|
+
case 37:
|
|
2580
|
+
return _context30.abrupt("return", result);
|
|
2581
|
+
case 38:
|
|
2582
|
+
case "end":
|
|
2583
|
+
return _context30.stop();
|
|
2584
|
+
}
|
|
2585
|
+
}, _callee30, this, [[13, 31, 34, 37]]);
|
|
2586
|
+
}));
|
|
2587
|
+
function addAddTimeProductsToBooking(_x21) {
|
|
2588
|
+
return _addAddTimeProductsToBooking.apply(this, arguments);
|
|
2589
|
+
}
|
|
2590
|
+
return addAddTimeProductsToBooking;
|
|
2591
|
+
}())
|
|
2592
|
+
}, {
|
|
2593
|
+
key: "setOtherParams",
|
|
2594
|
+
value: function () {
|
|
2595
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
2596
|
+
var _ref19,
|
|
2597
|
+
_ref19$cover,
|
|
2598
|
+
cover,
|
|
2599
|
+
_args31 = arguments;
|
|
2600
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2601
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2602
|
+
case 0:
|
|
2603
|
+
_ref19 = _args31.length > 1 && _args31[1] !== undefined ? _args31[1] : {}, _ref19$cover = _ref19.cover, cover = _ref19$cover === void 0 ? false : _ref19$cover;
|
|
2604
|
+
_get(_getPrototypeOf(BookingTicketImpl.prototype), "setOtherParams", this).call(this, params, {
|
|
2605
|
+
cover: cover
|
|
2606
|
+
});
|
|
2607
|
+
if (!(params !== null && params !== void 0 && params.businessCode)) {
|
|
2608
|
+
_context31.next = 5;
|
|
2609
|
+
break;
|
|
2610
|
+
}
|
|
2611
|
+
_context31.next = 5;
|
|
2612
|
+
return this.configureIdGeneratorFromOpenData();
|
|
2613
|
+
case 5:
|
|
2614
|
+
case "end":
|
|
2615
|
+
return _context31.stop();
|
|
2616
|
+
}
|
|
2617
|
+
}, _callee31, this);
|
|
2618
|
+
}));
|
|
2619
|
+
function setOtherParams(_x22) {
|
|
2620
|
+
return _setOtherParams.apply(this, arguments);
|
|
2621
|
+
}
|
|
2622
|
+
return setOtherParams;
|
|
2623
|
+
}()
|
|
2624
|
+
}, {
|
|
2625
|
+
key: "getDeviceTaskPlugin",
|
|
2626
|
+
value: function getDeviceTaskPlugin() {
|
|
2627
|
+
var _app$getApp;
|
|
2628
|
+
var app = this.core.getPlugin('app');
|
|
2629
|
+
return (app === null || app === void 0 || (_app$getApp = app.getApp()) === null || _app$getApp === void 0 ? void 0 : _app$getApp.getPlugin('deviceTask')) || null;
|
|
736
2630
|
}
|
|
2631
|
+
|
|
2632
|
+
// 打印手环,单个或批量都可以
|
|
2633
|
+
}, {
|
|
2634
|
+
key: "handlePrintWristband",
|
|
2635
|
+
value: function () {
|
|
2636
|
+
var _handlePrintWristband = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
2637
|
+
var _this$getOrderIdentit;
|
|
2638
|
+
var deviceTask, deviceId, idempotencyKey;
|
|
2639
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
2640
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
2641
|
+
case 0:
|
|
2642
|
+
deviceTask = this.getDeviceTaskPlugin();
|
|
2643
|
+
if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
|
|
2644
|
+
_context32.next = 4;
|
|
2645
|
+
break;
|
|
2646
|
+
}
|
|
2647
|
+
this.logger.addLog({
|
|
2648
|
+
type: 'info',
|
|
2649
|
+
title: '[BookingTicket] handlePrintWristband: deviceTask.dispatch 不可用',
|
|
2650
|
+
metadata: {
|
|
2651
|
+
voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
|
|
2652
|
+
}
|
|
2653
|
+
});
|
|
2654
|
+
return _context32.abrupt("return");
|
|
2655
|
+
case 4:
|
|
2656
|
+
this.logger.addLog({
|
|
2657
|
+
type: 'info',
|
|
2658
|
+
title: '[BookingTicket] handlePrintWristband',
|
|
2659
|
+
metadata: {
|
|
2660
|
+
voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
|
|
2661
|
+
}
|
|
2662
|
+
});
|
|
2663
|
+
_context32.next = 7;
|
|
2664
|
+
return this.getShortNumberOrDeviceId();
|
|
2665
|
+
case 7:
|
|
2666
|
+
deviceId = _context32.sent;
|
|
2667
|
+
idempotencyKey = createUuidV4();
|
|
2668
|
+
deviceTask.dispatch({
|
|
2669
|
+
action: 'print_all',
|
|
2670
|
+
device_id: deviceId,
|
|
2671
|
+
payload: {
|
|
2672
|
+
type: 'WRISTBAND',
|
|
2673
|
+
data: {
|
|
2674
|
+
order_id: (_this$getOrderIdentit = this.getOrderIdentity()) === null || _this$getOrderIdentit === void 0 ? void 0 : _this$getOrderIdentit.orderId,
|
|
2675
|
+
voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
|
|
2676
|
+
}
|
|
2677
|
+
},
|
|
2678
|
+
idempotency_key: idempotencyKey,
|
|
2679
|
+
name: 'PRINT_WRISTBAND',
|
|
2680
|
+
source: 'bookingTicket',
|
|
2681
|
+
source_type: 'handlePrintWristband',
|
|
2682
|
+
source_id: idempotencyKey
|
|
2683
|
+
});
|
|
2684
|
+
case 10:
|
|
2685
|
+
case "end":
|
|
2686
|
+
return _context32.stop();
|
|
2687
|
+
}
|
|
2688
|
+
}, _callee32, this);
|
|
2689
|
+
}));
|
|
2690
|
+
function handlePrintWristband(_x23) {
|
|
2691
|
+
return _handlePrintWristband.apply(this, arguments);
|
|
2692
|
+
}
|
|
2693
|
+
return handlePrintWristband;
|
|
2694
|
+
}() // 触发核销
|
|
2695
|
+
}, {
|
|
2696
|
+
key: "handleRedeem",
|
|
2697
|
+
value: function () {
|
|
2698
|
+
var _handleRedeem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
2699
|
+
var _this$store$order5, _this$store$order5$ge, _this$store$order6, _ref20, _tempOrder$order_id2;
|
|
2700
|
+
var voucherIds, status, voucherIdSet, tempOrder, vouchers, hasUpdatedVoucher, nextVouchers, identity, externalSaleNumber, orderId, orderLookup;
|
|
2701
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2702
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
2703
|
+
case 0:
|
|
2704
|
+
voucherIds = Array.isArray(params.voucher_ids) ? params.voucher_ids : [];
|
|
2705
|
+
status = params.is_checkin ? 'used' : 'unused';
|
|
2706
|
+
this.logger.addLog({
|
|
2707
|
+
type: 'info',
|
|
2708
|
+
title: '[BookingTicket] handleRedeem',
|
|
2709
|
+
metadata: {
|
|
2710
|
+
voucher_ids: voucherIds,
|
|
2711
|
+
status: status
|
|
2712
|
+
}
|
|
2713
|
+
});
|
|
2714
|
+
voucherIdSet = new Set(voucherIds);
|
|
2715
|
+
tempOrder = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || (_this$store$order5$ge = _this$store$order5.getTempOrder) === null || _this$store$order5$ge === void 0 ? void 0 : _this$store$order5$ge.call(_this$store$order5);
|
|
2716
|
+
vouchers = (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.vouchers) || ((_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getVouchers()) || [];
|
|
2717
|
+
hasUpdatedVoucher = false;
|
|
2718
|
+
nextVouchers = vouchers.map(function (voucher) {
|
|
2719
|
+
if (!voucherIdSet.has(voucher.voucher_id)) return voucher;
|
|
2720
|
+
hasUpdatedVoucher = true;
|
|
2721
|
+
return _objectSpread(_objectSpread({}, voucher), {}, {
|
|
2722
|
+
status: status
|
|
2723
|
+
});
|
|
2724
|
+
});
|
|
2725
|
+
if (!(tempOrder && hasUpdatedVoucher)) {
|
|
2726
|
+
_context33.next = 11;
|
|
2727
|
+
break;
|
|
2728
|
+
}
|
|
2729
|
+
_context33.next = 11;
|
|
2730
|
+
return this.replaceTempOrder(_objectSpread(_objectSpread({}, tempOrder), {}, {
|
|
2731
|
+
vouchers: nextVouchers
|
|
2732
|
+
}));
|
|
2733
|
+
case 11:
|
|
2734
|
+
this.core.effects.emit("".concat(this.name, ":onVouchersChange"), {});
|
|
2735
|
+
if (!(voucherIds.length === 0)) {
|
|
2736
|
+
_context33.next = 14;
|
|
2737
|
+
break;
|
|
2738
|
+
}
|
|
2739
|
+
return _context33.abrupt("return", {
|
|
2740
|
+
code: 200,
|
|
2741
|
+
status: true,
|
|
2742
|
+
message: '',
|
|
2743
|
+
data: []
|
|
2744
|
+
});
|
|
2745
|
+
case 14:
|
|
2746
|
+
identity = this.getOrderIdentity();
|
|
2747
|
+
externalSaleNumber = (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.external_sale_number) || (identity === null || identity === void 0 ? void 0 : identity.externalSaleNumber) || undefined;
|
|
2748
|
+
orderId = (_ref20 = (_tempOrder$order_id2 = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) !== null && _tempOrder$order_id2 !== void 0 ? _tempOrder$order_id2 : identity === null || identity === void 0 ? void 0 : identity.orderId) !== null && _ref20 !== void 0 ? _ref20 : undefined;
|
|
2749
|
+
orderLookup = externalSaleNumber || orderId || (identity === null || identity === void 0 ? void 0 : identity.orderNumber) || (identity === null || identity === void 0 ? void 0 : identity.shopOrderNumber) || (identity === null || identity === void 0 ? void 0 : identity.shopFullOrderNumber) || undefined;
|
|
2750
|
+
return _context33.abrupt("return", this.request.post('/machinecode/batch', {
|
|
2751
|
+
ids: voucherIds,
|
|
2752
|
+
status: status,
|
|
2753
|
+
order_lookup: orderLookup,
|
|
2754
|
+
order_id: orderId,
|
|
2755
|
+
external_sale_number: externalSaleNumber
|
|
2756
|
+
}, {
|
|
2757
|
+
osServer: true
|
|
2758
|
+
}));
|
|
2759
|
+
case 19:
|
|
2760
|
+
case "end":
|
|
2761
|
+
return _context33.stop();
|
|
2762
|
+
}
|
|
2763
|
+
}, _callee33, this);
|
|
2764
|
+
}));
|
|
2765
|
+
function handleRedeem(_x24) {
|
|
2766
|
+
return _handleRedeem.apply(this, arguments);
|
|
2767
|
+
}
|
|
2768
|
+
return handleRedeem;
|
|
2769
|
+
}()
|
|
2770
|
+
/**
|
|
2771
|
+
* 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
|
|
2772
|
+
* 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
|
|
2773
|
+
*/
|
|
2774
|
+
}, {
|
|
2775
|
+
key: "destroy",
|
|
2776
|
+
value: (function () {
|
|
2777
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
2778
|
+
var _this$scan;
|
|
2779
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2780
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
2781
|
+
case 0:
|
|
2782
|
+
_context34.next = 2;
|
|
2783
|
+
return _get(_getPrototypeOf(BookingTicketImpl.prototype), "destroy", this).call(this);
|
|
2784
|
+
case 2:
|
|
2785
|
+
try {
|
|
2786
|
+
(_this$scan = this.scan) === null || _this$scan === void 0 || _this$scan.removeAllListeners();
|
|
2787
|
+
} catch (error) {
|
|
2788
|
+
console.warn('[BookingTicket] scan removeAllListeners 失败', error);
|
|
2789
|
+
}
|
|
2790
|
+
scanCache.clear();
|
|
2791
|
+
case 4:
|
|
2792
|
+
case "end":
|
|
2793
|
+
return _context34.stop();
|
|
2794
|
+
}
|
|
2795
|
+
}, _callee34, this);
|
|
2796
|
+
}));
|
|
2797
|
+
function destroy() {
|
|
2798
|
+
return _destroy.apply(this, arguments);
|
|
2799
|
+
}
|
|
2800
|
+
return destroy;
|
|
2801
|
+
}())
|
|
737
2802
|
}]);
|
|
738
2803
|
return BookingTicketImpl;
|
|
739
|
-
}(
|
|
2804
|
+
}(BaseSalesImpl);
|
|
740
2805
|
|
|
741
2806
|
// 导出相关类型和实现
|
|
742
2807
|
export * from "./types";
|