@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
|
@@ -1,71 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
28
2
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
__export(cartProduct_exports, {
|
|
32
|
-
formatBundle: () => formatBundle,
|
|
33
|
-
formatBundleToOrigin: () => formatBundleToOrigin,
|
|
34
|
-
formatOptions: () => formatOptions,
|
|
35
|
-
formatOptionsToOrigin: () => formatOptionsToOrigin,
|
|
36
|
-
formatProductToCartItem: () => formatProductToCartItem,
|
|
37
|
-
formatProductToCartItemOrigin: () => formatProductToCartItemOrigin,
|
|
38
|
-
getProductDeposit: () => getProductDeposit,
|
|
39
|
-
getProductOriginTotalPrice: () => getProductOriginTotalPrice,
|
|
40
|
-
getProductTotalPrice: () => getProductTotalPrice,
|
|
41
|
-
handleProductDeposit: () => handleProductDeposit,
|
|
42
|
-
handleVariantProduct: () => handleVariantProduct
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
43
5
|
});
|
|
44
|
-
|
|
45
|
-
var
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
var
|
|
49
|
-
var
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
6
|
+
exports.handleVariantProduct = exports.handleProductDeposit = exports.getProductTotalPrice = exports.getProductOriginTotalPrice = exports.getProductDeposit = exports.formatProductToCartItemOrigin = exports.formatProductToCartItem = exports.formatOptionsToOrigin = exports.formatOptions = exports.formatBundleToOrigin = exports.formatBundle = void 0;
|
|
7
|
+
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
8
|
+
var _utils = require("../../Product/utils");
|
|
9
|
+
var _utils2 = require("../../../solution/ShopDiscount/utils");
|
|
10
|
+
var _utils3 = require("../../Summary/utils");
|
|
11
|
+
var _utils4 = require("../../Order/utils");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
/** 与 Rules / ShopDiscount 一致的折扣入参,用于主价与 option 单价 */
|
|
14
|
+
const toDiscountPayload = discountItem => ({
|
|
15
|
+
amount: discountItem.amount,
|
|
16
|
+
tag: discountItem.type,
|
|
17
|
+
par_value: discountItem.discount?.percent,
|
|
18
|
+
config: discountItem.config,
|
|
19
|
+
metadata: {
|
|
20
|
+
discount_card_type: discountItem?.discount?.discount_card_type
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @title 处理组合商品
|
|
26
|
+
* @description 组合商品需要直接修改 product 里的价格和 is_charge_tax
|
|
27
|
+
* @param product 商品
|
|
28
|
+
* @returns 处理后的商品
|
|
29
|
+
*/
|
|
30
|
+
const handleVariantProduct = product => {
|
|
31
|
+
// 判断组合商品,然后直接修改 product 里的价格和 is_charge_tax
|
|
32
|
+
if (product?.product_variant_id) {
|
|
33
|
+
// 还需要判断 能从 variant 里找到对应的组合规格信息,才可以替换
|
|
34
|
+
const targetVariant = product?.variant?.find(n => n.id === product.product_variant_id);
|
|
67
35
|
if (targetVariant) {
|
|
68
36
|
product.price = targetVariant.price;
|
|
37
|
+
// 如果 original_price 为 0,就不改了
|
|
69
38
|
if (Number(targetVariant.original_price) > 0) {
|
|
70
39
|
product.original_price = targetVariant.original_price;
|
|
71
40
|
}
|
|
@@ -74,9 +43,14 @@ var handleVariantProduct = (product) => {
|
|
|
74
43
|
}
|
|
75
44
|
return product;
|
|
76
45
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 格式化商品到购物车
|
|
49
|
+
* @param product 商品
|
|
50
|
+
* @returns 格式化后的商品
|
|
51
|
+
*/
|
|
52
|
+
exports.handleVariantProduct = handleVariantProduct;
|
|
53
|
+
const formatProductToCartItem = params => {
|
|
80
54
|
const {
|
|
81
55
|
cartItem,
|
|
82
56
|
product,
|
|
@@ -86,14 +60,25 @@ var formatProductToCartItem = (params) => {
|
|
|
86
60
|
quantity = 1,
|
|
87
61
|
discounts
|
|
88
62
|
} = params;
|
|
89
|
-
const num = quantity;
|
|
63
|
+
const num = quantity; // 当前按照单个商品加入购物车
|
|
64
|
+
|
|
90
65
|
if (product) {
|
|
91
|
-
cartItem.id = product
|
|
92
|
-
cartItem.name = product
|
|
93
|
-
cartItem.price = product
|
|
66
|
+
cartItem.id = product?.id;
|
|
67
|
+
cartItem.name = product?.title;
|
|
68
|
+
cartItem.price = product?.price;
|
|
94
69
|
cartItem.num = num;
|
|
95
|
-
cartItem.total = getProductTotalPrice({
|
|
96
|
-
|
|
70
|
+
cartItem.total = getProductTotalPrice({
|
|
71
|
+
product,
|
|
72
|
+
bundle,
|
|
73
|
+
options,
|
|
74
|
+
num,
|
|
75
|
+
discounts
|
|
76
|
+
});
|
|
77
|
+
cartItem.totalDifference = getTotalDifference({
|
|
78
|
+
product,
|
|
79
|
+
bundle,
|
|
80
|
+
discounts
|
|
81
|
+
});
|
|
97
82
|
cartItem.summaryTotal = cartItem.total * (num || 1);
|
|
98
83
|
cartItem.origin_total = getProductOriginTotalPrice({
|
|
99
84
|
product,
|
|
@@ -102,6 +87,7 @@ var formatProductToCartItem = (params) => {
|
|
|
102
87
|
num,
|
|
103
88
|
discounts
|
|
104
89
|
});
|
|
90
|
+
// 不包含折扣卡商品券的总价
|
|
105
91
|
const origin_total = getProductTotalPrice({
|
|
106
92
|
product: cartItem._productInit || cartItem._productOrigin,
|
|
107
93
|
bundle,
|
|
@@ -110,44 +96,38 @@ var formatProductToCartItem = (params) => {
|
|
|
110
96
|
discounts: []
|
|
111
97
|
});
|
|
112
98
|
cartItem.summaryOriginTotal = (origin_total || 0) * (num || 1);
|
|
113
|
-
cartItem.image = product
|
|
114
|
-
cartItem.like_status =
|
|
115
|
-
cartItem.duration = product
|
|
116
|
-
cartItem.isNormalProduct = (0,
|
|
117
|
-
cartItem.is_charge_tax = product
|
|
99
|
+
cartItem.image = product?.cover;
|
|
100
|
+
cartItem.like_status = 'common';
|
|
101
|
+
cartItem.duration = product?.duration;
|
|
102
|
+
cartItem.isNormalProduct = (0, _utils.isNormalProduct)(product);
|
|
103
|
+
cartItem.is_charge_tax = product?.is_charge_tax;
|
|
118
104
|
}
|
|
119
|
-
if (bundle
|
|
105
|
+
if (bundle?.length) {
|
|
120
106
|
cartItem.bundle = formatBundle(bundle);
|
|
121
107
|
}
|
|
122
|
-
if (options
|
|
108
|
+
if (options?.length) {
|
|
123
109
|
cartItem.options = formatOptions(options);
|
|
124
110
|
}
|
|
111
|
+
// 拼装出 product_option_string
|
|
125
112
|
if (product_variant_id) {
|
|
126
|
-
const sku_key = (
|
|
127
|
-
(n) => n.id === product_variant_id
|
|
128
|
-
)) == null ? void 0 : _b.sku_key;
|
|
113
|
+
const sku_key = product?.variant?.find(n => n.id === product_variant_id)?.sku_key;
|
|
129
114
|
if (sku_key) {
|
|
130
|
-
const sku_key_arr = sku_key.split(
|
|
115
|
+
const sku_key_arr = sku_key.split('_');
|
|
131
116
|
const product_option_string = [];
|
|
132
|
-
sku_key_arr.forEach(
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
(n) => String(n.position_id) === keyMap[0]
|
|
137
|
-
);
|
|
138
|
-
const targetVariantItem = (_b2 = targetVariantGroup == null ? void 0 : targetVariantGroup.variant_item) == null ? void 0 : _b2.find(
|
|
139
|
-
(n) => String(n.position_id) === keyMap[1]
|
|
140
|
-
);
|
|
117
|
+
sku_key_arr.forEach(item => {
|
|
118
|
+
const keyMap = item.split(':');
|
|
119
|
+
const targetVariantGroup = product?.variant_group?.find(n => String(n.position_id) === keyMap[0]);
|
|
120
|
+
const targetVariantItem = targetVariantGroup?.variant_item?.find(n => String(n.position_id) === keyMap[1]);
|
|
141
121
|
if (targetVariantGroup && targetVariantItem) {
|
|
142
|
-
product_option_string.push(
|
|
143
|
-
`${targetVariantGroup.name}:${targetVariantItem.name}`
|
|
144
|
-
);
|
|
122
|
+
product_option_string.push(`${targetVariantGroup.name}:${targetVariantItem.name}`);
|
|
145
123
|
}
|
|
146
124
|
});
|
|
147
|
-
cartItem.product_option_string = product_option_string.join(
|
|
125
|
+
cartItem.product_option_string = product_option_string.join(', ');
|
|
148
126
|
}
|
|
149
127
|
}
|
|
150
|
-
|
|
128
|
+
|
|
129
|
+
// 如果商品有定金规则,则计算定金
|
|
130
|
+
if (product?.custom_deposit_data?.has_deposit == 1) {
|
|
151
131
|
cartItem.deposit = getProductDeposit({
|
|
152
132
|
cartItem,
|
|
153
133
|
product,
|
|
@@ -160,8 +140,8 @@ var formatProductToCartItem = (params) => {
|
|
|
160
140
|
cartItem._origin = oringin;
|
|
161
141
|
return cartItem;
|
|
162
142
|
};
|
|
163
|
-
|
|
164
|
-
|
|
143
|
+
exports.formatProductToCartItem = formatProductToCartItem;
|
|
144
|
+
const formatProductToCartItemOrigin = params => {
|
|
165
145
|
const {
|
|
166
146
|
cartItem,
|
|
167
147
|
product,
|
|
@@ -171,177 +151,241 @@ var formatProductToCartItemOrigin = (params) => {
|
|
|
171
151
|
quantity = 1
|
|
172
152
|
} = params;
|
|
173
153
|
let origin = cartItem._origin;
|
|
174
|
-
const product_discount_difference = (
|
|
175
|
-
|
|
176
|
-
return !((_a2 = item == null ? void 0 : item.metadata) == null ? void 0 : _a2.custom_product_bundle_map_id);
|
|
177
|
-
}).reduce((pre, cur) => {
|
|
178
|
-
var _a2;
|
|
179
|
-
return pre + (((_a2 = cur == null ? void 0 : cur.metadata) == null ? void 0 : _a2.product_discount_difference) || 0);
|
|
154
|
+
const product_discount_difference = (origin.product?.discount_list || []).filter(item => !item?.metadata?.custom_product_bundle_map_id).reduce((pre, cur) => {
|
|
155
|
+
return pre + (cur?.metadata?.product_discount_difference || 0);
|
|
180
156
|
}, 0);
|
|
181
157
|
if (product) {
|
|
182
158
|
origin.product = {
|
|
183
|
-
...origin.product || {},
|
|
159
|
+
...(origin.product || {}),
|
|
184
160
|
num: quantity,
|
|
185
161
|
product_id: product.id,
|
|
186
162
|
product_variant_id: product_variant_id || 0,
|
|
187
|
-
product_bundle:
|
|
188
|
-
|
|
163
|
+
product_bundle: origin.product?.product_bundle || [],
|
|
164
|
+
product_sku: origin.product?.product_sku || {
|
|
165
|
+
option: []
|
|
166
|
+
},
|
|
189
167
|
metadata: {
|
|
190
168
|
product_discount_difference
|
|
191
169
|
}
|
|
192
170
|
};
|
|
193
|
-
|
|
194
|
-
origin.
|
|
195
|
-
|
|
171
|
+
// 时长类型
|
|
172
|
+
origin.sub_type = product?.duration?.type;
|
|
173
|
+
// 时长
|
|
174
|
+
origin.duration = product?.duration?.value;
|
|
175
|
+
if (bundle?.length) {
|
|
196
176
|
origin.product.product_bundle = formatBundleToOrigin(bundle);
|
|
197
177
|
}
|
|
198
|
-
if (options
|
|
199
|
-
origin.product.
|
|
178
|
+
if (options?.length) {
|
|
179
|
+
origin.product.product_sku = {
|
|
180
|
+
...(origin.product.product_sku || {}),
|
|
181
|
+
option: formatOptionsToOrigin(options).map(option => {
|
|
182
|
+
const next = {
|
|
183
|
+
...option,
|
|
184
|
+
add_price: option.add_price ?? option.price
|
|
185
|
+
};
|
|
186
|
+
delete next.price;
|
|
187
|
+
return next;
|
|
188
|
+
})
|
|
189
|
+
};
|
|
200
190
|
}
|
|
201
191
|
}
|
|
202
192
|
return origin;
|
|
203
193
|
};
|
|
204
|
-
|
|
205
|
-
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* 获取商品总价
|
|
197
|
+
* @description 当前总价计算基于商品数量为1
|
|
198
|
+
* @param item 商品
|
|
199
|
+
* @returns 商品总价
|
|
200
|
+
*/
|
|
201
|
+
exports.formatProductToCartItemOrigin = formatProductToCartItemOrigin;
|
|
202
|
+
const getProductTotalPrice = params => {
|
|
203
|
+
const {
|
|
204
|
+
product,
|
|
205
|
+
bundle,
|
|
206
|
+
options,
|
|
207
|
+
discounts
|
|
208
|
+
} = params;
|
|
209
|
+
// const num = params.num || 1;
|
|
206
210
|
let price = Number(product.price);
|
|
207
|
-
|
|
211
|
+
|
|
212
|
+
// option 行:unit 折后价在循环中与主商品使用同一套 getDiscountAmount(含 deductOptionPrice)
|
|
213
|
+
const optionRows = options?.map(currentValue => ({
|
|
208
214
|
unit: Number(currentValue.price ?? currentValue.add_price ?? 0),
|
|
209
215
|
num: Number(currentValue.num ?? currentValue.quantity ?? 1)
|
|
210
|
-
}))
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
216
|
+
})) ?? [];
|
|
217
|
+
|
|
218
|
+
// 如果商品有折扣,则计算折扣
|
|
219
|
+
if (discounts?.length) {
|
|
220
|
+
discounts.forEach(currentValue => {
|
|
214
221
|
const payload = toDiscountPayload(currentValue);
|
|
215
|
-
price = (0,
|
|
216
|
-
if (
|
|
222
|
+
price = (0, _utils2.getDiscountAmount)(payload, price, price);
|
|
223
|
+
if (currentValue?.config?.deductOptionPrice && optionRows.length) {
|
|
217
224
|
for (let i = 0; i < optionRows.length; i++) {
|
|
218
225
|
const row = optionRows[i];
|
|
219
226
|
optionRows[i] = {
|
|
220
227
|
...row,
|
|
221
|
-
unit: (0,
|
|
228
|
+
unit: (0, _utils2.getDiscountAmount)(payload, row.unit, row.unit)
|
|
222
229
|
};
|
|
223
230
|
}
|
|
224
231
|
}
|
|
225
232
|
});
|
|
226
233
|
}
|
|
227
|
-
if (bundle
|
|
234
|
+
if (bundle?.length) {
|
|
228
235
|
price = bundle.reduce((accumulator, currentValue) => {
|
|
229
236
|
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
230
237
|
}, price);
|
|
231
238
|
}
|
|
239
|
+
|
|
240
|
+
// 单规格 / 加购 option
|
|
232
241
|
if (optionRows.length) {
|
|
233
|
-
price = optionRows.reduce(
|
|
234
|
-
(accumulator, row) => accumulator + row.unit * row.num,
|
|
235
|
-
price
|
|
236
|
-
);
|
|
242
|
+
price = optionRows.reduce((accumulator, row) => accumulator + row.unit * row.num, price);
|
|
237
243
|
}
|
|
238
244
|
return Math.max(0, price);
|
|
239
245
|
};
|
|
240
|
-
|
|
241
|
-
|
|
246
|
+
exports.getProductTotalPrice = getProductTotalPrice;
|
|
247
|
+
const getTotalDifference = params => {
|
|
248
|
+
const {
|
|
249
|
+
bundle,
|
|
250
|
+
discounts
|
|
251
|
+
} = params;
|
|
242
252
|
const bundleDiscountList = [];
|
|
243
|
-
if (bundle
|
|
244
|
-
bundle.forEach(
|
|
245
|
-
bundleDiscountList.push(...(currentValue
|
|
253
|
+
if (bundle?.length) {
|
|
254
|
+
bundle.forEach(currentValue => {
|
|
255
|
+
bundleDiscountList.push(...(currentValue?.discount_list || []));
|
|
246
256
|
});
|
|
247
257
|
}
|
|
248
|
-
const allDiscounts = [...discounts || [], ...bundleDiscountList];
|
|
249
|
-
const productDiscountProductDiscountDifference = (0,
|
|
258
|
+
const allDiscounts = [...(discounts || []), ...bundleDiscountList];
|
|
259
|
+
const productDiscountProductDiscountDifference = (0, _utils3.calcDiscountListDifference)(allDiscounts);
|
|
250
260
|
return productDiscountProductDiscountDifference || 0;
|
|
251
261
|
};
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* 获取商品原始总价
|
|
265
|
+
* @description 当前总价计算基于商品数量为1
|
|
266
|
+
* @param item 商品
|
|
267
|
+
* @returns 商品原始总价
|
|
268
|
+
*/
|
|
269
|
+
const getProductOriginTotalPrice = params => {
|
|
270
|
+
const {
|
|
271
|
+
product,
|
|
272
|
+
bundle,
|
|
273
|
+
options,
|
|
274
|
+
discounts
|
|
275
|
+
} = params;
|
|
276
|
+
const num = params?.num || 1;
|
|
255
277
|
let price = Number(product.original_price);
|
|
256
|
-
if ((isNaN(price) || price === 0) && !
|
|
257
|
-
return
|
|
278
|
+
if ((isNaN(price) || price === 0) && !discounts?.length) {
|
|
279
|
+
return undefined;
|
|
258
280
|
}
|
|
259
|
-
if (bundle
|
|
281
|
+
if (bundle?.length) {
|
|
260
282
|
price = bundle.reduce((accumulator, currentValue) => {
|
|
261
283
|
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
262
284
|
}, price);
|
|
263
285
|
}
|
|
264
|
-
|
|
286
|
+
|
|
287
|
+
// 单规格
|
|
288
|
+
if (options?.length) {
|
|
265
289
|
price = options.reduce((accumulator, currentValue) => {
|
|
266
290
|
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
267
291
|
}, price);
|
|
268
292
|
}
|
|
269
293
|
return price;
|
|
270
294
|
};
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* 格式化套餐规格信息
|
|
298
|
+
* @param options 套餐规格信息
|
|
299
|
+
* @returns 格式化后的套餐规格信息
|
|
300
|
+
*/
|
|
301
|
+
exports.getProductOriginTotalPrice = getProductOriginTotalPrice;
|
|
302
|
+
const formatOptions = options => {
|
|
303
|
+
if (!options?.length) return [];
|
|
304
|
+
return options.map(item => {
|
|
275
305
|
return {
|
|
276
|
-
id: item
|
|
277
|
-
name: item
|
|
278
|
-
num: item
|
|
279
|
-
price: item
|
|
280
|
-
total: item
|
|
281
|
-
origin_total: item
|
|
306
|
+
id: item?.id,
|
|
307
|
+
name: item?.name,
|
|
308
|
+
num: item?.num,
|
|
309
|
+
price: item?.price,
|
|
310
|
+
total: item?.price,
|
|
311
|
+
origin_total: item?.original_price
|
|
282
312
|
};
|
|
283
313
|
});
|
|
284
314
|
};
|
|
285
|
-
|
|
286
|
-
|
|
315
|
+
exports.formatOptions = formatOptions;
|
|
316
|
+
const formatOptionsToOrigin = options => {
|
|
317
|
+
if (!options?.length) {
|
|
287
318
|
return [];
|
|
288
319
|
}
|
|
289
|
-
return options.map(
|
|
320
|
+
return options.map(d => {
|
|
290
321
|
return {
|
|
291
322
|
num: d.num,
|
|
292
|
-
option_group_item_id: d.
|
|
323
|
+
option_group_item_id: d.option_group_item_id,
|
|
293
324
|
option_group_id: d.option_group_id
|
|
294
325
|
};
|
|
295
326
|
});
|
|
296
327
|
};
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* 格式化商品套餐信息
|
|
331
|
+
* @param bundle 商品套餐信息
|
|
332
|
+
* @returns 格式化后的商品套餐信息
|
|
333
|
+
*/
|
|
334
|
+
exports.formatOptionsToOrigin = formatOptionsToOrigin;
|
|
335
|
+
const formatBundle = bundle => {
|
|
336
|
+
if (!bundle?.length) return [];
|
|
337
|
+
return bundle.map(item => {
|
|
301
338
|
return {
|
|
302
|
-
id: item
|
|
303
|
-
title: item
|
|
304
|
-
num: item
|
|
305
|
-
price: item
|
|
306
|
-
total: item
|
|
307
|
-
price_type: item
|
|
308
|
-
original_price: item
|
|
309
|
-
original_total: item
|
|
310
|
-
price_type_ext: item
|
|
311
|
-
bundle_sum_price: item
|
|
312
|
-
bundle_sum_type: item
|
|
313
|
-
options: formatOptions(item
|
|
339
|
+
id: item?.id,
|
|
340
|
+
title: item?.title,
|
|
341
|
+
num: item?.num,
|
|
342
|
+
price: item?.price,
|
|
343
|
+
total: item?.price,
|
|
344
|
+
price_type: item?.price_type,
|
|
345
|
+
original_price: item?.original_price,
|
|
346
|
+
original_total: item?.original_total,
|
|
347
|
+
price_type_ext: item?.price_type_ext,
|
|
348
|
+
bundle_sum_price: item?.bundle_sum_price,
|
|
349
|
+
bundle_sum_type: item?.bundle_sum_type,
|
|
350
|
+
options: formatOptions(item?.option),
|
|
314
351
|
_bundle_product_id: item._bundle_product_id,
|
|
315
352
|
discount_list: item.discount_list,
|
|
316
353
|
originBundleItem: item.originBundleItem || item,
|
|
317
|
-
is_charge_tax: item
|
|
354
|
+
is_charge_tax: item?.is_charge_tax
|
|
318
355
|
};
|
|
319
356
|
});
|
|
320
357
|
};
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
return bundle.map(
|
|
325
|
-
const getBundleValueByKey =
|
|
326
|
-
|
|
327
|
-
return (d == null ? void 0 : d[key]) || ((_a = d == null ? void 0 : d.originBundleItem) == null ? void 0 : _a[key]);
|
|
358
|
+
exports.formatBundle = formatBundle;
|
|
359
|
+
const formatBundleToOrigin = bundle => {
|
|
360
|
+
if (!bundle?.length) return [];
|
|
361
|
+
return bundle.map(d => {
|
|
362
|
+
const getBundleValueByKey = key => {
|
|
363
|
+
return d?.[key] || d?.originBundleItem?.[key];
|
|
328
364
|
};
|
|
329
|
-
const product_discount_difference = (
|
|
330
|
-
|
|
331
|
-
return pre + (((_a = cur == null ? void 0 : cur.metadata) == null ? void 0 : _a.product_discount_difference) || 0);
|
|
365
|
+
const product_discount_difference = (d?.discount_list || []).reduce((pre, cur) => {
|
|
366
|
+
return pre + (cur?.metadata?.product_discount_difference || 0);
|
|
332
367
|
}, 0);
|
|
368
|
+
const normalizedBundle = {
|
|
369
|
+
...d,
|
|
370
|
+
// 计算 markdown 净额时只传真实毛价;若仅有 bundle_selling_price,则由 helper 当历史净额兜底。
|
|
371
|
+
price: d?.price ?? d?.custom_price,
|
|
372
|
+
bundle_selling_price: d?.bundle_selling_price,
|
|
373
|
+
price_type: d?.price_type ?? d?.custom_price_type,
|
|
374
|
+
price_type_ext: d?.price_type_ext ?? d?.custom_price_type_ext,
|
|
375
|
+
option: getBundleValueByKey('option')
|
|
376
|
+
};
|
|
333
377
|
return {
|
|
334
|
-
bundle_group_id: getBundleValueByKey(
|
|
378
|
+
bundle_group_id: getBundleValueByKey('group_id'),
|
|
335
379
|
bundle_id: d.id,
|
|
336
|
-
bundle_product_id: getBundleValueByKey(
|
|
337
|
-
bundle_variant_id: getBundleValueByKey(
|
|
380
|
+
bundle_product_id: getBundleValueByKey('_bundle_product_id') || getBundleValueByKey('product_id'),
|
|
381
|
+
bundle_variant_id: getBundleValueByKey('bundle_variant_id'),
|
|
338
382
|
num: d.num,
|
|
339
|
-
extension_id: getBundleValueByKey(
|
|
340
|
-
extension_type: getBundleValueByKey(
|
|
341
|
-
option: formatOptionsToOrigin(getBundleValueByKey(
|
|
383
|
+
extension_id: getBundleValueByKey('extension_id'),
|
|
384
|
+
extension_type: getBundleValueByKey('extension_type'),
|
|
385
|
+
option: formatOptionsToOrigin(getBundleValueByKey('option')),
|
|
342
386
|
discount_list: d.discount_list,
|
|
343
|
-
"bundle_selling_price":
|
|
344
|
-
|
|
387
|
+
"bundle_selling_price": (0, _utils4.getBundleSellingMagnitude)(normalizedBundle).toFixed(2),
|
|
388
|
+
"custom_price": d?.price,
|
|
345
389
|
metadata: {
|
|
346
390
|
custom_product_bundle_map_id: d._id,
|
|
347
391
|
product_discount_difference
|
|
@@ -349,103 +393,146 @@ var formatBundleToOrigin = (bundle) => {
|
|
|
349
393
|
};
|
|
350
394
|
});
|
|
351
395
|
};
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* 获取商品定金
|
|
399
|
+
* @description 定金基于商品售价来算,最终乘商品数量
|
|
400
|
+
* 1、如果套餐主商品有定金规则,则定金为:(套餐商品总售价 * 定金百分比 + 定金固定金额)* 商品数量
|
|
401
|
+
* 2、如果套餐主商品没有定金规则,子商品有定金规则,则定金为:(套餐子商品售价 * 套餐子商品定金百分比 + 套餐子商品定金固定金额)* 商品数量,最终将所有子商品定金相加
|
|
402
|
+
* 3、普通商品/单规格商品/组合规则商品,定金规则:(商品总售价 * 定金百分比 + 定金固定金额)* 商品数量
|
|
403
|
+
* @param params 参数
|
|
404
|
+
* @returns 商品定金
|
|
405
|
+
*/
|
|
406
|
+
exports.formatBundleToOrigin = formatBundleToOrigin;
|
|
407
|
+
const getProductDeposit = params => {
|
|
408
|
+
const {
|
|
409
|
+
cartItem,
|
|
410
|
+
product,
|
|
411
|
+
bundle,
|
|
412
|
+
options
|
|
413
|
+
} = params;
|
|
414
|
+
const num = params?.num || 1;
|
|
415
|
+
|
|
416
|
+
// 判定商品是否有定金规则
|
|
417
|
+
if (product?.custom_deposit_data?.has_deposit == 1) {
|
|
418
|
+
let total = new _decimal.default(0);
|
|
358
419
|
const {
|
|
359
420
|
deposit_fixed,
|
|
360
421
|
deposit_percentage,
|
|
361
422
|
deposit_policy_data,
|
|
362
423
|
self_deposit_policy_ids
|
|
363
|
-
} =
|
|
424
|
+
} = product?.custom_deposit_data || {};
|
|
425
|
+
// 所有协议数据
|
|
364
426
|
const allProtocols = deposit_policy_data || [];
|
|
427
|
+
// 是否存在定金,主商品has_deposit为1,但是自身没有定金设置,需要判定子商品是否存在定金,如果不存在最终判定也是不存在定金
|
|
365
428
|
let productHasDeposit = false;
|
|
429
|
+
// 关联的定金协议id
|
|
366
430
|
const protocolIds = [];
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
431
|
+
|
|
432
|
+
// 判断主商品是否有定金规则
|
|
433
|
+
if (typeof deposit_fixed === 'string' && typeof deposit_percentage === 'string') {
|
|
434
|
+
const {
|
|
435
|
+
depositTotal,
|
|
436
|
+
result
|
|
437
|
+
} = handleProductDeposit({
|
|
438
|
+
depositData: product?.custom_deposit_data,
|
|
370
439
|
total: cartItem.total || 0,
|
|
371
440
|
num
|
|
372
441
|
});
|
|
373
442
|
if (result) {
|
|
374
443
|
total = depositTotal;
|
|
375
|
-
protocolIds.push(...self_deposit_policy_ids || []);
|
|
444
|
+
protocolIds.push(...(self_deposit_policy_ids || []));
|
|
376
445
|
productHasDeposit = true;
|
|
377
446
|
}
|
|
378
447
|
} else {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
);
|
|
448
|
+
// 组合规格商品
|
|
449
|
+
if (product?.product_variant_id) {
|
|
450
|
+
const variantProduct = product?.variant?.find(item => item?.id === product?.product_variant_id);
|
|
383
451
|
if (variantProduct) {
|
|
384
|
-
const depositData = variantProduct
|
|
385
|
-
const {
|
|
452
|
+
const depositData = variantProduct?.custom_deposit_data;
|
|
453
|
+
const {
|
|
454
|
+
depositTotal,
|
|
455
|
+
result
|
|
456
|
+
} = handleProductDeposit({
|
|
386
457
|
depositData,
|
|
387
|
-
total:
|
|
458
|
+
total: cartItem?.total || 0,
|
|
388
459
|
num
|
|
389
460
|
});
|
|
390
461
|
if (result) {
|
|
391
462
|
total = depositTotal;
|
|
392
|
-
protocolIds.push(...(depositData
|
|
463
|
+
protocolIds.push(...(depositData?.self_deposit_policy_ids || []));
|
|
393
464
|
productHasDeposit = true;
|
|
394
465
|
}
|
|
395
466
|
}
|
|
396
467
|
}
|
|
397
|
-
if (bundle
|
|
468
|
+
if (bundle?.length) {
|
|
398
469
|
total = bundle.reduce((accumulator, currBundleProduct) => {
|
|
399
|
-
const depositData = currBundleProduct
|
|
400
|
-
const {
|
|
470
|
+
const depositData = currBundleProduct?.custom_deposit_data;
|
|
471
|
+
const {
|
|
472
|
+
depositTotal,
|
|
473
|
+
result
|
|
474
|
+
} = handleProductDeposit({
|
|
401
475
|
depositData,
|
|
402
|
-
total: currBundleProduct
|
|
403
|
-
num:
|
|
476
|
+
total: currBundleProduct?.price,
|
|
477
|
+
num: currBundleProduct?.num || 1
|
|
404
478
|
});
|
|
405
479
|
if (result) {
|
|
406
|
-
protocolIds.push(...(depositData
|
|
480
|
+
protocolIds.push(...(depositData?.self_deposit_policy_ids || []));
|
|
407
481
|
productHasDeposit = true;
|
|
408
482
|
return accumulator.plus(depositTotal);
|
|
409
483
|
}
|
|
410
484
|
return accumulator;
|
|
411
|
-
}, new
|
|
485
|
+
}, new _decimal.default(0));
|
|
412
486
|
}
|
|
413
487
|
}
|
|
414
488
|
if (productHasDeposit) {
|
|
415
489
|
const ids = new Set(protocolIds);
|
|
416
|
-
const protocols = allProtocols.filter(
|
|
417
|
-
return {
|
|
490
|
+
const protocols = allProtocols.filter(item => ids.has(item.id));
|
|
491
|
+
return {
|
|
492
|
+
total: total.toNumber(),
|
|
493
|
+
protocols
|
|
494
|
+
};
|
|
418
495
|
}
|
|
419
496
|
return null;
|
|
420
497
|
}
|
|
421
498
|
return null;
|
|
422
499
|
};
|
|
423
|
-
|
|
424
|
-
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* 计算商品定金
|
|
503
|
+
* @param params 参数
|
|
504
|
+
* @returns 商品定金
|
|
505
|
+
*/
|
|
506
|
+
exports.getProductDeposit = getProductDeposit;
|
|
507
|
+
const handleProductDeposit = params => {
|
|
508
|
+
const {
|
|
509
|
+
depositData,
|
|
510
|
+
total,
|
|
511
|
+
num
|
|
512
|
+
} = params;
|
|
425
513
|
if (!depositData) {
|
|
426
|
-
return {
|
|
514
|
+
return {
|
|
515
|
+
result: false,
|
|
516
|
+
depositTotal: new _decimal.default(0)
|
|
517
|
+
};
|
|
427
518
|
}
|
|
428
|
-
const {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
519
|
+
const {
|
|
520
|
+
deposit_fixed,
|
|
521
|
+
deposit_percentage
|
|
522
|
+
} = depositData || {};
|
|
523
|
+
if (typeof deposit_fixed === 'string' && typeof deposit_percentage === 'string') {
|
|
524
|
+
const depositFixed = (0, _decimal.default)(deposit_fixed || 0);
|
|
525
|
+
const depositPercent = (0, _decimal.default)(deposit_percentage || 0);
|
|
526
|
+
const productTotalPrice = (0, _decimal.default)(total || 0);
|
|
433
527
|
const deposit = depositFixed.plus(depositPercent.times(productTotalPrice));
|
|
434
|
-
return {
|
|
528
|
+
return {
|
|
529
|
+
depositTotal: deposit.times(num),
|
|
530
|
+
result: true
|
|
531
|
+
};
|
|
435
532
|
}
|
|
436
|
-
return {
|
|
533
|
+
return {
|
|
534
|
+
result: false,
|
|
535
|
+
depositTotal: new _decimal.default(0)
|
|
536
|
+
};
|
|
437
537
|
};
|
|
438
|
-
|
|
439
|
-
0 && (module.exports = {
|
|
440
|
-
formatBundle,
|
|
441
|
-
formatBundleToOrigin,
|
|
442
|
-
formatOptions,
|
|
443
|
-
formatOptionsToOrigin,
|
|
444
|
-
formatProductToCartItem,
|
|
445
|
-
formatProductToCartItemOrigin,
|
|
446
|
-
getProductDeposit,
|
|
447
|
-
getProductOriginTotalPrice,
|
|
448
|
-
getProductTotalPrice,
|
|
449
|
-
handleProductDeposit,
|
|
450
|
-
handleVariantProduct
|
|
451
|
-
});
|
|
538
|
+
exports.handleProductDeposit = handleProductDeposit;
|