@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
|
@@ -0,0 +1,4009 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
4
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
5
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
6
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
7
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
8
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
10
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
11
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
12
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
13
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
14
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
15
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
16
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
17
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
18
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
19
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
20
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
21
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
22
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
23
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
24
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
25
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
26
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
27
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
28
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
29
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
30
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
31
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
32
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
33
|
+
import { BaseModule } from "../../modules/BaseModule";
|
|
34
|
+
import { BaseSalesHookNames } from "./types";
|
|
35
|
+
import { OrderModule } from "../../modules/Order";
|
|
36
|
+
import Decimal from 'decimal.js';
|
|
37
|
+
import { cloneDeep, mergeWith } from 'lodash-es';
|
|
38
|
+
import { createModule } from "../BookingByStep/types";
|
|
39
|
+
import { composeLinePrice, createUuidV4, ensureProductSku, getProductSkuOptions, resolveIsFormSubject, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
40
|
+
import { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrderCollectionReferenceUid, getOrderCollectionUid, isSameOrderCollectionItem, mergeOrderCollectionItems, normalizeOrderCollection, normalizeOrderCollections, setOrderCollectionUid } from "../../modules/Order/utils/orderCollectionIdentity";
|
|
41
|
+
import dayjs from 'dayjs';
|
|
42
|
+
export * from "./types";
|
|
43
|
+
import { QuotationModule } from "../../modules/Quotation";
|
|
44
|
+
import { transformBaseProductToOrderProduct as _transformBaseProductToOrderProduct } from "./utils/transformBaseProductToOrderProduct";
|
|
45
|
+
import { calculateBaseSalesProductBookingPrice } from "./utils/quotationPrice";
|
|
46
|
+
var SERVER_ORDER_CHANGED_EVENT = 'order:onOrdersChanged';
|
|
47
|
+
function isBaseSalesManualProductDiscountProduct(product) {
|
|
48
|
+
var _product$metadata, _product$metadata2;
|
|
49
|
+
return (product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.is_manual_discount) === true || (product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.is_manual_discount) === 1 || ((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (item) {
|
|
50
|
+
return (item === null || item === void 0 ? void 0 : item.type) === 'product';
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function getBaseSalesProductUid(product) {
|
|
54
|
+
var _product$metadata3;
|
|
55
|
+
var uid = (product === null || product === void 0 || (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
56
|
+
if (uid === undefined || uid === null || uid === '') return null;
|
|
57
|
+
return String(uid);
|
|
58
|
+
}
|
|
59
|
+
function preserveManualProductDiscountProducts(previousProducts, nextProducts) {
|
|
60
|
+
var previousByUid = new Map();
|
|
61
|
+
(previousProducts || []).forEach(function (product, index) {
|
|
62
|
+
var uid = getBaseSalesProductUid(product);
|
|
63
|
+
if (uid) previousByUid.set(uid, product);
|
|
64
|
+
previousByUid.set("__index__:".concat(index), product);
|
|
65
|
+
});
|
|
66
|
+
return (nextProducts || []).map(function (product, index) {
|
|
67
|
+
var uid = getBaseSalesProductUid(product);
|
|
68
|
+
var previous = (uid ? previousByUid.get(uid) : undefined) || previousByUid.get("__index__:".concat(index));
|
|
69
|
+
return previous && isBaseSalesManualProductDiscountProduct(previous) ? previous : product;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function isBaseSalesHistoricalDiscountEntry(discount) {
|
|
73
|
+
return Boolean((discount === null || discount === void 0 ? void 0 : discount.isEditMode) || (discount === null || discount === void 0 ? void 0 : discount.isDisabled) || (discount === null || discount === void 0 ? void 0 : discount.order_discount_id) != null);
|
|
74
|
+
}
|
|
75
|
+
var BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND = {
|
|
76
|
+
product: 'order_detail_id',
|
|
77
|
+
booking: 'schedule_event_id',
|
|
78
|
+
payment: 'order_payment_id'
|
|
79
|
+
};
|
|
80
|
+
function getBaseSalesOrderCollectionKind(key) {
|
|
81
|
+
if (key === 'products') return 'product';
|
|
82
|
+
if (key === 'bookings') return 'booking';
|
|
83
|
+
if (key === 'payments' || key === 'payment') return 'payment';
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
function isSameBaseSalesOrderRecord(left, right) {
|
|
87
|
+
if (!left || !right || _typeof(left) !== 'object' || _typeof(right) !== 'object') return false;
|
|
88
|
+
var leftIdentities = new Set([left.order_id, left.id, left.external_sale_number, left.order_number].filter(function (value) {
|
|
89
|
+
return value !== undefined && value !== null && value !== '';
|
|
90
|
+
}).map(String));
|
|
91
|
+
if (leftIdentities.size === 0) return false;
|
|
92
|
+
return [right.order_id, right.id, right.external_sale_number, right.order_number].some(function (value) {
|
|
93
|
+
return value !== undefined && value !== null && value !== '' && leftIdentities.has(String(value));
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function isBaseSalesBlankValue(value) {
|
|
97
|
+
return value === undefined || value === null || value === '';
|
|
98
|
+
}
|
|
99
|
+
function mergeBaseSalesProductSnapshotFields(currentItem, loadedItem) {
|
|
100
|
+
var _currentItem$metadata, _mergedItem$metadata, _mergedItem$metadata2;
|
|
101
|
+
var mergedItem = cloneDeep(loadedItem);
|
|
102
|
+
if (isBaseSalesBlankValue(mergedItem.product_cover) && !isBaseSalesBlankValue(currentItem === null || currentItem === void 0 ? void 0 : currentItem.product_cover)) {
|
|
103
|
+
mergedItem.product_cover = currentItem.product_cover;
|
|
104
|
+
}
|
|
105
|
+
var currentHolderConfig = currentItem === null || currentItem === void 0 || (_currentItem$metadata = currentItem.metadata) === null || _currentItem$metadata === void 0 ? void 0 : _currentItem$metadata.holder_config;
|
|
106
|
+
if ((((_mergedItem$metadata = mergedItem.metadata) === null || _mergedItem$metadata === void 0 ? void 0 : _mergedItem$metadata.holder_config) === undefined || ((_mergedItem$metadata2 = mergedItem.metadata) === null || _mergedItem$metadata2 === void 0 ? void 0 : _mergedItem$metadata2.holder_config) === null) && currentHolderConfig !== undefined && currentHolderConfig !== null) {
|
|
107
|
+
mergedItem.metadata = _objectSpread(_objectSpread({}, mergedItem.metadata || {}), {}, {
|
|
108
|
+
holder_config: currentHolderConfig
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return mergedItem;
|
|
112
|
+
}
|
|
113
|
+
function mergeBaseSalesCollectionItem(kind, currentItem, incomingItem, uidRemaps) {
|
|
114
|
+
var currentReferenceUid = getOrderCollectionReferenceUid(kind, currentItem);
|
|
115
|
+
var incomingReferenceUid = getOrderCollectionReferenceUid(kind, incomingItem);
|
|
116
|
+
var identityMergedItem = mergeOrderCollectionItems(kind, currentItem, incomingItem);
|
|
117
|
+
var mergedUid = getOrderCollectionUid(kind, identityMergedItem);
|
|
118
|
+
if (mergedUid) {
|
|
119
|
+
var _iterator = _createForOfIteratorHelper(new Set([currentReferenceUid, incomingReferenceUid])),
|
|
120
|
+
_step;
|
|
121
|
+
try {
|
|
122
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
123
|
+
var from = _step.value;
|
|
124
|
+
if (!from || from === mergedUid) continue;
|
|
125
|
+
uidRemaps.push({
|
|
126
|
+
kind: kind,
|
|
127
|
+
from: from,
|
|
128
|
+
to: mergedUid,
|
|
129
|
+
persistentId: getOrderCollectionPersistentId(kind, incomingItem) || getOrderCollectionPersistentId(kind, currentItem)
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
} catch (err) {
|
|
133
|
+
_iterator.e(err);
|
|
134
|
+
} finally {
|
|
135
|
+
_iterator.f();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
var mergedItem = mergedUid ? setOrderCollectionUid(kind, incomingItem, mergedUid) : cloneDeep(incomingItem);
|
|
139
|
+
var persistentIdField = BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND[kind];
|
|
140
|
+
if (isBaseSalesBlankValue(mergedItem[persistentIdField]) && !isBaseSalesBlankValue(identityMergedItem[persistentIdField])) {
|
|
141
|
+
mergedItem[persistentIdField] = identityMergedItem[persistentIdField];
|
|
142
|
+
}
|
|
143
|
+
return kind === 'product' ? mergeBaseSalesProductSnapshotFields(currentItem, mergedItem) : mergedItem;
|
|
144
|
+
}
|
|
145
|
+
function mergeBaseSalesOrderCollection(kind, currentValue, incomingValue, strategy, uidRemaps) {
|
|
146
|
+
var currentItems = normalizeOrderCollection(kind, currentValue, {
|
|
147
|
+
ensureUid: false
|
|
148
|
+
}).items;
|
|
149
|
+
var incomingItems = normalizeOrderCollection(kind, incomingValue, {
|
|
150
|
+
ensureUid: false
|
|
151
|
+
}).items;
|
|
152
|
+
if (strategy === 'authoritative-incoming') {
|
|
153
|
+
var _result = cloneDeep(incomingItems);
|
|
154
|
+
currentItems.forEach(function (currentItem) {
|
|
155
|
+
var incomingIndex = _result.findIndex(function (incomingItem) {
|
|
156
|
+
return isSameOrderCollectionItem(kind, currentItem, incomingItem);
|
|
157
|
+
});
|
|
158
|
+
if (incomingIndex !== -1) {
|
|
159
|
+
_result[incomingIndex] = mergeBaseSalesCollectionItem(kind, currentItem, _result[incomingIndex], uidRemaps);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// 完整服务端快照负责已落库行;仅保留尚未提交的本地新行。
|
|
164
|
+
if (!getOrderCollectionPersistentId(kind, currentItem)) {
|
|
165
|
+
_result.push(cloneDeep(currentItem));
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
return _result;
|
|
169
|
+
}
|
|
170
|
+
var result = cloneDeep(currentItems);
|
|
171
|
+
incomingItems.forEach(function (incomingItem) {
|
|
172
|
+
var currentIndex = result.findIndex(function (currentItem) {
|
|
173
|
+
return isSameOrderCollectionItem(kind, currentItem, incomingItem);
|
|
174
|
+
});
|
|
175
|
+
if (currentIndex !== -1) {
|
|
176
|
+
result[currentIndex] = mergeBaseSalesCollectionItem(kind, result[currentIndex], incomingItem, uidRemaps);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
result.push(cloneDeep(incomingItem));
|
|
180
|
+
});
|
|
181
|
+
return result;
|
|
182
|
+
}
|
|
183
|
+
function normalizeBaseSalesRecordCollections(sourceRecord, options) {
|
|
184
|
+
var normalizedRecord = normalizeOrderCollections(cloneDeep(sourceRecord || {}), options).order;
|
|
185
|
+
|
|
186
|
+
// 兼容旧调用方偶尔使用的单数 payment 字段。
|
|
187
|
+
if (Array.isArray(normalizedRecord.payment)) {
|
|
188
|
+
normalizedRecord.payment = normalizeOrderCollection('payment', normalizedRecord.payment, options).items;
|
|
189
|
+
}
|
|
190
|
+
return normalizedRecord;
|
|
191
|
+
}
|
|
192
|
+
function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
|
|
193
|
+
var normalizedLoadedRecord = normalizeBaseSalesRecordCollections(loadedRecord || {}, {
|
|
194
|
+
ensureUid: false
|
|
195
|
+
});
|
|
196
|
+
if (!currentTempOrder) {
|
|
197
|
+
return normalizeBaseSalesRecordCollections(normalizedLoadedRecord);
|
|
198
|
+
}
|
|
199
|
+
var normalizedCurrentTempOrder = normalizeBaseSalesRecordCollections(currentTempOrder, {
|
|
200
|
+
ensureUid: false
|
|
201
|
+
});
|
|
202
|
+
var uidRemaps = [];
|
|
203
|
+
var mergedRecord = mergeWith(normalizedCurrentTempOrder, normalizedLoadedRecord, function (currentValue, loadedValue, key) {
|
|
204
|
+
var collectionKind = getBaseSalesOrderCollectionKind(key);
|
|
205
|
+
if (collectionKind && Array.isArray(loadedValue)) {
|
|
206
|
+
return mergeBaseSalesOrderCollection(collectionKind, Array.isArray(currentValue) ? currentValue : [], loadedValue, strategy, uidRemaps);
|
|
207
|
+
}
|
|
208
|
+
if (Array.isArray(currentValue) && Array.isArray(loadedValue)) {
|
|
209
|
+
return [].concat(_toConsumableArray(cloneDeep(currentValue)), _toConsumableArray(cloneDeep(loadedValue)));
|
|
210
|
+
}
|
|
211
|
+
if (Array.isArray(loadedValue)) return cloneDeep(loadedValue);
|
|
212
|
+
if (Array.isArray(currentValue) && loadedValue === undefined) {
|
|
213
|
+
return cloneDeep(currentValue);
|
|
214
|
+
}
|
|
215
|
+
return undefined;
|
|
216
|
+
});
|
|
217
|
+
delete mergedRecord.request_unique_idempotency_token;
|
|
218
|
+
return normalizeBaseSalesRecordCollections(applyOrderCollectionUidRemaps(mergedRecord, uidRemaps));
|
|
219
|
+
}
|
|
220
|
+
export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
221
|
+
_inherits(BaseSalesImpl, _BaseModule);
|
|
222
|
+
var _super = _createSuper(BaseSalesImpl);
|
|
223
|
+
function BaseSalesImpl(name, version) {
|
|
224
|
+
var _this;
|
|
225
|
+
_classCallCheck(this, BaseSalesImpl);
|
|
226
|
+
_this = _super.call(this, name, version);
|
|
227
|
+
_defineProperty(_assertThisInitialized(_this), "defaultName", 'baseSales');
|
|
228
|
+
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
229
|
+
_defineProperty(_assertThisInitialized(_this), "isSolution", true);
|
|
230
|
+
_defineProperty(_assertThisInitialized(_this), "initializeOptions", {});
|
|
231
|
+
_defineProperty(_assertThisInitialized(_this), "logger", void 0);
|
|
232
|
+
// LoggerManager 实例
|
|
233
|
+
_defineProperty(_assertThisInitialized(_this), "appPlugin", void 0);
|
|
234
|
+
_defineProperty(_assertThisInitialized(_this), "store", {
|
|
235
|
+
order: undefined
|
|
236
|
+
});
|
|
237
|
+
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
238
|
+
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
239
|
+
/**
|
|
240
|
+
* window / request 暴露为 public:现存外部工具(如 BookingTicket Scan)通过
|
|
241
|
+
* `solution.window` / `solution.request` 直接访问插件,保持原有契约不破坏。
|
|
242
|
+
*/
|
|
243
|
+
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
244
|
+
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
245
|
+
// 当前缓存中已加载的最新 SalesDetail;只读 getter 走它对外暴露详情数据。
|
|
246
|
+
_defineProperty(_assertThisInitialized(_this), "currentSalesDetail", null);
|
|
247
|
+
_defineProperty(_assertThisInitialized(_this), "discountConfigCacheKey", null);
|
|
248
|
+
_defineProperty(_assertThisInitialized(_this), "hasManualDiscountSelection", false);
|
|
249
|
+
_defineProperty(_assertThisInitialized(_this), "reusedSharedSubModuleNames", new Set());
|
|
250
|
+
_defineProperty(_assertThisInitialized(_this), "paymentMethodsCache", []);
|
|
251
|
+
_defineProperty(_assertThisInitialized(_this), "queuedAutoPaymentSync", false);
|
|
252
|
+
_defineProperty(_assertThisInitialized(_this), "autoPaymentSyncFlushing", false);
|
|
253
|
+
_defineProperty(_assertThisInitialized(_this), "autoPaymentSyncTimer", null);
|
|
254
|
+
_defineProperty(_assertThisInitialized(_this), "salesDetailLoadInFlightCount", 0);
|
|
255
|
+
_defineProperty(_assertThisInitialized(_this), "salesDetailLoadSequence", 0);
|
|
256
|
+
_defineProperty(_assertThisInitialized(_this), "salesDetailHydrateQueue", Promise.resolve());
|
|
257
|
+
_defineProperty(_assertThisInitialized(_this), "serverOrderChangeUnsubscribe", null);
|
|
258
|
+
_defineProperty(_assertThisInitialized(_this), "serverOrderChangeHydrateInFlight", null);
|
|
259
|
+
_defineProperty(_assertThisInitialized(_this), "queuedServerOrderChanges", []);
|
|
260
|
+
_defineProperty(_assertThisInitialized(_this), "serverOrderChangeSyncEnabled", false);
|
|
261
|
+
return _this;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
266
|
+
* 默认包含通用销售模块:products / order / salesSummary / schedule / payment / quotation。
|
|
267
|
+
*/
|
|
268
|
+
_createClass(BaseSalesImpl, [{
|
|
269
|
+
key: "getRegisteredModuleNames",
|
|
270
|
+
value: function getRegisteredModuleNames() {
|
|
271
|
+
return ['products', 'order', 'salesSummary', 'schedule', 'payment', 'quotation'];
|
|
272
|
+
}
|
|
273
|
+
}, {
|
|
274
|
+
key: "getReusableSharedSubModule",
|
|
275
|
+
value: function getReusableSharedSubModule(moduleName) {
|
|
276
|
+
var _this$core, _this$core$getModule;
|
|
277
|
+
if (moduleName !== 'schedule' && moduleName !== 'quotation') return null;
|
|
278
|
+
return ((_this$core = this.core) === null || _this$core === void 0 || (_this$core$getModule = _this$core.getModule) === null || _this$core$getModule === void 0 ? void 0 : _this$core$getModule.call(_this$core, moduleName)) || null;
|
|
279
|
+
}
|
|
280
|
+
}, {
|
|
281
|
+
key: "isScheduleListLoaded",
|
|
282
|
+
value: function isScheduleListLoaded(scheduleModule) {
|
|
283
|
+
if (!scheduleModule) return false;
|
|
284
|
+
if (typeof scheduleModule.isScheduleListLoaded === 'function') {
|
|
285
|
+
return scheduleModule.isScheduleListLoaded();
|
|
286
|
+
}
|
|
287
|
+
if (typeof scheduleModule.getScheduleList === 'function') {
|
|
288
|
+
return Array.isArray(scheduleModule.getScheduleList());
|
|
289
|
+
}
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* 记录信息日志
|
|
295
|
+
*/
|
|
296
|
+
}, {
|
|
297
|
+
key: "logInfo",
|
|
298
|
+
value: function logInfo(title, metadata) {
|
|
299
|
+
if (this.logger) {
|
|
300
|
+
var tempOrder = this.getTempOrder();
|
|
301
|
+
this.logger.addLog({
|
|
302
|
+
type: 'info',
|
|
303
|
+
title: "[BaseSales] ".concat(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id, " ").concat(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.external_sale_number, " ").concat(title),
|
|
304
|
+
metadata: metadata || {}
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* 记录警告日志
|
|
311
|
+
*/
|
|
312
|
+
}, {
|
|
313
|
+
key: "logWarning",
|
|
314
|
+
value: function logWarning(title, metadata) {
|
|
315
|
+
if (this.logger) {
|
|
316
|
+
var tempOrder = this.getTempOrder();
|
|
317
|
+
this.logger.addLog({
|
|
318
|
+
type: 'warning',
|
|
319
|
+
title: "[BaseSales] ".concat(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id, " ").concat(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.external_sale_number, " ").concat(title),
|
|
320
|
+
metadata: metadata || {}
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* 记录错误日志
|
|
327
|
+
*/
|
|
328
|
+
}, {
|
|
329
|
+
key: "logError",
|
|
330
|
+
value: function logError(title, metadata) {
|
|
331
|
+
if (this.logger) {
|
|
332
|
+
var tempOrder = this.getTempOrder();
|
|
333
|
+
this.logger.addLog({
|
|
334
|
+
type: 'error',
|
|
335
|
+
title: "[BaseSales] ".concat(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id, " ").concat(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.external_sale_number, " ").concat(title),
|
|
336
|
+
metadata: metadata || {}
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}, {
|
|
341
|
+
key: "isCurrentSalesOrderRecord",
|
|
342
|
+
value: function isCurrentSalesOrderRecord(order) {
|
|
343
|
+
var _this$store$order, _this$store$order$get;
|
|
344
|
+
var currentTempOrder = (_this$store$order = this.store.order) === null || _this$store$order === void 0 || (_this$store$order$get = _this$store$order.getTempOrder) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.call(_this$store$order);
|
|
345
|
+
var currentRecords = [currentTempOrder, this.currentSalesDetail].filter(Boolean);
|
|
346
|
+
return currentRecords.some(function (record) {
|
|
347
|
+
return isSameBaseSalesOrderRecord(record, order);
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
}, {
|
|
351
|
+
key: "setServerOrderChangeSyncEnabled",
|
|
352
|
+
value: function setServerOrderChangeSyncEnabled(enabled) {
|
|
353
|
+
this.serverOrderChangeSyncEnabled = enabled;
|
|
354
|
+
if (!enabled) this.queuedServerOrderChanges = [];
|
|
355
|
+
}
|
|
356
|
+
}, {
|
|
357
|
+
key: "queueLatestServerOrderChange",
|
|
358
|
+
value: function queueLatestServerOrderChange(order) {
|
|
359
|
+
var snapshot = cloneDeep(order);
|
|
360
|
+
var existingIndex = this.queuedServerOrderChanges.findIndex(function (queued) {
|
|
361
|
+
return isSameBaseSalesOrderRecord(queued, snapshot);
|
|
362
|
+
});
|
|
363
|
+
if (existingIndex >= 0) {
|
|
364
|
+
this.queuedServerOrderChanges[existingIndex] = snapshot;
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
this.queuedServerOrderChanges.push(snapshot);
|
|
368
|
+
}
|
|
369
|
+
}, {
|
|
370
|
+
key: "drainQueuedServerOrderChanges",
|
|
371
|
+
value: function () {
|
|
372
|
+
var _drainQueuedServerOrderChanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
373
|
+
var changedOrders;
|
|
374
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
375
|
+
while (1) switch (_context.prev = _context.next) {
|
|
376
|
+
case 0:
|
|
377
|
+
if (!(!this.serverOrderChangeSyncEnabled || this.salesDetailLoadInFlightCount > 0 || this.serverOrderChangeHydrateInFlight || this.queuedServerOrderChanges.length === 0)) {
|
|
378
|
+
_context.next = 2;
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
return _context.abrupt("return");
|
|
382
|
+
case 2:
|
|
383
|
+
changedOrders = this.queuedServerOrderChanges;
|
|
384
|
+
this.queuedServerOrderChanges = [];
|
|
385
|
+
_context.next = 6;
|
|
386
|
+
return this.syncCurrentSalesDetailFromServerOrderChange({
|
|
387
|
+
changedOrders: changedOrders
|
|
388
|
+
});
|
|
389
|
+
case 6:
|
|
390
|
+
case "end":
|
|
391
|
+
return _context.stop();
|
|
392
|
+
}
|
|
393
|
+
}, _callee, this);
|
|
394
|
+
}));
|
|
395
|
+
function drainQueuedServerOrderChanges() {
|
|
396
|
+
return _drainQueuedServerOrderChanges.apply(this, arguments);
|
|
397
|
+
}
|
|
398
|
+
return drainQueuedServerOrderChanges;
|
|
399
|
+
}()
|
|
400
|
+
}, {
|
|
401
|
+
key: "syncCurrentSalesDetailFromServerOrderChange",
|
|
402
|
+
value: function () {
|
|
403
|
+
var _syncCurrentSalesDetailFromServerOrderChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(payload) {
|
|
404
|
+
var _this2 = this;
|
|
405
|
+
var changedOrders, changedOrder;
|
|
406
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
407
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
408
|
+
case 0:
|
|
409
|
+
changedOrders = Array.isArray(payload) ? payload : Array.isArray(payload === null || payload === void 0 ? void 0 : payload.changedOrders) ? payload.changedOrders : payload !== null && payload !== void 0 && payload.data && _typeof(payload.data) === 'object' ? [payload.data] : [];
|
|
410
|
+
if (this.serverOrderChangeSyncEnabled) {
|
|
411
|
+
_context3.next = 3;
|
|
412
|
+
break;
|
|
413
|
+
}
|
|
414
|
+
return _context3.abrupt("return");
|
|
415
|
+
case 3:
|
|
416
|
+
if (!(this.salesDetailLoadInFlightCount > 0)) {
|
|
417
|
+
_context3.next = 6;
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
420
|
+
changedOrders.forEach(function (order) {
|
|
421
|
+
return _this2.queueLatestServerOrderChange(order);
|
|
422
|
+
});
|
|
423
|
+
return _context3.abrupt("return");
|
|
424
|
+
case 6:
|
|
425
|
+
changedOrder = changedOrders.find(function (order) {
|
|
426
|
+
return _this2.isCurrentSalesOrderRecord(order);
|
|
427
|
+
});
|
|
428
|
+
if (changedOrder) {
|
|
429
|
+
_context3.next = 9;
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
432
|
+
return _context3.abrupt("return");
|
|
433
|
+
case 9:
|
|
434
|
+
if (!this.serverOrderChangeHydrateInFlight) {
|
|
435
|
+
_context3.next = 12;
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
this.queueLatestServerOrderChange(changedOrder);
|
|
439
|
+
return _context3.abrupt("return");
|
|
440
|
+
case 12:
|
|
441
|
+
if (this.store.order) {
|
|
442
|
+
_context3.next = 14;
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
445
|
+
return _context3.abrupt("return");
|
|
446
|
+
case 14:
|
|
447
|
+
this.serverOrderChangeHydrateInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
448
|
+
var _getTempOrder, _ref2;
|
|
449
|
+
var currentTempOrder, record, sales;
|
|
450
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
451
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
452
|
+
case 0:
|
|
453
|
+
currentTempOrder = (_getTempOrder = (_ref2 = _this2.store.order).getTempOrder) === null || _getTempOrder === void 0 ? void 0 : _getTempOrder.call(_ref2);
|
|
454
|
+
record = mergeSalesDetailRecordWithTempOrder(currentTempOrder, changedOrder, 'authoritative-incoming');
|
|
455
|
+
_context2.next = 4;
|
|
456
|
+
return _this2.store.order.hydrateTempOrderFromRecord(record, {
|
|
457
|
+
recalcOnHydrate: false
|
|
458
|
+
});
|
|
459
|
+
case 4:
|
|
460
|
+
sales = _context2.sent;
|
|
461
|
+
_this2.currentSalesDetail = sales;
|
|
462
|
+
_context2.next = 8;
|
|
463
|
+
return _this2.core.effects.emit("".concat(_this2.name, ":onSalesOrderLoaded"), {
|
|
464
|
+
sales: sales
|
|
465
|
+
});
|
|
466
|
+
case 8:
|
|
467
|
+
case "end":
|
|
468
|
+
return _context2.stop();
|
|
469
|
+
}
|
|
470
|
+
}, _callee2);
|
|
471
|
+
}))();
|
|
472
|
+
_context3.prev = 15;
|
|
473
|
+
_context3.next = 18;
|
|
474
|
+
return this.serverOrderChangeHydrateInFlight;
|
|
475
|
+
case 18:
|
|
476
|
+
_context3.prev = 18;
|
|
477
|
+
this.serverOrderChangeHydrateInFlight = null;
|
|
478
|
+
_context3.next = 22;
|
|
479
|
+
return this.drainQueuedServerOrderChanges();
|
|
480
|
+
case 22:
|
|
481
|
+
return _context3.finish(18);
|
|
482
|
+
case 23:
|
|
483
|
+
case "end":
|
|
484
|
+
return _context3.stop();
|
|
485
|
+
}
|
|
486
|
+
}, _callee3, this, [[15,, 18, 23]]);
|
|
487
|
+
}));
|
|
488
|
+
function syncCurrentSalesDetailFromServerOrderChange(_x) {
|
|
489
|
+
return _syncCurrentSalesDetailFromServerOrderChange.apply(this, arguments);
|
|
490
|
+
}
|
|
491
|
+
return syncCurrentSalesDetailFromServerOrderChange;
|
|
492
|
+
}()
|
|
493
|
+
}, {
|
|
494
|
+
key: "registerServerOrderChangeSync",
|
|
495
|
+
value: function registerServerOrderChangeSync() {
|
|
496
|
+
var _this$serverOrderChan,
|
|
497
|
+
_this$core2,
|
|
498
|
+
_this3 = this;
|
|
499
|
+
(_this$serverOrderChan = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan === void 0 || _this$serverOrderChan.call(this);
|
|
500
|
+
var effects = (_this$core2 = this.core) === null || _this$core2 === void 0 ? void 0 : _this$core2.effects;
|
|
501
|
+
if (!effects || typeof effects.on !== 'function') return;
|
|
502
|
+
this.serverOrderChangeUnsubscribe = effects.on(SERVER_ORDER_CHANGED_EVENT, function (payload) {
|
|
503
|
+
return _this3.syncCurrentSalesDetailFromServerOrderChange(payload).catch(function (error) {
|
|
504
|
+
_this3.logError('sync sales detail from server order change failed', {
|
|
505
|
+
error: error instanceof Error ? error.message : String(error)
|
|
506
|
+
});
|
|
507
|
+
});
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
}, {
|
|
511
|
+
key: "hydrateLatestLoadedSalesDetail",
|
|
512
|
+
value: function () {
|
|
513
|
+
var _hydrateLatestLoadedSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(record, loadSequence) {
|
|
514
|
+
var _this4 = this;
|
|
515
|
+
var hydratedSales, skippedBeforeHydrate, hydrateTask, queuedTask;
|
|
516
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
517
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
518
|
+
case 0:
|
|
519
|
+
hydratedSales = null;
|
|
520
|
+
skippedBeforeHydrate = false;
|
|
521
|
+
hydrateTask = /*#__PURE__*/function () {
|
|
522
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
523
|
+
var sales;
|
|
524
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
525
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
526
|
+
case 0:
|
|
527
|
+
if (!(loadSequence !== _this4.salesDetailLoadSequence)) {
|
|
528
|
+
_context4.next = 3;
|
|
529
|
+
break;
|
|
530
|
+
}
|
|
531
|
+
skippedBeforeHydrate = true;
|
|
532
|
+
return _context4.abrupt("return");
|
|
533
|
+
case 3:
|
|
534
|
+
if (_this4.store.order) {
|
|
535
|
+
_context4.next = 5;
|
|
536
|
+
break;
|
|
537
|
+
}
|
|
538
|
+
throw new Error('order 模块未初始化');
|
|
539
|
+
case 5:
|
|
540
|
+
_context4.next = 7;
|
|
541
|
+
return _this4.store.order.hydrateTempOrderFromRecord(record, {
|
|
542
|
+
recalcOnHydrate: false
|
|
543
|
+
});
|
|
544
|
+
case 7:
|
|
545
|
+
sales = _context4.sent;
|
|
546
|
+
hydratedSales = sales;
|
|
547
|
+
|
|
548
|
+
// hydrate 期间可能又发起了更新请求;后续任务已串行排队,将负责最终状态。
|
|
549
|
+
if (!(loadSequence !== _this4.salesDetailLoadSequence)) {
|
|
550
|
+
_context4.next = 11;
|
|
551
|
+
break;
|
|
552
|
+
}
|
|
553
|
+
return _context4.abrupt("return");
|
|
554
|
+
case 11:
|
|
555
|
+
_this4.currentSalesDetail = sales;
|
|
556
|
+
_context4.next = 14;
|
|
557
|
+
return _this4.core.effects.emit("".concat(_this4.name, ":onSalesOrderLoaded"), {
|
|
558
|
+
sales: sales
|
|
559
|
+
});
|
|
560
|
+
case 14:
|
|
561
|
+
case "end":
|
|
562
|
+
return _context4.stop();
|
|
563
|
+
}
|
|
564
|
+
}, _callee4);
|
|
565
|
+
}));
|
|
566
|
+
return function hydrateTask() {
|
|
567
|
+
return _ref3.apply(this, arguments);
|
|
568
|
+
};
|
|
569
|
+
}();
|
|
570
|
+
queuedTask = this.salesDetailHydrateQueue.then(hydrateTask, hydrateTask);
|
|
571
|
+
this.salesDetailHydrateQueue = queuedTask.then(function () {
|
|
572
|
+
return undefined;
|
|
573
|
+
}, function () {
|
|
574
|
+
return undefined;
|
|
575
|
+
});
|
|
576
|
+
_context5.next = 7;
|
|
577
|
+
return queuedTask;
|
|
578
|
+
case 7:
|
|
579
|
+
if (!skippedBeforeHydrate) {
|
|
580
|
+
_context5.next = 9;
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
583
|
+
return _context5.abrupt("return", record);
|
|
584
|
+
case 9:
|
|
585
|
+
return _context5.abrupt("return", hydratedSales || this.currentSalesDetail || record);
|
|
586
|
+
case 10:
|
|
587
|
+
case "end":
|
|
588
|
+
return _context5.stop();
|
|
589
|
+
}
|
|
590
|
+
}, _callee5, this);
|
|
591
|
+
}));
|
|
592
|
+
function hydrateLatestLoadedSalesDetail(_x2, _x3) {
|
|
593
|
+
return _hydrateLatestLoadedSalesDetail.apply(this, arguments);
|
|
594
|
+
}
|
|
595
|
+
return hydrateLatestLoadedSalesDetail;
|
|
596
|
+
}()
|
|
597
|
+
}, {
|
|
598
|
+
key: "hydrateOrderPaymentNames",
|
|
599
|
+
value: function hydrateOrderPaymentNames(payments) {
|
|
600
|
+
if (!payments.length) return [];
|
|
601
|
+
if (!this.paymentMethodsCache.length) {
|
|
602
|
+
return payments.map(function (payment) {
|
|
603
|
+
return _objectSpread({}, payment);
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
var paymentMethodById = new Map();
|
|
607
|
+
var paymentMethodByCode = new Map();
|
|
608
|
+
this.paymentMethodsCache.forEach(function (method) {
|
|
609
|
+
if ((method === null || method === void 0 ? void 0 : method.id) !== undefined && (method === null || method === void 0 ? void 0 : method.id) !== null) {
|
|
610
|
+
paymentMethodById.set(String(method.id), method);
|
|
611
|
+
}
|
|
612
|
+
if (method !== null && method !== void 0 && method.code) {
|
|
613
|
+
paymentMethodByCode.set(String(method.code), method);
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
return payments.map(function (payment) {
|
|
617
|
+
var nextPayment = _objectSpread({}, payment);
|
|
618
|
+
if (nextPayment.name) return nextPayment;
|
|
619
|
+
var paymentMethod = paymentMethodById.get(String(nextPayment.custom_payment_id)) || paymentMethodByCode.get(String(nextPayment.code));
|
|
620
|
+
if (!(paymentMethod !== null && paymentMethod !== void 0 && paymentMethod.name)) return nextPayment;
|
|
621
|
+
return _objectSpread(_objectSpread({}, nextPayment), {}, {
|
|
622
|
+
name: paymentMethod.name
|
|
623
|
+
});
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
}, {
|
|
627
|
+
key: "payment",
|
|
628
|
+
get: function get() {
|
|
629
|
+
return this.store.payment;
|
|
630
|
+
}
|
|
631
|
+
}, {
|
|
632
|
+
key: "getCurrentOrderCustomerId",
|
|
633
|
+
value: function getCurrentOrderCustomerId() {
|
|
634
|
+
var _this$store$order2, _this$store$order2$ge;
|
|
635
|
+
var tempOrder = (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || (_this$store$order2$ge = _this$store$order2.getTempOrder) === null || _this$store$order2$ge === void 0 ? void 0 : _this$store$order2$ge.call(_this$store$order2);
|
|
636
|
+
var customerId = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id;
|
|
637
|
+
if (customerId === null || customerId === undefined) return undefined;
|
|
638
|
+
return customerId;
|
|
639
|
+
}
|
|
640
|
+
}, {
|
|
641
|
+
key: "normalizePriceContextCustomerId",
|
|
642
|
+
value: function normalizePriceContextCustomerId(customerId) {
|
|
643
|
+
if (customerId === undefined || customerId === null || customerId === '') return null;
|
|
644
|
+
return String(customerId);
|
|
645
|
+
}
|
|
646
|
+
}, {
|
|
647
|
+
key: "applyQuotationScheduleResolver",
|
|
648
|
+
value: function applyQuotationScheduleResolver(quotation) {
|
|
649
|
+
var scheduleModule = this.store.schedule;
|
|
650
|
+
if (!scheduleModule) return;
|
|
651
|
+
var scheduleById = new Map();
|
|
652
|
+
var scheduleList = typeof scheduleModule.getScheduleList === 'function' ? scheduleModule.getScheduleList() : [];
|
|
653
|
+
if (Array.isArray(scheduleList)) {
|
|
654
|
+
scheduleList.forEach(function (schedule) {
|
|
655
|
+
if ((schedule === null || schedule === void 0 ? void 0 : schedule.id) !== undefined && (schedule === null || schedule === void 0 ? void 0 : schedule.id) !== null) {
|
|
656
|
+
scheduleById.set(String(schedule.id), schedule);
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
quotation.setScheduleResolver(function (id) {
|
|
661
|
+
var _scheduleModule$getSc, _getScheduleByIds, _ref4;
|
|
662
|
+
var scheduleId = String(id);
|
|
663
|
+
if (scheduleById.has(scheduleId)) return scheduleById.get(scheduleId);
|
|
664
|
+
var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (_ref4 = scheduleModule).getScheduleByIds) === null || _getScheduleByIds === void 0 ? void 0 : _getScheduleByIds.call(_ref4, [id])) || [];
|
|
665
|
+
if (schedules[0]) scheduleById.set(scheduleId, schedules[0]);
|
|
666
|
+
return schedules[0];
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
}, {
|
|
670
|
+
key: "loadQuotationForPriceQuery",
|
|
671
|
+
value: function () {
|
|
672
|
+
var _loadQuotationForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
|
|
673
|
+
var _this$otherParams;
|
|
674
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
675
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
676
|
+
case 0:
|
|
677
|
+
if (params.quotation) {
|
|
678
|
+
_context6.next = 2;
|
|
679
|
+
break;
|
|
680
|
+
}
|
|
681
|
+
return _context6.abrupt("return");
|
|
682
|
+
case 2:
|
|
683
|
+
this.applyQuotationScheduleResolver(params.quotation);
|
|
684
|
+
_context6.next = 5;
|
|
685
|
+
return params.quotation.loadQuotations({
|
|
686
|
+
channel: params.channel || ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel),
|
|
687
|
+
customer_id: params.customer_id
|
|
688
|
+
});
|
|
689
|
+
case 5:
|
|
690
|
+
case "end":
|
|
691
|
+
return _context6.stop();
|
|
692
|
+
}
|
|
693
|
+
}, _callee6, this);
|
|
694
|
+
}));
|
|
695
|
+
function loadQuotationForPriceQuery(_x4) {
|
|
696
|
+
return _loadQuotationForPriceQuery.apply(this, arguments);
|
|
697
|
+
}
|
|
698
|
+
return loadQuotationForPriceQuery;
|
|
699
|
+
}()
|
|
700
|
+
}, {
|
|
701
|
+
key: "getPriceQueryProductId",
|
|
702
|
+
value: function getPriceQueryProductId(product) {
|
|
703
|
+
var _product$product_id;
|
|
704
|
+
var productId = Number((_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product === null || product === void 0 ? void 0 : product.id);
|
|
705
|
+
if (!Number.isFinite(productId)) return null;
|
|
706
|
+
return productId;
|
|
707
|
+
}
|
|
708
|
+
}, {
|
|
709
|
+
key: "getPriceQuerySchedule",
|
|
710
|
+
value: function getPriceQuerySchedule(params) {
|
|
711
|
+
var booking = params.booking || {};
|
|
712
|
+
if (typeof booking.start_date === 'string' && booking.start_date.trim()) {
|
|
713
|
+
var scheduleDate = booking.start_date.trim();
|
|
714
|
+
var startTime = typeof booking.start_time === 'string' && booking.start_time.trim() ? booking.start_time.trim() : '00:00:00';
|
|
715
|
+
var datetime = dayjs("".concat(scheduleDate, " ").concat(startTime));
|
|
716
|
+
return {
|
|
717
|
+
schedule_date: scheduleDate,
|
|
718
|
+
schedule_datetime: datetime.isValid() ? datetime.format('YYYY-MM-DD HH:mm:ss') : "".concat(scheduleDate, " ").concat(startTime)
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
if (typeof params.datetime === 'string' && params.datetime.trim()) {
|
|
722
|
+
var _datetime = dayjs(params.datetime.trim());
|
|
723
|
+
if (_datetime.isValid()) {
|
|
724
|
+
return {
|
|
725
|
+
schedule_date: _datetime.format('YYYY-MM-DD'),
|
|
726
|
+
schedule_datetime: _datetime.format('YYYY-MM-DD HH:mm:ss')
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
var now = dayjs();
|
|
731
|
+
return {
|
|
732
|
+
schedule_date: now.format('YYYY-MM-DD'),
|
|
733
|
+
schedule_datetime: now.format('YYYY-MM-DD HH:mm:ss')
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
}, {
|
|
737
|
+
key: "loadProductsForPriceQuery",
|
|
738
|
+
value: function () {
|
|
739
|
+
var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
|
|
740
|
+
var ids, productsById, _this$otherParams2, _response$data, response, list;
|
|
741
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
742
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
743
|
+
case 0:
|
|
744
|
+
ids = Array.from(new Set(params.ids.filter(function (id) {
|
|
745
|
+
return Number.isFinite(id);
|
|
746
|
+
})));
|
|
747
|
+
productsById = new Map();
|
|
748
|
+
if (!(!ids.length || !this.request)) {
|
|
749
|
+
_context7.next = 4;
|
|
750
|
+
break;
|
|
751
|
+
}
|
|
752
|
+
return _context7.abrupt("return", productsById);
|
|
753
|
+
case 4:
|
|
754
|
+
_context7.prev = 4;
|
|
755
|
+
_context7.next = 7;
|
|
756
|
+
return this.request.post('/product/query', {
|
|
757
|
+
ids: ids,
|
|
758
|
+
open_quotation: 1,
|
|
759
|
+
open_bundle: 1,
|
|
760
|
+
status: 'published',
|
|
761
|
+
num: 1,
|
|
762
|
+
skip: 1,
|
|
763
|
+
customer_id: params.customerId,
|
|
764
|
+
schedule_date: params.schedule.schedule_date,
|
|
765
|
+
schedule_datetime: params.schedule.schedule_datetime,
|
|
766
|
+
application_code: params.channel || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.channel)
|
|
767
|
+
}, {
|
|
768
|
+
osServer: true,
|
|
769
|
+
customToast: function customToast() {}
|
|
770
|
+
});
|
|
771
|
+
case 7:
|
|
772
|
+
response = _context7.sent;
|
|
773
|
+
list = (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.list) || (response === null || response === void 0 ? void 0 : response.list) || [];
|
|
774
|
+
if (Array.isArray(list)) {
|
|
775
|
+
_context7.next = 11;
|
|
776
|
+
break;
|
|
777
|
+
}
|
|
778
|
+
return _context7.abrupt("return", productsById);
|
|
779
|
+
case 11:
|
|
780
|
+
list.forEach(function (item) {
|
|
781
|
+
var _item$id;
|
|
782
|
+
var productId = Number((_item$id = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id !== void 0 ? _item$id : item === null || item === void 0 ? void 0 : item.product_id);
|
|
783
|
+
if (Number.isFinite(productId)) productsById.set(productId, item);
|
|
784
|
+
});
|
|
785
|
+
return _context7.abrupt("return", productsById);
|
|
786
|
+
case 15:
|
|
787
|
+
_context7.prev = 15;
|
|
788
|
+
_context7.t0 = _context7["catch"](4);
|
|
789
|
+
this.logWarning('loadProductsForPriceQuery: 商品批量重查失败,使用入参 fallback', {
|
|
790
|
+
ids: ids,
|
|
791
|
+
error: _context7.t0 instanceof Error ? _context7.t0.message : String(_context7.t0)
|
|
792
|
+
});
|
|
793
|
+
return _context7.abrupt("return", productsById);
|
|
794
|
+
case 19:
|
|
795
|
+
case "end":
|
|
796
|
+
return _context7.stop();
|
|
797
|
+
}
|
|
798
|
+
}, _callee7, this, [[4, 15]]);
|
|
799
|
+
}));
|
|
800
|
+
function loadProductsForPriceQuery(_x5) {
|
|
801
|
+
return _loadProductsForPriceQuery.apply(this, arguments);
|
|
802
|
+
}
|
|
803
|
+
return loadProductsForPriceQuery;
|
|
804
|
+
}()
|
|
805
|
+
}, {
|
|
806
|
+
key: "loadProductForPriceQuery",
|
|
807
|
+
value: function () {
|
|
808
|
+
var _loadProductForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params, customerId) {
|
|
809
|
+
var product, productId, schedule, productsById;
|
|
810
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
811
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
812
|
+
case 0:
|
|
813
|
+
product = params.product || {};
|
|
814
|
+
productId = this.getPriceQueryProductId(product);
|
|
815
|
+
if (!(productId === null || !this.request)) {
|
|
816
|
+
_context8.next = 4;
|
|
817
|
+
break;
|
|
818
|
+
}
|
|
819
|
+
return _context8.abrupt("return", null);
|
|
820
|
+
case 4:
|
|
821
|
+
schedule = this.getPriceQuerySchedule(params);
|
|
822
|
+
_context8.next = 7;
|
|
823
|
+
return this.loadProductsForPriceQuery({
|
|
824
|
+
ids: [productId],
|
|
825
|
+
schedule: schedule,
|
|
826
|
+
customerId: customerId,
|
|
827
|
+
channel: params.channel
|
|
828
|
+
});
|
|
829
|
+
case 7:
|
|
830
|
+
productsById = _context8.sent;
|
|
831
|
+
return _context8.abrupt("return", productsById.get(productId) || null);
|
|
832
|
+
case 9:
|
|
833
|
+
case "end":
|
|
834
|
+
return _context8.stop();
|
|
835
|
+
}
|
|
836
|
+
}, _callee8, this);
|
|
837
|
+
}));
|
|
838
|
+
function loadProductForPriceQuery(_x6, _x7) {
|
|
839
|
+
return _loadProductForPriceQuery.apply(this, arguments);
|
|
840
|
+
}
|
|
841
|
+
return loadProductForPriceQuery;
|
|
842
|
+
}()
|
|
843
|
+
}, {
|
|
844
|
+
key: "getAuthoritativeBundleItems",
|
|
845
|
+
value: function getAuthoritativeBundleItems(product) {
|
|
846
|
+
if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product.product_bundle;
|
|
847
|
+
var groups = Array.isArray(product === null || product === void 0 ? void 0 : product.bundle_group) ? product.bundle_group : Array.isArray(product === null || product === void 0 ? void 0 : product.bundleGroup) ? product.bundleGroup : [];
|
|
848
|
+
return groups.flatMap(function (group) {
|
|
849
|
+
var items = Array.isArray(group === null || group === void 0 ? void 0 : group.bundle_item) ? group.bundle_item : Array.isArray(group === null || group === void 0 ? void 0 : group.bundleItem) ? group.bundleItem : [];
|
|
850
|
+
return items.map(function (item) {
|
|
851
|
+
var _item$group_id, _ref5, _item$bundle_group_id;
|
|
852
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
853
|
+
group_id: (_item$group_id = item === null || item === void 0 ? void 0 : item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : group === null || group === void 0 ? void 0 : group.id,
|
|
854
|
+
bundle_group_id: (_ref5 = (_item$bundle_group_id = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item === null || item === void 0 ? void 0 : item.group_id) !== null && _ref5 !== void 0 ? _ref5 : group === null || group === void 0 ? void 0 : group.id
|
|
855
|
+
});
|
|
856
|
+
});
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
}, {
|
|
860
|
+
key: "findAuthoritativeBundleItem",
|
|
861
|
+
value: function findAuthoritativeBundleItem(bundle, candidates) {
|
|
862
|
+
var _bundle$bundle_id, _bundle$bundle_produc, _bundle$bundle_group_;
|
|
863
|
+
var bundleId = (_bundle$bundle_id = bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle.id;
|
|
864
|
+
if (bundleId != null) {
|
|
865
|
+
var matchedById = candidates.find(function (item) {
|
|
866
|
+
var _item$bundle_id;
|
|
867
|
+
return String((_item$bundle_id = item === null || item === void 0 ? void 0 : item.bundle_id) !== null && _item$bundle_id !== void 0 ? _item$bundle_id : item === null || item === void 0 ? void 0 : item.id) === String(bundleId);
|
|
868
|
+
});
|
|
869
|
+
if (matchedById) return matchedById;
|
|
870
|
+
}
|
|
871
|
+
var productId = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id;
|
|
872
|
+
var groupId = (_bundle$bundle_group_ = bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle.group_id;
|
|
873
|
+
return candidates.find(function (item) {
|
|
874
|
+
var _item$bundle_product_, _item$bundle_group_id2;
|
|
875
|
+
var itemProductId = (_item$bundle_product_ = item === null || item === void 0 ? void 0 : item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item === null || item === void 0 ? void 0 : item._bundle_product_id;
|
|
876
|
+
var itemGroupId = (_item$bundle_group_id2 = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id2 !== void 0 ? _item$bundle_group_id2 : item === null || item === void 0 ? void 0 : item.group_id;
|
|
877
|
+
if (productId == null || String(itemProductId) !== String(productId)) return false;
|
|
878
|
+
if (groupId == null) return true;
|
|
879
|
+
return String(itemGroupId) === String(groupId);
|
|
880
|
+
}) || null;
|
|
881
|
+
}
|
|
882
|
+
}, {
|
|
883
|
+
key: "getAuthoritativeBundleUnitPrice",
|
|
884
|
+
value: function getAuthoritativeBundleUnitPrice(bundle) {
|
|
885
|
+
var _ref6, _ref7, _ref8, _bundle$price;
|
|
886
|
+
return (_ref6 = (_ref7 = (_ref8 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref8 !== void 0 ? _ref8 : bundle.custom_price) !== null && _ref7 !== void 0 ? _ref7 : bundle.product_price) !== null && _ref6 !== void 0 ? _ref6 : bundle.base_price;
|
|
887
|
+
}
|
|
888
|
+
}, {
|
|
889
|
+
key: "mergeProductForPriceQuery",
|
|
890
|
+
value: function mergeProductForPriceQuery(product, authoritativeProduct) {
|
|
891
|
+
var _this5 = this,
|
|
892
|
+
_product$id,
|
|
893
|
+
_ref9,
|
|
894
|
+
_product$product_id2,
|
|
895
|
+
_ref10,
|
|
896
|
+
_product$product_vari,
|
|
897
|
+
_ref11,
|
|
898
|
+
_product$num,
|
|
899
|
+
_ref12,
|
|
900
|
+
_product$quantity,
|
|
901
|
+
_product$metadata4;
|
|
902
|
+
if (!authoritativeProduct) return product;
|
|
903
|
+
var selectedBundles = Array.isArray(product.product_bundle) ? product.product_bundle : [];
|
|
904
|
+
var authoritativeBundles = this.getAuthoritativeBundleItems(authoritativeProduct);
|
|
905
|
+
var productBundle = selectedBundles.map(function (bundle) {
|
|
906
|
+
var _authoritativeBundle$, _authoritativeBundle$2;
|
|
907
|
+
var authoritativeBundle = _this5.findAuthoritativeBundleItem(bundle, authoritativeBundles);
|
|
908
|
+
var unitPrice = authoritativeBundle ? _this5.getAuthoritativeBundleUnitPrice(authoritativeBundle) : undefined;
|
|
909
|
+
if (unitPrice === undefined || unitPrice === null || unitPrice === '') return bundle;
|
|
910
|
+
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
911
|
+
price: unitPrice,
|
|
912
|
+
bundle_selling_price: unitPrice,
|
|
913
|
+
base_price: (_authoritativeBundle$ = authoritativeBundle === null || authoritativeBundle === void 0 ? void 0 : authoritativeBundle.base_price) !== null && _authoritativeBundle$ !== void 0 ? _authoritativeBundle$ : bundle.base_price,
|
|
914
|
+
product_price: (_authoritativeBundle$2 = authoritativeBundle === null || authoritativeBundle === void 0 ? void 0 : authoritativeBundle.product_price) !== null && _authoritativeBundle$2 !== void 0 ? _authoritativeBundle$2 : bundle.product_price
|
|
915
|
+
});
|
|
916
|
+
});
|
|
917
|
+
return _objectSpread(_objectSpread(_objectSpread({}, product), authoritativeProduct), {}, {
|
|
918
|
+
id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : authoritativeProduct.id,
|
|
919
|
+
product_id: (_ref9 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref9 !== void 0 ? _ref9 : authoritativeProduct.id,
|
|
920
|
+
product_variant_id: (_ref10 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref10 !== void 0 ? _ref10 : 0,
|
|
921
|
+
num: (_ref11 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref11 !== void 0 ? _ref11 : authoritativeProduct.num,
|
|
922
|
+
quantity: (_ref12 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref12 !== void 0 ? _ref12 : authoritativeProduct.quantity,
|
|
923
|
+
product_sku: function () {
|
|
924
|
+
var authoritativeSku = ensureProductSku(authoritativeProduct);
|
|
925
|
+
var productSku = ensureProductSku(product);
|
|
926
|
+
var hasProductSku = product.product_sku && _typeof(product.product_sku) === 'object';
|
|
927
|
+
return _objectSpread(_objectSpread(_objectSpread({}, authoritativeSku), productSku), {}, {
|
|
928
|
+
option: hasProductSku ? productSku.option : authoritativeSku.option
|
|
929
|
+
});
|
|
930
|
+
}(),
|
|
931
|
+
product_bundle: productBundle,
|
|
932
|
+
metadata: (_product$metadata4 = product.metadata) !== null && _product$metadata4 !== void 0 ? _product$metadata4 : authoritativeProduct.metadata
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
}, {
|
|
936
|
+
key: "getSubmitOrderSalesChannel",
|
|
937
|
+
value: function getSubmitOrderSalesChannel() {
|
|
938
|
+
var _this$otherParams3;
|
|
939
|
+
return (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.channel;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* 工厂入口:根据子模块名实例化对应模块。
|
|
944
|
+
* 默认使用 BookingByStep 公共 `createModule`。子类若需引入额外类型(如 customer),
|
|
945
|
+
* 可覆盖此方法并把未识别的 name 委托给 `super.createSubModule(name)`。
|
|
946
|
+
*/
|
|
947
|
+
}, {
|
|
948
|
+
key: "createSubModule",
|
|
949
|
+
value: function createSubModule(moduleName) {
|
|
950
|
+
if (moduleName === 'quotation') {
|
|
951
|
+
return new QuotationModule("".concat(this.name, "_quotation"));
|
|
952
|
+
}
|
|
953
|
+
return createModule(moduleName, this.name);
|
|
954
|
+
}
|
|
955
|
+
}, {
|
|
956
|
+
key: "getSubModuleHooks",
|
|
957
|
+
value: function getSubModuleHooks(moduleName) {
|
|
958
|
+
var _this$otherParams$mod;
|
|
959
|
+
var optionHooks = this.initializeOptions.hooks || {};
|
|
960
|
+
var otherHooks = this.otherParams.hooks || {};
|
|
961
|
+
if (moduleName === 'order') {
|
|
962
|
+
var _this$otherParams$ord;
|
|
963
|
+
var directOrderHooks = optionHooks;
|
|
964
|
+
return optionHooks.order || ((_this$otherParams$ord = this.otherParams.order) === null || _this$otherParams$ord === void 0 ? void 0 : _this$otherParams$ord.hooks) || otherHooks.order || (directOrderHooks.onBeforeMergeProductToOrder ? directOrderHooks : undefined);
|
|
965
|
+
}
|
|
966
|
+
return optionHooks[moduleName] || ((_this$otherParams$mod = this.otherParams[moduleName]) === null || _this$otherParams$mod === void 0 ? void 0 : _this$otherParams$mod.hooks) || otherHooks[moduleName];
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* 构造传给 BaseSales 子模块的完整运行态参数,保证初始化和后续同步语义一致。
|
|
971
|
+
*
|
|
972
|
+
* @example
|
|
973
|
+
* const params = this.buildSubModuleOtherParams();
|
|
974
|
+
* this.core.registerModule(orderModule, { otherParams: params });
|
|
975
|
+
*/
|
|
976
|
+
}, {
|
|
977
|
+
key: "buildSubModuleOtherParams",
|
|
978
|
+
value: function buildSubModuleOtherParams() {
|
|
979
|
+
return _objectSpread(_objectSpread({}, this.otherParams), {}, {
|
|
980
|
+
salesSummaryModuleName: "".concat(this.name, "_salesSummary"),
|
|
981
|
+
fatherModule: this.name,
|
|
982
|
+
openCache: this.cacheId ? true : false,
|
|
983
|
+
cacheId: this.cacheId
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
/**
|
|
988
|
+
* 将父级 otherParams 的变更显式同步给已注册的子模块。
|
|
989
|
+
*
|
|
990
|
+
* @example
|
|
991
|
+
* await this.syncOtherParamsToSubModules({ channel: 'pos' });
|
|
992
|
+
*/
|
|
993
|
+
}, {
|
|
994
|
+
key: "syncOtherParamsToSubModules",
|
|
995
|
+
value: (function () {
|
|
996
|
+
var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(changedParams) {
|
|
997
|
+
var _this6 = this;
|
|
998
|
+
var _ref13,
|
|
999
|
+
_ref13$cover,
|
|
1000
|
+
cover,
|
|
1001
|
+
nextSubModuleOtherParams,
|
|
1002
|
+
_args10 = arguments;
|
|
1003
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1004
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1005
|
+
case 0:
|
|
1006
|
+
_ref13 = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {}, _ref13$cover = _ref13.cover, cover = _ref13$cover === void 0 ? false : _ref13$cover;
|
|
1007
|
+
nextSubModuleOtherParams = this.buildSubModuleOtherParams();
|
|
1008
|
+
_context10.next = 4;
|
|
1009
|
+
return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
|
|
1010
|
+
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref14) {
|
|
1011
|
+
var _ref16, moduleName, subModule, targetModule;
|
|
1012
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
1013
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1014
|
+
case 0:
|
|
1015
|
+
_ref16 = _slicedToArray(_ref14, 2), moduleName = _ref16[0], subModule = _ref16[1];
|
|
1016
|
+
if (!_this6.reusedSharedSubModuleNames.has(moduleName)) {
|
|
1017
|
+
_context9.next = 3;
|
|
1018
|
+
break;
|
|
1019
|
+
}
|
|
1020
|
+
return _context9.abrupt("return");
|
|
1021
|
+
case 3:
|
|
1022
|
+
targetModule = subModule;
|
|
1023
|
+
if (!(!targetModule || typeof targetModule.updateOtherParams !== 'function')) {
|
|
1024
|
+
_context9.next = 6;
|
|
1025
|
+
break;
|
|
1026
|
+
}
|
|
1027
|
+
return _context9.abrupt("return");
|
|
1028
|
+
case 6:
|
|
1029
|
+
_context9.next = 8;
|
|
1030
|
+
return targetModule.updateOtherParams(nextSubModuleOtherParams, {
|
|
1031
|
+
changedParams: changedParams,
|
|
1032
|
+
cover: cover
|
|
1033
|
+
});
|
|
1034
|
+
case 8:
|
|
1035
|
+
case "end":
|
|
1036
|
+
return _context9.stop();
|
|
1037
|
+
}
|
|
1038
|
+
}, _callee9);
|
|
1039
|
+
}));
|
|
1040
|
+
return function (_x9) {
|
|
1041
|
+
return _ref15.apply(this, arguments);
|
|
1042
|
+
};
|
|
1043
|
+
}()));
|
|
1044
|
+
case 4:
|
|
1045
|
+
case "end":
|
|
1046
|
+
return _context10.stop();
|
|
1047
|
+
}
|
|
1048
|
+
}, _callee10, this);
|
|
1049
|
+
}));
|
|
1050
|
+
function syncOtherParamsToSubModules(_x8) {
|
|
1051
|
+
return _syncOtherParamsToSubModules.apply(this, arguments);
|
|
1052
|
+
}
|
|
1053
|
+
return syncOtherParamsToSubModules;
|
|
1054
|
+
}()
|
|
1055
|
+
/**
|
|
1056
|
+
* 读取 sessionStorage[this.name][cacheId],作为子模块 initialState 的来源。
|
|
1057
|
+
* sessionStorage 损坏时静默忽略,按空状态注册。
|
|
1058
|
+
*/
|
|
1059
|
+
)
|
|
1060
|
+
}, {
|
|
1061
|
+
key: "readSessionCacheData",
|
|
1062
|
+
value: function readSessionCacheData() {
|
|
1063
|
+
if (!this.cacheId || !this.window) return {};
|
|
1064
|
+
try {
|
|
1065
|
+
var sessionData = this.window.sessionStorage.getItem(this.name);
|
|
1066
|
+
if (!sessionData) return {};
|
|
1067
|
+
var data = JSON.parse(sessionData);
|
|
1068
|
+
return data && data[this.cacheId] || {};
|
|
1069
|
+
} catch (_unused) {
|
|
1070
|
+
return {};
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
}, {
|
|
1074
|
+
key: "getAppData",
|
|
1075
|
+
value: function getAppData(key) {
|
|
1076
|
+
var _this$appPlugin$getDa, _this$appPlugin, _app$models, _app$models$getStore, _app$models$getStore$, _app$models$getStore$2;
|
|
1077
|
+
var getData = (_this$appPlugin$getDa = (_this$appPlugin = this.appPlugin).getData) === null || _this$appPlugin$getDa === void 0 ? void 0 : _this$appPlugin$getDa.call(_this$appPlugin);
|
|
1078
|
+
if (typeof getData === 'function') return getData(key);
|
|
1079
|
+
var app = this.appPlugin.getApp();
|
|
1080
|
+
var coreData = app === null || app === void 0 || (_app$models = app.models) === null || _app$models === void 0 || (_app$models$getStore = _app$models.getStore) === null || _app$models$getStore === void 0 || (_app$models$getStore$ = (_app$models$getStore$2 = _app$models$getStore.call(_app$models)).getDataByModel) === null || _app$models$getStore$ === void 0 ? void 0 : _app$models$getStore$.call(_app$models$getStore$2, 'core', 'core');
|
|
1081
|
+
return coreData === null || coreData === void 0 ? void 0 : coreData[key];
|
|
1082
|
+
}
|
|
1083
|
+
}, {
|
|
1084
|
+
key: "syncAppDataToTempOrder",
|
|
1085
|
+
value: function syncAppDataToTempOrder(tempOrder) {
|
|
1086
|
+
var isPriceIncludeTax = this.getAppData('is_price_include_tax');
|
|
1087
|
+
var taxCountryCode = this.getAppData('tax_country_code');
|
|
1088
|
+
var currencyCode = this.getAppData('shop_currency_code');
|
|
1089
|
+
var currencySymbol = this.getAppData('shop_symbol');
|
|
1090
|
+
var isChanged = false;
|
|
1091
|
+
if (isPriceIncludeTax !== undefined) {
|
|
1092
|
+
var nextIsPriceIncludeTax = Number(isPriceIncludeTax);
|
|
1093
|
+
if ((nextIsPriceIncludeTax === 0 || nextIsPriceIncludeTax === 1) && tempOrder.is_price_include_tax !== nextIsPriceIncludeTax) {
|
|
1094
|
+
tempOrder.is_price_include_tax = nextIsPriceIncludeTax;
|
|
1095
|
+
isChanged = true;
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
if (taxCountryCode !== undefined) {
|
|
1099
|
+
var nextTaxCountryCode = String(taxCountryCode || '');
|
|
1100
|
+
if (tempOrder.tax_country_code !== nextTaxCountryCode) {
|
|
1101
|
+
tempOrder.tax_country_code = nextTaxCountryCode;
|
|
1102
|
+
isChanged = true;
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
if (currencyCode !== undefined) {
|
|
1106
|
+
var nextCurrencyCode = String(currencyCode || '');
|
|
1107
|
+
if (tempOrder.currency_code !== nextCurrencyCode) {
|
|
1108
|
+
tempOrder.currency_code = nextCurrencyCode;
|
|
1109
|
+
isChanged = true;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
if (currencySymbol !== undefined) {
|
|
1113
|
+
var nextCurrencySymbol = String(currencySymbol || '');
|
|
1114
|
+
if (tempOrder.currency_symbol !== nextCurrencySymbol) {
|
|
1115
|
+
tempOrder.currency_symbol = nextCurrencySymbol;
|
|
1116
|
+
isChanged = true;
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
return isChanged;
|
|
1120
|
+
}
|
|
1121
|
+
}, {
|
|
1122
|
+
key: "initialize",
|
|
1123
|
+
value: function () {
|
|
1124
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(core) {
|
|
1125
|
+
var _this$otherParams4,
|
|
1126
|
+
_this$appPlugin2,
|
|
1127
|
+
_this$appPlugin2$getA,
|
|
1128
|
+
_this7 = this,
|
|
1129
|
+
_this$otherParams5;
|
|
1130
|
+
var options,
|
|
1131
|
+
app,
|
|
1132
|
+
targetCacheData,
|
|
1133
|
+
moduleNames,
|
|
1134
|
+
_args11 = arguments;
|
|
1135
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1136
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1137
|
+
case 0:
|
|
1138
|
+
options = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
|
|
1139
|
+
this.core = core;
|
|
1140
|
+
this.initializeOptions = options || {};
|
|
1141
|
+
// this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
|
|
1142
|
+
this.otherParams = options.otherParams || {};
|
|
1143
|
+
this.cacheId = (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.cacheId;
|
|
1144
|
+
this.reusedSharedSubModuleNames.clear();
|
|
1145
|
+
this.window = core.getPlugin('window');
|
|
1146
|
+
this.request = core.getPlugin('request');
|
|
1147
|
+
|
|
1148
|
+
// 获取 logger 实例
|
|
1149
|
+
this.appPlugin = core.getPlugin('app');
|
|
1150
|
+
if (!this.appPlugin) {
|
|
1151
|
+
// throw new Error('Checkout 解决方案需要 app 插件支持');
|
|
1152
|
+
}
|
|
1153
|
+
app = (_this$appPlugin2 = this.appPlugin) === null || _this$appPlugin2 === void 0 || (_this$appPlugin2$getA = _this$appPlugin2.getApp) === null || _this$appPlugin2$getA === void 0 ? void 0 : _this$appPlugin2$getA.call(_this$appPlugin2);
|
|
1154
|
+
this.logger = app === null || app === void 0 ? void 0 : app.logger;
|
|
1155
|
+
targetCacheData = this.readSessionCacheData();
|
|
1156
|
+
moduleNames = this.getRegisteredModuleNames();
|
|
1157
|
+
moduleNames.forEach(function (step) {
|
|
1158
|
+
var reusedModule = _this7.getReusableSharedSubModule(step);
|
|
1159
|
+
if (reusedModule) {
|
|
1160
|
+
_this7.store[step] = reusedModule;
|
|
1161
|
+
_this7.reusedSharedSubModuleNames.add(step);
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
var targetModule = _this7.createSubModule(step);
|
|
1165
|
+
if (!targetModule) {
|
|
1166
|
+
throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
|
|
1167
|
+
}
|
|
1168
|
+
var hooks = _this7.getSubModuleHooks(step);
|
|
1169
|
+
_this7.store[step] = targetModule;
|
|
1170
|
+
_this7.core.registerModule(targetModule, _objectSpread(_objectSpread({
|
|
1171
|
+
initialState: (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {}
|
|
1172
|
+
}, hooks ? {
|
|
1173
|
+
hooks: hooks
|
|
1174
|
+
} : {}), {}, {
|
|
1175
|
+
otherParams: _this7.buildSubModuleOtherParams()
|
|
1176
|
+
}));
|
|
1177
|
+
});
|
|
1178
|
+
if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
|
|
1179
|
+
_context11.next = 18;
|
|
1180
|
+
break;
|
|
1181
|
+
}
|
|
1182
|
+
_context11.next = 18;
|
|
1183
|
+
return this.store.schedule.loadAllSchedule();
|
|
1184
|
+
case 18:
|
|
1185
|
+
if (this.store.order && typeof ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.enableTempOrderPersist) === 'boolean') {
|
|
1186
|
+
this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
|
|
1187
|
+
}
|
|
1188
|
+
_context11.next = 21;
|
|
1189
|
+
return this.getPaymentMethodsAsync();
|
|
1190
|
+
case 21:
|
|
1191
|
+
this.registerServerOrderChangeSync();
|
|
1192
|
+
this.core.effects.emit("".concat(this.name, ":onInited"), {});
|
|
1193
|
+
case 23:
|
|
1194
|
+
case "end":
|
|
1195
|
+
return _context11.stop();
|
|
1196
|
+
}
|
|
1197
|
+
}, _callee11, this);
|
|
1198
|
+
}));
|
|
1199
|
+
function initialize(_x10) {
|
|
1200
|
+
return _initialize.apply(this, arguments);
|
|
1201
|
+
}
|
|
1202
|
+
return initialize;
|
|
1203
|
+
}()
|
|
1204
|
+
}, {
|
|
1205
|
+
key: "destroy",
|
|
1206
|
+
value: function () {
|
|
1207
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
1208
|
+
var _this$serverOrderChan2,
|
|
1209
|
+
_this8 = this;
|
|
1210
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1211
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1212
|
+
case 0:
|
|
1213
|
+
(_this$serverOrderChan2 = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan2 === void 0 || _this$serverOrderChan2.call(this);
|
|
1214
|
+
this.serverOrderChangeUnsubscribe = null;
|
|
1215
|
+
Object.keys(this.store).forEach(function (key) {
|
|
1216
|
+
if (_this8.reusedSharedSubModuleNames.has(key)) return;
|
|
1217
|
+
var sub = _this8.store[key];
|
|
1218
|
+
if (sub && typeof sub.destroy === 'function') {
|
|
1219
|
+
try {
|
|
1220
|
+
sub.destroy();
|
|
1221
|
+
} catch (error) {
|
|
1222
|
+
console.warn("[BaseSales] \u5B50\u6A21\u5757 ".concat(key, " \u9500\u6BC1\u5931\u8D25"), error);
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
});
|
|
1226
|
+
this.currentSalesDetail = null;
|
|
1227
|
+
this.queuedServerOrderChanges = [];
|
|
1228
|
+
this.salesDetailLoadSequence += 1;
|
|
1229
|
+
_context12.next = 8;
|
|
1230
|
+
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
1231
|
+
case 8:
|
|
1232
|
+
_get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
|
|
1233
|
+
case 9:
|
|
1234
|
+
case "end":
|
|
1235
|
+
return _context12.stop();
|
|
1236
|
+
}
|
|
1237
|
+
}, _callee12, this);
|
|
1238
|
+
}));
|
|
1239
|
+
function destroy() {
|
|
1240
|
+
return _destroy.apply(this, arguments);
|
|
1241
|
+
}
|
|
1242
|
+
return destroy;
|
|
1243
|
+
}()
|
|
1244
|
+
/**
|
|
1245
|
+
* 加载销售订单到统一 tempOrder 工作区。
|
|
1246
|
+
* 统一通过 OrderModule 的 sales detail lookup 加载订单详情。
|
|
1247
|
+
*
|
|
1248
|
+
* 子类可在 `super.loadSalesDetail` 之后基于返回的 `sales` 做业务侧装配
|
|
1249
|
+
* (比如把 `sales.customer` 写入 CustomerModule、emit 业务 hook 等)。
|
|
1250
|
+
*/
|
|
1251
|
+
}, {
|
|
1252
|
+
key: "loadSalesDetail",
|
|
1253
|
+
value: (function () {
|
|
1254
|
+
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderIdOrParams) {
|
|
1255
|
+
var loadSequence, _ref17, _ref18, _ref19, _ref20, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, record;
|
|
1256
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1257
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1258
|
+
case 0:
|
|
1259
|
+
if (this.store.order) {
|
|
1260
|
+
_context13.next = 2;
|
|
1261
|
+
break;
|
|
1262
|
+
}
|
|
1263
|
+
throw new Error('order 模块未初始化');
|
|
1264
|
+
case 2:
|
|
1265
|
+
loadSequence = ++this.salesDetailLoadSequence;
|
|
1266
|
+
this.salesDetailLoadInFlightCount += 1;
|
|
1267
|
+
_context13.prev = 4;
|
|
1268
|
+
params = _typeof(orderIdOrParams) === 'object' ? orderIdOrParams : {
|
|
1269
|
+
orderId: orderIdOrParams
|
|
1270
|
+
};
|
|
1271
|
+
externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
1272
|
+
preloadedSalesDetail = params.preloadedSalesDetail;
|
|
1273
|
+
lookup = (_ref17 = (_ref18 = (_ref19 = (_ref20 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref20 !== void 0 ? _ref20 : params.orderNumber) !== null && _ref19 !== void 0 ? _ref19 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref18 !== void 0 ? _ref18 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref17 !== void 0 ? _ref17 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
|
|
1274
|
+
if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
|
|
1275
|
+
_context13.next = 11;
|
|
1276
|
+
break;
|
|
1277
|
+
}
|
|
1278
|
+
throw new Error('加载销售详情需要 orderId、externalSaleNumber 或 orderNumber');
|
|
1279
|
+
case 11:
|
|
1280
|
+
if (!(preloadedSalesDetail !== null && preloadedSalesDetail !== void 0)) {
|
|
1281
|
+
_context13.next = 15;
|
|
1282
|
+
break;
|
|
1283
|
+
}
|
|
1284
|
+
_context13.t0 = preloadedSalesDetail;
|
|
1285
|
+
_context13.next = 18;
|
|
1286
|
+
break;
|
|
1287
|
+
case 15:
|
|
1288
|
+
_context13.next = 17;
|
|
1289
|
+
return this.store.order.getSalesOrderByLookup({
|
|
1290
|
+
lookup: lookup,
|
|
1291
|
+
forceRemote: params.forceRemote
|
|
1292
|
+
});
|
|
1293
|
+
case 17:
|
|
1294
|
+
_context13.t0 = _context13.sent;
|
|
1295
|
+
case 18:
|
|
1296
|
+
loadedRecord = _context13.t0;
|
|
1297
|
+
if (!(!preloadedSalesDetail && (!loadedRecord || loadedRecord.code !== 200))) {
|
|
1298
|
+
_context13.next = 22;
|
|
1299
|
+
break;
|
|
1300
|
+
}
|
|
1301
|
+
message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
|
|
1302
|
+
throw new Error(message);
|
|
1303
|
+
case 22:
|
|
1304
|
+
remoteRecord = preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data;
|
|
1305
|
+
currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
|
|
1306
|
+
record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord, 'preserve-local') : remoteRecord;
|
|
1307
|
+
_context13.next = 27;
|
|
1308
|
+
return this.hydrateLatestLoadedSalesDetail(record, loadSequence);
|
|
1309
|
+
case 27:
|
|
1310
|
+
return _context13.abrupt("return", _context13.sent);
|
|
1311
|
+
case 28:
|
|
1312
|
+
_context13.prev = 28;
|
|
1313
|
+
this.salesDetailLoadInFlightCount = Math.max(0, this.salesDetailLoadInFlightCount - 1);
|
|
1314
|
+
if (!(this.salesDetailLoadInFlightCount === 0)) {
|
|
1315
|
+
_context13.next = 39;
|
|
1316
|
+
break;
|
|
1317
|
+
}
|
|
1318
|
+
_context13.prev = 31;
|
|
1319
|
+
_context13.next = 34;
|
|
1320
|
+
return this.drainQueuedServerOrderChanges();
|
|
1321
|
+
case 34:
|
|
1322
|
+
_context13.next = 39;
|
|
1323
|
+
break;
|
|
1324
|
+
case 36:
|
|
1325
|
+
_context13.prev = 36;
|
|
1326
|
+
_context13.t1 = _context13["catch"](31);
|
|
1327
|
+
this.logError('drain queued server order changes failed', {
|
|
1328
|
+
error: _context13.t1 instanceof Error ? _context13.t1.message : String(_context13.t1)
|
|
1329
|
+
});
|
|
1330
|
+
case 39:
|
|
1331
|
+
return _context13.finish(28);
|
|
1332
|
+
case 40:
|
|
1333
|
+
case "end":
|
|
1334
|
+
return _context13.stop();
|
|
1335
|
+
}
|
|
1336
|
+
}, _callee13, this, [[4,, 28, 40], [31, 36]]);
|
|
1337
|
+
}));
|
|
1338
|
+
function loadSalesDetail(_x11) {
|
|
1339
|
+
return _loadSalesDetail.apply(this, arguments);
|
|
1340
|
+
}
|
|
1341
|
+
return loadSalesDetail;
|
|
1342
|
+
}() /** 获取当前已加载的销售详情(只读快照)。未加载过则返回 null。 */)
|
|
1343
|
+
}, {
|
|
1344
|
+
key: "getSalesOrder",
|
|
1345
|
+
value: function getSalesOrder() {
|
|
1346
|
+
return this.currentSalesDetail;
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
/** 获取销售详情顶部业务字段(订单号/状态/金额等通用字段集合)。 */
|
|
1350
|
+
}, {
|
|
1351
|
+
key: "getOrderHeader",
|
|
1352
|
+
value: function getOrderHeader() {
|
|
1353
|
+
if (!this.currentSalesDetail) return null;
|
|
1354
|
+
return this.currentSalesDetail.header || this.currentSalesDetail;
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
/** 获取所有 booking(含 root + children),按服务端原始顺序输出。 */
|
|
1358
|
+
}, {
|
|
1359
|
+
key: "getBookings",
|
|
1360
|
+
value: function getBookings() {
|
|
1361
|
+
var _this$currentSalesDet;
|
|
1362
|
+
return ((_this$currentSalesDet = this.currentSalesDetail) === null || _this$currentSalesDet === void 0 ? void 0 : _this$currentSalesDet.bookings) || [];
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
/** 获取根 booking(is_next === 0 / is_root === 1),多个时取第一个。 */
|
|
1366
|
+
}, {
|
|
1367
|
+
key: "getRootBooking",
|
|
1368
|
+
value: function getRootBooking() {
|
|
1369
|
+
if (!this.currentSalesDetail) return null;
|
|
1370
|
+
if (this.currentSalesDetail.rootBooking) return this.currentSalesDetail.rootBooking;
|
|
1371
|
+
var bookings = this.currentSalesDetail.bookings || [];
|
|
1372
|
+
return bookings.find(function (booking) {
|
|
1373
|
+
var parentId = booking === null || booking === void 0 ? void 0 : booking.parent_id;
|
|
1374
|
+
return parentId === 0 || parentId === null || parentId === undefined;
|
|
1375
|
+
}) || null;
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
/** 按 product_uid 反查 booking 列表(用于商品行 ↔ booking 映射)。 */
|
|
1379
|
+
}, {
|
|
1380
|
+
key: "getChildBookingsByProductUid",
|
|
1381
|
+
value: function getChildBookingsByProductUid(productUid) {
|
|
1382
|
+
var _this$currentSalesDet2;
|
|
1383
|
+
if (!this.currentSalesDetail || !productUid) return [];
|
|
1384
|
+
var indexed = (_this$currentSalesDet2 = this.currentSalesDetail.bookingsByProductUid) === null || _this$currentSalesDet2 === void 0 ? void 0 : _this$currentSalesDet2[productUid];
|
|
1385
|
+
if (indexed) return indexed;
|
|
1386
|
+
return (this.currentSalesDetail.bookings || []).filter(function (booking) {
|
|
1387
|
+
var _booking$metadata;
|
|
1388
|
+
var uid = (booking === null || booking === void 0 ? void 0 : booking.product_uid) || (booking === null || booking === void 0 || (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.product_uid);
|
|
1389
|
+
return String(uid || '') === String(productUid);
|
|
1390
|
+
});
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
/** 获取支付列表(已支付/退款等明细)。 */
|
|
1394
|
+
}, {
|
|
1395
|
+
key: "getPayments",
|
|
1396
|
+
value: function getPayments() {
|
|
1397
|
+
var _this$currentSalesDet3;
|
|
1398
|
+
return ((_this$currentSalesDet3 = this.currentSalesDetail) === null || _this$currentSalesDet3 === void 0 ? void 0 : _this$currentSalesDet3.payments) || [];
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
/** 获取附加费用(运费/服务费/税费等)。 */
|
|
1402
|
+
}, {
|
|
1403
|
+
key: "getSurcharges",
|
|
1404
|
+
value: function getSurcharges() {
|
|
1405
|
+
var _this$currentSalesDet4;
|
|
1406
|
+
return ((_this$currentSalesDet4 = this.currentSalesDetail) === null || _this$currentSalesDet4 === void 0 ? void 0 : _this$currentSalesDet4.surcharges) || [];
|
|
1407
|
+
}
|
|
1408
|
+
}, {
|
|
1409
|
+
key: "getTempOrder",
|
|
1410
|
+
value: function getTempOrder() {
|
|
1411
|
+
var _this$store$order3;
|
|
1412
|
+
var result = ((_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 ? void 0 : _this$store$order3.getTempOrder()) || null;
|
|
1413
|
+
return result;
|
|
1414
|
+
}
|
|
1415
|
+
}, {
|
|
1416
|
+
key: "replaceTempOrder",
|
|
1417
|
+
value: function () {
|
|
1418
|
+
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(tempOrder) {
|
|
1419
|
+
var nextTempOrder;
|
|
1420
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1421
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1422
|
+
case 0:
|
|
1423
|
+
if (this.store.order) {
|
|
1424
|
+
_context14.next = 2;
|
|
1425
|
+
break;
|
|
1426
|
+
}
|
|
1427
|
+
throw new Error('order 模块未初始化');
|
|
1428
|
+
case 2:
|
|
1429
|
+
_context14.next = 4;
|
|
1430
|
+
return this.store.order.replaceTempOrder(tempOrder);
|
|
1431
|
+
case 4:
|
|
1432
|
+
nextTempOrder = _context14.sent;
|
|
1433
|
+
_context14.next = 7;
|
|
1434
|
+
return this.effectsEmit('onTempOrderReplaced', {
|
|
1435
|
+
tempOrder: nextTempOrder
|
|
1436
|
+
});
|
|
1437
|
+
case 7:
|
|
1438
|
+
return _context14.abrupt("return", nextTempOrder);
|
|
1439
|
+
case 8:
|
|
1440
|
+
case "end":
|
|
1441
|
+
return _context14.stop();
|
|
1442
|
+
}
|
|
1443
|
+
}, _callee14, this);
|
|
1444
|
+
}));
|
|
1445
|
+
function replaceTempOrder(_x12) {
|
|
1446
|
+
return _replaceTempOrder.apply(this, arguments);
|
|
1447
|
+
}
|
|
1448
|
+
return replaceTempOrder;
|
|
1449
|
+
}()
|
|
1450
|
+
}, {
|
|
1451
|
+
key: "getOrderIdentity",
|
|
1452
|
+
value: function getOrderIdentity() {
|
|
1453
|
+
if (!this.store.order) return null;
|
|
1454
|
+
return this.store.order.getOrderIdentity();
|
|
1455
|
+
}
|
|
1456
|
+
}, {
|
|
1457
|
+
key: "getOrderSnapshot",
|
|
1458
|
+
value: function getOrderSnapshot() {
|
|
1459
|
+
if (!this.store.order) return null;
|
|
1460
|
+
return this.store.order.getOrderSnapshot();
|
|
1461
|
+
}
|
|
1462
|
+
}, {
|
|
1463
|
+
key: "getOrderSyncState",
|
|
1464
|
+
value: function getOrderSyncState() {
|
|
1465
|
+
if (!this.store.order) return 'local';
|
|
1466
|
+
return this.store.order.getOrderSyncState();
|
|
1467
|
+
}
|
|
1468
|
+
}, {
|
|
1469
|
+
key: "getOrderAmountSnapshot",
|
|
1470
|
+
value: function getOrderAmountSnapshot() {
|
|
1471
|
+
if (!this.store.order) return null;
|
|
1472
|
+
return this.store.order.getOrderAmountSnapshot();
|
|
1473
|
+
}
|
|
1474
|
+
}, {
|
|
1475
|
+
key: "getTempOrderNote",
|
|
1476
|
+
value: function getTempOrderNote() {
|
|
1477
|
+
if (!this.store.order) return '';
|
|
1478
|
+
return this.store.order.getTempOrderNote();
|
|
1479
|
+
}
|
|
1480
|
+
}, {
|
|
1481
|
+
key: "updateTempOrderNote",
|
|
1482
|
+
value: function updateTempOrderNote(note) {
|
|
1483
|
+
var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1484
|
+
try {
|
|
1485
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
1486
|
+
var result = this.store.order.updateTempOrderNote(note, sync);
|
|
1487
|
+
return result;
|
|
1488
|
+
} catch (error) {
|
|
1489
|
+
throw error;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
}, {
|
|
1493
|
+
key: "updateRemoteOrderNote",
|
|
1494
|
+
value: function updateRemoteOrderNote(orderId, note) {
|
|
1495
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
1496
|
+
this.store.order.syncTempOrderNoteToRemote(orderId, note);
|
|
1497
|
+
}
|
|
1498
|
+
}, {
|
|
1499
|
+
key: "updateTempOrderShopDiscount",
|
|
1500
|
+
value: function updateTempOrderShopDiscount(amount) {
|
|
1501
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
1502
|
+
return this.store.order.updateTempOrderShopDiscount(amount);
|
|
1503
|
+
}
|
|
1504
|
+
}, {
|
|
1505
|
+
key: "updateTempOrderDepositAmount",
|
|
1506
|
+
value: function updateTempOrderDepositAmount(amount) {
|
|
1507
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
1508
|
+
return this.store.order.updateTempOrderDepositAmount(amount);
|
|
1509
|
+
}
|
|
1510
|
+
}, {
|
|
1511
|
+
key: "updateTempOrderContactsInfo",
|
|
1512
|
+
value: function updateTempOrderContactsInfo(contactsInfo) {
|
|
1513
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
1514
|
+
return this.store.order.updateTempOrderContactsInfo(contactsInfo);
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
/** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化。 */
|
|
1518
|
+
}, {
|
|
1519
|
+
key: "setEnableTempOrderPersist",
|
|
1520
|
+
value: function setEnableTempOrderPersist(enabled) {
|
|
1521
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
1522
|
+
this.store.order.setEnableTempOrderPersist(enabled);
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
/** 是否允许 saveDraft 写入 IndexedDB 草稿。 */
|
|
1526
|
+
}, {
|
|
1527
|
+
key: "isTempOrderPersistEnabled",
|
|
1528
|
+
value: function isTempOrderPersistEnabled() {
|
|
1529
|
+
if (!this.store.order) return false;
|
|
1530
|
+
return this.store.order.isTempOrderPersistEnabled();
|
|
1531
|
+
}
|
|
1532
|
+
}, {
|
|
1533
|
+
key: "ensureTempOrder",
|
|
1534
|
+
value: function ensureTempOrder() {
|
|
1535
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
1536
|
+
return this.store.order.ensureTempOrder();
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
// 主动创建临时订单;若已存在则直接返回已有订单
|
|
1540
|
+
}, {
|
|
1541
|
+
key: "addNewOrder",
|
|
1542
|
+
value: function () {
|
|
1543
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
1544
|
+
var tempOrder;
|
|
1545
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1546
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1547
|
+
case 0:
|
|
1548
|
+
_context15.prev = 0;
|
|
1549
|
+
if (this.store.order) {
|
|
1550
|
+
_context15.next = 3;
|
|
1551
|
+
break;
|
|
1552
|
+
}
|
|
1553
|
+
throw new Error('order 模块未初始化');
|
|
1554
|
+
case 3:
|
|
1555
|
+
_context15.next = 5;
|
|
1556
|
+
return this.store.order.addNewOrder();
|
|
1557
|
+
case 5:
|
|
1558
|
+
tempOrder = _context15.sent;
|
|
1559
|
+
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
1560
|
+
_context15.next = 10;
|
|
1561
|
+
break;
|
|
1562
|
+
}
|
|
1563
|
+
this.store.order.persistTempOrder();
|
|
1564
|
+
_context15.next = 10;
|
|
1565
|
+
return this.store.order.saveDraft();
|
|
1566
|
+
case 10:
|
|
1567
|
+
return _context15.abrupt("return", tempOrder);
|
|
1568
|
+
case 13:
|
|
1569
|
+
_context15.prev = 13;
|
|
1570
|
+
_context15.t0 = _context15["catch"](0);
|
|
1571
|
+
throw _context15.t0;
|
|
1572
|
+
case 16:
|
|
1573
|
+
case "end":
|
|
1574
|
+
return _context15.stop();
|
|
1575
|
+
}
|
|
1576
|
+
}, _callee15, this, [[0, 13]]);
|
|
1577
|
+
}));
|
|
1578
|
+
function addNewOrder() {
|
|
1579
|
+
return _addNewOrder.apply(this, arguments);
|
|
1580
|
+
}
|
|
1581
|
+
return addNewOrder;
|
|
1582
|
+
}()
|
|
1583
|
+
}, {
|
|
1584
|
+
key: "saveDraft",
|
|
1585
|
+
value: function () {
|
|
1586
|
+
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
1587
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1588
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1589
|
+
case 0:
|
|
1590
|
+
if (this.store.order) {
|
|
1591
|
+
_context16.next = 2;
|
|
1592
|
+
break;
|
|
1593
|
+
}
|
|
1594
|
+
throw new Error('order 模块未初始化');
|
|
1595
|
+
case 2:
|
|
1596
|
+
return _context16.abrupt("return", this.store.order.saveDraft());
|
|
1597
|
+
case 3:
|
|
1598
|
+
case "end":
|
|
1599
|
+
return _context16.stop();
|
|
1600
|
+
}
|
|
1601
|
+
}, _callee16, this);
|
|
1602
|
+
}));
|
|
1603
|
+
function saveDraft() {
|
|
1604
|
+
return _saveDraft.apply(this, arguments);
|
|
1605
|
+
}
|
|
1606
|
+
return saveDraft;
|
|
1607
|
+
}() // 重置 tempOrder 与与上一单强相关的运行态(resource/entryPaxNumber/enabledReservationRuleProducts),
|
|
1608
|
+
// 适用于从支付页通过 react-router 跳回继续下单时清理残留数据
|
|
1609
|
+
}, {
|
|
1610
|
+
key: "restoreOrder",
|
|
1611
|
+
value: function () {
|
|
1612
|
+
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
1613
|
+
var tempOrder;
|
|
1614
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1615
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1616
|
+
case 0:
|
|
1617
|
+
_context17.prev = 0;
|
|
1618
|
+
if (this.store.order) {
|
|
1619
|
+
_context17.next = 3;
|
|
1620
|
+
break;
|
|
1621
|
+
}
|
|
1622
|
+
throw new Error('scanOrder 解决方案需要 order 模块支持');
|
|
1623
|
+
case 3:
|
|
1624
|
+
// this.store.resource = null;
|
|
1625
|
+
tempOrder = this.store.order.restoreOrder();
|
|
1626
|
+
this.currentSalesDetail = null;
|
|
1627
|
+
this.discountConfigCacheKey = null;
|
|
1628
|
+
this.hasManualDiscountSelection = false;
|
|
1629
|
+
_context17.next = 9;
|
|
1630
|
+
return this.effectsEmit('onTempOrderReplaced', {
|
|
1631
|
+
tempOrder: tempOrder
|
|
1632
|
+
});
|
|
1633
|
+
case 9:
|
|
1634
|
+
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
1635
|
+
_context17.next = 13;
|
|
1636
|
+
break;
|
|
1637
|
+
}
|
|
1638
|
+
this.store.order.persistTempOrder();
|
|
1639
|
+
_context17.next = 13;
|
|
1640
|
+
return this.store.order.saveDraft();
|
|
1641
|
+
case 13:
|
|
1642
|
+
return _context17.abrupt("return", tempOrder);
|
|
1643
|
+
case 16:
|
|
1644
|
+
_context17.prev = 16;
|
|
1645
|
+
_context17.t0 = _context17["catch"](0);
|
|
1646
|
+
throw _context17.t0;
|
|
1647
|
+
case 19:
|
|
1648
|
+
case "end":
|
|
1649
|
+
return _context17.stop();
|
|
1650
|
+
}
|
|
1651
|
+
}, _callee17, this, [[0, 16]]);
|
|
1652
|
+
}));
|
|
1653
|
+
function restoreOrder() {
|
|
1654
|
+
return _restoreOrder.apply(this, arguments);
|
|
1655
|
+
}
|
|
1656
|
+
return restoreOrder;
|
|
1657
|
+
}()
|
|
1658
|
+
/**
|
|
1659
|
+
* 仅清空 tempOrder 购物车行(products / bookings / discount_list)。
|
|
1660
|
+
* 同步清空内存中的 salesDetail 商品/预约视图,避免编辑态仍读到旧 bookings。
|
|
1661
|
+
*/
|
|
1662
|
+
}, {
|
|
1663
|
+
key: "clearOrderCartLines",
|
|
1664
|
+
value: (function () {
|
|
1665
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1666
|
+
var tempOrder;
|
|
1667
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1668
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1669
|
+
case 0:
|
|
1670
|
+
_context18.prev = 0;
|
|
1671
|
+
if (this.store.order) {
|
|
1672
|
+
_context18.next = 3;
|
|
1673
|
+
break;
|
|
1674
|
+
}
|
|
1675
|
+
throw new Error('order 模块未初始化');
|
|
1676
|
+
case 3:
|
|
1677
|
+
_context18.next = 5;
|
|
1678
|
+
return this.store.order.clearOrderCartLines();
|
|
1679
|
+
case 5:
|
|
1680
|
+
tempOrder = _context18.sent;
|
|
1681
|
+
if (this.currentSalesDetail) {
|
|
1682
|
+
this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
|
|
1683
|
+
products: [],
|
|
1684
|
+
bookings: [],
|
|
1685
|
+
rootBooking: null,
|
|
1686
|
+
bookingsByProductUid: {},
|
|
1687
|
+
discount_list: []
|
|
1688
|
+
});
|
|
1689
|
+
}
|
|
1690
|
+
_context18.next = 9;
|
|
1691
|
+
return this.effectsEmit('onTempOrderReplaced', {
|
|
1692
|
+
tempOrder: tempOrder
|
|
1693
|
+
});
|
|
1694
|
+
case 9:
|
|
1695
|
+
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
1696
|
+
_context18.next = 13;
|
|
1697
|
+
break;
|
|
1698
|
+
}
|
|
1699
|
+
this.store.order.persistTempOrder();
|
|
1700
|
+
_context18.next = 13;
|
|
1701
|
+
return this.store.order.saveDraft();
|
|
1702
|
+
case 13:
|
|
1703
|
+
return _context18.abrupt("return", tempOrder);
|
|
1704
|
+
case 16:
|
|
1705
|
+
_context18.prev = 16;
|
|
1706
|
+
_context18.t0 = _context18["catch"](0);
|
|
1707
|
+
throw _context18.t0;
|
|
1708
|
+
case 19:
|
|
1709
|
+
case "end":
|
|
1710
|
+
return _context18.stop();
|
|
1711
|
+
}
|
|
1712
|
+
}, _callee18, this, [[0, 16]]);
|
|
1713
|
+
}));
|
|
1714
|
+
function clearOrderCartLines() {
|
|
1715
|
+
return _clearOrderCartLines.apply(this, arguments);
|
|
1716
|
+
}
|
|
1717
|
+
return clearOrderCartLines;
|
|
1718
|
+
}())
|
|
1719
|
+
}, {
|
|
1720
|
+
key: "getOrderProducts",
|
|
1721
|
+
value: function getOrderProducts() {
|
|
1722
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
1723
|
+
var products = this.store.order.getOrderProducts();
|
|
1724
|
+
return products;
|
|
1725
|
+
}
|
|
1726
|
+
}, {
|
|
1727
|
+
key: "getSummary",
|
|
1728
|
+
value: function () {
|
|
1729
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
1730
|
+
var summary;
|
|
1731
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1732
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1733
|
+
case 0:
|
|
1734
|
+
_context19.prev = 0;
|
|
1735
|
+
if (this.store.order) {
|
|
1736
|
+
_context19.next = 3;
|
|
1737
|
+
break;
|
|
1738
|
+
}
|
|
1739
|
+
throw new Error('order 模块未初始化');
|
|
1740
|
+
case 3:
|
|
1741
|
+
_context19.next = 5;
|
|
1742
|
+
return this.store.order.getOrderSummary();
|
|
1743
|
+
case 5:
|
|
1744
|
+
summary = _context19.sent;
|
|
1745
|
+
return _context19.abrupt("return", summary);
|
|
1746
|
+
case 9:
|
|
1747
|
+
_context19.prev = 9;
|
|
1748
|
+
_context19.t0 = _context19["catch"](0);
|
|
1749
|
+
throw _context19.t0;
|
|
1750
|
+
case 12:
|
|
1751
|
+
case "end":
|
|
1752
|
+
return _context19.stop();
|
|
1753
|
+
}
|
|
1754
|
+
}, _callee19, this, [[0, 9]]);
|
|
1755
|
+
}));
|
|
1756
|
+
function getSummary() {
|
|
1757
|
+
return _getSummary.apply(this, arguments);
|
|
1758
|
+
}
|
|
1759
|
+
return getSummary;
|
|
1760
|
+
}()
|
|
1761
|
+
}, {
|
|
1762
|
+
key: "getHistoricalProductDiscountList",
|
|
1763
|
+
value: function getHistoricalProductDiscountList(products) {
|
|
1764
|
+
var _this9 = this;
|
|
1765
|
+
var historyDiscountList = [];
|
|
1766
|
+
products.forEach(function (item) {
|
|
1767
|
+
if (!_this9.isPersistedOrderProduct(item)) return;
|
|
1768
|
+
(item.discount_list || []).forEach(function (discount) {
|
|
1769
|
+
var _discount$discount, _discount$metadata, _discount$discount2, _discount$discount3, _discount$discount4;
|
|
1770
|
+
var discountId = ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
|
|
1771
|
+
if (!discountId || !['good_pass', 'discount_card'].includes(discount.type)) return;
|
|
1772
|
+
var quantity = item.quantity || item.num || item.product_quantity || 1;
|
|
1773
|
+
var savedAmount = new Decimal(discount.amount || 0).times(quantity).plus((discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.product_discount_difference) || 0);
|
|
1774
|
+
var index = historyDiscountList.findIndex(function (n) {
|
|
1775
|
+
return n.id === discountId;
|
|
1776
|
+
});
|
|
1777
|
+
if (index !== -1) {
|
|
1778
|
+
historyDiscountList[index] = _objectSpread(_objectSpread({}, historyDiscountList[index]), {}, {
|
|
1779
|
+
amount: new Decimal(historyDiscountList[index].amount || 0).plus(discount.amount || 0).toNumber(),
|
|
1780
|
+
savedAmount: savedAmount.plus(historyDiscountList[index].savedAmount || 0).toNumber()
|
|
1781
|
+
});
|
|
1782
|
+
return;
|
|
1783
|
+
}
|
|
1784
|
+
historyDiscountList.push(_objectSpread(_objectSpread({}, discount), {}, {
|
|
1785
|
+
id: discountId,
|
|
1786
|
+
tag: discount.tag || discount.type,
|
|
1787
|
+
name: discount.name || ((_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 || (_discount$discount2 = _discount$discount2.title) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.auto),
|
|
1788
|
+
format_title: ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.title) || discount.format_title,
|
|
1789
|
+
isEditMode: true,
|
|
1790
|
+
limited_relation_product_data: {},
|
|
1791
|
+
savedAmount: savedAmount.toNumber(),
|
|
1792
|
+
isAvailable: true,
|
|
1793
|
+
isDisabled: true,
|
|
1794
|
+
isSelected: true,
|
|
1795
|
+
product_id: ((_discount$discount4 = discount.discount) === null || _discount$discount4 === void 0 ? void 0 : _discount$discount4.product_id) || discount.product_id
|
|
1796
|
+
}));
|
|
1797
|
+
});
|
|
1798
|
+
});
|
|
1799
|
+
return historyDiscountList;
|
|
1800
|
+
}
|
|
1801
|
+
}, {
|
|
1802
|
+
key: "isPersistedOrderProduct",
|
|
1803
|
+
value: function isPersistedOrderProduct(product) {
|
|
1804
|
+
var _product$order_detail, _product$booking_id;
|
|
1805
|
+
var orderDetailId = (_product$order_detail = product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : product.orderDetailId;
|
|
1806
|
+
if (orderDetailId !== undefined && orderDetailId !== null && orderDetailId !== '') {
|
|
1807
|
+
return true;
|
|
1808
|
+
}
|
|
1809
|
+
var bookingId = (_product$booking_id = product.booking_id) !== null && _product$booking_id !== void 0 ? _product$booking_id : product.bookingId;
|
|
1810
|
+
return bookingId !== undefined && bookingId !== null && bookingId !== '';
|
|
1811
|
+
}
|
|
1812
|
+
}, {
|
|
1813
|
+
key: "mergeHistoricalDiscountList",
|
|
1814
|
+
value: function mergeHistoricalDiscountList(discountList, products) {
|
|
1815
|
+
var historyDiscountList = this.getHistoricalProductDiscountList(products);
|
|
1816
|
+
var historyIds = new Set(historyDiscountList.map(function (discount) {
|
|
1817
|
+
return discount.id;
|
|
1818
|
+
}));
|
|
1819
|
+
return [].concat(_toConsumableArray(historyDiscountList), _toConsumableArray((discountList || []).filter(function (discount) {
|
|
1820
|
+
if (!historyIds.has(discount.id)) return true;
|
|
1821
|
+
return !isBaseSalesHistoricalDiscountEntry(discount);
|
|
1822
|
+
})));
|
|
1823
|
+
}
|
|
1824
|
+
}, {
|
|
1825
|
+
key: "shouldSkipAutoApplyFetchedDiscountsInEditMode",
|
|
1826
|
+
value: function shouldSkipAutoApplyFetchedDiscountsInEditMode(params) {
|
|
1827
|
+
var _this10 = this;
|
|
1828
|
+
if (params.discountAction !== 'edit') return false;
|
|
1829
|
+
if (!params.products.length) return false;
|
|
1830
|
+
var hasDraftProduct = params.products.some(function (product) {
|
|
1831
|
+
return !_this10.isPersistedOrderProduct(product);
|
|
1832
|
+
});
|
|
1833
|
+
if (hasDraftProduct) return false;
|
|
1834
|
+
var hasSelectedDiscount = params.currentDiscountList.some(function (discount) {
|
|
1835
|
+
return discount.isSelected || discount.isEditMode || discount.isManualSelect;
|
|
1836
|
+
});
|
|
1837
|
+
if (hasSelectedDiscount) return false;
|
|
1838
|
+
return !params.nextDiscountList.some(function (discount) {
|
|
1839
|
+
return discount.isSelected || discount.isEditMode || discount.isManualSelect;
|
|
1840
|
+
});
|
|
1841
|
+
}
|
|
1842
|
+
}, {
|
|
1843
|
+
key: "mergeCurrentDiscountSelectionState",
|
|
1844
|
+
value: function mergeCurrentDiscountSelectionState(discountList, currentDiscountList) {
|
|
1845
|
+
if (!currentDiscountList.length) return discountList;
|
|
1846
|
+
var currentDiscountMap = new Map();
|
|
1847
|
+
currentDiscountList.forEach(function (discount) {
|
|
1848
|
+
currentDiscountMap.set("".concat(discount.id, ":").concat(isBaseSalesHistoricalDiscountEntry(discount) ? 'historical' : 'runtime'), discount);
|
|
1849
|
+
});
|
|
1850
|
+
return discountList.map(function (discount) {
|
|
1851
|
+
var currentDiscount = currentDiscountMap.get("".concat(discount.id, ":").concat(isBaseSalesHistoricalDiscountEntry(discount) ? 'historical' : 'runtime'));
|
|
1852
|
+
if (!currentDiscount) return discount;
|
|
1853
|
+
if (currentDiscount.isManualSelect) {
|
|
1854
|
+
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1855
|
+
isSelected: false,
|
|
1856
|
+
isManualSelect: true
|
|
1857
|
+
});
|
|
1858
|
+
}
|
|
1859
|
+
if (currentDiscount.isSelected) {
|
|
1860
|
+
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1861
|
+
isSelected: true,
|
|
1862
|
+
isManualSelect: false
|
|
1863
|
+
});
|
|
1864
|
+
}
|
|
1865
|
+
return discount;
|
|
1866
|
+
});
|
|
1867
|
+
}
|
|
1868
|
+
}, {
|
|
1869
|
+
key: "loadDiscountConfig",
|
|
1870
|
+
value: function () {
|
|
1871
|
+
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
1872
|
+
var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
|
|
1873
|
+
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _orderStore$summary, orderTotalAmount, result, _iterator2, _step2, _product$metadata5, _tempOrder$_extend3, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
|
|
1874
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1875
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1876
|
+
case 0:
|
|
1877
|
+
if (this.store.order) {
|
|
1878
|
+
_context20.next = 2;
|
|
1879
|
+
break;
|
|
1880
|
+
}
|
|
1881
|
+
throw new Error('order 模块未初始化');
|
|
1882
|
+
case 2:
|
|
1883
|
+
tempOrder = this.store.order.ensureTempOrder();
|
|
1884
|
+
orderStore = this.store.order.store || {};
|
|
1885
|
+
discountModule = orderStore.discount;
|
|
1886
|
+
rulesModule = orderStore.rules;
|
|
1887
|
+
orderId = tempOrder.order_id || ((_this$getOrderIdentit = this.getOrderIdentity) === null || _this$getOrderIdentit === void 0 || (_this$getOrderIdentit = _this$getOrderIdentit.call(this)) === null || _this$getOrderIdentit === void 0 ? void 0 : _this$getOrderIdentit.orderId);
|
|
1888
|
+
customerId = Number((params === null || params === void 0 ? void 0 : params.customerId) || tempOrder.customer_id || ((_tempOrder$customer = tempOrder.customer) === null || _tempOrder$customer === void 0 ? void 0 : _tempOrder$customer.id) || ((_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.customerSnapshot) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.id) || ((_tempOrder$_extend2 = tempOrder._extend) === null || _tempOrder$_extend2 === void 0 || (_tempOrder$_extend2 = _tempOrder$_extend2.customerSnapshot) === null || _tempOrder$_extend2 === void 0 ? void 0 : _tempOrder$_extend2.customer_id) || 0);
|
|
1889
|
+
currentDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
1890
|
+
originalDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
1891
|
+
hasManualDiscountSelection = this.hasManualDiscountSelection || currentDiscountList.some(function (discount) {
|
|
1892
|
+
return discount.isManualSelect;
|
|
1893
|
+
});
|
|
1894
|
+
discountAction = (params === null || params === void 0 ? void 0 : params.action) || (orderId ? 'edit' : 'create');
|
|
1895
|
+
discountConfigCacheKey = [customerId, discountAction, Number(orderId) || 0].join(':');
|
|
1896
|
+
preparedDiscountList = [];
|
|
1897
|
+
if (!(customerId && customerId !== 1)) {
|
|
1898
|
+
_context20.next = 25;
|
|
1899
|
+
break;
|
|
1900
|
+
}
|
|
1901
|
+
if (!(this.discountConfigCacheKey === discountConfigCacheKey)) {
|
|
1902
|
+
_context20.next = 19;
|
|
1903
|
+
break;
|
|
1904
|
+
}
|
|
1905
|
+
preparedDiscountList = originalDiscountList;
|
|
1906
|
+
_context20.next = 25;
|
|
1907
|
+
break;
|
|
1908
|
+
case 19:
|
|
1909
|
+
_context20.next = 21;
|
|
1910
|
+
return this.store.order.loadDiscountConfig({
|
|
1911
|
+
customerId: customerId,
|
|
1912
|
+
action: discountAction,
|
|
1913
|
+
orderId: Number(orderId) || undefined,
|
|
1914
|
+
apply: false
|
|
1915
|
+
});
|
|
1916
|
+
case 21:
|
|
1917
|
+
preparedDiscountList = _context20.sent;
|
|
1918
|
+
this.discountConfigCacheKey = discountConfigCacheKey;
|
|
1919
|
+
_context20.next = 25;
|
|
1920
|
+
return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, preparedDiscountList);
|
|
1921
|
+
case 25:
|
|
1922
|
+
if (!(hasManualDiscountSelection && currentDiscountList.length)) {
|
|
1923
|
+
_context20.next = 27;
|
|
1924
|
+
break;
|
|
1925
|
+
}
|
|
1926
|
+
return _context20.abrupt("return", {
|
|
1927
|
+
productList: tempOrder.products || [],
|
|
1928
|
+
discountList: currentDiscountList,
|
|
1929
|
+
availableWalletIds: this.getAvailableWalletIds()
|
|
1930
|
+
});
|
|
1931
|
+
case 27:
|
|
1932
|
+
nextDiscountList = this.mergeHistoricalDiscountList(preparedDiscountList || (discountModule === null || discountModule === void 0 || (_discountModule$getDi2 = discountModule.getDiscountList) === null || _discountModule$getDi2 === void 0 ? void 0 : _discountModule$getDi2.call(discountModule)) || [], tempOrder.products || []);
|
|
1933
|
+
nextDiscountList = this.mergeCurrentDiscountSelectionState(nextDiscountList, currentDiscountList);
|
|
1934
|
+
_context20.next = 31;
|
|
1935
|
+
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1936
|
+
case 31:
|
|
1937
|
+
shouldSkipAutoApplyFetchedDiscounts = this.shouldSkipAutoApplyFetchedDiscountsInEditMode({
|
|
1938
|
+
discountAction: discountAction,
|
|
1939
|
+
products: tempOrder.products || [],
|
|
1940
|
+
currentDiscountList: currentDiscountList,
|
|
1941
|
+
nextDiscountList: nextDiscountList
|
|
1942
|
+
});
|
|
1943
|
+
if (!shouldSkipAutoApplyFetchedDiscounts) {
|
|
1944
|
+
_context20.next = 40;
|
|
1945
|
+
break;
|
|
1946
|
+
}
|
|
1947
|
+
_context20.next = 35;
|
|
1948
|
+
return this.store.order.recalculateSummary({
|
|
1949
|
+
createIfMissing: true
|
|
1950
|
+
});
|
|
1951
|
+
case 35:
|
|
1952
|
+
_summary = _context20.sent;
|
|
1953
|
+
this.store.order.persistTempOrder();
|
|
1954
|
+
_context20.next = 39;
|
|
1955
|
+
return this.effectsEmit('onDiscountApplied', {
|
|
1956
|
+
productList: tempOrder.products || [],
|
|
1957
|
+
discountList: nextDiscountList,
|
|
1958
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
1959
|
+
tempOrder: tempOrder
|
|
1960
|
+
});
|
|
1961
|
+
case 39:
|
|
1962
|
+
return _context20.abrupt("return", {
|
|
1963
|
+
productList: tempOrder.products || [],
|
|
1964
|
+
discountList: nextDiscountList,
|
|
1965
|
+
availableWalletIds: this.getAvailableWalletIds()
|
|
1966
|
+
});
|
|
1967
|
+
case 40:
|
|
1968
|
+
if (!rulesModule) {
|
|
1969
|
+
_context20.next = 77;
|
|
1970
|
+
break;
|
|
1971
|
+
}
|
|
1972
|
+
orderTotalAmount = Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0);
|
|
1973
|
+
console.log('[BaseSales.applyDiscountConfig.calcDiscount]');
|
|
1974
|
+
result = rulesModule.calcDiscount({
|
|
1975
|
+
productList: tempOrder.products,
|
|
1976
|
+
discountList: nextDiscountList,
|
|
1977
|
+
holders: [],
|
|
1978
|
+
isFormSubject: function isFormSubject(product) {
|
|
1979
|
+
return resolveIsFormSubject(tempOrder, product);
|
|
1980
|
+
},
|
|
1981
|
+
orderTotalAmount: orderTotalAmount
|
|
1982
|
+
}) || {
|
|
1983
|
+
productList: tempOrder.products,
|
|
1984
|
+
discountList: nextDiscountList
|
|
1985
|
+
};
|
|
1986
|
+
if (result.productList) {
|
|
1987
|
+
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
1988
|
+
}
|
|
1989
|
+
_iterator2 = _createForOfIteratorHelper(tempOrder.products || []);
|
|
1990
|
+
_context20.prev = 46;
|
|
1991
|
+
_iterator2.s();
|
|
1992
|
+
case 48:
|
|
1993
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
1994
|
+
_context20.next = 63;
|
|
1995
|
+
break;
|
|
1996
|
+
}
|
|
1997
|
+
product = _step2.value;
|
|
1998
|
+
productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
|
|
1999
|
+
runtimeOrigin = productUid ? (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3[productUid]) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.origin : undefined;
|
|
2000
|
+
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
2001
|
+
_context20.next = 54;
|
|
2002
|
+
break;
|
|
2003
|
+
}
|
|
2004
|
+
return _context20.abrupt("continue", 61);
|
|
2005
|
+
case 54:
|
|
2006
|
+
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
2007
|
+
return sum + Number(pd.amount || 0);
|
|
2008
|
+
}, 0);
|
|
2009
|
+
optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
|
|
2010
|
+
sourcePrice = (_product$metadata$sou = (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : '0';
|
|
2011
|
+
newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
2012
|
+
newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
2013
|
+
if (product.metadata) {
|
|
2014
|
+
product.metadata.main_product_selling_price = newMainSellingPrice;
|
|
2015
|
+
product.metadata.price_schema_version = 2;
|
|
2016
|
+
}
|
|
2017
|
+
product.selling_price = composeLinePrice({
|
|
2018
|
+
mainPrice: newMainSellingPrice,
|
|
2019
|
+
bundle: product.product_bundle
|
|
2020
|
+
});
|
|
2021
|
+
case 61:
|
|
2022
|
+
_context20.next = 48;
|
|
2023
|
+
break;
|
|
2024
|
+
case 63:
|
|
2025
|
+
_context20.next = 68;
|
|
2026
|
+
break;
|
|
2027
|
+
case 65:
|
|
2028
|
+
_context20.prev = 65;
|
|
2029
|
+
_context20.t0 = _context20["catch"](46);
|
|
2030
|
+
_iterator2.e(_context20.t0);
|
|
2031
|
+
case 68:
|
|
2032
|
+
_context20.prev = 68;
|
|
2033
|
+
_iterator2.f();
|
|
2034
|
+
return _context20.finish(68);
|
|
2035
|
+
case 71:
|
|
2036
|
+
if (!result.discountList) {
|
|
2037
|
+
_context20.next = 77;
|
|
2038
|
+
break;
|
|
2039
|
+
}
|
|
2040
|
+
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
2041
|
+
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2042
|
+
_context20.next = 76;
|
|
2043
|
+
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2044
|
+
case 76:
|
|
2045
|
+
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
2046
|
+
return discount.isSelected;
|
|
2047
|
+
});
|
|
2048
|
+
case 77:
|
|
2049
|
+
_context20.next = 79;
|
|
2050
|
+
return this.store.order.recalculateSummary({
|
|
2051
|
+
createIfMissing: true
|
|
2052
|
+
});
|
|
2053
|
+
case 79:
|
|
2054
|
+
summary = _context20.sent;
|
|
2055
|
+
this.store.order.persistTempOrder();
|
|
2056
|
+
_context20.next = 83;
|
|
2057
|
+
return this.effectsEmit('onDiscountApplied', {
|
|
2058
|
+
productList: tempOrder.products || [],
|
|
2059
|
+
discountList: nextDiscountList,
|
|
2060
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
2061
|
+
tempOrder: tempOrder
|
|
2062
|
+
});
|
|
2063
|
+
case 83:
|
|
2064
|
+
return _context20.abrupt("return", {
|
|
2065
|
+
productList: tempOrder.products || [],
|
|
2066
|
+
discountList: nextDiscountList,
|
|
2067
|
+
availableWalletIds: this.getAvailableWalletIds()
|
|
2068
|
+
});
|
|
2069
|
+
case 84:
|
|
2070
|
+
case "end":
|
|
2071
|
+
return _context20.stop();
|
|
2072
|
+
}
|
|
2073
|
+
}, _callee20, this, [[46, 65, 68, 71]]);
|
|
2074
|
+
}));
|
|
2075
|
+
function loadDiscountConfig(_x13) {
|
|
2076
|
+
return _loadDiscountConfig.apply(this, arguments);
|
|
2077
|
+
}
|
|
2078
|
+
return loadDiscountConfig;
|
|
2079
|
+
}()
|
|
2080
|
+
}, {
|
|
2081
|
+
key: "getAvailableWalletIds",
|
|
2082
|
+
value: function getAvailableWalletIds() {
|
|
2083
|
+
var _this$store$order4;
|
|
2084
|
+
if (!((_this$store$order4 = this.store.order) !== null && _this$store$order4 !== void 0 && _this$store$order4.getAvailableWalletIds)) return [];
|
|
2085
|
+
return this.store.order.getAvailableWalletIds();
|
|
2086
|
+
}
|
|
2087
|
+
}, {
|
|
2088
|
+
key: "bestDiscount",
|
|
2089
|
+
value: function () {
|
|
2090
|
+
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(cb) {
|
|
2091
|
+
var _discountModule$getOr2, _discountModule$getDi3;
|
|
2092
|
+
var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
|
|
2093
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2094
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
2095
|
+
case 0:
|
|
2096
|
+
if (this.store.order) {
|
|
2097
|
+
_context21.next = 2;
|
|
2098
|
+
break;
|
|
2099
|
+
}
|
|
2100
|
+
throw new Error('order 模块未初始化');
|
|
2101
|
+
case 2:
|
|
2102
|
+
tempOrder = this.store.order.ensureTempOrder();
|
|
2103
|
+
orderStore = this.store.order.store || {};
|
|
2104
|
+
discountModule = orderStore.discount;
|
|
2105
|
+
rulesModule = orderStore.rules;
|
|
2106
|
+
originalDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getOr2 = discountModule.getOriginalDiscountList) === null || _discountModule$getOr2 === void 0 ? void 0 : _discountModule$getOr2.call(discountModule)) || this.getDiscountList();
|
|
2107
|
+
currentDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getDi3 = discountModule.getDiscountList) === null || _discountModule$getDi3 === void 0 ? void 0 : _discountModule$getDi3.call(discountModule)) || [];
|
|
2108
|
+
nextDiscountList = this.mergeHistoricalDiscountList(originalDiscountList || [], tempOrder.products || []);
|
|
2109
|
+
result = {
|
|
2110
|
+
productList: tempOrder.products || [],
|
|
2111
|
+
discountList: nextDiscountList
|
|
2112
|
+
};
|
|
2113
|
+
_context21.next = 12;
|
|
2114
|
+
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2115
|
+
case 12:
|
|
2116
|
+
if (!rulesModule) {
|
|
2117
|
+
_context21.next = 24;
|
|
2118
|
+
break;
|
|
2119
|
+
}
|
|
2120
|
+
orderTotalAmount = Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0);
|
|
2121
|
+
console.log('[BaseSales.bestDiscount.calcDiscount]');
|
|
2122
|
+
result = rulesModule.calcDiscount({
|
|
2123
|
+
productList: tempOrder.products,
|
|
2124
|
+
discountList: nextDiscountList,
|
|
2125
|
+
holders: [],
|
|
2126
|
+
isFormSubject: function isFormSubject(product) {
|
|
2127
|
+
return resolveIsFormSubject(tempOrder, product);
|
|
2128
|
+
},
|
|
2129
|
+
orderTotalAmount: orderTotalAmount
|
|
2130
|
+
}) || result;
|
|
2131
|
+
if (result.productList) {
|
|
2132
|
+
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2133
|
+
}
|
|
2134
|
+
if (!result.discountList) {
|
|
2135
|
+
_context21.next = 24;
|
|
2136
|
+
break;
|
|
2137
|
+
}
|
|
2138
|
+
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
2139
|
+
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2140
|
+
_context21.next = 22;
|
|
2141
|
+
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2142
|
+
case 22:
|
|
2143
|
+
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
2144
|
+
return discount.isSelected;
|
|
2145
|
+
});
|
|
2146
|
+
result = {
|
|
2147
|
+
productList: tempOrder.products,
|
|
2148
|
+
discountList: nextDiscountList
|
|
2149
|
+
};
|
|
2150
|
+
case 24:
|
|
2151
|
+
_context21.next = 26;
|
|
2152
|
+
return this.store.order.recalculateSummary({
|
|
2153
|
+
createIfMissing: true
|
|
2154
|
+
});
|
|
2155
|
+
case 26:
|
|
2156
|
+
this.store.order.persistTempOrder();
|
|
2157
|
+
_context21.next = 29;
|
|
2158
|
+
return this.effectsEmit('onDiscountApplied', {
|
|
2159
|
+
productList: tempOrder.products || [],
|
|
2160
|
+
discountList: nextDiscountList,
|
|
2161
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
2162
|
+
tempOrder: tempOrder
|
|
2163
|
+
});
|
|
2164
|
+
case 29:
|
|
2165
|
+
cb === null || cb === void 0 || cb(result);
|
|
2166
|
+
return _context21.abrupt("return", result);
|
|
2167
|
+
case 31:
|
|
2168
|
+
case "end":
|
|
2169
|
+
return _context21.stop();
|
|
2170
|
+
}
|
|
2171
|
+
}, _callee21, this);
|
|
2172
|
+
}));
|
|
2173
|
+
function bestDiscount(_x14) {
|
|
2174
|
+
return _bestDiscount.apply(this, arguments);
|
|
2175
|
+
}
|
|
2176
|
+
return bestDiscount;
|
|
2177
|
+
}()
|
|
2178
|
+
}, {
|
|
2179
|
+
key: "getDiscountList",
|
|
2180
|
+
value: function getDiscountList() {
|
|
2181
|
+
if (!this.store.order) return [];
|
|
2182
|
+
return this.store.order.getDiscountList();
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
/** 读取 Discount 模块原始券列表(未经过 bookingTime 等过滤)。 */
|
|
2186
|
+
}, {
|
|
2187
|
+
key: "getOriginalDiscountList",
|
|
2188
|
+
value: function getOriginalDiscountList() {
|
|
2189
|
+
var _store, _discountModule$getOr3;
|
|
2190
|
+
if (!this.store.order) return [];
|
|
2191
|
+
var discountModule = (_store = this.store.order.store) === null || _store === void 0 ? void 0 : _store.discount;
|
|
2192
|
+
return (discountModule === null || discountModule === void 0 || (_discountModule$getOr3 = discountModule.getOriginalDiscountList) === null || _discountModule$getOr3 === void 0 ? void 0 : _discountModule$getOr3.call(discountModule)) || [];
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2195
|
+
/**
|
|
2196
|
+
* 同步写入 Discount 模块的 discountList / originalDiscountList。
|
|
2197
|
+
* 供 Holder 补全等场景在 OS store 层更新 machinecode holder 字段。
|
|
2198
|
+
*/
|
|
2199
|
+
}, {
|
|
2200
|
+
key: "replaceDiscountStoreLists",
|
|
2201
|
+
value: (function () {
|
|
2202
|
+
var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
2203
|
+
var _store2;
|
|
2204
|
+
var discountModule;
|
|
2205
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2206
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
2207
|
+
case 0:
|
|
2208
|
+
if (this.store.order) {
|
|
2209
|
+
_context22.next = 2;
|
|
2210
|
+
break;
|
|
2211
|
+
}
|
|
2212
|
+
throw new Error('order 模块未初始化');
|
|
2213
|
+
case 2:
|
|
2214
|
+
discountModule = (_store2 = this.store.order.store) === null || _store2 === void 0 ? void 0 : _store2.discount;
|
|
2215
|
+
if (discountModule) {
|
|
2216
|
+
_context22.next = 5;
|
|
2217
|
+
break;
|
|
2218
|
+
}
|
|
2219
|
+
return _context22.abrupt("return");
|
|
2220
|
+
case 5:
|
|
2221
|
+
if (!params.originalDiscountList) {
|
|
2222
|
+
_context22.next = 8;
|
|
2223
|
+
break;
|
|
2224
|
+
}
|
|
2225
|
+
_context22.next = 8;
|
|
2226
|
+
return discountModule.setOriginalDiscountList(params.originalDiscountList);
|
|
2227
|
+
case 8:
|
|
2228
|
+
_context22.next = 10;
|
|
2229
|
+
return discountModule.setDiscountList(params.discountList);
|
|
2230
|
+
case 10:
|
|
2231
|
+
case "end":
|
|
2232
|
+
return _context22.stop();
|
|
2233
|
+
}
|
|
2234
|
+
}, _callee22, this);
|
|
2235
|
+
}));
|
|
2236
|
+
function replaceDiscountStoreLists(_x15) {
|
|
2237
|
+
return _replaceDiscountStoreLists.apply(this, arguments);
|
|
2238
|
+
}
|
|
2239
|
+
return replaceDiscountStoreLists;
|
|
2240
|
+
}())
|
|
2241
|
+
}, {
|
|
2242
|
+
key: "scanPromotionCode",
|
|
2243
|
+
value: function () {
|
|
2244
|
+
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(code, customerId) {
|
|
2245
|
+
var raw, tempOrder;
|
|
2246
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2247
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
2248
|
+
case 0:
|
|
2249
|
+
_context23.prev = 0;
|
|
2250
|
+
if (this.store.order) {
|
|
2251
|
+
_context23.next = 3;
|
|
2252
|
+
break;
|
|
2253
|
+
}
|
|
2254
|
+
throw new Error('order 模块未初始化');
|
|
2255
|
+
case 3:
|
|
2256
|
+
_context23.next = 5;
|
|
2257
|
+
return this.store.order.scanCode(code, customerId);
|
|
2258
|
+
case 5:
|
|
2259
|
+
raw = _context23.sent;
|
|
2260
|
+
if (!raw.isAvailable) {
|
|
2261
|
+
_context23.next = 13;
|
|
2262
|
+
break;
|
|
2263
|
+
}
|
|
2264
|
+
_context23.next = 9;
|
|
2265
|
+
return this.store.order.recalculateSummary({
|
|
2266
|
+
createIfMissing: true
|
|
2267
|
+
});
|
|
2268
|
+
case 9:
|
|
2269
|
+
this.store.order.persistTempOrder();
|
|
2270
|
+
tempOrder = this.store.order.ensureTempOrder();
|
|
2271
|
+
_context23.next = 13;
|
|
2272
|
+
return this.effectsEmit('onDiscountApplied', {
|
|
2273
|
+
productList: tempOrder.products || [],
|
|
2274
|
+
discountList: this.store.order.getDiscountList(),
|
|
2275
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
2276
|
+
tempOrder: tempOrder
|
|
2277
|
+
});
|
|
2278
|
+
case 13:
|
|
2279
|
+
return _context23.abrupt("return", {
|
|
2280
|
+
isAvailable: raw.isAvailable,
|
|
2281
|
+
type: raw.type,
|
|
2282
|
+
unavailableReason: raw.unavailableReason,
|
|
2283
|
+
scannedDiscountList: raw.scannedDiscountList
|
|
2284
|
+
});
|
|
2285
|
+
case 16:
|
|
2286
|
+
_context23.prev = 16;
|
|
2287
|
+
_context23.t0 = _context23["catch"](0);
|
|
2288
|
+
throw _context23.t0;
|
|
2289
|
+
case 19:
|
|
2290
|
+
case "end":
|
|
2291
|
+
return _context23.stop();
|
|
2292
|
+
}
|
|
2293
|
+
}, _callee23, this, [[0, 16]]);
|
|
2294
|
+
}));
|
|
2295
|
+
function scanPromotionCode(_x16, _x17) {
|
|
2296
|
+
return _scanPromotionCode.apply(this, arguments);
|
|
2297
|
+
}
|
|
2298
|
+
return scanPromotionCode;
|
|
2299
|
+
}() // TODO 需要优化,这段逻辑太长了,里面应该有些历史遗留问题
|
|
2300
|
+
}, {
|
|
2301
|
+
key: "setDiscountSelected",
|
|
2302
|
+
value: function () {
|
|
2303
|
+
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
|
|
2304
|
+
var list, updated, tempOrder, orderStore, discountModule, rulesModule, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds, _iterator3, _step3, d, selectedResourceIds, filterSelectedDiscountDetails, _iterator4, _step4, _product$metadata8, _tempOrder$_extend4, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
|
|
2305
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2306
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2307
|
+
case 0:
|
|
2308
|
+
_context24.prev = 0;
|
|
2309
|
+
if (this.store.order) {
|
|
2310
|
+
_context24.next = 3;
|
|
2311
|
+
break;
|
|
2312
|
+
}
|
|
2313
|
+
throw new Error('order 模块未初始化');
|
|
2314
|
+
case 3:
|
|
2315
|
+
list = this.store.order.getDiscountList();
|
|
2316
|
+
updated = list.map(function (d) {
|
|
2317
|
+
return d.id === params.discountId && !isBaseSalesHistoricalDiscountEntry(d) ? _objectSpread(_objectSpread({}, d), {}, {
|
|
2318
|
+
isSelected: params.isSelected,
|
|
2319
|
+
isManualSelect: !params.isSelected
|
|
2320
|
+
}) : d;
|
|
2321
|
+
});
|
|
2322
|
+
this.hasManualDiscountSelection = true;
|
|
2323
|
+
tempOrder = this.store.order.ensureTempOrder();
|
|
2324
|
+
orderStore = this.store.order.store || {};
|
|
2325
|
+
discountModule = orderStore.discount;
|
|
2326
|
+
rulesModule = orderStore.rules;
|
|
2327
|
+
nextDiscountList = updated;
|
|
2328
|
+
_context24.next = 13;
|
|
2329
|
+
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
|
|
2330
|
+
case 13:
|
|
2331
|
+
if (rulesModule) {
|
|
2332
|
+
orderTotalAmount = Number(((_orderStore$summary3 = orderStore.summary) === null || _orderStore$summary3 === void 0 ? void 0 : _orderStore$summary3.total_amount) || 0);
|
|
2333
|
+
console.log('[BaseSales.setDiscountSelected.calcDiscount]');
|
|
2334
|
+
result = rulesModule.calcDiscount({
|
|
2335
|
+
productList: tempOrder.products,
|
|
2336
|
+
discountList: updated,
|
|
2337
|
+
holders: [],
|
|
2338
|
+
isFormSubject: function isFormSubject(product) {
|
|
2339
|
+
return resolveIsFormSubject(tempOrder, product);
|
|
2340
|
+
},
|
|
2341
|
+
orderTotalAmount: orderTotalAmount
|
|
2342
|
+
}, {
|
|
2343
|
+
discountId: params.discountId,
|
|
2344
|
+
isSelected: params.isSelected
|
|
2345
|
+
}) || {
|
|
2346
|
+
productList: tempOrder.products,
|
|
2347
|
+
discountList: updated
|
|
2348
|
+
};
|
|
2349
|
+
if (result !== null && result !== void 0 && result.productList) {
|
|
2350
|
+
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2351
|
+
}
|
|
2352
|
+
if (result !== null && result !== void 0 && result.discountList) {
|
|
2353
|
+
nextDiscountList = result.discountList;
|
|
2354
|
+
if (!params.isSelected) {
|
|
2355
|
+
beforeSelectedIds = new Set(updated.filter(function (d) {
|
|
2356
|
+
return d.isSelected;
|
|
2357
|
+
}).map(function (d) {
|
|
2358
|
+
return d.id;
|
|
2359
|
+
}));
|
|
2360
|
+
_iterator3 = _createForOfIteratorHelper(nextDiscountList);
|
|
2361
|
+
try {
|
|
2362
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
2363
|
+
d = _step3.value;
|
|
2364
|
+
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
2365
|
+
d.isSelected = false;
|
|
2366
|
+
d.isManualSelect = true;
|
|
2367
|
+
d.appliedProductDetails = [];
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
} catch (err) {
|
|
2371
|
+
_iterator3.e(err);
|
|
2372
|
+
} finally {
|
|
2373
|
+
_iterator3.f();
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
selectedResourceIds = new Set(nextDiscountList.filter(function (d) {
|
|
2379
|
+
return d.isSelected;
|
|
2380
|
+
}).map(function (d) {
|
|
2381
|
+
return d.id;
|
|
2382
|
+
}));
|
|
2383
|
+
filterSelectedDiscountDetails = function filterSelectedDiscountDetails(discountList) {
|
|
2384
|
+
return (discountList || []).filter(function (pd) {
|
|
2385
|
+
var _pd$discount$resource, _pd$discount;
|
|
2386
|
+
var rid = (_pd$discount$resource = (_pd$discount = pd.discount) === null || _pd$discount === void 0 ? void 0 : _pd$discount.resource_id) !== null && _pd$discount$resource !== void 0 ? _pd$discount$resource : pd.id;
|
|
2387
|
+
return rid != null && selectedResourceIds.has(rid);
|
|
2388
|
+
});
|
|
2389
|
+
};
|
|
2390
|
+
_iterator4 = _createForOfIteratorHelper(tempOrder.products);
|
|
2391
|
+
_context24.prev = 17;
|
|
2392
|
+
_iterator4.s();
|
|
2393
|
+
case 19:
|
|
2394
|
+
if ((_step4 = _iterator4.n()).done) {
|
|
2395
|
+
_context24.next = 36;
|
|
2396
|
+
break;
|
|
2397
|
+
}
|
|
2398
|
+
product = _step4.value;
|
|
2399
|
+
productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
|
|
2400
|
+
runtimeOrigin = productUid ? (_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.productsByUid) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4[productUid]) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.origin : undefined;
|
|
2401
|
+
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
2402
|
+
_context24.next = 25;
|
|
2403
|
+
break;
|
|
2404
|
+
}
|
|
2405
|
+
return _context24.abrupt("continue", 34);
|
|
2406
|
+
case 25:
|
|
2407
|
+
product.discount_list = filterSelectedDiscountDetails(product.discount_list);
|
|
2408
|
+
if (Array.isArray(product.product_bundle)) {
|
|
2409
|
+
product.product_bundle = product.product_bundle.map(function (bundle) {
|
|
2410
|
+
var _ref21, _bundle$original_pric;
|
|
2411
|
+
var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
|
|
2412
|
+
var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
|
|
2413
|
+
var restoredBundlePrice = (_ref21 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref21 !== void 0 ? _ref21 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
|
|
2414
|
+
return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
|
|
2415
|
+
price: restoredBundlePrice,
|
|
2416
|
+
bundle_selling_price: restoredBundlePrice
|
|
2417
|
+
} : {}), {}, {
|
|
2418
|
+
discount_list: nextBundleDiscountList
|
|
2419
|
+
});
|
|
2420
|
+
});
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
// 券作用于 source(不含 option、不含 bundle);算出新 source 折后价后补回 options
|
|
2424
|
+
// 写入含 option 的 main_product_selling_price,再合成 composite 回写 selling_price。
|
|
2425
|
+
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
2426
|
+
return sum + (pd.amount || 0);
|
|
2427
|
+
}, 0); // TODO 这块逻辑需要拿掉
|
|
2428
|
+
optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
|
|
2429
|
+
sourcePrice = (_product$metadata$sou2 = (_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.source_product_price) !== null && _product$metadata$sou2 !== void 0 ? _product$metadata$sou2 : ((_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri2 = product.original_price) !== null && _product$original_pri2 !== void 0 ? _product$original_pri2 : '0';
|
|
2430
|
+
newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
2431
|
+
newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
2432
|
+
if (product.metadata) {
|
|
2433
|
+
product.metadata.main_product_selling_price = newMainSellingPrice;
|
|
2434
|
+
product.metadata.price_schema_version = 2;
|
|
2435
|
+
}
|
|
2436
|
+
product.selling_price = composeLinePrice({
|
|
2437
|
+
mainPrice: newMainSellingPrice,
|
|
2438
|
+
bundle: product.product_bundle
|
|
2439
|
+
});
|
|
2440
|
+
case 34:
|
|
2441
|
+
_context24.next = 19;
|
|
2442
|
+
break;
|
|
2443
|
+
case 36:
|
|
2444
|
+
_context24.next = 41;
|
|
2445
|
+
break;
|
|
2446
|
+
case 38:
|
|
2447
|
+
_context24.prev = 38;
|
|
2448
|
+
_context24.t0 = _context24["catch"](17);
|
|
2449
|
+
_iterator4.e(_context24.t0);
|
|
2450
|
+
case 41:
|
|
2451
|
+
_context24.prev = 41;
|
|
2452
|
+
_iterator4.f();
|
|
2453
|
+
return _context24.finish(41);
|
|
2454
|
+
case 44:
|
|
2455
|
+
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2456
|
+
_context24.next = 47;
|
|
2457
|
+
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2458
|
+
case 47:
|
|
2459
|
+
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
2460
|
+
return d.isSelected;
|
|
2461
|
+
});
|
|
2462
|
+
_context24.next = 50;
|
|
2463
|
+
return this.store.order.recalculateSummary({
|
|
2464
|
+
createIfMissing: true
|
|
2465
|
+
});
|
|
2466
|
+
case 50:
|
|
2467
|
+
this.store.order.persistTempOrder();
|
|
2468
|
+
this.effectsEmit('onDiscountApplied', {
|
|
2469
|
+
productList: tempOrder.products,
|
|
2470
|
+
discountList: nextDiscountList,
|
|
2471
|
+
selectedDiscountList: tempOrder.discount_list,
|
|
2472
|
+
tempOrder: tempOrder
|
|
2473
|
+
});
|
|
2474
|
+
_context24.next = 57;
|
|
2475
|
+
break;
|
|
2476
|
+
case 54:
|
|
2477
|
+
_context24.prev = 54;
|
|
2478
|
+
_context24.t1 = _context24["catch"](0);
|
|
2479
|
+
throw _context24.t1;
|
|
2480
|
+
case 57:
|
|
2481
|
+
case "end":
|
|
2482
|
+
return _context24.stop();
|
|
2483
|
+
}
|
|
2484
|
+
}, _callee24, this, [[0, 54], [17, 38, 41, 44]]);
|
|
2485
|
+
}));
|
|
2486
|
+
function setDiscountSelected(_x18) {
|
|
2487
|
+
return _setDiscountSelected.apply(this, arguments);
|
|
2488
|
+
}
|
|
2489
|
+
return setDiscountSelected;
|
|
2490
|
+
}()
|
|
2491
|
+
}, {
|
|
2492
|
+
key: "applyDiscountCalculationResult",
|
|
2493
|
+
value: function () {
|
|
2494
|
+
var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(result) {
|
|
2495
|
+
var tempOrder, orderStore, discountModule;
|
|
2496
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2497
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2498
|
+
case 0:
|
|
2499
|
+
_context25.prev = 0;
|
|
2500
|
+
if (this.store.order) {
|
|
2501
|
+
_context25.next = 3;
|
|
2502
|
+
break;
|
|
2503
|
+
}
|
|
2504
|
+
throw new Error('order 模块未初始化');
|
|
2505
|
+
case 3:
|
|
2506
|
+
if (result) {
|
|
2507
|
+
_context25.next = 5;
|
|
2508
|
+
break;
|
|
2509
|
+
}
|
|
2510
|
+
return _context25.abrupt("return");
|
|
2511
|
+
case 5:
|
|
2512
|
+
tempOrder = this.store.order.ensureTempOrder();
|
|
2513
|
+
orderStore = this.store.order.store || {};
|
|
2514
|
+
discountModule = orderStore.discount;
|
|
2515
|
+
if (result.productList) {
|
|
2516
|
+
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2517
|
+
}
|
|
2518
|
+
if (!result.discountList) {
|
|
2519
|
+
_context25.next = 14;
|
|
2520
|
+
break;
|
|
2521
|
+
}
|
|
2522
|
+
OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
|
|
2523
|
+
_context25.next = 13;
|
|
2524
|
+
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(result.discountList);
|
|
2525
|
+
case 13:
|
|
2526
|
+
tempOrder.discount_list = result.discountList.filter(function (discount) {
|
|
2527
|
+
return discount.isSelected;
|
|
2528
|
+
});
|
|
2529
|
+
case 14:
|
|
2530
|
+
_context25.next = 16;
|
|
2531
|
+
return this.store.order.recalculateSummary({
|
|
2532
|
+
createIfMissing: true
|
|
2533
|
+
});
|
|
2534
|
+
case 16:
|
|
2535
|
+
this.store.order.persistTempOrder();
|
|
2536
|
+
_context25.next = 19;
|
|
2537
|
+
return this.effectsEmit('onDiscountApplied', {
|
|
2538
|
+
productList: tempOrder.products || [],
|
|
2539
|
+
discountList: result.discountList || [],
|
|
2540
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
2541
|
+
tempOrder: tempOrder
|
|
2542
|
+
});
|
|
2543
|
+
case 19:
|
|
2544
|
+
_context25.next = 24;
|
|
2545
|
+
break;
|
|
2546
|
+
case 21:
|
|
2547
|
+
_context25.prev = 21;
|
|
2548
|
+
_context25.t0 = _context25["catch"](0);
|
|
2549
|
+
throw _context25.t0;
|
|
2550
|
+
case 24:
|
|
2551
|
+
case "end":
|
|
2552
|
+
return _context25.stop();
|
|
2553
|
+
}
|
|
2554
|
+
}, _callee25, this, [[0, 21]]);
|
|
2555
|
+
}));
|
|
2556
|
+
function applyDiscountCalculationResult(_x19) {
|
|
2557
|
+
return _applyDiscountCalculationResult.apply(this, arguments);
|
|
2558
|
+
}
|
|
2559
|
+
return applyDiscountCalculationResult;
|
|
2560
|
+
}()
|
|
2561
|
+
}, {
|
|
2562
|
+
key: "submitScanOrder",
|
|
2563
|
+
value: function () {
|
|
2564
|
+
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
|
|
2565
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2566
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2567
|
+
case 0:
|
|
2568
|
+
return _context26.abrupt("return", this.submitSalesOrder(params));
|
|
2569
|
+
case 1:
|
|
2570
|
+
case "end":
|
|
2571
|
+
return _context26.stop();
|
|
2572
|
+
}
|
|
2573
|
+
}, _callee26, this);
|
|
2574
|
+
}));
|
|
2575
|
+
function submitScanOrder(_x20) {
|
|
2576
|
+
return _submitScanOrder.apply(this, arguments);
|
|
2577
|
+
}
|
|
2578
|
+
return submitScanOrder;
|
|
2579
|
+
}()
|
|
2580
|
+
/**
|
|
2581
|
+
* 提交当前 Sales 订单。
|
|
2582
|
+
*
|
|
2583
|
+
* PaymentModal 场景通过 smallTicketDataFlag=1 请求 B 端小票数据;
|
|
2584
|
+
* payments 会交给 OrderModule 统一映射为 Sales 协议支付项。
|
|
2585
|
+
*/
|
|
2586
|
+
}, {
|
|
2587
|
+
key: "submitSalesOrder",
|
|
2588
|
+
value: (function () {
|
|
2589
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
2590
|
+
var _params$smallTicketDa, _this$otherParams6, _this$otherParams7, _this$otherParams8, _this$otherParams9;
|
|
2591
|
+
var inferredPaymentStatus, smallTicketDataFlag, submitParams;
|
|
2592
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2593
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2594
|
+
case 0:
|
|
2595
|
+
if (this.store.order) {
|
|
2596
|
+
_context27.next = 2;
|
|
2597
|
+
break;
|
|
2598
|
+
}
|
|
2599
|
+
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
2600
|
+
case 2:
|
|
2601
|
+
// this.store.order.persistTempOrder();
|
|
2602
|
+
inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
|
|
2603
|
+
smallTicketDataFlag = (_params$smallTicketDa = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa !== void 0 ? _params$smallTicketDa : this.getDefaultCheckoutSmallTicketDataFlag();
|
|
2604
|
+
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
2605
|
+
cacheId: this.cacheId,
|
|
2606
|
+
platform: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform,
|
|
2607
|
+
businessCode: ((_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) || ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code),
|
|
2608
|
+
channel: this.getSubmitOrderSalesChannel(),
|
|
2609
|
+
type: (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.type,
|
|
2610
|
+
request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
|
|
2611
|
+
}, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
|
|
2612
|
+
payments: params.payments
|
|
2613
|
+
} : {}), inferredPaymentStatus !== undefined ? {
|
|
2614
|
+
paymentStatus: inferredPaymentStatus
|
|
2615
|
+
} : {}), smallTicketDataFlag !== undefined ? {
|
|
2616
|
+
smallTicketDataFlag: smallTicketDataFlag
|
|
2617
|
+
} : {}), (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== undefined ? {
|
|
2618
|
+
confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
|
|
2619
|
+
} : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
2620
|
+
enhancePayload: params.enhancePayload
|
|
2621
|
+
} : {});
|
|
2622
|
+
return _context27.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
|
|
2623
|
+
case 6:
|
|
2624
|
+
case "end":
|
|
2625
|
+
return _context27.stop();
|
|
2626
|
+
}
|
|
2627
|
+
}, _callee27, this);
|
|
2628
|
+
}));
|
|
2629
|
+
function submitSalesOrder(_x21) {
|
|
2630
|
+
return _submitSalesOrder.apply(this, arguments);
|
|
2631
|
+
}
|
|
2632
|
+
return submitSalesOrder;
|
|
2633
|
+
}())
|
|
2634
|
+
}, {
|
|
2635
|
+
key: "submitTempOrderAsync",
|
|
2636
|
+
value: function () {
|
|
2637
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
2638
|
+
var _params$smallTicketDa2, _this$otherParams10, _this$otherParams11, _this$otherParams12, _this$otherParams13;
|
|
2639
|
+
var inferredPaymentStatus, smallTicketDataFlag, submitParams;
|
|
2640
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2641
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2642
|
+
case 0:
|
|
2643
|
+
if (this.store.order) {
|
|
2644
|
+
_context28.next = 2;
|
|
2645
|
+
break;
|
|
2646
|
+
}
|
|
2647
|
+
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
2648
|
+
case 2:
|
|
2649
|
+
inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
|
|
2650
|
+
smallTicketDataFlag = (_params$smallTicketDa2 = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa2 !== void 0 ? _params$smallTicketDa2 : this.getDefaultCheckoutSmallTicketDataFlag();
|
|
2651
|
+
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
2652
|
+
cacheId: this.cacheId,
|
|
2653
|
+
platform: (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform,
|
|
2654
|
+
businessCode: ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code),
|
|
2655
|
+
channel: this.getSubmitOrderSalesChannel(),
|
|
2656
|
+
type: (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.type,
|
|
2657
|
+
request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
|
|
2658
|
+
}, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
|
|
2659
|
+
payments: params.payments
|
|
2660
|
+
} : {}), inferredPaymentStatus !== undefined ? {
|
|
2661
|
+
paymentStatus: inferredPaymentStatus
|
|
2662
|
+
} : {}), smallTicketDataFlag !== undefined ? {
|
|
2663
|
+
smallTicketDataFlag: smallTicketDataFlag
|
|
2664
|
+
} : {}), (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== undefined ? {
|
|
2665
|
+
confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
|
|
2666
|
+
} : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
2667
|
+
enhancePayload: params.enhancePayload
|
|
2668
|
+
} : {});
|
|
2669
|
+
return _context28.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
|
|
2670
|
+
case 6:
|
|
2671
|
+
case "end":
|
|
2672
|
+
return _context28.stop();
|
|
2673
|
+
}
|
|
2674
|
+
}, _callee28, this);
|
|
2675
|
+
}));
|
|
2676
|
+
function submitTempOrderAsync(_x22) {
|
|
2677
|
+
return _submitTempOrderAsync.apply(this, arguments);
|
|
2678
|
+
}
|
|
2679
|
+
return submitTempOrderAsync;
|
|
2680
|
+
}()
|
|
2681
|
+
/**
|
|
2682
|
+
* 默认保持 WebPOS 的本地待同步订单模式;需要云端确认后才算成功的渠道可覆盖此策略。
|
|
2683
|
+
* otherParams.checkoutSyncTaskEnabled 优先,便于同一 solution 按入口恢复旧行为。
|
|
2684
|
+
*/
|
|
2685
|
+
}, {
|
|
2686
|
+
key: "shouldUseCheckoutSyncTask",
|
|
2687
|
+
value: function shouldUseCheckoutSyncTask() {
|
|
2688
|
+
var _this$otherParams14;
|
|
2689
|
+
var configured = (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.checkoutSyncTaskEnabled;
|
|
2690
|
+
return typeof configured === 'boolean' ? configured : true;
|
|
2691
|
+
}
|
|
2692
|
+
|
|
2693
|
+
/** 可由特定 solution 为真实 checkout 补充默认收据数据请求。 */
|
|
2694
|
+
}, {
|
|
2695
|
+
key: "getDefaultCheckoutSmallTicketDataFlag",
|
|
2696
|
+
value: function getDefaultCheckoutSmallTicketDataFlag() {
|
|
2697
|
+
return undefined;
|
|
2698
|
+
}
|
|
2699
|
+
}, {
|
|
2700
|
+
key: "printLocalOrderReceipt",
|
|
2701
|
+
value: function () {
|
|
2702
|
+
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(lookup) {
|
|
2703
|
+
var _this$otherParams15, _this$otherParams16, _this$otherParams17, _this$otherParams18;
|
|
2704
|
+
var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order5, _data;
|
|
2705
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2706
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2707
|
+
case 0:
|
|
2708
|
+
if (this.store.order) {
|
|
2709
|
+
_context29.next = 2;
|
|
2710
|
+
break;
|
|
2711
|
+
}
|
|
2712
|
+
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
2713
|
+
case 2:
|
|
2714
|
+
hasLookup = lookup !== undefined && lookup !== null && lookup !== '';
|
|
2715
|
+
lookupPayload = typeof lookup === 'number' ? {
|
|
2716
|
+
order_id: lookup
|
|
2717
|
+
} : {
|
|
2718
|
+
external_sale_number: lookup
|
|
2719
|
+
};
|
|
2720
|
+
context = {
|
|
2721
|
+
platform: (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.platform,
|
|
2722
|
+
businessCode: ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.businessCode) || ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.business_code),
|
|
2723
|
+
channel: this.getSubmitOrderSalesChannel(),
|
|
2724
|
+
type: (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.type
|
|
2725
|
+
};
|
|
2726
|
+
payload = hasLookup ? _objectSpread(_objectSpread({}, lookupPayload), {}, {
|
|
2727
|
+
lookup_order_from_db: 1,
|
|
2728
|
+
small_ticket_data_flag: 1,
|
|
2729
|
+
platform: context.platform,
|
|
2730
|
+
business_code: context.businessCode,
|
|
2731
|
+
order_sales_channel: context.channel,
|
|
2732
|
+
type: context.type
|
|
2733
|
+
}) : this.store.order.buildCurrentSubmitPayloadForLocalPrint({
|
|
2734
|
+
cacheId: this.cacheId,
|
|
2735
|
+
platform: context.platform,
|
|
2736
|
+
businessCode: context.businessCode,
|
|
2737
|
+
channel: context.channel,
|
|
2738
|
+
type: context.type
|
|
2739
|
+
});
|
|
2740
|
+
_context29.next = 8;
|
|
2741
|
+
return this.request.post('/local/print-order', payload, {
|
|
2742
|
+
osServer: true,
|
|
2743
|
+
customToast: function customToast() {}
|
|
2744
|
+
});
|
|
2745
|
+
case 8:
|
|
2746
|
+
response = _context29.sent;
|
|
2747
|
+
if (hasLookup) {
|
|
2748
|
+
_context29.next = 12;
|
|
2749
|
+
break;
|
|
2750
|
+
}
|
|
2751
|
+
_context29.next = 12;
|
|
2752
|
+
return (_this$store$order$app = (_this$store$order5 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order5, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
|
|
2753
|
+
case 12:
|
|
2754
|
+
return _context29.abrupt("return", response);
|
|
2755
|
+
case 13:
|
|
2756
|
+
case "end":
|
|
2757
|
+
return _context29.stop();
|
|
2758
|
+
}
|
|
2759
|
+
}, _callee29, this);
|
|
2760
|
+
}));
|
|
2761
|
+
function printLocalOrderReceipt(_x23) {
|
|
2762
|
+
return _printLocalOrderReceipt.apply(this, arguments);
|
|
2763
|
+
}
|
|
2764
|
+
return printLocalOrderReceipt;
|
|
2765
|
+
}()
|
|
2766
|
+
}, {
|
|
2767
|
+
key: "getSubmitPaymentStatus",
|
|
2768
|
+
value: function getSubmitPaymentStatus(paymentStatus) {
|
|
2769
|
+
var _this$store$order6, _this$store$order6$ge;
|
|
2770
|
+
if (paymentStatus !== undefined) return paymentStatus;
|
|
2771
|
+
var amountSnapshot = (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 || (_this$store$order6$ge = _this$store$order6.getOrderAmountSnapshot) === null || _this$store$order6$ge === void 0 ? void 0 : _this$store$order6$ge.call(_this$store$order6);
|
|
2772
|
+
if (!amountSnapshot) return undefined;
|
|
2773
|
+
try {
|
|
2774
|
+
return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
|
|
2775
|
+
} catch (_unused2) {
|
|
2776
|
+
return undefined;
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
}, {
|
|
2780
|
+
key: "syncPaymentsToOrder",
|
|
2781
|
+
value: function () {
|
|
2782
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
2783
|
+
var _ref22, _params$businessCode, _this$otherParams19, _this$otherParams20, _params$channel;
|
|
2784
|
+
var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
|
|
2785
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2786
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2787
|
+
case 0:
|
|
2788
|
+
if (this.store.order) {
|
|
2789
|
+
_context30.next = 2;
|
|
2790
|
+
break;
|
|
2791
|
+
}
|
|
2792
|
+
throw new Error('order 模块未初始化');
|
|
2793
|
+
case 2:
|
|
2794
|
+
businessCode = (_ref22 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.businessCode) !== null && _ref22 !== void 0 ? _ref22 : (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.business_code;
|
|
2795
|
+
channel = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel();
|
|
2796
|
+
syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), {}, {
|
|
2797
|
+
checkoutSyncTaskEnabled: this.shouldUseCheckoutSyncTask()
|
|
2798
|
+
}, businessCode !== undefined ? {
|
|
2799
|
+
businessCode: businessCode
|
|
2800
|
+
} : {}), channel !== undefined ? {
|
|
2801
|
+
channel: channel
|
|
2802
|
+
} : {});
|
|
2803
|
+
syncState = this.store.order.getOrderSyncState();
|
|
2804
|
+
if (!(params.submitWhenPaid && syncState === 'submitting')) {
|
|
2805
|
+
_context30.next = 9;
|
|
2806
|
+
break;
|
|
2807
|
+
}
|
|
2808
|
+
this.queueLatestAutoPaymentSync();
|
|
2809
|
+
return _context30.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
|
|
2810
|
+
case 9:
|
|
2811
|
+
payments = params.payments || [];
|
|
2812
|
+
_context30.next = 12;
|
|
2813
|
+
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
|
|
2814
|
+
payments: payments,
|
|
2815
|
+
params: syncParams,
|
|
2816
|
+
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
2817
|
+
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
2818
|
+
});
|
|
2819
|
+
case 12:
|
|
2820
|
+
_context30.prev = 12;
|
|
2821
|
+
_context30.next = 15;
|
|
2822
|
+
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
2823
|
+
case 15:
|
|
2824
|
+
syncResult = _context30.sent;
|
|
2825
|
+
latestPayments = this.store.order.getOrderPayments();
|
|
2826
|
+
amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
2827
|
+
orderSnapshot = this.store.order.getOrderSnapshot();
|
|
2828
|
+
syncPayload = {
|
|
2829
|
+
ok: true,
|
|
2830
|
+
syncResult: syncResult,
|
|
2831
|
+
payments: latestPayments,
|
|
2832
|
+
params: syncParams,
|
|
2833
|
+
amountSnapshot: amountSnapshot,
|
|
2834
|
+
orderSnapshot: orderSnapshot,
|
|
2835
|
+
isFullyPaid: syncResult.isFullyPaid,
|
|
2836
|
+
isOrderFullyPaid: syncResult.isOrderFullyPaid,
|
|
2837
|
+
isDepositFullyPaid: syncResult.isDepositFullyPaid,
|
|
2838
|
+
paymentStage: syncResult.paymentStage,
|
|
2839
|
+
depositAmount: syncResult.depositAmount,
|
|
2840
|
+
orderExpectedAmount: syncResult.orderExpectedAmount
|
|
2841
|
+
};
|
|
2842
|
+
_context30.next = 22;
|
|
2843
|
+
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
|
|
2844
|
+
case 22:
|
|
2845
|
+
if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
|
|
2846
|
+
_context30.next = 25;
|
|
2847
|
+
break;
|
|
2848
|
+
}
|
|
2849
|
+
_context30.next = 25;
|
|
2850
|
+
return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
|
|
2851
|
+
case 25:
|
|
2852
|
+
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
2853
|
+
return _context30.abrupt("return", syncResult);
|
|
2854
|
+
case 29:
|
|
2855
|
+
_context30.prev = 29;
|
|
2856
|
+
_context30.t0 = _context30["catch"](12);
|
|
2857
|
+
_context30.next = 33;
|
|
2858
|
+
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
|
|
2859
|
+
ok: false,
|
|
2860
|
+
error: _context30.t0,
|
|
2861
|
+
payments: this.store.order.getOrderPayments(),
|
|
2862
|
+
params: syncParams,
|
|
2863
|
+
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
2864
|
+
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
2865
|
+
});
|
|
2866
|
+
case 33:
|
|
2867
|
+
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
2868
|
+
throw _context30.t0;
|
|
2869
|
+
case 35:
|
|
2870
|
+
case "end":
|
|
2871
|
+
return _context30.stop();
|
|
2872
|
+
}
|
|
2873
|
+
}, _callee30, this, [[12, 29]]);
|
|
2874
|
+
}));
|
|
2875
|
+
function syncPaymentsToOrder(_x24) {
|
|
2876
|
+
return _syncPaymentsToOrder.apply(this, arguments);
|
|
2877
|
+
}
|
|
2878
|
+
return syncPaymentsToOrder;
|
|
2879
|
+
}() /** 读取当前 BaseSales 订单上下文中的 Sales 协议支付项。 */
|
|
2880
|
+
}, {
|
|
2881
|
+
key: "getOrderPayments",
|
|
2882
|
+
value: function getOrderPayments() {
|
|
2883
|
+
if (!this.store.order) return [];
|
|
2884
|
+
var payments = this.store.order.getOrderPayments();
|
|
2885
|
+
return this.hydrateOrderPaymentNames(payments);
|
|
2886
|
+
}
|
|
2887
|
+
|
|
2888
|
+
/** 覆盖当前订单支付项,内部由 OrderModule 清洗为 Sales 协议字段。 */
|
|
2889
|
+
}, {
|
|
2890
|
+
key: "setOrderPayments",
|
|
2891
|
+
value: function setOrderPayments(payments) {
|
|
2892
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2893
|
+
return this.store.order.setOrderPayments(payments);
|
|
2894
|
+
}
|
|
2895
|
+
}, {
|
|
2896
|
+
key: "getPaymentStatusForSync",
|
|
2897
|
+
value: function getPaymentStatusForSync(payments) {
|
|
2898
|
+
var order = this.store.order;
|
|
2899
|
+
if (!order) throw new Error('order 模块未初始化');
|
|
2900
|
+
var completion = order.getPaymentCompletion(payments);
|
|
2901
|
+
return completion.isOrderFullyPaid ? 'paid' : 'partially_paid';
|
|
2902
|
+
}
|
|
2903
|
+
}, {
|
|
2904
|
+
key: "queueLatestAutoPaymentSync",
|
|
2905
|
+
value: function queueLatestAutoPaymentSync() {
|
|
2906
|
+
this.queuedAutoPaymentSync = true;
|
|
2907
|
+
this.scheduleQueuedAutoPaymentSyncFlush();
|
|
2908
|
+
}
|
|
2909
|
+
}, {
|
|
2910
|
+
key: "scheduleQueuedAutoPaymentSyncFlush",
|
|
2911
|
+
value: function scheduleQueuedAutoPaymentSyncFlush() {
|
|
2912
|
+
var _this11 = this;
|
|
2913
|
+
var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
|
|
2914
|
+
if (!this.queuedAutoPaymentSync) return;
|
|
2915
|
+
if (this.autoPaymentSyncTimer) return;
|
|
2916
|
+
this.autoPaymentSyncTimer = setTimeout(function () {
|
|
2917
|
+
_this11.autoPaymentSyncTimer = null;
|
|
2918
|
+
void _this11.flushQueuedAutoPaymentSync();
|
|
2919
|
+
}, delay);
|
|
2920
|
+
}
|
|
2921
|
+
}, {
|
|
2922
|
+
key: "flushQueuedAutoPaymentSync",
|
|
2923
|
+
value: function () {
|
|
2924
|
+
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
2925
|
+
var payments;
|
|
2926
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2927
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2928
|
+
case 0:
|
|
2929
|
+
if (this.store.order) {
|
|
2930
|
+
_context31.next = 2;
|
|
2931
|
+
break;
|
|
2932
|
+
}
|
|
2933
|
+
return _context31.abrupt("return");
|
|
2934
|
+
case 2:
|
|
2935
|
+
if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
|
|
2936
|
+
_context31.next = 4;
|
|
2937
|
+
break;
|
|
2938
|
+
}
|
|
2939
|
+
return _context31.abrupt("return");
|
|
2940
|
+
case 4:
|
|
2941
|
+
if (!(this.store.order.getOrderSyncState() === 'submitting')) {
|
|
2942
|
+
_context31.next = 7;
|
|
2943
|
+
break;
|
|
2944
|
+
}
|
|
2945
|
+
this.scheduleQueuedAutoPaymentSyncFlush();
|
|
2946
|
+
return _context31.abrupt("return");
|
|
2947
|
+
case 7:
|
|
2948
|
+
this.autoPaymentSyncFlushing = true;
|
|
2949
|
+
_context31.prev = 8;
|
|
2950
|
+
case 9:
|
|
2951
|
+
if (!this.queuedAutoPaymentSync) {
|
|
2952
|
+
_context31.next = 18;
|
|
2953
|
+
break;
|
|
2954
|
+
}
|
|
2955
|
+
this.queuedAutoPaymentSync = false;
|
|
2956
|
+
payments = this.store.order.getOrderPayments();
|
|
2957
|
+
if (payments.length) {
|
|
2958
|
+
_context31.next = 14;
|
|
2959
|
+
break;
|
|
2960
|
+
}
|
|
2961
|
+
return _context31.abrupt("continue", 9);
|
|
2962
|
+
case 14:
|
|
2963
|
+
_context31.next = 16;
|
|
2964
|
+
return this.syncPaymentsToOrder({
|
|
2965
|
+
payments: payments,
|
|
2966
|
+
paymentStatus: this.getPaymentStatusForSync(payments),
|
|
2967
|
+
submitWhenPaid: true,
|
|
2968
|
+
smallTicketDataFlag: 1
|
|
2969
|
+
});
|
|
2970
|
+
case 16:
|
|
2971
|
+
_context31.next = 9;
|
|
2972
|
+
break;
|
|
2973
|
+
case 18:
|
|
2974
|
+
_context31.next = 23;
|
|
2975
|
+
break;
|
|
2976
|
+
case 20:
|
|
2977
|
+
_context31.prev = 20;
|
|
2978
|
+
_context31.t0 = _context31["catch"](8);
|
|
2979
|
+
this.logError('queued auto sync payments failed', {
|
|
2980
|
+
error: _context31.t0 instanceof Error ? _context31.t0.message : String(_context31.t0)
|
|
2981
|
+
});
|
|
2982
|
+
case 23:
|
|
2983
|
+
_context31.prev = 23;
|
|
2984
|
+
this.autoPaymentSyncFlushing = false;
|
|
2985
|
+
if (this.queuedAutoPaymentSync) {
|
|
2986
|
+
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
2987
|
+
}
|
|
2988
|
+
return _context31.finish(23);
|
|
2989
|
+
case 27:
|
|
2990
|
+
case "end":
|
|
2991
|
+
return _context31.stop();
|
|
2992
|
+
}
|
|
2993
|
+
}, _callee31, this, [[8, 20, 23, 27]]);
|
|
2994
|
+
}));
|
|
2995
|
+
function flushQueuedAutoPaymentSync() {
|
|
2996
|
+
return _flushQueuedAutoPaymentSync.apply(this, arguments);
|
|
2997
|
+
}
|
|
2998
|
+
return flushQueuedAutoPaymentSync;
|
|
2999
|
+
}() /** 追加单个支付项到当前订单。 */
|
|
3000
|
+
}, {
|
|
3001
|
+
key: "addOrderPayment",
|
|
3002
|
+
value: function addOrderPayment(payment) {
|
|
3003
|
+
var _this$otherParams21,
|
|
3004
|
+
_paymentRecord$paymen,
|
|
3005
|
+
_paymentRecord$create,
|
|
3006
|
+
_ref23,
|
|
3007
|
+
_paymentRecord$origin,
|
|
3008
|
+
_this12 = this;
|
|
3009
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3010
|
+
var paymentRecord = payment;
|
|
3011
|
+
var paymentAmount = new Decimal(paymentRecord.amount || 0);
|
|
3012
|
+
if (paymentAmount.isZero()) {
|
|
3013
|
+
this.logWarning('addOrderPayment: 支付金额为 0,跳过添加支付项', {
|
|
3014
|
+
payment: paymentRecord
|
|
3015
|
+
});
|
|
3016
|
+
return this.store.order.getOrderPayments();
|
|
3017
|
+
}
|
|
3018
|
+
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
3019
|
+
var shopWalletPassId = (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.shop_wallet_pass_id;
|
|
3020
|
+
if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
|
|
3021
|
+
metadata.shop_wallet_pass_id = shopWalletPassId;
|
|
3022
|
+
}
|
|
3023
|
+
if (!metadata.unique_payment_number) {
|
|
3024
|
+
metadata.unique_payment_number = createUuidV4();
|
|
3025
|
+
}
|
|
3026
|
+
var paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
3027
|
+
var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
|
|
3028
|
+
var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
|
|
3029
|
+
var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
|
|
3030
|
+
var calculatedServiceFee = serviceCharge ? new Decimal((_ref23 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref23 !== void 0 ? _ref23 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
|
|
3031
|
+
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, paymentRecord), calculatedServiceFee !== undefined ? {
|
|
3032
|
+
service_fee: calculatedServiceFee
|
|
3033
|
+
} : {}), {}, {
|
|
3034
|
+
metadata: metadata,
|
|
3035
|
+
payment_time: paymentTime,
|
|
3036
|
+
created_at: createdAt
|
|
3037
|
+
}));
|
|
3038
|
+
var amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
3039
|
+
var syncState = this.store.order.getOrderSyncState();
|
|
3040
|
+
if (amountSnapshot) {
|
|
3041
|
+
if (syncState === 'submitting') {
|
|
3042
|
+
this.queueLatestAutoPaymentSync();
|
|
3043
|
+
return payments;
|
|
3044
|
+
}
|
|
3045
|
+
void this.syncPaymentsToOrder({
|
|
3046
|
+
payments: payments,
|
|
3047
|
+
paymentStatus: this.getPaymentStatusForSync(payments),
|
|
3048
|
+
submitWhenPaid: true,
|
|
3049
|
+
smallTicketDataFlag: 1
|
|
3050
|
+
}).catch(function (error) {
|
|
3051
|
+
_this12.logError('auto sync payments failed', {
|
|
3052
|
+
error: error instanceof Error ? error.message : String(error)
|
|
3053
|
+
});
|
|
3054
|
+
});
|
|
3055
|
+
}
|
|
3056
|
+
return payments;
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
|
+
/** 更新当前订单中的指定支付项。 */
|
|
3060
|
+
}, {
|
|
3061
|
+
key: "updateOrderPayment",
|
|
3062
|
+
value: function updateOrderPayment(paymentIdentity, updates) {
|
|
3063
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3064
|
+
return this.store.order.updateOrderPayment(paymentIdentity, updates);
|
|
3065
|
+
}
|
|
3066
|
+
|
|
3067
|
+
/** 删除当前订单中的指定支付项。 */
|
|
3068
|
+
}, {
|
|
3069
|
+
key: "deleteOrderPayment",
|
|
3070
|
+
value: function deleteOrderPayment(paymentIdentity) {
|
|
3071
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3072
|
+
return this.store.order.deleteOrderPayment(paymentIdentity);
|
|
3073
|
+
}
|
|
3074
|
+
|
|
3075
|
+
/** 覆盖 wallet pass 支付项,同时保留普通支付项。 */
|
|
3076
|
+
}, {
|
|
3077
|
+
key: "updateVoucherOrderPayments",
|
|
3078
|
+
value: function updateVoucherOrderPayments(payments, options) {
|
|
3079
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3080
|
+
return this.store.order.updateVoucherOrderPayments(payments, options);
|
|
3081
|
+
}
|
|
3082
|
+
}, {
|
|
3083
|
+
key: "confirmPendingVoucherPayments",
|
|
3084
|
+
value: function confirmPendingVoucherPayments() {
|
|
3085
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3086
|
+
return this.store.order.confirmPendingVoucherPayments();
|
|
3087
|
+
}
|
|
3088
|
+
}, {
|
|
3089
|
+
key: "discardPendingVoucherPayments",
|
|
3090
|
+
value: function discardPendingVoucherPayments() {
|
|
3091
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3092
|
+
return this.store.order.discardPendingVoucherPayments();
|
|
3093
|
+
}
|
|
3094
|
+
}, {
|
|
3095
|
+
key: "getWalletProductList",
|
|
3096
|
+
value: function getWalletProductList() {
|
|
3097
|
+
var _this$store$order7, _tempOrder$products;
|
|
3098
|
+
var tempOrder = (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getTempOrder();
|
|
3099
|
+
if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
|
|
3100
|
+
// 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
|
|
3101
|
+
// debugger
|
|
3102
|
+
// const products = tempOrder?.products?.filter(n => n.product_id)
|
|
3103
|
+
|
|
3104
|
+
var walletProducts = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products.map(function (product) {
|
|
3105
|
+
var _product$holder_id, _product$product_vari2, _product$is_charge_ta, _metadata$main_produc, _metadata$main_produc2;
|
|
3106
|
+
var metadata = product.metadata || {};
|
|
3107
|
+
var rawHolderId = (_product$holder_id = product.holder_id) !== null && _product$holder_id !== void 0 ? _product$holder_id : metadata.holder_id;
|
|
3108
|
+
var holderIdValue = Array.isArray(rawHolderId) ? rawHolderId[0] : rawHolderId;
|
|
3109
|
+
var holder_id = Number.isInteger(Number(holderIdValue)) ? Number(holderIdValue) : undefined;
|
|
3110
|
+
return {
|
|
3111
|
+
product_id: product.product_id || 0,
|
|
3112
|
+
product_variant_id: String((_product$product_vari2 = product.product_variant_id) !== null && _product$product_vari2 !== void 0 ? _product$product_vari2 : ''),
|
|
3113
|
+
quantity: product.num || 1,
|
|
3114
|
+
is_price_include_tax: tempOrder.is_price_include_tax,
|
|
3115
|
+
is_charge_tax: (_product$is_charge_ta = product.is_charge_tax) !== null && _product$is_charge_ta !== void 0 ? _product$is_charge_ta : 0,
|
|
3116
|
+
tax_fee: product.tax_fee,
|
|
3117
|
+
selling_price: Number(product.selling_price || 0),
|
|
3118
|
+
discount_list: product.discount_list || [],
|
|
3119
|
+
holder_id: holder_id,
|
|
3120
|
+
original_price: product.original_price,
|
|
3121
|
+
main_product_original_price: (_metadata$main_produc = metadata.main_product_original_price) !== null && _metadata$main_produc !== void 0 ? _metadata$main_produc : product.original_price,
|
|
3122
|
+
main_product_selling_price: (_metadata$main_produc2 = metadata.main_product_selling_price) !== null && _metadata$main_produc2 !== void 0 ? _metadata$main_produc2 : product.selling_price,
|
|
3123
|
+
metadata: {
|
|
3124
|
+
main_product_attached_bundle_tax_fee: metadata.main_product_attached_bundle_tax_fee,
|
|
3125
|
+
main_product_attached_bundle_surcharge_fee: metadata.main_product_attached_bundle_surcharge_fee,
|
|
3126
|
+
surcharge_rounding_remainder: metadata.surcharge_rounding_remainder
|
|
3127
|
+
},
|
|
3128
|
+
product_bundle: (product.product_bundle || []).map(function (bundle) {
|
|
3129
|
+
var _bundle$bundle_id2, _bundle$bundle_produc2, _bundle$bundle_group_2;
|
|
3130
|
+
var bundleMetadata = bundle.metadata || {};
|
|
3131
|
+
return {
|
|
3132
|
+
is_price_include_tax: tempOrder.is_price_include_tax,
|
|
3133
|
+
// 套餐子项在 tempOrder 上常为 id(如 1718),prepare/deduction 协议要求 bundle_id
|
|
3134
|
+
bundle_id: (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id,
|
|
3135
|
+
bundle_product_id: (_bundle$bundle_produc2 = bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle._bundle_product_id,
|
|
3136
|
+
bundle_group_id: (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id,
|
|
3137
|
+
bundle_variant_id: bundle.bundle_variant_id,
|
|
3138
|
+
price_type: bundle.price_type,
|
|
3139
|
+
price_type_ext: bundle.price_type_ext,
|
|
3140
|
+
bundle_sum_price: bundle.bundle_sum_price,
|
|
3141
|
+
bundle_selling_price: bundle.bundle_selling_price,
|
|
3142
|
+
num: bundle.num,
|
|
3143
|
+
is_charge_tax: bundle.is_charge_tax,
|
|
3144
|
+
tax_fee: bundle.tax_fee,
|
|
3145
|
+
metadata: {
|
|
3146
|
+
surcharge_fee: bundleMetadata.surcharge_fee,
|
|
3147
|
+
surcharge_rounding_remainder: bundleMetadata.surcharge_rounding_remainder
|
|
3148
|
+
}
|
|
3149
|
+
};
|
|
3150
|
+
})
|
|
3151
|
+
};
|
|
3152
|
+
});
|
|
3153
|
+
return walletProducts;
|
|
3154
|
+
}
|
|
3155
|
+
}, {
|
|
3156
|
+
key: "initWalletData",
|
|
3157
|
+
value: function () {
|
|
3158
|
+
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
3159
|
+
var _params$order_wait_pa, _ref24, _tempOrder$is_price_i;
|
|
3160
|
+
var snapshot, tempOrder, amount, walletBusinessData, result;
|
|
3161
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
3162
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
3163
|
+
case 0:
|
|
3164
|
+
if (this.store.order) {
|
|
3165
|
+
_context32.next = 2;
|
|
3166
|
+
break;
|
|
3167
|
+
}
|
|
3168
|
+
throw new Error('order 模块未初始化');
|
|
3169
|
+
case 2:
|
|
3170
|
+
if (this.store.payment) {
|
|
3171
|
+
_context32.next = 4;
|
|
3172
|
+
break;
|
|
3173
|
+
}
|
|
3174
|
+
throw new Error('payment 模块未初始化');
|
|
3175
|
+
case 4:
|
|
3176
|
+
snapshot = this.store.order.getOrderSnapshot();
|
|
3177
|
+
tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
|
|
3178
|
+
amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
|
|
3179
|
+
if (!(!tempOrder || !amount)) {
|
|
3180
|
+
_context32.next = 9;
|
|
3181
|
+
break;
|
|
3182
|
+
}
|
|
3183
|
+
return _context32.abrupt("return", {
|
|
3184
|
+
walletRecommendList: [],
|
|
3185
|
+
userIdentificationCodes: [],
|
|
3186
|
+
transformList: [],
|
|
3187
|
+
noApplicableVoucher: [],
|
|
3188
|
+
products: []
|
|
3189
|
+
});
|
|
3190
|
+
case 9:
|
|
3191
|
+
walletBusinessData = _objectSpread({
|
|
3192
|
+
customer_id: tempOrder.customer_id ? Number(tempOrder.customer_id) : undefined,
|
|
3193
|
+
holder: tempOrder.holder,
|
|
3194
|
+
amountInfo: {
|
|
3195
|
+
totalAmount: amount.totalAmount,
|
|
3196
|
+
subTotal: amount.summary.product_amount || amount.summary.product_expect_amount || amount.totalAmount,
|
|
3197
|
+
depositAmount: amount.depositAmount,
|
|
3198
|
+
isDeposit: tempOrder.is_deposit
|
|
3199
|
+
},
|
|
3200
|
+
products: this.getWalletProductList(),
|
|
3201
|
+
order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
|
|
3202
|
+
is_price_include_tax: (_ref24 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref24 !== void 0 ? _ref24 : 1
|
|
3203
|
+
}, snapshot.identity.orderId ? {
|
|
3204
|
+
payment_order_id: String(snapshot.identity.orderId)
|
|
3205
|
+
} : {});
|
|
3206
|
+
_context32.next = 12;
|
|
3207
|
+
return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
|
|
3208
|
+
case 12:
|
|
3209
|
+
result = _context32.sent;
|
|
3210
|
+
_context32.next = 15;
|
|
3211
|
+
return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
|
|
3212
|
+
orderId: snapshot.identity.orderId,
|
|
3213
|
+
customerId: walletBusinessData.customer_id,
|
|
3214
|
+
walletBusinessData: {
|
|
3215
|
+
customer_id: walletBusinessData.customer_id,
|
|
3216
|
+
amountInfo: walletBusinessData.amountInfo,
|
|
3217
|
+
order_wait_pay_amount: walletBusinessData.order_wait_pay_amount
|
|
3218
|
+
},
|
|
3219
|
+
timestamp: Date.now()
|
|
3220
|
+
});
|
|
3221
|
+
case 15:
|
|
3222
|
+
return _context32.abrupt("return", result);
|
|
3223
|
+
case 16:
|
|
3224
|
+
case "end":
|
|
3225
|
+
return _context32.stop();
|
|
3226
|
+
}
|
|
3227
|
+
}, _callee32, this);
|
|
3228
|
+
}));
|
|
3229
|
+
function initWalletData(_x25) {
|
|
3230
|
+
return _initWalletData.apply(this, arguments);
|
|
3231
|
+
}
|
|
3232
|
+
return initWalletData;
|
|
3233
|
+
}()
|
|
3234
|
+
/**
|
|
3235
|
+
* 更新当前订单客户字段。
|
|
3236
|
+
*
|
|
3237
|
+
* 这是 PaymentModal 客户切换的订单事实入口;外部客户模块同步应由
|
|
3238
|
+
* 调用方通过 onCustomerChange 回调完成。
|
|
3239
|
+
*/
|
|
3240
|
+
}, {
|
|
3241
|
+
key: "updateOrderCustomer",
|
|
3242
|
+
value: function updateOrderCustomer(customer) {
|
|
3243
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3244
|
+
var result = this.store.order.updateTempOrderCustomer(customer);
|
|
3245
|
+
this.store.order.recalculateSummary({
|
|
3246
|
+
createIfMissing: true
|
|
3247
|
+
});
|
|
3248
|
+
this.store.order.persistTempOrder();
|
|
3249
|
+
return result;
|
|
3250
|
+
}
|
|
3251
|
+
|
|
3252
|
+
/** 获取可用支付方式列表,供 PaymentModal 渲染支付选项。 */
|
|
3253
|
+
}, {
|
|
3254
|
+
key: "getPaymentMethodsAsync",
|
|
3255
|
+
value: (function () {
|
|
3256
|
+
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
3257
|
+
var response, paymentMethods;
|
|
3258
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
3259
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
3260
|
+
case 0:
|
|
3261
|
+
_context33.prev = 0;
|
|
3262
|
+
_context33.next = 3;
|
|
3263
|
+
return this.request.get('/pay/custom-payment/all', {
|
|
3264
|
+
filterPaymentMethods: true
|
|
3265
|
+
}, {
|
|
3266
|
+
osServer: true
|
|
3267
|
+
});
|
|
3268
|
+
case 3:
|
|
3269
|
+
response = _context33.sent;
|
|
3270
|
+
paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
3271
|
+
this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
|
|
3272
|
+
return _context33.abrupt("return", this.getPaymentMethods());
|
|
3273
|
+
case 9:
|
|
3274
|
+
_context33.prev = 9;
|
|
3275
|
+
_context33.t0 = _context33["catch"](0);
|
|
3276
|
+
this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
|
|
3277
|
+
error: _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0)
|
|
3278
|
+
});
|
|
3279
|
+
return _context33.abrupt("return", this.getPaymentMethods());
|
|
3280
|
+
case 13:
|
|
3281
|
+
case "end":
|
|
3282
|
+
return _context33.stop();
|
|
3283
|
+
}
|
|
3284
|
+
}, _callee33, this, [[0, 9]]);
|
|
3285
|
+
}));
|
|
3286
|
+
function getPaymentMethodsAsync() {
|
|
3287
|
+
return _getPaymentMethodsAsync.apply(this, arguments);
|
|
3288
|
+
}
|
|
3289
|
+
return getPaymentMethodsAsync;
|
|
3290
|
+
}() /** 同步读取初始化时缓存的支付方式列表。 */)
|
|
3291
|
+
}, {
|
|
3292
|
+
key: "getPaymentMethods",
|
|
3293
|
+
value: function getPaymentMethods() {
|
|
3294
|
+
return _toConsumableArray(this.paymentMethodsCache);
|
|
3295
|
+
}
|
|
3296
|
+
|
|
3297
|
+
/** 轻量舍入能力,供现金支付 UI 计算 rounding_amount。 */
|
|
3298
|
+
}, {
|
|
3299
|
+
key: "roundAmount",
|
|
3300
|
+
value: function roundAmount(params) {
|
|
3301
|
+
var amount = new Decimal(params.amount || 0);
|
|
3302
|
+
var interval = new Decimal(params.interval || 0.05);
|
|
3303
|
+
var rule = params.rule || 'standard_rounding';
|
|
3304
|
+
var quotient = amount.div(interval);
|
|
3305
|
+
var roundedQuotient;
|
|
3306
|
+
if (rule === 'always_up') {
|
|
3307
|
+
roundedQuotient = quotient.ceil();
|
|
3308
|
+
} else if (rule === 'always_down') {
|
|
3309
|
+
roundedQuotient = quotient.floor();
|
|
3310
|
+
} else if (rule === 'standard_down') {
|
|
3311
|
+
roundedQuotient = quotient.toDecimalPlaces(0, Decimal.ROUND_HALF_DOWN);
|
|
3312
|
+
} else {
|
|
3313
|
+
roundedQuotient = quotient.toDecimalPlaces(0, Decimal.ROUND_HALF_UP);
|
|
3314
|
+
}
|
|
3315
|
+
var roundedAmount = roundedQuotient.times(interval).toDecimalPlaces(2);
|
|
3316
|
+
return {
|
|
3317
|
+
originalAmount: amount.toFixed(2),
|
|
3318
|
+
roundedAmount: roundedAmount.toFixed(2),
|
|
3319
|
+
roundingDifference: roundedAmount.minus(amount).toFixed(2)
|
|
3320
|
+
};
|
|
3321
|
+
}
|
|
3322
|
+
|
|
3323
|
+
/**
|
|
3324
|
+
* 发送支付链接。
|
|
3325
|
+
*
|
|
3326
|
+
* 如果没有 orderIds 或显式 submitBeforeSend,会先提交当前本地订单到云端;
|
|
3327
|
+
* 只有成功拿到远端 order_id 后才调用 OrderModule 发送邮件。
|
|
3328
|
+
*/
|
|
3329
|
+
}, {
|
|
3330
|
+
key: "sendCustomerPayLink",
|
|
3331
|
+
value: (function () {
|
|
3332
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
3333
|
+
var orderIds, _ref25, _ref26, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
|
|
3334
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
3335
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
3336
|
+
case 0:
|
|
3337
|
+
if (this.store.order) {
|
|
3338
|
+
_context34.next = 2;
|
|
3339
|
+
break;
|
|
3340
|
+
}
|
|
3341
|
+
throw new Error('order 模块未初始化');
|
|
3342
|
+
case 2:
|
|
3343
|
+
orderIds = params.order_ids || params.orderIds || [];
|
|
3344
|
+
if (!(!orderIds.length || params.submitBeforeSend)) {
|
|
3345
|
+
_context34.next = 11;
|
|
3346
|
+
break;
|
|
3347
|
+
}
|
|
3348
|
+
_context34.next = 6;
|
|
3349
|
+
return this.submitSalesOrder({
|
|
3350
|
+
smallTicketDataFlag: 1
|
|
3351
|
+
});
|
|
3352
|
+
case 6:
|
|
3353
|
+
submitResult = _context34.sent;
|
|
3354
|
+
orderId = (_ref25 = (_ref26 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref26 !== void 0 ? _ref26 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref25 !== void 0 ? _ref25 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
|
|
3355
|
+
if (orderId) {
|
|
3356
|
+
_context34.next = 10;
|
|
3357
|
+
break;
|
|
3358
|
+
}
|
|
3359
|
+
throw new Error('本地订单提交云端失败,无法发送支付链接');
|
|
3360
|
+
case 10:
|
|
3361
|
+
orderIds = [orderId];
|
|
3362
|
+
case 11:
|
|
3363
|
+
return _context34.abrupt("return", this.store.order.sendCustomerPayLink({
|
|
3364
|
+
emails: params.emails,
|
|
3365
|
+
notify_action: params.notify_action,
|
|
3366
|
+
order_ids: orderIds
|
|
3367
|
+
}));
|
|
3368
|
+
case 12:
|
|
3369
|
+
case "end":
|
|
3370
|
+
return _context34.stop();
|
|
3371
|
+
}
|
|
3372
|
+
}, _callee34, this);
|
|
3373
|
+
}));
|
|
3374
|
+
function sendCustomerPayLink(_x26) {
|
|
3375
|
+
return _sendCustomerPayLink.apply(this, arguments);
|
|
3376
|
+
}
|
|
3377
|
+
return sendCustomerPayLink;
|
|
3378
|
+
}())
|
|
3379
|
+
}, {
|
|
3380
|
+
key: "transformBaseProductToOrderProduct",
|
|
3381
|
+
value: function transformBaseProductToOrderProduct(params) {
|
|
3382
|
+
return _transformBaseProductToOrderProduct(params);
|
|
3383
|
+
}
|
|
3384
|
+
}, {
|
|
3385
|
+
key: "calculateProductBookingPrice",
|
|
3386
|
+
value: function () {
|
|
3387
|
+
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
3388
|
+
var _params$customer_id;
|
|
3389
|
+
var quotation, customerId, authoritativeProduct, product;
|
|
3390
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
3391
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
3392
|
+
case 0:
|
|
3393
|
+
quotation = this.store.quotation;
|
|
3394
|
+
customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
|
|
3395
|
+
_context35.next = 4;
|
|
3396
|
+
return this.loadProductForPriceQuery(params, customerId);
|
|
3397
|
+
case 4:
|
|
3398
|
+
authoritativeProduct = _context35.sent;
|
|
3399
|
+
product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
|
|
3400
|
+
_context35.next = 8;
|
|
3401
|
+
return this.loadQuotationForPriceQuery({
|
|
3402
|
+
quotation: quotation,
|
|
3403
|
+
customer_id: customerId,
|
|
3404
|
+
channel: params.channel
|
|
3405
|
+
});
|
|
3406
|
+
case 8:
|
|
3407
|
+
return _context35.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
3408
|
+
product: product,
|
|
3409
|
+
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
3410
|
+
customer_id: customerId,
|
|
3411
|
+
quotation: quotation
|
|
3412
|
+
})));
|
|
3413
|
+
case 9:
|
|
3414
|
+
case "end":
|
|
3415
|
+
return _context35.stop();
|
|
3416
|
+
}
|
|
3417
|
+
}, _callee35, this);
|
|
3418
|
+
}));
|
|
3419
|
+
function calculateProductBookingPrice(_x27) {
|
|
3420
|
+
return _calculateProductBookingPrice.apply(this, arguments);
|
|
3421
|
+
}
|
|
3422
|
+
return calculateProductBookingPrice;
|
|
3423
|
+
}()
|
|
3424
|
+
}, {
|
|
3425
|
+
key: "getQuotationCustomerScopeInfo",
|
|
3426
|
+
value: function getQuotationCustomerScopeInfo() {
|
|
3427
|
+
var _this13 = this;
|
|
3428
|
+
var quotation = this.store.quotation;
|
|
3429
|
+
if (quotation && typeof quotation.getQuotationCustomerScopeInfo === 'function') {
|
|
3430
|
+
return quotation.getQuotationCustomerScopeInfo();
|
|
3431
|
+
}
|
|
3432
|
+
var list = typeof (quotation === null || quotation === void 0 ? void 0 : quotation.getQuotationList) === 'function' ? quotation.getQuotationList() : [];
|
|
3433
|
+
var customerById = new Map();
|
|
3434
|
+
var quotationScopes = (Array.isArray(list) ? list : []).filter(function (item) {
|
|
3435
|
+
return Array.isArray(item === null || item === void 0 ? void 0 : item.customer) && item.customer.length > 0;
|
|
3436
|
+
}).map(function (item) {
|
|
3437
|
+
var localSeen = new Set();
|
|
3438
|
+
var customers = item.customer.filter(function (customer) {
|
|
3439
|
+
var customerId = _this13.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
|
|
3440
|
+
if (!customerId || localSeen.has(customerId)) return false;
|
|
3441
|
+
localSeen.add(customerId);
|
|
3442
|
+
if (!customerById.has(customerId)) customerById.set(customerId, customer);
|
|
3443
|
+
return true;
|
|
3444
|
+
});
|
|
3445
|
+
return {
|
|
3446
|
+
quotationId: item.id,
|
|
3447
|
+
quotationName: item.name,
|
|
3448
|
+
customerIds: customers.map(function (customer) {
|
|
3449
|
+
return String(customer.id);
|
|
3450
|
+
}),
|
|
3451
|
+
customers: customers
|
|
3452
|
+
};
|
|
3453
|
+
});
|
|
3454
|
+
return {
|
|
3455
|
+
quotationCount: Array.isArray(list) ? list.length : 0,
|
|
3456
|
+
hasCustomerScopedQuotations: quotationScopes.length > 0,
|
|
3457
|
+
allQuotationsCustomerScoped: Array.isArray(list) && list.length > 0 && quotationScopes.length === list.length,
|
|
3458
|
+
customerIds: Array.from(customerById.keys()),
|
|
3459
|
+
customers: Array.from(customerById.values()),
|
|
3460
|
+
quotationScopes: quotationScopes
|
|
3461
|
+
};
|
|
3462
|
+
}
|
|
3463
|
+
}, {
|
|
3464
|
+
key: "shouldRecalculateProductBookingPricesForContextChange",
|
|
3465
|
+
value: function shouldRecalculateProductBookingPricesForContextChange(params) {
|
|
3466
|
+
var scopeInfo = this.getQuotationCustomerScopeInfo();
|
|
3467
|
+
var scopedCustomerIds = new Set(scopeInfo.customerIds.map(function (id) {
|
|
3468
|
+
return String(id);
|
|
3469
|
+
}));
|
|
3470
|
+
var previousCustomerId = this.normalizePriceContextCustomerId(params.previousCustomerId);
|
|
3471
|
+
var nextCustomerId = this.normalizePriceContextCustomerId(params.nextCustomerId);
|
|
3472
|
+
var previousInScope = previousCustomerId ? scopedCustomerIds.has(previousCustomerId) : false;
|
|
3473
|
+
var nextInScope = nextCustomerId ? scopedCustomerIds.has(nextCustomerId) : false;
|
|
3474
|
+
var shouldRecalculate = false;
|
|
3475
|
+
if (scopeInfo.hasCustomerScopedQuotations) {
|
|
3476
|
+
if (previousInScope) {
|
|
3477
|
+
shouldRecalculate = true;
|
|
3478
|
+
} else if (!previousCustomerId && !nextInScope) {
|
|
3479
|
+
shouldRecalculate = false;
|
|
3480
|
+
} else {
|
|
3481
|
+
shouldRecalculate = nextInScope;
|
|
3482
|
+
}
|
|
3483
|
+
}
|
|
3484
|
+
return shouldRecalculate;
|
|
3485
|
+
}
|
|
3486
|
+
}, {
|
|
3487
|
+
key: "calculateProductBookingPrices",
|
|
3488
|
+
value: function () {
|
|
3489
|
+
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(paramsList) {
|
|
3490
|
+
var _paramsList$0$custome,
|
|
3491
|
+
_paramsList$,
|
|
3492
|
+
_this14 = this,
|
|
3493
|
+
_paramsList$2;
|
|
3494
|
+
var quotation, customerId, productMapsByGroup, groups;
|
|
3495
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
3496
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
3497
|
+
case 0:
|
|
3498
|
+
if (paramsList.length) {
|
|
3499
|
+
_context37.next = 2;
|
|
3500
|
+
break;
|
|
3501
|
+
}
|
|
3502
|
+
return _context37.abrupt("return", []);
|
|
3503
|
+
case 2:
|
|
3504
|
+
quotation = this.store.quotation;
|
|
3505
|
+
customerId = (_paramsList$0$custome = (_paramsList$ = paramsList[0]) === null || _paramsList$ === void 0 ? void 0 : _paramsList$.customer_id) !== null && _paramsList$0$custome !== void 0 ? _paramsList$0$custome : this.getCurrentOrderCustomerId();
|
|
3506
|
+
productMapsByGroup = new Map();
|
|
3507
|
+
groups = new Map();
|
|
3508
|
+
paramsList.forEach(function (params) {
|
|
3509
|
+
var _this14$otherParams;
|
|
3510
|
+
var product = params.product || {};
|
|
3511
|
+
var productId = _this14.getPriceQueryProductId(product);
|
|
3512
|
+
if (productId === null) return;
|
|
3513
|
+
var schedule = _this14.getPriceQuerySchedule(params);
|
|
3514
|
+
var channel = params.channel || ((_this14$otherParams = _this14.otherParams) === null || _this14$otherParams === void 0 ? void 0 : _this14$otherParams.channel);
|
|
3515
|
+
var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
|
|
3516
|
+
var group = groups.get(groupKey) || {
|
|
3517
|
+
ids: new Set(),
|
|
3518
|
+
schedule: schedule,
|
|
3519
|
+
channel: channel
|
|
3520
|
+
};
|
|
3521
|
+
group.ids.add(productId);
|
|
3522
|
+
groups.set(groupKey, group);
|
|
3523
|
+
});
|
|
3524
|
+
_context37.next = 9;
|
|
3525
|
+
return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
|
|
3526
|
+
var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(_ref27) {
|
|
3527
|
+
var _ref29, groupKey, group, productsById;
|
|
3528
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
3529
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
3530
|
+
case 0:
|
|
3531
|
+
_ref29 = _slicedToArray(_ref27, 2), groupKey = _ref29[0], group = _ref29[1];
|
|
3532
|
+
_context36.next = 3;
|
|
3533
|
+
return _this14.loadProductsForPriceQuery({
|
|
3534
|
+
ids: Array.from(group.ids),
|
|
3535
|
+
schedule: group.schedule,
|
|
3536
|
+
customerId: customerId,
|
|
3537
|
+
channel: group.channel
|
|
3538
|
+
});
|
|
3539
|
+
case 3:
|
|
3540
|
+
productsById = _context36.sent;
|
|
3541
|
+
productMapsByGroup.set(groupKey, productsById);
|
|
3542
|
+
case 5:
|
|
3543
|
+
case "end":
|
|
3544
|
+
return _context36.stop();
|
|
3545
|
+
}
|
|
3546
|
+
}, _callee36);
|
|
3547
|
+
}));
|
|
3548
|
+
return function (_x29) {
|
|
3549
|
+
return _ref28.apply(this, arguments);
|
|
3550
|
+
};
|
|
3551
|
+
}()));
|
|
3552
|
+
case 9:
|
|
3553
|
+
_context37.next = 11;
|
|
3554
|
+
return this.loadQuotationForPriceQuery({
|
|
3555
|
+
quotation: quotation,
|
|
3556
|
+
customer_id: customerId,
|
|
3557
|
+
channel: (_paramsList$2 = paramsList[0]) === null || _paramsList$2 === void 0 ? void 0 : _paramsList$2.channel
|
|
3558
|
+
});
|
|
3559
|
+
case 11:
|
|
3560
|
+
return _context37.abrupt("return", paramsList.map(function (params) {
|
|
3561
|
+
var _this14$otherParams2, _productMapsByGroup$g;
|
|
3562
|
+
var productInput = params.product || {};
|
|
3563
|
+
var productId = _this14.getPriceQueryProductId(productInput);
|
|
3564
|
+
var schedule = _this14.getPriceQuerySchedule(params);
|
|
3565
|
+
var channel = params.channel || ((_this14$otherParams2 = _this14.otherParams) === null || _this14$otherParams2 === void 0 ? void 0 : _this14$otherParams2.channel);
|
|
3566
|
+
var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
|
|
3567
|
+
var authoritativeProduct = productId === null ? null : ((_productMapsByGroup$g = productMapsByGroup.get(groupKey)) === null || _productMapsByGroup$g === void 0 ? void 0 : _productMapsByGroup$g.get(productId)) || null;
|
|
3568
|
+
var product = _this14.mergeProductForPriceQuery(productInput, authoritativeProduct);
|
|
3569
|
+
return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
3570
|
+
product: product,
|
|
3571
|
+
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
3572
|
+
customer_id: customerId,
|
|
3573
|
+
quotation: quotation
|
|
3574
|
+
}));
|
|
3575
|
+
}));
|
|
3576
|
+
case 12:
|
|
3577
|
+
case "end":
|
|
3578
|
+
return _context37.stop();
|
|
3579
|
+
}
|
|
3580
|
+
}, _callee37, this);
|
|
3581
|
+
}));
|
|
3582
|
+
function calculateProductBookingPrices(_x28) {
|
|
3583
|
+
return _calculateProductBookingPrices.apply(this, arguments);
|
|
3584
|
+
}
|
|
3585
|
+
return calculateProductBookingPrices;
|
|
3586
|
+
}()
|
|
3587
|
+
}, {
|
|
3588
|
+
key: "addProductToOrder",
|
|
3589
|
+
value: function () {
|
|
3590
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(product, booking) {
|
|
3591
|
+
var products;
|
|
3592
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
3593
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
3594
|
+
case 0:
|
|
3595
|
+
_context38.prev = 0;
|
|
3596
|
+
if (this.store.order) {
|
|
3597
|
+
_context38.next = 3;
|
|
3598
|
+
break;
|
|
3599
|
+
}
|
|
3600
|
+
throw new Error('order 模块未初始化');
|
|
3601
|
+
case 3:
|
|
3602
|
+
_context38.next = 5;
|
|
3603
|
+
return this.store.order.addProductToOrder(product, booking);
|
|
3604
|
+
case 5:
|
|
3605
|
+
products = _context38.sent;
|
|
3606
|
+
return _context38.abrupt("return", products);
|
|
3607
|
+
case 9:
|
|
3608
|
+
_context38.prev = 9;
|
|
3609
|
+
_context38.t0 = _context38["catch"](0);
|
|
3610
|
+
throw _context38.t0;
|
|
3611
|
+
case 12:
|
|
3612
|
+
case "end":
|
|
3613
|
+
return _context38.stop();
|
|
3614
|
+
}
|
|
3615
|
+
}, _callee38, this, [[0, 9]]);
|
|
3616
|
+
}));
|
|
3617
|
+
function addProductToOrder(_x30, _x31) {
|
|
3618
|
+
return _addProductToOrder.apply(this, arguments);
|
|
3619
|
+
}
|
|
3620
|
+
return addProductToOrder;
|
|
3621
|
+
}()
|
|
3622
|
+
}, {
|
|
3623
|
+
key: "updateOrderProduct",
|
|
3624
|
+
value: function () {
|
|
3625
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
3626
|
+
var products;
|
|
3627
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
3628
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
3629
|
+
case 0:
|
|
3630
|
+
_context39.prev = 0;
|
|
3631
|
+
if (this.store.order) {
|
|
3632
|
+
_context39.next = 3;
|
|
3633
|
+
break;
|
|
3634
|
+
}
|
|
3635
|
+
throw new Error('order 模块未初始化');
|
|
3636
|
+
case 3:
|
|
3637
|
+
_context39.next = 5;
|
|
3638
|
+
return this.store.order.updateOrderProduct(params);
|
|
3639
|
+
case 5:
|
|
3640
|
+
products = _context39.sent;
|
|
3641
|
+
return _context39.abrupt("return", products);
|
|
3642
|
+
case 9:
|
|
3643
|
+
_context39.prev = 9;
|
|
3644
|
+
_context39.t0 = _context39["catch"](0);
|
|
3645
|
+
throw _context39.t0;
|
|
3646
|
+
case 12:
|
|
3647
|
+
case "end":
|
|
3648
|
+
return _context39.stop();
|
|
3649
|
+
}
|
|
3650
|
+
}, _callee39, this, [[0, 9]]);
|
|
3651
|
+
}));
|
|
3652
|
+
function updateOrderProduct(_x32) {
|
|
3653
|
+
return _updateOrderProduct.apply(this, arguments);
|
|
3654
|
+
}
|
|
3655
|
+
return updateOrderProduct;
|
|
3656
|
+
}()
|
|
3657
|
+
}, {
|
|
3658
|
+
key: "updateOrderProducts",
|
|
3659
|
+
value: function () {
|
|
3660
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(paramsList) {
|
|
3661
|
+
var products;
|
|
3662
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3663
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
3664
|
+
case 0:
|
|
3665
|
+
_context40.prev = 0;
|
|
3666
|
+
if (this.store.order) {
|
|
3667
|
+
_context40.next = 3;
|
|
3668
|
+
break;
|
|
3669
|
+
}
|
|
3670
|
+
throw new Error('order 模块未初始化');
|
|
3671
|
+
case 3:
|
|
3672
|
+
_context40.next = 5;
|
|
3673
|
+
return this.store.order.updateOrderProducts(paramsList);
|
|
3674
|
+
case 5:
|
|
3675
|
+
products = _context40.sent;
|
|
3676
|
+
return _context40.abrupt("return", products);
|
|
3677
|
+
case 9:
|
|
3678
|
+
_context40.prev = 9;
|
|
3679
|
+
_context40.t0 = _context40["catch"](0);
|
|
3680
|
+
throw _context40.t0;
|
|
3681
|
+
case 12:
|
|
3682
|
+
case "end":
|
|
3683
|
+
return _context40.stop();
|
|
3684
|
+
}
|
|
3685
|
+
}, _callee40, this, [[0, 9]]);
|
|
3686
|
+
}));
|
|
3687
|
+
function updateOrderProducts(_x33) {
|
|
3688
|
+
return _updateOrderProducts.apply(this, arguments);
|
|
3689
|
+
}
|
|
3690
|
+
return updateOrderProducts;
|
|
3691
|
+
}()
|
|
3692
|
+
}, {
|
|
3693
|
+
key: "updateOrderProductQuantity",
|
|
3694
|
+
value: function () {
|
|
3695
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
3696
|
+
var products;
|
|
3697
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3698
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
3699
|
+
case 0:
|
|
3700
|
+
_context41.prev = 0;
|
|
3701
|
+
if (this.store.order) {
|
|
3702
|
+
_context41.next = 3;
|
|
3703
|
+
break;
|
|
3704
|
+
}
|
|
3705
|
+
throw new Error('order 模块未初始化');
|
|
3706
|
+
case 3:
|
|
3707
|
+
_context41.next = 5;
|
|
3708
|
+
return this.store.order.updateOrderProductQuantity(params);
|
|
3709
|
+
case 5:
|
|
3710
|
+
products = _context41.sent;
|
|
3711
|
+
return _context41.abrupt("return", products);
|
|
3712
|
+
case 9:
|
|
3713
|
+
_context41.prev = 9;
|
|
3714
|
+
_context41.t0 = _context41["catch"](0);
|
|
3715
|
+
throw _context41.t0;
|
|
3716
|
+
case 12:
|
|
3717
|
+
case "end":
|
|
3718
|
+
return _context41.stop();
|
|
3719
|
+
}
|
|
3720
|
+
}, _callee41, this, [[0, 9]]);
|
|
3721
|
+
}));
|
|
3722
|
+
function updateOrderProductQuantity(_x34) {
|
|
3723
|
+
return _updateOrderProductQuantity.apply(this, arguments);
|
|
3724
|
+
}
|
|
3725
|
+
return updateOrderProductQuantity;
|
|
3726
|
+
}()
|
|
3727
|
+
}, {
|
|
3728
|
+
key: "updateOrderBooking",
|
|
3729
|
+
value: function updateOrderBooking(params) {
|
|
3730
|
+
try {
|
|
3731
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3732
|
+
return this.store.order.updateOrderBooking(params);
|
|
3733
|
+
} catch (error) {
|
|
3734
|
+
throw error;
|
|
3735
|
+
}
|
|
3736
|
+
}
|
|
3737
|
+
|
|
3738
|
+
/**
|
|
3739
|
+
* 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
|
|
3740
|
+
* 多行同 SKU 时必须传入与删除/更新一致的 unique_identification_number。
|
|
3741
|
+
*/
|
|
3742
|
+
}, {
|
|
3743
|
+
key: "setOrderProductLineNote",
|
|
3744
|
+
value: (function () {
|
|
3745
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(identity, note) {
|
|
3746
|
+
var params, products;
|
|
3747
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
3748
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
3749
|
+
case 0:
|
|
3750
|
+
_context42.prev = 0;
|
|
3751
|
+
params = {
|
|
3752
|
+
product_id: identity.product_id,
|
|
3753
|
+
product_variant_id: identity.product_variant_id,
|
|
3754
|
+
updates: {
|
|
3755
|
+
note: String(note || '')
|
|
3756
|
+
}
|
|
3757
|
+
};
|
|
3758
|
+
if (identity.unique_identification_number !== undefined) {
|
|
3759
|
+
params.unique_identification_number = identity.unique_identification_number;
|
|
3760
|
+
}
|
|
3761
|
+
if (identity.product_sku !== undefined) {
|
|
3762
|
+
params.product_sku = identity.product_sku;
|
|
3763
|
+
}
|
|
3764
|
+
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
3765
|
+
_context42.next = 7;
|
|
3766
|
+
return this.updateOrderProduct(params);
|
|
3767
|
+
case 7:
|
|
3768
|
+
products = _context42.sent;
|
|
3769
|
+
return _context42.abrupt("return", products);
|
|
3770
|
+
case 11:
|
|
3771
|
+
_context42.prev = 11;
|
|
3772
|
+
_context42.t0 = _context42["catch"](0);
|
|
3773
|
+
throw _context42.t0;
|
|
3774
|
+
case 14:
|
|
3775
|
+
case "end":
|
|
3776
|
+
return _context42.stop();
|
|
3777
|
+
}
|
|
3778
|
+
}, _callee42, this, [[0, 11]]);
|
|
3779
|
+
}));
|
|
3780
|
+
function setOrderProductLineNote(_x35, _x36) {
|
|
3781
|
+
return _setOrderProductLineNote.apply(this, arguments);
|
|
3782
|
+
}
|
|
3783
|
+
return setOrderProductLineNote;
|
|
3784
|
+
}()
|
|
3785
|
+
/**
|
|
3786
|
+
* 批量删除购物车行,末尾仅一次促销重算。
|
|
3787
|
+
*
|
|
3788
|
+
* @example
|
|
3789
|
+
* await baseSales.removeProductsFromOrder([identityA, identityB]);
|
|
3790
|
+
*/
|
|
3791
|
+
)
|
|
3792
|
+
}, {
|
|
3793
|
+
key: "removeProductsFromOrder",
|
|
3794
|
+
value: (function () {
|
|
3795
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(identities) {
|
|
3796
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
3797
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
3798
|
+
case 0:
|
|
3799
|
+
_context43.prev = 0;
|
|
3800
|
+
if (this.store.order) {
|
|
3801
|
+
_context43.next = 3;
|
|
3802
|
+
break;
|
|
3803
|
+
}
|
|
3804
|
+
throw new Error('order 模块未初始化');
|
|
3805
|
+
case 3:
|
|
3806
|
+
_context43.next = 5;
|
|
3807
|
+
return this.store.order.removeProductsFromOrder(identities);
|
|
3808
|
+
case 5:
|
|
3809
|
+
return _context43.abrupt("return", _context43.sent);
|
|
3810
|
+
case 8:
|
|
3811
|
+
_context43.prev = 8;
|
|
3812
|
+
_context43.t0 = _context43["catch"](0);
|
|
3813
|
+
throw _context43.t0;
|
|
3814
|
+
case 11:
|
|
3815
|
+
case "end":
|
|
3816
|
+
return _context43.stop();
|
|
3817
|
+
}
|
|
3818
|
+
}, _callee43, this, [[0, 8]]);
|
|
3819
|
+
}));
|
|
3820
|
+
function removeProductsFromOrder(_x37) {
|
|
3821
|
+
return _removeProductsFromOrder.apply(this, arguments);
|
|
3822
|
+
}
|
|
3823
|
+
return removeProductsFromOrder;
|
|
3824
|
+
}())
|
|
3825
|
+
}, {
|
|
3826
|
+
key: "removeProductFromOrder",
|
|
3827
|
+
value: function () {
|
|
3828
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(identity) {
|
|
3829
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
3830
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
3831
|
+
case 0:
|
|
3832
|
+
return _context44.abrupt("return", this.removeProductsFromOrder([identity]));
|
|
3833
|
+
case 1:
|
|
3834
|
+
case "end":
|
|
3835
|
+
return _context44.stop();
|
|
3836
|
+
}
|
|
3837
|
+
}, _callee44, this);
|
|
3838
|
+
}));
|
|
3839
|
+
function removeProductFromOrder(_x38) {
|
|
3840
|
+
return _removeProductFromOrder.apply(this, arguments);
|
|
3841
|
+
}
|
|
3842
|
+
return removeProductFromOrder;
|
|
3843
|
+
}() // ─── 促销/赠品 透传(迁移自 booking usePromotion) ────────────────
|
|
3844
|
+
/**
|
|
3845
|
+
* 注入促销评估器到底层 OrderModule。
|
|
3846
|
+
*
|
|
3847
|
+
* @example
|
|
3848
|
+
* solution.setPromotionEvaluator(appHelper.utils.promotionEvaluator);
|
|
3849
|
+
*/
|
|
3850
|
+
}, {
|
|
3851
|
+
key: "setPromotionEvaluator",
|
|
3852
|
+
value: function setPromotionEvaluator(evaluator) {
|
|
3853
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3854
|
+
this.store.order.setPromotionEvaluator(evaluator);
|
|
3855
|
+
}
|
|
3856
|
+
|
|
3857
|
+
/**
|
|
3858
|
+
* 注入赠品选择 resolver。UI 层(SalesSdk)通过 bridge 提供。
|
|
3859
|
+
*
|
|
3860
|
+
* @example
|
|
3861
|
+
* solution.setGiftSelectResolver(async (ctx) => bridge.request(ctx));
|
|
3862
|
+
*/
|
|
3863
|
+
}, {
|
|
3864
|
+
key: "setGiftSelectResolver",
|
|
3865
|
+
value: function setGiftSelectResolver(resolver) {
|
|
3866
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3867
|
+
this.store.order.setGiftSelectResolver(resolver);
|
|
3868
|
+
}
|
|
3869
|
+
|
|
3870
|
+
/**
|
|
3871
|
+
* 为商品目录追加促销标签,供 SalesSdkProductProvider 等商品列表入口复用。
|
|
3872
|
+
*
|
|
3873
|
+
* @example
|
|
3874
|
+
* const products = solution.appendPromotionTags(catalogProducts);
|
|
3875
|
+
*/
|
|
3876
|
+
}, {
|
|
3877
|
+
key: "appendPromotionTags",
|
|
3878
|
+
value: function appendPromotionTags(products) {
|
|
3879
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3880
|
+
return this.store.order.appendPromotionTags(products);
|
|
3881
|
+
}
|
|
3882
|
+
|
|
3883
|
+
/**
|
|
3884
|
+
* 主动触发一次促销应用(一般写路径会自动触发,少数场景如客户切换后可手动调)。
|
|
3885
|
+
*/
|
|
3886
|
+
}, {
|
|
3887
|
+
key: "applyPromotion",
|
|
3888
|
+
value: (function () {
|
|
3889
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
|
|
3890
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
3891
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
3892
|
+
case 0:
|
|
3893
|
+
if (this.store.order) {
|
|
3894
|
+
_context45.next = 2;
|
|
3895
|
+
break;
|
|
3896
|
+
}
|
|
3897
|
+
throw new Error('order 模块未初始化');
|
|
3898
|
+
case 2:
|
|
3899
|
+
_context45.next = 4;
|
|
3900
|
+
return this.store.order.applyPromotion();
|
|
3901
|
+
case 4:
|
|
3902
|
+
case "end":
|
|
3903
|
+
return _context45.stop();
|
|
3904
|
+
}
|
|
3905
|
+
}, _callee45, this);
|
|
3906
|
+
}));
|
|
3907
|
+
function applyPromotion() {
|
|
3908
|
+
return _applyPromotion.apply(this, arguments);
|
|
3909
|
+
}
|
|
3910
|
+
return applyPromotion;
|
|
3911
|
+
}() /** 最近一次促销计算输出的未满足提示。 */)
|
|
3912
|
+
}, {
|
|
3913
|
+
key: "getUnfulfilledPromotions",
|
|
3914
|
+
value: function getUnfulfilledPromotions() {
|
|
3915
|
+
var _this$store$order8;
|
|
3916
|
+
return ((_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getUnfulfilledPromotions()) || [];
|
|
3917
|
+
}
|
|
3918
|
+
|
|
3919
|
+
/** 最近一次促销计算输出的赠品操作 diff。 */
|
|
3920
|
+
}, {
|
|
3921
|
+
key: "getLastGiftActions",
|
|
3922
|
+
value: function getLastGiftActions() {
|
|
3923
|
+
var _this$store$order9;
|
|
3924
|
+
return ((_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 ? void 0 : _this$store$order9.getLastGiftActions()) || null;
|
|
3925
|
+
}
|
|
3926
|
+
|
|
3927
|
+
// 获取商品列表
|
|
3928
|
+
// TODO 需要跟 webpos 内的对齐一下
|
|
3929
|
+
}, {
|
|
3930
|
+
key: "getProductList",
|
|
3931
|
+
value: function () {
|
|
3932
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
|
|
3933
|
+
var _this$otherParams22;
|
|
3934
|
+
var menu_list_ids, _this$store$products, res;
|
|
3935
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
3936
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
3937
|
+
case 0:
|
|
3938
|
+
// 可以直接通过配置里的 menu 读取
|
|
3939
|
+
menu_list_ids = ((_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 || (_this$otherParams22 = _this$otherParams22.dineInConfig) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22['menu.associated_menus'].map(function (n) {
|
|
3940
|
+
return Number(n.value);
|
|
3941
|
+
})) || [];
|
|
3942
|
+
_context46.prev = 1;
|
|
3943
|
+
_context46.next = 4;
|
|
3944
|
+
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
3945
|
+
menu_list_ids: menu_list_ids,
|
|
3946
|
+
cacheId: this.cacheId,
|
|
3947
|
+
schedule_date: dayjs().format('YYYY-MM-DD'),
|
|
3948
|
+
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
3949
|
+
});
|
|
3950
|
+
case 4:
|
|
3951
|
+
res = _context46.sent;
|
|
3952
|
+
return _context46.abrupt("return", res);
|
|
3953
|
+
case 8:
|
|
3954
|
+
_context46.prev = 8;
|
|
3955
|
+
_context46.t0 = _context46["catch"](1);
|
|
3956
|
+
throw _context46.t0;
|
|
3957
|
+
case 11:
|
|
3958
|
+
case "end":
|
|
3959
|
+
return _context46.stop();
|
|
3960
|
+
}
|
|
3961
|
+
}, _callee46, this, [[1, 8]]);
|
|
3962
|
+
}));
|
|
3963
|
+
function getProductList() {
|
|
3964
|
+
return _getProductList.apply(this, arguments);
|
|
3965
|
+
}
|
|
3966
|
+
return getProductList;
|
|
3967
|
+
}()
|
|
3968
|
+
}, {
|
|
3969
|
+
key: "getOtherParams",
|
|
3970
|
+
value: function getOtherParams() {
|
|
3971
|
+
return this.otherParams;
|
|
3972
|
+
}
|
|
3973
|
+
}, {
|
|
3974
|
+
key: "setOtherParams",
|
|
3975
|
+
value: function () {
|
|
3976
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
|
|
3977
|
+
var _this$otherParams23;
|
|
3978
|
+
var _ref30,
|
|
3979
|
+
_ref30$cover,
|
|
3980
|
+
cover,
|
|
3981
|
+
_args47 = arguments;
|
|
3982
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
3983
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
3984
|
+
case 0:
|
|
3985
|
+
_ref30 = _args47.length > 1 && _args47[1] !== undefined ? _args47[1] : {}, _ref30$cover = _ref30.cover, cover = _ref30$cover === void 0 ? false : _ref30$cover;
|
|
3986
|
+
if (cover) {
|
|
3987
|
+
this.otherParams = _objectSpread({}, params);
|
|
3988
|
+
} else {
|
|
3989
|
+
this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
|
|
3990
|
+
}
|
|
3991
|
+
this.cacheId = (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.cacheId;
|
|
3992
|
+
_context47.next = 5;
|
|
3993
|
+
return this.syncOtherParamsToSubModules(params, {
|
|
3994
|
+
cover: cover
|
|
3995
|
+
});
|
|
3996
|
+
case 5:
|
|
3997
|
+
case "end":
|
|
3998
|
+
return _context47.stop();
|
|
3999
|
+
}
|
|
4000
|
+
}, _callee47, this);
|
|
4001
|
+
}));
|
|
4002
|
+
function setOtherParams(_x39) {
|
|
4003
|
+
return _setOtherParams.apply(this, arguments);
|
|
4004
|
+
}
|
|
4005
|
+
return setOtherParams;
|
|
4006
|
+
}()
|
|
4007
|
+
}]);
|
|
4008
|
+
return BaseSalesImpl;
|
|
4009
|
+
}(BaseModule);
|