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