@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,471 +1,372 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
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);
|
|
28
|
+
|
|
29
|
+
// src/model/strategy/adapter/walletPass/utils.ts
|
|
30
|
+
var utils_exports = {};
|
|
31
|
+
__export(utils_exports, {
|
|
32
|
+
getApplicableProductIds: () => getApplicableProductIds,
|
|
33
|
+
getBundleItemIsDiscountPrice: () => getBundleItemIsDiscountPrice,
|
|
34
|
+
getBundleItemIsMarkupOrDiscountPrice: () => getBundleItemIsMarkupOrDiscountPrice,
|
|
35
|
+
getBundleItemIsMarkupPrice: () => getBundleItemIsMarkupPrice,
|
|
36
|
+
getBundleItemIsOriginalPrice: () => getBundleItemIsOriginalPrice,
|
|
37
|
+
getBundleItemPrice: () => getBundleItemPrice,
|
|
38
|
+
getMainProductPrice: () => getMainProductPrice,
|
|
39
|
+
getProductQuantity: () => getProductQuantity,
|
|
40
|
+
processVouchers: () => processVouchers,
|
|
41
|
+
recalculateVouchers: () => recalculateVouchers,
|
|
42
|
+
resolveWalletPassLineKey: () => resolveWalletPassLineKey
|
|
5
43
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.resolveWalletPassLineKey = resolveWalletPassLineKey;
|
|
10
|
-
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
/** 订单商品数量 */
|
|
13
|
-
const getProductQuantity = product => {
|
|
44
|
+
module.exports = __toCommonJS(utils_exports);
|
|
45
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
46
|
+
var getProductQuantity = (product) => {
|
|
14
47
|
return product.quantity || product.product_quantity || 1;
|
|
15
48
|
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 订单商品行唯一键,用于 maxPassesPerItem 按行、按件配额(同 SPU 不同规格视为不同行)。
|
|
19
|
-
*/
|
|
20
|
-
exports.getProductQuantity = getProductQuantity;
|
|
21
49
|
function resolveWalletPassLineKey(product, indexInOrder) {
|
|
22
|
-
const m = product
|
|
50
|
+
const m = (product == null ? void 0 : product.metadata) || {};
|
|
23
51
|
const u1 = m.product_unique;
|
|
24
|
-
if (u1 != null && String(u1).length > 0)
|
|
52
|
+
if (u1 != null && String(u1).length > 0)
|
|
53
|
+
return String(u1);
|
|
25
54
|
const u2 = m.unique_identification_number;
|
|
26
|
-
if (u2 != null && String(u2).length > 0)
|
|
27
|
-
|
|
28
|
-
if (product
|
|
55
|
+
if (u2 != null && String(u2).length > 0)
|
|
56
|
+
return String(u2);
|
|
57
|
+
if ((product == null ? void 0 : product.id) != null && String(product.id).length > 0)
|
|
58
|
+
return `order_item:${product.id}`;
|
|
59
|
+
if ((product == null ? void 0 : product.product_unique_string) != null && String(product.product_unique_string).length > 0) {
|
|
29
60
|
return String(product.product_unique_string);
|
|
30
61
|
}
|
|
31
62
|
return `order_line_${indexInOrder}`;
|
|
32
63
|
}
|
|
33
64
|
function getExpandedOrderLineQuantity(p) {
|
|
34
|
-
if (p
|
|
65
|
+
if ((p == null ? void 0 : p._orderLineQuantity) != null && p._orderLineQuantity > 0)
|
|
66
|
+
return p._orderLineQuantity;
|
|
35
67
|
return getProductQuantity(p);
|
|
36
68
|
}
|
|
37
|
-
|
|
38
|
-
/** 该行允许消耗的「券次」上限:maxPassesPerItem × 订单行件数 */
|
|
39
69
|
function getMaxPassSlotsForExpandedLine(maxPassesPerItem, p) {
|
|
40
|
-
if (maxPassesPerItem <= 0)
|
|
70
|
+
if (maxPassesPerItem <= 0)
|
|
71
|
+
return Infinity;
|
|
41
72
|
return maxPassesPerItem * getExpandedOrderLineQuantity(p);
|
|
42
73
|
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* 本次抵扣占用多少「券次」配额:有抵扣时至少占 1,并与按金额折算的件数挂钩,不超过剩余额度。
|
|
46
|
-
*/
|
|
47
74
|
function computePassSlotsIncrement(deductAmount, deductQty, maxPassesPerItem, orderLineQuantity, currentUsage) {
|
|
48
|
-
if (maxPassesPerItem <= 0 || !deductAmount.greaterThan(0))
|
|
75
|
+
if (maxPassesPerItem <= 0 || !deductAmount.greaterThan(0))
|
|
76
|
+
return 0;
|
|
49
77
|
const cap = maxPassesPerItem * orderLineQuantity;
|
|
50
78
|
const room = Math.max(0, cap - currentUsage);
|
|
51
|
-
if (room <= 0)
|
|
79
|
+
if (room <= 0)
|
|
80
|
+
return 0;
|
|
52
81
|
const raw = Math.max(1, Math.ceil(Number(deductQty)) || 1);
|
|
53
82
|
return Math.min(raw, room);
|
|
54
83
|
}
|
|
55
84
|
function applyMaxPassUsageIncrements(usageMap, walletPassProductId, maxPassesPerItem, deductionDetails) {
|
|
56
|
-
deductionDetails.forEach(detail => {
|
|
85
|
+
deductionDetails.forEach((detail) => {
|
|
86
|
+
var _a;
|
|
57
87
|
const lineKey = detail.lineKey;
|
|
58
|
-
if (!lineKey || maxPassesPerItem <= 0)
|
|
88
|
+
if (!lineKey || maxPassesPerItem <= 0)
|
|
89
|
+
return;
|
|
59
90
|
const orderLineQty = detail.orderLineQuantity != null && detail.orderLineQuantity > 0 ? detail.orderLineQuantity : 1;
|
|
60
|
-
const cur = usageMap.get(walletPassProductId)
|
|
61
|
-
const inc = computePassSlotsIncrement(
|
|
62
|
-
|
|
63
|
-
|
|
91
|
+
const cur = ((_a = usageMap.get(walletPassProductId)) == null ? void 0 : _a.get(lineKey)) || 0;
|
|
92
|
+
const inc = computePassSlotsIncrement(
|
|
93
|
+
new import_decimal.default(detail.deductAmount),
|
|
94
|
+
detail.deductQuantity,
|
|
95
|
+
maxPassesPerItem,
|
|
96
|
+
orderLineQty,
|
|
97
|
+
cur
|
|
98
|
+
);
|
|
99
|
+
if (inc <= 0)
|
|
100
|
+
return;
|
|
101
|
+
if (!usageMap.has(walletPassProductId))
|
|
102
|
+
usageMap.set(walletPassProductId, /* @__PURE__ */ new Map());
|
|
64
103
|
const inner = usageMap.get(walletPassProductId);
|
|
65
104
|
inner.set(lineKey, cur + inc);
|
|
66
105
|
});
|
|
67
106
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
config,
|
|
73
|
-
recommended_usage_amount,
|
|
74
|
-
recommended_pure_product_usage_amount
|
|
75
|
-
} = voucher;
|
|
76
|
-
const deductTaxAndFee = config?.deductTaxAndFee ?? true; // 默认开启抵扣税费
|
|
77
|
-
|
|
78
|
-
// 如果开启抵扣税费,使用 recommended_usage_amount(包含税费)
|
|
79
|
-
// 如果关闭抵扣税费,使用 recommended_pure_product_usage_amount(仅商品金额)
|
|
107
|
+
var getRecommendedAmount = (voucher) => {
|
|
108
|
+
console.log("voucher312", voucher);
|
|
109
|
+
const { config, recommended_usage_amount, recommended_pure_product_usage_amount } = voucher;
|
|
110
|
+
const deductTaxAndFee = (config == null ? void 0 : config.deductTaxAndFee) ?? true;
|
|
80
111
|
return deductTaxAndFee ? recommended_usage_amount : recommended_pure_product_usage_amount ?? recommended_usage_amount;
|
|
81
112
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
available_product_type,
|
|
87
|
-
available_product_ids
|
|
88
|
-
} = voucher;
|
|
89
|
-
|
|
90
|
-
// 如果没有 available_product_type,默认为 product_all
|
|
91
|
-
const productType = available_product_type || 'product_all';
|
|
92
|
-
|
|
93
|
-
// product_all 时,返回 null 表示适用所有商品
|
|
94
|
-
if (productType === 'product_all') {
|
|
113
|
+
var getApplicableProductIds = (voucher) => {
|
|
114
|
+
const { available_product_type, available_product_ids } = voucher;
|
|
115
|
+
const productType = available_product_type || "product_all";
|
|
116
|
+
if (productType === "product_all") {
|
|
95
117
|
return null;
|
|
96
118
|
}
|
|
97
|
-
|
|
98
|
-
// product_collection 或 products 时,返回指定的商品ID列表
|
|
99
|
-
if (productType === 'product_collection' || productType === 'products') {
|
|
119
|
+
if (productType === "product_collection" || productType === "products") {
|
|
100
120
|
return available_product_ids || [];
|
|
101
121
|
}
|
|
102
|
-
|
|
103
|
-
// 其他情况默认返回空数组(不适用任何商品)
|
|
104
122
|
return [];
|
|
105
123
|
};
|
|
106
|
-
|
|
107
|
-
// 辅助函数:计算适用商品的总金额(基于剩余金额)
|
|
108
|
-
exports.getApplicableProductIds = getApplicableProductIds;
|
|
109
|
-
const getApplicableProductsAmount = (voucher, productsData) => {
|
|
124
|
+
var getApplicableProductsAmount = (voucher, productsData) => {
|
|
110
125
|
const applicableProductIds = getApplicableProductIds(voucher);
|
|
111
|
-
const {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const deductTaxAndFee = config?.deductTaxAndFee ?? true;
|
|
115
|
-
|
|
116
|
-
// 根据券的配置选择使用哪个金额字段
|
|
117
|
-
const amountField = deductTaxAndFee ? 'remainingAmountWithTax' : 'remainingAmountPure';
|
|
118
|
-
|
|
119
|
-
// 如果为 null,适用于所有商品
|
|
126
|
+
const { config } = voucher;
|
|
127
|
+
const deductTaxAndFee = (config == null ? void 0 : config.deductTaxAndFee) ?? true;
|
|
128
|
+
const amountField = deductTaxAndFee ? "remainingAmountWithTax" : "remainingAmountPure";
|
|
120
129
|
if (applicableProductIds === null) {
|
|
121
|
-
return productsData.filter(p => p[amountField].greaterThan(0)).reduce((sum, p) => sum.plus(p[amountField]), new
|
|
130
|
+
return productsData.filter((p) => p[amountField].greaterThan(0)).reduce((sum, p) => sum.plus(p[amountField]), new import_decimal.default(0));
|
|
122
131
|
}
|
|
123
|
-
|
|
124
|
-
// 如果为空数组,不适用任何商品
|
|
125
132
|
if (applicableProductIds.length === 0) {
|
|
126
|
-
return new
|
|
133
|
+
return new import_decimal.default(0);
|
|
127
134
|
}
|
|
128
|
-
|
|
129
|
-
// 计算指定商品的总金额
|
|
130
|
-
return productsData.filter(p => applicableProductIds.includes(p.product_id) && p[amountField].greaterThan(0)).reduce((sum, p) => sum.plus(p[amountField]), new _decimal.default(0));
|
|
135
|
+
return productsData.filter((p) => applicableProductIds.includes(p.product_id) && p[amountField].greaterThan(0)).reduce((sum, p) => sum.plus(p[amountField]), new import_decimal.default(0));
|
|
131
136
|
};
|
|
132
|
-
|
|
133
|
-
// 辅助函数:获取适用的商品列表
|
|
134
|
-
const getApplicableProducts = (voucher, productsData) => {
|
|
137
|
+
var getApplicableProducts = (voucher, productsData) => {
|
|
135
138
|
const applicableProductIds = getApplicableProductIds(voucher);
|
|
136
|
-
|
|
137
|
-
// 如果为 null,适用于所有商品
|
|
138
139
|
if (applicableProductIds === null) {
|
|
139
140
|
return productsData;
|
|
140
141
|
}
|
|
141
|
-
|
|
142
|
-
// 如果为空数组,不适用任何商品
|
|
143
142
|
if (applicableProductIds.length === 0) {
|
|
144
143
|
return [];
|
|
145
144
|
}
|
|
146
|
-
|
|
147
|
-
// 返回指定的商品列表
|
|
148
|
-
return productsData.filter(p => applicableProductIds.includes(p.product_id));
|
|
145
|
+
return productsData.filter((p) => applicableProductIds.includes(p.product_id));
|
|
149
146
|
};
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* 优惠券处理函数
|
|
153
|
-
* @param applicableVouchers 可用的券列表
|
|
154
|
-
* @param orderTotalAmount 订单总金额
|
|
155
|
-
* @param products 订单商品列表
|
|
156
|
-
* @returns 返回推荐券列表和全部列表,每个券包含 _available_max_amount 和 _unified_available_status
|
|
157
|
-
*/
|
|
158
147
|
function processVouchers(applicableVouchers, orderTotalAmount, products) {
|
|
159
|
-
|
|
160
|
-
// remainingAmountWithTax: 含税费的剩余可抵扣金额
|
|
161
|
-
// remainingAmountPure: 纯商品金额(不含税费)的剩余可抵扣金额
|
|
162
|
-
// 在抵扣时,会根据券的 deductTaxAndFee 配置选择从哪个金额池扣除
|
|
148
|
+
console.log(products, "products123");
|
|
163
149
|
const productsCopy = expandProductsWithBundleItems(products, true);
|
|
164
|
-
let remainingOrderAmount = new
|
|
165
|
-
|
|
166
|
-
// ========== 辅助工具:maxPassesPerItem(按订单行 + 件数)追踪 ==========
|
|
150
|
+
let remainingOrderAmount = new import_decimal.default(orderTotalAmount);
|
|
167
151
|
const getItemPassUsage = (usageMap, walletPassProductId, lineKey) => {
|
|
168
|
-
|
|
152
|
+
var _a;
|
|
153
|
+
return ((_a = usageMap.get(walletPassProductId)) == null ? void 0 : _a.get(lineKey)) || 0;
|
|
169
154
|
};
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
return products.filter(p => {
|
|
155
|
+
const filterByMaxPassesPerItem = (products2, usageMap, walletPassProductId, maxPassesPerItem) => {
|
|
156
|
+
if (maxPassesPerItem <= 0)
|
|
157
|
+
return products2;
|
|
158
|
+
return products2.filter((p) => {
|
|
175
159
|
const lineKey = p._walletPassLineKey;
|
|
176
|
-
if (!lineKey)
|
|
160
|
+
if (!lineKey)
|
|
161
|
+
return true;
|
|
177
162
|
return getItemPassUsage(usageMap, walletPassProductId, lineKey) < getMaxPassSlotsForExpandedLine(maxPassesPerItem, p);
|
|
178
163
|
});
|
|
179
164
|
};
|
|
180
|
-
// ================================================================
|
|
181
|
-
|
|
182
|
-
// 辅助函数:计算单张券的 _available_max_amount
|
|
183
165
|
const calculateAvailableMaxAmount = (voucher, productsData, itemPassUsage) => {
|
|
184
|
-
const {
|
|
185
|
-
|
|
186
|
-
} = voucher;
|
|
187
|
-
const {
|
|
188
|
-
maxDeductionAmount = 0,
|
|
189
|
-
allowCrossProduct = true,
|
|
190
|
-
applicableProductLimit = 0,
|
|
191
|
-
deductTaxAndFee = true,
|
|
192
|
-
maxPassesPerItem = 0
|
|
193
|
-
} = config ?? {};
|
|
194
|
-
|
|
195
|
-
// 根据 deductTaxAndFee 配置获取推荐金额
|
|
166
|
+
const { config } = voucher;
|
|
167
|
+
const { maxDeductionAmount = 0, allowCrossProduct = true, applicableProductLimit = 0, deductTaxAndFee = true, maxPassesPerItem = 0 } = config ?? {};
|
|
196
168
|
const recommendedAmount = getRecommendedAmount(voucher);
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
// 获取适用商品列表(只筛选有剩余金额的商品)
|
|
206
|
-
let applicableProducts = getApplicableProducts(voucher, productsData).filter(p => p[amountField].greaterThan(0));
|
|
207
|
-
|
|
208
|
-
// 按 maxPassesPerItem 过滤:排除已达到单商品可用卡券上限的商品
|
|
169
|
+
const baseAmount = import_decimal.default.min(
|
|
170
|
+
new import_decimal.default(recommendedAmount),
|
|
171
|
+
new import_decimal.default(maxDeductionAmount)
|
|
172
|
+
);
|
|
173
|
+
const unitPriceField = deductTaxAndFee ? "unitPriceWithTax" : "unitPricePure";
|
|
174
|
+
const amountField = deductTaxAndFee ? "remainingAmountWithTax" : "remainingAmountPure";
|
|
175
|
+
let applicableProducts = getApplicableProducts(voucher, productsData).filter((p) => p[amountField].greaterThan(0));
|
|
209
176
|
if (itemPassUsage) {
|
|
210
177
|
applicableProducts = filterByMaxPassesPerItem(applicableProducts, itemPassUsage, voucher.product_id, maxPassesPerItem);
|
|
211
178
|
}
|
|
212
179
|
if (applicableProducts.length === 0) {
|
|
213
|
-
return new
|
|
180
|
+
return new import_decimal.default(0);
|
|
214
181
|
}
|
|
215
|
-
|
|
216
|
-
// 根据跨商品配置计算适用商品金额
|
|
217
|
-
let finalApplicableAmount = new _decimal.default(0);
|
|
182
|
+
let finalApplicableAmount = new import_decimal.default(0);
|
|
218
183
|
if (allowCrossProduct) {
|
|
219
|
-
// 跨商品券:可以抵扣多个商品
|
|
220
184
|
if (applicableProductLimit > 0) {
|
|
221
|
-
// 有数量限制:按剩余金额从高到低排序,按动态计算的可抵扣数量累计直到达到 limit
|
|
222
185
|
const sortedProducts = [...applicableProducts].sort((a, b) => a[amountField].comparedTo(b[amountField]) > 0 ? -1 : 1);
|
|
223
186
|
let remainingLimit = applicableProductLimit;
|
|
224
187
|
for (const product of sortedProducts) {
|
|
225
|
-
if (remainingLimit <= 0)
|
|
226
|
-
|
|
188
|
+
if (remainingLimit <= 0)
|
|
189
|
+
break;
|
|
227
190
|
const currentAvailableQty = Math.ceil(product[amountField].dividedBy(product[unitPriceField]).toNumber());
|
|
228
191
|
const deductQty = Math.min(currentAvailableQty, remainingLimit);
|
|
229
|
-
|
|
230
|
-
|
|
192
|
+
const deductAmount = import_decimal.default.min(
|
|
193
|
+
product[unitPriceField].times(deductQty),
|
|
194
|
+
product[amountField]
|
|
195
|
+
);
|
|
231
196
|
finalApplicableAmount = finalApplicableAmount.plus(deductAmount);
|
|
232
197
|
remainingLimit -= deductQty;
|
|
233
198
|
}
|
|
234
199
|
} else {
|
|
235
|
-
|
|
236
|
-
|
|
200
|
+
finalApplicableAmount = applicableProducts.reduce(
|
|
201
|
+
(sum, p) => sum.plus(p[amountField]),
|
|
202
|
+
new import_decimal.default(0)
|
|
203
|
+
);
|
|
237
204
|
}
|
|
238
205
|
} else {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
206
|
+
const maxProduct = applicableProducts.reduce(
|
|
207
|
+
(max, p) => p[unitPriceField].greaterThan(max[unitPriceField]) ? p : max
|
|
208
|
+
);
|
|
242
209
|
if (maxPassesPerItem > 0) {
|
|
243
|
-
finalApplicableAmount =
|
|
210
|
+
finalApplicableAmount = import_decimal.default.min(
|
|
211
|
+
maxProduct[unitPriceField].times(maxPassesPerItem),
|
|
212
|
+
maxProduct[amountField]
|
|
213
|
+
);
|
|
244
214
|
} else {
|
|
245
215
|
finalApplicableAmount = maxProduct[amountField];
|
|
246
216
|
}
|
|
247
217
|
}
|
|
248
|
-
|
|
249
|
-
// 返回最小值
|
|
250
|
-
return _decimal.default.min(baseAmount, finalApplicableAmount, remainingOrderAmount);
|
|
218
|
+
return import_decimal.default.min(baseAmount, finalApplicableAmount, remainingOrderAmount);
|
|
251
219
|
};
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
const isVoucherAvailable = (voucher, productsData, usedVoucherCounts, itemPassUsage) => {
|
|
255
|
-
const {
|
|
256
|
-
config,
|
|
257
|
-
id,
|
|
258
|
-
product_id
|
|
259
|
-
} = voucher;
|
|
260
|
-
|
|
261
|
-
// 根据 deductTaxAndFee 配置获取推荐金额
|
|
220
|
+
const isVoucherAvailable = (voucher, productsData, usedVoucherCounts2, itemPassUsage) => {
|
|
221
|
+
const { config, id, product_id } = voucher;
|
|
262
222
|
const recommendedAmount = getRecommendedAmount(voucher);
|
|
263
|
-
|
|
264
|
-
// 余额为 0
|
|
265
223
|
if (recommendedAmount <= 0) {
|
|
266
|
-
return {
|
|
267
|
-
isAvailable: false,
|
|
268
|
-
reasonCode: 'not_meet_the_required_conditions'
|
|
269
|
-
};
|
|
224
|
+
return { isAvailable: false, reasonCode: "not_meet_the_required_conditions" };
|
|
270
225
|
}
|
|
271
|
-
|
|
272
|
-
// 订单金额已抵扣完
|
|
273
226
|
if (remainingOrderAmount.lessThanOrEqualTo(0)) {
|
|
274
|
-
return {
|
|
275
|
-
isAvailable: false,
|
|
276
|
-
reasonCode: 'exceeds_the_maximum_deduction_limit'
|
|
277
|
-
};
|
|
227
|
+
return { isAvailable: false, reasonCode: "exceeds_the_maximum_deduction_limit" };
|
|
278
228
|
}
|
|
279
|
-
|
|
280
|
-
// 适用商品金额已被抵扣完
|
|
281
229
|
const applicableAmount = getApplicableProductsAmount(voucher, productsData);
|
|
282
230
|
if (applicableAmount.lessThanOrEqualTo(0)) {
|
|
283
|
-
return {
|
|
284
|
-
isAvailable: false,
|
|
285
|
-
reasonCode: 'not_meet_the_required_conditions'
|
|
286
|
-
};
|
|
231
|
+
return { isAvailable: false, reasonCode: "not_meet_the_required_conditions" };
|
|
287
232
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
if (usedCount >= (config?.maxUsagePerOrder || 0)) {
|
|
293
|
-
return {
|
|
294
|
-
isAvailable: false,
|
|
295
|
-
reasonCode: 'usage_limit_reached'
|
|
296
|
-
};
|
|
233
|
+
if (((config == null ? void 0 : config.maxUsagePerOrder) || 0) > 0) {
|
|
234
|
+
const usedCount = usedVoucherCounts2.get(product_id) || 0;
|
|
235
|
+
if (usedCount >= ((config == null ? void 0 : config.maxUsagePerOrder) || 0)) {
|
|
236
|
+
return { isAvailable: false, reasonCode: "usage_limit_reached" };
|
|
297
237
|
}
|
|
298
238
|
}
|
|
299
|
-
|
|
300
|
-
// 检查 maxPassesPerItem:如果所有适用商品都已达到单商品可用卡券上限,则不可用
|
|
301
|
-
const maxPassesPerItem = config?.maxPassesPerItem || 0;
|
|
239
|
+
const maxPassesPerItem = (config == null ? void 0 : config.maxPassesPerItem) || 0;
|
|
302
240
|
if (maxPassesPerItem > 0 && itemPassUsage) {
|
|
303
|
-
const deductTaxAndFee = config
|
|
304
|
-
const amountField = deductTaxAndFee ?
|
|
305
|
-
const availableAfterPassLimit = getApplicableProducts(voucher, productsData).filter(p => p[amountField].greaterThan(0)).filter(p => {
|
|
241
|
+
const deductTaxAndFee = (config == null ? void 0 : config.deductTaxAndFee) ?? true;
|
|
242
|
+
const amountField = deductTaxAndFee ? "remainingAmountWithTax" : "remainingAmountPure";
|
|
243
|
+
const availableAfterPassLimit = getApplicableProducts(voucher, productsData).filter((p) => p[amountField].greaterThan(0)).filter((p) => {
|
|
306
244
|
const lineKey = p._walletPassLineKey;
|
|
307
|
-
if (!lineKey)
|
|
245
|
+
if (!lineKey)
|
|
246
|
+
return true;
|
|
308
247
|
return getItemPassUsage(itemPassUsage, product_id, lineKey) < getMaxPassSlotsForExpandedLine(maxPassesPerItem, p);
|
|
309
248
|
});
|
|
310
249
|
if (availableAfterPassLimit.length === 0) {
|
|
311
|
-
return {
|
|
312
|
-
isAvailable: false,
|
|
313
|
-
reasonCode: 'max_passes_per_item_reached'
|
|
314
|
-
};
|
|
250
|
+
return { isAvailable: false, reasonCode: "max_passes_per_item_reached" };
|
|
315
251
|
}
|
|
316
252
|
}
|
|
317
|
-
return {
|
|
318
|
-
isAvailable: true
|
|
319
|
-
};
|
|
253
|
+
return { isAvailable: true };
|
|
320
254
|
};
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
255
|
+
const usedVoucherCountsForAll = /* @__PURE__ */ new Map();
|
|
256
|
+
const allVouchersWithStatus = applicableVouchers.map((voucher) => {
|
|
257
|
+
const _available_max_amount = calculateAvailableMaxAmount(
|
|
258
|
+
voucher,
|
|
259
|
+
productsCopy
|
|
260
|
+
);
|
|
261
|
+
const availabilityResult = isVoucherAvailable(
|
|
262
|
+
voucher,
|
|
263
|
+
productsCopy,
|
|
264
|
+
usedVoucherCountsForAll
|
|
265
|
+
);
|
|
327
266
|
const _unified_available_status = availabilityResult.isAvailable ? 1 : 0;
|
|
328
267
|
return {
|
|
329
268
|
...voucher,
|
|
330
269
|
_available_max_amount: _available_max_amount.toNumber(),
|
|
331
270
|
// 转换为数字
|
|
332
271
|
_unified_available_status,
|
|
333
|
-
...
|
|
334
|
-
reasonCode: availabilityResult.reasonCode
|
|
335
|
-
})
|
|
272
|
+
...availabilityResult.reasonCode && { reasonCode: availabilityResult.reasonCode }
|
|
336
273
|
};
|
|
337
274
|
});
|
|
338
|
-
|
|
339
|
-
// ========== 第二步:计算推荐券列表 ==========
|
|
340
275
|
const recommendedVouchers = [];
|
|
341
|
-
const usedVoucherCounts = new Map();
|
|
342
|
-
|
|
343
|
-
// 重置商品余额追踪(同时维护含税和不含税两个金额池)
|
|
276
|
+
const usedVoucherCounts = /* @__PURE__ */ new Map();
|
|
344
277
|
const productsForRecommendation = expandProductsWithBundleItems(products, true);
|
|
345
|
-
remainingOrderAmount = new
|
|
346
|
-
|
|
347
|
-
const
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
const crossProductVouchers = applicableVouchers.filter(
|
|
355
|
-
(v) => v.config?.allowCrossProduct,
|
|
356
|
-
);
|
|
357
|
-
// 按 tag 分组
|
|
358
|
-
const groupByType = (vouchers: any[]) => {
|
|
359
|
-
const groups = new Map<string, any[]>();
|
|
360
|
-
vouchers.forEach((v) => {
|
|
361
|
-
const tag = v.tag;
|
|
362
|
-
if (!groups.has(tag)) {
|
|
363
|
-
groups.set(tag, []);
|
|
364
|
-
}
|
|
365
|
-
groups.get(tag)!.push(v);
|
|
366
|
-
});
|
|
367
|
-
return groups;
|
|
368
|
-
};
|
|
369
|
-
// 对每组券按金额(balance)从大到小排序
|
|
370
|
-
const sortVouchersByAmount = (vouchers: Voucher[]) => {
|
|
371
|
-
return [...vouchers].sort((a, b) => getRecommendedAmount(b) - getRecommendedAmount(a));
|
|
372
|
-
};
|
|
373
|
-
*/
|
|
374
|
-
|
|
375
|
-
// 处理单张券的抵扣
|
|
376
|
-
const applyVoucher = voucher => {
|
|
377
|
-
// 检查是否可用
|
|
378
|
-
const availabilityCheck = isVoucherAvailable(voucher, productsForRecommendation, usedVoucherCounts, itemPassUsageMap);
|
|
278
|
+
remainingOrderAmount = new import_decimal.default(orderTotalAmount);
|
|
279
|
+
const itemPassUsageMap = /* @__PURE__ */ new Map();
|
|
280
|
+
const applyVoucher = (voucher) => {
|
|
281
|
+
const availabilityCheck = isVoucherAvailable(
|
|
282
|
+
voucher,
|
|
283
|
+
productsForRecommendation,
|
|
284
|
+
usedVoucherCounts,
|
|
285
|
+
itemPassUsageMap
|
|
286
|
+
);
|
|
379
287
|
if (!availabilityCheck.isAvailable) {
|
|
380
288
|
return false;
|
|
381
289
|
}
|
|
382
|
-
const {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
applicableProductLimit = 0,
|
|
391
|
-
deductTaxAndFee = true,
|
|
392
|
-
maxPassesPerItem = 0
|
|
393
|
-
} = config ?? {};
|
|
394
|
-
|
|
395
|
-
// 根据券的配置选择使用哪个单价字段和金额字段
|
|
396
|
-
const unitPriceField = deductTaxAndFee ? 'unitPriceWithTax' : 'unitPricePure';
|
|
397
|
-
const amountField = deductTaxAndFee ? 'remainingAmountWithTax' : 'remainingAmountPure';
|
|
398
|
-
|
|
399
|
-
// 获取适用商品(只筛选有剩余金额的商品)
|
|
400
|
-
let applicableProducts = getApplicableProducts(voucher, productsForRecommendation).filter(p => p[amountField].greaterThan(0));
|
|
401
|
-
|
|
402
|
-
// 按 maxPassesPerItem 过滤:排除已达到单商品可用卡券上限的商品
|
|
290
|
+
const { config, id, product_id } = voucher;
|
|
291
|
+
const { maxDeductionAmount = 0, allowCrossProduct = true, applicableProductLimit = 0, deductTaxAndFee = true, maxPassesPerItem = 0 } = config ?? {};
|
|
292
|
+
const unitPriceField = deductTaxAndFee ? "unitPriceWithTax" : "unitPricePure";
|
|
293
|
+
const amountField = deductTaxAndFee ? "remainingAmountWithTax" : "remainingAmountPure";
|
|
294
|
+
let applicableProducts = getApplicableProducts(
|
|
295
|
+
voucher,
|
|
296
|
+
productsForRecommendation
|
|
297
|
+
).filter((p) => p[amountField].greaterThan(0));
|
|
403
298
|
applicableProducts = filterByMaxPassesPerItem(applicableProducts, itemPassUsageMap, product_id, maxPassesPerItem);
|
|
404
|
-
if (applicableProducts.length === 0)
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
299
|
+
if (applicableProducts.length === 0)
|
|
300
|
+
return false;
|
|
301
|
+
const usageAmount = typeof voucher.edit_current_amount === "number" ? voucher.edit_current_amount : getRecommendedAmount(voucher);
|
|
302
|
+
const baseAmount = import_decimal.default.min(
|
|
303
|
+
new import_decimal.default(usageAmount),
|
|
304
|
+
new import_decimal.default(maxDeductionAmount)
|
|
305
|
+
);
|
|
306
|
+
let calculatedAvailableMaxAmount = new import_decimal.default(0);
|
|
411
307
|
if (allowCrossProduct) {
|
|
412
|
-
// 跨商品券:按 quantity 限制计算可抵扣金额
|
|
413
308
|
if (applicableProductLimit > 0) {
|
|
414
|
-
// 按剩余金额从高到低排序
|
|
415
309
|
const sortedProducts = [...applicableProducts].sort((a, b) => a[amountField].comparedTo(b[amountField]) > 0 ? -1 : 1);
|
|
416
310
|
let remainingLimit = applicableProductLimit;
|
|
417
311
|
for (const product of sortedProducts) {
|
|
418
|
-
if (remainingLimit <= 0)
|
|
419
|
-
|
|
312
|
+
if (remainingLimit <= 0)
|
|
313
|
+
break;
|
|
420
314
|
const currentAvailableQty = Math.ceil(product[amountField].dividedBy(product[unitPriceField]).toNumber());
|
|
421
315
|
const deductQty = Math.min(currentAvailableQty, remainingLimit);
|
|
422
|
-
|
|
423
|
-
|
|
316
|
+
const deductAmount = import_decimal.default.min(
|
|
317
|
+
product[unitPriceField].times(deductQty),
|
|
318
|
+
product[amountField]
|
|
319
|
+
);
|
|
424
320
|
calculatedAvailableMaxAmount = calculatedAvailableMaxAmount.plus(deductAmount);
|
|
425
321
|
remainingLimit -= deductQty;
|
|
426
322
|
}
|
|
427
323
|
} else {
|
|
428
|
-
|
|
429
|
-
|
|
324
|
+
calculatedAvailableMaxAmount = applicableProducts.reduce(
|
|
325
|
+
(sum, p) => sum.plus(p[amountField]),
|
|
326
|
+
new import_decimal.default(0)
|
|
327
|
+
);
|
|
430
328
|
}
|
|
431
329
|
} else {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
330
|
+
const maxProduct = applicableProducts.reduce(
|
|
331
|
+
(max, p) => p[unitPriceField].greaterThan(max[unitPriceField]) ? p : max
|
|
332
|
+
);
|
|
435
333
|
if (maxPassesPerItem > 0) {
|
|
436
|
-
calculatedAvailableMaxAmount =
|
|
334
|
+
calculatedAvailableMaxAmount = import_decimal.default.min(
|
|
335
|
+
maxProduct[unitPriceField].times(maxPassesPerItem),
|
|
336
|
+
maxProduct[amountField]
|
|
337
|
+
);
|
|
437
338
|
} else {
|
|
438
339
|
calculatedAvailableMaxAmount = maxProduct[amountField];
|
|
439
340
|
}
|
|
440
341
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
342
|
+
const availableMaxAmount = import_decimal.default.min(
|
|
343
|
+
baseAmount,
|
|
344
|
+
calculatedAvailableMaxAmount,
|
|
345
|
+
remainingOrderAmount
|
|
346
|
+
);
|
|
347
|
+
const maxDeduction = import_decimal.default.min(
|
|
348
|
+
new import_decimal.default(usageAmount),
|
|
349
|
+
new import_decimal.default(maxDeductionAmount),
|
|
350
|
+
remainingOrderAmount
|
|
351
|
+
);
|
|
448
352
|
let deductionLeft = maxDeduction;
|
|
449
353
|
const deductionDetails = [];
|
|
450
354
|
if (allowCrossProduct) {
|
|
451
|
-
|
|
452
|
-
|
|
355
|
+
const sortedProducts = [...applicableProducts].sort(
|
|
356
|
+
(a, b) => a[amountField].comparedTo(b[amountField]) > 0 ? -1 : 1
|
|
357
|
+
);
|
|
453
358
|
let remainingLimit = applicableProductLimit > 0 ? applicableProductLimit : Infinity;
|
|
454
359
|
for (const product of sortedProducts) {
|
|
455
|
-
if (deductionLeft.lessThanOrEqualTo(0) || remainingLimit <= 0)
|
|
456
|
-
|
|
457
|
-
// 动态计算当前可抵扣数量 = ceil(剩余金额 / 单价)
|
|
360
|
+
if (deductionLeft.lessThanOrEqualTo(0) || remainingLimit <= 0)
|
|
361
|
+
break;
|
|
458
362
|
const currentAvailableQty = Math.ceil(product[amountField].dividedBy(product[unitPriceField]).toNumber());
|
|
459
363
|
const availableQty = Math.min(currentAvailableQty, remainingLimit);
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
// 计算实际抵扣的数量(用于记录和配额计算)
|
|
364
|
+
const maxDeductForProduct = import_decimal.default.min(
|
|
365
|
+
product[unitPriceField].times(availableQty),
|
|
366
|
+
product[amountField]
|
|
367
|
+
);
|
|
368
|
+
const actualDeductAmount = import_decimal.default.min(deductionLeft, maxDeductForProduct);
|
|
466
369
|
const actualDeductQty = Math.ceil(actualDeductAmount.dividedBy(product[unitPriceField]).toNumber());
|
|
467
|
-
|
|
468
|
-
// 只更新商品的剩余金额,不更新 remainingQuantity
|
|
469
370
|
product[amountField] = product[amountField].minus(actualDeductAmount);
|
|
470
371
|
deductionLeft = deductionLeft.minus(actualDeductAmount);
|
|
471
372
|
remainingLimit -= actualDeductQty;
|
|
@@ -477,24 +378,23 @@ function processVouchers(applicableVouchers, orderTotalAmount, products) {
|
|
|
477
378
|
orderLineQuantity: getExpandedOrderLineQuantity(product),
|
|
478
379
|
deductAmount: actualDeductAmount.toNumber(),
|
|
479
380
|
// 转换为数字
|
|
480
|
-
deductQuantity: actualDeductQty
|
|
381
|
+
deductQuantity: actualDeductQty
|
|
382
|
+
// 抵扣涉及的数量(用于记录)
|
|
481
383
|
});
|
|
482
384
|
}
|
|
483
385
|
} else {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
// maxPassesPerItem 限制每张券最多抵扣的单位数
|
|
386
|
+
const targetProduct = applicableProducts.reduce(
|
|
387
|
+
(max, p) => p[unitPriceField].greaterThan(max[unitPriceField]) ? p : max
|
|
388
|
+
);
|
|
488
389
|
let maxDeductForProduct = targetProduct[amountField];
|
|
489
390
|
if (maxPassesPerItem > 0) {
|
|
490
|
-
maxDeductForProduct =
|
|
391
|
+
maxDeductForProduct = import_decimal.default.min(
|
|
392
|
+
targetProduct[unitPriceField].times(maxPassesPerItem),
|
|
393
|
+
targetProduct[amountField]
|
|
394
|
+
);
|
|
491
395
|
}
|
|
492
|
-
const actualDeductAmount =
|
|
493
|
-
|
|
494
|
-
// 计算实际抵扣的数量
|
|
396
|
+
const actualDeductAmount = import_decimal.default.min(deductionLeft, maxDeductForProduct);
|
|
495
397
|
const actualDeductQty = Math.ceil(actualDeductAmount.dividedBy(targetProduct[unitPriceField]).toNumber());
|
|
496
|
-
|
|
497
|
-
// 只更新商品的剩余金额,不更新 remainingQuantity
|
|
498
398
|
targetProduct[amountField] = targetProduct[amountField].minus(actualDeductAmount);
|
|
499
399
|
deductionLeft = deductionLeft.minus(actualDeductAmount);
|
|
500
400
|
deductionDetails.push({
|
|
@@ -509,14 +409,9 @@ function processVouchers(applicableVouchers, orderTotalAmount, products) {
|
|
|
509
409
|
}
|
|
510
410
|
const totalDeducted = maxDeduction.minus(deductionLeft);
|
|
511
411
|
if (totalDeducted.greaterThan(0)) {
|
|
512
|
-
// 更新订单剩余金额
|
|
513
412
|
remainingOrderAmount = remainingOrderAmount.minus(totalDeducted);
|
|
514
|
-
|
|
515
|
-
// 更新券使用次数(按 product_id 统计)
|
|
516
413
|
usedVoucherCounts.set(product_id, (usedVoucherCounts.get(product_id) || 0) + 1);
|
|
517
414
|
applyMaxPassUsageIncrements(itemPassUsageMap, product_id, maxPassesPerItem, deductionDetails);
|
|
518
|
-
|
|
519
|
-
// 添加到推荐列表(包含基于当前剩余金额计算的 available_max_amount)
|
|
520
415
|
recommendedVouchers.push({
|
|
521
416
|
...voucher,
|
|
522
417
|
actualDeduction: totalDeducted.toNumber(),
|
|
@@ -530,47 +425,17 @@ function processVouchers(applicableVouchers, orderTotalAmount, products) {
|
|
|
530
425
|
}
|
|
531
426
|
return false;
|
|
532
427
|
};
|
|
533
|
-
|
|
534
|
-
/**
|
|
535
|
-
// 第一轮:处理未跨商品券
|
|
536
|
-
const nonCrossGroups = groupByType(nonCrossProductVouchers);
|
|
537
|
-
nonCrossGroups.forEach((vouchersInGroup) => {
|
|
538
|
-
const sortedVouchers = sortVouchersByAmount(vouchersInGroup);
|
|
539
|
-
sortedVouchers.forEach((voucher) => {
|
|
540
|
-
applyVoucher(voucher);
|
|
541
|
-
});
|
|
542
|
-
});
|
|
543
|
-
// 第二轮:处理跨商品券
|
|
544
|
-
const crossGroups = groupByType(crossProductVouchers);
|
|
545
|
-
crossGroups.forEach((vouchersInGroup) => {
|
|
546
|
-
const sortedVouchers = sortVouchersByAmount(vouchersInGroup);
|
|
547
|
-
sortedVouchers.forEach((voucher) => {
|
|
548
|
-
applyVoucher(voucher);
|
|
549
|
-
});
|
|
550
|
-
});
|
|
551
|
-
*/
|
|
552
|
-
|
|
553
|
-
// 直接按 applicableVouchers 的顺序处理所有券
|
|
554
|
-
applicableVouchers.forEach(voucher => {
|
|
428
|
+
applicableVouchers.forEach((voucher) => {
|
|
555
429
|
applyVoucher(voucher);
|
|
556
430
|
});
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
// ========== 第三步:构建 all 数组,以 recommended 为基础 ==========
|
|
561
|
-
// 创建 recommended 券的 Map,以 id 为 key
|
|
562
|
-
const recommendedMap = new Map();
|
|
563
|
-
recommendedVouchers.forEach(v => {
|
|
431
|
+
const recommendedMap = /* @__PURE__ */ new Map();
|
|
432
|
+
recommendedVouchers.forEach((v) => {
|
|
564
433
|
recommendedMap.set(v.id, v);
|
|
565
434
|
});
|
|
566
|
-
|
|
567
|
-
// 遍历所有券,如果在 recommended 中则使用增强数据,否则使用基础数据
|
|
568
|
-
const allWithEnhancedData = allVouchersWithStatus.map(voucher => {
|
|
435
|
+
const allWithEnhancedData = allVouchersWithStatus.map((voucher) => {
|
|
569
436
|
if (recommendedMap.has(voucher.id)) {
|
|
570
|
-
// 使用 recommended 中的增强数据
|
|
571
437
|
return recommendedMap.get(voucher.id);
|
|
572
438
|
} else {
|
|
573
|
-
// 不在 recommended 中的券,补充基础字段
|
|
574
439
|
return {
|
|
575
440
|
...voucher,
|
|
576
441
|
actualDeduction: 0,
|
|
@@ -584,96 +449,70 @@ function processVouchers(applicableVouchers, orderTotalAmount, products) {
|
|
|
584
449
|
transformList: allWithEnhancedData
|
|
585
450
|
};
|
|
586
451
|
}
|
|
587
|
-
|
|
588
|
-
/**
|
|
589
|
-
* 重新计算优惠券状态(基于已选券的增量计算)
|
|
590
|
-
* @param allVouchers 所有原始券列表
|
|
591
|
-
* @param selectedVouchers 已选中的券列表(按选中顺序)
|
|
592
|
-
* @param orderTotalAmount 订单总金额
|
|
593
|
-
* @param products 订单商品列表
|
|
594
|
-
* @returns 返回更新后的所有券列表和已选券的详细抵扣信息
|
|
595
|
-
*/
|
|
596
452
|
function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmount, products) {
|
|
597
|
-
// 深拷贝并拆分商品列表(包含主商品和原价子商品,同时维护含税和不含税两个金额池),用于计算
|
|
598
453
|
const productsForCalc = expandProductsWithBundleItems(products, true);
|
|
599
|
-
let remainingOrderAmount = new
|
|
454
|
+
let remainingOrderAmount = new import_decimal.default(orderTotalAmount);
|
|
600
455
|
const selectedWithDetails = [];
|
|
601
|
-
|
|
602
|
-
// 追踪每个 Wallet Pass 商品对每个订单商品行的已使用卡券次数(按行唯一键)
|
|
603
|
-
const itemPassUsageMap = new Map();
|
|
456
|
+
const itemPassUsageMap = /* @__PURE__ */ new Map();
|
|
604
457
|
const getItemPassUsageRecalc = (walletPassProductId, lineKey) => {
|
|
605
|
-
|
|
458
|
+
var _a;
|
|
459
|
+
return ((_a = itemPassUsageMap.get(walletPassProductId)) == null ? void 0 : _a.get(lineKey)) || 0;
|
|
606
460
|
};
|
|
607
|
-
const filterByMaxPassesPerItemRecalc = (
|
|
608
|
-
if (maxPassesPerItem <= 0)
|
|
609
|
-
|
|
461
|
+
const filterByMaxPassesPerItemRecalc = (products2, walletPassProductId, maxPassesPerItem) => {
|
|
462
|
+
if (maxPassesPerItem <= 0)
|
|
463
|
+
return products2;
|
|
464
|
+
return products2.filter((p) => {
|
|
610
465
|
const lineKey = p._walletPassLineKey;
|
|
611
|
-
if (!lineKey)
|
|
466
|
+
if (!lineKey)
|
|
467
|
+
return true;
|
|
612
468
|
return getItemPassUsageRecalc(walletPassProductId, lineKey) < getMaxPassSlotsForExpandedLine(maxPassesPerItem, p);
|
|
613
469
|
});
|
|
614
470
|
};
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
const
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
allowCrossProduct,
|
|
625
|
-
applicableProductLimit,
|
|
626
|
-
deductTaxAndFee = true,
|
|
627
|
-
maxPassesPerItem = 0
|
|
628
|
-
} = config;
|
|
629
|
-
|
|
630
|
-
// 根据券的配置选择使用哪个单价字段和金额字段
|
|
631
|
-
const unitPriceField = deductTaxAndFee ? 'unitPriceWithTax' : 'unitPricePure';
|
|
632
|
-
const amountField = deductTaxAndFee ? 'remainingAmountWithTax' : 'remainingAmountPure';
|
|
633
|
-
|
|
634
|
-
// 获取适用商品(只筛选有剩余金额的商品)
|
|
635
|
-
let applicableProducts = getApplicableProducts(selectedVoucher, productsForCalc).filter(p => p[amountField].greaterThan(0));
|
|
636
|
-
|
|
637
|
-
// 按 maxPassesPerItem 过滤:排除已达到该行券次上限的展开行
|
|
471
|
+
selectedVouchers.forEach((selectedVoucher) => {
|
|
472
|
+
const { config, id } = selectedVoucher;
|
|
473
|
+
const { maxDeductionAmount, allowCrossProduct, applicableProductLimit, deductTaxAndFee = true, maxPassesPerItem = 0 } = config;
|
|
474
|
+
const unitPriceField = deductTaxAndFee ? "unitPriceWithTax" : "unitPricePure";
|
|
475
|
+
const amountField = deductTaxAndFee ? "remainingAmountWithTax" : "remainingAmountPure";
|
|
476
|
+
let applicableProducts = getApplicableProducts(
|
|
477
|
+
selectedVoucher,
|
|
478
|
+
productsForCalc
|
|
479
|
+
).filter((p) => p[amountField].greaterThan(0));
|
|
638
480
|
applicableProducts = filterByMaxPassesPerItemRecalc(applicableProducts, selectedVoucher.product_id, maxPassesPerItem);
|
|
639
481
|
if (applicableProducts.length === 0) {
|
|
640
|
-
// 无适用商品,跳过
|
|
641
482
|
selectedWithDetails.push({
|
|
642
483
|
...selectedVoucher,
|
|
643
484
|
actualDeduction: 0,
|
|
644
485
|
deductionDetails: [],
|
|
645
486
|
_available_max_amount: 0,
|
|
646
487
|
_unified_available_status: 0,
|
|
647
|
-
reasonCode:
|
|
488
|
+
reasonCode: "not_meet_the_required_conditions"
|
|
648
489
|
});
|
|
649
490
|
return;
|
|
650
491
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
492
|
+
const usageAmount = typeof selectedVoucher.edit_current_amount === "number" ? selectedVoucher.edit_current_amount : selectedVoucher._available_max_amount ?? getRecommendedAmount(selectedVoucher);
|
|
493
|
+
const maxDeduction = import_decimal.default.min(
|
|
494
|
+
new import_decimal.default(usageAmount),
|
|
495
|
+
new import_decimal.default(maxDeductionAmount),
|
|
496
|
+
remainingOrderAmount
|
|
497
|
+
);
|
|
656
498
|
let deductionLeft = maxDeduction;
|
|
657
499
|
const deductionDetails = [];
|
|
658
500
|
if (allowCrossProduct) {
|
|
659
|
-
|
|
660
|
-
|
|
501
|
+
const sortedProducts = [...applicableProducts].sort(
|
|
502
|
+
(a, b) => a[amountField].comparedTo(b[amountField]) > 0 ? -1 : 1
|
|
503
|
+
);
|
|
661
504
|
let remainingLimit = applicableProductLimit > 0 ? applicableProductLimit : Infinity;
|
|
662
505
|
for (const product of sortedProducts) {
|
|
663
|
-
if (deductionLeft.lessThanOrEqualTo(0) || remainingLimit <= 0)
|
|
664
|
-
|
|
665
|
-
// 动态计算当前可抵扣数量 = ceil(剩余金额 / 单价)
|
|
506
|
+
if (deductionLeft.lessThanOrEqualTo(0) || remainingLimit <= 0)
|
|
507
|
+
break;
|
|
666
508
|
const currentAvailableQty = Math.ceil(product[amountField].dividedBy(product[unitPriceField]).toNumber());
|
|
667
509
|
const availableQty = Math.min(currentAvailableQty, remainingLimit);
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
// 计算实际抵扣的数量(用于记录和配额计算)
|
|
510
|
+
const maxDeductForProduct = import_decimal.default.min(
|
|
511
|
+
product[unitPriceField].times(availableQty),
|
|
512
|
+
product[amountField]
|
|
513
|
+
);
|
|
514
|
+
const actualDeductAmount = import_decimal.default.min(deductionLeft, maxDeductForProduct);
|
|
674
515
|
const actualDeductQty = Math.ceil(actualDeductAmount.dividedBy(product[unitPriceField]).toNumber());
|
|
675
|
-
|
|
676
|
-
// 只更新商品的剩余金额,不更新 remainingQuantity
|
|
677
516
|
product[amountField] = product[amountField].minus(actualDeductAmount);
|
|
678
517
|
deductionLeft = deductionLeft.minus(actualDeductAmount);
|
|
679
518
|
remainingLimit -= actualDeductQty;
|
|
@@ -685,24 +524,23 @@ function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmount, pr
|
|
|
685
524
|
orderLineQuantity: getExpandedOrderLineQuantity(product),
|
|
686
525
|
deductAmount: actualDeductAmount.toNumber(),
|
|
687
526
|
// 转换为数字
|
|
688
|
-
deductQuantity: actualDeductQty
|
|
527
|
+
deductQuantity: actualDeductQty
|
|
528
|
+
// 抵扣涉及的数量(用于记录)
|
|
689
529
|
});
|
|
690
530
|
}
|
|
691
531
|
} else {
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
// maxPassesPerItem 限制每张券最多抵扣的单位数
|
|
532
|
+
const targetProduct = applicableProducts.reduce(
|
|
533
|
+
(max, p) => p[unitPriceField].greaterThan(max[unitPriceField]) ? p : max
|
|
534
|
+
);
|
|
696
535
|
let maxDeductForProduct = targetProduct[amountField];
|
|
697
536
|
if (maxPassesPerItem > 0) {
|
|
698
|
-
maxDeductForProduct =
|
|
537
|
+
maxDeductForProduct = import_decimal.default.min(
|
|
538
|
+
targetProduct[unitPriceField].times(maxPassesPerItem),
|
|
539
|
+
targetProduct[amountField]
|
|
540
|
+
);
|
|
699
541
|
}
|
|
700
|
-
const actualDeductAmount =
|
|
701
|
-
|
|
702
|
-
// 计算实际抵扣的数量
|
|
542
|
+
const actualDeductAmount = import_decimal.default.min(deductionLeft, maxDeductForProduct);
|
|
703
543
|
const actualDeductQty = Math.ceil(actualDeductAmount.dividedBy(targetProduct[unitPriceField]).toNumber());
|
|
704
|
-
|
|
705
|
-
// 只更新商品的剩余金额,不更新 remainingQuantity
|
|
706
544
|
targetProduct[amountField] = targetProduct[amountField].minus(actualDeductAmount);
|
|
707
545
|
deductionLeft = deductionLeft.minus(actualDeductAmount);
|
|
708
546
|
deductionDetails.push({
|
|
@@ -716,8 +554,6 @@ function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmount, pr
|
|
|
716
554
|
});
|
|
717
555
|
}
|
|
718
556
|
const totalDeducted = maxDeduction.minus(deductionLeft);
|
|
719
|
-
|
|
720
|
-
// 更新订单剩余金额
|
|
721
557
|
remainingOrderAmount = remainingOrderAmount.minus(totalDeducted);
|
|
722
558
|
applyMaxPassUsageIncrements(itemPassUsageMap, selectedVoucher.product_id, maxPassesPerItem, deductionDetails);
|
|
723
559
|
selectedWithDetails.push({
|
|
@@ -730,105 +566,97 @@ function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmount, pr
|
|
|
730
566
|
_unified_available_status: totalDeducted.greaterThan(0) ? 1 : 0
|
|
731
567
|
});
|
|
732
568
|
});
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
const usedVoucherCounts = new Map();
|
|
737
|
-
selectedVouchers.forEach(v => {
|
|
569
|
+
const selectedIds = new Set(selectedVouchers.map((v) => v.id));
|
|
570
|
+
const usedVoucherCounts = /* @__PURE__ */ new Map();
|
|
571
|
+
selectedVouchers.forEach((v) => {
|
|
738
572
|
usedVoucherCounts.set(v.product_id, (usedVoucherCounts.get(v.product_id) || 0) + 1);
|
|
739
573
|
});
|
|
740
|
-
const allWithUpdatedStatus = allVouchers.map(voucher => {
|
|
741
|
-
// 如果是已选中的券,使用详细计算结果
|
|
574
|
+
const allWithUpdatedStatus = allVouchers.map((voucher) => {
|
|
742
575
|
if (selectedIds.has(voucher.id)) {
|
|
743
|
-
const selectedDetail = selectedWithDetails.find(
|
|
576
|
+
const selectedDetail = selectedWithDetails.find(
|
|
577
|
+
(v) => v.id === voucher.id
|
|
578
|
+
);
|
|
744
579
|
return selectedDetail || voucher;
|
|
745
580
|
}
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
const
|
|
749
|
-
|
|
750
|
-
id,
|
|
751
|
-
product_id
|
|
752
|
-
} = voucher;
|
|
753
|
-
const {
|
|
754
|
-
maxDeductionAmount,
|
|
755
|
-
allowCrossProduct,
|
|
756
|
-
applicableProductLimit,
|
|
757
|
-
deductTaxAndFee = true,
|
|
758
|
-
maxPassesPerItem = 0
|
|
759
|
-
} = config;
|
|
760
|
-
|
|
761
|
-
// 根据券的配置选择使用哪个单价字段和金额字段
|
|
762
|
-
const unitPriceField = deductTaxAndFee ? 'unitPriceWithTax' : 'unitPricePure';
|
|
763
|
-
const amountField = deductTaxAndFee ? 'remainingAmountWithTax' : 'remainingAmountPure';
|
|
764
|
-
|
|
765
|
-
// 根据 deductTaxAndFee 配置获取推荐金额
|
|
581
|
+
const { config, id, product_id } = voucher;
|
|
582
|
+
const { maxDeductionAmount, allowCrossProduct, applicableProductLimit, deductTaxAndFee = true, maxPassesPerItem = 0 } = config;
|
|
583
|
+
const unitPriceField = deductTaxAndFee ? "unitPriceWithTax" : "unitPricePure";
|
|
584
|
+
const amountField = deductTaxAndFee ? "remainingAmountWithTax" : "remainingAmountPure";
|
|
766
585
|
const recommendedAmount = getRecommendedAmount(voucher);
|
|
767
|
-
|
|
768
|
-
// 检查基本可用性
|
|
769
586
|
let isAvailable = true;
|
|
770
|
-
let calculatedMaxAmount = new
|
|
587
|
+
let calculatedMaxAmount = new import_decimal.default(0);
|
|
771
588
|
let reasonCode;
|
|
772
589
|
if (recommendedAmount <= 0) {
|
|
773
590
|
isAvailable = false;
|
|
774
|
-
reasonCode =
|
|
591
|
+
reasonCode = "not_meet_the_required_conditions";
|
|
775
592
|
} else if (remainingOrderAmount.lessThanOrEqualTo(0)) {
|
|
776
593
|
isAvailable = false;
|
|
777
|
-
reasonCode =
|
|
594
|
+
reasonCode = "exceeds_the_maximum_deduction_limit";
|
|
778
595
|
} else {
|
|
779
|
-
// 检查 maxUsagePerOrder(按 product_id 统计),0 表示不限制
|
|
780
596
|
if (config.maxUsagePerOrder > 0) {
|
|
781
597
|
const usedCount = usedVoucherCounts.get(product_id) || 0;
|
|
782
598
|
if (usedCount >= config.maxUsagePerOrder) {
|
|
783
599
|
isAvailable = false;
|
|
784
|
-
reasonCode =
|
|
600
|
+
reasonCode = "usage_limit_reached";
|
|
785
601
|
}
|
|
786
602
|
}
|
|
787
603
|
if (isAvailable) {
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
604
|
+
let applicableProducts = getApplicableProducts(
|
|
605
|
+
voucher,
|
|
606
|
+
productsForCalc
|
|
607
|
+
).filter((p) => p[amountField].greaterThan(0));
|
|
792
608
|
applicableProducts = filterByMaxPassesPerItemRecalc(applicableProducts, product_id, maxPassesPerItem);
|
|
793
609
|
if (applicableProducts.length === 0) {
|
|
794
610
|
isAvailable = false;
|
|
795
|
-
reasonCode =
|
|
611
|
+
reasonCode = "not_meet_the_required_conditions";
|
|
796
612
|
} else {
|
|
797
|
-
|
|
798
|
-
|
|
613
|
+
const baseAmount = import_decimal.default.min(
|
|
614
|
+
new import_decimal.default(recommendedAmount),
|
|
615
|
+
new import_decimal.default(maxDeductionAmount)
|
|
616
|
+
);
|
|
799
617
|
if (allowCrossProduct) {
|
|
800
618
|
if (applicableProductLimit > 0) {
|
|
801
|
-
// 按剩余金额从高到低排序,按动态计算的可抵扣数量累计直到达到 limit
|
|
802
619
|
const sortedProducts = [...applicableProducts].sort((a, b) => a[amountField].comparedTo(b[amountField]) > 0 ? -1 : 1);
|
|
803
620
|
let remainingLimit = applicableProductLimit;
|
|
804
621
|
for (const product of sortedProducts) {
|
|
805
|
-
if (remainingLimit <= 0)
|
|
806
|
-
|
|
622
|
+
if (remainingLimit <= 0)
|
|
623
|
+
break;
|
|
807
624
|
const currentAvailableQty = Math.ceil(product[amountField].dividedBy(product[unitPriceField]).toNumber());
|
|
808
625
|
const deductQty = Math.min(currentAvailableQty, remainingLimit);
|
|
809
|
-
|
|
810
|
-
|
|
626
|
+
const deductAmount = import_decimal.default.min(
|
|
627
|
+
product[unitPriceField].times(deductQty),
|
|
628
|
+
product[amountField]
|
|
629
|
+
);
|
|
811
630
|
calculatedMaxAmount = calculatedMaxAmount.plus(deductAmount);
|
|
812
631
|
remainingLimit -= deductQty;
|
|
813
632
|
}
|
|
814
633
|
} else {
|
|
815
|
-
|
|
816
|
-
|
|
634
|
+
calculatedMaxAmount = applicableProducts.reduce(
|
|
635
|
+
(sum, p) => sum.plus(p[amountField]),
|
|
636
|
+
new import_decimal.default(0)
|
|
637
|
+
);
|
|
817
638
|
}
|
|
818
639
|
} else {
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
640
|
+
const maxProduct = applicableProducts.reduce(
|
|
641
|
+
(max, p) => p[unitPriceField].greaterThan(max[unitPriceField]) ? p : max
|
|
642
|
+
);
|
|
822
643
|
if (maxPassesPerItem > 0) {
|
|
823
|
-
calculatedMaxAmount =
|
|
644
|
+
calculatedMaxAmount = import_decimal.default.min(
|
|
645
|
+
maxProduct[unitPriceField].times(maxPassesPerItem),
|
|
646
|
+
maxProduct[amountField]
|
|
647
|
+
);
|
|
824
648
|
} else {
|
|
825
649
|
calculatedMaxAmount = maxProduct[amountField];
|
|
826
650
|
}
|
|
827
651
|
}
|
|
828
|
-
calculatedMaxAmount =
|
|
652
|
+
calculatedMaxAmount = import_decimal.default.min(
|
|
653
|
+
baseAmount,
|
|
654
|
+
calculatedMaxAmount,
|
|
655
|
+
remainingOrderAmount
|
|
656
|
+
);
|
|
829
657
|
if (calculatedMaxAmount.lessThanOrEqualTo(0)) {
|
|
830
658
|
isAvailable = false;
|
|
831
|
-
reasonCode =
|
|
659
|
+
reasonCode = "exceeds_the_maximum_deduction_limit";
|
|
832
660
|
}
|
|
833
661
|
}
|
|
834
662
|
}
|
|
@@ -838,9 +666,7 @@ function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmount, pr
|
|
|
838
666
|
_available_max_amount: calculatedMaxAmount.toNumber(),
|
|
839
667
|
// 转换为数字
|
|
840
668
|
_unified_available_status: isAvailable ? 1 : 0,
|
|
841
|
-
...
|
|
842
|
-
reasonCode
|
|
843
|
-
})
|
|
669
|
+
...reasonCode && { reasonCode }
|
|
844
670
|
};
|
|
845
671
|
});
|
|
846
672
|
return {
|
|
@@ -848,158 +674,47 @@ function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmount, pr
|
|
|
848
674
|
selectedWithDetails
|
|
849
675
|
};
|
|
850
676
|
}
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
* @param isDeductTaxAndFee 是否抵扣税费与附加费
|
|
856
|
-
* @returns 舍入余数(税费 + 附加费的舍入余数)
|
|
857
|
-
*/
|
|
858
|
-
const getTaxAndFeeRoundingRemainder = (product, isDeductTaxAndFee) => {
|
|
859
|
-
if (!isDeductTaxAndFee) {
|
|
860
|
-
return 0;
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
// 税费舍入余数(如果价格包含税则为0)
|
|
864
|
-
let taxFeeRoundingRemainder = new _decimal.default(0);
|
|
865
|
-
if (product.is_price_include_tax !== 1) {
|
|
866
|
-
taxFeeRoundingRemainder = new _decimal.default(product?.metadata?.tax_fee_rounding_remainder || 0);
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
// 附加费舍入余数
|
|
870
|
-
const surchargeFeeRoundingRemainder = new _decimal.default(product?.metadata?.surcharge_rounding_remainder || 0);
|
|
871
|
-
return taxFeeRoundingRemainder.add(surchargeFeeRoundingRemainder).toNumber();
|
|
872
|
-
};
|
|
873
|
-
|
|
874
|
-
/**
|
|
875
|
-
* 获取主商品的商品差额
|
|
876
|
-
* @param product 商品
|
|
877
|
-
* @returns 商品差额(与数量无关,计算总价时需要减去)
|
|
878
|
-
*/
|
|
879
|
-
exports.getTaxAndFeeRoundingRemainder = getTaxAndFeeRoundingRemainder;
|
|
880
|
-
const getProductDiscountDifference = product => {
|
|
881
|
-
return new _decimal.default(product?.metadata?.product_discount_difference || 0).toNumber();
|
|
882
|
-
};
|
|
883
|
-
|
|
884
|
-
/**
|
|
885
|
-
* 获取主商品价格(单价,不含舍入余数)
|
|
886
|
-
* @param product 商品
|
|
887
|
-
* @param isDeductTaxAndFee 是否抵扣税费与附加费
|
|
888
|
-
* @returns 商品单价
|
|
889
|
-
*/
|
|
890
|
-
exports.getProductDiscountDifference = getProductDiscountDifference;
|
|
891
|
-
const getMainProductPrice = (product, isDeductTaxAndFee) => {
|
|
892
|
-
let mainProductPrice = new _decimal.default(product?.main_product_selling_price || product.metadata?.main_product_selling_price || 0);
|
|
893
|
-
for (let bundleItem of product?.product_bundle || []) {
|
|
894
|
-
// 子商品是加价或减价才需要计算
|
|
677
|
+
var getMainProductPrice = (product, isDeductTaxAndFee) => {
|
|
678
|
+
var _a, _b, _c, _d, _e;
|
|
679
|
+
let mainProductPrice = new import_decimal.default((product == null ? void 0 : product.main_product_selling_price) || ((_a = product.metadata) == null ? void 0 : _a.main_product_selling_price) || 0);
|
|
680
|
+
for (let bundleItem of (product == null ? void 0 : product.product_bundle) || []) {
|
|
895
681
|
if (getBundleItemIsMarkupOrDiscountPrice(bundleItem)) {
|
|
896
|
-
|
|
897
|
-
const bundleItemPrice = new _decimal.default(bundleItem.bundle_selling_price ?? 0);
|
|
682
|
+
const bundleItemPrice = new import_decimal.default(bundleItem.bundle_selling_price ?? 0);
|
|
898
683
|
mainProductPrice = mainProductPrice.add(bundleItemPrice.times(bundleItem.num));
|
|
899
684
|
}
|
|
900
685
|
}
|
|
901
|
-
let taxFee = new
|
|
686
|
+
let taxFee = new import_decimal.default((product == null ? void 0 : product.tax_fee) || ((_b = product == null ? void 0 : product.metadata) == null ? void 0 : _b.main_product_attached_bundle_tax_fee) || 0).add(((_c = product == null ? void 0 : product.metadata) == null ? void 0 : _c.tax_fee_rounding_remainder) || 0);
|
|
902
687
|
if (product.is_price_include_tax === 1) {
|
|
903
|
-
taxFee = new
|
|
688
|
+
taxFee = new import_decimal.default(0);
|
|
904
689
|
}
|
|
905
|
-
|
|
906
|
-
// 税费
|
|
907
|
-
// 附加费
|
|
908
|
-
const surchargeFee = new _decimal.default(product?.metadata?.main_product_attached_bundle_surcharge_fee || 0).add(product?.metadata?.surcharge_rounding_remainder || 0);
|
|
909
|
-
|
|
910
|
-
// 税费附加费总额
|
|
690
|
+
const surchargeFee = new import_decimal.default(((_d = product == null ? void 0 : product.metadata) == null ? void 0 : _d.main_product_attached_bundle_surcharge_fee) || 0).add(((_e = product == null ? void 0 : product.metadata) == null ? void 0 : _e.surcharge_rounding_remainder) || 0);
|
|
911
691
|
const taxAndFeeTotal = taxFee.add(surchargeFee);
|
|
912
|
-
|
|
913
|
-
// 如果需要抵扣税费与附加费,则加上税费附加费总额
|
|
914
692
|
if (isDeductTaxAndFee) {
|
|
915
693
|
mainProductPrice = mainProductPrice.add(taxAndFeeTotal);
|
|
916
694
|
}
|
|
917
695
|
return mainProductPrice.toNumber();
|
|
918
696
|
};
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
* 获取套餐子商品税费和附加费的舍入余数
|
|
922
|
-
* @param bundleItem 套餐子商品
|
|
923
|
-
* @param isDeductTaxAndFee 是否抵扣税费与附加费
|
|
924
|
-
* @returns 舍入余数(税费 + 附加费的舍入余数)
|
|
925
|
-
*/
|
|
926
|
-
exports.getMainProductPrice = getMainProductPrice;
|
|
927
|
-
const getBundleItemTaxAndFeeRoundingRemainder = (bundleItem, isDeductTaxAndFee) => {
|
|
928
|
-
if (!isDeductTaxAndFee) {
|
|
929
|
-
return 0;
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
// 税费舍入余数(如果价格包含税则为0)
|
|
933
|
-
let taxFeeRoundingRemainder = new _decimal.default(0);
|
|
934
|
-
if (bundleItem.is_price_include_tax !== 1) {
|
|
935
|
-
taxFeeRoundingRemainder = new _decimal.default(bundleItem.metadata?.tax_fee_rounding_remainder || 0);
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
// 附加费舍入余数
|
|
939
|
-
const surchargeFeeRoundingRemainder = new _decimal.default(bundleItem.metadata?.surcharge_rounding_remainder || 0);
|
|
940
|
-
return taxFeeRoundingRemainder.add(surchargeFeeRoundingRemainder).toNumber();
|
|
941
|
-
};
|
|
942
|
-
|
|
943
|
-
/**
|
|
944
|
-
* 获取套餐子商品的商品差额
|
|
945
|
-
* @param bundleItem 套餐子商品
|
|
946
|
-
* @returns 商品差额(与数量无关,计算总价时需要减去)
|
|
947
|
-
*/
|
|
948
|
-
exports.getBundleItemTaxAndFeeRoundingRemainder = getBundleItemTaxAndFeeRoundingRemainder;
|
|
949
|
-
const getBundleItemDiscountDifference = bundleItem => {
|
|
950
|
-
return new _decimal.default(bundleItem.metadata?.product_discount_difference || 0).toNumber();
|
|
951
|
-
};
|
|
952
|
-
|
|
953
|
-
/**
|
|
954
|
-
* 获取套餐子商品价格(不含舍入余数)
|
|
955
|
-
* @param bundleItem 套餐子商品
|
|
956
|
-
* @param parentQuantity 父商品数量
|
|
957
|
-
* @param isDeductTaxAndFee 是否抵扣税费与附加费
|
|
958
|
-
* @returns 子商品总价格(不含舍入余数)
|
|
959
|
-
*/
|
|
960
|
-
exports.getBundleItemDiscountDifference = getBundleItemDiscountDifference;
|
|
961
|
-
const getBundleItemPrice = (bundleItem, parentQuantity, isDeductTaxAndFee) => {
|
|
962
|
-
// 子商品基础价格 = bundle_selling_price * num * 主商品数量
|
|
697
|
+
var getBundleItemPrice = (bundleItem, parentQuantity, isDeductTaxAndFee) => {
|
|
698
|
+
var _a;
|
|
963
699
|
const totalQuantity = bundleItem.num * parentQuantity;
|
|
964
|
-
let bundleItemPrice = new
|
|
965
|
-
|
|
966
|
-
// 根据 deductTaxAndFee 配置决定是否加上税费和附加费
|
|
700
|
+
let bundleItemPrice = new import_decimal.default(bundleItem.bundle_selling_price ?? 0).times(totalQuantity);
|
|
967
701
|
if (isDeductTaxAndFee) {
|
|
968
|
-
|
|
969
|
-
let taxFee = new _decimal.default(bundleItem.tax_fee ?? 0).times(totalQuantity);
|
|
702
|
+
let taxFee = new import_decimal.default(bundleItem.tax_fee ?? 0).times(totalQuantity);
|
|
970
703
|
if (bundleItem.is_price_include_tax === 1) {
|
|
971
|
-
taxFee = new
|
|
704
|
+
taxFee = new import_decimal.default(0);
|
|
972
705
|
}
|
|
973
|
-
|
|
974
|
-
const surchargeFee = new _decimal.default(bundleItem.metadata?.surcharge_fee ?? 0).times(totalQuantity);
|
|
706
|
+
const surchargeFee = new import_decimal.default(((_a = bundleItem.metadata) == null ? void 0 : _a.surcharge_fee) ?? 0).times(totalQuantity);
|
|
975
707
|
bundleItemPrice = bundleItemPrice.add(taxFee).add(surchargeFee);
|
|
976
708
|
}
|
|
977
709
|
return bundleItemPrice.toNumber();
|
|
978
710
|
};
|
|
979
|
-
|
|
980
|
-
/**
|
|
981
|
-
* 将商品数据拆分,包含主商品和原价子商品
|
|
982
|
-
* @param products 原始商品列表
|
|
983
|
-
* @param deductTaxAndFee 是否抵扣税费与附加费(已废弃,保留参数以兼容旧代码)
|
|
984
|
-
* @returns 拆分后的商品数据(包含主商品和子商品,同时维护含税和不含税两个金额池,以及单价和剩余数量)
|
|
985
|
-
*/
|
|
986
|
-
exports.getBundleItemPrice = getBundleItemPrice;
|
|
987
|
-
const expandProductsWithBundleItems = (products, deductTaxAndFee) => {
|
|
711
|
+
var expandProductsWithBundleItems = (products, deductTaxAndFee) => {
|
|
988
712
|
const expandedProducts = [];
|
|
989
713
|
products.forEach((product, indexInOrder) => {
|
|
990
714
|
const productQuantity = getProductQuantity(product);
|
|
991
715
|
const parentLineKey = resolveWalletPassLineKey(product, indexInOrder);
|
|
992
|
-
|
|
993
|
-
// 计算主商品单价(含税和不含税)
|
|
994
716
|
const unitPriceWithTax = getMainProductPrice(product, true);
|
|
995
717
|
const unitPricePure = getMainProductPrice(product, false);
|
|
996
|
-
|
|
997
|
-
// 获取舍入余数(与数量无关,只加一次)
|
|
998
|
-
const roundingRemainderWithTax = getTaxAndFeeRoundingRemainder(product, true);
|
|
999
|
-
// 获取商品差额(与数量无关,计算总价时需要减去)
|
|
1000
|
-
const discountDifference = getProductDiscountDifference(product);
|
|
1001
|
-
|
|
1002
|
-
// 1. 添加主商品(同时计算含税和不含税两个金额,以及单价和剩余数量)
|
|
1003
718
|
expandedProducts.push({
|
|
1004
719
|
...product,
|
|
1005
720
|
is_bundle_item: false,
|
|
@@ -1007,32 +722,22 @@ const expandProductsWithBundleItems = (products, deductTaxAndFee) => {
|
|
|
1007
722
|
_walletPassLineKey: parentLineKey,
|
|
1008
723
|
_orderLineQuantity: productQuantity,
|
|
1009
724
|
// 单价(用于按 quantity 计算抵扣)
|
|
1010
|
-
unitPriceWithTax: new
|
|
1011
|
-
unitPricePure: new
|
|
725
|
+
unitPriceWithTax: new import_decimal.default(unitPriceWithTax),
|
|
726
|
+
unitPricePure: new import_decimal.default(unitPricePure),
|
|
1012
727
|
// 剩余可抵扣数量
|
|
1013
728
|
remainingQuantity: productQuantity,
|
|
1014
|
-
//
|
|
1015
|
-
remainingAmountWithTax: new
|
|
1016
|
-
//
|
|
1017
|
-
remainingAmountPure: new
|
|
729
|
+
// 含税费的剩余金额
|
|
730
|
+
remainingAmountWithTax: new import_decimal.default(unitPriceWithTax).times(productQuantity),
|
|
731
|
+
// 纯商品金额(不含税费)
|
|
732
|
+
remainingAmountPure: new import_decimal.default(unitPricePure).times(productQuantity)
|
|
1018
733
|
});
|
|
1019
|
-
|
|
1020
|
-
// 2. 添加原价子商品(作为独立商品项)
|
|
1021
734
|
if (product.product_bundle && product.product_bundle.length > 0) {
|
|
1022
|
-
product.product_bundle.forEach(bundleItem => {
|
|
735
|
+
product.product_bundle.forEach((bundleItem) => {
|
|
1023
736
|
if (getBundleItemIsOriginalPrice(bundleItem)) {
|
|
1024
737
|
const bundleQuantity = bundleItem.num * productQuantity;
|
|
1025
738
|
const bundleLineKey = `${parentLineKey}#bundle:${bundleItem.bundle_id}:${bundleItem.bundle_product_id}`;
|
|
1026
|
-
|
|
1027
|
-
const
|
|
1028
|
-
const bundleUnitPricePure = new _decimal.default(getBundleItemPrice(bundleItem, 1, false)).dividedBy(bundleItem.num);
|
|
1029
|
-
|
|
1030
|
-
// 获取子商品舍入余数(与数量无关,只加一次)
|
|
1031
|
-
const bundleRoundingRemainder = getBundleItemTaxAndFeeRoundingRemainder(bundleItem, true);
|
|
1032
|
-
// 获取子商品差额(与数量无关,计算总价时需要减去)
|
|
1033
|
-
const bundleDiscountDifference = getBundleItemDiscountDifference(bundleItem);
|
|
1034
|
-
|
|
1035
|
-
// 原价子商品作为独立商品
|
|
739
|
+
const bundleUnitPriceWithTax = new import_decimal.default(getBundleItemPrice(bundleItem, 1, true)).dividedBy(bundleItem.num);
|
|
740
|
+
const bundleUnitPricePure = new import_decimal.default(getBundleItemPrice(bundleItem, 1, false)).dividedBy(bundleItem.num);
|
|
1036
741
|
expandedProducts.push({
|
|
1037
742
|
...bundleItem,
|
|
1038
743
|
product_id: bundleItem.bundle_product_id,
|
|
@@ -1048,10 +753,10 @@ const expandProductsWithBundleItems = (products, deductTaxAndFee) => {
|
|
|
1048
753
|
unitPricePure: bundleUnitPricePure,
|
|
1049
754
|
// 剩余可抵扣数量
|
|
1050
755
|
remainingQuantity: bundleQuantity,
|
|
1051
|
-
//
|
|
1052
|
-
remainingAmountWithTax: new
|
|
1053
|
-
//
|
|
1054
|
-
remainingAmountPure: new
|
|
756
|
+
// 含税费的剩余金额
|
|
757
|
+
remainingAmountWithTax: new import_decimal.default(getBundleItemPrice(bundleItem, productQuantity, true)),
|
|
758
|
+
// 纯商品金额(不含税费)
|
|
759
|
+
remainingAmountPure: new import_decimal.default(getBundleItemPrice(bundleItem, productQuantity, false))
|
|
1055
760
|
});
|
|
1056
761
|
}
|
|
1057
762
|
});
|
|
@@ -1059,27 +764,29 @@ const expandProductsWithBundleItems = (products, deductTaxAndFee) => {
|
|
|
1059
764
|
});
|
|
1060
765
|
return expandedProducts;
|
|
1061
766
|
};
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
const getBundleItemIsOriginalPrice = item => {
|
|
1065
|
-
return item?.price_type === 'markup' && item?.price_type_ext === 'product_price';
|
|
767
|
+
var getBundleItemIsOriginalPrice = (item) => {
|
|
768
|
+
return (item == null ? void 0 : item.price_type) === "markup" && (item == null ? void 0 : item.price_type_ext) === "product_price";
|
|
1066
769
|
};
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
exports.getBundleItemIsOriginalPrice = getBundleItemIsOriginalPrice;
|
|
1070
|
-
const getBundleItemIsMarkupPrice = item => {
|
|
1071
|
-
return item?.price_type === 'markup' && (item?.price_type_ext === '' || !item?.price_type_ext);
|
|
770
|
+
var getBundleItemIsMarkupPrice = (item) => {
|
|
771
|
+
return (item == null ? void 0 : item.price_type) === "markup" && ((item == null ? void 0 : item.price_type_ext) === "" || !(item == null ? void 0 : item.price_type_ext));
|
|
1072
772
|
};
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
exports.getBundleItemIsMarkupPrice = getBundleItemIsMarkupPrice;
|
|
1076
|
-
const getBundleItemIsDiscountPrice = item => {
|
|
1077
|
-
return item?.price_type === 'markdown' && (item?.price_type_ext === '' || !item?.price_type_ext);
|
|
773
|
+
var getBundleItemIsDiscountPrice = (item) => {
|
|
774
|
+
return (item == null ? void 0 : item.price_type) === "markdown" && ((item == null ? void 0 : item.price_type_ext) === "" || !(item == null ? void 0 : item.price_type_ext));
|
|
1078
775
|
};
|
|
1079
|
-
|
|
1080
|
-
// bundle商品是否是加价或减价
|
|
1081
|
-
exports.getBundleItemIsDiscountPrice = getBundleItemIsDiscountPrice;
|
|
1082
|
-
const getBundleItemIsMarkupOrDiscountPrice = item => {
|
|
776
|
+
var getBundleItemIsMarkupOrDiscountPrice = (item) => {
|
|
1083
777
|
return getBundleItemIsMarkupPrice(item) || getBundleItemIsDiscountPrice(item);
|
|
1084
778
|
};
|
|
1085
|
-
|
|
779
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
780
|
+
0 && (module.exports = {
|
|
781
|
+
getApplicableProductIds,
|
|
782
|
+
getBundleItemIsDiscountPrice,
|
|
783
|
+
getBundleItemIsMarkupOrDiscountPrice,
|
|
784
|
+
getBundleItemIsMarkupPrice,
|
|
785
|
+
getBundleItemIsOriginalPrice,
|
|
786
|
+
getBundleItemPrice,
|
|
787
|
+
getMainProductPrice,
|
|
788
|
+
getProductQuantity,
|
|
789
|
+
processVouchers,
|
|
790
|
+
recalculateVouchers,
|
|
791
|
+
resolveWalletPassLineKey
|
|
792
|
+
});
|