@pisell/pisellos 2.2.187 → 2.2.189
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/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +11 -4
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +11 -4
- package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/dist/modules/BookingContext/utils/orderLineDisplay.js +36 -0
- package/dist/modules/Order/index.d.ts +5 -0
- package/dist/modules/Order/index.js +174 -70
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/modules/Order/utils.js +3 -1
- package/dist/modules/Rules/index.js +32 -21
- package/dist/solution/BaseSales/utils/cartPromotion.js +31 -11
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +15 -0
- package/dist/solution/BookingTicket/index.js +135 -10
- package/dist/solution/BookingTicket/types.d.ts +48 -0
- package/dist/solution/BookingTicket/types.js +5 -1
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +394 -0
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +56 -0
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +150 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +4 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +56 -0
- package/lib/modules/Order/index.d.ts +5 -0
- package/lib/modules/Order/index.js +99 -14
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/modules/Order/utils.js +1 -0
- package/lib/modules/Rules/index.js +88 -78
- package/lib/solution/BaseSales/utils/cartPromotion.js +22 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +15 -0
- package/lib/solution/BookingTicket/index.js +75 -2
- package/lib/solution/BookingTicket/types.d.ts +48 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +166 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +51 -0
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +127 -0
- package/package.json +1 -1
|
@@ -314,7 +314,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
314
314
|
}, {
|
|
315
315
|
key: "calcDiscount",
|
|
316
316
|
value: function calcDiscount(_ref2, options) {
|
|
317
|
-
var
|
|
317
|
+
var _options$selectedList,
|
|
318
|
+
_this3 = this;
|
|
318
319
|
var discountList = _ref2.discountList,
|
|
319
320
|
productList = _ref2.productList,
|
|
320
321
|
holders = _ref2.holders,
|
|
@@ -360,6 +361,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
360
361
|
var filteredDiscountList = addModeDiscount.filter(function (discount) {
|
|
361
362
|
return !discount.isManualSelect;
|
|
362
363
|
});
|
|
364
|
+
var hasDiscountInput = editModeDiscount.length > 0 || addModeDiscount.length > 0 || Boolean(options === null || options === void 0 ? void 0 : options.discountId) || Boolean(options === null || options === void 0 || (_options$selectedList = options.selectedList) === null || _options$selectedList === void 0 ? void 0 : _options$selectedList.length) || Boolean(options === null || options === void 0 ? void 0 : options.scan);
|
|
365
|
+
if (!hasDiscountInput) {
|
|
366
|
+
return {
|
|
367
|
+
discountList: discountList,
|
|
368
|
+
productList: productList
|
|
369
|
+
};
|
|
370
|
+
}
|
|
363
371
|
|
|
364
372
|
// 🔥 扁平化商品列表:将 bundle 子商品展开为虚拟商品
|
|
365
373
|
var flattenProductsWithBundle = function flattenProductsWithBundle(productList) {
|
|
@@ -1177,8 +1185,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1177
1185
|
var _product$discount_lis9;
|
|
1178
1186
|
// 主商品:检查自己的 discount_list
|
|
1179
1187
|
if (flatItem.type === 'main' && (_product$discount_lis9 = product.discount_list) !== null && _product$discount_lis9 !== void 0 && _product$discount_lis9.some(function (item) {
|
|
1180
|
-
var _options$
|
|
1181
|
-
return options === null || options === void 0 || (_options$
|
|
1188
|
+
var _options$selectedList2;
|
|
1189
|
+
return options === null || options === void 0 || (_options$selectedList2 = options.selectedList) === null || _options$selectedList2 === void 0 ? void 0 : _options$selectedList2.some(function (n) {
|
|
1182
1190
|
var _item$discount4;
|
|
1183
1191
|
return n.discountId === ((_item$discount4 = item.discount) === null || _item$discount4 === void 0 ? void 0 : _item$discount4.resource_id);
|
|
1184
1192
|
});
|
|
@@ -1189,14 +1197,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1189
1197
|
if (flatItem.type === 'bundle') {
|
|
1190
1198
|
var _product$discount_lis10, _flatItem$parentProdu8;
|
|
1191
1199
|
if ((_product$discount_lis10 = product.discount_list) !== null && _product$discount_lis10 !== void 0 && _product$discount_lis10.some(function (item) {
|
|
1192
|
-
var _options$
|
|
1193
|
-
return options === null || options === void 0 || (_options$
|
|
1200
|
+
var _options$selectedList3;
|
|
1201
|
+
return options === null || options === void 0 || (_options$selectedList3 = options.selectedList) === null || _options$selectedList3 === void 0 ? void 0 : _options$selectedList3.some(function (n) {
|
|
1194
1202
|
var _item$discount5;
|
|
1195
1203
|
return n.discountId === ((_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.resource_id);
|
|
1196
1204
|
});
|
|
1197
1205
|
}) || (_flatItem$parentProdu8 = flatItem.parentProduct) !== null && _flatItem$parentProdu8 !== void 0 && (_flatItem$parentProdu8 = _flatItem$parentProdu8.discount_list) !== null && _flatItem$parentProdu8 !== void 0 && _flatItem$parentProdu8.some(function (item) {
|
|
1198
|
-
var _options$
|
|
1199
|
-
return options === null || options === void 0 || (_options$
|
|
1206
|
+
var _options$selectedList4;
|
|
1207
|
+
return options === null || options === void 0 || (_options$selectedList4 = options.selectedList) === null || _options$selectedList4 === void 0 ? void 0 : _options$selectedList4.some(function (n) {
|
|
1200
1208
|
var _item$discount6;
|
|
1201
1209
|
return n.discountId === ((_item$discount6 = item.discount) === null || _item$discount6 === void 0 ? void 0 : _item$discount6.resource_id);
|
|
1202
1210
|
});
|
|
@@ -1871,7 +1879,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1871
1879
|
} else {
|
|
1872
1880
|
// 🔥 没有子商品被拆分,使用原有逻辑
|
|
1873
1881
|
mainProductArr.forEach(function (mainProduct) {
|
|
1874
|
-
var
|
|
1882
|
+
var _ref15, _mainProductData$main, _mainProductData$disc, _mainProductData$disc2, _mainProductData$disc3;
|
|
1875
1883
|
var mainProductData = _this3.hooks.getProduct(mainProduct);
|
|
1876
1884
|
|
|
1877
1885
|
// 重组bundle
|
|
@@ -1886,6 +1894,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1886
1894
|
} else {
|
|
1887
1895
|
// 🔥 关键:拆分后的bundle item
|
|
1888
1896
|
processedBundleItems.forEach(function (item) {
|
|
1897
|
+
var _item$price, _ref14, _item$bundle_selling_;
|
|
1898
|
+
var nextBundlePrice = (_item$price = item.price) !== null && _item$price !== void 0 ? _item$price : bundleItem.price;
|
|
1899
|
+
var nextBundleSellingPrice = (_ref14 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref14 !== void 0 ? _ref14 : bundleItem.bundle_selling_price;
|
|
1889
1900
|
// 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
|
|
1890
1901
|
var updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1891
1902
|
var _discount$metadata10;
|
|
@@ -1900,10 +1911,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1900
1911
|
newBundle.push(_objectSpread(_objectSpread({}, bundleItem), {}, {
|
|
1901
1912
|
_id: item._id,
|
|
1902
1913
|
product_id: bundleItem.product_id,
|
|
1903
|
-
price:
|
|
1914
|
+
price: nextBundlePrice,
|
|
1904
1915
|
num: item.num,
|
|
1905
1916
|
discount_list: updatedDiscountList,
|
|
1906
|
-
bundle_selling_price: bundleItem.bundle_selling_price !== undefined ?
|
|
1917
|
+
bundle_selling_price: bundleItem.bundle_selling_price !== undefined ? nextBundleSellingPrice : undefined
|
|
1907
1918
|
}));
|
|
1908
1919
|
});
|
|
1909
1920
|
}
|
|
@@ -1912,7 +1923,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1912
1923
|
|
|
1913
1924
|
// 主商品已经在前面的 setProduct 中应用过折扣;这里只替换 bundle,
|
|
1914
1925
|
// 避免把主商品 discount_list 再扣一次。
|
|
1915
|
-
var mainSellingPrice = (
|
|
1926
|
+
var mainSellingPrice = (_ref15 = (_mainProductData$main = mainProductData.main_product_selling_price) !== null && _mainProductData$main !== void 0 ? _mainProductData$main : mainProductData.price) !== null && _ref15 !== void 0 ? _ref15 : 0;
|
|
1916
1927
|
var newTotal = Number(mainSellingPrice || 0);
|
|
1917
1928
|
var newOriginTotal = Number(mainProductData.original_price || mainProductData.price || 0);
|
|
1918
1929
|
|
|
@@ -1930,8 +1941,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1930
1941
|
// 累加 bundle 的折后价格(只累加一次)
|
|
1931
1942
|
if (newBundle.length > 0) {
|
|
1932
1943
|
newBundle.forEach(function (item) {
|
|
1933
|
-
var _item$
|
|
1934
|
-
var bundleSellingPrice = (_item$
|
|
1944
|
+
var _item$bundle_selling_2;
|
|
1945
|
+
var bundleSellingPrice = (_item$bundle_selling_2 = item.bundle_selling_price) !== null && _item$bundle_selling_2 !== void 0 ? _item$bundle_selling_2 : item.price;
|
|
1935
1946
|
newTotal += Number(bundleSellingPrice) * Number(item.num);
|
|
1936
1947
|
});
|
|
1937
1948
|
|
|
@@ -2060,14 +2071,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2060
2071
|
var ruleType = usageRules.type;
|
|
2061
2072
|
// 套餐适用范围配置
|
|
2062
2073
|
var packageScope = usageRules === null || usageRules === void 0 ? void 0 : usageRules.package_scope;
|
|
2063
|
-
var
|
|
2064
|
-
scopeType =
|
|
2065
|
-
|
|
2066
|
-
exclude_bundle_product_ids =
|
|
2067
|
-
|
|
2068
|
-
include_bundle_product_ids =
|
|
2069
|
-
|
|
2070
|
-
filter =
|
|
2074
|
+
var _ref16 = packageScope || {},
|
|
2075
|
+
scopeType = _ref16.type,
|
|
2076
|
+
_ref16$exclude_bundle = _ref16.exclude_bundle_product_ids,
|
|
2077
|
+
exclude_bundle_product_ids = _ref16$exclude_bundle === void 0 ? [] : _ref16$exclude_bundle,
|
|
2078
|
+
_ref16$include_bundle = _ref16.include_bundle_product_ids,
|
|
2079
|
+
include_bundle_product_ids = _ref16$include_bundle === void 0 ? [] : _ref16$include_bundle,
|
|
2080
|
+
_ref16$filter = _ref16.filter,
|
|
2081
|
+
filter = _ref16$filter === void 0 ? 0 : _ref16$filter;
|
|
2071
2082
|
var isMainProduct = flatItem.type === 'main'; // 单独购买
|
|
2072
2083
|
var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
|
|
2073
2084
|
|
|
@@ -230,7 +230,7 @@ export function mergeIdenticalPromotionCartLines(products) {
|
|
|
230
230
|
_step;
|
|
231
231
|
try {
|
|
232
232
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
233
|
-
var _line$metadata, _ref2, _line$metadata$source, _line$metadata2, _ref3, _promotion$finalPrice, _line$metadata3, _line$booking_uid, _line$metadata4, _line$product_variant;
|
|
233
|
+
var _line$metadata, _ref2, _line$metadata$source, _line$metadata2, _ref3, _promotion$finalPrice, _line$metadata3, _line$booking_uid, _line$metadata4, _line$order_detail_id, _line$product_variant;
|
|
234
234
|
var line = _step.value;
|
|
235
235
|
if (getGiftInfo(line)) {
|
|
236
236
|
merged.push(line);
|
|
@@ -245,7 +245,8 @@ export function mergeIdenticalPromotionCartLines(products) {
|
|
|
245
245
|
var unitPrice = String((_ref2 = (_line$metadata$source = (_line$metadata2 = line.metadata) === null || _line$metadata2 === void 0 ? void 0 : _line$metadata2.source_product_price) !== null && _line$metadata$source !== void 0 ? _line$metadata$source : line.selling_price) !== null && _ref2 !== void 0 ? _ref2 : '');
|
|
246
246
|
var promoUnitPrice = String((_ref3 = (_promotion$finalPrice = promotion.finalPrice) !== null && _promotion$finalPrice !== void 0 ? _promotion$finalPrice : (_line$metadata3 = line.metadata) === null || _line$metadata3 === void 0 ? void 0 : _line$metadata3.main_product_selling_price) !== null && _ref3 !== void 0 ? _ref3 : '');
|
|
247
247
|
var bookingUid = (_line$booking_uid = line === null || line === void 0 ? void 0 : line.booking_uid) !== null && _line$booking_uid !== void 0 ? _line$booking_uid : line === null || line === void 0 || (_line$metadata4 = line.metadata) === null || _line$metadata4 === void 0 ? void 0 : _line$metadata4.booking_uid;
|
|
248
|
-
var
|
|
248
|
+
var orderDetailId = (_line$order_detail_id = line === null || line === void 0 ? void 0 : line.order_detail_id) !== null && _line$order_detail_id !== void 0 ? _line$order_detail_id : line === null || line === void 0 ? void 0 : line.orderDetailId;
|
|
249
|
+
var mergeKey = [line.product_id, (_line$product_variant = line.product_variant_id) !== null && _line$product_variant !== void 0 ? _line$product_variant : 0, fingerprint, bookingUid ? String(bookingUid) : '', orderDetailId !== undefined && orderDetailId !== null && orderDetailId !== '' ? String(orderDetailId) : '', promotion.strategyId, unitPrice, promoUnitPrice].join('#');
|
|
249
250
|
var hitIndex = indexByKey.get(mergeKey);
|
|
250
251
|
if (hitIndex === undefined) {
|
|
251
252
|
indexByKey.set(mergeKey, merged.length);
|
|
@@ -413,6 +414,15 @@ function getGiftInfo(product) {
|
|
|
413
414
|
var _product$metadata2;
|
|
414
415
|
return (product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2._giftInfo) || (product === null || product === void 0 ? void 0 : product._giftInfo) || null;
|
|
415
416
|
}
|
|
417
|
+
function isPersistedGeneratedVoucher(product) {
|
|
418
|
+
var _product$order_detail;
|
|
419
|
+
var orderDetailId = (_product$order_detail = product === null || product === void 0 ? void 0 : product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : product === null || product === void 0 ? void 0 : product.orderDetailId;
|
|
420
|
+
if (orderDetailId === undefined || orderDetailId === null || orderDetailId === '') {
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
424
|
+
return (product === null || product === void 0 ? void 0 : product.extension_type) === 'product_voucher' || metadata.parent_order_detail_id !== undefined || metadata.gift_card_type !== undefined;
|
|
425
|
+
}
|
|
416
426
|
function getProductBundleForEvaluator(product) {
|
|
417
427
|
var bundles = Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle) ? product.product_bundle : [];
|
|
418
428
|
return bundles.map(function (b) {
|
|
@@ -441,14 +451,19 @@ function getProductBundleForEvaluator(product) {
|
|
|
441
451
|
* // => 单行 num=4,清除 _promotion 后重新评估
|
|
442
452
|
*/
|
|
443
453
|
export function buildConsolidateKeyForPromotion(item) {
|
|
444
|
-
var _item$booking_uid, _item$metadata, _item$
|
|
454
|
+
var _item$booking_uid, _item$metadata, _item$order_detail_id, _item$product_variant3;
|
|
445
455
|
var fingerprint = buildProductLineFingerprint(item.product_option_item, item.product_bundle);
|
|
446
456
|
var bookingUid = (_item$booking_uid = item === null || item === void 0 ? void 0 : item.booking_uid) !== null && _item$booking_uid !== void 0 ? _item$booking_uid : item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.booking_uid;
|
|
447
|
-
|
|
457
|
+
var orderDetailId = (_item$order_detail_id = item === null || item === void 0 ? void 0 : item.order_detail_id) !== null && _item$order_detail_id !== void 0 ? _item$order_detail_id : item === null || item === void 0 ? void 0 : item.orderDetailId;
|
|
458
|
+
if (orderDetailId !== undefined && orderDetailId !== null && orderDetailId !== '') {
|
|
448
459
|
var _item$product_variant;
|
|
449
|
-
return [item.product_id, (_item$product_variant = item.product_variant_id) !== null && _item$product_variant !== void 0 ? _item$product_variant : 0, fingerprint, String(
|
|
460
|
+
return [item.product_id, (_item$product_variant = item.product_variant_id) !== null && _item$product_variant !== void 0 ? _item$product_variant : 0, fingerprint, String(orderDetailId)].join('#');
|
|
461
|
+
}
|
|
462
|
+
if (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '') {
|
|
463
|
+
var _item$product_variant2;
|
|
464
|
+
return [item.product_id, (_item$product_variant2 = item.product_variant_id) !== null && _item$product_variant2 !== void 0 ? _item$product_variant2 : 0, fingerprint, String(bookingUid)].join('#');
|
|
450
465
|
}
|
|
451
|
-
return [item.product_id, (_item$
|
|
466
|
+
return [item.product_id, (_item$product_variant3 = item.product_variant_id) !== null && _item$product_variant3 !== void 0 ? _item$product_variant3 : 0, fingerprint].join('#');
|
|
452
467
|
}
|
|
453
468
|
function consolidateMainProductsForPromotion(entries) {
|
|
454
469
|
if (!Array.isArray(entries) || entries.length <= 1) {
|
|
@@ -882,11 +897,11 @@ export function appendPromotionTags(products, evaluator) {
|
|
|
882
897
|
|
|
883
898
|
// 评估器期望的 product shape,最少字段集
|
|
884
899
|
var evaluatorInput = products.map(function (item, index) {
|
|
885
|
-
var _ref14, _item$id, _item$
|
|
900
|
+
var _ref14, _item$id, _item$product_variant4, _item$price, _item$quantity;
|
|
886
901
|
return {
|
|
887
902
|
id: index,
|
|
888
903
|
product_id: Number((_ref14 = (_item$id = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id !== void 0 ? _item$id : item === null || item === void 0 ? void 0 : item.product_id) !== null && _ref14 !== void 0 ? _ref14 : 0) || 0,
|
|
889
|
-
product_variant_id: Number((_item$
|
|
904
|
+
product_variant_id: Number((_item$product_variant4 = item === null || item === void 0 ? void 0 : item.product_variant_id) !== null && _item$product_variant4 !== void 0 ? _item$product_variant4 : 0) || 0,
|
|
890
905
|
name: (item === null || item === void 0 ? void 0 : item.title) || (item === null || item === void 0 ? void 0 : item.name) || '',
|
|
891
906
|
price: Number((_item$price = item === null || item === void 0 ? void 0 : item.price) !== null && _item$price !== void 0 ? _item$price : 0) || 0,
|
|
892
907
|
quantity: Number((_item$quantity = item === null || item === void 0 ? void 0 : item.quantity) !== null && _item$quantity !== void 0 ? _item$quantity : 1) || 1,
|
|
@@ -975,7 +990,12 @@ export function processCartPromotion(list, evaluator, options) {
|
|
|
975
990
|
for (var i = 0; i < list.length; i++) {
|
|
976
991
|
var item = list[i];
|
|
977
992
|
var giftInfo = getGiftInfo(item);
|
|
978
|
-
if (
|
|
993
|
+
if (isPersistedGeneratedVoucher(item)) {
|
|
994
|
+
editProductsWithIndex.push({
|
|
995
|
+
item: item,
|
|
996
|
+
originalListIndex: i
|
|
997
|
+
});
|
|
998
|
+
} else if (giftInfo) {
|
|
979
999
|
existingGiftsWithIndex.push({
|
|
980
1000
|
item: item,
|
|
981
1001
|
originalListIndex: i
|
|
@@ -1039,12 +1059,12 @@ export function processCartPromotion(list, evaluator, options) {
|
|
|
1039
1059
|
var promotionProducts = [];
|
|
1040
1060
|
var originalItemMap = new Map();
|
|
1041
1061
|
var productsForStrategies = consolidatedMainProductsWithIndex.map(function (_ref16, i) {
|
|
1042
|
-
var _item$product_id, _item$
|
|
1062
|
+
var _item$product_id, _item$product_variant5, _item$metadata2, _item$num;
|
|
1043
1063
|
var item = _ref16.item;
|
|
1044
1064
|
return {
|
|
1045
1065
|
id: i,
|
|
1046
1066
|
product_id: Number((_item$product_id = item === null || item === void 0 ? void 0 : item.product_id) !== null && _item$product_id !== void 0 ? _item$product_id : 0) || 0,
|
|
1047
|
-
product_variant_id: Number((_item$
|
|
1067
|
+
product_variant_id: Number((_item$product_variant5 = item === null || item === void 0 ? void 0 : item.product_variant_id) !== null && _item$product_variant5 !== void 0 ? _item$product_variant5 : 0) || 0,
|
|
1048
1068
|
name: (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.product_name) || (item === null || item === void 0 ? void 0 : item.title) || '',
|
|
1049
1069
|
price: getOrderProductBasePrice(item),
|
|
1050
1070
|
quantity: Number((_item$num = item === null || item === void 0 ? void 0 : item.num) !== null && _item$num !== void 0 ? _item$num : 1) || 1,
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 | 1 | 2 | 6 | 3 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 6 | 3 | 5 | 4;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -7,6 +7,7 @@ import { BaseSalesImpl } from '../BaseSales';
|
|
|
7
7
|
import type { BaseSalesScanCodeResult } from '../BaseSales/types';
|
|
8
8
|
import type { ISalesDetail } from '../BaseSales/utils/parseSalesResponse';
|
|
9
9
|
import type { LoadSalesDetailParams } from '../../modules/Order/types';
|
|
10
|
+
import type { GlobalScanHandleResult, GlobalScanHostBridge } from './types';
|
|
10
11
|
import { AddProductDecideContext, AddProductRequiresDetailPayload } from './utils/addProductDecision';
|
|
11
12
|
import { type BuildCacheItemFromOrderLineInput } from '../../modules/BookingContext/utils/buildCacheItemFromOrderLine';
|
|
12
13
|
import { type BuildNormalProductCacheItemFromOrderLineInput } from '../../modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine';
|
|
@@ -441,6 +442,20 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
441
442
|
buildNormalProductCacheItemFromOrderLine(input: BuildNormalProductCacheItemFromOrderLineInput): Record<string, any>;
|
|
442
443
|
/** 文档别名:与 OrderModule.updateOrderProduct 一致。 */
|
|
443
444
|
updateProductInOrder(params: UpdateOrderProductParams): Promise<OrderProduct[]>;
|
|
445
|
+
/**
|
|
446
|
+
* 全局扫码 pubsub 入口:解析码值 → 搜索 → 业务分发(客户 / 加车 / 开单)。
|
|
447
|
+
* UI 层在 pubsub 订阅回调里注入 `bridge`(uiHosts / action / cart.confirm*)。
|
|
448
|
+
*
|
|
449
|
+
* @example
|
|
450
|
+
* ```ts
|
|
451
|
+
* await bookingTicket.handleGlobalScanCode(payload.data, {
|
|
452
|
+
* openProductDetail: uiHosts.openProductDetail,
|
|
453
|
+
* confirmDetail: cart.confirmDetail,
|
|
454
|
+
* openOrder: ({ order_id }) => action({ type: 'pisell1.handleOpenCachedBigSale', data: { order_id } }),
|
|
455
|
+
* });
|
|
456
|
+
* ```
|
|
457
|
+
*/
|
|
458
|
+
handleGlobalScanCode(code: string, bridge?: GlobalScanHostBridge): Promise<GlobalScanHandleResult>;
|
|
444
459
|
/**
|
|
445
460
|
* 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
|
|
446
461
|
* 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
|
|
@@ -2,8 +2,6 @@ var _excluded = ["id"],
|
|
|
2
2
|
_excluded2 = ["product_id"],
|
|
3
3
|
_excluded3 = ["product_id"];
|
|
4
4
|
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); }
|
|
5
|
-
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; }
|
|
6
|
-
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; }
|
|
7
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; }
|
|
8
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; }
|
|
9
7
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
@@ -27,6 +25,8 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
27
25
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
28
26
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
29
27
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
28
|
+
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; }
|
|
29
|
+
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; }
|
|
30
30
|
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; }
|
|
31
31
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
32
32
|
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); }
|
|
@@ -37,11 +37,25 @@ import Scan from "./utils/scan";
|
|
|
37
37
|
import { formatOrderCustomerPatch } from "./utils/orderCustomer";
|
|
38
38
|
import { handleGlobalScan, handleCustomerScan, handleUniversalScan } from "./utils/scan/handleScan";
|
|
39
39
|
import scanCache from "./utils/scan/scanCache";
|
|
40
|
+
import { formatGlobalScanResult } from "./utils/scan/formatGlobalScan";
|
|
41
|
+
import { applyGlobalScan } from "./utils/scan/applyGlobalScan";
|
|
40
42
|
import { buildCartView } from "./utils/cartView";
|
|
41
43
|
import { buildCacheItemFromCartDetail, buildCacheItemFromDetail, buildRequiresDetailPayload as _buildRequiresDetailPayload, decideAddProduct as decideAddProductUtil, decideAfterDetail as decideAfterDetailUtil, decideAutoClose as decideAutoCloseUtil, getIsEject as getIsEjectUtil, getIsOnlySession as getIsOnlySessionUtil, transformDetailToProductAndBooking as transformDetailToProductAndBookingUtil } from "./utils/addProductDecision";
|
|
42
44
|
import { buildCacheItemFromOrderLine as buildCacheItemFromOrderLineUtil } from "../../modules/BookingContext/utils/buildCacheItemFromOrderLine";
|
|
43
45
|
import { buildNormalProductCacheItemFromOrderLine as buildNormalProductCacheItemFromOrderLineUtil } from "../../modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine";
|
|
46
|
+
import { buildProductOptionStringFromOrderLine } from "../../modules/BookingContext/utils/orderLineDisplay";
|
|
44
47
|
import { applyBookingsStatus, resolveScheduleId, restoreBookingsStatus } from "./utils/bookingStatus";
|
|
48
|
+
function withProductOptionString(cacheItem) {
|
|
49
|
+
var _cacheItem$_extend;
|
|
50
|
+
var productOptionString = buildProductOptionStringFromOrderLine(cacheItem);
|
|
51
|
+
if (!productOptionString) return cacheItem;
|
|
52
|
+
return _objectSpread(_objectSpread({}, cacheItem), {}, {
|
|
53
|
+
product_option_string: (cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.product_option_string) || productOptionString,
|
|
54
|
+
_extend: _objectSpread(_objectSpread({}, (cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem._extend) || {}), {}, {
|
|
55
|
+
product_option_string: (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.product_option_string) || productOptionString
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
}
|
|
45
59
|
export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
46
60
|
_inherits(BookingTicketImpl, _BaseSalesImpl);
|
|
47
61
|
var _super = _createSuper(BookingTicketImpl);
|
|
@@ -1579,10 +1593,12 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1579
1593
|
}, {
|
|
1580
1594
|
key: "getProductExtend",
|
|
1581
1595
|
value: function getProductExtend(cacheItem, extra) {
|
|
1582
|
-
|
|
1583
|
-
|
|
1596
|
+
var preparedCacheItem = withProductOptionString(cacheItem);
|
|
1597
|
+
var result = getProductExtendUtil({
|
|
1598
|
+
cacheItem: preparedCacheItem,
|
|
1584
1599
|
ctx: this.buildBookingCalcContext(extra)
|
|
1585
1600
|
});
|
|
1601
|
+
return result;
|
|
1586
1602
|
}
|
|
1587
1603
|
|
|
1588
1604
|
/**
|
|
@@ -1724,6 +1740,115 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1724
1740
|
}
|
|
1725
1741
|
return updateProductInOrder;
|
|
1726
1742
|
}()
|
|
1743
|
+
/**
|
|
1744
|
+
* 全局扫码 pubsub 入口:解析码值 → 搜索 → 业务分发(客户 / 加车 / 开单)。
|
|
1745
|
+
* UI 层在 pubsub 订阅回调里注入 `bridge`(uiHosts / action / cart.confirm*)。
|
|
1746
|
+
*
|
|
1747
|
+
* @example
|
|
1748
|
+
* ```ts
|
|
1749
|
+
* await bookingTicket.handleGlobalScanCode(payload.data, {
|
|
1750
|
+
* openProductDetail: uiHosts.openProductDetail,
|
|
1751
|
+
* confirmDetail: cart.confirmDetail,
|
|
1752
|
+
* openOrder: ({ order_id }) => action({ type: 'pisell1.handleOpenCachedBigSale', data: { order_id } }),
|
|
1753
|
+
* });
|
|
1754
|
+
* ```
|
|
1755
|
+
*/
|
|
1756
|
+
)
|
|
1757
|
+
}, {
|
|
1758
|
+
key: "handleGlobalScanCode",
|
|
1759
|
+
value: (function () {
|
|
1760
|
+
var _handleGlobalScanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(code, bridge) {
|
|
1761
|
+
var _this6 = this;
|
|
1762
|
+
var trimmed, _bridge$onNotify, _bridge$refresh, localSearch, scanCallback, raw, formatted, _bridge$onNotify2, _result7, _bridge$onNotify3;
|
|
1763
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1764
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1765
|
+
case 0:
|
|
1766
|
+
trimmed = typeof code === 'string' ? code.trim() : '';
|
|
1767
|
+
if (trimmed) {
|
|
1768
|
+
_context23.next = 4;
|
|
1769
|
+
break;
|
|
1770
|
+
}
|
|
1771
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify = bridge.onNotify) === null || _bridge$onNotify === void 0 || _bridge$onNotify.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
1772
|
+
return _context23.abrupt("return", {
|
|
1773
|
+
status: 'failed',
|
|
1774
|
+
reason: 'empty_code'
|
|
1775
|
+
});
|
|
1776
|
+
case 4:
|
|
1777
|
+
_context23.prev = 4;
|
|
1778
|
+
localSearch = function localSearch(v) {
|
|
1779
|
+
return _this6.store.products.findProductsByCodeOrBarcode(v);
|
|
1780
|
+
};
|
|
1781
|
+
scanCallback = handleGlobalScan(this.request, localSearch);
|
|
1782
|
+
_context23.next = 9;
|
|
1783
|
+
return scanCallback({
|
|
1784
|
+
type: 'nativeScanner',
|
|
1785
|
+
value: trimmed
|
|
1786
|
+
});
|
|
1787
|
+
case 9:
|
|
1788
|
+
raw = _context23.sent;
|
|
1789
|
+
formatted = formatGlobalScanResult(raw, trimmed);
|
|
1790
|
+
if (formatted) {
|
|
1791
|
+
_context23.next = 14;
|
|
1792
|
+
break;
|
|
1793
|
+
}
|
|
1794
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify2 = bridge.onNotify) === null || _bridge$onNotify2 === void 0 || _bridge$onNotify2.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
1795
|
+
return _context23.abrupt("return", {
|
|
1796
|
+
status: 'failed',
|
|
1797
|
+
reason: 'not_found'
|
|
1798
|
+
});
|
|
1799
|
+
case 14:
|
|
1800
|
+
_context23.next = 16;
|
|
1801
|
+
return applyGlobalScan({
|
|
1802
|
+
setOrderCustomer: function setOrderCustomer(customer) {
|
|
1803
|
+
return _this6.setOrderCustomer(customer);
|
|
1804
|
+
},
|
|
1805
|
+
getOrderCustomerSnapshot: function getOrderCustomerSnapshot() {
|
|
1806
|
+
return _this6.getOrderCustomerSnapshot();
|
|
1807
|
+
},
|
|
1808
|
+
getBusinessCode: function getBusinessCode() {
|
|
1809
|
+
var _this6$otherParams;
|
|
1810
|
+
return (_this6$otherParams = _this6.otherParams) === null || _this6$otherParams === void 0 ? void 0 : _this6$otherParams.businessCode;
|
|
1811
|
+
},
|
|
1812
|
+
buildAddProductCtx: function buildAddProductCtx(extra) {
|
|
1813
|
+
return _this6.buildAddProductCtx(extra);
|
|
1814
|
+
},
|
|
1815
|
+
decideAddProduct: function decideAddProduct(item, options) {
|
|
1816
|
+
return _this6.decideAddProduct(item, options);
|
|
1817
|
+
},
|
|
1818
|
+
decideAfterDetail: function decideAfterDetail(cacheItem, options) {
|
|
1819
|
+
return _this6.decideAfterDetail(cacheItem, options);
|
|
1820
|
+
},
|
|
1821
|
+
transformDetailToProductAndBooking: function transformDetailToProductAndBooking(input) {
|
|
1822
|
+
return _this6.transformDetailToProductAndBooking(input);
|
|
1823
|
+
},
|
|
1824
|
+
addProductToOrder: function addProductToOrder(product, booking) {
|
|
1825
|
+
return _this6.addProductToOrder(product, booking);
|
|
1826
|
+
}
|
|
1827
|
+
}, formatted, bridge);
|
|
1828
|
+
case 16:
|
|
1829
|
+
_result7 = _context23.sent;
|
|
1830
|
+
bridge === null || bridge === void 0 || (_bridge$refresh = bridge.refresh) === null || _bridge$refresh === void 0 || _bridge$refresh.call(bridge);
|
|
1831
|
+
return _context23.abrupt("return", _result7);
|
|
1832
|
+
case 21:
|
|
1833
|
+
_context23.prev = 21;
|
|
1834
|
+
_context23.t0 = _context23["catch"](4);
|
|
1835
|
+
console.error('[BookingTicket] handleGlobalScanCode failed', _context23.t0);
|
|
1836
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify3 = bridge.onNotify) === null || _bridge$onNotify3 === void 0 || _bridge$onNotify3.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
1837
|
+
return _context23.abrupt("return", {
|
|
1838
|
+
status: 'failed',
|
|
1839
|
+
reason: 'not_found'
|
|
1840
|
+
});
|
|
1841
|
+
case 26:
|
|
1842
|
+
case "end":
|
|
1843
|
+
return _context23.stop();
|
|
1844
|
+
}
|
|
1845
|
+
}, _callee23, this, [[4, 21]]);
|
|
1846
|
+
}));
|
|
1847
|
+
function handleGlobalScanCode(_x18, _x19) {
|
|
1848
|
+
return _handleGlobalScanCode.apply(this, arguments);
|
|
1849
|
+
}
|
|
1850
|
+
return handleGlobalScanCode;
|
|
1851
|
+
}()
|
|
1727
1852
|
/**
|
|
1728
1853
|
* 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
|
|
1729
1854
|
* 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
|
|
@@ -1732,12 +1857,12 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1732
1857
|
}, {
|
|
1733
1858
|
key: "destroy",
|
|
1734
1859
|
value: (function () {
|
|
1735
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1860
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
1736
1861
|
var _this$scan;
|
|
1737
|
-
return _regeneratorRuntime().wrap(function
|
|
1738
|
-
while (1) switch (
|
|
1862
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1863
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1739
1864
|
case 0:
|
|
1740
|
-
|
|
1865
|
+
_context24.next = 2;
|
|
1741
1866
|
return _get(_getPrototypeOf(BookingTicketImpl.prototype), "destroy", this).call(this);
|
|
1742
1867
|
case 2:
|
|
1743
1868
|
try {
|
|
@@ -1748,9 +1873,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1748
1873
|
scanCache.clear();
|
|
1749
1874
|
case 4:
|
|
1750
1875
|
case "end":
|
|
1751
|
-
return
|
|
1876
|
+
return _context24.stop();
|
|
1752
1877
|
}
|
|
1753
|
-
},
|
|
1878
|
+
}, _callee24, this);
|
|
1754
1879
|
}));
|
|
1755
1880
|
function destroy() {
|
|
1756
1881
|
return _destroy.apply(this, arguments);
|
|
@@ -134,3 +134,51 @@ export interface BookingTicketCustomerView {
|
|
|
134
134
|
export interface BookingTicketProductCatalogView {
|
|
135
135
|
products: ProductData[];
|
|
136
136
|
}
|
|
137
|
+
/** 扫码宿主桥接:SalesSdk 在 pubsub 订阅回调里注入,OS 需要 UI 时直接调用 */
|
|
138
|
+
export interface GlobalScanHostBridge {
|
|
139
|
+
openProductDetail?: (payload: Record<string, any>) => Promise<any | null>;
|
|
140
|
+
openBookingEdit?: (payload: Record<string, any>) => Promise<any | null>;
|
|
141
|
+
confirmDetail?: (input: {
|
|
142
|
+
item: any;
|
|
143
|
+
detailResult: {
|
|
144
|
+
e: any;
|
|
145
|
+
extension_type?: any;
|
|
146
|
+
detail?: any;
|
|
147
|
+
};
|
|
148
|
+
options?: Record<string, any>;
|
|
149
|
+
}) => Promise<any>;
|
|
150
|
+
confirmBookingEdit?: (input: {
|
|
151
|
+
cacheItem: any;
|
|
152
|
+
options?: Record<string, any>;
|
|
153
|
+
}) => Promise<any>;
|
|
154
|
+
openOrder?: (data: {
|
|
155
|
+
order_id: number;
|
|
156
|
+
business_code?: string;
|
|
157
|
+
}) => void;
|
|
158
|
+
/**
|
|
159
|
+
* walk-in 扫 walletPass:直接核销优惠码(对齐 SaleDetail Voucher.handleApplyCode / cart.scanCode)。
|
|
160
|
+
*/
|
|
161
|
+
applyPromotionCode?: (code: string, customerId?: number) => Promise<{
|
|
162
|
+
isAvailable?: boolean;
|
|
163
|
+
type?: string;
|
|
164
|
+
unavailableReason?: string;
|
|
165
|
+
}>;
|
|
166
|
+
onNotify?: (type: 'success' | 'fail' | 'info', messageKey?: string) => void;
|
|
167
|
+
refresh?: () => void;
|
|
168
|
+
}
|
|
169
|
+
/** handleGlobalScanCode 结构化返回 */
|
|
170
|
+
export type GlobalScanHandleResult = {
|
|
171
|
+
status: 'success';
|
|
172
|
+
kind: 'customer' | 'products' | 'promotion';
|
|
173
|
+
meta?: {
|
|
174
|
+
count?: number;
|
|
175
|
+
};
|
|
176
|
+
} | {
|
|
177
|
+
status: 'pending';
|
|
178
|
+
kind: 'openOrder' | 'requiresDetail' | 'requiresBookingEdit';
|
|
179
|
+
} | {
|
|
180
|
+
status: 'cancelled';
|
|
181
|
+
} | {
|
|
182
|
+
status: 'failed';
|
|
183
|
+
reason: 'empty_code' | 'not_found' | 'invalid_data' | 'no_bridge';
|
|
184
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { GlobalScanHandleResult, GlobalScanHostBridge, ICustomer } from '../../types';
|
|
2
|
+
import type { AddProductDecision } from '../addProductDecision';
|
|
3
|
+
import { GlobalScanFormattedResult } from './formatGlobalScan';
|
|
4
|
+
/** applyGlobalScan 所需的 BookingTicket 运行时能力 */
|
|
5
|
+
export interface GlobalScanApplyHost {
|
|
6
|
+
setOrderCustomer(customer: ICustomer | null): void;
|
|
7
|
+
getOrderCustomerSnapshot(): ICustomer | null;
|
|
8
|
+
getBusinessCode(): string | undefined;
|
|
9
|
+
buildAddProductCtx(extra?: Record<string, any>): Record<string, any>;
|
|
10
|
+
decideAddProduct(item: any, options?: Record<string, any>): AddProductDecision;
|
|
11
|
+
decideAfterDetail(cacheItem: any, options?: Record<string, any>): AddProductDecision;
|
|
12
|
+
transformDetailToProductAndBooking(input: {
|
|
13
|
+
item: any;
|
|
14
|
+
cacheItem?: any;
|
|
15
|
+
detailResult?: {
|
|
16
|
+
e: any;
|
|
17
|
+
extension_type?: any;
|
|
18
|
+
detail?: any;
|
|
19
|
+
};
|
|
20
|
+
options?: Record<string, any>;
|
|
21
|
+
}): {
|
|
22
|
+
product: any;
|
|
23
|
+
booking?: any;
|
|
24
|
+
cacheItem: any;
|
|
25
|
+
};
|
|
26
|
+
addProductToOrder(product: any, booking?: any): Promise<any>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 应用全局扫码格式化结果:设客户 / 加车 / 开单 / 弹窗链。
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* const result = await applyGlobalScan(bookingTicket, formatted, bridge);
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function applyGlobalScan(host: GlobalScanApplyHost, formatted: GlobalScanFormattedResult, bridge?: GlobalScanHostBridge): Promise<GlobalScanHandleResult>;
|