@pisell/pisellos 2.2.243 → 2.2.244
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 +2 -3
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/utils.js +4 -7
- package/dist/modules/Cart/utils/cartProduct.js +3 -24
- package/dist/modules/Cart/utils/changePrice.js +11 -11
- package/dist/modules/Customer/index.d.ts +0 -20
- package/dist/modules/Customer/index.js +83 -172
- package/dist/modules/Customer/types.d.ts +0 -2
- package/dist/modules/Discount/index.js +3 -4
- package/dist/modules/Discount/types.d.ts +0 -1
- package/dist/modules/OpenData/index.d.ts +0 -8
- package/dist/modules/OpenData/index.js +17 -37
- package/dist/modules/Order/index.d.ts +18 -268
- package/dist/modules/Order/index.js +757 -3306
- package/dist/modules/Order/types.d.ts +31 -279
- package/dist/modules/Order/types.js +0 -38
- package/dist/modules/Order/utils.d.ts +5 -147
- package/dist/modules/Order/utils.js +103 -746
- package/dist/modules/Payment/index.d.ts +13 -10
- package/dist/modules/Payment/index.js +837 -467
- package/dist/modules/Payment/types.d.ts +0 -2
- package/dist/modules/Payment/utils.js +1 -2
- package/dist/modules/Payment/walletpass.js +7 -14
- package/dist/modules/ProductList/index.d.ts +12 -16
- package/dist/modules/ProductList/index.js +59 -133
- package/dist/modules/ProductList/types.d.ts +0 -14
- package/dist/modules/Quotation/index.d.ts +1 -0
- package/dist/modules/Quotation/index.js +22 -25
- package/dist/modules/Rules/index.d.ts +0 -4
- package/dist/modules/Rules/index.js +69 -93
- package/dist/modules/Rules/types.d.ts +0 -1
- package/dist/modules/SalesSummary/index.d.ts +25 -8
- package/dist/modules/SalesSummary/index.js +35 -86
- package/dist/modules/SalesSummary/types.d.ts +1 -4
- package/dist/modules/SalesSummary/utils.d.ts +25 -2
- package/dist/modules/SalesSummary/utils.js +162 -794
- package/dist/modules/Schedule/index.d.ts +0 -7
- package/dist/modules/Schedule/index.js +2 -24
- package/dist/modules/Summary/index.js +3 -4
- package/dist/modules/index.d.ts +0 -2
- package/dist/modules/index.js +1 -3
- package/dist/plugins/request.d.ts +0 -1
- package/dist/server/index.d.ts +1 -204
- package/dist/server/index.js +928 -3658
- package/dist/server/modules/index.d.ts +0 -2
- package/dist/server/modules/index.js +0 -2
- package/dist/server/modules/order/index.d.ts +4 -120
- package/dist/server/modules/order/index.js +483 -1779
- package/dist/server/modules/order/types.d.ts +3 -32
- package/dist/server/modules/order/types.js +0 -8
- package/dist/server/modules/order/utils/filterBookings.js +3 -26
- package/dist/server/modules/order/utils/filterOrders.js +8 -23
- package/dist/server/modules/products/index.d.ts +7 -34
- package/dist/server/modules/products/index.js +317 -631
- package/dist/server/modules/resource/index.d.ts +0 -2
- package/dist/server/modules/resource/index.js +3 -29
- package/dist/server/modules/schedule/index.d.ts +4 -4
- package/dist/server/modules/schedule/index.js +88 -111
- package/dist/solution/BaseSales/index.d.ts +9 -131
- package/dist/solution/BaseSales/index.js +447 -1944
- package/dist/solution/BaseSales/types.d.ts +6 -76
- package/dist/solution/BaseSales/types.js +4 -5
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +0 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -105
- package/dist/solution/BaseSales/utils.d.ts +1 -1
- package/dist/solution/BaseSales/utils.js +21 -62
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +10 -270
- package/dist/solution/BookingTicket/index.js +237 -1772
- package/dist/solution/BookingTicket/types.d.ts +1 -118
- package/dist/solution/BookingTicket/types.js +2 -41
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +0 -40
- package/dist/solution/BookingTicket/utils/bookingStatus.js +0 -70
- package/dist/solution/BookingTicket/utils/cartView.d.ts +1 -9
- package/dist/solution/BookingTicket/utils/cartView.js +7 -94
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +0 -5
- package/dist/solution/BookingTicket/utils/scan/index.js +8 -20
- package/dist/solution/Checkout/appointmentDemo.json +1 -0
- package/dist/solution/Checkout/index.d.ts +0 -1
- package/dist/solution/Checkout/index.js +9 -10
- package/dist/solution/RegisterAndLogin/config.js +10 -2
- package/dist/solution/ScanOrder/index.d.ts +3 -9
- package/dist/solution/ScanOrder/index.js +134 -241
- package/dist/solution/ScanOrder/types.d.ts +5 -9
- package/dist/solution/ScanOrder/types.js +3 -2
- package/dist/solution/ScanOrder/utils.d.ts +1 -1
- package/dist/solution/ScanOrder/utils.js +22 -84
- package/dist/solution/VenueBooking/index.d.ts +2 -5
- package/dist/solution/VenueBooking/index.js +59 -110
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +2 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/dist/types/index.d.ts +0 -10
- package/lib/model/strategy/adapter/promotion/evaluator.js +1 -2
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/model/strategy/adapter/walletPass/utils.js +2 -3
- package/lib/modules/Cart/utils/cartProduct.js +3 -20
- package/lib/modules/Cart/utils/changePrice.js +20 -12
- package/lib/modules/Customer/index.d.ts +0 -20
- package/lib/modules/Customer/index.js +11 -64
- package/lib/modules/Customer/types.d.ts +0 -2
- package/lib/modules/Discount/index.js +1 -5
- package/lib/modules/Discount/types.d.ts +0 -1
- package/lib/modules/OpenData/index.d.ts +0 -8
- package/lib/modules/OpenData/index.js +5 -19
- package/lib/modules/Order/index.d.ts +18 -268
- package/lib/modules/Order/index.js +344 -2149
- package/lib/modules/Order/types.d.ts +31 -279
- package/lib/modules/Order/types.js +0 -1
- package/lib/modules/Order/utils.d.ts +5 -147
- package/lib/modules/Order/utils.js +46 -614
- package/lib/modules/Payment/index.d.ts +13 -10
- package/lib/modules/Payment/index.js +150 -18
- package/lib/modules/Payment/types.d.ts +0 -2
- package/lib/modules/Payment/utils.js +1 -2
- package/lib/modules/Payment/walletpass.js +3 -7
- package/lib/modules/ProductList/index.d.ts +12 -16
- package/lib/modules/ProductList/index.js +4 -41
- package/lib/modules/ProductList/types.d.ts +0 -14
- package/lib/modules/Quotation/index.d.ts +1 -0
- package/lib/modules/Quotation/index.js +16 -19
- package/lib/modules/Rules/index.d.ts +0 -4
- package/lib/modules/Rules/index.js +120 -136
- package/lib/modules/Rules/types.d.ts +0 -1
- package/lib/modules/SalesSummary/index.d.ts +25 -8
- package/lib/modules/SalesSummary/index.js +4 -30
- package/lib/modules/SalesSummary/types.d.ts +1 -4
- package/lib/modules/SalesSummary/utils.d.ts +25 -2
- package/lib/modules/SalesSummary/utils.js +91 -645
- package/lib/modules/Schedule/index.d.ts +0 -7
- package/lib/modules/Schedule/index.js +1 -17
- package/lib/modules/Summary/index.js +4 -5
- package/lib/modules/index.d.ts +0 -2
- package/lib/modules/index.js +1 -5
- package/lib/plugins/request.d.ts +0 -1
- package/lib/server/index.d.ts +1 -204
- package/lib/server/index.js +57 -1888
- package/lib/server/modules/index.d.ts +0 -2
- package/lib/server/modules/index.js +0 -3
- package/lib/server/modules/order/index.d.ts +4 -120
- package/lib/server/modules/order/index.js +142 -919
- package/lib/server/modules/order/types.d.ts +3 -32
- package/lib/server/modules/order/utils/filterBookings.js +5 -24
- package/lib/server/modules/order/utils/filterOrders.js +6 -15
- package/lib/server/modules/products/index.d.ts +7 -34
- package/lib/server/modules/products/index.js +54 -189
- package/lib/server/modules/resource/index.d.ts +0 -2
- package/lib/server/modules/resource/index.js +3 -27
- package/lib/server/modules/schedule/index.d.ts +4 -4
- package/lib/server/modules/schedule/index.js +40 -47
- package/lib/solution/BaseSales/index.d.ts +9 -131
- package/lib/solution/BaseSales/index.js +63 -1106
- package/lib/solution/BaseSales/types.d.ts +6 -76
- package/lib/solution/BaseSales/types.js +1 -3
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +0 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +18 -106
- package/lib/solution/BaseSales/utils.d.ts +1 -1
- package/lib/solution/BaseSales/utils.js +10 -54
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +10 -270
- package/lib/solution/BookingTicket/index.js +29 -922
- package/lib/solution/BookingTicket/types.d.ts +1 -118
- package/lib/solution/BookingTicket/types.js +0 -11
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +0 -40
- package/lib/solution/BookingTicket/utils/bookingStatus.js +2 -44
- package/lib/solution/BookingTicket/utils/cartView.d.ts +1 -9
- package/lib/solution/BookingTicket/utils/cartView.js +6 -61
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +0 -5
- package/lib/solution/BookingTicket/utils/scan/index.js +3 -17
- package/lib/solution/Checkout/appointmentDemo.json +1 -0
- package/lib/solution/Checkout/index.d.ts +0 -1
- package/lib/solution/Checkout/index.js +2 -1
- package/lib/solution/RegisterAndLogin/config.js +10 -2
- package/lib/solution/ScanOrder/index.d.ts +3 -9
- package/lib/solution/ScanOrder/index.js +70 -153
- package/lib/solution/ScanOrder/types.d.ts +5 -9
- package/lib/solution/ScanOrder/utils.d.ts +1 -1
- package/lib/solution/ScanOrder/utils.js +17 -83
- package/lib/solution/VenueBooking/index.d.ts +2 -5
- package/lib/solution/VenueBooking/index.js +17 -54
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +2 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/lib/types/index.d.ts +0 -10
- package/package.json +1 -1
- package/dist/modules/BookingContext/index.d.ts +0 -48
- package/dist/modules/BookingContext/index.js +0 -566
- package/dist/modules/BookingContext/types.d.ts +0 -102
- package/dist/modules/BookingContext/types.js +0 -51
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -284
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -145
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -76
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -218
- package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/dist/modules/BookingContext/utils/flexible.js +0 -56
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
- package/dist/modules/BookingContext/utils/index.d.ts +0 -11
- package/dist/modules/BookingContext/utils/index.js +0 -11
- package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/dist/modules/BookingContext/utils/noResource.js +0 -77
- package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +0 -1
- package/dist/modules/BookingContext/utils/orderLineDisplay.js +0 -36
- package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/dist/modules/BookingContext/utils/productExtend.js +0 -339
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
- package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
- package/dist/modules/BookingContext/utils/resources.js +0 -486
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/dist/modules/Order/utils/manualProductDiscount.js +0 -210
- package/dist/modules/SurchargeList/index.d.ts +0 -16
- package/dist/modules/SurchargeList/index.js +0 -162
- package/dist/modules/SurchargeList/types.d.ts +0 -11
- package/dist/modules/SurchargeList/types.js +0 -1
- package/dist/server/modules/payment/index.d.ts +0 -28
- package/dist/server/modules/payment/index.js +0 -305
- package/dist/server/modules/payment/types.d.ts +0 -9
- package/dist/server/modules/payment/types.js +0 -1
- package/dist/server/test.json +0 -713
- package/dist/server/utils/small-ticket.d.ts +0 -71
- package/dist/server/utils/small-ticket.js +0 -830
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +0 -287
- package/dist/solution/BaseSales/utils/cartPromotion.js +0 -1438
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -117
- package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
- package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +0 -35
- package/dist/solution/BookingTicket/utils/addTimeAvailability.js +0 -95
- package/dist/solution/BookingTicket/utils/exampleData.d.ts +0 -123
- package/dist/solution/BookingTicket/utils/exampleData.js +0 -183
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +0 -185
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +0 -438
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -36
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +0 -399
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -32
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +0 -56
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +0 -21
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +0 -150
- package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +0 -23
- package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +0 -78
- package/lib/modules/BookingContext/index.d.ts +0 -48
- package/lib/modules/BookingContext/index.js +0 -368
- package/lib/modules/BookingContext/types.d.ts +0 -102
- package/lib/modules/BookingContext/types.js +0 -34
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -276
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -151
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -76
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -201
- package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/lib/modules/BookingContext/utils/flexible.js +0 -80
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
- package/lib/modules/BookingContext/utils/index.d.ts +0 -11
- package/lib/modules/BookingContext/utils/index.js +0 -43
- package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/lib/modules/BookingContext/utils/noResource.js +0 -90
- package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +0 -1
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +0 -56
- package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/lib/modules/BookingContext/utils/productExtend.js +0 -283
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
- package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
- package/lib/modules/BookingContext/utils/resources.js +0 -377
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/lib/modules/Order/utils/manualProductDiscount.js +0 -206
- package/lib/modules/SurchargeList/index.d.ts +0 -16
- package/lib/modules/SurchargeList/index.js +0 -89
- package/lib/modules/SurchargeList/types.d.ts +0 -11
- package/lib/modules/SurchargeList/types.js +0 -17
- package/lib/server/modules/payment/index.d.ts +0 -28
- package/lib/server/modules/payment/index.js +0 -192
- package/lib/server/modules/payment/types.d.ts +0 -9
- package/lib/server/modules/payment/types.js +0 -17
- package/lib/server/test.json +0 -713
- package/lib/server/utils/small-ticket.d.ts +0 -71
- package/lib/server/utils/small-ticket.js +0 -781
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +0 -287
- package/lib/solution/BaseSales/utils/cartPromotion.js +0 -992
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -117
- package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
- package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +0 -35
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +0 -125
- package/lib/solution/BookingTicket/utils/exampleData.d.ts +0 -123
- package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +0 -185
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +0 -254
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -36
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +0 -168
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -32
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +0 -51
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +0 -21
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +0 -127
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +0 -23
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +0 -85
|
@@ -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", "product_option_item", "surcharge_fee"],
|
|
3
|
+
_excluded3 = ["_extend", "relation_id", "table_form_id", "resource_id", "summary", "lastOrderInfo", "paid_amount", "shop_id", "shop_note", "shop_service_type", "start_time", "customer", "shop_full_order_number", "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); }
|
|
7
8
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
9
|
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."); }
|
|
9
10
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
10
11
|
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
|
|
22
|
+
import { buildProductLineFingerprint } from "../../solution/ScanOrder/utils";
|
|
23
23
|
/**
|
|
24
24
|
* 把"含 option 的主商品单价"与 bundle 合成"单行 composite 单价"。
|
|
25
25
|
*
|
|
@@ -43,15 +43,13 @@ export function composeLinePrice(params) {
|
|
|
43
43
|
_step;
|
|
44
44
|
try {
|
|
45
45
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
46
|
-
var _ref, _item$num;
|
|
46
|
+
var _ref, _item$original_price, _item$bundle_selling_, _ref2, _item$num;
|
|
47
47
|
var item = _step.value;
|
|
48
|
-
|
|
49
|
-
var
|
|
50
|
-
|
|
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;
|
|
48
|
+
var rawPrice = useOriginalBundle ? (_ref = (_item$original_price = item === null || item === void 0 ? void 0 : item.original_price) !== null && _item$original_price !== void 0 ? _item$original_price : item === null || item === void 0 ? void 0 : item.product_price) !== null && _ref !== void 0 ? _ref : item === null || item === void 0 ? void 0 : item.price : (_item$bundle_selling_ = item === null || item === void 0 ? void 0 : item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item === null || item === void 0 ? void 0 : item.price;
|
|
49
|
+
var price = new Decimal(Number(rawPrice) || 0);
|
|
50
|
+
var rawNum = (_ref2 = (_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 && _ref2 !== void 0 ? _ref2 : 1;
|
|
53
51
|
var num = new Decimal(Number(rawNum) || 0);
|
|
54
|
-
total = total.plus(
|
|
52
|
+
total = total.plus(price.times(num));
|
|
55
53
|
}
|
|
56
54
|
} catch (err) {
|
|
57
55
|
_iterator.e(err);
|
|
@@ -61,30 +59,9 @@ export function composeLinePrice(params) {
|
|
|
61
59
|
}
|
|
62
60
|
return total.toDecimalPlaces(2).toFixed(2);
|
|
63
61
|
}
|
|
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
|
-
}
|
|
84
62
|
|
|
85
63
|
/**
|
|
86
|
-
* 计算 option 单价合计:Σ(option.
|
|
87
|
-
* 兼容入参仍带旧 `price` 的调用方,但运行时归一化后只维护 `add_price`。
|
|
64
|
+
* 计算 option 单价合计:Σ(option.price × option.num)。
|
|
88
65
|
* 在新语义 v2 下,main_product_original_price = source_product_price + 本函数结果。
|
|
89
66
|
*/
|
|
90
67
|
export function sumOptionUnitPrice(options) {
|
|
@@ -94,9 +71,8 @@ export function sumOptionUnitPrice(options) {
|
|
|
94
71
|
_step2;
|
|
95
72
|
try {
|
|
96
73
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
97
|
-
var _opt$add_price;
|
|
98
74
|
var opt = _step2.value;
|
|
99
|
-
var price = new Decimal(Number(
|
|
75
|
+
var price = new Decimal(Number(opt === null || opt === void 0 ? void 0 : opt.price) || 0);
|
|
100
76
|
var num = new Decimal(Number(opt === null || opt === void 0 ? void 0 : opt.num) || 0);
|
|
101
77
|
total = total.plus(price.times(num));
|
|
102
78
|
}
|
|
@@ -107,263 +83,6 @@ export function sumOptionUnitPrice(options) {
|
|
|
107
83
|
}
|
|
108
84
|
return total;
|
|
109
85
|
}
|
|
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
|
-
}
|
|
367
86
|
|
|
368
87
|
/**
|
|
369
88
|
* OrderModule 默认 Rules 钩子工厂。
|
|
@@ -377,7 +96,7 @@ export function getBundleSellingMagnitude(bundle) {
|
|
|
377
96
|
* 不含折扣。**权威源**。
|
|
378
97
|
* - `metadata.main_product_original_price` = source + Σ(option.price × option.num)(含 option、不含折扣)。
|
|
379
98
|
* - `metadata.main_product_selling_price` = main_original − 主商品券 per-unit amount(含 option、含折扣)。
|
|
380
|
-
* - `payment_price`:出站 payload
|
|
99
|
+
* - `payment_price`:出站 payload 中由 `selling_price` 派生以兼容后端(composite)。
|
|
381
100
|
*
|
|
382
101
|
* Rules 钩子契约(hook_adapt 方案,Rules 内部保持不变):
|
|
383
102
|
* - `getProduct.price` / `getProduct.original_price` 回传 **source-level 主价**
|
|
@@ -394,168 +113,17 @@ export function getBundleSellingMagnitude(bundle) {
|
|
|
394
113
|
*
|
|
395
114
|
* 导出为纯函数方便单测直接驱动钩子,不依赖 OrderModule 实例。
|
|
396
115
|
*/
|
|
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
|
-
}
|
|
519
116
|
export function createDefaultOrderRulesHooks() {
|
|
520
117
|
var toUnitPriceString = function toUnitPriceString(totalLike, num) {
|
|
521
118
|
var effectiveNum = Number(num) > 0 ? Number(num) : 1;
|
|
522
119
|
return new Decimal(Number(totalLike) || 0).dividedBy(effectiveNum).toDecimalPlaces(2).toString();
|
|
523
120
|
};
|
|
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
|
-
};
|
|
553
121
|
return {
|
|
554
122
|
getProduct: function getProduct(product) {
|
|
555
|
-
var _product$metadata2, _product$metadata3, _product$metadata4, _product$metadata5, _product$metadata6
|
|
123
|
+
var _product$metadata, _product$metadata2, _product$metadata3, _product$metadata4, _product$metadata5, _product$metadata6;
|
|
556
124
|
// source_product_price 是权威源;兜底链:source → mainSelling − options(反推)→ 行 selling_price
|
|
557
125
|
var metadataAny = product.metadata || {};
|
|
558
|
-
var optionSum = sumOptionUnitPrice(
|
|
126
|
+
var optionSum = sumOptionUnitPrice(product.product_option_item);
|
|
559
127
|
var sourcePrice;
|
|
560
128
|
if (metadataAny.source_product_price !== undefined) {
|
|
561
129
|
sourcePrice = String(metadataAny.source_product_price);
|
|
@@ -577,9 +145,9 @@ export function createDefaultOrderRulesHooks() {
|
|
|
577
145
|
id: product.product_id,
|
|
578
146
|
// Rules 引擎用 _id 作为 processedProductsMap 键;必须与购物车行级 identity 一致,
|
|
579
147
|
// 否则同 SKU 不同小料会在 calcDiscount 重组时互相覆盖。
|
|
580
|
-
// 不透明 identity 契约下,normalizeOrderProduct /
|
|
148
|
+
// 不透明 identity 契约下,normalizeOrderProduct / restoreTempOrderFromStorage 已保证唯一值存在;
|
|
581
149
|
// 留 fingerprint 分支仅作 Rules 单测里直接传裸 product 时的兜底。
|
|
582
|
-
_id: (_product$
|
|
150
|
+
_id: (_product$metadata = product.metadata) !== null && _product$metadata !== void 0 && _product$metadata.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(product.product_option_item, product.product_bundle)),
|
|
583
151
|
// Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
|
|
584
152
|
// 所以这里必须喂 source-level(不含 option、不含 bundle、不含折扣)单价,避免双加 option。
|
|
585
153
|
price: sourcePrice,
|
|
@@ -591,24 +159,19 @@ export function createDefaultOrderRulesHooks() {
|
|
|
591
159
|
num: product.num || 1,
|
|
592
160
|
discount_list: product.discount_list || [],
|
|
593
161
|
bundle: product.product_bundle || [],
|
|
594
|
-
booking_id: ((_product$
|
|
162
|
+
booking_id: ((_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.booking_id) || null,
|
|
595
163
|
isClient: false,
|
|
596
|
-
|
|
597
|
-
// 无券时会把 bundle 价还原成 original_price(手动改价套餐会从 20 回到 30)。
|
|
598
|
-
isManualDiscount: resolveRulesManualDiscountFlag(metadataAny),
|
|
164
|
+
isManualDiscount: ((_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.is_manual_discount) || false,
|
|
599
165
|
holder_id: (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.holder_id,
|
|
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
|
|
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)
|
|
604
167
|
};
|
|
605
168
|
},
|
|
606
169
|
setProduct: function setProduct(product, values) {
|
|
607
|
-
var
|
|
608
|
-
var nextNum = Number((
|
|
170
|
+
var _ref3, _values$quantity, _ref4, _metadataAny$source_p, _values$bundle, _values$discount_list, _values$quantity2;
|
|
171
|
+
var nextNum = Number((_ref3 = (_values$quantity = values.quantity) !== null && _values$quantity !== void 0 ? _values$quantity : product.num) !== null && _ref3 !== void 0 ? _ref3 : 1) || 1;
|
|
609
172
|
var metadataAny = product.metadata || {};
|
|
610
|
-
var existedSource = (
|
|
611
|
-
var nextOptions =
|
|
173
|
+
var existedSource = (_ref4 = (_metadataAny$source_p = metadataAny.source_product_price) !== null && _metadataAny$source_p !== void 0 ? _metadataAny$source_p : product.selling_price) !== null && _ref4 !== void 0 ? _ref4 : '0';
|
|
174
|
+
var nextOptions = product.product_option_item;
|
|
612
175
|
var optionSum = sumOptionUnitPrice(nextOptions);
|
|
613
176
|
|
|
614
177
|
// Rules 返回的 main_product_selling_price / price / total 均为 source-level。
|
|
@@ -623,7 +186,7 @@ export function createDefaultOrderRulesHooks() {
|
|
|
623
186
|
// 含 option 的 main_product_*
|
|
624
187
|
var nextMainSellingPrice = new Decimal(Number(nextSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
625
188
|
var nextMainOriginalPrice = new Decimal(Number(nextSourceOriginalPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
626
|
-
var nextBundle = values.bundle !==
|
|
189
|
+
var nextBundle = (_values$bundle = values.bundle) !== null && _values$bundle !== void 0 ? _values$bundle : product.product_bundle;
|
|
627
190
|
var composedSellingPrice = composeLinePrice({
|
|
628
191
|
mainPrice: nextMainSellingPrice,
|
|
629
192
|
bundle: nextBundle
|
|
@@ -633,14 +196,9 @@ export function createDefaultOrderRulesHooks() {
|
|
|
633
196
|
bundle: nextBundle,
|
|
634
197
|
useOriginalBundle: true
|
|
635
198
|
});
|
|
636
|
-
var finalOriginalPrice = resolveManualOverrideLineOriginalPrice({
|
|
637
|
-
num: nextNum,
|
|
638
|
-
metadata: metadataAny,
|
|
639
|
-
lineOriginalPrice: product.original_price
|
|
640
|
-
}, composedOriginalPrice);
|
|
641
199
|
return _objectSpread(_objectSpread({}, product), {}, {
|
|
642
200
|
selling_price: composedSellingPrice,
|
|
643
|
-
original_price:
|
|
201
|
+
original_price: composedOriginalPrice,
|
|
644
202
|
discount_list: (_values$discount_list = values.discount_list) !== null && _values$discount_list !== void 0 ? _values$discount_list : product.discount_list,
|
|
645
203
|
num: (_values$quantity2 = values.quantity) !== null && _values$quantity2 !== void 0 ? _values$quantity2 : product.num,
|
|
646
204
|
product_bundle: nextBundle,
|
|
@@ -753,14 +311,13 @@ function formatSubmitOptionItems(options) {
|
|
|
753
311
|
if (!Array.isArray(options)) return [];
|
|
754
312
|
return options.map(function (d) {
|
|
755
313
|
var _d$add_price;
|
|
756
|
-
var option =
|
|
314
|
+
var option = {
|
|
757
315
|
num: d === null || d === void 0 ? void 0 : d.num,
|
|
758
316
|
option_group_item_id: d === null || d === void 0 ? void 0 : d.option_group_item_id,
|
|
759
317
|
option_group_id: d === null || d === void 0 ? void 0 : d.option_group_id
|
|
760
|
-
}
|
|
318
|
+
};
|
|
761
319
|
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;
|
|
762
320
|
if (addPrice !== undefined) option.add_price = String(addPrice);
|
|
763
|
-
delete option.price;
|
|
764
321
|
return option;
|
|
765
322
|
});
|
|
766
323
|
}
|
|
@@ -780,16 +337,11 @@ function toMoneyString(value) {
|
|
|
780
337
|
function formatSubmitBundleItems(bundle) {
|
|
781
338
|
if (!Array.isArray(bundle)) return [];
|
|
782
339
|
return bundle.map(function (b) {
|
|
783
|
-
var
|
|
340
|
+
var _rawBundle$bundle_sel, _ref5, _rawBundle$price, _rawBundle$surcharge_, _rawBundle$num, _rawBundle$is_charge_, _rawBundle$bundle_var, _rawBundle$quantity, _rawBundle$extension_, _rawBundle$extension_2, _ref6, _rawBundle$price_type, _ref7, _rawBundle$price_type2, _rawBundle$bundle_gro, _rawBundle$bundle_id, _rawBundle$bundle_pro;
|
|
784
341
|
var rawBundle = b && _typeof(b) === 'object' ? b : {};
|
|
785
342
|
var existedMetadata = rawBundle.metadata && _typeof(rawBundle.metadata) === 'object' ? rawBundle.metadata : {};
|
|
786
|
-
|
|
787
|
-
|
|
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;
|
|
343
|
+
var sellingPrice = toMoneyString((_rawBundle$bundle_sel = rawBundle.bundle_selling_price) !== null && _rawBundle$bundle_sel !== void 0 ? _rawBundle$bundle_sel : rawBundle.price);
|
|
344
|
+
var priceValue = (_ref5 = (_rawBundle$price = rawBundle.price) !== null && _rawBundle$price !== void 0 ? _rawBundle$price : rawBundle.custom_price) !== null && _ref5 !== void 0 ? _ref5 : rawBundle.bundle_selling_price;
|
|
793
345
|
var relationSurchargeIds = Array.isArray(rawBundle.relation_surcharge_ids) ? rawBundle.relation_surcharge_ids : Array.isArray(existedMetadata.relation_surcharge_ids) ? existedMetadata.relation_surcharge_ids : [];
|
|
794
346
|
var surchargeFee = toMoneyString((_rawBundle$surcharge_ = rawBundle.surcharge_fee) !== null && _rawBundle$surcharge_ !== void 0 ? _rawBundle$surcharge_ : existedMetadata.surcharge_fee);
|
|
795
347
|
var productDiscountDifference = toBundleNumber(existedMetadata.product_discount_difference, 0);
|
|
@@ -802,10 +354,9 @@ function formatSubmitBundleItems(bundle) {
|
|
|
802
354
|
extension_id: (_rawBundle$extension_ = rawBundle.extension_id) !== null && _rawBundle$extension_ !== void 0 ? _rawBundle$extension_ : 0,
|
|
803
355
|
extension_type: (_rawBundle$extension_2 = rawBundle.extension_type) !== null && _rawBundle$extension_2 !== void 0 ? _rawBundle$extension_2 : 'normal',
|
|
804
356
|
price: priceValue,
|
|
805
|
-
price_type: (
|
|
806
|
-
price_type_ext: (
|
|
357
|
+
price_type: (_ref6 = (_rawBundle$price_type = rawBundle.price_type) !== null && _rawBundle$price_type !== void 0 ? _rawBundle$price_type : rawBundle.custom_price_type) !== null && _ref6 !== void 0 ? _ref6 : '',
|
|
358
|
+
price_type_ext: (_ref7 = (_rawBundle$price_type2 = rawBundle.price_type_ext) !== null && _rawBundle$price_type2 !== void 0 ? _rawBundle$price_type2 : rawBundle.custom_price_type_ext) !== null && _ref7 !== void 0 ? _ref7 : '',
|
|
807
359
|
bundle_selling_price: sellingPrice,
|
|
808
|
-
bundle_payment_price: paymentPrice,
|
|
809
360
|
option: formatSubmitOptionItems(rawBundle.option),
|
|
810
361
|
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,
|
|
811
362
|
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,
|
|
@@ -827,7 +378,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
827
378
|
* = `metadata.main_product_selling_price` + Σ(bundle_selling_price × num)。
|
|
828
379
|
* - `original_price`:**行 composite 券前单价**
|
|
829
380
|
* = `metadata.main_product_original_price` + Σ(bundle 原价 × num)。
|
|
830
|
-
* - `payment_price
|
|
381
|
+
* - `payment_price`:兼容后端的出站字段,直接从 `selling_price` 派生(composite)。
|
|
831
382
|
* - `metadata.source_product_price`:主商品/variant 基础价(不含 option、不含折扣),权威源。
|
|
832
383
|
* - `metadata.main_product_original_price`:含 option、不含折扣。
|
|
833
384
|
* - `metadata.main_product_selling_price`:含 option、含主商品折扣。
|
|
@@ -836,26 +387,21 @@ function formatSubmitBundleItems(bundle) {
|
|
|
836
387
|
* 本函数不再改造价格字段形状,仅做字段/metadata 裁剪。
|
|
837
388
|
*/
|
|
838
389
|
function normalizeSubmitProduct(product) {
|
|
839
|
-
var _rawMetadata$product_, _submitProduct$produc
|
|
840
|
-
var
|
|
841
|
-
_runtimeUid =
|
|
842
|
-
submitProduct = _objectWithoutProperties(
|
|
390
|
+
var _rawMetadata$product_, _submitProduct$produc;
|
|
391
|
+
var _ref8 = product,
|
|
392
|
+
_runtimeUid = _ref8.unique_identification_number,
|
|
393
|
+
submitProduct = _objectWithoutProperties(_ref8, _excluded);
|
|
843
394
|
var num = submitProduct.num,
|
|
395
|
+
productOptionItem = submitProduct.product_option_item,
|
|
844
396
|
_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,
|
|
850
397
|
productRest = _objectWithoutProperties(submitProduct, _excluded2);
|
|
851
|
-
delete productRest["product_".concat('option', "_item")];
|
|
852
398
|
var rawMetadata = submitProduct.metadata || {};
|
|
853
399
|
var bookingUid = rawMetadata.booking_uid;
|
|
854
400
|
var cleanMetadata = {};
|
|
855
401
|
if (rawMetadata.unique_identification_number) {
|
|
856
402
|
cleanMetadata.unique_identification_number = rawMetadata.unique_identification_number;
|
|
857
403
|
}
|
|
858
|
-
var priceMetaKeys = ['main_product_original_price', 'main_product_selling_price', '
|
|
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'];
|
|
859
405
|
for (var _i = 0, _priceMetaKeys = priceMetaKeys; _i < _priceMetaKeys.length; _i++) {
|
|
860
406
|
var key = _priceMetaKeys[_i];
|
|
861
407
|
if (rawMetadata[key] !== undefined) {
|
|
@@ -870,22 +416,22 @@ function normalizeSubmitProduct(product) {
|
|
|
870
416
|
cleanMetadata.is_rule = rawMetadata.is_rule;
|
|
871
417
|
}
|
|
872
418
|
var productSku = _objectSpread(_objectSpread({}, submitProduct.product_sku && _typeof(submitProduct.product_sku) === 'object' ? submitProduct.product_sku : {}), {}, {
|
|
873
|
-
option: formatSubmitOptionItems((_submitProduct$produc = submitProduct.product_sku) === null || _submitProduct$produc === void 0 ? void 0 : _submitProduct$produc.option)
|
|
419
|
+
option: formatSubmitOptionItems(productOptionItem !== null && productOptionItem !== void 0 && productOptionItem.length ? productOptionItem : (_submitProduct$produc = submitProduct.product_sku) === null || _submitProduct$produc === void 0 ? void 0 : _submitProduct$produc.option)
|
|
874
420
|
});
|
|
875
421
|
return _objectSpread(_objectSpread(_objectSpread({}, productRest), bookingUid ? {
|
|
876
422
|
booking_uid: bookingUid
|
|
877
423
|
} : {}), {}, {
|
|
878
424
|
product_quantity: toBundleNumber(num !== null && num !== void 0 ? num : submitProduct.product_quantity, 1),
|
|
879
425
|
product_sku: productSku,
|
|
880
|
-
discount_list:
|
|
426
|
+
discount_list: submitProduct.discount_list || [],
|
|
881
427
|
product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
|
|
882
428
|
metadata: cleanMetadata,
|
|
883
|
-
// 出站兼容:后端消费 payment_price
|
|
884
|
-
//
|
|
885
|
-
payment_price:
|
|
429
|
+
// 出站兼容:后端消费 payment_price 字段,这里从 selling_price 直接派生。
|
|
430
|
+
// 新语义下 selling_price 是 composite(含 option/bundle),payment_price 同语义。
|
|
431
|
+
payment_price: submitProduct.selling_price
|
|
886
432
|
});
|
|
887
433
|
}
|
|
888
|
-
var SUBMIT_BOOKING_METADATA_WHITELIST = ['unique_identification_number', 'collect_pax', 'capacity', 'holder_id', 'resource_select_type'
|
|
434
|
+
var SUBMIT_BOOKING_METADATA_WHITELIST = ['unique_identification_number', 'collect_pax', 'capacity', 'holder_id', 'resource_select_type'];
|
|
889
435
|
export function normalizeBookingIsAll(booking) {
|
|
890
436
|
return booking.is_all === true || booking.is_all === 1 || booking.is_all === '1' || booking.is_all === 'true' ? 1 : 0;
|
|
891
437
|
}
|
|
@@ -899,19 +445,19 @@ export function normalizeBookingSubType(booking) {
|
|
|
899
445
|
export function normalizeSubmitBooking(booking) {
|
|
900
446
|
var rawMetadata = booking.metadata || {};
|
|
901
447
|
var cleanMetadata = {};
|
|
902
|
-
var
|
|
903
|
-
|
|
448
|
+
var _iterator3 = _createForOfIteratorHelper(SUBMIT_BOOKING_METADATA_WHITELIST),
|
|
449
|
+
_step3;
|
|
904
450
|
try {
|
|
905
|
-
for (
|
|
906
|
-
var key =
|
|
451
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
452
|
+
var key = _step3.value;
|
|
907
453
|
if (rawMetadata[key] !== undefined) {
|
|
908
454
|
cleanMetadata[key] = rawMetadata[key];
|
|
909
455
|
}
|
|
910
456
|
}
|
|
911
457
|
} catch (err) {
|
|
912
|
-
|
|
458
|
+
_iterator3.e(err);
|
|
913
459
|
} finally {
|
|
914
|
-
|
|
460
|
+
_iterator3.f();
|
|
915
461
|
}
|
|
916
462
|
if (cleanMetadata.holder_id === undefined) cleanMetadata.holder_id = null;
|
|
917
463
|
var bookingRecord = booking;
|
|
@@ -956,23 +502,22 @@ export function createDefaultTempOrder(params) {
|
|
|
956
502
|
return {
|
|
957
503
|
order_id: null,
|
|
958
504
|
external_sale_number: '',
|
|
959
|
-
order_number:
|
|
960
|
-
shop_order_number:
|
|
961
|
-
shop_full_order_number:
|
|
962
|
-
type: '',
|
|
963
|
-
business_code:
|
|
505
|
+
order_number: '',
|
|
506
|
+
shop_order_number: '',
|
|
507
|
+
shop_full_order_number: '',
|
|
508
|
+
type: 'appointment_booking',
|
|
509
|
+
business_code: 'appointment_booking',
|
|
964
510
|
platform: 'h5',
|
|
965
511
|
sales_channel: 'my_pisel',
|
|
966
512
|
order_sales_channel: 'online_store',
|
|
967
513
|
status: 'normal',
|
|
968
514
|
payment_status: 'payment_processing',
|
|
969
515
|
shipping_status: 'unfulfilled',
|
|
970
|
-
customer_id:
|
|
516
|
+
customer_id: null,
|
|
971
517
|
customer_name: '',
|
|
972
518
|
country_calling_code: '',
|
|
973
519
|
phone: '',
|
|
974
520
|
email: '',
|
|
975
|
-
customer: null,
|
|
976
521
|
is_price_include_tax: 1,
|
|
977
522
|
tax_title: '',
|
|
978
523
|
tax_country_code: '',
|
|
@@ -985,13 +530,14 @@ export function createDefaultTempOrder(params) {
|
|
|
985
530
|
surcharge_fee: '0.00',
|
|
986
531
|
note: '',
|
|
987
532
|
schedule_date: params.now,
|
|
988
|
-
created_at:
|
|
533
|
+
created_at: params.now,
|
|
989
534
|
request_unique_idempotency_token: '',
|
|
990
535
|
vouchers: [],
|
|
991
536
|
products: [],
|
|
992
537
|
bookings: [],
|
|
993
538
|
payments: [],
|
|
994
539
|
surcharges: [],
|
|
540
|
+
discount_list: [],
|
|
995
541
|
relation_forms: [],
|
|
996
542
|
contacts: [],
|
|
997
543
|
contacts_info: null,
|
|
@@ -1003,7 +549,7 @@ export function createDefaultTempOrder(params) {
|
|
|
1003
549
|
};
|
|
1004
550
|
}
|
|
1005
551
|
export function buildSubmitPayload(params) {
|
|
1006
|
-
var
|
|
552
|
+
var _ref10, _ref11, _ref12, _tempOrder$is_price_i, _tempOrder$is_deposit;
|
|
1007
553
|
var tempOrder = params.tempOrder,
|
|
1008
554
|
cacheId = params.cacheId,
|
|
1009
555
|
_params$now = params.now,
|
|
@@ -1012,52 +558,36 @@ export function buildSubmitPayload(params) {
|
|
|
1012
558
|
businessCode = params.businessCode,
|
|
1013
559
|
channel = params.channel,
|
|
1014
560
|
type = params.type,
|
|
1015
|
-
summary = params.summary,
|
|
1016
561
|
enhance = params.enhance;
|
|
1017
562
|
var scheduleDate = tempOrder.schedule_date || tempOrder.created_at || formatDateTime(now);
|
|
1018
563
|
var bookingUuid = createUuidV4();
|
|
1019
|
-
var
|
|
1020
|
-
_extend =
|
|
1021
|
-
_relationId =
|
|
1022
|
-
_tableFormId =
|
|
1023
|
-
_resourceId =
|
|
1024
|
-
_summary =
|
|
1025
|
-
_lastOrderInfo =
|
|
1026
|
-
_paidAmount =
|
|
1027
|
-
_shopId =
|
|
1028
|
-
_shopNote =
|
|
1029
|
-
_shopServiceType =
|
|
1030
|
-
_startTime =
|
|
1031
|
-
_customer =
|
|
1032
|
-
|
|
1033
|
-
_rootTaxFee =
|
|
1034
|
-
_totalAmount =
|
|
1035
|
-
_totalRefundAmount =
|
|
1036
|
-
_createDate =
|
|
1037
|
-
_holderId =
|
|
1038
|
-
tempOrderRest = _objectWithoutProperties(
|
|
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
|
-
}
|
|
564
|
+
var _ref9 = tempOrder,
|
|
565
|
+
_extend = _ref9._extend,
|
|
566
|
+
_relationId = _ref9.relation_id,
|
|
567
|
+
_tableFormId = _ref9.table_form_id,
|
|
568
|
+
_resourceId = _ref9.resource_id,
|
|
569
|
+
_summary = _ref9.summary,
|
|
570
|
+
_lastOrderInfo = _ref9.lastOrderInfo,
|
|
571
|
+
_paidAmount = _ref9.paid_amount,
|
|
572
|
+
_shopId = _ref9.shop_id,
|
|
573
|
+
_shopNote = _ref9.shop_note,
|
|
574
|
+
_shopServiceType = _ref9.shop_service_type,
|
|
575
|
+
_startTime = _ref9.start_time,
|
|
576
|
+
_customer = _ref9.customer,
|
|
577
|
+
_shopFullOrderNumber = _ref9.shop_full_order_number,
|
|
578
|
+
_rootTaxFee = _ref9.tax_fee,
|
|
579
|
+
_totalAmount = _ref9.total_amount,
|
|
580
|
+
_totalRefundAmount = _ref9.total_refund_amount,
|
|
581
|
+
_createDate = _ref9.create_date,
|
|
582
|
+
_holderId = _ref9.holder_id,
|
|
583
|
+
tempOrderRest = _objectWithoutProperties(_ref9, _excluded3);
|
|
1049
584
|
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,
|
|
1055
585
|
platform: normalizeSubmitPlatform(platform),
|
|
1056
|
-
request_unique_idempotency_token:
|
|
1057
|
-
type:
|
|
1058
|
-
business_code: businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code,
|
|
586
|
+
request_unique_idempotency_token: tempOrder.request_unique_idempotency_token || "".concat(tempOrder.external_sale_number, "_").concat(now.getTime()),
|
|
587
|
+
type: (_ref10 = type !== null && type !== void 0 ? type : tempOrder.type) !== null && _ref10 !== void 0 ? _ref10 : 'table-order',
|
|
588
|
+
business_code: (_ref11 = businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code) !== null && _ref11 !== void 0 ? _ref11 : 'table-order',
|
|
1059
589
|
sales_channel: tempOrder.sales_channel || 'my_pisel',
|
|
1060
|
-
order_sales_channel: (
|
|
590
|
+
order_sales_channel: (_ref12 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref12 !== void 0 ? _ref12 : 'online_store',
|
|
1061
591
|
status: tempOrder.status || 'normal',
|
|
1062
592
|
payment_status: tempOrder.payment_status || 'payment_processing',
|
|
1063
593
|
// shipping_status: tempOrder.shipping_status || 'unfulfilled',
|
|
@@ -1070,41 +600,39 @@ export function buildSubmitPayload(params) {
|
|
|
1070
600
|
note: tempOrder.note || '',
|
|
1071
601
|
delivery_type: tempOrder.delivery_type || 'nil',
|
|
1072
602
|
schedule_date: scheduleDate,
|
|
1073
|
-
|
|
603
|
+
created_at: tempOrder.created_at || formatDateTime(now),
|
|
1074
604
|
bookings: (tempOrder.bookings || []).filter(function (booking) {
|
|
1075
|
-
|
|
605
|
+
var _parent_id;
|
|
606
|
+
return Number((_parent_id = booking.parent_id) !== null && _parent_id !== void 0 ? _parent_id : 0) !== 0;
|
|
1076
607
|
}).map(function (booking) {
|
|
1077
608
|
return normalizeSubmitBooking(booking);
|
|
1078
609
|
}),
|
|
1079
610
|
payments: tempOrder.payments || [],
|
|
611
|
+
// discount_list: tempOrder.discount_list || [],
|
|
1080
612
|
relation_forms: tempOrder.relation_forms || [],
|
|
1081
613
|
// contacts: tempOrder.contacts || [],
|
|
1082
614
|
contacts_info: tempOrder.contacts_info && !Array.isArray(tempOrder.contacts_info) ? tempOrder.contacts_info : null,
|
|
1083
615
|
// holder: tempOrder.holder || null,
|
|
1084
|
-
|
|
616
|
+
// summary,
|
|
1085
617
|
metadata: function () {
|
|
1086
|
-
var
|
|
1087
|
-
_collectPax =
|
|
1088
|
-
_tableOccupancyDuration =
|
|
1089
|
-
rest = _objectWithoutProperties(
|
|
618
|
+
var _ref13 = tempOrder.metadata || {},
|
|
619
|
+
_collectPax = _ref13.collect_pax,
|
|
620
|
+
_tableOccupancyDuration = _ref13.table_occupancy_duration,
|
|
621
|
+
rest = _objectWithoutProperties(_ref13, _excluded4);
|
|
1090
622
|
return _objectSpread({}, rest);
|
|
1091
623
|
}(),
|
|
1092
624
|
products: (tempOrder.products || []).map(function (product) {
|
|
1093
625
|
return normalizeSubmitProduct(product);
|
|
1094
626
|
})
|
|
1095
627
|
});
|
|
1096
|
-
|
|
1097
|
-
var enhancedPayload = enhance(payload, {
|
|
628
|
+
return enhance ? enhance(payload, {
|
|
1098
629
|
tempOrder: tempOrder,
|
|
1099
630
|
bookingUuid: bookingUuid,
|
|
1100
631
|
now: now
|
|
1101
|
-
});
|
|
1102
|
-
return _objectSpread(_objectSpread({}, enhancedPayload), {}, {
|
|
1103
|
-
summary: (_enhancedPayload$summ = enhancedPayload.summary) !== null && _enhancedPayload$summ !== void 0 ? _enhancedPayload$summ : payload.summary
|
|
1104
|
-
});
|
|
632
|
+
}) : payload;
|
|
1105
633
|
}
|
|
1106
634
|
export function mapPaymentItemToOrderPayment(paymentItem) {
|
|
1107
|
-
var _item$custom_payment_, _item$
|
|
635
|
+
var _item$custom_payment_, _item$amount;
|
|
1108
636
|
var item = paymentItem;
|
|
1109
637
|
var customPaymentId = (_item$custom_payment_ = item.custom_payment_id) !== null && _item$custom_payment_ !== void 0 ? _item$custom_payment_ : item.id;
|
|
1110
638
|
var metadata = item.metadata && _typeof(item.metadata) === 'object' ? _objectSpread({}, item.metadata) : {};
|
|
@@ -1118,12 +646,7 @@ export function mapPaymentItemToOrderPayment(paymentItem) {
|
|
|
1118
646
|
metadata[key] = item[key];
|
|
1119
647
|
}
|
|
1120
648
|
}
|
|
1121
|
-
|
|
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({}, item.order_payment_id !== undefined ? {
|
|
1125
|
-
order_payment_id: item.order_payment_id
|
|
1126
|
-
} : {}), {}, {
|
|
649
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
1127
650
|
amount: String((_item$amount = item.amount) !== null && _item$amount !== void 0 ? _item$amount : '0.00'),
|
|
1128
651
|
code: String(item.code || ''),
|
|
1129
652
|
custom_payment_id: Number(customPaymentId !== null && customPaymentId !== void 0 ? customPaymentId : 0),
|
|
@@ -1137,15 +660,12 @@ export function mapPaymentItemToOrderPayment(paymentItem) {
|
|
|
1137
660
|
service_fee: String(item.service_fee)
|
|
1138
661
|
} : {}), item.status !== undefined ? {
|
|
1139
662
|
status: item.status
|
|
1140
|
-
} : {}),
|
|
1141
|
-
payment_time:
|
|
1142
|
-
|
|
1143
|
-
}, item.wallet_pass_usage_unit !== undefined ? {
|
|
663
|
+
} : {}), item.payment_time !== undefined ? {
|
|
664
|
+
payment_time: item.payment_time
|
|
665
|
+
} : {}), item.wallet_pass_usage_unit !== undefined ? {
|
|
1144
666
|
wallet_pass_usage_unit: item.wallet_pass_usage_unit
|
|
1145
667
|
} : {}), item.wallet_pass_use_value !== undefined ? {
|
|
1146
668
|
wallet_pass_use_value: item.wallet_pass_use_value
|
|
1147
|
-
} : {}), item.fund_record && _typeof(item.fund_record) === 'object' && !Array.isArray(item.fund_record) ? {
|
|
1148
|
-
fund_record: _objectSpread({}, item.fund_record)
|
|
1149
669
|
} : {}), {}, {
|
|
1150
670
|
metadata: metadata
|
|
1151
671
|
}, item.rounding_amount !== undefined ? {
|
|
@@ -1154,6 +674,8 @@ export function mapPaymentItemToOrderPayment(paymentItem) {
|
|
|
1154
674
|
service_charge: item.service_charge
|
|
1155
675
|
} : {}), item.order_payment_type !== undefined ? {
|
|
1156
676
|
order_payment_type: item.order_payment_type
|
|
677
|
+
} : {}), item.created_at !== undefined ? {
|
|
678
|
+
created_at: item.created_at
|
|
1157
679
|
} : {}), item.updated_at !== undefined ? {
|
|
1158
680
|
updated_at: item.updated_at
|
|
1159
681
|
} : {});
|
|
@@ -1191,169 +713,4 @@ export function formatV1Product(products) {
|
|
|
1191
713
|
};
|
|
1192
714
|
});
|
|
1193
715
|
}
|
|
1194
|
-
|
|
1195
|
-
/**
|
|
1196
|
-
* 判断 holder_id 是否已分配(非空)。
|
|
1197
|
-
*
|
|
1198
|
-
* @example
|
|
1199
|
-
* hasAssignedHolderId(12); // true
|
|
1200
|
-
* hasAssignedHolderId([]); // false
|
|
1201
|
-
*/
|
|
1202
|
-
export function hasAssignedHolderId(value) {
|
|
1203
|
-
if (value === undefined || value === null || value === '') return false;
|
|
1204
|
-
if (Array.isArray(value)) return value.length > 0;
|
|
1205
|
-
return true;
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
/**
|
|
1209
|
-
* 清空 tempOrder 购物车行上的 holder 分配(products / bookings / runtime origin)。
|
|
1210
|
-
* 移除或更换下单客户时调用,与 booking 页换客户清 holder 行为对齐。
|
|
1211
|
-
*
|
|
1212
|
-
* @example
|
|
1213
|
-
* clearTempOrderHolderAssignments(tempOrder);
|
|
1214
|
-
*/
|
|
1215
|
-
export function clearTempOrderHolderAssignments(tempOrder) {
|
|
1216
|
-
var _tempOrder$_extend;
|
|
1217
|
-
var changed = false;
|
|
1218
|
-
var resetHolderField = function resetHolderField(target) {
|
|
1219
|
-
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'holder_id';
|
|
1220
|
-
if (!hasAssignedHolderId(target[key])) return;
|
|
1221
|
-
target[key] = null;
|
|
1222
|
-
changed = true;
|
|
1223
|
-
};
|
|
1224
|
-
var _iterator7 = _createForOfIteratorHelper(tempOrder.products || []),
|
|
1225
|
-
_step7;
|
|
1226
|
-
try {
|
|
1227
|
-
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
1228
|
-
var product = _step7.value;
|
|
1229
|
-
if (product.metadata && _typeof(product.metadata) === 'object') {
|
|
1230
|
-
resetHolderField(product.metadata);
|
|
1231
|
-
}
|
|
1232
|
-
}
|
|
1233
|
-
} catch (err) {
|
|
1234
|
-
_iterator7.e(err);
|
|
1235
|
-
} finally {
|
|
1236
|
-
_iterator7.f();
|
|
1237
|
-
}
|
|
1238
|
-
var _iterator8 = _createForOfIteratorHelper(tempOrder.bookings || []),
|
|
1239
|
-
_step8;
|
|
1240
|
-
try {
|
|
1241
|
-
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
1242
|
-
var booking = _step8.value;
|
|
1243
|
-
var bookingRecord = booking;
|
|
1244
|
-
if (booking.metadata && _typeof(booking.metadata) === 'object') {
|
|
1245
|
-
resetHolderField(booking.metadata);
|
|
1246
|
-
}
|
|
1247
|
-
if (bookingRecord.holder !== undefined && bookingRecord.holder !== null) {
|
|
1248
|
-
delete bookingRecord.holder;
|
|
1249
|
-
changed = true;
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
} catch (err) {
|
|
1253
|
-
_iterator8.e(err);
|
|
1254
|
-
} finally {
|
|
1255
|
-
_iterator8.f();
|
|
1256
|
-
}
|
|
1257
|
-
var productsByUid = (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.productsByUid;
|
|
1258
|
-
if (productsByUid && _typeof(productsByUid) === 'object') {
|
|
1259
|
-
for (var _i4 = 0, _Object$values = Object.values(productsByUid); _i4 < _Object$values.length; _i4++) {
|
|
1260
|
-
var entry = _Object$values[_i4];
|
|
1261
|
-
var origin = entry === null || entry === void 0 ? void 0 : entry.origin;
|
|
1262
|
-
if (!origin || _typeof(origin) !== 'object') continue;
|
|
1263
|
-
if (origin.metadata && _typeof(origin.metadata) === 'object') {
|
|
1264
|
-
resetHolderField(origin.metadata);
|
|
1265
|
-
}
|
|
1266
|
-
if (origin._extend && _typeof(origin._extend) === 'object') {
|
|
1267
|
-
resetHolderField(origin._extend);
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
return changed;
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
/**
|
|
1275
|
-
* 读取购物车行的 stable uid(优先 metadata.unique_identification_number)。
|
|
1276
|
-
*
|
|
1277
|
-
* @example
|
|
1278
|
-
* getOrderProductLineUid({ metadata: { unique_identification_number: 'line-1' } }); // 'line-1'
|
|
1279
|
-
*/
|
|
1280
|
-
export function getOrderProductLineUid(product) {
|
|
1281
|
-
var _product$metadata$uni, _product$metadata7;
|
|
1282
|
-
if (!product || _typeof(product) !== 'object') return null;
|
|
1283
|
-
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;
|
|
1284
|
-
if (uid === undefined || uid === null || uid === '') return null;
|
|
1285
|
-
return String(uid);
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1288
|
-
/**
|
|
1289
|
-
* 判断展示字段是否为空(含 i18n 对象全空)。
|
|
1290
|
-
*
|
|
1291
|
-
* @example
|
|
1292
|
-
* isEmptyOrderProductDisplayValue(''); // true
|
|
1293
|
-
* isEmptyOrderProductDisplayValue({ auto: '桌台费' }); // false
|
|
1294
|
-
*/
|
|
1295
|
-
export function isEmptyOrderProductDisplayValue(value) {
|
|
1296
|
-
if (value === undefined || value === null) return true;
|
|
1297
|
-
if (typeof value === 'string') return value.trim() === '';
|
|
1298
|
-
if (_typeof(value) === 'object') {
|
|
1299
|
-
var record = value;
|
|
1300
|
-
return !Object.values(record).some(function (item) {
|
|
1301
|
-
return typeof item === 'string' && item.trim() !== '';
|
|
1302
|
-
});
|
|
1303
|
-
}
|
|
1304
|
-
return false;
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
/**
|
|
1308
|
-
* calcDiscount / applyDiscount 回写时 Rules 往往不带 product_title 等展示字段;
|
|
1309
|
-
* 用旧行补齐,避免编辑态 hydrate 后标题被冲掉。
|
|
1310
|
-
*
|
|
1311
|
-
* @example
|
|
1312
|
-
* mergeOrderProductDisplayFields(
|
|
1313
|
-
* { product_title: { auto: '桌台费' }, metadata: { unique_identification_number: 'u1' } },
|
|
1314
|
-
* { selling_price: '10.00', metadata: { unique_identification_number: 'u1' } },
|
|
1315
|
-
* );
|
|
1316
|
-
*/
|
|
1317
|
-
export function mergeOrderProductDisplayFields(previous, next) {
|
|
1318
|
-
var merged = _objectSpread({}, next);
|
|
1319
|
-
var displayFields = ['product_title', 'product_name', 'product_cover', 'cover', 'variant_title', 'product_sku', 'payment_price'];
|
|
1320
|
-
displayFields.forEach(function (field) {
|
|
1321
|
-
if (isEmptyOrderProductDisplayValue(merged[field]) && !isEmptyOrderProductDisplayValue(previous[field])) {
|
|
1322
|
-
merged[field] = previous[field];
|
|
1323
|
-
}
|
|
1324
|
-
});
|
|
1325
|
-
if (previous.metadata || next.metadata) {
|
|
1326
|
-
merged.metadata = _objectSpread(_objectSpread({}, previous.metadata || {}), next.metadata || {});
|
|
1327
|
-
['product_title', 'product_name'].forEach(function (field) {
|
|
1328
|
-
var _previous$metadata;
|
|
1329
|
-
if (isEmptyOrderProductDisplayValue(merged.metadata[field]) && !isEmptyOrderProductDisplayValue((_previous$metadata = previous.metadata) === null || _previous$metadata === void 0 ? void 0 : _previous$metadata[field])) {
|
|
1330
|
-
merged.metadata[field] = previous.metadata[field];
|
|
1331
|
-
}
|
|
1332
|
-
});
|
|
1333
|
-
}
|
|
1334
|
-
if (previous._extend && !merged._extend) {
|
|
1335
|
-
merged._extend = previous._extend;
|
|
1336
|
-
}
|
|
1337
|
-
return merged;
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
/**
|
|
1341
|
-
* 按 uid 索引 tempOrder.products,供 applyDiscount 合并展示字段。
|
|
1342
|
-
*
|
|
1343
|
-
* @example
|
|
1344
|
-
* indexOrderProductsByUid([{ metadata: { unique_identification_number: 'u1' } }]);
|
|
1345
|
-
*/
|
|
1346
|
-
export function indexOrderProductsByUid(products) {
|
|
1347
|
-
var map = new Map();
|
|
1348
|
-
(products || []).forEach(function (product, index) {
|
|
1349
|
-
var uid = getOrderProductLineUid(product);
|
|
1350
|
-
if (uid) {
|
|
1351
|
-
map.set(uid, product);
|
|
1352
|
-
return;
|
|
1353
|
-
}
|
|
1354
|
-
map.set("__index__:".concat(index), product);
|
|
1355
|
-
});
|
|
1356
|
-
return map;
|
|
1357
|
-
}
|
|
1358
|
-
export { createEmptySummary } from "../../solution/ScanOrder/utils";
|
|
1359
|
-
export { buildManualProductDiscountItem, ensureManualProductDiscountList, findManualProductDiscountItem, mergeManualProductDiscountIntoList, resolveManualDiscountMessage, resolveManualDiscountOriginTotal, resolveManualDiscountReasonFromSources, resolveSafeProductNum, shouldBuildManualProductDiscount, syncManualProductDiscountProductNum, stripManualProductDiscountItems } from "./utils/manualProductDiscount";
|
|
716
|
+
export { createEmptySummary } from "../../solution/ScanOrder/utils";
|