@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
|
@@ -18,6 +18,8 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
18
18
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
19
19
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
20
20
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
21
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
22
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
21
23
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
22
24
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
23
25
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
@@ -116,7 +118,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
116
118
|
// 非表单类型 holder 视为匹配
|
|
117
119
|
if (((_discount$holder = discount.holder) === null || _discount$holder === void 0 ? void 0 : _discount$holder.holder_type) !== 'form') return true;
|
|
118
120
|
// 主预约holder, 目前(20251124)默认只考虑单个holder的情况
|
|
119
|
-
|
|
121
|
+
// 旧版 holders[0].form_record_id 新版 holders[0]
|
|
122
|
+
var orderHolderId = Array.isArray(holders) && holders.length > 0 ? holders[0].form_record_id || holders[0] : undefined;
|
|
120
123
|
var productHolderId = Array.isArray(product.holder_id) ? product.holder_id[0] : product.holder_id;
|
|
121
124
|
// 商品不需要选holder,则不对比holder,直接返回true,
|
|
122
125
|
if (!product.isNeedHolder) return true;
|
|
@@ -169,8 +172,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
169
172
|
var result = this.calcDiscount({
|
|
170
173
|
discountList: mergedDiscountList,
|
|
171
174
|
productList: _toConsumableArray(productList),
|
|
172
|
-
holders: holders,
|
|
173
175
|
orderTotalAmount: orderTotalAmount,
|
|
176
|
+
holders: holders,
|
|
174
177
|
isFormSubject: isFormSubject
|
|
175
178
|
}, {
|
|
176
179
|
scan: true
|
|
@@ -223,6 +226,21 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
223
226
|
});
|
|
224
227
|
}
|
|
225
228
|
|
|
229
|
+
/** 剔除指定 type/tag 的折扣项,保留手动改价(type=product) / 券等 */
|
|
230
|
+
}, {
|
|
231
|
+
key: "excludeDiscountListByType",
|
|
232
|
+
value: function excludeDiscountListByType(discountList, type) {
|
|
233
|
+
return (discountList || []).filter(function (item) {
|
|
234
|
+
return item.type !== type && item.tag !== type;
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** 手动改价场景:去掉 promotion,保留 type=product 等行内折扣 */
|
|
239
|
+
}, {
|
|
240
|
+
key: "resolveDiscountListForManualOverride",
|
|
241
|
+
value: function resolveDiscountListForManualOverride(discountList) {
|
|
242
|
+
return this.excludeDiscountListByType(discountList, 'promotion');
|
|
243
|
+
}
|
|
226
244
|
// 获取券不可用的原因
|
|
227
245
|
}, {
|
|
228
246
|
key: "getUnavailableReason",
|
|
@@ -299,12 +317,50 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
299
317
|
}, {
|
|
300
318
|
key: "calcDiscount",
|
|
301
319
|
value: function calcDiscount(_ref2, options) {
|
|
302
|
-
var
|
|
320
|
+
var _options$selectedList,
|
|
321
|
+
_this3 = this;
|
|
303
322
|
var discountList = _ref2.discountList,
|
|
304
323
|
productList = _ref2.productList,
|
|
305
324
|
holders = _ref2.holders,
|
|
306
325
|
isFormSubject = _ref2.isFormSubject,
|
|
307
326
|
orderTotalAmount = _ref2.orderTotalAmount;
|
|
327
|
+
var resolveIsFormSubject = function resolveIsFormSubject(product) {
|
|
328
|
+
return typeof isFormSubject === 'function' ? Boolean(isFormSubject(product)) : Boolean(isFormSubject);
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
// 识别出来是不是在编辑的界面里又新增了商品
|
|
332
|
+
// 这种情况下,如果有可用的优惠券,也会自动勾选上
|
|
333
|
+
var isEditModeAddNewProduct = productList.find(function (n) {
|
|
334
|
+
return n.booking_id;
|
|
335
|
+
}) && productList.find(function (n) {
|
|
336
|
+
return !n.booking_id;
|
|
337
|
+
});
|
|
338
|
+
var reapplyBookingDiscountProductUids = new Set(((options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids) || []).filter(function (uid) {
|
|
339
|
+
return uid !== undefined && uid !== null && uid !== '';
|
|
340
|
+
}).map(String));
|
|
341
|
+
var getOriginProductUid = function getOriginProductUid(originProduct) {
|
|
342
|
+
var _originProduct$metada, _originProduct$metada2;
|
|
343
|
+
var uid = (_originProduct$metada = originProduct === null || originProduct === void 0 || (_originProduct$metada2 = originProduct.metadata) === null || _originProduct$metada2 === void 0 ? void 0 : _originProduct$metada2.unique_identification_number) !== null && _originProduct$metada !== void 0 ? _originProduct$metada : originProduct === null || originProduct === void 0 ? void 0 : originProduct.unique_identification_number;
|
|
344
|
+
if (uid === undefined || uid === null || uid === '') return undefined;
|
|
345
|
+
return String(uid);
|
|
346
|
+
};
|
|
347
|
+
var shouldReapplyBookingDiscount = function shouldReapplyBookingDiscount(originProduct, selectedDiscount) {
|
|
348
|
+
if (!selectedDiscount) return false;
|
|
349
|
+
var uid = getOriginProductUid(originProduct);
|
|
350
|
+
if (!uid || !reapplyBookingDiscountProductUids.has(uid)) return false;
|
|
351
|
+
var discountType = selectedDiscount.tag || selectedDiscount.type;
|
|
352
|
+
return selectedDiscount.isEditMode === true && selectedDiscount.isSelected === true && ['good_pass', 'discount_card', 'product_discount_card'].includes(discountType);
|
|
353
|
+
};
|
|
354
|
+
var resolveReapplyEditModeDiscountPercent = function resolveReapplyEditModeDiscountPercent(originProduct, selectedDiscount) {
|
|
355
|
+
var _discount2;
|
|
356
|
+
if (!shouldReapplyBookingDiscount(originProduct, selectedDiscount)) return undefined;
|
|
357
|
+
var discountType = (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.tag) || (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.type);
|
|
358
|
+
if (discountType !== 'discount_card' && discountType !== 'product_discount_card') {
|
|
359
|
+
return undefined;
|
|
360
|
+
}
|
|
361
|
+
var percent = Number((_discount2 = selectedDiscount.discount) === null || _discount2 === void 0 ? void 0 : _discount2.percent);
|
|
362
|
+
return Number.isFinite(percent) ? percent : undefined;
|
|
363
|
+
};
|
|
308
364
|
var editModeDiscount = [];
|
|
309
365
|
var addModeDiscount = [];
|
|
310
366
|
discountList.forEach(function (discount) {
|
|
@@ -333,11 +389,23 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
333
389
|
}
|
|
334
390
|
});
|
|
335
391
|
}
|
|
392
|
+
var hasDiscountInput = editModeDiscount.length > 0 || addModeDiscount.length > 0 || Boolean(options === null || options === void 0 ? void 0 : options.discountId) || Boolean(options === null || options === void 0 || (_options$selectedList = options.selectedList) === null || _options$selectedList === void 0 ? void 0 : _options$selectedList.length) || Boolean(options === null || options === void 0 ? void 0 : options.scan);
|
|
393
|
+
if (!hasDiscountInput) {
|
|
394
|
+
return {
|
|
395
|
+
discountList: discountList,
|
|
396
|
+
productList: productList
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
var canUseEditModeDiscountForReapply = function canUseEditModeDiscountForReapply(discount) {
|
|
400
|
+
var discountType = discount.tag || discount.type;
|
|
401
|
+
return reapplyBookingDiscountProductUids.size > 0 && discount.isEditMode === true && discount.isSelected === true && ['good_pass', 'discount_card', 'product_discount_card'].includes(discountType);
|
|
402
|
+
};
|
|
336
403
|
|
|
337
|
-
// 过滤掉手动取消false
|
|
338
|
-
|
|
404
|
+
// 过滤掉手动取消false的优惠券,但仅用于应用优惠逻辑。
|
|
405
|
+
// Change time 重报价需要把已选编辑态折扣卡重新放入候选,再由目标 uid 限定作用范围。
|
|
406
|
+
var filteredDiscountList = [].concat(_toConsumableArray(addModeDiscount.filter(function (discount) {
|
|
339
407
|
return !discount.isManualSelect;
|
|
340
|
-
});
|
|
408
|
+
})), _toConsumableArray(editModeDiscount.filter(canUseEditModeDiscountForReapply)));
|
|
341
409
|
|
|
342
410
|
// 🔥 扁平化商品列表:将 bundle 子商品展开为虚拟商品
|
|
343
411
|
var flattenProductsWithBundle = function flattenProductsWithBundle(productList) {
|
|
@@ -518,14 +586,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
518
586
|
// 🔥 扁平化商品列表(包含主商品和bundle子商品)
|
|
519
587
|
var flattenedList = flattenProductsWithBundle(productList);
|
|
520
588
|
|
|
521
|
-
// 识别出来是不是在编辑的界面里又新增了商品
|
|
522
|
-
// 这种情况下,如果有可用的优惠券,也会自动勾选上
|
|
523
|
-
var isEditModeAddNewProduct = flattenedList.find(function (n) {
|
|
524
|
-
return n.booking_id;
|
|
525
|
-
}) && flattenedList.find(function (n) {
|
|
526
|
-
return !n.booking_id;
|
|
527
|
-
});
|
|
528
|
-
|
|
529
589
|
// 对扁平化后的列表按价格降序排序(用于应用优惠券时优先选择高价商品)
|
|
530
590
|
var sortedFlattenedList = flattenedList.sort(function (a, b) {
|
|
531
591
|
var _ref3, _a$original_price, _ref4, _b$original_price;
|
|
@@ -605,14 +665,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
605
665
|
}
|
|
606
666
|
});
|
|
607
667
|
}
|
|
608
|
-
// 检查商品是否被排除(全品类)
|
|
609
|
-
var isProductIncludedByLimitedData = function isProductIncludedByLimitedData(limitedData, productId) {
|
|
610
|
-
var excludedIds = (limitedData === null || limitedData === void 0 ? void 0 : limitedData.exclude_product_ids) || [];
|
|
611
|
-
var isExcluded = (limitedData === null || limitedData === void 0 ? void 0 : limitedData.filter) === 1 && excludedIds.some(function (id) {
|
|
612
|
-
return String(id) === String(productId);
|
|
613
|
-
});
|
|
614
|
-
return !isExcluded;
|
|
615
|
-
};
|
|
616
668
|
|
|
617
669
|
/**
|
|
618
670
|
// 对productList按价格降序排序(用于应用优惠券时优先选择高价商品) 价格相同时使用quantity 排序
|
|
@@ -637,19 +689,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
637
689
|
// 🔥 统计每个 product_id(商品券商品id)已使用的数量,用于 maxUsagePerOrder 限制
|
|
638
690
|
var usedProductIdCounts = new Map();
|
|
639
691
|
|
|
640
|
-
// 🔥 统计每张折扣卡的 applicableProductLimit 已使用次数(跨商品全局计数)
|
|
641
|
-
var usedDiscountCardLimitCounts = new Map();
|
|
642
|
-
|
|
643
|
-
// 🔥 预先将 editModeDiscount 中的折扣卡计入 applicableProductLimit 已使用次数
|
|
644
|
-
editModeDiscount.forEach(function (discount) {
|
|
645
|
-
var discountType = discount.tag || discount.type;
|
|
646
|
-
if (['discount_card', 'product_discount_card'].includes(discountType)) {
|
|
647
|
-
var _discount$metadata4;
|
|
648
|
-
var currentCount = usedDiscountCardLimitCounts.get(discount.id) || 0;
|
|
649
|
-
usedDiscountCardLimitCounts.set(discount.id, currentCount + (((_discount$metadata4 = discount.metadata) === null || _discount$metadata4 === void 0 ? void 0 : _discount$metadata4.num) || 1));
|
|
650
|
-
}
|
|
651
|
-
});
|
|
652
|
-
|
|
653
692
|
// 记录每个优惠券适用的商品ID
|
|
654
693
|
var discountApplicability = new Map();
|
|
655
694
|
|
|
@@ -784,6 +823,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
784
823
|
}
|
|
785
824
|
}
|
|
786
825
|
});
|
|
826
|
+
|
|
787
827
|
// 🔥 第三步:识别 order_level 折扣卡并预计算分摊(排除被其他专属折扣卡占用的商品)
|
|
788
828
|
sortedDiscountList.forEach(function (discount) {
|
|
789
829
|
if (!isOrderLevelFixedAmountDiscount(discount)) {
|
|
@@ -863,7 +903,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
863
903
|
var _flatItem$parentProdu5;
|
|
864
904
|
// bundle子商品:构造虚拟商品对象
|
|
865
905
|
product = {
|
|
866
|
-
startDate: flatItem === null || flatItem === void 0 || (_flatItem$parentProdu5 = flatItem.parentProduct) === null || _flatItem$parentProdu5 === void 0 ? void 0 : _flatItem$parentProdu5.startDate,
|
|
867
906
|
_id: flatItem._id,
|
|
868
907
|
id: flatItem.id,
|
|
869
908
|
price: flatItem.price,
|
|
@@ -872,7 +911,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
872
911
|
total: flatItem.total,
|
|
873
912
|
origin_total: flatItem.origin_total,
|
|
874
913
|
booking_id: flatItem.booking_id,
|
|
875
|
-
discount_list: flatItem.discount_list || []
|
|
914
|
+
discount_list: flatItem.discount_list || [],
|
|
915
|
+
startDate: (_flatItem$parentProdu5 = flatItem.parentProduct) === null || _flatItem$parentProdu5 === void 0 ? void 0 : _flatItem$parentProdu5.startDate
|
|
876
916
|
};
|
|
877
917
|
originProduct = flatItem.originProduct;
|
|
878
918
|
}
|
|
@@ -882,7 +922,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
882
922
|
// 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
|
|
883
923
|
var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
|
|
884
924
|
var isHolderMatch = _this3.checkHolderMatch(discount, {
|
|
885
|
-
isNeedHolder:
|
|
925
|
+
isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
|
|
886
926
|
holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
887
927
|
}, holders);
|
|
888
928
|
var timeLimit = true;
|
|
@@ -902,7 +942,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
902
942
|
|
|
903
943
|
// 判断优惠券是否适用于该商品
|
|
904
944
|
if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
|
|
905
|
-
var _discountApplicabilit, _discount$
|
|
945
|
+
var _discountApplicabilit, _discount$metadata4, _discount$metadata5;
|
|
906
946
|
// 记录此优惠券适用的商品
|
|
907
947
|
(_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
|
|
908
948
|
|
|
@@ -918,14 +958,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
918
958
|
type: discountType,
|
|
919
959
|
tag: discountType,
|
|
920
960
|
discount: {
|
|
921
|
-
discount_card_type: discount === null || discount === void 0 || (_discount$
|
|
961
|
+
discount_card_type: discount === null || discount === void 0 || (_discount$metadata4 = discount.metadata) === null || _discount$metadata4 === void 0 ? void 0 : _discount$metadata4.discount_card_type,
|
|
922
962
|
fixed_amount: product.price,
|
|
923
|
-
discount_calculation_mode: discount === null || discount === void 0 || (_discount$
|
|
963
|
+
discount_calculation_mode: discount === null || discount === void 0 || (_discount$metadata5 = discount.metadata) === null || _discount$metadata5 === void 0 ? void 0 : _discount$metadata5.discount_calculation_mode,
|
|
924
964
|
resource_id: discount.id,
|
|
925
965
|
title: discount.format_title,
|
|
926
966
|
original_amount: product.price || product.origin_total,
|
|
927
967
|
pre_value: discount.par_value,
|
|
928
|
-
product_id: originProduct.id,
|
|
968
|
+
product_id: originProduct.id || originProduct.product_id,
|
|
929
969
|
discount_product_id: discount.product_id
|
|
930
970
|
},
|
|
931
971
|
metadata: {
|
|
@@ -1000,17 +1040,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1000
1040
|
// 然后再处理应用哪些优惠券,此时只考虑filteredDiscountList中的优惠券
|
|
1001
1041
|
// 🔥 使用扁平化后的列表进行处理
|
|
1002
1042
|
sortedFlattenedList.forEach(function (flatItem, index) {
|
|
1003
|
-
var _product10, _product$discount_lis2, _product11
|
|
1043
|
+
var _product10, _originProduct, _originProduct2, _originProduct3, _product$discount_lis2, _product11;
|
|
1004
1044
|
// 获取商品数据
|
|
1005
1045
|
var product, originProduct;
|
|
1006
1046
|
if (flatItem.type === 'main') {
|
|
1007
1047
|
product = flatItem.product;
|
|
1008
1048
|
originProduct = flatItem.originProduct;
|
|
1009
1049
|
} else {
|
|
1010
|
-
var _flatItem$
|
|
1050
|
+
var _flatItem$bundleItem5, _flatItem$bundleItem6, _flatItem$bundleItem7, _flatItem$parentProdu6;
|
|
1011
1051
|
// bundle子商品
|
|
1012
1052
|
product = {
|
|
1013
|
-
startDate: flatItem === null || flatItem === void 0 || (_flatItem$parentProdu6 = flatItem.parentProduct) === null || _flatItem$parentProdu6 === void 0 ? void 0 : _flatItem$parentProdu6.startDate,
|
|
1014
1053
|
_id: flatItem._id,
|
|
1015
1054
|
id: flatItem.id,
|
|
1016
1055
|
price: flatItem.price,
|
|
@@ -1020,15 +1059,21 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1020
1059
|
original_price: flatItem === null || flatItem === void 0 || (_flatItem$bundleItem5 = flatItem.bundleItem) === null || _flatItem$bundleItem5 === void 0 ? void 0 : _flatItem$bundleItem5.original_price,
|
|
1021
1060
|
origin_total: flatItem === null || flatItem === void 0 || (_flatItem$bundleItem6 = flatItem.bundleItem) === null || _flatItem$bundleItem6 === void 0 ? void 0 : _flatItem$bundleItem6.original_price,
|
|
1022
1061
|
booking_id: flatItem.booking_id,
|
|
1023
|
-
discount_list: (flatItem === null || flatItem === void 0 || (_flatItem$bundleItem7 = flatItem.bundleItem) === null || _flatItem$bundleItem7 === void 0 ? void 0 : _flatItem$bundleItem7.discount_list) || []
|
|
1062
|
+
discount_list: (flatItem === null || flatItem === void 0 || (_flatItem$bundleItem7 = flatItem.bundleItem) === null || _flatItem$bundleItem7 === void 0 ? void 0 : _flatItem$bundleItem7.discount_list) || [],
|
|
1063
|
+
startDate: (_flatItem$parentProdu6 = flatItem.parentProduct) === null || _flatItem$parentProdu6 === void 0 ? void 0 : _flatItem$parentProdu6.startDate
|
|
1024
1064
|
};
|
|
1025
1065
|
originProduct = flatItem.originProduct;
|
|
1026
1066
|
}
|
|
1067
|
+
var isPersistedProduct = ((_product10 = product) === null || _product10 === void 0 ? void 0 : _product10.booking_id) || ((_originProduct = originProduct) === null || _originProduct === void 0 ? void 0 : _originProduct.order_detail_id) || ((_originProduct2 = originProduct) === null || _originProduct2 === void 0 ? void 0 : _originProduct2.orderDetailId) || ((_originProduct3 = originProduct) === null || _originProduct3 === void 0 ? void 0 : _originProduct3.booking_id);
|
|
1068
|
+
var hasExistingWalletDiscount = ((_product$discount_lis2 = product.discount_list) === null || _product$discount_lis2 === void 0 ? void 0 : _product$discount_lis2.length) && ((_product11 = product) === null || _product11 === void 0 || (_product11 = _product11.discount_list) === null || _product11 === void 0 ? void 0 : _product11.every(function (discount) {
|
|
1069
|
+
var _discount$id, _discount$discount4;
|
|
1070
|
+
var discountIdentity = (_discount$id = discount.id) !== null && _discount$id !== void 0 ? _discount$id : (_discount$discount4 = discount.discount) === null || _discount$discount4 === void 0 ? void 0 : _discount$discount4.resource_id;
|
|
1071
|
+
var discountType = discount.tag || discount.type;
|
|
1072
|
+
return Boolean(discountIdentity && ['good_pass', 'discount_card', 'product_discount_card'].includes(discountType));
|
|
1073
|
+
}));
|
|
1027
1074
|
|
|
1028
|
-
//
|
|
1029
|
-
if (
|
|
1030
|
-
return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.tag || discount.type);
|
|
1031
|
-
})) {
|
|
1075
|
+
// 已持久化且已有钱包券/折扣卡的商品行跳过,保留后端历史折扣结果。
|
|
1076
|
+
if (isPersistedProduct && hasExistingWalletDiscount) {
|
|
1032
1077
|
if (flatItem.type === 'main') {
|
|
1033
1078
|
processedProductsMap.set(product._id, [originProduct]);
|
|
1034
1079
|
} else {
|
|
@@ -1044,7 +1089,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1044
1089
|
var _product$discount_lis3, _product$discount_lis4;
|
|
1045
1090
|
// 🔥 检查策略可用性(针对 good_pass 和折扣卡)
|
|
1046
1091
|
var discountType = discount.tag || discount.type;
|
|
1047
|
-
|
|
1092
|
+
var currentOriginUid = getOriginProductUid(originProduct);
|
|
1093
|
+
var isReapplyEditModeDiscountForProduct = discount.isEditMode && reapplyBookingDiscountProductUids.size > 0 && currentOriginUid && reapplyBookingDiscountProductUids.has(String(currentOriginUid)) && discount.isSelected === true;
|
|
1094
|
+
if (discount.isEditMode && reapplyBookingDiscountProductUids.size > 0) {
|
|
1095
|
+
var uid = currentOriginUid;
|
|
1096
|
+
if (!uid || !reapplyBookingDiscountProductUids.has(uid)) return false;
|
|
1097
|
+
if (!discount.isSelected) return false;
|
|
1098
|
+
}
|
|
1099
|
+
if (['good_pass', 'discount_card', 'product_discount_card'].includes(discountType) && !isReapplyEditModeDiscountForProduct) {
|
|
1048
1100
|
var _discount$config2;
|
|
1049
1101
|
// 如果策略检查后没有config,说明不可用
|
|
1050
1102
|
if (discount.config === undefined || !(discount !== null && discount !== void 0 && (_discount$config2 = discount.config) !== null && _discount$config2 !== void 0 && _discount$config2.isAvailable)) {
|
|
@@ -1076,25 +1128,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1076
1128
|
}
|
|
1077
1129
|
}
|
|
1078
1130
|
}
|
|
1079
|
-
|
|
1080
|
-
// 🔥 检查折扣卡的 applicableProductLimit 限制:折扣卡可使用的最大次数(跨商品全局)
|
|
1081
|
-
var discountTypeForLimit = discount.tag || discount.type;
|
|
1082
|
-
if (['discount_card', 'product_discount_card'].includes(discountTypeForLimit)) {
|
|
1083
|
-
var _discount$config4;
|
|
1084
|
-
var applicableProductLimitConfig = ((_discount$config4 = discount.config) === null || _discount$config4 === void 0 ? void 0 : _discount$config4.applicableProductLimit) || 0;
|
|
1085
|
-
if (applicableProductLimitConfig > 0) {
|
|
1086
|
-
var currentUsedLimitCount = usedDiscountCardLimitCounts.get(discount.id) || 0;
|
|
1087
|
-
if (currentUsedLimitCount >= applicableProductLimitConfig) {
|
|
1088
|
-
return false;
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
1131
|
var limitedData = discount.limited_relation_product_data;
|
|
1093
1132
|
|
|
1094
1133
|
// 拿到discount配置的holder信息 product信息 product.holder 不可用return false
|
|
1095
1134
|
var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
|
|
1096
1135
|
var isHolderMatch = _this3.checkHolderMatch(discount, {
|
|
1097
|
-
isNeedHolder:
|
|
1136
|
+
isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
|
|
1098
1137
|
holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
1099
1138
|
}, holders);
|
|
1100
1139
|
// 如果 holder 不匹配,则不适用
|
|
@@ -1107,10 +1146,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1107
1146
|
|
|
1108
1147
|
// 判断优惠券是否适用于该商品
|
|
1109
1148
|
if (limitedData.type === 'product_all') {
|
|
1110
|
-
if (
|
|
1149
|
+
if (limitedData.filter === 1 && limitedData.exclude_product_ids.includes(product.id)) {
|
|
1111
1150
|
return false;
|
|
1112
1151
|
}
|
|
1113
|
-
|
|
1114
1152
|
// 检查 package_sub_item_usage_rules
|
|
1115
1153
|
if (!_this3.checkPackageSubItemUsageRules(discount, flatItem)) {
|
|
1116
1154
|
return false;
|
|
@@ -1137,12 +1175,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1137
1175
|
// 如果是手动折扣,则不适用优惠券
|
|
1138
1176
|
var isManualDiscount = false;
|
|
1139
1177
|
if (flatItem.type === 'main') {
|
|
1140
|
-
var _product$discount_lis5, _product12, _product12$every;
|
|
1178
|
+
var _product$discount_lis5, _product$discount_lis6, _product12, _product12$every;
|
|
1141
1179
|
// 主商品:判断自身是否手动折扣
|
|
1142
|
-
isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount :
|
|
1180
|
+
isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : ((_product$discount_lis5 = product.discount_list) === null || _product$discount_lis5 === void 0 ? void 0 : _product$discount_lis5.some(function (item) {
|
|
1181
|
+
return item.type === 'product';
|
|
1182
|
+
})) || product.total != product.origin_total && (product.bundle || []).every(function (item) {
|
|
1143
1183
|
var _ref11;
|
|
1144
1184
|
return !((_ref11 = item.discount_list || []) !== null && _ref11 !== void 0 && _ref11.length);
|
|
1145
|
-
}) && (!((_product$
|
|
1185
|
+
}) && (!((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.length) || ((_product12 = product) === null || _product12 === void 0 || (_product12 = _product12.discount_list) === null || _product12 === void 0 || (_product12$every = _product12.every) === null || _product12$every === void 0 ? void 0 : _product12$every.call(_product12, function (item) {
|
|
1146
1186
|
return item.type === 'product';
|
|
1147
1187
|
})));
|
|
1148
1188
|
if (product.inPromotion) {
|
|
@@ -1152,11 +1192,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1152
1192
|
// bundle子商品:判断父主商品是否手动折扣
|
|
1153
1193
|
var parentProduct = flatItem.parentProduct;
|
|
1154
1194
|
if (parentProduct) {
|
|
1155
|
-
var _parentProduct$discou, _parentProduct$discou2, _parentProduct$discou3;
|
|
1156
|
-
isManualDiscount = typeof parentProduct.isManualDiscount === 'boolean' ? parentProduct.isManualDiscount :
|
|
1195
|
+
var _parentProduct$discou, _parentProduct$discou2, _parentProduct$discou3, _parentProduct$discou4;
|
|
1196
|
+
isManualDiscount = typeof parentProduct.isManualDiscount === 'boolean' ? parentProduct.isManualDiscount : ((_parentProduct$discou = parentProduct.discount_list) === null || _parentProduct$discou === void 0 ? void 0 : _parentProduct$discou.some(function (item) {
|
|
1197
|
+
return item.type === 'product';
|
|
1198
|
+
})) || parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(function (item) {
|
|
1157
1199
|
var _ref12;
|
|
1158
1200
|
return !((_ref12 = item.discount_list || []) !== null && _ref12 !== void 0 && _ref12.length);
|
|
1159
|
-
}) && (!((_parentProduct$
|
|
1201
|
+
}) && (!((_parentProduct$discou2 = parentProduct.discount_list) !== null && _parentProduct$discou2 !== void 0 && _parentProduct$discou2.length) || (parentProduct === null || parentProduct === void 0 || (_parentProduct$discou3 = parentProduct.discount_list) === null || _parentProduct$discou3 === void 0 || (_parentProduct$discou4 = _parentProduct$discou3.every) === null || _parentProduct$discou4 === void 0 ? void 0 : _parentProduct$discou4.call(_parentProduct$discou3, function (item) {
|
|
1160
1202
|
return item.type === 'product';
|
|
1161
1203
|
})));
|
|
1162
1204
|
}
|
|
@@ -1164,9 +1206,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1164
1206
|
|
|
1165
1207
|
// 勾选时覆盖手动折扣
|
|
1166
1208
|
if (options !== null && options !== void 0 && options.discountId) {
|
|
1167
|
-
var _product$
|
|
1209
|
+
var _product$discount_lis7;
|
|
1168
1210
|
// 主商品:检查自己的 discount_list
|
|
1169
|
-
if (flatItem.type === 'main' && (_product$
|
|
1211
|
+
if (flatItem.type === 'main' && (_product$discount_lis7 = product.discount_list) !== null && _product$discount_lis7 !== void 0 && _product$discount_lis7.some(function (item) {
|
|
1170
1212
|
var _item$discount;
|
|
1171
1213
|
return ((_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.resource_id) === options.discountId;
|
|
1172
1214
|
})) {
|
|
@@ -1174,8 +1216,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1174
1216
|
}
|
|
1175
1217
|
// bundle子商品:检查自己的 discount_list 或父主商品的 discount_list
|
|
1176
1218
|
if (flatItem.type === 'bundle') {
|
|
1177
|
-
var _product$
|
|
1178
|
-
if ((_product$
|
|
1219
|
+
var _product$discount_lis8, _flatItem$parentProdu7;
|
|
1220
|
+
if ((_product$discount_lis8 = product.discount_list) !== null && _product$discount_lis8 !== void 0 && _product$discount_lis8.some(function (item) {
|
|
1179
1221
|
var _item$discount2;
|
|
1180
1222
|
return ((_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.resource_id) === options.discountId;
|
|
1181
1223
|
}) || (_flatItem$parentProdu7 = flatItem.parentProduct) !== null && _flatItem$parentProdu7 !== void 0 && (_flatItem$parentProdu7 = _flatItem$parentProdu7.discount_list) !== null && _flatItem$parentProdu7 !== void 0 && _flatItem$parentProdu7.some(function (item) {
|
|
@@ -1187,11 +1229,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1187
1229
|
}
|
|
1188
1230
|
}
|
|
1189
1231
|
if (options !== null && options !== void 0 && options.selectedList) {
|
|
1190
|
-
var _product$
|
|
1232
|
+
var _product$discount_lis9;
|
|
1191
1233
|
// 主商品:检查自己的 discount_list
|
|
1192
|
-
if (flatItem.type === 'main' && (_product$
|
|
1193
|
-
var _options$
|
|
1194
|
-
return options === null || options === void 0 || (_options$
|
|
1234
|
+
if (flatItem.type === 'main' && (_product$discount_lis9 = product.discount_list) !== null && _product$discount_lis9 !== void 0 && _product$discount_lis9.some(function (item) {
|
|
1235
|
+
var _options$selectedList2;
|
|
1236
|
+
return options === null || options === void 0 || (_options$selectedList2 = options.selectedList) === null || _options$selectedList2 === void 0 ? void 0 : _options$selectedList2.some(function (n) {
|
|
1195
1237
|
var _item$discount4;
|
|
1196
1238
|
return n.discountId === ((_item$discount4 = item.discount) === null || _item$discount4 === void 0 ? void 0 : _item$discount4.resource_id);
|
|
1197
1239
|
});
|
|
@@ -1200,16 +1242,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1200
1242
|
}
|
|
1201
1243
|
// bundle子商品:检查自己的 discount_list 或父主商品的 discount_list
|
|
1202
1244
|
if (flatItem.type === 'bundle') {
|
|
1203
|
-
var _product$
|
|
1204
|
-
if ((_product$
|
|
1205
|
-
var _options$
|
|
1206
|
-
return options === null || options === void 0 || (_options$
|
|
1245
|
+
var _product$discount_lis10, _flatItem$parentProdu8;
|
|
1246
|
+
if ((_product$discount_lis10 = product.discount_list) !== null && _product$discount_lis10 !== void 0 && _product$discount_lis10.some(function (item) {
|
|
1247
|
+
var _options$selectedList3;
|
|
1248
|
+
return options === null || options === void 0 || (_options$selectedList3 = options.selectedList) === null || _options$selectedList3 === void 0 ? void 0 : _options$selectedList3.some(function (n) {
|
|
1207
1249
|
var _item$discount5;
|
|
1208
1250
|
return n.discountId === ((_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.resource_id);
|
|
1209
1251
|
});
|
|
1210
1252
|
}) || (_flatItem$parentProdu8 = flatItem.parentProduct) !== null && _flatItem$parentProdu8 !== void 0 && (_flatItem$parentProdu8 = _flatItem$parentProdu8.discount_list) !== null && _flatItem$parentProdu8 !== void 0 && _flatItem$parentProdu8.some(function (item) {
|
|
1211
|
-
var _options$
|
|
1212
|
-
return options === null || options === void 0 || (_options$
|
|
1253
|
+
var _options$selectedList4;
|
|
1254
|
+
return options === null || options === void 0 || (_options$selectedList4 = options.selectedList) === null || _options$selectedList4 === void 0 ? void 0 : _options$selectedList4.some(function (n) {
|
|
1213
1255
|
var _item$discount6;
|
|
1214
1256
|
return n.discountId === ((_item$discount6 = item.discount) === null || _item$discount6 === void 0 ? void 0 : _item$discount6.resource_id);
|
|
1215
1257
|
});
|
|
@@ -1245,12 +1287,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1245
1287
|
price: product.price,
|
|
1246
1288
|
options: restoredOptions
|
|
1247
1289
|
}), {}, {
|
|
1248
|
-
discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1290
|
+
discount_list: isManualDiscount ? _this3.resolveDiscountListForManualOverride(product.discount_list) : _this3.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1249
1291
|
}))]);
|
|
1250
1292
|
} else {
|
|
1251
|
-
var _ref13, _product$_promotion$f, _product13, _product$origin_total
|
|
1293
|
+
var _ref13, _product$_promotion$f, _product13, _product$origin_total;
|
|
1252
1294
|
var total = product.inPromotion ? (_ref13 = (_product$_promotion$f = (_product13 = product) === null || _product13 === void 0 || (_product13 = _product13._promotion) === null || _product13 === void 0 ? void 0 : _product13.finalPrice) !== null && _product$_promotion$f !== void 0 ? _product$_promotion$f : product.origin_total) !== null && _ref13 !== void 0 ? _ref13 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
|
|
1253
|
-
var main_product_selling_price =
|
|
1295
|
+
var main_product_selling_price = product.price;
|
|
1254
1296
|
if ((product.discount_list || []).some(function (item) {
|
|
1255
1297
|
return item.type === 'promotion';
|
|
1256
1298
|
}) || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
@@ -1263,37 +1305,31 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1263
1305
|
} : {
|
|
1264
1306
|
_id: product._id.split('___')[0] + '___' + index,
|
|
1265
1307
|
total: total,
|
|
1266
|
-
original_price: product.original_price,
|
|
1267
1308
|
price: product.price,
|
|
1268
1309
|
main_product_selling_price: main_product_selling_price,
|
|
1269
1310
|
options: restoredOptions
|
|
1270
1311
|
}), {}, {
|
|
1271
|
-
discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1312
|
+
discount_list: isManualDiscount ? _this3.resolveDiscountListForManualOverride(product.discount_list) : _this3.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1272
1313
|
}))]);
|
|
1273
1314
|
}
|
|
1274
1315
|
} else {
|
|
1275
|
-
var _flatItem$bundleItem8;
|
|
1316
|
+
var _flatItem$bundleItem8, _flatItem$bundleItem9;
|
|
1276
1317
|
// bundle子商品:保存到扁平化Map
|
|
1277
1318
|
processedFlatItemsMap.set(flatItem._id, [_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
1278
|
-
discount_list: _this3.
|
|
1319
|
+
discount_list: isManualDiscount ? _this3.resolveDiscountListForManualOverride(((_flatItem$bundleItem8 = flatItem.bundleItem) === null || _flatItem$bundleItem8 === void 0 ? void 0 : _flatItem$bundleItem8.discount_list) || []) : _this3.filterDiscountListByType(((_flatItem$bundleItem9 = flatItem.bundleItem) === null || _flatItem$bundleItem9 === void 0 ? void 0 : _flatItem$bundleItem9.discount_list) || [], 'promotion'),
|
|
1279
1320
|
price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
|
|
1280
1321
|
processed: true
|
|
1281
1322
|
})]);
|
|
1282
1323
|
}
|
|
1283
1324
|
return;
|
|
1284
1325
|
}
|
|
1285
|
-
|
|
1326
|
+
var shouldReapplyBookingDiscountForProduct = shouldReapplyBookingDiscount(originProduct, selectedDiscount);
|
|
1327
|
+
if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === 'undefined' && !(options !== null && options !== void 0 && options.scan) && !isEditModeAddNewProduct && !shouldReapplyBookingDiscountForProduct) {
|
|
1286
1328
|
return;
|
|
1287
1329
|
}
|
|
1288
1330
|
|
|
1289
|
-
//
|
|
1290
|
-
var
|
|
1291
|
-
var isGoodPass = discountType === 'good_pass';
|
|
1292
|
-
var isDiscountCard = ['discount_card', 'product_discount_card'].includes(discountType);
|
|
1293
|
-
var applicableProductLimit = ((_selectedDiscount$con = selectedDiscount.config) === null || _selectedDiscount$con === void 0 ? void 0 : _selectedDiscount$con.applicableProductLimit) || 0;
|
|
1294
|
-
|
|
1295
|
-
// 商品券始终需要拆分,折扣卡在 applicableProductLimit > 0 时需要拆分
|
|
1296
|
-
var isNeedSplit = isGoodPass || isDiscountCard && applicableProductLimit > 0;
|
|
1331
|
+
// 是否需要拆分(商品券需要拆分)
|
|
1332
|
+
var isNeedSplit = (selectedDiscount.tag || selectedDiscount.type) === 'good_pass';
|
|
1297
1333
|
|
|
1298
1334
|
// 需要拆分出来的数量
|
|
1299
1335
|
var totalQuantity = product.quantity || product.num || 1;
|
|
@@ -1301,22 +1337,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1301
1337
|
return (item.tag || item.type) === 'good_pass';
|
|
1302
1338
|
}).length;
|
|
1303
1339
|
|
|
1304
|
-
// 🔥
|
|
1305
|
-
var maxUsageLimit;
|
|
1306
|
-
if (
|
|
1307
|
-
|
|
1308
|
-
maxUsageLimit = availableGoodPassCount;
|
|
1309
|
-
if (selectedDiscount.config && selectedDiscount.config.maxUsagePerOrder) {
|
|
1310
|
-
maxUsageLimit = Math.min(availableGoodPassCount, selectedDiscount.config.maxUsagePerOrder);
|
|
1311
|
-
}
|
|
1312
|
-
} else if (isDiscountCard && applicableProductLimit > 0) {
|
|
1313
|
-
// 折扣卡:使用 applicableProductLimit 限制(一个商品使用一次折扣卡算1次)
|
|
1314
|
-
// 需要减去已使用次数(跨商品全局计数)
|
|
1315
|
-
var usedLimitCount = usedDiscountCardLimitCounts.get(selectedDiscount.id) || 0;
|
|
1316
|
-
maxUsageLimit = Math.max(0, applicableProductLimit - usedLimitCount);
|
|
1317
|
-
} else {
|
|
1318
|
-
// 其他情况不拆分
|
|
1319
|
-
maxUsageLimit = 1;
|
|
1340
|
+
// 🔥 如果selectedDiscount有config配置,则使用config.maxUsagePerOrder限制使用次数
|
|
1341
|
+
var maxUsageLimit = availableGoodPassCount;
|
|
1342
|
+
if (selectedDiscount.config && selectedDiscount.config.maxUsagePerOrder) {
|
|
1343
|
+
maxUsageLimit = Math.min(availableGoodPassCount, selectedDiscount.config.maxUsagePerOrder);
|
|
1320
1344
|
}
|
|
1321
1345
|
var splitCount = isNeedSplit ? Math.min(product.quantity || product.num || 1, maxUsageLimit) : 1;
|
|
1322
1346
|
var arr = [];
|
|
@@ -1341,26 +1365,19 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1341
1365
|
}));
|
|
1342
1366
|
}
|
|
1343
1367
|
for (var i = 0; i < splitCount; i++) {
|
|
1344
|
-
var
|
|
1345
|
-
//
|
|
1346
|
-
|
|
1347
|
-
var currentSelectedDiscount = isGoodPass ? selectedDiscountCard || applicableDiscounts[i] : selectedDiscountCard || applicableDiscounts[0];
|
|
1368
|
+
var _originProduct4, _selectedDiscount$con, _product$options, _product$options2, _selectedDiscount$met, _selectedDiscount$met2, _reapplyDiscountPerce;
|
|
1369
|
+
// 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
|
|
1370
|
+
var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
|
|
1348
1371
|
// 标记优惠券为已使用
|
|
1349
|
-
usedDiscounts.set(
|
|
1372
|
+
usedDiscounts.set(_selectedDiscount.id, true);
|
|
1350
1373
|
// 🔥 更新 product_id 使用计数
|
|
1351
|
-
if ((
|
|
1352
|
-
var currentCount = usedProductIdCounts.get(
|
|
1353
|
-
usedProductIdCounts.set(
|
|
1354
|
-
}
|
|
1355
|
-
// 🔥 更新折扣卡 applicableProductLimit 使用计数(跨商品全局)
|
|
1356
|
-
var currentDiscountTypeForCount = currentSelectedDiscount.tag || currentSelectedDiscount.type;
|
|
1357
|
-
if (['discount_card', 'product_discount_card'].includes(currentDiscountTypeForCount)) {
|
|
1358
|
-
var currentLimitCount = usedDiscountCardLimitCounts.get(currentSelectedDiscount.id) || 0;
|
|
1359
|
-
usedDiscountCardLimitCounts.set(currentSelectedDiscount.id, currentLimitCount + 1);
|
|
1374
|
+
if ((_selectedDiscount.tag || _selectedDiscount.type) === 'good_pass') {
|
|
1375
|
+
var currentCount = usedProductIdCounts.get(_selectedDiscount.product_id) || 0;
|
|
1376
|
+
usedProductIdCounts.set(_selectedDiscount.product_id, currentCount + 1);
|
|
1360
1377
|
}
|
|
1361
1378
|
|
|
1362
1379
|
// 记录实际应用了优惠券的商品信息
|
|
1363
|
-
var appliedProducts = appliedDiscountProducts.get(
|
|
1380
|
+
var appliedProducts = appliedDiscountProducts.get(_selectedDiscount.id) || [];
|
|
1364
1381
|
|
|
1365
1382
|
// 优先从 origin_total拿,可能会拿不到(比如用户端预约在没有配置 original_price 的情况下)
|
|
1366
1383
|
var productOriginTotal = product.origin_total || product.total || 0;
|
|
@@ -1369,16 +1386,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1369
1386
|
productOriginTotal = product.origin_total;
|
|
1370
1387
|
}
|
|
1371
1388
|
// 如果originProduct?._productInit?.original_price为 0,product.origin_total可能为空,此时取 product.total
|
|
1372
|
-
if (Number(((
|
|
1389
|
+
if (Number(((_originProduct4 = originProduct) === null || _originProduct4 === void 0 || (_originProduct4 = _originProduct4._productInit) === null || _originProduct4 === void 0 ? void 0 : _originProduct4.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
|
|
1373
1390
|
productOriginTotal = product.total;
|
|
1374
1391
|
}
|
|
1375
1392
|
|
|
1376
1393
|
// 计算使用折扣卡/商品券以后,单个商品的总 total
|
|
1377
1394
|
// 🔥 检查是否是 order_level 固定金额折扣卡
|
|
1378
|
-
var isOrderLevel = isOrderLevelFixedAmountDiscount(
|
|
1379
|
-
var orderLevelAllocation = isOrderLevel ? orderLevelDiscountAllocations.get(
|
|
1395
|
+
var isOrderLevel = isOrderLevelFixedAmountDiscount(_selectedDiscount);
|
|
1396
|
+
var orderLevelAllocation = isOrderLevel ? orderLevelDiscountAllocations.get(_selectedDiscount.id) : null;
|
|
1380
1397
|
var productAllocation = orderLevelAllocation === null || orderLevelAllocation === void 0 ? void 0 : orderLevelAllocation.get(flatItem._id);
|
|
1381
|
-
var isDeductOptionPrice = !!((_selectedDiscount$
|
|
1398
|
+
var isDeductOptionPrice = !!((_selectedDiscount$con = _selectedDiscount.config) !== null && _selectedDiscount$con !== void 0 && _selectedDiscount$con.deductOptionPrice);
|
|
1382
1399
|
|
|
1383
1400
|
// 主商品折后价(不含 option);勿与 option 合计混在同一变量,否则 main_product_selling_price 错误
|
|
1384
1401
|
var mainProductSellingPrice = void 0;
|
|
@@ -1386,18 +1403,25 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1386
1403
|
var productDiscountDifference = void 0;
|
|
1387
1404
|
var discountedOptions = product.options;
|
|
1388
1405
|
var optionDiscountAmount = 0;
|
|
1406
|
+
var reapplyDiscountPercent = void 0;
|
|
1389
1407
|
if (isOrderLevel && productAllocation) {
|
|
1390
1408
|
// order_level:使用预计算的分摊金额
|
|
1391
1409
|
amount = productAllocation.discountAmount;
|
|
1392
1410
|
productDiscountDifference = productAllocation.difference;
|
|
1393
1411
|
mainProductSellingPrice = Math.max(new Decimal(product.price).minus(amount).toNumber(), 0);
|
|
1412
|
+
} else if (resolveReapplyEditModeDiscountPercent(originProduct, _selectedDiscount) !== undefined) {
|
|
1413
|
+
// Change time 重套编辑态折扣卡时,历史 par_value 不是运行时折扣口径,优先使用后端快照里的 percent。
|
|
1414
|
+
var percent = resolveReapplyEditModeDiscountPercent(originProduct, _selectedDiscount);
|
|
1415
|
+
reapplyDiscountPercent = new Decimal(percent).toFixed(2);
|
|
1416
|
+
mainProductSellingPrice = new Decimal(product.price || 0).mul(new Decimal(100).minus(percent)).div(100).toDecimalPlaces(2).toNumber();
|
|
1417
|
+
amount = new Decimal(product.price).minus(mainProductSellingPrice).toNumber();
|
|
1394
1418
|
} else {
|
|
1395
1419
|
// item_level 或其他类型:使用原有逻辑
|
|
1396
|
-
mainProductSellingPrice = getDiscountAmount(
|
|
1420
|
+
mainProductSellingPrice = getDiscountAmount(_selectedDiscount, product.price, product.price);
|
|
1397
1421
|
amount = new Decimal(product.price).minus(new Decimal(mainProductSellingPrice)).toNumber();
|
|
1398
1422
|
}
|
|
1399
1423
|
if (isDeductOptionPrice && (_product$options = product.options) !== null && _product$options !== void 0 && _product$options.length) {
|
|
1400
|
-
var optionResult = applyDiscountToOptions(product.options,
|
|
1424
|
+
var optionResult = applyDiscountToOptions(product.options, _selectedDiscount);
|
|
1401
1425
|
discountedOptions = optionResult.discountedOptions;
|
|
1402
1426
|
optionDiscountAmount = optionResult.optionDiscountAmount;
|
|
1403
1427
|
}
|
|
@@ -1410,29 +1434,28 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1410
1434
|
// discount_list.amount / fixed_amount:行级总优惠 = 主商品优惠 + option 优惠(与 total 变化一致)
|
|
1411
1435
|
var mainProductDiscountAmount = amount;
|
|
1412
1436
|
var lineDiscountAmount = new Decimal(mainProductDiscountAmount).plus(optionDiscountAmount).toNumber();
|
|
1413
|
-
var
|
|
1414
|
-
var
|
|
1415
|
-
var currentIsGoodPass = currentDiscountType === 'good_pass';
|
|
1437
|
+
var discountType = _selectedDiscount.tag || _selectedDiscount.type;
|
|
1438
|
+
var isGoodPass = discountType === 'good_pass';
|
|
1416
1439
|
var discountDetail = {
|
|
1417
1440
|
amount: lineDiscountAmount,
|
|
1418
|
-
type:
|
|
1441
|
+
type: _selectedDiscount.tag === 'product_discount_card' ? 'discount_card' : discountType,
|
|
1419
1442
|
discount: {
|
|
1420
|
-
discount_card_type:
|
|
1443
|
+
discount_card_type: _selectedDiscount === null || _selectedDiscount === void 0 || (_selectedDiscount$met = _selectedDiscount.metadata) === null || _selectedDiscount$met === void 0 ? void 0 : _selectedDiscount$met.discount_card_type,
|
|
1421
1444
|
fixed_amount: lineDiscountAmount,
|
|
1422
|
-
discount_calculation_mode:
|
|
1423
|
-
resource_id:
|
|
1424
|
-
title:
|
|
1445
|
+
discount_calculation_mode: _selectedDiscount === null || _selectedDiscount === void 0 || (_selectedDiscount$met2 = _selectedDiscount.metadata) === null || _selectedDiscount$met2 === void 0 ? void 0 : _selectedDiscount$met2.discount_calculation_mode,
|
|
1446
|
+
resource_id: _selectedDiscount.id,
|
|
1447
|
+
title: _selectedDiscount.format_title,
|
|
1425
1448
|
original_amount: product.price,
|
|
1426
|
-
product_id: originProduct.id,
|
|
1427
|
-
percent:
|
|
1428
|
-
discount_product_id:
|
|
1449
|
+
product_id: originProduct.id || originProduct.product_id,
|
|
1450
|
+
percent: (_reapplyDiscountPerce = reapplyDiscountPercent) !== null && _reapplyDiscountPerce !== void 0 ? _reapplyDiscountPerce : _selectedDiscount.par_value,
|
|
1451
|
+
discount_product_id: _selectedDiscount.product_id
|
|
1429
1452
|
},
|
|
1430
|
-
// 前端使用的num
|
|
1431
|
-
_num:
|
|
1432
|
-
config:
|
|
1453
|
+
// 前端使用的num数量,为了计算优惠金额
|
|
1454
|
+
_num: isGoodPass ? 1 : product.num,
|
|
1455
|
+
config: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.config,
|
|
1433
1456
|
metadata: _objectSpread(_objectSpread({
|
|
1434
1457
|
num: 1,
|
|
1435
|
-
discount_rule_uncheck_flag:
|
|
1458
|
+
discount_rule_uncheck_flag: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.discount_rule_uncheck_flag
|
|
1436
1459
|
}, productDiscountDifference !== undefined && {
|
|
1437
1460
|
product_discount_difference: productDiscountDifference
|
|
1438
1461
|
}), {}, {
|
|
@@ -1442,7 +1465,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1442
1465
|
})
|
|
1443
1466
|
};
|
|
1444
1467
|
appliedProducts.push(discountDetail);
|
|
1445
|
-
appliedDiscountProducts.set(
|
|
1468
|
+
appliedDiscountProducts.set(_selectedDiscount.id, appliedProducts);
|
|
1446
1469
|
|
|
1447
1470
|
// 记录应用了优惠券的商品
|
|
1448
1471
|
// 后续更新价格改为 getProductTotalPrice getProductOriginTotalPrice逻辑
|
|
@@ -1450,7 +1473,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1450
1473
|
arr.push(_this3.hooks.setProduct(originProduct, {
|
|
1451
1474
|
discount_list: [discountDetail],
|
|
1452
1475
|
// good_pass:主商品价以折后价为准;勿用 product.price - amount(amount 含 option 优惠时会算错)
|
|
1453
|
-
price:
|
|
1476
|
+
price: isGoodPass ? mainProductSellingPrice : product.price,
|
|
1454
1477
|
quantity: isNeedSplit ? 1 : product.quantity,
|
|
1455
1478
|
origin_total: getProductOriginTotalPrice({
|
|
1456
1479
|
product: {
|
|
@@ -1467,8 +1490,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1467
1490
|
} else {
|
|
1468
1491
|
arr.push(_this3.hooks.setProduct(originProduct, {
|
|
1469
1492
|
discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion').concat([discountDetail]),
|
|
1470
|
-
_id: product._id.split('___')[0] + '___' +
|
|
1471
|
-
price:
|
|
1493
|
+
_id: product._id.split('___')[0] + '___' + _selectedDiscount.id + index,
|
|
1494
|
+
price: _selectedDiscount.tag === 'good_pass' ? 0 : product.price,
|
|
1472
1495
|
quantity: isNeedSplit ? 1 : product.quantity,
|
|
1473
1496
|
total: _total2,
|
|
1474
1497
|
origin_total: productOriginTotal,
|
|
@@ -1479,69 +1502,57 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1479
1502
|
}
|
|
1480
1503
|
processedProductsMap.set(product._id, arr);
|
|
1481
1504
|
} else {
|
|
1482
|
-
// 🔥 bundle
|
|
1505
|
+
// 🔥 bundle子商品:支持拆分
|
|
1483
1506
|
var processedItems = [];
|
|
1484
1507
|
if (isNeedSplit) {
|
|
1485
|
-
//
|
|
1508
|
+
// 商品券:需要拆分数量
|
|
1486
1509
|
var discountNum = splitCount;
|
|
1487
1510
|
var normalNum = totalQuantity - discountNum;
|
|
1488
1511
|
|
|
1489
|
-
//
|
|
1512
|
+
// 生成有折扣的商品(每张商品券对应 num: 1)
|
|
1490
1513
|
for (var _i = 0; _i < discountNum; _i++) {
|
|
1491
|
-
var
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
var currentBundleDiscount = isGoodPass ? selectedDiscountCard || applicableDiscounts[_i] : selectedDiscountCard || applicableDiscounts[0];
|
|
1495
|
-
usedDiscounts.set(currentBundleDiscount.id, true);
|
|
1514
|
+
var _selectedDiscount2$me;
|
|
1515
|
+
var _selectedDiscount2 = applicableDiscounts[_i];
|
|
1516
|
+
usedDiscounts.set(_selectedDiscount2.id, true);
|
|
1496
1517
|
// 🔥 更新 product_id 使用计数
|
|
1497
|
-
if ((
|
|
1498
|
-
var _currentCount = usedProductIdCounts.get(
|
|
1499
|
-
usedProductIdCounts.set(
|
|
1500
|
-
}
|
|
1501
|
-
// 🔥 更新折扣卡 applicableProductLimit 使用计数(跨商品全局)
|
|
1502
|
-
var bundleDiscountTypeForCount = currentBundleDiscount.tag || currentBundleDiscount.type;
|
|
1503
|
-
if (['discount_card', 'product_discount_card'].includes(bundleDiscountTypeForCount)) {
|
|
1504
|
-
var currentBundleLimitCount = usedDiscountCardLimitCounts.get(currentBundleDiscount.id) || 0;
|
|
1505
|
-
usedDiscountCardLimitCounts.set(currentBundleDiscount.id, currentBundleLimitCount + 1);
|
|
1518
|
+
if ((_selectedDiscount2.tag || _selectedDiscount2.type) === 'good_pass') {
|
|
1519
|
+
var _currentCount = usedProductIdCounts.get(_selectedDiscount2.product_id) || 0;
|
|
1520
|
+
usedProductIdCounts.set(_selectedDiscount2.product_id, _currentCount + 1);
|
|
1506
1521
|
}
|
|
1507
1522
|
|
|
1508
1523
|
// 🔥 生成唯一的 _id
|
|
1509
1524
|
var uniqueId = "".concat(flatItem._id, "_split_").concat(_i);
|
|
1510
1525
|
|
|
1511
1526
|
// 计算折扣后的价格(使用 getDiscountAmount,内部已处理 maxDeductionAmount)
|
|
1512
|
-
var discountedPrice = getDiscountAmount(
|
|
1527
|
+
var discountedPrice = getDiscountAmount(_selectedDiscount2, product.origin_total, product.origin_total);
|
|
1513
1528
|
var bundleDiscountAmount = new Decimal(product.origin_total || 0).minus(discountedPrice).toNumber();
|
|
1514
|
-
|
|
1515
|
-
// 确定折扣类型
|
|
1516
|
-
var bundleDiscountType = currentBundleDiscount.tag === 'product_discount_card' ? 'discount_card' : currentBundleDiscount.tag;
|
|
1529
|
+
debugger;
|
|
1517
1530
|
var _discountDetail = {
|
|
1518
1531
|
amount: bundleDiscountAmount,
|
|
1519
|
-
type:
|
|
1532
|
+
type: 'good_pass',
|
|
1520
1533
|
discount: {
|
|
1521
|
-
|
|
1522
|
-
discount_calculation_mode:
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
title: currentBundleDiscount.format_title,
|
|
1534
|
+
fixed_amount: product.origin_total,
|
|
1535
|
+
discount_calculation_mode: _selectedDiscount2 === null || _selectedDiscount2 === void 0 || (_selectedDiscount2$me = _selectedDiscount2.metadata) === null || _selectedDiscount2$me === void 0 ? void 0 : _selectedDiscount2$me.discount_calculation_mode,
|
|
1536
|
+
resource_id: _selectedDiscount2.id,
|
|
1537
|
+
title: _selectedDiscount2.format_title,
|
|
1526
1538
|
original_amount: product.origin_total,
|
|
1527
|
-
product_id: product.id,
|
|
1528
|
-
|
|
1529
|
-
discount_product_id: currentBundleDiscount.product_id
|
|
1539
|
+
product_id: product.id || product.product_id,
|
|
1540
|
+
discount_product_id: _selectedDiscount2.product_id
|
|
1530
1541
|
},
|
|
1531
1542
|
metadata: {
|
|
1532
1543
|
// 🔥 使用拆分后的唯一 _id
|
|
1533
1544
|
custom_product_bundle_map_id: uniqueId,
|
|
1534
|
-
discount_rule_uncheck_flag:
|
|
1545
|
+
discount_rule_uncheck_flag: _selectedDiscount2 === null || _selectedDiscount2 === void 0 ? void 0 : _selectedDiscount2.discount_rule_uncheck_flag,
|
|
1535
1546
|
num: 1
|
|
1536
1547
|
},
|
|
1537
1548
|
_num: 1,
|
|
1538
|
-
config:
|
|
1549
|
+
config: _selectedDiscount2 === null || _selectedDiscount2 === void 0 ? void 0 : _selectedDiscount2.config
|
|
1539
1550
|
};
|
|
1540
1551
|
|
|
1541
1552
|
// 记录实际应用的折扣
|
|
1542
|
-
var _appliedProducts = appliedDiscountProducts.get(
|
|
1553
|
+
var _appliedProducts = appliedDiscountProducts.get(_selectedDiscount2.id) || [];
|
|
1543
1554
|
_appliedProducts.push(_discountDetail);
|
|
1544
|
-
appliedDiscountProducts.set(
|
|
1555
|
+
appliedDiscountProducts.set(_selectedDiscount2.id, _appliedProducts);
|
|
1545
1556
|
processedItems.push(_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
1546
1557
|
// 🔥 使用唯一的 _id
|
|
1547
1558
|
_id: uniqueId,
|
|
@@ -1552,263 +1563,36 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1552
1563
|
total: discountedPrice,
|
|
1553
1564
|
discount_list: [_discountDetail],
|
|
1554
1565
|
processed: true,
|
|
1555
|
-
_discountId:
|
|
1566
|
+
_discountId: _selectedDiscount2.id
|
|
1556
1567
|
}));
|
|
1557
1568
|
}
|
|
1558
1569
|
|
|
1559
|
-
//
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
if (['good_pass', 'discount_card', 'product_discount_card'].includes(nextDiscountType)) {
|
|
1570
|
-
var _nextDiscount$config;
|
|
1571
|
-
if (nextDiscount.config === undefined || !(nextDiscount !== null && nextDiscount !== void 0 && (_nextDiscount$config = nextDiscount.config) !== null && _nextDiscount$config !== void 0 && _nextDiscount$config.isAvailable)) {
|
|
1572
|
-
return false;
|
|
1573
|
-
}
|
|
1574
|
-
}
|
|
1575
|
-
// 折扣卡时总价为0时不可用
|
|
1576
|
-
if ((Number(product.total) <= 0 || !product.total) && !((_product$discount_lis10 = product.discount_list) !== null && _product$discount_lis10 !== void 0 && _product$discount_lis10.find(function (n) {
|
|
1577
|
-
var _n$discount2;
|
|
1578
|
-
return ((_n$discount2 = n.discount) === null || _n$discount2 === void 0 ? void 0 : _n$discount2.resource_id) === nextDiscount.id;
|
|
1579
|
-
})) && nextDiscountType !== 'good_pass') return false;
|
|
1580
|
-
|
|
1581
|
-
// 商品券已被使用则跳过
|
|
1582
|
-
if (usedDiscounts.get(nextDiscount.id) && nextDiscountType === 'good_pass') return false;
|
|
1583
|
-
|
|
1584
|
-
// 检查 maxUsagePerOrder 限制
|
|
1585
|
-
if (nextDiscountType === 'good_pass') {
|
|
1586
|
-
var _nextDiscount$config2;
|
|
1587
|
-
var maxUsagePerOrder = (_nextDiscount$config2 = nextDiscount.config) === null || _nextDiscount$config2 === void 0 ? void 0 : _nextDiscount$config2.maxUsagePerOrder;
|
|
1588
|
-
if (maxUsagePerOrder && maxUsagePerOrder > 0) {
|
|
1589
|
-
var currentUsedCount = usedProductIdCounts.get(nextDiscount.product_id) || 0;
|
|
1590
|
-
if (currentUsedCount >= maxUsagePerOrder) {
|
|
1591
|
-
return false;
|
|
1592
|
-
}
|
|
1593
|
-
}
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1596
|
-
// 检查折扣卡的 applicableProductLimit 限制
|
|
1597
|
-
if (['discount_card', 'product_discount_card'].includes(nextDiscountType)) {
|
|
1598
|
-
var _nextDiscount$config3;
|
|
1599
|
-
var limitConfig = ((_nextDiscount$config3 = nextDiscount.config) === null || _nextDiscount$config3 === void 0 ? void 0 : _nextDiscount$config3.applicableProductLimit) || 0;
|
|
1600
|
-
if (limitConfig > 0) {
|
|
1601
|
-
var currentUsedLimitCount = usedDiscountCardLimitCounts.get(nextDiscount.id) || 0;
|
|
1602
|
-
if (currentUsedLimitCount >= limitConfig) {
|
|
1603
|
-
return false;
|
|
1604
|
-
}
|
|
1605
|
-
}
|
|
1606
|
-
}
|
|
1607
|
-
var limitedData = nextDiscount.limited_relation_product_data;
|
|
1608
|
-
if (limitedData.type === 'product_all') {
|
|
1609
|
-
if (limitedData.filter === 1 && limitedData.exclude_product_ids.includes(product.id)) {
|
|
1610
|
-
return false;
|
|
1611
|
-
}
|
|
1612
|
-
if (!_this3.checkPackageSubItemUsageRules(nextDiscount, flatItem)) {
|
|
1613
|
-
return false;
|
|
1614
|
-
}
|
|
1615
|
-
return true;
|
|
1616
|
-
} else if (limitedData.product_ids && limitedData.product_ids.includes(product.id)) {
|
|
1617
|
-
if (!_this3.checkPackageSubItemUsageRules(nextDiscount, flatItem)) {
|
|
1618
|
-
return false;
|
|
1619
|
-
}
|
|
1620
|
-
return true;
|
|
1621
|
-
}
|
|
1622
|
-
return false;
|
|
1623
|
-
});
|
|
1624
|
-
|
|
1625
|
-
// 没有更多可用折扣,剩余商品无折扣存储
|
|
1626
|
-
if (nextApplicableDiscounts.length === 0) {
|
|
1627
|
-
processedItems.push(_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
1628
|
-
_id: "".concat(flatItem._id, "_split_rest"),
|
|
1629
|
-
num: remainingNum,
|
|
1630
|
-
quantity: remainingNum,
|
|
1631
|
-
discount_list: [],
|
|
1632
|
-
processed: true
|
|
1633
|
-
}));
|
|
1634
|
-
break;
|
|
1635
|
-
}
|
|
1636
|
-
|
|
1637
|
-
// 选择最优折扣
|
|
1638
|
-
var nextSelectedDiscountCard = nextApplicableDiscounts.find(function (n) {
|
|
1639
|
-
return n.isScan && n.isSelected && (n.tag || n.type) !== 'good_pass';
|
|
1640
|
-
});
|
|
1641
|
-
var nextSelectedDiscount = nextSelectedDiscountCard || nextApplicableDiscounts[0];
|
|
1642
|
-
|
|
1643
|
-
// 判断新折扣是否需要拆分
|
|
1644
|
-
var nextDiscType = nextSelectedDiscount.tag || nextSelectedDiscount.type;
|
|
1645
|
-
var nextIsGoodPass = nextDiscType === 'good_pass';
|
|
1646
|
-
var nextIsDiscountCard = ['discount_card', 'product_discount_card'].includes(nextDiscType);
|
|
1647
|
-
var nextApplicableProductLimit = ((_nextSelectedDiscount = nextSelectedDiscount.config) === null || _nextSelectedDiscount === void 0 ? void 0 : _nextSelectedDiscount.applicableProductLimit) || 0;
|
|
1648
|
-
var nextIsNeedSplit = nextIsGoodPass || nextIsDiscountCard && nextApplicableProductLimit > 0;
|
|
1649
|
-
if (!nextIsNeedSplit) {
|
|
1650
|
-
var _nextBundleDiscount$m, _flatItem$parentProdu9;
|
|
1651
|
-
// 🔥 不需要拆分:直接应用折扣到所有剩余商品
|
|
1652
|
-
var nextBundleDiscount = nextSelectedDiscountCard || nextApplicableDiscounts[0];
|
|
1653
|
-
usedDiscounts.set(nextBundleDiscount.id, true);
|
|
1654
|
-
if ((nextBundleDiscount.tag || nextBundleDiscount.type) === 'good_pass') {
|
|
1655
|
-
var curCount = usedProductIdCounts.get(nextBundleDiscount.product_id) || 0;
|
|
1656
|
-
usedProductIdCounts.set(nextBundleDiscount.product_id, curCount + 1);
|
|
1657
|
-
}
|
|
1658
|
-
var nextNoSplitType = nextBundleDiscount.tag || nextBundleDiscount.type;
|
|
1659
|
-
if (['discount_card', 'product_discount_card'].includes(nextNoSplitType)) {
|
|
1660
|
-
var _curCount = usedDiscountCardLimitCounts.get(nextBundleDiscount.id) || 0;
|
|
1661
|
-
usedDiscountCardLimitCounts.set(nextBundleDiscount.id, _curCount + remainingNum);
|
|
1662
|
-
}
|
|
1663
|
-
var nextOriginTotal = product.original_price || product.price || 0;
|
|
1664
|
-
var nextTargetTotal = getDiscountAmount(nextBundleDiscount, nextOriginTotal, nextOriginTotal);
|
|
1665
|
-
var nextDiscountAmount = new Decimal(nextOriginTotal).minus(nextTargetTotal).toNumber();
|
|
1666
|
-
var nextUniqueId = "".concat(flatItem._id, "_split_").concat(continueSplitIndex);
|
|
1667
|
-
var nextBundleDiscType = nextBundleDiscount.tag === 'product_discount_card' ? 'discount_card' : nextBundleDiscount.tag;
|
|
1668
|
-
var nextDiscountDetail = {
|
|
1669
|
-
amount: nextDiscountAmount * remainingNum,
|
|
1670
|
-
type: nextBundleDiscType,
|
|
1671
|
-
discount: {
|
|
1672
|
-
discount_card_type: nextBundleDiscount === null || nextBundleDiscount === void 0 || (_nextBundleDiscount$m = nextBundleDiscount.metadata) === null || _nextBundleDiscount$m === void 0 ? void 0 : _nextBundleDiscount$m.discount_card_type,
|
|
1673
|
-
fixed_amount: nextDiscountAmount,
|
|
1674
|
-
resource_id: nextBundleDiscount.id,
|
|
1675
|
-
title: nextBundleDiscount.format_title,
|
|
1676
|
-
original_amount: product.original_price,
|
|
1677
|
-
product_id: product.id,
|
|
1678
|
-
percent: nextBundleDiscount.par_value,
|
|
1679
|
-
discount_product_id: nextBundleDiscount.product_id
|
|
1680
|
-
},
|
|
1681
|
-
metadata: {
|
|
1682
|
-
custom_product_bundle_map_id: nextUniqueId,
|
|
1683
|
-
num: remainingNum
|
|
1684
|
-
},
|
|
1685
|
-
config: nextBundleDiscount === null || nextBundleDiscount === void 0 ? void 0 : nextBundleDiscount.config,
|
|
1686
|
-
_num: remainingNum * ((flatItem === null || flatItem === void 0 || (_flatItem$parentProdu9 = flatItem.parentProduct) === null || _flatItem$parentProdu9 === void 0 ? void 0 : _flatItem$parentProdu9.num) || 1)
|
|
1687
|
-
};
|
|
1688
|
-
var nextAppliedProducts = appliedDiscountProducts.get(nextBundleDiscount.id) || [];
|
|
1689
|
-
nextAppliedProducts.push(nextDiscountDetail);
|
|
1690
|
-
appliedDiscountProducts.set(nextBundleDiscount.id, nextAppliedProducts);
|
|
1691
|
-
processedItems.push(_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
1692
|
-
_id: nextUniqueId,
|
|
1693
|
-
num: remainingNum,
|
|
1694
|
-
quantity: remainingNum,
|
|
1695
|
-
total: nextTargetTotal,
|
|
1696
|
-
price: new Decimal(nextOriginTotal || 0).minus(nextDiscountDetail.discount.fixed_amount).toNumber(),
|
|
1697
|
-
discount_list: [nextDiscountDetail],
|
|
1698
|
-
processed: true
|
|
1699
|
-
}));
|
|
1700
|
-
remainingNum = 0;
|
|
1701
|
-
break;
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
|
-
// 🔥 需要拆分:计算最大使用次数
|
|
1705
|
-
var nextMaxUsageLimit = void 0;
|
|
1706
|
-
if (nextIsGoodPass) {
|
|
1707
|
-
var _nextSelectedDiscount2;
|
|
1708
|
-
var nextGoodPassCount = nextApplicableDiscounts.filter(function (item) {
|
|
1709
|
-
return (item.tag || item.type) === 'good_pass';
|
|
1710
|
-
}).length;
|
|
1711
|
-
nextMaxUsageLimit = nextGoodPassCount;
|
|
1712
|
-
if ((_nextSelectedDiscount2 = nextSelectedDiscount.config) !== null && _nextSelectedDiscount2 !== void 0 && _nextSelectedDiscount2.maxUsagePerOrder) {
|
|
1713
|
-
var usedCount = usedProductIdCounts.get(nextSelectedDiscount.product_id) || 0;
|
|
1714
|
-
nextMaxUsageLimit = Math.min(nextGoodPassCount, Math.max(0, nextSelectedDiscount.config.maxUsagePerOrder - usedCount));
|
|
1715
|
-
}
|
|
1716
|
-
} else if (nextIsDiscountCard && nextApplicableProductLimit > 0) {
|
|
1717
|
-
var _usedLimitCount = usedDiscountCardLimitCounts.get(nextSelectedDiscount.id) || 0;
|
|
1718
|
-
nextMaxUsageLimit = Math.max(0, nextApplicableProductLimit - _usedLimitCount);
|
|
1719
|
-
} else {
|
|
1720
|
-
nextMaxUsageLimit = 1;
|
|
1721
|
-
}
|
|
1722
|
-
var nextSplitCount = Math.min(remainingNum, nextMaxUsageLimit);
|
|
1723
|
-
if (nextSplitCount === 0) {
|
|
1724
|
-
// 已达使用上限,剩余商品无折扣存储
|
|
1725
|
-
processedItems.push(_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
1726
|
-
_id: "".concat(flatItem._id, "_split_rest"),
|
|
1727
|
-
num: remainingNum,
|
|
1728
|
-
quantity: remainingNum,
|
|
1729
|
-
discount_list: [],
|
|
1730
|
-
processed: true
|
|
1731
|
-
}));
|
|
1732
|
-
break;
|
|
1733
|
-
}
|
|
1734
|
-
|
|
1735
|
-
// 生成有折扣的商品
|
|
1736
|
-
for (var j = 0; j < nextSplitCount; j++) {
|
|
1737
|
-
var _nextBundleDiscount$m2;
|
|
1738
|
-
var _nextBundleDiscount = nextIsGoodPass ? nextSelectedDiscountCard || nextApplicableDiscounts[j] : nextSelectedDiscountCard || nextApplicableDiscounts[0];
|
|
1739
|
-
usedDiscounts.set(_nextBundleDiscount.id, true);
|
|
1740
|
-
if ((_nextBundleDiscount.tag || _nextBundleDiscount.type) === 'good_pass') {
|
|
1741
|
-
var _curCount2 = usedProductIdCounts.get(_nextBundleDiscount.product_id) || 0;
|
|
1742
|
-
usedProductIdCounts.set(_nextBundleDiscount.product_id, _curCount2 + 1);
|
|
1743
|
-
}
|
|
1744
|
-
var nextBundleDiscTypeForCount = _nextBundleDiscount.tag || _nextBundleDiscount.type;
|
|
1745
|
-
if (['discount_card', 'product_discount_card'].includes(nextBundleDiscTypeForCount)) {
|
|
1746
|
-
var curLimitCount = usedDiscountCardLimitCounts.get(_nextBundleDiscount.id) || 0;
|
|
1747
|
-
usedDiscountCardLimitCounts.set(_nextBundleDiscount.id, curLimitCount + 1);
|
|
1748
|
-
}
|
|
1749
|
-
var _nextUniqueId = "".concat(flatItem._id, "_split_").concat(continueSplitIndex);
|
|
1750
|
-
var nextDiscountedPrice = getDiscountAmount(_nextBundleDiscount, product.origin_total, product.origin_total);
|
|
1751
|
-
var nextBundleDiscAmount = new Decimal(product.origin_total || 0).minus(nextDiscountedPrice).toNumber();
|
|
1752
|
-
var nextBundleDiscTypeStr = _nextBundleDiscount.tag === 'product_discount_card' ? 'discount_card' : _nextBundleDiscount.tag;
|
|
1753
|
-
var _nextDiscountDetail = {
|
|
1754
|
-
amount: nextBundleDiscAmount,
|
|
1755
|
-
type: nextBundleDiscTypeStr,
|
|
1756
|
-
discount: {
|
|
1757
|
-
discount_card_type: _nextBundleDiscount === null || _nextBundleDiscount === void 0 || (_nextBundleDiscount$m2 = _nextBundleDiscount.metadata) === null || _nextBundleDiscount$m2 === void 0 ? void 0 : _nextBundleDiscount$m2.discount_card_type,
|
|
1758
|
-
fixed_amount: nextBundleDiscAmount,
|
|
1759
|
-
resource_id: _nextBundleDiscount.id,
|
|
1760
|
-
title: _nextBundleDiscount.format_title,
|
|
1761
|
-
original_amount: product.origin_total,
|
|
1762
|
-
product_id: product.id,
|
|
1763
|
-
percent: _nextBundleDiscount.par_value,
|
|
1764
|
-
discount_product_id: _nextBundleDiscount.product_id
|
|
1765
|
-
},
|
|
1766
|
-
metadata: {
|
|
1767
|
-
custom_product_bundle_map_id: _nextUniqueId,
|
|
1768
|
-
num: 1
|
|
1769
|
-
},
|
|
1770
|
-
_num: 1,
|
|
1771
|
-
config: _nextBundleDiscount === null || _nextBundleDiscount === void 0 ? void 0 : _nextBundleDiscount.config
|
|
1772
|
-
};
|
|
1773
|
-
var _nextAppliedProducts = appliedDiscountProducts.get(_nextBundleDiscount.id) || [];
|
|
1774
|
-
_nextAppliedProducts.push(_nextDiscountDetail);
|
|
1775
|
-
appliedDiscountProducts.set(_nextBundleDiscount.id, _nextAppliedProducts);
|
|
1776
|
-
processedItems.push(_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
1777
|
-
_id: _nextUniqueId,
|
|
1778
|
-
num: 1,
|
|
1779
|
-
quantity: 1,
|
|
1780
|
-
price: nextDiscountedPrice,
|
|
1781
|
-
total: nextDiscountedPrice,
|
|
1782
|
-
discount_list: [_nextDiscountDetail],
|
|
1783
|
-
processed: true,
|
|
1784
|
-
_discountId: _nextBundleDiscount.id
|
|
1785
|
-
}));
|
|
1786
|
-
continueSplitIndex++;
|
|
1787
|
-
}
|
|
1788
|
-
remainingNum -= nextSplitCount;
|
|
1570
|
+
// 生成无折扣的商品(剩余数量)
|
|
1571
|
+
if (normalNum > 0) {
|
|
1572
|
+
processedItems.push(_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
1573
|
+
// 🔥 为剩余商品生成唯一的 _id
|
|
1574
|
+
_id: "".concat(flatItem._id, "_split_rest"),
|
|
1575
|
+
num: normalNum,
|
|
1576
|
+
quantity: normalNum,
|
|
1577
|
+
discount_list: _this3.filterDiscountListByType(flatItem.discount_list, 'promotion'),
|
|
1578
|
+
processed: true
|
|
1579
|
+
}));
|
|
1789
1580
|
}
|
|
1790
1581
|
} else {
|
|
1791
|
-
var
|
|
1792
|
-
//
|
|
1793
|
-
var
|
|
1794
|
-
usedDiscounts.set(
|
|
1795
|
-
// 🔥 更新 product_id
|
|
1796
|
-
if ((
|
|
1797
|
-
var _currentCount2 = usedProductIdCounts.get(
|
|
1798
|
-
usedProductIdCounts.set(
|
|
1799
|
-
}
|
|
1800
|
-
// 🔥 更新折扣卡 applicableProductLimit 使用计数(不拆分时按商品数量计数)
|
|
1801
|
-
var noSplitDiscountType = _currentBundleDiscount.tag || _currentBundleDiscount.type;
|
|
1802
|
-
if (['discount_card', 'product_discount_card'].includes(noSplitDiscountType)) {
|
|
1803
|
-
var bundleQuantity = product.num || 1;
|
|
1804
|
-
var currentNoSplitCount = usedDiscountCardLimitCounts.get(_currentBundleDiscount.id) || 0;
|
|
1805
|
-
usedDiscountCardLimitCounts.set(_currentBundleDiscount.id, currentNoSplitCount + bundleQuantity);
|
|
1582
|
+
var _selectedDiscount3$me, _selectedDiscount3$me2, _flatItem$parentProdu9;
|
|
1583
|
+
// 折扣卡:不拆分数量,直接应用
|
|
1584
|
+
var _selectedDiscount3 = selectedDiscountCard || applicableDiscounts[0];
|
|
1585
|
+
usedDiscounts.set(_selectedDiscount3.id, true);
|
|
1586
|
+
// 🔥 更新 product_id 使用计数(虽然此处主要是折扣卡,但保持一致性)
|
|
1587
|
+
if ((_selectedDiscount3.tag || _selectedDiscount3.type) === 'good_pass') {
|
|
1588
|
+
var _currentCount2 = usedProductIdCounts.get(_selectedDiscount3.product_id) || 0;
|
|
1589
|
+
usedProductIdCounts.set(_selectedDiscount3.product_id, _currentCount2 + 1);
|
|
1806
1590
|
}
|
|
1807
1591
|
var _productOriginTotal = product.original_price || product.price || 0;
|
|
1808
1592
|
|
|
1809
1593
|
// 🔥 检查是否是 order_level 固定金额折扣卡
|
|
1810
|
-
var _isOrderLevel = isOrderLevelFixedAmountDiscount(
|
|
1811
|
-
var _orderLevelAllocation = _isOrderLevel ? orderLevelDiscountAllocations.get(
|
|
1594
|
+
var _isOrderLevel = isOrderLevelFixedAmountDiscount(_selectedDiscount3);
|
|
1595
|
+
var _orderLevelAllocation = _isOrderLevel ? orderLevelDiscountAllocations.get(_selectedDiscount3.id) : null;
|
|
1812
1596
|
var _productAllocation = _orderLevelAllocation === null || _orderLevelAllocation === void 0 ? void 0 : _orderLevelAllocation.get(flatItem._id);
|
|
1813
1597
|
var targetProductTotal;
|
|
1814
1598
|
var fixedAmountPerItem;
|
|
@@ -1820,45 +1604,43 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1820
1604
|
targetProductTotal = Math.max(new Decimal(_productOriginTotal).minus(fixedAmountPerItem).toNumber(), 0);
|
|
1821
1605
|
} else {
|
|
1822
1606
|
// item_level 或其他类型:使用原有逻辑
|
|
1823
|
-
targetProductTotal = getDiscountAmount(
|
|
1607
|
+
targetProductTotal = getDiscountAmount(_selectedDiscount3, _productOriginTotal, _productOriginTotal);
|
|
1824
1608
|
fixedAmountPerItem = new Decimal(_productOriginTotal).minus(targetProductTotal).toNumber();
|
|
1825
1609
|
}
|
|
1826
1610
|
|
|
1827
|
-
// 计算实际折扣金额
|
|
1828
|
-
var bundleActualDiscountAmount = new Decimal(_productOriginTotal).minus(targetProductTotal).toNumber();
|
|
1829
|
-
|
|
1830
1611
|
// 🔥 使用当前的 _id 作为唯一标识
|
|
1831
1612
|
var _uniqueId = flatItem._id;
|
|
1613
|
+
debugger;
|
|
1832
1614
|
var _discountDetail2 = {
|
|
1833
|
-
amount:
|
|
1834
|
-
type:
|
|
1615
|
+
amount: fixedAmountPerItem * (product.num || 1),
|
|
1616
|
+
type: _selectedDiscount3.tag === 'product_discount_card' ? 'discount_card' : _selectedDiscount3.tag,
|
|
1835
1617
|
discount: {
|
|
1836
|
-
discount_card_type:
|
|
1837
|
-
fixed_amount:
|
|
1838
|
-
discount_calculation_mode:
|
|
1839
|
-
resource_id:
|
|
1840
|
-
title:
|
|
1618
|
+
discount_card_type: _selectedDiscount3 === null || _selectedDiscount3 === void 0 || (_selectedDiscount3$me = _selectedDiscount3.metadata) === null || _selectedDiscount3$me === void 0 ? void 0 : _selectedDiscount3$me.discount_card_type,
|
|
1619
|
+
fixed_amount: fixedAmountPerItem,
|
|
1620
|
+
discount_calculation_mode: _selectedDiscount3 === null || _selectedDiscount3 === void 0 || (_selectedDiscount3$me2 = _selectedDiscount3.metadata) === null || _selectedDiscount3$me2 === void 0 ? void 0 : _selectedDiscount3$me2.discount_calculation_mode,
|
|
1621
|
+
resource_id: _selectedDiscount3.id,
|
|
1622
|
+
title: _selectedDiscount3.format_title,
|
|
1841
1623
|
original_amount: product.original_price,
|
|
1842
|
-
product_id: product.id,
|
|
1843
|
-
percent:
|
|
1844
|
-
discount_product_id:
|
|
1624
|
+
product_id: product.id || product.product_id,
|
|
1625
|
+
percent: _selectedDiscount3.par_value,
|
|
1626
|
+
discount_product_id: _selectedDiscount3.product_id
|
|
1845
1627
|
},
|
|
1846
1628
|
metadata: _objectSpread({
|
|
1847
1629
|
// 🔥 使用唯一的 _id
|
|
1848
1630
|
custom_product_bundle_map_id: _uniqueId,
|
|
1849
|
-
discount_rule_uncheck_flag:
|
|
1631
|
+
discount_rule_uncheck_flag: _selectedDiscount3 === null || _selectedDiscount3 === void 0 ? void 0 : _selectedDiscount3.discount_rule_uncheck_flag,
|
|
1850
1632
|
num: product.num || 1
|
|
1851
1633
|
}, _productDiscountDifference !== undefined && {
|
|
1852
1634
|
product_discount_difference: _productDiscountDifference
|
|
1853
1635
|
}),
|
|
1854
|
-
config:
|
|
1855
|
-
_num: (product.num || 1) * ((flatItem === null || flatItem === void 0 || (_flatItem$
|
|
1636
|
+
config: _selectedDiscount3 === null || _selectedDiscount3 === void 0 ? void 0 : _selectedDiscount3.config,
|
|
1637
|
+
_num: (product.num || 1) * ((flatItem === null || flatItem === void 0 || (_flatItem$parentProdu9 = flatItem.parentProduct) === null || _flatItem$parentProdu9 === void 0 ? void 0 : _flatItem$parentProdu9.num) || 1)
|
|
1856
1638
|
};
|
|
1857
1639
|
|
|
1858
1640
|
// 记录实际应用的折扣
|
|
1859
|
-
var _appliedProducts2 = appliedDiscountProducts.get(
|
|
1641
|
+
var _appliedProducts2 = appliedDiscountProducts.get(_selectedDiscount3.id) || [];
|
|
1860
1642
|
_appliedProducts2.push(_discountDetail2);
|
|
1861
|
-
appliedDiscountProducts.set(
|
|
1643
|
+
appliedDiscountProducts.set(_selectedDiscount3.id, _appliedProducts2);
|
|
1862
1644
|
processedItems.push(_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
1863
1645
|
total: targetProductTotal,
|
|
1864
1646
|
price: new Decimal(_productOriginTotal || 0).minus(fixedAmountPerItem).toNumber(),
|
|
@@ -1986,7 +1768,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1986
1768
|
product_id: bundleItem.product_id,
|
|
1987
1769
|
price: item.price,
|
|
1988
1770
|
num: item.num,
|
|
1989
|
-
quantity: item.num,
|
|
1990
1771
|
discount_list: updatedDiscountList
|
|
1991
1772
|
}));
|
|
1992
1773
|
});
|
|
@@ -2010,7 +1791,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2010
1791
|
product_id: bundleItem.product_id,
|
|
2011
1792
|
price: item.price,
|
|
2012
1793
|
num: item.num,
|
|
2013
|
-
quantity: item.num,
|
|
2014
1794
|
discount_list: _updatedDiscountList
|
|
2015
1795
|
}));
|
|
2016
1796
|
} else {
|
|
@@ -2025,8 +1805,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2025
1805
|
|
|
2026
1806
|
// 🔥 更新主商品自己的 discount_list 中的 num(quantity=1)
|
|
2027
1807
|
var updatedMainDiscountList = mainProductData.discount_list.map(function (discount) {
|
|
2028
|
-
var _discount$
|
|
2029
|
-
if (discount !== null && discount !== void 0 && (_discount$
|
|
1808
|
+
var _discount$metadata6, _discount$metadata7;
|
|
1809
|
+
if (discount !== null && discount !== void 0 && (_discount$metadata6 = discount.metadata) !== null && _discount$metadata6 !== void 0 && _discount$metadata6.custom_product_bundle_map_id) {
|
|
2030
1810
|
// bundle的discount_list保持不变
|
|
2031
1811
|
return discount;
|
|
2032
1812
|
}
|
|
@@ -2034,7 +1814,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2034
1814
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
2035
1815
|
// num: 1,
|
|
2036
1816
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
2037
|
-
custom_product_bundle_map_id: discount === null || discount === void 0 || (_discount$
|
|
1817
|
+
custom_product_bundle_map_id: discount === null || discount === void 0 || (_discount$metadata7 = discount.metadata) === null || _discount$metadata7 === void 0 ? void 0 : _discount$metadata7.custom_product_bundle_map_id,
|
|
2038
1818
|
num: 1
|
|
2039
1819
|
})
|
|
2040
1820
|
});
|
|
@@ -2099,8 +1879,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2099
1879
|
|
|
2100
1880
|
// 🔥 更新主商品自己的 discount_list 中的 num(quantity=原quantity-1)
|
|
2101
1881
|
var updatedMainDiscountListOriginal = mainProductData.discount_list.map(function (discount) {
|
|
2102
|
-
var _discount$
|
|
2103
|
-
if (discount !== null && discount !== void 0 && (_discount$
|
|
1882
|
+
var _discount$metadata8, _discount$metadata9;
|
|
1883
|
+
if (discount !== null && discount !== void 0 && (_discount$metadata8 = discount.metadata) !== null && _discount$metadata8 !== void 0 && _discount$metadata8.custom_product_bundle_map_id) {
|
|
2104
1884
|
// bundle的discount_list保持不变
|
|
2105
1885
|
return discount;
|
|
2106
1886
|
}
|
|
@@ -2108,7 +1888,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2108
1888
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
2109
1889
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
2110
1890
|
num: mainProductQuantity - 1,
|
|
2111
|
-
custom_product_bundle_map_id: discount === null || discount === void 0 || (_discount$
|
|
1891
|
+
custom_product_bundle_map_id: discount === null || discount === void 0 || (_discount$metadata9 = discount.metadata) === null || _discount$metadata9 === void 0 ? void 0 : _discount$metadata9.custom_product_bundle_map_id
|
|
2112
1892
|
})
|
|
2113
1893
|
// num: mainProductQuantity - 1,
|
|
2114
1894
|
});
|
|
@@ -2158,7 +1938,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2158
1938
|
} else {
|
|
2159
1939
|
// 🔥 没有子商品被拆分,使用原有逻辑
|
|
2160
1940
|
mainProductArr.forEach(function (mainProduct) {
|
|
2161
|
-
var _mainProductData$disc, _mainProductData$disc2, _mainProductData$disc3;
|
|
1941
|
+
var _ref15, _mainProductData$main, _mainProductData$disc, _mainProductData$disc2, _mainProductData$disc3;
|
|
2162
1942
|
var mainProductData = _this3.hooks.getProduct(mainProduct);
|
|
2163
1943
|
|
|
2164
1944
|
// 重组bundle
|
|
@@ -2173,13 +1953,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2173
1953
|
} else {
|
|
2174
1954
|
// 🔥 关键:拆分后的bundle item
|
|
2175
1955
|
processedBundleItems.forEach(function (item) {
|
|
1956
|
+
var _item$price, _ref14, _item$bundle_selling_;
|
|
1957
|
+
var nextBundlePrice = (_item$price = item.price) !== null && _item$price !== void 0 ? _item$price : bundleItem.price;
|
|
1958
|
+
var nextBundleSellingPrice = (_ref14 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref14 !== void 0 ? _ref14 : bundleItem.bundle_selling_price;
|
|
2176
1959
|
// 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
|
|
2177
1960
|
var updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
2178
|
-
var _discount$
|
|
1961
|
+
var _discount$metadata10;
|
|
2179
1962
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
2180
1963
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
2181
1964
|
num: item.num,
|
|
2182
|
-
custom_product_bundle_map_id: discount === null || discount === void 0 || (_discount$
|
|
1965
|
+
custom_product_bundle_map_id: discount === null || discount === void 0 || (_discount$metadata10 = discount.metadata) === null || _discount$metadata10 === void 0 ? void 0 : _discount$metadata10.custom_product_bundle_map_id
|
|
2183
1966
|
})
|
|
2184
1967
|
// num: item.num, // 使用拆分后的 num
|
|
2185
1968
|
});
|
|
@@ -2187,18 +1970,20 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2187
1970
|
newBundle.push(_objectSpread(_objectSpread({}, bundleItem), {}, {
|
|
2188
1971
|
_id: item._id,
|
|
2189
1972
|
product_id: bundleItem.product_id,
|
|
2190
|
-
price:
|
|
1973
|
+
price: nextBundlePrice,
|
|
2191
1974
|
num: item.num,
|
|
2192
1975
|
discount_list: updatedDiscountList,
|
|
2193
|
-
bundle_selling_price: bundleItem.bundle_selling_price !== undefined ?
|
|
1976
|
+
bundle_selling_price: bundleItem.bundle_selling_price !== undefined ? nextBundleSellingPrice : undefined
|
|
2194
1977
|
}));
|
|
2195
1978
|
});
|
|
2196
1979
|
}
|
|
2197
1980
|
});
|
|
2198
1981
|
}
|
|
2199
1982
|
|
|
2200
|
-
//
|
|
2201
|
-
|
|
1983
|
+
// 主商品已经在前面的 setProduct 中应用过折扣;这里只替换 bundle,
|
|
1984
|
+
// 避免把主商品 discount_list 再扣一次。
|
|
1985
|
+
var mainSellingPrice = (_ref15 = (_mainProductData$main = mainProductData.main_product_selling_price) !== null && _mainProductData$main !== void 0 ? _mainProductData$main : mainProductData.price) !== null && _ref15 !== void 0 ? _ref15 : 0;
|
|
1986
|
+
var newTotal = Number(mainSellingPrice || 0);
|
|
2202
1987
|
var newOriginTotal = Number(mainProductData.original_price || mainProductData.price || 0);
|
|
2203
1988
|
|
|
2204
1989
|
// 判断是否是手动折扣
|
|
@@ -2212,25 +1997,17 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2212
1997
|
newTotal = (_mainProductData$tota = mainProductData.total) !== null && _mainProductData$tota !== void 0 ? _mainProductData$tota : newTotal;
|
|
2213
1998
|
newOriginTotal = (_mainProductData$orig3 = mainProductData.origin_total) !== null && _mainProductData$orig3 !== void 0 ? _mainProductData$orig3 : newOriginTotal;
|
|
2214
1999
|
} else {
|
|
2215
|
-
//
|
|
2216
|
-
var _mainDiscountList = mainProductData.discount_list.filter(function (item) {
|
|
2217
|
-
var _item$metadata5;
|
|
2218
|
-
return !(item !== null && item !== void 0 && (_item$metadata5 = item.metadata) !== null && _item$metadata5 !== void 0 && _item$metadata5.custom_product_bundle_map_id);
|
|
2219
|
-
});
|
|
2220
|
-
|
|
2221
|
-
// 如果主商品本身有折扣,需要重新计算主商品价格
|
|
2222
|
-
if (_mainDiscountList && _mainDiscountList.length > 0) {
|
|
2223
|
-
var _Decimal$minus$toNumb3, _mainProductData$orig4;
|
|
2224
|
-
var _allDiscountAmount2 = getDiscountListAmount(_mainDiscountList);
|
|
2225
|
-
newTotal = (_Decimal$minus$toNumb3 = new Decimal(mainProductData.price || 0).minus(_allDiscountAmount2).toNumber()) !== null && _Decimal$minus$toNumb3 !== void 0 ? _Decimal$minus$toNumb3 : newTotal;
|
|
2226
|
-
newOriginTotal = (_mainProductData$orig4 = mainProductData.origin_total) !== null && _mainProductData$orig4 !== void 0 ? _mainProductData$orig4 : newOriginTotal;
|
|
2227
|
-
}
|
|
2228
|
-
|
|
2229
|
-
// 累加bundle的价格(只累加一次)
|
|
2000
|
+
// 累加 bundle 的折后价格(只累加一次)
|
|
2230
2001
|
if (newBundle.length > 0) {
|
|
2002
|
+
newBundle.forEach(function (item) {
|
|
2003
|
+
var _item$bundle_selling_2;
|
|
2004
|
+
var bundleSellingPrice = (_item$bundle_selling_2 = item.bundle_selling_price) !== null && _item$bundle_selling_2 !== void 0 ? _item$bundle_selling_2 : item.price;
|
|
2005
|
+
newTotal += Number(bundleSellingPrice) * Number(item.num);
|
|
2006
|
+
});
|
|
2007
|
+
|
|
2008
|
+
// 计算原始总价(不考虑折扣)
|
|
2231
2009
|
newBundle.forEach(function (item) {
|
|
2232
2010
|
var _item$discount_list3;
|
|
2233
|
-
newTotal += Number(item.price) * Number(item.num);
|
|
2234
2011
|
var originalPrice = ((_item$discount_list3 = item.discount_list) === null || _item$discount_list3 === void 0 || (_item$discount_list3 = _item$discount_list3[0]) === null || _item$discount_list3 === void 0 || (_item$discount_list3 = _item$discount_list3.discount) === null || _item$discount_list3 === void 0 ? void 0 : _item$discount_list3.original_amount) || item.price;
|
|
2235
2012
|
newOriginTotal += Number(originalPrice) * Number(item.num);
|
|
2236
2013
|
});
|
|
@@ -2342,6 +2119,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2342
2119
|
}, {
|
|
2343
2120
|
key: "checkPackageSubItemUsageRules",
|
|
2344
2121
|
value: function checkPackageSubItemUsageRules(discount, flatItem) {
|
|
2122
|
+
var _flatItem$product;
|
|
2345
2123
|
var limitedData = discount.limited_relation_product_data;
|
|
2346
2124
|
var usageRules = limitedData === null || limitedData === void 0 ? void 0 : limitedData.package_sub_item_usage_rules;
|
|
2347
2125
|
var rules = ['original_price'].concat(_toConsumableArray((usageRules === null || usageRules === void 0 ? void 0 : usageRules.rules) || []));
|
|
@@ -2353,16 +2131,17 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2353
2131
|
var ruleType = usageRules.type;
|
|
2354
2132
|
// 套餐适用范围配置
|
|
2355
2133
|
var packageScope = usageRules === null || usageRules === void 0 ? void 0 : usageRules.package_scope;
|
|
2356
|
-
var
|
|
2357
|
-
scopeType =
|
|
2358
|
-
|
|
2359
|
-
exclude_bundle_product_ids =
|
|
2360
|
-
|
|
2361
|
-
include_bundle_product_ids =
|
|
2362
|
-
|
|
2363
|
-
filter =
|
|
2134
|
+
var _ref16 = packageScope || {},
|
|
2135
|
+
scopeType = _ref16.type,
|
|
2136
|
+
_ref16$exclude_bundle = _ref16.exclude_bundle_product_ids,
|
|
2137
|
+
exclude_bundle_product_ids = _ref16$exclude_bundle === void 0 ? [] : _ref16$exclude_bundle,
|
|
2138
|
+
_ref16$include_bundle = _ref16.include_bundle_product_ids,
|
|
2139
|
+
include_bundle_product_ids = _ref16$include_bundle === void 0 ? [] : _ref16$include_bundle,
|
|
2140
|
+
_ref16$filter = _ref16.filter,
|
|
2141
|
+
filter = _ref16$filter === void 0 ? 0 : _ref16$filter;
|
|
2364
2142
|
var isMainProduct = flatItem.type === 'main'; // 单独购买
|
|
2365
2143
|
var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
|
|
2144
|
+
var bundleMainProductId = (_flatItem$product = flatItem.product) === null || _flatItem$product === void 0 ? void 0 : _flatItem$product.product_id;
|
|
2366
2145
|
|
|
2367
2146
|
// 主商品直接可用
|
|
2368
2147
|
if (isMainProduct) {
|
|
@@ -2375,12 +2154,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2375
2154
|
return true; // 单独购买时可用
|
|
2376
2155
|
}
|
|
2377
2156
|
if (isBundleItem) {
|
|
2378
|
-
var _flatItem$
|
|
2157
|
+
var _flatItem$bundleItem10, _flatItem$bundleItem11, _flatItem$originProdu, _flatItem$parentProdu10;
|
|
2379
2158
|
// 套餐中购买时,判断是否为原价
|
|
2380
|
-
var priceType = (_flatItem$
|
|
2381
|
-
var priceTypeExt = (_flatItem$
|
|
2159
|
+
var priceType = (_flatItem$bundleItem10 = flatItem.bundleItem) === null || _flatItem$bundleItem10 === void 0 ? void 0 : _flatItem$bundleItem10.price_type;
|
|
2160
|
+
var priceTypeExt = (_flatItem$bundleItem11 = flatItem.bundleItem) === null || _flatItem$bundleItem11 === void 0 ? void 0 : _flatItem$bundleItem11.price_type_ext;
|
|
2382
2161
|
// 主商品id
|
|
2383
|
-
var mainProductId = (flatItem === null || flatItem === void 0 || (_flatItem$originProdu = flatItem.originProduct) === null || _flatItem$originProdu === void 0 || (_flatItem$originProdu = _flatItem$originProdu._productOrigin) === null || _flatItem$originProdu === void 0 ? void 0 : _flatItem$originProdu.id) || (flatItem === null || flatItem === void 0 || (_flatItem$
|
|
2162
|
+
var mainProductId = (flatItem === null || flatItem === void 0 || (_flatItem$originProdu = flatItem.originProduct) === null || _flatItem$originProdu === void 0 || (_flatItem$originProdu = _flatItem$originProdu._productOrigin) === null || _flatItem$originProdu === void 0 ? void 0 : _flatItem$originProdu.id) || (flatItem === null || flatItem === void 0 || (_flatItem$parentProdu10 = flatItem.parentProduct) === null || _flatItem$parentProdu10 === void 0 ? void 0 : _flatItem$parentProdu10.id) || 0;
|
|
2384
2163
|
// original_price 对应:
|
|
2385
2164
|
// 1. price_type: "markup" && price_type_ext: "product_price"
|
|
2386
2165
|
// markup_price 对应:
|
|
@@ -2405,13 +2184,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2405
2184
|
if (!filter) {
|
|
2406
2185
|
isScopeValid = true;
|
|
2407
2186
|
} else {
|
|
2408
|
-
isScopeValid = !exclude_bundle_product_ids.includes(Number(
|
|
2187
|
+
isScopeValid = !exclude_bundle_product_ids.includes(Number(bundleMainProductId));
|
|
2409
2188
|
}
|
|
2410
2189
|
}
|
|
2411
2190
|
|
|
2412
2191
|
// 包含套餐判断, products值兼容旧数据
|
|
2413
2192
|
if (scopeType === 'specific_packages' || scopeType === 'products') {
|
|
2414
|
-
isScopeValid = include_bundle_product_ids.includes(Number(
|
|
2193
|
+
isScopeValid = include_bundle_product_ids.includes(Number(bundleMainProductId));
|
|
2415
2194
|
}
|
|
2416
2195
|
|
|
2417
2196
|
// 价格和套餐适用范围都符合,则可用
|
|
@@ -2445,10 +2224,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2445
2224
|
return false; // 单独购买时不可用
|
|
2446
2225
|
}
|
|
2447
2226
|
if (isBundleItem) {
|
|
2448
|
-
var _flatItem$
|
|
2227
|
+
var _flatItem$bundleItem12, _flatItem$bundleItem13;
|
|
2449
2228
|
// 套餐中购买时,判断是否为原价
|
|
2450
|
-
var _priceType = (_flatItem$
|
|
2451
|
-
var _priceTypeExt = (_flatItem$
|
|
2229
|
+
var _priceType = (_flatItem$bundleItem12 = flatItem.bundleItem) === null || _flatItem$bundleItem12 === void 0 ? void 0 : _flatItem$bundleItem12.price_type;
|
|
2230
|
+
var _priceTypeExt = (_flatItem$bundleItem13 = flatItem.bundleItem) === null || _flatItem$bundleItem13 === void 0 ? void 0 : _flatItem$bundleItem13.price_type_ext;
|
|
2452
2231
|
|
|
2453
2232
|
// original_price 对应:
|
|
2454
2233
|
// 1. price_type: "markup" && price_type_ext: "product_price"
|
|
@@ -2461,16 +2240,43 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2461
2240
|
|
|
2462
2241
|
// 检查 rules
|
|
2463
2242
|
if (rules.length > 0) {
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2243
|
+
var _isOriginalPrice3 = _isOriginalPrice2 && rules.includes('original_price');
|
|
2244
|
+
var _isMarkupPrice3 = _isMarkupPrice2 && rules.includes('markup_price');
|
|
2245
|
+
// 价格是否符合规则:原价或加价
|
|
2246
|
+
var _isPriceValid = _isOriginalPrice3 || _isMarkupPrice3;
|
|
2247
|
+
// 套餐适用范围校验
|
|
2248
|
+
var _isScopeValid = false;
|
|
2249
|
+
|
|
2250
|
+
// 排除套餐判断, product_all值兼容旧数据
|
|
2251
|
+
if (scopeType === 'all_packages' || scopeType === 'product_all') {
|
|
2252
|
+
// 所有套餐可用
|
|
2253
|
+
if (!filter) {
|
|
2254
|
+
_isScopeValid = true;
|
|
2255
|
+
} else {
|
|
2256
|
+
_isScopeValid = !exclude_bundle_product_ids.includes(Number(bundleMainProductId));
|
|
2257
|
+
}
|
|
2467
2258
|
}
|
|
2468
2259
|
|
|
2469
|
-
//
|
|
2470
|
-
if (
|
|
2260
|
+
// 包含套餐判断, products值兼容旧数据
|
|
2261
|
+
if (scopeType === 'specific_packages' || scopeType === 'products') {
|
|
2262
|
+
_isScopeValid = include_bundle_product_ids.includes(Number(bundleMainProductId));
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
// 价格和套餐适用范围都符合,则可用
|
|
2266
|
+
if (_isPriceValid && _isScopeValid) {
|
|
2471
2267
|
return true;
|
|
2472
2268
|
}
|
|
2473
2269
|
|
|
2270
|
+
// 检查原价
|
|
2271
|
+
// if (isOriginalPrice && rules.includes('original_price')) {
|
|
2272
|
+
// return true;
|
|
2273
|
+
// }
|
|
2274
|
+
|
|
2275
|
+
// 检查加价
|
|
2276
|
+
// if (isMarkupPrice && rules.includes('markup_price')) {
|
|
2277
|
+
// return true;
|
|
2278
|
+
// }
|
|
2279
|
+
|
|
2474
2280
|
// 如果都不匹配,则不可用
|
|
2475
2281
|
return false;
|
|
2476
2282
|
}
|
|
@@ -2547,6 +2353,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2547
2353
|
_context3.next = 3;
|
|
2548
2354
|
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
2549
2355
|
case 3:
|
|
2356
|
+
console.log('[Rules] 已销毁');
|
|
2357
|
+
_get(_getPrototypeOf(RulesModule.prototype), "destroy", this).call(this);
|
|
2358
|
+
case 5:
|
|
2550
2359
|
case "end":
|
|
2551
2360
|
return _context3.stop();
|
|
2552
2361
|
}
|
|
@@ -2564,6 +2373,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2564
2373
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
2565
2374
|
while (1) switch (_context4.prev = _context4.next) {
|
|
2566
2375
|
case 0:
|
|
2376
|
+
console.log('[Rules] clear');
|
|
2377
|
+
case 1:
|
|
2567
2378
|
case "end":
|
|
2568
2379
|
return _context4.stop();
|
|
2569
2380
|
}
|