@pisell/pisellos 2.2.308 → 2.2.310
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/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +4 -2
- package/dist/modules/BookingContext/index.js +4 -4
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +58 -19
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +24 -12
- package/dist/modules/Customer/index.js +6 -3
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/availability.d.ts +7 -0
- package/dist/modules/Discount/availability.js +49 -0
- package/dist/modules/Discount/entitlementPass.d.ts +34 -0
- package/dist/modules/Discount/entitlementPass.js +147 -0
- package/dist/modules/Discount/index.d.ts +2 -2
- package/dist/modules/Discount/index.js +37 -151
- package/dist/modules/Discount/types.d.ts +36 -5
- package/dist/modules/OpenData/index.d.ts +1 -1
- package/dist/modules/OpenData/index.js +21 -12
- package/dist/modules/Order/index.d.ts +33 -4
- package/dist/modules/Order/index.js +830 -411
- package/dist/modules/Order/types.d.ts +17 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +16 -12
- package/dist/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/dist/modules/Order/utils/weighedProduct.js +94 -0
- package/dist/modules/Order/utils.d.ts +14 -2
- package/dist/modules/Order/utils.js +280 -79
- package/dist/modules/Payment/index.d.ts +0 -5
- package/dist/modules/Payment/index.js +35 -85
- package/dist/modules/Payment/types.d.ts +21 -1
- package/dist/modules/Payment/types.js +2 -0
- package/dist/modules/Payment/walletpass.d.ts +1 -1
- package/dist/modules/Payment/walletpass.js +80 -47
- package/dist/modules/ProductList/index.js +18 -5
- package/dist/modules/Rules/index.d.ts +2 -2
- package/dist/modules/Rules/index.js +484 -188
- package/dist/modules/Rules/types.d.ts +6 -0
- package/dist/server/index.js +8 -5
- package/dist/server/modules/order/index.js +6 -0
- package/dist/server/modules/order/types.d.ts +12 -0
- package/dist/server/modules/payment/index.d.ts +25 -6
- package/dist/server/modules/payment/index.js +660 -133
- package/dist/server/utils/small-ticket.d.ts +8 -5
- package/dist/server/utils/small-ticket.js +1269 -199
- package/dist/solution/BaseSales/index.d.ts +11 -2
- package/dist/solution/BaseSales/index.js +1463 -1173
- package/dist/solution/BaseSales/types.d.ts +7 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +141 -126
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +40 -25
- package/dist/solution/BaseSales/utils.js +3 -2
- package/dist/solution/BookingTicket/index.d.ts +11 -2
- package/dist/solution/BookingTicket/index.js +663 -542
- package/dist/solution/BookingTicket/types.d.ts +5 -1
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +338 -147
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +19 -6
- package/dist/solution/ScanOrder/utils.js +3 -2
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +99 -42
- package/dist/solution/ShopDiscount/utils.d.ts +4 -2
- package/dist/solution/ShopDiscount/utils.js +43 -23
- package/dist/solution/UnifiedBookingSales/index.d.ts +2 -2
- package/dist/solution/UnifiedBookingSales/index.js +5 -5
- package/dist/utils/os-private-payload.d.ts +5 -0
- package/dist/utils/os-private-payload.js +17 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -0
- package/lib/modules/BookingContext/index.js +3 -3
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +35 -6
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +13 -6
- package/lib/modules/Customer/index.js +5 -1
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/availability.d.ts +7 -0
- package/lib/modules/Discount/availability.js +43 -0
- package/lib/modules/Discount/entitlementPass.d.ts +34 -0
- package/lib/modules/Discount/entitlementPass.js +141 -0
- package/lib/modules/Discount/index.d.ts +2 -2
- package/lib/modules/Discount/index.js +23 -129
- package/lib/modules/Discount/types.d.ts +36 -5
- package/lib/modules/OpenData/index.d.ts +1 -1
- package/lib/modules/OpenData/index.js +11 -2
- package/lib/modules/Order/index.d.ts +33 -4
- package/lib/modules/Order/index.js +411 -81
- package/lib/modules/Order/types.d.ts +17 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +14 -11
- package/lib/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/lib/modules/Order/utils/weighedProduct.js +89 -0
- package/lib/modules/Order/utils.d.ts +14 -2
- package/lib/modules/Order/utils.js +189 -5
- package/lib/modules/Payment/index.d.ts +0 -5
- package/lib/modules/Payment/index.js +3 -28
- package/lib/modules/Payment/types.d.ts +21 -1
- package/lib/modules/Payment/types.js +1 -0
- package/lib/modules/Payment/walletpass.d.ts +1 -1
- package/lib/modules/Payment/walletpass.js +29 -9
- package/lib/modules/ProductList/index.js +14 -1
- package/lib/modules/Rules/index.d.ts +2 -2
- package/lib/modules/Rules/index.js +361 -112
- package/lib/modules/Rules/types.d.ts +6 -0
- package/lib/server/index.js +8 -5
- package/lib/server/modules/order/index.js +6 -0
- package/lib/server/modules/order/types.d.ts +12 -0
- package/lib/server/modules/payment/index.d.ts +25 -6
- package/lib/server/modules/payment/index.js +350 -78
- package/lib/server/utils/small-ticket.d.ts +8 -5
- package/lib/server/utils/small-ticket.js +1009 -121
- package/lib/solution/BaseSales/index.d.ts +11 -2
- package/lib/solution/BaseSales/index.js +164 -30
- package/lib/solution/BaseSales/types.d.ts +7 -3
- package/lib/solution/BaseSales/utils/cartPromotion.js +12 -4
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -9
- package/lib/solution/BaseSales/utils.js +2 -1
- package/lib/solution/BookingTicket/index.d.ts +11 -2
- package/lib/solution/BookingTicket/index.js +103 -41
- package/lib/solution/BookingTicket/types.d.ts +5 -1
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +174 -42
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +11 -3
- package/lib/solution/ScanOrder/utils.js +2 -1
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +55 -9
- package/lib/solution/ShopDiscount/utils.d.ts +4 -2
- package/lib/solution/ShopDiscount/utils.js +42 -25
- package/lib/solution/UnifiedBookingSales/index.d.ts +2 -2
- package/lib/solution/UnifiedBookingSales/index.js +5 -5
- package/lib/utils/os-private-payload.d.ts +5 -0
- package/lib/utils/os-private-payload.js +22 -0
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
11
11
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
12
12
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
13
13
|
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; }
|
|
14
|
+
import { resolveWeighedSourcePrice, withOriginalBundleOptionPrices } from "../../../modules/Order/utils/weighedProduct";
|
|
14
15
|
import { composeLinePrice, getBundleSellingMagnitude, normalizeProductSkuOptions, sumOptionUnitPrice } from "../../../modules/Order/utils";
|
|
15
16
|
import { buildManualProductDiscountItem, mergeManualProductDiscountIntoList, resolveManualDiscountOriginTotal, resolveManualDiscountReasonFromSources, shouldBuildManualProductDiscount } from "../../../modules/Order/utils/manualProductDiscount";
|
|
16
17
|
function toNumber(value) {
|
|
@@ -101,11 +102,12 @@ function appendDataVariantIds(base) {
|
|
|
101
102
|
return Array.isArray(base) || result.length ? result : undefined;
|
|
102
103
|
}
|
|
103
104
|
function normalizeOptionItems(optionItems) {
|
|
105
|
+
var useOriginalPrice = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
104
106
|
if (!Array.isArray(optionItems)) return [];
|
|
105
107
|
return optionItems.map(function (optionItem) {
|
|
106
|
-
var _optionItem$option_gr, _ref,
|
|
108
|
+
var _optionItem$option_gr, _ref, _ref2, _ref3, _optionItem$num;
|
|
107
109
|
var optionGroupItemId = toNumber((_optionItem$option_gr = optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id) !== null && _optionItem$option_gr !== void 0 ? _optionItem$option_gr : optionItem === null || optionItem === void 0 ? void 0 : optionItem.id);
|
|
108
|
-
var price = (_ref = (
|
|
110
|
+
var price = (_ref = (_ref2 = (_ref3 = useOriginalPrice ? optionItem === null || optionItem === void 0 ? void 0 : optionItem.original_price : undefined) !== null && _ref3 !== void 0 ? _ref3 : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref2 !== void 0 ? _ref2 : optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _ref !== void 0 ? _ref : 0;
|
|
109
111
|
return _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
110
112
|
option_group_item_id: optionGroupItemId,
|
|
111
113
|
option_group_id: toNumber(optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_id),
|
|
@@ -117,10 +119,13 @@ function normalizeOptionItems(optionItems) {
|
|
|
117
119
|
}
|
|
118
120
|
function normalizeBundleItems(bundleItems) {
|
|
119
121
|
var preferPriceField = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
122
|
+
var preferBundleSellingPrice = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
120
123
|
if (!Array.isArray(bundleItems)) return [];
|
|
121
124
|
return bundleItems.map(function (bundleItem) {
|
|
122
|
-
var
|
|
123
|
-
|
|
125
|
+
var _ref4, _ref5, _ref6, _bundleItem$price, _ref7, _ref8, _ref9, _bundleItem$bundle_se, _bundleItem$num, _bundleItem$price2, _bundleItem$quantity, _bundleItem$price3, _ref10, _ref11, _bundleItem$original_, _normalizedItem$price;
|
|
126
|
+
// Weighed manual prices distribute the bundle base and nested options separately.
|
|
127
|
+
// Its explicit selling amount already includes those options.
|
|
128
|
+
var unitSelling = preferPriceField && !preferBundleSellingPrice ? (_ref4 = (_ref5 = (_ref6 = (_bundleItem$price = bundleItem.price) !== null && _bundleItem$price !== void 0 ? _bundleItem$price : bundleItem.bundle_selling_price) !== null && _ref6 !== void 0 ? _ref6 : bundleItem.custom_price) !== null && _ref5 !== void 0 ? _ref5 : bundleItem.product_price) !== null && _ref4 !== void 0 ? _ref4 : '0' : (_ref7 = (_ref8 = (_ref9 = (_bundleItem$bundle_se = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se !== void 0 ? _bundleItem$bundle_se : bundleItem.price) !== null && _ref9 !== void 0 ? _ref9 : bundleItem.custom_price) !== null && _ref8 !== void 0 ? _ref8 : bundleItem.product_price) !== null && _ref7 !== void 0 ? _ref7 : '0';
|
|
124
129
|
var unitStr = toPriceString(unitSelling, '0.00');
|
|
125
130
|
var num = toSafePositiveInt((_bundleItem$num = bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.num) !== null && _bundleItem$num !== void 0 ? _bundleItem$num : bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.quantity, 1);
|
|
126
131
|
var magnitudeSource = _objectSpread(_objectSpread({}, bundleItem), {}, {
|
|
@@ -135,7 +140,7 @@ function normalizeBundleItems(bundleItems) {
|
|
|
135
140
|
// price 保留毛价(markdown 仍为正),由 price_type 决定符号。
|
|
136
141
|
price: (_bundleItem$price3 = bundleItem.price) !== null && _bundleItem$price3 !== void 0 ? _bundleItem$price3 : unitStr,
|
|
137
142
|
bundle_selling_price: unitStr,
|
|
138
|
-
original_price: (
|
|
143
|
+
original_price: (_ref10 = (_ref11 = (_bundleItem$original_ = bundleItem.original_price) !== null && _bundleItem$original_ !== void 0 ? _bundleItem$original_ : bundleItem.product_price) !== null && _ref11 !== void 0 ? _ref11 : bundleItem.price) !== null && _ref10 !== void 0 ? _ref10 : unitStr,
|
|
139
144
|
option: normalizeOptionItems(bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.option),
|
|
140
145
|
discount_list: preferPriceField ? [] : bundleItem.discount_list
|
|
141
146
|
});
|
|
@@ -163,49 +168,55 @@ function findVariantById(origin, variantId) {
|
|
|
163
168
|
* 注意:这里不生成 identity,缺省时由 OrderModule 自动补齐。
|
|
164
169
|
*/
|
|
165
170
|
export function transformBaseProductToOrderProduct(params) {
|
|
166
|
-
var
|
|
171
|
+
var _ref12, _ref13, _ref14, _payload$product_id, _ref15, _ref16, _payload$product_vari, _payload$_origin, _payload$_origin2, _payload$metadata, _sourceProduct$metada, _callbackOrigin$metad, _origin$metadata, _payload$metadata2, _payload$_extend, _sourceProduct$metada2, _sourceProduct$_exten, _callbackOrigin$metad2, _callbackOrigin$_exte, _payload$_dataVariant, _sourceProduct$_dataV, _callbackOrigin$_data, _origin$_dataVariant, _ref17, _findVariantById, _origin$production_co, _ref18, _ref19, _ref20, _ref21, _ref22, _matchedVariant$price, _payload$product_sku, _payload$_extend$weig, _payload$_extend2, _origin$_extend, _ref23, _ref24, _payload$price, _ref25, _payload$line_total, _payload$_extend3, _ref26, _ref27, _payload$product_sku$, _payload$product_sku2, _payload$bundle, _payload$quantity, _payload$_extend4, _extend, _extend2, _ref28, _ref29, _origin$base_price, _ref30, _ref31, _payload$line_total2, _payload$_extend5, _payload$_extend6, _extend3, _payload$_extend7, _payload$_extend8, _ref32, _ref33, _payload$tax_fee, _ref34, _ref35, _payload$is_charge_ta;
|
|
167
172
|
var payload = params.payload,
|
|
168
173
|
_params$fallbackProdu = params.fallbackProductId,
|
|
169
174
|
fallbackProductId = _params$fallbackProdu === void 0 ? null : _params$fallbackProdu;
|
|
170
175
|
if (!payload || _typeof(payload) !== 'object') return null;
|
|
171
176
|
var sourceProduct = params.sourceProduct || params.sourceItem || {};
|
|
172
|
-
var productId = toProductId((
|
|
177
|
+
var productId = toProductId((_ref12 = (_ref13 = (_ref14 = (_payload$product_id = payload.product_id) !== null && _payload$product_id !== void 0 ? _payload$product_id : payload.id) !== null && _ref14 !== void 0 ? _ref14 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.product_id) !== null && _ref13 !== void 0 ? _ref13 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.id) !== null && _ref12 !== void 0 ? _ref12 : fallbackProductId);
|
|
173
178
|
if (productId === null) return null;
|
|
174
|
-
var productVariantId = toNumber((
|
|
179
|
+
var productVariantId = toNumber((_ref15 = (_ref16 = (_payload$product_vari = payload.product_variant_id) !== null && _payload$product_vari !== void 0 ? _payload$product_vari : payload.variant_id) !== null && _ref16 !== void 0 ? _ref16 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.product_variant_id) !== null && _ref15 !== void 0 ? _ref15 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.variant_id, 0);
|
|
175
180
|
var callbackOrigin = payload.origin || ((_payload$_origin = payload._origin) === null || _payload$_origin === void 0 ? void 0 : _payload$_origin.sourceProduct) || ((_payload$_origin2 = payload._origin) === null || _payload$_origin2 === void 0 ? void 0 : _payload$_origin2.sourceItem) || payload._origin || {};
|
|
176
181
|
var origin = _objectSpread(_objectSpread({}, sourceProduct || {}), callbackOrigin || {});
|
|
177
182
|
var authoritativeDataVariantIds = cloneFirstDataVariantIds((_payload$metadata = payload.metadata) === null || _payload$metadata === void 0 ? void 0 : _payload$metadata.data_variant_ids, sourceProduct === null || sourceProduct === void 0 || (_sourceProduct$metada = sourceProduct.metadata) === null || _sourceProduct$metada === void 0 ? void 0 : _sourceProduct$metada.data_variant_ids, callbackOrigin === null || callbackOrigin === void 0 || (_callbackOrigin$metad = callbackOrigin.metadata) === null || _callbackOrigin$metad === void 0 ? void 0 : _callbackOrigin$metad.data_variant_ids, origin === null || origin === void 0 || (_origin$metadata = origin.metadata) === null || _origin$metadata === void 0 ? void 0 : _origin$metadata.data_variant_ids);
|
|
178
183
|
var selectedSettlementSnapshot = firstNonBlank(payload.selected_settlement_snapshot, (_payload$metadata2 = payload.metadata) === null || _payload$metadata2 === void 0 ? void 0 : _payload$metadata2.selected_settlement_snapshot, (_payload$_extend = payload._extend) === null || _payload$_extend === void 0 || (_payload$_extend = _payload$_extend.metadata) === null || _payload$_extend === void 0 ? void 0 : _payload$_extend.selected_settlement_snapshot, sourceProduct === null || sourceProduct === void 0 || (_sourceProduct$metada2 = sourceProduct.metadata) === null || _sourceProduct$metada2 === void 0 ? void 0 : _sourceProduct$metada2.selected_settlement_snapshot, sourceProduct === null || sourceProduct === void 0 || (_sourceProduct$_exten = sourceProduct._extend) === null || _sourceProduct$_exten === void 0 || (_sourceProduct$_exten = _sourceProduct$_exten.metadata) === null || _sourceProduct$_exten === void 0 ? void 0 : _sourceProduct$_exten.selected_settlement_snapshot, callbackOrigin === null || callbackOrigin === void 0 || (_callbackOrigin$metad2 = callbackOrigin.metadata) === null || _callbackOrigin$metad2 === void 0 ? void 0 : _callbackOrigin$metad2.selected_settlement_snapshot, callbackOrigin === null || callbackOrigin === void 0 || (_callbackOrigin$_exte = callbackOrigin._extend) === null || _callbackOrigin$_exte === void 0 || (_callbackOrigin$_exte = _callbackOrigin$_exte.metadata) === null || _callbackOrigin$_exte === void 0 ? void 0 : _callbackOrigin$_exte.selected_settlement_snapshot);
|
|
179
184
|
var locallyAppliedVariantIds = authoritativeDataVariantIds === undefined ? cloneFirstDataVariantIds((_payload$_dataVariant = payload._dataVariant) === null || _payload$_dataVariant === void 0 ? void 0 : _payload$_dataVariant.appliedVariantIds, sourceProduct === null || sourceProduct === void 0 || (_sourceProduct$_dataV = sourceProduct._dataVariant) === null || _sourceProduct$_dataV === void 0 ? void 0 : _sourceProduct$_dataV.appliedVariantIds, callbackOrigin === null || callbackOrigin === void 0 || (_callbackOrigin$_data = callbackOrigin._dataVariant) === null || _callbackOrigin$_data === void 0 ? void 0 : _callbackOrigin$_data.appliedVariantIds, origin === null || origin === void 0 || (_origin$_dataVariant = origin._dataVariant) === null || _origin$_dataVariant === void 0 ? void 0 : _origin$_dataVariant.appliedVariantIds) : undefined;
|
|
180
185
|
var dataVariantIds = appendDataVariantIds(authoritativeDataVariantIds, locallyAppliedVariantIds, selectedSettlementSnapshot === null || selectedSettlementSnapshot === void 0 ? void 0 : selectedSettlementSnapshot.data_variant_id);
|
|
181
|
-
var matchedVariant = (
|
|
186
|
+
var matchedVariant = (_ref17 = (_findVariantById = findVariantById(callbackOrigin, productVariantId)) !== null && _findVariantById !== void 0 ? _findVariantById : findVariantById(sourceProduct, productVariantId)) !== null && _ref17 !== void 0 ? _ref17 : findVariantById(origin, productVariantId);
|
|
182
187
|
var productionCode = normalizeProductionCode(Object.prototype.hasOwnProperty.call(payload, 'production_code') ? payload.production_code : productVariantId > 0 ? matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.production_code : (_origin$production_co = origin === null || origin === void 0 ? void 0 : origin.production_code) !== null && _origin$production_co !== void 0 ? _origin$production_co : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.production_code);
|
|
183
188
|
var hasPriceOverride = payload.price_override !== undefined && payload.price_override !== null && payload.price_override !== '';
|
|
184
189
|
// 手动改价后 payload.price 是分摊后的主商品售价,不能再作为券前 source。
|
|
185
|
-
//
|
|
186
|
-
|
|
187
|
-
var
|
|
188
|
-
var
|
|
190
|
+
// 称重商品使用改价前净重金额;其它商品从商品/variant 快照读取目录价。
|
|
191
|
+
// 售价仍由 line_total - bundle 推导。
|
|
192
|
+
var catalogSourcePrice = (_ref18 = (_ref19 = (_ref20 = (_ref21 = (_ref22 = (_matchedVariant$price = matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.price) !== null && _matchedVariant$price !== void 0 ? _matchedVariant$price : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.base_price) !== null && _ref22 !== void 0 ? _ref22 : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref21 !== void 0 ? _ref21 : origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _ref20 !== void 0 ? _ref20 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _ref19 !== void 0 ? _ref19 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.selling_price) !== null && _ref18 !== void 0 ? _ref18 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price;
|
|
193
|
+
var weighedSourcePrice = resolveWeighedSourcePrice((_payload$product_sku = payload.product_sku) !== null && _payload$product_sku !== void 0 ? _payload$product_sku : origin.product_sku, (_payload$_extend$weig = (_payload$_extend2 = payload._extend) === null || _payload$_extend2 === void 0 ? void 0 : _payload$_extend2.weighing) !== null && _payload$_extend$weig !== void 0 ? _payload$_extend$weig : (_origin$_extend = origin._extend) === null || _origin$_extend === void 0 ? void 0 : _origin$_extend.weighing);
|
|
194
|
+
var sourceProductPrice = toPriceString(weighedSourcePrice !== null && weighedSourcePrice !== void 0 ? weighedSourcePrice : hasPriceOverride ? (_ref23 = catalogSourcePrice !== null && catalogSourcePrice !== void 0 ? catalogSourcePrice : payload.price) !== null && _ref23 !== void 0 ? _ref23 : payload.selling_price : (_ref24 = (_payload$price = payload.price) !== null && _payload$price !== void 0 ? _payload$price : payload.selling_price) !== null && _ref24 !== void 0 ? _ref24 : catalogSourcePrice, '0.00');
|
|
195
|
+
var explicitLineTotal = (_ref25 = (_payload$line_total = payload.line_total) !== null && _payload$line_total !== void 0 ? _payload$line_total : payload.total) !== null && _ref25 !== void 0 ? _ref25 : (_payload$_extend3 = payload._extend) === null || _payload$_extend3 === void 0 ? void 0 : _payload$_extend3.total;
|
|
189
196
|
var hasExplicitLineTotal = Number.isFinite(Number(explicitLineTotal));
|
|
190
197
|
var lineCompositeTotal = toPriceString(explicitLineTotal, sourceProductPrice);
|
|
191
|
-
var productOptionItem = normalizeProductSkuOptions(normalizeOptionItems((
|
|
192
|
-
var productBundle = normalizeBundleItems((_payload$bundle = payload.bundle) !== null && _payload$bundle !== void 0 ? _payload$bundle : payload.product_bundle, hasPriceOverride);
|
|
198
|
+
var productOptionItem = normalizeProductSkuOptions(normalizeOptionItems((_ref26 = (_ref27 = (_payload$product_sku$ = (_payload$product_sku2 = payload.product_sku) === null || _payload$product_sku2 === void 0 ? void 0 : _payload$product_sku2.option) !== null && _payload$product_sku$ !== void 0 ? _payload$product_sku$ : payload.option) !== null && _ref27 !== void 0 ? _ref27 : payload.options) !== null && _ref26 !== void 0 ? _ref26 : payload.product_option_item, hasPriceOverride || weighedSourcePrice !== undefined));
|
|
199
|
+
var productBundle = normalizeBundleItems((_payload$bundle = payload.bundle) !== null && _payload$bundle !== void 0 ? _payload$bundle : payload.product_bundle, hasPriceOverride, hasPriceOverride && weighedSourcePrice !== undefined);
|
|
193
200
|
// `payload.unique` 是业务侧商品/票务标识,可能在连续加同一商品时重复;
|
|
194
201
|
// 行级唯一值只接受显式协议字段,缺省交给 OrderModule 生成。
|
|
195
202
|
var uniqueIdentificationNumber = payload.unique_identification_number;
|
|
196
203
|
var resolvedQuantity = toSafePositiveInt((_payload$quantity = payload.quantity) !== null && _payload$quantity !== void 0 ? _payload$quantity : payload.num, 1);
|
|
197
|
-
var originTotal =
|
|
204
|
+
var originTotal = weighedSourcePrice !== undefined ? Number(composeLinePrice({
|
|
205
|
+
mainPrice: Number(weighedSourcePrice) + sumOptionUnitPrice(productOptionItem).toNumber(),
|
|
206
|
+
bundle: hasPriceOverride ? withOriginalBundleOptionPrices(productBundle) : productBundle,
|
|
207
|
+
useOriginalBundle: true
|
|
208
|
+
})) : resolveManualDiscountOriginTotal({
|
|
198
209
|
originTotal: payload.origin_total,
|
|
199
|
-
extendOriginTotal: (_payload$
|
|
210
|
+
extendOriginTotal: (_payload$_extend4 = payload._extend) === null || _payload$_extend4 === void 0 ? void 0 : _payload$_extend4.origin_total,
|
|
200
211
|
originExtendOriginTotal: origin === null || origin === void 0 || (_extend = origin._extend) === null || _extend === void 0 ? void 0 : _extend.origin_total,
|
|
201
212
|
sourceExtendOriginTotal: sourceProduct === null || sourceProduct === void 0 || (_extend2 = sourceProduct._extend) === null || _extend2 === void 0 ? void 0 : _extend2.origin_total,
|
|
202
|
-
catalogUnitPrice: (
|
|
213
|
+
catalogUnitPrice: (_ref28 = (_ref29 = (_origin$base_price = origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _origin$base_price !== void 0 ? _origin$base_price : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref29 !== void 0 ? _ref29 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price) !== null && _ref28 !== void 0 ? _ref28 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price,
|
|
203
214
|
quantity: resolvedQuantity
|
|
204
215
|
});
|
|
205
|
-
var sellingTotal = Number((
|
|
216
|
+
var sellingTotal = Number((_ref30 = (_ref31 = (_payload$line_total2 = payload.line_total) !== null && _payload$line_total2 !== void 0 ? _payload$line_total2 : payload.total) !== null && _ref31 !== void 0 ? _ref31 : (_payload$_extend5 = payload._extend) === null || _payload$_extend5 === void 0 ? void 0 : _payload$_extend5.total) !== null && _ref30 !== void 0 ? _ref30 : lineCompositeTotal);
|
|
206
217
|
var discountReason = resolveManualDiscountReasonFromSources({
|
|
207
218
|
discountReason: payload.discount_reason,
|
|
208
|
-
extendDiscountReason: (_payload$
|
|
219
|
+
extendDiscountReason: (_payload$_extend6 = payload._extend) === null || _payload$_extend6 === void 0 ? void 0 : _payload$_extend6.discount_reason,
|
|
209
220
|
originExtendDiscountReason: origin === null || origin === void 0 || (_extend3 = origin._extend) === null || _extend3 === void 0 ? void 0 : _extend3.discount_reason
|
|
210
221
|
});
|
|
211
222
|
var lineOriginalPrice = hasPriceOverride && Number.isFinite(originTotal) ? toPriceString(originTotal) : lineCompositeTotal;
|
|
@@ -218,8 +229,8 @@ export function transformBaseProductToOrderProduct(params) {
|
|
|
218
229
|
sellingTotal: Number.isFinite(sellingTotal) ? sellingTotal : Number(lineCompositeTotal),
|
|
219
230
|
quantity: resolvedQuantity,
|
|
220
231
|
message: discountReason,
|
|
221
|
-
discountway: (_payload$
|
|
222
|
-
discount_per: (_payload$
|
|
232
|
+
discountway: (_payload$_extend7 = payload._extend) === null || _payload$_extend7 === void 0 ? void 0 : _payload$_extend7.discountway,
|
|
233
|
+
discount_per: (_payload$_extend8 = payload._extend) === null || _payload$_extend8 === void 0 ? void 0 : _payload$_extend8.discount_per
|
|
223
234
|
})) : payload.discount_list || [];
|
|
224
235
|
|
|
225
236
|
// v2:source 不含 option;main_product_* 含 option(与 normalizeOrderProduct 一致)
|
|
@@ -281,13 +292,17 @@ export function transformBaseProductToOrderProduct(params) {
|
|
|
281
292
|
// 折后行价由 normalizeOrderProduct 按 main + bundle 合成;手动改价时 bundle 已为分摊后单价
|
|
282
293
|
selling_price: lineCompositeTotal,
|
|
283
294
|
original_price: lineOriginalPrice,
|
|
284
|
-
tax_fee: toPriceString((
|
|
285
|
-
is_charge_tax: toNumber((
|
|
295
|
+
tax_fee: toPriceString((_ref32 = (_ref33 = (_payload$tax_fee = payload.tax_fee) !== null && _payload$tax_fee !== void 0 ? _payload$tax_fee : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.tax_fee) !== null && _ref33 !== void 0 ? _ref33 : origin === null || origin === void 0 ? void 0 : origin.tax_fee) !== null && _ref32 !== void 0 ? _ref32 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.tax_fee, '0.00'),
|
|
296
|
+
is_charge_tax: toNumber((_ref34 = (_ref35 = (_payload$is_charge_ta = payload.is_charge_tax) !== null && _payload$is_charge_ta !== void 0 ? _payload$is_charge_ta : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.is_charge_tax) !== null && _ref35 !== void 0 ? _ref35 : origin === null || origin === void 0 ? void 0 : origin.is_charge_tax) !== null && _ref34 !== void 0 ? _ref34 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.is_charge_tax, 0),
|
|
286
297
|
metadata: metadata,
|
|
287
298
|
note: payload.note != null ? String(payload.note) : '',
|
|
288
299
|
product_title: productTitle,
|
|
289
300
|
product_cover: firstNonBlank(matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.cover, sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.cover),
|
|
290
|
-
_origin: _objectSpread(_objectSpread({}, sourceProduct || {}),
|
|
301
|
+
_origin: _objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), weighedSourcePrice !== undefined && hasPriceOverride ? {
|
|
302
|
+
_extend: _objectSpread(_objectSpread({}, sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct._extend), {}, {
|
|
303
|
+
origin_total: originTotal
|
|
304
|
+
})
|
|
305
|
+
} : {}), {}, {
|
|
291
306
|
callbackData: payload
|
|
292
307
|
})
|
|
293
308
|
});
|
|
@@ -4,9 +4,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
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; }
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import { withOriginalBundleOptionPrices } from "../../modules/Order/utils/weighedProduct";
|
|
7
8
|
import Decimal from 'decimal.js';
|
|
8
9
|
import { composeLinePrice, createUuidV4, ensureProductSku, normalizeProductSkuOptions, resolveManualOverrideLineOriginalPrice, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
9
|
-
import { ensureManualProductDiscountList } from "../../modules/Order/utils/manualProductDiscount";
|
|
10
|
+
import { ensureManualProductDiscountList, hasManualProductDiscountFlag } from "../../modules/Order/utils/manualProductDiscount";
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* 构建金额全为 0 的空 summary。
|
|
@@ -241,7 +242,7 @@ export function normalizeOrderProduct(product) {
|
|
|
241
242
|
});
|
|
242
243
|
var composedOriginalPrice = composeLinePrice({
|
|
243
244
|
mainPrice: mainOriginalStr,
|
|
244
|
-
bundle: normalizedBundle,
|
|
245
|
+
bundle: Number(productSku.open_sold_weight) === 1 && hasManualProductDiscountFlag(metadata) ? withOriginalBundleOptionPrices(normalizedBundle) : normalizedBundle,
|
|
245
246
|
useOriginalBundle: true
|
|
246
247
|
});
|
|
247
248
|
var finalOriginalPrice = resolveManualOverrideLineOriginalPrice({
|
|
@@ -8,6 +8,7 @@ import { BaseSalesImpl } from '../BaseSales';
|
|
|
8
8
|
import type { BaseSalesScanCodeResult } from '../BaseSales/types';
|
|
9
9
|
import type { ISalesDetail } from '../BaseSales/utils/parseSalesResponse';
|
|
10
10
|
import type { LoadSalesDetailParams } from '../../modules/Order/types';
|
|
11
|
+
import type { GlobalScanSearchType } from './utils/scan/formatGlobalScan';
|
|
11
12
|
import type { AddAddTimeProductToBookingInput, AddAddTimeProductsToBookingInput, GlobalScanHandleResult, GlobalScanHostBridge } from './types';
|
|
12
13
|
import { AddProductDecideContext, AddProductRequiresDetailPayload } from './utils/addProductDecision';
|
|
13
14
|
import { type BuildCacheItemFromOrderLineInput } from '../../modules/BookingContext/utils/buildCacheItemFromOrderLine';
|
|
@@ -29,7 +30,9 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
29
30
|
private addTimeProductsCatalog;
|
|
30
31
|
private orderCustomerDiscountRefreshInFlight;
|
|
31
32
|
private orderCustomerDiscountRefreshCustomerId;
|
|
33
|
+
private orderCustomerDiscountRefreshTarget;
|
|
32
34
|
private orderCustomerPromotionRefreshInFlight;
|
|
35
|
+
private readonly customerResolveRequests;
|
|
33
36
|
protected loadOpenDataInFlight: Promise<OpenDataConfig> | null;
|
|
34
37
|
protected loadOpenDataInFlightTarget: string | null;
|
|
35
38
|
protected openDataTarget: string | null;
|
|
@@ -45,6 +48,12 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
45
48
|
*/
|
|
46
49
|
protected createSubModule(moduleName: string): Module | null;
|
|
47
50
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
51
|
+
private getInjectedOpenDataConfig;
|
|
52
|
+
/**
|
|
53
|
+
* 在解决方案对外 ready 前准备 Invoice Document;失败只降级模板,不阻断销售。
|
|
54
|
+
* 已由页面取得的 OpenData 直接交给模块接管,没有注入数据时再走 target-scoped 加载。
|
|
55
|
+
*/
|
|
56
|
+
private prepareInvoiceTemplateAtSolutionReady;
|
|
48
57
|
protected getBookingTicketBusinessCode(): string | null;
|
|
49
58
|
private getIdGeneratorPlugin;
|
|
50
59
|
private loadOpenDataConfig;
|
|
@@ -72,10 +81,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
72
81
|
resolveCustomerById(customerId: string | number): Promise<ICustomer | null>;
|
|
73
82
|
/** 兼容既有优惠码扫码逻辑。 */
|
|
74
83
|
private resolveCustomerByDiscountCustomerId;
|
|
75
|
-
private findCustomerById;
|
|
76
84
|
private normalizeCustomer;
|
|
77
85
|
private getRawCustomerId;
|
|
78
|
-
private hasUsableCustomerDetails;
|
|
79
86
|
/**
|
|
80
87
|
* 更新当前预约的 appointment_status。
|
|
81
88
|
*
|
|
@@ -531,6 +538,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
531
538
|
* ```
|
|
532
539
|
*/
|
|
533
540
|
handleGlobalScanCode(code: string, bridge?: GlobalScanHostBridge): Promise<GlobalScanHandleResult>;
|
|
541
|
+
/** 查询码类型;复用原有识别和缓存,不写订单、不打开选择 UI。 */
|
|
542
|
+
getGlobalScanCodeType(code: string): Promise<GlobalScanSearchType | null>;
|
|
534
543
|
resolveBestAddTimePlan(addTimeProducts: any[], targetMinutes: number): any;
|
|
535
544
|
/**
|
|
536
545
|
* 构造一条绑定到已有 booking 的加时商品行。
|