@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
|
@@ -76,6 +76,13 @@ function generateRequestUniqueId() {
|
|
|
76
76
|
|
|
77
77
|
return "".concat(year).concat(month).concat(day).concat(hour).concat(minute).concat(second).concat(millisecond).concat(randomDigits);
|
|
78
78
|
}
|
|
79
|
+
function normalizeCustomPaymentId(paymentItem) {
|
|
80
|
+
var _ref, _paymentItem$custom_p;
|
|
81
|
+
var rawId = (_ref = (_paymentItem$custom_p = paymentItem.custom_payment_id) !== null && _paymentItem$custom_p !== void 0 ? _paymentItem$custom_p : paymentItem.id) !== null && _ref !== void 0 ? _ref : 0;
|
|
82
|
+
var parsedId = Number(rawId);
|
|
83
|
+
if (!Number.isFinite(parsedId)) return 0;
|
|
84
|
+
return parsedId;
|
|
85
|
+
}
|
|
79
86
|
|
|
80
87
|
/**
|
|
81
88
|
* 支付模块实现
|
|
@@ -190,16 +197,16 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
190
197
|
this.logger = this.app.logger;
|
|
191
198
|
|
|
192
199
|
// 确保支付模块所需的对象存储已创建
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
case 15:
|
|
200
|
+
// await this.ensurePaymentTables();
|
|
201
|
+
|
|
196
202
|
this.registerNetworkHandlers();
|
|
197
203
|
|
|
198
204
|
// // 预连接数据库
|
|
199
205
|
// this.dbManager.connect()
|
|
200
206
|
|
|
207
|
+
console.log('[PaymentModule] 初始化完成');
|
|
201
208
|
this.logInfo('PaymentModule initialized successfully');
|
|
202
|
-
case
|
|
209
|
+
case 16:
|
|
203
210
|
case "end":
|
|
204
211
|
return _context.stop();
|
|
205
212
|
}
|
|
@@ -210,6 +217,18 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
210
217
|
}
|
|
211
218
|
return initialize;
|
|
212
219
|
}()
|
|
220
|
+
/**
|
|
221
|
+
* 更新父级解决方案透传的运行态参数,主要用于日志父模块等上下文。
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* paymentModule.updateOtherParams({ fatherModule: 'bookingTicket' });
|
|
225
|
+
*/
|
|
226
|
+
}, {
|
|
227
|
+
key: "updateOtherParams",
|
|
228
|
+
value: function updateOtherParams(params) {
|
|
229
|
+
this.otherParams = params || {};
|
|
230
|
+
}
|
|
231
|
+
|
|
213
232
|
/**
|
|
214
233
|
* 记录信息日志
|
|
215
234
|
*/
|
|
@@ -296,10 +315,11 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
296
315
|
var network = this.app.plugins.get('network');
|
|
297
316
|
this.logInfo('Registering network status listener');
|
|
298
317
|
network === null || network === void 0 || network.addListener('networkStatusChange', /*#__PURE__*/function () {
|
|
299
|
-
var
|
|
318
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(status) {
|
|
300
319
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
301
320
|
while (1) switch (_context2.prev = _context2.next) {
|
|
302
321
|
case 0:
|
|
322
|
+
console.log('网络状态:', status.connected);
|
|
303
323
|
_this3.logInfo('Network status changed', {
|
|
304
324
|
connected: status.connected,
|
|
305
325
|
previousStatus: status.previousStatus
|
|
@@ -308,347 +328,89 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
308
328
|
_this3.logInfo('Network reconnected');
|
|
309
329
|
// 网络恢复时的处理逻辑可以在这里添加
|
|
310
330
|
}
|
|
311
|
-
case
|
|
331
|
+
case 3:
|
|
312
332
|
case "end":
|
|
313
333
|
return _context2.stop();
|
|
314
334
|
}
|
|
315
335
|
}, _callee2);
|
|
316
336
|
}));
|
|
317
337
|
return function (_x3) {
|
|
318
|
-
return
|
|
338
|
+
return _ref2.apply(this, arguments);
|
|
319
339
|
};
|
|
320
340
|
}());
|
|
321
341
|
}
|
|
322
|
-
|
|
323
|
-
key: "filterPayMethods",
|
|
324
|
-
value: function () {
|
|
325
|
-
var _filterPayMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(payMethods) {
|
|
326
|
-
var walletPassMethod;
|
|
327
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
328
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
329
|
-
case 0:
|
|
330
|
-
// 1. 筛选 status === 1 && disable === 0的数据
|
|
331
|
-
// 2. 检查列表里是否有 code=WALLET_PASS的数据,如果没有,则列表里如果有 PRODUCTVOUCHER 、 GIFTCARD 、 POINTCARD 则删除他们
|
|
332
|
-
// 如果有 code = WALLET_PASS的数据,则列表里PRODUCTVOUCHER 、 GIFTCARD 、 POINTCARD 的channel_application 指向 WALLET_PASS 的 channel_application
|
|
333
|
-
payMethods = payMethods.filter(function (method) {
|
|
334
|
-
return method.status === 1 && method.disable === 0;
|
|
335
|
-
});
|
|
336
|
-
walletPassMethod = payMethods.find(function (method) {
|
|
337
|
-
return method.code === 'WALLET_PASS';
|
|
338
|
-
});
|
|
339
|
-
if (walletPassMethod) {
|
|
340
|
-
payMethods.forEach(function (method) {
|
|
341
|
-
if (method.code === 'PRODUCTVOUCHER' || method.code === 'GIFTCARD' || method.code === 'POINTCARD') {
|
|
342
|
-
method.channel_application = walletPassMethod.channel_application;
|
|
343
|
-
}
|
|
344
|
-
});
|
|
345
|
-
} else {
|
|
346
|
-
payMethods = payMethods.filter(function (method) {
|
|
347
|
-
return method.code !== 'PRODUCTVOUCHER' && method.code !== 'GIFTCARD' && method.code !== 'POINTCARD';
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
return _context3.abrupt("return", payMethods);
|
|
351
|
-
case 4:
|
|
352
|
-
case "end":
|
|
353
|
-
return _context3.stop();
|
|
354
|
-
}
|
|
355
|
-
}, _callee3);
|
|
356
|
-
}));
|
|
357
|
-
function filterPayMethods(_x4) {
|
|
358
|
-
return _filterPayMethods.apply(this, arguments);
|
|
359
|
-
}
|
|
360
|
-
return filterPayMethods;
|
|
361
|
-
}()
|
|
342
|
+
|
|
362
343
|
/**
|
|
363
344
|
* 获取支付方式列表
|
|
364
345
|
*/
|
|
365
346
|
}, {
|
|
366
347
|
key: "getPayMethodListAsync",
|
|
367
348
|
value: (function () {
|
|
368
|
-
var _getPayMethodListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
369
|
-
var
|
|
370
|
-
return _regeneratorRuntime().wrap(function
|
|
371
|
-
while (1) switch (
|
|
349
|
+
var _getPayMethodListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
350
|
+
var response, payMethods;
|
|
351
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
352
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
372
353
|
case 0:
|
|
373
354
|
this.logInfo('Starting getPayMethodListAsync');
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
case 9:
|
|
385
|
-
_context4.prev = 9;
|
|
386
|
-
_context4.t0 = _context4["catch"](3);
|
|
387
|
-
console.warn('[PaymentModule] pay_method 表不存在,将从服务器获取数据');
|
|
388
|
-
case 12:
|
|
389
|
-
// 如果有缓存,先返回缓存数据
|
|
390
|
-
hasCache = cachedMethods.length > 0;
|
|
391
|
-
if (!hasCache) {
|
|
392
|
-
_context4.next = 16;
|
|
393
|
-
break;
|
|
394
|
-
}
|
|
395
|
-
// 后台异步获取最新数据
|
|
396
|
-
this.refreshPaymentMethodsInBackground(cachedMethods);
|
|
397
|
-
return _context4.abrupt("return", cachedMethods);
|
|
398
|
-
case 16:
|
|
399
|
-
_context4.next = 18;
|
|
400
|
-
return this.request.get('/pay/custom-payment/all');
|
|
401
|
-
case 18:
|
|
402
|
-
response = _context4.sent;
|
|
403
|
-
response.data = this.filterPayMethods(response.data);
|
|
404
|
-
payMethods = response.data || []; // 尝试缓存到 IndexDB
|
|
405
|
-
_context4.prev = 21;
|
|
406
|
-
_iterator2 = _createForOfIteratorHelper(payMethods);
|
|
407
|
-
_context4.prev = 23;
|
|
408
|
-
_iterator2.s();
|
|
409
|
-
case 25:
|
|
410
|
-
if ((_step2 = _iterator2.n()).done) {
|
|
411
|
-
_context4.next = 31;
|
|
412
|
-
break;
|
|
413
|
-
}
|
|
414
|
-
method = _step2.value;
|
|
415
|
-
_context4.next = 29;
|
|
416
|
-
return this.dbManager.update('pay_method', method);
|
|
417
|
-
case 29:
|
|
418
|
-
_context4.next = 25;
|
|
419
|
-
break;
|
|
420
|
-
case 31:
|
|
421
|
-
_context4.next = 36;
|
|
422
|
-
break;
|
|
423
|
-
case 33:
|
|
424
|
-
_context4.prev = 33;
|
|
425
|
-
_context4.t1 = _context4["catch"](23);
|
|
426
|
-
_iterator2.e(_context4.t1);
|
|
427
|
-
case 36:
|
|
428
|
-
_context4.prev = 36;
|
|
429
|
-
_iterator2.f();
|
|
430
|
-
return _context4.finish(36);
|
|
431
|
-
case 39:
|
|
432
|
-
_context4.next = 44;
|
|
433
|
-
break;
|
|
434
|
-
case 41:
|
|
435
|
-
_context4.prev = 41;
|
|
436
|
-
_context4.t2 = _context4["catch"](21);
|
|
437
|
-
console.warn('[PaymentModule] 无法缓存支付方式,pay_method 表不存在');
|
|
438
|
-
case 44:
|
|
439
|
-
_context4.next = 46;
|
|
440
|
-
return this.core.effects.emit("".concat(this.name, ":onPaymentMethodsLoaded"), payMethods);
|
|
441
|
-
case 46:
|
|
355
|
+
_context3.prev = 1;
|
|
356
|
+
_context3.next = 4;
|
|
357
|
+
return this.request.get('/pay/custom-payment/all', {
|
|
358
|
+
filterPaymentMethods: true
|
|
359
|
+
}, {
|
|
360
|
+
osServer: true
|
|
361
|
+
});
|
|
362
|
+
case 4:
|
|
363
|
+
response = _context3.sent;
|
|
364
|
+
payMethods = (response === null || response === void 0 ? void 0 : response.data) || response || [];
|
|
442
365
|
this.logInfo('getPayMethodListAsync completed successfully', {
|
|
443
366
|
payMethods: payMethods
|
|
444
367
|
});
|
|
445
|
-
return
|
|
446
|
-
case
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
console.error('[PaymentModule] 获取支付方式列表失败',
|
|
450
|
-
this.logError('getPayMethodListAsync failed',
|
|
368
|
+
return _context3.abrupt("return", payMethods);
|
|
369
|
+
case 10:
|
|
370
|
+
_context3.prev = 10;
|
|
371
|
+
_context3.t0 = _context3["catch"](1);
|
|
372
|
+
console.error('[PaymentModule] 获取支付方式列表失败', _context3.t0);
|
|
373
|
+
this.logError('getPayMethodListAsync failed', _context3.t0);
|
|
451
374
|
// 如果所有操作都失败,返回空数组
|
|
452
|
-
return
|
|
453
|
-
case
|
|
375
|
+
return _context3.abrupt("return", []);
|
|
376
|
+
case 15:
|
|
454
377
|
case "end":
|
|
455
|
-
return
|
|
378
|
+
return _context3.stop();
|
|
456
379
|
}
|
|
457
|
-
},
|
|
380
|
+
}, _callee3, this, [[1, 10]]);
|
|
458
381
|
}));
|
|
459
382
|
function getPayMethodListAsync() {
|
|
460
383
|
return _getPayMethodListAsync.apply(this, arguments);
|
|
461
384
|
}
|
|
462
385
|
return getPayMethodListAsync;
|
|
463
386
|
}()
|
|
464
|
-
/**
|
|
465
|
-
* 后台刷新支付方式列表
|
|
466
|
-
*/
|
|
467
|
-
)
|
|
468
|
-
}, {
|
|
469
|
-
key: "refreshPaymentMethodsInBackground",
|
|
470
|
-
value: (function () {
|
|
471
|
-
var _refreshPaymentMethodsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(cachedMethods) {
|
|
472
|
-
var response, newPayMethods, hasChanges, _iterator3, _step3, method, _iterator4, _step4, _method, eventData;
|
|
473
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
474
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
475
|
-
case 0:
|
|
476
|
-
this.logInfo('Starting refreshPaymentMethodsInBackground', {
|
|
477
|
-
cachedMethodsCount: cachedMethods.length
|
|
478
|
-
});
|
|
479
|
-
_context5.prev = 1;
|
|
480
|
-
_context5.next = 4;
|
|
481
|
-
return this.request.get('/pay/custom-payment/all');
|
|
482
|
-
case 4:
|
|
483
|
-
response = _context5.sent;
|
|
484
|
-
response.data = this.filterPayMethods(response.data);
|
|
485
|
-
newPayMethods = response.data || []; // 检查是否有变化
|
|
486
|
-
hasChanges = this.hasPaymentMethodsChanged(cachedMethods, newPayMethods);
|
|
487
|
-
if (!hasChanges) {
|
|
488
|
-
_context5.next = 55;
|
|
489
|
-
break;
|
|
490
|
-
}
|
|
491
|
-
this.logInfo('Payment methods updated in background', {
|
|
492
|
-
oldCount: cachedMethods.length,
|
|
493
|
-
newCount: newPayMethods.length
|
|
494
|
-
});
|
|
495
|
-
|
|
496
|
-
// 更新缓存
|
|
497
|
-
_context5.prev = 10;
|
|
498
|
-
// 先清除旧数据
|
|
499
|
-
_iterator3 = _createForOfIteratorHelper(cachedMethods);
|
|
500
|
-
_context5.prev = 12;
|
|
501
|
-
_iterator3.s();
|
|
502
|
-
case 14:
|
|
503
|
-
if ((_step3 = _iterator3.n()).done) {
|
|
504
|
-
_context5.next = 20;
|
|
505
|
-
break;
|
|
506
|
-
}
|
|
507
|
-
method = _step3.value;
|
|
508
|
-
_context5.next = 18;
|
|
509
|
-
return this.dbManager.delete('pay_method', method.id);
|
|
510
|
-
case 18:
|
|
511
|
-
_context5.next = 14;
|
|
512
|
-
break;
|
|
513
|
-
case 20:
|
|
514
|
-
_context5.next = 25;
|
|
515
|
-
break;
|
|
516
|
-
case 22:
|
|
517
|
-
_context5.prev = 22;
|
|
518
|
-
_context5.t0 = _context5["catch"](12);
|
|
519
|
-
_iterator3.e(_context5.t0);
|
|
520
|
-
case 25:
|
|
521
|
-
_context5.prev = 25;
|
|
522
|
-
_iterator3.f();
|
|
523
|
-
return _context5.finish(25);
|
|
524
|
-
case 28:
|
|
525
|
-
// 添加新数据
|
|
526
|
-
_iterator4 = _createForOfIteratorHelper(newPayMethods);
|
|
527
|
-
_context5.prev = 29;
|
|
528
|
-
_iterator4.s();
|
|
529
|
-
case 31:
|
|
530
|
-
if ((_step4 = _iterator4.n()).done) {
|
|
531
|
-
_context5.next = 37;
|
|
532
|
-
break;
|
|
533
|
-
}
|
|
534
|
-
_method = _step4.value;
|
|
535
|
-
_context5.next = 35;
|
|
536
|
-
return this.dbManager.update('pay_method', _method);
|
|
537
|
-
case 35:
|
|
538
|
-
_context5.next = 31;
|
|
539
|
-
break;
|
|
540
|
-
case 37:
|
|
541
|
-
_context5.next = 42;
|
|
542
|
-
break;
|
|
543
|
-
case 39:
|
|
544
|
-
_context5.prev = 39;
|
|
545
|
-
_context5.t1 = _context5["catch"](29);
|
|
546
|
-
_iterator4.e(_context5.t1);
|
|
547
|
-
case 42:
|
|
548
|
-
_context5.prev = 42;
|
|
549
|
-
_iterator4.f();
|
|
550
|
-
return _context5.finish(42);
|
|
551
|
-
case 45:
|
|
552
|
-
_context5.next = 50;
|
|
553
|
-
break;
|
|
554
|
-
case 47:
|
|
555
|
-
_context5.prev = 47;
|
|
556
|
-
_context5.t2 = _context5["catch"](10);
|
|
557
|
-
console.warn('[PaymentModule] 无法更新支付方式缓存', _context5.t2);
|
|
558
|
-
case 50:
|
|
559
|
-
// 通知外部支付方式已变化
|
|
560
|
-
eventData = {
|
|
561
|
-
oldMethods: cachedMethods,
|
|
562
|
-
newMethods: newPayMethods
|
|
563
|
-
};
|
|
564
|
-
_context5.next = 53;
|
|
565
|
-
return this.core.effects.emit("".concat(this.name, ":onPaymentMethodsChanged"), eventData);
|
|
566
|
-
case 53:
|
|
567
|
-
_context5.next = 55;
|
|
568
|
-
break;
|
|
569
|
-
case 55:
|
|
570
|
-
_context5.next = 60;
|
|
571
|
-
break;
|
|
572
|
-
case 57:
|
|
573
|
-
_context5.prev = 57;
|
|
574
|
-
_context5.t3 = _context5["catch"](1);
|
|
575
|
-
console.error('[PaymentModule] 后台刷新支付方式失败', _context5.t3);
|
|
576
|
-
case 60:
|
|
577
|
-
case "end":
|
|
578
|
-
return _context5.stop();
|
|
579
|
-
}
|
|
580
|
-
}, _callee5, this, [[1, 57], [10, 47], [12, 22, 25, 28], [29, 39, 42, 45]]);
|
|
581
|
-
}));
|
|
582
|
-
function refreshPaymentMethodsInBackground(_x5) {
|
|
583
|
-
return _refreshPaymentMethodsInBackground.apply(this, arguments);
|
|
584
|
-
}
|
|
585
|
-
return refreshPaymentMethodsInBackground;
|
|
586
|
-
}()
|
|
587
|
-
/**
|
|
588
|
-
* 检查支付方式列表是否有变化
|
|
589
|
-
*/
|
|
590
|
-
)
|
|
591
|
-
}, {
|
|
592
|
-
key: "hasPaymentMethodsChanged",
|
|
593
|
-
value: function hasPaymentMethodsChanged(oldMethods, newMethods) {
|
|
594
|
-
if (oldMethods.length !== newMethods.length) {
|
|
595
|
-
return true;
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
// 创建旧数据的 Map 便于查找
|
|
599
|
-
var oldMethodsMap = new Map(oldMethods.map(function (method) {
|
|
600
|
-
return [method.id, method];
|
|
601
|
-
}));
|
|
602
|
-
|
|
603
|
-
// 检查每个新方法是否与旧方法相同
|
|
604
|
-
var _iterator5 = _createForOfIteratorHelper(newMethods),
|
|
605
|
-
_step5;
|
|
606
|
-
try {
|
|
607
|
-
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
608
|
-
var newMethod = _step5.value;
|
|
609
|
-
var oldMethod = oldMethodsMap.get(newMethod.id);
|
|
610
|
-
if (!oldMethod) {
|
|
611
|
-
return true; // 新增方法
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
// 检查关键字段是否有变化
|
|
615
|
-
if (oldMethod.code !== newMethod.code || oldMethod.name !== newMethod.name || oldMethod.type !== newMethod.type || oldMethod.description !== newMethod.description || oldMethod.status !== newMethod.status || oldMethod.disable !== newMethod.disable || oldMethod.is_surcharge !== newMethod.is_surcharge || oldMethod.fixed !== newMethod.fixed || oldMethod.percentage !== newMethod.percentage || oldMethod.enabled !== newMethod.enabled || JSON.stringify(oldMethod.channel_application || []) !== JSON.stringify(newMethod.channel_application || []) || JSON.stringify(oldMethod.companies || []) !== JSON.stringify(newMethod.companies || []) || JSON.stringify(oldMethod.metadata || {}) !== JSON.stringify(newMethod.metadata || {})) {
|
|
616
|
-
return true; // 方法属性有变化
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
} catch (err) {
|
|
620
|
-
_iterator5.e(err);
|
|
621
|
-
} finally {
|
|
622
|
-
_iterator5.f();
|
|
623
|
-
}
|
|
624
|
-
return false;
|
|
625
|
-
}
|
|
626
|
-
|
|
627
387
|
/**
|
|
628
388
|
* 获取订单列表
|
|
629
389
|
*/
|
|
390
|
+
/** @deprecated */
|
|
391
|
+
)
|
|
630
392
|
}, {
|
|
631
393
|
key: "getOrderListAsync",
|
|
632
394
|
value: (function () {
|
|
633
|
-
var _getOrderListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
634
|
-
return _regeneratorRuntime().wrap(function
|
|
635
|
-
while (1) switch (
|
|
395
|
+
var _getOrderListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
396
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
397
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
636
398
|
case 0:
|
|
637
|
-
|
|
638
|
-
|
|
399
|
+
_context4.prev = 0;
|
|
400
|
+
_context4.next = 3;
|
|
639
401
|
return this.dbManager.getAll('order');
|
|
640
402
|
case 3:
|
|
641
|
-
return
|
|
403
|
+
return _context4.abrupt("return", _context4.sent);
|
|
642
404
|
case 6:
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
console.error('[PaymentModule] 获取订单列表失败',
|
|
646
|
-
return
|
|
405
|
+
_context4.prev = 6;
|
|
406
|
+
_context4.t0 = _context4["catch"](0);
|
|
407
|
+
console.error('[PaymentModule] 获取订单列表失败', _context4.t0);
|
|
408
|
+
return _context4.abrupt("return", []);
|
|
647
409
|
case 10:
|
|
648
410
|
case "end":
|
|
649
|
-
return
|
|
411
|
+
return _context4.stop();
|
|
650
412
|
}
|
|
651
|
-
},
|
|
413
|
+
}, _callee4, this, [[0, 6]]);
|
|
652
414
|
}));
|
|
653
415
|
function getOrderListAsync() {
|
|
654
416
|
return _getOrderListAsync.apply(this, arguments);
|
|
@@ -662,27 +424,27 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
662
424
|
}, {
|
|
663
425
|
key: "getPaymentOrderByUuidAsync",
|
|
664
426
|
value: (function () {
|
|
665
|
-
var _getPaymentOrderByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
666
|
-
return _regeneratorRuntime().wrap(function
|
|
667
|
-
while (1) switch (
|
|
427
|
+
var _getPaymentOrderByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(orderUuid) {
|
|
428
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
429
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
668
430
|
case 0:
|
|
669
|
-
|
|
670
|
-
|
|
431
|
+
_context5.prev = 0;
|
|
432
|
+
_context5.next = 3;
|
|
671
433
|
return this.dbManager.get('order', orderUuid, true);
|
|
672
434
|
case 3:
|
|
673
|
-
return
|
|
435
|
+
return _context5.abrupt("return", _context5.sent);
|
|
674
436
|
case 6:
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
console.error('[PaymentModule] 获取支付订单失败',
|
|
678
|
-
return
|
|
437
|
+
_context5.prev = 6;
|
|
438
|
+
_context5.t0 = _context5["catch"](0);
|
|
439
|
+
console.error('[PaymentModule] 获取支付订单失败', _context5.t0);
|
|
440
|
+
return _context5.abrupt("return", null);
|
|
679
441
|
case 10:
|
|
680
442
|
case "end":
|
|
681
|
-
return
|
|
443
|
+
return _context5.stop();
|
|
682
444
|
}
|
|
683
|
-
},
|
|
445
|
+
}, _callee5, this, [[0, 6]]);
|
|
684
446
|
}));
|
|
685
|
-
function getPaymentOrderByUuidAsync(
|
|
447
|
+
function getPaymentOrderByUuidAsync(_x4) {
|
|
686
448
|
return _getPaymentOrderByUuidAsync.apply(this, arguments);
|
|
687
449
|
}
|
|
688
450
|
return getPaymentOrderByUuidAsync;
|
|
@@ -694,17 +456,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
694
456
|
}, {
|
|
695
457
|
key: "createPaymentOrderAsync",
|
|
696
458
|
value: (function () {
|
|
697
|
-
var _createPaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
459
|
+
var _createPaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
|
|
698
460
|
var _this4 = this;
|
|
699
461
|
var newOrder, currentTime, dbAddStartTime, dbAddDuration;
|
|
700
|
-
return _regeneratorRuntime().wrap(function
|
|
701
|
-
while (1) switch (
|
|
462
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
463
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
702
464
|
case 0:
|
|
703
465
|
this.logInfo('Starting createPaymentOrderAsync', {
|
|
704
466
|
orderId: params.order_id,
|
|
705
467
|
totalAmount: params.total_amount
|
|
706
468
|
});
|
|
707
|
-
|
|
469
|
+
_context6.prev = 1;
|
|
708
470
|
// 检测是否有重复的 order_id
|
|
709
471
|
// console.time('createLocalOrderAsync: getExistingOrder')
|
|
710
472
|
// const existingOrder = await this.dbManager.get('order', params.order_id);
|
|
@@ -790,7 +552,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
790
552
|
|
|
791
553
|
// 🚀 性能监控:记录数据库添加操作耗时
|
|
792
554
|
dbAddStartTime = Date.now();
|
|
793
|
-
|
|
555
|
+
_context6.next = 7;
|
|
794
556
|
return this.dbManager.add('order', newOrder, true);
|
|
795
557
|
case 7:
|
|
796
558
|
dbAddDuration = Date.now() - dbAddStartTime;
|
|
@@ -805,22 +567,22 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
805
567
|
setTimeout(function () {
|
|
806
568
|
_this4.core.effects.emit("".concat(_this4.name, ":onOrderAdded"), newOrder);
|
|
807
569
|
}, 0);
|
|
808
|
-
return
|
|
570
|
+
return _context6.abrupt("return", newOrder);
|
|
809
571
|
case 13:
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
console.error('[PaymentModule] 创建支付订单失败',
|
|
813
|
-
this.logError('createPaymentOrderAsync failed',
|
|
572
|
+
_context6.prev = 13;
|
|
573
|
+
_context6.t0 = _context6["catch"](1);
|
|
574
|
+
console.error('[PaymentModule] 创建支付订单失败', _context6.t0);
|
|
575
|
+
this.logError('createPaymentOrderAsync failed', _context6.t0, {
|
|
814
576
|
orderId: params.order_id
|
|
815
577
|
});
|
|
816
|
-
throw
|
|
578
|
+
throw _context6.t0;
|
|
817
579
|
case 18:
|
|
818
580
|
case "end":
|
|
819
|
-
return
|
|
581
|
+
return _context6.stop();
|
|
820
582
|
}
|
|
821
|
-
},
|
|
583
|
+
}, _callee6, this, [[1, 13]]);
|
|
822
584
|
}));
|
|
823
|
-
function createPaymentOrderAsync(
|
|
585
|
+
function createPaymentOrderAsync(_x5) {
|
|
824
586
|
return _createPaymentOrderAsync.apply(this, arguments);
|
|
825
587
|
}
|
|
826
588
|
return createPaymentOrderAsync;
|
|
@@ -832,40 +594,42 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
832
594
|
}, {
|
|
833
595
|
key: "deletePaymentOrderAsync",
|
|
834
596
|
value: (function () {
|
|
835
|
-
var _deletePaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
597
|
+
var _deletePaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(orderUuid) {
|
|
836
598
|
var order;
|
|
837
|
-
return _regeneratorRuntime().wrap(function
|
|
838
|
-
while (1) switch (
|
|
599
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
600
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
839
601
|
case 0:
|
|
840
|
-
|
|
841
|
-
|
|
602
|
+
_context7.prev = 0;
|
|
603
|
+
_context7.next = 3;
|
|
842
604
|
return this.dbManager.get('order', orderUuid);
|
|
843
605
|
case 3:
|
|
844
|
-
order =
|
|
606
|
+
order = _context7.sent;
|
|
845
607
|
if (!order) {
|
|
846
|
-
|
|
608
|
+
_context7.next = 10;
|
|
847
609
|
break;
|
|
848
610
|
}
|
|
849
|
-
|
|
611
|
+
_context7.next = 7;
|
|
850
612
|
return this.dbManager.delete('order', orderUuid);
|
|
851
613
|
case 7:
|
|
852
|
-
|
|
614
|
+
_context7.next = 9;
|
|
853
615
|
return this.core.effects.emit("".concat(this.name, ":onOrderDeleted"), order);
|
|
854
616
|
case 9:
|
|
855
|
-
|
|
617
|
+
console.log('[PaymentModule] 支付订单删除成功:', orderUuid);
|
|
618
|
+
case 10:
|
|
619
|
+
_context7.next = 16;
|
|
856
620
|
break;
|
|
857
|
-
case
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
console.error('[PaymentModule] 删除支付订单失败',
|
|
861
|
-
throw
|
|
862
|
-
case
|
|
621
|
+
case 12:
|
|
622
|
+
_context7.prev = 12;
|
|
623
|
+
_context7.t0 = _context7["catch"](0);
|
|
624
|
+
console.error('[PaymentModule] 删除支付订单失败', _context7.t0);
|
|
625
|
+
throw _context7.t0;
|
|
626
|
+
case 16:
|
|
863
627
|
case "end":
|
|
864
|
-
return
|
|
628
|
+
return _context7.stop();
|
|
865
629
|
}
|
|
866
|
-
},
|
|
630
|
+
}, _callee7, this, [[0, 12]]);
|
|
867
631
|
}));
|
|
868
|
-
function deletePaymentOrderAsync(
|
|
632
|
+
function deletePaymentOrderAsync(_x6) {
|
|
869
633
|
return _deletePaymentOrderAsync.apply(this, arguments);
|
|
870
634
|
}
|
|
871
635
|
return deletePaymentOrderAsync;
|
|
@@ -877,49 +641,49 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
877
641
|
}, {
|
|
878
642
|
key: "updateOrderAsync",
|
|
879
643
|
value: (function () {
|
|
880
|
-
var _updateOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
644
|
+
var _updateOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(orderUuid, params) {
|
|
881
645
|
var order, updatedOrder;
|
|
882
|
-
return _regeneratorRuntime().wrap(function
|
|
883
|
-
while (1) switch (
|
|
646
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
647
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
884
648
|
case 0:
|
|
885
|
-
|
|
886
|
-
|
|
649
|
+
_context8.prev = 0;
|
|
650
|
+
_context8.next = 3;
|
|
887
651
|
return this.dbManager.get('order', orderUuid);
|
|
888
652
|
case 3:
|
|
889
|
-
order =
|
|
653
|
+
order = _context8.sent;
|
|
890
654
|
if (!order) {
|
|
891
|
-
|
|
655
|
+
_context8.next = 13;
|
|
892
656
|
break;
|
|
893
657
|
}
|
|
894
658
|
updatedOrder = _objectSpread(_objectSpread({}, order), params);
|
|
895
659
|
this.recalculateOrderAmount(updatedOrder);
|
|
896
|
-
|
|
660
|
+
_context8.next = 9;
|
|
897
661
|
return this.dbManager.update('order', updatedOrder);
|
|
898
662
|
case 9:
|
|
899
|
-
|
|
663
|
+
_context8.next = 11;
|
|
900
664
|
return this.core.effects.emit("".concat(this.name, ":onOrderUpdated"), updatedOrder);
|
|
901
665
|
case 11:
|
|
902
|
-
|
|
666
|
+
_context8.next = 13;
|
|
903
667
|
return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
|
|
904
668
|
action: 'update',
|
|
905
669
|
order: updatedOrder,
|
|
906
670
|
originalOrder: order
|
|
907
671
|
});
|
|
908
672
|
case 13:
|
|
909
|
-
|
|
673
|
+
_context8.next = 19;
|
|
910
674
|
break;
|
|
911
675
|
case 15:
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
console.error('[PaymentModule] 更新订单失败',
|
|
915
|
-
throw
|
|
676
|
+
_context8.prev = 15;
|
|
677
|
+
_context8.t0 = _context8["catch"](0);
|
|
678
|
+
console.error('[PaymentModule] 更新订单失败', _context8.t0);
|
|
679
|
+
throw _context8.t0;
|
|
916
680
|
case 19:
|
|
917
681
|
case "end":
|
|
918
|
-
return
|
|
682
|
+
return _context8.stop();
|
|
919
683
|
}
|
|
920
|
-
},
|
|
684
|
+
}, _callee8, this, [[0, 15]]);
|
|
921
685
|
}));
|
|
922
|
-
function updateOrderAsync(
|
|
686
|
+
function updateOrderAsync(_x7, _x8) {
|
|
923
687
|
return _updateOrderAsync.apply(this, arguments);
|
|
924
688
|
}
|
|
925
689
|
return updateOrderAsync;
|
|
@@ -938,38 +702,38 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
938
702
|
}, {
|
|
939
703
|
key: "replaceOrderIdByUuidAsync",
|
|
940
704
|
value: (function () {
|
|
941
|
-
var _replaceOrderIdByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
705
|
+
var _replaceOrderIdByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(orderUuid, newOrderId) {
|
|
942
706
|
var existingOrder, allOrders, duplicateOrder, originalOrderId, updatedOrder;
|
|
943
|
-
return _regeneratorRuntime().wrap(function
|
|
944
|
-
while (1) switch (
|
|
707
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
708
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
945
709
|
case 0:
|
|
946
710
|
this.logInfo('Starting replaceOrderIdByUuidAsync', {
|
|
947
711
|
orderUuid: orderUuid,
|
|
948
712
|
newOrderId: newOrderId
|
|
949
713
|
});
|
|
950
|
-
|
|
951
|
-
|
|
714
|
+
_context9.prev = 1;
|
|
715
|
+
_context9.next = 4;
|
|
952
716
|
return this.dbManager.get('order', orderUuid);
|
|
953
717
|
case 4:
|
|
954
|
-
existingOrder =
|
|
718
|
+
existingOrder = _context9.sent;
|
|
955
719
|
if (existingOrder) {
|
|
956
|
-
|
|
720
|
+
_context9.next = 8;
|
|
957
721
|
break;
|
|
958
722
|
}
|
|
959
723
|
this.logWarning('Order not found for UUID replacement', {
|
|
960
724
|
orderUuid: orderUuid
|
|
961
725
|
});
|
|
962
|
-
return
|
|
726
|
+
return _context9.abrupt("return", null);
|
|
963
727
|
case 8:
|
|
964
|
-
|
|
728
|
+
_context9.next = 10;
|
|
965
729
|
return this.dbManager.getAll('order');
|
|
966
730
|
case 10:
|
|
967
|
-
allOrders =
|
|
731
|
+
allOrders = _context9.sent;
|
|
968
732
|
duplicateOrder = allOrders.find(function (order) {
|
|
969
733
|
return String(order.order_id) === String(newOrderId) && order.uuid !== orderUuid;
|
|
970
734
|
});
|
|
971
735
|
if (!duplicateOrder) {
|
|
972
|
-
|
|
736
|
+
_context9.next = 15;
|
|
973
737
|
break;
|
|
974
738
|
}
|
|
975
739
|
this.logWarning('New order ID already exists', {
|
|
@@ -991,13 +755,13 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
991
755
|
updated_at: new Date().toISOString()
|
|
992
756
|
})
|
|
993
757
|
}); // 更新到数据库
|
|
994
|
-
|
|
758
|
+
_context9.next = 19;
|
|
995
759
|
return this.dbManager.update('order', updatedOrder);
|
|
996
760
|
case 19:
|
|
997
|
-
|
|
761
|
+
_context9.next = 21;
|
|
998
762
|
return this.core.effects.emit("".concat(this.name, ":onOrderUpdated"), updatedOrder);
|
|
999
763
|
case 21:
|
|
1000
|
-
|
|
764
|
+
_context9.next = 23;
|
|
1001
765
|
return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
|
|
1002
766
|
action: 'order_id_replaced',
|
|
1003
767
|
order: updatedOrder,
|
|
@@ -1013,23 +777,24 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1013
777
|
originalOrderId: originalOrderId,
|
|
1014
778
|
newOrderId: newOrderId
|
|
1015
779
|
});
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
780
|
+
console.log("[PaymentModule] \u8BA2\u5355ID\u66FF\u6362\u6210\u529F: ".concat(originalOrderId, " \u2192 ").concat(newOrderId));
|
|
781
|
+
return _context9.abrupt("return", updatedOrder);
|
|
782
|
+
case 28:
|
|
783
|
+
_context9.prev = 28;
|
|
784
|
+
_context9.t0 = _context9["catch"](1);
|
|
785
|
+
console.error('[PaymentModule] 替换订单ID失败', _context9.t0);
|
|
786
|
+
this.logError('replaceOrderIdByUuidAsync failed', _context9.t0, {
|
|
1022
787
|
orderUuid: orderUuid,
|
|
1023
788
|
newOrderId: newOrderId
|
|
1024
789
|
});
|
|
1025
|
-
throw
|
|
1026
|
-
case
|
|
790
|
+
throw _context9.t0;
|
|
791
|
+
case 33:
|
|
1027
792
|
case "end":
|
|
1028
|
-
return
|
|
793
|
+
return _context9.stop();
|
|
1029
794
|
}
|
|
1030
|
-
},
|
|
795
|
+
}, _callee9, this, [[1, 28]]);
|
|
1031
796
|
}));
|
|
1032
|
-
function replaceOrderIdByUuidAsync(
|
|
797
|
+
function replaceOrderIdByUuidAsync(_x9, _x10) {
|
|
1033
798
|
return _replaceOrderIdByUuidAsync.apply(this, arguments);
|
|
1034
799
|
}
|
|
1035
800
|
return replaceOrderIdByUuidAsync;
|
|
@@ -1045,42 +810,42 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1045
810
|
}, {
|
|
1046
811
|
key: "getPaymentItemsAsync",
|
|
1047
812
|
value: (function () {
|
|
1048
|
-
var _getPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
813
|
+
var _getPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(orderUuid) {
|
|
1049
814
|
var includeVoided,
|
|
1050
815
|
order,
|
|
1051
816
|
allPayments,
|
|
1052
|
-
|
|
1053
|
-
return _regeneratorRuntime().wrap(function
|
|
1054
|
-
while (1) switch (
|
|
817
|
+
_args10 = arguments;
|
|
818
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
819
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1055
820
|
case 0:
|
|
1056
|
-
includeVoided =
|
|
821
|
+
includeVoided = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : false;
|
|
1057
822
|
if (orderUuid) {
|
|
1058
|
-
|
|
823
|
+
_context10.next = 3;
|
|
1059
824
|
break;
|
|
1060
825
|
}
|
|
1061
826
|
throw new Error('orderUuid is required');
|
|
1062
827
|
case 3:
|
|
1063
|
-
|
|
828
|
+
_context10.next = 5;
|
|
1064
829
|
return this.getPaymentOrderByUuidAsync(orderUuid);
|
|
1065
830
|
case 5:
|
|
1066
|
-
order =
|
|
831
|
+
order = _context10.sent;
|
|
1067
832
|
allPayments = (order === null || order === void 0 ? void 0 : order.payment) || [];
|
|
1068
833
|
if (!includeVoided) {
|
|
1069
|
-
|
|
834
|
+
_context10.next = 9;
|
|
1070
835
|
break;
|
|
1071
836
|
}
|
|
1072
|
-
return
|
|
837
|
+
return _context10.abrupt("return", allPayments);
|
|
1073
838
|
case 9:
|
|
1074
|
-
return
|
|
839
|
+
return _context10.abrupt("return", allPayments.filter(function (payment) {
|
|
1075
840
|
return payment.status !== 'voided';
|
|
1076
841
|
}));
|
|
1077
842
|
case 10:
|
|
1078
843
|
case "end":
|
|
1079
|
-
return
|
|
844
|
+
return _context10.stop();
|
|
1080
845
|
}
|
|
1081
|
-
},
|
|
846
|
+
}, _callee10, this);
|
|
1082
847
|
}));
|
|
1083
|
-
function getPaymentItemsAsync(
|
|
848
|
+
function getPaymentItemsAsync(_x11) {
|
|
1084
849
|
return _getPaymentItemsAsync.apply(this, arguments);
|
|
1085
850
|
}
|
|
1086
851
|
return getPaymentItemsAsync;
|
|
@@ -1095,18 +860,18 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1095
860
|
}, {
|
|
1096
861
|
key: "getAllPaymentItemsAsync",
|
|
1097
862
|
value: (function () {
|
|
1098
|
-
var _getAllPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1099
|
-
return _regeneratorRuntime().wrap(function
|
|
1100
|
-
while (1) switch (
|
|
863
|
+
var _getAllPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(orderUuid) {
|
|
864
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
865
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1101
866
|
case 0:
|
|
1102
|
-
return
|
|
867
|
+
return _context11.abrupt("return", this.getPaymentItemsAsync(orderUuid, true));
|
|
1103
868
|
case 1:
|
|
1104
869
|
case "end":
|
|
1105
|
-
return
|
|
870
|
+
return _context11.stop();
|
|
1106
871
|
}
|
|
1107
|
-
},
|
|
872
|
+
}, _callee11, this);
|
|
1108
873
|
}));
|
|
1109
|
-
function getAllPaymentItemsAsync(
|
|
874
|
+
function getAllPaymentItemsAsync(_x12) {
|
|
1110
875
|
return _getAllPaymentItemsAsync.apply(this, arguments);
|
|
1111
876
|
}
|
|
1112
877
|
return getAllPaymentItemsAsync;
|
|
@@ -1118,10 +883,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1118
883
|
}, {
|
|
1119
884
|
key: "addPaymentItemAsync",
|
|
1120
885
|
value: (function () {
|
|
1121
|
-
var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
886
|
+
var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(orderUuid, paymentItem) {
|
|
1122
887
|
var _paymentItem$metadata, _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, paidDepositAmount, expectedDepositAmount, warningMessage, paymentUuid, currentTime, newPaymentItem;
|
|
1123
|
-
return _regeneratorRuntime().wrap(function
|
|
1124
|
-
while (1) switch (
|
|
888
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
889
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1125
890
|
case 0:
|
|
1126
891
|
this.logInfo('Starting addPaymentItemAsync', {
|
|
1127
892
|
orderUuid: orderUuid,
|
|
@@ -1129,20 +894,20 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1129
894
|
paymentCode: paymentItem.code,
|
|
1130
895
|
orderPaymentType: paymentItem.order_payment_type
|
|
1131
896
|
});
|
|
1132
|
-
|
|
897
|
+
_context12.prev = 1;
|
|
1133
898
|
this.logInfo('准备获取订单', {
|
|
1134
899
|
orderUuid: orderUuid
|
|
1135
900
|
});
|
|
1136
|
-
|
|
901
|
+
_context12.next = 5;
|
|
1137
902
|
return this.getPaymentOrderByUuidAsync(orderUuid);
|
|
1138
903
|
case 5:
|
|
1139
|
-
order =
|
|
904
|
+
order = _context12.sent;
|
|
1140
905
|
this.logInfo('获取订单信息成功', {
|
|
1141
906
|
orderUuid: orderUuid,
|
|
1142
907
|
order: order
|
|
1143
908
|
});
|
|
1144
909
|
if (order) {
|
|
1145
|
-
|
|
910
|
+
_context12.next = 9;
|
|
1146
911
|
break;
|
|
1147
912
|
}
|
|
1148
913
|
throw new Error("Order not found: ".concat(orderUuid));
|
|
@@ -1157,7 +922,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1157
922
|
}, new Decimal(0));
|
|
1158
923
|
expectedDepositAmount = new Decimal(order.deposit_amount || '0').sub(paidDepositAmount); // 有一种特殊情况,订单金额为 0,但是定金金额>0,且此时是定金状态的,允许添加支付项
|
|
1159
924
|
if (!(expectAmount.lte(0) && expectedDepositAmount.eq(0))) {
|
|
1160
|
-
|
|
925
|
+
_context12.next = 17;
|
|
1161
926
|
break;
|
|
1162
927
|
}
|
|
1163
928
|
warningMessage = "\u8BA2\u5355 ".concat(orderUuid, " \u5F85\u4ED8\u91D1\u989D\u5DF2\u4E3A0\uFF0C\u4E0D\u5141\u8BB8\u6DFB\u52A0\u65B0\u7684\u652F\u4ED8\u9879");
|
|
@@ -1183,12 +948,14 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1183
948
|
currentTime = formatDateTime(new Date());
|
|
1184
949
|
newPaymentItem = {
|
|
1185
950
|
uuid: paymentUuid,
|
|
1186
|
-
custom_payment_id: paymentItem
|
|
951
|
+
custom_payment_id: normalizeCustomPaymentId(paymentItem),
|
|
1187
952
|
name: paymentItem.name,
|
|
1188
953
|
code: paymentItem.code,
|
|
1189
954
|
type: paymentItem.type,
|
|
1190
955
|
amount: formatAmount(paymentItem.amount),
|
|
1191
956
|
voucher_id: paymentItem.voucher_id || '',
|
|
957
|
+
wallet_pass_usage_unit: paymentItem.wallet_pass_usage_unit,
|
|
958
|
+
wallet_pass_use_value: paymentItem.wallet_pass_use_value,
|
|
1192
959
|
rounding_amount: paymentItem.rounding_amount || '0.00',
|
|
1193
960
|
service_charge: paymentItem.service_charge,
|
|
1194
961
|
status: 'active',
|
|
@@ -1199,8 +966,6 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1199
966
|
// 创建时间
|
|
1200
967
|
updated_at: currentTime,
|
|
1201
968
|
// 更新时间
|
|
1202
|
-
wallet_pass_usage_unit: paymentItem === null || paymentItem === void 0 ? void 0 : paymentItem.wallet_pass_usage_unit,
|
|
1203
|
-
wallet_pass_use_value: paymentItem === null || paymentItem === void 0 ? void 0 : paymentItem.wallet_pass_use_value,
|
|
1204
969
|
metadata: _objectSpread(_objectSpread({}, paymentItem.metadata), {}, {
|
|
1205
970
|
// 保留传入的所有 metadata 字段
|
|
1206
971
|
unique_payment_number: paymentUuid // 设置唯一支付号为支付项的 uuid
|
|
@@ -1212,7 +977,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1212
977
|
orderUuid: orderUuid,
|
|
1213
978
|
order: order
|
|
1214
979
|
});
|
|
1215
|
-
|
|
980
|
+
_context12.next = 25;
|
|
1216
981
|
return this.dbManager.update('order', order, true);
|
|
1217
982
|
case 25:
|
|
1218
983
|
this.logInfo('更新订单支付项完成', {
|
|
@@ -1235,24 +1000,24 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1235
1000
|
actualPaidAmount: (_newPaymentItem$metad2 = newPaymentItem.metadata) === null || _newPaymentItem$metad2 === void 0 ? void 0 : _newPaymentItem$metad2.actual_paid_amount,
|
|
1236
1001
|
changeGivenAmount: (_newPaymentItem$metad3 = newPaymentItem.metadata) === null || _newPaymentItem$metad3 === void 0 ? void 0 : _newPaymentItem$metad3.change_given_amount
|
|
1237
1002
|
});
|
|
1238
|
-
|
|
1003
|
+
_context12.next = 35;
|
|
1239
1004
|
break;
|
|
1240
1005
|
case 30:
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
console.error('[PaymentModule] 添加支付项失败',
|
|
1244
|
-
this.logError('addPaymentItemAsync failed',
|
|
1006
|
+
_context12.prev = 30;
|
|
1007
|
+
_context12.t0 = _context12["catch"](1);
|
|
1008
|
+
console.error('[PaymentModule] 添加支付项失败', _context12.t0);
|
|
1009
|
+
this.logError('addPaymentItemAsync failed', _context12.t0, {
|
|
1245
1010
|
orderUuid: orderUuid,
|
|
1246
1011
|
paymentItem: paymentItem
|
|
1247
1012
|
});
|
|
1248
|
-
throw
|
|
1013
|
+
throw _context12.t0;
|
|
1249
1014
|
case 35:
|
|
1250
1015
|
case "end":
|
|
1251
|
-
return
|
|
1016
|
+
return _context12.stop();
|
|
1252
1017
|
}
|
|
1253
|
-
},
|
|
1018
|
+
}, _callee12, this, [[1, 30]]);
|
|
1254
1019
|
}));
|
|
1255
|
-
function addPaymentItemAsync(
|
|
1020
|
+
function addPaymentItemAsync(_x13, _x14) {
|
|
1256
1021
|
return _addPaymentItemAsync.apply(this, arguments);
|
|
1257
1022
|
}
|
|
1258
1023
|
return addPaymentItemAsync;
|
|
@@ -1264,22 +1029,22 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1264
1029
|
}, {
|
|
1265
1030
|
key: "deletePaymentAsync",
|
|
1266
1031
|
value: (function () {
|
|
1267
|
-
var _deletePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1032
|
+
var _deletePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderUuid, paymentUuid) {
|
|
1268
1033
|
var order, paymentItem;
|
|
1269
|
-
return _regeneratorRuntime().wrap(function
|
|
1270
|
-
while (1) switch (
|
|
1034
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1035
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1271
1036
|
case 0:
|
|
1272
1037
|
this.logInfo('Starting deletePaymentAsync (mark as voided)', {
|
|
1273
1038
|
orderUuid: orderUuid,
|
|
1274
1039
|
paymentUuid: paymentUuid
|
|
1275
1040
|
});
|
|
1276
|
-
|
|
1277
|
-
|
|
1041
|
+
_context13.prev = 1;
|
|
1042
|
+
_context13.next = 4;
|
|
1278
1043
|
return this.dbManager.get('order', orderUuid);
|
|
1279
1044
|
case 4:
|
|
1280
|
-
order =
|
|
1045
|
+
order = _context13.sent;
|
|
1281
1046
|
if (order) {
|
|
1282
|
-
|
|
1047
|
+
_context13.next = 7;
|
|
1283
1048
|
break;
|
|
1284
1049
|
}
|
|
1285
1050
|
throw new Error('订单不存在');
|
|
@@ -1288,67 +1053,73 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1288
1053
|
return payment.uuid === paymentUuid;
|
|
1289
1054
|
});
|
|
1290
1055
|
if (paymentItem) {
|
|
1291
|
-
|
|
1056
|
+
_context13.next = 10;
|
|
1292
1057
|
break;
|
|
1293
1058
|
}
|
|
1294
1059
|
throw new Error("\u652F\u4ED8\u9879\u4E0D\u5B58\u5728: ".concat(paymentUuid));
|
|
1295
1060
|
case 10:
|
|
1296
1061
|
if (!(paymentItem.status === 'voided')) {
|
|
1297
|
-
|
|
1062
|
+
_context13.next = 13;
|
|
1298
1063
|
break;
|
|
1299
1064
|
}
|
|
1300
1065
|
console.warn("[PaymentModule] \u652F\u4ED8\u9879 ".concat(paymentUuid, " \u5DF2\u7ECF\u88AB\u5220\u9664\uFF0C\u8DF3\u8FC7\u64CD\u4F5C"));
|
|
1301
|
-
return
|
|
1066
|
+
return _context13.abrupt("return");
|
|
1302
1067
|
case 13:
|
|
1303
1068
|
// 标记删除而不是物理删除
|
|
1304
1069
|
paymentItem.status = 'voided';
|
|
1305
1070
|
paymentItem.origin_amount = paymentItem.amount; // 保存原始金额
|
|
1306
1071
|
paymentItem.amount = '0.00'; // 将金额设为0,不参与订单金额计算
|
|
1307
1072
|
|
|
1073
|
+
console.log("[PaymentModule] \u652F\u4ED8\u9879\u6807\u8BB0\u4E3A\u5220\u9664:", {
|
|
1074
|
+
uuid: paymentItem.uuid,
|
|
1075
|
+
originalAmount: paymentItem.origin_amount,
|
|
1076
|
+
status: paymentItem.status
|
|
1077
|
+
});
|
|
1078
|
+
|
|
1308
1079
|
// 重新计算待付金额
|
|
1309
1080
|
this.recalculateOrderAmount(order);
|
|
1310
1081
|
|
|
1311
1082
|
// 更新到 IndexDB
|
|
1312
|
-
|
|
1083
|
+
_context13.next = 20;
|
|
1313
1084
|
return this.dbManager.update('order', order);
|
|
1314
|
-
case
|
|
1315
|
-
|
|
1085
|
+
case 20:
|
|
1086
|
+
_context13.next = 22;
|
|
1316
1087
|
return this.core.effects.emit("".concat(this.name, ":onPaymentDeleted"), {
|
|
1317
1088
|
order: order,
|
|
1318
1089
|
paymentItem: paymentItem
|
|
1319
1090
|
});
|
|
1320
|
-
case
|
|
1321
|
-
|
|
1091
|
+
case 22:
|
|
1092
|
+
_context13.next = 24;
|
|
1322
1093
|
return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
|
|
1323
1094
|
action: 'payment_delete',
|
|
1324
1095
|
order: order,
|
|
1325
1096
|
paymentItem: paymentItem
|
|
1326
1097
|
});
|
|
1327
|
-
case
|
|
1098
|
+
case 24:
|
|
1328
1099
|
this.logInfo('deletePaymentAsync completed successfully (marked as voided)', {
|
|
1329
1100
|
orderUuid: orderUuid,
|
|
1330
1101
|
paymentUuid: paymentUuid,
|
|
1331
1102
|
originalAmount: paymentItem.origin_amount,
|
|
1332
1103
|
newExpectAmount: order.expect_amount
|
|
1333
1104
|
});
|
|
1334
|
-
|
|
1105
|
+
_context13.next = 32;
|
|
1335
1106
|
break;
|
|
1336
|
-
case
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
console.error('[PaymentModule] 删除支付项失败',
|
|
1340
|
-
this.logError('deletePaymentAsync failed',
|
|
1107
|
+
case 27:
|
|
1108
|
+
_context13.prev = 27;
|
|
1109
|
+
_context13.t0 = _context13["catch"](1);
|
|
1110
|
+
console.error('[PaymentModule] 删除支付项失败', _context13.t0);
|
|
1111
|
+
this.logError('deletePaymentAsync failed', _context13.t0, {
|
|
1341
1112
|
orderUuid: orderUuid,
|
|
1342
1113
|
paymentUuid: paymentUuid
|
|
1343
1114
|
});
|
|
1344
|
-
throw
|
|
1345
|
-
case
|
|
1115
|
+
throw _context13.t0;
|
|
1116
|
+
case 32:
|
|
1346
1117
|
case "end":
|
|
1347
|
-
return
|
|
1118
|
+
return _context13.stop();
|
|
1348
1119
|
}
|
|
1349
|
-
},
|
|
1120
|
+
}, _callee13, this, [[1, 27]]);
|
|
1350
1121
|
}));
|
|
1351
|
-
function deletePaymentAsync(
|
|
1122
|
+
function deletePaymentAsync(_x15, _x16) {
|
|
1352
1123
|
return _deletePaymentAsync.apply(this, arguments);
|
|
1353
1124
|
}
|
|
1354
1125
|
return deletePaymentAsync;
|
|
@@ -1363,15 +1134,15 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1363
1134
|
}, {
|
|
1364
1135
|
key: "updateVoucherPaymentItemsAsync",
|
|
1365
1136
|
value: (function () {
|
|
1366
|
-
var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1137
|
+
var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(orderUuid, voucherPaymentItems) {
|
|
1367
1138
|
var _this5 = this;
|
|
1368
|
-
return _regeneratorRuntime().wrap(function
|
|
1369
|
-
while (1) switch (
|
|
1139
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1140
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1370
1141
|
case 0:
|
|
1371
|
-
return
|
|
1372
|
-
var _this5$normalizeVouch, normalizedVoucherItems, originalCount, normalizedCount, order, existingVoucherItems,
|
|
1373
|
-
return _regeneratorRuntime().wrap(function
|
|
1374
|
-
while (1) switch (
|
|
1142
|
+
return _context15.abrupt("return", this.runVoucherUpdateLocked(orderUuid, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
1143
|
+
var _this5$normalizeVouch, normalizedVoucherItems, originalCount, normalizedCount, order, existingVoucherItems, _iterator2, _step2, voucherItem, orderAfterDelete, existingActiveVoucherKeys, _iterator3, _step3, _voucherItem, orderPaymentType, key, updatedOrder;
|
|
1144
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1145
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1375
1146
|
case 0:
|
|
1376
1147
|
_this5$normalizeVouch = _this5.normalizeVoucherPaymentItems(voucherPaymentItems), normalizedVoucherItems = _this5$normalizeVouch.items, originalCount = _this5$normalizeVouch.originalCount, normalizedCount = _this5$normalizeVouch.normalizedCount;
|
|
1377
1148
|
_this5.logInfo('Starting updateVoucherPaymentItemsAsync', {
|
|
@@ -1394,13 +1165,13 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1394
1165
|
normalizedCount: normalizedCount
|
|
1395
1166
|
});
|
|
1396
1167
|
}
|
|
1397
|
-
|
|
1398
|
-
|
|
1168
|
+
_context14.prev = 3;
|
|
1169
|
+
_context14.next = 6;
|
|
1399
1170
|
return _this5.getPaymentOrderByUuidAsync(orderUuid);
|
|
1400
1171
|
case 6:
|
|
1401
|
-
order =
|
|
1172
|
+
order = _context14.sent;
|
|
1402
1173
|
if (order) {
|
|
1403
|
-
|
|
1174
|
+
_context14.next = 9;
|
|
1404
1175
|
break;
|
|
1405
1176
|
}
|
|
1406
1177
|
throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728: ".concat(orderUuid));
|
|
@@ -1410,61 +1181,80 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1410
1181
|
existingVoucherItems = order.payment.filter(function (payment) {
|
|
1411
1182
|
return payment.voucher_id && payment.status !== 'voided' && !payment.isSynced;
|
|
1412
1183
|
});
|
|
1184
|
+
console.log('[PaymentModule] 发现现有代金券支付项:', {
|
|
1185
|
+
orderUuid: orderUuid,
|
|
1186
|
+
existingVoucherCount: existingVoucherItems.length,
|
|
1187
|
+
existingItems: existingVoucherItems.map(function (item) {
|
|
1188
|
+
return {
|
|
1189
|
+
uuid: item.uuid,
|
|
1190
|
+
code: item.code,
|
|
1191
|
+
amount: item.amount,
|
|
1192
|
+
voucher_id: item.voucher_id,
|
|
1193
|
+
isSynced: item.isSynced
|
|
1194
|
+
};
|
|
1195
|
+
})
|
|
1196
|
+
});
|
|
1197
|
+
|
|
1413
1198
|
// 2. 删除所有现有的代金券支付项(仅删除未同步的)
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
case
|
|
1418
|
-
if ((
|
|
1419
|
-
|
|
1199
|
+
_iterator2 = _createForOfIteratorHelper(existingVoucherItems);
|
|
1200
|
+
_context14.prev = 12;
|
|
1201
|
+
_iterator2.s();
|
|
1202
|
+
case 14:
|
|
1203
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
1204
|
+
_context14.next = 21;
|
|
1420
1205
|
break;
|
|
1421
1206
|
}
|
|
1422
|
-
voucherItem =
|
|
1423
|
-
|
|
1207
|
+
voucherItem = _step2.value;
|
|
1208
|
+
console.log("[PaymentModule] \u5220\u9664\u73B0\u6709\u4EE3\u91D1\u5238\u652F\u4ED8\u9879: ".concat(voucherItem.uuid));
|
|
1209
|
+
_context14.next = 19;
|
|
1424
1210
|
return _this5.deletePaymentAsync(orderUuid, voucherItem.uuid);
|
|
1425
|
-
case 17:
|
|
1426
|
-
_context16.next = 13;
|
|
1427
|
-
break;
|
|
1428
1211
|
case 19:
|
|
1429
|
-
|
|
1212
|
+
_context14.next = 14;
|
|
1430
1213
|
break;
|
|
1431
1214
|
case 21:
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
return
|
|
1215
|
+
_context14.next = 26;
|
|
1216
|
+
break;
|
|
1217
|
+
case 23:
|
|
1218
|
+
_context14.prev = 23;
|
|
1219
|
+
_context14.t0 = _context14["catch"](12);
|
|
1220
|
+
_iterator2.e(_context14.t0);
|
|
1221
|
+
case 26:
|
|
1222
|
+
_context14.prev = 26;
|
|
1223
|
+
_iterator2.f();
|
|
1224
|
+
return _context14.finish(26);
|
|
1442
1225
|
case 29:
|
|
1443
|
-
|
|
1226
|
+
_context14.next = 31;
|
|
1227
|
+
return _this5.getPaymentOrderByUuidAsync(orderUuid);
|
|
1228
|
+
case 31:
|
|
1229
|
+
orderAfterDelete = _context14.sent;
|
|
1444
1230
|
if (orderAfterDelete) {
|
|
1445
|
-
|
|
1231
|
+
_context14.next = 34;
|
|
1446
1232
|
break;
|
|
1447
1233
|
}
|
|
1448
1234
|
throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728: ".concat(orderUuid));
|
|
1449
|
-
case
|
|
1235
|
+
case 34:
|
|
1450
1236
|
existingActiveVoucherKeys = new Set(orderAfterDelete.payment.filter(function (p) {
|
|
1451
1237
|
return p.voucher_id && p.status !== 'voided' && !p.isSynced;
|
|
1452
1238
|
}).map(function (p) {
|
|
1453
1239
|
return "".concat(p.voucher_id, "|").concat(p.order_payment_type || 'normal');
|
|
1454
1240
|
}));
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1241
|
+
console.log('[PaymentModule] 添加新的代金券支付项:', {
|
|
1242
|
+
orderUuid: orderUuid,
|
|
1243
|
+
newItemCount: normalizedVoucherItems.length
|
|
1244
|
+
});
|
|
1245
|
+
_iterator3 = _createForOfIteratorHelper(normalizedVoucherItems);
|
|
1246
|
+
_context14.prev = 37;
|
|
1247
|
+
_iterator3.s();
|
|
1248
|
+
case 39:
|
|
1249
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
1250
|
+
_context14.next = 52;
|
|
1461
1251
|
break;
|
|
1462
1252
|
}
|
|
1463
|
-
_voucherItem =
|
|
1253
|
+
_voucherItem = _step3.value;
|
|
1464
1254
|
orderPaymentType = _voucherItem.order_payment_type || 'normal';
|
|
1465
1255
|
key = "".concat(_voucherItem.voucher_id, "|").concat(orderPaymentType);
|
|
1466
1256
|
if (!existingActiveVoucherKeys.has(key)) {
|
|
1467
|
-
|
|
1257
|
+
_context14.next = 46;
|
|
1468
1258
|
break;
|
|
1469
1259
|
}
|
|
1470
1260
|
console.warn('[PaymentModule] Skip adding voucher payment item because it already exists (active)', {
|
|
@@ -1472,68 +1262,74 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1472
1262
|
voucher_id: _voucherItem.voucher_id,
|
|
1473
1263
|
order_payment_type: orderPaymentType
|
|
1474
1264
|
});
|
|
1475
|
-
return
|
|
1476
|
-
case
|
|
1477
|
-
|
|
1265
|
+
return _context14.abrupt("continue", 50);
|
|
1266
|
+
case 46:
|
|
1267
|
+
console.log("[PaymentModule] \u6DFB\u52A0\u4EE3\u91D1\u5238\u652F\u4ED8\u9879:", _objectSpread(_objectSpread({}, _voucherItem), {}, {
|
|
1268
|
+
code: _voucherItem.code,
|
|
1269
|
+
amount: _voucherItem.amount,
|
|
1270
|
+
voucher_id: _voucherItem.voucher_id,
|
|
1271
|
+
order_payment_type: orderPaymentType
|
|
1272
|
+
}));
|
|
1273
|
+
_context14.next = 49;
|
|
1478
1274
|
return _this5.addPaymentItemAsync(orderUuid, _voucherItem);
|
|
1479
|
-
case
|
|
1275
|
+
case 49:
|
|
1480
1276
|
existingActiveVoucherKeys.add(key);
|
|
1481
|
-
case
|
|
1482
|
-
|
|
1277
|
+
case 50:
|
|
1278
|
+
_context14.next = 39;
|
|
1483
1279
|
break;
|
|
1484
|
-
case
|
|
1485
|
-
|
|
1280
|
+
case 52:
|
|
1281
|
+
_context14.next = 57;
|
|
1486
1282
|
break;
|
|
1487
|
-
case
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
case
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
return
|
|
1495
|
-
case
|
|
1496
|
-
|
|
1283
|
+
case 54:
|
|
1284
|
+
_context14.prev = 54;
|
|
1285
|
+
_context14.t1 = _context14["catch"](37);
|
|
1286
|
+
_iterator3.e(_context14.t1);
|
|
1287
|
+
case 57:
|
|
1288
|
+
_context14.prev = 57;
|
|
1289
|
+
_iterator3.f();
|
|
1290
|
+
return _context14.finish(57);
|
|
1291
|
+
case 60:
|
|
1292
|
+
_context14.next = 62;
|
|
1497
1293
|
return _this5.getPaymentOrderByUuidAsync(orderUuid);
|
|
1498
|
-
case
|
|
1499
|
-
updatedOrder =
|
|
1500
|
-
|
|
1294
|
+
case 62:
|
|
1295
|
+
updatedOrder = _context14.sent;
|
|
1296
|
+
_context14.next = 65;
|
|
1501
1297
|
return _this5.core.effects.emit("".concat(_this5.name, ":onPaymentAdded"), {
|
|
1502
1298
|
orderUuid: orderUuid,
|
|
1503
1299
|
order: updatedOrder,
|
|
1504
1300
|
payment: null // 批量操作不提供单个支付项
|
|
1505
1301
|
});
|
|
1506
|
-
case
|
|
1302
|
+
case 65:
|
|
1507
1303
|
_this5.logInfo('updateVoucherPaymentItemsAsync completed successfully', {
|
|
1508
1304
|
orderUuid: orderUuid,
|
|
1509
1305
|
removedVoucherCount: existingVoucherItems.length,
|
|
1510
1306
|
addedVoucherCount: normalizedVoucherItems.length,
|
|
1511
1307
|
finalExpectAmount: updatedOrder === null || updatedOrder === void 0 ? void 0 : updatedOrder.expect_amount
|
|
1512
1308
|
});
|
|
1513
|
-
|
|
1309
|
+
_context14.next = 73;
|
|
1514
1310
|
break;
|
|
1515
|
-
case
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
console.error('[PaymentModule] 批量更新代金券支付项失败:',
|
|
1519
|
-
_this5.logError('updateVoucherPaymentItemsAsync failed',
|
|
1311
|
+
case 68:
|
|
1312
|
+
_context14.prev = 68;
|
|
1313
|
+
_context14.t2 = _context14["catch"](3);
|
|
1314
|
+
console.error('[PaymentModule] 批量更新代金券支付项失败:', _context14.t2);
|
|
1315
|
+
_this5.logError('updateVoucherPaymentItemsAsync failed', _context14.t2, {
|
|
1520
1316
|
orderUuid: orderUuid,
|
|
1521
1317
|
voucherPaymentItems: voucherPaymentItems
|
|
1522
1318
|
});
|
|
1523
|
-
throw
|
|
1524
|
-
case
|
|
1319
|
+
throw _context14.t2;
|
|
1320
|
+
case 73:
|
|
1525
1321
|
case "end":
|
|
1526
|
-
return
|
|
1322
|
+
return _context14.stop();
|
|
1527
1323
|
}
|
|
1528
|
-
},
|
|
1324
|
+
}, _callee14, null, [[3, 68], [12, 23, 26, 29], [37, 54, 57, 60]]);
|
|
1529
1325
|
}))));
|
|
1530
1326
|
case 1:
|
|
1531
1327
|
case "end":
|
|
1532
|
-
return
|
|
1328
|
+
return _context15.stop();
|
|
1533
1329
|
}
|
|
1534
|
-
},
|
|
1330
|
+
}, _callee15, this);
|
|
1535
1331
|
}));
|
|
1536
|
-
function updateVoucherPaymentItemsAsync(
|
|
1332
|
+
function updateVoucherPaymentItemsAsync(_x17, _x18) {
|
|
1537
1333
|
return _updateVoucherPaymentItemsAsync.apply(this, arguments);
|
|
1538
1334
|
}
|
|
1539
1335
|
return updateVoucherPaymentItemsAsync;
|
|
@@ -1545,18 +1341,18 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1545
1341
|
}, {
|
|
1546
1342
|
key: "updatePaymentAsync",
|
|
1547
1343
|
value: (function () {
|
|
1548
|
-
var _updatePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1344
|
+
var _updatePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(orderUuid, paymentUuid, params) {
|
|
1549
1345
|
var order, paymentItem, formattedParams;
|
|
1550
|
-
return _regeneratorRuntime().wrap(function
|
|
1551
|
-
while (1) switch (
|
|
1346
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1347
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1552
1348
|
case 0:
|
|
1553
|
-
|
|
1554
|
-
|
|
1349
|
+
_context16.prev = 0;
|
|
1350
|
+
_context16.next = 3;
|
|
1555
1351
|
return this.dbManager.get('order', orderUuid);
|
|
1556
1352
|
case 3:
|
|
1557
|
-
order =
|
|
1353
|
+
order = _context16.sent;
|
|
1558
1354
|
if (order) {
|
|
1559
|
-
|
|
1355
|
+
_context16.next = 6;
|
|
1560
1356
|
break;
|
|
1561
1357
|
}
|
|
1562
1358
|
throw new Error('订单不存在');
|
|
@@ -1565,7 +1361,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1565
1361
|
return payment.uuid === paymentUuid;
|
|
1566
1362
|
});
|
|
1567
1363
|
if (!paymentItem) {
|
|
1568
|
-
|
|
1364
|
+
_context16.next = 18;
|
|
1569
1365
|
break;
|
|
1570
1366
|
}
|
|
1571
1367
|
// 如果更新参数中包含 amount,先格式化
|
|
@@ -1579,36 +1375,36 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1579
1375
|
this.recalculateOrderAmount(order);
|
|
1580
1376
|
|
|
1581
1377
|
// 更新到 IndexDB
|
|
1582
|
-
|
|
1378
|
+
_context16.next = 14;
|
|
1583
1379
|
return this.dbManager.update('order', order);
|
|
1584
1380
|
case 14:
|
|
1585
|
-
|
|
1381
|
+
_context16.next = 16;
|
|
1586
1382
|
return this.core.effects.emit("".concat(this.name, ":onPaymentUpdated"), {
|
|
1587
1383
|
order: order,
|
|
1588
1384
|
paymentItem: paymentItem
|
|
1589
1385
|
});
|
|
1590
1386
|
case 16:
|
|
1591
|
-
|
|
1387
|
+
_context16.next = 18;
|
|
1592
1388
|
return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
|
|
1593
1389
|
action: 'payment_update',
|
|
1594
1390
|
order: order,
|
|
1595
1391
|
paymentItem: paymentItem
|
|
1596
1392
|
});
|
|
1597
1393
|
case 18:
|
|
1598
|
-
|
|
1394
|
+
_context16.next = 24;
|
|
1599
1395
|
break;
|
|
1600
1396
|
case 20:
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
console.error('[PaymentModule] 更新支付项失败',
|
|
1604
|
-
throw
|
|
1397
|
+
_context16.prev = 20;
|
|
1398
|
+
_context16.t0 = _context16["catch"](0);
|
|
1399
|
+
console.error('[PaymentModule] 更新支付项失败', _context16.t0);
|
|
1400
|
+
throw _context16.t0;
|
|
1605
1401
|
case 24:
|
|
1606
1402
|
case "end":
|
|
1607
|
-
return
|
|
1403
|
+
return _context16.stop();
|
|
1608
1404
|
}
|
|
1609
|
-
},
|
|
1405
|
+
}, _callee16, this, [[0, 20]]);
|
|
1610
1406
|
}));
|
|
1611
|
-
function updatePaymentAsync(
|
|
1407
|
+
function updatePaymentAsync(_x19, _x20, _x21) {
|
|
1612
1408
|
return _updatePaymentAsync.apply(this, arguments);
|
|
1613
1409
|
}
|
|
1614
1410
|
return updatePaymentAsync;
|
|
@@ -1620,61 +1416,61 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1620
1416
|
}, {
|
|
1621
1417
|
key: "submitPayAsync",
|
|
1622
1418
|
value: (function () {
|
|
1623
|
-
var _submitPayAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1624
|
-
var orderToSubmit, order, allOrders,
|
|
1625
|
-
return _regeneratorRuntime().wrap(function
|
|
1626
|
-
while (1) switch (
|
|
1419
|
+
var _submitPayAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(orderUuid) {
|
|
1420
|
+
var orderToSubmit, order, allOrders, _iterator4, _step4, _order, result;
|
|
1421
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1422
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1627
1423
|
case 0:
|
|
1628
1424
|
this.logInfo('Starting submitPayAsync', {
|
|
1629
1425
|
orderUuid: orderUuid
|
|
1630
1426
|
});
|
|
1631
|
-
|
|
1427
|
+
_context17.prev = 1;
|
|
1632
1428
|
if (!orderUuid) {
|
|
1633
|
-
|
|
1429
|
+
_context17.next = 9;
|
|
1634
1430
|
break;
|
|
1635
1431
|
}
|
|
1636
|
-
|
|
1432
|
+
_context17.next = 5;
|
|
1637
1433
|
return this.dbManager.get('order', orderUuid);
|
|
1638
1434
|
case 5:
|
|
1639
|
-
order =
|
|
1435
|
+
order = _context17.sent;
|
|
1640
1436
|
orderToSubmit = order ? [order] : [];
|
|
1641
|
-
|
|
1437
|
+
_context17.next = 13;
|
|
1642
1438
|
break;
|
|
1643
1439
|
case 9:
|
|
1644
|
-
|
|
1440
|
+
_context17.next = 11;
|
|
1645
1441
|
return this.dbManager.getAll('order');
|
|
1646
1442
|
case 11:
|
|
1647
|
-
allOrders =
|
|
1443
|
+
allOrders = _context17.sent;
|
|
1648
1444
|
// 包括正在处理中的订单和部分支付的订单(可能添加了新的支付项)
|
|
1649
1445
|
orderToSubmit = allOrders.filter(function (order) {
|
|
1650
1446
|
return order.payment_status === PaymentStatus.Processing || order.payment_status === PaymentStatus.PartiallyPaid;
|
|
1651
1447
|
});
|
|
1652
1448
|
case 13:
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1449
|
+
_iterator4 = _createForOfIteratorHelper(orderToSubmit);
|
|
1450
|
+
_context17.prev = 14;
|
|
1451
|
+
_iterator4.s();
|
|
1656
1452
|
case 16:
|
|
1657
|
-
if ((
|
|
1658
|
-
|
|
1453
|
+
if ((_step4 = _iterator4.n()).done) {
|
|
1454
|
+
_context17.next = 22;
|
|
1659
1455
|
break;
|
|
1660
1456
|
}
|
|
1661
|
-
_order =
|
|
1662
|
-
|
|
1457
|
+
_order = _step4.value;
|
|
1458
|
+
_context17.next = 20;
|
|
1663
1459
|
return this.submitSingleOrderPayment(_order);
|
|
1664
1460
|
case 20:
|
|
1665
|
-
|
|
1461
|
+
_context17.next = 16;
|
|
1666
1462
|
break;
|
|
1667
1463
|
case 22:
|
|
1668
|
-
|
|
1464
|
+
_context17.next = 27;
|
|
1669
1465
|
break;
|
|
1670
1466
|
case 24:
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1467
|
+
_context17.prev = 24;
|
|
1468
|
+
_context17.t0 = _context17["catch"](14);
|
|
1469
|
+
_iterator4.e(_context17.t0);
|
|
1674
1470
|
case 27:
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
return
|
|
1471
|
+
_context17.prev = 27;
|
|
1472
|
+
_iterator4.f();
|
|
1473
|
+
return _context17.finish(27);
|
|
1678
1474
|
case 30:
|
|
1679
1475
|
result = {
|
|
1680
1476
|
status: 'success'
|
|
@@ -1683,24 +1479,24 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1683
1479
|
result: result.status,
|
|
1684
1480
|
processedOrdersCount: orderToSubmit.length
|
|
1685
1481
|
});
|
|
1686
|
-
return
|
|
1482
|
+
return _context17.abrupt("return", result);
|
|
1687
1483
|
case 35:
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
console.error('[PaymentModule] 提交支付失败',
|
|
1691
|
-
this.logError('submitPayAsync failed',
|
|
1484
|
+
_context17.prev = 35;
|
|
1485
|
+
_context17.t1 = _context17["catch"](1);
|
|
1486
|
+
console.error('[PaymentModule] 提交支付失败', _context17.t1);
|
|
1487
|
+
this.logError('submitPayAsync failed', _context17.t1, {
|
|
1692
1488
|
orderUuid: orderUuid
|
|
1693
1489
|
});
|
|
1694
|
-
return
|
|
1490
|
+
return _context17.abrupt("return", {
|
|
1695
1491
|
status: 'failed'
|
|
1696
1492
|
});
|
|
1697
1493
|
case 40:
|
|
1698
1494
|
case "end":
|
|
1699
|
-
return
|
|
1495
|
+
return _context17.stop();
|
|
1700
1496
|
}
|
|
1701
|
-
},
|
|
1497
|
+
}, _callee17, this, [[1, 35], [14, 24, 27, 30]]);
|
|
1702
1498
|
}));
|
|
1703
|
-
function submitPayAsync(
|
|
1499
|
+
function submitPayAsync(_x22) {
|
|
1704
1500
|
return _submitPayAsync.apply(this, arguments);
|
|
1705
1501
|
}
|
|
1706
1502
|
return submitPayAsync;
|
|
@@ -1712,12 +1508,12 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1712
1508
|
}, {
|
|
1713
1509
|
key: "submitSingleOrderPayment",
|
|
1714
1510
|
value: (function () {
|
|
1715
|
-
var _submitSingleOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1511
|
+
var _submitSingleOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(order) {
|
|
1716
1512
|
var paymentData, totalPaidAmount, orderTotalAmount;
|
|
1717
|
-
return _regeneratorRuntime().wrap(function
|
|
1718
|
-
while (1) switch (
|
|
1513
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1514
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1719
1515
|
case 0:
|
|
1720
|
-
|
|
1516
|
+
_context18.prev = 0;
|
|
1721
1517
|
paymentData = {
|
|
1722
1518
|
payments: order.payment.map(function (payment) {
|
|
1723
1519
|
return {
|
|
@@ -1742,51 +1538,54 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1742
1538
|
if (totalPaidAmount.gte(orderTotalAmount)) {
|
|
1743
1539
|
// 支付金额足够,标记为已完成
|
|
1744
1540
|
order.payment_status = PaymentStatus.Finished;
|
|
1541
|
+
console.log("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u5B8C\u6210\uFF0C\u91D1\u989D: ").concat(totalPaidAmount.toString(), "/").concat(orderTotalAmount.toString()));
|
|
1745
1542
|
} else {
|
|
1746
1543
|
// 支付金额不足,标记为部分支付
|
|
1747
1544
|
order.payment_status = PaymentStatus.PartiallyPaid;
|
|
1545
|
+
console.log("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u90E8\u5206\u652F\u4ED8\uFF0C\u91D1\u989D: ").concat(totalPaidAmount.toString(), "/").concat(orderTotalAmount.toString()));
|
|
1748
1546
|
}
|
|
1749
1547
|
|
|
1750
1548
|
// 给后端标记一下是全部支付(paid)还是部分支付
|
|
1751
1549
|
paymentData.payment_status = order.payment_status === PaymentStatus.Finished ? 'paid' : 'partially_paid';
|
|
1752
1550
|
|
|
1753
1551
|
// 更新订单状态到数据库
|
|
1754
|
-
|
|
1552
|
+
_context18.next = 8;
|
|
1755
1553
|
return this.dbManager.update('order', order);
|
|
1756
1554
|
case 8:
|
|
1757
1555
|
if (!(paymentData.payments.length === 0)) {
|
|
1758
|
-
|
|
1556
|
+
_context18.next = 12;
|
|
1759
1557
|
break;
|
|
1760
1558
|
}
|
|
1559
|
+
console.log("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u5217\u8868\u4E3A\u7A7A\uFF0C\u8DF3\u8FC7\u652F\u4ED8\u5904\u7406"));
|
|
1761
1560
|
this.logWarning('Empty payment list', {
|
|
1762
1561
|
orderUuid: order.uuid,
|
|
1763
1562
|
orderId: order.order_id
|
|
1764
1563
|
});
|
|
1765
|
-
return
|
|
1766
|
-
case
|
|
1767
|
-
|
|
1564
|
+
return _context18.abrupt("return");
|
|
1565
|
+
case 12:
|
|
1566
|
+
_context18.next = 14;
|
|
1768
1567
|
return this.core.effects.emit("".concat(this.name, ":onPaymentSubmitted"), order);
|
|
1769
|
-
case
|
|
1770
|
-
|
|
1568
|
+
case 14:
|
|
1569
|
+
_context18.next = 16;
|
|
1771
1570
|
return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
|
|
1772
1571
|
action: 'submit',
|
|
1773
1572
|
order: order
|
|
1774
1573
|
});
|
|
1775
|
-
case
|
|
1776
|
-
|
|
1574
|
+
case 16:
|
|
1575
|
+
_context18.next = 22;
|
|
1777
1576
|
break;
|
|
1778
|
-
case
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
console.error("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u63D0\u4EA4\u5931\u8D25"),
|
|
1782
|
-
throw
|
|
1783
|
-
case
|
|
1577
|
+
case 18:
|
|
1578
|
+
_context18.prev = 18;
|
|
1579
|
+
_context18.t0 = _context18["catch"](0);
|
|
1580
|
+
console.error("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u63D0\u4EA4\u5931\u8D25"), _context18.t0);
|
|
1581
|
+
throw _context18.t0;
|
|
1582
|
+
case 22:
|
|
1784
1583
|
case "end":
|
|
1785
|
-
return
|
|
1584
|
+
return _context18.stop();
|
|
1786
1585
|
}
|
|
1787
|
-
},
|
|
1586
|
+
}, _callee18, this, [[0, 18]]);
|
|
1788
1587
|
}));
|
|
1789
|
-
function submitSingleOrderPayment(
|
|
1588
|
+
function submitSingleOrderPayment(_x23) {
|
|
1790
1589
|
return _submitSingleOrderPayment.apply(this, arguments);
|
|
1791
1590
|
}
|
|
1792
1591
|
return submitSingleOrderPayment;
|
|
@@ -1798,29 +1597,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1798
1597
|
}, {
|
|
1799
1598
|
key: "getRemainingOrderAmountAsync",
|
|
1800
1599
|
value: (function () {
|
|
1801
|
-
var _getRemainingOrderAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1600
|
+
var _getRemainingOrderAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(orderUuid) {
|
|
1802
1601
|
var order;
|
|
1803
|
-
return _regeneratorRuntime().wrap(function
|
|
1804
|
-
while (1) switch (
|
|
1602
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1603
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1805
1604
|
case 0:
|
|
1806
|
-
|
|
1605
|
+
_context19.next = 2;
|
|
1807
1606
|
return this.getPaymentOrderByUuidAsync(orderUuid);
|
|
1808
1607
|
case 2:
|
|
1809
|
-
order =
|
|
1608
|
+
order = _context19.sent;
|
|
1810
1609
|
if (order) {
|
|
1811
|
-
|
|
1610
|
+
_context19.next = 5;
|
|
1812
1611
|
break;
|
|
1813
1612
|
}
|
|
1814
1613
|
throw new Error('订单不存在');
|
|
1815
1614
|
case 5:
|
|
1816
|
-
return
|
|
1615
|
+
return _context19.abrupt("return", new Decimal(order.expect_amount).toNumber());
|
|
1817
1616
|
case 6:
|
|
1818
1617
|
case "end":
|
|
1819
|
-
return
|
|
1618
|
+
return _context19.stop();
|
|
1820
1619
|
}
|
|
1821
|
-
},
|
|
1620
|
+
}, _callee19, this);
|
|
1822
1621
|
}));
|
|
1823
|
-
function getRemainingOrderAmountAsync(
|
|
1622
|
+
function getRemainingOrderAmountAsync(_x24) {
|
|
1824
1623
|
return _getRemainingOrderAmountAsync.apply(this, arguments);
|
|
1825
1624
|
}
|
|
1826
1625
|
return getRemainingOrderAmountAsync;
|
|
@@ -1832,65 +1631,65 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1832
1631
|
}, {
|
|
1833
1632
|
key: "getRemainingOrderAmountWithInputAsync",
|
|
1834
1633
|
value: (function () {
|
|
1835
|
-
var _getRemainingOrderAmountWithInputAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1634
|
+
var _getRemainingOrderAmountWithInputAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(inputAmount, orderUuid) {
|
|
1836
1635
|
var order, inputDecimal;
|
|
1837
|
-
return _regeneratorRuntime().wrap(function
|
|
1838
|
-
while (1) switch (
|
|
1636
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1637
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1839
1638
|
case 0:
|
|
1840
|
-
|
|
1639
|
+
_context20.next = 2;
|
|
1841
1640
|
return this.getPaymentOrderByUuidAsync(orderUuid);
|
|
1842
1641
|
case 2:
|
|
1843
|
-
order =
|
|
1642
|
+
order = _context20.sent;
|
|
1844
1643
|
if (order) {
|
|
1845
|
-
|
|
1644
|
+
_context20.next = 5;
|
|
1846
1645
|
break;
|
|
1847
1646
|
}
|
|
1848
1647
|
throw new Error('订单不存在');
|
|
1849
1648
|
case 5:
|
|
1850
1649
|
if (!(inputAmount === null || inputAmount === undefined)) {
|
|
1851
|
-
|
|
1650
|
+
_context20.next = 7;
|
|
1852
1651
|
break;
|
|
1853
1652
|
}
|
|
1854
|
-
return
|
|
1653
|
+
return _context20.abrupt("return", new Decimal(order.expect_amount).toNumber());
|
|
1855
1654
|
case 7:
|
|
1856
1655
|
if (!(typeof inputAmount === 'string')) {
|
|
1857
|
-
|
|
1656
|
+
_context20.next = 10;
|
|
1858
1657
|
break;
|
|
1859
1658
|
}
|
|
1860
1659
|
if (!(inputAmount.trim() === '')) {
|
|
1861
|
-
|
|
1660
|
+
_context20.next = 10;
|
|
1862
1661
|
break;
|
|
1863
1662
|
}
|
|
1864
|
-
return
|
|
1663
|
+
return _context20.abrupt("return", new Decimal(order.expect_amount).toNumber());
|
|
1865
1664
|
case 10:
|
|
1866
1665
|
if (!(typeof inputAmount === 'number')) {
|
|
1867
|
-
|
|
1666
|
+
_context20.next = 14;
|
|
1868
1667
|
break;
|
|
1869
1668
|
}
|
|
1870
1669
|
if (!(isNaN(inputAmount) || !isFinite(inputAmount))) {
|
|
1871
|
-
|
|
1670
|
+
_context20.next = 14;
|
|
1872
1671
|
break;
|
|
1873
1672
|
}
|
|
1874
1673
|
// 如果输入是 NaN 或无穷大,返回原始的待付金额
|
|
1875
1674
|
console.warn("[PaymentModule] \u8F93\u5165\u91D1\u989D\u4E0D\u662F\u6709\u6548\u6570\u5B57: ".concat(inputAmount, "\uFF0C\u8FD4\u56DE\u539F\u59CB\u5F85\u4ED8\u91D1\u989D"));
|
|
1876
|
-
return
|
|
1675
|
+
return _context20.abrupt("return", new Decimal(order.expect_amount).toNumber());
|
|
1877
1676
|
case 14:
|
|
1878
|
-
|
|
1677
|
+
_context20.prev = 14;
|
|
1879
1678
|
inputDecimal = new Decimal(inputAmount);
|
|
1880
|
-
return
|
|
1679
|
+
return _context20.abrupt("return", new Decimal(order.expect_amount).minus(inputDecimal).toNumber());
|
|
1881
1680
|
case 19:
|
|
1882
|
-
|
|
1883
|
-
|
|
1681
|
+
_context20.prev = 19;
|
|
1682
|
+
_context20.t0 = _context20["catch"](14);
|
|
1884
1683
|
// 如果输入不是有效的数字,返回原始的待付金额
|
|
1885
1684
|
console.warn("[PaymentModule] \u8F93\u5165\u91D1\u989D\u683C\u5F0F\u65E0\u6548: ".concat(inputAmount, "\uFF0C\u8FD4\u56DE\u539F\u59CB\u5F85\u4ED8\u91D1\u989D"));
|
|
1886
|
-
return
|
|
1685
|
+
return _context20.abrupt("return", new Decimal(order.expect_amount).toNumber());
|
|
1887
1686
|
case 23:
|
|
1888
1687
|
case "end":
|
|
1889
|
-
return
|
|
1688
|
+
return _context20.stop();
|
|
1890
1689
|
}
|
|
1891
|
-
},
|
|
1690
|
+
}, _callee20, this, [[14, 19]]);
|
|
1892
1691
|
}));
|
|
1893
|
-
function getRemainingOrderAmountWithInputAsync(
|
|
1692
|
+
function getRemainingOrderAmountWithInputAsync(_x25, _x26) {
|
|
1894
1693
|
return _getRemainingOrderAmountWithInputAsync.apply(this, arguments);
|
|
1895
1694
|
}
|
|
1896
1695
|
return getRemainingOrderAmountWithInputAsync;
|
|
@@ -1926,6 +1725,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1926
1725
|
// 如果是定金模式,则使用deposit_amount 去减已付款金额
|
|
1927
1726
|
var remainingAmount = order.is_deposit === 1 ? new Decimal(order.deposit_amount).minus(paidAmount) : totalAmount.minus(paidAmount);
|
|
1928
1727
|
order.expect_amount = Decimal.max(0, remainingAmount).toFixed(2);
|
|
1728
|
+
console.log("[PaymentModule] \u91CD\u65B0\u8BA1\u7B97\u8BA2\u5355\u91D1\u989D:", {
|
|
1729
|
+
orderUuid: order.uuid,
|
|
1730
|
+
totalAmount: order.total_amount,
|
|
1731
|
+
effectivePaidAmount: paidAmount.toFixed(2),
|
|
1732
|
+
remainingAmount: order.expect_amount,
|
|
1733
|
+
activePayments: order.payment.filter(function (p) {
|
|
1734
|
+
return p.status !== 'voided';
|
|
1735
|
+
}).length,
|
|
1736
|
+
voidedPayments: order.payment.filter(function (p) {
|
|
1737
|
+
return p.status === 'voided';
|
|
1738
|
+
}).length,
|
|
1739
|
+
paymentDetails: order.payment.filter(function (p) {
|
|
1740
|
+
return p.status !== 'voided';
|
|
1741
|
+
}).map(function (p) {
|
|
1742
|
+
return {
|
|
1743
|
+
code: p.code,
|
|
1744
|
+
amount: p.amount,
|
|
1745
|
+
rounding_amount: p.rounding_amount || '0.00',
|
|
1746
|
+
effective_amount: new Decimal(p.amount || 0).minus(new Decimal(p.rounding_amount || 0)).toFixed(2)
|
|
1747
|
+
};
|
|
1748
|
+
}),
|
|
1749
|
+
说明: '有效支付金额包含抹零计算(amount + |rounding_amount|)'
|
|
1750
|
+
});
|
|
1929
1751
|
}
|
|
1930
1752
|
|
|
1931
1753
|
/**
|
|
@@ -1934,29 +1756,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1934
1756
|
}, {
|
|
1935
1757
|
key: "getCashPaymentMethod",
|
|
1936
1758
|
value: (function () {
|
|
1937
|
-
var _getCashPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1759
|
+
var _getCashPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
1938
1760
|
var payMethods;
|
|
1939
|
-
return _regeneratorRuntime().wrap(function
|
|
1940
|
-
while (1) switch (
|
|
1761
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1762
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1941
1763
|
case 0:
|
|
1942
|
-
|
|
1943
|
-
|
|
1764
|
+
_context21.prev = 0;
|
|
1765
|
+
_context21.next = 3;
|
|
1944
1766
|
return this.dbManager.getAll('pay_method');
|
|
1945
1767
|
case 3:
|
|
1946
|
-
payMethods =
|
|
1947
|
-
return
|
|
1768
|
+
payMethods = _context21.sent;
|
|
1769
|
+
return _context21.abrupt("return", payMethods.find(function (method) {
|
|
1948
1770
|
return method.code === PaymentMethodType.Cash;
|
|
1949
1771
|
}) || null);
|
|
1950
1772
|
case 7:
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
console.error('[PaymentModule] 获取现金支付方式失败',
|
|
1954
|
-
return
|
|
1773
|
+
_context21.prev = 7;
|
|
1774
|
+
_context21.t0 = _context21["catch"](0);
|
|
1775
|
+
console.error('[PaymentModule] 获取现金支付方式失败', _context21.t0);
|
|
1776
|
+
return _context21.abrupt("return", null);
|
|
1955
1777
|
case 11:
|
|
1956
1778
|
case "end":
|
|
1957
|
-
return
|
|
1779
|
+
return _context21.stop();
|
|
1958
1780
|
}
|
|
1959
|
-
},
|
|
1781
|
+
}, _callee21, this, [[0, 7]]);
|
|
1960
1782
|
}));
|
|
1961
1783
|
function getCashPaymentMethod() {
|
|
1962
1784
|
return _getCashPaymentMethod.apply(this, arguments);
|
|
@@ -1970,29 +1792,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1970
1792
|
}, {
|
|
1971
1793
|
key: "getEftposPaymentMethod",
|
|
1972
1794
|
value: (function () {
|
|
1973
|
-
var _getEftposPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1795
|
+
var _getEftposPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
1974
1796
|
var payMethods;
|
|
1975
|
-
return _regeneratorRuntime().wrap(function
|
|
1976
|
-
while (1) switch (
|
|
1797
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1798
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1977
1799
|
case 0:
|
|
1978
|
-
|
|
1979
|
-
|
|
1800
|
+
_context22.prev = 0;
|
|
1801
|
+
_context22.next = 3;
|
|
1980
1802
|
return this.dbManager.getAll('pay_method');
|
|
1981
1803
|
case 3:
|
|
1982
|
-
payMethods =
|
|
1983
|
-
return
|
|
1804
|
+
payMethods = _context22.sent;
|
|
1805
|
+
return _context22.abrupt("return", payMethods.find(function (method) {
|
|
1984
1806
|
return method.code === PaymentMethodType.Eftpos;
|
|
1985
1807
|
}) || null);
|
|
1986
1808
|
case 7:
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
console.error('[PaymentModule] 获取Eftpos支付方式失败',
|
|
1990
|
-
return
|
|
1809
|
+
_context22.prev = 7;
|
|
1810
|
+
_context22.t0 = _context22["catch"](0);
|
|
1811
|
+
console.error('[PaymentModule] 获取Eftpos支付方式失败', _context22.t0);
|
|
1812
|
+
return _context22.abrupt("return", null);
|
|
1991
1813
|
case 11:
|
|
1992
1814
|
case "end":
|
|
1993
|
-
return
|
|
1815
|
+
return _context22.stop();
|
|
1994
1816
|
}
|
|
1995
|
-
},
|
|
1817
|
+
}, _callee22, this, [[0, 7]]);
|
|
1996
1818
|
}));
|
|
1997
1819
|
function getEftposPaymentMethod() {
|
|
1998
1820
|
return _getEftposPaymentMethod.apply(this, arguments);
|
|
@@ -2006,29 +1828,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2006
1828
|
}, {
|
|
2007
1829
|
key: "getWalletPaymentMethod",
|
|
2008
1830
|
value: (function () {
|
|
2009
|
-
var _getWalletPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1831
|
+
var _getWalletPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
2010
1832
|
var payMethods;
|
|
2011
|
-
return _regeneratorRuntime().wrap(function
|
|
2012
|
-
while (1) switch (
|
|
1833
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1834
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
2013
1835
|
case 0:
|
|
2014
|
-
|
|
2015
|
-
|
|
1836
|
+
_context23.prev = 0;
|
|
1837
|
+
_context23.next = 3;
|
|
2016
1838
|
return this.dbManager.getAll('pay_method');
|
|
2017
1839
|
case 3:
|
|
2018
|
-
payMethods =
|
|
2019
|
-
return
|
|
1840
|
+
payMethods = _context23.sent;
|
|
1841
|
+
return _context23.abrupt("return", payMethods.find(function (method) {
|
|
2020
1842
|
return method.code === PaymentMethodType.Wallet;
|
|
2021
1843
|
}) || null);
|
|
2022
1844
|
case 7:
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
console.error('[PaymentModule] 获取钱包支付方式失败',
|
|
2026
|
-
return
|
|
1845
|
+
_context23.prev = 7;
|
|
1846
|
+
_context23.t0 = _context23["catch"](0);
|
|
1847
|
+
console.error('[PaymentModule] 获取钱包支付方式失败', _context23.t0);
|
|
1848
|
+
return _context23.abrupt("return", null);
|
|
2027
1849
|
case 11:
|
|
2028
1850
|
case "end":
|
|
2029
|
-
return
|
|
1851
|
+
return _context23.stop();
|
|
2030
1852
|
}
|
|
2031
|
-
},
|
|
1853
|
+
}, _callee23, this, [[0, 7]]);
|
|
2032
1854
|
}));
|
|
2033
1855
|
function getWalletPaymentMethod() {
|
|
2034
1856
|
return _getWalletPaymentMethod.apply(this, arguments);
|
|
@@ -2038,42 +1860,43 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2038
1860
|
/**
|
|
2039
1861
|
* 确保支付模块所需的数据库表已创建
|
|
2040
1862
|
*/
|
|
1863
|
+
/** @deprecated */
|
|
2041
1864
|
)
|
|
2042
1865
|
}, {
|
|
2043
1866
|
key: "ensurePaymentTables",
|
|
2044
1867
|
value: (function () {
|
|
2045
|
-
var _ensurePaymentTables = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2046
|
-
return _regeneratorRuntime().wrap(function
|
|
2047
|
-
while (1) switch (
|
|
1868
|
+
var _ensurePaymentTables = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
1869
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1870
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2048
1871
|
case 0:
|
|
2049
|
-
|
|
2050
|
-
|
|
1872
|
+
_context24.prev = 0;
|
|
1873
|
+
_context24.next = 3;
|
|
2051
1874
|
return this.dbManager.getAll('pay_method');
|
|
2052
1875
|
case 3:
|
|
2053
|
-
|
|
1876
|
+
_context24.next = 9;
|
|
2054
1877
|
break;
|
|
2055
1878
|
case 5:
|
|
2056
|
-
|
|
2057
|
-
|
|
1879
|
+
_context24.prev = 5;
|
|
1880
|
+
_context24.t0 = _context24["catch"](0);
|
|
2058
1881
|
console.warn('[PaymentModule] pay_method 表不存在,请在数据库配置中添加以下配置:');
|
|
2059
1882
|
console.warn('{ name: "pay_method", keyPath: "id" }');
|
|
2060
1883
|
case 9:
|
|
2061
|
-
|
|
2062
|
-
|
|
1884
|
+
_context24.prev = 9;
|
|
1885
|
+
_context24.next = 12;
|
|
2063
1886
|
return this.dbManager.getAll('order');
|
|
2064
1887
|
case 12:
|
|
2065
|
-
|
|
1888
|
+
_context24.next = 18;
|
|
2066
1889
|
break;
|
|
2067
1890
|
case 14:
|
|
2068
|
-
|
|
2069
|
-
|
|
1891
|
+
_context24.prev = 14;
|
|
1892
|
+
_context24.t1 = _context24["catch"](9);
|
|
2070
1893
|
console.warn('[PaymentModule] order 表不存在,请在数据库配置中添加以下配置:');
|
|
2071
1894
|
console.warn('{ name: "order", keyPath: "uuid" }');
|
|
2072
1895
|
case 18:
|
|
2073
1896
|
case "end":
|
|
2074
|
-
return
|
|
1897
|
+
return _context24.stop();
|
|
2075
1898
|
}
|
|
2076
|
-
},
|
|
1899
|
+
}, _callee24, this, [[0, 5], [9, 14]]);
|
|
2077
1900
|
}));
|
|
2078
1901
|
function ensurePaymentTables() {
|
|
2079
1902
|
return _ensurePaymentTables.apply(this, arguments);
|
|
@@ -2083,33 +1906,34 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2083
1906
|
/**
|
|
2084
1907
|
* 获取部分支付的订单
|
|
2085
1908
|
*/
|
|
1909
|
+
/** @deprecated */
|
|
2086
1910
|
)
|
|
2087
1911
|
}, {
|
|
2088
1912
|
key: "getPartiallyPaidOrdersAsync",
|
|
2089
1913
|
value: (function () {
|
|
2090
|
-
var _getPartiallyPaidOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1914
|
+
var _getPartiallyPaidOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
2091
1915
|
var allOrders;
|
|
2092
|
-
return _regeneratorRuntime().wrap(function
|
|
2093
|
-
while (1) switch (
|
|
1916
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1917
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2094
1918
|
case 0:
|
|
2095
|
-
|
|
2096
|
-
|
|
1919
|
+
_context25.prev = 0;
|
|
1920
|
+
_context25.next = 3;
|
|
2097
1921
|
return this.dbManager.getAll('order');
|
|
2098
1922
|
case 3:
|
|
2099
|
-
allOrders =
|
|
2100
|
-
return
|
|
1923
|
+
allOrders = _context25.sent;
|
|
1924
|
+
return _context25.abrupt("return", allOrders.filter(function (order) {
|
|
2101
1925
|
return order.payment_status === PaymentStatus.PartiallyPaid;
|
|
2102
1926
|
}));
|
|
2103
1927
|
case 7:
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
console.error('[PaymentModule] 获取部分支付订单失败',
|
|
2107
|
-
return
|
|
1928
|
+
_context25.prev = 7;
|
|
1929
|
+
_context25.t0 = _context25["catch"](0);
|
|
1930
|
+
console.error('[PaymentModule] 获取部分支付订单失败', _context25.t0);
|
|
1931
|
+
return _context25.abrupt("return", []);
|
|
2108
1932
|
case 11:
|
|
2109
1933
|
case "end":
|
|
2110
|
-
return
|
|
1934
|
+
return _context25.stop();
|
|
2111
1935
|
}
|
|
2112
|
-
},
|
|
1936
|
+
}, _callee25, this, [[0, 7]]);
|
|
2113
1937
|
}));
|
|
2114
1938
|
function getPartiallyPaidOrdersAsync() {
|
|
2115
1939
|
return _getPartiallyPaidOrdersAsync.apply(this, arguments);
|
|
@@ -2130,17 +1954,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2130
1954
|
}, {
|
|
2131
1955
|
key: "roundAmountAsync",
|
|
2132
1956
|
value: function () {
|
|
2133
|
-
var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1957
|
+
var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(originalAmount, interval, rule) {
|
|
2134
1958
|
var amount, roundingInterval, supportedIntervals, intervalValue, baseValue, roundedValue, finalAmount, originalAmountStr, roundedAmountStr, roundingDifference, roundingDifferenceStr;
|
|
2135
|
-
return _regeneratorRuntime().wrap(function
|
|
2136
|
-
while (1) switch (
|
|
1959
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1960
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2137
1961
|
case 0:
|
|
2138
|
-
|
|
1962
|
+
_context26.prev = 0;
|
|
2139
1963
|
// 参数验证
|
|
2140
1964
|
amount = new Decimal(originalAmount);
|
|
2141
1965
|
roundingInterval = new Decimal(interval);
|
|
2142
1966
|
if (!roundingInterval.lte(0)) {
|
|
2143
|
-
|
|
1967
|
+
_context26.next = 5;
|
|
2144
1968
|
break;
|
|
2145
1969
|
}
|
|
2146
1970
|
throw new Error('舍入间隔必须大于 0');
|
|
@@ -2154,61 +1978,64 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2154
1978
|
|
|
2155
1979
|
// 计算基础值:x / interval
|
|
2156
1980
|
baseValue = amount.div(roundingInterval);
|
|
2157
|
-
|
|
2158
|
-
|
|
1981
|
+
console.log("[PaymentModule] \u820D\u5165\u8BA1\u7B97 - \u539F\u59CB\u91D1\u989D: ".concat(amount.toString(), ", \u95F4\u9694: ").concat(intervalValue, ", \u57FA\u7840\u503C: ").concat(baseValue.toString(), ", \u89C4\u5219: ").concat(rule));
|
|
1982
|
+
_context26.t0 = rule;
|
|
1983
|
+
_context26.next = _context26.t0 === RoundingRule.Standard ? 13 : _context26.t0 === 'standard' ? 13 : _context26.t0 === RoundingRule.StandardDown ? 15 : _context26.t0 === 'standard_down' ? 15 : _context26.t0 === RoundingRule.AlwaysUp ? 17 : _context26.t0 === 'always_up' ? 17 : _context26.t0 === RoundingRule.AlwaysDown ? 19 : _context26.t0 === 'always_down' ? 19 : 21;
|
|
2159
1984
|
break;
|
|
2160
|
-
case
|
|
1985
|
+
case 13:
|
|
2161
1986
|
// 标准舍入(中点向上)
|
|
2162
1987
|
roundedValue = this.standardRound(baseValue, true);
|
|
2163
|
-
return
|
|
2164
|
-
case
|
|
1988
|
+
return _context26.abrupt("break", 22);
|
|
1989
|
+
case 15:
|
|
2165
1990
|
// 标准舍入(中点向下)
|
|
2166
1991
|
roundedValue = this.standardRound(baseValue, false);
|
|
2167
|
-
return
|
|
2168
|
-
case
|
|
1992
|
+
return _context26.abrupt("break", 22);
|
|
1993
|
+
case 17:
|
|
2169
1994
|
// 总是向上舍入
|
|
2170
1995
|
roundedValue = baseValue.ceil();
|
|
2171
|
-
return
|
|
2172
|
-
case
|
|
1996
|
+
return _context26.abrupt("break", 22);
|
|
1997
|
+
case 19:
|
|
2173
1998
|
// 总是向下舍入
|
|
2174
1999
|
roundedValue = baseValue.floor();
|
|
2175
|
-
return
|
|
2176
|
-
case 20:
|
|
2177
|
-
throw new Error("\u4E0D\u652F\u6301\u7684\u820D\u5165\u89C4\u5219: ".concat(rule));
|
|
2000
|
+
return _context26.abrupt("break", 22);
|
|
2178
2001
|
case 21:
|
|
2002
|
+
throw new Error("\u4E0D\u652F\u6301\u7684\u820D\u5165\u89C4\u5219: ".concat(rule));
|
|
2003
|
+
case 22:
|
|
2179
2004
|
// 计算最终金额:roundedValue * interval
|
|
2180
2005
|
finalAmount = roundedValue.mul(roundingInterval);
|
|
2181
2006
|
originalAmountStr = amount.toFixed(2); // 如果最终金额是 0 元,则不采用舍入金额,返回原始金额
|
|
2182
2007
|
if (!finalAmount.eq(0)) {
|
|
2183
|
-
|
|
2008
|
+
_context26.next = 27;
|
|
2184
2009
|
break;
|
|
2185
2010
|
}
|
|
2186
|
-
|
|
2011
|
+
console.log("[PaymentModule] \u6700\u7EC8\u91D1\u989D\u4E3A0\uFF0C\u8FD4\u56DE\u539F\u59CB\u91D1\u989D: ".concat(originalAmountStr));
|
|
2012
|
+
return _context26.abrupt("return", {
|
|
2187
2013
|
originalAmount: originalAmountStr,
|
|
2188
2014
|
roundedAmount: originalAmountStr,
|
|
2189
2015
|
roundingDifference: '0.00'
|
|
2190
2016
|
});
|
|
2191
|
-
case
|
|
2017
|
+
case 27:
|
|
2192
2018
|
roundedAmountStr = finalAmount.toFixed(2); // 计算舍入差额
|
|
2193
2019
|
roundingDifference = finalAmount.sub(amount);
|
|
2194
2020
|
roundingDifferenceStr = roundingDifference.toFixed(2);
|
|
2195
|
-
|
|
2021
|
+
console.log("[PaymentModule] \u820D\u5165\u7ED3\u679C - \u539F\u59CB\u91D1\u989D: ".concat(originalAmountStr, ", \u820D\u5165\u540E\u91D1\u989D: ").concat(roundedAmountStr, ", \u820D\u5165\u5DEE\u989D: ").concat(roundingDifferenceStr));
|
|
2022
|
+
return _context26.abrupt("return", {
|
|
2196
2023
|
originalAmount: originalAmountStr,
|
|
2197
2024
|
roundedAmount: roundedAmountStr,
|
|
2198
2025
|
roundingDifference: roundingDifferenceStr
|
|
2199
2026
|
});
|
|
2200
|
-
case
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
console.error('[PaymentModule] 金额舍入失败:',
|
|
2204
|
-
throw new Error("\u91D1\u989D\u820D\u5165\u5931\u8D25: ".concat(
|
|
2205
|
-
case
|
|
2027
|
+
case 34:
|
|
2028
|
+
_context26.prev = 34;
|
|
2029
|
+
_context26.t1 = _context26["catch"](0);
|
|
2030
|
+
console.error('[PaymentModule] 金额舍入失败:', _context26.t1);
|
|
2031
|
+
throw new Error("\u91D1\u989D\u820D\u5165\u5931\u8D25: ".concat(_context26.t1 instanceof Error ? _context26.t1.message : String(_context26.t1)));
|
|
2032
|
+
case 38:
|
|
2206
2033
|
case "end":
|
|
2207
|
-
return
|
|
2034
|
+
return _context26.stop();
|
|
2208
2035
|
}
|
|
2209
|
-
},
|
|
2036
|
+
}, _callee26, this, [[0, 34]]);
|
|
2210
2037
|
}));
|
|
2211
|
-
function roundAmountAsync(
|
|
2038
|
+
function roundAmountAsync(_x27, _x28, _x29) {
|
|
2212
2039
|
return _roundAmountAsync.apply(this, arguments);
|
|
2213
2040
|
}
|
|
2214
2041
|
return roundAmountAsync;
|