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