@pisell/pisellos 0.0.568 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.js +10 -6
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -3
- package/dist/model/strategy/adapter/promotion/evaluator.js +3 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +7 -5
- package/dist/model/strategy/adapter/walletPass/example.js +26 -3
- package/dist/model/strategy/adapter/walletPass/index.js +5 -5
- package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/dist/model/strategy/adapter/walletPass/utils.js +24 -96
- package/dist/model/strategy/strategy-example.js +19 -5
- package/dist/modules/BaseModule.d.ts +2 -2
- package/dist/modules/BaseModule.js +12 -14
- package/dist/modules/BookingContext/index.d.ts +48 -0
- package/dist/modules/BookingContext/index.js +566 -0
- package/dist/modules/BookingContext/types.d.ts +102 -0
- package/dist/modules/BookingContext/types.js +51 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +302 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +149 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +249 -0
- package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/dist/modules/BookingContext/utils/flexible.js +56 -0
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
- package/dist/modules/BookingContext/utils/index.d.ts +11 -0
- package/dist/modules/BookingContext/utils/index.js +11 -0
- package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/dist/modules/BookingContext/utils/noResource.js +77 -0
- package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/dist/modules/BookingContext/utils/orderLineDisplay.js +36 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/dist/modules/BookingContext/utils/productExtend.js +339 -0
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
- package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
- package/dist/modules/BookingContext/utils/resources.js +486 -0
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
- package/dist/modules/Cart/index.js +3 -0
- package/dist/modules/Cart/utils/cartProduct.js +27 -5
- package/dist/modules/Cart/utils/cartResource.js +0 -2
- package/dist/modules/Cart/utils/changePrice.js +11 -11
- package/dist/modules/Customer/index.d.ts +20 -0
- package/dist/modules/Customer/index.js +172 -83
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Date/index.js +5 -1
- package/dist/modules/Discount/index.d.ts +2 -2
- package/dist/modules/Discount/index.js +43 -30
- package/dist/modules/Discount/types.d.ts +1 -1
- package/dist/modules/OpenData/index.d.ts +8 -0
- package/dist/modules/OpenData/index.js +38 -16
- package/dist/modules/Order/index.d.ts +449 -24
- package/dist/modules/Order/index.js +5460 -574
- package/dist/modules/Order/types.d.ts +693 -88
- package/dist/modules/Order/types.js +68 -1
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/dist/modules/Order/utils/manualProductDiscount.js +210 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
- package/dist/modules/Order/utils.d.ts +167 -18
- package/dist/modules/Order/utils.js +960 -165
- package/dist/modules/Payment/index.d.ts +10 -9
- package/dist/modules/Payment/index.js +573 -746
- package/dist/modules/Payment/types.d.ts +44 -24
- package/dist/modules/Payment/utils.d.ts +1 -1
- package/dist/modules/Payment/utils.js +4 -3
- package/dist/modules/Payment/walletpass.d.ts +0 -2
- package/dist/modules/Payment/walletpass.js +49 -33
- package/dist/modules/Product/types.d.ts +29 -7
- package/dist/modules/ProductList/index.d.ts +17 -13
- package/dist/modules/ProductList/index.js +182 -81
- package/dist/modules/ProductList/types.d.ts +16 -0
- package/dist/modules/Quotation/index.d.ts +22 -2
- package/dist/modules/Quotation/index.js +108 -42
- package/dist/modules/Quotation/types.d.ts +19 -0
- package/dist/modules/ResourcePlanner/index.d.ts +24 -0
- package/dist/modules/ResourcePlanner/index.js +181 -0
- package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
- package/dist/modules/ResourcePlanner/planner.js +1069 -0
- package/dist/modules/ResourcePlanner/types.d.ts +227 -0
- package/dist/modules/ResourcePlanner/types.js +1 -0
- package/dist/modules/Rules/index.d.ts +8 -10
- package/dist/modules/Rules/index.js +324 -513
- package/dist/modules/Rules/types.d.ts +14 -3
- package/dist/modules/SalesSummary/index.d.ts +23 -26
- package/dist/modules/SalesSummary/index.js +152 -46
- package/dist/modules/SalesSummary/types.d.ts +9 -1
- package/dist/modules/SalesSummary/utils.d.ts +3 -22
- package/dist/modules/SalesSummary/utils.js +804 -165
- package/dist/modules/Schedule/getDateIsInSchedule.js +14 -12
- package/dist/modules/Schedule/index.d.ts +18 -5
- package/dist/modules/Schedule/index.js +79 -24
- package/dist/modules/Schedule/types.d.ts +2 -0
- package/dist/modules/Schedule/utils.js +1 -0
- package/dist/modules/Step/index.js +1 -0
- package/dist/modules/Summary/index.js +4 -3
- package/dist/modules/Summary/utils.js +22 -43
- package/dist/modules/SurchargeList/index.d.ts +18 -0
- package/dist/modules/SurchargeList/index.js +185 -0
- package/dist/modules/SurchargeList/types.d.ts +15 -0
- package/dist/modules/SurchargeList/types.js +1 -0
- package/dist/modules/index.d.ts +3 -0
- package/dist/modules/index.js +4 -1
- package/dist/plugins/app.d.ts +2 -0
- package/dist/plugins/request.d.ts +1 -0
- package/dist/plugins/request.js +4 -1
- package/dist/plugins/window.js +6 -2
- package/dist/server/index.d.ts +462 -8
- package/dist/server/index.js +6168 -680
- package/dist/server/modules/floor-plan/index.d.ts +39 -0
- package/dist/server/modules/floor-plan/index.js +595 -0
- package/dist/server/modules/floor-plan/types.d.ts +43 -0
- package/dist/server/modules/floor-plan/types.js +13 -0
- package/dist/server/modules/index.d.ts +7 -2
- package/dist/server/modules/index.js +6 -0
- package/dist/server/modules/menu/index.js +41 -32
- package/dist/server/modules/order/index.d.ts +207 -14
- package/dist/server/modules/order/index.js +2328 -379
- package/dist/server/modules/order/types.d.ts +76 -5
- package/dist/server/modules/order/types.js +14 -1
- package/dist/server/modules/order/utils/filterBookings.d.ts +7 -1
- package/dist/server/modules/order/utils/filterBookings.js +118 -11
- package/dist/server/modules/order/utils/filterOrders.js +242 -14
- package/dist/server/modules/payment/index.d.ts +28 -0
- package/dist/server/modules/payment/index.js +305 -0
- package/dist/server/modules/payment/types.d.ts +9 -0
- package/dist/server/modules/payment/types.js +1 -0
- package/dist/server/modules/products/index.d.ts +105 -14
- package/dist/server/modules/products/index.js +1416 -521
- package/dist/server/modules/products/types.d.ts +34 -1
- package/dist/server/modules/products/types.js +4 -0
- package/dist/server/modules/quotation/index.d.ts +39 -0
- package/dist/server/modules/quotation/index.js +298 -77
- package/dist/server/modules/resource/index.d.ts +2 -3
- package/dist/server/modules/resource/index.js +109 -86
- package/dist/server/modules/schedule/index.d.ts +6 -4
- package/dist/server/modules/schedule/index.js +145 -106
- package/dist/server/test.json +713 -0
- package/dist/server/types.d.ts +2 -0
- package/dist/server/utils/product.js +3 -2
- package/dist/server/utils/small-ticket.d.ts +71 -0
- package/dist/server/utils/small-ticket.js +963 -0
- package/dist/solution/BaseSales/index.d.ts +378 -0
- package/dist/solution/BaseSales/index.js +4009 -0
- package/dist/solution/BaseSales/types.d.ts +394 -0
- package/dist/solution/BaseSales/types.js +40 -0
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
- package/dist/solution/BaseSales/utils/cartPromotion.js +1450 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +144 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +157 -0
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +18 -0
- package/dist/solution/BaseSales/utils/quotationPrice.js +250 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +63 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +218 -0
- package/dist/solution/BaseSales/utils.d.ts +40 -0
- package/dist/solution/BaseSales/utils.js +263 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +60 -11
- package/dist/solution/BookingByStep/utils/capacity.js +11 -1
- package/dist/solution/BookingByStep/utils/resources.js +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +43 -2
- package/dist/solution/BookingTicket/index.d.ts +393 -24
- package/dist/solution/BookingTicket/index.js +2508 -443
- package/dist/solution/BookingTicket/types.d.ts +191 -6
- package/dist/solution/BookingTicket/types.js +83 -10
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
- package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
- package/dist/solution/BookingTicket/utils/addTimeAvailability.js +95 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.js +136 -0
- package/dist/solution/BookingTicket/utils/cartView.d.ts +29 -0
- package/dist/solution/BookingTicket/utils/cartView.js +209 -0
- package/dist/solution/BookingTicket/utils/exampleData.d.ts +123 -0
- package/dist/solution/BookingTicket/utils/exampleData.js +183 -0
- package/dist/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
- package/dist/solution/BookingTicket/utils/orderCustomer.js +31 -0
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +438 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +400 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +4 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +42 -1
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +56 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +42 -28
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +30 -14
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +150 -0
- package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
- package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +78 -0
- package/dist/solution/BuyTickets/index.js +12 -9
- package/dist/solution/Checkout/index.d.ts +1 -0
- package/dist/solution/Checkout/index.js +275 -209
- package/dist/solution/Checkout/utils/index.js +20 -8
- package/dist/solution/RegisterAndLogin/config.js +2 -10
- package/dist/solution/RegisterAndLogin/index.js +76 -30
- package/dist/solution/Sales/index.d.ts +50 -5
- package/dist/solution/Sales/index.js +484 -92
- package/dist/solution/Sales/types.d.ts +26 -2
- package/dist/solution/ScanOrder/index.d.ts +27 -21
- package/dist/solution/ScanOrder/index.js +519 -444
- package/dist/solution/ScanOrder/types.d.ts +33 -11
- package/dist/solution/ScanOrder/types.js +4 -5
- package/dist/solution/ScanOrder/utils.d.ts +4 -1
- package/dist/solution/ScanOrder/utils.js +109 -34
- package/dist/solution/ShopDiscount/index.js +18 -19
- package/dist/solution/ShopDiscount/types.d.ts +4 -5
- package/dist/solution/ShopDiscount/utils.d.ts +0 -9
- package/dist/solution/ShopDiscount/utils.js +0 -9
- package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/dist/solution/UnifiedBookingSales/index.js +1871 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/dist/solution/UnifiedBookingSales/types.js +11 -0
- package/dist/solution/VenueBooking/index.d.ts +32 -51
- package/dist/solution/VenueBooking/index.js +741 -808
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/dist/solution/VenueBooking/types.d.ts +1 -3
- package/dist/solution/VenueBooking/types.js +0 -1
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +9 -3
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -1
- package/dist/types/index.d.ts +12 -2
- package/dist/utils/task.js +18 -15
- package/dist/utils/watch.js +1 -0
- package/lib/apis/picoding.js +0 -2
- package/lib/core/index.js +132 -130
- package/lib/effects/index.js +57 -46
- package/lib/index.d.ts +0 -1
- package/lib/index.js +50 -92
- package/lib/model/index.js +21 -14
- package/lib/model/strategy/adapter/dataVariant/adapter.js +50 -38
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +236 -162
- package/lib/model/strategy/adapter/dataVariant/examples.js +237 -229
- package/lib/model/strategy/adapter/dataVariant/index.js +34 -39
- package/lib/model/strategy/adapter/dataVariant/type.js +28 -57
- package/lib/model/strategy/adapter/index.js +64 -100
- package/lib/model/strategy/adapter/itemRule/adapter.js +144 -156
- package/lib/model/strategy/adapter/itemRule/evaluator.js +48 -36
- package/lib/model/strategy/adapter/itemRule/examples.js +225 -295
- package/lib/model/strategy/adapter/itemRule/index.js +57 -83
- package/lib/model/strategy/adapter/itemRule/type.js +36 -97
- package/lib/model/strategy/adapter/promotion/adapter.js +63 -84
- package/lib/model/strategy/adapter/promotion/evaluator.js +233 -382
- package/lib/model/strategy/adapter/promotion/examples.js +159 -139
- package/lib/model/strategy/adapter/promotion/index.js +0 -1
- package/lib/model/strategy/adapter/promotion/type.js +35 -199
- package/lib/model/strategy/adapter/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/evaluator.js +152 -180
- package/lib/model/strategy/adapter/walletPass/example.js +190 -217
- package/lib/model/strategy/adapter/walletPass/index.js +51 -75
- package/lib/model/strategy/adapter/walletPass/locales.js +58 -36
- package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/lib/model/strategy/adapter/walletPass/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/lib/model/strategy/adapter/walletPass/utils.js +383 -676
- package/lib/model/strategy/engine.js +168 -270
- package/lib/model/strategy/index.js +34 -49
- package/lib/model/strategy/strategy-example.js +239 -243
- package/lib/model/strategy/type.js +40 -100
- package/lib/modules/Account/index.js +53 -39
- package/lib/modules/Account/types.js +33 -20
- package/lib/modules/AccountList/index.js +154 -116
- package/lib/modules/AccountList/types.js +31 -30
- package/lib/modules/AccountList/utils.js +30 -18
- package/lib/modules/BaseModule.d.ts +2 -2
- package/lib/modules/BaseModule.js +50 -29
- package/lib/modules/BookingContext/index.d.ts +48 -0
- package/lib/modules/BookingContext/index.js +368 -0
- package/lib/modules/BookingContext/types.d.ts +102 -0
- package/lib/modules/BookingContext/types.js +34 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +298 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +155 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +222 -0
- package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/lib/modules/BookingContext/utils/flexible.js +80 -0
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
- package/lib/modules/BookingContext/utils/index.d.ts +11 -0
- package/lib/modules/BookingContext/utils/index.js +43 -0
- package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/lib/modules/BookingContext/utils/noResource.js +90 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +56 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/lib/modules/BookingContext/utils/productExtend.js +283 -0
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
- package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
- package/lib/modules/BookingContext/utils/resources.js +377 -0
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
- package/lib/modules/Cart/index.js +124 -170
- package/lib/modules/Cart/types.js +51 -46
- package/lib/modules/Cart/utils/cartAccount.js +39 -40
- package/lib/modules/Cart/utils/cartDate.js +61 -56
- package/lib/modules/Cart/utils/cartDiscount.js +33 -28
- package/lib/modules/Cart/utils/cartNote.js +32 -27
- package/lib/modules/Cart/utils/cartProduct.js +261 -309
- package/lib/modules/Cart/utils/cartRelationForms.js +35 -29
- package/lib/modules/Cart/utils/cartResource.js +78 -72
- package/lib/modules/Cart/utils/changePrice.js +59 -31
- package/lib/modules/Cart/utils/index.js +48 -106
- package/lib/modules/Customer/constants.js +34 -13
- package/lib/modules/Customer/index.d.ts +20 -0
- package/lib/modules/Customer/index.js +207 -217
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Customer/types.js +35 -38
- package/lib/modules/Date/index.js +115 -116
- package/lib/modules/Date/types.js +28 -16
- package/lib/modules/Date/utils.js +123 -174
- package/lib/modules/Discount/index.d.ts +2 -2
- package/lib/modules/Discount/index.js +133 -119
- package/lib/modules/Discount/types.d.ts +1 -1
- package/lib/modules/Discount/types.js +31 -9
- package/lib/modules/Guests/index.js +56 -30
- package/lib/modules/Guests/types.js +33 -23
- package/lib/modules/Holder/index.js +189 -209
- package/lib/modules/Holder/types.js +16 -4
- package/lib/modules/Holder/utils.js +49 -20
- package/lib/modules/OpenData/index.d.ts +8 -0
- package/lib/modules/OpenData/index.js +88 -63
- package/lib/modules/OpenData/types.js +16 -4
- package/lib/modules/OpenData/utils.js +78 -44
- package/lib/modules/Order/index.d.ts +449 -24
- package/lib/modules/Order/index.js +4184 -514
- package/lib/modules/Order/types.d.ts +693 -88
- package/lib/modules/Order/types.js +35 -24
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/lib/modules/Order/utils/bundleDiscountHydration.js +139 -0
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/lib/modules/Order/utils/manualProductDiscount.js +206 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +415 -0
- package/lib/modules/Order/utils.d.ts +167 -18
- package/lib/modules/Order/utils.js +1085 -414
- package/lib/modules/Payment/cash.js +33 -20
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +76 -145
- package/lib/modules/Payment/eftpos.js +30 -16
- package/lib/modules/Payment/index.d.ts +10 -9
- package/lib/modules/Payment/index.js +402 -636
- package/lib/modules/Payment/mx51.js +0 -1
- package/lib/modules/Payment/types.d.ts +44 -24
- package/lib/modules/Payment/types.js +107 -216
- package/lib/modules/Payment/utils.d.ts +1 -1
- package/lib/modules/Payment/utils.js +50 -52
- package/lib/modules/Payment/walletpass.d.ts +0 -2
- package/lib/modules/Payment/walletpass.js +216 -221
- package/lib/modules/Product/index.js +46 -51
- package/lib/modules/Product/types.d.ts +29 -7
- package/lib/modules/Product/types.js +16 -4
- package/lib/modules/Product/utils.js +33 -32
- package/lib/modules/ProductList/index.d.ts +17 -13
- package/lib/modules/ProductList/index.js +161 -120
- package/lib/modules/ProductList/types.d.ts +16 -0
- package/lib/modules/ProductList/types.js +31 -9
- package/lib/modules/Quotation/index.d.ts +22 -2
- package/lib/modules/Quotation/index.js +154 -64
- package/lib/modules/Quotation/types.d.ts +19 -0
- package/lib/modules/Quotation/types.js +16 -4
- package/lib/modules/Resource/index.js +59 -27
- package/lib/modules/Resource/types.js +32 -22
- package/lib/modules/Resource/utils.js +38 -30
- package/lib/modules/ResourcePlanner/index.d.ts +24 -0
- package/lib/modules/ResourcePlanner/index.js +148 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
- package/lib/modules/ResourcePlanner/planner.js +933 -0
- package/lib/modules/ResourcePlanner/types.d.ts +227 -0
- package/lib/modules/ResourcePlanner/types.js +17 -0
- package/lib/modules/Rules/index.d.ts +8 -10
- package/lib/modules/Rules/index.js +960 -1440
- package/lib/modules/Rules/types.d.ts +14 -3
- package/lib/modules/Rules/types.js +40 -17
- package/lib/modules/SalesSummary/index.d.ts +23 -26
- package/lib/modules/SalesSummary/index.js +134 -61
- package/lib/modules/SalesSummary/types.d.ts +9 -1
- package/lib/modules/SalesSummary/types.js +16 -4
- package/lib/modules/SalesSummary/utils.d.ts +3 -22
- package/lib/modules/SalesSummary/utils.js +814 -233
- package/lib/modules/ScanOrderLogger/index.js +79 -59
- package/lib/modules/ScanOrderLogger/providers/feishu.js +78 -54
- package/lib/modules/ScanOrderLogger/providers/grafana.js +36 -13
- package/lib/modules/ScanOrderLogger/types.js +16 -4
- package/lib/modules/Schedule/getDateIsInSchedule.js +169 -338
- package/lib/modules/Schedule/index.d.ts +18 -5
- package/lib/modules/Schedule/index.js +153 -104
- package/lib/modules/Schedule/type.js +16 -4
- package/lib/modules/Schedule/types.d.ts +2 -0
- package/lib/modules/Schedule/types.js +16 -4
- package/lib/modules/Schedule/utils.js +291 -433
- package/lib/modules/Step/index.js +52 -40
- package/lib/modules/Step/tyeps.js +16 -4
- package/lib/modules/Summary/index.js +71 -66
- package/lib/modules/Summary/types.js +16 -4
- package/lib/modules/Summary/utils.js +418 -791
- package/lib/modules/SurchargeList/index.d.ts +18 -0
- package/lib/modules/SurchargeList/index.js +109 -0
- package/lib/modules/SurchargeList/types.d.ts +15 -0
- package/lib/modules/SurchargeList/types.js +17 -0
- package/lib/modules/index.d.ts +3 -0
- package/lib/modules/index.js +63 -212
- package/lib/plugins/app.d.ts +2 -0
- package/lib/plugins/app.js +16 -4
- package/lib/plugins/index.js +25 -36
- package/lib/plugins/request.d.ts +1 -0
- package/lib/plugins/request.js +126 -137
- package/lib/plugins/shopStore.js +16 -4
- package/lib/plugins/user.js +16 -4
- package/lib/plugins/window.js +179 -171
- package/lib/server/index.d.ts +462 -8
- package/lib/server/index.js +4520 -1162
- package/lib/server/modules/floor-plan/index.d.ts +39 -0
- package/lib/server/modules/floor-plan/index.js +327 -0
- package/lib/server/modules/floor-plan/types.d.ts +43 -0
- package/lib/server/modules/floor-plan/types.js +34 -0
- package/lib/server/modules/index.d.ts +7 -2
- package/lib/server/modules/index.js +67 -84
- package/lib/server/modules/menu/index.js +122 -146
- package/lib/server/modules/menu/types.js +31 -18
- package/lib/server/modules/order/index.d.ts +207 -14
- package/lib/server/modules/order/index.js +1543 -285
- package/lib/server/modules/order/types.d.ts +76 -5
- package/lib/server/modules/order/types.js +32 -107
- package/lib/server/modules/order/utils/filterBookings.d.ts +7 -1
- package/lib/server/modules/order/utils/filterBookings.js +259 -176
- package/lib/server/modules/order/utils/filterOrders.js +293 -94
- package/lib/server/modules/payment/index.d.ts +28 -0
- package/lib/server/modules/payment/index.js +192 -0
- package/lib/server/modules/payment/types.d.ts +9 -0
- package/lib/server/modules/payment/types.js +17 -0
- package/lib/server/modules/products/index.d.ts +105 -14
- package/lib/server/modules/products/index.js +850 -475
- package/lib/server/modules/products/types.d.ts +34 -1
- package/lib/server/modules/products/types.js +34 -41
- package/lib/server/modules/quotation/index.d.ts +39 -0
- package/lib/server/modules/quotation/index.js +254 -75
- package/lib/server/modules/quotation/types.js +31 -21
- package/lib/server/modules/resource/index.d.ts +2 -3
- package/lib/server/modules/resource/index.js +240 -243
- package/lib/server/modules/resource/types.js +33 -42
- package/lib/server/modules/schedule/index.d.ts +6 -4
- package/lib/server/modules/schedule/index.js +146 -147
- package/lib/server/modules/schedule/types.js +21 -14
- package/lib/server/modules/schedule/utils.js +163 -334
- package/lib/server/test.json +713 -0
- package/lib/server/types.d.ts +2 -0
- package/lib/server/types.js +16 -4
- package/lib/server/utils/index.js +23 -25
- package/lib/server/utils/product.js +140 -197
- package/lib/server/utils/schedule.js +41 -34
- package/lib/server/utils/small-ticket.d.ts +71 -0
- package/lib/server/utils/small-ticket.js +904 -0
- package/lib/server/utils/time.js +49 -40
- package/lib/solution/BaseSales/index.d.ts +378 -0
- package/lib/solution/BaseSales/index.js +2533 -0
- package/lib/solution/BaseSales/types.d.ts +394 -0
- package/lib/solution/BaseSales/types.js +43 -0
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
- package/lib/solution/BaseSales/utils/cartPromotion.js +1004 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +144 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +160 -0
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +18 -0
- package/lib/solution/BaseSales/utils/quotationPrice.js +289 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +63 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +256 -0
- package/lib/solution/BaseSales/utils.d.ts +40 -0
- package/lib/solution/BaseSales/utils.js +244 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +1340 -1530
- package/lib/solution/BookingByStep/types.js +99 -40
- package/lib/solution/BookingByStep/utils/capacity.js +160 -192
- package/lib/solution/BookingByStep/utils/products.js +52 -42
- package/lib/solution/BookingByStep/utils/resources.js +330 -527
- package/lib/solution/BookingByStep/utils/stock.js +44 -65
- package/lib/solution/BookingByStep/utils/timeslots.js +131 -129
- package/lib/solution/BookingTicket/index.d.ts +393 -24
- package/lib/solution/BookingTicket/index.js +1374 -184
- package/lib/solution/BookingTicket/types.d.ts +191 -6
- package/lib/solution/BookingTicket/types.js +79 -40
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
- package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +125 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.js +107 -0
- package/lib/solution/BookingTicket/utils/cartView.d.ts +29 -0
- package/lib/solution/BookingTicket/utils/cartView.js +184 -0
- package/lib/solution/BookingTicket/utils/exampleData.d.ts +123 -0
- package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +58 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +254 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +169 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +97 -64
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +51 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +81 -82
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +109 -91
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +43 -90
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +127 -0
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +85 -0
- package/lib/solution/BuyTickets/index.js +70 -67
- package/lib/solution/BuyTickets/types.js +38 -22
- package/lib/solution/Checkout/index.d.ts +1 -0
- package/lib/solution/Checkout/index.js +1169 -1463
- package/lib/solution/Checkout/types.js +61 -91
- package/lib/solution/Checkout/utils/index.js +156 -228
- package/lib/solution/PlaceOrder/index.js +0 -55
- package/lib/solution/RegisterAndLogin/config.js +462 -503
- package/lib/solution/RegisterAndLogin/index.js +630 -633
- package/lib/solution/RegisterAndLogin/types.js +76 -189
- package/lib/solution/RegisterAndLogin/utils.js +125 -183
- package/lib/solution/Sales/index.d.ts +50 -5
- package/lib/solution/Sales/index.js +498 -238
- package/lib/solution/Sales/types.d.ts +26 -2
- package/lib/solution/Sales/types.js +33 -27
- package/lib/solution/ScanOrder/index.d.ts +27 -21
- package/lib/solution/ScanOrder/index.js +936 -864
- package/lib/solution/ScanOrder/types.d.ts +33 -11
- package/lib/solution/ScanOrder/types.js +34 -34
- package/lib/solution/ScanOrder/utils.d.ts +4 -1
- package/lib/solution/ScanOrder/utils.js +422 -385
- package/lib/solution/ShopDiscount/index.js +233 -235
- package/lib/solution/ShopDiscount/types.d.ts +4 -5
- package/lib/solution/ShopDiscount/types.js +37 -15
- package/lib/solution/ShopDiscount/utils.d.ts +0 -9
- package/lib/solution/ShopDiscount/utils.js +172 -309
- package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/lib/solution/UnifiedBookingSales/index.js +1076 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/lib/solution/UnifiedBookingSales/types.js +33 -0
- package/lib/solution/VenueBooking/index.d.ts +32 -51
- package/lib/solution/VenueBooking/index.js +1008 -984
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/lib/solution/VenueBooking/types.d.ts +1 -3
- package/lib/solution/VenueBooking/types.js +39 -20
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/lib/solution/VenueBooking/utils/dateSummary.js +62 -25
- package/lib/solution/VenueBooking/utils/resource.js +54 -31
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +109 -90
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/lib/solution/VenueBooking/utils/timeSlot.js +133 -138
- package/lib/solution/VenueBooking/utils.js +67 -130
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +41 -102
- package/lib/store/createStore.js +29 -32
- package/lib/types/index.d.ts +12 -2
- package/lib/types/index.js +16 -4
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +47 -81
- package/package.json +2 -4
- package/dist/solution/Checkout/appointmentDemo.json +0 -1
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
- package/lib/solution/Checkout/appointmentDemo.json +0 -1
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/lib/solution/VenueBooking/utils/smartPricing.js +0 -192
|
@@ -1,134 +1,539 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
16
|
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/modules/Order/utils.ts
|
|
30
|
+
var utils_exports = {};
|
|
31
|
+
__export(utils_exports, {
|
|
32
|
+
buildManualProductDiscountItem: () => import_manualProductDiscount.buildManualProductDiscountItem,
|
|
33
|
+
buildSubmitPayload: () => buildSubmitPayload,
|
|
34
|
+
calculateOrderProductsDeposit: () => calculateOrderProductsDeposit,
|
|
35
|
+
clearTempOrderHolderAssignments: () => clearTempOrderHolderAssignments,
|
|
36
|
+
composeLinePrice: () => composeLinePrice,
|
|
37
|
+
createDefaultOrderRulesHooks: () => createDefaultOrderRulesHooks,
|
|
38
|
+
createDefaultTempOrder: () => createDefaultTempOrder,
|
|
39
|
+
createEmptySummary: () => import_utils3.createEmptySummary,
|
|
40
|
+
createUuidV4: () => import_orderCollectionIdentity.createUuidV4,
|
|
41
|
+
ensureCartItemOriginHolder: () => ensureCartItemOriginHolder,
|
|
42
|
+
ensureManualProductDiscountList: () => import_manualProductDiscount.ensureManualProductDiscountList,
|
|
43
|
+
ensureProductSku: () => ensureProductSku,
|
|
44
|
+
findManualProductDiscountItem: () => import_manualProductDiscount.findManualProductDiscountItem,
|
|
45
|
+
formatDateTime: () => formatDateTime,
|
|
46
|
+
formatV1Product: () => formatV1Product,
|
|
47
|
+
generateDuration: () => generateDuration,
|
|
48
|
+
getAllDiscountList: () => getAllDiscountList,
|
|
49
|
+
getBundleSellingMagnitude: () => getBundleSellingMagnitude,
|
|
50
|
+
getBundleSignedUnit: () => getBundleSignedUnit,
|
|
51
|
+
getOrderProductLineUid: () => getOrderProductLineUid,
|
|
52
|
+
getProductSkuOptions: () => getProductSkuOptions,
|
|
53
|
+
getRuntimeProductOrigin: () => getRuntimeProductOrigin,
|
|
54
|
+
hasAssignedHolderId: () => hasAssignedHolderId,
|
|
55
|
+
indexOrderProductsByUid: () => indexOrderProductsByUid,
|
|
56
|
+
isEmptyOrderProductDisplayValue: () => isEmptyOrderProductDisplayValue,
|
|
57
|
+
isHolderConfigRequired: () => isHolderConfigRequired,
|
|
58
|
+
isMarkdownBundle: () => isMarkdownBundle,
|
|
59
|
+
isTempOrder: () => isTempOrder,
|
|
60
|
+
mapPaymentItemToOrderPayment: () => mapPaymentItemToOrderPayment,
|
|
61
|
+
mapPaymentItemsToOrderPayments: () => mapPaymentItemsToOrderPayments,
|
|
62
|
+
mergeManualProductDiscountIntoList: () => import_manualProductDiscount.mergeManualProductDiscountIntoList,
|
|
63
|
+
mergeOrderProductDisplayFields: () => mergeOrderProductDisplayFields,
|
|
64
|
+
mergeRelationForms: () => mergeRelationForms,
|
|
65
|
+
normalizeBookingIsAll: () => normalizeBookingIsAll,
|
|
66
|
+
normalizeBookingSubType: () => normalizeBookingSubType,
|
|
67
|
+
normalizeOrderProductDiscountList: () => normalizeOrderProductDiscountList,
|
|
68
|
+
normalizeProductSkuOptions: () => normalizeProductSkuOptions,
|
|
69
|
+
normalizeSubmitBooking: () => normalizeSubmitBooking,
|
|
70
|
+
normalizeSubmitCollectPaxValue: () => normalizeSubmitCollectPaxValue,
|
|
71
|
+
productRequiresFormSubject: () => productRequiresFormSubject,
|
|
72
|
+
resolveEffectivePerUnitDiscount: () => resolveEffectivePerUnitDiscount,
|
|
73
|
+
resolveIsFormSubject: () => resolveIsFormSubject,
|
|
74
|
+
resolveManualDiscountMessage: () => import_manualProductDiscount.resolveManualDiscountMessage,
|
|
75
|
+
resolveManualDiscountOriginTotal: () => import_manualProductDiscount.resolveManualDiscountOriginTotal,
|
|
76
|
+
resolveManualDiscountReasonFromSources: () => import_manualProductDiscount.resolveManualDiscountReasonFromSources,
|
|
77
|
+
resolveManualOverrideLineOriginalPrice: () => resolveManualOverrideLineOriginalPrice,
|
|
78
|
+
resolveRulesManualDiscountFlag: () => resolveRulesManualDiscountFlag,
|
|
79
|
+
resolveSafeProductNum: () => import_manualProductDiscount.resolveSafeProductNum,
|
|
80
|
+
resolveSubmitCollectPax: () => resolveSubmitCollectPax,
|
|
81
|
+
shouldBuildManualProductDiscount: () => import_manualProductDiscount.shouldBuildManualProductDiscount,
|
|
82
|
+
stripManualProductDiscountItems: () => import_manualProductDiscount.stripManualProductDiscountItems,
|
|
83
|
+
sumOptionUnitPrice: () => sumOptionUnitPrice,
|
|
84
|
+
syncManualProductDiscountProductNum: () => import_manualProductDiscount.syncManualProductDiscountProductNum
|
|
15
85
|
});
|
|
16
|
-
exports
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
exports.normalizeSubmitBooking = normalizeSubmitBooking;
|
|
25
|
-
exports.normalizeSubmitCollectPaxValue = normalizeSubmitCollectPaxValue;
|
|
26
|
-
exports.resolveSubmitCollectPax = resolveSubmitCollectPax;
|
|
27
|
-
exports.sumOptionUnitPrice = sumOptionUnitPrice;
|
|
28
|
-
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
29
|
-
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
30
|
-
var _utils = require("../Holder/utils");
|
|
31
|
-
var _utils2 = require("../../solution/ScanOrder/utils");
|
|
32
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
|
-
/**
|
|
34
|
-
* 把"含 option 的主商品单价"与 bundle 合成"单行 composite 单价"。
|
|
35
|
-
*
|
|
36
|
-
* 新语义 v2 约定:
|
|
37
|
-
* - `mainPrice` 必须是**已经包含 option 的主商品单价**(即 `metadata.main_product_selling_price`
|
|
38
|
-
* 或 `metadata.main_product_original_price`),option 价格不由本函数叠加。
|
|
39
|
-
* - 套餐价:Σ((bundle.bundle_selling_price ?? bundle.price) × (bundle.num ?? bundle.quantity ?? 1))
|
|
40
|
-
* 当 `useOriginalBundle=true` 时,改用 `bundle.original_price ?? bundle.product_price ?? bundle.price`。
|
|
41
|
-
* - 返回值:保留 2 位小数的字符串,方便直接写回 `selling_price` / `original_price` 字段。
|
|
42
|
-
*
|
|
43
|
-
* 被 `normalizeOrderProduct`、Rules setProduct 钩子、各 Solution 的 setDiscountSelected 共用,
|
|
44
|
-
* 保证合成逻辑单点来源。
|
|
45
|
-
*/
|
|
86
|
+
module.exports = __toCommonJS(utils_exports);
|
|
87
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
88
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
89
|
+
var import_utils = require("../Holder/utils");
|
|
90
|
+
var import_utils2 = require("../../solution/ScanOrder/utils");
|
|
91
|
+
var import_orderCollectionIdentity = require("./utils/orderCollectionIdentity");
|
|
92
|
+
var import_utils3 = require("../../solution/ScanOrder/utils");
|
|
93
|
+
var import_manualProductDiscount = require("./utils/manualProductDiscount");
|
|
46
94
|
function composeLinePrice(params) {
|
|
47
|
-
const {
|
|
48
|
-
|
|
49
|
-
bundle,
|
|
50
|
-
useOriginalBundle
|
|
51
|
-
} = params;
|
|
52
|
-
let total = new _decimal.default(Number(mainPrice) || 0);
|
|
95
|
+
const { mainPrice, bundle, useOriginalBundle } = params;
|
|
96
|
+
let total = new import_decimal.default(Number(mainPrice) || 0);
|
|
53
97
|
if (Array.isArray(bundle)) {
|
|
54
98
|
for (const item of bundle) {
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
total = total.plus(price.times(num));
|
|
99
|
+
const signedUnit = getBundleSignedUnit(item, { useOriginal: useOriginalBundle });
|
|
100
|
+
const rawNum = (item == null ? void 0 : item.num) ?? (item == null ? void 0 : item.quantity) ?? 1;
|
|
101
|
+
const num = new import_decimal.default(Number(rawNum) || 0);
|
|
102
|
+
total = total.plus(signedUnit.times(num));
|
|
60
103
|
}
|
|
61
104
|
}
|
|
62
105
|
return total.toDecimalPlaces(2).toFixed(2);
|
|
63
106
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
107
|
+
function normalizeProductSkuOptions(options) {
|
|
108
|
+
if (!Array.isArray(options))
|
|
109
|
+
return [];
|
|
110
|
+
return options.map((option) => {
|
|
111
|
+
const normalized = {
|
|
112
|
+
...option && typeof option === "object" ? option : {}
|
|
113
|
+
};
|
|
114
|
+
const addPrice = normalized.add_price ?? normalized.price;
|
|
115
|
+
if (addPrice !== void 0)
|
|
116
|
+
normalized.add_price = addPrice;
|
|
117
|
+
delete normalized.price;
|
|
118
|
+
return normalized;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function ensureProductSku(product) {
|
|
122
|
+
const rawSku = (product == null ? void 0 : product.product_sku) && typeof product.product_sku === "object" ? product.product_sku : {};
|
|
123
|
+
return {
|
|
124
|
+
...rawSku,
|
|
125
|
+
option: normalizeProductSkuOptions(rawSku.option)
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function getProductSkuOptions(product) {
|
|
129
|
+
return ensureProductSku(product).option;
|
|
130
|
+
}
|
|
69
131
|
function sumOptionUnitPrice(options) {
|
|
70
|
-
let total = new
|
|
71
|
-
if (!Array.isArray(options))
|
|
132
|
+
let total = new import_decimal.default(0);
|
|
133
|
+
if (!Array.isArray(options))
|
|
134
|
+
return total;
|
|
72
135
|
for (const opt of options) {
|
|
73
|
-
const price = new
|
|
74
|
-
const num = new
|
|
136
|
+
const price = new import_decimal.default(Number((opt == null ? void 0 : opt.add_price) ?? (opt == null ? void 0 : opt.price)) || 0);
|
|
137
|
+
const num = new import_decimal.default(Number(opt == null ? void 0 : opt.num) || 0);
|
|
75
138
|
total = total.plus(price.times(num));
|
|
76
139
|
}
|
|
77
140
|
return total;
|
|
78
141
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
142
|
+
function getSafeOrderProductNum(num) {
|
|
143
|
+
const parsedNum = Number(num ?? 1);
|
|
144
|
+
if (!Number.isFinite(parsedNum) || parsedNum < 1)
|
|
145
|
+
return 1;
|
|
146
|
+
return Math.floor(parsedNum);
|
|
147
|
+
}
|
|
148
|
+
function getOrderProductDepositUnitTotal(product) {
|
|
149
|
+
const metadata = product.metadata || {};
|
|
150
|
+
const paymentPrice = metadata.main_product_attached_bundle_payment_price;
|
|
151
|
+
const mainSellingPrice = metadata.main_product_selling_price;
|
|
152
|
+
const fallbackPrice = product.selling_price;
|
|
153
|
+
return new import_decimal.default(Number(paymentPrice ?? mainSellingPrice ?? fallbackPrice) || 0);
|
|
154
|
+
}
|
|
155
|
+
function normalizeDepositProtocols(protocols) {
|
|
156
|
+
if (!Array.isArray(protocols))
|
|
157
|
+
return [];
|
|
158
|
+
return protocols.reduce((result, protocol) => {
|
|
159
|
+
const id = Number(protocol == null ? void 0 : protocol.id);
|
|
160
|
+
if (!Number.isFinite(id))
|
|
161
|
+
return result;
|
|
162
|
+
result.push({
|
|
163
|
+
id: Math.floor(id),
|
|
164
|
+
title: String((protocol == null ? void 0 : protocol.title) || "")
|
|
165
|
+
});
|
|
166
|
+
return result;
|
|
167
|
+
}, []);
|
|
168
|
+
}
|
|
169
|
+
function getDepositPolicyIds(depositData) {
|
|
170
|
+
const ids = [
|
|
171
|
+
...Array.isArray(depositData == null ? void 0 : depositData.self_deposit_policy_ids) ? depositData.self_deposit_policy_ids : [],
|
|
172
|
+
...Array.isArray(depositData == null ? void 0 : depositData.deposit_policy_ids) ? depositData.deposit_policy_ids : []
|
|
173
|
+
];
|
|
174
|
+
return ids.reduce((result, id) => {
|
|
175
|
+
const normalizedId = Number(id);
|
|
176
|
+
if (!Number.isFinite(normalizedId))
|
|
177
|
+
return result;
|
|
178
|
+
result.push(Math.floor(normalizedId));
|
|
179
|
+
return result;
|
|
180
|
+
}, []);
|
|
181
|
+
}
|
|
182
|
+
function handleOrderProductDeposit(params) {
|
|
183
|
+
const { depositData, total, num } = params;
|
|
184
|
+
if (!depositData)
|
|
185
|
+
return { result: false, depositTotal: new import_decimal.default(0) };
|
|
186
|
+
const { deposit_fixed, deposit_percentage } = depositData;
|
|
187
|
+
if (typeof deposit_fixed !== "string" || typeof deposit_percentage !== "string") {
|
|
188
|
+
return { result: false, depositTotal: new import_decimal.default(0) };
|
|
189
|
+
}
|
|
190
|
+
const depositFixed = new import_decimal.default(deposit_fixed || 0);
|
|
191
|
+
const depositPercent = new import_decimal.default(deposit_percentage || 0);
|
|
192
|
+
const productTotalPrice = new import_decimal.default(total || 0);
|
|
193
|
+
const deposit = depositFixed.plus(depositPercent.times(productTotalPrice));
|
|
194
|
+
return { depositTotal: deposit.times(num), result: true };
|
|
195
|
+
}
|
|
196
|
+
function resolveOrderProductDepositSource(product, runtimeOrigin) {
|
|
197
|
+
const record = product;
|
|
198
|
+
const origin = record._origin || runtimeOrigin || {};
|
|
199
|
+
const originProduct = origin.product || {};
|
|
200
|
+
return {
|
|
201
|
+
...originProduct,
|
|
202
|
+
...origin,
|
|
203
|
+
...record,
|
|
204
|
+
custom_deposit_data: record.custom_deposit_data ?? origin.custom_deposit_data ?? originProduct.custom_deposit_data,
|
|
205
|
+
variant: record.variant ?? origin.variant ?? originProduct.variant
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function getOrderProductDeposit(product, runtimeOrigin) {
|
|
209
|
+
const depositProduct = resolveOrderProductDepositSource(product, runtimeOrigin);
|
|
210
|
+
const depositData = depositProduct.custom_deposit_data;
|
|
211
|
+
if ((depositData == null ? void 0 : depositData.has_deposit) != 1)
|
|
212
|
+
return null;
|
|
213
|
+
const num = getSafeOrderProductNum(product.num);
|
|
214
|
+
const total = getOrderProductDepositUnitTotal(product).times(num);
|
|
215
|
+
const allProtocols = normalizeDepositProtocols(depositData.deposit_policy_data);
|
|
216
|
+
const protocolIds = [];
|
|
217
|
+
let depositTotal = new import_decimal.default(0);
|
|
218
|
+
let hasDeposit = false;
|
|
219
|
+
if (typeof depositData.deposit_fixed === "string" && typeof depositData.deposit_percentage === "string") {
|
|
220
|
+
const result = handleOrderProductDeposit({
|
|
221
|
+
depositData,
|
|
222
|
+
total,
|
|
223
|
+
num
|
|
224
|
+
});
|
|
225
|
+
if (result.result) {
|
|
226
|
+
depositTotal = result.depositTotal;
|
|
227
|
+
protocolIds.push(...getDepositPolicyIds({
|
|
228
|
+
self_deposit_policy_ids: depositData.self_deposit_policy_ids
|
|
229
|
+
}));
|
|
230
|
+
hasDeposit = true;
|
|
231
|
+
}
|
|
232
|
+
} else {
|
|
233
|
+
const productVariantId = depositProduct.product_variant_id ?? product.product_variant_id;
|
|
234
|
+
if (productVariantId) {
|
|
235
|
+
const variantProduct = (depositProduct.variant || []).find(
|
|
236
|
+
(item) => (item == null ? void 0 : item.id) === productVariantId
|
|
237
|
+
);
|
|
238
|
+
const variantDepositData = variantProduct == null ? void 0 : variantProduct.custom_deposit_data;
|
|
239
|
+
const result = handleOrderProductDeposit({
|
|
240
|
+
depositData: variantDepositData,
|
|
241
|
+
total,
|
|
242
|
+
num
|
|
243
|
+
});
|
|
244
|
+
if (result.result) {
|
|
245
|
+
depositTotal = result.depositTotal;
|
|
246
|
+
protocolIds.push(...getDepositPolicyIds({
|
|
247
|
+
self_deposit_policy_ids: variantDepositData == null ? void 0 : variantDepositData.self_deposit_policy_ids
|
|
248
|
+
}));
|
|
249
|
+
hasDeposit = true;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if (Array.isArray(product.product_bundle) && product.product_bundle.length) {
|
|
253
|
+
depositTotal = product.product_bundle.reduce((accumulator, bundleProduct) => {
|
|
254
|
+
const bundleDepositData = bundleProduct == null ? void 0 : bundleProduct.custom_deposit_data;
|
|
255
|
+
const result = handleOrderProductDeposit({
|
|
256
|
+
depositData: bundleDepositData,
|
|
257
|
+
total: bundleProduct == null ? void 0 : bundleProduct.price,
|
|
258
|
+
num: getSafeOrderProductNum((bundleProduct == null ? void 0 : bundleProduct.num) || 1)
|
|
259
|
+
});
|
|
260
|
+
if (!result.result)
|
|
261
|
+
return accumulator;
|
|
262
|
+
protocolIds.push(...getDepositPolicyIds({
|
|
263
|
+
self_deposit_policy_ids: bundleDepositData == null ? void 0 : bundleDepositData.self_deposit_policy_ids
|
|
264
|
+
}));
|
|
265
|
+
hasDeposit = true;
|
|
266
|
+
return accumulator.plus(result.depositTotal);
|
|
267
|
+
}, new import_decimal.default(0));
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
if (!hasDeposit)
|
|
271
|
+
return null;
|
|
272
|
+
const protocolIdSet = new Set(protocolIds);
|
|
273
|
+
const protocols = allProtocols.filter((protocol) => protocolIdSet.has(protocol.id));
|
|
274
|
+
return {
|
|
275
|
+
total: depositTotal.toNumber(),
|
|
276
|
+
protocols
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
function calculateOrderProductsDeposit(products = [], options) {
|
|
280
|
+
var _a, _b, _c;
|
|
281
|
+
const protocolMap = /* @__PURE__ */ new Map();
|
|
282
|
+
let total = new import_decimal.default(0);
|
|
283
|
+
let hasDeposit = false;
|
|
284
|
+
for (const product of products || []) {
|
|
285
|
+
const productUid = (_a = product.metadata) == null ? void 0 : _a.unique_identification_number;
|
|
286
|
+
const runtimeOrigin = productUid ? (_c = (_b = options == null ? void 0 : options.productsByUid) == null ? void 0 : _b[productUid]) == null ? void 0 : _c.origin : void 0;
|
|
287
|
+
const deposit = getOrderProductDeposit(product, runtimeOrigin);
|
|
288
|
+
product.deposit = deposit;
|
|
289
|
+
if (!(deposit == null ? void 0 : deposit.total) || Number(deposit.total) <= 0)
|
|
290
|
+
continue;
|
|
291
|
+
total = total.plus(deposit.total);
|
|
292
|
+
for (const protocol of deposit.protocols || []) {
|
|
293
|
+
if (!protocolMap.has(protocol.id))
|
|
294
|
+
protocolMap.set(protocol.id, protocol);
|
|
295
|
+
}
|
|
296
|
+
hasDeposit = true;
|
|
297
|
+
}
|
|
298
|
+
const roundedTotal = total.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP);
|
|
299
|
+
const protocols = [...protocolMap.values()];
|
|
300
|
+
return {
|
|
301
|
+
total: roundedTotal.toNumber(),
|
|
302
|
+
totalText: roundedTotal.toFixed(2),
|
|
303
|
+
protocols,
|
|
304
|
+
deposit_policy_ids: protocols.map((protocol) => protocol.id),
|
|
305
|
+
hasDeposit
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function isMarkdownBundle(bundle) {
|
|
309
|
+
if (!bundle || typeof bundle !== "object")
|
|
310
|
+
return false;
|
|
311
|
+
const ext = bundle.price_type_ext ?? bundle.custom_price_type_ext;
|
|
312
|
+
const type = bundle.price_type ?? bundle.custom_price_type;
|
|
313
|
+
return type === "markdown" && ext !== "product_price";
|
|
314
|
+
}
|
|
315
|
+
function getBundleSignedUnit(bundle, options) {
|
|
316
|
+
if (!bundle || typeof bundle !== "object")
|
|
317
|
+
return new import_decimal.default(0);
|
|
318
|
+
const useOriginal = (options == null ? void 0 : options.useOriginal) ?? false;
|
|
319
|
+
if (isMarkdownBundle(bundle)) {
|
|
320
|
+
const catalog = useOriginal ? bundle.original_price ?? bundle.product_price ?? bundle.custom_price ?? bundle.base_price ?? bundle.price : bundle.custom_price ?? bundle.product_price ?? bundle.original_price ?? bundle.base_price ?? bundle.price;
|
|
321
|
+
if (catalog !== void 0 && catalog !== null && catalog !== "") {
|
|
322
|
+
const raw = new import_decimal.default(Number(catalog) || 0);
|
|
323
|
+
if (raw.lt(0))
|
|
324
|
+
return raw;
|
|
325
|
+
return raw.minus(sumOptionUnitPrice(bundle.option)).negated();
|
|
326
|
+
}
|
|
327
|
+
return new import_decimal.default(Number(bundle.bundle_selling_price) || 0).abs().negated();
|
|
328
|
+
}
|
|
329
|
+
const rawPrice = useOriginal ? bundle.original_price ?? bundle.product_price ?? bundle.price : bundle.bundle_selling_price ?? bundle.price;
|
|
330
|
+
return new import_decimal.default(Number(rawPrice) || 0);
|
|
331
|
+
}
|
|
332
|
+
function getBundleSellingMagnitude(bundle) {
|
|
333
|
+
return getBundleSignedUnit(bundle).abs();
|
|
334
|
+
}
|
|
335
|
+
function resolveRulesManualDiscountFlag(metadata) {
|
|
336
|
+
if (!metadata)
|
|
337
|
+
return void 0;
|
|
338
|
+
if (metadata.is_manual_discount === true || metadata.is_manual_discount === 1) {
|
|
339
|
+
return true;
|
|
340
|
+
}
|
|
341
|
+
const priceOverride = metadata.price_override;
|
|
342
|
+
if (priceOverride !== void 0 && priceOverride !== null && priceOverride !== "") {
|
|
343
|
+
return true;
|
|
344
|
+
}
|
|
345
|
+
return void 0;
|
|
346
|
+
}
|
|
347
|
+
function normalizeOrderProductDiscountAmount(amount) {
|
|
348
|
+
if (amount === void 0 || amount === null)
|
|
349
|
+
return void 0;
|
|
350
|
+
return String(amount);
|
|
351
|
+
}
|
|
352
|
+
function normalizeOrderProductDiscountList(discountList) {
|
|
353
|
+
if (!Array.isArray(discountList))
|
|
354
|
+
return [];
|
|
355
|
+
return discountList.filter((item) => !!item && typeof item === "object").map((item) => {
|
|
356
|
+
const normalized = {
|
|
357
|
+
discount_id: Number.isFinite(Number(item.discount_id)) ? Number(item.discount_id) : 0
|
|
358
|
+
};
|
|
359
|
+
if (item.order_discount_id === null) {
|
|
360
|
+
normalized.order_discount_id = null;
|
|
361
|
+
} else if (item.order_discount_id !== void 0) {
|
|
362
|
+
const orderDiscountId = Number(item.order_discount_id);
|
|
363
|
+
if (Number.isFinite(orderDiscountId)) {
|
|
364
|
+
normalized.order_discount_id = orderDiscountId;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (item.type !== void 0)
|
|
368
|
+
normalized.type = item.type;
|
|
369
|
+
const amount = normalizeOrderProductDiscountAmount(item.amount);
|
|
370
|
+
if (amount !== void 0)
|
|
371
|
+
normalized.amount = amount;
|
|
372
|
+
if (item.discount && typeof item.discount === "object") {
|
|
373
|
+
normalized.discount = { ...item.discount };
|
|
374
|
+
}
|
|
375
|
+
if (item.metadata === null) {
|
|
376
|
+
normalized.metadata = null;
|
|
377
|
+
} else if (item.metadata && typeof item.metadata === "object") {
|
|
378
|
+
normalized.metadata = { ...item.metadata };
|
|
379
|
+
}
|
|
380
|
+
return normalized;
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
function resolveSubmitBundleMapId(bundle) {
|
|
384
|
+
var _a;
|
|
385
|
+
const metadataMapId = (_a = bundle.metadata) == null ? void 0 : _a.custom_product_bundle_map_id;
|
|
386
|
+
if (metadataMapId !== void 0 && metadataMapId !== null && metadataMapId !== "") {
|
|
387
|
+
return metadataMapId;
|
|
388
|
+
}
|
|
389
|
+
if (bundle._id !== void 0 && bundle._id !== null && bundle._id !== "") {
|
|
390
|
+
return bundle._id;
|
|
391
|
+
}
|
|
392
|
+
return void 0;
|
|
393
|
+
}
|
|
394
|
+
function collectSubmitProductDiscountList(product) {
|
|
395
|
+
const submitDiscountList = Array.isArray(product == null ? void 0 : product.discount_list) ? [...product.discount_list] : [];
|
|
396
|
+
for (const bundle of (product == null ? void 0 : product.product_bundle) || []) {
|
|
397
|
+
if (!bundle || typeof bundle !== "object")
|
|
398
|
+
continue;
|
|
399
|
+
const bundleMapId = resolveSubmitBundleMapId(bundle);
|
|
400
|
+
const bundleDiscountList = Array.isArray(bundle.discount_list) ? bundle.discount_list : [];
|
|
401
|
+
for (const discount of bundleDiscountList) {
|
|
402
|
+
if (!discount || typeof discount !== "object")
|
|
403
|
+
continue;
|
|
404
|
+
const discountMetadata = discount.metadata && typeof discount.metadata === "object" ? discount.metadata : {};
|
|
405
|
+
const discountMapId = discountMetadata.custom_product_bundle_map_id !== void 0 && discountMetadata.custom_product_bundle_map_id !== null && discountMetadata.custom_product_bundle_map_id !== "" ? discountMetadata.custom_product_bundle_map_id : bundleMapId;
|
|
406
|
+
submitDiscountList.push({
|
|
407
|
+
...discount,
|
|
408
|
+
...discountMapId !== void 0 ? {
|
|
409
|
+
metadata: {
|
|
410
|
+
...discountMetadata,
|
|
411
|
+
custom_product_bundle_map_id: discountMapId
|
|
412
|
+
}
|
|
413
|
+
} : {}
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
return normalizeOrderProductDiscountList(submitDiscountList);
|
|
418
|
+
}
|
|
419
|
+
function resolveManualOverrideLineOriginalPrice(params, fallbackCompositeOriginal) {
|
|
420
|
+
var _a, _b;
|
|
421
|
+
const metadata = params.metadata || {};
|
|
422
|
+
const priceOverride = metadata.price_override;
|
|
423
|
+
if (priceOverride === void 0 || priceOverride === null || priceOverride === "") {
|
|
424
|
+
return fallbackCompositeOriginal;
|
|
425
|
+
}
|
|
426
|
+
const refTotal = (_b = (_a = metadata.origin) == null ? void 0 : _a._extend) == null ? void 0 : _b.origin_total;
|
|
427
|
+
if (refTotal !== void 0 && refTotal !== null && refTotal !== "") {
|
|
428
|
+
const parsed = Number(refTotal);
|
|
429
|
+
if (Number.isFinite(parsed)) {
|
|
430
|
+
return new import_decimal.default(parsed).toDecimalPlaces(2).toFixed(2);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
const lineOriginal = params.lineOriginalPrice;
|
|
434
|
+
if (lineOriginal !== void 0 && lineOriginal !== null && lineOriginal !== "") {
|
|
435
|
+
const parsedLine = Number(lineOriginal);
|
|
436
|
+
const parsedFallback = Number(fallbackCompositeOriginal);
|
|
437
|
+
if (Number.isFinite(parsedLine) && Number.isFinite(parsedFallback) && parsedLine > parsedFallback) {
|
|
438
|
+
return new import_decimal.default(parsedLine).toDecimalPlaces(2).toFixed(2);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
return fallbackCompositeOriginal;
|
|
442
|
+
}
|
|
443
|
+
function resolveEffectivePerUnitDiscount(product) {
|
|
444
|
+
const discountList = Array.isArray(product == null ? void 0 : product.discount_list) ? product.discount_list : [];
|
|
445
|
+
const fromList = discountList.reduce(
|
|
446
|
+
(sum, discount) => sum + Number((discount == null ? void 0 : discount.amount) || 0),
|
|
447
|
+
0
|
|
448
|
+
);
|
|
449
|
+
const hasPromoDiscountItem = discountList.some((item) => (item == null ? void 0 : item.type) === "promotion");
|
|
450
|
+
if (hasPromoDiscountItem)
|
|
451
|
+
return fromList;
|
|
452
|
+
const metadata = (product == null ? void 0 : product.metadata) || {};
|
|
453
|
+
const promo = metadata._promotion;
|
|
454
|
+
if ((promo == null ? void 0 : promo.inPromotion) !== true)
|
|
455
|
+
return fromList;
|
|
456
|
+
const optionSum = sumOptionUnitPrice(getProductSkuOptions(product)).toNumber();
|
|
457
|
+
if (!discountList.length && metadata.source_product_price != null && metadata.main_product_selling_price != null) {
|
|
458
|
+
const source = Number(metadata.source_product_price);
|
|
459
|
+
const selling = Number(metadata.main_product_selling_price) - optionSum;
|
|
460
|
+
if (Number.isFinite(source) && Number.isFinite(selling) && source !== selling) {
|
|
461
|
+
return fromList + (source - selling);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
const originalPrice = Number(promo.originalPrice);
|
|
465
|
+
const finalPrice = Number(promo.finalPrice);
|
|
466
|
+
if (!Number.isFinite(originalPrice) || !Number.isFinite(finalPrice))
|
|
467
|
+
return fromList;
|
|
468
|
+
return fromList + (originalPrice - finalPrice);
|
|
469
|
+
}
|
|
109
470
|
function createDefaultOrderRulesHooks() {
|
|
110
471
|
const toUnitPriceString = (totalLike, num) => {
|
|
111
472
|
const effectiveNum = Number(num) > 0 ? Number(num) : 1;
|
|
112
|
-
return new
|
|
473
|
+
return new import_decimal.default(Number(totalLike) || 0).dividedBy(effectiveNum).toDecimalPlaces(2).toString();
|
|
474
|
+
};
|
|
475
|
+
const getBundleIdentity = (bundle) => {
|
|
476
|
+
return [
|
|
477
|
+
bundle.bundle_id ?? bundle.id ?? "",
|
|
478
|
+
bundle.bundle_product_id ?? bundle._bundle_product_id ?? bundle.product_id ?? "",
|
|
479
|
+
bundle.bundle_variant_id ?? bundle.variant_id ?? bundle.product_variant_id ?? 0,
|
|
480
|
+
bundle.bundle_group_id ?? bundle.group_id ?? ""
|
|
481
|
+
].join("|");
|
|
482
|
+
};
|
|
483
|
+
const mergeRulesBundlePrices = (currentBundle, rulesBundle) => {
|
|
484
|
+
if (!Array.isArray(rulesBundle))
|
|
485
|
+
return rulesBundle;
|
|
486
|
+
const currentByIdentity = /* @__PURE__ */ new Map();
|
|
487
|
+
(currentBundle || []).forEach((bundle) => {
|
|
488
|
+
if (!bundle || typeof bundle !== "object")
|
|
489
|
+
return;
|
|
490
|
+
currentByIdentity.set(getBundleIdentity(bundle), bundle);
|
|
491
|
+
});
|
|
492
|
+
return rulesBundle.map((bundle) => {
|
|
493
|
+
if (!bundle || typeof bundle !== "object")
|
|
494
|
+
return bundle;
|
|
495
|
+
const current = currentByIdentity.get(getBundleIdentity(bundle));
|
|
496
|
+
if (!current)
|
|
497
|
+
return bundle;
|
|
498
|
+
const bundleWithDisplayFields = {
|
|
499
|
+
...bundle,
|
|
500
|
+
...isEmptyOrderProductDisplayValue(bundle.cover) && !isEmptyOrderProductDisplayValue(current.cover) ? { cover: current.cover } : {}
|
|
501
|
+
};
|
|
502
|
+
const isProductPriceBundle = (bundle.price_type_ext ?? current.price_type_ext) === "product_price";
|
|
503
|
+
if (!isProductPriceBundle)
|
|
504
|
+
return bundleWithDisplayFields;
|
|
505
|
+
const sourcePrice = current.price ?? current.custom_price ?? current.original_price ?? current.bundle_selling_price;
|
|
506
|
+
const originalPrice = current.original_price ?? current.product_price ?? current.price ?? current.custom_price ?? sourcePrice;
|
|
507
|
+
return {
|
|
508
|
+
...bundleWithDisplayFields,
|
|
509
|
+
...sourcePrice !== void 0 ? { price: sourcePrice } : {},
|
|
510
|
+
...originalPrice !== void 0 ? { original_price: originalPrice } : {},
|
|
511
|
+
...current.original_total !== void 0 ? { original_total: current.original_total } : {}
|
|
512
|
+
};
|
|
513
|
+
});
|
|
113
514
|
};
|
|
114
515
|
return {
|
|
115
|
-
getProduct: product => {
|
|
116
|
-
|
|
516
|
+
getProduct: (product) => {
|
|
517
|
+
var _a, _b, _c, _d, _e, _f;
|
|
117
518
|
const metadataAny = product.metadata || {};
|
|
118
|
-
const optionSum = sumOptionUnitPrice(product
|
|
519
|
+
const optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
|
|
119
520
|
let sourcePrice;
|
|
120
|
-
if (metadataAny.source_product_price !==
|
|
521
|
+
if (metadataAny.source_product_price !== void 0) {
|
|
121
522
|
sourcePrice = String(metadataAny.source_product_price);
|
|
122
|
-
} else if (metadataAny.main_product_selling_price !==
|
|
123
|
-
sourcePrice = new
|
|
523
|
+
} else if (metadataAny.main_product_selling_price !== void 0) {
|
|
524
|
+
sourcePrice = new import_decimal.default(
|
|
525
|
+
Number(metadataAny.main_product_selling_price) || 0
|
|
526
|
+
).minus(optionSum).toDecimalPlaces(2).toString();
|
|
124
527
|
} else {
|
|
125
528
|
sourcePrice = String(product.selling_price ?? 0);
|
|
126
529
|
}
|
|
127
530
|
let sourceOriginalPrice;
|
|
128
|
-
if (metadataAny.source_product_price !==
|
|
531
|
+
if (metadataAny.source_product_price !== void 0) {
|
|
129
532
|
sourceOriginalPrice = String(metadataAny.source_product_price);
|
|
130
|
-
} else if (metadataAny.main_product_original_price !==
|
|
131
|
-
sourceOriginalPrice = new
|
|
533
|
+
} else if (metadataAny.main_product_original_price !== void 0) {
|
|
534
|
+
sourceOriginalPrice = new import_decimal.default(
|
|
535
|
+
Number(metadataAny.main_product_original_price) || 0
|
|
536
|
+
).minus(optionSum).toDecimalPlaces(2).toString();
|
|
132
537
|
} else {
|
|
133
538
|
sourceOriginalPrice = sourcePrice;
|
|
134
539
|
}
|
|
@@ -136,47 +541,48 @@ function createDefaultOrderRulesHooks() {
|
|
|
136
541
|
id: product.product_id,
|
|
137
542
|
// Rules 引擎用 _id 作为 processedProductsMap 键;必须与购物车行级 identity 一致,
|
|
138
543
|
// 否则同 SKU 不同小料会在 calcDiscount 重组时互相覆盖。
|
|
139
|
-
// 不透明 identity 契约下,normalizeOrderProduct /
|
|
544
|
+
// 不透明 identity 契约下,normalizeOrderProduct / hydrate 已保证唯一值存在;
|
|
140
545
|
// 留 fingerprint 分支仅作 Rules 单测里直接传裸 product 时的兜底。
|
|
141
|
-
_id: product.
|
|
546
|
+
_id: ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) ? `${product.product_id}_${product.product_variant_id}_${product.metadata.unique_identification_number}` : `${product.product_id}_${product.product_variant_id}_${(0, import_utils2.buildProductLineFingerprint)(
|
|
547
|
+
getProductSkuOptions(product),
|
|
548
|
+
product.product_bundle
|
|
549
|
+
)}`,
|
|
142
550
|
// Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
|
|
143
551
|
// 所以这里必须喂 source-level(不含 option、不含 bundle、不含折扣)单价,避免双加 option。
|
|
144
552
|
price: sourcePrice,
|
|
145
553
|
// total / origin_total 使用 composite × num,跟 Rules 内部产出的 total 对齐(含 option + bundle)。
|
|
146
|
-
total: new
|
|
147
|
-
origin_total: new
|
|
554
|
+
total: new import_decimal.default(product.selling_price || 0).times(product.num || 1).toNumber(),
|
|
555
|
+
origin_total: new import_decimal.default(
|
|
556
|
+
product.original_price || product.selling_price || 0
|
|
557
|
+
).times(product.num || 1).toNumber(),
|
|
148
558
|
original_price: sourceOriginalPrice,
|
|
149
559
|
quantity: product.num || 1,
|
|
150
560
|
num: product.num || 1,
|
|
151
561
|
discount_list: product.discount_list || [],
|
|
152
562
|
bundle: product.product_bundle || [],
|
|
153
|
-
booking_id: product.
|
|
563
|
+
booking_id: ((_b = product.metadata) == null ? void 0 : _b.booking_id) || null,
|
|
154
564
|
isClient: false,
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
565
|
+
// 勿写死 false:否则 Rules 不会走 total≠origin_total 的手动价推断,
|
|
566
|
+
// 无券时会把 bundle 价还原成 original_price(手动改价套餐会从 20 回到 30)。
|
|
567
|
+
isManualDiscount: resolveRulesManualDiscountFlag(metadataAny),
|
|
568
|
+
holder_id: (_c = product.metadata) == null ? void 0 : _c.holder_id,
|
|
569
|
+
startDate: ((_d = product.metadata) == null ? void 0 : _d.start_date) || ((_e = product.metadata) == null ? void 0 : _e.startDate),
|
|
570
|
+
main_product_selling_price: metadataAny.main_product_selling_price !== void 0 ? new import_decimal.default(Number(metadataAny.main_product_selling_price) || 0).minus(optionSum).toDecimalPlaces(2).toString() : void 0,
|
|
571
|
+
inPromotion: ((_f = metadataAny._promotion) == null ? void 0 : _f.inPromotion) === true,
|
|
572
|
+
_promotion: metadataAny._promotion
|
|
158
573
|
};
|
|
159
574
|
},
|
|
160
575
|
setProduct: (product, values) => {
|
|
161
576
|
const nextNum = Number(values.quantity ?? product.num ?? 1) || 1;
|
|
162
577
|
const metadataAny = product.metadata || {};
|
|
163
|
-
const existedSource = metadataAny.source_product_price ?? product.selling_price ??
|
|
164
|
-
const nextOptions = product
|
|
578
|
+
const existedSource = metadataAny.source_product_price ?? product.selling_price ?? "0";
|
|
579
|
+
const nextOptions = getProductSkuOptions(product);
|
|
165
580
|
const optionSum = sumOptionUnitPrice(nextOptions);
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
// 券前 source:values.original_price 是 source-level(Rules 层本就不含 option),
|
|
173
|
-
// 缺省时保留现有 source(券前 = 当前 source)。
|
|
174
|
-
const nextSourceOriginalPrice = values.original_price !== undefined ? String(values.original_price) : String(existedSource);
|
|
175
|
-
|
|
176
|
-
// 含 option 的 main_product_*
|
|
177
|
-
const nextMainSellingPrice = new _decimal.default(Number(nextSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
178
|
-
const nextMainOriginalPrice = new _decimal.default(Number(nextSourceOriginalPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
179
|
-
const nextBundle = values.bundle ?? product.product_bundle;
|
|
581
|
+
const nextSourceSellingPrice = values.main_product_selling_price !== void 0 ? String(values.main_product_selling_price) : values.price !== void 0 ? String(values.price) : values.total !== void 0 ? toUnitPriceString(values.total, nextNum) : String(existedSource);
|
|
582
|
+
const nextSourceOriginalPrice = values.original_price !== void 0 ? String(values.original_price) : String(existedSource);
|
|
583
|
+
const nextMainSellingPrice = new import_decimal.default(Number(nextSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
584
|
+
const nextMainOriginalPrice = new import_decimal.default(Number(nextSourceOriginalPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
585
|
+
const nextBundle = values.bundle !== void 0 ? mergeRulesBundlePrices(product.product_bundle, values.bundle) : product.product_bundle;
|
|
180
586
|
const composedSellingPrice = composeLinePrice({
|
|
181
587
|
mainPrice: nextMainSellingPrice,
|
|
182
588
|
bundle: nextBundle
|
|
@@ -186,10 +592,14 @@ function createDefaultOrderRulesHooks() {
|
|
|
186
592
|
bundle: nextBundle,
|
|
187
593
|
useOriginalBundle: true
|
|
188
594
|
});
|
|
595
|
+
const finalOriginalPrice = resolveManualOverrideLineOriginalPrice(
|
|
596
|
+
{ num: nextNum, metadata: metadataAny, lineOriginalPrice: product.original_price },
|
|
597
|
+
composedOriginalPrice
|
|
598
|
+
);
|
|
189
599
|
return {
|
|
190
600
|
...product,
|
|
191
601
|
selling_price: composedSellingPrice,
|
|
192
|
-
original_price:
|
|
602
|
+
original_price: finalOriginalPrice,
|
|
193
603
|
discount_list: values.discount_list ?? product.discount_list,
|
|
194
604
|
num: values.quantity ?? product.num,
|
|
195
605
|
product_bundle: nextBundle,
|
|
@@ -204,73 +614,47 @@ function createDefaultOrderRulesHooks() {
|
|
|
204
614
|
}
|
|
205
615
|
};
|
|
206
616
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
*/
|
|
213
|
-
const generateDuration = cartItem => {
|
|
214
|
-
const startDate = (0, _dayjs.default)(`${cartItem.start_date} ${cartItem.start_time}`);
|
|
215
|
-
const endDate = (0, _dayjs.default)(`${cartItem.end_date} ${cartItem.end_time}`);
|
|
216
|
-
const duration = endDate.diff(startDate, 'minutes');
|
|
217
|
-
return {
|
|
218
|
-
duration,
|
|
219
|
-
durationType: 'minutes'
|
|
220
|
-
};
|
|
617
|
+
var generateDuration = (cartItem) => {
|
|
618
|
+
const startDate = (0, import_dayjs.default)(`${cartItem.start_date} ${cartItem.start_time}`);
|
|
619
|
+
const endDate = (0, import_dayjs.default)(`${cartItem.end_date} ${cartItem.end_time}`);
|
|
620
|
+
const duration = endDate.diff(startDate, "minutes");
|
|
621
|
+
return { duration, durationType: "minutes" };
|
|
221
622
|
};
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
form_id
|
|
233
|
-
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
if (!acc[form_id]) {
|
|
237
|
-
acc[form_id] = {
|
|
238
|
-
form_id,
|
|
239
|
-
form_record_ids: []
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// 兼容 form_record_id 可能是数组或单个数字
|
|
244
|
-
const ids = Array.isArray(form_record_ids) ? form_record_ids : [form_record_ids];
|
|
245
|
-
// 过滤掉空值(null、undefined等)
|
|
246
|
-
const validIds = ids.filter(id => id != null);
|
|
247
|
-
acc[form_id].form_record_ids.push(...validIds);
|
|
248
|
-
// 去重
|
|
249
|
-
acc[form_id].form_record_ids = [...new Set(acc[form_id].form_record_ids)];
|
|
250
|
-
return acc;
|
|
251
|
-
}, {})).filter(item => item.form_record_ids.length > 0); // 过滤掉没有有效记录的表单
|
|
623
|
+
var mergeRelationForms = (relationForms) => {
|
|
624
|
+
return Object.values(
|
|
625
|
+
relationForms.reduce((acc, cur) => {
|
|
626
|
+
const { form_id, form_record_ids } = cur;
|
|
627
|
+
if (!acc[form_id]) {
|
|
628
|
+
acc[form_id] = { form_id, form_record_ids: [] };
|
|
629
|
+
}
|
|
630
|
+
const ids = Array.isArray(form_record_ids) ? form_record_ids : [form_record_ids];
|
|
631
|
+
const validIds = ids.filter((id) => id != null);
|
|
632
|
+
acc[form_id].form_record_ids.push(...validIds);
|
|
633
|
+
acc[form_id].form_record_ids = [...new Set(acc[form_id].form_record_ids)];
|
|
634
|
+
return acc;
|
|
635
|
+
}, {})
|
|
636
|
+
).filter((item) => item.form_record_ids.length > 0);
|
|
252
637
|
};
|
|
253
|
-
exports.mergeRelationForms = mergeRelationForms;
|
|
254
638
|
function getCustomerIdFromStorage(window) {
|
|
639
|
+
var _a;
|
|
255
640
|
try {
|
|
256
|
-
const customer = JSON.parse(window
|
|
257
|
-
const customerId = Number(customer
|
|
258
|
-
return Number.isFinite(customerId) && customerId > 0 ? customerId :
|
|
641
|
+
const customer = JSON.parse(((_a = window == null ? void 0 : window.getLocalStorage) == null ? void 0 : _a.call(window, "customer")) || "{}");
|
|
642
|
+
const customerId = Number(customer == null ? void 0 : customer.id);
|
|
643
|
+
return Number.isFinite(customerId) && customerId > 0 ? customerId : void 0;
|
|
259
644
|
} catch {
|
|
260
|
-
return
|
|
645
|
+
return void 0;
|
|
261
646
|
}
|
|
262
647
|
}
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* 为购物车行补齐订单所需的 holder 信息(与 cartAccount 结构保持一致)
|
|
266
|
-
*/
|
|
267
648
|
function ensureCartItemOriginHolder(cartItem, window) {
|
|
268
|
-
|
|
649
|
+
var _a;
|
|
650
|
+
if ((_a = cartItem == null ? void 0 : cartItem._origin) == null ? void 0 : _a.holder) {
|
|
269
651
|
return;
|
|
270
652
|
}
|
|
271
|
-
const holderConfig = (0,
|
|
272
|
-
|
|
273
|
-
|
|
653
|
+
const holderConfig = (0, import_utils.getProductHolderConfig)(
|
|
654
|
+
(cartItem == null ? void 0 : cartItem._productInit) ?? (cartItem == null ? void 0 : cartItem._productOrigin)
|
|
655
|
+
);
|
|
656
|
+
const formRecordId = cartItem == null ? void 0 : cartItem.holder_id;
|
|
657
|
+
if (!(holderConfig == null ? void 0 : holderConfig.resource_id) || formRecordId == null) {
|
|
274
658
|
return;
|
|
275
659
|
}
|
|
276
660
|
cartItem._origin.holder = {
|
|
@@ -279,33 +663,24 @@ function ensureCartItemOriginHolder(cartItem, window) {
|
|
|
279
663
|
form_record: [formRecordId]
|
|
280
664
|
};
|
|
281
665
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
let discountList = cartItem
|
|
285
|
-
(cartItem
|
|
286
|
-
discountList = [...discountList, ...(item
|
|
287
|
-
item.discount_list =
|
|
666
|
+
var getAllDiscountList = (cartItem) => {
|
|
667
|
+
var _a, _b, _c, _d;
|
|
668
|
+
let discountList = ((_b = (_a = cartItem == null ? void 0 : cartItem._origin) == null ? void 0 : _a.product) == null ? void 0 : _b.discount_list) || [];
|
|
669
|
+
(((_d = (_c = cartItem == null ? void 0 : cartItem._origin) == null ? void 0 : _c.product) == null ? void 0 : _d.product_bundle) || []).forEach((item) => {
|
|
670
|
+
discountList = [...discountList, ...(item == null ? void 0 : item.discount_list) || []];
|
|
671
|
+
item.discount_list = void 0;
|
|
288
672
|
});
|
|
289
673
|
return discountList;
|
|
290
674
|
};
|
|
291
|
-
|
|
292
|
-
// ─── 以下为从 ScanOrder/utils.ts 迁入的 Order 专属工具函数 ───
|
|
293
|
-
exports.getAllDiscountList = getAllDiscountList;
|
|
294
|
-
function createUuidV4() {
|
|
295
|
-
const template = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
|
296
|
-
return template.replace(/[xy]/g, char => {
|
|
297
|
-
const randomValue = Math.floor(Math.random() * 16);
|
|
298
|
-
const value = char === 'x' ? randomValue : randomValue & 0x3 | 0x8;
|
|
299
|
-
return value.toString(16);
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
675
|
function isTempOrder(data) {
|
|
303
|
-
if (!data || typeof data !==
|
|
304
|
-
|
|
676
|
+
if (!data || typeof data !== "object")
|
|
677
|
+
return false;
|
|
678
|
+
if (!Array.isArray(data.products))
|
|
679
|
+
return false;
|
|
305
680
|
return true;
|
|
306
681
|
}
|
|
307
682
|
function formatDateTime(date) {
|
|
308
|
-
const pad = value => value.toString().padStart(2,
|
|
683
|
+
const pad = (value) => value.toString().padStart(2, "0");
|
|
309
684
|
const year = date.getFullYear();
|
|
310
685
|
const month = pad(date.getMonth() + 1);
|
|
311
686
|
const day = pad(date.getDate());
|
|
@@ -315,70 +690,89 @@ function formatDateTime(date) {
|
|
|
315
690
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
316
691
|
}
|
|
317
692
|
function normalizeSubmitPlatform(platform) {
|
|
318
|
-
|
|
693
|
+
const value = String(platform || "").trim();
|
|
694
|
+
if (!value)
|
|
695
|
+
return "H5";
|
|
696
|
+
const lower = value.toLowerCase();
|
|
697
|
+
if (lower === "pc")
|
|
698
|
+
return "PC";
|
|
699
|
+
if (lower === "h5")
|
|
700
|
+
return "H5";
|
|
701
|
+
return value;
|
|
319
702
|
}
|
|
320
|
-
|
|
321
|
-
// 出站重命名:后端 checkout 协议字段 option_group_item_id;
|
|
322
|
-
// tempOrder / UI 运行时一律使用 product_option_item_id。仅保留后端契约字段,
|
|
323
|
-
// 与 src/modules/Cart/utils/cartProduct.ts#formatOptionsToOrigin 形状一致。
|
|
324
703
|
function formatSubmitOptionItems(options) {
|
|
325
|
-
if (!Array.isArray(options))
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
704
|
+
if (!Array.isArray(options))
|
|
705
|
+
return [];
|
|
706
|
+
return options.map((d) => {
|
|
707
|
+
const option = {
|
|
708
|
+
...d && typeof d === "object" ? d : {},
|
|
709
|
+
num: d == null ? void 0 : d.num,
|
|
710
|
+
option_group_item_id: d == null ? void 0 : d.option_group_item_id,
|
|
711
|
+
option_group_id: d == null ? void 0 : d.option_group_id
|
|
712
|
+
};
|
|
713
|
+
const addPrice = (d == null ? void 0 : d.add_price) ?? (d == null ? void 0 : d.price);
|
|
714
|
+
if (addPrice !== void 0)
|
|
715
|
+
option.add_price = String(addPrice);
|
|
716
|
+
delete option.price;
|
|
717
|
+
return option;
|
|
718
|
+
});
|
|
331
719
|
}
|
|
332
720
|
function toBundleNumber(value, fallback = 0) {
|
|
333
721
|
const parsed = Number(value);
|
|
334
722
|
return Number.isFinite(parsed) ? parsed : fallback;
|
|
335
723
|
}
|
|
336
|
-
function
|
|
724
|
+
function toMoneyString(value) {
|
|
337
725
|
const parsed = Number(value);
|
|
338
|
-
if (Number.isFinite(parsed))
|
|
339
|
-
|
|
726
|
+
if (Number.isFinite(parsed))
|
|
727
|
+
return parsed.toFixed(2);
|
|
728
|
+
if (value === null || value === void 0 || value === "")
|
|
729
|
+
return "0.00";
|
|
340
730
|
return String(value);
|
|
341
731
|
}
|
|
342
|
-
|
|
343
|
-
// 出站补齐:以 additive 方式把 bundle 项补足为后端 checkout 协议所需的形状,
|
|
344
|
-
// 同时把 Summary / Rules 运行时写到 bundle 顶层的 surcharge_fee / relation_surcharge_ids
|
|
345
|
-
// 和来自 _origin 的 product_discount_difference 汇总到 metadata。
|
|
346
|
-
// 保留原对象上已有字段(如 discount_list、metadata.custom_product_bundle_map_id)
|
|
347
|
-
// 以兼容运行时 bundle 归一化、Rules、Summary 的消费。
|
|
348
732
|
function formatSubmitBundleItems(bundle) {
|
|
349
|
-
if (!Array.isArray(bundle))
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
const
|
|
353
|
-
const
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
733
|
+
if (!Array.isArray(bundle))
|
|
734
|
+
return [];
|
|
735
|
+
return bundle.map((b) => {
|
|
736
|
+
const rawBundle = b && typeof b === "object" ? b : {};
|
|
737
|
+
const existedMetadata = rawBundle.metadata && typeof rawBundle.metadata === "object" ? rawBundle.metadata : {};
|
|
738
|
+
const {
|
|
739
|
+
custom_product_bundle_map_id: _customProductBundleMapId,
|
|
740
|
+
...submitMetadata
|
|
741
|
+
} = existedMetadata;
|
|
742
|
+
const sellingPrice = getBundleSellingMagnitude(rawBundle).toFixed(2);
|
|
743
|
+
const paymentPrice = rawBundle.bundle_payment_price !== void 0 && rawBundle.bundle_payment_price !== null && rawBundle.bundle_payment_price !== "" ? toMoneyString(rawBundle.bundle_payment_price) : sellingPrice;
|
|
744
|
+
const priceValue = rawBundle.price ?? rawBundle.custom_price ?? rawBundle.bundle_selling_price;
|
|
360
745
|
const relationSurchargeIds = Array.isArray(rawBundle.relation_surcharge_ids) ? rawBundle.relation_surcharge_ids : Array.isArray(existedMetadata.relation_surcharge_ids) ? existedMetadata.relation_surcharge_ids : [];
|
|
361
|
-
const surchargeFee =
|
|
362
|
-
|
|
746
|
+
const surchargeFee = toMoneyString(
|
|
747
|
+
rawBundle.surcharge_fee ?? existedMetadata.surcharge_fee
|
|
748
|
+
);
|
|
749
|
+
const productDiscountDifference = toBundleNumber(
|
|
750
|
+
existedMetadata.product_discount_difference,
|
|
751
|
+
0
|
|
752
|
+
);
|
|
753
|
+
const num = toBundleNumber(rawBundle.num ?? rawBundle.quantity, 1);
|
|
754
|
+
const bundleMapId = resolveSubmitBundleMapId(rawBundle);
|
|
755
|
+
const hasSubmitBundleDiscounts = Array.isArray(rawBundle.discount_list) && rawBundle.discount_list.length > 0;
|
|
363
756
|
return {
|
|
364
|
-
...rawBundle,
|
|
365
757
|
is_charge_tax: rawBundle.is_charge_tax ?? 0,
|
|
366
|
-
tax_fee: toBundleNumber(rawBundle.tax_fee, 0),
|
|
367
758
|
bundle_variant_id: rawBundle.bundle_variant_id ?? 0,
|
|
368
|
-
num
|
|
759
|
+
num,
|
|
760
|
+
quantity: toBundleNumber(rawBundle.quantity ?? rawBundle.num, num),
|
|
369
761
|
extension_id: rawBundle.extension_id ?? 0,
|
|
370
|
-
extension_type: rawBundle.extension_type ??
|
|
371
|
-
price:
|
|
372
|
-
price_type:
|
|
373
|
-
price_type_ext: rawBundle.price_type_ext ??
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
bundle_selling_price: sellingPriceNum,
|
|
762
|
+
extension_type: rawBundle.extension_type ?? "normal",
|
|
763
|
+
price: priceValue,
|
|
764
|
+
price_type: rawBundle.price_type ?? rawBundle.custom_price_type ?? "",
|
|
765
|
+
price_type_ext: rawBundle.price_type_ext ?? rawBundle.custom_price_type_ext ?? "",
|
|
766
|
+
bundle_selling_price: sellingPrice,
|
|
767
|
+
bundle_payment_price: paymentPrice,
|
|
377
768
|
option: formatSubmitOptionItems(rawBundle.option),
|
|
378
|
-
bundle_group_id: rawBundle
|
|
379
|
-
bundle_id: rawBundle
|
|
769
|
+
bundle_group_id: (rawBundle == null ? void 0 : rawBundle.bundle_group_id) ?? (rawBundle == null ? void 0 : rawBundle.group_id),
|
|
770
|
+
bundle_id: (rawBundle == null ? void 0 : rawBundle.bundle_id) ?? (rawBundle == null ? void 0 : rawBundle.id),
|
|
771
|
+
bundle_product_id: (rawBundle == null ? void 0 : rawBundle.bundle_product_id) ?? (rawBundle == null ? void 0 : rawBundle._bundle_product_id),
|
|
772
|
+
cover: rawBundle.cover,
|
|
380
773
|
metadata: {
|
|
381
|
-
...
|
|
774
|
+
...submitMetadata,
|
|
775
|
+
...hasSubmitBundleDiscounts && bundleMapId !== void 0 ? { custom_product_bundle_map_id: bundleMapId } : {},
|
|
382
776
|
surcharge_fee: surchargeFee,
|
|
383
777
|
relation_surcharge_ids: relationSurchargeIds,
|
|
384
778
|
product_discount_difference: productDiscountDifference
|
|
@@ -386,266 +780,543 @@ function formatSubmitBundleItems(bundle) {
|
|
|
386
780
|
};
|
|
387
781
|
});
|
|
388
782
|
}
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* 把 tempOrder product 打包成出站 submit payload。
|
|
392
|
-
*
|
|
393
|
-
* 价格字段语义(出站口径,v2 composite):
|
|
394
|
-
* - `selling_price`:**行 composite 券后单价**
|
|
395
|
-
* = `metadata.main_product_selling_price` + Σ(bundle_selling_price × num)。
|
|
396
|
-
* - `original_price`:**行 composite 券前单价**
|
|
397
|
-
* = `metadata.main_product_original_price` + Σ(bundle 原价 × num)。
|
|
398
|
-
* - `payment_price`:兼容后端的出站字段,直接从 `selling_price` 派生(composite)。
|
|
399
|
-
* - `metadata.source_product_price`:主商品/variant 基础价(不含 option、不含折扣),权威源。
|
|
400
|
-
* - `metadata.main_product_original_price`:含 option、不含折扣。
|
|
401
|
-
* - `metadata.main_product_selling_price`:含 option、含主商品折扣。
|
|
402
|
-
* - `metadata.price_schema_version`:schema 版本号(当前 = 2),用于跨端协商价格口径。
|
|
403
|
-
*
|
|
404
|
-
* 本函数不再改造价格字段形状,仅做字段/metadata 裁剪。
|
|
405
|
-
*/
|
|
406
783
|
function normalizeSubmitProduct(product) {
|
|
784
|
+
var _a;
|
|
785
|
+
const { unique_identification_number: _runtimeUid, ...submitProduct } = product;
|
|
407
786
|
const {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
787
|
+
num,
|
|
788
|
+
surcharge_fee: _productSurchargeFee,
|
|
789
|
+
discount_amount: _deprecatedDiscountAmount,
|
|
790
|
+
discount_type: _deprecatedDiscountType,
|
|
791
|
+
discountway: _deprecatedDiscountway,
|
|
792
|
+
product_discount_reason: _deprecatedProductDiscountReason,
|
|
793
|
+
discount_per: _deprecatedDiscountPer,
|
|
794
|
+
...productRest
|
|
795
|
+
} = submitProduct;
|
|
796
|
+
delete productRest[`product_${"option"}_item`];
|
|
412
797
|
const rawMetadata = submitProduct.metadata || {};
|
|
413
798
|
const bookingUid = rawMetadata.booking_uid;
|
|
414
799
|
const cleanMetadata = {};
|
|
415
800
|
if (rawMetadata.unique_identification_number) {
|
|
416
801
|
cleanMetadata.unique_identification_number = rawMetadata.unique_identification_number;
|
|
417
802
|
}
|
|
418
|
-
const priceMetaKeys = [
|
|
803
|
+
const priceMetaKeys = [
|
|
804
|
+
"main_product_original_price",
|
|
805
|
+
"main_product_selling_price",
|
|
806
|
+
"main_product_attached_bundle_selling_price",
|
|
807
|
+
"main_product_attached_bundle_payment_price",
|
|
808
|
+
"average_discount_amount_rate",
|
|
809
|
+
"source_product_price",
|
|
810
|
+
"main_product_attached_bundle_surcharge_fee",
|
|
811
|
+
"main_product_attached_bundle_tax_fee",
|
|
812
|
+
"surcharge_rounding_remainder",
|
|
813
|
+
"tax_fee_rounding_remainder",
|
|
814
|
+
"relation_surcharge_ids",
|
|
815
|
+
"discountable_flag",
|
|
816
|
+
"parent_unique_identification_number",
|
|
817
|
+
"product_add_schedule_time"
|
|
818
|
+
];
|
|
419
819
|
for (const key of priceMetaKeys) {
|
|
420
|
-
if (rawMetadata[key] !==
|
|
820
|
+
if (rawMetadata[key] !== void 0) {
|
|
421
821
|
cleanMetadata[key] = rawMetadata[key];
|
|
422
822
|
}
|
|
423
823
|
}
|
|
824
|
+
cleanMetadata.product_discount_difference = rawMetadata.product_discount_difference ?? "";
|
|
424
825
|
if (rawMetadata.price_breakdown) {
|
|
425
826
|
cleanMetadata.price_breakdown = rawMetadata.price_breakdown;
|
|
426
827
|
}
|
|
427
|
-
if (rawMetadata.is_rule !==
|
|
828
|
+
if (rawMetadata.is_rule !== void 0) {
|
|
428
829
|
cleanMetadata.is_rule = rawMetadata.is_rule;
|
|
429
830
|
}
|
|
831
|
+
if (rawMetadata.holder_config !== void 0) {
|
|
832
|
+
cleanMetadata.holder_config = rawMetadata.holder_config;
|
|
833
|
+
}
|
|
834
|
+
const productSku = {
|
|
835
|
+
...submitProduct.product_sku && typeof submitProduct.product_sku === "object" ? submitProduct.product_sku : {},
|
|
836
|
+
option: formatSubmitOptionItems((_a = submitProduct.product_sku) == null ? void 0 : _a.option)
|
|
837
|
+
};
|
|
430
838
|
return {
|
|
431
|
-
...
|
|
432
|
-
...
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
discount_list: submitProduct.discount_list || [],
|
|
839
|
+
...productRest,
|
|
840
|
+
...bookingUid ? { booking_uid: bookingUid } : {},
|
|
841
|
+
product_quantity: toBundleNumber(num ?? submitProduct.product_quantity, 1),
|
|
842
|
+
product_sku: productSku,
|
|
843
|
+
discount_list: collectSubmitProductDiscountList(submitProduct),
|
|
437
844
|
product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
|
|
438
845
|
metadata: cleanMetadata,
|
|
439
|
-
// 出站兼容:后端消费 payment_price
|
|
440
|
-
//
|
|
441
|
-
payment_price: submitProduct.selling_price
|
|
846
|
+
// 出站兼容:后端消费 payment_price 字段(行 composite 已减整单折扣均摊)。
|
|
847
|
+
// 由整单折扣均摊层产出;缺省(无折扣)时与 selling_price 同义。
|
|
848
|
+
payment_price: submitProduct.payment_price ?? submitProduct.selling_price
|
|
442
849
|
};
|
|
443
850
|
}
|
|
444
|
-
|
|
851
|
+
var SUBMIT_BOOKING_METADATA_WHITELIST = [
|
|
852
|
+
"unique_identification_number",
|
|
853
|
+
"collect_pax",
|
|
854
|
+
"capacity",
|
|
855
|
+
"holder_id",
|
|
856
|
+
"resource_select_type",
|
|
857
|
+
"holder"
|
|
858
|
+
];
|
|
859
|
+
function normalizeBookingIsAll(booking) {
|
|
860
|
+
return booking.is_all === true || booking.is_all === 1 || booking.is_all === "1" || booking.is_all === "true" ? 1 : 0;
|
|
861
|
+
}
|
|
862
|
+
function normalizeBookingSubType(booking) {
|
|
863
|
+
if (normalizeBookingIsAll(booking) === 1)
|
|
864
|
+
return "days";
|
|
865
|
+
if (booking.sub_type !== void 0 && booking.sub_type !== null && booking.sub_type !== "") {
|
|
866
|
+
return String(booking.sub_type);
|
|
867
|
+
}
|
|
868
|
+
return "minutes";
|
|
869
|
+
}
|
|
445
870
|
function normalizeSubmitBooking(booking) {
|
|
446
871
|
const rawMetadata = booking.metadata || {};
|
|
447
872
|
const cleanMetadata = {};
|
|
448
873
|
for (const key of SUBMIT_BOOKING_METADATA_WHITELIST) {
|
|
449
|
-
if (rawMetadata[key] !==
|
|
874
|
+
if (rawMetadata[key] !== void 0) {
|
|
450
875
|
cleanMetadata[key] = rawMetadata[key];
|
|
451
876
|
}
|
|
452
877
|
}
|
|
878
|
+
if (cleanMetadata.holder_id === void 0)
|
|
879
|
+
cleanMetadata.holder_id = null;
|
|
880
|
+
const bookingRecord = booking;
|
|
881
|
+
const startDate = bookingRecord.start_date;
|
|
882
|
+
const shouldRestoreSelectDate = bookingRecord.select_date === void 0 || bookingRecord.select_date === null || bookingRecord.select_date === "";
|
|
883
|
+
const selectDateFromStartDate = typeof startDate === "string" ? startDate.split(/\s+/)[0] : startDate;
|
|
453
884
|
return {
|
|
454
885
|
...booking,
|
|
886
|
+
...shouldRestoreSelectDate && selectDateFromStartDate ? { select_date: selectDateFromStartDate } : {},
|
|
887
|
+
is_all: normalizeBookingIsAll(bookingRecord),
|
|
888
|
+
sub_type: normalizeBookingSubType(bookingRecord),
|
|
455
889
|
metadata: cleanMetadata
|
|
456
890
|
};
|
|
457
891
|
}
|
|
458
|
-
const DEFAULT_TABLE_OCCUPANCY_DURATION = 20;
|
|
459
|
-
function resolveTableOccupancyDuration(tempOrder) {
|
|
460
|
-
const metadata = tempOrder.metadata || {};
|
|
461
|
-
const candidates = [metadata.table_occupancy_duration, metadata.booking_duration, metadata.table_duration, metadata.duration, metadata.table_config?.occupancy_duration, metadata.tableConfig?.occupancy_duration, metadata.resource_config?.occupancy_duration, metadata.resourceConfig?.occupancy_duration];
|
|
462
|
-
for (const value of candidates) {
|
|
463
|
-
const duration = Number(value);
|
|
464
|
-
if (Number.isFinite(duration) && duration > 0) {
|
|
465
|
-
return Math.floor(duration);
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
return DEFAULT_TABLE_OCCUPANCY_DURATION;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
/** 提交用人数:有限且为正则向下取整,否则为 1 */
|
|
472
892
|
function normalizeSubmitCollectPaxValue(value) {
|
|
473
893
|
const n = Number(value);
|
|
474
894
|
return Number.isFinite(n) && n > 0 ? Math.floor(n) : 1;
|
|
475
895
|
}
|
|
476
|
-
|
|
477
|
-
/** 从临时订单 metadata 解析合成 booking 的 collect_pax */
|
|
478
896
|
function resolveSubmitCollectPax(tempOrder) {
|
|
479
|
-
|
|
897
|
+
var _a;
|
|
898
|
+
return normalizeSubmitCollectPaxValue((_a = tempOrder.metadata) == null ? void 0 : _a.collect_pax);
|
|
480
899
|
}
|
|
481
900
|
function createDefaultTempOrder(params) {
|
|
482
|
-
const summary = params.summary || (0, _utils2.createEmptySummary)();
|
|
483
901
|
return {
|
|
484
902
|
order_id: null,
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
903
|
+
external_sale_number: "",
|
|
904
|
+
order_number: null,
|
|
905
|
+
shop_order_number: null,
|
|
906
|
+
shop_full_order_number: null,
|
|
907
|
+
type: "",
|
|
908
|
+
business_code: void 0,
|
|
909
|
+
platform: "h5",
|
|
910
|
+
sales_channel: "my_pisel",
|
|
911
|
+
order_sales_channel: "online_store",
|
|
912
|
+
status: "normal",
|
|
913
|
+
payment_status: "payment_processing",
|
|
914
|
+
shipping_status: "unfulfilled",
|
|
915
|
+
customer_id: 0,
|
|
916
|
+
customer_name: "",
|
|
917
|
+
country_calling_code: "",
|
|
918
|
+
phone: "",
|
|
919
|
+
email: "",
|
|
920
|
+
customer: null,
|
|
503
921
|
is_price_include_tax: 1,
|
|
504
|
-
tax_title:
|
|
505
|
-
tax_country_code:
|
|
506
|
-
currency_code:
|
|
507
|
-
currency_symbol:
|
|
508
|
-
currency_format:
|
|
922
|
+
tax_title: "",
|
|
923
|
+
tax_country_code: "",
|
|
924
|
+
currency_code: "",
|
|
925
|
+
currency_symbol: "",
|
|
926
|
+
currency_format: "symbol_first",
|
|
509
927
|
is_deposit: 0,
|
|
510
|
-
deposit_amount:
|
|
511
|
-
shop_discount:
|
|
512
|
-
surcharge_fee:
|
|
513
|
-
note:
|
|
928
|
+
deposit_amount: "0.00",
|
|
929
|
+
shop_discount: "0.00",
|
|
930
|
+
surcharge_fee: "0.00",
|
|
931
|
+
note: "",
|
|
514
932
|
schedule_date: params.now,
|
|
515
|
-
created_at:
|
|
933
|
+
created_at: void 0,
|
|
934
|
+
request_unique_idempotency_token: "",
|
|
935
|
+
vouchers: [],
|
|
516
936
|
products: [],
|
|
517
937
|
bookings: [],
|
|
518
938
|
payments: [],
|
|
519
939
|
surcharges: [],
|
|
520
|
-
discount_list: [],
|
|
521
940
|
relation_forms: [],
|
|
522
941
|
contacts: [],
|
|
523
|
-
contacts_info:
|
|
942
|
+
contacts_info: null,
|
|
524
943
|
holder: null,
|
|
525
|
-
|
|
526
|
-
|
|
944
|
+
metadata: {},
|
|
945
|
+
_extend: {
|
|
946
|
+
productsByUid: {}
|
|
947
|
+
}
|
|
527
948
|
};
|
|
528
949
|
}
|
|
529
950
|
function buildSubmitPayload(params) {
|
|
951
|
+
var _a;
|
|
530
952
|
const {
|
|
531
953
|
tempOrder,
|
|
532
954
|
cacheId,
|
|
533
|
-
now = new Date(),
|
|
955
|
+
now = /* @__PURE__ */ new Date(),
|
|
534
956
|
platform,
|
|
535
957
|
businessCode,
|
|
536
958
|
channel,
|
|
537
959
|
type,
|
|
960
|
+
summary,
|
|
538
961
|
enhance
|
|
539
962
|
} = params;
|
|
540
963
|
const scheduleDate = tempOrder.schedule_date || tempOrder.created_at || formatDateTime(now);
|
|
541
|
-
const
|
|
542
|
-
const relationId = tempOrder.relation_id;
|
|
543
|
-
const tableFormId = tempOrder.table_form_id;
|
|
544
|
-
const bookingUuid = createUuidV4();
|
|
545
|
-
const bookingStart = (0, _dayjs.default)(now);
|
|
546
|
-
const bookingDuration = resolveTableOccupancyDuration(tempOrder);
|
|
547
|
-
const bookingEnd = bookingStart.add(bookingDuration, 'minute');
|
|
548
|
-
const bookings = relationId && tableFormId ? [{
|
|
549
|
-
relation_id: 0,
|
|
550
|
-
form_id: 0,
|
|
551
|
-
start_time: bookingStart.format('HH:mm'),
|
|
552
|
-
start_date: bookingStart.format('YYYY-MM-DD'),
|
|
553
|
-
end_time: bookingEnd.format('HH:mm'),
|
|
554
|
-
end_date: bookingEnd.format('YYYY-MM-DD'),
|
|
555
|
-
duration: bookingDuration,
|
|
556
|
-
metadata: {
|
|
557
|
-
unique_identification_number: bookingUuid,
|
|
558
|
-
collect_pax: resolveSubmitCollectPax(tempOrder)
|
|
559
|
-
},
|
|
560
|
-
select_date: bookingStart.format('YYYY-MM-DD'),
|
|
561
|
-
is_all: false,
|
|
562
|
-
like_status: 'common',
|
|
563
|
-
schedule_id: 0,
|
|
564
|
-
relation_type: '',
|
|
565
|
-
number: 1
|
|
566
|
-
}] : tempOrder.bookings || [];
|
|
567
|
-
const formRecordIds = relationId && tableFormId ? [{
|
|
568
|
-
form_id: tableFormId,
|
|
569
|
-
form_record_id: relationId
|
|
570
|
-
}] : undefined;
|
|
964
|
+
const bookingUuid = (0, import_orderCollectionIdentity.createUuidV4)();
|
|
571
965
|
const {
|
|
572
|
-
|
|
966
|
+
_extend,
|
|
967
|
+
relation_id: _relationId,
|
|
968
|
+
table_form_id: _tableFormId,
|
|
969
|
+
resource_id: _resourceId,
|
|
573
970
|
summary: _summary,
|
|
574
|
-
|
|
971
|
+
lastOrderInfo: _lastOrderInfo,
|
|
972
|
+
paid_amount: _paidAmount,
|
|
973
|
+
shop_id: _shopId,
|
|
974
|
+
shop_note: _shopNote,
|
|
975
|
+
shop_service_type: _shopServiceType,
|
|
976
|
+
start_time: _startTime,
|
|
977
|
+
customer: _customer,
|
|
978
|
+
discount_list: _discountList,
|
|
979
|
+
tax_fee: _rootTaxFee,
|
|
980
|
+
total_amount: _totalAmount,
|
|
981
|
+
total_refund_amount: _totalRefundAmount,
|
|
982
|
+
create_date: _createDate,
|
|
983
|
+
holder_id: _holderId,
|
|
575
984
|
...tempOrderRest
|
|
576
985
|
} = tempOrder;
|
|
986
|
+
let submitType = type ?? tempOrder.type;
|
|
987
|
+
if (!submitType) {
|
|
988
|
+
if ((_a = tempOrder == null ? void 0 : tempOrder.bookings) == null ? void 0 : _a.length) {
|
|
989
|
+
submitType = "appointment_booking";
|
|
990
|
+
} else {
|
|
991
|
+
submitType = "virtual";
|
|
992
|
+
}
|
|
993
|
+
}
|
|
577
994
|
const payload = {
|
|
578
995
|
...tempOrderRest,
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
996
|
+
customer_id: tempOrder.customer_id ?? 1,
|
|
997
|
+
customer_name: tempOrder.customer_name || "Walk-In",
|
|
998
|
+
order_number: tempOrder.order_number ?? null,
|
|
999
|
+
shop_order_number: tempOrder.shop_order_number ?? null,
|
|
1000
|
+
shop_full_order_number: tempOrder.shop_full_order_number ?? null,
|
|
1001
|
+
platform: normalizeSubmitPlatform(platform),
|
|
1002
|
+
request_unique_idempotency_token: (params == null ? void 0 : params.request_unique_idempotency_token) || tempOrder.request_unique_idempotency_token || `${tempOrder.external_sale_number}_${now.getTime()}`,
|
|
1003
|
+
type: submitType,
|
|
1004
|
+
business_code: businessCode ?? tempOrder.business_code,
|
|
1005
|
+
sales_channel: tempOrder.sales_channel || "my_pisel",
|
|
1006
|
+
order_sales_channel: channel ?? tempOrder.order_sales_channel ?? "online_store",
|
|
1007
|
+
status: tempOrder.status || "normal",
|
|
1008
|
+
payment_status: tempOrder.payment_status || "payment_processing",
|
|
587
1009
|
// shipping_status: tempOrder.shipping_status || 'unfulfilled',
|
|
588
1010
|
is_price_include_tax: tempOrder.is_price_include_tax ?? 1,
|
|
589
|
-
currency_format: tempOrder.currency_format ||
|
|
1011
|
+
currency_format: tempOrder.currency_format || "symbol_first",
|
|
590
1012
|
is_deposit: tempOrder.is_deposit ?? 0,
|
|
591
|
-
deposit_amount: tempOrder.deposit_amount ||
|
|
592
|
-
shop_discount: tempOrder.shop_discount ||
|
|
593
|
-
surcharge_fee:
|
|
594
|
-
note: tempOrder.note ||
|
|
1013
|
+
deposit_amount: tempOrder.deposit_amount || "0.00",
|
|
1014
|
+
shop_discount: tempOrder.shop_discount || "0.00",
|
|
1015
|
+
surcharge_fee: tempOrder.surcharge_fee || "0.00",
|
|
1016
|
+
note: tempOrder.note || "",
|
|
1017
|
+
delivery_type: tempOrder.delivery_type || "nil",
|
|
595
1018
|
schedule_date: scheduleDate,
|
|
596
|
-
|
|
1019
|
+
// created_at: tempOrder.created_at || formatDateTime(now), 和后端协定这个字段先不提交到接口
|
|
1020
|
+
bookings: (tempOrder.bookings || []).filter(
|
|
1021
|
+
(booking) => Number(booking.parent_id) !== 0
|
|
1022
|
+
).map((booking) => normalizeSubmitBooking(booking)),
|
|
597
1023
|
payments: tempOrder.payments || [],
|
|
598
|
-
// discount_list: tempOrder.discount_list || [],
|
|
599
1024
|
relation_forms: tempOrder.relation_forms || [],
|
|
600
|
-
form_record_ids: formRecordIds,
|
|
601
1025
|
// contacts: tempOrder.contacts || [],
|
|
602
|
-
contacts_info: tempOrder.contacts_info
|
|
1026
|
+
contacts_info: tempOrder.contacts_info && !Array.isArray(tempOrder.contacts_info) ? tempOrder.contacts_info : null,
|
|
603
1027
|
// holder: tempOrder.holder || null,
|
|
604
|
-
|
|
1028
|
+
summary: summary || tempOrder.summary || (0, import_utils2.createEmptySummary)(),
|
|
605
1029
|
metadata: (() => {
|
|
606
1030
|
const {
|
|
607
1031
|
collect_pax: _collectPax,
|
|
608
1032
|
table_occupancy_duration: _tableOccupancyDuration,
|
|
609
1033
|
...rest
|
|
610
1034
|
} = tempOrder.metadata || {};
|
|
611
|
-
return {
|
|
612
|
-
...rest
|
|
613
|
-
};
|
|
1035
|
+
return { ...rest };
|
|
614
1036
|
})(),
|
|
615
|
-
products: (tempOrder.products || []).map(
|
|
1037
|
+
products: (tempOrder.products || []).map(
|
|
1038
|
+
(product) => normalizeSubmitProduct(product)
|
|
1039
|
+
)
|
|
1040
|
+
};
|
|
1041
|
+
if (!enhance)
|
|
1042
|
+
return payload;
|
|
1043
|
+
const enhancedPayload = enhance(payload, { tempOrder, bookingUuid, now });
|
|
1044
|
+
return {
|
|
1045
|
+
...enhancedPayload,
|
|
1046
|
+
summary: enhancedPayload.summary ?? payload.summary
|
|
616
1047
|
};
|
|
617
|
-
return enhance ? enhance(payload, {
|
|
618
|
-
tempOrder,
|
|
619
|
-
bookingUuid,
|
|
620
|
-
now
|
|
621
|
-
}) : payload;
|
|
622
1048
|
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
1049
|
+
function mapPaymentItemToOrderPayment(paymentItem) {
|
|
1050
|
+
const item = paymentItem;
|
|
1051
|
+
const customPaymentId = item.custom_payment_id ?? item.id;
|
|
1052
|
+
const metadata = item.metadata && typeof item.metadata === "object" ? { ...item.metadata } : {};
|
|
1053
|
+
if (item.uuid && !metadata.unique_payment_number) {
|
|
1054
|
+
metadata.unique_payment_number = String(item.uuid);
|
|
1055
|
+
}
|
|
1056
|
+
const paymentMetadataKeys = [
|
|
1057
|
+
"rounding_rule",
|
|
1058
|
+
"shop_wallet_pass_id",
|
|
1059
|
+
"actual_paid_amount",
|
|
1060
|
+
"change_given_amount"
|
|
1061
|
+
];
|
|
1062
|
+
for (const key of paymentMetadataKeys) {
|
|
1063
|
+
if (item[key] !== void 0 && metadata[key] === void 0) {
|
|
1064
|
+
metadata[key] = item[key];
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
const timestamp = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
1068
|
+
const paymentTime = item.payment_time ?? timestamp;
|
|
1069
|
+
const createdAt = item.created_at ?? timestamp;
|
|
1070
|
+
return {
|
|
1071
|
+
...item.order_payment_id !== void 0 ? { order_payment_id: item.order_payment_id } : {},
|
|
1072
|
+
amount: String(item.amount ?? "0.00"),
|
|
1073
|
+
code: String(item.code || ""),
|
|
1074
|
+
custom_payment_id: Number(customPaymentId ?? 0),
|
|
1075
|
+
...item.custom_payment_type !== void 0 ? { custom_payment_type: String(item.custom_payment_type) } : {},
|
|
1076
|
+
name: String(item.name || ""),
|
|
1077
|
+
type: String(item.type || ""),
|
|
1078
|
+
...item.voucher_id !== void 0 ? { voucher_id: item.voucher_id } : {},
|
|
1079
|
+
...item.origin_amount !== void 0 ? { origin_amount: String(item.origin_amount) } : {},
|
|
1080
|
+
...item.service_fee !== void 0 ? { service_fee: String(item.service_fee) } : {},
|
|
1081
|
+
...item.status !== void 0 ? { status: item.status } : {},
|
|
1082
|
+
payment_time: paymentTime,
|
|
1083
|
+
created_at: createdAt,
|
|
1084
|
+
...item.wallet_pass_usage_unit !== void 0 ? { wallet_pass_usage_unit: item.wallet_pass_usage_unit } : {},
|
|
1085
|
+
...item.wallet_pass_use_value !== void 0 ? { wallet_pass_use_value: item.wallet_pass_use_value } : {},
|
|
1086
|
+
...item.fund_record && typeof item.fund_record === "object" && !Array.isArray(item.fund_record) ? { fund_record: { ...item.fund_record } } : {},
|
|
1087
|
+
metadata,
|
|
1088
|
+
...item.rounding_amount !== void 0 ? { rounding_amount: String(item.rounding_amount) } : {},
|
|
1089
|
+
...item.service_charge !== void 0 ? { service_charge: item.service_charge } : {},
|
|
1090
|
+
...item.order_payment_type !== void 0 ? { order_payment_type: item.order_payment_type } : {},
|
|
1091
|
+
...item.updated_at !== void 0 ? { updated_at: item.updated_at } : {}
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1094
|
+
function mapPaymentItemsToOrderPayments(paymentItems, options = {}) {
|
|
1095
|
+
if (!Array.isArray(paymentItems))
|
|
1096
|
+
return [];
|
|
1097
|
+
return paymentItems.filter((item) => options.includeVoided || item.status !== "voided").map((item) => mapPaymentItemToOrderPayment(item));
|
|
627
1098
|
}
|
|
628
|
-
|
|
629
|
-
/**
|
|
630
|
-
* 历史 V1 加餐结构映射器。
|
|
631
|
-
*
|
|
632
|
-
* @deprecated 加餐(`PUT /order/order/product/:id`)已改为与正常 checkout 共用
|
|
633
|
-
* `ScanOrderSubmitProduct` 新结构(见 `OrderModule.submitTempOrder` 的加餐分支)。
|
|
634
|
-
* 本函数仅保留以兼容历史接入方,未来会移除。新代码请勿再调用。
|
|
635
|
-
*/
|
|
636
1099
|
function formatV1Product(products) {
|
|
637
|
-
return products.map(product => {
|
|
1100
|
+
return products.map((product) => {
|
|
1101
|
+
var _a;
|
|
638
1102
|
return {
|
|
639
1103
|
bundle: product.product_bundle,
|
|
640
1104
|
key: product.product_id,
|
|
641
|
-
option: product.
|
|
1105
|
+
option: ((_a = product.product_sku) == null ? void 0 : _a.option) || [],
|
|
642
1106
|
product_id: product.product_id,
|
|
643
1107
|
product_variant_id: product.product_variant_id,
|
|
644
|
-
num: product.
|
|
645
|
-
note: String(product.note ??
|
|
1108
|
+
num: product.product_quantity,
|
|
1109
|
+
note: String(product.note ?? ""),
|
|
646
1110
|
rowKey: product.product_id,
|
|
647
1111
|
session: null,
|
|
648
|
-
unique: createUuidV4()
|
|
1112
|
+
unique: (0, import_orderCollectionIdentity.createUuidV4)()
|
|
1113
|
+
};
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
function hasAssignedHolderId(value) {
|
|
1117
|
+
if (value === void 0 || value === null || value === "")
|
|
1118
|
+
return false;
|
|
1119
|
+
if (Array.isArray(value))
|
|
1120
|
+
return value.length > 0;
|
|
1121
|
+
return true;
|
|
1122
|
+
}
|
|
1123
|
+
function clearTempOrderHolderAssignments(tempOrder) {
|
|
1124
|
+
var _a;
|
|
1125
|
+
let changed = false;
|
|
1126
|
+
const resetHolderField = (target, key = "holder_id") => {
|
|
1127
|
+
if (!hasAssignedHolderId(target[key]))
|
|
1128
|
+
return;
|
|
1129
|
+
target[key] = null;
|
|
1130
|
+
changed = true;
|
|
1131
|
+
};
|
|
1132
|
+
for (const product of tempOrder.products || []) {
|
|
1133
|
+
if (product.metadata && typeof product.metadata === "object") {
|
|
1134
|
+
resetHolderField(product.metadata);
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
for (const booking of tempOrder.bookings || []) {
|
|
1138
|
+
const bookingRecord = booking;
|
|
1139
|
+
if (booking.metadata && typeof booking.metadata === "object") {
|
|
1140
|
+
resetHolderField(booking.metadata);
|
|
1141
|
+
}
|
|
1142
|
+
if (bookingRecord.holder !== void 0 && bookingRecord.holder !== null) {
|
|
1143
|
+
delete bookingRecord.holder;
|
|
1144
|
+
changed = true;
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
const productsByUid = (_a = tempOrder._extend) == null ? void 0 : _a.productsByUid;
|
|
1148
|
+
if (productsByUid && typeof productsByUid === "object") {
|
|
1149
|
+
for (const entry of Object.values(productsByUid)) {
|
|
1150
|
+
const origin = entry == null ? void 0 : entry.origin;
|
|
1151
|
+
if (!origin || typeof origin !== "object")
|
|
1152
|
+
continue;
|
|
1153
|
+
if (origin.metadata && typeof origin.metadata === "object") {
|
|
1154
|
+
resetHolderField(origin.metadata);
|
|
1155
|
+
}
|
|
1156
|
+
if (origin._extend && typeof origin._extend === "object") {
|
|
1157
|
+
resetHolderField(origin._extend);
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
return changed;
|
|
1162
|
+
}
|
|
1163
|
+
function getOrderProductLineUid(product) {
|
|
1164
|
+
var _a;
|
|
1165
|
+
if (!product || typeof product !== "object")
|
|
1166
|
+
return null;
|
|
1167
|
+
const uid = ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) ?? product.unique_identification_number;
|
|
1168
|
+
if (uid === void 0 || uid === null || uid === "")
|
|
1169
|
+
return null;
|
|
1170
|
+
return String(uid);
|
|
1171
|
+
}
|
|
1172
|
+
function getRuntimeProductOrigin(tempOrder, product) {
|
|
1173
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1174
|
+
const uid = getOrderProductLineUid(product);
|
|
1175
|
+
if (uid && ((_c = (_b = (_a = tempOrder == null ? void 0 : tempOrder._extend) == null ? void 0 : _a.productsByUid) == null ? void 0 : _b[uid]) == null ? void 0 : _c.origin)) {
|
|
1176
|
+
return tempOrder._extend.productsByUid[uid].origin;
|
|
1177
|
+
}
|
|
1178
|
+
const matchedProduct = ((tempOrder == null ? void 0 : tempOrder.products) || []).find((item) => item === product || getOrderProductLineUid(item) === uid || String((item == null ? void 0 : item.product_id) ?? (item == null ? void 0 : item.id) ?? "") === String((product == null ? void 0 : product.product_id) ?? (product == null ? void 0 : product.id) ?? ""));
|
|
1179
|
+
const matchedUid = matchedProduct ? getOrderProductLineUid(matchedProduct) : "";
|
|
1180
|
+
return matchedUid ? ((_f = (_e = (_d = tempOrder == null ? void 0 : tempOrder._extend) == null ? void 0 : _d.productsByUid) == null ? void 0 : _e[matchedUid]) == null ? void 0 : _f.origin) || null : null;
|
|
1181
|
+
}
|
|
1182
|
+
function isHolderConfigRequired(holderConfig) {
|
|
1183
|
+
if (!holderConfig || typeof holderConfig !== "object")
|
|
1184
|
+
return false;
|
|
1185
|
+
if (holderConfig.status === "disable")
|
|
1186
|
+
return false;
|
|
1187
|
+
return Number(holderConfig.required) === 1;
|
|
1188
|
+
}
|
|
1189
|
+
function productRequiresFormSubject(tempOrder, product) {
|
|
1190
|
+
var _a, _b;
|
|
1191
|
+
const _orderProduct = (_a = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _a.find((item) => {
|
|
1192
|
+
return item.metadata.unique_identification_number === product._id || item.product_id === product.id;
|
|
1193
|
+
});
|
|
1194
|
+
const runtimeOrigin = getRuntimeProductOrigin(tempOrder, product);
|
|
1195
|
+
return isHolderConfigRequired((_b = _orderProduct == null ? void 0 : _orderProduct.metadata) == null ? void 0 : _b.holder_config) || isHolderConfigRequired(runtimeOrigin == null ? void 0 : runtimeOrigin.holder_config) || isHolderConfigRequired(product == null ? void 0 : product.holder_config);
|
|
1196
|
+
}
|
|
1197
|
+
function resolveIsFormSubject(tempOrder, product) {
|
|
1198
|
+
var _a;
|
|
1199
|
+
debugger;
|
|
1200
|
+
if (((_a = tempOrder == null ? void 0 : tempOrder.holder) == null ? void 0 : _a.type) === "form")
|
|
1201
|
+
return true;
|
|
1202
|
+
if (product)
|
|
1203
|
+
return productRequiresFormSubject(tempOrder, product);
|
|
1204
|
+
return ((tempOrder == null ? void 0 : tempOrder.products) || []).some(
|
|
1205
|
+
(item) => productRequiresFormSubject(tempOrder, item)
|
|
1206
|
+
);
|
|
1207
|
+
}
|
|
1208
|
+
function isEmptyOrderProductDisplayValue(value) {
|
|
1209
|
+
if (value === void 0 || value === null)
|
|
1210
|
+
return true;
|
|
1211
|
+
if (typeof value === "string")
|
|
1212
|
+
return value.trim() === "";
|
|
1213
|
+
if (typeof value === "object") {
|
|
1214
|
+
const record = value;
|
|
1215
|
+
return !Object.values(record).some(
|
|
1216
|
+
(item) => typeof item === "string" && item.trim() !== ""
|
|
1217
|
+
);
|
|
1218
|
+
}
|
|
1219
|
+
return false;
|
|
1220
|
+
}
|
|
1221
|
+
function mergeOrderProductDisplayFields(previous, next) {
|
|
1222
|
+
const merged = { ...next };
|
|
1223
|
+
const displayFields = [
|
|
1224
|
+
"product_title",
|
|
1225
|
+
"product_name",
|
|
1226
|
+
"product_cover",
|
|
1227
|
+
"cover",
|
|
1228
|
+
"product_cover",
|
|
1229
|
+
"variant_title",
|
|
1230
|
+
"product_sku",
|
|
1231
|
+
"payment_price"
|
|
1232
|
+
];
|
|
1233
|
+
displayFields.forEach((field) => {
|
|
1234
|
+
if (isEmptyOrderProductDisplayValue(merged[field]) && !isEmptyOrderProductDisplayValue(previous[field])) {
|
|
1235
|
+
merged[field] = previous[field];
|
|
1236
|
+
}
|
|
1237
|
+
});
|
|
1238
|
+
if (previous.metadata || next.metadata) {
|
|
1239
|
+
merged.metadata = {
|
|
1240
|
+
...previous.metadata || {},
|
|
1241
|
+
...next.metadata || {}
|
|
649
1242
|
};
|
|
1243
|
+
["product_title", "product_name"].forEach((field) => {
|
|
1244
|
+
var _a;
|
|
1245
|
+
if (isEmptyOrderProductDisplayValue(merged.metadata[field]) && !isEmptyOrderProductDisplayValue((_a = previous.metadata) == null ? void 0 : _a[field])) {
|
|
1246
|
+
merged.metadata[field] = previous.metadata[field];
|
|
1247
|
+
}
|
|
1248
|
+
});
|
|
1249
|
+
}
|
|
1250
|
+
if (previous._extend && !merged._extend) {
|
|
1251
|
+
merged._extend = previous._extend;
|
|
1252
|
+
}
|
|
1253
|
+
return merged;
|
|
1254
|
+
}
|
|
1255
|
+
function indexOrderProductsByUid(products) {
|
|
1256
|
+
const map = /* @__PURE__ */ new Map();
|
|
1257
|
+
(products || []).forEach((product, index) => {
|
|
1258
|
+
const uid = getOrderProductLineUid(product);
|
|
1259
|
+
if (uid) {
|
|
1260
|
+
map.set(uid, product);
|
|
1261
|
+
return;
|
|
1262
|
+
}
|
|
1263
|
+
map.set(`__index__:${index}`, product);
|
|
650
1264
|
});
|
|
651
|
-
|
|
1265
|
+
return map;
|
|
1266
|
+
}
|
|
1267
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1268
|
+
0 && (module.exports = {
|
|
1269
|
+
buildManualProductDiscountItem,
|
|
1270
|
+
buildSubmitPayload,
|
|
1271
|
+
calculateOrderProductsDeposit,
|
|
1272
|
+
clearTempOrderHolderAssignments,
|
|
1273
|
+
composeLinePrice,
|
|
1274
|
+
createDefaultOrderRulesHooks,
|
|
1275
|
+
createDefaultTempOrder,
|
|
1276
|
+
createEmptySummary,
|
|
1277
|
+
createUuidV4,
|
|
1278
|
+
ensureCartItemOriginHolder,
|
|
1279
|
+
ensureManualProductDiscountList,
|
|
1280
|
+
ensureProductSku,
|
|
1281
|
+
findManualProductDiscountItem,
|
|
1282
|
+
formatDateTime,
|
|
1283
|
+
formatV1Product,
|
|
1284
|
+
generateDuration,
|
|
1285
|
+
getAllDiscountList,
|
|
1286
|
+
getBundleSellingMagnitude,
|
|
1287
|
+
getBundleSignedUnit,
|
|
1288
|
+
getOrderProductLineUid,
|
|
1289
|
+
getProductSkuOptions,
|
|
1290
|
+
getRuntimeProductOrigin,
|
|
1291
|
+
hasAssignedHolderId,
|
|
1292
|
+
indexOrderProductsByUid,
|
|
1293
|
+
isEmptyOrderProductDisplayValue,
|
|
1294
|
+
isHolderConfigRequired,
|
|
1295
|
+
isMarkdownBundle,
|
|
1296
|
+
isTempOrder,
|
|
1297
|
+
mapPaymentItemToOrderPayment,
|
|
1298
|
+
mapPaymentItemsToOrderPayments,
|
|
1299
|
+
mergeManualProductDiscountIntoList,
|
|
1300
|
+
mergeOrderProductDisplayFields,
|
|
1301
|
+
mergeRelationForms,
|
|
1302
|
+
normalizeBookingIsAll,
|
|
1303
|
+
normalizeBookingSubType,
|
|
1304
|
+
normalizeOrderProductDiscountList,
|
|
1305
|
+
normalizeProductSkuOptions,
|
|
1306
|
+
normalizeSubmitBooking,
|
|
1307
|
+
normalizeSubmitCollectPaxValue,
|
|
1308
|
+
productRequiresFormSubject,
|
|
1309
|
+
resolveEffectivePerUnitDiscount,
|
|
1310
|
+
resolveIsFormSubject,
|
|
1311
|
+
resolveManualDiscountMessage,
|
|
1312
|
+
resolveManualDiscountOriginTotal,
|
|
1313
|
+
resolveManualDiscountReasonFromSources,
|
|
1314
|
+
resolveManualOverrideLineOriginalPrice,
|
|
1315
|
+
resolveRulesManualDiscountFlag,
|
|
1316
|
+
resolveSafeProductNum,
|
|
1317
|
+
resolveSubmitCollectPax,
|
|
1318
|
+
shouldBuildManualProductDiscount,
|
|
1319
|
+
stripManualProductDiscountItems,
|
|
1320
|
+
sumOptionUnitPrice,
|
|
1321
|
+
syncManualProductDiscountProductNum
|
|
1322
|
+
});
|