@pisell/pisellos 2.3.127 → 2.3.128
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 +0 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +2 -4
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +19 -58
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +12 -24
- package/dist/modules/Customer/index.js +3 -6
- package/dist/modules/Customer/types.d.ts +0 -2
- package/dist/modules/Discount/index.d.ts +2 -2
- package/dist/modules/Discount/index.js +151 -37
- package/dist/modules/Discount/types.d.ts +5 -36
- package/dist/modules/Order/index.d.ts +2 -7
- package/dist/modules/Order/index.js +331 -480
- package/dist/modules/Order/utils/orderCollectionIdentity.js +12 -16
- 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 +1 -1
- package/dist/modules/Order/utils.js +65 -104
- package/dist/modules/Payment/types.d.ts +1 -21
- package/dist/modules/Payment/types.js +0 -2
- package/dist/modules/Payment/walletpass.d.ts +1 -1
- package/dist/modules/Payment/walletpass.js +47 -80
- package/dist/modules/Rules/index.d.ts +2 -2
- package/dist/modules/Rules/index.js +190 -482
- package/dist/modules/Rules/types.d.ts +2 -4
- package/dist/server/modules/order/types.d.ts +0 -2
- package/dist/server/utils/small-ticket.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +2 -3
- package/dist/solution/BaseSales/index.js +77 -44
- package/dist/solution/BaseSales/types.d.ts +7 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +126 -141
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +40 -25
- package/dist/solution/BaseSales/utils.js +3 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +3 -2
- package/dist/solution/BookingTicket/index.js +63 -60
- package/dist/solution/BookingTicket/types.d.ts +1 -5
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -2
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +147 -338
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +4 -8
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -6
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +6 -19
- package/dist/solution/ScanOrder/utils.js +3 -2
- package/dist/solution/ShopDiscount/index.d.ts +0 -2
- package/dist/solution/ShopDiscount/index.js +42 -99
- package/dist/solution/ShopDiscount/utils.d.ts +2 -4
- package/dist/solution/ShopDiscount/utils.js +23 -43
- package/dist/solution/UnifiedBookingSales/index.js +2 -2
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
- package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +6 -35
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -13
- package/lib/modules/Customer/index.js +1 -5
- package/lib/modules/Customer/types.d.ts +0 -2
- package/lib/modules/Discount/index.d.ts +2 -2
- package/lib/modules/Discount/index.js +129 -23
- package/lib/modules/Discount/types.d.ts +5 -36
- package/lib/modules/Order/index.d.ts +2 -7
- package/lib/modules/Order/index.js +109 -222
- package/lib/modules/Order/utils/orderCollectionIdentity.js +11 -14
- 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 +1 -1
- package/lib/modules/Order/utils.js +6 -41
- package/lib/modules/Payment/types.d.ts +1 -21
- package/lib/modules/Payment/types.js +0 -1
- package/lib/modules/Payment/walletpass.d.ts +1 -1
- package/lib/modules/Payment/walletpass.js +9 -29
- package/lib/modules/Rules/index.d.ts +2 -2
- package/lib/modules/Rules/index.js +114 -359
- package/lib/modules/Rules/types.d.ts +2 -4
- package/lib/server/modules/order/types.d.ts +0 -2
- package/lib/server/utils/small-ticket.js +1 -1
- package/lib/solution/BaseSales/index.d.ts +2 -3
- package/lib/solution/BaseSales/index.js +17 -11
- package/lib/solution/BaseSales/types.d.ts +7 -3
- package/lib/solution/BaseSales/utils/cartPromotion.js +4 -12
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -9
- package/lib/solution/BaseSales/utils.js +2 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +3 -2
- package/lib/solution/BookingTicket/index.js +33 -36
- package/lib/solution/BookingTicket/types.d.ts +1 -5
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -2
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +42 -174
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +4 -8
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -6
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +3 -11
- package/lib/solution/ScanOrder/utils.js +2 -1
- package/lib/solution/ShopDiscount/index.d.ts +0 -2
- package/lib/solution/ShopDiscount/index.js +9 -55
- package/lib/solution/ShopDiscount/utils.d.ts +2 -4
- package/lib/solution/ShopDiscount/utils.js +25 -42
- package/lib/solution/UnifiedBookingSales/index.js +2 -2
- package/package.json +1 -1
- package/dist/modules/Discount/availability.d.ts +0 -7
- package/dist/modules/Discount/availability.js +0 -49
- package/dist/modules/Discount/entitlementPass.d.ts +0 -34
- package/dist/modules/Discount/entitlementPass.js +0 -147
- package/lib/modules/Discount/availability.d.ts +0 -7
- package/lib/modules/Discount/availability.js +0 -43
- package/lib/modules/Discount/entitlementPass.d.ts +0 -34
- package/lib/modules/Discount/entitlementPass.js +0 -141
|
@@ -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({
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
date: string;
|
|
327
327
|
status: string;
|
|
328
328
|
week: string;
|
|
329
|
-
weekNum: 0 |
|
|
329
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -32,7 +32,6 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
32
32
|
private orderCustomerDiscountRefreshCustomerId;
|
|
33
33
|
private orderCustomerDiscountRefreshTarget;
|
|
34
34
|
private orderCustomerPromotionRefreshInFlight;
|
|
35
|
-
private readonly customerResolveRequests;
|
|
36
35
|
protected loadOpenDataInFlight: Promise<OpenDataConfig> | null;
|
|
37
36
|
protected loadOpenDataInFlightTarget: string | null;
|
|
38
37
|
protected openDataTarget: string | null;
|
|
@@ -81,8 +80,10 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
81
80
|
resolveCustomerById(customerId: string | number): Promise<ICustomer | null>;
|
|
82
81
|
/** 兼容既有优惠码扫码逻辑。 */
|
|
83
82
|
private resolveCustomerByDiscountCustomerId;
|
|
83
|
+
private findCustomerById;
|
|
84
84
|
private normalizeCustomer;
|
|
85
85
|
private getRawCustomerId;
|
|
86
|
+
private hasUsableCustomerDetails;
|
|
86
87
|
/**
|
|
87
88
|
* 更新当前预约的 appointment_status。
|
|
88
89
|
*
|
|
@@ -346,7 +347,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
346
347
|
* 获取当前的客户搜索条件
|
|
347
348
|
* @returns 当前搜索条件
|
|
348
349
|
*/
|
|
349
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
350
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
350
351
|
/**
|
|
351
352
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
352
353
|
* @returns 客户状态
|
|
@@ -182,7 +182,6 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
182
182
|
_defineProperty(_assertThisInitialized(_this), "orderCustomerDiscountRefreshCustomerId", null);
|
|
183
183
|
_defineProperty(_assertThisInitialized(_this), "orderCustomerDiscountRefreshTarget", null);
|
|
184
184
|
_defineProperty(_assertThisInitialized(_this), "orderCustomerPromotionRefreshInFlight", null);
|
|
185
|
-
_defineProperty(_assertThisInitialized(_this), "customerResolveRequests", new Map());
|
|
186
185
|
_defineProperty(_assertThisInitialized(_this), "loadOpenDataInFlight", null);
|
|
187
186
|
_defineProperty(_assertThisInitialized(_this), "loadOpenDataInFlightTarget", null);
|
|
188
187
|
_defineProperty(_assertThisInitialized(_this), "openDataTarget", null);
|
|
@@ -757,43 +756,31 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
757
756
|
hasOrderCustomer = Boolean(this.store.order.getOrderCustomer());
|
|
758
757
|
isUserPlatform = USER_PLATFORM.includes(this.otherParams.platform); // 缺 Holder 等场景 isAvailable=false,但仍需把 Pass 归属客户带入订单,供 Holder 弹窗使用。
|
|
759
758
|
if (!(!hasOrderCustomer && extractedCustomerId && !isUserPlatform)) {
|
|
760
|
-
_context10.next =
|
|
759
|
+
_context10.next = 12;
|
|
761
760
|
break;
|
|
762
761
|
}
|
|
763
|
-
_context10.
|
|
764
|
-
_context10.next = 13;
|
|
762
|
+
_context10.next = 12;
|
|
765
763
|
return this.hydrateOrderCustomerFromScanDiscounts(scannedList);
|
|
766
|
-
case
|
|
767
|
-
_context10.next = 18;
|
|
768
|
-
break;
|
|
769
|
-
case 15:
|
|
770
|
-
_context10.prev = 15;
|
|
771
|
-
_context10.t0 = _context10["catch"](10);
|
|
772
|
-
// 客户映射失败不能阻断原有 Pass 的可用性、展示或优惠处理。
|
|
773
|
-
console.warn('[BookingTicket] scan discount customer resolve failed', {
|
|
774
|
-
customerId: extractedCustomerId,
|
|
775
|
-
error: _context10.t0
|
|
776
|
-
});
|
|
777
|
-
case 18:
|
|
764
|
+
case 12:
|
|
778
765
|
if (!raw.isAvailable) {
|
|
779
|
-
_context10.next =
|
|
766
|
+
_context10.next = 19;
|
|
780
767
|
break;
|
|
781
768
|
}
|
|
782
|
-
_context10.next =
|
|
769
|
+
_context10.next = 15;
|
|
783
770
|
return this.store.order.recalculateSummary({
|
|
784
771
|
createIfMissing: true
|
|
785
772
|
});
|
|
786
|
-
case
|
|
773
|
+
case 15:
|
|
787
774
|
this.store.order.persistTempOrder();
|
|
788
775
|
tempOrder = this.store.order.ensureTempOrder();
|
|
789
|
-
_context10.next =
|
|
776
|
+
_context10.next = 19;
|
|
790
777
|
return this.effectsEmit('onDiscountApplied', {
|
|
791
778
|
productList: tempOrder.products || [],
|
|
792
779
|
discountList: this.store.order.getDiscountList(),
|
|
793
780
|
selectedDiscountList: tempOrder.discount_list || [],
|
|
794
781
|
tempOrder: tempOrder
|
|
795
782
|
});
|
|
796
|
-
case
|
|
783
|
+
case 19:
|
|
797
784
|
return _context10.abrupt("return", _objectSpread(_objectSpread({
|
|
798
785
|
isAvailable: raw.isAvailable
|
|
799
786
|
}, raw.isAccepted !== undefined ? {
|
|
@@ -803,11 +790,11 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
803
790
|
unavailableReason: raw.unavailableReason,
|
|
804
791
|
scannedDiscountList: raw.scannedDiscountList
|
|
805
792
|
}));
|
|
806
|
-
case
|
|
793
|
+
case 20:
|
|
807
794
|
case "end":
|
|
808
795
|
return _context10.stop();
|
|
809
796
|
}
|
|
810
|
-
}, _callee10, this
|
|
797
|
+
}, _callee10, this);
|
|
811
798
|
}));
|
|
812
799
|
function scanPromotionCode(_x4, _x5) {
|
|
813
800
|
return _scanPromotionCode.apply(this, arguments);
|
|
@@ -889,51 +876,54 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
889
876
|
key: "resolveCustomerById",
|
|
890
877
|
value: function () {
|
|
891
878
|
var _resolveCustomerById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(customerId) {
|
|
892
|
-
var
|
|
893
|
-
var
|
|
879
|
+
var _result$list;
|
|
880
|
+
var localCustomers, localCustomer, normalizedLocalCustomer, result, remoteCustomer, detailCustomer;
|
|
894
881
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
895
882
|
while (1) switch (_context12.prev = _context12.next) {
|
|
896
883
|
case 0:
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
884
|
+
localCustomers = this.store.customer.getCustomers();
|
|
885
|
+
localCustomer = this.findCustomerById(localCustomers, customerId);
|
|
886
|
+
normalizedLocalCustomer = localCustomer ? this.normalizeCustomer(localCustomer) : null;
|
|
887
|
+
if (!(normalizedLocalCustomer && this.hasUsableCustomerDetails(normalizedLocalCustomer))) {
|
|
888
|
+
_context12.next = 5;
|
|
901
889
|
break;
|
|
902
890
|
}
|
|
903
|
-
return _context12.abrupt("return",
|
|
904
|
-
case
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
891
|
+
return _context12.abrupt("return", normalizedLocalCustomer);
|
|
892
|
+
case 5:
|
|
893
|
+
_context12.next = 7;
|
|
894
|
+
return this.store.customer.queryCustomerList({
|
|
895
|
+
ids: [customerId],
|
|
896
|
+
skip: 1,
|
|
897
|
+
num: 1
|
|
898
|
+
});
|
|
899
|
+
case 7:
|
|
900
|
+
result = _context12.sent;
|
|
901
|
+
remoteCustomer = this.findCustomerById((result === null || result === void 0 ? void 0 : result.list) || [], customerId) || (result === null || result === void 0 || (_result$list = result.list) === null || _result$list === void 0 ? void 0 : _result$list[0]) || null;
|
|
902
|
+
if (!remoteCustomer) {
|
|
903
|
+
_context12.next = 11;
|
|
909
904
|
break;
|
|
910
905
|
}
|
|
911
|
-
return _context12.abrupt("return",
|
|
912
|
-
case 8:
|
|
913
|
-
request = this.request.post("/customer/resolve/".concat(encodeURIComponent(normalizedCustomerId)), {
|
|
914
|
-
with_franchisor_data: 1,
|
|
915
|
-
with: ['latestWalletDetail.wallet', 'contactsInfo', 'formRecord']
|
|
916
|
-
}).then(function (result) {
|
|
917
|
-
var customer = result === null || result === void 0 ? void 0 : result.data;
|
|
918
|
-
var resolvedCustomerId = Number(customer && _typeof(customer) === 'object' && !Array.isArray(customer) ? _this2.getRawCustomerId(customer) : NaN);
|
|
919
|
-
if ((result === null || result === void 0 ? void 0 : result.status) !== true || (result === null || result === void 0 ? void 0 : result.code) !== 200 || !customer || _typeof(customer) !== 'object' || Array.isArray(customer) || !Number.isInteger(resolvedCustomerId) || resolvedCustomerId <= 1) {
|
|
920
|
-
var error = new Error((result === null || result === void 0 ? void 0 : result.message) || 'Customer resolve failed');
|
|
921
|
-
error.code = result === null || result === void 0 ? void 0 : result.code;
|
|
922
|
-
throw error;
|
|
923
|
-
}
|
|
924
|
-
return _this2.normalizeCustomer(customer);
|
|
925
|
-
}).finally(function () {
|
|
926
|
-
if (_this2.customerResolveRequests.get(normalizedCustomerId) === request) {
|
|
927
|
-
_this2.customerResolveRequests.delete(normalizedCustomerId);
|
|
928
|
-
}
|
|
929
|
-
});
|
|
930
|
-
this.customerResolveRequests.set(normalizedCustomerId, request);
|
|
931
|
-
return _context12.abrupt("return", request);
|
|
906
|
+
return _context12.abrupt("return", this.normalizeCustomer(remoteCustomer));
|
|
932
907
|
case 11:
|
|
908
|
+
_context12.prev = 11;
|
|
909
|
+
_context12.next = 14;
|
|
910
|
+
return this.store.customer.queryCustomerDetail(customerId);
|
|
911
|
+
case 14:
|
|
912
|
+
detailCustomer = _context12.sent;
|
|
913
|
+
return _context12.abrupt("return", detailCustomer ? this.normalizeCustomer(detailCustomer) : null);
|
|
914
|
+
case 18:
|
|
915
|
+
_context12.prev = 18;
|
|
916
|
+
_context12.t0 = _context12["catch"](11);
|
|
917
|
+
console.warn('[BookingTicket] resolveCustomerById detail request failed', {
|
|
918
|
+
customerId: customerId,
|
|
919
|
+
error: _context12.t0
|
|
920
|
+
});
|
|
921
|
+
return _context12.abrupt("return", null);
|
|
922
|
+
case 22:
|
|
933
923
|
case "end":
|
|
934
924
|
return _context12.stop();
|
|
935
925
|
}
|
|
936
|
-
}, _callee12, this);
|
|
926
|
+
}, _callee12, this, [[11, 18]]);
|
|
937
927
|
}));
|
|
938
928
|
function resolveCustomerById(_x7) {
|
|
939
929
|
return _resolveCustomerById.apply(this, arguments);
|
|
@@ -945,6 +935,17 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
945
935
|
value: function resolveCustomerByDiscountCustomerId(customerId) {
|
|
946
936
|
return this.resolveCustomerById(customerId);
|
|
947
937
|
}
|
|
938
|
+
}, {
|
|
939
|
+
key: "findCustomerById",
|
|
940
|
+
value: function findCustomerById() {
|
|
941
|
+
var _this2 = this;
|
|
942
|
+
var customers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
943
|
+
var customerId = arguments.length > 1 ? arguments[1] : undefined;
|
|
944
|
+
return customers.find(function (customer) {
|
|
945
|
+
var rawId = _this2.getRawCustomerId(customer);
|
|
946
|
+
return rawId !== null && String(rawId) === String(customerId);
|
|
947
|
+
}) || null;
|
|
948
|
+
}
|
|
948
949
|
}, {
|
|
949
950
|
key: "normalizeCustomer",
|
|
950
951
|
value: function normalizeCustomer(customer) {
|
|
@@ -967,6 +968,11 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
967
968
|
var raw = customer;
|
|
968
969
|
return (_ref9 = (_ref10 = (_customer$id = customer.id) !== null && _customer$id !== void 0 ? _customer$id : raw.customer_id) !== null && _ref10 !== void 0 ? _ref10 : raw.customerId) !== null && _ref9 !== void 0 ? _ref9 : null;
|
|
969
970
|
}
|
|
971
|
+
}, {
|
|
972
|
+
key: "hasUsableCustomerDetails",
|
|
973
|
+
value: function hasUsableCustomerDetails(customer) {
|
|
974
|
+
return !!(customer.name || customer.phone || customer.email || customer.display_name || customer.customer_name);
|
|
975
|
+
}
|
|
970
976
|
|
|
971
977
|
/**
|
|
972
978
|
* 更新当前预约的 appointment_status。
|
|
@@ -2710,9 +2716,6 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2710
2716
|
getOrderCustomerSnapshot: function getOrderCustomerSnapshot() {
|
|
2711
2717
|
return _this7.getOrderCustomerSnapshot();
|
|
2712
2718
|
},
|
|
2713
|
-
resolveCustomerById: function resolveCustomerById(customerId) {
|
|
2714
|
-
return _this7.resolveCustomerById(customerId);
|
|
2715
|
-
},
|
|
2716
2719
|
getBusinessCode: function getBusinessCode() {
|
|
2717
2720
|
var _this7$otherParams;
|
|
2718
2721
|
return (_this7$otherParams = _this7.otherParams) === null || _this7$otherParams === void 0 ? void 0 : _this7$otherParams.businessCode;
|
|
@@ -230,16 +230,12 @@ export interface GlobalScanHostBridge {
|
|
|
230
230
|
/**
|
|
231
231
|
* walk-in 扫 walletPass:直接核销优惠码(对齐 SaleDetail Voucher.handleApplyCode / cart.scanCode)。
|
|
232
232
|
*/
|
|
233
|
-
applyPromotionCode?: (code: string, customerId?: number
|
|
234
|
-
suppressFailureNotification?: boolean;
|
|
235
|
-
}) => Promise<{
|
|
233
|
+
applyPromotionCode?: (code: string, customerId?: number) => Promise<{
|
|
236
234
|
isAvailable?: boolean;
|
|
237
235
|
isAccepted?: boolean;
|
|
238
236
|
type?: string;
|
|
239
237
|
unavailableReason?: string;
|
|
240
238
|
}>;
|
|
241
|
-
/** 当前订单已有其他客户时,由宿主复用客户组件完成确认及切换。 */
|
|
242
|
-
requestCustomerSwitch?: (customer: ICustomer) => Promise<boolean | null>;
|
|
243
239
|
onNotify?: (type: 'success' | 'fail' | 'info', messageKey?: string) => void;
|
|
244
240
|
refresh?: () => void;
|
|
245
241
|
}
|
|
@@ -5,7 +5,6 @@ import { GlobalScanFormattedResult } from './formatGlobalScan';
|
|
|
5
5
|
export interface GlobalScanApplyHost {
|
|
6
6
|
setOrderCustomer(customer: ICustomer | null): void;
|
|
7
7
|
getOrderCustomerSnapshot(): ICustomer | null;
|
|
8
|
-
resolveCustomerById?(customerId: string | number): Promise<ICustomer | null>;
|
|
9
8
|
getBusinessCode(): string | undefined;
|
|
10
9
|
buildAddProductCtx(extra?: Record<string, any>): Record<string, any>;
|
|
11
10
|
decideAddProduct(item: any, options?: Record<string, any>): AddProductDecision;
|
|
@@ -27,7 +26,6 @@ export interface GlobalScanApplyHost {
|
|
|
27
26
|
addProductToOrder(product: any, booking?: any): Promise<any>;
|
|
28
27
|
refreshWalletAssets?(params?: {
|
|
29
28
|
preserveSelection?: boolean;
|
|
30
|
-
retainSearchResultCodes?: string[];
|
|
31
29
|
}): Promise<any>;
|
|
32
30
|
scanWalletAsset?(code: string): Promise<{
|
|
33
31
|
type: 'walletCode' | 'normalCode';
|