@pisell/pisellos 0.0.567 → 0.0.569
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.js +6 -9
- package/dist/model/strategy/adapter/promotion/evaluator.js +3 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -2
- package/dist/model/strategy/adapter/walletPass/example.js +3 -26
- package/dist/model/strategy/adapter/walletPass/utils.js +7 -7
- package/dist/model/strategy/strategy-example.js +5 -19
- package/dist/modules/BaseModule.d.ts +2 -2
- package/dist/modules/BaseModule.js +4 -4
- package/dist/modules/BookingContext/index.d.ts +48 -0
- package/dist/modules/BookingContext/index.js +566 -0
- package/dist/modules/BookingContext/types.d.ts +102 -0
- package/dist/modules/BookingContext/types.js +51 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +302 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +149 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +249 -0
- package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/dist/modules/BookingContext/utils/flexible.js +56 -0
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
- package/dist/modules/BookingContext/utils/index.d.ts +11 -0
- package/dist/modules/BookingContext/utils/index.js +11 -0
- package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/dist/modules/BookingContext/utils/noResource.js +77 -0
- package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/dist/modules/BookingContext/utils/orderLineDisplay.js +36 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/dist/modules/BookingContext/utils/productExtend.js +339 -0
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
- package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
- package/dist/modules/BookingContext/utils/resources.js +486 -0
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
- package/dist/modules/Cart/index.js +0 -3
- package/dist/modules/Cart/utils/cartProduct.js +26 -6
- package/dist/modules/Cart/utils/changePrice.js +27 -20
- package/dist/modules/Customer/index.d.ts +20 -0
- package/dist/modules/Customer/index.js +172 -83
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Date/index.js +1 -5
- package/dist/modules/Discount/index.d.ts +2 -1
- package/dist/modules/Discount/index.js +37 -12
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/OpenData/index.d.ts +8 -0
- package/dist/modules/OpenData/index.js +35 -17
- package/dist/modules/Order/index.d.ts +449 -24
- package/dist/modules/Order/index.js +5437 -608
- package/dist/modules/Order/types.d.ts +693 -88
- package/dist/modules/Order/types.js +68 -1
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/dist/modules/Order/utils/manualProductDiscount.js +210 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
- package/dist/modules/Order/utils.d.ts +167 -18
- package/dist/modules/Order/utils.js +960 -165
- package/dist/modules/Payment/index.d.ts +10 -9
- package/dist/modules/Payment/index.js +508 -874
- package/dist/modules/Payment/types.d.ts +40 -16
- package/dist/modules/Payment/utils.d.ts +1 -1
- package/dist/modules/Payment/utils.js +4 -3
- package/dist/modules/Payment/walletpass.js +48 -34
- package/dist/modules/Product/types.d.ts +29 -7
- package/dist/modules/ProductList/index.d.ts +17 -13
- package/dist/modules/ProductList/index.js +184 -74
- package/dist/modules/ProductList/types.d.ts +17 -0
- package/dist/modules/Quotation/index.d.ts +22 -2
- package/dist/modules/Quotation/index.js +108 -42
- package/dist/modules/Quotation/types.d.ts +19 -0
- package/dist/modules/ResourcePlanner/index.d.ts +24 -0
- package/dist/modules/ResourcePlanner/index.js +181 -0
- package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
- package/dist/modules/ResourcePlanner/planner.js +1069 -0
- package/dist/modules/ResourcePlanner/types.d.ts +227 -0
- package/dist/modules/ResourcePlanner/types.js +1 -0
- package/dist/modules/Rules/index.d.ts +8 -10
- package/dist/modules/Rules/index.js +219 -114
- package/dist/modules/Rules/types.d.ts +14 -3
- package/dist/modules/SalesSummary/index.d.ts +23 -26
- package/dist/modules/SalesSummary/index.js +152 -46
- package/dist/modules/SalesSummary/types.d.ts +9 -1
- package/dist/modules/SalesSummary/utils.d.ts +3 -22
- package/dist/modules/SalesSummary/utils.js +803 -163
- package/dist/modules/Schedule/getDateIsInSchedule.js +14 -7
- package/dist/modules/Schedule/index.d.ts +18 -5
- package/dist/modules/Schedule/index.js +78 -24
- package/dist/modules/Schedule/types.d.ts +2 -0
- package/dist/modules/Schedule/utils.js +0 -1
- package/dist/modules/Step/index.js +0 -1
- package/dist/modules/Summary/index.js +4 -3
- package/dist/modules/SurchargeList/index.d.ts +18 -0
- package/dist/modules/SurchargeList/index.js +185 -0
- package/dist/modules/SurchargeList/types.d.ts +15 -0
- package/dist/modules/SurchargeList/types.js +1 -0
- package/dist/modules/index.d.ts +3 -0
- package/dist/modules/index.js +4 -1
- package/dist/plugins/app.d.ts +2 -0
- package/dist/plugins/request.d.ts +1 -0
- package/dist/plugins/request.js +1 -4
- package/dist/plugins/window.js +2 -6
- package/dist/server/index.d.ts +462 -8
- package/dist/server/index.js +6137 -714
- package/dist/server/modules/floor-plan/index.d.ts +39 -0
- package/dist/server/modules/floor-plan/index.js +595 -0
- package/dist/server/modules/floor-plan/types.d.ts +43 -0
- package/dist/server/modules/floor-plan/types.js +13 -0
- package/dist/server/modules/index.d.ts +7 -2
- package/dist/server/modules/index.js +6 -0
- package/dist/server/modules/menu/index.js +32 -41
- package/dist/server/modules/order/index.d.ts +207 -14
- package/dist/server/modules/order/index.js +2326 -379
- package/dist/server/modules/order/types.d.ts +76 -5
- package/dist/server/modules/order/types.js +14 -1
- package/dist/server/modules/order/utils/filterBookings.d.ts +7 -1
- package/dist/server/modules/order/utils/filterBookings.js +118 -11
- package/dist/server/modules/order/utils/filterOrders.js +242 -14
- package/dist/server/modules/payment/index.d.ts +28 -0
- package/dist/server/modules/payment/index.js +305 -0
- package/dist/server/modules/payment/types.d.ts +9 -0
- package/dist/server/modules/payment/types.js +1 -0
- package/dist/server/modules/products/index.d.ts +105 -14
- package/dist/server/modules/products/index.js +1397 -540
- package/dist/server/modules/products/types.d.ts +34 -1
- package/dist/server/modules/products/types.js +4 -0
- package/dist/server/modules/quotation/index.d.ts +39 -0
- package/dist/server/modules/quotation/index.js +289 -86
- package/dist/server/modules/resource/index.d.ts +2 -3
- package/dist/server/modules/resource/index.js +105 -84
- package/dist/server/modules/schedule/index.d.ts +6 -4
- package/dist/server/modules/schedule/index.js +137 -114
- package/dist/server/test.json +713 -0
- package/dist/server/types.d.ts +2 -0
- package/dist/server/utils/product.js +2 -3
- package/dist/server/utils/small-ticket.d.ts +71 -0
- package/dist/server/utils/small-ticket.js +963 -0
- package/dist/solution/BaseSales/index.d.ts +378 -0
- package/dist/solution/BaseSales/index.js +4006 -0
- package/dist/solution/BaseSales/types.d.ts +394 -0
- package/dist/solution/BaseSales/types.js +40 -0
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
- package/dist/solution/BaseSales/utils/cartPromotion.js +1450 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +144 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +157 -0
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +18 -0
- package/dist/solution/BaseSales/utils/quotationPrice.js +250 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +63 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +218 -0
- package/dist/solution/BaseSales/utils.d.ts +40 -0
- package/dist/solution/BaseSales/utils.js +263 -0
- package/dist/solution/BookingByStep/index.js +7 -59
- package/dist/solution/BookingByStep/utils/capacity.js +1 -11
- package/dist/solution/BookingByStep/utils/resources.js +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +2 -43
- package/dist/solution/BookingTicket/index.d.ts +393 -24
- package/dist/solution/BookingTicket/index.js +2506 -445
- package/dist/solution/BookingTicket/types.d.ts +191 -6
- package/dist/solution/BookingTicket/types.js +83 -10
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
- package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
- package/dist/solution/BookingTicket/utils/addTimeAvailability.js +95 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.js +136 -0
- package/dist/solution/BookingTicket/utils/cartView.d.ts +29 -0
- package/dist/solution/BookingTicket/utils/cartView.js +209 -0
- package/dist/solution/BookingTicket/utils/exampleData.d.ts +123 -0
- package/dist/solution/BookingTicket/utils/exampleData.js +183 -0
- package/dist/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
- package/dist/solution/BookingTicket/utils/orderCustomer.js +31 -0
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +438 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +400 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +4 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +41 -1
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +56 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +36 -34
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +26 -18
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +150 -0
- package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
- package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +78 -0
- package/dist/solution/BuyTickets/index.js +9 -12
- package/dist/solution/Checkout/index.d.ts +1 -0
- package/dist/solution/Checkout/index.js +199 -277
- package/dist/solution/Checkout/utils/index.js +8 -20
- package/dist/solution/RegisterAndLogin/config.js +2 -10
- package/dist/solution/RegisterAndLogin/index.js +30 -76
- package/dist/solution/Sales/index.d.ts +50 -5
- package/dist/solution/Sales/index.js +484 -92
- package/dist/solution/Sales/types.d.ts +26 -2
- package/dist/solution/ScanOrder/index.d.ts +27 -21
- package/dist/solution/ScanOrder/index.js +509 -454
- package/dist/solution/ScanOrder/types.d.ts +33 -11
- package/dist/solution/ScanOrder/types.js +4 -5
- package/dist/solution/ScanOrder/utils.d.ts +4 -1
- package/dist/solution/ScanOrder/utils.js +109 -34
- package/dist/solution/ShopDiscount/index.js +6 -11
- package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/dist/solution/UnifiedBookingSales/index.js +1871 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/dist/solution/UnifiedBookingSales/types.js +11 -0
- package/dist/solution/VenueBooking/index.d.ts +34 -20
- package/dist/solution/VenueBooking/index.js +630 -505
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +9 -3
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -1
- package/dist/types/index.d.ts +11 -1
- package/dist/utils/task.js +15 -18
- package/dist/utils/watch.js +0 -1
- package/lib/apis/picoding.js +2 -0
- package/lib/core/index.js +130 -131
- package/lib/effects/index.js +46 -57
- package/lib/index.js +92 -53
- package/lib/model/index.js +14 -21
- package/lib/model/strategy/adapter/dataVariant/adapter.js +38 -50
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +162 -236
- package/lib/model/strategy/adapter/dataVariant/examples.js +229 -237
- package/lib/model/strategy/adapter/dataVariant/index.js +39 -34
- package/lib/model/strategy/adapter/dataVariant/type.js +57 -28
- package/lib/model/strategy/adapter/index.js +100 -64
- package/lib/model/strategy/adapter/itemRule/adapter.js +156 -144
- package/lib/model/strategy/adapter/itemRule/evaluator.js +36 -48
- package/lib/model/strategy/adapter/itemRule/examples.js +295 -225
- package/lib/model/strategy/adapter/itemRule/index.js +83 -57
- package/lib/model/strategy/adapter/itemRule/type.js +97 -36
- package/lib/model/strategy/adapter/promotion/adapter.js +84 -63
- package/lib/model/strategy/adapter/promotion/evaluator.js +383 -232
- package/lib/model/strategy/adapter/promotion/examples.js +139 -159
- package/lib/model/strategy/adapter/promotion/index.js +1 -49
- package/lib/model/strategy/adapter/promotion/type.js +199 -35
- package/lib/model/strategy/adapter/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -152
- package/lib/model/strategy/adapter/walletPass/example.js +217 -190
- package/lib/model/strategy/adapter/walletPass/index.js +75 -51
- package/lib/model/strategy/adapter/walletPass/locales.js +36 -58
- package/lib/model/strategy/adapter/walletPass/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/utils.js +654 -402
- package/lib/model/strategy/engine.js +270 -168
- package/lib/model/strategy/index.js +49 -34
- package/lib/model/strategy/strategy-example.js +243 -239
- package/lib/model/strategy/type.js +100 -40
- package/lib/modules/Account/index.js +39 -53
- package/lib/modules/Account/types.js +20 -33
- package/lib/modules/AccountList/index.js +116 -154
- package/lib/modules/AccountList/types.js +30 -31
- package/lib/modules/AccountList/utils.js +18 -30
- package/lib/modules/BaseModule.d.ts +2 -2
- package/lib/modules/BaseModule.js +26 -49
- package/lib/modules/BookingContext/index.d.ts +48 -0
- package/lib/modules/BookingContext/index.js +390 -0
- package/lib/modules/BookingContext/types.d.ts +102 -0
- package/lib/modules/BookingContext/types.js +48 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +286 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +148 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +242 -0
- package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/lib/modules/BookingContext/utils/flexible.js +63 -0
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/lib/modules/BookingContext/utils/formatResourceList.js +35 -0
- package/lib/modules/BookingContext/utils/index.d.ts +11 -0
- package/lib/modules/BookingContext/utils/index.js +126 -0
- package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/lib/modules/BookingContext/utils/noResource.js +78 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +29 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/lib/modules/BookingContext/utils/productExtend.js +330 -0
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/lib/modules/BookingContext/utils/resourceSelection.js +24 -0
- package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
- package/lib/modules/BookingContext/utils/resources.js +419 -0
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/lib/modules/BookingContext/utils/serviceTimes.js +161 -0
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/lib/modules/BookingContext/utils/timeSlices.js +114 -0
- package/lib/modules/Cart/index.js +170 -124
- package/lib/modules/Cart/types.js +46 -51
- package/lib/modules/Cart/utils/cartAccount.js +40 -39
- package/lib/modules/Cart/utils/cartDate.js +56 -61
- package/lib/modules/Cart/utils/cartDiscount.js +28 -33
- package/lib/modules/Cart/utils/cartNote.js +27 -32
- package/lib/modules/Cart/utils/cartProduct.js +331 -244
- package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
- package/lib/modules/Cart/utils/cartResource.js +72 -78
- package/lib/modules/Cart/utils/changePrice.js +37 -67
- package/lib/modules/Cart/utils/index.js +106 -48
- package/lib/modules/Customer/constants.js +13 -34
- package/lib/modules/Customer/index.d.ts +20 -0
- package/lib/modules/Customer/index.js +270 -154
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Customer/types.js +38 -35
- package/lib/modules/Date/index.js +116 -115
- package/lib/modules/Date/types.js +16 -28
- package/lib/modules/Date/utils.js +174 -123
- package/lib/modules/Discount/index.d.ts +2 -1
- package/lib/modules/Discount/index.js +133 -113
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Discount/types.js +9 -31
- package/lib/modules/Guests/index.js +30 -56
- package/lib/modules/Guests/types.js +23 -33
- package/lib/modules/Holder/index.js +209 -189
- package/lib/modules/Holder/types.js +4 -16
- package/lib/modules/Holder/utils.js +20 -49
- package/lib/modules/OpenData/index.d.ts +8 -0
- package/lib/modules/OpenData/index.js +81 -74
- package/lib/modules/OpenData/types.js +4 -16
- package/lib/modules/OpenData/utils.js +44 -78
- package/lib/modules/Order/index.d.ts +449 -24
- package/lib/modules/Order/index.js +3834 -489
- package/lib/modules/Order/types.d.ts +693 -88
- package/lib/modules/Order/types.js +78 -33
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/lib/modules/Order/utils/bundleDiscountHydration.js +106 -0
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/lib/modules/Order/utils/manualProductDiscount.js +207 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +353 -0
- package/lib/modules/Order/utils.d.ts +167 -18
- package/lib/modules/Order/utils.js +1247 -345
- package/lib/modules/Payment/cash.js +20 -33
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +145 -76
- package/lib/modules/Payment/eftpos.js +16 -30
- package/lib/modules/Payment/index.d.ts +10 -9
- package/lib/modules/Payment/index.js +542 -502
- package/lib/modules/Payment/mx51.js +1 -0
- package/lib/modules/Payment/types.d.ts +40 -16
- package/lib/modules/Payment/types.js +216 -107
- package/lib/modules/Payment/utils.d.ts +1 -1
- package/lib/modules/Payment/utils.js +53 -49
- package/lib/modules/Payment/walletpass.js +231 -203
- package/lib/modules/Product/index.js +51 -46
- package/lib/modules/Product/types.d.ts +29 -7
- package/lib/modules/Product/types.js +4 -16
- package/lib/modules/Product/utils.js +32 -33
- package/lib/modules/ProductList/index.d.ts +17 -13
- package/lib/modules/ProductList/index.js +160 -118
- package/lib/modules/ProductList/types.d.ts +17 -0
- package/lib/modules/ProductList/types.js +9 -31
- package/lib/modules/Quotation/index.d.ts +22 -2
- package/lib/modules/Quotation/index.js +123 -89
- package/lib/modules/Quotation/types.d.ts +19 -0
- package/lib/modules/Quotation/types.js +4 -16
- package/lib/modules/Resource/index.js +27 -59
- package/lib/modules/Resource/types.js +22 -32
- package/lib/modules/Resource/utils.js +30 -38
- package/lib/modules/ResourcePlanner/index.d.ts +24 -0
- package/lib/modules/ResourcePlanner/index.js +147 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
- package/lib/modules/ResourcePlanner/planner.js +895 -0
- package/lib/modules/ResourcePlanner/types.d.ts +227 -0
- package/lib/modules/ResourcePlanner/types.js +5 -0
- package/lib/modules/Rules/index.d.ts +8 -10
- package/lib/modules/Rules/index.js +1286 -894
- package/lib/modules/Rules/types.d.ts +14 -3
- package/lib/modules/Rules/types.js +17 -40
- package/lib/modules/SalesSummary/index.d.ts +23 -26
- package/lib/modules/SalesSummary/index.js +130 -71
- package/lib/modules/SalesSummary/types.d.ts +9 -1
- package/lib/modules/SalesSummary/types.js +4 -16
- package/lib/modules/SalesSummary/utils.d.ts +3 -22
- package/lib/modules/SalesSummary/utils.js +738 -250
- package/lib/modules/ScanOrderLogger/index.js +59 -79
- package/lib/modules/ScanOrderLogger/providers/feishu.js +54 -78
- package/lib/modules/ScanOrderLogger/providers/grafana.js +13 -36
- package/lib/modules/ScanOrderLogger/types.js +4 -16
- package/lib/modules/Schedule/getDateIsInSchedule.js +345 -171
- package/lib/modules/Schedule/index.d.ts +18 -5
- package/lib/modules/Schedule/index.js +139 -114
- package/lib/modules/Schedule/type.js +4 -16
- package/lib/modules/Schedule/types.d.ts +2 -0
- package/lib/modules/Schedule/types.js +4 -16
- package/lib/modules/Schedule/utils.js +433 -291
- package/lib/modules/Step/index.js +40 -52
- package/lib/modules/Step/tyeps.js +4 -16
- package/lib/modules/Summary/index.js +66 -70
- package/lib/modules/Summary/types.js +4 -16
- package/lib/modules/Summary/utils.js +782 -429
- package/lib/modules/SurchargeList/index.d.ts +18 -0
- package/lib/modules/SurchargeList/index.js +95 -0
- package/lib/modules/SurchargeList/types.d.ts +15 -0
- package/lib/modules/SurchargeList/types.js +5 -0
- package/lib/modules/index.d.ts +3 -0
- package/lib/modules/index.js +245 -57
- package/lib/plugins/app.d.ts +2 -0
- package/lib/plugins/app.js +4 -16
- package/lib/plugins/index.js +36 -25
- package/lib/plugins/request.d.ts +1 -0
- package/lib/plugins/request.js +137 -126
- package/lib/plugins/shopStore.js +4 -16
- package/lib/plugins/user.js +4 -16
- package/lib/plugins/window.js +171 -179
- package/lib/server/index.d.ts +462 -8
- package/lib/server/index.js +4668 -713
- package/lib/server/modules/floor-plan/index.d.ts +39 -0
- package/lib/server/modules/floor-plan/index.js +306 -0
- package/lib/server/modules/floor-plan/types.d.ts +43 -0
- package/lib/server/modules/floor-plan/types.js +19 -0
- package/lib/server/modules/index.d.ts +7 -2
- package/lib/server/modules/index.js +106 -59
- package/lib/server/modules/menu/index.js +146 -122
- package/lib/server/modules/menu/types.js +18 -31
- package/lib/server/modules/order/index.d.ts +207 -14
- package/lib/server/modules/order/index.js +1463 -316
- package/lib/server/modules/order/types.d.ts +76 -5
- package/lib/server/modules/order/types.js +117 -32
- package/lib/server/modules/order/utils/filterBookings.d.ts +7 -1
- package/lib/server/modules/order/utils/filterBookings.js +288 -146
- package/lib/server/modules/order/utils/filterOrders.js +318 -64
- package/lib/server/modules/payment/index.d.ts +28 -0
- package/lib/server/modules/payment/index.js +168 -0
- package/lib/server/modules/payment/types.d.ts +9 -0
- package/lib/server/modules/payment/types.js +5 -0
- package/lib/server/modules/products/index.d.ts +105 -14
- package/lib/server/modules/products/index.js +969 -383
- package/lib/server/modules/products/types.d.ts +34 -1
- package/lib/server/modules/products/types.js +44 -34
- package/lib/server/modules/quotation/index.d.ts +39 -0
- package/lib/server/modules/quotation/index.js +220 -77
- package/lib/server/modules/quotation/types.js +21 -31
- package/lib/server/modules/resource/index.d.ts +2 -3
- package/lib/server/modules/resource/index.js +269 -214
- package/lib/server/modules/resource/types.js +42 -33
- package/lib/server/modules/schedule/index.d.ts +6 -4
- package/lib/server/modules/schedule/index.js +158 -132
- package/lib/server/modules/schedule/types.js +14 -21
- package/lib/server/modules/schedule/utils.js +334 -163
- package/lib/server/test.json +713 -0
- package/lib/server/types.d.ts +2 -0
- package/lib/server/types.js +4 -16
- package/lib/server/utils/index.js +25 -23
- package/lib/server/utils/product.js +197 -140
- package/lib/server/utils/schedule.js +34 -41
- package/lib/server/utils/small-ticket.d.ts +71 -0
- package/lib/server/utils/small-ticket.js +926 -0
- package/lib/server/utils/time.js +40 -49
- package/lib/solution/BaseSales/index.d.ts +378 -0
- package/lib/solution/BaseSales/index.js +2367 -0
- package/lib/solution/BaseSales/types.d.ts +394 -0
- package/lib/solution/BaseSales/types.js +47 -0
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
- package/lib/solution/BaseSales/utils/cartPromotion.js +1155 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +144 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +140 -0
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +18 -0
- package/lib/solution/BaseSales/utils/quotationPrice.js +231 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +63 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +215 -0
- package/lib/solution/BaseSales/utils.d.ts +40 -0
- package/lib/solution/BaseSales/utils.js +259 -0
- package/lib/solution/BookingByStep/index.js +1530 -1343
- package/lib/solution/BookingByStep/types.js +40 -99
- package/lib/solution/BookingByStep/utils/capacity.js +192 -160
- package/lib/solution/BookingByStep/utils/products.js +42 -52
- package/lib/solution/BookingByStep/utils/resources.js +527 -330
- package/lib/solution/BookingByStep/utils/stock.js +65 -44
- package/lib/solution/BookingByStep/utils/timeslots.js +129 -131
- package/lib/solution/BookingTicket/index.d.ts +393 -24
- package/lib/solution/BookingTicket/index.js +1459 -160
- package/lib/solution/BookingTicket/types.d.ts +191 -6
- package/lib/solution/BookingTicket/types.js +101 -66
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +353 -0
- package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +94 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.js +136 -0
- package/lib/solution/BookingTicket/utils/cartView.d.ts +29 -0
- package/lib/solution/BookingTicket/utils/cartView.js +200 -0
- package/lib/solution/BookingTicket/utils/exampleData.d.ts +123 -0
- package/lib/solution/BookingTicket/utils/exampleData.js +185 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +35 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +387 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +220 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +85 -80
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +64 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +84 -80
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +103 -95
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +115 -0
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +83 -0
- package/lib/solution/BuyTickets/index.js +67 -70
- package/lib/solution/BuyTickets/types.js +22 -38
- package/lib/solution/Checkout/index.d.ts +1 -0
- package/lib/solution/Checkout/index.js +1461 -1169
- package/lib/solution/Checkout/types.js +91 -61
- package/lib/solution/Checkout/utils/index.js +228 -159
- package/lib/solution/PlaceOrder/index.js +55 -0
- package/lib/solution/RegisterAndLogin/config.js +495 -470
- package/lib/solution/RegisterAndLogin/index.js +633 -630
- package/lib/solution/RegisterAndLogin/types.js +189 -76
- package/lib/solution/RegisterAndLogin/utils.js +183 -125
- package/lib/solution/Sales/index.d.ts +50 -5
- package/lib/solution/Sales/index.js +495 -220
- package/lib/solution/Sales/types.d.ts +26 -2
- package/lib/solution/Sales/types.js +27 -33
- package/lib/solution/ScanOrder/index.d.ts +27 -21
- package/lib/solution/ScanOrder/index.js +908 -904
- package/lib/solution/ScanOrder/types.d.ts +33 -11
- package/lib/solution/ScanOrder/types.js +33 -34
- package/lib/solution/ScanOrder/utils.d.ts +4 -1
- package/lib/solution/ScanOrder/utils.js +457 -344
- package/lib/solution/ShopDiscount/index.js +230 -236
- package/lib/solution/ShopDiscount/types.js +15 -37
- package/lib/solution/ShopDiscount/utils.js +309 -172
- package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/lib/solution/UnifiedBookingSales/index.js +1050 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/lib/solution/UnifiedBookingSales/types.js +14 -0
- package/lib/solution/VenueBooking/index.d.ts +34 -20
- package/lib/solution/VenueBooking/index.js +982 -950
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/lib/solution/VenueBooking/types.js +20 -40
- package/lib/solution/VenueBooking/utils/dateSummary.js +22 -54
- package/lib/solution/VenueBooking/utils/resource.js +31 -54
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +96 -108
- package/lib/solution/VenueBooking/utils/smartPricing.js +112 -100
- package/lib/solution/VenueBooking/utils/timeSlot.js +133 -132
- package/lib/solution/VenueBooking/utils.js +130 -67
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +124 -37
- package/lib/store/createStore.js +32 -29
- package/lib/types/index.d.ts +11 -1
- package/lib/types/index.js +4 -16
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +81 -47
- package/package.json +2 -1
- package/dist/solution/Checkout/appointmentDemo.json +0 -1
- package/lib/solution/Checkout/appointmentDemo.json +0 -1
|
@@ -1,141 +1,689 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
BookingTicketImpl: true,
|
|
8
|
+
BookingTicket: true
|
|
18
9
|
};
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
__export(BookingTicket_exports, {
|
|
33
|
-
BookingTicket: () => BookingTicketImpl,
|
|
34
|
-
BookingTicketImpl: () => BookingTicketImpl
|
|
10
|
+
exports.BookingTicketImpl = exports.BookingTicket = void 0;
|
|
11
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
12
|
+
var _types = require("./types");
|
|
13
|
+
Object.keys(_types).forEach(function (key) {
|
|
14
|
+
if (key === "default" || key === "__esModule") return;
|
|
15
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
16
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
17
|
+
Object.defineProperty(exports, key, {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () {
|
|
20
|
+
return _types[key];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
35
23
|
});
|
|
36
|
-
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
var
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
24
|
+
var _BookingContext = require("../../modules/BookingContext");
|
|
25
|
+
var _BaseSales = require("../BaseSales");
|
|
26
|
+
var _scan = _interopRequireDefault(require("./utils/scan"));
|
|
27
|
+
var _orderCustomer = require("./utils/orderCustomer");
|
|
28
|
+
var _handleScan = require("./utils/scan/handleScan");
|
|
29
|
+
var _scanCache = _interopRequireDefault(require("./utils/scan/scanCache"));
|
|
30
|
+
var _formatGlobalScan = require("./utils/scan/formatGlobalScan");
|
|
31
|
+
var _applyGlobalScan = require("./utils/scan/applyGlobalScan");
|
|
32
|
+
var _cartView = require("./utils/cartView");
|
|
33
|
+
var _addProductDecision = require("./utils/addProductDecision");
|
|
34
|
+
var _buildCacheItemFromOrderLine = require("../../modules/BookingContext/utils/buildCacheItemFromOrderLine");
|
|
35
|
+
var _sessionCatalogStale = require("./utils/sessionCatalogStale");
|
|
36
|
+
var _buildNormalProductCacheItemFromOrderLine = require("../../modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine");
|
|
37
|
+
var _orderLineDisplay = require("../../modules/BookingContext/utils/orderLineDisplay");
|
|
38
|
+
var _bookingStatus = require("./utils/bookingStatus");
|
|
39
|
+
var _resolveBestAddTimePlan = require("./utils/resolveBestAddTimePlan");
|
|
40
|
+
var _utils = require("../../modules/Order/utils");
|
|
41
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
42
|
+
const OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow'];
|
|
43
|
+
const OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 读取已有 booking 的协议唯一值,用于加时商品行绑定原预约。
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* const bookingUid = resolveBookingUidForAddTime(booking);
|
|
50
|
+
*/
|
|
51
|
+
function resolveBookingUidForAddTime(booking) {
|
|
52
|
+
const uid = booking?.metadata?.unique_identification_number;
|
|
53
|
+
return uid === undefined || uid === null ? '' : String(uid);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 规范化加车数量,避免非法值进入 OrderModule。
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* const quantity = normalizeAddTimeQuantity(product.num);
|
|
61
|
+
*/
|
|
62
|
+
function normalizeAddTimeQuantity(value) {
|
|
63
|
+
const parsed = Math.floor(Number(value));
|
|
64
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : 1;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 解析加时时长,优先使用显式入参,其次回退商品字段。
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* const minutes = resolveAddTimeScheduleMinutes(input.product_add_schedule_time, product);
|
|
72
|
+
*/
|
|
73
|
+
function resolveAddTimeScheduleMinutes(explicitValue, product) {
|
|
74
|
+
const raw = explicitValue ?? product?.product_add_schedule_time;
|
|
75
|
+
if (raw === undefined || raw === null || raw === '') return undefined;
|
|
76
|
+
const parsed = Number(raw);
|
|
77
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 计算加时商品行价格字段,保持 `price` 与 `selling_price` 输入口径一致。
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* const price = resolveAddTimeProductPrice(input.price, product);
|
|
85
|
+
*/
|
|
86
|
+
function resolveAddTimeProductPrice(explicitValue, product) {
|
|
87
|
+
return explicitValue ?? product?.price ?? product?.selling_price ?? product?.base_price;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 规范化加时覆盖分钟数。
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* const minutes = normalizeCoveredMinutes(input.coveredMinutes);
|
|
95
|
+
*/
|
|
96
|
+
function normalizeCoveredMinutes(value) {
|
|
97
|
+
const parsed = Math.ceil(Number(value));
|
|
98
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 计算 booking 加时后的结束时间与时长。
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* const updates = buildAddTimeBookingTimePatch(booking, 30);
|
|
106
|
+
*/
|
|
107
|
+
function buildAddTimeBookingTimePatch(booking, coveredMinutes) {
|
|
108
|
+
if (coveredMinutes <= 0) return null;
|
|
109
|
+
const endDate = booking?.end_date;
|
|
110
|
+
const endTime = booking?.end_time;
|
|
111
|
+
if (!endDate || !endTime) {
|
|
112
|
+
throw new Error('[BookingTicket] addAddTimeProductsToBooking: booking.end_date/end_time 缺失');
|
|
113
|
+
}
|
|
114
|
+
const currentEnd = (0, _dayjs.default)(`${endDate} ${endTime}`);
|
|
115
|
+
if (!currentEnd.isValid()) {
|
|
116
|
+
throw new Error('[BookingTicket] addAddTimeProductsToBooking: booking.end_date/end_time 无效');
|
|
117
|
+
}
|
|
118
|
+
const nextEnd = currentEnd.add(coveredMinutes, 'minute');
|
|
119
|
+
const currentDuration = Number(booking?.duration);
|
|
120
|
+
let duration = Number.isFinite(currentDuration) ? currentDuration + coveredMinutes : coveredMinutes;
|
|
121
|
+
if (booking?.start_date && booking?.start_time) {
|
|
122
|
+
const start = (0, _dayjs.default)(`${booking.start_date} ${booking.start_time}`);
|
|
123
|
+
if (start.isValid()) {
|
|
124
|
+
const diffMinutes = nextEnd.diff(start, 'minute');
|
|
125
|
+
duration = diffMinutes > 0 ? diffMinutes : duration;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
end_date: nextEnd.format('YYYY-MM-DD'),
|
|
130
|
+
end_time: nextEnd.format('HH:mm'),
|
|
131
|
+
duration
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function withProductOptionString(cacheItem) {
|
|
135
|
+
const productOptionString = (0, _orderLineDisplay.buildProductOptionStringFromOrderLine)(cacheItem);
|
|
136
|
+
if (!productOptionString) return cacheItem;
|
|
137
|
+
return {
|
|
138
|
+
...cacheItem,
|
|
139
|
+
product_option_string: cacheItem?.product_option_string || productOptionString,
|
|
140
|
+
_extend: {
|
|
141
|
+
...(cacheItem?._extend || {}),
|
|
142
|
+
product_option_string: cacheItem?._extend?.product_option_string || productOptionString
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
147
|
+
defaultName = 'bookingTicket';
|
|
148
|
+
defaultVersion = '1.0.0';
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 子类覆盖 store 类型为 BookingTicket 子模块清单(在父类基础上追加 customer)。
|
|
152
|
+
* 父类按 `getRegisteredModuleNames` 注入成员到该 store。
|
|
153
|
+
*/
|
|
154
|
+
store = {};
|
|
155
|
+
platform;
|
|
156
|
+
scan;
|
|
157
|
+
productCatalog = [];
|
|
158
|
+
addTimeProductsCatalog = [];
|
|
159
|
+
orderCustomerDiscountRefreshInFlight = null;
|
|
160
|
+
orderCustomerDiscountRefreshCustomerId = null;
|
|
161
|
+
loadOpenDataConfigInFlight = null;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer + bookingContext。
|
|
165
|
+
* bookingContext 是 SalesSdk 加车下沉所需的「预约 UI 上下文」(bookingConfig / resourcesOrigin / date)。
|
|
166
|
+
*/
|
|
167
|
+
getRegisteredModuleNames() {
|
|
168
|
+
return [...super.getRegisteredModuleNames(), 'customer', 'bookingContext', 'openData'];
|
|
169
|
+
}
|
|
170
|
+
getSubmitOrderSalesChannel() {
|
|
171
|
+
const channel = this.core?.context?.getChannel?.();
|
|
172
|
+
return !channel || channel === 'system' ? 'pos' : channel;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* 业务侧子模块工厂:BookingTicket 自带的 createBookingTicketModule 优先匹配;
|
|
177
|
+
* 未识别的模块名(如 BookingByStep 公共类型)回退到父类工厂。
|
|
178
|
+
*/
|
|
179
|
+
createSubModule(moduleName) {
|
|
180
|
+
const localModule = (0, _types.createBookingTicketModule)(moduleName, this.name);
|
|
181
|
+
if (localModule) return localModule;
|
|
182
|
+
return super.createSubModule(moduleName);
|
|
183
|
+
}
|
|
184
|
+
async initialize(core, options = {}) {
|
|
185
|
+
this.scan = new _scan.default(this, `BOOKING_TICKET_SCAN:${this.name}`);
|
|
186
|
+
await super.initialize(core, options);
|
|
60
187
|
if (!this.request) {
|
|
61
|
-
throw new Error(
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
188
|
+
throw new Error('bookingTicket解决方案需要 request 插件支持');
|
|
189
|
+
}
|
|
190
|
+
this.platform = this.otherParams?.platform;
|
|
191
|
+
await this.configureIdGeneratorFromOpenData();
|
|
192
|
+
}
|
|
193
|
+
getBookingTicketBusinessCode() {
|
|
194
|
+
const businessCode = this.otherParams?.businessCode ?? this.otherParams?.business_code;
|
|
195
|
+
if (businessCode === undefined || businessCode === null) return null;
|
|
196
|
+
const normalized = String(businessCode).trim();
|
|
197
|
+
return normalized || null;
|
|
198
|
+
}
|
|
199
|
+
getIdGeneratorPlugin() {
|
|
200
|
+
const appPlugin = this.core.getPlugin('app');
|
|
201
|
+
const app = appPlugin?.getApp?.();
|
|
202
|
+
return app?.getPlugin?.('idGenerator') || null;
|
|
203
|
+
}
|
|
204
|
+
async loadOpenDataConfig() {
|
|
205
|
+
if (!this.store.openData) throw new Error('openData 模块未初始化');
|
|
206
|
+
const businessCode = this.getBookingTicketBusinessCode();
|
|
207
|
+
if (!businessCode) {
|
|
208
|
+
console.warn('[BookingTicket] businessCode 缺失,跳过 OpenData 配置加载,当前 module name: ', this.name);
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
const lastFetchedAt = this.store.openData.getLastFetchedAt();
|
|
212
|
+
const cachedData = this.store.openData.getOpenData();
|
|
213
|
+
if (cachedData && lastFetchedAt && Date.now() - lastFetchedAt < OPEN_DATA_CACHE_TTL) {
|
|
214
|
+
this.otherParams.openData = cachedData;
|
|
215
|
+
return cachedData;
|
|
216
|
+
}
|
|
217
|
+
if (this.loadOpenDataConfigInFlight) return await this.loadOpenDataConfigInFlight;
|
|
218
|
+
const channel = this.getSubmitOrderSalesChannel();
|
|
219
|
+
this.loadOpenDataConfigInFlight = this.store.openData.fetchOpenData({
|
|
220
|
+
scope: 'board',
|
|
221
|
+
target: `${businessCode}+${channel}`,
|
|
222
|
+
// target: `dine_in+pos`,
|
|
223
|
+
section_code: [...OPEN_DATA_SECTION_CODES]
|
|
224
|
+
});
|
|
225
|
+
try {
|
|
226
|
+
const openDataConfig = await this.loadOpenDataConfigInFlight;
|
|
227
|
+
this.otherParams.openData = openDataConfig;
|
|
228
|
+
return openDataConfig;
|
|
229
|
+
} finally {
|
|
230
|
+
this.loadOpenDataConfigInFlight = null;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
async getOpenData() {
|
|
234
|
+
return this.store.openData?.getOpenData();
|
|
235
|
+
}
|
|
236
|
+
async getShortNumberOrDeviceId() {
|
|
237
|
+
const getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
|
|
238
|
+
if (getAsyncIotDeviceInfo) {
|
|
239
|
+
const res = await getAsyncIotDeviceInfo?.();
|
|
240
|
+
if (res?.short_number) {
|
|
241
|
+
return res?.short_number;
|
|
75
242
|
}
|
|
76
243
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
244
|
+
return String(this.getAppData('device_id') || 0).slice(-2);
|
|
245
|
+
}
|
|
246
|
+
async configureIdGeneratorFromOpenData() {
|
|
247
|
+
let openDataConfig = null;
|
|
248
|
+
try {
|
|
249
|
+
openDataConfig = await this.loadOpenDataConfig();
|
|
250
|
+
} catch (error) {
|
|
251
|
+
console.warn('[BookingTicket] OpenData 配置加载失败,跳过 idGenerator 配置', error);
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// if (!openDataConfig) return;
|
|
256
|
+
|
|
257
|
+
const idGenerator = this.getIdGeneratorPlugin();
|
|
258
|
+
if (!idGenerator?.configure) {
|
|
259
|
+
console.warn('[BookingTicket] idGenerator 插件不可用,跳过配置');
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const receiptSequenceLength = this.normalizePositiveInteger(openDataConfig?.['sale.short_number_digits'], 5);
|
|
263
|
+
const receiptSequenceStart = this.normalizePositiveInteger(openDataConfig?.['sale.short_number_start_number'], 1);
|
|
264
|
+
const prefix = this.normalizeIdPrefix(openDataConfig?.['sale.short_number_prefix'], '');
|
|
265
|
+
const shopOrderPrefix = this.normalizeIdPrefix(openDataConfig?.['sale.sale_number_prefix'], '');
|
|
266
|
+
const resetReceiptSequenceDaily = typeof openDataConfig?.['sale.short_number_daily_reset'] === 'boolean' ? openDataConfig?.['sale.short_number_daily_reset'] : false;
|
|
267
|
+
const operatingDayBoundary = this.getAppData('operating_day_boundary');
|
|
268
|
+
const deviceId = await this.getShortNumberOrDeviceId();
|
|
269
|
+
const businessCode = this.getBookingTicketBusinessCode();
|
|
270
|
+
if (!businessCode) {
|
|
271
|
+
console.warn('[BookingTicket] businessCode 缺失,跳过 idGenerator 配置');
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
try {
|
|
275
|
+
await idGenerator.configure({
|
|
276
|
+
biz: businessCode,
|
|
277
|
+
config: {
|
|
278
|
+
prefix,
|
|
279
|
+
deviceCode: deviceId,
|
|
280
|
+
// TODO 现在 picoding 没这个配置的 key
|
|
281
|
+
padReceiptSequence: false,
|
|
282
|
+
receiptSequenceLength,
|
|
283
|
+
resetReceiptSequenceDaily,
|
|
284
|
+
receiptSequenceResetTime: operatingDayBoundary.time,
|
|
285
|
+
receiptSequenceStart,
|
|
286
|
+
shopOrderPrefix
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
} catch (error) {
|
|
290
|
+
console.warn('[BookingTicket] idGenerator 配置失败', error);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
normalizePositiveInteger(value, fallback) {
|
|
294
|
+
const numeric = Number(value);
|
|
295
|
+
if (!Number.isInteger(numeric) || numeric <= 0) return fallback;
|
|
296
|
+
return numeric;
|
|
297
|
+
}
|
|
298
|
+
normalizeIdPrefix(value, fallback) {
|
|
299
|
+
if (value === undefined || value === null) return fallback;
|
|
300
|
+
const normalized = String(value).trim().toUpperCase();
|
|
301
|
+
return normalized || fallback;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* 加载销售详情,并在父类基础上把 customer 信息装配到 CustomerModule。
|
|
306
|
+
*
|
|
307
|
+
* 业务上 ticketBooking 进入「编辑/查看」时需要 active customer 状态,因此从
|
|
308
|
+
* sales.customer / sales.header / tempOrder 顶层字段中拼装 ICustomer 后调 setSelectedCustomer,
|
|
309
|
+
* 让现有 setActiveCustomer / getActiveCustomer 调用方零成本拿到详情态客户。
|
|
310
|
+
*/
|
|
311
|
+
async loadSalesDetail(orderIdOrParams) {
|
|
312
|
+
const sales = await super.loadSalesDetail(orderIdOrParams);
|
|
313
|
+
const customerModule = this.store.customer;
|
|
314
|
+
const detailCustomer = sales?.customer;
|
|
315
|
+
const orderCustomerSnapshot = this.store.order.getOrderCustomerSnapshot();
|
|
316
|
+
const protocolCustomerId = sales?.customer_id;
|
|
317
|
+
const protocolCustomer = protocolCustomerId !== undefined && protocolCustomerId !== null ? {
|
|
318
|
+
id: protocolCustomerId,
|
|
319
|
+
name: String(sales?.customer_name || ''),
|
|
320
|
+
phone: sales?.phone,
|
|
321
|
+
email: sales?.email,
|
|
322
|
+
country_calling_code: sales?.country_calling_code
|
|
323
|
+
} : null;
|
|
324
|
+
const selectedCustomer = detailCustomer ?? orderCustomerSnapshot ?? protocolCustomer;
|
|
325
|
+
if (customerModule && selectedCustomer) {
|
|
326
|
+
const {
|
|
327
|
+
id: detailCustomerId,
|
|
328
|
+
...detailCustomerRest
|
|
329
|
+
} = selectedCustomer ?? {};
|
|
330
|
+
const rawId = detailCustomerId ?? '';
|
|
331
|
+
const customer = {
|
|
332
|
+
...detailCustomerRest,
|
|
333
|
+
id: rawId == null ? '' : rawId,
|
|
334
|
+
name: selectedCustomer?.name ?? '',
|
|
335
|
+
phone: selectedCustomer?.phone,
|
|
336
|
+
email: selectedCustomer?.email,
|
|
337
|
+
country_calling_code: selectedCustomer?.country_calling_code
|
|
338
|
+
};
|
|
339
|
+
customerModule.setSelectedCustomer(customer);
|
|
340
|
+
this.setOrderCustomer(customer);
|
|
341
|
+
// await this.store.order.saveDraft();
|
|
342
|
+
}
|
|
343
|
+
return sales;
|
|
344
|
+
}
|
|
345
|
+
async scanPromotionCode(code, customerId) {
|
|
346
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
347
|
+
const raw = await this.store.order.scanCode(code, customerId);
|
|
348
|
+
const scannedList = raw.scannedDiscountList || [];
|
|
349
|
+
const extractedCustomerId = this.getDiscountCustomerId(scannedList);
|
|
350
|
+
const hasOrderCustomer = Boolean(this.store.order.getOrderCustomer());
|
|
351
|
+
|
|
352
|
+
// 缺 Holder 等场景 isAvailable=false,但仍需把 Pass 归属客户带入订单,供 Holder 弹窗使用。
|
|
353
|
+
if (!hasOrderCustomer && extractedCustomerId) {
|
|
354
|
+
await this.hydrateOrderCustomerFromScanDiscounts(scannedList);
|
|
355
|
+
}
|
|
356
|
+
if (raw.isAvailable) {
|
|
357
|
+
await this.store.order.recalculateSummary({
|
|
358
|
+
createIfMissing: true
|
|
359
|
+
});
|
|
360
|
+
this.store.order.persistTempOrder();
|
|
361
|
+
const tempOrder = this.store.order.ensureTempOrder();
|
|
362
|
+
await this.effectsEmit('onDiscountApplied', {
|
|
363
|
+
productList: tempOrder.products || [],
|
|
364
|
+
discountList: this.store.order.getDiscountList(),
|
|
365
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
366
|
+
tempOrder
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
return {
|
|
370
|
+
isAvailable: raw.isAvailable,
|
|
371
|
+
type: raw.type,
|
|
372
|
+
unavailableReason: raw.unavailableReason,
|
|
373
|
+
scannedDiscountList: raw.scannedDiscountList
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
async hydrateOrderCustomerFromScanDiscounts(discounts) {
|
|
377
|
+
const currentOrderCustomer = this.store.order.getOrderCustomer();
|
|
378
|
+
if (currentOrderCustomer) return;
|
|
379
|
+
const customerId = this.getDiscountCustomerId(discounts);
|
|
380
|
+
if (!customerId) return;
|
|
381
|
+
const customer = await this.resolveCustomerByDiscountCustomerId(customerId);
|
|
382
|
+
if (!customer) return;
|
|
383
|
+
this.store.customer.setSelectedCustomer(customer);
|
|
384
|
+
this.setOrderCustomer(customer);
|
|
385
|
+
}
|
|
386
|
+
getDiscountCustomerId(discounts) {
|
|
387
|
+
for (const item of discounts) {
|
|
388
|
+
const topLevelId = Number(item.customer_id);
|
|
389
|
+
if (Number.isFinite(topLevelId) && topLevelId > 0) {
|
|
390
|
+
return topLevelId;
|
|
100
391
|
}
|
|
392
|
+
}
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
async resolveCustomerByDiscountCustomerId(customerId) {
|
|
396
|
+
const localCustomers = this.store.customer.getCustomers();
|
|
397
|
+
const localCustomer = this.findCustomerById(localCustomers, customerId);
|
|
398
|
+
const normalizedLocalCustomer = localCustomer ? this.normalizeCustomer(localCustomer) : null;
|
|
399
|
+
if (normalizedLocalCustomer && this.hasUsableCustomerDetails(normalizedLocalCustomer)) {
|
|
400
|
+
return normalizedLocalCustomer;
|
|
401
|
+
}
|
|
402
|
+
const result = await this.store.customer.queryCustomerList({
|
|
403
|
+
ids: [customerId],
|
|
404
|
+
skip: 1,
|
|
405
|
+
num: 1
|
|
101
406
|
});
|
|
102
|
-
this.
|
|
407
|
+
const remoteCustomer = this.findCustomerById(result?.list || [], customerId) || result?.list?.[0] || null;
|
|
408
|
+
return remoteCustomer ? this.normalizeCustomer(remoteCustomer) : null;
|
|
409
|
+
}
|
|
410
|
+
findCustomerById(customers = [], customerId) {
|
|
411
|
+
return customers.find(customer => {
|
|
412
|
+
const rawId = this.getRawCustomerId(customer);
|
|
413
|
+
return rawId !== null && String(rawId) === String(customerId);
|
|
414
|
+
}) || null;
|
|
415
|
+
}
|
|
416
|
+
normalizeCustomer(customer) {
|
|
417
|
+
const raw = customer;
|
|
418
|
+
const rawId = this.getRawCustomerId(customer);
|
|
419
|
+
const name = customer.name || raw.display_name || raw.nickname || raw.customer_name || [raw.first_name, raw.last_name].filter(Boolean).join(' ') || '';
|
|
420
|
+
return {
|
|
421
|
+
...customer,
|
|
422
|
+
id: rawId ?? customer.id,
|
|
423
|
+
name,
|
|
424
|
+
phone: customer.phone ?? raw.phone ?? raw.mobile ?? '',
|
|
425
|
+
email: customer.email ?? raw.email ?? '',
|
|
426
|
+
country_calling_code: customer.country_calling_code ?? raw.country_calling_code ?? ''
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
getRawCustomerId(customer) {
|
|
430
|
+
const raw = customer;
|
|
431
|
+
return customer.id ?? raw.customer_id ?? raw.customerId ?? null;
|
|
103
432
|
}
|
|
433
|
+
hasUsableCustomerDetails(customer) {
|
|
434
|
+
return !!(customer.name || customer.phone || customer.email || customer.display_name || customer.customer_name);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* 更新当前预约的 appointment_status。
|
|
439
|
+
*
|
|
440
|
+
* 数据源:从 OrderModule.tempOrder 内部读取,调用方无需传 orderId / scheduleId。
|
|
441
|
+
* schedule id 解析优先级:
|
|
442
|
+
* 1. `tempOrder.metadata.appointment_booking_parent_schedule_id`
|
|
443
|
+
* 2. `tempOrder.bookings` 中 `parent_id === 0` 的 `schedule_event_id`
|
|
444
|
+
*
|
|
445
|
+
* 流程:先乐观更新本地 bookings 的 appointment_status,再调 PUT 接口,
|
|
446
|
+
* 接口成功后强制刷新销售详情;任一步失败都回滚本地状态并抛错。
|
|
447
|
+
*
|
|
448
|
+
* @param status 目标状态(如 'confirmed')
|
|
449
|
+
* @returns 接口返回的 data
|
|
450
|
+
*/
|
|
451
|
+
async setBookingStatus(status) {
|
|
452
|
+
const tempOrder = this.store.order?.getTempOrder?.();
|
|
453
|
+
if (!tempOrder) {
|
|
454
|
+
throw new Error('setBookingStatus: tempOrder 未加载');
|
|
455
|
+
}
|
|
456
|
+
const orderId = tempOrder.order_id;
|
|
457
|
+
if (orderId === undefined || orderId === null) {
|
|
458
|
+
throw new Error('setBookingStatus: tempOrder.order_id 缺失');
|
|
459
|
+
}
|
|
460
|
+
const scheduleId = (0, _bookingStatus.resolveScheduleId)(tempOrder);
|
|
461
|
+
if (scheduleId === null) {
|
|
462
|
+
throw new Error('setBookingStatus: 无法解析 schedule id(metadata 与 root booking 均缺失)');
|
|
463
|
+
}
|
|
464
|
+
const bookings = Array.isArray(tempOrder.bookings) ? tempOrder.bookings : [];
|
|
465
|
+
const previous = (0, _bookingStatus.applyBookingsStatus)(bookings, status);
|
|
466
|
+
try {
|
|
467
|
+
const res = await this.request.put(`/schedule/booking/appointment-status/${scheduleId}`, {
|
|
468
|
+
appointment_status: status
|
|
469
|
+
});
|
|
470
|
+
await this.refreshSalesDetail();
|
|
471
|
+
this.core.effects.emit(`${this.name}:onBookingStatusChange`, {
|
|
472
|
+
orderId,
|
|
473
|
+
status
|
|
474
|
+
});
|
|
475
|
+
return res?.data ?? res;
|
|
476
|
+
} catch (error) {
|
|
477
|
+
(0, _bookingStatus.restoreBookingsStatus)(bookings, previous);
|
|
478
|
+
throw error;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* 子预约状态机转移(POST /schedule/booking-transition/{schedule_event_id})。
|
|
484
|
+
*
|
|
485
|
+
* 与 `setBookingStatus`(父预约 PUT appointment-status)不同,本方法按子预约
|
|
486
|
+
* `schedule_event_id` 调用状态转移接口,body 为 `{ action }`。
|
|
487
|
+
*
|
|
488
|
+
* 流程:能解析出目标状态时先乐观更新对应子预约的 `appointment_status`,
|
|
489
|
+
* 再调 POST;成功后强制刷新销售详情;失败则回滚该子预约本地状态并抛错。
|
|
490
|
+
* `reschedule` 暂未启用状态矩阵,跳过乐观更新仅调接口。
|
|
491
|
+
*
|
|
492
|
+
* @param params.schedule_event_id 子预约 schedule_event_id
|
|
493
|
+
* @param params.action 转移动作:confirm | reject | arrive | start | complete | cancel | no_show | reschedule
|
|
494
|
+
* @returns 接口返回的 data
|
|
495
|
+
*
|
|
496
|
+
* @example
|
|
497
|
+
* await bookingTicket.transitionChildBooking({
|
|
498
|
+
* schedule_event_id: 301,
|
|
499
|
+
* action: 'confirm',
|
|
500
|
+
* });
|
|
501
|
+
*/
|
|
502
|
+
async transitionChildBooking(params) {
|
|
503
|
+
const {
|
|
504
|
+
schedule_event_id,
|
|
505
|
+
action
|
|
506
|
+
} = params;
|
|
507
|
+
if (schedule_event_id === undefined || schedule_event_id === null || schedule_event_id === '') {
|
|
508
|
+
throw new Error('transitionChildBooking: schedule_event_id 不能为空');
|
|
509
|
+
}
|
|
510
|
+
if (!action) {
|
|
511
|
+
throw new Error('transitionChildBooking: action 不能为空');
|
|
512
|
+
}
|
|
513
|
+
const tempOrder = this.store.order?.getTempOrder?.();
|
|
514
|
+
if (!tempOrder) {
|
|
515
|
+
throw new Error('transitionChildBooking: tempOrder 未加载');
|
|
516
|
+
}
|
|
517
|
+
const orderId = tempOrder.order_id;
|
|
518
|
+
if (orderId === undefined || orderId === null) {
|
|
519
|
+
throw new Error('transitionChildBooking: tempOrder.order_id 缺失');
|
|
520
|
+
}
|
|
521
|
+
const bookings = Array.isArray(tempOrder.bookings) ? tempOrder.bookings : [];
|
|
522
|
+
const targetStatus = (0, _bookingStatus.resolveStatusAfterTransition)(action);
|
|
523
|
+
const previous = targetStatus !== null ? (0, _bookingStatus.applyChildBookingStatus)(bookings, schedule_event_id, targetStatus) : undefined;
|
|
524
|
+
try {
|
|
525
|
+
const res = await this.request.post(`/schedule/booking-transition/${schedule_event_id}`, {
|
|
526
|
+
action
|
|
527
|
+
});
|
|
528
|
+
await this.refreshSalesDetail();
|
|
529
|
+
this.core.effects.emit(`${this.name}:onChildBookingStatusChange`, {
|
|
530
|
+
orderId,
|
|
531
|
+
schedule_event_id,
|
|
532
|
+
action,
|
|
533
|
+
status: targetStatus
|
|
534
|
+
});
|
|
535
|
+
return res?.data ?? res;
|
|
536
|
+
} catch (error) {
|
|
537
|
+
if (previous !== undefined) {
|
|
538
|
+
(0, _bookingStatus.restoreChildBookingStatus)(bookings, schedule_event_id, previous);
|
|
539
|
+
}
|
|
540
|
+
throw error;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* 基于当前 tempOrder.order_id 强制从远端重新拉取销售详情。
|
|
546
|
+
*
|
|
547
|
+
* 适用场景:在 BookingTicket 内执行了「修改服务端订单状态」的动作(如改预约状态、
|
|
548
|
+
* 改下单客户、改商品行等)后,统一刷新本地销售详情,保证 UI 与服务端一致。
|
|
549
|
+
*
|
|
550
|
+
* 约束:调用前必须已有 tempOrder 且 order_id 存在,否则视为非法调用并抛错。
|
|
551
|
+
*
|
|
552
|
+
* @returns loadSalesDetail 的返回值
|
|
553
|
+
*/
|
|
554
|
+
async refreshSalesDetail(params = {}) {
|
|
555
|
+
const tempOrder = this.store.order?.getTempOrder?.();
|
|
556
|
+
if (!tempOrder) {
|
|
557
|
+
throw new Error('refreshSalesDetail: tempOrder 未加载');
|
|
558
|
+
}
|
|
559
|
+
debugger;
|
|
560
|
+
const orderId = tempOrder.order_id || tempOrder.external_sale_number;
|
|
561
|
+
if (orderId === undefined || orderId === null) {
|
|
562
|
+
return {};
|
|
563
|
+
}
|
|
564
|
+
return this.loadSalesDetail({
|
|
565
|
+
orderId: orderId,
|
|
566
|
+
// merge: true
|
|
567
|
+
forceRemote: params.forceRemote
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
|
|
104
571
|
/**
|
|
105
572
|
* 获取商品列表
|
|
106
573
|
* @param params 包含 schedule_date 的参数
|
|
107
574
|
* @returns 商品列表
|
|
108
575
|
*/
|
|
109
576
|
async loadProducts(params = {}, options) {
|
|
110
|
-
const {
|
|
577
|
+
const {
|
|
578
|
+
schedule_date,
|
|
579
|
+
customer_id,
|
|
580
|
+
menu_list_ids,
|
|
581
|
+
schedule_datetime
|
|
582
|
+
} = params;
|
|
583
|
+
|
|
584
|
+
// 优先写入 schedule_datetime(含时分),供加购 presetStartTime 与 TimeBar 对齐;
|
|
585
|
+
// requiresDetail 弹窗仍通过 formatBookingDateForUI 只取日历日 YYYY-MM-DD。
|
|
586
|
+
const bookingDate = schedule_datetime || schedule_date || '';
|
|
587
|
+
if (bookingDate) {
|
|
588
|
+
this.setBookingDate(bookingDate);
|
|
589
|
+
}
|
|
111
590
|
try {
|
|
112
591
|
const result = await this.store.products.loadProducts({
|
|
113
|
-
with_count: [
|
|
592
|
+
with_count: ['bundleGroup', 'optionGroup'],
|
|
114
593
|
with_schedule: 1,
|
|
115
594
|
...params,
|
|
116
595
|
cacheId: this.cacheId
|
|
117
596
|
}, options);
|
|
597
|
+
this.productCatalog = Array.isArray(result) ? [...result] : [];
|
|
118
598
|
this.core.effects.emit(`${this.name}:onProductsLoaded`, result);
|
|
119
599
|
return result;
|
|
120
600
|
} catch (error) {
|
|
121
|
-
console.error(
|
|
601
|
+
console.error('Failed to load products:', error);
|
|
122
602
|
throw error;
|
|
123
603
|
}
|
|
124
604
|
}
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* 获取加时商品列表。
|
|
608
|
+
*
|
|
609
|
+
* @example
|
|
610
|
+
* const products = await bookingTicket.getAddTimeProducts({ schedule_date: '2026-06-16' });
|
|
611
|
+
*/
|
|
612
|
+
async getAddTimeProducts(params = {}) {
|
|
613
|
+
const result = await this.store.products.getAddTimeProducts({
|
|
614
|
+
...params,
|
|
615
|
+
cacheId: this.cacheId
|
|
616
|
+
});
|
|
617
|
+
this.addTimeProductsCatalog = Array.isArray(result) ? [...result] : [];
|
|
618
|
+
return result;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* 只读查询单商品详情:走 ProductList 报价查询,但不写 productCatalog、
|
|
623
|
+
* 不 emit onProductsLoaded、不修改 BookingDate。
|
|
624
|
+
*
|
|
625
|
+
* 供「列表已 loadProducts、仅需补 product_resource / capacity」等场景使用,
|
|
626
|
+
* 避免 loadProductDetail 覆盖左侧商品列表。
|
|
627
|
+
*
|
|
628
|
+
* @example
|
|
629
|
+
* const detail = await bookingTicket.queryProductDetail({
|
|
630
|
+
* product_id: 2,
|
|
631
|
+
* schedule_date: '2030-01-15',
|
|
632
|
+
* schedule_datetime: '2030-01-15 10:00:00',
|
|
633
|
+
* });
|
|
634
|
+
*/
|
|
635
|
+
async queryProductDetail(params, options) {
|
|
636
|
+
const {
|
|
637
|
+
product_id,
|
|
638
|
+
...queryParams
|
|
639
|
+
} = params;
|
|
640
|
+
try {
|
|
641
|
+
const result = await this.store.products.loadProducts({
|
|
642
|
+
with_count: ['bundleGroup', 'optionGroup'],
|
|
643
|
+
with_schedule: 1,
|
|
644
|
+
...queryParams,
|
|
645
|
+
product_ids: [product_id],
|
|
646
|
+
cacheId: this.cacheId
|
|
647
|
+
}, options);
|
|
648
|
+
const list = Array.isArray(result) ? result : [];
|
|
649
|
+
return list.find(product => Number(product.id) === Number(product_id));
|
|
650
|
+
} catch (error) {
|
|
651
|
+
console.error('Failed to query product detail:', error);
|
|
652
|
+
throw error;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* 按预约时间加载单个商品详情。
|
|
658
|
+
* 价格仍由 server products 的报价单桥接统一计算,避免 solution 实例重复请求报价单。
|
|
659
|
+
*/
|
|
660
|
+
async loadProductDetail(params, options) {
|
|
661
|
+
const {
|
|
662
|
+
product_id,
|
|
663
|
+
...queryParams
|
|
664
|
+
} = params;
|
|
665
|
+
const products = await this.loadProducts({
|
|
666
|
+
...queryParams,
|
|
667
|
+
product_ids: [product_id]
|
|
668
|
+
}, options);
|
|
669
|
+
return products.find(product => Number(product.id) === Number(product_id));
|
|
670
|
+
}
|
|
671
|
+
|
|
125
672
|
/**
|
|
126
673
|
* 取消商品查询订阅
|
|
127
674
|
* @param subscriberId 订阅时传入的 subscriberId
|
|
128
675
|
*/
|
|
129
676
|
unsubscribeProductQuery(subscriberId) {
|
|
130
|
-
|
|
131
|
-
(_a = this.core.server) == null ? void 0 : _a.removeProductQuerySubscriber(subscriberId);
|
|
677
|
+
this.core.server?.removeProductQuerySubscriber(subscriberId);
|
|
132
678
|
}
|
|
679
|
+
|
|
133
680
|
/**
|
|
134
681
|
* 初始化外设扫码结果监听
|
|
135
682
|
*/
|
|
136
683
|
initPeripheralsListener() {
|
|
137
684
|
this.scan.initPeripheralsListener();
|
|
138
685
|
}
|
|
686
|
+
|
|
139
687
|
/**
|
|
140
688
|
* 获取商品列表(不加载到模块中)
|
|
141
689
|
* @returns 商品列表
|
|
@@ -143,19 +691,72 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
143
691
|
async getProducts() {
|
|
144
692
|
return this.store.products.getProducts();
|
|
145
693
|
}
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* 获取当前已加载的商品池 UI 视图。
|
|
697
|
+
*
|
|
698
|
+
* ProductList.getProducts 是异步 API;BookingTicket 维护最近一次 loadProducts 结果,
|
|
699
|
+
* 供 UI 同步 getter 使用。未加载时返回空列表。
|
|
700
|
+
*/
|
|
701
|
+
getProductCatalog() {
|
|
702
|
+
return {
|
|
703
|
+
products: [...this.productCatalog]
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* 获取购物车 UI 视图。
|
|
709
|
+
*
|
|
710
|
+
* tempOrder 仍是 checkout 协议对象;商品行直接透传 products,bookings 附带关联商品。
|
|
711
|
+
*/
|
|
712
|
+
getCart() {
|
|
713
|
+
const tempOrder = this.store.order?.getTempOrder() ?? null;
|
|
714
|
+
const salesDetail = this.getSalesOrder();
|
|
715
|
+
const bookings = salesDetail?.bookings ?? (tempOrder?.bookings || []);
|
|
716
|
+
let operatingDayBoundary;
|
|
717
|
+
try {
|
|
718
|
+
operatingDayBoundary = this.getAppData('operating_day_boundary');
|
|
719
|
+
} catch {
|
|
720
|
+
operatingDayBoundary = undefined;
|
|
721
|
+
}
|
|
722
|
+
const shopOpeningHours = operatingDayBoundary?.type === 'start_time' ? '23:59' : operatingDayBoundary?.time;
|
|
723
|
+
return (0, _cartView.buildCartView)(tempOrder?.products || [], bookings, {
|
|
724
|
+
addTimeProducts: this.addTimeProductsCatalog,
|
|
725
|
+
bookingConfig: this.getBookingConfig(),
|
|
726
|
+
productsByUid: tempOrder?._extend?.productsByUid,
|
|
727
|
+
shopOpeningHours
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* 获取当前下单客户(与 OrderModule.tempOrder snapshot 一致)。
|
|
733
|
+
*/
|
|
734
|
+
getCustomer() {
|
|
735
|
+
return this.getOrderCustomerSnapshot();
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* 通过 ids 获取商品列表(不加载到模块中)
|
|
740
|
+
* @returns 商品列表
|
|
741
|
+
*/
|
|
742
|
+
async getProductByIds(ids) {
|
|
743
|
+
return this.store.products.getProductByIds(ids);
|
|
744
|
+
}
|
|
745
|
+
|
|
146
746
|
/**
|
|
147
747
|
* 获取日程时间段点
|
|
148
748
|
* @param params 参数
|
|
149
749
|
* @returns 日程时间段点
|
|
150
750
|
*/
|
|
151
751
|
async getScheduleTimePoints(params) {
|
|
152
|
-
const result = await this.request.post(
|
|
752
|
+
const result = await this.request.post('/menu/schedule-time-points', {
|
|
153
753
|
menu_list_ids: params.menu_list_ids
|
|
154
754
|
}, {
|
|
155
755
|
osServer: true
|
|
156
756
|
});
|
|
157
757
|
return result.data || [];
|
|
158
758
|
}
|
|
759
|
+
|
|
159
760
|
/**
|
|
160
761
|
* 获取客户列表
|
|
161
762
|
* @param params 查询参数
|
|
@@ -166,10 +767,11 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
166
767
|
const result = await this.store.customer.getCustomerList(params);
|
|
167
768
|
return result;
|
|
168
769
|
} catch (error) {
|
|
169
|
-
console.error(
|
|
770
|
+
console.error('Failed to get customer list:', error);
|
|
170
771
|
throw error;
|
|
171
772
|
}
|
|
172
773
|
}
|
|
774
|
+
|
|
173
775
|
/**
|
|
174
776
|
* 设置活跃客户
|
|
175
777
|
* @param customer 客户信息
|
|
@@ -180,6 +782,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
180
782
|
customer
|
|
181
783
|
});
|
|
182
784
|
}
|
|
785
|
+
|
|
183
786
|
/**
|
|
184
787
|
* 获取当前活跃客户
|
|
185
788
|
* @returns 当前活跃客户
|
|
@@ -187,6 +790,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
187
790
|
getActiveCustomer() {
|
|
188
791
|
return this.store.customer.getSelectedCustomer();
|
|
189
792
|
}
|
|
793
|
+
|
|
190
794
|
/**
|
|
191
795
|
* 根据ID设置选中的客户
|
|
192
796
|
* @param customerId 客户ID
|
|
@@ -200,6 +804,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
200
804
|
});
|
|
201
805
|
}
|
|
202
806
|
}
|
|
807
|
+
|
|
203
808
|
/**
|
|
204
809
|
* 获取所有客户
|
|
205
810
|
* @returns 客户列表
|
|
@@ -207,6 +812,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
207
812
|
getCustomers() {
|
|
208
813
|
return this.store.customer.getCustomers();
|
|
209
814
|
}
|
|
815
|
+
|
|
210
816
|
/**
|
|
211
817
|
* 根据ID获取客户
|
|
212
818
|
* @param customerId 客户ID
|
|
@@ -215,12 +821,14 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
215
821
|
getCustomerById(customerId) {
|
|
216
822
|
return this.store.customer.getCustomerById(customerId);
|
|
217
823
|
}
|
|
824
|
+
|
|
218
825
|
/**
|
|
219
826
|
* 清空客户列表
|
|
220
827
|
*/
|
|
221
828
|
clearCustomers() {
|
|
222
829
|
this.store.customer.clearCustomers();
|
|
223
830
|
}
|
|
831
|
+
|
|
224
832
|
/**
|
|
225
833
|
* 添加客户到列表第一位
|
|
226
834
|
* @param customer 要添加的客户信息
|
|
@@ -228,6 +836,155 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
228
836
|
addCustomerToFirst(customer) {
|
|
229
837
|
this.store.customer.addCustomerToFirst(customer);
|
|
230
838
|
}
|
|
839
|
+
|
|
840
|
+
// ─── 下单客户(基于 OrderModule.tempOrder,单一真源)───
|
|
841
|
+
// 与老的 setActiveCustomer/getActiveCustomer 解耦:
|
|
842
|
+
// - 老路:写入 CustomerModule.selectedCustomer(保留兼容,存量调用方不动)
|
|
843
|
+
// - 新路:写入 tempOrder 的 customer 协议字段 + _extend.customerSnapshot
|
|
844
|
+
// 新业务(如 SalesSdk)应优先使用本组方法。
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* 设置当前下单客户。
|
|
848
|
+
*
|
|
849
|
+
* @param customer 完整客户对象;null 表示清空
|
|
850
|
+
*
|
|
851
|
+
* 内部将 customer 格式化为 tempOrder 协议字段后写入 OrderModule,
|
|
852
|
+
* 并以 customer 作为 snapshot 保存富字段。
|
|
853
|
+
*
|
|
854
|
+
* 同时透传 OrderModule 内部 emit 的 `order:onOrderCustomerChange` 之外,
|
|
855
|
+
* 在 BookingTicket 命名空间也 emit 一次,方便上层统一从 Solution 订阅。
|
|
856
|
+
*/
|
|
857
|
+
setOrderCustomer(customer) {
|
|
858
|
+
if (!customer) {
|
|
859
|
+
this.clearOrderCustomer();
|
|
860
|
+
return;
|
|
861
|
+
}
|
|
862
|
+
const previousCustomerId = this.store.order.getOrderCustomer()?.customer_id;
|
|
863
|
+
const snapshotBeforeSet = this.store.order.getOrderCustomerSnapshot();
|
|
864
|
+
const patch = (0, _orderCustomer.formatOrderCustomerPatch)(customer);
|
|
865
|
+
const customerUnchanged = Number(previousCustomerId || 0) === Number(patch.customer_id || 0);
|
|
866
|
+
if (!customerUnchanged) {
|
|
867
|
+
this.discountConfigCacheKey = null;
|
|
868
|
+
this.hasManualDiscountSelection = false;
|
|
869
|
+
}
|
|
870
|
+
this.store.order.setOrderCustomer(patch, customer);
|
|
871
|
+
const snapshotAfterOrderSet = this.store.order.getOrderCustomerSnapshot();
|
|
872
|
+
if (customerUnchanged) {
|
|
873
|
+
// hydrate 后 customer_id 已存在但 _extend.customerSnapshot 仍为空时,
|
|
874
|
+
// 须通知 SalesSdk 刷新 selected(否则会一直停在 onSalesOrderLoaded 时的 null)。
|
|
875
|
+
const snapshotReplenished = !snapshotBeforeSet && Boolean(snapshotAfterOrderSet);
|
|
876
|
+
if (snapshotReplenished) {
|
|
877
|
+
const next = this.buildOrderCustomerPayload();
|
|
878
|
+
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next);
|
|
879
|
+
}
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
const next = this.buildOrderCustomerPayload();
|
|
883
|
+
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next);
|
|
884
|
+
this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
|
|
885
|
+
// 客户切换可能改变可用促销/赠品;触发一次重算(recursion-safe)。
|
|
886
|
+
void this.store.order.applyPromotion().catch(error => {
|
|
887
|
+
console.error('[BookingTicket] applyPromotion after customer change failed', error);
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
|
|
893
|
+
*/
|
|
894
|
+
getOrderCustomer() {
|
|
895
|
+
return this.store.order.getOrderCustomer();
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* 读取 tempOrder._extend.customerSnapshot 中的完整客户对象。
|
|
900
|
+
*/
|
|
901
|
+
getOrderCustomerSnapshot() {
|
|
902
|
+
return this.store.order.getOrderCustomerSnapshot();
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* 清空下单客户(协议字段 + snapshot)。
|
|
907
|
+
*/
|
|
908
|
+
clearOrderCustomer() {
|
|
909
|
+
this.store.order.clearOrderCustomer();
|
|
910
|
+
this.discountConfigCacheKey = null;
|
|
911
|
+
this.hasManualDiscountSelection = false;
|
|
912
|
+
const orderStore = this.store.order.store || {};
|
|
913
|
+
const discountModule = orderStore.discount;
|
|
914
|
+
void discountModule?.setOriginalDiscountList?.([]);
|
|
915
|
+
void discountModule?.setDiscountList?.([]);
|
|
916
|
+
this.store.order.applyDiscount();
|
|
917
|
+
void this.store.order.recalculateSummary({
|
|
918
|
+
createIfMissing: true
|
|
919
|
+
}).then(() => {
|
|
920
|
+
const tempOrder = this.store.order.ensureTempOrder();
|
|
921
|
+
this.store.order.persistTempOrder();
|
|
922
|
+
return this.effectsEmit('onDiscountApplied', {
|
|
923
|
+
productList: tempOrder.products || [],
|
|
924
|
+
discountList: discountModule?.getDiscountList?.() || [],
|
|
925
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
926
|
+
tempOrder
|
|
927
|
+
});
|
|
928
|
+
}).catch(error => {
|
|
929
|
+
console.error('Failed to recalculate summary after clearing customer:', error);
|
|
930
|
+
});
|
|
931
|
+
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, null);
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* 重置 tempOrder,并同步清空下单客户运行态。
|
|
936
|
+
*
|
|
937
|
+
* OrderModule.restoreOrder 会重建空单(customer_id 已为 null),但不会:
|
|
938
|
+
* - emit BookingTicket `onOrderCustomerChange`
|
|
939
|
+
* - 重置 CustomerModule.selectedCustomer(老路 getActiveCustomer)
|
|
940
|
+
*
|
|
941
|
+
* 因此在 super.restoreOrder 之后显式清客户,保证 SalesSdk / ticketBooking 订阅方与 tempOrder 一致。
|
|
942
|
+
*/
|
|
943
|
+
async restoreOrder() {
|
|
944
|
+
const tempOrder = await super.restoreOrder();
|
|
945
|
+
this.clearOrderCustomer();
|
|
946
|
+
this.store.customer?.setSelectedCustomer(null);
|
|
947
|
+
return tempOrder;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
/** 内部:基于 OrderModule 当前状态构造一份 OrderCustomerChangePayload。 */
|
|
951
|
+
buildOrderCustomerPayload() {
|
|
952
|
+
const patch = this.store.order.getOrderCustomer();
|
|
953
|
+
if (!patch) return null;
|
|
954
|
+
return {
|
|
955
|
+
patch,
|
|
956
|
+
snapshot: this.store.order.getOrderCustomerSnapshot()
|
|
957
|
+
};
|
|
958
|
+
}
|
|
959
|
+
refreshDiscountConfigAfterOrderCustomerChange(customerId) {
|
|
960
|
+
if (!customerId || customerId === 1) return;
|
|
961
|
+
if (this.orderCustomerDiscountRefreshInFlight && this.orderCustomerDiscountRefreshCustomerId === customerId) {
|
|
962
|
+
return;
|
|
963
|
+
}
|
|
964
|
+
const previousRefresh = this.orderCustomerDiscountRefreshInFlight;
|
|
965
|
+
const refreshTask = (async () => {
|
|
966
|
+
if (previousRefresh) {
|
|
967
|
+
await previousRefresh.catch(() => undefined);
|
|
968
|
+
}
|
|
969
|
+
const currentCustomer = this.store.order.getOrderCustomer();
|
|
970
|
+
if (!currentCustomer || Number(currentCustomer.customer_id) !== customerId) {
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
await this.loadDiscountConfig({
|
|
974
|
+
customerId
|
|
975
|
+
});
|
|
976
|
+
})();
|
|
977
|
+
this.orderCustomerDiscountRefreshInFlight = refreshTask;
|
|
978
|
+
this.orderCustomerDiscountRefreshCustomerId = customerId;
|
|
979
|
+
refreshTask.catch(error => {
|
|
980
|
+
console.error('Failed to load discount config after customer change:', error);
|
|
981
|
+
}).finally(() => {
|
|
982
|
+
if (this.orderCustomerDiscountRefreshInFlight !== refreshTask) return;
|
|
983
|
+
this.orderCustomerDiscountRefreshInFlight = null;
|
|
984
|
+
this.orderCustomerDiscountRefreshCustomerId = null;
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
|
|
231
988
|
/**
|
|
232
989
|
* 获取客户分页信息
|
|
233
990
|
* @returns 分页信息
|
|
@@ -235,6 +992,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
235
992
|
getCustomerPaginationInfo() {
|
|
236
993
|
return this.store.customer.getPaginationInfo();
|
|
237
994
|
}
|
|
995
|
+
|
|
238
996
|
/**
|
|
239
997
|
* 获取客户列表总数
|
|
240
998
|
* @returns 总数
|
|
@@ -242,6 +1000,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
242
1000
|
getCustomerTotal() {
|
|
243
1001
|
return this.store.customer.getState().total;
|
|
244
1002
|
}
|
|
1003
|
+
|
|
245
1004
|
/**
|
|
246
1005
|
* 设置客户分页信息
|
|
247
1006
|
* @param page 页码
|
|
@@ -250,6 +1009,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
250
1009
|
setCustomerPaginationInfo(page, pageSize) {
|
|
251
1010
|
this.store.customer.setPaginationInfo(page, pageSize);
|
|
252
1011
|
}
|
|
1012
|
+
|
|
253
1013
|
/**
|
|
254
1014
|
* 便捷方法:切换客户分页并自动获取数据
|
|
255
1015
|
* @param page 页码
|
|
@@ -258,16 +1018,14 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
258
1018
|
*/
|
|
259
1019
|
async changeCustomerPage(page, pageSize) {
|
|
260
1020
|
try {
|
|
261
|
-
const result = await this.store.customer.changeCustomerPage(
|
|
262
|
-
page,
|
|
263
|
-
pageSize
|
|
264
|
-
);
|
|
1021
|
+
const result = await this.store.customer.changeCustomerPage(page, pageSize);
|
|
265
1022
|
return result;
|
|
266
1023
|
} catch (error) {
|
|
267
|
-
console.error(
|
|
1024
|
+
console.error('Failed to change customer page:', error);
|
|
268
1025
|
throw error;
|
|
269
1026
|
}
|
|
270
1027
|
}
|
|
1028
|
+
|
|
271
1029
|
/**
|
|
272
1030
|
* 滚动加载更多客户数据 - 数据会追加到现有列表中
|
|
273
1031
|
* @returns 客户列表响应
|
|
@@ -278,10 +1036,11 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
278
1036
|
this.core.effects.emit(`${this.name}:onCustomerListUpdate`, result);
|
|
279
1037
|
return result;
|
|
280
1038
|
} catch (error) {
|
|
281
|
-
console.error(
|
|
1039
|
+
console.error('Failed to load more customers:', error);
|
|
282
1040
|
throw error;
|
|
283
1041
|
}
|
|
284
1042
|
}
|
|
1043
|
+
|
|
285
1044
|
/**
|
|
286
1045
|
* 重置并重新开始滚动加载客户数据
|
|
287
1046
|
* @param params 查询参数
|
|
@@ -293,10 +1052,11 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
293
1052
|
this.core.effects.emit(`${this.name}:onCustomerListReset`, result);
|
|
294
1053
|
return result;
|
|
295
1054
|
} catch (error) {
|
|
296
|
-
console.error(
|
|
1055
|
+
console.error('Failed to reset and load customers:', error);
|
|
297
1056
|
throw error;
|
|
298
1057
|
}
|
|
299
1058
|
}
|
|
1059
|
+
|
|
300
1060
|
/**
|
|
301
1061
|
* 检查是否还有更多客户数据可以加载
|
|
302
1062
|
* @returns 是否还有更多数据
|
|
@@ -304,6 +1064,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
304
1064
|
hasMoreCustomers() {
|
|
305
1065
|
return this.store.customer.hasMoreCustomers();
|
|
306
1066
|
}
|
|
1067
|
+
|
|
307
1068
|
/**
|
|
308
1069
|
* 获取当前的客户搜索条件
|
|
309
1070
|
* @returns 当前搜索条件
|
|
@@ -311,6 +1072,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
311
1072
|
getCurrentCustomerSearchParams() {
|
|
312
1073
|
return this.store.customer.getCurrentSearchParams();
|
|
313
1074
|
}
|
|
1075
|
+
|
|
314
1076
|
/**
|
|
315
1077
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
316
1078
|
* @returns 客户状态
|
|
@@ -318,104 +1080,105 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
318
1080
|
getCustomerState() {
|
|
319
1081
|
return this.store.customer.getState();
|
|
320
1082
|
}
|
|
1083
|
+
|
|
321
1084
|
/**
|
|
322
1085
|
* 全局扫描监听
|
|
323
1086
|
* @param callback 回调
|
|
324
1087
|
*/
|
|
325
1088
|
scanGlobalListener(callback) {
|
|
326
|
-
const localSearch =
|
|
327
|
-
const scanCallback = (0,
|
|
328
|
-
const safeCallback =
|
|
1089
|
+
const localSearch = v => this.store.products.findProductsByCodeOrBarcode(v);
|
|
1090
|
+
const scanCallback = (0, _handleScan.handleGlobalScan)(this.request, localSearch, this.getSubmitOrderSalesChannel());
|
|
1091
|
+
const safeCallback = d => {
|
|
329
1092
|
try {
|
|
330
1093
|
callback(d);
|
|
331
1094
|
} catch (error) {
|
|
332
|
-
console.error(
|
|
1095
|
+
console.error('scanGlobalListener传入的回调函数异常', error);
|
|
333
1096
|
}
|
|
334
1097
|
};
|
|
335
|
-
const listener = {
|
|
1098
|
+
const listener = {
|
|
1099
|
+
key: 'global',
|
|
1100
|
+
callback: safeCallback
|
|
1101
|
+
};
|
|
336
1102
|
const removeListener = this.scan.addListener(listener, scanCallback);
|
|
337
1103
|
return removeListener;
|
|
338
1104
|
}
|
|
1105
|
+
|
|
339
1106
|
/**
|
|
340
1107
|
* 客户扫描监听
|
|
341
1108
|
* @param callback 回调
|
|
342
1109
|
*/
|
|
343
1110
|
scanCustomerListener(callback) {
|
|
344
|
-
const scanCallback = (0,
|
|
345
|
-
const safeCallback =
|
|
1111
|
+
const scanCallback = (0, _handleScan.handleCustomerScan)();
|
|
1112
|
+
const safeCallback = d => {
|
|
346
1113
|
try {
|
|
347
1114
|
callback(d);
|
|
348
1115
|
} catch (error) {
|
|
349
|
-
console.error(
|
|
1116
|
+
console.error('scanCustomerListener传入的回调函数异常', error);
|
|
350
1117
|
}
|
|
351
1118
|
};
|
|
352
|
-
const listener = {
|
|
1119
|
+
const listener = {
|
|
1120
|
+
key: 'customer',
|
|
1121
|
+
callback: safeCallback
|
|
1122
|
+
};
|
|
353
1123
|
const removeListener = this.scan.addListener(listener, scanCallback);
|
|
354
1124
|
return removeListener;
|
|
355
1125
|
}
|
|
1126
|
+
|
|
356
1127
|
/**
|
|
357
1128
|
* @title 通用扫描监听
|
|
358
1129
|
* @description 直接将扫描结果返回给调用方
|
|
359
1130
|
* @param callback 回调
|
|
360
1131
|
*/
|
|
361
1132
|
scanUniversalListener(callback, key) {
|
|
362
|
-
const scanCallback = (0,
|
|
363
|
-
const safeCallback =
|
|
1133
|
+
const scanCallback = (0, _handleScan.handleUniversalScan)();
|
|
1134
|
+
const safeCallback = d => {
|
|
364
1135
|
try {
|
|
365
1136
|
callback(d);
|
|
366
1137
|
} catch (error) {
|
|
367
|
-
console.error(
|
|
368
|
-
`scanUniversalListener传入的回调函数异常, key: ${key}`,
|
|
369
|
-
error
|
|
370
|
-
);
|
|
1138
|
+
console.error(`scanUniversalListener传入的回调函数异常, key: ${key}`, error);
|
|
371
1139
|
}
|
|
372
1140
|
};
|
|
373
|
-
const listener = {
|
|
1141
|
+
const listener = {
|
|
1142
|
+
key,
|
|
1143
|
+
callback: safeCallback
|
|
1144
|
+
};
|
|
374
1145
|
const removeListener = this.scan.addListener(listener, scanCallback);
|
|
375
1146
|
return removeListener;
|
|
376
1147
|
}
|
|
1148
|
+
|
|
377
1149
|
/**
|
|
378
1150
|
* 调用摄像头
|
|
379
1151
|
* @param data 用户自定义数据
|
|
380
1152
|
*/
|
|
381
1153
|
activateCamera(data) {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
key: "active_native_scanner",
|
|
1154
|
+
this.window?.interaction?.utils?.postMessageToApp?.({
|
|
1155
|
+
module: 'global',
|
|
1156
|
+
key: 'active_native_scanner',
|
|
386
1157
|
data
|
|
387
1158
|
});
|
|
388
1159
|
}
|
|
1160
|
+
|
|
389
1161
|
/**
|
|
390
1162
|
* 禁用所有扫描监听
|
|
391
1163
|
*/
|
|
392
1164
|
disableAllScanListeners() {
|
|
393
1165
|
this.scan.disableAllListeners();
|
|
394
1166
|
}
|
|
1167
|
+
|
|
395
1168
|
/**
|
|
396
1169
|
* 启用所有扫描监听
|
|
397
1170
|
*/
|
|
398
1171
|
enableAllScanListeners() {
|
|
399
1172
|
this.scan.enableAllListeners();
|
|
400
1173
|
}
|
|
1174
|
+
|
|
401
1175
|
/**
|
|
402
1176
|
* 清空所有扫描监听对应的任务执行队列
|
|
403
1177
|
*/
|
|
404
1178
|
clearAllScanListenersTaskQueue() {
|
|
405
1179
|
this.scan.clearTaskQueue();
|
|
406
1180
|
}
|
|
407
|
-
|
|
408
|
-
* 设置其他参数
|
|
409
|
-
* @param params 参数
|
|
410
|
-
* @param options 选项
|
|
411
|
-
*/
|
|
412
|
-
async setOtherParams(params, { cover = false } = {}) {
|
|
413
|
-
if (cover) {
|
|
414
|
-
this.otherParams = params;
|
|
415
|
-
} else {
|
|
416
|
-
this.otherParams = { ...this.otherParams, ...params };
|
|
417
|
-
}
|
|
418
|
-
}
|
|
1181
|
+
|
|
419
1182
|
/**
|
|
420
1183
|
* 获取其他参数
|
|
421
1184
|
* @returns 其他参数
|
|
@@ -423,25 +1186,561 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
423
1186
|
async getOtherParams() {
|
|
424
1187
|
return this.otherParams;
|
|
425
1188
|
}
|
|
1189
|
+
|
|
1190
|
+
// ─── BookingContext API(透传给 BookingContextModule) ──────────────────────
|
|
1191
|
+
// SalesSdkProvider 挂载时默认调 initBookingContext;也可由 UI 显式 set* 灌入已有数据。
|
|
1192
|
+
|
|
1193
|
+
/** 拉取 board config 并写入 BookingContext。 */
|
|
1194
|
+
loadBookingConfig(params) {
|
|
1195
|
+
return this.store.bookingContext.loadBookingConfig(params);
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
/** 拉取资源全集并写入 BookingContext。 */
|
|
1199
|
+
loadBookingResources(params) {
|
|
1200
|
+
return this.store.bookingContext.loadResources(params);
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/** 初始化 BookingContext(date + config + resources)。 */
|
|
1204
|
+
initBookingContext(params) {
|
|
1205
|
+
return this.store.bookingContext.initBookingContext(params);
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
/** 当前 store 是否已具备与入参等价的 config / resources(无需再请求接口)。 */
|
|
1209
|
+
isBookingContextReady(params) {
|
|
1210
|
+
return this.store.bookingContext.isBookingContextReady(params);
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
/** 写入 booking config(来源:`/core/board/management/config`)。 */
|
|
1214
|
+
setBookingConfig(config) {
|
|
1215
|
+
this.store.bookingContext.setBookingConfig(config);
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
/** 读取当前 booking config。 */
|
|
1219
|
+
getBookingConfig() {
|
|
1220
|
+
return this.store.bookingContext.getBookingConfig();
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
/** 写入资源全集(来源:`/form/schedule`),同步派生 resourcesOriginMap。 */
|
|
1224
|
+
setResources(resources) {
|
|
1225
|
+
this.store.bookingContext.setResources(resources);
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
/** 读取资源全集(浅克隆)。 */
|
|
1229
|
+
getResourcesOrigin() {
|
|
1230
|
+
return this.store.bookingContext.getResourcesOrigin();
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
/** 读取资源全集 map(id → resource)。 */
|
|
1234
|
+
getResourcesOriginMap() {
|
|
1235
|
+
return this.store.bookingContext.getResourcesOriginMap();
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
/** 写入当前选择的日期;支持 dayjs / Date / string。 */
|
|
1239
|
+
setBookingDate(date) {
|
|
1240
|
+
this.store.bookingContext.setDate(date);
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
/** 读取当前选择的日期(统一 string)。 */
|
|
1244
|
+
getBookingDate() {
|
|
1245
|
+
return this.store.bookingContext.getDate();
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
/** 读取 BookingContext 完整 store(调试 / 测试 / 透传给 SDK 使用)。 */
|
|
1249
|
+
getBookingContextState() {
|
|
1250
|
+
return this.store.bookingContext.getState();
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
/** 清空 BookingContext(切租户 / destroy 场景)。 */
|
|
1254
|
+
clearBookingContext() {
|
|
1255
|
+
this.store.bookingContext.clear();
|
|
1256
|
+
}
|
|
1257
|
+
|
|
426
1258
|
/**
|
|
427
|
-
*
|
|
1259
|
+
* 构造 BookingContext 计算上下文(供 getProductExtend / getResourceByIds 等读 API 复用)。
|
|
428
1260
|
*/
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
1261
|
+
buildBookingCalcContext(extra) {
|
|
1262
|
+
const state = this.store.bookingContext.getState();
|
|
1263
|
+
const date = extra?.date ?? state.date;
|
|
1264
|
+
return {
|
|
1265
|
+
bookingConfig: state.bookingConfig,
|
|
1266
|
+
resourcesOrigin: state.resourcesOrigin,
|
|
1267
|
+
resourcesOriginMap: state.resourcesOriginMap,
|
|
1268
|
+
date,
|
|
1269
|
+
presetStartTime: extra?.presetStartTime ?? (0, _BookingContext.derivePresetStartTimeFromDate)(date),
|
|
1270
|
+
...(extra || {})
|
|
1271
|
+
};
|
|
440
1272
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* 取商品当前可选资源列表(透传 OS BookingContext utils#getResourceByIds)。
|
|
1276
|
+
* `extraResources` 用于把拖入未绑定的资源也展示出来。
|
|
1277
|
+
*/
|
|
1278
|
+
getResourcesForProduct(product, options) {
|
|
1279
|
+
const ctx = this.buildBookingCalcContext();
|
|
1280
|
+
return (0, _BookingContext.getResourceByIds)(ctx.resourcesOriginMap || {}, product, {
|
|
1281
|
+
resourceTab: ctx.bookingConfig?.config?.resource_tab,
|
|
1282
|
+
resourcesOrigin: ctx.resourcesOrigin,
|
|
1283
|
+
extraResources: options?.extraResources || []
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
/**
|
|
1288
|
+
* 拼装 cacheItem 的 _extend / _data(资源 / 容量 / timeObj),与 info2 `getProductExtend` 等价。
|
|
1289
|
+
*/
|
|
1290
|
+
getProductExtend(cacheItem, extra) {
|
|
1291
|
+
const preparedCacheItem = withProductOptionString(cacheItem);
|
|
1292
|
+
const result = (0, _BookingContext.getProductExtend)({
|
|
1293
|
+
cacheItem: preparedCacheItem,
|
|
1294
|
+
ctx: this.buildBookingCalcContext(extra)
|
|
1295
|
+
});
|
|
1296
|
+
return result;
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
/**
|
|
1300
|
+
* 取资源不可用原因列表(结构化 enum + params,i18n 文案由 UI 渲染)。
|
|
1301
|
+
*/
|
|
1302
|
+
getResourceErrors(resource, cacheItem) {
|
|
1303
|
+
return (0, _BookingContext.getResourceErrors)(resource, cacheItem);
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
// ─── addProduct 决策 / 转换 API(SDK 加车下沉所需) ─────────────────────────
|
|
1307
|
+
// 这一组方法是 SalesSdkCartContext.addProduct / confirmDetail 的 OS 后端。
|
|
1308
|
+
// 调用方传入 ProductData,OS 自取 bookingContext / customer / date 等上下文,
|
|
1309
|
+
// 输出 (a) autoClose 决策结果或 (b) `{ product, booking }` 协议入参。
|
|
1310
|
+
|
|
1311
|
+
/**
|
|
1312
|
+
* session 商品 catalog 日期与 TimeBar 不一致时写业务日志。
|
|
1313
|
+
*
|
|
1314
|
+
* @example
|
|
1315
|
+
* this.logSessionCatalogDateMismatch(product, ctx.date);
|
|
1316
|
+
*/
|
|
1317
|
+
logSessionCatalogDateMismatch(item, bookingDate) {
|
|
1318
|
+
const logger = this.logger;
|
|
1319
|
+
if (!logger?.addLog) return;
|
|
1320
|
+
const tempOrder = this.getTempOrder?.();
|
|
1321
|
+
const staleInfo = (0, _sessionCatalogStale.buildSessionCatalogStaleInfo)(item, bookingDate);
|
|
1322
|
+
logger.addLog({
|
|
1323
|
+
type: 'warning',
|
|
1324
|
+
title: `[BookingTicket] session catalog date mismatch, reload products`,
|
|
1325
|
+
metadata: {
|
|
1326
|
+
order_id: tempOrder?.order_id ?? null,
|
|
1327
|
+
external_sale_number: tempOrder?.external_sale_number ?? null,
|
|
1328
|
+
...staleInfo,
|
|
1329
|
+
cartDetailValueSession: item?.cartDetailValue?.session ?? null
|
|
1330
|
+
}
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
/**
|
|
1335
|
+
* 加车前:session 商品 catalog 日历日与 bookingDate 不一致时中断加购,交由 SDK reload products。
|
|
1336
|
+
*/
|
|
1337
|
+
resolveSessionCatalogBeforeAdd(item, ctx) {
|
|
1338
|
+
if (!(0, _sessionCatalogStale.isSessionCatalogDateStale)(item, ctx.date)) {
|
|
1339
|
+
return null;
|
|
1340
|
+
}
|
|
1341
|
+
this.logSessionCatalogDateMismatch(item, ctx.date);
|
|
1342
|
+
return {
|
|
1343
|
+
action: 'reloadCatalog'
|
|
1344
|
+
};
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
/**
|
|
1348
|
+
* 拼装 addProductDecision 通用上下文(从 store 自取)。
|
|
1349
|
+
*/
|
|
1350
|
+
buildAddProductCtx(extra) {
|
|
1351
|
+
const bookingContextState = this.store.bookingContext.getState();
|
|
1352
|
+
const date = extra?.date ?? bookingContextState.date;
|
|
1353
|
+
const orderCustomerId = this.getOrderCustomerSnapshot()?.id ?? this.store.order.getTempOrder()?.customer_id ?? undefined;
|
|
1354
|
+
return {
|
|
1355
|
+
bookingConfig: bookingContextState.bookingConfig,
|
|
1356
|
+
resourcesOrigin: bookingContextState.resourcesOrigin,
|
|
1357
|
+
resourcesOriginMap: bookingContextState.resourcesOriginMap,
|
|
1358
|
+
date,
|
|
1359
|
+
presetStartTime: extra?.presetStartTime ?? (0, _BookingContext.derivePresetStartTimeFromDate)(date),
|
|
1360
|
+
customerId: orderCustomerId,
|
|
1361
|
+
...(extra || {})
|
|
1362
|
+
};
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
/**
|
|
1366
|
+
* 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
|
|
1367
|
+
* 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
|
|
1368
|
+
*/
|
|
1369
|
+
decideAddProduct(item, options) {
|
|
1370
|
+
const ctx = this.buildAddProductCtx(options);
|
|
1371
|
+
const staleDecision = this.resolveSessionCatalogBeforeAdd(item, ctx);
|
|
1372
|
+
if (staleDecision) {
|
|
1373
|
+
return staleDecision;
|
|
1374
|
+
}
|
|
1375
|
+
return (0, _addProductDecision.decideAddProduct)(item, ctx);
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
/** 规格弹窗 callback 后的第二段决策。 */
|
|
1379
|
+
decideAfterDetail(cacheItem, options) {
|
|
1380
|
+
return (0, _addProductDecision.decideAfterDetail)(cacheItem, this.buildAddProductCtx(options));
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
/**
|
|
1384
|
+
* @deprecated 请用 `decideAddProduct`;`autoClose=true` 仅当 action=add。
|
|
1385
|
+
*/
|
|
1386
|
+
decideAutoClose(item, options) {
|
|
1387
|
+
return (0, _addProductDecision.decideAutoClose)(item, this.buildAddProductCtx(options));
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
/** 替代 info2 `getIsEject`:商品是否需要弹窗(0/1)。 */
|
|
1391
|
+
getIsEject(item, type = 'select') {
|
|
1392
|
+
return (0, _addProductDecision.getIsEject)(item, type);
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
/** 仅 session 商品(无 variant/option/package)→ true。 */
|
|
1396
|
+
getIsOnlySession(item) {
|
|
1397
|
+
return (0, _addProductDecision.getIsOnlySession)(item);
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
/**
|
|
1401
|
+
* 拼装 requiresDetail payload(给 SDK 直接 return 给 UI 用)。
|
|
1402
|
+
*/
|
|
1403
|
+
buildRequiresDetailPayload(item, options) {
|
|
1404
|
+
const ctx = this.buildAddProductCtx(options);
|
|
1405
|
+
return (0, _addProductDecision.buildRequiresDetailPayload)(item, ctx);
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
/**
|
|
1409
|
+
* 把 detail 弹窗回调结果(e, extension_type, detail)转换为 `(product, booking)` 入参。
|
|
1410
|
+
* 内部会先拼 cacheItem,再走 cacheItemToBookingInput 严格协议对齐。
|
|
1411
|
+
*/
|
|
1412
|
+
transformDetailToProductAndBooking(input) {
|
|
1413
|
+
const {
|
|
1414
|
+
item,
|
|
1415
|
+
cacheItem: preparedCacheItem,
|
|
1416
|
+
detailResult,
|
|
1417
|
+
options
|
|
1418
|
+
} = input;
|
|
1419
|
+
const ctx = this.buildAddProductCtx(options);
|
|
1420
|
+
const cacheItem = preparedCacheItem || (detailResult ? (0, _addProductDecision.buildCacheItemFromDetail)(item, detailResult, ctx) : (0, _addProductDecision.buildCacheItemFromCartDetail)(item, ctx));
|
|
1421
|
+
return (0, _addProductDecision.transformDetailToProductAndBooking)(cacheItem, ctx);
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
/**
|
|
1425
|
+
* 从已加车的 order line + booking 反查资源编辑抽屉所需的 cacheItem。
|
|
1426
|
+
* 供 SalesSdk「编辑资源」等场景使用;字段语义与 buildCacheItemFromDetail 产出对齐。
|
|
1427
|
+
*/
|
|
1428
|
+
buildCacheItemFromOrderLine(input) {
|
|
1429
|
+
return (0, _buildCacheItemFromOrderLine.buildCacheItemFromOrderLine)(input);
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
/**
|
|
1433
|
+
* 从已加车的普通商品 order line 反查 SkuDetailModal edit 所需的 cacheItem。
|
|
1434
|
+
*/
|
|
1435
|
+
buildNormalProductCacheItemFromOrderLine(input) {
|
|
1436
|
+
return (0, _buildNormalProductCacheItemFromOrderLine.buildNormalProductCacheItemFromOrderLine)(input);
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
/** 文档别名:与 OrderModule.updateOrderProduct 一致。 */
|
|
1440
|
+
async updateProductInOrder(params) {
|
|
1441
|
+
return this.updateOrderProduct(params);
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
/**
|
|
1445
|
+
* 全局扫码 pubsub 入口:解析码值 → 搜索 → 业务分发(客户 / 加车 / 开单)。
|
|
1446
|
+
* UI 层在 pubsub 订阅回调里注入 `bridge`(uiHosts / action / cart.confirm*)。
|
|
1447
|
+
*
|
|
1448
|
+
* @example
|
|
1449
|
+
* ```ts
|
|
1450
|
+
* await bookingTicket.handleGlobalScanCode(payload.data, {
|
|
1451
|
+
* openProductDetail: uiHosts.openProductDetail,
|
|
1452
|
+
* confirmDetail: cart.confirmDetail,
|
|
1453
|
+
* openOrder: ({ order_id }) => action({ type: 'pisell1.handleOpenCachedBigSale', data: { order_id } }),
|
|
1454
|
+
* });
|
|
1455
|
+
* ```
|
|
1456
|
+
*/
|
|
1457
|
+
async handleGlobalScanCode(code, bridge) {
|
|
1458
|
+
const trimmed = typeof code === 'string' ? code.trim() : '';
|
|
1459
|
+
if (!trimmed) {
|
|
1460
|
+
bridge?.onNotify?.('fail', 'pisell2.text.scan-global-failed');
|
|
1461
|
+
return {
|
|
1462
|
+
status: 'failed',
|
|
1463
|
+
reason: 'empty_code'
|
|
1464
|
+
};
|
|
1465
|
+
}
|
|
1466
|
+
try {
|
|
1467
|
+
const localSearch = v => this.store.products.findProductsByCodeOrBarcode(v);
|
|
1468
|
+
const scanCallback = (0, _handleScan.handleGlobalScan)(this.request, localSearch, this.getSubmitOrderSalesChannel());
|
|
1469
|
+
const raw = await scanCallback({
|
|
1470
|
+
type: 'nativeScanner',
|
|
1471
|
+
value: trimmed
|
|
1472
|
+
});
|
|
1473
|
+
const formatted = (0, _formatGlobalScan.formatGlobalScanResult)(raw, trimmed);
|
|
1474
|
+
if (!formatted) {
|
|
1475
|
+
bridge?.onNotify?.('fail', 'pisell2.text.scan-global-failed');
|
|
1476
|
+
return {
|
|
1477
|
+
status: 'failed',
|
|
1478
|
+
reason: 'not_found'
|
|
1479
|
+
};
|
|
1480
|
+
}
|
|
1481
|
+
const result = await (0, _applyGlobalScan.applyGlobalScan)({
|
|
1482
|
+
setOrderCustomer: customer => this.setOrderCustomer(customer),
|
|
1483
|
+
getOrderCustomerSnapshot: () => this.getOrderCustomerSnapshot(),
|
|
1484
|
+
getBusinessCode: () => this.otherParams?.businessCode,
|
|
1485
|
+
buildAddProductCtx: extra => this.buildAddProductCtx(extra),
|
|
1486
|
+
decideAddProduct: (item, options) => this.decideAddProduct(item, options),
|
|
1487
|
+
decideAfterDetail: (cacheItem, options) => this.decideAfterDetail(cacheItem, options),
|
|
1488
|
+
transformDetailToProductAndBooking: input => this.transformDetailToProductAndBooking(input),
|
|
1489
|
+
addProductToOrder: (product, booking) => this.addProductToOrder(product, booking)
|
|
1490
|
+
}, formatted, bridge);
|
|
1491
|
+
bridge?.refresh?.();
|
|
1492
|
+
return result;
|
|
1493
|
+
} catch (error) {
|
|
1494
|
+
console.error('[BookingTicket] handleGlobalScanCode failed', error);
|
|
1495
|
+
bridge?.onNotify?.('fail', 'pisell2.text.scan-global-failed');
|
|
1496
|
+
return {
|
|
1497
|
+
status: 'failed',
|
|
1498
|
+
reason: 'not_found'
|
|
1499
|
+
};
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
resolveBestAddTimePlan(addTimeProducts, targetMinutes) {
|
|
1503
|
+
return (0, _resolveBestAddTimePlan.resolveBestAddTimePlan)(addTimeProducts, targetMinutes);
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
/**
|
|
1507
|
+
* 构造一条绑定到已有 booking 的加时商品行。
|
|
1508
|
+
*
|
|
1509
|
+
* @example
|
|
1510
|
+
* const line = this.buildAddTimeOrderLine({ product, product_add_schedule_time: 30 }, 'booking-1');
|
|
1511
|
+
*/
|
|
1512
|
+
buildAddTimeOrderLine(input, bookingUid) {
|
|
1513
|
+
const product = input?.product;
|
|
1514
|
+
if (!product || typeof product !== 'object') {
|
|
1515
|
+
throw new Error('[BookingTicket] addAddTimeProductToBooking: product 不能为空');
|
|
1516
|
+
}
|
|
1517
|
+
const quantity = normalizeAddTimeQuantity(input.num ?? product.num);
|
|
1518
|
+
const price = resolveAddTimeProductPrice(input.price, product);
|
|
1519
|
+
const addScheduleTime = resolveAddTimeScheduleMinutes(input.product_add_schedule_time, product);
|
|
1520
|
+
const payload = {
|
|
1521
|
+
id: product.id ?? product.product_id,
|
|
1522
|
+
product_id: product.product_id ?? product.id,
|
|
1523
|
+
product_variant_id: product.product_variant_id ?? product.variant_id ?? 0,
|
|
1524
|
+
variant_id: product.variant_id ?? product.product_variant_id ?? 0,
|
|
1525
|
+
quantity,
|
|
1526
|
+
num: quantity,
|
|
1527
|
+
price,
|
|
1528
|
+
selling_price: price,
|
|
1529
|
+
original_price: product.original_price ?? price,
|
|
1530
|
+
line_total: price,
|
|
1531
|
+
total: price,
|
|
1532
|
+
product_sku: product.product_sku,
|
|
1533
|
+
option: product.option ?? product.options ?? product.product_sku?.option ?? [],
|
|
1534
|
+
bundle: product.bundle ?? product.bundles ?? product.product_bundle ?? []
|
|
1535
|
+
};
|
|
1536
|
+
const orderLine = this.transformBaseProductToOrderProduct({
|
|
1537
|
+
payload,
|
|
1538
|
+
fallbackProductId: product.id ?? product.product_id,
|
|
1539
|
+
sourceProduct: product,
|
|
1540
|
+
sourceItem: product
|
|
1541
|
+
});
|
|
1542
|
+
if (!orderLine) {
|
|
1543
|
+
throw new Error('[BookingTicket] addAddTimeProductToBooking: product transform failed');
|
|
1544
|
+
}
|
|
1545
|
+
const metadata = {
|
|
1546
|
+
...(orderLine.metadata || {}),
|
|
1547
|
+
...(addScheduleTime !== undefined ? {
|
|
1548
|
+
product_add_schedule_time: addScheduleTime
|
|
1549
|
+
} : {}),
|
|
1550
|
+
booking_uid: bookingUid
|
|
1551
|
+
};
|
|
1552
|
+
return {
|
|
1553
|
+
...orderLine,
|
|
1554
|
+
booking_uid: bookingUid,
|
|
1555
|
+
metadata
|
|
1556
|
+
};
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
/**
|
|
1560
|
+
* 将加时商品作为独立商品行绑定到已有 booking。
|
|
1561
|
+
*
|
|
1562
|
+
* 与预约商品加车不同,本方法不会把当前 booking 作为 `addProductToOrder` 第二参数传入,
|
|
1563
|
+
* 避免 OrderModule 新建 booking 或重写已有 booking.product_uid。
|
|
1564
|
+
*
|
|
1565
|
+
* @example
|
|
1566
|
+
* await bookingTicket.addAddTimeProductToBooking({
|
|
1567
|
+
* booking,
|
|
1568
|
+
* product,
|
|
1569
|
+
* num: 1,
|
|
1570
|
+
* price: '10.00',
|
|
1571
|
+
* product_add_schedule_time: 30,
|
|
1572
|
+
* });
|
|
1573
|
+
*/
|
|
1574
|
+
async addAddTimeProductToBooking(input) {
|
|
1575
|
+
return this.addAddTimeProductsToBooking({
|
|
1576
|
+
booking: input.booking,
|
|
1577
|
+
products: [input],
|
|
1578
|
+
coveredMinutes: input.coveredMinutes,
|
|
1579
|
+
bookingPatch: input.bookingPatch
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
/**
|
|
1584
|
+
* 批量将加时商品作为独立商品行绑定到已有 booking,并只触发一次购物车重算。
|
|
1585
|
+
*
|
|
1586
|
+
* @example
|
|
1587
|
+
* await bookingTicket.addAddTimeProductsToBooking({
|
|
1588
|
+
* booking,
|
|
1589
|
+
* products: [{ product, product_add_schedule_time: 30 }],
|
|
1590
|
+
* });
|
|
1591
|
+
*/
|
|
1592
|
+
async addAddTimeProductsToBooking(input) {
|
|
1593
|
+
const bookingUid = resolveBookingUidForAddTime(input?.booking);
|
|
1594
|
+
if (!bookingUid) {
|
|
1595
|
+
throw new Error('[BookingTicket] addAddTimeProductToBooking: booking.metadata.unique_identification_number 缺失');
|
|
1596
|
+
}
|
|
1597
|
+
const orderLines = (input.products || []).map(line => ({
|
|
1598
|
+
product: this.buildAddTimeOrderLine(line, bookingUid)
|
|
1599
|
+
}));
|
|
1600
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
1601
|
+
const coveredMinutes = normalizeCoveredMinutes(input.coveredMinutes);
|
|
1602
|
+
const bookingTimePatch = input.bookingPatch ?? buildAddTimeBookingTimePatch(input.booking, coveredMinutes);
|
|
1603
|
+
if (bookingTimePatch) {
|
|
1604
|
+
this.store.order.updateOrderBooking({
|
|
1605
|
+
unique_identification_number: bookingUid,
|
|
1606
|
+
updates: bookingTimePatch
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
if (typeof this.store.order.addProductsToOrder === 'function') {
|
|
1610
|
+
return this.store.order.addProductsToOrder(orderLines, {
|
|
1611
|
+
skipEditDiscountConfigRefresh: true,
|
|
1612
|
+
skipDiscountRecalculation: true
|
|
1613
|
+
});
|
|
1614
|
+
}
|
|
1615
|
+
const result = [];
|
|
1616
|
+
for (const line of orderLines) {
|
|
1617
|
+
result.splice(0, result.length, ...(await this.addProductToOrder(line.product)));
|
|
1618
|
+
}
|
|
1619
|
+
return result;
|
|
1620
|
+
}
|
|
1621
|
+
async setOtherParams(params, {
|
|
1622
|
+
cover = false
|
|
1623
|
+
} = {}) {
|
|
1624
|
+
super.setOtherParams(params, {
|
|
1625
|
+
cover
|
|
1626
|
+
});
|
|
1627
|
+
if (params?.businessCode) {
|
|
1628
|
+
await this.configureIdGeneratorFromOpenData();
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
getDeviceTaskPlugin() {
|
|
1632
|
+
const app = this.core.getPlugin('app');
|
|
1633
|
+
return app?.getApp()?.getPlugin('deviceTask') || null;
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
// 打印手环,单个或批量都可以
|
|
1637
|
+
async handlePrintWristband(params) {
|
|
1638
|
+
const deviceTask = this.getDeviceTaskPlugin();
|
|
1639
|
+
if (!deviceTask?.dispatch) {
|
|
1640
|
+
this.logger.addLog({
|
|
1641
|
+
type: 'info',
|
|
1642
|
+
title: '[BookingTicket] handlePrintWristband: deviceTask.dispatch 不可用',
|
|
1643
|
+
metadata: {
|
|
1644
|
+
voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
|
|
1645
|
+
}
|
|
1646
|
+
});
|
|
1647
|
+
return;
|
|
1648
|
+
}
|
|
1649
|
+
this.logger.addLog({
|
|
1650
|
+
type: 'info',
|
|
1651
|
+
title: '[BookingTicket] handlePrintWristband',
|
|
1652
|
+
metadata: {
|
|
1653
|
+
voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
|
|
1654
|
+
}
|
|
1655
|
+
});
|
|
1656
|
+
const deviceId = await this.getShortNumberOrDeviceId();
|
|
1657
|
+
const idempotencyKey = (0, _utils.createUuidV4)();
|
|
1658
|
+
deviceTask.dispatch({
|
|
1659
|
+
action: 'print_all',
|
|
1660
|
+
device_id: deviceId,
|
|
1661
|
+
payload: {
|
|
1662
|
+
type: 'WRISTBAND',
|
|
1663
|
+
data: {
|
|
1664
|
+
order_id: this.getOrderIdentity()?.orderId,
|
|
1665
|
+
voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
|
|
1666
|
+
}
|
|
1667
|
+
},
|
|
1668
|
+
idempotency_key: idempotencyKey,
|
|
1669
|
+
name: 'PRINT_WRISTBAND',
|
|
1670
|
+
source: 'bookingTicket',
|
|
1671
|
+
source_type: 'handlePrintWristband',
|
|
1672
|
+
source_id: idempotencyKey
|
|
1673
|
+
});
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
// 触发核销
|
|
1677
|
+
async handleRedeem(params) {
|
|
1678
|
+
const voucherIds = Array.isArray(params.voucher_ids) ? params.voucher_ids : [];
|
|
1679
|
+
const status = params.is_checkin ? 'used' : 'unused';
|
|
1680
|
+
this.logger.addLog({
|
|
1681
|
+
type: 'info',
|
|
1682
|
+
title: '[BookingTicket] handleRedeem',
|
|
1683
|
+
metadata: {
|
|
1684
|
+
voucher_ids: voucherIds,
|
|
1685
|
+
status
|
|
1686
|
+
}
|
|
1687
|
+
});
|
|
1688
|
+
const voucherIdSet = new Set(voucherIds);
|
|
1689
|
+
const tempOrder = this.store.order?.getTempOrder?.();
|
|
1690
|
+
const vouchers = tempOrder?.vouchers || this.store.order?.getVouchers() || [];
|
|
1691
|
+
let hasUpdatedVoucher = false;
|
|
1692
|
+
const nextVouchers = vouchers.map(voucher => {
|
|
1693
|
+
if (!voucherIdSet.has(voucher.voucher_id)) return voucher;
|
|
1694
|
+
hasUpdatedVoucher = true;
|
|
1695
|
+
return {
|
|
1696
|
+
...voucher,
|
|
1697
|
+
status
|
|
1698
|
+
};
|
|
1699
|
+
});
|
|
1700
|
+
if (tempOrder && hasUpdatedVoucher) {
|
|
1701
|
+
await this.replaceTempOrder({
|
|
1702
|
+
...tempOrder,
|
|
1703
|
+
vouchers: nextVouchers
|
|
1704
|
+
});
|
|
1705
|
+
}
|
|
1706
|
+
this.core.effects.emit(`${this.name}:onVouchersChange`, {});
|
|
1707
|
+
if (voucherIds.length === 0) {
|
|
1708
|
+
return {
|
|
1709
|
+
code: 200,
|
|
1710
|
+
status: true,
|
|
1711
|
+
message: '',
|
|
1712
|
+
data: []
|
|
1713
|
+
};
|
|
1714
|
+
}
|
|
1715
|
+
const identity = this.getOrderIdentity();
|
|
1716
|
+
const externalSaleNumber = tempOrder?.external_sale_number || identity?.externalSaleNumber || undefined;
|
|
1717
|
+
const orderId = tempOrder?.order_id ?? identity?.orderId ?? undefined;
|
|
1718
|
+
const orderLookup = externalSaleNumber || orderId || identity?.orderNumber || identity?.shopOrderNumber || identity?.shopFullOrderNumber || undefined;
|
|
1719
|
+
return this.request.post('/machinecode/batch', {
|
|
1720
|
+
ids: voucherIds,
|
|
1721
|
+
status,
|
|
1722
|
+
order_lookup: orderLookup,
|
|
1723
|
+
order_id: orderId,
|
|
1724
|
+
external_sale_number: externalSaleNumber
|
|
1725
|
+
}, {
|
|
1726
|
+
osServer: true
|
|
1727
|
+
});
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
/**
|
|
1731
|
+
* 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
|
|
1732
|
+
* 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
|
|
1733
|
+
*/
|
|
1734
|
+
async destroy() {
|
|
1735
|
+
await super.destroy();
|
|
1736
|
+
try {
|
|
1737
|
+
this.scan?.removeAllListeners();
|
|
1738
|
+
} catch (error) {
|
|
1739
|
+
console.warn('[BookingTicket] scan removeAllListeners 失败', error);
|
|
1740
|
+
}
|
|
1741
|
+
_scanCache.default.clear();
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
// 导出相关类型和实现
|
|
1746
|
+
exports.BookingTicket = exports.BookingTicketImpl = BookingTicketImpl;
|