@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
|
@@ -3,10 +3,69 @@ export var OrderHooks = /*#__PURE__*/function (OrderHooks) {
|
|
|
3
3
|
OrderHooks["OnOrderUpdate"] = "order:onOrderUpdate";
|
|
4
4
|
OrderHooks["OnOrderCancel"] = "order:onOrderCancel";
|
|
5
5
|
OrderHooks["OnOrderStatusChange"] = "order:onOrderStatusChange";
|
|
6
|
+
OrderHooks["OnOrderCustomerChange"] = "order:onOrderCustomerChange";
|
|
7
|
+
OrderHooks["OnPromotionApplied"] = "order:onPromotionApplied";
|
|
6
8
|
return OrderHooks;
|
|
7
9
|
}({});
|
|
8
10
|
|
|
9
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* 促销评估器协议(OS 与 PromotionEvaluator 之间的桥接接口)。
|
|
13
|
+
*
|
|
14
|
+
* 与 `pisell_os/src/model/strategy/adapter/promotion/evaluator.ts` 中的
|
|
15
|
+
* `PromotionEvaluator` 实例结构保持兼容。SalesSdkProvider 会从 `appHelper.utils.promotionEvaluator`
|
|
16
|
+
* 读取实例并通过 `setPromotionEvaluator` 注入到 OrderModule。
|
|
17
|
+
*
|
|
18
|
+
* 这里只声明 OrderModule 需要调用的子集,避免反向依赖具体 evaluator 实现。
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** 赠品解析回调 context(OS → SDK 的请求体) */
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 赠品 resolver 返回值。
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* return { products: [giftProduct], bookings: [giftBooking] };
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 赠品解析回调签名(SDK → OS 的返回值)。
|
|
32
|
+
*
|
|
33
|
+
* - 单选项:SDK 内部自动构造商品,不弹窗
|
|
34
|
+
* - 多选项:SDK 弹窗等用户确认后构造
|
|
35
|
+
* - 用户取消:抛错或返回空数组(OS 视为放弃本次添加)
|
|
36
|
+
*
|
|
37
|
+
* 返回数组时沿用旧协议,只写 tempOrder.products;返回对象时可同时写入预约 bookings。
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/** 未满足的促销策略(购物车底部 alert 渲染源) */
|
|
41
|
+
|
|
42
|
+
/** 上一次 applyPromotion 计算出的赠品操作(仅供调试/读取使用) */
|
|
43
|
+
|
|
44
|
+
/** onPromotionApplied 事件 payload */
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* tempOrder 上的下单客户协议字段视图。
|
|
48
|
+
* 这些字段会随订单提交到后端。
|
|
49
|
+
*
|
|
50
|
+
* customer_id 与 OrderTempOrder.customer_id 保持一致(number | null),
|
|
51
|
+
* 调用方若持有 string id(如 ICustomer.id 联合类型),需自行 Number() 转型。
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 写入下单客户的协议字段输入。
|
|
56
|
+
* `customer_id` 必传(null 表示无客户);其余字段缺省视为「清空」(全量覆盖语义)。
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 下单客户变更事件 payload。
|
|
61
|
+
* - `patch`:tempOrder 上的协议字段视图(会随订单提交)
|
|
62
|
+
* - `snapshot`:UI 富字段快照(仅本地,不随订单提交)
|
|
63
|
+
* 清空时整个 payload 为 null。
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
/** 更新购物车行:仅传 SKU 时命中同 SKU 第一行;多行同 SKU 须传 unique_identification_number / 选项指纹等 */
|
|
67
|
+
|
|
68
|
+
/** 仅更新购物车行数量;行定位语义与 updateOrderProduct / removeProductFromOrder 保持一致 */
|
|
10
69
|
|
|
11
70
|
/**
|
|
12
71
|
* 订单信息
|
|
@@ -20,6 +79,14 @@ export var OrderHooks = /*#__PURE__*/function (OrderHooks) {
|
|
|
20
79
|
* Checkout 专用订单创建参数
|
|
21
80
|
*/
|
|
22
81
|
|
|
82
|
+
/**
|
|
83
|
+
* 取消订单参数
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 变更预约状态参数
|
|
88
|
+
*/
|
|
89
|
+
|
|
23
90
|
/**
|
|
24
91
|
* 订单模块 API
|
|
25
92
|
*/
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { OrderProductDiscountItem } from '../types';
|
|
2
|
+
type NormalizeDiscountList = (discountList?: unknown[] | null) => OrderProductDiscountItem[];
|
|
3
|
+
export declare function restoreHydratedBundleDiscounts<T extends Record<string, any>>(product: T, normalizeDiscountList: NormalizeDiscountList): T;
|
|
4
|
+
export declare function expandHydratedProductsForDiscountCollection(products: any[] | undefined | null): any[];
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
12
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
14
|
+
var BUNDLE_MAP_ID_KEY = 'custom_product_bundle_map_id';
|
|
15
|
+
function getBundleMapId(bundle) {
|
|
16
|
+
var _bundle$metadata;
|
|
17
|
+
var metadataMapId = bundle === null || bundle === void 0 || (_bundle$metadata = bundle.metadata) === null || _bundle$metadata === void 0 ? void 0 : _bundle$metadata[BUNDLE_MAP_ID_KEY];
|
|
18
|
+
if (metadataMapId !== undefined && metadataMapId !== null && metadataMapId !== '') {
|
|
19
|
+
return String(metadataMapId);
|
|
20
|
+
}
|
|
21
|
+
if ((bundle === null || bundle === void 0 ? void 0 : bundle._id) !== undefined && bundle._id !== null && bundle._id !== '') {
|
|
22
|
+
return String(bundle._id);
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
function getDiscountBundleMapId(discount) {
|
|
27
|
+
var _discount$metadata;
|
|
28
|
+
var mapId = discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata[BUNDLE_MAP_ID_KEY];
|
|
29
|
+
if (mapId === undefined || mapId === null || mapId === '') return null;
|
|
30
|
+
return String(mapId);
|
|
31
|
+
}
|
|
32
|
+
function hasSameBundleDiscount(discountList, discount) {
|
|
33
|
+
var _ref, _discount$discount$re, _discount$discount;
|
|
34
|
+
var targetOrderDiscountId = discount.order_discount_id;
|
|
35
|
+
if (targetOrderDiscountId !== undefined && targetOrderDiscountId !== null) {
|
|
36
|
+
return discountList.some(function (item) {
|
|
37
|
+
return (item === null || item === void 0 ? void 0 : item.order_discount_id) === targetOrderDiscountId;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
var targetResourceId = (_ref = (_discount$discount$re = discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _discount$discount$re !== void 0 ? _discount$discount$re : discount === null || discount === void 0 ? void 0 : discount.resource_id) !== null && _ref !== void 0 ? _ref : discount === null || discount === void 0 ? void 0 : discount.discount_id;
|
|
41
|
+
var targetMapId = getDiscountBundleMapId(discount);
|
|
42
|
+
return discountList.some(function (item) {
|
|
43
|
+
var _ref2, _item$discount$resour, _item$discount, _item$amount, _discount$amount;
|
|
44
|
+
var resourceId = (_ref2 = (_item$discount$resour = item === null || item === void 0 || (_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.resource_id) !== null && _item$discount$resour !== void 0 ? _item$discount$resour : item === null || item === void 0 ? void 0 : item.resource_id) !== null && _ref2 !== void 0 ? _ref2 : item === null || item === void 0 ? void 0 : item.discount_id;
|
|
45
|
+
return resourceId === targetResourceId && String((_item$amount = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount !== void 0 ? _item$amount : '') === String((_discount$amount = discount === null || discount === void 0 ? void 0 : discount.amount) !== null && _discount$amount !== void 0 ? _discount$amount : '') && getDiscountBundleMapId(item) === targetMapId;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export function restoreHydratedBundleDiscounts(product, normalizeDiscountList) {
|
|
49
|
+
if (!Array.isArray(product.product_bundle) || !Array.isArray(product.discount_list)) {
|
|
50
|
+
return product;
|
|
51
|
+
}
|
|
52
|
+
var bundleByMapId = new Map();
|
|
53
|
+
product.product_bundle.forEach(function (bundle) {
|
|
54
|
+
if (!bundle || _typeof(bundle) !== 'object') return;
|
|
55
|
+
var mapId = getBundleMapId(bundle);
|
|
56
|
+
if (mapId) bundleByMapId.set(mapId, bundle);
|
|
57
|
+
});
|
|
58
|
+
if (!bundleByMapId.size) return product;
|
|
59
|
+
var mainDiscountList = [];
|
|
60
|
+
var bundleDiscounts = [];
|
|
61
|
+
product.discount_list.forEach(function (discount) {
|
|
62
|
+
var mapId = getDiscountBundleMapId(discount);
|
|
63
|
+
if (mapId && bundleByMapId.has(mapId)) {
|
|
64
|
+
bundleDiscounts.push({
|
|
65
|
+
mapId: mapId,
|
|
66
|
+
discount: discount
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
mainDiscountList.push(discount);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
if (!bundleDiscounts.length) return product;
|
|
73
|
+
return _objectSpread(_objectSpread({}, product), {}, {
|
|
74
|
+
discount_list: normalizeDiscountList(mainDiscountList),
|
|
75
|
+
product_bundle: product.product_bundle.map(function (bundle) {
|
|
76
|
+
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
77
|
+
var mapId = getBundleMapId(bundle);
|
|
78
|
+
if (!mapId) return bundle;
|
|
79
|
+
var matchedDiscounts = bundleDiscounts.filter(function (item) {
|
|
80
|
+
return item.mapId === mapId;
|
|
81
|
+
}).map(function (item) {
|
|
82
|
+
return item.discount;
|
|
83
|
+
});
|
|
84
|
+
if (!matchedDiscounts.length) return bundle;
|
|
85
|
+
var currentDiscountList = Array.isArray(bundle.discount_list) ? _toConsumableArray(bundle.discount_list) : [];
|
|
86
|
+
var _iterator = _createForOfIteratorHelper(matchedDiscounts),
|
|
87
|
+
_step;
|
|
88
|
+
try {
|
|
89
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
90
|
+
var discount = _step.value;
|
|
91
|
+
if (!hasSameBundleDiscount(currentDiscountList, discount)) {
|
|
92
|
+
currentDiscountList.push(discount);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
} catch (err) {
|
|
96
|
+
_iterator.e(err);
|
|
97
|
+
} finally {
|
|
98
|
+
_iterator.f();
|
|
99
|
+
}
|
|
100
|
+
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
101
|
+
discount_list: normalizeDiscountList(currentDiscountList),
|
|
102
|
+
metadata: _objectSpread(_objectSpread({}, bundle.metadata || {}), {}, _defineProperty({}, BUNDLE_MAP_ID_KEY, mapId))
|
|
103
|
+
});
|
|
104
|
+
})
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
export function expandHydratedProductsForDiscountCollection(products) {
|
|
108
|
+
var expanded = [];
|
|
109
|
+
var _iterator2 = _createForOfIteratorHelper(products || []),
|
|
110
|
+
_step2;
|
|
111
|
+
try {
|
|
112
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
113
|
+
var product = _step2.value;
|
|
114
|
+
expanded.push(product);
|
|
115
|
+
var _iterator3 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.product_bundle) || []),
|
|
116
|
+
_step3;
|
|
117
|
+
try {
|
|
118
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
119
|
+
var _ref3, _ref4, _bundle$bundle_produc, _ref5, _bundle$num, _ref6, _bundle$quantity, _ref7, _bundle$original_pric, _bundle$bundle_sellin, _bundle$is_charge_tax;
|
|
120
|
+
var bundle = _step3.value;
|
|
121
|
+
if (!Array.isArray(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || bundle.discount_list.length === 0) continue;
|
|
122
|
+
expanded.push(_objectSpread(_objectSpread({}, product), {}, {
|
|
123
|
+
product_id: (_ref3 = (_ref4 = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id) !== null && _ref4 !== void 0 ? _ref4 : bundle.product_id) !== null && _ref3 !== void 0 ? _ref3 : product === null || product === void 0 ? void 0 : product.product_id,
|
|
124
|
+
num: (_ref5 = (_bundle$num = bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle.quantity) !== null && _ref5 !== void 0 ? _ref5 : product === null || product === void 0 ? void 0 : product.num,
|
|
125
|
+
product_quantity: (_ref6 = (_bundle$quantity = bundle.quantity) !== null && _bundle$quantity !== void 0 ? _bundle$quantity : bundle.num) !== null && _ref6 !== void 0 ? _ref6 : product === null || product === void 0 ? void 0 : product.product_quantity,
|
|
126
|
+
original_price: (_ref7 = (_bundle$original_pric = bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle.product_price) !== null && _ref7 !== void 0 ? _ref7 : bundle.price,
|
|
127
|
+
selling_price: (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.price,
|
|
128
|
+
is_charge_tax: (_bundle$is_charge_tax = bundle.is_charge_tax) !== null && _bundle$is_charge_tax !== void 0 ? _bundle$is_charge_tax : product === null || product === void 0 ? void 0 : product.is_charge_tax,
|
|
129
|
+
discount_list: bundle.discount_list
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
} catch (err) {
|
|
133
|
+
_iterator3.e(err);
|
|
134
|
+
} finally {
|
|
135
|
+
_iterator3.f();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
} catch (err) {
|
|
139
|
+
_iterator2.e(err);
|
|
140
|
+
} finally {
|
|
141
|
+
_iterator2.f();
|
|
142
|
+
}
|
|
143
|
+
return expanded;
|
|
144
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/** 解析商品行数量(checkout 协议 product_num 语义 = 当前行 num) */
|
|
2
|
+
export declare function resolveSafeProductNum(num?: number | null): number;
|
|
3
|
+
/**
|
|
4
|
+
* 将 discount_list 中 type=product 项的 product_num 同步为当前商品数量。
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* syncManualProductDiscountProductNum(line.discount_list, line.num);
|
|
8
|
+
*/
|
|
9
|
+
export declare function syncManualProductDiscountProductNum(discountList: any[] | undefined | null, productNum?: number | null): any[];
|
|
10
|
+
/** 从多源解析改价前行总价(与 cacheItem._extend.origin_total 语义一致) */
|
|
11
|
+
export declare function resolveManualDiscountOriginTotal(sources: {
|
|
12
|
+
originTotal?: unknown;
|
|
13
|
+
extendOriginTotal?: unknown;
|
|
14
|
+
originExtendOriginTotal?: unknown;
|
|
15
|
+
sourceExtendOriginTotal?: unknown;
|
|
16
|
+
catalogUnitPrice?: unknown;
|
|
17
|
+
quantity?: number;
|
|
18
|
+
}): number;
|
|
19
|
+
/** 从 payload / extend / origin 解析手动折扣原因 */
|
|
20
|
+
export declare function resolveManualDiscountReasonFromSources(sources: {
|
|
21
|
+
discountReason?: unknown;
|
|
22
|
+
extendDiscountReason?: unknown;
|
|
23
|
+
originExtendDiscountReason?: unknown;
|
|
24
|
+
}): string;
|
|
25
|
+
/** 是否带手动改价标记(price_override / is_manual_discount) */
|
|
26
|
+
export declare function hasManualProductDiscountFlag(metadata?: Record<string, any> | null): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* normalize 兜底:手动改价但 discount_list 缺 type=product 时,按行级原价/折后价补写。
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ensureManualProductDiscountList({
|
|
32
|
+
* discountList: [],
|
|
33
|
+
* metadata: { price_override: '5', is_manual_discount: 1 },
|
|
34
|
+
* originalPrice: '11.00',
|
|
35
|
+
* sellingPrice: '5.00',
|
|
36
|
+
* quantity: 1,
|
|
37
|
+
* });
|
|
38
|
+
*/
|
|
39
|
+
export declare function ensureManualProductDiscountList(params: {
|
|
40
|
+
discountList?: any[] | null;
|
|
41
|
+
metadata?: Record<string, any> | null;
|
|
42
|
+
originalPrice: string | number;
|
|
43
|
+
sellingPrice: string | number;
|
|
44
|
+
quantity?: number;
|
|
45
|
+
}): any[];
|
|
46
|
+
/** 商品手动折扣 discount_list 项(checkout 协议,type = product) */
|
|
47
|
+
export interface ManualProductDiscountItem {
|
|
48
|
+
amount: number;
|
|
49
|
+
type: 'product';
|
|
50
|
+
discount: {
|
|
51
|
+
message: string;
|
|
52
|
+
discountway: string;
|
|
53
|
+
product_num: number;
|
|
54
|
+
discount_per: string;
|
|
55
|
+
discount_type: 'discount' | 'change_price';
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 从 discount_list 中取手动改价项(type = product)。
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* const manual = findManualProductDiscountItem(product.discount_list);
|
|
63
|
+
* manual?.discount.message; // 折扣原因
|
|
64
|
+
*/
|
|
65
|
+
export declare function findManualProductDiscountItem(discountList?: any[] | null): ManualProductDiscountItem | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* 解析折扣原因:优先 discount_list[type=product].discount.message。
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* resolveManualDiscountMessage(line.discount_list, line.metadata?.legacy_reason);
|
|
71
|
+
*/
|
|
72
|
+
export declare function resolveManualDiscountMessage(discountList?: any[] | null, fallback?: string): string;
|
|
73
|
+
/** 去掉 discount_list 中已有的手动改价项,避免重复叠加 */
|
|
74
|
+
export declare function stripManualProductDiscountItems(discountList?: any[] | null): any[];
|
|
75
|
+
/**
|
|
76
|
+
* 由改价前后行总价构建手动折扣项;amount = |originTotal - sellingTotal|(行级差额)。
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* buildManualProductDiscountItem({
|
|
80
|
+
* originTotal: 11,
|
|
81
|
+
* sellingTotal: 4,
|
|
82
|
+
* quantity: 1,
|
|
83
|
+
* message: 'VIP',
|
|
84
|
+
* });
|
|
85
|
+
*/
|
|
86
|
+
export declare function buildManualProductDiscountItem(params: {
|
|
87
|
+
originTotal: number;
|
|
88
|
+
sellingTotal: number;
|
|
89
|
+
quantity?: number;
|
|
90
|
+
message?: string;
|
|
91
|
+
discountway?: string;
|
|
92
|
+
discount_per?: string;
|
|
93
|
+
}): ManualProductDiscountItem;
|
|
94
|
+
/**
|
|
95
|
+
* 将手动改价项合并进 discount_list(替换已有 type=product 项)。
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* mergeManualProductDiscountIntoList(coupons, manualItem);
|
|
99
|
+
*/
|
|
100
|
+
export declare function mergeManualProductDiscountIntoList(discountList: any[] | undefined | null, manualItem: ManualProductDiscountItem | null | undefined): any[];
|
|
101
|
+
/** 是否应写入手动改价 discount_list 项 */
|
|
102
|
+
export declare function shouldBuildManualProductDiscount(params: {
|
|
103
|
+
hasPriceOverride?: boolean;
|
|
104
|
+
originTotal?: number;
|
|
105
|
+
sellingTotal?: number;
|
|
106
|
+
}): boolean;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
12
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
|
+
import Decimal from 'decimal.js';
|
|
14
|
+
|
|
15
|
+
/** 解析商品行数量(checkout 协议 product_num 语义 = 当前行 num) */
|
|
16
|
+
export function resolveSafeProductNum(num) {
|
|
17
|
+
var parsed = Number(num);
|
|
18
|
+
if (!Number.isFinite(parsed) || parsed <= 0) return 1;
|
|
19
|
+
return Math.floor(parsed);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 将 discount_list 中 type=product 项的 product_num 同步为当前商品数量。
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* syncManualProductDiscountProductNum(line.discount_list, line.num);
|
|
27
|
+
*/
|
|
28
|
+
export function syncManualProductDiscountProductNum(discountList, productNum) {
|
|
29
|
+
var quantity = resolveSafeProductNum(productNum);
|
|
30
|
+
return (discountList || []).map(function (item) {
|
|
31
|
+
if ((item === null || item === void 0 ? void 0 : item.type) !== 'product') return item;
|
|
32
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
33
|
+
discount: _objectSpread(_objectSpread({}, item.discount || {}), {}, {
|
|
34
|
+
product_num: quantity
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** 从多源解析改价前行总价(与 cacheItem._extend.origin_total 语义一致) */
|
|
41
|
+
export function resolveManualDiscountOriginTotal(sources) {
|
|
42
|
+
var _sources$quantity;
|
|
43
|
+
var candidates = [sources.originTotal, sources.extendOriginTotal, sources.originExtendOriginTotal, sources.sourceExtendOriginTotal];
|
|
44
|
+
for (var _i = 0, _candidates = candidates; _i < _candidates.length; _i++) {
|
|
45
|
+
var candidate = _candidates[_i];
|
|
46
|
+
if (candidate === undefined || candidate === null || candidate === '') continue;
|
|
47
|
+
var parsed = Number(candidate);
|
|
48
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
49
|
+
}
|
|
50
|
+
var unit = Number(sources.catalogUnitPrice);
|
|
51
|
+
var quantity = (_sources$quantity = sources.quantity) !== null && _sources$quantity !== void 0 ? _sources$quantity : 1;
|
|
52
|
+
if (Number.isFinite(unit) && unit > 0) {
|
|
53
|
+
return new Decimal(unit).mul(quantity).toNumber();
|
|
54
|
+
}
|
|
55
|
+
return NaN;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** 从 payload / extend / origin 解析手动折扣原因 */
|
|
59
|
+
export function resolveManualDiscountReasonFromSources(sources) {
|
|
60
|
+
for (var _i2 = 0, _arr = [sources.discountReason, sources.extendDiscountReason, sources.originExtendDiscountReason]; _i2 < _arr.length; _i2++) {
|
|
61
|
+
var candidate = _arr[_i2];
|
|
62
|
+
if (candidate != null && String(candidate).trim() !== '') {
|
|
63
|
+
return String(candidate);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return '';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** 是否带手动改价标记(price_override / is_manual_discount) */
|
|
70
|
+
export function hasManualProductDiscountFlag(metadata) {
|
|
71
|
+
if (!metadata) return false;
|
|
72
|
+
var override = metadata.price_override;
|
|
73
|
+
if (override !== undefined && override !== null && override !== '') {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
return metadata.is_manual_discount === 1 || metadata.is_manual_discount === true;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* normalize 兜底:手动改价但 discount_list 缺 type=product 时,按行级原价/折后价补写。
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ensureManualProductDiscountList({
|
|
84
|
+
* discountList: [],
|
|
85
|
+
* metadata: { price_override: '5', is_manual_discount: 1 },
|
|
86
|
+
* originalPrice: '11.00',
|
|
87
|
+
* sellingPrice: '5.00',
|
|
88
|
+
* quantity: 1,
|
|
89
|
+
* });
|
|
90
|
+
*/
|
|
91
|
+
export function ensureManualProductDiscountList(params) {
|
|
92
|
+
var _metadata$origin, _metadata$origin2, _metadata$origin3, _metadata$origin4;
|
|
93
|
+
var list = params.discountList || [];
|
|
94
|
+
var quantity = resolveSafeProductNum(params.quantity);
|
|
95
|
+
if (findManualProductDiscountItem(list)) {
|
|
96
|
+
return syncManualProductDiscountProductNum(list, quantity);
|
|
97
|
+
}
|
|
98
|
+
var metadata = params.metadata || {};
|
|
99
|
+
var originalNum = Number(params.originalPrice);
|
|
100
|
+
var sellingNum = Number(params.sellingPrice);
|
|
101
|
+
var hasPriceOverride = hasManualProductDiscountFlag(metadata);
|
|
102
|
+
var shouldBuild = shouldBuildManualProductDiscount({
|
|
103
|
+
hasPriceOverride: hasPriceOverride,
|
|
104
|
+
originTotal: originalNum,
|
|
105
|
+
sellingTotal: sellingNum
|
|
106
|
+
});
|
|
107
|
+
if (!shouldBuild) {
|
|
108
|
+
return list;
|
|
109
|
+
}
|
|
110
|
+
if (!Number.isFinite(originalNum) || !Number.isFinite(sellingNum) || originalNum === sellingNum) {
|
|
111
|
+
return list;
|
|
112
|
+
}
|
|
113
|
+
var message = resolveManualDiscountMessage(list, resolveManualDiscountReasonFromSources({
|
|
114
|
+
extendDiscountReason: (_metadata$origin = metadata.origin) === null || _metadata$origin === void 0 || (_metadata$origin = _metadata$origin._extend) === null || _metadata$origin === void 0 ? void 0 : _metadata$origin.discount_reason,
|
|
115
|
+
originExtendDiscountReason: (_metadata$origin2 = metadata.origin) === null || _metadata$origin2 === void 0 || (_metadata$origin2 = _metadata$origin2._extend) === null || _metadata$origin2 === void 0 ? void 0 : _metadata$origin2.discount_reason
|
|
116
|
+
}));
|
|
117
|
+
return mergeManualProductDiscountIntoList(list, buildManualProductDiscountItem({
|
|
118
|
+
originTotal: originalNum,
|
|
119
|
+
sellingTotal: sellingNum,
|
|
120
|
+
quantity: quantity,
|
|
121
|
+
message: message,
|
|
122
|
+
discountway: (_metadata$origin3 = metadata.origin) === null || _metadata$origin3 === void 0 || (_metadata$origin3 = _metadata$origin3._extend) === null || _metadata$origin3 === void 0 ? void 0 : _metadata$origin3.discountway,
|
|
123
|
+
discount_per: (_metadata$origin4 = metadata.origin) === null || _metadata$origin4 === void 0 || (_metadata$origin4 = _metadata$origin4._extend) === null || _metadata$origin4 === void 0 ? void 0 : _metadata$origin4.discount_per
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** 商品手动折扣 discount_list 项(checkout 协议,type = product) */
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* 从 discount_list 中取手动改价项(type = product)。
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* const manual = findManualProductDiscountItem(product.discount_list);
|
|
134
|
+
* manual?.discount.message; // 折扣原因
|
|
135
|
+
*/
|
|
136
|
+
export function findManualProductDiscountItem(discountList) {
|
|
137
|
+
return (discountList || []).find(function (item) {
|
|
138
|
+
return (item === null || item === void 0 ? void 0 : item.type) === 'product';
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* 解析折扣原因:优先 discount_list[type=product].discount.message。
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* resolveManualDiscountMessage(line.discount_list, line.metadata?.legacy_reason);
|
|
147
|
+
*/
|
|
148
|
+
export function resolveManualDiscountMessage(discountList, fallback) {
|
|
149
|
+
var _findManualProductDis;
|
|
150
|
+
var message = (_findManualProductDis = findManualProductDiscountItem(discountList)) === null || _findManualProductDis === void 0 || (_findManualProductDis = _findManualProductDis.discount) === null || _findManualProductDis === void 0 ? void 0 : _findManualProductDis.message;
|
|
151
|
+
if (message != null && String(message).trim() !== '') {
|
|
152
|
+
return String(message);
|
|
153
|
+
}
|
|
154
|
+
return fallback !== null && fallback !== void 0 ? fallback : '';
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** 去掉 discount_list 中已有的手动改价项,避免重复叠加 */
|
|
158
|
+
export function stripManualProductDiscountItems(discountList) {
|
|
159
|
+
return (discountList || []).filter(function (item) {
|
|
160
|
+
return (item === null || item === void 0 ? void 0 : item.type) !== 'product';
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* 由改价前后行总价构建手动折扣项;amount = |originTotal - sellingTotal|(行级差额)。
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* buildManualProductDiscountItem({
|
|
169
|
+
* originTotal: 11,
|
|
170
|
+
* sellingTotal: 4,
|
|
171
|
+
* quantity: 1,
|
|
172
|
+
* message: 'VIP',
|
|
173
|
+
* });
|
|
174
|
+
*/
|
|
175
|
+
export function buildManualProductDiscountItem(params) {
|
|
176
|
+
var _params$message, _params$discountway, _params$discount_per;
|
|
177
|
+
var origin = new Decimal(Number(params.originTotal) || 0);
|
|
178
|
+
var selling = new Decimal(Number(params.sellingTotal) || 0);
|
|
179
|
+
var diff = origin.minus(selling);
|
|
180
|
+
var quantity = resolveSafeProductNum(params.quantity);
|
|
181
|
+
return {
|
|
182
|
+
amount: diff.toDecimalPlaces(2).toNumber(),
|
|
183
|
+
type: 'product',
|
|
184
|
+
discount: {
|
|
185
|
+
message: (_params$message = params.message) !== null && _params$message !== void 0 ? _params$message : '',
|
|
186
|
+
discountway: (_params$discountway = params.discountway) !== null && _params$discountway !== void 0 ? _params$discountway : 'num',
|
|
187
|
+
product_num: quantity,
|
|
188
|
+
discount_per: (_params$discount_per = params.discount_per) !== null && _params$discount_per !== void 0 ? _params$discount_per : '',
|
|
189
|
+
discount_type: diff.isNegative() ? 'change_price' : 'discount'
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* 将手动改价项合并进 discount_list(替换已有 type=product 项)。
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* mergeManualProductDiscountIntoList(coupons, manualItem);
|
|
199
|
+
*/
|
|
200
|
+
export function mergeManualProductDiscountIntoList(discountList, manualItem) {
|
|
201
|
+
var base = stripManualProductDiscountItems(discountList);
|
|
202
|
+
if (!manualItem) return base;
|
|
203
|
+
if (manualItem.amount === 0 && !manualItem.discount.message) return base;
|
|
204
|
+
return [].concat(_toConsumableArray(base), [manualItem]);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** 是否应写入手动改价 discount_list 项 */
|
|
208
|
+
export function shouldBuildManualProductDiscount(params) {
|
|
209
|
+
return Boolean(params.hasPriceOverride);
|
|
210
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type OrderCollectionKind = 'product' | 'booking' | 'payment';
|
|
2
|
+
export interface OrderCollectionIdentityStats {
|
|
3
|
+
backfilledUidCount: number;
|
|
4
|
+
collapsedDuplicateCount: number;
|
|
5
|
+
uidConflictCount: number;
|
|
6
|
+
anonymousRowCount: number;
|
|
7
|
+
}
|
|
8
|
+
export interface OrderCollectionUidRemap {
|
|
9
|
+
kind: OrderCollectionKind;
|
|
10
|
+
from: string;
|
|
11
|
+
to: string;
|
|
12
|
+
persistentId: string | null;
|
|
13
|
+
/** 默认全局迁移;UID 冲突时只能迁移能由另一侧 UID 明确定位的引用。 */
|
|
14
|
+
scope?: 'global' | 'linked-owner';
|
|
15
|
+
referenceOwnerUid?: string | null;
|
|
16
|
+
}
|
|
17
|
+
export interface NormalizeOrderCollectionResult<T> {
|
|
18
|
+
items: T[];
|
|
19
|
+
stats: OrderCollectionIdentityStats;
|
|
20
|
+
uidRemaps: OrderCollectionUidRemap[];
|
|
21
|
+
}
|
|
22
|
+
export interface NormalizeOrderCollectionsResult<T> {
|
|
23
|
+
order: T;
|
|
24
|
+
stats: Record<OrderCollectionKind, OrderCollectionIdentityStats>;
|
|
25
|
+
uidRemaps: OrderCollectionUidRemap[];
|
|
26
|
+
}
|
|
27
|
+
export declare function createUuidV4(): string;
|
|
28
|
+
export declare function isBlankOrderCollectionIdentity(value: unknown): boolean;
|
|
29
|
+
export declare function getOrderCollectionPersistentId(kind: OrderCollectionKind, item: unknown): string | null;
|
|
30
|
+
export declare function getOrderCollectionUid(kind: OrderCollectionKind, item: unknown): string | null;
|
|
31
|
+
export declare function buildOrderCollectionFallbackUid(kind: OrderCollectionKind, persistentId: string | number): string;
|
|
32
|
+
export declare function getOrderCollectionReferenceUid(kind: OrderCollectionKind, item: unknown): string | null;
|
|
33
|
+
export declare function setOrderCollectionUid<T>(kind: OrderCollectionKind, item: T, uid: string): T;
|
|
34
|
+
/**
|
|
35
|
+
* 持久化行 ID 是服务端事实主键;只有至少一侧尚未持久化时,才允许用 runtime UID 对齐。
|
|
36
|
+
*/
|
|
37
|
+
export declare function isSameOrderCollectionItem(kind: OrderCollectionKind, left: unknown, right: unknown): boolean;
|
|
38
|
+
export declare function mergeOrderCollectionItems<T>(kind: OrderCollectionKind, currentItem: T, incomingItem: T, options?: {
|
|
39
|
+
ensureUid?: boolean;
|
|
40
|
+
createAnonymousUid?: () => string;
|
|
41
|
+
}): T;
|
|
42
|
+
/**
|
|
43
|
+
* 规范化单一数组:强身份重复时保留首次位置、用最后一条业务字段覆盖,并统一补 UID。
|
|
44
|
+
*/
|
|
45
|
+
export declare function normalizeOrderCollection<T>(kind: OrderCollectionKind, items: T[] | null | undefined, options?: {
|
|
46
|
+
ensureUid?: boolean;
|
|
47
|
+
createAnonymousUid?: () => string;
|
|
48
|
+
}): NormalizeOrderCollectionResult<T>;
|
|
49
|
+
export declare function applyOrderCollectionUidRemaps<T extends Record<string, any>>(sourceOrder: T, uidRemaps: OrderCollectionUidRemap[]): T;
|
|
50
|
+
export declare function normalizeOrderCollections<T extends Record<string, any>>(sourceOrder: T, options?: {
|
|
51
|
+
ensureUid?: boolean;
|
|
52
|
+
createAnonymousUid?: () => string;
|
|
53
|
+
}): NormalizeOrderCollectionsResult<T>;
|