@pisell/pisellos 0.0.568 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.js +10 -6
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -3
- package/dist/model/strategy/adapter/promotion/evaluator.js +3 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +7 -5
- package/dist/model/strategy/adapter/walletPass/example.js +26 -3
- package/dist/model/strategy/adapter/walletPass/index.js +5 -5
- package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/dist/model/strategy/adapter/walletPass/utils.js +24 -96
- package/dist/model/strategy/strategy-example.js +19 -5
- package/dist/modules/BaseModule.d.ts +2 -2
- package/dist/modules/BaseModule.js +12 -14
- package/dist/modules/BookingContext/index.d.ts +48 -0
- package/dist/modules/BookingContext/index.js +566 -0
- package/dist/modules/BookingContext/types.d.ts +102 -0
- package/dist/modules/BookingContext/types.js +51 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +302 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +149 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +249 -0
- package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/dist/modules/BookingContext/utils/flexible.js +56 -0
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
- package/dist/modules/BookingContext/utils/index.d.ts +11 -0
- package/dist/modules/BookingContext/utils/index.js +11 -0
- package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/dist/modules/BookingContext/utils/noResource.js +77 -0
- package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/dist/modules/BookingContext/utils/orderLineDisplay.js +36 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/dist/modules/BookingContext/utils/productExtend.js +339 -0
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
- package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
- package/dist/modules/BookingContext/utils/resources.js +486 -0
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
- package/dist/modules/Cart/index.js +3 -0
- package/dist/modules/Cart/utils/cartProduct.js +27 -5
- package/dist/modules/Cart/utils/cartResource.js +0 -2
- package/dist/modules/Cart/utils/changePrice.js +11 -11
- package/dist/modules/Customer/index.d.ts +20 -0
- package/dist/modules/Customer/index.js +172 -83
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Date/index.js +5 -1
- package/dist/modules/Discount/index.d.ts +2 -2
- package/dist/modules/Discount/index.js +43 -30
- package/dist/modules/Discount/types.d.ts +1 -1
- package/dist/modules/OpenData/index.d.ts +8 -0
- package/dist/modules/OpenData/index.js +38 -16
- package/dist/modules/Order/index.d.ts +449 -24
- package/dist/modules/Order/index.js +5460 -574
- package/dist/modules/Order/types.d.ts +693 -88
- package/dist/modules/Order/types.js +68 -1
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/dist/modules/Order/utils/manualProductDiscount.js +210 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
- package/dist/modules/Order/utils.d.ts +167 -18
- package/dist/modules/Order/utils.js +960 -165
- package/dist/modules/Payment/index.d.ts +10 -9
- package/dist/modules/Payment/index.js +573 -746
- package/dist/modules/Payment/types.d.ts +44 -24
- package/dist/modules/Payment/utils.d.ts +1 -1
- package/dist/modules/Payment/utils.js +4 -3
- package/dist/modules/Payment/walletpass.d.ts +0 -2
- package/dist/modules/Payment/walletpass.js +49 -33
- package/dist/modules/Product/types.d.ts +29 -7
- package/dist/modules/ProductList/index.d.ts +17 -13
- package/dist/modules/ProductList/index.js +182 -81
- package/dist/modules/ProductList/types.d.ts +16 -0
- package/dist/modules/Quotation/index.d.ts +22 -2
- package/dist/modules/Quotation/index.js +108 -42
- package/dist/modules/Quotation/types.d.ts +19 -0
- package/dist/modules/ResourcePlanner/index.d.ts +24 -0
- package/dist/modules/ResourcePlanner/index.js +181 -0
- package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
- package/dist/modules/ResourcePlanner/planner.js +1069 -0
- package/dist/modules/ResourcePlanner/types.d.ts +227 -0
- package/dist/modules/ResourcePlanner/types.js +1 -0
- package/dist/modules/Rules/index.d.ts +8 -10
- package/dist/modules/Rules/index.js +324 -513
- package/dist/modules/Rules/types.d.ts +14 -3
- package/dist/modules/SalesSummary/index.d.ts +23 -26
- package/dist/modules/SalesSummary/index.js +152 -46
- package/dist/modules/SalesSummary/types.d.ts +9 -1
- package/dist/modules/SalesSummary/utils.d.ts +3 -22
- package/dist/modules/SalesSummary/utils.js +804 -165
- package/dist/modules/Schedule/getDateIsInSchedule.js +14 -12
- package/dist/modules/Schedule/index.d.ts +18 -5
- package/dist/modules/Schedule/index.js +79 -24
- package/dist/modules/Schedule/types.d.ts +2 -0
- package/dist/modules/Schedule/utils.js +1 -0
- package/dist/modules/Step/index.js +1 -0
- package/dist/modules/Summary/index.js +4 -3
- package/dist/modules/Summary/utils.js +22 -43
- package/dist/modules/SurchargeList/index.d.ts +18 -0
- package/dist/modules/SurchargeList/index.js +185 -0
- package/dist/modules/SurchargeList/types.d.ts +15 -0
- package/dist/modules/SurchargeList/types.js +1 -0
- package/dist/modules/index.d.ts +3 -0
- package/dist/modules/index.js +4 -1
- package/dist/plugins/app.d.ts +2 -0
- package/dist/plugins/request.d.ts +1 -0
- package/dist/plugins/request.js +4 -1
- package/dist/plugins/window.js +6 -2
- package/dist/server/index.d.ts +462 -8
- package/dist/server/index.js +6168 -680
- package/dist/server/modules/floor-plan/index.d.ts +39 -0
- package/dist/server/modules/floor-plan/index.js +595 -0
- package/dist/server/modules/floor-plan/types.d.ts +43 -0
- package/dist/server/modules/floor-plan/types.js +13 -0
- package/dist/server/modules/index.d.ts +7 -2
- package/dist/server/modules/index.js +6 -0
- package/dist/server/modules/menu/index.js +41 -32
- package/dist/server/modules/order/index.d.ts +207 -14
- package/dist/server/modules/order/index.js +2328 -379
- package/dist/server/modules/order/types.d.ts +76 -5
- package/dist/server/modules/order/types.js +14 -1
- package/dist/server/modules/order/utils/filterBookings.d.ts +7 -1
- package/dist/server/modules/order/utils/filterBookings.js +118 -11
- package/dist/server/modules/order/utils/filterOrders.js +242 -14
- package/dist/server/modules/payment/index.d.ts +28 -0
- package/dist/server/modules/payment/index.js +305 -0
- package/dist/server/modules/payment/types.d.ts +9 -0
- package/dist/server/modules/payment/types.js +1 -0
- package/dist/server/modules/products/index.d.ts +105 -14
- package/dist/server/modules/products/index.js +1416 -521
- package/dist/server/modules/products/types.d.ts +34 -1
- package/dist/server/modules/products/types.js +4 -0
- package/dist/server/modules/quotation/index.d.ts +39 -0
- package/dist/server/modules/quotation/index.js +298 -77
- package/dist/server/modules/resource/index.d.ts +2 -3
- package/dist/server/modules/resource/index.js +109 -86
- package/dist/server/modules/schedule/index.d.ts +6 -4
- package/dist/server/modules/schedule/index.js +145 -106
- package/dist/server/test.json +713 -0
- package/dist/server/types.d.ts +2 -0
- package/dist/server/utils/product.js +3 -2
- package/dist/server/utils/small-ticket.d.ts +71 -0
- package/dist/server/utils/small-ticket.js +963 -0
- package/dist/solution/BaseSales/index.d.ts +378 -0
- package/dist/solution/BaseSales/index.js +4009 -0
- package/dist/solution/BaseSales/types.d.ts +394 -0
- package/dist/solution/BaseSales/types.js +40 -0
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
- package/dist/solution/BaseSales/utils/cartPromotion.js +1450 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +144 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +157 -0
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +18 -0
- package/dist/solution/BaseSales/utils/quotationPrice.js +250 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +63 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +218 -0
- package/dist/solution/BaseSales/utils.d.ts +40 -0
- package/dist/solution/BaseSales/utils.js +263 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +60 -11
- package/dist/solution/BookingByStep/utils/capacity.js +11 -1
- package/dist/solution/BookingByStep/utils/resources.js +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +43 -2
- package/dist/solution/BookingTicket/index.d.ts +393 -24
- package/dist/solution/BookingTicket/index.js +2508 -443
- package/dist/solution/BookingTicket/types.d.ts +191 -6
- package/dist/solution/BookingTicket/types.js +83 -10
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
- package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
- package/dist/solution/BookingTicket/utils/addTimeAvailability.js +95 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.js +136 -0
- package/dist/solution/BookingTicket/utils/cartView.d.ts +29 -0
- package/dist/solution/BookingTicket/utils/cartView.js +209 -0
- package/dist/solution/BookingTicket/utils/exampleData.d.ts +123 -0
- package/dist/solution/BookingTicket/utils/exampleData.js +183 -0
- package/dist/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
- package/dist/solution/BookingTicket/utils/orderCustomer.js +31 -0
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +438 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +400 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +4 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +42 -1
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +56 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +42 -28
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +30 -14
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +150 -0
- package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
- package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +78 -0
- package/dist/solution/BuyTickets/index.js +12 -9
- package/dist/solution/Checkout/index.d.ts +1 -0
- package/dist/solution/Checkout/index.js +275 -209
- package/dist/solution/Checkout/utils/index.js +20 -8
- package/dist/solution/RegisterAndLogin/config.js +2 -10
- package/dist/solution/RegisterAndLogin/index.js +76 -30
- package/dist/solution/Sales/index.d.ts +50 -5
- package/dist/solution/Sales/index.js +484 -92
- package/dist/solution/Sales/types.d.ts +26 -2
- package/dist/solution/ScanOrder/index.d.ts +27 -21
- package/dist/solution/ScanOrder/index.js +519 -444
- package/dist/solution/ScanOrder/types.d.ts +33 -11
- package/dist/solution/ScanOrder/types.js +4 -5
- package/dist/solution/ScanOrder/utils.d.ts +4 -1
- package/dist/solution/ScanOrder/utils.js +109 -34
- package/dist/solution/ShopDiscount/index.js +18 -19
- package/dist/solution/ShopDiscount/types.d.ts +4 -5
- package/dist/solution/ShopDiscount/utils.d.ts +0 -9
- package/dist/solution/ShopDiscount/utils.js +0 -9
- package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/dist/solution/UnifiedBookingSales/index.js +1871 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/dist/solution/UnifiedBookingSales/types.js +11 -0
- package/dist/solution/VenueBooking/index.d.ts +32 -51
- package/dist/solution/VenueBooking/index.js +741 -808
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/dist/solution/VenueBooking/types.d.ts +1 -3
- package/dist/solution/VenueBooking/types.js +0 -1
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +9 -3
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -1
- package/dist/types/index.d.ts +12 -2
- package/dist/utils/task.js +18 -15
- package/dist/utils/watch.js +1 -0
- package/lib/apis/picoding.js +0 -2
- package/lib/core/index.js +132 -130
- package/lib/effects/index.js +57 -46
- package/lib/index.d.ts +0 -1
- package/lib/index.js +50 -92
- package/lib/model/index.js +21 -14
- package/lib/model/strategy/adapter/dataVariant/adapter.js +50 -38
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +236 -162
- package/lib/model/strategy/adapter/dataVariant/examples.js +237 -229
- package/lib/model/strategy/adapter/dataVariant/index.js +34 -39
- package/lib/model/strategy/adapter/dataVariant/type.js +28 -57
- package/lib/model/strategy/adapter/index.js +64 -100
- package/lib/model/strategy/adapter/itemRule/adapter.js +144 -156
- package/lib/model/strategy/adapter/itemRule/evaluator.js +48 -36
- package/lib/model/strategy/adapter/itemRule/examples.js +225 -295
- package/lib/model/strategy/adapter/itemRule/index.js +57 -83
- package/lib/model/strategy/adapter/itemRule/type.js +36 -97
- package/lib/model/strategy/adapter/promotion/adapter.js +63 -84
- package/lib/model/strategy/adapter/promotion/evaluator.js +233 -382
- package/lib/model/strategy/adapter/promotion/examples.js +159 -139
- package/lib/model/strategy/adapter/promotion/index.js +0 -1
- package/lib/model/strategy/adapter/promotion/type.js +35 -199
- package/lib/model/strategy/adapter/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/evaluator.js +152 -180
- package/lib/model/strategy/adapter/walletPass/example.js +190 -217
- package/lib/model/strategy/adapter/walletPass/index.js +51 -75
- package/lib/model/strategy/adapter/walletPass/locales.js +58 -36
- package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/lib/model/strategy/adapter/walletPass/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/lib/model/strategy/adapter/walletPass/utils.js +383 -676
- package/lib/model/strategy/engine.js +168 -270
- package/lib/model/strategy/index.js +34 -49
- package/lib/model/strategy/strategy-example.js +239 -243
- package/lib/model/strategy/type.js +40 -100
- package/lib/modules/Account/index.js +53 -39
- package/lib/modules/Account/types.js +33 -20
- package/lib/modules/AccountList/index.js +154 -116
- package/lib/modules/AccountList/types.js +31 -30
- package/lib/modules/AccountList/utils.js +30 -18
- package/lib/modules/BaseModule.d.ts +2 -2
- package/lib/modules/BaseModule.js +50 -29
- package/lib/modules/BookingContext/index.d.ts +48 -0
- package/lib/modules/BookingContext/index.js +368 -0
- package/lib/modules/BookingContext/types.d.ts +102 -0
- package/lib/modules/BookingContext/types.js +34 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +298 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +155 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +222 -0
- package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/lib/modules/BookingContext/utils/flexible.js +80 -0
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
- package/lib/modules/BookingContext/utils/index.d.ts +11 -0
- package/lib/modules/BookingContext/utils/index.js +43 -0
- package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/lib/modules/BookingContext/utils/noResource.js +90 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +56 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/lib/modules/BookingContext/utils/productExtend.js +283 -0
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
- package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
- package/lib/modules/BookingContext/utils/resources.js +377 -0
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
- package/lib/modules/Cart/index.js +124 -170
- package/lib/modules/Cart/types.js +51 -46
- package/lib/modules/Cart/utils/cartAccount.js +39 -40
- package/lib/modules/Cart/utils/cartDate.js +61 -56
- package/lib/modules/Cart/utils/cartDiscount.js +33 -28
- package/lib/modules/Cart/utils/cartNote.js +32 -27
- package/lib/modules/Cart/utils/cartProduct.js +261 -309
- package/lib/modules/Cart/utils/cartRelationForms.js +35 -29
- package/lib/modules/Cart/utils/cartResource.js +78 -72
- package/lib/modules/Cart/utils/changePrice.js +59 -31
- package/lib/modules/Cart/utils/index.js +48 -106
- package/lib/modules/Customer/constants.js +34 -13
- package/lib/modules/Customer/index.d.ts +20 -0
- package/lib/modules/Customer/index.js +207 -217
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Customer/types.js +35 -38
- package/lib/modules/Date/index.js +115 -116
- package/lib/modules/Date/types.js +28 -16
- package/lib/modules/Date/utils.js +123 -174
- package/lib/modules/Discount/index.d.ts +2 -2
- package/lib/modules/Discount/index.js +133 -119
- package/lib/modules/Discount/types.d.ts +1 -1
- package/lib/modules/Discount/types.js +31 -9
- package/lib/modules/Guests/index.js +56 -30
- package/lib/modules/Guests/types.js +33 -23
- package/lib/modules/Holder/index.js +189 -209
- package/lib/modules/Holder/types.js +16 -4
- package/lib/modules/Holder/utils.js +49 -20
- package/lib/modules/OpenData/index.d.ts +8 -0
- package/lib/modules/OpenData/index.js +88 -63
- package/lib/modules/OpenData/types.js +16 -4
- package/lib/modules/OpenData/utils.js +78 -44
- package/lib/modules/Order/index.d.ts +449 -24
- package/lib/modules/Order/index.js +4184 -514
- package/lib/modules/Order/types.d.ts +693 -88
- package/lib/modules/Order/types.js +35 -24
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/lib/modules/Order/utils/bundleDiscountHydration.js +139 -0
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/lib/modules/Order/utils/manualProductDiscount.js +206 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +415 -0
- package/lib/modules/Order/utils.d.ts +167 -18
- package/lib/modules/Order/utils.js +1085 -414
- package/lib/modules/Payment/cash.js +33 -20
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +76 -145
- package/lib/modules/Payment/eftpos.js +30 -16
- package/lib/modules/Payment/index.d.ts +10 -9
- package/lib/modules/Payment/index.js +402 -636
- package/lib/modules/Payment/mx51.js +0 -1
- package/lib/modules/Payment/types.d.ts +44 -24
- package/lib/modules/Payment/types.js +107 -216
- package/lib/modules/Payment/utils.d.ts +1 -1
- package/lib/modules/Payment/utils.js +50 -52
- package/lib/modules/Payment/walletpass.d.ts +0 -2
- package/lib/modules/Payment/walletpass.js +216 -221
- package/lib/modules/Product/index.js +46 -51
- package/lib/modules/Product/types.d.ts +29 -7
- package/lib/modules/Product/types.js +16 -4
- package/lib/modules/Product/utils.js +33 -32
- package/lib/modules/ProductList/index.d.ts +17 -13
- package/lib/modules/ProductList/index.js +161 -120
- package/lib/modules/ProductList/types.d.ts +16 -0
- package/lib/modules/ProductList/types.js +31 -9
- package/lib/modules/Quotation/index.d.ts +22 -2
- package/lib/modules/Quotation/index.js +154 -64
- package/lib/modules/Quotation/types.d.ts +19 -0
- package/lib/modules/Quotation/types.js +16 -4
- package/lib/modules/Resource/index.js +59 -27
- package/lib/modules/Resource/types.js +32 -22
- package/lib/modules/Resource/utils.js +38 -30
- package/lib/modules/ResourcePlanner/index.d.ts +24 -0
- package/lib/modules/ResourcePlanner/index.js +148 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
- package/lib/modules/ResourcePlanner/planner.js +933 -0
- package/lib/modules/ResourcePlanner/types.d.ts +227 -0
- package/lib/modules/ResourcePlanner/types.js +17 -0
- package/lib/modules/Rules/index.d.ts +8 -10
- package/lib/modules/Rules/index.js +960 -1440
- package/lib/modules/Rules/types.d.ts +14 -3
- package/lib/modules/Rules/types.js +40 -17
- package/lib/modules/SalesSummary/index.d.ts +23 -26
- package/lib/modules/SalesSummary/index.js +134 -61
- package/lib/modules/SalesSummary/types.d.ts +9 -1
- package/lib/modules/SalesSummary/types.js +16 -4
- package/lib/modules/SalesSummary/utils.d.ts +3 -22
- package/lib/modules/SalesSummary/utils.js +814 -233
- package/lib/modules/ScanOrderLogger/index.js +79 -59
- package/lib/modules/ScanOrderLogger/providers/feishu.js +78 -54
- package/lib/modules/ScanOrderLogger/providers/grafana.js +36 -13
- package/lib/modules/ScanOrderLogger/types.js +16 -4
- package/lib/modules/Schedule/getDateIsInSchedule.js +169 -338
- package/lib/modules/Schedule/index.d.ts +18 -5
- package/lib/modules/Schedule/index.js +153 -104
- package/lib/modules/Schedule/type.js +16 -4
- package/lib/modules/Schedule/types.d.ts +2 -0
- package/lib/modules/Schedule/types.js +16 -4
- package/lib/modules/Schedule/utils.js +291 -433
- package/lib/modules/Step/index.js +52 -40
- package/lib/modules/Step/tyeps.js +16 -4
- package/lib/modules/Summary/index.js +71 -66
- package/lib/modules/Summary/types.js +16 -4
- package/lib/modules/Summary/utils.js +418 -791
- package/lib/modules/SurchargeList/index.d.ts +18 -0
- package/lib/modules/SurchargeList/index.js +109 -0
- package/lib/modules/SurchargeList/types.d.ts +15 -0
- package/lib/modules/SurchargeList/types.js +17 -0
- package/lib/modules/index.d.ts +3 -0
- package/lib/modules/index.js +63 -212
- package/lib/plugins/app.d.ts +2 -0
- package/lib/plugins/app.js +16 -4
- package/lib/plugins/index.js +25 -36
- package/lib/plugins/request.d.ts +1 -0
- package/lib/plugins/request.js +126 -137
- package/lib/plugins/shopStore.js +16 -4
- package/lib/plugins/user.js +16 -4
- package/lib/plugins/window.js +179 -171
- package/lib/server/index.d.ts +462 -8
- package/lib/server/index.js +4520 -1162
- package/lib/server/modules/floor-plan/index.d.ts +39 -0
- package/lib/server/modules/floor-plan/index.js +327 -0
- package/lib/server/modules/floor-plan/types.d.ts +43 -0
- package/lib/server/modules/floor-plan/types.js +34 -0
- package/lib/server/modules/index.d.ts +7 -2
- package/lib/server/modules/index.js +67 -84
- package/lib/server/modules/menu/index.js +122 -146
- package/lib/server/modules/menu/types.js +31 -18
- package/lib/server/modules/order/index.d.ts +207 -14
- package/lib/server/modules/order/index.js +1543 -285
- package/lib/server/modules/order/types.d.ts +76 -5
- package/lib/server/modules/order/types.js +32 -107
- package/lib/server/modules/order/utils/filterBookings.d.ts +7 -1
- package/lib/server/modules/order/utils/filterBookings.js +259 -176
- package/lib/server/modules/order/utils/filterOrders.js +293 -94
- package/lib/server/modules/payment/index.d.ts +28 -0
- package/lib/server/modules/payment/index.js +192 -0
- package/lib/server/modules/payment/types.d.ts +9 -0
- package/lib/server/modules/payment/types.js +17 -0
- package/lib/server/modules/products/index.d.ts +105 -14
- package/lib/server/modules/products/index.js +850 -475
- package/lib/server/modules/products/types.d.ts +34 -1
- package/lib/server/modules/products/types.js +34 -41
- package/lib/server/modules/quotation/index.d.ts +39 -0
- package/lib/server/modules/quotation/index.js +254 -75
- package/lib/server/modules/quotation/types.js +31 -21
- package/lib/server/modules/resource/index.d.ts +2 -3
- package/lib/server/modules/resource/index.js +240 -243
- package/lib/server/modules/resource/types.js +33 -42
- package/lib/server/modules/schedule/index.d.ts +6 -4
- package/lib/server/modules/schedule/index.js +146 -147
- package/lib/server/modules/schedule/types.js +21 -14
- package/lib/server/modules/schedule/utils.js +163 -334
- package/lib/server/test.json +713 -0
- package/lib/server/types.d.ts +2 -0
- package/lib/server/types.js +16 -4
- package/lib/server/utils/index.js +23 -25
- package/lib/server/utils/product.js +140 -197
- package/lib/server/utils/schedule.js +41 -34
- package/lib/server/utils/small-ticket.d.ts +71 -0
- package/lib/server/utils/small-ticket.js +904 -0
- package/lib/server/utils/time.js +49 -40
- package/lib/solution/BaseSales/index.d.ts +378 -0
- package/lib/solution/BaseSales/index.js +2533 -0
- package/lib/solution/BaseSales/types.d.ts +394 -0
- package/lib/solution/BaseSales/types.js +43 -0
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
- package/lib/solution/BaseSales/utils/cartPromotion.js +1004 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +144 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +160 -0
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +18 -0
- package/lib/solution/BaseSales/utils/quotationPrice.js +289 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +63 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +256 -0
- package/lib/solution/BaseSales/utils.d.ts +40 -0
- package/lib/solution/BaseSales/utils.js +244 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +1340 -1530
- package/lib/solution/BookingByStep/types.js +99 -40
- package/lib/solution/BookingByStep/utils/capacity.js +160 -192
- package/lib/solution/BookingByStep/utils/products.js +52 -42
- package/lib/solution/BookingByStep/utils/resources.js +330 -527
- package/lib/solution/BookingByStep/utils/stock.js +44 -65
- package/lib/solution/BookingByStep/utils/timeslots.js +131 -129
- package/lib/solution/BookingTicket/index.d.ts +393 -24
- package/lib/solution/BookingTicket/index.js +1374 -184
- package/lib/solution/BookingTicket/types.d.ts +191 -6
- package/lib/solution/BookingTicket/types.js +79 -40
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
- package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +125 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.js +107 -0
- package/lib/solution/BookingTicket/utils/cartView.d.ts +29 -0
- package/lib/solution/BookingTicket/utils/cartView.js +184 -0
- package/lib/solution/BookingTicket/utils/exampleData.d.ts +123 -0
- package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +58 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +254 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +169 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +97 -64
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +51 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +81 -82
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +109 -91
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +43 -90
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +127 -0
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +85 -0
- package/lib/solution/BuyTickets/index.js +70 -67
- package/lib/solution/BuyTickets/types.js +38 -22
- package/lib/solution/Checkout/index.d.ts +1 -0
- package/lib/solution/Checkout/index.js +1169 -1463
- package/lib/solution/Checkout/types.js +61 -91
- package/lib/solution/Checkout/utils/index.js +156 -228
- package/lib/solution/PlaceOrder/index.js +0 -55
- package/lib/solution/RegisterAndLogin/config.js +462 -503
- package/lib/solution/RegisterAndLogin/index.js +630 -633
- package/lib/solution/RegisterAndLogin/types.js +76 -189
- package/lib/solution/RegisterAndLogin/utils.js +125 -183
- package/lib/solution/Sales/index.d.ts +50 -5
- package/lib/solution/Sales/index.js +498 -238
- package/lib/solution/Sales/types.d.ts +26 -2
- package/lib/solution/Sales/types.js +33 -27
- package/lib/solution/ScanOrder/index.d.ts +27 -21
- package/lib/solution/ScanOrder/index.js +936 -864
- package/lib/solution/ScanOrder/types.d.ts +33 -11
- package/lib/solution/ScanOrder/types.js +34 -34
- package/lib/solution/ScanOrder/utils.d.ts +4 -1
- package/lib/solution/ScanOrder/utils.js +422 -385
- package/lib/solution/ShopDiscount/index.js +233 -235
- package/lib/solution/ShopDiscount/types.d.ts +4 -5
- package/lib/solution/ShopDiscount/types.js +37 -15
- package/lib/solution/ShopDiscount/utils.d.ts +0 -9
- package/lib/solution/ShopDiscount/utils.js +172 -309
- package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/lib/solution/UnifiedBookingSales/index.js +1076 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/lib/solution/UnifiedBookingSales/types.js +33 -0
- package/lib/solution/VenueBooking/index.d.ts +32 -51
- package/lib/solution/VenueBooking/index.js +1008 -984
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/lib/solution/VenueBooking/types.d.ts +1 -3
- package/lib/solution/VenueBooking/types.js +39 -20
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/lib/solution/VenueBooking/utils/dateSummary.js +62 -25
- package/lib/solution/VenueBooking/utils/resource.js +54 -31
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +109 -90
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/lib/solution/VenueBooking/utils/timeSlot.js +133 -138
- package/lib/solution/VenueBooking/utils.js +67 -130
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +41 -102
- package/lib/store/createStore.js +29 -32
- package/lib/types/index.d.ts +12 -2
- package/lib/types/index.js +16 -4
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +47 -81
- package/package.json +2 -4
- package/dist/solution/Checkout/appointmentDemo.json +0 -1
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
- package/lib/solution/Checkout/appointmentDemo.json +0 -1
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/lib/solution/VenueBooking/utils/smartPricing.js +0 -192
|
@@ -1,93 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
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;
|
|
8
18
|
};
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/solution/ScanOrder/index.ts
|
|
31
|
+
var ScanOrder_exports = {};
|
|
32
|
+
__export(ScanOrder_exports, {
|
|
33
|
+
ScanOrderImpl: () => ScanOrderImpl
|
|
22
34
|
});
|
|
23
|
-
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
35
|
+
module.exports = __toCommonJS(ScanOrder_exports);
|
|
36
|
+
var import_BaseSales = require("../BaseSales");
|
|
37
|
+
var import_types = require("./types");
|
|
38
|
+
var import_Order = require("../../modules/Order");
|
|
39
|
+
var import_types2 = require("../../modules/Account/types");
|
|
40
|
+
var import_types3 = require("../RegisterAndLogin/types");
|
|
41
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
42
|
+
var import_utils = require("./utils");
|
|
43
|
+
var import_types4 = require("../BookingByStep/types");
|
|
44
|
+
var import_ProductList = require("../../modules/ProductList");
|
|
45
|
+
var import_getDateIsInSchedule = require("../../modules/Schedule/getDateIsInSchedule");
|
|
46
|
+
var import_utils2 = require("../../modules/Order/utils");
|
|
47
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
48
|
+
var import_itemRule = require("../../model/strategy/adapter/itemRule");
|
|
49
|
+
__reExport(ScanOrder_exports, require("./types"), module.exports);
|
|
50
|
+
var _ScanOrderImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
51
|
+
constructor(name, version) {
|
|
52
|
+
super(name, version);
|
|
53
|
+
this.defaultName = "scanOrder";
|
|
54
|
+
this.defaultVersion = "1.0.0";
|
|
55
|
+
this.isSolution = true;
|
|
56
|
+
this.initializeOptions = {};
|
|
57
|
+
this.store = {
|
|
58
|
+
entryContext: null,
|
|
59
|
+
status: "idle",
|
|
60
|
+
config: null,
|
|
61
|
+
resource: null,
|
|
62
|
+
flow: {},
|
|
63
|
+
error: null,
|
|
64
|
+
products: void 0,
|
|
65
|
+
itemRuleQuantityLimits: [],
|
|
66
|
+
cartValidation: {
|
|
67
|
+
passed: null,
|
|
68
|
+
failures: []
|
|
69
|
+
},
|
|
70
|
+
entryPaxNumber: 1
|
|
71
|
+
};
|
|
72
|
+
this.otherParams = {};
|
|
73
|
+
this.itemRuleEvaluator = new import_itemRule.ItemRuleEvaluator();
|
|
74
|
+
this.itemRuleConfigs = [];
|
|
75
|
+
this.itemRuleConfigsPromise = null;
|
|
76
|
+
this.itemRulePrefillApplied = false;
|
|
77
|
+
this.itemRuleRuntimeConfig = {};
|
|
78
|
+
/** 最近一次 checkResourceAvailable 从预约规则 link 拉取的商品快照 */
|
|
79
|
+
this.enabledReservationRuleProducts = [];
|
|
80
|
+
this.loginEffectDisposers = [];
|
|
81
|
+
this.customerLoginRefreshInFlight = null;
|
|
82
|
+
this.customerLoginRefreshIdInFlight = null;
|
|
83
|
+
}
|
|
71
84
|
getScanOrderLoggerContext() {
|
|
72
85
|
return {
|
|
73
86
|
cacheId: this.cacheId,
|
|
74
87
|
solutionName: this.name,
|
|
75
|
-
moduleName:
|
|
88
|
+
moduleName: "scanOrder"
|
|
76
89
|
};
|
|
77
90
|
}
|
|
78
91
|
safeStringify(value) {
|
|
79
92
|
try {
|
|
80
93
|
return JSON.stringify(value);
|
|
81
94
|
} catch {
|
|
82
|
-
return
|
|
95
|
+
return void 0;
|
|
83
96
|
}
|
|
84
97
|
}
|
|
85
98
|
pickErrorMessage(error) {
|
|
86
|
-
|
|
99
|
+
var _a, _b, _c, _d;
|
|
100
|
+
const candidates = [
|
|
101
|
+
error.message,
|
|
102
|
+
(_a = error.data) == null ? void 0 : _a.message,
|
|
103
|
+
(_c = (_b = error.response) == null ? void 0 : _b.data) == null ? void 0 : _c.message,
|
|
104
|
+
(_d = error.error) == null ? void 0 : _d.message
|
|
105
|
+
];
|
|
87
106
|
for (const candidate of candidates) {
|
|
88
|
-
if (typeof candidate ===
|
|
107
|
+
if (typeof candidate === "string" && candidate.trim())
|
|
108
|
+
return candidate;
|
|
89
109
|
}
|
|
90
|
-
return
|
|
110
|
+
return void 0;
|
|
91
111
|
}
|
|
92
112
|
serializeError(error) {
|
|
93
113
|
if (error instanceof Error) {
|
|
@@ -97,23 +117,15 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
97
117
|
stack: error.stack
|
|
98
118
|
};
|
|
99
119
|
}
|
|
100
|
-
if (error && typeof error ===
|
|
120
|
+
if (error && typeof error === "object") {
|
|
101
121
|
const raw = error;
|
|
102
122
|
const message = this.pickErrorMessage(raw) || this.safeStringify(raw) || String(error);
|
|
103
123
|
return {
|
|
104
|
-
...
|
|
105
|
-
name: raw.name
|
|
106
|
-
} : {}),
|
|
124
|
+
...typeof raw.name === "string" ? { name: raw.name } : {},
|
|
107
125
|
message,
|
|
108
|
-
...
|
|
109
|
-
|
|
110
|
-
} : {}
|
|
111
|
-
...('status' in raw ? {
|
|
112
|
-
status: raw.status
|
|
113
|
-
} : {}),
|
|
114
|
-
...(this.safeStringify(raw) ? {
|
|
115
|
-
raw: this.safeStringify(raw)
|
|
116
|
-
} : {})
|
|
126
|
+
..."code" in raw ? { code: raw.code } : {},
|
|
127
|
+
..."status" in raw ? { status: raw.status } : {},
|
|
128
|
+
...this.safeStringify(raw) ? { raw: this.safeStringify(raw) } : {}
|
|
117
129
|
};
|
|
118
130
|
}
|
|
119
131
|
return {
|
|
@@ -123,19 +135,18 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
123
135
|
async addScanOrderLog(params) {
|
|
124
136
|
const payload = {
|
|
125
137
|
cacheId: this.cacheId,
|
|
126
|
-
...
|
|
138
|
+
...params.payload || {}
|
|
127
139
|
};
|
|
128
140
|
const extra = {
|
|
129
|
-
...
|
|
141
|
+
...params.extra || {}
|
|
130
142
|
};
|
|
131
143
|
const logger = this.store.scanOrderLogger;
|
|
132
144
|
if (!logger) {
|
|
133
|
-
if ((params.level ||
|
|
134
|
-
console.error(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
} else {}
|
|
145
|
+
if ((params.level || "info") === "error") {
|
|
146
|
+
console.error("[ScanOrder][log-fallback]", params.title, { payload, extra });
|
|
147
|
+
} else {
|
|
148
|
+
console.log("[ScanOrder][log-fallback]", params.title, { payload, extra });
|
|
149
|
+
}
|
|
139
150
|
return;
|
|
140
151
|
}
|
|
141
152
|
await logger.addLog({
|
|
@@ -146,7 +157,7 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
146
157
|
}
|
|
147
158
|
logMethodStart(method, payload = {}) {
|
|
148
159
|
void this.addScanOrderLog({
|
|
149
|
-
level:
|
|
160
|
+
level: "info",
|
|
150
161
|
title: `[ScanOrder] ${method} start`,
|
|
151
162
|
payload: {
|
|
152
163
|
method,
|
|
@@ -156,7 +167,7 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
156
167
|
}
|
|
157
168
|
logMethodSuccess(method, payload = {}) {
|
|
158
169
|
void this.addScanOrderLog({
|
|
159
|
-
level:
|
|
170
|
+
level: "info",
|
|
160
171
|
title: `[ScanOrder] ${method} success`,
|
|
161
172
|
payload: {
|
|
162
173
|
method,
|
|
@@ -166,7 +177,7 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
166
177
|
}
|
|
167
178
|
logMethodError(method, error, payload = {}) {
|
|
168
179
|
void this.addScanOrderLog({
|
|
169
|
-
level:
|
|
180
|
+
level: "error",
|
|
170
181
|
title: `[ScanOrder] ${method} failed`,
|
|
171
182
|
payload: {
|
|
172
183
|
method,
|
|
@@ -176,8 +187,9 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
176
187
|
});
|
|
177
188
|
}
|
|
178
189
|
assertProductListLoaded(method, result, payload = {}) {
|
|
179
|
-
if (Array.isArray(result))
|
|
180
|
-
|
|
190
|
+
if (Array.isArray(result))
|
|
191
|
+
return result;
|
|
192
|
+
const error = result instanceof Error ? result : new Error("商品列表接口返回异常");
|
|
181
193
|
this.logMethodError(method, error, payload);
|
|
182
194
|
error.__scanOrderLogged = true;
|
|
183
195
|
throw error;
|
|
@@ -186,21 +198,36 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
186
198
|
await this.addScanOrderLog({
|
|
187
199
|
...params,
|
|
188
200
|
payload: {
|
|
189
|
-
source:
|
|
190
|
-
...
|
|
201
|
+
source: "ui-bridge",
|
|
202
|
+
...params.payload || {}
|
|
191
203
|
}
|
|
192
204
|
});
|
|
193
205
|
}
|
|
194
206
|
normalizeCustomerId(value) {
|
|
195
207
|
const customerId = Number(value);
|
|
196
|
-
if (!Number.isFinite(customerId) || customerId <= 0)
|
|
208
|
+
if (!Number.isFinite(customerId) || customerId <= 0)
|
|
209
|
+
return null;
|
|
197
210
|
return customerId;
|
|
198
211
|
}
|
|
199
212
|
resolveCustomerIdFromLoginPayload(payload) {
|
|
200
|
-
|
|
213
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
214
|
+
const candidates = [
|
|
215
|
+
payload == null ? void 0 : payload.customerId,
|
|
216
|
+
payload == null ? void 0 : payload.customer_id,
|
|
217
|
+
payload == null ? void 0 : payload.id,
|
|
218
|
+
(_a = payload == null ? void 0 : payload.user) == null ? void 0 : _a.customerId,
|
|
219
|
+
(_b = payload == null ? void 0 : payload.user) == null ? void 0 : _b.customer_id,
|
|
220
|
+
(_c = payload == null ? void 0 : payload.user) == null ? void 0 : _c.id,
|
|
221
|
+
(_e = (_d = payload == null ? void 0 : payload.user) == null ? void 0 : _d._origin) == null ? void 0 : _e.customer_id,
|
|
222
|
+
(_f = payload == null ? void 0 : payload.account) == null ? void 0 : _f.customerId,
|
|
223
|
+
(_g = payload == null ? void 0 : payload.account) == null ? void 0 : _g.customer_id,
|
|
224
|
+
(_h = payload == null ? void 0 : payload.account) == null ? void 0 : _h.id,
|
|
225
|
+
(_i = payload == null ? void 0 : payload._origin) == null ? void 0 : _i.customer_id
|
|
226
|
+
];
|
|
201
227
|
for (const candidate of candidates) {
|
|
202
228
|
const customerId = this.normalizeCustomerId(candidate);
|
|
203
|
-
if (customerId)
|
|
229
|
+
if (customerId)
|
|
230
|
+
return customerId;
|
|
204
231
|
}
|
|
205
232
|
return null;
|
|
206
233
|
}
|
|
@@ -211,30 +238,38 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
211
238
|
this.loginEffectDisposers = [];
|
|
212
239
|
}
|
|
213
240
|
registerLoginEffect(event, callback) {
|
|
214
|
-
|
|
215
|
-
|
|
241
|
+
var _a;
|
|
242
|
+
const effects = (_a = this.core) == null ? void 0 : _a.effects;
|
|
243
|
+
if (!(effects == null ? void 0 : effects.on))
|
|
244
|
+
return;
|
|
216
245
|
effects.on(event, callback);
|
|
217
246
|
this.loginEffectDisposers.push(() => {
|
|
218
|
-
if (typeof effects.off ===
|
|
247
|
+
if (typeof effects.off === "function") {
|
|
219
248
|
effects.off(event, callback);
|
|
220
249
|
}
|
|
221
250
|
});
|
|
222
251
|
}
|
|
223
252
|
registerCustomerLoginListeners() {
|
|
224
253
|
this.clearLoginEffectListeners();
|
|
225
|
-
const createHandleLogin = () => async payload => {
|
|
254
|
+
const createHandleLogin = () => async (payload) => {
|
|
226
255
|
const customerId = this.resolveCustomerIdFromLoginPayload(payload);
|
|
227
|
-
if (!customerId)
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
});
|
|
256
|
+
if (!customerId)
|
|
257
|
+
return;
|
|
258
|
+
await this.refreshOrderMarketingAfterLogin({ customerId });
|
|
231
259
|
};
|
|
232
|
-
this.registerLoginEffect(
|
|
233
|
-
|
|
234
|
-
|
|
260
|
+
this.registerLoginEffect(
|
|
261
|
+
_ScanOrderImpl.PISELL1_LOGIN_SUCCESS,
|
|
262
|
+
createHandleLogin()
|
|
263
|
+
);
|
|
264
|
+
this.registerLoginEffect(import_types2.AccountHooks.OnLogin, createHandleLogin());
|
|
265
|
+
this.registerLoginEffect(
|
|
266
|
+
import_types3.RegisterAndLoginHooks.onLoginSuccess,
|
|
267
|
+
createHandleLogin()
|
|
268
|
+
);
|
|
235
269
|
}
|
|
236
270
|
async refreshOrderMarketingAfterLogin(params) {
|
|
237
|
-
if (!this.store.order)
|
|
271
|
+
if (!this.store.order)
|
|
272
|
+
throw new Error("order 模块未初始化");
|
|
238
273
|
if (this.customerLoginRefreshInFlight) {
|
|
239
274
|
if (this.customerLoginRefreshIdInFlight === params.customerId) {
|
|
240
275
|
await this.customerLoginRefreshInFlight;
|
|
@@ -247,9 +282,7 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
247
282
|
await this.store.order.loadDiscountConfig({
|
|
248
283
|
customerId: params.customerId
|
|
249
284
|
});
|
|
250
|
-
await this.store.order.recalculateSummary({
|
|
251
|
-
createIfMissing: true
|
|
252
|
-
});
|
|
285
|
+
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
253
286
|
this.store.order.persistTempOrder();
|
|
254
287
|
await this.refreshItemRuleQuantityLimits();
|
|
255
288
|
await this.refreshCartValidationPassed();
|
|
@@ -266,34 +299,29 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
266
299
|
}
|
|
267
300
|
}
|
|
268
301
|
}
|
|
269
|
-
|
|
270
|
-
|
|
302
|
+
getRegisteredModuleNames() {
|
|
303
|
+
return ["scanOrderLogger", "products", "order", "salesSummary", "schedule"];
|
|
304
|
+
}
|
|
305
|
+
createSubModule(moduleName) {
|
|
306
|
+
if (moduleName === "scanOrderLogger") {
|
|
307
|
+
return (0, import_types4.createModule)("scanOrderLogger", this.name);
|
|
308
|
+
}
|
|
309
|
+
return super.createSubModule(moduleName);
|
|
271
310
|
}
|
|
272
|
-
|
|
273
311
|
/** 与 `otherParams.cacheId` 一致,供宿主在 URL 变化时判断是否需要重新注册模块 */
|
|
274
312
|
getCacheId() {
|
|
275
313
|
return this.cacheId;
|
|
276
314
|
}
|
|
277
|
-
async destroyRegisteredChildModules() {
|
|
278
|
-
const modules = [this.store.schedule, this.store.salesSummary, this.store.order, this.store.products, this.store.scanOrderLogger];
|
|
279
|
-
for (const mod of modules) {
|
|
280
|
-
if (mod && typeof mod.destroy === 'function') await Promise.resolve(mod.destroy());
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
315
|
async initialize(core, options = {}) {
|
|
284
|
-
|
|
285
|
-
this.
|
|
286
|
-
this.
|
|
287
|
-
this.store =
|
|
288
|
-
|
|
289
|
-
...options.store
|
|
290
|
-
};
|
|
291
|
-
this.store.entryContext = options.otherParams?.entryContext || this.store.entryContext;
|
|
292
|
-
this.store.status = 'initializing';
|
|
316
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
317
|
+
this.logMethodStart("initialize");
|
|
318
|
+
this.store = { ...this.store, ...options.store };
|
|
319
|
+
this.store.entryContext = ((_a = options.otherParams) == null ? void 0 : _a.entryContext) || this.store.entryContext;
|
|
320
|
+
this.store.status = "initializing";
|
|
293
321
|
this.store.error = null;
|
|
294
322
|
this.otherParams = options.otherParams || {};
|
|
295
|
-
this.cacheId = this.otherParams
|
|
296
|
-
this.itemRuleRuntimeConfig = this.otherParams
|
|
323
|
+
this.cacheId = (_b = this.otherParams) == null ? void 0 : _b.cacheId;
|
|
324
|
+
this.itemRuleRuntimeConfig = ((_c = this.otherParams) == null ? void 0 : _c.scanOrderItemRule) || ((_d = this.otherParams) == null ? void 0 : _d.itemRule) || {};
|
|
297
325
|
this.itemRuleConfigs = [];
|
|
298
326
|
this.itemRuleConfigsPromise = null;
|
|
299
327
|
this.itemRulePrefillApplied = false;
|
|
@@ -302,391 +330,361 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
302
330
|
passed: null,
|
|
303
331
|
failures: []
|
|
304
332
|
};
|
|
305
|
-
|
|
306
|
-
this.
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
this.logMethodError('initialize', 'request plugin missing');
|
|
313
|
-
throw new Error('scanOrder解决方案需要 request 插件支持');
|
|
314
|
-
}
|
|
315
|
-
const moduleArr = ['scanOrderLogger', 'products', 'order', 'salesSummary'];
|
|
316
|
-
moduleArr.forEach(step => {
|
|
317
|
-
const targetModule = (0, _types4.createModule)(step, this.name);
|
|
318
|
-
if (targetModule) {
|
|
319
|
-
this.store[step] = targetModule;
|
|
320
|
-
const initialState = step === 'salesSummary' ? {
|
|
321
|
-
summary: this.store.order?.getTempOrder()?.summary || (0, _utils.createEmptySummary)()
|
|
322
|
-
} : {};
|
|
323
|
-
const loggerProvider = this.otherParams?.scanOrderLoggerProvider || 'feishu';
|
|
324
|
-
const loggerConfig = this.otherParams?.scanOrderLoggerConfig || {
|
|
333
|
+
await super.initialize(core, options);
|
|
334
|
+
if (this.store.scanOrderLogger) {
|
|
335
|
+
this.store.scanOrderLogger.setProvider(
|
|
336
|
+
((_e = this.otherParams) == null ? void 0 : _e.scanOrderLoggerProvider) || "feishu"
|
|
337
|
+
);
|
|
338
|
+
this.store.scanOrderLogger.setProviderConfig(
|
|
339
|
+
((_f = this.otherParams) == null ? void 0 : _f.scanOrderLoggerConfig) || {
|
|
325
340
|
feishu: {
|
|
326
|
-
webhook:
|
|
327
|
-
errorHook:
|
|
328
|
-
}
|
|
329
|
-
};
|
|
330
|
-
this.core.registerModule(targetModule, {
|
|
331
|
-
initialState,
|
|
332
|
-
otherParams: {
|
|
333
|
-
...this.otherParams,
|
|
334
|
-
fatherModule: this.name,
|
|
335
|
-
openCache: this.otherParams?.cacheId ? true : false,
|
|
336
|
-
cacheId: this.otherParams?.cacheId,
|
|
337
|
-
salesSummaryModuleName: `${this.name}_salesSummary`,
|
|
338
|
-
provider: loggerProvider,
|
|
339
|
-
providerConfig: loggerConfig,
|
|
340
|
-
context: this.getScanOrderLoggerContext()
|
|
341
|
+
webhook: "https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed",
|
|
342
|
+
errorHook: "https://open.feishu.cn/open-apis/bot/v2/hook/015b7c2a-dd3c-4c30-9898-ef0f5253111f"
|
|
341
343
|
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
this.logMethodError('initialize', `module ${step} missing`);
|
|
345
|
-
throw new Error(`模块 ${step} 不存在`);
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
if (this.store.scanOrderLogger) {
|
|
344
|
+
}
|
|
345
|
+
);
|
|
349
346
|
this.store.scanOrderLogger.setContext(this.getScanOrderLoggerContext());
|
|
350
347
|
}
|
|
351
|
-
const scheduleModule = new _Schedule.ScheduleModule(`${this.name}_schedule`);
|
|
352
|
-
this.store.schedule = scheduleModule;
|
|
353
|
-
this.core.registerModule(scheduleModule, {
|
|
354
|
-
otherParams: {
|
|
355
|
-
...this.otherParams,
|
|
356
|
-
fatherModule: this.name
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
348
|
this.registerCustomerLoginListeners();
|
|
349
|
+
console.log("[ScanOrder] 初始化开始");
|
|
360
350
|
try {
|
|
361
|
-
await this.store.order
|
|
362
|
-
|
|
363
|
-
});
|
|
364
|
-
this.store.order?.persistTempOrder();
|
|
351
|
+
await ((_g = this.store.order) == null ? void 0 : _g.recalculateSummary({ createIfMissing: false }));
|
|
352
|
+
(_h = this.store.order) == null ? void 0 : _h.persistTempOrder();
|
|
365
353
|
await this.loadRuntimeConfigs();
|
|
366
354
|
if (this.store.schedule) {
|
|
367
355
|
try {
|
|
368
356
|
await this.store.schedule.loadAllSchedule();
|
|
369
357
|
} catch (scheduleError) {
|
|
370
|
-
console.warn(
|
|
358
|
+
console.warn("[ScanOrder] loadAllSchedule 失败,operating_hours 判定将跳过", scheduleError);
|
|
371
359
|
}
|
|
372
360
|
}
|
|
373
361
|
await this.refreshItemRuleQuantityLimits();
|
|
374
|
-
this.store.status =
|
|
375
|
-
|
|
362
|
+
this.store.status = "ready";
|
|
363
|
+
console.log("[ScanOrder] 初始化完成");
|
|
364
|
+
await this.core.effects.emit(import_types.ScanOrderHooks.onInited, {
|
|
376
365
|
status: this.store.status
|
|
377
366
|
});
|
|
378
|
-
this.logMethodSuccess(
|
|
367
|
+
this.logMethodSuccess("initialize", {
|
|
379
368
|
status: this.store.status
|
|
380
369
|
});
|
|
381
370
|
} catch (error) {
|
|
382
|
-
this.store.status =
|
|
383
|
-
this.store.error = error instanceof Error ? error.message :
|
|
384
|
-
console.error(
|
|
385
|
-
this.logMethodError(
|
|
371
|
+
this.store.status = "error";
|
|
372
|
+
this.store.error = error instanceof Error ? error.message : "初始化失败";
|
|
373
|
+
console.error("[ScanOrder] 初始化失败", error);
|
|
374
|
+
this.logMethodError("initialize", error, {
|
|
386
375
|
status: this.store.status
|
|
387
376
|
});
|
|
388
377
|
throw error;
|
|
389
378
|
}
|
|
390
379
|
}
|
|
391
380
|
async destroy() {
|
|
392
|
-
this.logMethodStart(
|
|
381
|
+
this.logMethodStart("destroy");
|
|
393
382
|
this.clearLoginEffectListeners();
|
|
394
|
-
await this.core.effects.emit(
|
|
395
|
-
await this.destroyRegisteredChildModules();
|
|
383
|
+
await this.core.effects.emit(import_types.ScanOrderHooks.onDestroy, {});
|
|
396
384
|
super.destroy();
|
|
397
|
-
|
|
385
|
+
console.log("[ScanOrder] 已销毁");
|
|
386
|
+
this.logMethodSuccess("destroy");
|
|
398
387
|
}
|
|
399
388
|
async retryInit() {
|
|
400
|
-
this.logMethodStart(
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
await this.core.effects.emit(_types.ScanOrderHooks.onRetryInit, {});
|
|
389
|
+
this.logMethodStart("retryInit");
|
|
390
|
+
console.log("[ScanOrder] retryInit 调用");
|
|
391
|
+
await this.core.effects.emit(import_types.ScanOrderHooks.onRetryInit, {});
|
|
404
392
|
try {
|
|
405
393
|
await this.initialize(this.core, this.initializeOptions);
|
|
406
|
-
this.logMethodSuccess(
|
|
394
|
+
this.logMethodSuccess("retryInit");
|
|
407
395
|
} catch (error) {
|
|
408
|
-
this.logMethodError(
|
|
396
|
+
this.logMethodError("retryInit", error);
|
|
409
397
|
throw error;
|
|
410
398
|
}
|
|
411
399
|
}
|
|
412
400
|
async refresh() {
|
|
413
|
-
this.logMethodStart(
|
|
414
|
-
|
|
415
|
-
|
|
401
|
+
this.logMethodStart("refresh");
|
|
402
|
+
console.log("[ScanOrder] refresh 调用");
|
|
416
403
|
try {
|
|
417
|
-
this.store.status =
|
|
404
|
+
this.store.status = "initializing";
|
|
418
405
|
await this.loadRuntimeConfigs();
|
|
419
406
|
await this.refreshItemRuleQuantityLimits();
|
|
420
|
-
this.store.status =
|
|
421
|
-
await this.core.effects.emit(
|
|
407
|
+
this.store.status = "ready";
|
|
408
|
+
await this.core.effects.emit(import_types.ScanOrderHooks.onRefresh, {
|
|
422
409
|
status: this.store.status
|
|
423
410
|
});
|
|
424
|
-
this.logMethodSuccess(
|
|
411
|
+
this.logMethodSuccess("refresh", {
|
|
425
412
|
status: this.store.status
|
|
426
413
|
});
|
|
427
414
|
} catch (error) {
|
|
428
|
-
this.logMethodError(
|
|
415
|
+
this.logMethodError("refresh", error);
|
|
429
416
|
throw error;
|
|
430
417
|
}
|
|
431
418
|
}
|
|
432
419
|
getStatus() {
|
|
433
|
-
this.logMethodStart(
|
|
420
|
+
this.logMethodStart("getStatus");
|
|
434
421
|
const result = this.store.status;
|
|
435
|
-
this.logMethodSuccess(
|
|
422
|
+
this.logMethodSuccess("getStatus", {
|
|
436
423
|
status: result
|
|
437
424
|
});
|
|
438
425
|
return result;
|
|
439
426
|
}
|
|
440
427
|
getEntryContext() {
|
|
441
|
-
this.logMethodStart(
|
|
428
|
+
this.logMethodStart("getEntryContext");
|
|
442
429
|
const result = this.store.entryContext;
|
|
443
|
-
this.logMethodSuccess(
|
|
430
|
+
this.logMethodSuccess("getEntryContext", {
|
|
444
431
|
hasEntryContext: Boolean(result)
|
|
445
432
|
});
|
|
446
433
|
return result;
|
|
447
434
|
}
|
|
448
435
|
getConfig() {
|
|
449
|
-
this.logMethodStart(
|
|
436
|
+
this.logMethodStart("getConfig");
|
|
450
437
|
const result = this.store.config || {};
|
|
451
|
-
this.logMethodSuccess(
|
|
438
|
+
this.logMethodSuccess("getConfig", {
|
|
452
439
|
configKeys: Object.keys(result || {})
|
|
453
440
|
});
|
|
454
441
|
return result;
|
|
455
442
|
}
|
|
456
443
|
getItemRuleQuantityLimits() {
|
|
457
|
-
this.logMethodStart(
|
|
444
|
+
this.logMethodStart("getItemRuleQuantityLimits");
|
|
458
445
|
const result = this.store.itemRuleQuantityLimits || [];
|
|
459
|
-
this.logMethodSuccess(
|
|
446
|
+
this.logMethodSuccess("getItemRuleQuantityLimits", {
|
|
460
447
|
limitCount: result.length
|
|
461
448
|
});
|
|
462
449
|
return result;
|
|
463
450
|
}
|
|
464
451
|
getCartValidationPassed() {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
this.
|
|
452
|
+
var _a;
|
|
453
|
+
this.logMethodStart("getCartValidationPassed");
|
|
454
|
+
const result = ((_a = this.store.cartValidation) == null ? void 0 : _a.passed) ?? null;
|
|
455
|
+
this.logMethodSuccess("getCartValidationPassed", {
|
|
468
456
|
cartValidationPassed: result
|
|
469
457
|
});
|
|
470
458
|
return result;
|
|
471
459
|
}
|
|
472
460
|
getCartValidation() {
|
|
473
|
-
this.logMethodStart(
|
|
461
|
+
this.logMethodStart("getCartValidation");
|
|
474
462
|
const result = this.store.cartValidation || {
|
|
475
463
|
passed: null,
|
|
476
464
|
failures: []
|
|
477
465
|
};
|
|
478
|
-
this.logMethodSuccess(
|
|
466
|
+
this.logMethodSuccess("getCartValidation", {
|
|
479
467
|
cartValidationPassed: result.passed,
|
|
480
468
|
failureCount: Array.isArray(result.failures) ? result.failures.length : 0
|
|
481
469
|
});
|
|
482
470
|
return result;
|
|
483
471
|
}
|
|
484
472
|
getTempOrder() {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
this.
|
|
473
|
+
var _a, _b, _c;
|
|
474
|
+
this.logMethodStart("getTempOrder");
|
|
475
|
+
const result = ((_a = this.store.order) == null ? void 0 : _a.getTempOrder()) || null;
|
|
476
|
+
this.logMethodSuccess("getTempOrder", {
|
|
488
477
|
hasTempOrder: Boolean(result),
|
|
489
|
-
productCount: result
|
|
490
|
-
noteLength: result
|
|
478
|
+
productCount: ((_b = result == null ? void 0 : result.products) == null ? void 0 : _b.length) || 0,
|
|
479
|
+
noteLength: ((_c = result == null ? void 0 : result.note) == null ? void 0 : _c.length) || 0
|
|
491
480
|
});
|
|
492
481
|
return result;
|
|
493
482
|
}
|
|
494
|
-
updateTempOrderNote(note) {
|
|
495
|
-
this.logMethodStart(
|
|
496
|
-
noteLength: String(note ||
|
|
483
|
+
updateTempOrderNote(note, sync = false) {
|
|
484
|
+
this.logMethodStart("updateTempOrderNote", {
|
|
485
|
+
noteLength: String(note || "").length
|
|
497
486
|
});
|
|
498
487
|
try {
|
|
499
|
-
if (!this.store.order)
|
|
500
|
-
|
|
501
|
-
this.
|
|
502
|
-
|
|
488
|
+
if (!this.store.order)
|
|
489
|
+
throw new Error("order 模块未初始化");
|
|
490
|
+
const result = this.store.order.updateTempOrderNote(note, sync);
|
|
491
|
+
if (result && typeof result.then === "function") {
|
|
492
|
+
return result.then((nextNote2) => {
|
|
493
|
+
this.logMethodSuccess("updateTempOrderNote", {
|
|
494
|
+
noteLength: nextNote2.length
|
|
495
|
+
});
|
|
496
|
+
return nextNote2;
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
const nextNote = result;
|
|
500
|
+
this.logMethodSuccess("updateTempOrderNote", {
|
|
501
|
+
noteLength: nextNote.length
|
|
503
502
|
});
|
|
504
|
-
return
|
|
503
|
+
return nextNote;
|
|
505
504
|
} catch (error) {
|
|
506
|
-
this.logMethodError(
|
|
505
|
+
this.logMethodError("updateTempOrderNote", error);
|
|
507
506
|
throw error;
|
|
508
507
|
}
|
|
509
508
|
}
|
|
510
|
-
|
|
511
509
|
// 存储 UI 层选择的取餐方式到 tempOrder.metadata.shop_service_data
|
|
512
510
|
// service_type 在扫码点餐场景固定为 dine_in
|
|
513
511
|
setPickupReferenceMode(mode) {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
});
|
|
512
|
+
var _a;
|
|
513
|
+
this.logMethodStart("setPickupReferenceMode", { mode });
|
|
517
514
|
try {
|
|
518
|
-
if (!this.store.order)
|
|
515
|
+
if (!this.store.order)
|
|
516
|
+
throw new Error("order 模块未初始化");
|
|
519
517
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
520
518
|
tempOrder.metadata = {
|
|
521
|
-
...
|
|
519
|
+
...tempOrder.metadata || {},
|
|
522
520
|
shop_service_data: {
|
|
523
|
-
...(
|
|
524
|
-
service_type: this.otherParams
|
|
521
|
+
...(tempOrder.metadata || {}).shop_service_data || {},
|
|
522
|
+
service_type: ((_a = this.otherParams) == null ? void 0 : _a.businessCode) === "dine_in" ? "dine_in" : "",
|
|
525
523
|
pickup_reference_mode: mode
|
|
526
524
|
}
|
|
527
525
|
};
|
|
528
526
|
this.store.order.persistTempOrder();
|
|
529
|
-
this.logMethodSuccess(
|
|
527
|
+
this.logMethodSuccess("setPickupReferenceMode", {
|
|
530
528
|
mode
|
|
531
529
|
});
|
|
532
530
|
return tempOrder.metadata.shop_service_data;
|
|
533
531
|
} catch (error) {
|
|
534
|
-
this.logMethodError(
|
|
535
|
-
mode
|
|
536
|
-
});
|
|
532
|
+
this.logMethodError("setPickupReferenceMode", error, { mode });
|
|
537
533
|
throw error;
|
|
538
534
|
}
|
|
539
535
|
}
|
|
540
|
-
|
|
541
536
|
// 存储用户自定义取餐标识到 tempOrder.buzzer
|
|
542
537
|
setPickupRef(buzzer) {
|
|
543
|
-
this.logMethodStart(
|
|
544
|
-
buzzerLength: String(buzzer ||
|
|
538
|
+
this.logMethodStart("setPickupRef", {
|
|
539
|
+
buzzerLength: String(buzzer || "").length
|
|
545
540
|
});
|
|
546
541
|
try {
|
|
547
|
-
if (!this.store.order)
|
|
542
|
+
if (!this.store.order)
|
|
543
|
+
throw new Error("order 模块未初始化");
|
|
548
544
|
const result = this.store.order.updateTempOrderBuzzer(buzzer);
|
|
549
|
-
this.logMethodSuccess(
|
|
545
|
+
this.logMethodSuccess("setPickupRef", {
|
|
550
546
|
buzzerLength: result.length
|
|
551
547
|
});
|
|
552
548
|
return result;
|
|
553
549
|
} catch (error) {
|
|
554
|
-
this.logMethodError(
|
|
550
|
+
this.logMethodError("setPickupRef", error);
|
|
555
551
|
throw error;
|
|
556
552
|
}
|
|
557
553
|
}
|
|
558
|
-
|
|
559
|
-
if (!this.store.order)
|
|
554
|
+
ensureScanOrderTempOrder() {
|
|
555
|
+
if (!this.store.order)
|
|
556
|
+
throw new Error("order 模块未初始化");
|
|
560
557
|
return this.store.order.ensureTempOrder();
|
|
561
558
|
}
|
|
562
|
-
|
|
563
559
|
// 主动创建临时订单;若已存在则直接返回已有订单
|
|
564
560
|
async addNewOrder() {
|
|
565
|
-
this.logMethodStart(
|
|
561
|
+
this.logMethodStart("addNewOrder");
|
|
566
562
|
try {
|
|
567
|
-
if (!this.store.order)
|
|
563
|
+
if (!this.store.order)
|
|
564
|
+
throw new Error("order 模块未初始化");
|
|
568
565
|
const tempOrder = await this.store.order.addNewOrder();
|
|
569
|
-
this.logMethodSuccess(
|
|
566
|
+
this.logMethodSuccess("addNewOrder", {
|
|
570
567
|
productCount: tempOrder.products.length
|
|
571
568
|
});
|
|
572
569
|
return tempOrder;
|
|
573
570
|
} catch (error) {
|
|
574
|
-
this.logMethodError(
|
|
571
|
+
this.logMethodError("addNewOrder", error);
|
|
575
572
|
throw error;
|
|
576
573
|
}
|
|
577
574
|
}
|
|
578
|
-
|
|
579
575
|
// 重置 tempOrder 与与上一单强相关的运行态(resource/entryPaxNumber/enabledReservationRuleProducts),
|
|
580
576
|
// 适用于从支付页通过 react-router 跳回继续下单时清理残留数据
|
|
581
577
|
async restoreOrder() {
|
|
582
|
-
this.logMethodStart(
|
|
578
|
+
this.logMethodStart("restoreOrder");
|
|
583
579
|
try {
|
|
584
580
|
if (!this.store.order) {
|
|
585
|
-
throw new Error(
|
|
581
|
+
throw new Error("scanOrder 解决方案需要 order 模块支持");
|
|
586
582
|
}
|
|
587
583
|
this.store.resource = null;
|
|
588
584
|
this.store.entryPaxNumber = 1;
|
|
589
585
|
this.enabledReservationRuleProducts = [];
|
|
590
586
|
const tempOrder = this.store.order.restoreOrder();
|
|
591
|
-
this.logMethodSuccess(
|
|
587
|
+
this.logMethodSuccess("restoreOrder");
|
|
592
588
|
return tempOrder;
|
|
593
589
|
} catch (error) {
|
|
594
|
-
this.logMethodError(
|
|
590
|
+
this.logMethodError("restoreOrder", error);
|
|
595
591
|
throw error;
|
|
596
592
|
}
|
|
597
593
|
}
|
|
598
594
|
getOrderProducts() {
|
|
599
|
-
this.logMethodStart(
|
|
600
|
-
if (!this.store.order)
|
|
595
|
+
this.logMethodStart("getOrderProducts");
|
|
596
|
+
if (!this.store.order)
|
|
597
|
+
throw new Error("order 模块未初始化");
|
|
601
598
|
const products = this.store.order.getOrderProducts();
|
|
602
|
-
this.logMethodSuccess(
|
|
599
|
+
this.logMethodSuccess("getOrderProducts", {
|
|
603
600
|
productCount: products.length
|
|
604
601
|
});
|
|
605
602
|
return products;
|
|
606
603
|
}
|
|
607
604
|
async getSummary() {
|
|
608
|
-
this.logMethodStart(
|
|
605
|
+
this.logMethodStart("getSummary");
|
|
609
606
|
try {
|
|
610
|
-
if (!this.store.order)
|
|
611
|
-
|
|
612
|
-
this.
|
|
607
|
+
if (!this.store.order)
|
|
608
|
+
throw new Error("order 模块未初始化");
|
|
609
|
+
const summary = await this.store.order.getOrderSummary();
|
|
610
|
+
this.logMethodSuccess("getSummary", {
|
|
613
611
|
totalAmount: summary.total_amount
|
|
614
612
|
});
|
|
615
613
|
return summary;
|
|
616
614
|
} catch (error) {
|
|
617
|
-
this.logMethodError(
|
|
615
|
+
this.logMethodError("getSummary", error);
|
|
618
616
|
throw error;
|
|
619
617
|
}
|
|
620
618
|
}
|
|
621
619
|
getDiscountList() {
|
|
622
|
-
if (!this.store.order)
|
|
620
|
+
if (!this.store.order)
|
|
621
|
+
return [];
|
|
623
622
|
return this.store.order.getDiscountList();
|
|
624
623
|
}
|
|
625
624
|
async scanCode(code, customerId) {
|
|
626
|
-
this.logMethodStart(
|
|
627
|
-
code
|
|
628
|
-
});
|
|
625
|
+
this.logMethodStart("scanCode", { code });
|
|
629
626
|
try {
|
|
630
|
-
if (!this.store.order)
|
|
627
|
+
if (!this.store.order)
|
|
628
|
+
throw new Error("order 模块未初始化");
|
|
631
629
|
const raw = await this.store.order.scanCode(code, customerId);
|
|
632
630
|
if (raw.isAvailable) {
|
|
633
|
-
await this.store.order.recalculateSummary({
|
|
634
|
-
createIfMissing: true
|
|
635
|
-
});
|
|
631
|
+
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
636
632
|
this.store.order.persistTempOrder();
|
|
637
633
|
}
|
|
638
|
-
this.logMethodSuccess(
|
|
639
|
-
isAvailable: raw.isAvailable
|
|
640
|
-
});
|
|
634
|
+
this.logMethodSuccess("scanCode", { isAvailable: raw.isAvailable });
|
|
641
635
|
return {
|
|
642
636
|
isAvailable: raw.isAvailable,
|
|
643
637
|
type: raw.type,
|
|
644
638
|
unavailableReason: raw.unavailableReason
|
|
645
639
|
};
|
|
646
640
|
} catch (error) {
|
|
647
|
-
this.logMethodError(
|
|
641
|
+
this.logMethodError("scanCode", error);
|
|
648
642
|
throw error;
|
|
649
643
|
}
|
|
650
644
|
}
|
|
651
645
|
async setDiscountSelected(params) {
|
|
652
|
-
|
|
646
|
+
var _a, _b, _c, _d, _e;
|
|
647
|
+
this.logMethodStart("setDiscountSelected", params);
|
|
653
648
|
try {
|
|
654
|
-
if (!this.store.order)
|
|
649
|
+
if (!this.store.order)
|
|
650
|
+
throw new Error("order 模块未初始化");
|
|
655
651
|
const list = this.store.order.getDiscountList();
|
|
656
|
-
const updated = list.map(
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
652
|
+
const updated = list.map(
|
|
653
|
+
(d) => d.id === params.discountId ? {
|
|
654
|
+
...d,
|
|
655
|
+
isSelected: params.isSelected,
|
|
656
|
+
isManualSelect: !params.isSelected
|
|
657
|
+
} : d
|
|
658
|
+
);
|
|
661
659
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
662
660
|
const orderStore = this.store.order.store || {};
|
|
663
661
|
const discountModule = orderStore.discount;
|
|
664
662
|
const rulesModule = orderStore.rules;
|
|
665
|
-
const holders = tempOrder.holder
|
|
666
|
-
form_record_id: tempOrder.holder.form_record_id
|
|
667
|
-
}] : [];
|
|
663
|
+
const holders = ((_a = tempOrder.holder) == null ? void 0 : _a.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
|
|
668
664
|
let nextDiscountList = updated;
|
|
669
|
-
await discountModule
|
|
665
|
+
await (discountModule == null ? void 0 : discountModule.setDiscountList(updated));
|
|
670
666
|
if (rulesModule) {
|
|
671
|
-
const result = rulesModule.calcDiscount(
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
};
|
|
683
|
-
if (result
|
|
667
|
+
const result = rulesModule.calcDiscount(
|
|
668
|
+
{
|
|
669
|
+
productList: tempOrder.products,
|
|
670
|
+
discountList: updated,
|
|
671
|
+
holders,
|
|
672
|
+
isFormSubject: !!((_b = tempOrder.holder) == null ? void 0 : _b.type) && tempOrder.holder.type === "form"
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
discountId: params.discountId,
|
|
676
|
+
isSelected: params.isSelected
|
|
677
|
+
}
|
|
678
|
+
) || { productList: tempOrder.products, discountList: updated };
|
|
679
|
+
if (result == null ? void 0 : result.productList) {
|
|
684
680
|
tempOrder.products = result.productList;
|
|
685
681
|
}
|
|
686
|
-
if (result
|
|
682
|
+
if (result == null ? void 0 : result.discountList) {
|
|
687
683
|
nextDiscountList = result.discountList;
|
|
688
684
|
if (!params.isSelected) {
|
|
689
|
-
const beforeSelectedIds = new Set(
|
|
685
|
+
const beforeSelectedIds = new Set(
|
|
686
|
+
updated.filter((d) => d.isSelected).map((d) => d.id)
|
|
687
|
+
);
|
|
690
688
|
for (const d of nextDiscountList) {
|
|
691
689
|
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
692
690
|
d.isSelected = false;
|
|
@@ -695,92 +693,88 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
695
693
|
}
|
|
696
694
|
}
|
|
697
695
|
}
|
|
698
|
-
const selectedResourceIds = new Set(
|
|
696
|
+
const selectedResourceIds = new Set(
|
|
697
|
+
nextDiscountList.filter((d) => d.isSelected).map((d) => d.id)
|
|
698
|
+
);
|
|
699
699
|
for (const product of tempOrder.products) {
|
|
700
|
-
if (product._origin
|
|
701
|
-
|
|
702
|
-
|
|
700
|
+
if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
|
|
701
|
+
continue;
|
|
702
|
+
product.discount_list = (product.discount_list || []).filter((pd) => {
|
|
703
|
+
var _a2;
|
|
704
|
+
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
|
703
705
|
return rid != null && selectedResourceIds.has(rid);
|
|
704
706
|
});
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
const optionSum = (0,
|
|
710
|
-
const sourcePrice = product.metadata
|
|
711
|
-
const newSourceSellingPrice = new
|
|
712
|
-
const newMainSellingPrice = new
|
|
707
|
+
const totalPerUnitDiscount = (product.discount_list || []).reduce(
|
|
708
|
+
(sum, pd) => sum + (pd.amount || 0),
|
|
709
|
+
0
|
|
710
|
+
);
|
|
711
|
+
const optionSum = (0, import_utils2.sumOptionUnitPrice)((0, import_utils2.getProductSkuOptions)(product));
|
|
712
|
+
const sourcePrice = ((_d = product.metadata) == null ? void 0 : _d.source_product_price) ?? (((_e = product.metadata) == null ? void 0 : _e.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
|
|
713
|
+
const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
714
|
+
const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
713
715
|
if (product.metadata) {
|
|
714
716
|
product.metadata.main_product_selling_price = newMainSellingPrice;
|
|
715
717
|
product.metadata.price_schema_version = 2;
|
|
716
718
|
}
|
|
717
|
-
product.selling_price = (0,
|
|
719
|
+
product.selling_price = (0, import_utils2.composeLinePrice)({
|
|
718
720
|
mainPrice: newMainSellingPrice,
|
|
719
721
|
bundle: product.product_bundle
|
|
720
722
|
});
|
|
721
723
|
}
|
|
722
|
-
|
|
723
|
-
await discountModule
|
|
724
|
-
tempOrder.discount_list = (nextDiscountList || []).filter(d => d.isSelected);
|
|
725
|
-
await this.store.order.recalculateSummary({
|
|
726
|
-
createIfMissing: true
|
|
727
|
-
});
|
|
724
|
+
import_Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
725
|
+
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
726
|
+
tempOrder.discount_list = (nextDiscountList || []).filter((d) => d.isSelected);
|
|
727
|
+
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
728
728
|
this.store.order.persistTempOrder();
|
|
729
|
-
this.logMethodSuccess(
|
|
729
|
+
this.logMethodSuccess("setDiscountSelected", params);
|
|
730
730
|
} catch (error) {
|
|
731
|
-
this.logMethodError(
|
|
731
|
+
this.logMethodError("setDiscountSelected", error);
|
|
732
732
|
throw error;
|
|
733
733
|
}
|
|
734
734
|
}
|
|
735
735
|
async onCustomerLogin(params) {
|
|
736
|
-
this.logMethodStart(
|
|
737
|
-
customerId: params.customerId
|
|
738
|
-
});
|
|
736
|
+
this.logMethodStart("onCustomerLogin", { customerId: params.customerId });
|
|
739
737
|
try {
|
|
740
738
|
await this.refreshOrderMarketingAfterLogin({
|
|
741
739
|
customerId: params.customerId
|
|
742
740
|
});
|
|
743
|
-
this.logMethodSuccess(
|
|
744
|
-
customerId: params.customerId
|
|
745
|
-
});
|
|
741
|
+
this.logMethodSuccess("onCustomerLogin", { customerId: params.customerId });
|
|
746
742
|
} catch (error) {
|
|
747
|
-
this.logMethodError(
|
|
743
|
+
this.logMethodError("onCustomerLogin", error);
|
|
748
744
|
throw error;
|
|
749
745
|
}
|
|
750
746
|
}
|
|
751
747
|
findReservationRuleResource(formId) {
|
|
752
|
-
|
|
748
|
+
var _a;
|
|
749
|
+
if (formId == null)
|
|
750
|
+
return void 0;
|
|
753
751
|
const numericFormId = Number(formId);
|
|
754
|
-
if (!Number.isFinite(numericFormId) || numericFormId <= 0)
|
|
752
|
+
if (!Number.isFinite(numericFormId) || numericFormId <= 0)
|
|
753
|
+
return void 0;
|
|
755
754
|
for (const product of this.enabledReservationRuleProducts) {
|
|
756
|
-
const resources = product
|
|
757
|
-
if (!Array.isArray(resources))
|
|
758
|
-
|
|
759
|
-
|
|
755
|
+
const resources = (_a = product == null ? void 0 : product.product_resource) == null ? void 0 : _a.resources;
|
|
756
|
+
if (!Array.isArray(resources))
|
|
757
|
+
continue;
|
|
758
|
+
const matched = resources.find((resource) => Number(resource == null ? void 0 : resource.id) === numericFormId);
|
|
759
|
+
if (matched)
|
|
760
|
+
return matched;
|
|
760
761
|
}
|
|
761
|
-
return
|
|
762
|
+
return void 0;
|
|
762
763
|
}
|
|
763
764
|
buildScanOrderResourceMetadata(params) {
|
|
764
|
-
const {
|
|
765
|
-
resourceState,
|
|
766
|
-
resourceName
|
|
767
|
-
} = params;
|
|
765
|
+
const { resourceState, resourceName } = params;
|
|
768
766
|
const ruleResource = this.findReservationRuleResource(resourceState.tableFormId);
|
|
769
|
-
const combined = ruleResource
|
|
767
|
+
const combined = ruleResource == null ? void 0 : ruleResource.combined_resource;
|
|
770
768
|
const isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids));
|
|
771
769
|
return {
|
|
772
|
-
form_name: ruleResource
|
|
770
|
+
form_name: (ruleResource == null ? void 0 : ruleResource.title) ?? "",
|
|
773
771
|
resource_name: resourceName,
|
|
774
772
|
combined_resource: isCombined ? combined : null
|
|
775
773
|
};
|
|
776
774
|
}
|
|
777
775
|
async prepareRetailAvailability(params) {
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
hasOrderId,
|
|
781
|
-
resourceId,
|
|
782
|
-
reason
|
|
783
|
-
} = params;
|
|
776
|
+
var _a, _b;
|
|
777
|
+
const { tempOrder, hasOrderId, resourceId, reason } = params;
|
|
784
778
|
this.enabledReservationRuleProducts = [];
|
|
785
779
|
tempOrder.bookings = [];
|
|
786
780
|
tempOrder.order_id = null;
|
|
@@ -788,12 +782,10 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
788
782
|
delete tempOrder.table_form_id;
|
|
789
783
|
delete tempOrder.resource_id;
|
|
790
784
|
delete tempOrder.table_number;
|
|
791
|
-
tempOrder.metadata = {
|
|
792
|
-
...(tempOrder.metadata || {})
|
|
793
|
-
};
|
|
785
|
+
tempOrder.metadata = { ...tempOrder.metadata || {} };
|
|
794
786
|
delete tempOrder.metadata.table_occupancy_duration;
|
|
795
787
|
const resourceState = {
|
|
796
|
-
mode:
|
|
788
|
+
mode: "idle",
|
|
797
789
|
deskmate_valid: false,
|
|
798
790
|
allowSnack: false,
|
|
799
791
|
deskmateValid: false,
|
|
@@ -802,28 +794,27 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
802
794
|
raw: null
|
|
803
795
|
};
|
|
804
796
|
this.store.resource = resourceState;
|
|
805
|
-
this.store.order
|
|
797
|
+
(_a = this.store.order) == null ? void 0 : _a.persistTempOrder();
|
|
806
798
|
await this.addNewOrder();
|
|
807
799
|
await this.setItemRuleRuntimeConfig({
|
|
808
|
-
serviceType: this.otherParams
|
|
800
|
+
serviceType: (_b = this.otherParams) == null ? void 0 : _b.businessCode,
|
|
809
801
|
submissionIndex: hasOrderId ? 1 : 0,
|
|
810
802
|
historicalItems: []
|
|
811
803
|
});
|
|
812
804
|
const availabilityInfo = {
|
|
813
|
-
mode:
|
|
805
|
+
mode: "idle",
|
|
814
806
|
deskmate_valid: false
|
|
815
807
|
};
|
|
816
|
-
this.logMethodSuccess(
|
|
808
|
+
this.logMethodSuccess("checkResourceAvailable", {
|
|
817
809
|
resourceId,
|
|
818
810
|
mode: availabilityInfo.mode,
|
|
819
811
|
retailMode: true,
|
|
820
812
|
retailReason: reason,
|
|
821
|
-
|
|
822
|
-
persistedResourceId:
|
|
813
|
+
relationId: resourceState.relationId,
|
|
814
|
+
persistedResourceId: resourceState.relationId
|
|
823
815
|
});
|
|
824
816
|
return availabilityInfo;
|
|
825
817
|
}
|
|
826
|
-
|
|
827
818
|
// ScanOrder 提交 payload enhancer:
|
|
828
819
|
// - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
|
|
829
820
|
// - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
|
|
@@ -832,45 +823,45 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
832
823
|
buildSubmitPayloadEnhancer() {
|
|
833
824
|
const ruleProduct = this.enabledReservationRuleProducts[0];
|
|
834
825
|
const resourceState = this.store.resource;
|
|
835
|
-
const resourceSelectType = resourceState
|
|
836
|
-
|
|
837
|
-
// ScanOrder 的 booking 容量只由预约规则决定:single 占用整张桌台,multiple 占用 1 个容量位。
|
|
826
|
+
const resourceSelectType = resourceState == null ? void 0 : resourceState.resourceSelectType;
|
|
838
827
|
const resolveBookingCapacityValue = () => {
|
|
839
|
-
|
|
840
|
-
|
|
828
|
+
var _a;
|
|
829
|
+
if (resourceSelectType === "single") {
|
|
830
|
+
const raw = (_a = resourceState == null ? void 0 : resourceState.table_form_record) == null ? void 0 : _a.capacity;
|
|
841
831
|
const num = Number(raw);
|
|
842
|
-
if (Number.isFinite(num) && num > 0)
|
|
832
|
+
if (Number.isFinite(num) && num > 0)
|
|
833
|
+
return Math.max(1, Math.floor(num));
|
|
843
834
|
return 1;
|
|
844
835
|
}
|
|
845
836
|
return 1;
|
|
846
837
|
};
|
|
847
|
-
return (payload, {
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
838
|
+
return (payload, { bookingUuid, tempOrder }) => {
|
|
839
|
+
var _a, _b;
|
|
840
|
+
const resourceId = String((resourceState == null ? void 0 : resourceState.relationId) ?? "").trim();
|
|
841
|
+
const hasReservationBookingContext = Boolean(
|
|
842
|
+
ruleProduct && resourceState && resourceId && resourceState.relationId && resourceState.tableFormId
|
|
843
|
+
);
|
|
853
844
|
if (!hasReservationBookingContext) {
|
|
854
845
|
return {
|
|
855
846
|
...payload,
|
|
856
847
|
bookings: [],
|
|
857
|
-
products: [...
|
|
848
|
+
products: [...payload.products || []]
|
|
858
849
|
};
|
|
859
850
|
}
|
|
860
|
-
const rawCollectPax = tempOrder.metadata
|
|
861
|
-
const hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !==
|
|
851
|
+
const rawCollectPax = (_a = tempOrder.metadata) == null ? void 0 : _a.collect_pax;
|
|
852
|
+
const hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !== void 0 && rawCollectPax !== "";
|
|
862
853
|
const bookingCapacityValue = resolveBookingCapacityValue();
|
|
863
|
-
const pickOriginal = value => {
|
|
864
|
-
if (value && typeof value ===
|
|
854
|
+
const pickOriginal = (value) => {
|
|
855
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
865
856
|
const original = value.original;
|
|
866
|
-
return typeof original ===
|
|
857
|
+
return typeof original === "string" && original.length > 0 ? original : void 0;
|
|
867
858
|
}
|
|
868
|
-
return
|
|
859
|
+
return void 0;
|
|
869
860
|
};
|
|
870
|
-
const mainField = pickOriginal(tempOrder.table_number) ?? pickOriginal(resourceState
|
|
861
|
+
const mainField = pickOriginal(tempOrder.table_number) ?? pickOriginal((_b = resourceState == null ? void 0 : resourceState.table_form_record) == null ? void 0 : _b.name) ?? "";
|
|
871
862
|
const resourceEntry = resourceState && resourceId ? {
|
|
872
|
-
relation_type:
|
|
873
|
-
like_status:
|
|
863
|
+
relation_type: "form",
|
|
864
|
+
like_status: "common",
|
|
874
865
|
id: Number(resourceId),
|
|
875
866
|
main_field: mainField,
|
|
876
867
|
form_id: resourceState.tableFormId,
|
|
@@ -880,48 +871,43 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
880
871
|
resourceState,
|
|
881
872
|
resourceName: mainField
|
|
882
873
|
})
|
|
883
|
-
} :
|
|
884
|
-
const ruleProductUid = ruleProduct ? (0,
|
|
885
|
-
const bookingCapacityDimensionId = (0,
|
|
874
|
+
} : void 0;
|
|
875
|
+
const ruleProductUid = ruleProduct ? (0, import_utils2.createUuidV4)() : void 0;
|
|
876
|
+
const bookingCapacityDimensionId = (0, import_utils.pickFirstCustomCapacityDimensionId)(this.enabledReservationRuleProducts) ?? 0;
|
|
886
877
|
const nextBookings = (payload.bookings || []).map((booking, idx) => {
|
|
887
|
-
const metadata = {
|
|
888
|
-
...(booking.metadata || {})
|
|
889
|
-
};
|
|
878
|
+
const metadata = { ...booking.metadata || {} };
|
|
890
879
|
if (hasExplicitCollectPax) {
|
|
891
|
-
metadata.collect_pax = (0,
|
|
880
|
+
metadata.collect_pax = (0, import_utils2.normalizeSubmitCollectPaxValue)(rawCollectPax);
|
|
892
881
|
} else {
|
|
893
882
|
delete metadata.collect_pax;
|
|
894
883
|
}
|
|
895
884
|
return {
|
|
896
885
|
...booking,
|
|
897
886
|
number: bookingCapacityValue,
|
|
898
|
-
appointment_status:
|
|
887
|
+
appointment_status: "started",
|
|
899
888
|
metadata: {
|
|
900
889
|
...metadata,
|
|
901
|
-
...
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
} : {}
|
|
890
|
+
...resourceSelectType ? { resource_select_type: resourceSelectType } : {},
|
|
891
|
+
...resourceSelectType ? {
|
|
892
|
+
capacity: [
|
|
893
|
+
{
|
|
894
|
+
id: bookingCapacityDimensionId,
|
|
895
|
+
value: bookingCapacityValue,
|
|
896
|
+
name: ""
|
|
897
|
+
}
|
|
898
|
+
]
|
|
899
|
+
} : {}
|
|
911
900
|
},
|
|
912
|
-
...
|
|
913
|
-
|
|
914
|
-
} : {}),
|
|
915
|
-
...(idx === 0 && ruleProductUid ? {
|
|
916
|
-
product_uid: ruleProductUid
|
|
917
|
-
} : {})
|
|
901
|
+
...idx === 0 && resourceEntry ? { resources: [resourceEntry] } : {},
|
|
902
|
+
...idx === 0 && ruleProductUid ? { product_uid: ruleProductUid } : {}
|
|
918
903
|
};
|
|
919
904
|
});
|
|
920
|
-
const nextProducts = [...
|
|
921
|
-
// 加餐(已有 order_id)走 scanOrderMore,原单已含 booking 规则行,勿再追加虚拟规则商品
|
|
905
|
+
const nextProducts = [...payload.products || []];
|
|
922
906
|
if (ruleProduct && ruleProductUid && !tempOrder.order_id) {
|
|
923
|
-
const sellingPrice = String(ruleProduct.price ??
|
|
924
|
-
const originalPrice = String(
|
|
907
|
+
const sellingPrice = String(ruleProduct.price ?? "0.00");
|
|
908
|
+
const originalPrice = String(
|
|
909
|
+
ruleProduct.original_price ?? ruleProduct.price ?? "0.00"
|
|
910
|
+
);
|
|
925
911
|
nextProducts.push({
|
|
926
912
|
product_id: ruleProduct.id,
|
|
927
913
|
product_variant_id: 0,
|
|
@@ -930,7 +916,7 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
930
916
|
original_price: originalPrice,
|
|
931
917
|
payment_price: sellingPrice,
|
|
932
918
|
is_charge_tax: ruleProduct.is_gst ?? 0,
|
|
933
|
-
|
|
919
|
+
product_sku: { option: [] },
|
|
934
920
|
discount_list: [],
|
|
935
921
|
product_bundle: [],
|
|
936
922
|
booking_uid: bookingUuid,
|
|
@@ -941,93 +927,142 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
941
927
|
}
|
|
942
928
|
});
|
|
943
929
|
}
|
|
930
|
+
return { ...payload, bookings: nextBookings, products: nextProducts };
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
isScanOrderMoreMode(tempOrder) {
|
|
934
|
+
var _a, _b;
|
|
935
|
+
const mode = (_a = this.store.resource) == null ? void 0 : _a.mode;
|
|
936
|
+
return Boolean(
|
|
937
|
+
tempOrder.order_id && (mode === "additional_order" || mode === "additional_order_with_code" || ((_b = this.store.entryContext) == null ? void 0 : _b.mode) === "append")
|
|
938
|
+
);
|
|
939
|
+
}
|
|
940
|
+
async submitScanOrderMore(params) {
|
|
941
|
+
var _a, _b, _c, _d, _e;
|
|
942
|
+
if (!this.request) {
|
|
943
|
+
throw new Error("scanOrder解决方案需要 request 插件支持");
|
|
944
|
+
}
|
|
945
|
+
if (!this.store.order) {
|
|
946
|
+
throw new Error("scanOrder解决方案需要 order 模块支持");
|
|
947
|
+
}
|
|
948
|
+
const { tempOrder, enhancePayload } = params;
|
|
949
|
+
const latestSummary = await this.store.order.recalculateSummary({
|
|
950
|
+
createIfMissing: true
|
|
951
|
+
});
|
|
952
|
+
const payload = (0, import_utils2.buildSubmitPayload)({
|
|
953
|
+
tempOrder,
|
|
954
|
+
cacheId: this.cacheId,
|
|
955
|
+
platform: (_a = this.otherParams) == null ? void 0 : _a.platform,
|
|
956
|
+
businessCode: ((_b = this.otherParams) == null ? void 0 : _b.businessCode) || ((_c = this.otherParams) == null ? void 0 : _c.business_code),
|
|
957
|
+
channel: (_d = this.otherParams) == null ? void 0 : _d.channel,
|
|
958
|
+
type: (_e = this.otherParams) == null ? void 0 : _e.type,
|
|
959
|
+
summary: latestSummary,
|
|
960
|
+
enhance: enhancePayload
|
|
961
|
+
});
|
|
962
|
+
const products = (0, import_utils.filterProductsForScanOrderMore)(payload.products);
|
|
963
|
+
const orderId = tempOrder.order_id;
|
|
964
|
+
const result = await this.request.put(
|
|
965
|
+
`/order/order/product/${orderId}`,
|
|
966
|
+
{
|
|
967
|
+
products,
|
|
968
|
+
request_unique_idempotency_token: payload.request_unique_idempotency_token
|
|
969
|
+
},
|
|
970
|
+
{ customToast: () => {
|
|
971
|
+
} }
|
|
972
|
+
);
|
|
973
|
+
if ((result == null ? void 0 : result.code) === 200 && !(result == null ? void 0 : result.data)) {
|
|
944
974
|
return {
|
|
945
|
-
...
|
|
946
|
-
|
|
947
|
-
|
|
975
|
+
...result,
|
|
976
|
+
data: {
|
|
977
|
+
order_id: orderId
|
|
978
|
+
}
|
|
948
979
|
};
|
|
949
|
-
}
|
|
980
|
+
}
|
|
981
|
+
return result;
|
|
950
982
|
}
|
|
951
983
|
async submitScanOrder() {
|
|
952
|
-
|
|
984
|
+
var _a, _b, _c;
|
|
985
|
+
this.logMethodStart("submitScanOrder");
|
|
953
986
|
try {
|
|
954
987
|
await this.validateBeforeSubmitByItemRule();
|
|
955
988
|
if (!this.store.order) {
|
|
956
|
-
throw new Error(
|
|
989
|
+
throw new Error("scanOrder解决方案需要 order 模块支持");
|
|
957
990
|
}
|
|
991
|
+
const pax = (0, import_utils2.normalizeSubmitCollectPaxValue)(this.store.entryPaxNumber);
|
|
992
|
+
this.store.entryPaxNumber = pax;
|
|
958
993
|
const tempOrderForSubmit = this.store.order.ensureTempOrder();
|
|
959
|
-
tempOrderForSubmit.
|
|
960
|
-
|
|
961
|
-
|
|
994
|
+
tempOrderForSubmit.metadata = { ...tempOrderForSubmit.metadata, collect_pax: pax };
|
|
995
|
+
tempOrderForSubmit.delivery_type = "shop_service";
|
|
996
|
+
const resourceTableName = (_b = (_a = this.store.resource) == null ? void 0 : _a.table_form_record) == null ? void 0 : _b.name;
|
|
997
|
+
if (resourceTableName && typeof resourceTableName === "object") {
|
|
962
998
|
tempOrderForSubmit.table_number = resourceTableName;
|
|
963
999
|
} else {
|
|
964
1000
|
delete tempOrderForSubmit.table_number;
|
|
965
1001
|
}
|
|
966
1002
|
this.store.order.persistTempOrder();
|
|
967
1003
|
const enhancePayload = this.buildSubmitPayloadEnhancer();
|
|
968
|
-
const result = await this.
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
channel: this.otherParams?.channel,
|
|
973
|
-
type: this.otherParams?.type,
|
|
1004
|
+
const result = this.isScanOrderMoreMode(tempOrderForSubmit) ? await this.submitScanOrderMore({
|
|
1005
|
+
tempOrder: tempOrderForSubmit,
|
|
1006
|
+
enhancePayload
|
|
1007
|
+
}) : await this.submitSalesOrder({
|
|
974
1008
|
enhancePayload
|
|
975
1009
|
});
|
|
976
1010
|
const tempOrder = this.store.order.getTempOrder();
|
|
977
|
-
this.logMethodSuccess(
|
|
978
|
-
productCount: tempOrder
|
|
1011
|
+
this.logMethodSuccess("submitScanOrder", {
|
|
1012
|
+
productCount: ((_c = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _c.length) || 0
|
|
979
1013
|
});
|
|
980
1014
|
return result;
|
|
981
1015
|
} catch (error) {
|
|
982
|
-
this.logMethodError(
|
|
1016
|
+
this.logMethodError("submitScanOrder", error);
|
|
983
1017
|
throw error;
|
|
984
1018
|
}
|
|
985
1019
|
}
|
|
986
1020
|
async addProductToOrder(product) {
|
|
987
|
-
this.logMethodStart(
|
|
1021
|
+
this.logMethodStart("addProductToOrder", {
|
|
988
1022
|
product_id: product.product_id,
|
|
989
1023
|
product_variant_id: product.product_variant_id
|
|
990
1024
|
});
|
|
991
1025
|
try {
|
|
992
|
-
if (!this.store.order)
|
|
1026
|
+
if (!this.store.order)
|
|
1027
|
+
throw new Error("order 模块未初始化");
|
|
993
1028
|
const products = await this.store.order.addProductToOrder(product);
|
|
994
1029
|
await this.refreshItemRuleQuantityLimits();
|
|
995
1030
|
await this.refreshCartValidationPassed();
|
|
996
|
-
this.logMethodSuccess(
|
|
1031
|
+
this.logMethodSuccess("addProductToOrder", {
|
|
997
1032
|
productCount: products.length
|
|
998
1033
|
});
|
|
999
1034
|
return products;
|
|
1000
1035
|
} catch (error) {
|
|
1001
|
-
this.logMethodError(
|
|
1036
|
+
this.logMethodError("addProductToOrder", error);
|
|
1002
1037
|
throw error;
|
|
1003
1038
|
}
|
|
1004
1039
|
}
|
|
1005
|
-
async
|
|
1006
|
-
this.logMethodStart(
|
|
1040
|
+
async updateOrderProduct(params) {
|
|
1041
|
+
this.logMethodStart("updateOrderProduct", {
|
|
1007
1042
|
product_id: params.product_id,
|
|
1008
1043
|
product_variant_id: params.product_variant_id
|
|
1009
1044
|
});
|
|
1010
1045
|
try {
|
|
1011
|
-
if (!this.store.order)
|
|
1012
|
-
|
|
1046
|
+
if (!this.store.order)
|
|
1047
|
+
throw new Error("order 模块未初始化");
|
|
1048
|
+
const products = await this.store.order.updateOrderProduct(params);
|
|
1013
1049
|
await this.refreshItemRuleQuantityLimits();
|
|
1014
1050
|
await this.refreshCartValidationPassed();
|
|
1015
|
-
this.logMethodSuccess(
|
|
1051
|
+
this.logMethodSuccess("updateOrderProduct", {
|
|
1016
1052
|
productCount: products.length
|
|
1017
1053
|
});
|
|
1018
1054
|
return products;
|
|
1019
1055
|
} catch (error) {
|
|
1020
|
-
this.logMethodError(
|
|
1056
|
+
this.logMethodError("updateOrderProduct", error);
|
|
1021
1057
|
throw error;
|
|
1022
1058
|
}
|
|
1023
1059
|
}
|
|
1024
|
-
|
|
1025
1060
|
/**
|
|
1026
1061
|
* 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
|
|
1027
1062
|
* 多行同 SKU 时必须传入与删除/更新一致的 identity(如 `identity_key`)。
|
|
1028
1063
|
*/
|
|
1029
1064
|
async setOrderProductLineNote(identity, note) {
|
|
1030
|
-
this.logMethodStart(
|
|
1065
|
+
this.logMethodStart("setOrderProductLineNote", {
|
|
1031
1066
|
product_id: identity.product_id,
|
|
1032
1067
|
product_variant_id: identity.product_variant_id
|
|
1033
1068
|
});
|
|
@@ -1035,47 +1070,46 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
1035
1070
|
const params = {
|
|
1036
1071
|
product_id: identity.product_id,
|
|
1037
1072
|
product_variant_id: identity.product_variant_id,
|
|
1038
|
-
updates: {
|
|
1039
|
-
note: String(note || '')
|
|
1040
|
-
}
|
|
1073
|
+
updates: { note: String(note || "") }
|
|
1041
1074
|
};
|
|
1042
|
-
if (identity.identity_key !==
|
|
1043
|
-
|
|
1044
|
-
|
|
1075
|
+
if (identity.identity_key !== void 0)
|
|
1076
|
+
params.identity_key = identity.identity_key;
|
|
1077
|
+
if (identity.product_sku !== void 0) {
|
|
1078
|
+
params.product_sku = identity.product_sku;
|
|
1045
1079
|
}
|
|
1046
|
-
if (identity.product_bundle !==
|
|
1047
|
-
|
|
1048
|
-
this.
|
|
1049
|
-
|
|
1050
|
-
});
|
|
1080
|
+
if (identity.product_bundle !== void 0)
|
|
1081
|
+
params.product_bundle = identity.product_bundle;
|
|
1082
|
+
const products = await this.updateOrderProduct(params);
|
|
1083
|
+
this.logMethodSuccess("setOrderProductLineNote", { productCount: products.length });
|
|
1051
1084
|
return products;
|
|
1052
1085
|
} catch (error) {
|
|
1053
|
-
this.logMethodError(
|
|
1086
|
+
this.logMethodError("setOrderProductLineNote", error);
|
|
1054
1087
|
throw error;
|
|
1055
1088
|
}
|
|
1056
1089
|
}
|
|
1057
1090
|
async removeProductFromOrder(identity) {
|
|
1058
|
-
this.logMethodStart(
|
|
1091
|
+
this.logMethodStart("removeProductFromOrder", {
|
|
1059
1092
|
product_id: identity.product_id,
|
|
1060
1093
|
product_variant_id: identity.product_variant_id
|
|
1061
1094
|
});
|
|
1062
1095
|
try {
|
|
1063
|
-
if (!this.store.order)
|
|
1096
|
+
if (!this.store.order)
|
|
1097
|
+
throw new Error("order 模块未初始化");
|
|
1064
1098
|
const products = await this.store.order.removeProductFromOrder(identity);
|
|
1065
1099
|
await this.refreshItemRuleQuantityLimits();
|
|
1066
1100
|
await this.refreshCartValidationPassed();
|
|
1067
|
-
this.logMethodSuccess(
|
|
1101
|
+
this.logMethodSuccess("removeProductFromOrder", {
|
|
1068
1102
|
productCount: products.length
|
|
1069
1103
|
});
|
|
1070
1104
|
return products;
|
|
1071
1105
|
} catch (error) {
|
|
1072
|
-
this.logMethodError(
|
|
1106
|
+
this.logMethodError("removeProductFromOrder", error);
|
|
1073
1107
|
throw error;
|
|
1074
1108
|
}
|
|
1075
1109
|
}
|
|
1076
1110
|
async loadRuntimeConfigs() {
|
|
1077
1111
|
const itemRuleConfigs = await this.ensureItemRuleConfigsLoaded();
|
|
1078
|
-
this.logMethodSuccess(
|
|
1112
|
+
this.logMethodSuccess("loadRuntimeConfigs", {
|
|
1079
1113
|
itemRuleCount: itemRuleConfigs.length
|
|
1080
1114
|
});
|
|
1081
1115
|
return {
|
|
@@ -1083,24 +1117,28 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
1083
1117
|
};
|
|
1084
1118
|
}
|
|
1085
1119
|
async syncItemRuleConfigsFromDineInConfig(dineInConfig) {
|
|
1086
|
-
const enableItemRules = (0,
|
|
1087
|
-
const strategyModelIds = (0,
|
|
1120
|
+
const enableItemRules = (0, import_utils.toBoolean)(dineInConfig == null ? void 0 : dineInConfig["sale.enable_item_rules"]);
|
|
1121
|
+
const strategyModelIds = (0, import_utils.normalizeEnabledItemRuleIds)(
|
|
1122
|
+
dineInConfig == null ? void 0 : dineInConfig["sale.enabled_item_rules"]
|
|
1123
|
+
);
|
|
1088
1124
|
if (!enableItemRules || !strategyModelIds.length) {
|
|
1089
1125
|
this.itemRuleConfigs = [];
|
|
1090
1126
|
this.itemRuleConfigsPromise = Promise.resolve([]);
|
|
1091
1127
|
this.itemRuleEvaluator.setStrategyConfigs([]);
|
|
1092
|
-
this.logMethodSuccess(
|
|
1128
|
+
this.logMethodSuccess("syncItemRuleConfigsFromDineInConfig", {
|
|
1093
1129
|
enabled: enableItemRules,
|
|
1094
1130
|
strategyModelIds: [],
|
|
1095
1131
|
itemRuleCount: 0
|
|
1096
1132
|
});
|
|
1097
1133
|
return [];
|
|
1098
1134
|
}
|
|
1099
|
-
const itemRuleConfigs = await this.fetchItemRuleConfigsByModelIds(
|
|
1135
|
+
const itemRuleConfigs = await this.fetchItemRuleConfigsByModelIds(
|
|
1136
|
+
strategyModelIds
|
|
1137
|
+
);
|
|
1100
1138
|
this.itemRuleConfigs = itemRuleConfigs;
|
|
1101
1139
|
this.itemRuleConfigsPromise = Promise.resolve(itemRuleConfigs);
|
|
1102
1140
|
this.itemRuleEvaluator.setStrategyConfigs(itemRuleConfigs);
|
|
1103
|
-
this.logMethodSuccess(
|
|
1141
|
+
this.logMethodSuccess("syncItemRuleConfigsFromDineInConfig", {
|
|
1104
1142
|
enabled: enableItemRules,
|
|
1105
1143
|
strategyModelIds,
|
|
1106
1144
|
itemRuleCount: itemRuleConfigs.length
|
|
@@ -1108,70 +1146,76 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
1108
1146
|
return itemRuleConfigs;
|
|
1109
1147
|
}
|
|
1110
1148
|
async fetchItemRuleConfigsByModelIds(strategyModelIds) {
|
|
1111
|
-
this.logMethodStart(
|
|
1149
|
+
this.logMethodStart("fetchItemRuleConfigsByModelIds", {
|
|
1112
1150
|
strategyModelIds
|
|
1113
1151
|
});
|
|
1114
|
-
if (!strategyModelIds.length)
|
|
1152
|
+
if (!strategyModelIds.length)
|
|
1153
|
+
return [];
|
|
1115
1154
|
try {
|
|
1116
|
-
const result = await this.request.get(
|
|
1155
|
+
const result = await this.request.get("/promotion", {
|
|
1117
1156
|
skip: 1,
|
|
1118
1157
|
num: 99,
|
|
1119
|
-
status:
|
|
1158
|
+
status: "active",
|
|
1120
1159
|
ids: strategyModelIds
|
|
1121
1160
|
});
|
|
1122
1161
|
let configs = [];
|
|
1123
1162
|
if (result.code === 200) {
|
|
1124
|
-
configs = result.data.list.map(item => {
|
|
1163
|
+
configs = result.data.list.map((item) => {
|
|
1125
1164
|
return item.metadata;
|
|
1126
1165
|
});
|
|
1127
1166
|
}
|
|
1128
|
-
this.logMethodSuccess(
|
|
1167
|
+
this.logMethodSuccess("fetchItemRuleConfigsByModelIds", {
|
|
1129
1168
|
strategyModelIds,
|
|
1130
1169
|
strategyCount: configs.length
|
|
1131
1170
|
});
|
|
1132
1171
|
return configs;
|
|
1133
1172
|
} catch (error) {
|
|
1134
|
-
this.logMethodError(
|
|
1173
|
+
this.logMethodError("fetchItemRuleConfigsByModelIds", error, {
|
|
1135
1174
|
strategyModelIds
|
|
1136
1175
|
});
|
|
1137
|
-
// A:策略加载失败时不阻塞下单
|
|
1138
1176
|
return [];
|
|
1139
1177
|
}
|
|
1140
1178
|
}
|
|
1141
1179
|
async buildPrefillProductSourceMap() {
|
|
1142
|
-
const sourceMap = new Map();
|
|
1180
|
+
const sourceMap = /* @__PURE__ */ new Map();
|
|
1143
1181
|
try {
|
|
1144
1182
|
const productList = await this.getProductList();
|
|
1145
|
-
if (!Array.isArray(productList))
|
|
1146
|
-
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1149
|
-
if (
|
|
1183
|
+
if (!Array.isArray(productList))
|
|
1184
|
+
return sourceMap;
|
|
1185
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1186
|
+
const collectFromValue = (value) => {
|
|
1187
|
+
if (!value || typeof value !== "object")
|
|
1188
|
+
return;
|
|
1189
|
+
if (visited.has(value))
|
|
1190
|
+
return;
|
|
1150
1191
|
visited.add(value);
|
|
1151
1192
|
if (Array.isArray(value)) {
|
|
1152
|
-
for (const item of value)
|
|
1193
|
+
for (const item of value)
|
|
1194
|
+
collectFromValue(item);
|
|
1153
1195
|
return;
|
|
1154
1196
|
}
|
|
1155
1197
|
const node = value;
|
|
1156
1198
|
const rawProductId = node.product_id ?? node.id;
|
|
1157
1199
|
const productId = Number(rawProductId);
|
|
1158
1200
|
if (Number.isFinite(productId) && productId > 0) {
|
|
1159
|
-
const productVariantId = Number(
|
|
1201
|
+
const productVariantId = Number(
|
|
1202
|
+
node.product_variant_id ?? node.variant_id ?? 0
|
|
1203
|
+
);
|
|
1160
1204
|
const normalizedVariantId = Number.isNaN(productVariantId) ? 0 : productVariantId;
|
|
1161
|
-
const key = (0,
|
|
1205
|
+
const key = (0, import_utils.buildProductKey)(productId, normalizedVariantId);
|
|
1162
1206
|
if (!sourceMap.has(key)) {
|
|
1163
1207
|
sourceMap.set(key, node);
|
|
1164
1208
|
}
|
|
1165
1209
|
}
|
|
1166
1210
|
for (const childValue of Object.values(node)) {
|
|
1167
|
-
if (childValue && typeof childValue ===
|
|
1211
|
+
if (childValue && typeof childValue === "object") {
|
|
1168
1212
|
collectFromValue(childValue);
|
|
1169
1213
|
}
|
|
1170
1214
|
}
|
|
1171
1215
|
};
|
|
1172
1216
|
collectFromValue(productList);
|
|
1173
1217
|
} catch (error) {
|
|
1174
|
-
this.logMethodError(
|
|
1218
|
+
this.logMethodError("buildPrefillProductSourceMap", error);
|
|
1175
1219
|
}
|
|
1176
1220
|
return sourceMap;
|
|
1177
1221
|
}
|
|
@@ -1179,11 +1223,13 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
1179
1223
|
return this.itemRuleRuntimeConfig || {};
|
|
1180
1224
|
}
|
|
1181
1225
|
async ensureItemRuleConfigsLoaded() {
|
|
1182
|
-
if (this.itemRuleConfigs.length > 0)
|
|
1183
|
-
|
|
1226
|
+
if (this.itemRuleConfigs.length > 0)
|
|
1227
|
+
return this.itemRuleConfigs;
|
|
1228
|
+
if (this.itemRuleConfigsPromise)
|
|
1229
|
+
return this.itemRuleConfigsPromise;
|
|
1184
1230
|
this.itemRuleConfigsPromise = (async () => {
|
|
1185
1231
|
const runtimeConfig = this.getItemRuleRuntimeConfig();
|
|
1186
|
-
const staticConfigs = (0,
|
|
1232
|
+
const staticConfigs = (0, import_utils.normalizeItemRuleStrategies)(runtimeConfig.strategyConfigs);
|
|
1187
1233
|
if (staticConfigs.length > 0) {
|
|
1188
1234
|
this.itemRuleConfigs = staticConfigs;
|
|
1189
1235
|
this.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
|
|
@@ -1203,30 +1249,34 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
1203
1249
|
this.store.itemRuleQuantityLimits = [];
|
|
1204
1250
|
return [];
|
|
1205
1251
|
}
|
|
1206
|
-
const businessData = (0,
|
|
1207
|
-
tempOrder: this.
|
|
1252
|
+
const businessData = (0, import_utils.buildItemRuleBusinessData)({
|
|
1253
|
+
tempOrder: this.ensureScanOrderTempOrder(),
|
|
1208
1254
|
runtimeConfig: this.getItemRuleRuntimeConfig(),
|
|
1209
1255
|
itemRuleConfigs: this.itemRuleConfigs
|
|
1210
1256
|
});
|
|
1211
1257
|
const limits = this.itemRuleEvaluator.getQuantityLimits(businessData);
|
|
1212
1258
|
this.store.itemRuleQuantityLimits = limits;
|
|
1213
|
-
this.logMethodSuccess(
|
|
1259
|
+
this.logMethodSuccess("refreshItemRuleQuantityLimits", {
|
|
1214
1260
|
limitCount: limits.length
|
|
1215
1261
|
});
|
|
1216
1262
|
return limits;
|
|
1217
1263
|
} catch (error) {
|
|
1218
1264
|
this.store.itemRuleQuantityLimits = [];
|
|
1219
|
-
this.logMethodError(
|
|
1265
|
+
this.logMethodError("refreshItemRuleQuantityLimits", error);
|
|
1220
1266
|
return [];
|
|
1221
1267
|
}
|
|
1222
1268
|
}
|
|
1223
1269
|
async applyPrefillByItemRule() {
|
|
1224
|
-
|
|
1225
|
-
if (
|
|
1270
|
+
var _a, _b, _c;
|
|
1271
|
+
if (this.itemRulePrefillApplied)
|
|
1272
|
+
return;
|
|
1273
|
+
if (!this.store.order)
|
|
1274
|
+
return;
|
|
1226
1275
|
const strategyConfigs = await this.ensureItemRuleConfigsLoaded();
|
|
1227
|
-
if (!strategyConfigs.length)
|
|
1228
|
-
|
|
1229
|
-
|
|
1276
|
+
if (!strategyConfigs.length)
|
|
1277
|
+
return;
|
|
1278
|
+
const businessData = (0, import_utils.buildItemRuleBusinessData)({
|
|
1279
|
+
tempOrder: this.ensureScanOrderTempOrder(),
|
|
1230
1280
|
runtimeConfig: this.getItemRuleRuntimeConfig(),
|
|
1231
1281
|
itemRuleConfigs: this.itemRuleConfigs
|
|
1232
1282
|
});
|
|
@@ -1236,86 +1286,93 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
1236
1286
|
return;
|
|
1237
1287
|
}
|
|
1238
1288
|
const productSourceMap = await this.buildPrefillProductSourceMap();
|
|
1239
|
-
const tempOrder = this.
|
|
1289
|
+
const tempOrder = this.ensureScanOrderTempOrder();
|
|
1240
1290
|
let hasChanges = false;
|
|
1241
1291
|
for (const prefillItem of prefillItems) {
|
|
1242
1292
|
const productId = Number(prefillItem.product_id);
|
|
1243
1293
|
const productVariantId = Number(prefillItem.product_variant_id ?? 0);
|
|
1244
|
-
const targetQuantity = (0,
|
|
1245
|
-
if (!Number.isFinite(productId) || targetQuantity <= 0)
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1294
|
+
const targetQuantity = (0, import_utils.toNonNegativeInt)(prefillItem.quantity);
|
|
1295
|
+
if (!Number.isFinite(productId) || targetQuantity <= 0)
|
|
1296
|
+
continue;
|
|
1297
|
+
if (Number.isNaN(productVariantId))
|
|
1298
|
+
continue;
|
|
1299
|
+
const sourceItem = productSourceMap.get(
|
|
1300
|
+
(0, import_utils.buildProductKey)(productId, productVariantId)
|
|
1301
|
+
) || productSourceMap.get((0, import_utils.buildProductKey)(productId, 0)) || null;
|
|
1302
|
+
const productIndex = (0, import_utils.getProductIdentityIndex)(tempOrder.products, {
|
|
1249
1303
|
product_id: productId,
|
|
1250
1304
|
product_variant_id: productVariantId
|
|
1251
1305
|
});
|
|
1252
1306
|
if (productIndex === -1) {
|
|
1253
|
-
const sellingPrice = (0,
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1307
|
+
const sellingPrice = (0, import_utils.toPriceString)(
|
|
1308
|
+
(sourceItem == null ? void 0 : sourceItem.price) ?? (sourceItem == null ? void 0 : sourceItem.selling_price),
|
|
1309
|
+
"0.00"
|
|
1310
|
+
);
|
|
1311
|
+
tempOrder.products.push(
|
|
1312
|
+
(0, import_utils.normalizeOrderProduct)({
|
|
1313
|
+
...sourceItem,
|
|
1314
|
+
product_id: productId,
|
|
1315
|
+
product_variant_id: productVariantId,
|
|
1316
|
+
num: targetQuantity,
|
|
1317
|
+
selling_price: sellingPrice,
|
|
1318
|
+
original_price: sellingPrice,
|
|
1319
|
+
metadata: {
|
|
1320
|
+
item_rule_prefill: true,
|
|
1321
|
+
item_rule_id: prefillItem.ruleId
|
|
1322
|
+
},
|
|
1323
|
+
_origin: {
|
|
1324
|
+
...sourceItem || {},
|
|
1325
|
+
item_rule_prefill: true,
|
|
1326
|
+
item_rule_id: prefillItem.ruleId
|
|
1327
|
+
}
|
|
1328
|
+
})
|
|
1329
|
+
);
|
|
1271
1330
|
hasChanges = true;
|
|
1272
1331
|
continue;
|
|
1273
1332
|
}
|
|
1274
1333
|
const targetProduct = tempOrder.products[productIndex];
|
|
1275
|
-
const existedQuantity = (0,
|
|
1334
|
+
const existedQuantity = (0, import_utils.toNonNegativeInt)(targetProduct.num);
|
|
1276
1335
|
const delta = targetQuantity - existedQuantity;
|
|
1277
1336
|
const nextProduct = {
|
|
1278
1337
|
...targetProduct,
|
|
1279
|
-
...
|
|
1280
|
-
num: (0, _utils.getSafeProductNum)(existedQuantity + delta)
|
|
1281
|
-
} : {}),
|
|
1338
|
+
...delta > 0 ? { num: (0, import_utils.getSafeProductNum)(existedQuantity + delta) } : {},
|
|
1282
1339
|
metadata: {
|
|
1283
|
-
...
|
|
1340
|
+
...targetProduct.metadata || {},
|
|
1284
1341
|
item_rule_prefill: true,
|
|
1285
1342
|
item_rule_id: prefillItem.ruleId
|
|
1286
1343
|
},
|
|
1287
1344
|
_origin: sourceItem ? {
|
|
1288
|
-
...
|
|
1345
|
+
...targetProduct._origin || {},
|
|
1289
1346
|
...sourceItem
|
|
1290
1347
|
} : targetProduct._origin
|
|
1291
1348
|
};
|
|
1292
1349
|
const hasQuantityChanged = delta > 0;
|
|
1293
|
-
const hasOriginChanged = Boolean(
|
|
1350
|
+
const hasOriginChanged = Boolean(
|
|
1351
|
+
sourceItem && (!targetProduct._origin || ((_a = targetProduct._origin) == null ? void 0 : _a.name) !== (sourceItem == null ? void 0 : sourceItem.name) || ((_b = targetProduct._origin) == null ? void 0 : _b.title) !== (sourceItem == null ? void 0 : sourceItem.title) || ((_c = targetProduct._origin) == null ? void 0 : _c.price) !== (sourceItem == null ? void 0 : sourceItem.price))
|
|
1352
|
+
);
|
|
1294
1353
|
if (hasQuantityChanged || hasOriginChanged) {
|
|
1295
1354
|
tempOrder.products[productIndex] = nextProduct;
|
|
1296
1355
|
hasChanges = true;
|
|
1297
1356
|
}
|
|
1298
1357
|
}
|
|
1299
1358
|
if (hasChanges) {
|
|
1300
|
-
// Prefill 属于 products CRUD 的一种形式:新增后让 Rules 重算,以支持自动应用可用优惠券。
|
|
1301
1359
|
this.store.order.applyDiscount();
|
|
1302
|
-
await this.store.order.recalculateSummary({
|
|
1303
|
-
createIfMissing: true
|
|
1304
|
-
});
|
|
1360
|
+
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
1305
1361
|
this.store.order.persistTempOrder();
|
|
1306
1362
|
}
|
|
1307
1363
|
await this.refreshItemRuleQuantityLimits();
|
|
1308
1364
|
this.itemRulePrefillApplied = true;
|
|
1309
|
-
this.logMethodSuccess(
|
|
1365
|
+
this.logMethodSuccess("applyPrefillByItemRule", {
|
|
1310
1366
|
prefillCount: prefillItems.length,
|
|
1311
1367
|
hasChanges
|
|
1312
1368
|
});
|
|
1313
1369
|
}
|
|
1314
1370
|
async applyItemRulePrefill() {
|
|
1315
|
-
|
|
1371
|
+
var _a, _b;
|
|
1372
|
+
if ((_b = (_a = this.store.order) == null ? void 0 : _a.getLastOrderInfo) == null ? void 0 : _b.call(_a)) {
|
|
1316
1373
|
return;
|
|
1317
1374
|
}
|
|
1318
|
-
this.logMethodStart(
|
|
1375
|
+
this.logMethodStart("applyItemRulePrefill");
|
|
1319
1376
|
await this.applyPrefillByItemRule();
|
|
1320
1377
|
await this.refreshItemRuleQuantityLimits();
|
|
1321
1378
|
await this.refreshCartValidationPassed();
|
|
@@ -1328,8 +1385,8 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
1328
1385
|
failures: []
|
|
1329
1386
|
};
|
|
1330
1387
|
}
|
|
1331
|
-
const businessData = (0,
|
|
1332
|
-
tempOrder: this.
|
|
1388
|
+
const businessData = (0, import_utils.buildItemRuleBusinessData)({
|
|
1389
|
+
tempOrder: this.ensureScanOrderTempOrder(),
|
|
1333
1390
|
runtimeConfig: this.getItemRuleRuntimeConfig(),
|
|
1334
1391
|
itemRuleConfigs: this.itemRuleConfigs
|
|
1335
1392
|
});
|
|
@@ -1337,9 +1394,10 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
1337
1394
|
}
|
|
1338
1395
|
async validateBeforeSubmitByItemRule() {
|
|
1339
1396
|
const validationResult = await this.evaluateCartValidationByItemRule();
|
|
1340
|
-
if (validationResult.passed)
|
|
1397
|
+
if (validationResult.passed)
|
|
1398
|
+
return;
|
|
1341
1399
|
const firstFailure = validationResult.failures[0];
|
|
1342
|
-
const errorMessage = firstFailure
|
|
1400
|
+
const errorMessage = (firstFailure == null ? void 0 : firstFailure.validationMessage) || "当前购物车未满足商品规则,请调整后再提交";
|
|
1343
1401
|
const error = new Error(String(errorMessage));
|
|
1344
1402
|
error.failures = validationResult.failures;
|
|
1345
1403
|
throw error;
|
|
@@ -1368,7 +1426,7 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
1368
1426
|
this.store.cartValidation = nextState;
|
|
1369
1427
|
const changed = previous.passed !== nextState.passed || previous.failures !== nextState.failures;
|
|
1370
1428
|
if (changed) {
|
|
1371
|
-
await this.core.effects.emit(
|
|
1429
|
+
await this.core.effects.emit(import_types.ScanOrderHooks.onCartValidationChanged, {
|
|
1372
1430
|
cartValidation: nextState,
|
|
1373
1431
|
cartValidationPassed: nextState.passed
|
|
1374
1432
|
});
|
|
@@ -1376,20 +1434,21 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
1376
1434
|
return nextState.passed;
|
|
1377
1435
|
}
|
|
1378
1436
|
async setItemRuleRuntimeConfig(config = {}) {
|
|
1379
|
-
|
|
1437
|
+
var _a, _b;
|
|
1438
|
+
this.logMethodStart("setItemRuleRuntimeConfig");
|
|
1380
1439
|
this.itemRuleRuntimeConfig = {
|
|
1381
1440
|
...this.itemRuleRuntimeConfig,
|
|
1382
1441
|
...config,
|
|
1383
1442
|
pax: {
|
|
1384
|
-
...(this.itemRuleRuntimeConfig
|
|
1385
|
-
...(config
|
|
1443
|
+
...((_a = this.itemRuleRuntimeConfig) == null ? void 0 : _a.pax) || {},
|
|
1444
|
+
...(config == null ? void 0 : config.pax) || {}
|
|
1386
1445
|
},
|
|
1387
1446
|
custom: {
|
|
1388
|
-
...(this.itemRuleRuntimeConfig
|
|
1389
|
-
...(config
|
|
1447
|
+
...((_b = this.itemRuleRuntimeConfig) == null ? void 0 : _b.custom) || {},
|
|
1448
|
+
...(config == null ? void 0 : config.custom) || {}
|
|
1390
1449
|
}
|
|
1391
1450
|
};
|
|
1392
|
-
if (
|
|
1451
|
+
if ("strategyConfigs" in config) {
|
|
1393
1452
|
this.itemRuleConfigs = [];
|
|
1394
1453
|
this.itemRuleConfigsPromise = null;
|
|
1395
1454
|
this.itemRuleEvaluator.setStrategyConfigs([]);
|
|
@@ -1397,47 +1456,42 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
1397
1456
|
this.itemRulePrefillApplied = false;
|
|
1398
1457
|
await this.refreshItemRuleQuantityLimits();
|
|
1399
1458
|
await this.refreshCartValidationPassed();
|
|
1400
|
-
this.logMethodSuccess(
|
|
1459
|
+
this.logMethodSuccess("setItemRuleRuntimeConfig", {
|
|
1401
1460
|
strategyCount: Array.isArray(this.itemRuleRuntimeConfig.strategyConfigs) ? this.itemRuleRuntimeConfig.strategyConfigs.length : 0
|
|
1402
1461
|
});
|
|
1403
1462
|
}
|
|
1404
1463
|
normalizeResourceState(detail, resourceSelectType, hasOrderId) {
|
|
1405
|
-
|
|
1406
|
-
const
|
|
1407
|
-
const
|
|
1408
|
-
const
|
|
1409
|
-
const
|
|
1410
|
-
|
|
1411
|
-
const allowSnack = this.otherParams
|
|
1412
|
-
// 开启同桌验证 - 本期没有这个配置,默认关掉
|
|
1464
|
+
var _a, _b, _c, _d;
|
|
1465
|
+
const currentOrderId = (0, import_utils.toPositiveString)(detail == null ? void 0 : detail.order_id);
|
|
1466
|
+
const lastOrderId = (0, import_utils.toPositiveString)(detail == null ? void 0 : detail.last_order_id);
|
|
1467
|
+
const relationId = (0, import_utils.toPositiveString)(detail == null ? void 0 : detail.form_record_id);
|
|
1468
|
+
const tableFormId = (0, import_utils.toPositiveString)(detail == null ? void 0 : detail.form_id);
|
|
1469
|
+
const formRecord = (detail == null ? void 0 : detail.form_record) ?? null;
|
|
1470
|
+
const allowSnack = ((_b = (_a = this.otherParams) == null ? void 0 : _a.dineInConfig) == null ? void 0 : _b["sale.allow_add_items"]) || false;
|
|
1413
1471
|
const deskmateValid = false;
|
|
1414
|
-
const isExclusive = resourceSelectType ===
|
|
1415
|
-
const isFull = (0,
|
|
1472
|
+
const isExclusive = resourceSelectType === "single";
|
|
1473
|
+
const isFull = (0, import_utils.computeResourceIsFull)({
|
|
1416
1474
|
resourceSelectType,
|
|
1417
1475
|
lastOrderId,
|
|
1418
|
-
capacityList: detail
|
|
1419
|
-
capacity: formRecord
|
|
1476
|
+
capacityList: ((_d = (_c = detail == null ? void 0 : detail.resource_capacity) == null ? void 0 : _c[0]) == null ? void 0 : _d.capacity_list) ?? [],
|
|
1477
|
+
capacity: formRecord == null ? void 0 : formRecord.capacity
|
|
1420
1478
|
});
|
|
1421
1479
|
let availabilityInfo = {
|
|
1422
|
-
mode:
|
|
1480
|
+
mode: "idle",
|
|
1423
1481
|
deskmate_valid: deskmateValid
|
|
1424
1482
|
};
|
|
1425
|
-
|
|
1426
|
-
// 有currentOrderId代表是我点的单
|
|
1427
|
-
// 如果 url 上没有 hasOrderId,则跳转到订单详情,通过返回 resource_busy 实现
|
|
1428
1483
|
if (currentOrderId) {
|
|
1429
1484
|
if (!hasOrderId) {
|
|
1430
1485
|
availabilityInfo = {
|
|
1431
|
-
mode:
|
|
1486
|
+
mode: "resource_busy",
|
|
1432
1487
|
order_id: currentOrderId,
|
|
1433
1488
|
relation_id: relationId,
|
|
1434
1489
|
table_form_id: tableFormId,
|
|
1435
1490
|
deskmate_valid: deskmateValid
|
|
1436
1491
|
};
|
|
1437
1492
|
} else {
|
|
1438
|
-
// 如果有 hasOrderId,需要检测是否允许加餐,如果允许则返回additional_order,否则也是 resource_busy
|
|
1439
1493
|
availabilityInfo = {
|
|
1440
|
-
mode: allowSnack ?
|
|
1494
|
+
mode: allowSnack ? "additional_order" : "resource_busy",
|
|
1441
1495
|
order_id: currentOrderId,
|
|
1442
1496
|
relation_id: relationId,
|
|
1443
1497
|
table_form_id: tableFormId,
|
|
@@ -1445,13 +1499,11 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
1445
1499
|
};
|
|
1446
1500
|
}
|
|
1447
1501
|
} else if (lastOrderId) {
|
|
1448
|
-
|
|
1449
|
-
// multiple 预约且容量仍有剩余时,其他人的单不影响当前用户下单,保持 idle 走正常下单流程
|
|
1450
|
-
const canFallthroughToIdle = resourceSelectType === 'multiple' && !isFull;
|
|
1502
|
+
const canFallthroughToIdle = resourceSelectType === "multiple" && !isFull;
|
|
1451
1503
|
if (!canFallthroughToIdle) {
|
|
1452
1504
|
availabilityInfo = {
|
|
1453
|
-
mode:
|
|
1454
|
-
order_id:
|
|
1505
|
+
mode: "resource_busy",
|
|
1506
|
+
order_id: "0",
|
|
1455
1507
|
relation_id: relationId,
|
|
1456
1508
|
table_form_id: tableFormId,
|
|
1457
1509
|
deskmate_valid: deskmateValid
|
|
@@ -1473,62 +1525,67 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
1473
1525
|
table_form_record: formRecord
|
|
1474
1526
|
};
|
|
1475
1527
|
}
|
|
1476
|
-
|
|
1477
1528
|
// 从首个预约规则商品的 product_resource.resources 中,按 form_id 匹配返回 type
|
|
1478
1529
|
resolveResourceSelectType(formId) {
|
|
1530
|
+
var _a;
|
|
1479
1531
|
const firstProduct = this.enabledReservationRuleProducts[0];
|
|
1480
|
-
const resources = firstProduct
|
|
1532
|
+
const resources = ((_a = firstProduct == null ? void 0 : firstProduct.product_resource) == null ? void 0 : _a.resources) || [];
|
|
1481
1533
|
const numericFormId = Number(formId);
|
|
1482
|
-
if (!Number.isFinite(numericFormId) || numericFormId <= 0)
|
|
1483
|
-
|
|
1484
|
-
|
|
1534
|
+
if (!Number.isFinite(numericFormId) || numericFormId <= 0)
|
|
1535
|
+
return void 0;
|
|
1536
|
+
const matched = resources.find((r) => Number(r == null ? void 0 : r.id) === numericFormId);
|
|
1537
|
+
return matched == null ? void 0 : matched.type;
|
|
1485
1538
|
}
|
|
1486
1539
|
async fetchResourceOccupyDetailsByResourceId(resourceId) {
|
|
1540
|
+
var _a, _b, _c;
|
|
1487
1541
|
const formRecordId = Number(resourceId);
|
|
1488
1542
|
if (!Number.isFinite(formRecordId) || formRecordId <= 0) {
|
|
1489
1543
|
throw new Error(`[ScanOrder] 非法桌台 resourceId: ${resourceId}`);
|
|
1490
1544
|
}
|
|
1491
|
-
const shopId = this.otherParams
|
|
1545
|
+
const shopId = (_b = (_a = this.otherParams) == null ? void 0 : _a.getStateData) == null ? void 0 : _b.call(_a, "shop_id");
|
|
1492
1546
|
if (!shopId) {
|
|
1493
|
-
throw new Error(
|
|
1494
|
-
}
|
|
1495
|
-
const response = await this.request.get(
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1547
|
+
throw new Error("[ScanOrder] 无法获取 shop_id");
|
|
1548
|
+
}
|
|
1549
|
+
const response = await this.request.get(
|
|
1550
|
+
"/order/resource/occupy-detail",
|
|
1551
|
+
{
|
|
1552
|
+
shop_id: shopId,
|
|
1553
|
+
"form_record_ids[]": formRecordId,
|
|
1554
|
+
with_resource_capacity_info: 1,
|
|
1555
|
+
with_resource_order_info: 1,
|
|
1556
|
+
with_resource_form_info: 1
|
|
1557
|
+
}
|
|
1558
|
+
);
|
|
1559
|
+
if (!(response == null ? void 0 : response.status)) {
|
|
1560
|
+
throw new Error((response == null ? void 0 : response.message) || "获取资源占用详情失败");
|
|
1504
1561
|
}
|
|
1505
|
-
return response
|
|
1562
|
+
return ((_c = response == null ? void 0 : response.data) == null ? void 0 : _c.occupy_details) ?? [];
|
|
1506
1563
|
}
|
|
1507
1564
|
resolveAdditionalOrderFromOccupyDetail(detail, resourceSelectType, allowAddItems) {
|
|
1508
|
-
const currentOrderId = (0,
|
|
1565
|
+
const currentOrderId = (0, import_utils.toPositiveString)(detail == null ? void 0 : detail.order_id);
|
|
1509
1566
|
if (currentOrderId) {
|
|
1510
1567
|
return {
|
|
1511
1568
|
matched: true,
|
|
1512
1569
|
order_id: currentOrderId
|
|
1513
1570
|
};
|
|
1514
1571
|
}
|
|
1515
|
-
const orderListIds = (Array.isArray(detail
|
|
1516
|
-
if (resourceSelectType !==
|
|
1572
|
+
const orderListIds = (Array.isArray(detail == null ? void 0 : detail.order_list) ? (detail == null ? void 0 : detail.order_list) || [] : []).map((order) => (0, import_utils.toPositiveString)(order == null ? void 0 : order.id)).filter(Boolean);
|
|
1573
|
+
if (resourceSelectType !== "single") {
|
|
1517
1574
|
return {
|
|
1518
1575
|
matched: false,
|
|
1519
|
-
reason:
|
|
1576
|
+
reason: "no_order"
|
|
1520
1577
|
};
|
|
1521
1578
|
}
|
|
1522
1579
|
if (!orderListIds.length) {
|
|
1523
1580
|
return {
|
|
1524
1581
|
matched: false,
|
|
1525
|
-
reason:
|
|
1582
|
+
reason: "no_order"
|
|
1526
1583
|
};
|
|
1527
1584
|
}
|
|
1528
1585
|
if (!allowAddItems) {
|
|
1529
1586
|
return {
|
|
1530
1587
|
matched: false,
|
|
1531
|
-
reason:
|
|
1588
|
+
reason: "add_items_disabled"
|
|
1532
1589
|
};
|
|
1533
1590
|
}
|
|
1534
1591
|
if (orderListIds.length === 1) {
|
|
@@ -1540,103 +1597,94 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
1540
1597
|
if (orderListIds.length > 1) {
|
|
1541
1598
|
return {
|
|
1542
1599
|
matched: false,
|
|
1543
|
-
reason:
|
|
1600
|
+
reason: "multiple_orders"
|
|
1544
1601
|
};
|
|
1545
1602
|
}
|
|
1546
1603
|
return {
|
|
1547
1604
|
matched: false,
|
|
1548
|
-
reason:
|
|
1605
|
+
reason: "no_order"
|
|
1549
1606
|
};
|
|
1550
1607
|
}
|
|
1551
|
-
|
|
1552
1608
|
// 检测当前链接是否可用
|
|
1553
1609
|
// 通过 resource_id + 店铺配置
|
|
1554
1610
|
// hasOrderId 表示 url 上是否有 orderid,如果是的话,后续的流程会走加单
|
|
1555
1611
|
async checkResourceAvailable(resourceId, hasOrderId = false) {
|
|
1556
|
-
|
|
1557
|
-
|
|
1612
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
1613
|
+
const normalizedResourceId = String(resourceId ?? "").trim();
|
|
1614
|
+
this.logMethodStart("checkResourceAvailable", {
|
|
1558
1615
|
resourceId: normalizedResourceId
|
|
1559
1616
|
});
|
|
1560
1617
|
try {
|
|
1561
|
-
const businessCode = String(this.otherParams
|
|
1562
|
-
const channel = String(this.otherParams
|
|
1563
|
-
const openDataTarget = businessCode && channel ? `${businessCode}+${channel}` :
|
|
1564
|
-
const openData = await this.otherParams
|
|
1565
|
-
scope:
|
|
1618
|
+
const businessCode = String(((_a = this.otherParams) == null ? void 0 : _a.businessCode) ?? "").trim();
|
|
1619
|
+
const channel = String(((_b = this.otherParams) == null ? void 0 : _b.channel) ?? "").trim();
|
|
1620
|
+
const openDataTarget = businessCode && channel ? `${businessCode}+${channel}` : "dine_in+scan_to_order";
|
|
1621
|
+
const openData = await ((_d = (_c = this.otherParams) == null ? void 0 : _c.getOpenData) == null ? void 0 : _d.call(_c, {
|
|
1622
|
+
scope: "board",
|
|
1566
1623
|
target: openDataTarget,
|
|
1567
|
-
section_code: [
|
|
1568
|
-
});
|
|
1569
|
-
if (openData
|
|
1570
|
-
throw new Error(openData
|
|
1624
|
+
section_code: ["basic", "fulfillment", "reservation", "sale", "menu", "availability", "workflow"]
|
|
1625
|
+
}));
|
|
1626
|
+
if ((openData == null ? void 0 : openData.status) === false) {
|
|
1627
|
+
throw new Error((openData == null ? void 0 : openData.message) || "获取店铺配置失败");
|
|
1571
1628
|
}
|
|
1572
|
-
const dineInConfig = openData
|
|
1629
|
+
const dineInConfig = (openData == null ? void 0 : openData.data) || {};
|
|
1573
1630
|
this.otherParams.dineInConfig = dineInConfig;
|
|
1574
1631
|
await this.syncItemRuleConfigsFromDineInConfig(dineInConfig);
|
|
1575
|
-
const closedBehaviorValue = dineInConfig
|
|
1576
|
-
const closedMessage = dineInConfig
|
|
1577
|
-
const basicUnavailableMessage = dineInConfig
|
|
1578
|
-
const pauseMessage = dineInConfig
|
|
1632
|
+
const closedBehaviorValue = dineInConfig == null ? void 0 : dineInConfig["availability.closed_behavior"];
|
|
1633
|
+
const closedMessage = (dineInConfig == null ? void 0 : dineInConfig["availability.closed_message"]) || (dineInConfig == null ? void 0 : dineInConfig["availability.message"]) || (dineInConfig == null ? void 0 : dineInConfig["basic.closed_message"]);
|
|
1634
|
+
const basicUnavailableMessage = (dineInConfig == null ? void 0 : dineInConfig["basic.unavailable_message"]) || closedMessage;
|
|
1635
|
+
const pauseMessage = (dineInConfig == null ? void 0 : dineInConfig["availability.pause_message"]) || closedMessage;
|
|
1579
1636
|
const makeShopClosed = (errorTips, closed_behavior) => ({
|
|
1580
|
-
mode:
|
|
1581
|
-
order_id:
|
|
1582
|
-
relation_id:
|
|
1583
|
-
table_form_id:
|
|
1637
|
+
mode: "shop_closed",
|
|
1638
|
+
order_id: void 0,
|
|
1639
|
+
relation_id: void 0,
|
|
1640
|
+
table_form_id: void 0,
|
|
1584
1641
|
deskmate_valid: false,
|
|
1585
1642
|
errorTips,
|
|
1586
1643
|
closed_behavior
|
|
1587
1644
|
});
|
|
1588
|
-
|
|
1589
|
-
// 1. 基础开关 basic.enable 关闭
|
|
1590
|
-
if (dineInConfig?.['basic.enable'] === false) {
|
|
1645
|
+
if ((dineInConfig == null ? void 0 : dineInConfig["basic.enable"]) === false) {
|
|
1591
1646
|
return makeShopClosed(basicUnavailableMessage);
|
|
1592
1647
|
}
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
if ((0, _utils.toBoolean)(dineInConfig?.['availability.paused'])) {
|
|
1596
|
-
if (dineInConfig?.['availability.pause_behavior'] === 'hide_all') {
|
|
1648
|
+
if ((0, import_utils.toBoolean)(dineInConfig == null ? void 0 : dineInConfig["availability.paused"])) {
|
|
1649
|
+
if ((dineInConfig == null ? void 0 : dineInConfig["availability.pause_behavior"]) === "hide_all") {
|
|
1597
1650
|
return makeShopClosed(pauseMessage);
|
|
1598
1651
|
}
|
|
1599
1652
|
}
|
|
1600
|
-
|
|
1601
|
-
// 3. 营业时间 operating_hours 闸门
|
|
1602
|
-
const operatingHourIds = Array.isArray(dineInConfig?.['availability.operating_hours']) ? dineInConfig['availability.operating_hours'].map(id => Number(id)).filter(id => Number.isFinite(id) && id > 0) : [];
|
|
1653
|
+
const operatingHourIds = Array.isArray(dineInConfig == null ? void 0 : dineInConfig["availability.operating_hours"]) ? dineInConfig["availability.operating_hours"].map((id) => Number(id)).filter((id) => Number.isFinite(id) && id > 0) : [];
|
|
1603
1654
|
let outsideOperatingHours = false;
|
|
1604
1655
|
if (operatingHourIds.length && this.store.schedule) {
|
|
1605
1656
|
const scheduleList = this.store.schedule.getScheduleListByIds(operatingHourIds);
|
|
1606
1657
|
if (scheduleList.length) {
|
|
1607
|
-
const now = (0,
|
|
1608
|
-
outsideOperatingHours = !(0,
|
|
1658
|
+
const now = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
1659
|
+
outsideOperatingHours = !(0, import_getDateIsInSchedule.getDateIsInSchedule)(now, scheduleList);
|
|
1609
1660
|
}
|
|
1610
1661
|
}
|
|
1611
|
-
if (outsideOperatingHours && closedBehaviorValue !==
|
|
1662
|
+
if (outsideOperatingHours && closedBehaviorValue !== "show_menu_disabled") {
|
|
1612
1663
|
return makeShopClosed(closedMessage, closedBehaviorValue);
|
|
1613
1664
|
}
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
const reservationLinkIds = (0, _utils.collectLinkProductIdsFromReservationRules)(dineInConfig['fulfillment.enabled_resource_rules']);
|
|
1665
|
+
const tempOrder = this.ensureScanOrderTempOrder();
|
|
1666
|
+
const reservationLinkIds = (0, import_utils.collectLinkProductIdsFromReservationRules)(
|
|
1667
|
+
dineInConfig["fulfillment.enabled_resource_rules"]
|
|
1668
|
+
);
|
|
1619
1669
|
if (!normalizedResourceId || reservationLinkIds.length === 0) {
|
|
1620
1670
|
return await this.prepareRetailAvailability({
|
|
1621
1671
|
tempOrder,
|
|
1622
1672
|
hasOrderId,
|
|
1623
1673
|
resourceId: normalizedResourceId,
|
|
1624
|
-
reason: !normalizedResourceId ?
|
|
1674
|
+
reason: !normalizedResourceId ? "missing_resource_id" : "missing_enabled_resource_rules"
|
|
1625
1675
|
});
|
|
1626
1676
|
}
|
|
1627
1677
|
let pendingRequestEntryPax;
|
|
1628
1678
|
let pendingRequestPaxMin;
|
|
1629
1679
|
let pendingRequestPaxMax;
|
|
1630
|
-
tempOrder.metadata = {
|
|
1631
|
-
...(tempOrder.metadata || {})
|
|
1632
|
-
};
|
|
1680
|
+
tempOrder.metadata = { ...tempOrder.metadata || {} };
|
|
1633
1681
|
delete tempOrder.metadata.table_occupancy_duration;
|
|
1634
|
-
const reservationProductList = new
|
|
1682
|
+
const reservationProductList = new import_ProductList.ProductList(
|
|
1683
|
+
`${this.name}_reservationEnabledRules`,
|
|
1684
|
+
this.defaultVersion
|
|
1685
|
+
);
|
|
1635
1686
|
await reservationProductList.initialize(this.core, {
|
|
1636
|
-
store: {
|
|
1637
|
-
list: [],
|
|
1638
|
-
selectProducts: []
|
|
1639
|
-
},
|
|
1687
|
+
store: { list: [], selectProducts: [] },
|
|
1640
1688
|
otherParams: {
|
|
1641
1689
|
...this.otherParams,
|
|
1642
1690
|
fatherModule: this.name,
|
|
@@ -1644,8 +1692,8 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
1644
1692
|
cacheId: this.cacheId
|
|
1645
1693
|
}
|
|
1646
1694
|
});
|
|
1647
|
-
const scheduleDate = (0,
|
|
1648
|
-
const scheduleDatetime = (0,
|
|
1695
|
+
const scheduleDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
1696
|
+
const scheduleDatetime = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
1649
1697
|
const loaded = await reservationProductList.loadProducts({
|
|
1650
1698
|
product_ids: reservationLinkIds,
|
|
1651
1699
|
schedule_date: scheduleDate,
|
|
@@ -1653,85 +1701,116 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
1653
1701
|
cacheId: this.cacheId
|
|
1654
1702
|
});
|
|
1655
1703
|
if (Array.isArray(loaded)) {
|
|
1656
|
-
const matchedRuleProduct = (0,
|
|
1704
|
+
const matchedRuleProduct = (0, import_utils.findReservationRuleProductByResourceId)(
|
|
1705
|
+
loaded,
|
|
1706
|
+
normalizedResourceId
|
|
1707
|
+
);
|
|
1657
1708
|
const ruleProductsForResource = matchedRuleProduct ? [matchedRuleProduct] : [];
|
|
1658
1709
|
this.enabledReservationRuleProducts = ruleProductsForResource;
|
|
1659
|
-
const occupancyMinutes = (0,
|
|
1660
|
-
if (occupancyMinutes !==
|
|
1710
|
+
const occupancyMinutes = (0, import_utils.pickFirstDurationMinutesFromProducts)(ruleProductsForResource);
|
|
1711
|
+
if (occupancyMinutes !== void 0) {
|
|
1661
1712
|
tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
|
|
1662
1713
|
}
|
|
1663
|
-
if ((0,
|
|
1714
|
+
if ((0, import_utils.hasCustomCapacityProduct)(ruleProductsForResource)) {
|
|
1664
1715
|
pendingRequestEntryPax = 1;
|
|
1665
|
-
const paxBounds = (0,
|
|
1666
|
-
if (paxBounds
|
|
1667
|
-
|
|
1716
|
+
const paxBounds = (0, import_utils.pickFirstCustomCapacityPaxBounds)(ruleProductsForResource);
|
|
1717
|
+
if ((paxBounds == null ? void 0 : paxBounds.min) !== void 0)
|
|
1718
|
+
pendingRequestPaxMin = paxBounds.min;
|
|
1719
|
+
if ((paxBounds == null ? void 0 : paxBounds.max) !== void 0)
|
|
1720
|
+
pendingRequestPaxMax = paxBounds.max;
|
|
1668
1721
|
}
|
|
1669
1722
|
} else {
|
|
1670
1723
|
this.enabledReservationRuleProducts = [];
|
|
1671
|
-
const error = loaded instanceof Error ? loaded : new Error(
|
|
1672
|
-
this.logMethodError(
|
|
1724
|
+
const error = loaded instanceof Error ? loaded : new Error("预约规则商品列表接口返回异常");
|
|
1725
|
+
this.logMethodError("loadReservationRuleProducts", error, {
|
|
1673
1726
|
resourceId: normalizedResourceId,
|
|
1674
1727
|
reservationLinkIds,
|
|
1675
1728
|
scheduleDate,
|
|
1676
1729
|
scheduleDatetime,
|
|
1677
1730
|
cacheId: this.cacheId
|
|
1678
1731
|
});
|
|
1732
|
+
if (Array.isArray(loaded)) {
|
|
1733
|
+
this.enabledReservationRuleProducts = loaded;
|
|
1734
|
+
const occupancyMinutes = (0, import_utils.pickFirstDurationMinutesFromProducts)(loaded);
|
|
1735
|
+
if (occupancyMinutes !== void 0) {
|
|
1736
|
+
tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
|
|
1737
|
+
}
|
|
1738
|
+
if ((0, import_utils.hasCustomCapacityProduct)(loaded)) {
|
|
1739
|
+
pendingRequestEntryPax = 1;
|
|
1740
|
+
const paxBounds = (0, import_utils.pickFirstCustomCapacityPaxBounds)(loaded);
|
|
1741
|
+
if ((paxBounds == null ? void 0 : paxBounds.min) !== void 0)
|
|
1742
|
+
pendingRequestPaxMin = paxBounds.min;
|
|
1743
|
+
if ((paxBounds == null ? void 0 : paxBounds.max) !== void 0)
|
|
1744
|
+
pendingRequestPaxMax = paxBounds.max;
|
|
1745
|
+
}
|
|
1746
|
+
} else {
|
|
1747
|
+
this.enabledReservationRuleProducts = [];
|
|
1748
|
+
const error2 = loaded instanceof Error ? loaded : new Error("预约规则商品列表接口返回异常");
|
|
1749
|
+
this.logMethodError("loadReservationRuleProducts", error2, {
|
|
1750
|
+
resourceId,
|
|
1751
|
+
reservationLinkIds,
|
|
1752
|
+
scheduleDate,
|
|
1753
|
+
scheduleDatetime,
|
|
1754
|
+
cacheId: this.cacheId
|
|
1755
|
+
});
|
|
1756
|
+
}
|
|
1679
1757
|
}
|
|
1680
|
-
|
|
1681
|
-
// Step2: 请求新的资源占用详情接口。occupy_details 第一维是资源,不是订单。
|
|
1682
1758
|
const occupyDetails = await this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
|
|
1683
1759
|
const occupyDetail = occupyDetails[0] ?? null;
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
const
|
|
1688
|
-
const
|
|
1689
|
-
|
|
1690
|
-
|
|
1760
|
+
const resourceSelectType = this.resolveResourceSelectType(
|
|
1761
|
+
(0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_id)
|
|
1762
|
+
);
|
|
1763
|
+
const allowAddItems = (0, import_utils.toBoolean)(dineInConfig == null ? void 0 : dineInConfig["sale.allow_add_items"]);
|
|
1764
|
+
const additionalOrderResult = this.resolveAdditionalOrderFromOccupyDetail(
|
|
1765
|
+
occupyDetail,
|
|
1766
|
+
resourceSelectType,
|
|
1767
|
+
allowAddItems
|
|
1768
|
+
);
|
|
1769
|
+
if (additionalOrderResult.reason === "multiple_orders") {
|
|
1691
1770
|
const multipleOrdersState = {
|
|
1692
1771
|
...this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId),
|
|
1693
|
-
mode:
|
|
1772
|
+
mode: "multiple_orders"
|
|
1694
1773
|
};
|
|
1695
1774
|
this.store.resource = multipleOrdersState;
|
|
1696
|
-
const
|
|
1697
|
-
mode:
|
|
1775
|
+
const availabilityInfo2 = {
|
|
1776
|
+
mode: "multiple_orders",
|
|
1698
1777
|
deskmate_valid: multipleOrdersState.deskmate_valid,
|
|
1699
1778
|
relation_id: multipleOrdersState.relationId,
|
|
1700
1779
|
table_form_id: multipleOrdersState.tableFormId,
|
|
1701
1780
|
table_form_record: multipleOrdersState.table_form_record
|
|
1702
1781
|
};
|
|
1703
|
-
this.logMethodSuccess(
|
|
1782
|
+
this.logMethodSuccess("checkResourceAvailable", {
|
|
1704
1783
|
resourceId: normalizedResourceId,
|
|
1705
|
-
mode:
|
|
1706
|
-
orderListCount: occupyDetail
|
|
1784
|
+
mode: availabilityInfo2.mode,
|
|
1785
|
+
orderListCount: ((_e = occupyDetail == null ? void 0 : occupyDetail.order_list) == null ? void 0 : _e.length) || 0,
|
|
1707
1786
|
resourceSelectType
|
|
1708
1787
|
});
|
|
1709
|
-
return
|
|
1788
|
+
return availabilityInfo2;
|
|
1710
1789
|
}
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1790
|
+
const resourceState = this.normalizeResourceState(
|
|
1791
|
+
occupyDetail,
|
|
1792
|
+
resourceSelectType,
|
|
1793
|
+
hasOrderId
|
|
1794
|
+
);
|
|
1714
1795
|
const additionalOrderId = additionalOrderResult.order_id;
|
|
1715
1796
|
if (additionalOrderId) {
|
|
1716
|
-
resourceState.mode =
|
|
1797
|
+
resourceState.mode = "additional_order";
|
|
1717
1798
|
resourceState.order_id = additionalOrderId;
|
|
1718
|
-
} else if (additionalOrderResult.reason ===
|
|
1719
|
-
resourceState.mode =
|
|
1720
|
-
resourceState.order_id =
|
|
1721
|
-
} else if (resourceSelectType ===
|
|
1722
|
-
resourceState.mode =
|
|
1723
|
-
resourceState.order_id =
|
|
1799
|
+
} else if (additionalOrderResult.reason === "add_items_disabled") {
|
|
1800
|
+
resourceState.mode = "resource_busy";
|
|
1801
|
+
resourceState.order_id = "0";
|
|
1802
|
+
} else if (resourceSelectType === "multiple" && resourceState.isFull) {
|
|
1803
|
+
resourceState.mode = "resource_busy";
|
|
1804
|
+
resourceState.order_id = "0";
|
|
1724
1805
|
}
|
|
1725
1806
|
this.store.resource = resourceState;
|
|
1726
|
-
|
|
1727
|
-
// Step5: 把预约规则商品阶段暂存的 requestEntryPax 等注入 store.resource
|
|
1728
|
-
if (pendingRequestEntryPax !== undefined) {
|
|
1807
|
+
if (pendingRequestEntryPax !== void 0) {
|
|
1729
1808
|
this.store.resource.requestEntryPax = pendingRequestEntryPax;
|
|
1730
1809
|
}
|
|
1731
|
-
if (pendingRequestPaxMin !==
|
|
1810
|
+
if (pendingRequestPaxMin !== void 0) {
|
|
1732
1811
|
this.store.resource.requestPaxMin = pendingRequestPaxMin;
|
|
1733
1812
|
}
|
|
1734
|
-
if (pendingRequestPaxMax !==
|
|
1813
|
+
if (pendingRequestPaxMax !== void 0) {
|
|
1735
1814
|
this.store.resource.requestPaxMax = pendingRequestPaxMax;
|
|
1736
1815
|
}
|
|
1737
1816
|
const availabilityInfo = {
|
|
@@ -1741,67 +1820,49 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
1741
1820
|
table_form_id: resourceState.tableFormId,
|
|
1742
1821
|
deskmate_valid: resourceState.deskmate_valid,
|
|
1743
1822
|
table_form_record: resourceState.table_form_record,
|
|
1744
|
-
policy: occupyDetail
|
|
1745
|
-
partyroom_booking: occupyDetail
|
|
1746
|
-
...
|
|
1747
|
-
|
|
1748
|
-
} : {}
|
|
1749
|
-
...(this.store.resource.requestPaxMin !== undefined ? {
|
|
1750
|
-
requestPaxMin: this.store.resource.requestPaxMin
|
|
1751
|
-
} : {}),
|
|
1752
|
-
...(this.store.resource.requestPaxMax !== undefined ? {
|
|
1753
|
-
requestPaxMax: this.store.resource.requestPaxMax
|
|
1754
|
-
} : {})
|
|
1823
|
+
policy: (_f = occupyDetail == null ? void 0 : occupyDetail.form_record) == null ? void 0 : _f.policy,
|
|
1824
|
+
partyroom_booking: (_g = occupyDetail == null ? void 0 : occupyDetail.form_record) == null ? void 0 : _g.partyroom_booking,
|
|
1825
|
+
...this.store.resource.requestEntryPax !== void 0 ? { requestEntryPax: this.store.resource.requestEntryPax } : {},
|
|
1826
|
+
...this.store.resource.requestPaxMin !== void 0 ? { requestPaxMin: this.store.resource.requestPaxMin } : {},
|
|
1827
|
+
...this.store.resource.requestPaxMax !== void 0 ? { requestPaxMax: this.store.resource.requestPaxMax } : {}
|
|
1755
1828
|
};
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
tempOrder.resource_id = normalizedResourceId;
|
|
1759
|
-
this.store.order?.persistTempOrder();
|
|
1760
|
-
|
|
1761
|
-
// 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
|
|
1762
|
-
if (availabilityInfo.mode === 'idle') {
|
|
1829
|
+
(_h = this.store.order) == null ? void 0 : _h.persistTempOrder();
|
|
1830
|
+
if (availabilityInfo.mode === "idle") {
|
|
1763
1831
|
await this.addNewOrder();
|
|
1764
1832
|
}
|
|
1765
|
-
const isAdditionalOrderMode = availabilityInfo.mode ===
|
|
1766
|
-
// 如果是加单模式,tempOrder 里需要记录目标订单 id,提交的时候走加单接口
|
|
1833
|
+
const isAdditionalOrderMode = availabilityInfo.mode === "additional_order" || availabilityInfo.mode === "additional_order_with_code";
|
|
1767
1834
|
if (isAdditionalOrderMode) {
|
|
1768
1835
|
tempOrder.order_id = additionalOrderId;
|
|
1769
1836
|
}
|
|
1770
|
-
const lastOrderInfo = this.store.order
|
|
1771
|
-
const historicalItems = isAdditionalOrderMode && Array.isArray(lastOrderInfo
|
|
1772
|
-
if (typeof p
|
|
1837
|
+
const lastOrderInfo = (_j = (_i = this.store.order) == null ? void 0 : _i.getLastOrderInfo) == null ? void 0 : _j.call(_i);
|
|
1838
|
+
const historicalItems = isAdditionalOrderMode && Array.isArray(lastOrderInfo == null ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce((acc, p) => {
|
|
1839
|
+
if (typeof (p == null ? void 0 : p.product_id) !== "number")
|
|
1840
|
+
return acc;
|
|
1773
1841
|
acc.push({
|
|
1774
1842
|
product_id: p.product_id,
|
|
1775
1843
|
quantity: Number(p.product_quantity) || 0,
|
|
1776
|
-
...
|
|
1777
|
-
product_variant_id: p.product_variant_id
|
|
1778
|
-
} : {})
|
|
1844
|
+
...typeof p.product_variant_id === "number" ? { product_variant_id: p.product_variant_id } : {}
|
|
1779
1845
|
});
|
|
1780
1846
|
return acc;
|
|
1781
1847
|
}, []) : [];
|
|
1782
|
-
|
|
1783
|
-
// pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
|
|
1784
1848
|
await this.setItemRuleRuntimeConfig({
|
|
1785
|
-
serviceType: this.otherParams
|
|
1849
|
+
serviceType: (_k = this.otherParams) == null ? void 0 : _k.businessCode,
|
|
1786
1850
|
submissionIndex: isAdditionalOrderMode ? 1 : 0,
|
|
1787
1851
|
historicalItems
|
|
1788
1852
|
});
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
// 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
|
|
1792
|
-
if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
|
|
1793
|
-
availabilityInfo.mode = 'submit_disabled';
|
|
1853
|
+
if (outsideOperatingHours && closedBehaviorValue === "show_menu_disabled") {
|
|
1854
|
+
availabilityInfo.mode = "submit_disabled";
|
|
1794
1855
|
availabilityInfo.errorTips = closedMessage;
|
|
1795
1856
|
availabilityInfo.closed_behavior = closedBehaviorValue;
|
|
1796
1857
|
}
|
|
1797
|
-
this.logMethodSuccess(
|
|
1858
|
+
this.logMethodSuccess("checkResourceAvailable", {
|
|
1798
1859
|
resourceId: normalizedResourceId,
|
|
1799
1860
|
mode: availabilityInfo.mode,
|
|
1800
1861
|
orderId: availabilityInfo.order_id,
|
|
1801
1862
|
relationId: availabilityInfo.relation_id,
|
|
1802
1863
|
tableFormId: availabilityInfo.table_form_id,
|
|
1803
|
-
persistedRelationId:
|
|
1804
|
-
persistedResourceId:
|
|
1864
|
+
persistedRelationId: (_l = this.store.resource) == null ? void 0 : _l.relationId,
|
|
1865
|
+
persistedResourceId: (_m = this.store.resource) == null ? void 0 : _m.relationId,
|
|
1805
1866
|
deskmateValid: availabilityInfo.deskmate_valid,
|
|
1806
1867
|
resourceSelectType: resourceState.resourceSelectType,
|
|
1807
1868
|
isExclusive: resourceState.isExclusive,
|
|
@@ -1809,68 +1870,76 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
1809
1870
|
});
|
|
1810
1871
|
return availabilityInfo;
|
|
1811
1872
|
} catch (error) {
|
|
1812
|
-
this.logMethodError(
|
|
1873
|
+
this.logMethodError("checkResourceAvailable", error.message, {
|
|
1813
1874
|
resourceId: normalizedResourceId
|
|
1814
1875
|
});
|
|
1815
1876
|
throw error;
|
|
1816
1877
|
}
|
|
1817
1878
|
}
|
|
1818
|
-
|
|
1819
1879
|
// 恢复之前订单的数据,读取 entrypax
|
|
1820
1880
|
async restorePreviousOrderData() {
|
|
1821
|
-
|
|
1881
|
+
var _a, _b, _c, _d;
|
|
1882
|
+
const orderModule = this.store.order;
|
|
1883
|
+
if (!orderModule)
|
|
1884
|
+
return;
|
|
1885
|
+
const tempOrder = orderModule.ensureTempOrder();
|
|
1822
1886
|
if (tempOrder.order_id) {
|
|
1823
|
-
const res = await
|
|
1824
|
-
|
|
1825
|
-
|
|
1887
|
+
const res = await orderModule.getOrderInfo(tempOrder.order_id);
|
|
1888
|
+
const entryPaxNumber = (_d = (_c = (_b = (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.bookings) == null ? void 0 : _b.find((p) => {
|
|
1889
|
+
var _a2;
|
|
1890
|
+
return (_a2 = p.metadata) == null ? void 0 : _a2.collect_pax;
|
|
1891
|
+
})) == null ? void 0 : _c.metadata) == null ? void 0 : _d.collect_pax;
|
|
1826
1892
|
if (entryPaxNumber) {
|
|
1827
1893
|
await this.setEntryPaxNumber(entryPaxNumber);
|
|
1828
1894
|
}
|
|
1829
1895
|
}
|
|
1830
1896
|
}
|
|
1831
|
-
|
|
1832
1897
|
// 如果是加单的情况,提供返回当前订单相关信息的能力
|
|
1833
1898
|
async getAdditionalOrderInfo() {
|
|
1834
|
-
this.logMethodStart(
|
|
1899
|
+
this.logMethodStart("getAdditionalOrderInfo");
|
|
1835
1900
|
const result = {
|
|
1836
|
-
orderId:
|
|
1837
|
-
orderStatus:
|
|
1838
|
-
orderTime:
|
|
1901
|
+
orderId: "123567890",
|
|
1902
|
+
orderStatus: "pending",
|
|
1903
|
+
orderTime: "2026-03-31 10:00:00",
|
|
1839
1904
|
orderAmount: 100,
|
|
1840
1905
|
orderItems: []
|
|
1841
1906
|
};
|
|
1842
|
-
this.logMethodSuccess(
|
|
1907
|
+
this.logMethodSuccess("getAdditionalOrderInfo", {
|
|
1843
1908
|
orderId: result.orderId,
|
|
1844
1909
|
orderStatus: result.orderStatus
|
|
1845
1910
|
});
|
|
1846
1911
|
return result;
|
|
1847
1912
|
}
|
|
1848
|
-
|
|
1849
1913
|
// 获取商品列表
|
|
1850
1914
|
async getProductList() {
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
const
|
|
1915
|
+
var _a, _b;
|
|
1916
|
+
this.logMethodStart("getProductList");
|
|
1917
|
+
const associatedMenus = (_b = (_a = this.otherParams) == null ? void 0 : _a.dineInConfig) == null ? void 0 : _b["menu.associated_menus"];
|
|
1918
|
+
const menu_list_ids = associatedMenus.map((n) => Number(n.value)) || [];
|
|
1854
1919
|
try {
|
|
1855
|
-
if (!this.store.products)
|
|
1920
|
+
if (!this.store.products)
|
|
1921
|
+
throw new Error("products 模块未初始化");
|
|
1856
1922
|
const res = await this.store.products.loadProducts({
|
|
1857
1923
|
menu_list_ids,
|
|
1858
1924
|
cacheId: this.cacheId,
|
|
1859
|
-
schedule_date: (0,
|
|
1860
|
-
schedule_datetime: (0,
|
|
1925
|
+
schedule_date: (0, import_dayjs.default)().format("YYYY-MM-DD"),
|
|
1926
|
+
schedule_datetime: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
|
|
1861
1927
|
});
|
|
1862
|
-
const productList = this.assertProductListLoaded(
|
|
1928
|
+
const productList = this.assertProductListLoaded("getProductList", res, {
|
|
1863
1929
|
menu_list_ids,
|
|
1864
1930
|
cacheId: this.cacheId
|
|
1865
1931
|
});
|
|
1866
|
-
const formattedRes = (0,
|
|
1867
|
-
|
|
1932
|
+
const formattedRes = (0, import_utils.attachItemRuleLimitsToTopLevelProducts)(
|
|
1933
|
+
productList,
|
|
1934
|
+
this.store.itemRuleQuantityLimits || []
|
|
1935
|
+
);
|
|
1936
|
+
this.logMethodSuccess("getProductList", {
|
|
1868
1937
|
menuCount: menu_list_ids.length
|
|
1869
1938
|
});
|
|
1870
1939
|
return formattedRes;
|
|
1871
1940
|
} catch (error) {
|
|
1872
|
-
if (!error
|
|
1873
|
-
this.logMethodError(
|
|
1941
|
+
if (!(error == null ? void 0 : error.__scanOrderLogged)) {
|
|
1942
|
+
this.logMethodError("getProductList", error, {
|
|
1874
1943
|
menu_list_ids,
|
|
1875
1944
|
cacheId: this.cacheId
|
|
1876
1945
|
});
|
|
@@ -1881,107 +1950,87 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
1881
1950
|
getOtherParams() {
|
|
1882
1951
|
return this.otherParams;
|
|
1883
1952
|
}
|
|
1884
|
-
async setOtherParams(params, {
|
|
1885
|
-
cover = false
|
|
1886
|
-
} = {}) {
|
|
1953
|
+
async setOtherParams(params, { cover = false } = {}) {
|
|
1887
1954
|
if (cover) {
|
|
1888
1955
|
this.otherParams = params;
|
|
1889
1956
|
} else {
|
|
1890
|
-
this.otherParams = {
|
|
1891
|
-
...this.otherParams,
|
|
1892
|
-
...params
|
|
1893
|
-
};
|
|
1957
|
+
this.otherParams = { ...this.otherParams, ...params };
|
|
1894
1958
|
}
|
|
1895
1959
|
}
|
|
1896
|
-
|
|
1897
|
-
// ─── UI 状态缓存(按 cacheId 分桶,localStorage) ───
|
|
1898
|
-
//
|
|
1899
|
-
// 用于物料层持久化 UI 层面的轻量状态(如当前步骤、gate 标记、登录回跳意图等)。
|
|
1900
|
-
// 桶键:pisell.scanOrder.uiState:<cacheId>;内部以 JSON object 形式存储多个字段。
|
|
1901
|
-
// 无 cacheId 时所有方法自动降级为 no-op,上层不用判空。
|
|
1902
|
-
//
|
|
1903
|
-
// 之所以用 localStorage 而不是 sessionStorage:
|
|
1904
|
-
// 1. 与 Order 模块 openCache 下的 tempOrder 同栈,购物车在 / UIState 在,行为对齐;
|
|
1905
|
-
// 2. pisell1.login 整页 OAuth 跳转在 H5 壳 / iOS Safari 场景下可能丢 sessionStorage,
|
|
1906
|
-
// 导致登录回跳后 gate 标记失效、pax 弹窗重开、落点错误;localStorage 稳定不受影响。
|
|
1907
|
-
// 3. 失效由上层显式控制:提交成功 clearStepCache / entryContext 不一致 clearUIState /
|
|
1908
|
-
// pendingStep 登录回调 deleteUIState,足够约束生命周期。
|
|
1909
|
-
|
|
1910
|
-
static UI_STATE_KEY_PREFIX = 'pisell.scanOrder.uiState:';
|
|
1911
1960
|
getUIStateBucketKey() {
|
|
1912
|
-
if (!this.cacheId)
|
|
1913
|
-
|
|
1961
|
+
if (!this.cacheId)
|
|
1962
|
+
return null;
|
|
1963
|
+
return `${_ScanOrderImpl.UI_STATE_KEY_PREFIX}${this.cacheId}`;
|
|
1914
1964
|
}
|
|
1915
1965
|
readUIStateBucket() {
|
|
1966
|
+
var _a;
|
|
1916
1967
|
const key = this.getUIStateBucketKey();
|
|
1917
|
-
if (!key || !this.window
|
|
1968
|
+
if (!key || !((_a = this.window) == null ? void 0 : _a.localStorage))
|
|
1969
|
+
return {};
|
|
1918
1970
|
try {
|
|
1919
|
-
const raw = this.window.localStorage.getItem(key) ||
|
|
1971
|
+
const raw = this.window.localStorage.getItem(key) || "{}";
|
|
1920
1972
|
const parsed = JSON.parse(raw);
|
|
1921
|
-
return parsed && typeof parsed ===
|
|
1973
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
1922
1974
|
} catch {
|
|
1923
1975
|
return {};
|
|
1924
1976
|
}
|
|
1925
1977
|
}
|
|
1926
1978
|
writeUIStateBucket(bucket) {
|
|
1979
|
+
var _a;
|
|
1927
1980
|
const key = this.getUIStateBucketKey();
|
|
1928
|
-
if (!key || !this.window
|
|
1981
|
+
if (!key || !((_a = this.window) == null ? void 0 : _a.localStorage))
|
|
1982
|
+
return;
|
|
1929
1983
|
try {
|
|
1930
1984
|
this.window.localStorage.setItem(key, JSON.stringify(bucket));
|
|
1931
1985
|
} catch (error) {
|
|
1932
|
-
console.warn(
|
|
1986
|
+
console.warn("[ScanOrder] writeUIStateBucket failed", error);
|
|
1933
1987
|
}
|
|
1934
1988
|
}
|
|
1935
1989
|
setUIState(key, value) {
|
|
1936
|
-
if (!this.getUIStateBucketKey())
|
|
1990
|
+
if (!this.getUIStateBucketKey())
|
|
1991
|
+
return;
|
|
1937
1992
|
const bucket = this.readUIStateBucket();
|
|
1938
1993
|
bucket[key] = value;
|
|
1939
1994
|
this.writeUIStateBucket(bucket);
|
|
1940
1995
|
}
|
|
1941
1996
|
getUIState(key) {
|
|
1942
|
-
if (!this.getUIStateBucketKey())
|
|
1997
|
+
if (!this.getUIStateBucketKey())
|
|
1998
|
+
return void 0;
|
|
1943
1999
|
const bucket = this.readUIStateBucket();
|
|
1944
2000
|
return bucket[key];
|
|
1945
2001
|
}
|
|
1946
2002
|
deleteUIState(key) {
|
|
1947
|
-
if (!this.getUIStateBucketKey())
|
|
2003
|
+
if (!this.getUIStateBucketKey())
|
|
2004
|
+
return;
|
|
1948
2005
|
const bucket = this.readUIStateBucket();
|
|
1949
2006
|
if (key in bucket) {
|
|
1950
2007
|
delete bucket[key];
|
|
1951
2008
|
this.writeUIStateBucket(bucket);
|
|
1952
2009
|
}
|
|
1953
2010
|
}
|
|
1954
|
-
|
|
1955
2011
|
// 整桶清空(用于扫新桌、提交成功、restoreOrder 等场景)
|
|
1956
2012
|
clearUIState() {
|
|
2013
|
+
var _a;
|
|
1957
2014
|
const key = this.getUIStateBucketKey();
|
|
1958
|
-
if (!key || !this.window
|
|
2015
|
+
if (!key || !((_a = this.window) == null ? void 0 : _a.localStorage))
|
|
2016
|
+
return;
|
|
1959
2017
|
try {
|
|
1960
2018
|
this.window.localStorage.removeItem(key);
|
|
1961
2019
|
} catch (error) {
|
|
1962
|
-
console.warn(
|
|
2020
|
+
console.warn("[ScanOrder] clearUIState failed", error);
|
|
1963
2021
|
}
|
|
1964
2022
|
}
|
|
1965
2023
|
async setEntryPaxNumber(number) {
|
|
1966
|
-
const pax = (0,
|
|
2024
|
+
const pax = (0, import_utils2.normalizeSubmitCollectPaxValue)(number);
|
|
1967
2025
|
this.store.entryPaxNumber = pax;
|
|
1968
2026
|
if (this.store.order) {
|
|
1969
2027
|
const t = this.store.order.ensureTempOrder();
|
|
1970
|
-
t.metadata = {
|
|
1971
|
-
...t.metadata,
|
|
1972
|
-
collect_pax: pax
|
|
1973
|
-
};
|
|
2028
|
+
t.metadata = { ...t.metadata, collect_pax: pax };
|
|
1974
2029
|
this.store.order.persistTempOrder();
|
|
1975
2030
|
}
|
|
1976
|
-
|
|
1977
|
-
// pax 变化后同步到 itemRuleRuntimeConfig,并刷新限购 / 校验
|
|
1978
2031
|
this.itemRuleRuntimeConfig = {
|
|
1979
2032
|
...this.itemRuleRuntimeConfig,
|
|
1980
|
-
pax: {
|
|
1981
|
-
total: pax,
|
|
1982
|
-
adult: 0,
|
|
1983
|
-
child: 0
|
|
1984
|
-
}
|
|
2033
|
+
pax: { total: pax, adult: 0, child: 0 }
|
|
1985
2034
|
};
|
|
1986
2035
|
this.itemRulePrefillApplied = false;
|
|
1987
2036
|
await this.refreshItemRuleQuantityLimits();
|
|
@@ -1991,26 +2040,37 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
1991
2040
|
return this.store.entryPaxNumber;
|
|
1992
2041
|
}
|
|
1993
2042
|
async syncAdditionalOrderFromResource(resourceId) {
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
2043
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2044
|
+
if (!this.store.order)
|
|
2045
|
+
throw new Error("order 模块未初始化");
|
|
2046
|
+
const tempOrder = this.store.order.ensureTempOrder();
|
|
2047
|
+
const normalizedResourceId = String(
|
|
2048
|
+
resourceId ?? tempOrder.resource_id ?? ((_a = this.store.resource) == null ? void 0 : _a.relationId) ?? ((_b = this.store.resource) == null ? void 0 : _b.relation_id) ?? ""
|
|
2049
|
+
).trim();
|
|
2050
|
+
this.logMethodStart("syncAdditionalOrderFromResource", {
|
|
1997
2051
|
resourceId: normalizedResourceId
|
|
1998
2052
|
});
|
|
1999
2053
|
if (!normalizedResourceId) {
|
|
2000
|
-
const
|
|
2054
|
+
const result2 = {
|
|
2001
2055
|
matched: false,
|
|
2002
|
-
reason:
|
|
2056
|
+
reason: "missing_resource_id"
|
|
2003
2057
|
};
|
|
2004
|
-
this.logMethodSuccess(
|
|
2005
|
-
return
|
|
2058
|
+
this.logMethodSuccess("syncAdditionalOrderFromResource", result2);
|
|
2059
|
+
return result2;
|
|
2006
2060
|
}
|
|
2007
2061
|
const occupyDetails = await this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
|
|
2008
2062
|
const occupyDetail = occupyDetails[0] ?? null;
|
|
2009
|
-
const resourceSelectType = this.store.resource
|
|
2010
|
-
const allowAddItems = (0,
|
|
2011
|
-
|
|
2063
|
+
const resourceSelectType = ((_c = this.store.resource) == null ? void 0 : _c.resourceSelectType) || this.resolveResourceSelectType((0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_id));
|
|
2064
|
+
const allowAddItems = (0, import_utils.toBoolean)(
|
|
2065
|
+
(_e = (_d = this.otherParams) == null ? void 0 : _d.dineInConfig) == null ? void 0 : _e["sale.allow_add_items"]
|
|
2066
|
+
);
|
|
2067
|
+
const result = this.resolveAdditionalOrderFromOccupyDetail(
|
|
2068
|
+
occupyDetail,
|
|
2069
|
+
resourceSelectType,
|
|
2070
|
+
allowAddItems
|
|
2071
|
+
);
|
|
2012
2072
|
if (!result.matched || !result.order_id) {
|
|
2013
|
-
this.logMethodSuccess(
|
|
2073
|
+
this.logMethodSuccess("syncAdditionalOrderFromResource", {
|
|
2014
2074
|
...result,
|
|
2015
2075
|
resourceId: normalizedResourceId,
|
|
2016
2076
|
resourceSelectType,
|
|
@@ -2020,10 +2080,10 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
2020
2080
|
}
|
|
2021
2081
|
tempOrder.order_id = result.order_id;
|
|
2022
2082
|
tempOrder.resource_id = normalizedResourceId;
|
|
2023
|
-
tempOrder.relation_id = (0,
|
|
2024
|
-
tempOrder.table_form_id = (0,
|
|
2025
|
-
this.store.order
|
|
2026
|
-
this.logMethodSuccess(
|
|
2083
|
+
tempOrder.relation_id = (0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_record_id) || normalizedResourceId || tempOrder.relation_id;
|
|
2084
|
+
tempOrder.table_form_id = (0, import_utils.toPositiveString)(occupyDetail == null ? void 0 : occupyDetail.form_id) || tempOrder.table_form_id;
|
|
2085
|
+
(_f = this.store.order) == null ? void 0 : _f.persistTempOrder();
|
|
2086
|
+
this.logMethodSuccess("syncAdditionalOrderFromResource", {
|
|
2027
2087
|
...result,
|
|
2028
2088
|
resourceId: normalizedResourceId,
|
|
2029
2089
|
resourceSelectType,
|
|
@@ -2031,68 +2091,80 @@ class ScanOrderImpl extends _BaseModule.BaseModule {
|
|
|
2031
2091
|
});
|
|
2032
2092
|
return result;
|
|
2033
2093
|
}
|
|
2034
|
-
|
|
2035
2094
|
// 读取预约规则商品的资源选择类型:single=单个预约,multiple=多个预约,capacity=容量型预约
|
|
2036
2095
|
// 依赖 checkResourceAvailable 已根据预约规则商品与 occupy-detail 的 form_id 计算并缓存 store.resource
|
|
2037
2096
|
getReservationResourceSelectType() {
|
|
2038
|
-
|
|
2039
|
-
|
|
2097
|
+
var _a;
|
|
2098
|
+
this.logMethodStart("getReservationResourceSelectType");
|
|
2099
|
+
const resourceSelectType = (_a = this.store.resource) == null ? void 0 : _a.resourceSelectType;
|
|
2040
2100
|
const result = {
|
|
2041
|
-
...
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
isMultipleReservation: resourceSelectType === 'multiple',
|
|
2046
|
-
isCapacityReservation: resourceSelectType === 'capacity'
|
|
2101
|
+
...resourceSelectType ? { resourceSelectType } : {},
|
|
2102
|
+
isSingleReservation: resourceSelectType === "single",
|
|
2103
|
+
isMultipleReservation: resourceSelectType === "multiple",
|
|
2104
|
+
isCapacityReservation: resourceSelectType === "capacity"
|
|
2047
2105
|
};
|
|
2048
|
-
this.logMethodSuccess(
|
|
2106
|
+
this.logMethodSuccess("getReservationResourceSelectType", result);
|
|
2049
2107
|
return result;
|
|
2050
2108
|
}
|
|
2051
|
-
|
|
2052
2109
|
// 判定后台是否开启允许加餐
|
|
2053
2110
|
// 依赖 checkResourceAvailable 已缓存的 dineInConfig
|
|
2054
2111
|
checkAllowAddItems() {
|
|
2055
|
-
|
|
2056
|
-
|
|
2112
|
+
var _a;
|
|
2113
|
+
this.logMethodStart("checkAllowAddItems");
|
|
2114
|
+
const dineInConfig = ((_a = this.otherParams) == null ? void 0 : _a.dineInConfig) || {};
|
|
2057
2115
|
const result = {
|
|
2058
|
-
enabled: (0,
|
|
2116
|
+
enabled: (0, import_utils.toBoolean)(dineInConfig["sale.allow_add_items"])
|
|
2059
2117
|
};
|
|
2060
|
-
this.logMethodSuccess(
|
|
2118
|
+
this.logMethodSuccess("checkAllowAddItems", result);
|
|
2061
2119
|
return result;
|
|
2062
2120
|
}
|
|
2063
|
-
|
|
2064
2121
|
// 读取取餐/送餐开关
|
|
2065
2122
|
// 依赖 checkResourceAvailable 已缓存的 dineInConfig
|
|
2066
2123
|
getFulfillmentModes() {
|
|
2067
|
-
|
|
2068
|
-
|
|
2124
|
+
var _a;
|
|
2125
|
+
this.logMethodStart("getFulfillmentModes");
|
|
2126
|
+
const dineInConfig = ((_a = this.otherParams) == null ? void 0 : _a.dineInConfig) || {};
|
|
2069
2127
|
const result = {
|
|
2070
|
-
enablePickup: Boolean(dineInConfig[
|
|
2071
|
-
enableTableService: Boolean(dineInConfig[
|
|
2128
|
+
enablePickup: Boolean(dineInConfig["fulfillment.enable_pickup"]),
|
|
2129
|
+
enableTableService: Boolean(dineInConfig["fulfillment.enable_table_service"])
|
|
2072
2130
|
};
|
|
2073
|
-
this.logMethodSuccess(
|
|
2131
|
+
this.logMethodSuccess("getFulfillmentModes", result);
|
|
2074
2132
|
return result;
|
|
2075
2133
|
}
|
|
2076
|
-
|
|
2077
2134
|
// 判定后台是否开启客户自定义取餐标识
|
|
2078
2135
|
// 依赖 checkResourceAvailable 已缓存的 dineInConfig
|
|
2079
2136
|
checkManualPickupRef() {
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
const
|
|
2083
|
-
const
|
|
2084
|
-
const
|
|
2085
|
-
const
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
} : {
|
|
2089
|
-
enabled: false
|
|
2090
|
-
};
|
|
2091
|
-
this.logMethodSuccess('checkManualPickupRef', {
|
|
2137
|
+
var _a;
|
|
2138
|
+
this.logMethodStart("checkManualPickupRef");
|
|
2139
|
+
const dineInConfig = ((_a = this.otherParams) == null ? void 0 : _a.dineInConfig) || {};
|
|
2140
|
+
const refMode = dineInConfig["fulfillment.fulfillment_ref_mode"];
|
|
2141
|
+
const manualInputType = dineInConfig["fulfillment.manual_input_type"];
|
|
2142
|
+
const enabled = refMode === "manual_input";
|
|
2143
|
+
const result = enabled ? { enabled: true, manualInputType } : { enabled: false };
|
|
2144
|
+
this.logMethodSuccess("checkManualPickupRef", {
|
|
2092
2145
|
enabled,
|
|
2093
|
-
manualInputType: enabled ? manualInputType :
|
|
2146
|
+
manualInputType: enabled ? manualInputType : void 0
|
|
2094
2147
|
});
|
|
2095
2148
|
return result;
|
|
2096
2149
|
}
|
|
2097
|
-
}
|
|
2098
|
-
|
|
2150
|
+
};
|
|
2151
|
+
var ScanOrderImpl = _ScanOrderImpl;
|
|
2152
|
+
ScanOrderImpl.PISELL1_LOGIN_SUCCESS = "pisell1.login.success";
|
|
2153
|
+
// ─── UI 状态缓存(按 cacheId 分桶,localStorage) ───
|
|
2154
|
+
//
|
|
2155
|
+
// 用于物料层持久化 UI 层面的轻量状态(如当前步骤、gate 标记、登录回跳意图等)。
|
|
2156
|
+
// 桶键:pisell.scanOrder.uiState:<cacheId>;内部以 JSON object 形式存储多个字段。
|
|
2157
|
+
// 无 cacheId 时所有方法自动降级为 no-op,上层不用判空。
|
|
2158
|
+
//
|
|
2159
|
+
// 之所以用 localStorage 而不是 sessionStorage:
|
|
2160
|
+
// 1. 与 Order 模块 openCache 下的 tempOrder 同栈,购物车在 / UIState 在,行为对齐;
|
|
2161
|
+
// 2. pisell1.login 整页 OAuth 跳转在 H5 壳 / iOS Safari 场景下可能丢 sessionStorage,
|
|
2162
|
+
// 导致登录回跳后 gate 标记失效、pax 弹窗重开、落点错误;localStorage 稳定不受影响。
|
|
2163
|
+
// 3. 失效由上层显式控制:提交成功 clearStepCache / entryContext 不一致 clearUIState /
|
|
2164
|
+
// pendingStep 登录回调 deleteUIState,足够约束生命周期。
|
|
2165
|
+
ScanOrderImpl.UI_STATE_KEY_PREFIX = "pisell.scanOrder.uiState:";
|
|
2166
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2167
|
+
0 && (module.exports = {
|
|
2168
|
+
ScanOrderImpl,
|
|
2169
|
+
...require("./types")
|
|
2170
|
+
});
|