@pisell/pisellos 2.2.244 → 2.2.246
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/model/strategy/adapter/promotion/evaluator.js +3 -2
- package/dist/model/strategy/adapter/walletPass/utils.js +7 -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 +284 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +148 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +218 -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/utils/cartProduct.js +24 -3
- package/dist/modules/Cart/utils/changePrice.js +11 -11
- package/dist/modules/Customer/index.d.ts +20 -0
- package/dist/modules/Customer/index.js +172 -83
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/index.d.ts +1 -1
- package/dist/modules/Discount/index.js +13 -6
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/OpenData/index.d.ts +8 -0
- package/dist/modules/OpenData/index.js +37 -17
- package/dist/modules/Order/index.d.ts +277 -18
- package/dist/modules/Order/index.js +3581 -779
- package/dist/modules/Order/types.d.ts +286 -31
- package/dist/modules/Order/types.js +38 -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.d.ts +147 -5
- package/dist/modules/Order/utils.js +750 -104
- package/dist/modules/Payment/index.d.ts +10 -13
- package/dist/modules/Payment/index.js +467 -837
- package/dist/modules/Payment/types.d.ts +2 -0
- package/dist/modules/Payment/utils.js +2 -1
- package/dist/modules/Payment/walletpass.js +41 -25
- package/dist/modules/ProductList/index.d.ts +16 -12
- package/dist/modules/ProductList/index.js +133 -59
- package/dist/modules/ProductList/types.d.ts +14 -0
- package/dist/modules/Quotation/index.d.ts +0 -1
- package/dist/modules/Quotation/index.js +25 -22
- package/dist/modules/Rules/index.d.ts +4 -0
- package/dist/modules/Rules/index.js +97 -70
- package/dist/modules/Rules/types.d.ts +1 -0
- package/dist/modules/SalesSummary/index.d.ts +8 -25
- package/dist/modules/SalesSummary/index.js +86 -35
- package/dist/modules/SalesSummary/types.d.ts +4 -1
- package/dist/modules/SalesSummary/utils.d.ts +2 -25
- package/dist/modules/SalesSummary/utils.js +794 -162
- package/dist/modules/Schedule/index.d.ts +7 -0
- package/dist/modules/Schedule/index.js +24 -2
- package/dist/modules/Summary/index.js +4 -3
- package/dist/modules/SurchargeList/index.d.ts +16 -0
- package/dist/modules/SurchargeList/index.js +162 -0
- package/dist/modules/SurchargeList/types.d.ts +11 -0
- package/dist/modules/SurchargeList/types.js +1 -0
- package/dist/modules/index.d.ts +2 -0
- package/dist/modules/index.js +3 -1
- package/dist/plugins/request.d.ts +1 -0
- package/dist/server/index.d.ts +204 -1
- package/dist/server/index.js +3654 -922
- package/dist/server/modules/index.d.ts +2 -0
- package/dist/server/modules/index.js +2 -0
- package/dist/server/modules/order/index.d.ts +120 -3
- package/dist/server/modules/order/index.js +1762 -448
- package/dist/server/modules/order/types.d.ts +32 -3
- package/dist/server/modules/order/types.js +8 -0
- package/dist/server/modules/order/utils/filterBookings.js +26 -3
- package/dist/server/modules/order/utils/filterOrders.js +23 -8
- 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 +34 -7
- package/dist/server/modules/products/index.js +631 -317
- package/dist/server/modules/resource/index.d.ts +2 -0
- package/dist/server/modules/resource/index.js +29 -3
- package/dist/server/modules/schedule/index.d.ts +4 -4
- package/dist/server/modules/schedule/index.js +111 -88
- package/dist/server/test.json +713 -0
- package/dist/server/utils/small-ticket.d.ts +71 -0
- package/dist/server/utils/small-ticket.js +840 -0
- package/dist/solution/BaseSales/index.d.ts +133 -10
- package/dist/solution/BaseSales/index.js +1950 -447
- package/dist/solution/BaseSales/types.d.ts +82 -6
- package/dist/solution/BaseSales/types.js +5 -4
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
- package/dist/solution/BaseSales/utils/cartPromotion.js +1438 -0
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/dist/solution/BaseSales/utils/quotationPrice.js +237 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +105 -24
- package/dist/solution/BaseSales/utils.d.ts +1 -1
- package/dist/solution/BaseSales/utils.js +62 -21
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +271 -11
- package/dist/solution/BookingTicket/index.js +1777 -242
- package/dist/solution/BookingTicket/types.d.ts +118 -1
- package/dist/solution/BookingTicket/types.js +41 -2
- 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 +40 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.js +70 -0
- package/dist/solution/BookingTicket/utils/cartView.d.ts +9 -1
- package/dist/solution/BookingTicket/utils/cartView.js +94 -7
- package/dist/solution/BookingTicket/utils/exampleData.d.ts +123 -0
- package/dist/solution/BookingTicket/utils/exampleData.js +183 -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/formatGlobalScan.d.ts +32 -0
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +56 -0
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +20 -8
- 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/Checkout/index.d.ts +1 -0
- package/dist/solution/Checkout/index.js +10 -9
- package/dist/solution/RegisterAndLogin/config.js +2 -10
- package/dist/solution/ScanOrder/index.d.ts +9 -3
- package/dist/solution/ScanOrder/index.js +241 -134
- package/dist/solution/ScanOrder/types.d.ts +9 -5
- package/dist/solution/ScanOrder/types.js +2 -3
- package/dist/solution/ScanOrder/utils.d.ts +1 -1
- package/dist/solution/ScanOrder/utils.js +84 -22
- package/dist/solution/VenueBooking/index.d.ts +5 -2
- package/dist/solution/VenueBooking/index.js +110 -59
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/dist/types/index.d.ts +10 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +2 -1
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +3 -2
- package/lib/modules/BookingContext/index.d.ts +48 -0
- package/lib/modules/BookingContext/index.js +368 -0
- package/lib/modules/BookingContext/types.d.ts +102 -0
- package/lib/modules/BookingContext/types.js +34 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +276 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +154 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +201 -0
- package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/lib/modules/BookingContext/utils/flexible.js +80 -0
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
- package/lib/modules/BookingContext/utils/index.d.ts +11 -0
- package/lib/modules/BookingContext/utils/index.js +43 -0
- package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/lib/modules/BookingContext/utils/noResource.js +90 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +56 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/lib/modules/BookingContext/utils/productExtend.js +283 -0
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
- package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
- package/lib/modules/BookingContext/utils/resources.js +377 -0
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
- package/lib/modules/Cart/utils/cartProduct.js +20 -3
- package/lib/modules/Cart/utils/changePrice.js +12 -20
- package/lib/modules/Customer/index.d.ts +20 -0
- package/lib/modules/Customer/index.js +64 -11
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/index.d.ts +1 -1
- package/lib/modules/Discount/index.js +9 -1
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/OpenData/index.d.ts +8 -0
- package/lib/modules/OpenData/index.js +19 -5
- package/lib/modules/Order/index.d.ts +277 -18
- package/lib/modules/Order/index.js +2317 -337
- package/lib/modules/Order/types.d.ts +286 -31
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/lib/modules/Order/utils/manualProductDiscount.js +206 -0
- package/lib/modules/Order/utils.d.ts +147 -5
- package/lib/modules/Order/utils.js +615 -46
- package/lib/modules/Payment/index.d.ts +10 -13
- package/lib/modules/Payment/index.js +18 -150
- package/lib/modules/Payment/types.d.ts +2 -0
- package/lib/modules/Payment/utils.js +2 -1
- package/lib/modules/Payment/walletpass.js +16 -3
- package/lib/modules/ProductList/index.d.ts +16 -12
- package/lib/modules/ProductList/index.js +41 -4
- package/lib/modules/ProductList/types.d.ts +14 -0
- package/lib/modules/Quotation/index.d.ts +0 -1
- package/lib/modules/Quotation/index.js +19 -16
- package/lib/modules/Rules/index.d.ts +4 -0
- package/lib/modules/Rules/index.js +137 -120
- package/lib/modules/Rules/types.d.ts +1 -0
- package/lib/modules/SalesSummary/index.d.ts +8 -25
- package/lib/modules/SalesSummary/index.js +30 -4
- package/lib/modules/SalesSummary/types.d.ts +4 -1
- package/lib/modules/SalesSummary/utils.d.ts +2 -25
- package/lib/modules/SalesSummary/utils.js +645 -91
- package/lib/modules/Schedule/index.d.ts +7 -0
- package/lib/modules/Schedule/index.js +17 -1
- package/lib/modules/Summary/index.js +5 -4
- package/lib/modules/SurchargeList/index.d.ts +16 -0
- package/lib/modules/SurchargeList/index.js +89 -0
- package/lib/modules/SurchargeList/types.d.ts +11 -0
- package/lib/modules/SurchargeList/types.js +17 -0
- package/lib/modules/index.d.ts +2 -0
- package/lib/modules/index.js +5 -1
- package/lib/plugins/request.d.ts +1 -0
- package/lib/server/index.d.ts +204 -1
- package/lib/server/index.js +1891 -59
- package/lib/server/modules/index.d.ts +2 -0
- package/lib/server/modules/index.js +3 -0
- package/lib/server/modules/order/index.d.ts +120 -3
- package/lib/server/modules/order/index.js +887 -94
- package/lib/server/modules/order/types.d.ts +32 -3
- package/lib/server/modules/order/utils/filterBookings.js +24 -5
- package/lib/server/modules/order/utils/filterOrders.js +15 -6
- package/lib/server/modules/payment/index.d.ts +28 -0
- package/lib/server/modules/payment/index.js +192 -0
- package/lib/server/modules/payment/types.d.ts +9 -0
- package/lib/server/modules/payment/types.js +17 -0
- package/lib/server/modules/products/index.d.ts +34 -7
- package/lib/server/modules/products/index.js +189 -54
- package/lib/server/modules/resource/index.d.ts +2 -0
- package/lib/server/modules/resource/index.js +27 -3
- package/lib/server/modules/schedule/index.d.ts +4 -4
- package/lib/server/modules/schedule/index.js +47 -40
- package/lib/server/test.json +713 -0
- package/lib/server/utils/small-ticket.d.ts +71 -0
- package/lib/server/utils/small-ticket.js +800 -0
- package/lib/solution/BaseSales/index.d.ts +133 -10
- package/lib/solution/BaseSales/index.js +1111 -63
- package/lib/solution/BaseSales/types.d.ts +82 -6
- package/lib/solution/BaseSales/types.js +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
- package/lib/solution/BaseSales/utils/cartPromotion.js +992 -0
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/lib/solution/BaseSales/utils/quotationPrice.js +277 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +106 -18
- package/lib/solution/BaseSales/utils.d.ts +1 -1
- package/lib/solution/BaseSales/utils.js +54 -10
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +271 -11
- package/lib/solution/BookingTicket/index.js +922 -29
- package/lib/solution/BookingTicket/types.d.ts +118 -1
- package/lib/solution/BookingTicket/types.js +11 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
- package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +125 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +40 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.js +44 -2
- package/lib/solution/BookingTicket/utils/cartView.d.ts +9 -1
- package/lib/solution/BookingTicket/utils/cartView.js +61 -6
- package/lib/solution/BookingTicket/utils/exampleData.d.ts +123 -0
- package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +254 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +169 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +51 -0
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +17 -3
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +127 -0
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +85 -0
- package/lib/solution/Checkout/index.d.ts +1 -0
- package/lib/solution/Checkout/index.js +1 -2
- package/lib/solution/RegisterAndLogin/config.js +2 -10
- package/lib/solution/ScanOrder/index.d.ts +9 -3
- package/lib/solution/ScanOrder/index.js +153 -70
- package/lib/solution/ScanOrder/types.d.ts +9 -5
- package/lib/solution/ScanOrder/utils.d.ts +1 -1
- package/lib/solution/ScanOrder/utils.js +83 -17
- package/lib/solution/VenueBooking/index.d.ts +5 -2
- package/lib/solution/VenueBooking/index.js +54 -17
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/lib/types/index.d.ts +10 -0
- package/package.json +1 -1
- package/dist/solution/Checkout/appointmentDemo.json +0 -1
- package/lib/solution/Checkout/appointmentDemo.json +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
var _excluded = ["unique_identification_number"],
|
|
2
|
-
_excluded2 = ["num", "
|
|
3
|
-
_excluded3 = ["_extend", "relation_id", "table_form_id", "resource_id", "summary", "lastOrderInfo", "paid_amount", "shop_id", "shop_note", "shop_service_type", "start_time", "customer", "
|
|
2
|
+
_excluded2 = ["num", "surcharge_fee", "discount_amount", "discount_type", "discountway", "product_discount_reason", "discount_per"],
|
|
3
|
+
_excluded3 = ["_extend", "relation_id", "table_form_id", "resource_id", "summary", "lastOrderInfo", "paid_amount", "shop_id", "shop_note", "shop_service_type", "start_time", "customer", "discount_list", "tax_fee", "total_amount", "total_refund_amount", "create_date", "holder_id"],
|
|
4
4
|
_excluded4 = ["collect_pax", "table_occupancy_duration"];
|
|
5
5
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
6
6
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
7
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
7
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
9
8
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
9
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
11
10
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
11
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
12
12
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
13
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
14
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -19,7 +19,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
19
19
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
20
20
|
import dayjs from "dayjs";
|
|
21
21
|
import Decimal from 'decimal.js';
|
|
22
|
-
import { buildProductLineFingerprint } from "../../solution/ScanOrder/utils";
|
|
22
|
+
import { buildProductLineFingerprint, createEmptySummary } from "../../solution/ScanOrder/utils";
|
|
23
23
|
/**
|
|
24
24
|
* 把"含 option 的主商品单价"与 bundle 合成"单行 composite 单价"。
|
|
25
25
|
*
|
|
@@ -43,13 +43,15 @@ export function composeLinePrice(params) {
|
|
|
43
43
|
_step;
|
|
44
44
|
try {
|
|
45
45
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
46
|
-
var _ref, _item$
|
|
46
|
+
var _ref, _item$num;
|
|
47
47
|
var item = _step.value;
|
|
48
|
-
|
|
49
|
-
var
|
|
50
|
-
|
|
48
|
+
// markdown(减价)按带符号净额取减;markup/原价维持相加。
|
|
49
|
+
var signedUnit = getBundleSignedUnit(item, {
|
|
50
|
+
useOriginal: useOriginalBundle
|
|
51
|
+
});
|
|
52
|
+
var rawNum = (_ref = (_item$num = item === null || item === void 0 ? void 0 : item.num) !== null && _item$num !== void 0 ? _item$num : item === null || item === void 0 ? void 0 : item.quantity) !== null && _ref !== void 0 ? _ref : 1;
|
|
51
53
|
var num = new Decimal(Number(rawNum) || 0);
|
|
52
|
-
total = total.plus(
|
|
54
|
+
total = total.plus(signedUnit.times(num));
|
|
53
55
|
}
|
|
54
56
|
} catch (err) {
|
|
55
57
|
_iterator.e(err);
|
|
@@ -59,9 +61,30 @@ export function composeLinePrice(params) {
|
|
|
59
61
|
}
|
|
60
62
|
return total.toDecimalPlaces(2).toFixed(2);
|
|
61
63
|
}
|
|
64
|
+
export function normalizeProductSkuOptions(options) {
|
|
65
|
+
if (!Array.isArray(options)) return [];
|
|
66
|
+
return options.map(function (option) {
|
|
67
|
+
var _normalized$add_price;
|
|
68
|
+
var normalized = _objectSpread({}, option && _typeof(option) === 'object' ? option : {});
|
|
69
|
+
var addPrice = (_normalized$add_price = normalized.add_price) !== null && _normalized$add_price !== void 0 ? _normalized$add_price : normalized.price;
|
|
70
|
+
if (addPrice !== undefined) normalized.add_price = addPrice;
|
|
71
|
+
delete normalized.price;
|
|
72
|
+
return normalized;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export function ensureProductSku(product) {
|
|
76
|
+
var rawSku = product !== null && product !== void 0 && product.product_sku && _typeof(product.product_sku) === 'object' ? product.product_sku : {};
|
|
77
|
+
return _objectSpread(_objectSpread({}, rawSku), {}, {
|
|
78
|
+
option: normalizeProductSkuOptions(rawSku.option)
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
export function getProductSkuOptions(product) {
|
|
82
|
+
return ensureProductSku(product).option;
|
|
83
|
+
}
|
|
62
84
|
|
|
63
85
|
/**
|
|
64
|
-
* 计算 option 单价合计:Σ(option.
|
|
86
|
+
* 计算 option 单价合计:Σ(option.add_price × option.num)。
|
|
87
|
+
* 兼容入参仍带旧 `price` 的调用方,但运行时归一化后只维护 `add_price`。
|
|
65
88
|
* 在新语义 v2 下,main_product_original_price = source_product_price + 本函数结果。
|
|
66
89
|
*/
|
|
67
90
|
export function sumOptionUnitPrice(options) {
|
|
@@ -71,8 +94,9 @@ export function sumOptionUnitPrice(options) {
|
|
|
71
94
|
_step2;
|
|
72
95
|
try {
|
|
73
96
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
97
|
+
var _opt$add_price;
|
|
74
98
|
var opt = _step2.value;
|
|
75
|
-
var price = new Decimal(Number(opt === null || opt === void 0 ? void 0 : opt.price) || 0);
|
|
99
|
+
var price = new Decimal(Number((_opt$add_price = opt === null || opt === void 0 ? void 0 : opt.add_price) !== null && _opt$add_price !== void 0 ? _opt$add_price : opt === null || opt === void 0 ? void 0 : opt.price) || 0);
|
|
76
100
|
var num = new Decimal(Number(opt === null || opt === void 0 ? void 0 : opt.num) || 0);
|
|
77
101
|
total = total.plus(price.times(num));
|
|
78
102
|
}
|
|
@@ -83,6 +107,263 @@ export function sumOptionUnitPrice(options) {
|
|
|
83
107
|
}
|
|
84
108
|
return total;
|
|
85
109
|
}
|
|
110
|
+
function getSafeOrderProductNum(num) {
|
|
111
|
+
var parsedNum = Number(num !== null && num !== void 0 ? num : 1);
|
|
112
|
+
if (!Number.isFinite(parsedNum) || parsedNum < 1) return 1;
|
|
113
|
+
return Math.floor(parsedNum);
|
|
114
|
+
}
|
|
115
|
+
function getOrderProductDepositUnitTotal(product) {
|
|
116
|
+
var _ref2;
|
|
117
|
+
var metadata = product.metadata || {};
|
|
118
|
+
var paymentPrice = metadata.main_product_attached_bundle_payment_price;
|
|
119
|
+
var mainSellingPrice = metadata.main_product_selling_price;
|
|
120
|
+
var fallbackPrice = product.selling_price;
|
|
121
|
+
return new Decimal(Number((_ref2 = paymentPrice !== null && paymentPrice !== void 0 ? paymentPrice : mainSellingPrice) !== null && _ref2 !== void 0 ? _ref2 : fallbackPrice) || 0);
|
|
122
|
+
}
|
|
123
|
+
function normalizeDepositProtocols(protocols) {
|
|
124
|
+
if (!Array.isArray(protocols)) return [];
|
|
125
|
+
return protocols.reduce(function (result, protocol) {
|
|
126
|
+
var id = Number(protocol === null || protocol === void 0 ? void 0 : protocol.id);
|
|
127
|
+
if (!Number.isFinite(id)) return result;
|
|
128
|
+
result.push({
|
|
129
|
+
id: Math.floor(id),
|
|
130
|
+
title: String((protocol === null || protocol === void 0 ? void 0 : protocol.title) || '')
|
|
131
|
+
});
|
|
132
|
+
return result;
|
|
133
|
+
}, []);
|
|
134
|
+
}
|
|
135
|
+
function getDepositPolicyIds(depositData) {
|
|
136
|
+
var ids = [].concat(_toConsumableArray(Array.isArray(depositData === null || depositData === void 0 ? void 0 : depositData.self_deposit_policy_ids) ? depositData.self_deposit_policy_ids : []), _toConsumableArray(Array.isArray(depositData === null || depositData === void 0 ? void 0 : depositData.deposit_policy_ids) ? depositData.deposit_policy_ids : []));
|
|
137
|
+
return ids.reduce(function (result, id) {
|
|
138
|
+
var normalizedId = Number(id);
|
|
139
|
+
if (!Number.isFinite(normalizedId)) return result;
|
|
140
|
+
result.push(Math.floor(normalizedId));
|
|
141
|
+
return result;
|
|
142
|
+
}, []);
|
|
143
|
+
}
|
|
144
|
+
function handleOrderProductDeposit(params) {
|
|
145
|
+
var depositData = params.depositData,
|
|
146
|
+
total = params.total,
|
|
147
|
+
num = params.num;
|
|
148
|
+
if (!depositData) return {
|
|
149
|
+
result: false,
|
|
150
|
+
depositTotal: new Decimal(0)
|
|
151
|
+
};
|
|
152
|
+
var deposit_fixed = depositData.deposit_fixed,
|
|
153
|
+
deposit_percentage = depositData.deposit_percentage;
|
|
154
|
+
if (typeof deposit_fixed !== 'string' || typeof deposit_percentage !== 'string') {
|
|
155
|
+
return {
|
|
156
|
+
result: false,
|
|
157
|
+
depositTotal: new Decimal(0)
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
var depositFixed = new Decimal(deposit_fixed || 0);
|
|
161
|
+
var depositPercent = new Decimal(deposit_percentage || 0);
|
|
162
|
+
var productTotalPrice = new Decimal(total || 0);
|
|
163
|
+
var deposit = depositFixed.plus(depositPercent.times(productTotalPrice));
|
|
164
|
+
return {
|
|
165
|
+
depositTotal: deposit.times(num),
|
|
166
|
+
result: true
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function resolveOrderProductDepositSource(product, runtimeOrigin) {
|
|
170
|
+
var _ref3, _record$custom_deposi, _ref4, _record$variant;
|
|
171
|
+
var record = product;
|
|
172
|
+
var origin = record._origin || runtimeOrigin || {};
|
|
173
|
+
var originProduct = origin.product || {};
|
|
174
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, originProduct), origin), record), {}, {
|
|
175
|
+
custom_deposit_data: (_ref3 = (_record$custom_deposi = record.custom_deposit_data) !== null && _record$custom_deposi !== void 0 ? _record$custom_deposi : origin.custom_deposit_data) !== null && _ref3 !== void 0 ? _ref3 : originProduct.custom_deposit_data,
|
|
176
|
+
variant: (_ref4 = (_record$variant = record.variant) !== null && _record$variant !== void 0 ? _record$variant : origin.variant) !== null && _ref4 !== void 0 ? _ref4 : originProduct.variant
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
function getOrderProductDeposit(product, runtimeOrigin) {
|
|
180
|
+
var depositProduct = resolveOrderProductDepositSource(product, runtimeOrigin);
|
|
181
|
+
var depositData = depositProduct.custom_deposit_data;
|
|
182
|
+
if ((depositData === null || depositData === void 0 ? void 0 : depositData.has_deposit) != 1) return null;
|
|
183
|
+
var num = getSafeOrderProductNum(product.num);
|
|
184
|
+
var total = getOrderProductDepositUnitTotal(product).times(num);
|
|
185
|
+
var allProtocols = normalizeDepositProtocols(depositData.deposit_policy_data);
|
|
186
|
+
var protocolIds = [];
|
|
187
|
+
var depositTotal = new Decimal(0);
|
|
188
|
+
var hasDeposit = false;
|
|
189
|
+
if (typeof depositData.deposit_fixed === 'string' && typeof depositData.deposit_percentage === 'string') {
|
|
190
|
+
var result = handleOrderProductDeposit({
|
|
191
|
+
depositData: depositData,
|
|
192
|
+
total: total,
|
|
193
|
+
num: num
|
|
194
|
+
});
|
|
195
|
+
if (result.result) {
|
|
196
|
+
depositTotal = result.depositTotal;
|
|
197
|
+
protocolIds.push.apply(protocolIds, _toConsumableArray(getDepositPolicyIds({
|
|
198
|
+
self_deposit_policy_ids: depositData.self_deposit_policy_ids
|
|
199
|
+
})));
|
|
200
|
+
hasDeposit = true;
|
|
201
|
+
}
|
|
202
|
+
} else {
|
|
203
|
+
var _depositProduct$produ;
|
|
204
|
+
var productVariantId = (_depositProduct$produ = depositProduct.product_variant_id) !== null && _depositProduct$produ !== void 0 ? _depositProduct$produ : product.product_variant_id;
|
|
205
|
+
if (productVariantId) {
|
|
206
|
+
var variantProduct = (depositProduct.variant || []).find(function (item) {
|
|
207
|
+
return (item === null || item === void 0 ? void 0 : item.id) === productVariantId;
|
|
208
|
+
});
|
|
209
|
+
var variantDepositData = variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.custom_deposit_data;
|
|
210
|
+
var _result = handleOrderProductDeposit({
|
|
211
|
+
depositData: variantDepositData,
|
|
212
|
+
total: total,
|
|
213
|
+
num: num
|
|
214
|
+
});
|
|
215
|
+
if (_result.result) {
|
|
216
|
+
depositTotal = _result.depositTotal;
|
|
217
|
+
protocolIds.push.apply(protocolIds, _toConsumableArray(getDepositPolicyIds({
|
|
218
|
+
self_deposit_policy_ids: variantDepositData === null || variantDepositData === void 0 ? void 0 : variantDepositData.self_deposit_policy_ids
|
|
219
|
+
})));
|
|
220
|
+
hasDeposit = true;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (Array.isArray(product.product_bundle) && product.product_bundle.length) {
|
|
224
|
+
depositTotal = product.product_bundle.reduce(function (accumulator, bundleProduct) {
|
|
225
|
+
var bundleDepositData = bundleProduct === null || bundleProduct === void 0 ? void 0 : bundleProduct.custom_deposit_data;
|
|
226
|
+
var result = handleOrderProductDeposit({
|
|
227
|
+
depositData: bundleDepositData,
|
|
228
|
+
total: bundleProduct === null || bundleProduct === void 0 ? void 0 : bundleProduct.price,
|
|
229
|
+
num: getSafeOrderProductNum((bundleProduct === null || bundleProduct === void 0 ? void 0 : bundleProduct.num) || 1)
|
|
230
|
+
});
|
|
231
|
+
if (!result.result) return accumulator;
|
|
232
|
+
protocolIds.push.apply(protocolIds, _toConsumableArray(getDepositPolicyIds({
|
|
233
|
+
self_deposit_policy_ids: bundleDepositData === null || bundleDepositData === void 0 ? void 0 : bundleDepositData.self_deposit_policy_ids
|
|
234
|
+
})));
|
|
235
|
+
hasDeposit = true;
|
|
236
|
+
return accumulator.plus(result.depositTotal);
|
|
237
|
+
}, new Decimal(0));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (!hasDeposit) return null;
|
|
241
|
+
var protocolIdSet = new Set(protocolIds);
|
|
242
|
+
var protocols = allProtocols.filter(function (protocol) {
|
|
243
|
+
return protocolIdSet.has(protocol.id);
|
|
244
|
+
});
|
|
245
|
+
return {
|
|
246
|
+
total: depositTotal.toNumber(),
|
|
247
|
+
protocols: protocols
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* 仅基于 tempOrder.products 重算整单定金。
|
|
253
|
+
*
|
|
254
|
+
* 对齐 Checkout relation_products 分支:商品定金先按商品规则计算,
|
|
255
|
+
* 再扣减商品券/折扣卡抵扣金额;tempOrder.bookings 不参与这里的计算。
|
|
256
|
+
*/
|
|
257
|
+
export function calculateOrderProductsDeposit() {
|
|
258
|
+
var products = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
259
|
+
var options = arguments.length > 1 ? arguments[1] : undefined;
|
|
260
|
+
var protocolMap = new Map();
|
|
261
|
+
var total = new Decimal(0);
|
|
262
|
+
var hasDeposit = false;
|
|
263
|
+
var _iterator3 = _createForOfIteratorHelper(products || []),
|
|
264
|
+
_step3;
|
|
265
|
+
try {
|
|
266
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
267
|
+
var _product$metadata, _options$productsByUi;
|
|
268
|
+
var product = _step3.value;
|
|
269
|
+
var productUid = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.unique_identification_number;
|
|
270
|
+
var runtimeOrigin = productUid ? options === null || options === void 0 || (_options$productsByUi = options.productsByUid) === null || _options$productsByUi === void 0 || (_options$productsByUi = _options$productsByUi[productUid]) === null || _options$productsByUi === void 0 ? void 0 : _options$productsByUi.origin : undefined;
|
|
271
|
+
var deposit = getOrderProductDeposit(product, runtimeOrigin);
|
|
272
|
+
product.deposit = deposit;
|
|
273
|
+
if (!(deposit !== null && deposit !== void 0 && deposit.total) || Number(deposit.total) <= 0) continue;
|
|
274
|
+
total = total.plus(deposit.total);
|
|
275
|
+
var _iterator4 = _createForOfIteratorHelper(product.discount_list || []),
|
|
276
|
+
_step4;
|
|
277
|
+
try {
|
|
278
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
279
|
+
var discount = _step4.value;
|
|
280
|
+
total = total.minus((discount === null || discount === void 0 ? void 0 : discount.amount) || 0);
|
|
281
|
+
}
|
|
282
|
+
} catch (err) {
|
|
283
|
+
_iterator4.e(err);
|
|
284
|
+
} finally {
|
|
285
|
+
_iterator4.f();
|
|
286
|
+
}
|
|
287
|
+
var _iterator5 = _createForOfIteratorHelper(deposit.protocols || []),
|
|
288
|
+
_step5;
|
|
289
|
+
try {
|
|
290
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
291
|
+
var protocol = _step5.value;
|
|
292
|
+
if (!protocolMap.has(protocol.id)) protocolMap.set(protocol.id, protocol);
|
|
293
|
+
}
|
|
294
|
+
} catch (err) {
|
|
295
|
+
_iterator5.e(err);
|
|
296
|
+
} finally {
|
|
297
|
+
_iterator5.f();
|
|
298
|
+
}
|
|
299
|
+
hasDeposit = true;
|
|
300
|
+
}
|
|
301
|
+
} catch (err) {
|
|
302
|
+
_iterator3.e(err);
|
|
303
|
+
} finally {
|
|
304
|
+
_iterator3.f();
|
|
305
|
+
}
|
|
306
|
+
var roundedTotal = total.toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
|
|
307
|
+
var protocols = _toConsumableArray(protocolMap.values());
|
|
308
|
+
return {
|
|
309
|
+
total: roundedTotal.toNumber(),
|
|
310
|
+
totalText: roundedTotal.toFixed(2),
|
|
311
|
+
protocols: protocols,
|
|
312
|
+
deposit_policy_ids: protocols.map(function (protocol) {
|
|
313
|
+
return protocol.id;
|
|
314
|
+
}),
|
|
315
|
+
hasDeposit: hasDeposit
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* 判定套餐子商品是否为 markdown(减价)类型。
|
|
321
|
+
* 与后端口径一致:price_type='markdown' 且 price_type_ext 非 'product_price'(原价子商品)。
|
|
322
|
+
*/
|
|
323
|
+
export function isMarkdownBundle(bundle) {
|
|
324
|
+
var _bundle$price_type_ex, _bundle$price_type;
|
|
325
|
+
if (!bundle || _typeof(bundle) !== 'object') return false;
|
|
326
|
+
var ext = (_bundle$price_type_ex = bundle.price_type_ext) !== null && _bundle$price_type_ex !== void 0 ? _bundle$price_type_ex : bundle.custom_price_type_ext;
|
|
327
|
+
var type = (_bundle$price_type = bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : bundle.custom_price_type;
|
|
328
|
+
return type === 'markdown' && ext !== 'product_price';
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* 套餐子商品对「行价」的带符号单位贡献(与后端 markdown 口径对齐)。
|
|
333
|
+
*
|
|
334
|
+
* - markdown(减价):净额 = |catalog 毛价| − Σ(option.add_price×num),**取负**(行内减)。
|
|
335
|
+
* catalog 毛价优先 `price`/`custom_price`(避免读已落净额的 `bundle_selling_price` 造成 option 二次扣减);
|
|
336
|
+
* 仅当毛价缺失(历史/hydrate 仅剩净额)时退回 `bundle_selling_price`,且此时不再扣 option。
|
|
337
|
+
* - markup(加价)/原价子商品:维持 `+(bundle_selling_price ?? price)`,行为不变。
|
|
338
|
+
*/
|
|
339
|
+
export function getBundleSignedUnit(bundle, options) {
|
|
340
|
+
var _options$useOriginal, _ref11, _bundle$original_pric2, _bundle$bundle_sellin;
|
|
341
|
+
if (!bundle || _typeof(bundle) !== 'object') return new Decimal(0);
|
|
342
|
+
var useOriginal = (_options$useOriginal = options === null || options === void 0 ? void 0 : options.useOriginal) !== null && _options$useOriginal !== void 0 ? _options$useOriginal : false;
|
|
343
|
+
if (isMarkdownBundle(bundle)) {
|
|
344
|
+
var _ref5, _ref6, _ref7, _bundle$original_pric, _ref8, _ref9, _ref10, _bundle$custom_price;
|
|
345
|
+
var catalog = useOriginal ? (_ref5 = (_ref6 = (_ref7 = (_bundle$original_pric = bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle.product_price) !== null && _ref7 !== void 0 ? _ref7 : bundle.custom_price) !== null && _ref6 !== void 0 ? _ref6 : bundle.base_price) !== null && _ref5 !== void 0 ? _ref5 : bundle.price : (_ref8 = (_ref9 = (_ref10 = (_bundle$custom_price = bundle.custom_price) !== null && _bundle$custom_price !== void 0 ? _bundle$custom_price : bundle.product_price) !== null && _ref10 !== void 0 ? _ref10 : bundle.original_price) !== null && _ref9 !== void 0 ? _ref9 : bundle.base_price) !== null && _ref8 !== void 0 ? _ref8 : bundle.price;
|
|
346
|
+
if (catalog !== undefined && catalog !== null && catalog !== '') {
|
|
347
|
+
var raw = new Decimal(Number(catalog) || 0);
|
|
348
|
+
// 负值表示价格已是「带符号净额」(如 cart/changePrice 产出的 -3.7),直接取用不再扣 option,
|
|
349
|
+
// 避免与下游 option 二次扣减;正值为毛价(H5 路径,如 5),净额 = price − Σoptions 后取负。
|
|
350
|
+
if (raw.lt(0)) return raw;
|
|
351
|
+
return raw.minus(sumOptionUnitPrice(bundle.option)).negated();
|
|
352
|
+
}
|
|
353
|
+
// 仅剩净额(无毛价)兜底:直接取负,不再扣 option
|
|
354
|
+
return new Decimal(Number(bundle.bundle_selling_price) || 0).abs().negated();
|
|
355
|
+
}
|
|
356
|
+
var rawPrice = useOriginal ? (_ref11 = (_bundle$original_pric2 = bundle.original_price) !== null && _bundle$original_pric2 !== void 0 ? _bundle$original_pric2 : bundle.product_price) !== null && _ref11 !== void 0 ? _ref11 : bundle.price : (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.price;
|
|
357
|
+
return new Decimal(Number(rawPrice) || 0);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* 套餐子商品 `bundle_selling_price` 的存储净额(正值幅度)。
|
|
362
|
+
* markdown 取净额绝对值(3.70);markup/原价维持原值。
|
|
363
|
+
*/
|
|
364
|
+
export function getBundleSellingMagnitude(bundle) {
|
|
365
|
+
return getBundleSignedUnit(bundle).abs();
|
|
366
|
+
}
|
|
86
367
|
|
|
87
368
|
/**
|
|
88
369
|
* OrderModule 默认 Rules 钩子工厂。
|
|
@@ -96,7 +377,7 @@ export function sumOptionUnitPrice(options) {
|
|
|
96
377
|
* 不含折扣。**权威源**。
|
|
97
378
|
* - `metadata.main_product_original_price` = source + Σ(option.price × option.num)(含 option、不含折扣)。
|
|
98
379
|
* - `metadata.main_product_selling_price` = main_original − 主商品券 per-unit amount(含 option、含折扣)。
|
|
99
|
-
* - `payment_price`:出站 payload
|
|
380
|
+
* - `payment_price`:出站 payload 中为行 composite 已减整单折扣均摊价(无折扣时与 `selling_price` 同义)。
|
|
100
381
|
*
|
|
101
382
|
* Rules 钩子契约(hook_adapt 方案,Rules 内部保持不变):
|
|
102
383
|
* - `getProduct.price` / `getProduct.original_price` 回传 **source-level 主价**
|
|
@@ -113,17 +394,168 @@ export function sumOptionUnitPrice(options) {
|
|
|
113
394
|
*
|
|
114
395
|
* 导出为纯函数方便单测直接驱动钩子,不依赖 OrderModule 实例。
|
|
115
396
|
*/
|
|
397
|
+
|
|
398
|
+
/** Rules calcDiscount 用手动价标记;undefined 表示交给 Rules 用 total/origin_total 推断 */
|
|
399
|
+
export function resolveRulesManualDiscountFlag(metadata) {
|
|
400
|
+
if (!metadata) return undefined;
|
|
401
|
+
if (metadata.is_manual_discount === true || metadata.is_manual_discount === 1) {
|
|
402
|
+
return true;
|
|
403
|
+
}
|
|
404
|
+
var priceOverride = metadata.price_override;
|
|
405
|
+
if (priceOverride !== undefined && priceOverride !== null && priceOverride !== '') {
|
|
406
|
+
return true;
|
|
407
|
+
}
|
|
408
|
+
return undefined;
|
|
409
|
+
}
|
|
410
|
+
function normalizeOrderProductDiscountAmount(amount) {
|
|
411
|
+
if (amount === undefined || amount === null) return undefined;
|
|
412
|
+
return String(amount);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* 商品行折扣只保留后端 OrderProductDiscountItem 协议字段。
|
|
417
|
+
* Rules/券计算过程中的 `_num`、`config` 等运行态字段不应进入 tempOrder 或提交 payload。
|
|
418
|
+
*/
|
|
419
|
+
export function normalizeOrderProductDiscountList(discountList) {
|
|
420
|
+
if (!Array.isArray(discountList)) return [];
|
|
421
|
+
return discountList.filter(function (item) {
|
|
422
|
+
return !!item && _typeof(item) === 'object';
|
|
423
|
+
}).map(function (item) {
|
|
424
|
+
var normalized = {
|
|
425
|
+
discount_id: Number.isFinite(Number(item.discount_id)) ? Number(item.discount_id) : 0
|
|
426
|
+
};
|
|
427
|
+
if (item.order_discount_id === null) {
|
|
428
|
+
normalized.order_discount_id = null;
|
|
429
|
+
} else if (item.order_discount_id !== undefined) {
|
|
430
|
+
var orderDiscountId = Number(item.order_discount_id);
|
|
431
|
+
if (Number.isFinite(orderDiscountId)) {
|
|
432
|
+
normalized.order_discount_id = orderDiscountId;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
if (item.type !== undefined) normalized.type = item.type;
|
|
436
|
+
var amount = normalizeOrderProductDiscountAmount(item.amount);
|
|
437
|
+
if (amount !== undefined) normalized.amount = amount;
|
|
438
|
+
if (item.discount && _typeof(item.discount) === 'object') {
|
|
439
|
+
normalized.discount = _objectSpread({}, item.discount);
|
|
440
|
+
}
|
|
441
|
+
if (item.metadata === null) {
|
|
442
|
+
normalized.metadata = null;
|
|
443
|
+
} else if (item.metadata && _typeof(item.metadata) === 'object') {
|
|
444
|
+
normalized.metadata = _objectSpread({}, item.metadata);
|
|
445
|
+
}
|
|
446
|
+
return normalized;
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* 手动改价(price_override)时行级 original_price(composite 单价):
|
|
452
|
+
* 购物车划线价应对齐 metadata.origin._extend.origin_total(改价前单价 composite,如 40),
|
|
453
|
+
* 而非 bundle 子项 catalog 原价合成的 composedOriginalPrice(如 30)。
|
|
454
|
+
*
|
|
455
|
+
* origin_total 与 SkuDetailModal / cacheItem._extend 一致,为单价语义,不再除以 num。
|
|
456
|
+
*/
|
|
457
|
+
export function resolveManualOverrideLineOriginalPrice(params, fallbackCompositeOriginal) {
|
|
458
|
+
var _metadata$origin;
|
|
459
|
+
var metadata = params.metadata || {};
|
|
460
|
+
var priceOverride = metadata.price_override;
|
|
461
|
+
if (priceOverride === undefined || priceOverride === null || priceOverride === '') {
|
|
462
|
+
return fallbackCompositeOriginal;
|
|
463
|
+
}
|
|
464
|
+
var refTotal = (_metadata$origin = metadata.origin) === null || _metadata$origin === void 0 || (_metadata$origin = _metadata$origin._extend) === null || _metadata$origin === void 0 ? void 0 : _metadata$origin.origin_total;
|
|
465
|
+
if (refTotal !== undefined && refTotal !== null && refTotal !== '') {
|
|
466
|
+
var parsed = Number(refTotal);
|
|
467
|
+
if (Number.isFinite(parsed)) {
|
|
468
|
+
return new Decimal(parsed).toDecimalPlaces(2).toFixed(2);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
var lineOriginal = params.lineOriginalPrice;
|
|
472
|
+
if (lineOriginal !== undefined && lineOriginal !== null && lineOriginal !== '') {
|
|
473
|
+
var parsedLine = Number(lineOriginal);
|
|
474
|
+
var parsedFallback = Number(fallbackCompositeOriginal);
|
|
475
|
+
if (Number.isFinite(parsedLine) && Number.isFinite(parsedFallback) && parsedLine > parsedFallback) {
|
|
476
|
+
return new Decimal(parsedLine).toDecimalPlaces(2).toFixed(2);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return fallbackCompositeOriginal;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* 计算商品行「每单位有效折扣」:discount_list 合计 + 被 Rules 剥离但仍 inPromotion 的差额。
|
|
484
|
+
*
|
|
485
|
+
* Rules.calcDiscount 会把 type=promotion 从 discount_list 去掉,但 metadata._promotion 仍保留;
|
|
486
|
+
* applyProductDiscountPrices 必须回读 _promotion,否则抬价/降价都会在第二步被 source 原价覆盖。
|
|
487
|
+
*
|
|
488
|
+
* @example
|
|
489
|
+
* resolveEffectivePerUnitDiscount({ metadata: { _promotion: { inPromotion: true, originalPrice: 1, finalPrice: 5 } }, discount_list: [] });
|
|
490
|
+
* // => -4
|
|
491
|
+
*/
|
|
492
|
+
export function resolveEffectivePerUnitDiscount(product) {
|
|
493
|
+
var discountList = Array.isArray(product === null || product === void 0 ? void 0 : product.discount_list) ? product.discount_list : [];
|
|
494
|
+
var fromList = discountList.reduce(function (sum, discount) {
|
|
495
|
+
return sum + Number((discount === null || discount === void 0 ? void 0 : discount.amount) || 0);
|
|
496
|
+
}, 0);
|
|
497
|
+
var hasPromoDiscountItem = discountList.some(function (item) {
|
|
498
|
+
return (item === null || item === void 0 ? void 0 : item.type) === 'promotion';
|
|
499
|
+
});
|
|
500
|
+
if (hasPromoDiscountItem) return fromList;
|
|
501
|
+
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
502
|
+
var promo = metadata._promotion;
|
|
503
|
+
if ((promo === null || promo === void 0 ? void 0 : promo.inPromotion) !== true) return fromList;
|
|
504
|
+
var optionSum = sumOptionUnitPrice(getProductSkuOptions(product)).toNumber();
|
|
505
|
+
|
|
506
|
+
// applyPromotion 写价后、Rules 剥离 promotion discount 的兜底
|
|
507
|
+
if (!discountList.length && metadata.source_product_price != null && metadata.main_product_selling_price != null) {
|
|
508
|
+
var source = Number(metadata.source_product_price);
|
|
509
|
+
var selling = Number(metadata.main_product_selling_price) - optionSum;
|
|
510
|
+
if (Number.isFinite(source) && Number.isFinite(selling) && source !== selling) {
|
|
511
|
+
return fromList + (source - selling);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
var originalPrice = Number(promo.originalPrice);
|
|
515
|
+
var finalPrice = Number(promo.finalPrice);
|
|
516
|
+
if (!Number.isFinite(originalPrice) || !Number.isFinite(finalPrice)) return fromList;
|
|
517
|
+
return fromList + (originalPrice - finalPrice);
|
|
518
|
+
}
|
|
116
519
|
export function createDefaultOrderRulesHooks() {
|
|
117
520
|
var toUnitPriceString = function toUnitPriceString(totalLike, num) {
|
|
118
521
|
var effectiveNum = Number(num) > 0 ? Number(num) : 1;
|
|
119
522
|
return new Decimal(Number(totalLike) || 0).dividedBy(effectiveNum).toDecimalPlaces(2).toString();
|
|
120
523
|
};
|
|
524
|
+
var getBundleIdentity = function getBundleIdentity(bundle) {
|
|
525
|
+
var _ref12, _bundle$bundle_id, _ref13, _ref14, _bundle$bundle_produc, _ref15, _ref16, _bundle$bundle_varian, _ref17, _bundle$bundle_group_;
|
|
526
|
+
return [(_ref12 = (_bundle$bundle_id = bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle.id) !== null && _ref12 !== void 0 ? _ref12 : '', (_ref13 = (_ref14 = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id) !== null && _ref14 !== void 0 ? _ref14 : bundle.product_id) !== null && _ref13 !== void 0 ? _ref13 : '', (_ref15 = (_ref16 = (_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle.variant_id) !== null && _ref16 !== void 0 ? _ref16 : bundle.product_variant_id) !== null && _ref15 !== void 0 ? _ref15 : 0, (_ref17 = (_bundle$bundle_group_ = bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle.group_id) !== null && _ref17 !== void 0 ? _ref17 : ''].join('|');
|
|
527
|
+
};
|
|
528
|
+
var mergeRulesBundlePrices = function mergeRulesBundlePrices(currentBundle, rulesBundle) {
|
|
529
|
+
if (!Array.isArray(rulesBundle)) return rulesBundle;
|
|
530
|
+
var currentByIdentity = new Map();
|
|
531
|
+
(currentBundle || []).forEach(function (bundle) {
|
|
532
|
+
if (!bundle || _typeof(bundle) !== 'object') return;
|
|
533
|
+
currentByIdentity.set(getBundleIdentity(bundle), bundle);
|
|
534
|
+
});
|
|
535
|
+
return rulesBundle.map(function (bundle) {
|
|
536
|
+
var _bundle$price_type_ex2, _ref18, _ref19, _current$price, _ref20, _ref21, _ref22, _current$original_pri;
|
|
537
|
+
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
538
|
+
var current = currentByIdentity.get(getBundleIdentity(bundle));
|
|
539
|
+
if (!current) return bundle;
|
|
540
|
+
var isProductPriceBundle = ((_bundle$price_type_ex2 = bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : current.price_type_ext) === 'product_price';
|
|
541
|
+
if (!isProductPriceBundle) return bundle;
|
|
542
|
+
var sourcePrice = (_ref18 = (_ref19 = (_current$price = current.price) !== null && _current$price !== void 0 ? _current$price : current.custom_price) !== null && _ref19 !== void 0 ? _ref19 : current.original_price) !== null && _ref18 !== void 0 ? _ref18 : current.bundle_selling_price;
|
|
543
|
+
var originalPrice = (_ref20 = (_ref21 = (_ref22 = (_current$original_pri = current.original_price) !== null && _current$original_pri !== void 0 ? _current$original_pri : current.product_price) !== null && _ref22 !== void 0 ? _ref22 : current.price) !== null && _ref21 !== void 0 ? _ref21 : current.custom_price) !== null && _ref20 !== void 0 ? _ref20 : sourcePrice;
|
|
544
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, bundle), sourcePrice !== undefined ? {
|
|
545
|
+
price: sourcePrice
|
|
546
|
+
} : {}), originalPrice !== undefined ? {
|
|
547
|
+
original_price: originalPrice
|
|
548
|
+
} : {}), current.original_total !== undefined ? {
|
|
549
|
+
original_total: current.original_total
|
|
550
|
+
} : {});
|
|
551
|
+
});
|
|
552
|
+
};
|
|
121
553
|
return {
|
|
122
554
|
getProduct: function getProduct(product) {
|
|
123
|
-
var _product$
|
|
555
|
+
var _product$metadata2, _product$metadata3, _product$metadata4, _product$metadata5, _product$metadata6, _metadataAny$_promoti;
|
|
124
556
|
// source_product_price 是权威源;兜底链:source → mainSelling − options(反推)→ 行 selling_price
|
|
125
557
|
var metadataAny = product.metadata || {};
|
|
126
|
-
var optionSum = sumOptionUnitPrice(product
|
|
558
|
+
var optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
|
|
127
559
|
var sourcePrice;
|
|
128
560
|
if (metadataAny.source_product_price !== undefined) {
|
|
129
561
|
sourcePrice = String(metadataAny.source_product_price);
|
|
@@ -145,9 +577,9 @@ export function createDefaultOrderRulesHooks() {
|
|
|
145
577
|
id: product.product_id,
|
|
146
578
|
// Rules 引擎用 _id 作为 processedProductsMap 键;必须与购物车行级 identity 一致,
|
|
147
579
|
// 否则同 SKU 不同小料会在 calcDiscount 重组时互相覆盖。
|
|
148
|
-
// 不透明 identity 契约下,normalizeOrderProduct /
|
|
580
|
+
// 不透明 identity 契约下,normalizeOrderProduct / hydrate 已保证唯一值存在;
|
|
149
581
|
// 留 fingerprint 分支仅作 Rules 单测里直接传裸 product 时的兜底。
|
|
150
|
-
_id: (_product$
|
|
582
|
+
_id: (_product$metadata2 = product.metadata) !== null && _product$metadata2 !== void 0 && _product$metadata2.unique_identification_number ? "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(product.metadata.unique_identification_number) : "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(buildProductLineFingerprint(getProductSkuOptions(product), product.product_bundle)),
|
|
151
583
|
// Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
|
|
152
584
|
// 所以这里必须喂 source-level(不含 option、不含 bundle、不含折扣)单价,避免双加 option。
|
|
153
585
|
price: sourcePrice,
|
|
@@ -159,19 +591,24 @@ export function createDefaultOrderRulesHooks() {
|
|
|
159
591
|
num: product.num || 1,
|
|
160
592
|
discount_list: product.discount_list || [],
|
|
161
593
|
bundle: product.product_bundle || [],
|
|
162
|
-
booking_id: ((_product$
|
|
594
|
+
booking_id: ((_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.booking_id) || null,
|
|
163
595
|
isClient: false,
|
|
164
|
-
|
|
596
|
+
// 勿写死 false:否则 Rules 不会走 total≠origin_total 的手动价推断,
|
|
597
|
+
// 无券时会把 bundle 价还原成 original_price(手动改价套餐会从 20 回到 30)。
|
|
598
|
+
isManualDiscount: resolveRulesManualDiscountFlag(metadataAny),
|
|
165
599
|
holder_id: (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.holder_id,
|
|
166
|
-
startDate: ((_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.start_date) || ((_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.startDate)
|
|
600
|
+
startDate: ((_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.start_date) || ((_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.startDate),
|
|
601
|
+
main_product_selling_price: metadataAny.main_product_selling_price !== undefined ? new Decimal(Number(metadataAny.main_product_selling_price) || 0).minus(optionSum).toDecimalPlaces(2).toString() : undefined,
|
|
602
|
+
inPromotion: ((_metadataAny$_promoti = metadataAny._promotion) === null || _metadataAny$_promoti === void 0 ? void 0 : _metadataAny$_promoti.inPromotion) === true,
|
|
603
|
+
_promotion: metadataAny._promotion
|
|
167
604
|
};
|
|
168
605
|
},
|
|
169
606
|
setProduct: function setProduct(product, values) {
|
|
170
|
-
var
|
|
171
|
-
var nextNum = Number((
|
|
607
|
+
var _ref23, _values$quantity, _ref24, _metadataAny$source_p, _values$discount_list, _values$quantity2;
|
|
608
|
+
var nextNum = Number((_ref23 = (_values$quantity = values.quantity) !== null && _values$quantity !== void 0 ? _values$quantity : product.num) !== null && _ref23 !== void 0 ? _ref23 : 1) || 1;
|
|
172
609
|
var metadataAny = product.metadata || {};
|
|
173
|
-
var existedSource = (
|
|
174
|
-
var nextOptions = product
|
|
610
|
+
var existedSource = (_ref24 = (_metadataAny$source_p = metadataAny.source_product_price) !== null && _metadataAny$source_p !== void 0 ? _metadataAny$source_p : product.selling_price) !== null && _ref24 !== void 0 ? _ref24 : '0';
|
|
611
|
+
var nextOptions = getProductSkuOptions(product);
|
|
175
612
|
var optionSum = sumOptionUnitPrice(nextOptions);
|
|
176
613
|
|
|
177
614
|
// Rules 返回的 main_product_selling_price / price / total 均为 source-level。
|
|
@@ -186,7 +623,7 @@ export function createDefaultOrderRulesHooks() {
|
|
|
186
623
|
// 含 option 的 main_product_*
|
|
187
624
|
var nextMainSellingPrice = new Decimal(Number(nextSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
188
625
|
var nextMainOriginalPrice = new Decimal(Number(nextSourceOriginalPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
189
|
-
var nextBundle =
|
|
626
|
+
var nextBundle = values.bundle !== undefined ? mergeRulesBundlePrices(product.product_bundle, values.bundle) : product.product_bundle;
|
|
190
627
|
var composedSellingPrice = composeLinePrice({
|
|
191
628
|
mainPrice: nextMainSellingPrice,
|
|
192
629
|
bundle: nextBundle
|
|
@@ -196,9 +633,14 @@ export function createDefaultOrderRulesHooks() {
|
|
|
196
633
|
bundle: nextBundle,
|
|
197
634
|
useOriginalBundle: true
|
|
198
635
|
});
|
|
636
|
+
var finalOriginalPrice = resolveManualOverrideLineOriginalPrice({
|
|
637
|
+
num: nextNum,
|
|
638
|
+
metadata: metadataAny,
|
|
639
|
+
lineOriginalPrice: product.original_price
|
|
640
|
+
}, composedOriginalPrice);
|
|
199
641
|
return _objectSpread(_objectSpread({}, product), {}, {
|
|
200
642
|
selling_price: composedSellingPrice,
|
|
201
|
-
original_price:
|
|
643
|
+
original_price: finalOriginalPrice,
|
|
202
644
|
discount_list: (_values$discount_list = values.discount_list) !== null && _values$discount_list !== void 0 ? _values$discount_list : product.discount_list,
|
|
203
645
|
num: (_values$quantity2 = values.quantity) !== null && _values$quantity2 !== void 0 ? _values$quantity2 : product.num,
|
|
204
646
|
product_bundle: nextBundle,
|
|
@@ -311,13 +753,14 @@ function formatSubmitOptionItems(options) {
|
|
|
311
753
|
if (!Array.isArray(options)) return [];
|
|
312
754
|
return options.map(function (d) {
|
|
313
755
|
var _d$add_price;
|
|
314
|
-
var option = {
|
|
756
|
+
var option = _objectSpread(_objectSpread({}, d && _typeof(d) === 'object' ? d : {}), {}, {
|
|
315
757
|
num: d === null || d === void 0 ? void 0 : d.num,
|
|
316
758
|
option_group_item_id: d === null || d === void 0 ? void 0 : d.option_group_item_id,
|
|
317
759
|
option_group_id: d === null || d === void 0 ? void 0 : d.option_group_id
|
|
318
|
-
};
|
|
760
|
+
});
|
|
319
761
|
var addPrice = (_d$add_price = d === null || d === void 0 ? void 0 : d.add_price) !== null && _d$add_price !== void 0 ? _d$add_price : d === null || d === void 0 ? void 0 : d.price;
|
|
320
762
|
if (addPrice !== undefined) option.add_price = String(addPrice);
|
|
763
|
+
delete option.price;
|
|
321
764
|
return option;
|
|
322
765
|
});
|
|
323
766
|
}
|
|
@@ -337,11 +780,16 @@ function toMoneyString(value) {
|
|
|
337
780
|
function formatSubmitBundleItems(bundle) {
|
|
338
781
|
if (!Array.isArray(bundle)) return [];
|
|
339
782
|
return bundle.map(function (b) {
|
|
340
|
-
var
|
|
783
|
+
var _ref25, _rawBundle$price, _rawBundle$surcharge_, _rawBundle$num, _rawBundle$is_charge_, _rawBundle$bundle_var, _rawBundle$quantity, _rawBundle$extension_, _rawBundle$extension_2, _ref26, _rawBundle$price_type, _ref27, _rawBundle$price_type2, _rawBundle$bundle_gro, _rawBundle$bundle_id, _rawBundle$bundle_pro;
|
|
341
784
|
var rawBundle = b && _typeof(b) === 'object' ? b : {};
|
|
342
785
|
var existedMetadata = rawBundle.metadata && _typeof(rawBundle.metadata) === 'object' ? rawBundle.metadata : {};
|
|
343
|
-
|
|
344
|
-
|
|
786
|
+
|
|
787
|
+
// bundle_selling_price 出站存「正净额」:markdown 为 |price| − Σoptions(如 3.70),
|
|
788
|
+
// markup/原价维持原值;与后端口径一致(price 仍为毛价)。
|
|
789
|
+
var sellingPrice = getBundleSellingMagnitude(rawBundle).toFixed(2);
|
|
790
|
+
// payment 价由整单折扣均摊层产出;缺省(无折扣)时与 selling 净额同义。
|
|
791
|
+
var paymentPrice = rawBundle.bundle_payment_price !== undefined && rawBundle.bundle_payment_price !== null && rawBundle.bundle_payment_price !== '' ? toMoneyString(rawBundle.bundle_payment_price) : sellingPrice;
|
|
792
|
+
var priceValue = (_ref25 = (_rawBundle$price = rawBundle.price) !== null && _rawBundle$price !== void 0 ? _rawBundle$price : rawBundle.custom_price) !== null && _ref25 !== void 0 ? _ref25 : rawBundle.bundle_selling_price;
|
|
345
793
|
var relationSurchargeIds = Array.isArray(rawBundle.relation_surcharge_ids) ? rawBundle.relation_surcharge_ids : Array.isArray(existedMetadata.relation_surcharge_ids) ? existedMetadata.relation_surcharge_ids : [];
|
|
346
794
|
var surchargeFee = toMoneyString((_rawBundle$surcharge_ = rawBundle.surcharge_fee) !== null && _rawBundle$surcharge_ !== void 0 ? _rawBundle$surcharge_ : existedMetadata.surcharge_fee);
|
|
347
795
|
var productDiscountDifference = toBundleNumber(existedMetadata.product_discount_difference, 0);
|
|
@@ -354,9 +802,10 @@ function formatSubmitBundleItems(bundle) {
|
|
|
354
802
|
extension_id: (_rawBundle$extension_ = rawBundle.extension_id) !== null && _rawBundle$extension_ !== void 0 ? _rawBundle$extension_ : 0,
|
|
355
803
|
extension_type: (_rawBundle$extension_2 = rawBundle.extension_type) !== null && _rawBundle$extension_2 !== void 0 ? _rawBundle$extension_2 : 'normal',
|
|
356
804
|
price: priceValue,
|
|
357
|
-
price_type: (
|
|
358
|
-
price_type_ext: (
|
|
805
|
+
price_type: (_ref26 = (_rawBundle$price_type = rawBundle.price_type) !== null && _rawBundle$price_type !== void 0 ? _rawBundle$price_type : rawBundle.custom_price_type) !== null && _ref26 !== void 0 ? _ref26 : '',
|
|
806
|
+
price_type_ext: (_ref27 = (_rawBundle$price_type2 = rawBundle.price_type_ext) !== null && _rawBundle$price_type2 !== void 0 ? _rawBundle$price_type2 : rawBundle.custom_price_type_ext) !== null && _ref27 !== void 0 ? _ref27 : '',
|
|
359
807
|
bundle_selling_price: sellingPrice,
|
|
808
|
+
bundle_payment_price: paymentPrice,
|
|
360
809
|
option: formatSubmitOptionItems(rawBundle.option),
|
|
361
810
|
bundle_group_id: (_rawBundle$bundle_gro = rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.bundle_group_id) !== null && _rawBundle$bundle_gro !== void 0 ? _rawBundle$bundle_gro : rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.group_id,
|
|
362
811
|
bundle_id: (_rawBundle$bundle_id = rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.bundle_id) !== null && _rawBundle$bundle_id !== void 0 ? _rawBundle$bundle_id : rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.id,
|
|
@@ -378,7 +827,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
378
827
|
* = `metadata.main_product_selling_price` + Σ(bundle_selling_price × num)。
|
|
379
828
|
* - `original_price`:**行 composite 券前单价**
|
|
380
829
|
* = `metadata.main_product_original_price` + Σ(bundle 原价 × num)。
|
|
381
|
-
* - `payment_price
|
|
830
|
+
* - `payment_price`:兼容后端的出站字段,行 composite 已减整单折扣均摊(无折扣时与 `selling_price` 同义)。
|
|
382
831
|
* - `metadata.source_product_price`:主商品/variant 基础价(不含 option、不含折扣),权威源。
|
|
383
832
|
* - `metadata.main_product_original_price`:含 option、不含折扣。
|
|
384
833
|
* - `metadata.main_product_selling_price`:含 option、含主商品折扣。
|
|
@@ -387,21 +836,26 @@ function formatSubmitBundleItems(bundle) {
|
|
|
387
836
|
* 本函数不再改造价格字段形状,仅做字段/metadata 裁剪。
|
|
388
837
|
*/
|
|
389
838
|
function normalizeSubmitProduct(product) {
|
|
390
|
-
var _rawMetadata$product_, _submitProduct$produc;
|
|
391
|
-
var
|
|
392
|
-
_runtimeUid =
|
|
393
|
-
submitProduct = _objectWithoutProperties(
|
|
839
|
+
var _rawMetadata$product_, _submitProduct$produc, _submitProduct$paymen;
|
|
840
|
+
var _ref28 = product,
|
|
841
|
+
_runtimeUid = _ref28.unique_identification_number,
|
|
842
|
+
submitProduct = _objectWithoutProperties(_ref28, _excluded);
|
|
394
843
|
var num = submitProduct.num,
|
|
395
|
-
productOptionItem = submitProduct.product_option_item,
|
|
396
844
|
_productSurchargeFee = submitProduct.surcharge_fee,
|
|
845
|
+
_deprecatedDiscountAmount = submitProduct.discount_amount,
|
|
846
|
+
_deprecatedDiscountType = submitProduct.discount_type,
|
|
847
|
+
_deprecatedDiscountway = submitProduct.discountway,
|
|
848
|
+
_deprecatedProductDiscountReason = submitProduct.product_discount_reason,
|
|
849
|
+
_deprecatedDiscountPer = submitProduct.discount_per,
|
|
397
850
|
productRest = _objectWithoutProperties(submitProduct, _excluded2);
|
|
851
|
+
delete productRest["product_".concat('option', "_item")];
|
|
398
852
|
var rawMetadata = submitProduct.metadata || {};
|
|
399
853
|
var bookingUid = rawMetadata.booking_uid;
|
|
400
854
|
var cleanMetadata = {};
|
|
401
855
|
if (rawMetadata.unique_identification_number) {
|
|
402
856
|
cleanMetadata.unique_identification_number = rawMetadata.unique_identification_number;
|
|
403
857
|
}
|
|
404
|
-
var priceMetaKeys = ['main_product_original_price', 'main_product_selling_price', 'source_product_price', 'main_product_attached_bundle_surcharge_fee', 'main_product_attached_bundle_tax_fee', 'surcharge_rounding_remainder', 'tax_fee_rounding_remainder', 'relation_surcharge_ids', 'discountable_flag', 'parent_unique_identification_number', 'product_add_schedule_time'];
|
|
858
|
+
var priceMetaKeys = ['main_product_original_price', 'main_product_selling_price', 'main_product_attached_bundle_selling_price', 'main_product_attached_bundle_payment_price', 'average_discount_amount_rate', 'source_product_price', 'main_product_attached_bundle_surcharge_fee', 'main_product_attached_bundle_tax_fee', 'surcharge_rounding_remainder', 'tax_fee_rounding_remainder', 'relation_surcharge_ids', 'discountable_flag', 'parent_unique_identification_number', 'product_add_schedule_time'];
|
|
405
859
|
for (var _i = 0, _priceMetaKeys = priceMetaKeys; _i < _priceMetaKeys.length; _i++) {
|
|
406
860
|
var key = _priceMetaKeys[_i];
|
|
407
861
|
if (rawMetadata[key] !== undefined) {
|
|
@@ -416,22 +870,22 @@ function normalizeSubmitProduct(product) {
|
|
|
416
870
|
cleanMetadata.is_rule = rawMetadata.is_rule;
|
|
417
871
|
}
|
|
418
872
|
var productSku = _objectSpread(_objectSpread({}, submitProduct.product_sku && _typeof(submitProduct.product_sku) === 'object' ? submitProduct.product_sku : {}), {}, {
|
|
419
|
-
option: formatSubmitOptionItems(
|
|
873
|
+
option: formatSubmitOptionItems((_submitProduct$produc = submitProduct.product_sku) === null || _submitProduct$produc === void 0 ? void 0 : _submitProduct$produc.option)
|
|
420
874
|
});
|
|
421
875
|
return _objectSpread(_objectSpread(_objectSpread({}, productRest), bookingUid ? {
|
|
422
876
|
booking_uid: bookingUid
|
|
423
877
|
} : {}), {}, {
|
|
424
878
|
product_quantity: toBundleNumber(num !== null && num !== void 0 ? num : submitProduct.product_quantity, 1),
|
|
425
879
|
product_sku: productSku,
|
|
426
|
-
discount_list: submitProduct.discount_list
|
|
880
|
+
discount_list: normalizeOrderProductDiscountList(submitProduct.discount_list),
|
|
427
881
|
product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
|
|
428
882
|
metadata: cleanMetadata,
|
|
429
|
-
// 出站兼容:后端消费 payment_price
|
|
430
|
-
//
|
|
431
|
-
payment_price: submitProduct.selling_price
|
|
883
|
+
// 出站兼容:后端消费 payment_price 字段(行 composite 已减整单折扣均摊)。
|
|
884
|
+
// 由整单折扣均摊层产出;缺省(无折扣)时与 selling_price 同义。
|
|
885
|
+
payment_price: (_submitProduct$paymen = submitProduct.payment_price) !== null && _submitProduct$paymen !== void 0 ? _submitProduct$paymen : submitProduct.selling_price
|
|
432
886
|
});
|
|
433
887
|
}
|
|
434
|
-
var SUBMIT_BOOKING_METADATA_WHITELIST = ['unique_identification_number', 'collect_pax', 'capacity', 'holder_id', 'resource_select_type'];
|
|
888
|
+
var SUBMIT_BOOKING_METADATA_WHITELIST = ['unique_identification_number', 'collect_pax', 'capacity', 'holder_id', 'resource_select_type', 'holder'];
|
|
435
889
|
export function normalizeBookingIsAll(booking) {
|
|
436
890
|
return booking.is_all === true || booking.is_all === 1 || booking.is_all === '1' || booking.is_all === 'true' ? 1 : 0;
|
|
437
891
|
}
|
|
@@ -445,19 +899,19 @@ export function normalizeBookingSubType(booking) {
|
|
|
445
899
|
export function normalizeSubmitBooking(booking) {
|
|
446
900
|
var rawMetadata = booking.metadata || {};
|
|
447
901
|
var cleanMetadata = {};
|
|
448
|
-
var
|
|
449
|
-
|
|
902
|
+
var _iterator6 = _createForOfIteratorHelper(SUBMIT_BOOKING_METADATA_WHITELIST),
|
|
903
|
+
_step6;
|
|
450
904
|
try {
|
|
451
|
-
for (
|
|
452
|
-
var key =
|
|
905
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
906
|
+
var key = _step6.value;
|
|
453
907
|
if (rawMetadata[key] !== undefined) {
|
|
454
908
|
cleanMetadata[key] = rawMetadata[key];
|
|
455
909
|
}
|
|
456
910
|
}
|
|
457
911
|
} catch (err) {
|
|
458
|
-
|
|
912
|
+
_iterator6.e(err);
|
|
459
913
|
} finally {
|
|
460
|
-
|
|
914
|
+
_iterator6.f();
|
|
461
915
|
}
|
|
462
916
|
if (cleanMetadata.holder_id === undefined) cleanMetadata.holder_id = null;
|
|
463
917
|
var bookingRecord = booking;
|
|
@@ -502,22 +956,23 @@ export function createDefaultTempOrder(params) {
|
|
|
502
956
|
return {
|
|
503
957
|
order_id: null,
|
|
504
958
|
external_sale_number: '',
|
|
505
|
-
order_number:
|
|
506
|
-
shop_order_number:
|
|
507
|
-
shop_full_order_number:
|
|
508
|
-
type: '
|
|
509
|
-
business_code:
|
|
959
|
+
order_number: null,
|
|
960
|
+
shop_order_number: null,
|
|
961
|
+
shop_full_order_number: null,
|
|
962
|
+
type: '',
|
|
963
|
+
business_code: undefined,
|
|
510
964
|
platform: 'h5',
|
|
511
965
|
sales_channel: 'my_pisel',
|
|
512
966
|
order_sales_channel: 'online_store',
|
|
513
967
|
status: 'normal',
|
|
514
968
|
payment_status: 'payment_processing',
|
|
515
969
|
shipping_status: 'unfulfilled',
|
|
516
|
-
customer_id:
|
|
970
|
+
customer_id: 0,
|
|
517
971
|
customer_name: '',
|
|
518
972
|
country_calling_code: '',
|
|
519
973
|
phone: '',
|
|
520
974
|
email: '',
|
|
975
|
+
customer: null,
|
|
521
976
|
is_price_include_tax: 1,
|
|
522
977
|
tax_title: '',
|
|
523
978
|
tax_country_code: '',
|
|
@@ -530,14 +985,13 @@ export function createDefaultTempOrder(params) {
|
|
|
530
985
|
surcharge_fee: '0.00',
|
|
531
986
|
note: '',
|
|
532
987
|
schedule_date: params.now,
|
|
533
|
-
created_at:
|
|
988
|
+
created_at: undefined,
|
|
534
989
|
request_unique_idempotency_token: '',
|
|
535
990
|
vouchers: [],
|
|
536
991
|
products: [],
|
|
537
992
|
bookings: [],
|
|
538
993
|
payments: [],
|
|
539
994
|
surcharges: [],
|
|
540
|
-
discount_list: [],
|
|
541
995
|
relation_forms: [],
|
|
542
996
|
contacts: [],
|
|
543
997
|
contacts_info: null,
|
|
@@ -549,7 +1003,7 @@ export function createDefaultTempOrder(params) {
|
|
|
549
1003
|
};
|
|
550
1004
|
}
|
|
551
1005
|
export function buildSubmitPayload(params) {
|
|
552
|
-
var
|
|
1006
|
+
var _tempOrder$customer_i, _tempOrder$order_numb, _tempOrder$shop_order, _tempOrder$shop_full_, _ref30, _tempOrder$is_price_i, _tempOrder$is_deposit, _enhancedPayload$summ;
|
|
553
1007
|
var tempOrder = params.tempOrder,
|
|
554
1008
|
cacheId = params.cacheId,
|
|
555
1009
|
_params$now = params.now,
|
|
@@ -558,36 +1012,52 @@ export function buildSubmitPayload(params) {
|
|
|
558
1012
|
businessCode = params.businessCode,
|
|
559
1013
|
channel = params.channel,
|
|
560
1014
|
type = params.type,
|
|
1015
|
+
summary = params.summary,
|
|
561
1016
|
enhance = params.enhance;
|
|
562
1017
|
var scheduleDate = tempOrder.schedule_date || tempOrder.created_at || formatDateTime(now);
|
|
563
1018
|
var bookingUuid = createUuidV4();
|
|
564
|
-
var
|
|
565
|
-
_extend =
|
|
566
|
-
_relationId =
|
|
567
|
-
_tableFormId =
|
|
568
|
-
_resourceId =
|
|
569
|
-
_summary =
|
|
570
|
-
_lastOrderInfo =
|
|
571
|
-
_paidAmount =
|
|
572
|
-
_shopId =
|
|
573
|
-
_shopNote =
|
|
574
|
-
_shopServiceType =
|
|
575
|
-
_startTime =
|
|
576
|
-
_customer =
|
|
577
|
-
|
|
578
|
-
_rootTaxFee =
|
|
579
|
-
_totalAmount =
|
|
580
|
-
_totalRefundAmount =
|
|
581
|
-
_createDate =
|
|
582
|
-
_holderId =
|
|
583
|
-
tempOrderRest = _objectWithoutProperties(
|
|
1019
|
+
var _ref29 = tempOrder,
|
|
1020
|
+
_extend = _ref29._extend,
|
|
1021
|
+
_relationId = _ref29.relation_id,
|
|
1022
|
+
_tableFormId = _ref29.table_form_id,
|
|
1023
|
+
_resourceId = _ref29.resource_id,
|
|
1024
|
+
_summary = _ref29.summary,
|
|
1025
|
+
_lastOrderInfo = _ref29.lastOrderInfo,
|
|
1026
|
+
_paidAmount = _ref29.paid_amount,
|
|
1027
|
+
_shopId = _ref29.shop_id,
|
|
1028
|
+
_shopNote = _ref29.shop_note,
|
|
1029
|
+
_shopServiceType = _ref29.shop_service_type,
|
|
1030
|
+
_startTime = _ref29.start_time,
|
|
1031
|
+
_customer = _ref29.customer,
|
|
1032
|
+
_discountList = _ref29.discount_list,
|
|
1033
|
+
_rootTaxFee = _ref29.tax_fee,
|
|
1034
|
+
_totalAmount = _ref29.total_amount,
|
|
1035
|
+
_totalRefundAmount = _ref29.total_refund_amount,
|
|
1036
|
+
_createDate = _ref29.create_date,
|
|
1037
|
+
_holderId = _ref29.holder_id,
|
|
1038
|
+
tempOrderRest = _objectWithoutProperties(_ref29, _excluded3);
|
|
1039
|
+
var submitType = type !== null && type !== void 0 ? type : tempOrder.type;
|
|
1040
|
+
if (!submitType) {
|
|
1041
|
+
var _tempOrder$bookings;
|
|
1042
|
+
// 如果外部没有传递 types,根据订单里当前是否有 bookings 来决定是 appointment_booking 还是 virtual
|
|
1043
|
+
if (tempOrder !== null && tempOrder !== void 0 && (_tempOrder$bookings = tempOrder.bookings) !== null && _tempOrder$bookings !== void 0 && _tempOrder$bookings.length) {
|
|
1044
|
+
submitType = 'appointment_booking';
|
|
1045
|
+
} else {
|
|
1046
|
+
submitType = 'virtual';
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
584
1049
|
var payload = _objectSpread(_objectSpread({}, tempOrderRest), {}, {
|
|
1050
|
+
customer_id: (_tempOrder$customer_i = tempOrder.customer_id) !== null && _tempOrder$customer_i !== void 0 ? _tempOrder$customer_i : 1,
|
|
1051
|
+
customer_name: tempOrder.customer_name || 'Walk-In',
|
|
1052
|
+
order_number: (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : null,
|
|
1053
|
+
shop_order_number: (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : null,
|
|
1054
|
+
shop_full_order_number: (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : null,
|
|
585
1055
|
platform: normalizeSubmitPlatform(platform),
|
|
586
|
-
request_unique_idempotency_token: tempOrder.request_unique_idempotency_token || "".concat(tempOrder.external_sale_number, "_").concat(now.getTime()),
|
|
587
|
-
type:
|
|
588
|
-
business_code:
|
|
1056
|
+
request_unique_idempotency_token: (params === null || params === void 0 ? void 0 : params.request_unique_idempotency_token) || tempOrder.request_unique_idempotency_token || "".concat(tempOrder.external_sale_number, "_").concat(now.getTime()),
|
|
1057
|
+
type: submitType,
|
|
1058
|
+
business_code: businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code,
|
|
589
1059
|
sales_channel: tempOrder.sales_channel || 'my_pisel',
|
|
590
|
-
order_sales_channel: (
|
|
1060
|
+
order_sales_channel: (_ref30 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref30 !== void 0 ? _ref30 : 'online_store',
|
|
591
1061
|
status: tempOrder.status || 'normal',
|
|
592
1062
|
payment_status: tempOrder.payment_status || 'payment_processing',
|
|
593
1063
|
// shipping_status: tempOrder.shipping_status || 'unfulfilled',
|
|
@@ -600,39 +1070,41 @@ export function buildSubmitPayload(params) {
|
|
|
600
1070
|
note: tempOrder.note || '',
|
|
601
1071
|
delivery_type: tempOrder.delivery_type || 'nil',
|
|
602
1072
|
schedule_date: scheduleDate,
|
|
603
|
-
created_at: tempOrder.created_at || formatDateTime(now),
|
|
1073
|
+
// created_at: tempOrder.created_at || formatDateTime(now), 和后端协定这个字段先不提交到接口
|
|
604
1074
|
bookings: (tempOrder.bookings || []).filter(function (booking) {
|
|
605
|
-
|
|
606
|
-
return Number((_parent_id = booking.parent_id) !== null && _parent_id !== void 0 ? _parent_id : 0) !== 0;
|
|
1075
|
+
return Number(booking.parent_id) !== 0;
|
|
607
1076
|
}).map(function (booking) {
|
|
608
1077
|
return normalizeSubmitBooking(booking);
|
|
609
1078
|
}),
|
|
610
1079
|
payments: tempOrder.payments || [],
|
|
611
|
-
// discount_list: tempOrder.discount_list || [],
|
|
612
1080
|
relation_forms: tempOrder.relation_forms || [],
|
|
613
1081
|
// contacts: tempOrder.contacts || [],
|
|
614
1082
|
contacts_info: tempOrder.contacts_info && !Array.isArray(tempOrder.contacts_info) ? tempOrder.contacts_info : null,
|
|
615
1083
|
// holder: tempOrder.holder || null,
|
|
616
|
-
|
|
1084
|
+
summary: summary || tempOrder.summary || createEmptySummary(),
|
|
617
1085
|
metadata: function () {
|
|
618
|
-
var
|
|
619
|
-
_collectPax =
|
|
620
|
-
_tableOccupancyDuration =
|
|
621
|
-
rest = _objectWithoutProperties(
|
|
1086
|
+
var _ref31 = tempOrder.metadata || {},
|
|
1087
|
+
_collectPax = _ref31.collect_pax,
|
|
1088
|
+
_tableOccupancyDuration = _ref31.table_occupancy_duration,
|
|
1089
|
+
rest = _objectWithoutProperties(_ref31, _excluded4);
|
|
622
1090
|
return _objectSpread({}, rest);
|
|
623
1091
|
}(),
|
|
624
1092
|
products: (tempOrder.products || []).map(function (product) {
|
|
625
1093
|
return normalizeSubmitProduct(product);
|
|
626
1094
|
})
|
|
627
1095
|
});
|
|
628
|
-
|
|
1096
|
+
if (!enhance) return payload;
|
|
1097
|
+
var enhancedPayload = enhance(payload, {
|
|
629
1098
|
tempOrder: tempOrder,
|
|
630
1099
|
bookingUuid: bookingUuid,
|
|
631
1100
|
now: now
|
|
632
|
-
})
|
|
1101
|
+
});
|
|
1102
|
+
return _objectSpread(_objectSpread({}, enhancedPayload), {}, {
|
|
1103
|
+
summary: (_enhancedPayload$summ = enhancedPayload.summary) !== null && _enhancedPayload$summ !== void 0 ? _enhancedPayload$summ : payload.summary
|
|
1104
|
+
});
|
|
633
1105
|
}
|
|
634
1106
|
export function mapPaymentItemToOrderPayment(paymentItem) {
|
|
635
|
-
var _item$custom_payment_, _item$amount;
|
|
1107
|
+
var _item$custom_payment_, _item$payment_time, _item$created_at, _item$amount;
|
|
636
1108
|
var item = paymentItem;
|
|
637
1109
|
var customPaymentId = (_item$custom_payment_ = item.custom_payment_id) !== null && _item$custom_payment_ !== void 0 ? _item$custom_payment_ : item.id;
|
|
638
1110
|
var metadata = item.metadata && _typeof(item.metadata) === 'object' ? _objectSpread({}, item.metadata) : {};
|
|
@@ -646,10 +1118,18 @@ export function mapPaymentItemToOrderPayment(paymentItem) {
|
|
|
646
1118
|
metadata[key] = item[key];
|
|
647
1119
|
}
|
|
648
1120
|
}
|
|
649
|
-
|
|
1121
|
+
var timestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
1122
|
+
var paymentTime = (_item$payment_time = item.payment_time) !== null && _item$payment_time !== void 0 ? _item$payment_time : timestamp;
|
|
1123
|
+
var createdAt = (_item$created_at = item.created_at) !== null && _item$created_at !== void 0 ? _item$created_at : timestamp;
|
|
1124
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, item.order_payment_id !== undefined ? {
|
|
1125
|
+
order_payment_id: item.order_payment_id
|
|
1126
|
+
} : {}), {}, {
|
|
650
1127
|
amount: String((_item$amount = item.amount) !== null && _item$amount !== void 0 ? _item$amount : '0.00'),
|
|
651
1128
|
code: String(item.code || ''),
|
|
652
|
-
custom_payment_id: Number(customPaymentId !== null && customPaymentId !== void 0 ? customPaymentId : 0)
|
|
1129
|
+
custom_payment_id: Number(customPaymentId !== null && customPaymentId !== void 0 ? customPaymentId : 0)
|
|
1130
|
+
}, item.custom_payment_type !== undefined ? {
|
|
1131
|
+
custom_payment_type: String(item.custom_payment_type)
|
|
1132
|
+
} : {}), {}, {
|
|
653
1133
|
name: String(item.name || ''),
|
|
654
1134
|
type: String(item.type || '')
|
|
655
1135
|
}, item.voucher_id !== undefined ? {
|
|
@@ -660,12 +1140,15 @@ export function mapPaymentItemToOrderPayment(paymentItem) {
|
|
|
660
1140
|
service_fee: String(item.service_fee)
|
|
661
1141
|
} : {}), item.status !== undefined ? {
|
|
662
1142
|
status: item.status
|
|
663
|
-
} : {}),
|
|
664
|
-
payment_time:
|
|
665
|
-
|
|
1143
|
+
} : {}), {}, {
|
|
1144
|
+
payment_time: paymentTime,
|
|
1145
|
+
created_at: createdAt
|
|
1146
|
+
}, item.wallet_pass_usage_unit !== undefined ? {
|
|
666
1147
|
wallet_pass_usage_unit: item.wallet_pass_usage_unit
|
|
667
1148
|
} : {}), item.wallet_pass_use_value !== undefined ? {
|
|
668
1149
|
wallet_pass_use_value: item.wallet_pass_use_value
|
|
1150
|
+
} : {}), item.fund_record && _typeof(item.fund_record) === 'object' && !Array.isArray(item.fund_record) ? {
|
|
1151
|
+
fund_record: _objectSpread({}, item.fund_record)
|
|
669
1152
|
} : {}), {}, {
|
|
670
1153
|
metadata: metadata
|
|
671
1154
|
}, item.rounding_amount !== undefined ? {
|
|
@@ -674,8 +1157,6 @@ export function mapPaymentItemToOrderPayment(paymentItem) {
|
|
|
674
1157
|
service_charge: item.service_charge
|
|
675
1158
|
} : {}), item.order_payment_type !== undefined ? {
|
|
676
1159
|
order_payment_type: item.order_payment_type
|
|
677
|
-
} : {}), item.created_at !== undefined ? {
|
|
678
|
-
created_at: item.created_at
|
|
679
1160
|
} : {}), item.updated_at !== undefined ? {
|
|
680
1161
|
updated_at: item.updated_at
|
|
681
1162
|
} : {});
|
|
@@ -713,4 +1194,169 @@ export function formatV1Product(products) {
|
|
|
713
1194
|
};
|
|
714
1195
|
});
|
|
715
1196
|
}
|
|
716
|
-
|
|
1197
|
+
|
|
1198
|
+
/**
|
|
1199
|
+
* 判断 holder_id 是否已分配(非空)。
|
|
1200
|
+
*
|
|
1201
|
+
* @example
|
|
1202
|
+
* hasAssignedHolderId(12); // true
|
|
1203
|
+
* hasAssignedHolderId([]); // false
|
|
1204
|
+
*/
|
|
1205
|
+
export function hasAssignedHolderId(value) {
|
|
1206
|
+
if (value === undefined || value === null || value === '') return false;
|
|
1207
|
+
if (Array.isArray(value)) return value.length > 0;
|
|
1208
|
+
return true;
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
/**
|
|
1212
|
+
* 清空 tempOrder 购物车行上的 holder 分配(products / bookings / runtime origin)。
|
|
1213
|
+
* 移除或更换下单客户时调用,与 booking 页换客户清 holder 行为对齐。
|
|
1214
|
+
*
|
|
1215
|
+
* @example
|
|
1216
|
+
* clearTempOrderHolderAssignments(tempOrder);
|
|
1217
|
+
*/
|
|
1218
|
+
export function clearTempOrderHolderAssignments(tempOrder) {
|
|
1219
|
+
var _tempOrder$_extend;
|
|
1220
|
+
var changed = false;
|
|
1221
|
+
var resetHolderField = function resetHolderField(target) {
|
|
1222
|
+
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'holder_id';
|
|
1223
|
+
if (!hasAssignedHolderId(target[key])) return;
|
|
1224
|
+
target[key] = null;
|
|
1225
|
+
changed = true;
|
|
1226
|
+
};
|
|
1227
|
+
var _iterator7 = _createForOfIteratorHelper(tempOrder.products || []),
|
|
1228
|
+
_step7;
|
|
1229
|
+
try {
|
|
1230
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
1231
|
+
var product = _step7.value;
|
|
1232
|
+
if (product.metadata && _typeof(product.metadata) === 'object') {
|
|
1233
|
+
resetHolderField(product.metadata);
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
} catch (err) {
|
|
1237
|
+
_iterator7.e(err);
|
|
1238
|
+
} finally {
|
|
1239
|
+
_iterator7.f();
|
|
1240
|
+
}
|
|
1241
|
+
var _iterator8 = _createForOfIteratorHelper(tempOrder.bookings || []),
|
|
1242
|
+
_step8;
|
|
1243
|
+
try {
|
|
1244
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
1245
|
+
var booking = _step8.value;
|
|
1246
|
+
var bookingRecord = booking;
|
|
1247
|
+
if (booking.metadata && _typeof(booking.metadata) === 'object') {
|
|
1248
|
+
resetHolderField(booking.metadata);
|
|
1249
|
+
}
|
|
1250
|
+
if (bookingRecord.holder !== undefined && bookingRecord.holder !== null) {
|
|
1251
|
+
delete bookingRecord.holder;
|
|
1252
|
+
changed = true;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
} catch (err) {
|
|
1256
|
+
_iterator8.e(err);
|
|
1257
|
+
} finally {
|
|
1258
|
+
_iterator8.f();
|
|
1259
|
+
}
|
|
1260
|
+
var productsByUid = (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.productsByUid;
|
|
1261
|
+
if (productsByUid && _typeof(productsByUid) === 'object') {
|
|
1262
|
+
for (var _i4 = 0, _Object$values = Object.values(productsByUid); _i4 < _Object$values.length; _i4++) {
|
|
1263
|
+
var entry = _Object$values[_i4];
|
|
1264
|
+
var origin = entry === null || entry === void 0 ? void 0 : entry.origin;
|
|
1265
|
+
if (!origin || _typeof(origin) !== 'object') continue;
|
|
1266
|
+
if (origin.metadata && _typeof(origin.metadata) === 'object') {
|
|
1267
|
+
resetHolderField(origin.metadata);
|
|
1268
|
+
}
|
|
1269
|
+
if (origin._extend && _typeof(origin._extend) === 'object') {
|
|
1270
|
+
resetHolderField(origin._extend);
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
return changed;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
/**
|
|
1278
|
+
* 读取购物车行的 stable uid(优先 metadata.unique_identification_number)。
|
|
1279
|
+
*
|
|
1280
|
+
* @example
|
|
1281
|
+
* getOrderProductLineUid({ metadata: { unique_identification_number: 'line-1' } }); // 'line-1'
|
|
1282
|
+
*/
|
|
1283
|
+
export function getOrderProductLineUid(product) {
|
|
1284
|
+
var _product$metadata$uni, _product$metadata7;
|
|
1285
|
+
if (!product || _typeof(product) !== 'object') return null;
|
|
1286
|
+
var uid = (_product$metadata$uni = (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.unique_identification_number) !== null && _product$metadata$uni !== void 0 ? _product$metadata$uni : product.unique_identification_number;
|
|
1287
|
+
if (uid === undefined || uid === null || uid === '') return null;
|
|
1288
|
+
return String(uid);
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
/**
|
|
1292
|
+
* 判断展示字段是否为空(含 i18n 对象全空)。
|
|
1293
|
+
*
|
|
1294
|
+
* @example
|
|
1295
|
+
* isEmptyOrderProductDisplayValue(''); // true
|
|
1296
|
+
* isEmptyOrderProductDisplayValue({ auto: '桌台费' }); // false
|
|
1297
|
+
*/
|
|
1298
|
+
export function isEmptyOrderProductDisplayValue(value) {
|
|
1299
|
+
if (value === undefined || value === null) return true;
|
|
1300
|
+
if (typeof value === 'string') return value.trim() === '';
|
|
1301
|
+
if (_typeof(value) === 'object') {
|
|
1302
|
+
var record = value;
|
|
1303
|
+
return !Object.values(record).some(function (item) {
|
|
1304
|
+
return typeof item === 'string' && item.trim() !== '';
|
|
1305
|
+
});
|
|
1306
|
+
}
|
|
1307
|
+
return false;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
/**
|
|
1311
|
+
* calcDiscount / applyDiscount 回写时 Rules 往往不带 product_title 等展示字段;
|
|
1312
|
+
* 用旧行补齐,避免编辑态 hydrate 后标题被冲掉。
|
|
1313
|
+
*
|
|
1314
|
+
* @example
|
|
1315
|
+
* mergeOrderProductDisplayFields(
|
|
1316
|
+
* { product_title: { auto: '桌台费' }, metadata: { unique_identification_number: 'u1' } },
|
|
1317
|
+
* { selling_price: '10.00', metadata: { unique_identification_number: 'u1' } },
|
|
1318
|
+
* );
|
|
1319
|
+
*/
|
|
1320
|
+
export function mergeOrderProductDisplayFields(previous, next) {
|
|
1321
|
+
var merged = _objectSpread({}, next);
|
|
1322
|
+
var displayFields = ['product_title', 'product_name', 'product_cover', 'cover', 'variant_title', 'product_sku', 'payment_price'];
|
|
1323
|
+
displayFields.forEach(function (field) {
|
|
1324
|
+
if (isEmptyOrderProductDisplayValue(merged[field]) && !isEmptyOrderProductDisplayValue(previous[field])) {
|
|
1325
|
+
merged[field] = previous[field];
|
|
1326
|
+
}
|
|
1327
|
+
});
|
|
1328
|
+
if (previous.metadata || next.metadata) {
|
|
1329
|
+
merged.metadata = _objectSpread(_objectSpread({}, previous.metadata || {}), next.metadata || {});
|
|
1330
|
+
['product_title', 'product_name'].forEach(function (field) {
|
|
1331
|
+
var _previous$metadata;
|
|
1332
|
+
if (isEmptyOrderProductDisplayValue(merged.metadata[field]) && !isEmptyOrderProductDisplayValue((_previous$metadata = previous.metadata) === null || _previous$metadata === void 0 ? void 0 : _previous$metadata[field])) {
|
|
1333
|
+
merged.metadata[field] = previous.metadata[field];
|
|
1334
|
+
}
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
if (previous._extend && !merged._extend) {
|
|
1338
|
+
merged._extend = previous._extend;
|
|
1339
|
+
}
|
|
1340
|
+
return merged;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
/**
|
|
1344
|
+
* 按 uid 索引 tempOrder.products,供 applyDiscount 合并展示字段。
|
|
1345
|
+
*
|
|
1346
|
+
* @example
|
|
1347
|
+
* indexOrderProductsByUid([{ metadata: { unique_identification_number: 'u1' } }]);
|
|
1348
|
+
*/
|
|
1349
|
+
export function indexOrderProductsByUid(products) {
|
|
1350
|
+
var map = new Map();
|
|
1351
|
+
(products || []).forEach(function (product, index) {
|
|
1352
|
+
var uid = getOrderProductLineUid(product);
|
|
1353
|
+
if (uid) {
|
|
1354
|
+
map.set(uid, product);
|
|
1355
|
+
return;
|
|
1356
|
+
}
|
|
1357
|
+
map.set("__index__:".concat(index), product);
|
|
1358
|
+
});
|
|
1359
|
+
return map;
|
|
1360
|
+
}
|
|
1361
|
+
export { createEmptySummary } from "../../solution/ScanOrder/utils";
|
|
1362
|
+
export { buildManualProductDiscountItem, ensureManualProductDiscountList, findManualProductDiscountItem, mergeManualProductDiscountIntoList, resolveManualDiscountMessage, resolveManualDiscountOriginTotal, resolveManualDiscountReasonFromSources, resolveSafeProductNum, shouldBuildManualProductDiscount, syncManualProductDiscountProductNum, stripManualProductDiscountItems } from "./utils/manualProductDiscount";
|