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