@pisell/pisellos 0.0.568 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.js +10 -6
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -3
- package/dist/model/strategy/adapter/promotion/evaluator.js +3 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +7 -5
- package/dist/model/strategy/adapter/walletPass/example.js +26 -3
- package/dist/model/strategy/adapter/walletPass/index.js +5 -5
- package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/dist/model/strategy/adapter/walletPass/utils.js +24 -96
- package/dist/model/strategy/strategy-example.js +19 -5
- package/dist/modules/BaseModule.d.ts +2 -2
- package/dist/modules/BaseModule.js +12 -14
- package/dist/modules/BookingContext/index.d.ts +48 -0
- package/dist/modules/BookingContext/index.js +566 -0
- package/dist/modules/BookingContext/types.d.ts +102 -0
- package/dist/modules/BookingContext/types.js +51 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +302 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +149 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +249 -0
- package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/dist/modules/BookingContext/utils/flexible.js +56 -0
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
- package/dist/modules/BookingContext/utils/index.d.ts +11 -0
- package/dist/modules/BookingContext/utils/index.js +11 -0
- package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/dist/modules/BookingContext/utils/noResource.js +77 -0
- package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/dist/modules/BookingContext/utils/orderLineDisplay.js +36 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/dist/modules/BookingContext/utils/productExtend.js +339 -0
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
- package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
- package/dist/modules/BookingContext/utils/resources.js +486 -0
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
- package/dist/modules/Cart/index.js +3 -0
- package/dist/modules/Cart/utils/cartProduct.js +27 -5
- package/dist/modules/Cart/utils/cartResource.js +0 -2
- package/dist/modules/Cart/utils/changePrice.js +11 -11
- package/dist/modules/Customer/index.d.ts +20 -0
- package/dist/modules/Customer/index.js +172 -83
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Date/index.js +5 -1
- package/dist/modules/Discount/index.d.ts +2 -2
- package/dist/modules/Discount/index.js +43 -30
- package/dist/modules/Discount/types.d.ts +1 -1
- package/dist/modules/OpenData/index.d.ts +8 -0
- package/dist/modules/OpenData/index.js +38 -16
- package/dist/modules/Order/index.d.ts +449 -24
- package/dist/modules/Order/index.js +5460 -574
- package/dist/modules/Order/types.d.ts +693 -88
- package/dist/modules/Order/types.js +68 -1
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/dist/modules/Order/utils/manualProductDiscount.js +210 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
- package/dist/modules/Order/utils.d.ts +167 -18
- package/dist/modules/Order/utils.js +960 -165
- package/dist/modules/Payment/index.d.ts +10 -9
- package/dist/modules/Payment/index.js +573 -746
- package/dist/modules/Payment/types.d.ts +44 -24
- package/dist/modules/Payment/utils.d.ts +1 -1
- package/dist/modules/Payment/utils.js +4 -3
- package/dist/modules/Payment/walletpass.d.ts +0 -2
- package/dist/modules/Payment/walletpass.js +49 -33
- package/dist/modules/Product/types.d.ts +29 -7
- package/dist/modules/ProductList/index.d.ts +17 -13
- package/dist/modules/ProductList/index.js +182 -81
- package/dist/modules/ProductList/types.d.ts +16 -0
- package/dist/modules/Quotation/index.d.ts +22 -2
- package/dist/modules/Quotation/index.js +108 -42
- package/dist/modules/Quotation/types.d.ts +19 -0
- package/dist/modules/ResourcePlanner/index.d.ts +24 -0
- package/dist/modules/ResourcePlanner/index.js +181 -0
- package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
- package/dist/modules/ResourcePlanner/planner.js +1069 -0
- package/dist/modules/ResourcePlanner/types.d.ts +227 -0
- package/dist/modules/ResourcePlanner/types.js +1 -0
- package/dist/modules/Rules/index.d.ts +8 -10
- package/dist/modules/Rules/index.js +324 -513
- package/dist/modules/Rules/types.d.ts +14 -3
- package/dist/modules/SalesSummary/index.d.ts +23 -26
- package/dist/modules/SalesSummary/index.js +152 -46
- package/dist/modules/SalesSummary/types.d.ts +9 -1
- package/dist/modules/SalesSummary/utils.d.ts +3 -22
- package/dist/modules/SalesSummary/utils.js +804 -165
- package/dist/modules/Schedule/getDateIsInSchedule.js +14 -12
- package/dist/modules/Schedule/index.d.ts +18 -5
- package/dist/modules/Schedule/index.js +79 -24
- package/dist/modules/Schedule/types.d.ts +2 -0
- package/dist/modules/Schedule/utils.js +1 -0
- package/dist/modules/Step/index.js +1 -0
- package/dist/modules/Summary/index.js +4 -3
- package/dist/modules/Summary/utils.js +22 -43
- package/dist/modules/SurchargeList/index.d.ts +18 -0
- package/dist/modules/SurchargeList/index.js +185 -0
- package/dist/modules/SurchargeList/types.d.ts +15 -0
- package/dist/modules/SurchargeList/types.js +1 -0
- package/dist/modules/index.d.ts +3 -0
- package/dist/modules/index.js +4 -1
- package/dist/plugins/app.d.ts +2 -0
- package/dist/plugins/request.d.ts +1 -0
- package/dist/plugins/request.js +4 -1
- package/dist/plugins/window.js +6 -2
- package/dist/server/index.d.ts +462 -8
- package/dist/server/index.js +6168 -680
- package/dist/server/modules/floor-plan/index.d.ts +39 -0
- package/dist/server/modules/floor-plan/index.js +595 -0
- package/dist/server/modules/floor-plan/types.d.ts +43 -0
- package/dist/server/modules/floor-plan/types.js +13 -0
- package/dist/server/modules/index.d.ts +7 -2
- package/dist/server/modules/index.js +6 -0
- package/dist/server/modules/menu/index.js +41 -32
- package/dist/server/modules/order/index.d.ts +207 -14
- package/dist/server/modules/order/index.js +2328 -379
- package/dist/server/modules/order/types.d.ts +76 -5
- package/dist/server/modules/order/types.js +14 -1
- package/dist/server/modules/order/utils/filterBookings.d.ts +7 -1
- package/dist/server/modules/order/utils/filterBookings.js +118 -11
- package/dist/server/modules/order/utils/filterOrders.js +242 -14
- package/dist/server/modules/payment/index.d.ts +28 -0
- package/dist/server/modules/payment/index.js +305 -0
- package/dist/server/modules/payment/types.d.ts +9 -0
- package/dist/server/modules/payment/types.js +1 -0
- package/dist/server/modules/products/index.d.ts +105 -14
- package/dist/server/modules/products/index.js +1416 -521
- package/dist/server/modules/products/types.d.ts +34 -1
- package/dist/server/modules/products/types.js +4 -0
- package/dist/server/modules/quotation/index.d.ts +39 -0
- package/dist/server/modules/quotation/index.js +298 -77
- package/dist/server/modules/resource/index.d.ts +2 -3
- package/dist/server/modules/resource/index.js +109 -86
- package/dist/server/modules/schedule/index.d.ts +6 -4
- package/dist/server/modules/schedule/index.js +145 -106
- package/dist/server/test.json +713 -0
- package/dist/server/types.d.ts +2 -0
- package/dist/server/utils/product.js +3 -2
- package/dist/server/utils/small-ticket.d.ts +71 -0
- package/dist/server/utils/small-ticket.js +963 -0
- package/dist/solution/BaseSales/index.d.ts +378 -0
- package/dist/solution/BaseSales/index.js +4009 -0
- package/dist/solution/BaseSales/types.d.ts +394 -0
- package/dist/solution/BaseSales/types.js +40 -0
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
- package/dist/solution/BaseSales/utils/cartPromotion.js +1450 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +144 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +157 -0
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +18 -0
- package/dist/solution/BaseSales/utils/quotationPrice.js +250 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +63 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +218 -0
- package/dist/solution/BaseSales/utils.d.ts +40 -0
- package/dist/solution/BaseSales/utils.js +263 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +60 -11
- package/dist/solution/BookingByStep/utils/capacity.js +11 -1
- package/dist/solution/BookingByStep/utils/resources.js +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +43 -2
- package/dist/solution/BookingTicket/index.d.ts +393 -24
- package/dist/solution/BookingTicket/index.js +2508 -443
- package/dist/solution/BookingTicket/types.d.ts +191 -6
- package/dist/solution/BookingTicket/types.js +83 -10
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
- package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
- package/dist/solution/BookingTicket/utils/addTimeAvailability.js +95 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.js +136 -0
- package/dist/solution/BookingTicket/utils/cartView.d.ts +29 -0
- package/dist/solution/BookingTicket/utils/cartView.js +209 -0
- package/dist/solution/BookingTicket/utils/exampleData.d.ts +123 -0
- package/dist/solution/BookingTicket/utils/exampleData.js +183 -0
- package/dist/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
- package/dist/solution/BookingTicket/utils/orderCustomer.js +31 -0
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +438 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +400 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +4 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +42 -1
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +56 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +42 -28
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +30 -14
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +150 -0
- package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
- package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +78 -0
- package/dist/solution/BuyTickets/index.js +12 -9
- package/dist/solution/Checkout/index.d.ts +1 -0
- package/dist/solution/Checkout/index.js +275 -209
- package/dist/solution/Checkout/utils/index.js +20 -8
- package/dist/solution/RegisterAndLogin/config.js +2 -10
- package/dist/solution/RegisterAndLogin/index.js +76 -30
- package/dist/solution/Sales/index.d.ts +50 -5
- package/dist/solution/Sales/index.js +484 -92
- package/dist/solution/Sales/types.d.ts +26 -2
- package/dist/solution/ScanOrder/index.d.ts +27 -21
- package/dist/solution/ScanOrder/index.js +519 -444
- package/dist/solution/ScanOrder/types.d.ts +33 -11
- package/dist/solution/ScanOrder/types.js +4 -5
- package/dist/solution/ScanOrder/utils.d.ts +4 -1
- package/dist/solution/ScanOrder/utils.js +109 -34
- package/dist/solution/ShopDiscount/index.js +18 -19
- package/dist/solution/ShopDiscount/types.d.ts +4 -5
- package/dist/solution/ShopDiscount/utils.d.ts +0 -9
- package/dist/solution/ShopDiscount/utils.js +0 -9
- package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/dist/solution/UnifiedBookingSales/index.js +1871 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/dist/solution/UnifiedBookingSales/types.js +11 -0
- package/dist/solution/VenueBooking/index.d.ts +32 -51
- package/dist/solution/VenueBooking/index.js +741 -808
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/dist/solution/VenueBooking/types.d.ts +1 -3
- package/dist/solution/VenueBooking/types.js +0 -1
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +9 -3
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -1
- package/dist/types/index.d.ts +12 -2
- package/dist/utils/task.js +18 -15
- package/dist/utils/watch.js +1 -0
- package/lib/apis/picoding.js +0 -2
- package/lib/core/index.js +132 -130
- package/lib/effects/index.js +57 -46
- package/lib/index.d.ts +0 -1
- package/lib/index.js +50 -92
- package/lib/model/index.js +21 -14
- package/lib/model/strategy/adapter/dataVariant/adapter.js +50 -38
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +236 -162
- package/lib/model/strategy/adapter/dataVariant/examples.js +237 -229
- package/lib/model/strategy/adapter/dataVariant/index.js +34 -39
- package/lib/model/strategy/adapter/dataVariant/type.js +28 -57
- package/lib/model/strategy/adapter/index.js +64 -100
- package/lib/model/strategy/adapter/itemRule/adapter.js +144 -156
- package/lib/model/strategy/adapter/itemRule/evaluator.js +48 -36
- package/lib/model/strategy/adapter/itemRule/examples.js +225 -295
- package/lib/model/strategy/adapter/itemRule/index.js +57 -83
- package/lib/model/strategy/adapter/itemRule/type.js +36 -97
- package/lib/model/strategy/adapter/promotion/adapter.js +63 -84
- package/lib/model/strategy/adapter/promotion/evaluator.js +233 -382
- package/lib/model/strategy/adapter/promotion/examples.js +159 -139
- package/lib/model/strategy/adapter/promotion/index.js +0 -1
- package/lib/model/strategy/adapter/promotion/type.js +35 -199
- package/lib/model/strategy/adapter/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/evaluator.js +152 -180
- package/lib/model/strategy/adapter/walletPass/example.js +190 -217
- package/lib/model/strategy/adapter/walletPass/index.js +51 -75
- package/lib/model/strategy/adapter/walletPass/locales.js +58 -36
- package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/lib/model/strategy/adapter/walletPass/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/lib/model/strategy/adapter/walletPass/utils.js +383 -676
- package/lib/model/strategy/engine.js +168 -270
- package/lib/model/strategy/index.js +34 -49
- package/lib/model/strategy/strategy-example.js +239 -243
- package/lib/model/strategy/type.js +40 -100
- package/lib/modules/Account/index.js +53 -39
- package/lib/modules/Account/types.js +33 -20
- package/lib/modules/AccountList/index.js +154 -116
- package/lib/modules/AccountList/types.js +31 -30
- package/lib/modules/AccountList/utils.js +30 -18
- package/lib/modules/BaseModule.d.ts +2 -2
- package/lib/modules/BaseModule.js +50 -29
- package/lib/modules/BookingContext/index.d.ts +48 -0
- package/lib/modules/BookingContext/index.js +368 -0
- package/lib/modules/BookingContext/types.d.ts +102 -0
- package/lib/modules/BookingContext/types.js +34 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +298 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +155 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +222 -0
- package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/lib/modules/BookingContext/utils/flexible.js +80 -0
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
- package/lib/modules/BookingContext/utils/index.d.ts +11 -0
- package/lib/modules/BookingContext/utils/index.js +43 -0
- package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/lib/modules/BookingContext/utils/noResource.js +90 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +56 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/lib/modules/BookingContext/utils/productExtend.js +283 -0
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
- package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
- package/lib/modules/BookingContext/utils/resources.js +377 -0
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
- package/lib/modules/Cart/index.js +124 -170
- package/lib/modules/Cart/types.js +51 -46
- package/lib/modules/Cart/utils/cartAccount.js +39 -40
- package/lib/modules/Cart/utils/cartDate.js +61 -56
- package/lib/modules/Cart/utils/cartDiscount.js +33 -28
- package/lib/modules/Cart/utils/cartNote.js +32 -27
- package/lib/modules/Cart/utils/cartProduct.js +261 -309
- package/lib/modules/Cart/utils/cartRelationForms.js +35 -29
- package/lib/modules/Cart/utils/cartResource.js +78 -72
- package/lib/modules/Cart/utils/changePrice.js +59 -31
- package/lib/modules/Cart/utils/index.js +48 -106
- package/lib/modules/Customer/constants.js +34 -13
- package/lib/modules/Customer/index.d.ts +20 -0
- package/lib/modules/Customer/index.js +207 -217
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Customer/types.js +35 -38
- package/lib/modules/Date/index.js +115 -116
- package/lib/modules/Date/types.js +28 -16
- package/lib/modules/Date/utils.js +123 -174
- package/lib/modules/Discount/index.d.ts +2 -2
- package/lib/modules/Discount/index.js +133 -119
- package/lib/modules/Discount/types.d.ts +1 -1
- package/lib/modules/Discount/types.js +31 -9
- package/lib/modules/Guests/index.js +56 -30
- package/lib/modules/Guests/types.js +33 -23
- package/lib/modules/Holder/index.js +189 -209
- package/lib/modules/Holder/types.js +16 -4
- package/lib/modules/Holder/utils.js +49 -20
- package/lib/modules/OpenData/index.d.ts +8 -0
- package/lib/modules/OpenData/index.js +88 -63
- package/lib/modules/OpenData/types.js +16 -4
- package/lib/modules/OpenData/utils.js +78 -44
- package/lib/modules/Order/index.d.ts +449 -24
- package/lib/modules/Order/index.js +4184 -514
- package/lib/modules/Order/types.d.ts +693 -88
- package/lib/modules/Order/types.js +35 -24
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/lib/modules/Order/utils/bundleDiscountHydration.js +139 -0
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/lib/modules/Order/utils/manualProductDiscount.js +206 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +415 -0
- package/lib/modules/Order/utils.d.ts +167 -18
- package/lib/modules/Order/utils.js +1085 -414
- package/lib/modules/Payment/cash.js +33 -20
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +76 -145
- package/lib/modules/Payment/eftpos.js +30 -16
- package/lib/modules/Payment/index.d.ts +10 -9
- package/lib/modules/Payment/index.js +402 -636
- package/lib/modules/Payment/mx51.js +0 -1
- package/lib/modules/Payment/types.d.ts +44 -24
- package/lib/modules/Payment/types.js +107 -216
- package/lib/modules/Payment/utils.d.ts +1 -1
- package/lib/modules/Payment/utils.js +50 -52
- package/lib/modules/Payment/walletpass.d.ts +0 -2
- package/lib/modules/Payment/walletpass.js +216 -221
- package/lib/modules/Product/index.js +46 -51
- package/lib/modules/Product/types.d.ts +29 -7
- package/lib/modules/Product/types.js +16 -4
- package/lib/modules/Product/utils.js +33 -32
- package/lib/modules/ProductList/index.d.ts +17 -13
- package/lib/modules/ProductList/index.js +161 -120
- package/lib/modules/ProductList/types.d.ts +16 -0
- package/lib/modules/ProductList/types.js +31 -9
- package/lib/modules/Quotation/index.d.ts +22 -2
- package/lib/modules/Quotation/index.js +154 -64
- package/lib/modules/Quotation/types.d.ts +19 -0
- package/lib/modules/Quotation/types.js +16 -4
- package/lib/modules/Resource/index.js +59 -27
- package/lib/modules/Resource/types.js +32 -22
- package/lib/modules/Resource/utils.js +38 -30
- package/lib/modules/ResourcePlanner/index.d.ts +24 -0
- package/lib/modules/ResourcePlanner/index.js +148 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
- package/lib/modules/ResourcePlanner/planner.js +933 -0
- package/lib/modules/ResourcePlanner/types.d.ts +227 -0
- package/lib/modules/ResourcePlanner/types.js +17 -0
- package/lib/modules/Rules/index.d.ts +8 -10
- package/lib/modules/Rules/index.js +960 -1440
- package/lib/modules/Rules/types.d.ts +14 -3
- package/lib/modules/Rules/types.js +40 -17
- package/lib/modules/SalesSummary/index.d.ts +23 -26
- package/lib/modules/SalesSummary/index.js +134 -61
- package/lib/modules/SalesSummary/types.d.ts +9 -1
- package/lib/modules/SalesSummary/types.js +16 -4
- package/lib/modules/SalesSummary/utils.d.ts +3 -22
- package/lib/modules/SalesSummary/utils.js +814 -233
- package/lib/modules/ScanOrderLogger/index.js +79 -59
- package/lib/modules/ScanOrderLogger/providers/feishu.js +78 -54
- package/lib/modules/ScanOrderLogger/providers/grafana.js +36 -13
- package/lib/modules/ScanOrderLogger/types.js +16 -4
- package/lib/modules/Schedule/getDateIsInSchedule.js +169 -338
- package/lib/modules/Schedule/index.d.ts +18 -5
- package/lib/modules/Schedule/index.js +153 -104
- package/lib/modules/Schedule/type.js +16 -4
- package/lib/modules/Schedule/types.d.ts +2 -0
- package/lib/modules/Schedule/types.js +16 -4
- package/lib/modules/Schedule/utils.js +291 -433
- package/lib/modules/Step/index.js +52 -40
- package/lib/modules/Step/tyeps.js +16 -4
- package/lib/modules/Summary/index.js +71 -66
- package/lib/modules/Summary/types.js +16 -4
- package/lib/modules/Summary/utils.js +418 -791
- package/lib/modules/SurchargeList/index.d.ts +18 -0
- package/lib/modules/SurchargeList/index.js +109 -0
- package/lib/modules/SurchargeList/types.d.ts +15 -0
- package/lib/modules/SurchargeList/types.js +17 -0
- package/lib/modules/index.d.ts +3 -0
- package/lib/modules/index.js +63 -212
- package/lib/plugins/app.d.ts +2 -0
- package/lib/plugins/app.js +16 -4
- package/lib/plugins/index.js +25 -36
- package/lib/plugins/request.d.ts +1 -0
- package/lib/plugins/request.js +126 -137
- package/lib/plugins/shopStore.js +16 -4
- package/lib/plugins/user.js +16 -4
- package/lib/plugins/window.js +179 -171
- package/lib/server/index.d.ts +462 -8
- package/lib/server/index.js +4520 -1162
- package/lib/server/modules/floor-plan/index.d.ts +39 -0
- package/lib/server/modules/floor-plan/index.js +327 -0
- package/lib/server/modules/floor-plan/types.d.ts +43 -0
- package/lib/server/modules/floor-plan/types.js +34 -0
- package/lib/server/modules/index.d.ts +7 -2
- package/lib/server/modules/index.js +67 -84
- package/lib/server/modules/menu/index.js +122 -146
- package/lib/server/modules/menu/types.js +31 -18
- package/lib/server/modules/order/index.d.ts +207 -14
- package/lib/server/modules/order/index.js +1543 -285
- package/lib/server/modules/order/types.d.ts +76 -5
- package/lib/server/modules/order/types.js +32 -107
- package/lib/server/modules/order/utils/filterBookings.d.ts +7 -1
- package/lib/server/modules/order/utils/filterBookings.js +259 -176
- package/lib/server/modules/order/utils/filterOrders.js +293 -94
- package/lib/server/modules/payment/index.d.ts +28 -0
- package/lib/server/modules/payment/index.js +192 -0
- package/lib/server/modules/payment/types.d.ts +9 -0
- package/lib/server/modules/payment/types.js +17 -0
- package/lib/server/modules/products/index.d.ts +105 -14
- package/lib/server/modules/products/index.js +850 -475
- package/lib/server/modules/products/types.d.ts +34 -1
- package/lib/server/modules/products/types.js +34 -41
- package/lib/server/modules/quotation/index.d.ts +39 -0
- package/lib/server/modules/quotation/index.js +254 -75
- package/lib/server/modules/quotation/types.js +31 -21
- package/lib/server/modules/resource/index.d.ts +2 -3
- package/lib/server/modules/resource/index.js +240 -243
- package/lib/server/modules/resource/types.js +33 -42
- package/lib/server/modules/schedule/index.d.ts +6 -4
- package/lib/server/modules/schedule/index.js +146 -147
- package/lib/server/modules/schedule/types.js +21 -14
- package/lib/server/modules/schedule/utils.js +163 -334
- package/lib/server/test.json +713 -0
- package/lib/server/types.d.ts +2 -0
- package/lib/server/types.js +16 -4
- package/lib/server/utils/index.js +23 -25
- package/lib/server/utils/product.js +140 -197
- package/lib/server/utils/schedule.js +41 -34
- package/lib/server/utils/small-ticket.d.ts +71 -0
- package/lib/server/utils/small-ticket.js +904 -0
- package/lib/server/utils/time.js +49 -40
- package/lib/solution/BaseSales/index.d.ts +378 -0
- package/lib/solution/BaseSales/index.js +2533 -0
- package/lib/solution/BaseSales/types.d.ts +394 -0
- package/lib/solution/BaseSales/types.js +43 -0
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
- package/lib/solution/BaseSales/utils/cartPromotion.js +1004 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +144 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +160 -0
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +18 -0
- package/lib/solution/BaseSales/utils/quotationPrice.js +289 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +63 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +256 -0
- package/lib/solution/BaseSales/utils.d.ts +40 -0
- package/lib/solution/BaseSales/utils.js +244 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +1340 -1530
- package/lib/solution/BookingByStep/types.js +99 -40
- package/lib/solution/BookingByStep/utils/capacity.js +160 -192
- package/lib/solution/BookingByStep/utils/products.js +52 -42
- package/lib/solution/BookingByStep/utils/resources.js +330 -527
- package/lib/solution/BookingByStep/utils/stock.js +44 -65
- package/lib/solution/BookingByStep/utils/timeslots.js +131 -129
- package/lib/solution/BookingTicket/index.d.ts +393 -24
- package/lib/solution/BookingTicket/index.js +1374 -184
- package/lib/solution/BookingTicket/types.d.ts +191 -6
- package/lib/solution/BookingTicket/types.js +79 -40
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
- package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +125 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.js +107 -0
- package/lib/solution/BookingTicket/utils/cartView.d.ts +29 -0
- package/lib/solution/BookingTicket/utils/cartView.js +184 -0
- package/lib/solution/BookingTicket/utils/exampleData.d.ts +123 -0
- package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +58 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +254 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +169 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +97 -64
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +51 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +81 -82
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +109 -91
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +43 -90
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +127 -0
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +85 -0
- package/lib/solution/BuyTickets/index.js +70 -67
- package/lib/solution/BuyTickets/types.js +38 -22
- package/lib/solution/Checkout/index.d.ts +1 -0
- package/lib/solution/Checkout/index.js +1169 -1463
- package/lib/solution/Checkout/types.js +61 -91
- package/lib/solution/Checkout/utils/index.js +156 -228
- package/lib/solution/PlaceOrder/index.js +0 -55
- package/lib/solution/RegisterAndLogin/config.js +462 -503
- package/lib/solution/RegisterAndLogin/index.js +630 -633
- package/lib/solution/RegisterAndLogin/types.js +76 -189
- package/lib/solution/RegisterAndLogin/utils.js +125 -183
- package/lib/solution/Sales/index.d.ts +50 -5
- package/lib/solution/Sales/index.js +498 -238
- package/lib/solution/Sales/types.d.ts +26 -2
- package/lib/solution/Sales/types.js +33 -27
- package/lib/solution/ScanOrder/index.d.ts +27 -21
- package/lib/solution/ScanOrder/index.js +936 -864
- package/lib/solution/ScanOrder/types.d.ts +33 -11
- package/lib/solution/ScanOrder/types.js +34 -34
- package/lib/solution/ScanOrder/utils.d.ts +4 -1
- package/lib/solution/ScanOrder/utils.js +422 -385
- package/lib/solution/ShopDiscount/index.js +233 -235
- package/lib/solution/ShopDiscount/types.d.ts +4 -5
- package/lib/solution/ShopDiscount/types.js +37 -15
- package/lib/solution/ShopDiscount/utils.d.ts +0 -9
- package/lib/solution/ShopDiscount/utils.js +172 -309
- package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/lib/solution/UnifiedBookingSales/index.js +1076 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/lib/solution/UnifiedBookingSales/types.js +33 -0
- package/lib/solution/VenueBooking/index.d.ts +32 -51
- package/lib/solution/VenueBooking/index.js +1008 -984
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/lib/solution/VenueBooking/types.d.ts +1 -3
- package/lib/solution/VenueBooking/types.js +39 -20
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/lib/solution/VenueBooking/utils/dateSummary.js +62 -25
- package/lib/solution/VenueBooking/utils/resource.js +54 -31
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +109 -90
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/lib/solution/VenueBooking/utils/timeSlot.js +133 -138
- package/lib/solution/VenueBooking/utils.js +67 -130
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +41 -102
- package/lib/store/createStore.js +29 -32
- package/lib/types/index.d.ts +12 -2
- package/lib/types/index.js +16 -4
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +47 -81
- package/package.json +2 -4
- package/dist/solution/Checkout/appointmentDemo.json +0 -1
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
- package/lib/solution/Checkout/appointmentDemo.json +0 -1
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/lib/solution/VenueBooking/utils/smartPricing.js +0 -192
|
@@ -1,114 +1,126 @@
|
|
|
1
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
2
28
|
|
|
3
|
-
|
|
4
|
-
|
|
29
|
+
// src/solution/ScanOrder/utils.ts
|
|
30
|
+
var utils_exports = {};
|
|
31
|
+
__export(utils_exports, {
|
|
32
|
+
aggregateItemRuleLimit: () => aggregateItemRuleLimit,
|
|
33
|
+
attachItemRuleLimitsToTopLevelProducts: () => attachItemRuleLimitsToTopLevelProducts,
|
|
34
|
+
buildItemRuleBusinessData: () => buildItemRuleBusinessData,
|
|
35
|
+
buildProductKey: () => buildProductKey,
|
|
36
|
+
buildProductLineFingerprint: () => buildProductLineFingerprint,
|
|
37
|
+
buildQuantityLimitIndex: () => buildQuantityLimitIndex,
|
|
38
|
+
collectLinkProductIdsFromReservationRules: () => collectLinkProductIdsFromReservationRules,
|
|
39
|
+
computeResourceIsFull: () => computeResourceIsFull,
|
|
40
|
+
createEmptySummary: () => createEmptySummary,
|
|
41
|
+
extractStrategyModelIdsFromTableConfig: () => extractStrategyModelIdsFromTableConfig,
|
|
42
|
+
filterProductsForScanOrderMore: () => filterProductsForScanOrderMore,
|
|
43
|
+
findReservationRuleProductByResourceId: () => findReservationRuleProductByResourceId,
|
|
44
|
+
getProductIdentityIndex: () => getProductIdentityIndex,
|
|
45
|
+
getSafeProductNum: () => getSafeProductNum,
|
|
46
|
+
getTopLevelProductId: () => getTopLevelProductId,
|
|
47
|
+
getTopLevelVariantId: () => getTopLevelVariantId,
|
|
48
|
+
hasCustomCapacityProduct: () => hasCustomCapacityProduct,
|
|
49
|
+
isIdentityMatch: () => isIdentityMatch,
|
|
50
|
+
isSkuOnlyDeleteIdentity: () => isSkuOnlyDeleteIdentity,
|
|
51
|
+
normalizeEnabledItemRuleIds: () => normalizeEnabledItemRuleIds,
|
|
52
|
+
normalizeItemRuleStrategies: () => normalizeItemRuleStrategies,
|
|
53
|
+
normalizeOrderProduct: () => normalizeOrderProduct,
|
|
54
|
+
pickFirstCustomCapacityDimensionId: () => pickFirstCustomCapacityDimensionId,
|
|
55
|
+
pickFirstCustomCapacityPaxBounds: () => pickFirstCustomCapacityPaxBounds,
|
|
56
|
+
pickFirstDurationMinutesFromProducts: () => pickFirstDurationMinutesFromProducts,
|
|
57
|
+
resolveSkuMatchedQuantityLimits: () => resolveSkuMatchedQuantityLimits,
|
|
58
|
+
toBoolean: () => toBoolean,
|
|
59
|
+
toNonNegativeInt: () => toNonNegativeInt,
|
|
60
|
+
toNonNegativeNumber: () => toNonNegativeNumber,
|
|
61
|
+
toPositiveString: () => toPositiveString,
|
|
62
|
+
toPriceString: () => toPriceString
|
|
5
63
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
exports.buildQuantityLimitIndex = buildQuantityLimitIndex;
|
|
12
|
-
exports.collectLinkProductIdsFromReservationRules = collectLinkProductIdsFromReservationRules;
|
|
13
|
-
exports.computeResourceIsFull = computeResourceIsFull;
|
|
14
|
-
exports.createEmptySummary = createEmptySummary;
|
|
15
|
-
exports.extractStrategyModelIdsFromTableConfig = extractStrategyModelIdsFromTableConfig;
|
|
16
|
-
exports.findReservationRuleProductByResourceId = findReservationRuleProductByResourceId;
|
|
17
|
-
exports.getProductIdentityIndex = getProductIdentityIndex;
|
|
18
|
-
exports.getSafeProductNum = getSafeProductNum;
|
|
19
|
-
exports.getTopLevelProductId = getTopLevelProductId;
|
|
20
|
-
exports.getTopLevelVariantId = getTopLevelVariantId;
|
|
21
|
-
exports.hasCustomCapacityProduct = hasCustomCapacityProduct;
|
|
22
|
-
exports.isIdentityMatch = isIdentityMatch;
|
|
23
|
-
exports.isSkuOnlyDeleteIdentity = isSkuOnlyDeleteIdentity;
|
|
24
|
-
exports.normalizeEnabledItemRuleIds = normalizeEnabledItemRuleIds;
|
|
25
|
-
exports.normalizeItemRuleStrategies = normalizeItemRuleStrategies;
|
|
26
|
-
exports.normalizeOrderProduct = normalizeOrderProduct;
|
|
27
|
-
exports.pickFirstCustomCapacityDimensionId = pickFirstCustomCapacityDimensionId;
|
|
28
|
-
exports.pickFirstCustomCapacityPaxBounds = pickFirstCustomCapacityPaxBounds;
|
|
29
|
-
exports.pickFirstDurationMinutesFromProducts = pickFirstDurationMinutesFromProducts;
|
|
30
|
-
exports.resolveSkuMatchedQuantityLimits = resolveSkuMatchedQuantityLimits;
|
|
31
|
-
exports.toBoolean = toBoolean;
|
|
32
|
-
exports.toNonNegativeInt = toNonNegativeInt;
|
|
33
|
-
exports.toNonNegativeNumber = toNonNegativeNumber;
|
|
34
|
-
exports.toPositiveString = toPositiveString;
|
|
35
|
-
exports.toPriceString = toPriceString;
|
|
36
|
-
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
37
|
-
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
38
|
-
var _utils = require("../../modules/Order/utils");
|
|
39
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
40
|
-
/**
|
|
41
|
-
* 构建金额全为 0 的空 summary。
|
|
42
|
-
* 作为尚未计算金额时的兜底默认值,避免下游因 undefined 报错。
|
|
43
|
-
*/
|
|
64
|
+
module.exports = __toCommonJS(utils_exports);
|
|
65
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
66
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
67
|
+
var import_utils = require("../../modules/Order/utils");
|
|
68
|
+
var import_manualProductDiscount = require("../../modules/Order/utils/manualProductDiscount");
|
|
44
69
|
function createEmptySummary() {
|
|
45
70
|
return {
|
|
46
71
|
product_quantity: 0,
|
|
47
|
-
product_original_amount:
|
|
48
|
-
product_amount:
|
|
49
|
-
product_expect_amount:
|
|
50
|
-
product_tax_fee:
|
|
51
|
-
shipping_fee:
|
|
52
|
-
shipping_tax_fee:
|
|
53
|
-
tax_fee:
|
|
54
|
-
surcharge_fee:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
72
|
+
product_original_amount: "0.00",
|
|
73
|
+
product_amount: "0.00",
|
|
74
|
+
product_expect_amount: "0.00",
|
|
75
|
+
product_tax_fee: "0.00",
|
|
76
|
+
shipping_fee: "0.00",
|
|
77
|
+
shipping_tax_fee: "0.00",
|
|
78
|
+
tax_fee: "0.00",
|
|
79
|
+
surcharge_fee: "0.00",
|
|
80
|
+
surcharges: [],
|
|
81
|
+
discount_amount: "0.00",
|
|
82
|
+
deposit_amount: "0.00",
|
|
83
|
+
expect_amount: "0.00",
|
|
84
|
+
total_amount: "0.00",
|
|
85
|
+
total_refund_amount: "0.00",
|
|
86
|
+
customer_paid_amount: "0.00",
|
|
87
|
+
order_paid_amount: "0.00",
|
|
88
|
+
amount_gap: "0.00",
|
|
89
|
+
rounding_amount: "0.00",
|
|
90
|
+
pay_service_charge_amount: "0.00"
|
|
62
91
|
};
|
|
63
92
|
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* 商品数量安全取值。
|
|
67
|
-
* - NaN / undefined / < 1 均视作 1(最低起订量)
|
|
68
|
-
* - 有值时取整(不支持小数数量)
|
|
69
|
-
*/
|
|
70
93
|
function getSafeProductNum(num) {
|
|
71
|
-
if (!num || Number.isNaN(num))
|
|
72
|
-
|
|
94
|
+
if (!num || Number.isNaN(num))
|
|
95
|
+
return 1;
|
|
96
|
+
if (num < 1)
|
|
97
|
+
return 1;
|
|
73
98
|
return Math.floor(num);
|
|
74
99
|
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* 宽松布尔值转换。
|
|
78
|
-
* 兼容后端/配置中心常见的 boolean / number / string 表达,统一归一成 true/false。
|
|
79
|
-
*/
|
|
80
100
|
function toBoolean(value) {
|
|
81
|
-
if (typeof value ===
|
|
82
|
-
|
|
83
|
-
if (typeof value ===
|
|
101
|
+
if (typeof value === "boolean")
|
|
102
|
+
return value;
|
|
103
|
+
if (typeof value === "number")
|
|
104
|
+
return value !== 0;
|
|
105
|
+
if (typeof value === "string") {
|
|
84
106
|
const normalized = value.trim().toLowerCase();
|
|
85
|
-
return [
|
|
107
|
+
return ["1", "true", "yes", "y", "on"].includes(normalized);
|
|
86
108
|
}
|
|
87
109
|
return false;
|
|
88
110
|
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* 将值归一化为有效的正向字符串。
|
|
92
|
-
* null / undefined / 空串 / '0' / 'null' 统一视为无效值并返回 undefined。
|
|
93
|
-
*/
|
|
94
111
|
function toPositiveString(value) {
|
|
95
|
-
if (value === null || value ===
|
|
112
|
+
if (value === null || value === void 0 || value === "")
|
|
113
|
+
return void 0;
|
|
96
114
|
const normalized = String(value).trim();
|
|
97
|
-
if (!normalized || normalized ===
|
|
98
|
-
return
|
|
115
|
+
if (!normalized || normalized === "0" || normalized.toLowerCase() === "null") {
|
|
116
|
+
return void 0;
|
|
99
117
|
}
|
|
100
118
|
return normalized;
|
|
101
119
|
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* 归一化 item rule 策略模型 ID 列表。
|
|
105
|
-
* - 支持 string / number 混合输入
|
|
106
|
-
* - 仅保留 > 0 的合法数字
|
|
107
|
-
* - 自动去重
|
|
108
|
-
*/
|
|
109
120
|
function normalizeEnabledItemRuleIds(rawIds) {
|
|
110
|
-
if (!Array.isArray(rawIds))
|
|
111
|
-
|
|
121
|
+
if (!Array.isArray(rawIds))
|
|
122
|
+
return [];
|
|
123
|
+
const uniqueIds = /* @__PURE__ */ new Set();
|
|
112
124
|
for (const item of rawIds) {
|
|
113
125
|
const strategyId = Number(item);
|
|
114
126
|
if (Number.isFinite(strategyId) && strategyId > 0) {
|
|
@@ -117,27 +129,27 @@ function normalizeEnabledItemRuleIds(rawIds) {
|
|
|
117
129
|
}
|
|
118
130
|
return Array.from(uniqueIds);
|
|
119
131
|
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* 从 tableConfig 中提取合法策略模型 ID 列表。
|
|
123
|
-
*/
|
|
124
132
|
function extractStrategyModelIdsFromTableConfig(tableConfig) {
|
|
125
|
-
const rawIds = Array.isArray(tableConfig
|
|
126
|
-
return rawIds.map(id => Number(id)).filter(id => Number.isFinite(id) && id > 0);
|
|
133
|
+
const rawIds = Array.isArray(tableConfig == null ? void 0 : tableConfig.strategy_model_ids) ? tableConfig.strategy_model_ids : [];
|
|
134
|
+
return rawIds.map((id) => Number(id)).filter((id) => Number.isFinite(id) && id > 0);
|
|
127
135
|
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* 仅保留 item_rule 类型策略。
|
|
131
|
-
*/
|
|
132
136
|
function normalizeItemRuleStrategies(configs) {
|
|
133
|
-
if (!Array.isArray(configs))
|
|
134
|
-
|
|
137
|
+
if (!Array.isArray(configs))
|
|
138
|
+
return [];
|
|
139
|
+
return configs.filter(
|
|
140
|
+
(config) => {
|
|
141
|
+
var _a;
|
|
142
|
+
return Boolean(
|
|
143
|
+
config && typeof config === "object" && ((_a = config == null ? void 0 : config.metadata) == null ? void 0 : _a.type) === "item_rule"
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
);
|
|
135
147
|
}
|
|
136
148
|
function toNonNegativeNumber(value) {
|
|
137
|
-
if (typeof value ===
|
|
149
|
+
if (typeof value === "number") {
|
|
138
150
|
return Number.isFinite(value) && value >= 0 ? value : 0;
|
|
139
151
|
}
|
|
140
|
-
if (typeof value ===
|
|
152
|
+
if (typeof value === "string") {
|
|
141
153
|
const parsed = Number(value);
|
|
142
154
|
return Number.isFinite(parsed) && parsed >= 0 ? parsed : 0;
|
|
143
155
|
}
|
|
@@ -146,40 +158,49 @@ function toNonNegativeNumber(value) {
|
|
|
146
158
|
function toNonNegativeInt(value) {
|
|
147
159
|
return Math.floor(toNonNegativeNumber(value));
|
|
148
160
|
}
|
|
149
|
-
function toPriceString(value, fallback =
|
|
161
|
+
function toPriceString(value, fallback = "0.00") {
|
|
150
162
|
const parsedValue = Number(value);
|
|
151
|
-
if (Number.isNaN(parsedValue))
|
|
163
|
+
if (Number.isNaN(parsedValue))
|
|
164
|
+
return fallback;
|
|
152
165
|
return parsedValue.toFixed(2);
|
|
153
166
|
}
|
|
154
167
|
function buildProductKey(productId, productVariantId) {
|
|
155
168
|
return `${productId}_${productVariantId}`;
|
|
156
169
|
}
|
|
170
|
+
function filterProductsForScanOrderMore(products = []) {
|
|
171
|
+
return products.filter((product) => {
|
|
172
|
+
var _a;
|
|
173
|
+
return ((_a = product.metadata) == null ? void 0 : _a.is_rule) !== true;
|
|
174
|
+
});
|
|
175
|
+
}
|
|
157
176
|
function getTopLevelProductId(product) {
|
|
158
177
|
const rawProductId = product.product_id ?? product.id;
|
|
159
178
|
const productId = Number(rawProductId);
|
|
160
|
-
if (!Number.isFinite(productId) || productId <= 0)
|
|
179
|
+
if (!Number.isFinite(productId) || productId <= 0)
|
|
180
|
+
return null;
|
|
161
181
|
return productId;
|
|
162
182
|
}
|
|
163
183
|
function getTopLevelVariantId(product) {
|
|
164
184
|
const rawVariantId = product.product_variant_id ?? product.variant_id;
|
|
165
|
-
if (rawVariantId ===
|
|
185
|
+
if (rawVariantId === void 0 || rawVariantId === null || rawVariantId === "") {
|
|
166
186
|
return null;
|
|
167
187
|
}
|
|
168
188
|
const variantId = Number(rawVariantId);
|
|
169
|
-
if (!Number.isFinite(variantId) || variantId <= 0)
|
|
189
|
+
if (!Number.isFinite(variantId) || variantId <= 0)
|
|
190
|
+
return null;
|
|
170
191
|
return variantId;
|
|
171
192
|
}
|
|
172
193
|
function buildQuantityLimitIndex(limits) {
|
|
173
|
-
const exactLimitMap = new Map();
|
|
174
|
-
const productLimitMap = new Map();
|
|
194
|
+
const exactLimitMap = /* @__PURE__ */ new Map();
|
|
195
|
+
const productLimitMap = /* @__PURE__ */ new Map();
|
|
175
196
|
for (const limit of limits) {
|
|
176
197
|
const targets = limit.targets || [];
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if (targets.length !== 1) continue;
|
|
198
|
+
if (targets.length !== 1)
|
|
199
|
+
continue;
|
|
180
200
|
const target = targets[0];
|
|
181
201
|
const productId = Number(target.product_id);
|
|
182
|
-
if (!Number.isFinite(productId) || productId <= 0)
|
|
202
|
+
if (!Number.isFinite(productId) || productId <= 0)
|
|
203
|
+
continue;
|
|
183
204
|
const variantId = Number(target.product_variant_id);
|
|
184
205
|
const hasVariant = Number.isFinite(variantId) && variantId > 0;
|
|
185
206
|
if (hasVariant) {
|
|
@@ -197,53 +218,44 @@ function buildQuantityLimitIndex(limits) {
|
|
|
197
218
|
};
|
|
198
219
|
}
|
|
199
220
|
function resolveSkuMatchedQuantityLimits(params) {
|
|
200
|
-
const {
|
|
201
|
-
productId,
|
|
202
|
-
variantId,
|
|
203
|
-
limitIndex
|
|
204
|
-
} = params;
|
|
221
|
+
const { productId, variantId, limitIndex } = params;
|
|
205
222
|
const exactMatched = variantId && variantId > 0 ? limitIndex.exactLimitMap.get(buildProductKey(productId, variantId)) || [] : [];
|
|
206
223
|
const productMatched = limitIndex.productLimitMap.get(productId) || [];
|
|
207
224
|
return [...exactMatched, ...productMatched];
|
|
208
225
|
}
|
|
209
226
|
function aggregateItemRuleLimit(matchedLimits) {
|
|
210
|
-
if (!matchedLimits.length)
|
|
227
|
+
if (!matchedLimits.length)
|
|
228
|
+
return null;
|
|
211
229
|
let min;
|
|
212
230
|
let max;
|
|
213
231
|
let remainingMax;
|
|
214
232
|
let exact;
|
|
215
233
|
let mustInclude = false;
|
|
216
|
-
|
|
217
|
-
// 聚合 validationMessage 按 min / max 两个方向分别输出:
|
|
218
|
-
// - maxValidationMessage:触发"当前 max / remainingMax / exact"的那条规则的文案
|
|
219
|
-
// - minValidationMessage:触发"当前 min / exact"的那条规则的文案
|
|
220
|
-
// 各自再回退到其他带文案的规则(最后回退到第一条非空 validationMessage)。
|
|
221
|
-
// 前端可根据"加号/减号被拦"的方向取对应文案。
|
|
222
234
|
let maxSourceLimit;
|
|
223
235
|
let remainingMaxSourceLimit;
|
|
224
236
|
let exactSourceLimit;
|
|
225
237
|
let minSourceLimit;
|
|
226
238
|
let firstMessagedLimit;
|
|
227
239
|
for (const limit of matchedLimits) {
|
|
228
|
-
if (typeof limit.requiredMin ===
|
|
229
|
-
if (min ===
|
|
240
|
+
if (typeof limit.requiredMin === "number" && Number.isFinite(limit.requiredMin)) {
|
|
241
|
+
if (min === void 0 || limit.requiredMin > min) {
|
|
230
242
|
min = limit.requiredMin;
|
|
231
243
|
minSourceLimit = limit;
|
|
232
244
|
}
|
|
233
245
|
}
|
|
234
|
-
if (typeof limit.requiredMax ===
|
|
235
|
-
if (max ===
|
|
246
|
+
if (typeof limit.requiredMax === "number" && Number.isFinite(limit.requiredMax)) {
|
|
247
|
+
if (max === void 0 || limit.requiredMax < max) {
|
|
236
248
|
max = limit.requiredMax;
|
|
237
249
|
maxSourceLimit = limit;
|
|
238
250
|
}
|
|
239
251
|
}
|
|
240
|
-
if (typeof limit.remainingMax ===
|
|
241
|
-
if (remainingMax ===
|
|
252
|
+
if (typeof limit.remainingMax === "number" && Number.isFinite(limit.remainingMax)) {
|
|
253
|
+
if (remainingMax === void 0 || limit.remainingMax < remainingMax) {
|
|
242
254
|
remainingMax = limit.remainingMax;
|
|
243
255
|
remainingMaxSourceLimit = limit;
|
|
244
256
|
}
|
|
245
257
|
}
|
|
246
|
-
if (typeof limit.requiredExact ===
|
|
258
|
+
if (typeof limit.requiredExact === "number" && Number.isFinite(limit.requiredExact)) {
|
|
247
259
|
exact = limit.requiredExact;
|
|
248
260
|
exactSourceLimit = limit;
|
|
249
261
|
}
|
|
@@ -252,19 +264,16 @@ function aggregateItemRuleLimit(matchedLimits) {
|
|
|
252
264
|
firstMessagedLimit = limit;
|
|
253
265
|
}
|
|
254
266
|
}
|
|
255
|
-
if (typeof exact ===
|
|
267
|
+
if (typeof exact === "number" && Number.isFinite(exact)) {
|
|
256
268
|
min = exact;
|
|
257
269
|
max = exact;
|
|
258
270
|
}
|
|
259
271
|
const maxMessageSource = maxSourceLimit || remainingMaxSourceLimit || exactSourceLimit || firstMessagedLimit;
|
|
260
272
|
const minMessageSource = minSourceLimit || exactSourceLimit || firstMessagedLimit;
|
|
261
|
-
const maxValidationMessage = maxMessageSource
|
|
262
|
-
const rawMaxValidationMessage = maxMessageSource
|
|
263
|
-
const minValidationMessage = minMessageSource
|
|
264
|
-
const rawMinValidationMessage = minMessageSource
|
|
265
|
-
|
|
266
|
-
// validationMessage / rawValidationMessage 保留为"最严格限制"的聚合文案,
|
|
267
|
-
// 便于旧消费者(只关心 max 侧)不破坏。优先 max → min。
|
|
273
|
+
const maxValidationMessage = maxMessageSource == null ? void 0 : maxMessageSource.validationMessage;
|
|
274
|
+
const rawMaxValidationMessage = maxMessageSource == null ? void 0 : maxMessageSource.rawValidationMessage;
|
|
275
|
+
const minValidationMessage = minMessageSource == null ? void 0 : minMessageSource.validationMessage;
|
|
276
|
+
const rawMinValidationMessage = minMessageSource == null ? void 0 : minMessageSource.rawValidationMessage;
|
|
268
277
|
const validationMessage = maxValidationMessage ?? minValidationMessage;
|
|
269
278
|
const rawValidationMessage = rawMaxValidationMessage ?? rawMinValidationMessage;
|
|
270
279
|
return {
|
|
@@ -282,34 +291,28 @@ function aggregateItemRuleLimit(matchedLimits) {
|
|
|
282
291
|
};
|
|
283
292
|
}
|
|
284
293
|
function buildItemRuleBusinessData(params) {
|
|
285
|
-
const {
|
|
286
|
-
tempOrder,
|
|
287
|
-
runtimeConfig,
|
|
288
|
-
itemRuleConfigs
|
|
289
|
-
} = params;
|
|
294
|
+
const { tempOrder, runtimeConfig, itemRuleConfigs } = params;
|
|
290
295
|
const rawPax = runtimeConfig.pax || {};
|
|
291
296
|
const adultPax = toNonNegativeInt(rawPax.adult);
|
|
292
297
|
const childPax = toNonNegativeInt(rawPax.child);
|
|
293
298
|
const totalPax = toNonNegativeInt(rawPax.total) || adultPax + childPax || 1;
|
|
294
299
|
const cartItems = tempOrder.products.reduce((result, product) => {
|
|
295
|
-
if (typeof product.product_id !==
|
|
300
|
+
if (typeof product.product_id !== "number")
|
|
301
|
+
return result;
|
|
296
302
|
result.push({
|
|
297
303
|
product_id: product.product_id,
|
|
298
304
|
quantity: toNonNegativeInt(product.num),
|
|
299
|
-
...
|
|
300
|
-
product_variant_id: product.product_variant_id
|
|
301
|
-
} : {})
|
|
305
|
+
...typeof product.product_variant_id === "number" ? { product_variant_id: product.product_variant_id } : {}
|
|
302
306
|
});
|
|
303
307
|
return result;
|
|
304
308
|
}, []);
|
|
305
309
|
const historicalItems = Array.isArray(runtimeConfig.historicalItems) ? runtimeConfig.historicalItems.reduce((result, item) => {
|
|
306
|
-
if (typeof item
|
|
310
|
+
if (typeof (item == null ? void 0 : item.product_id) !== "number")
|
|
311
|
+
return result;
|
|
307
312
|
result.push({
|
|
308
313
|
product_id: item.product_id,
|
|
309
314
|
quantity: toNonNegativeInt(item.quantity),
|
|
310
|
-
...
|
|
311
|
-
product_variant_id: item.product_variant_id
|
|
312
|
-
} : {})
|
|
315
|
+
...typeof item.product_variant_id === "number" ? { product_variant_id: item.product_variant_id } : {}
|
|
313
316
|
});
|
|
314
317
|
return result;
|
|
315
318
|
}, []) : [];
|
|
@@ -321,20 +324,23 @@ function buildItemRuleBusinessData(params) {
|
|
|
321
324
|
},
|
|
322
325
|
cartItems,
|
|
323
326
|
historicalItems,
|
|
324
|
-
serviceType: runtimeConfig.serviceType ||
|
|
325
|
-
submissionIndex: typeof runtimeConfig.submissionIndex ===
|
|
327
|
+
serviceType: runtimeConfig.serviceType || "dine-in",
|
|
328
|
+
submissionIndex: typeof runtimeConfig.submissionIndex === "number" ? toNonNegativeInt(runtimeConfig.submissionIndex) : tempOrder.order_id ? 1 : 0,
|
|
326
329
|
custom: runtimeConfig.custom || {},
|
|
327
330
|
strategyConfigs: itemRuleConfigs
|
|
328
331
|
};
|
|
329
332
|
}
|
|
330
333
|
function attachItemRuleLimitsToTopLevelProducts(productList, limits) {
|
|
331
|
-
if (!Array.isArray(productList))
|
|
334
|
+
if (!Array.isArray(productList))
|
|
335
|
+
return productList;
|
|
332
336
|
const limitIndex = buildQuantityLimitIndex(limits || []);
|
|
333
337
|
for (const item of productList) {
|
|
334
|
-
if (!item || typeof item !==
|
|
338
|
+
if (!item || typeof item !== "object")
|
|
339
|
+
continue;
|
|
335
340
|
const productItem = item;
|
|
336
341
|
const productId = getTopLevelProductId(productItem);
|
|
337
|
-
if (productId === null)
|
|
342
|
+
if (productId === null)
|
|
343
|
+
continue;
|
|
338
344
|
const variantId = getTopLevelVariantId(productItem);
|
|
339
345
|
const matchedLimits = limits.length ? resolveSkuMatchedQuantityLimits({
|
|
340
346
|
productId,
|
|
@@ -344,356 +350,387 @@ function attachItemRuleLimitsToTopLevelProducts(productList, limits) {
|
|
|
344
350
|
const aggregatedLimit = aggregateItemRuleLimit(matchedLimits);
|
|
345
351
|
if (aggregatedLimit) {
|
|
346
352
|
productItem.item_rule_limit = aggregatedLimit;
|
|
347
|
-
} else if (
|
|
353
|
+
} else if ("item_rule_limit" in productItem) {
|
|
348
354
|
delete productItem.item_rule_limit;
|
|
349
355
|
}
|
|
350
356
|
}
|
|
351
357
|
return productList;
|
|
352
358
|
}
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* 将选项行 / 套餐行归一成稳定 JSON,用于「同 SKU 是否合并」判断。
|
|
356
|
-
* 数组元素先按主键排序再序列化,避免顺序差异导致误判为不同行。
|
|
357
|
-
*/
|
|
358
359
|
function buildProductLineFingerprint(productOptionItem, productBundle) {
|
|
359
360
|
const optArr = Array.isArray(productOptionItem) ? productOptionItem : [];
|
|
360
|
-
const normalizedOpts = optArr.map(item => ({
|
|
361
|
-
|
|
362
|
-
option_group_id: Number(item
|
|
363
|
-
num: typeof item
|
|
364
|
-
price: String(item
|
|
361
|
+
const normalizedOpts = optArr.map((item) => ({
|
|
362
|
+
option_group_item_id: Number(item == null ? void 0 : item.option_group_item_id) || 0,
|
|
363
|
+
option_group_id: Number(item == null ? void 0 : item.option_group_id) || 0,
|
|
364
|
+
num: typeof (item == null ? void 0 : item.num) === "number" && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
|
|
365
|
+
price: String((item == null ? void 0 : item.add_price) ?? (item == null ? void 0 : item.price) ?? "")
|
|
365
366
|
})).sort((p, q) => {
|
|
366
|
-
if (p.
|
|
367
|
-
return p.
|
|
367
|
+
if (p.option_group_item_id !== q.option_group_item_id) {
|
|
368
|
+
return p.option_group_item_id - q.option_group_item_id;
|
|
368
369
|
}
|
|
369
|
-
if (p.option_group_id !== q.option_group_id)
|
|
370
|
-
|
|
370
|
+
if (p.option_group_id !== q.option_group_id)
|
|
371
|
+
return p.option_group_id - q.option_group_id;
|
|
372
|
+
if (p.num !== q.num)
|
|
373
|
+
return p.num - q.num;
|
|
371
374
|
return p.price.localeCompare(q.price);
|
|
372
375
|
});
|
|
373
376
|
const bundleArr = Array.isArray(productBundle) ? productBundle : [];
|
|
374
|
-
const normalizedBundles = bundleArr.map(item => ({
|
|
375
|
-
bundle_id: Number(item
|
|
376
|
-
product_id: Number(item
|
|
377
|
-
num: typeof item
|
|
377
|
+
const normalizedBundles = bundleArr.map((item) => ({
|
|
378
|
+
bundle_id: Number((item == null ? void 0 : item.bundle_id) ?? (item == null ? void 0 : item.id) ?? 0) || 0,
|
|
379
|
+
product_id: Number(item == null ? void 0 : item.product_id) || 0,
|
|
380
|
+
num: typeof (item == null ? void 0 : item.num) === "number" && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1
|
|
378
381
|
})).sort((p, q) => {
|
|
379
|
-
if (p.bundle_id !== q.bundle_id)
|
|
380
|
-
|
|
382
|
+
if (p.bundle_id !== q.bundle_id)
|
|
383
|
+
return p.bundle_id - q.bundle_id;
|
|
384
|
+
if (p.product_id !== q.product_id)
|
|
385
|
+
return p.product_id - q.product_id;
|
|
381
386
|
return p.num - q.num;
|
|
382
387
|
});
|
|
383
388
|
return JSON.stringify([normalizedOpts, normalizedBundles]);
|
|
384
389
|
}
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* removeProductFromOrder 仅传 SKU 时的通配 identity(对象上未声明选项键)。
|
|
388
|
-
* 与显式 `product_option_item: []` 区分:后者只匹配「无选项」行。
|
|
389
|
-
*/
|
|
390
390
|
function isSkuOnlyDeleteIdentity(x) {
|
|
391
|
-
if (x.identity_key)
|
|
392
|
-
|
|
391
|
+
if (x.unique_identification_number || x.identity_key)
|
|
392
|
+
return false;
|
|
393
|
+
return !("product_sku" in x) && !("product_bundle" in x);
|
|
393
394
|
}
|
|
394
395
|
function fingerprintForIdentityWithOptionKeys(x) {
|
|
395
396
|
const row = x;
|
|
396
|
-
const opts =
|
|
397
|
-
const buds =
|
|
397
|
+
const opts = "product_sku" in row ? (0, import_utils.getProductSkuOptions)(row) : [];
|
|
398
|
+
const buds = "product_bundle" in row ? Array.isArray(row.product_bundle) ? row.product_bundle : [] : [];
|
|
398
399
|
return buildProductLineFingerprint(opts, buds);
|
|
399
400
|
}
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* 判断两个商品 identity 是否匹配(不透明 identity 契约)。
|
|
403
|
-
*
|
|
404
|
-
* 调用约定:始终 `isIdentityMatch(line, callerIdentity)`。
|
|
405
|
-
* - 若 SKU(product_id + product_variant_id)不一致 → 不匹配。
|
|
406
|
-
* - **双方都带** `identity_key` → 严格字符串相等比较(不再猜测合成 key / metadata 桥接)。
|
|
407
|
-
* 这是 opaque identity 契约的标准路径:UI 删改时透传 SDK 回灌的 identity_key。
|
|
408
|
-
* - 否则(即至少一侧未声明 identity_key)→ 进入「SKU 通配 / 显式空选项 / 指纹」回退路径,
|
|
409
|
-
* 忽略线侧 identity_key,按内容语义匹配。这给「行已 opaque、调用方却想按 SKU 通配 / 选项指纹删除」留兼容入口。
|
|
410
|
-
*/
|
|
411
401
|
function isIdentityMatch(a, b) {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
402
|
+
var _a, _b;
|
|
403
|
+
if (a.product_id !== b.product_id || a.product_variant_id !== b.product_variant_id)
|
|
404
|
+
return false;
|
|
405
|
+
const aUid = ((_a = a.metadata) == null ? void 0 : _a.unique_identification_number) ?? a.unique_identification_number ?? a.identity_key;
|
|
406
|
+
const bUid = ((_b = b.metadata) == null ? void 0 : _b.unique_identification_number) ?? b.unique_identification_number ?? b.identity_key;
|
|
407
|
+
const aHasKey = typeof aUid === "string" && aUid.length > 0;
|
|
408
|
+
const bHasKey = typeof bUid === "string" && bUid.length > 0;
|
|
409
|
+
if (aHasKey && bHasKey)
|
|
410
|
+
return aUid === bUid;
|
|
411
|
+
if (isSkuOnlyDeleteIdentity(a) || isSkuOnlyDeleteIdentity(b))
|
|
412
|
+
return true;
|
|
417
413
|
return fingerprintForIdentityWithOptionKeys(a) === fingerprintForIdentityWithOptionKeys(b);
|
|
418
414
|
}
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* 根据 identity 在商品列表中定位下标。
|
|
422
|
-
* 用于判断商品是否已存在(已存在则累加数量,否则新增)。
|
|
423
|
-
*/
|
|
424
415
|
function getProductIdentityIndex(products, identity) {
|
|
425
|
-
return products.findIndex(item => isIdentityMatch(item, identity));
|
|
416
|
+
return products.findIndex((item) => isIdentityMatch(item, identity));
|
|
426
417
|
}
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* 对外部传入的商品对象做归一化(v2 composite 语义):
|
|
430
|
-
* - 补全可选字段默认值(未传则使用兜底值,避免后续计算时因 undefined 导致异常)
|
|
431
|
-
* - 对 num 调用 getSafeProductNum 做安全处理
|
|
432
|
-
* - 保留 _origin 供后续业务流程(如促销规则)使用
|
|
433
|
-
*
|
|
434
|
-
* 价格字段语义(metadata 权威源 + composite 派生):
|
|
435
|
-
* - `metadata.source_product_price`:主商品/variant 基础价(已应用报价单),**不含 option**、
|
|
436
|
-
* **不含折扣**。是推导 main_product_* 的起点。variant 分支优先读 `metadata.origin.variant[vid].price`。
|
|
437
|
-
* - `metadata.main_product_original_price`:`source + Σ(option.price × option.num)`,**含 option**、
|
|
438
|
-
* **不含折扣**。
|
|
439
|
-
* - `metadata.main_product_selling_price`:`main_product_original_price - 主商品券 per-unit amount`,
|
|
440
|
-
* **含 option**、**含折扣**。
|
|
441
|
-
* - 行级 `selling_price` = `main_product_selling_price + Σ(bundle_selling_price × num)`。
|
|
442
|
-
* - 行级 `original_price` = `main_product_original_price + Σ(bundle 原价 × num)`。
|
|
443
|
-
*
|
|
444
|
-
* 迁移与幂等:
|
|
445
|
-
* - `metadata.price_schema_version === 2` → 已新语义归一化,保留 main_product_* 原值(保留折扣)。
|
|
446
|
-
* - 其它情况(v1 / 缺字段 / 无 metadata)→ 按"main_product_selling_price 曾是 main-only"的旧约定
|
|
447
|
-
* 反推 legacyDiscount,再以新 source + options 基准重算。最终统一打上 `price_schema_version: 2`。
|
|
448
|
-
* - 因此多次 normalize 不会重复叠加 option/bundle。
|
|
449
|
-
*/
|
|
450
418
|
function normalizeOrderProduct(product) {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
|
|
419
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
420
|
+
const metadata = { ...product.metadata || {} };
|
|
421
|
+
const resolvedIdentityKey = ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) ? String(product.metadata.unique_identification_number) : product.unique_identification_number && String(product.unique_identification_number).length > 0 ? String(product.unique_identification_number) : product.identity_key && String(product.identity_key).length > 0 ? String(product.identity_key) : (0, import_utils.createUuidV4)();
|
|
422
|
+
metadata.unique_identification_number = resolvedIdentityKey;
|
|
423
|
+
const priceOverride = metadata.price_override;
|
|
424
|
+
const originOtherBundle = (_d = (_c = (_b = metadata.origin) == null ? void 0 : _b._extend) == null ? void 0 : _c.other) == null ? void 0 : _d.bundle;
|
|
425
|
+
let bundleInput = product.product_bundle || [];
|
|
426
|
+
if (priceOverride !== void 0 && priceOverride !== null && priceOverride !== "" && Array.isArray(originOtherBundle) && originOtherBundle.length > 0) {
|
|
427
|
+
const priceById = /* @__PURE__ */ new Map();
|
|
428
|
+
originOtherBundle.forEach((item) => {
|
|
429
|
+
if ((item == null ? void 0 : item.id) == null)
|
|
430
|
+
return;
|
|
431
|
+
const unit = item.price ?? item.bundle_selling_price;
|
|
432
|
+
if (unit === void 0 || unit === null)
|
|
433
|
+
return;
|
|
434
|
+
priceById.set(String(item.id), String(unit));
|
|
435
|
+
});
|
|
436
|
+
const base = Array.isArray(bundleInput) && bundleInput.length > 0 ? bundleInput : originOtherBundle;
|
|
437
|
+
bundleInput = base.map((item) => {
|
|
438
|
+
const unit = priceById.get(String(item == null ? void 0 : item.id));
|
|
439
|
+
if (unit === void 0)
|
|
440
|
+
return item;
|
|
441
|
+
return {
|
|
442
|
+
...item,
|
|
443
|
+
price: unit,
|
|
444
|
+
bundle_selling_price: unit
|
|
445
|
+
};
|
|
446
|
+
});
|
|
459
447
|
}
|
|
460
|
-
const normalizedBundle =
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
448
|
+
const normalizedBundle = bundleInput.map((item) => {
|
|
449
|
+
const magnitudeSource = {
|
|
450
|
+
...item,
|
|
451
|
+
// 计算 markdown 净额时,只把真实毛价交给 helper;若只有 bundle_selling_price,
|
|
452
|
+
// helper 会按历史净额兜底,避免 option 二次扣减。
|
|
453
|
+
price: item.price ?? item.custom_price
|
|
454
|
+
};
|
|
455
|
+
const normalizedItem = {
|
|
456
|
+
...item,
|
|
457
|
+
bundle_id: item.bundle_id ?? item.id,
|
|
458
|
+
bundle_product_id: item.bundle_product_id ?? item._bundle_product_id,
|
|
459
|
+
bundle_group_id: item.bundle_group_id ?? item.group_id,
|
|
460
|
+
// price 保留毛价(markdown 仍为 5),由 price_type 决定符号。
|
|
461
|
+
price: item.price ?? item.custom_price ?? item.bundle_selling_price ?? "0.00",
|
|
462
|
+
price_type: item.price_type ?? item.custom_price_type ?? "",
|
|
463
|
+
price_type_ext: item.price_type_ext ?? item.custom_price_type_ext ?? ""
|
|
464
|
+
};
|
|
465
|
+
normalizedItem.bundle_selling_price = (0, import_utils.getBundleSellingMagnitude)(magnitudeSource).toFixed(2);
|
|
466
|
+
if (normalizedItem.price_type === "markdown" && (normalizedItem.price_type_ext === "" || normalizedItem.price_type_ext === void 0 || normalizedItem.price_type_ext === null)) {
|
|
467
|
+
normalizedItem.custom_price = normalizedItem.custom_price ?? normalizedItem.price;
|
|
468
|
+
normalizedItem.price = normalizedItem.bundle_selling_price;
|
|
469
|
+
}
|
|
470
|
+
if ((normalizedItem.price_type === "markdown" || normalizedItem.price_type === "markup") && (normalizedItem.price_type_ext === "" || normalizedItem.price_type_ext === void 0 || normalizedItem.price_type_ext === null)) {
|
|
471
|
+
delete normalizedItem.original_total;
|
|
472
|
+
}
|
|
473
|
+
return normalizedItem;
|
|
474
|
+
});
|
|
475
|
+
const normalizedOptions = (0, import_utils.normalizeProductSkuOptions)((_e = product.product_sku) == null ? void 0 : _e.option);
|
|
476
|
+
const optionSum = (0, import_utils.sumOptionUnitPrice)(normalizedOptions);
|
|
477
|
+
const productSku = {
|
|
478
|
+
...(0, import_utils.ensureProductSku)(product),
|
|
479
|
+
option: normalizedOptions
|
|
480
|
+
};
|
|
481
|
+
const isV2 = metadata.price_schema_version === 2 || metadata.price_schema_version === "2";
|
|
477
482
|
const variantId = Number(product.product_variant_id || 0);
|
|
478
|
-
const variantList = variantId ? metadata
|
|
479
|
-
const variantPrice = Array.isArray(variantList) ? variantList.find(v => Number(v
|
|
483
|
+
const variantList = variantId ? (_f = metadata == null ? void 0 : metadata.origin) == null ? void 0 : _f.variant : null;
|
|
484
|
+
const variantPrice = Array.isArray(variantList) ? (_g = variantList.find((v) => Number(v == null ? void 0 : v.id) === variantId)) == null ? void 0 : _g.price : void 0;
|
|
480
485
|
const resolvedSource = (() => {
|
|
481
|
-
|
|
486
|
+
var _a2, _b2;
|
|
487
|
+
if (metadata.source_product_price !== void 0) {
|
|
482
488
|
return String(metadata.source_product_price);
|
|
483
489
|
}
|
|
484
|
-
if (variantPrice !==
|
|
490
|
+
if (variantPrice !== void 0 && variantPrice !== null) {
|
|
485
491
|
return String(variantPrice);
|
|
486
492
|
}
|
|
487
|
-
const originPrice = product._origin
|
|
488
|
-
if (originPrice !==
|
|
493
|
+
const originPrice = (_a2 = product._origin) == null ? void 0 : _a2.price;
|
|
494
|
+
if (originPrice !== void 0 && originPrice !== null) {
|
|
489
495
|
return String(originPrice);
|
|
490
496
|
}
|
|
491
|
-
const originBasePrice = product._origin
|
|
492
|
-
if (originBasePrice !==
|
|
497
|
+
const originBasePrice = (_b2 = product._origin) == null ? void 0 : _b2.base_price;
|
|
498
|
+
if (originBasePrice !== void 0 && originBasePrice !== null) {
|
|
493
499
|
return String(originBasePrice);
|
|
494
500
|
}
|
|
495
|
-
if (!isV2 && metadata.main_product_original_price !==
|
|
501
|
+
if (!isV2 && metadata.main_product_original_price !== void 0) {
|
|
496
502
|
return String(metadata.main_product_original_price);
|
|
497
503
|
}
|
|
498
|
-
return product.original_price ?? product.selling_price ??
|
|
504
|
+
return product.original_price ?? product.selling_price ?? "0.00";
|
|
499
505
|
})();
|
|
500
|
-
|
|
501
|
-
// 2) 派生 main_product_original_price(含 option、不含折扣)
|
|
502
|
-
const mainOriginalDec = new _decimal.default(Number(resolvedSource) || 0).plus(optionSum);
|
|
506
|
+
const mainOriginalDec = new import_decimal.default(Number(resolvedSource) || 0).plus(optionSum);
|
|
503
507
|
const mainOriginalStr = mainOriginalDec.toDecimalPlaces(2).toFixed(2);
|
|
504
|
-
|
|
505
|
-
// 3) 派生 main_product_selling_price(含 option、含主商品折扣)
|
|
506
|
-
// - v2 数据:直接沿用 metadata.main_product_selling_price(保留折扣)
|
|
507
|
-
// - v1 metadata:main_product_selling_price 旧语义是 main-only(≈ source-level 折后价),
|
|
508
|
-
// 反推 legacyDiscount = main_original(旧) - main_selling(旧),再用新 main_original - legacyDiscount
|
|
509
|
-
// - v1 addProduct 入参:top-level selling_price < original_price 表示主商品折扣;
|
|
510
|
-
// 用差额作为 legacyDiscount 映射到新 main_selling
|
|
511
|
-
// - 其它:视为无折扣,main_selling = main_original
|
|
512
508
|
let mainSellingDec;
|
|
513
509
|
if (isV2 && metadata.main_product_selling_price != null) {
|
|
514
|
-
mainSellingDec = new
|
|
510
|
+
mainSellingDec = new import_decimal.default(Number(metadata.main_product_selling_price) || 0);
|
|
515
511
|
} else if (metadata.main_product_selling_price != null && metadata.main_product_original_price != null) {
|
|
516
|
-
const legacyOriginal = new
|
|
517
|
-
const legacySelling = new
|
|
512
|
+
const legacyOriginal = new import_decimal.default(Number(metadata.main_product_original_price) || 0);
|
|
513
|
+
const legacySelling = new import_decimal.default(Number(metadata.main_product_selling_price) || 0);
|
|
518
514
|
const legacyDiscount = legacyOriginal.minus(legacySelling);
|
|
519
515
|
mainSellingDec = mainOriginalDec.minus(legacyDiscount);
|
|
520
|
-
} else if (product.original_price != null && product.selling_price != null && new
|
|
521
|
-
|
|
522
|
-
|
|
516
|
+
} else if (product.original_price != null && product.selling_price != null && new import_decimal.default(Number(product.original_price) || 0).greaterThan(
|
|
517
|
+
new import_decimal.default(Number(product.selling_price) || 0)
|
|
518
|
+
)) {
|
|
519
|
+
const topOriginal = new import_decimal.default(Number(product.original_price) || 0);
|
|
520
|
+
const topSelling = new import_decimal.default(Number(product.selling_price) || 0);
|
|
523
521
|
const legacyDiscount = topOriginal.minus(topSelling);
|
|
524
522
|
mainSellingDec = mainOriginalDec.minus(legacyDiscount);
|
|
525
523
|
} else {
|
|
526
524
|
mainSellingDec = mainOriginalDec;
|
|
527
525
|
}
|
|
528
526
|
const mainSellingStr = mainSellingDec.toDecimalPlaces(2).toFixed(2);
|
|
529
|
-
|
|
530
|
-
// 4) 落盘 metadata:三字段 + schema 版本 sentinel
|
|
531
527
|
metadata.source_product_price = resolvedSource;
|
|
532
528
|
metadata.main_product_original_price = mainOriginalStr;
|
|
533
529
|
metadata.main_product_selling_price = mainSellingStr;
|
|
534
530
|
metadata.price_schema_version = 2;
|
|
535
|
-
|
|
536
|
-
// 5) 合成行级 composite(main 已含 option,本步只叠 bundle)
|
|
537
|
-
const composedSellingPrice = (0, _utils.composeLinePrice)({
|
|
531
|
+
const composedSellingPrice = (0, import_utils.composeLinePrice)({
|
|
538
532
|
mainPrice: mainSellingStr,
|
|
539
533
|
bundle: normalizedBundle
|
|
540
534
|
});
|
|
541
|
-
const composedOriginalPrice = (0,
|
|
535
|
+
const composedOriginalPrice = (0, import_utils.composeLinePrice)({
|
|
542
536
|
mainPrice: mainOriginalStr,
|
|
543
537
|
bundle: normalizedBundle,
|
|
544
538
|
useOriginalBundle: true
|
|
545
539
|
});
|
|
540
|
+
const finalOriginalPrice = (0, import_utils.resolveManualOverrideLineOriginalPrice)(
|
|
541
|
+
{ num: product.num, metadata, lineOriginalPrice: product.original_price },
|
|
542
|
+
composedOriginalPrice
|
|
543
|
+
);
|
|
544
|
+
const hasManualProductDiscount = (product.discount_list || []).some(
|
|
545
|
+
(item) => (item == null ? void 0 : item.type) === "product"
|
|
546
|
+
);
|
|
547
|
+
const manualOriginalPrice = hasManualProductDiscount && product.original_price != null ? String(product.original_price) : finalOriginalPrice;
|
|
548
|
+
const discountList = (0, import_manualProductDiscount.ensureManualProductDiscountList)({
|
|
549
|
+
discountList: product.discount_list,
|
|
550
|
+
metadata,
|
|
551
|
+
originalPrice: manualOriginalPrice,
|
|
552
|
+
sellingPrice: composedSellingPrice,
|
|
553
|
+
quantity: getSafeProductNum(product.num)
|
|
554
|
+
});
|
|
546
555
|
return {
|
|
547
556
|
order_detail_id: product.order_detail_id || null,
|
|
548
557
|
product_id: product.product_id,
|
|
549
558
|
num: getSafeProductNum(product.num),
|
|
550
559
|
product_variant_id: product.product_variant_id,
|
|
551
|
-
|
|
552
|
-
product_option_item: normalizedOptions,
|
|
560
|
+
product_sku: productSku,
|
|
553
561
|
selling_price: composedSellingPrice,
|
|
554
|
-
original_price:
|
|
555
|
-
tax_fee: product.tax_fee ||
|
|
562
|
+
original_price: manualOriginalPrice,
|
|
563
|
+
tax_fee: product.tax_fee || "0.00",
|
|
556
564
|
is_charge_tax: product.is_charge_tax ?? 0,
|
|
557
|
-
discount_list:
|
|
565
|
+
discount_list: discountList,
|
|
558
566
|
product_bundle: normalizedBundle,
|
|
559
567
|
metadata,
|
|
560
|
-
note: product.note != null ? String(product.note) :
|
|
561
|
-
_origin: product._origin
|
|
568
|
+
note: product.note != null ? String(product.note) : ""
|
|
562
569
|
};
|
|
563
570
|
}
|
|
564
|
-
|
|
565
|
-
/**
|
|
566
|
-
* 从 reservation.enabled_reservation_rules 中收集 type=link 的商品 id。
|
|
567
|
-
*/
|
|
568
571
|
function collectLinkProductIdsFromReservationRules(rules) {
|
|
569
|
-
if (!Array.isArray(rules))
|
|
572
|
+
if (!Array.isArray(rules))
|
|
573
|
+
return [];
|
|
570
574
|
const ids = [];
|
|
571
575
|
for (const entry of rules) {
|
|
572
|
-
if (!entry || typeof entry !==
|
|
576
|
+
if (!entry || typeof entry !== "object")
|
|
577
|
+
continue;
|
|
573
578
|
const rec = entry;
|
|
574
|
-
if (rec.type !==
|
|
575
|
-
|
|
579
|
+
if (rec.type !== "link")
|
|
580
|
+
continue;
|
|
581
|
+
if (!Array.isArray(rec.value))
|
|
582
|
+
continue;
|
|
576
583
|
for (const v of rec.value) {
|
|
577
584
|
const n = Number(v);
|
|
578
|
-
if (Number.isFinite(n) && n > 0)
|
|
585
|
+
if (Number.isFinite(n) && n > 0)
|
|
586
|
+
ids.push(Math.floor(n));
|
|
579
587
|
}
|
|
580
588
|
}
|
|
581
589
|
return [...new Set(ids)];
|
|
582
590
|
}
|
|
583
|
-
|
|
584
|
-
/**
|
|
585
|
-
* 找到第一个归属指定桌台的预约规则商品。
|
|
586
|
-
* 归属判断基于商品资源中的 default_resource / optional_resource。
|
|
587
|
-
*/
|
|
588
591
|
function findReservationRuleProductByResourceId(products, resourceId) {
|
|
592
|
+
var _a;
|
|
589
593
|
const numericResourceId = Number(resourceId);
|
|
590
|
-
if (!Number.isFinite(numericResourceId) || numericResourceId <= 0)
|
|
594
|
+
if (!Number.isFinite(numericResourceId) || numericResourceId <= 0)
|
|
595
|
+
return void 0;
|
|
591
596
|
for (const product of products) {
|
|
592
|
-
const resources = product
|
|
593
|
-
if (!Array.isArray(resources))
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
const
|
|
597
|
-
|
|
597
|
+
const resources = (_a = product == null ? void 0 : product.product_resource) == null ? void 0 : _a.resources;
|
|
598
|
+
if (!Array.isArray(resources))
|
|
599
|
+
continue;
|
|
600
|
+
const hasMatchedResource = resources.some((resource) => {
|
|
601
|
+
const defaultResources = Array.isArray(resource == null ? void 0 : resource.default_resource) ? resource.default_resource : [];
|
|
602
|
+
const optionalResources = Array.isArray(resource == null ? void 0 : resource.optional_resource) ? resource.optional_resource : [];
|
|
603
|
+
return [...defaultResources, ...optionalResources].some(
|
|
604
|
+
(id) => Number(id) === numericResourceId
|
|
605
|
+
);
|
|
598
606
|
});
|
|
599
|
-
if (hasMatchedResource)
|
|
607
|
+
if (hasMatchedResource)
|
|
608
|
+
return product;
|
|
600
609
|
}
|
|
601
|
-
return
|
|
610
|
+
return void 0;
|
|
602
611
|
}
|
|
603
|
-
|
|
604
|
-
/**
|
|
605
|
-
* 返回列表中第一个带有效 duration.value(分钟)的商品时长。
|
|
606
|
-
*/
|
|
607
612
|
function pickFirstDurationMinutesFromProducts(products) {
|
|
613
|
+
var _a;
|
|
608
614
|
for (const product of products) {
|
|
609
|
-
const value = product
|
|
615
|
+
const value = (_a = product == null ? void 0 : product.duration) == null ? void 0 : _a.value;
|
|
610
616
|
const n = Number(value);
|
|
611
|
-
if (Number.isFinite(n) && n > 0)
|
|
617
|
+
if (Number.isFinite(n) && n > 0)
|
|
618
|
+
return Math.floor(n);
|
|
612
619
|
}
|
|
613
|
-
return
|
|
620
|
+
return void 0;
|
|
614
621
|
}
|
|
615
|
-
|
|
616
|
-
/** 是否存在 capacity.type === 'custom' 的商品 */
|
|
617
622
|
function hasCustomCapacityProduct(products) {
|
|
618
|
-
return products.some(p =>
|
|
623
|
+
return products.some((p) => {
|
|
624
|
+
var _a;
|
|
625
|
+
return ((_a = p == null ? void 0 : p.capacity) == null ? void 0 : _a.type) === "custom";
|
|
626
|
+
});
|
|
619
627
|
}
|
|
620
|
-
|
|
621
|
-
/**
|
|
622
|
-
* 根据预约规则商品的 resource.type 计算桌台是否已被"占满"。
|
|
623
|
-
* - single:只要有 `lastOrderId` 即视为占用
|
|
624
|
-
* - multiple:当前时间落在 `capacity_list[i]` 的 `[start_at, end_at]`(inclusive)内的 pax 之和 >= 总容量
|
|
625
|
-
* - 其他('capacity' / undefined):返回 false,不施加限制
|
|
626
|
-
*/
|
|
627
628
|
function computeResourceIsFull(params) {
|
|
628
|
-
const {
|
|
629
|
-
|
|
630
|
-
lastOrderId
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
} = params;
|
|
634
|
-
if (resourceSelectType === 'single') return Boolean(lastOrderId);
|
|
635
|
-
if (resourceSelectType !== 'multiple') return false;
|
|
629
|
+
const { resourceSelectType, lastOrderId, capacityList, capacity } = params;
|
|
630
|
+
if (resourceSelectType === "single")
|
|
631
|
+
return Boolean(lastOrderId);
|
|
632
|
+
if (resourceSelectType !== "multiple")
|
|
633
|
+
return false;
|
|
636
634
|
const totalCapacity = Number(capacity);
|
|
637
|
-
if (!Number.isFinite(totalCapacity) || totalCapacity <= 0)
|
|
638
|
-
|
|
635
|
+
if (!Number.isFinite(totalCapacity) || totalCapacity <= 0)
|
|
636
|
+
return false;
|
|
637
|
+
const now = (0, import_dayjs.default)();
|
|
639
638
|
let occupied = 0;
|
|
640
639
|
for (const slot of capacityList || []) {
|
|
641
|
-
const start = (0,
|
|
642
|
-
const end = (0,
|
|
643
|
-
if (!start.isValid() || !end.isValid())
|
|
640
|
+
const start = (0, import_dayjs.default)(slot == null ? void 0 : slot.start_at);
|
|
641
|
+
const end = (0, import_dayjs.default)(slot == null ? void 0 : slot.end_at);
|
|
642
|
+
if (!start.isValid() || !end.isValid())
|
|
643
|
+
continue;
|
|
644
644
|
if ((now.isAfter(start) || now.isSame(start)) && (now.isBefore(end) || now.isSame(end))) {
|
|
645
|
-
const pax = Number(slot
|
|
646
|
-
if (Number.isFinite(pax) && pax > 0)
|
|
645
|
+
const pax = Number(slot == null ? void 0 : slot.pax);
|
|
646
|
+
if (Number.isFinite(pax) && pax > 0)
|
|
647
|
+
occupied += pax;
|
|
647
648
|
}
|
|
648
649
|
}
|
|
649
650
|
return occupied >= totalCapacity;
|
|
650
651
|
}
|
|
651
|
-
|
|
652
|
-
/**
|
|
653
|
-
* 在商品列表中找到第一个 `capacity.type === 'custom'` 的商品,取其 `custom` 数组第一项的 min/max。
|
|
654
|
-
* 仅返回有限数字字段;若均无法解析则返回 `undefined`。
|
|
655
|
-
*/
|
|
656
652
|
function pickFirstCustomCapacityPaxBounds(products) {
|
|
657
653
|
for (const p of products) {
|
|
658
|
-
const cap = p
|
|
659
|
-
if (!cap || cap.type !==
|
|
660
|
-
|
|
654
|
+
const cap = p == null ? void 0 : p.capacity;
|
|
655
|
+
if (!cap || cap.type !== "custom")
|
|
656
|
+
continue;
|
|
657
|
+
if (!Array.isArray(cap.custom) || cap.custom.length === 0)
|
|
658
|
+
continue;
|
|
661
659
|
const row = cap.custom[0];
|
|
662
|
-
if (!row || typeof row !==
|
|
660
|
+
if (!row || typeof row !== "object")
|
|
661
|
+
continue;
|
|
663
662
|
const raw = row;
|
|
664
663
|
const out = {};
|
|
665
|
-
if (raw.min !== null && raw.min !==
|
|
664
|
+
if (raw.min !== null && raw.min !== void 0 && raw.min !== "") {
|
|
666
665
|
const min = Number(raw.min);
|
|
667
|
-
if (Number.isFinite(min))
|
|
666
|
+
if (Number.isFinite(min))
|
|
667
|
+
out.min = min;
|
|
668
668
|
}
|
|
669
|
-
if (raw.max !== null && raw.max !==
|
|
669
|
+
if (raw.max !== null && raw.max !== void 0 && raw.max !== "") {
|
|
670
670
|
const max = Number(raw.max);
|
|
671
|
-
if (Number.isFinite(max))
|
|
671
|
+
if (Number.isFinite(max))
|
|
672
|
+
out.max = max;
|
|
672
673
|
}
|
|
673
|
-
if (out.min !==
|
|
674
|
+
if (out.min !== void 0 || out.max !== void 0)
|
|
675
|
+
return out;
|
|
674
676
|
}
|
|
675
|
-
return
|
|
677
|
+
return void 0;
|
|
676
678
|
}
|
|
677
|
-
|
|
678
|
-
/**
|
|
679
|
-
* 第一个 `capacity.type === 'custom'` 的商品,取其 `custom[0].id`(提交 booking metadata.capacity 维度 id)。
|
|
680
|
-
* 无匹配时返回 `undefined`,调用方应回退为 `0`。
|
|
681
|
-
*/
|
|
682
679
|
function pickFirstCustomCapacityDimensionId(products) {
|
|
683
680
|
for (const p of products) {
|
|
684
|
-
const cap = p
|
|
685
|
-
if (!cap || cap.type !==
|
|
686
|
-
|
|
681
|
+
const cap = p == null ? void 0 : p.capacity;
|
|
682
|
+
if (!cap || cap.type !== "custom")
|
|
683
|
+
continue;
|
|
684
|
+
if (!Array.isArray(cap.custom) || cap.custom.length === 0)
|
|
685
|
+
continue;
|
|
687
686
|
const row = cap.custom[0];
|
|
688
|
-
if (!row || typeof row !==
|
|
687
|
+
if (!row || typeof row !== "object")
|
|
688
|
+
continue;
|
|
689
689
|
const id = row.id;
|
|
690
|
-
if (id === null || id ===
|
|
691
|
-
|
|
692
|
-
if (typeof id ===
|
|
690
|
+
if (id === null || id === void 0 || id === "")
|
|
691
|
+
continue;
|
|
692
|
+
if (typeof id === "number" && Number.isFinite(id))
|
|
693
|
+
return id;
|
|
694
|
+
if (typeof id === "string") {
|
|
693
695
|
const trimmed = id.trim();
|
|
694
|
-
if (!trimmed)
|
|
696
|
+
if (!trimmed)
|
|
697
|
+
continue;
|
|
695
698
|
return trimmed;
|
|
696
699
|
}
|
|
697
700
|
}
|
|
698
|
-
return
|
|
699
|
-
}
|
|
701
|
+
return void 0;
|
|
702
|
+
}
|
|
703
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
704
|
+
0 && (module.exports = {
|
|
705
|
+
aggregateItemRuleLimit,
|
|
706
|
+
attachItemRuleLimitsToTopLevelProducts,
|
|
707
|
+
buildItemRuleBusinessData,
|
|
708
|
+
buildProductKey,
|
|
709
|
+
buildProductLineFingerprint,
|
|
710
|
+
buildQuantityLimitIndex,
|
|
711
|
+
collectLinkProductIdsFromReservationRules,
|
|
712
|
+
computeResourceIsFull,
|
|
713
|
+
createEmptySummary,
|
|
714
|
+
extractStrategyModelIdsFromTableConfig,
|
|
715
|
+
filterProductsForScanOrderMore,
|
|
716
|
+
findReservationRuleProductByResourceId,
|
|
717
|
+
getProductIdentityIndex,
|
|
718
|
+
getSafeProductNum,
|
|
719
|
+
getTopLevelProductId,
|
|
720
|
+
getTopLevelVariantId,
|
|
721
|
+
hasCustomCapacityProduct,
|
|
722
|
+
isIdentityMatch,
|
|
723
|
+
isSkuOnlyDeleteIdentity,
|
|
724
|
+
normalizeEnabledItemRuleIds,
|
|
725
|
+
normalizeItemRuleStrategies,
|
|
726
|
+
normalizeOrderProduct,
|
|
727
|
+
pickFirstCustomCapacityDimensionId,
|
|
728
|
+
pickFirstCustomCapacityPaxBounds,
|
|
729
|
+
pickFirstDurationMinutesFromProducts,
|
|
730
|
+
resolveSkuMatchedQuantityLimits,
|
|
731
|
+
toBoolean,
|
|
732
|
+
toNonNegativeInt,
|
|
733
|
+
toNonNegativeNumber,
|
|
734
|
+
toPositiveString,
|
|
735
|
+
toPriceString
|
|
736
|
+
});
|